:root {
  color-scheme: light;
  --bg: #f6f8fc;
  --panel: #ffffff;
  --panel-soft: #fbfcfe;
  --line: #e5edf8;
  --line-soft: #eef3fb;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --primary-soft: #eaf1ff;
  --ok: #16a34a;
  --ok-soft: #ecfdf5;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --bad: #dc2626;
  --bad-soft: #fef2f2;
  --blue-soft: #eff6ff;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 48px rgba(15, 23, 42, 0.12);
  --radius: 20px;
  --radius-lg: 24px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.shell {
  max-width: 1040px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #60a5fa);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.22);
}

.nav {
  display: flex;
  gap: 6px;
  background: var(--panel-soft);
  border: 1px solid var(--line-soft);
  padding: 4px;
  border-radius: 999px;
}

.nav-link {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 7px 14px;
  border-radius: 999px;
  transition: 0.15s ease;
}

.nav-link:hover { color: var(--primary); background: var(--primary-soft); }

.nav-link.active {
  color: var(--primary-strong);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.content { flex: 1; padding: 28px 24px 40px; }

.footer {
  padding: 16px 24px;
  border-top: 1px solid var(--line-soft);
  background: var(--panel-soft);
}

.footer p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.hidden { display: none !important; }

.view { animation: fadeIn 0.25s ease; }

h1 {
  font-size: 28px;
  line-height: 1.2;
  margin: 6px 0 8px;
  letter-spacing: -0.015em;
}

h3 { margin: 0 0 6px; font-size: 15px; font-weight: 700; }

p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
  margin: 0 0 12px;
}

.card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #fff;
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.value-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.value-grid .card { padding: 18px; transition: 0.18s ease; }

.value-grid .card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.value-grid .card h3 { font-size: 15px; margin-bottom: 4px; }

.actions { display: grid; gap: 10px; margin: 18px 0; }

.btn {
  width: 100%;
  padding: 13px 16px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.15s ease;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary {
  border: 0;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.18);
}

.btn.primary:hover:not(:disabled) {
  background: var(--primary-strong);
  transform: translateY(-1px);
}

.btn.secondary {
  border: 1.5px solid var(--line);
  background: #fff;
  color: #334155;
}

.btn.secondary:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary-strong);
  background: var(--primary-soft);
}

.btn.danger {
  border: 1.5px solid #fecaca;
  background: #fff;
  color: var(--bad);
}

.btn.danger:hover:not(:disabled) { background: var(--bad-soft); }

.form { display: grid; gap: 14px; margin-top: 16px; }

.field { display: grid; gap: 8px; }

.field > span { font-size: 13px; color: var(--muted); font-weight: 500; }

input,
textarea,
select {
  width: 100%;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 14px;
  outline: none;
  background: #fff;
  color: var(--text);
  font-family: inherit;
  transition: 0.15s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

textarea { resize: vertical; min-height: 74px; }

.error { color: var(--bad); font-size: 12px; }

.alert {
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 13px;
  margin: 10px 0;
  line-height: 1.6;
}

.alert.info {
  background: var(--primary-soft);
  color: var(--primary-strong);
  border: 1px solid #bfdbfe;
}

.alert.danger {
  background: var(--bad-soft);
  color: var(--bad);
  border: 1px solid #fecaca;
}

.limit-status {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 10px;
  padding: 8px 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
}

.limit-status.full {
  color: var(--bad);
  background: var(--bad-soft);
  border-color: #fecaca;
  font-weight: 600;
}

.segmented { display: grid; gap: 8px; }

.segmented > span { font-size: 13px; color: var(--muted); font-weight: 500; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chips button {
  border: 1.5px solid #cbd5e1;
  background: #fff;
  color: #334155;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: 0.15s ease;
  font-weight: 500;
}

.chips button:hover { border-color: var(--primary); color: var(--primary-strong); }

.chips button.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-strong);
  font-weight: 700;
}

.progress {
  height: 6px;
  background: var(--line-soft);
  border-radius: 999px;
  overflow: hidden;
  margin: 14px 0 18px;
}

.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  transition: width 0.3s ease;
}

.chat {
  display: grid;
  gap: 10px;
  max-height: 340px;
  overflow: auto;
  margin-bottom: 14px;
  padding: 4px;
}

.msg {
  max-width: 88%;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line-soft);
  background: #fff;
  font-size: 14px;
  line-height: 1.6;
  box-shadow: var(--shadow-sm);
}

.msg strong {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.msg.ai {
  align-self: start;
  border-top-left-radius: 4px;
}

.msg.user {
  align-self: end;
  background: var(--primary-soft);
  border-color: #bfdbfe;
  border-bottom-right-radius: 4px;
}

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

.question-head strong { font-size: 15px; line-height: 1.5; }

.tag {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--primary-strong);
  background: var(--primary-soft);
  font-weight: 600;
  white-space: nowrap;
}

.advice {
  border: 1.5px solid #fde68a;
  background: var(--warn-soft);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.advice.buy { border-color: #bbf7d0; background: var(--ok-soft); }
.advice.wait { border-color: #fde68a; background: var(--warn-soft); }
.advice.no { border-color: #fecaca; background: var(--bad-soft); }
.advice.down { border-color: #bfdbfe; background: var(--blue-soft); }

.advice-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.advice-sub { color: var(--muted); font-size: 14px; margin-top: 6px; }

.list { display: grid; gap: 8px; margin-top: 14px; }

.list div {
  border: 1px solid var(--line-soft);
  background: #fff;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric { padding: 16px; background: var(--panel-soft); }

.metric strong {
  display: block;
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 4px;
  letter-spacing: -0.015em;
}

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

.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 560px;
}

.table th,
.table td {
  border-bottom: 1px solid var(--line-soft);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
}

.table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  background: var(--panel-soft);
}

.table tr:hover td { background: var(--panel-soft); }

.table .row-actions { display: flex; flex-wrap: wrap; gap: 6px; min-width: 120px; }

.table .row-actions button {
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--bad);
  font-size: 12px;
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
  transition: 0.15s ease;
  font-weight: 600;
}

.table .row-actions button:hover { background: var(--bad-soft); border-color: #fecaca; }

.table .row-actions button[data-review-decision] { color: var(--primary-strong); }

.table .row-actions button[data-review-decision]:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  border: 1.5px dashed #cbd5e1;
  border-radius: 16px;
  background: var(--panel-soft);
  font-size: 14px;
}

.disclaimer {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  background: var(--panel-soft);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 10px;
  line-height: 1.6;
}

.calm-list { display: grid; gap: 10px; }

.calm-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line-soft);
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
}

.calm-item.reviewed { border-color: #bbf7d0; background: var(--ok-soft); }

.calm-item strong { color: var(--text); font-weight: 700; }

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

.calm-review-btn {
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--primary-strong);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: 0.15s ease;
  font-weight: 600;
}

.calm-review-btn:hover { background: var(--primary-soft); border-color: var(--primary); }

.calm-item.reviewed .calm-review-btn { color: var(--ok); border-color: #bbf7d0; background: #fff; }

.offline-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ok);
  background: var(--ok-soft);
  border: 1px solid #bbf7d0;
  border-radius: 999px;
  padding: 4px 10px;
  margin-top: 10px;
}

.offline-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 720px) {
  .content { padding: 20px 16px 32px; }

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

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

  .calm-item { grid-template-columns: 1fr; align-items: start; }

  .calm-item .calm-review-btn { width: 100%; }

  h1 { font-size: 24px; }
}
