:root {
  --bg: #f4f6f3;
  --panel: #ffffff;
  --ink: #17211b;
  --muted: #667066;
  --line: #dce2da;
  --accent: #166b5a;
  --accent-dark: #0f4d41;
  --accent-soft: #e5f3ef;
  --warn: #8a4c18;
  --warn-bg: #fff3df;
  --shadow: 0 18px 48px rgba(23, 33, 27, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-size: 12px;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: var(--bg);
}

.login-screen.hidden {
  display: none;
}

.login-card {
  width: min(300px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin-bottom: 18px;
}

.login-card label {
  display: block;
  margin-bottom: 12px;
}

.login-card label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.login-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  padding: 9px 10px;
  color: var(--ink);
  background: #fbfcfa;
}

.login-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-card button {
  width: 100%;
}

.login-error {
  min-height: 18px;
  margin-bottom: 10px;
  color: #9f241b;
  font-size: 12px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) 390px;
  gap: 18px;
  height: 100vh;
  padding: 10px;
}

.sidebar-mode {
  grid-template-columns: minmax(680px, 1fr);
  justify-content: center;
  align-items: stretch;
  background: #eef2ee;
}

.compact-app .chat-pane {
  display: none;
}

.chat-pane,
.assistant-pane {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.chat-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 14px;
}

.assistant-pane {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
  padding: 7px;
}

.assistant-scroll {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 5px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.top-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}

.top-toolbar .primary-button,
.top-toolbar .ghost-button {
  flex: 1;
  min-height: 36px;
  padding: 0 12px;
  font-size: 14px;
}

.analysis-progress {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 8px;
  background: #f7faf7;
}

.analysis-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.analysis-progress-row strong {
  color: var(--accent);
}

.analysis-progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #dde6df;
}

.analysis-progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #36a083);
  transition: width 0.28s ease;
}

.customer-queue {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px;
  background: #fbfcfa;
}

.customer-queue-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  max-height: 92px;
  overflow: auto;
}

.queue-item,
.queue-empty {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 7px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.queue-item {
  display: grid;
  gap: 2px;
}

.queue-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.queue-item.unread {
  border-color: #be3a2b;
}

.queue-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
}

.queue-meta {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 1px 5px;
  background: #be3a2b;
  color: #fff;
  font-size: 10px;
}

.queue-title-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.queue-delete {
  min-width: 20px;
  min-height: 20px;
  border: 1px solid #e4c2bc;
  border-radius: 999px;
  padding: 0;
  background: #fff7f5;
  color: #9f241b;
  font-size: 14px;
  line-height: 1;
  text-align: center;
}

.queue-delete:hover {
  background: #ffe7e1;
}

.queue-empty {
  grid-column: 1 / -1;
  color: var(--muted);
  text-align: center;
}

.prompt-settings {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fbfcfa;
}

.prompt-settings[hidden] {
  display: none;
}

.prompt-settings textarea {
  width: 100%;
  min-height: 118px;
  max-height: 180px;
  resize: vertical;
  padding: 9px 10px;
  font-size: 12px;
  line-height: 1.45;
}

.prompt-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.prompt-actions .primary-button {
  min-height: 30px;
  padding: 0 12px;
  font-size: 12px;
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.pane-header.compact {
  margin-bottom: 2px;
}

.eyebrow {
  margin: 0 0 1px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2 {
  margin-bottom: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 17px;
}

h2 {
  font-size: 18px;
}

h3 {
  margin-bottom: 3px;
  font-size: 14px;
}

.field-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

textarea {
  flex: 1;
  min-height: 420px;
  resize: none;
  border: 1px solid var(--line);
  outline: none;
  padding: 18px;
  color: var(--ink);
  background: #fbfcfa;
  line-height: 1.7;
}

.sidebar-mode textarea {
  min-height: 160px;
  font-size: 13px;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

button {
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  padding: 0 18px;
  color: #fff;
  background: var(--accent);
}

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

.ghost-button,
.plain-button {
  padding: 0 14px;
  color: var(--accent);
  background: var(--accent-soft);
}

.compact-button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.plain-button {
  color: var(--muted);
  background: transparent;
}

.customer-card,
.sync-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 10px;
  padding: 10px;
  background: #fbfcfa;
}

.customer-card span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.customer-card strong {
  display: block;
  font-size: 18px;
}

.customer-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

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

.desktop-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.mini-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.mini-check input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}

.sync-card strong,
.sync-card span {
  display: block;
}

.sync-card strong {
  margin-bottom: 5px;
  font-size: 14px;
}

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

.switch {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  width: 44px;
  height: 26px;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  width: 100%;
  border-radius: 999px;
  background: #b8c2bc;
  transition: background 0.2s ease;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(23, 33, 27, 0.25);
  transition: transform 0.2s ease;
}

.switch input:checked + span {
  background: var(--accent);
}

.switch input:checked + span::after {
  transform: translateX(18px);
}

.notes {
  margin-top: 18px;
  border-left: 3px solid var(--accent);
  padding-left: 14px;
  color: var(--muted);
}

.notes h2 {
  margin-bottom: 6px;
  font-size: 16px;
  color: var(--ink);
}

.notes p {
  margin-bottom: 0;
  line-height: 1.7;
}

.level-rules {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  line-height: 1.55;
}

.level-rules span {
  color: #3c463f;
}

.level-rules strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  margin-right: 8px;
  border-radius: 6px;
  padding: 2px 6px;
  color: #fff;
  background: var(--accent);
  font-size: 12px;
}

