:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-soft: #eef4f3;
  --line: #d9e2e1;
  --text: #1e2b2b;
  --muted: #687979;
  --accent: #1f7a6d;
  --accent-dark: #155b51;
  --accent-soft: #dcefeb;
  --blue: #2f6fba;
  --blue-soft: #e7f0fb;
  --amber: #a86c14;
  --amber-soft: #fff1d9;
  --red: #b64b4b;
  --red-soft: #fde8e8;
  --shadow: 0 18px 50px rgba(37, 56, 54, 0.1);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", Arial,
    sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 auto 14px;
  max-width: 1680px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(320px, 0.82fr);
  gap: 14px;
  max-width: 1680px;
  margin: 0 auto;
}

.replies-panel {
  grid-column: 1 / -1;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
}

.panel-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.user-switcher {
  display: grid;
  grid-template-columns: auto minmax(130px, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  min-width: 330px;
}

.user-switcher select {
  min-height: 32px;
}

.status-pill,
.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  white-space: nowrap;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--surface-soft);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}

.score-badge.high {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.score-badge.low {
  background: var(--amber-soft);
  color: var(--amber);
}

textarea {
  display: block;
  width: calc(100% - 36px);
  min-height: 150px;
  resize: vertical;
  margin: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: #fbfdfd;
  line-height: 1.7;
  outline: none;
}

.message-input {
  min-height: 177px;
  margin-top: 12px;
}

.input-label-row {
  display: flex;
  align-items: center;
  padding: 14px 18px 0;
}

.input-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.input-label-row + textarea.message-input {
  margin-top: 6px;
}

.history-block {
  padding: 18px 18px 0;
}

.conversation-history {
  display: grid;
  gap: 10px;
  min-height: 220px;
  max-height: 300px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdfd;
  padding: 12px;
}

.history-empty {
  display: grid;
  min-height: 190px;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.history-message {
  display: grid;
  gap: 5px;
  max-width: 88%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.history-message.sales {
  justify-self: end;
  background: var(--accent-soft);
  border-color: #bcded8;
}

.history-role {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.history-text {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.6;
}

.input-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 18px 16px;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 109, 0.14);
}

.sample-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 0 18px 16px;
}

.sample-button,
.ghost-button,
.primary-button,
.reply-action {
  min-height: 36px;
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    background 0.16s ease,
    color 0.16s ease,
    transform 0.16s ease;
}

.sample-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.sample-button.active,
.sample-button:hover {
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-color: transparent;
}

.field-grid,
.price-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0 18px 18px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdfd;
  color: var(--text);
  padding: 0 10px;
  outline: none;
}

.config-block {
  margin: 0 18px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdfd;
}

.profile-dialog {
  width: min(720px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.profile-dialog::backdrop {
  background: rgba(15, 28, 28, 0.38);
}

.profile-dialog form {
  margin: 0;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.dialog-head h2 {
  margin: 0;
  font-size: 17px;
}

.dialog-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.dialog-grid {
  padding: 18px;
}

.dialog-config {
  margin: 0 18px 18px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  padding: 0 18px 18px;
}

.config-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.config-title h3,
.section-block h3 {
  margin: 0;
  font-size: 14px;
}

.config-title span {
  color: var(--muted);
  font-size: 12px;
}

.price-grid {
  padding: 12px;
}

.wide-field {
  grid-column: 1 / -1;
}

.primary-button {
  background: var(--accent);
  color: #fff;
  padding: 0 16px;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.ghost-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 0 14px;
}

.ghost-button:hover {
  background: var(--surface-soft);
}

.full-width {
  width: calc(100% - 36px);
  margin: 0 18px 18px;
}

.diagnosis-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 18px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdfd;
  padding: 12px;
  min-height: 76px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 17px;
  line-height: 1.25;
}

.section-block {
  margin: 0 18px 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdfd;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.compact {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--blue-soft);
  color: #255a96;
  font-size: 12px;
  font-weight: 700;
}

.tag.warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.reason-list,
.guardrail-list {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.reason-list li,
.guardrail-list li {
  position: relative;
  padding-left: 14px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}

.reason-list li::before,
.guardrail-list li::before {
  content: "";
  position: absolute;
  top: 9px;
  left: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.guardrail-list li::before {
  background: var(--red);
}

.guardrail-block {
  background: #fffafa;
  border-color: #f1caca;
}

.admission-block {
  background: #f8fbff;
  border-color: #cfe0f6;
}

.admission-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admission-head h3 {
  margin: 0;
}

.admission-head label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.admission-head select {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 28px 0 10px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
}

.admission-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.admission-grid div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.76);
}

.admission-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.admission-grid strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 16px;
  overflow-wrap: anywhere;
}

.admission-major-list {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.76);
}

.admission-major-list span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.admission-major-list div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.admission-major-list em {
  border-radius: 999px;
  padding: 6px 9px;
  background: var(--blue-soft);
  color: #255a96;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.reply-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.88fr);
  gap: 14px;
  padding: 18px;
}

.reply-column,
.material-column {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdfd;
}

.subpanel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.subpanel-head h3 {
  margin: 0;
  font-size: 15px;
}

