:root {
  --bg: #f5f6fa;
  --panel: #ffffff;
  --line: #e8eaf0;
  --text: #1f2430;
  --muted: #8a91a3;
  --primary: #6b5cff;
  --primary-soft: #efeefc;
  --primary-hover: #5a4cf0;
  --danger: #e45757;
  --sidebar: #fbfbfe;
  --shadow: 0 8px 28px rgba(34, 41, 68, 0.06);
  --radius: 12px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}

button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }

.hidden { display: none !important; }

#login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 12% 18%, rgba(107, 92, 255, 0.16), transparent 40%),
    radial-gradient(circle at 88% 80%, rgba(255, 196, 92, 0.18), transparent 36%),
    var(--bg);
}

.login-card {
  width: 380px;
  background: var(--panel);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 36px 32px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

.login-card p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 13px;
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
}
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(107, 92, 255, 0.12);
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  background: #eef0f6;
  color: var(--text);
  transition: .15s ease;
}
.btn:hover { filter: brightness(0.97); }
.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
}
.btn-link {
  background: transparent;
  color: var(--primary);
  padding: 6px 10px;
}
.btn-block { width: 100%; }

#app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 56px 1fr;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}
.brand {
  font-weight: 700;
  color: #24315a;
  letter-spacing: .5px;
}
.userbox {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  min-height: calc(100vh - 56px);
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  color: #4c556d;
  margin-bottom: 6px;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
.nav-item .ico {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sidebar-foot {
  margin-top: auto;
  display: flex;
  justify-content: center;
}
.collapse-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}

.main {
  padding: 28px 36px 48px;
}

.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 8px auto 28px;
  max-width: 720px;
}
.step {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}
.step .n {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #e7e9f2;
  color: #6b7288;
  font-weight: 600;
}
.step.active { color: var(--primary); font-weight: 600; }
.step.active .n {
  background: var(--primary);
  color: #fff;
}
.step.done .n {
  background: #cfc9ff;
  color: var(--primary);
}
.step-line {
  width: 88px;
  height: 2px;
  background: #e0e3ee;
  margin: 0 12px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 32px;
}
.insight {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
  background: #fafbff;
  font-size: 13px;
  line-height: 1.7;
}
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 12px;
  margin-right: 6px;
}
.badge.red { background: #fde8e8; color: #c24141; }
.badge.yellow { background: #fff4d6; color: #9a6b00; }
.badge.green { background: #e7f7ee; color: #1d7a45; }
.consult {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 18px;
  background: #f7f8fc;
}
.consult-head {
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: #fff;
  border: 1px solid var(--line);
}
.consult-head.red { border-color: #f3c7c7; background: #fff8f8; }
.consult-head.yellow { border-color: #f3e2b0; background: #fffdf6; }
.consult-head.green { border-color: #cfe8da; background: #f7fcf9; }
.consult-head strong { margin-right: 8px; }
.consult-head p { margin: 8px 0 0; line-height: 1.7; }
.consult-grid, .consult-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.script-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.panel h4 { margin: 0 0 8px; font-size: 14px; }
.panel p { margin: 0 0 8px; line-height: 1.7; font-size: 14px; }
.muted { color: var(--muted); font-size: 12px; }
.gauge-row { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.ring { width: 92px; height: 92px; flex: none; }
.ring-track { fill: none; stroke: #eceef5; stroke-width: 8; }
.ring-value { fill: none; stroke-width: 8; stroke-linecap: round; }
.ring-num { font-size: 18px; font-weight: 700; fill: #24315a; font-family: var(--font); }
.ring-unit { font-size: 9px; fill: #8a91a3; }
.bars { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 72px 1fr 24px; gap: 8px; align-items: center; font-size: 12px; }
.bar-track { height: 8px; background: #eef0f6; border-radius: 99px; overflow: hidden; }
.bar-track div { height: 100%; background: linear-gradient(90deg, #8d7dff, #6b5cff); border-radius: 99px; }
.problem-list, .plain-list { margin: 0; padding: 0; list-style: none; }
.problem-list li, .plain-list li { display: flex; gap: 8px; margin: 0 0 8px; line-height: 1.6; font-size: 14px; }
.problem-list em {
  flex: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-style: normal;
  font-size: 12px;
  display: grid;
  place-items: center;
}
.product { font-weight: 700; color: #24315a; }
.quote-panel { margin-bottom: 12px; background: #f4f2ff; }
.reply { color: #3d4560; }
.script-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.script-card b { color: var(--primary); }
.tag-row { display: grid; gap: 8px; }
.tag-row > div { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  background: #efeefc;
  color: #4c43b8;
  border-radius: 99px;
  padding: 3px 8px;
  font-size: 12px;
}
.chip-warn { background: #fff1e8; color: #a85a24; }
@media (max-width: 800px) {
  .consult-grid, .consult-split, .script-row { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 64px 1fr 22px; }
}
.card h2 {
  margin: 0 0 8px;
  font-size: 20px;
}
.card .hint {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.dropzone {
  border: 1.5px dashed #c9cee0;
  border-radius: 12px;
  background: #fafbff;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: .15s ease;
  padding: 24px;
}
.dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.dropzone .folder {
  width: 56px;
  height: 44px;
  border-radius: 8px 8px 6px 6px;
  background: linear-gradient(180deg, #ffd86b, #f5b942);
  position: relative;
  margin-bottom: 8px;
}
.dropzone .folder:before {
  content: "";
  position: absolute;
  left: 0;
  top: -10px;
  width: 22px;
  height: 12px;
  border-radius: 4px 4px 0 0;
  background: #f0c35a;
}
.dropzone strong { font-size: 15px; }
.dropzone span { color: var(--muted); font-size: 12px; }

.file-list {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}
.file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
}
.file-item .rm {
  color: var(--danger);
  cursor: pointer;
  background: none;
  border: none;
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}
.form-grid .full { grid-column: 1 / -1; }

.facts {
  display: grid;
  gap: 8px;
}
.fact-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.preview-box {
  max-height: 180px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fafbff;
  white-space: pre-wrap;
  font-size: 12px;
  color: #4b5368;
  line-height: 1.6;
}

.gen-panel {
  text-align: center;
  padding: 40px 20px;
}
.spinner {
  width: 42px;
  height: 42px;
  border: 3px solid #e6e8f2;
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.plans-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  max-width: 960px;
}
.plans-head h2 { margin: 0; font-size: 22px; }
.filters {
  display: flex;
  gap: 10px;
  align-items: center;
}
.filters input, .filters select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  background: #fff;
  min-width: 140px;
}
.filters input { min-width: 200px; }

.plan-list {
  display: grid;
  gap: 14px;
  max-width: 960px;
}
.plan-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
}
.plan-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
}
.plan-meta {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 14px;
}
.plan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 40, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 24px;
}
.modal {
  width: min(980px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 22px 24px;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.modal-head h3 { margin: 0; }
.doc-view h1, .doc-edit h1 { font-size: 22px; text-align: center; margin: 8px 0; }
.doc-view .sub, .doc-edit .sub { text-align: center; color: var(--muted); margin-bottom: 18px; }
.doc-view .h1 { font-size: 18px; font-weight: 700; margin: 18px 0 8px; }
.doc-view .h2 { font-size: 15px; font-weight: 700; margin: 12px 0 6px; }
.doc-view .p { text-indent: 2em; line-height: 1.8; margin: 0 0 8px; }
.doc-view .li { margin: 0 0 6px 1.5em; line-height: 1.7; }
.block-edit {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
}
.block-edit select {
  margin-bottom: 8px;
}
.block-edit textarea {
  width: 100%;
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  resize: vertical;
}

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: #2b3144;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
}
.toast.show { opacity: 1; }

.empty {
  color: var(--muted);
  text-align: center;
  padding: 48px 12px;
}

@media print {
  body * { visibility: hidden; }
  #modal, #modal * { visibility: visible; }
  #modal { position: static; background: #fff; padding: 0; }
  .modal { box-shadow: none; max-height: none; width: 100%; }
  .modal-head, .toast, .sidebar, .topbar, .no-print { display: none !important; }
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 18px 14px 40px; }
  .form-grid { grid-template-columns: 1fr; }
  .plans-head { flex-direction: column; align-items: stretch; }
  .filters { flex-wrap: wrap; }
  .step-line { width: 36px; }
}