.status-dot {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 12px;
  font-weight: 800;
}

.status-group {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 5px;
}

.source-dot {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

button:disabled {
  cursor: progress;
  opacity: 0.72;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.level-card {
  display: grid;
  grid-template-columns: 58px 1fr;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fbfcfa;
}

.level-card span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.level-card strong {
  display: block;
  color: var(--accent-dark);
  font-size: 24px;
  line-height: 1;
}

.level-card p {
  margin-bottom: 0;
  color: #3c463f;
  font-size: 14px;
  line-height: 1.35;
}

.level-card[data-level="Splus"] {
  border-left-color: #a63b2b;
  background: #fff7f4;
}

.level-card[data-level="S"] {
  border-left-color: #bd7a12;
  background: #fff9ec;
}

.level-card[data-level="A"] {
  border-left-color: #166b5a;
  background: #f1faf7;
}

.level-card[data-level="B"] {
  border-left-color: #3f6fba;
}

.level-card[data-level="C"] {
  border-left-color: #7b8794;
}

.level-card[data-level="D"] {
  border-left-color: #7f1d1d;
  background: #fff5f5;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fbfcfa;
}

.metric span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  min-height: 20px;
  font-size: 15px;
}

.next-step-card {
  border: 1px solid #c9ded7;
  border-radius: 8px;
  padding: 8px 10px;
  background: #f4fbf8;
}

.next-step-card .section-heading {
  margin-bottom: 4px;
}

.next-step-card > strong {
  display: block;
  margin-bottom: 2px;
  color: var(--accent-dark);
  font-size: 15px;
  line-height: 1.35;
}

.question-list {
  display: none;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
  color: #3c463f;
  line-height: 1.55;
}

.question-list li::marker {
  color: var(--accent);
}

.insight-block {
  border-top: 1px solid var(--line);
  padding-top: 6px;
}

.insight-block p {
  margin-bottom: 0;
  color: #3c463f;
  font-size: 13px;
  line-height: 1.35;
}

.warning {
  border: 1px solid #f0d8b5;
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--warn-bg);
}

.warning h3,
.warning p {
  color: var(--warn);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.section-heading h3 {
  margin-bottom: 0;
}

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

.script-list {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  margin: 0 -7px -7px;
  padding: 7px;
  background: #fff;
  box-shadow: 0 -8px 20px rgba(23, 33, 27, 0.08);
}

.scripts-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--muted);
  line-height: 1.6;
}

.script-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 6px;
  overflow: hidden;
  background: #fff;
}

.script-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 9px;
  background: #f8faf7;
}

.script-title strong {
  font-size: 14px;
}

.copy-button {
  min-height: 30px;
  padding: 0 12px;
  color: #fff;
  background: var(--accent);
  font-size: 14px;
}

.script-text {
  margin: 0;
  padding: 8px 9px;
  font-size: 14px;
  line-height: 1.35;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  transform: translateY(20px);
  opacity: 0;
  border-radius: 8px;
  padding: 10px 14px;
  color: #fff;
  background: var(--accent-dark);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar-mode {
    justify-content: stretch;
  }

  .assistant-pane {
    min-height: 620px;
  }
}

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

  .chat-pane,
  .assistant-pane {
    padding: 16px;
  }

  .pane-header {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .level-card {
    grid-template-columns: 1fr;
  }
}