.subpanel-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.reply-list {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.reply-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}

.reply-empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--muted);
  background: #fff;
  font-size: 13px;
  text-align: center;
}

.reply-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.reply-card h3 {
  margin: 0;
  font-size: 15px;
}

.reply-reason {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.length-toggle {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  flex: 0 0 auto;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 3px;
  background: #fff;
}

.length-toggle button {
  min-height: 28px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0 8px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.length-toggle button.active {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.sop-index-toggle {
  display: inline-flex;
  flex-wrap: wrap;
  flex: 0 0 auto;
  gap: 6px;
}

.sop-index-toggle button {
  display: grid;
  min-width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.sop-index-toggle button.active {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
}

.sop-entry-body {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: #fff;
}

.sop-entry-meta {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.sop-entry-body section {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdfd;
  padding: 10px;
}

.sop-entry-body span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.sop-entry-body p {
  margin: 0;
  white-space: pre-wrap;
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
}

.gold-sales-block {
  min-height: 86px;
}

.gold-sales-empty {
  min-height: 42px;
}

.reply-text {
  margin: 0;
  padding: 14px;
  white-space: pre-wrap;
  color: var(--text);
  font-size: 15px;
  line-height: 1.75;
}

.reply-actions {
  display: grid;
  grid-template-columns: 1fr;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line);
}

.reply-action {
  min-height: 34px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.reply-action.copy {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

.reply-action:hover {
  background: var(--surface-soft);
}

.reply-action.copy:hover {
  background: #344242;
}

.material-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
  align-content: start;
  gap: 12px;
  max-height: 760px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px;
}

.material-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.material-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.material-preview {
  display: grid;
  min-height: 142px;
  background: var(--surface-soft);
}

.material-image-button {
  display: block;
  width: 100%;
  padding: 0;
  background: transparent;
  cursor: zoom-in;
}

.material-preview img,
.material-preview video {
  width: 100%;
  height: 154px;
  object-fit: cover;
  background: var(--surface-soft);
}

.material-meta {
  display: grid;
  gap: 6px;
  padding: 10px 10px 0;
}

.material-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.material-badge {
  width: fit-content;
  border-radius: 999px;
  background: var(--blue-soft);
  color: #255a96;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
}

.material-selected-badge {
  width: fit-content;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
}

.material-meta strong {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.material-meta p {
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.material-copy {
  width: calc(100% - 20px);
  margin: 10px;
}

.material-empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--muted);
  background: #fff;
  font-size: 13px;
  text-align: center;
}

.image-dialog {
  width: min(980px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow);
}

.image-dialog::backdrop {
  background: rgba(20, 32, 32, 0.52);
}

.image-dialog form {
  margin: 0;
}

.image-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.image-dialog-head h2 {
  margin: 0;
  font-size: 16px;
}

.image-dialog-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.image-dialog-body {
  display: grid;
  place-items: center;
  max-height: calc(100vh - 130px);
  padding: 14px;
  overflow: auto;
  background: #111b1b;
}

.image-dialog-body img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 160px);
  object-fit: contain;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  transform: translateX(-50%) translateY(18px);
  opacity: 0;
  pointer-events: none;
  border-radius: var(--radius);
  background: #1e2b2b;
  color: #fff;
  padding: 10px 16px;
  box-shadow: var(--shadow);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 10px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .panel-head {
    flex-direction: column;
  }

  .user-switcher {
    width: 100%;
    min-width: 0;
    grid-template-columns: 1fr;
  }

  .sample-row,
  .field-grid,
  .price-grid,
  .diagnosis-grid,
  .reply-actions,
  .input-actions {
    grid-template-columns: 1fr;
  }

  .history-message {
    max-width: 100%;
  }

  .dialog-head {
    flex-direction: column;
  }

  .reply-workbench {
    grid-template-columns: 1fr;
  }

  .reply-card-head {
    flex-direction: column;
  }

  .material-list {
    max-height: 620px;
    grid-template-columns: 1fr;
  }
}

.recommendation-section {
  margin-top: 0;
}

.recommendation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 0 18px;
  margin-bottom: 6px;
}

.recommendation-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.recommendation-title-row > span:first-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.goal-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  max-width: 128px;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.goal-badge.trust {
  color: #255a96;
  background: var(--blue-soft);
  border-color: #cfe1f5;
}

.goal-badge.concern {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: #f4d9a8;
}

.goal-badge.close {
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-color: #c7e1db;
}

.goal-badge.empty,
.goal-badge.loading {
  color: var(--muted);
  background: var(--surface-soft);
  border-color: var(--line);
}

.header-right {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 8px;
}

.recommendation-status {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.recommendation-status.generating {
  color: var(--accent);
}

.recommendation-status.done {
  color: var(--amber);
}

.recommendation-textarea {
  width: calc(100% - 36px);
  margin: 0 18px 12px;
  min-height: 300px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 14px;
  line-height: 1.7;
  resize: vertical;
  box-sizing: border-box;
  font: inherit;
}

.recommendation-textarea:focus {
  outline: none;
}

.recommendation-section .primary-button {
  width: calc(100% - 36px);
  margin: 0 18px 18px;
}
