:root {
  color-scheme: light;
  --background: #f8fafc;
  --surface: #ffffff;
  --foreground: #0f172a;
  --muted-text: #475569;
  --muted: #e9eef5;
  --border: #cbd5e1;
  --primary: #1e3a8a;
  --primary-strong: #172554;
  --accent: #92400e;
  --success: #166534;
  --danger: #b91c1c;
  --ring: #1e3a8a;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--background); color: var(--foreground); font-size: 16px; line-height: 1.6; }
a { color: inherit; }
button, a { touch-action: manipulation; }
button { min-height: 44px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--primary-strong); padding: 0 16px; font: inherit; font-weight: 650; cursor: pointer; transition: background-color 180ms ease, border-color 180ms ease; }
button:hover { background: var(--muted); border-color: #94a3b8; }
button:disabled { cursor: not-allowed; opacity: .55; }
select, textarea { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--foreground); font: inherit; }
select { min-height: 44px; padding: 0 36px 0 12px; }
textarea { width: 100%; min-height: 92px; padding: 10px 12px; resize: vertical; }
.workspace-link, .login-link { min-height: 44px; display: inline-flex; align-items: center; border-radius: 10px; padding: 0 14px; color: var(--primary); font-weight: 700; text-decoration: none; }
.workspace-link:hover, .login-link:hover { background: var(--muted); }
button:focus-visible, a:focus-visible { outline: 3px solid var(--ring); outline-offset: 3px; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 10; transform: translateY(-160%); background: var(--surface); padding: 10px 14px; border-radius: 8px; }
.skip-link:focus { transform: none; }
.topbar { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px clamp(16px, 4vw, 56px); background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { min-height: 48px; display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 11px; background: var(--primary-strong); color: #fff; font-family: Georgia, "Songti SC", serif; font-size: 22px; }
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted-text); font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.mode-badge, .count-badge { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border); border-radius: 999px; padding: 5px 10px; color: var(--muted-text); background: var(--surface); font-size: 13px; font-weight: 650; }
.mode-badge span { color: var(--accent); }
main { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 40px 0 64px; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 32px; margin-bottom: 28px; }
.eyebrow, .section-label { margin: 0 0 5px; color: var(--primary); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { max-width: 15ch; margin-bottom: 12px; font-family: Georgia, "Songti SC", serif; font-size: clamp(32px, 6vw, 54px); line-height: 1.12; letter-spacing: -.025em; }
.hero-copy { max-width: 68ch; margin-bottom: 0; color: var(--muted-text); }
.boundary-list { display: grid; grid-template-columns: repeat(3, minmax(92px, 1fr)); margin: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.boundary-list div { padding: 14px 16px; border-left: 1px solid var(--border); }
.boundary-list div:first-child { border-left: 0; }
.boundary-list dt { color: var(--muted-text); font-size: 12px; }
.boundary-list dd { margin: 2px 0 0; font-weight: 800; }
.status-message { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 18px; color: var(--muted-text); }
.status-message.error { color: var(--danger); border-color: #fecaca; background: #fff7f7; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.metric-grid article, .panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.metric-grid article { min-height: 132px; padding: 18px; }
.metric-grid span, .metric-grid small { display: block; color: var(--muted-text); }
.metric-grid strong { display: block; margin: 2px 0; color: var(--primary-strong); font-size: 34px; line-height: 1.25; font-variant-numeric: tabular-nums; }
.layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, .8fr); gap: 18px; align-items: start; }
.layout > *, .panel { min-width: 0; }
.panel { padding: 22px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel-heading.compact { margin-bottom: 12px; }
.lead-tools { display: flex; align-items: center; gap: 8px; }
.lead-tools label { color: var(--muted-text); font-size: 13px; font-weight: 700; }
.panel h2 { margin-bottom: 0; font-family: Georgia, "Songti SC", serif; font-size: 24px; line-height: 1.3; }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; min-width: 620px; border-collapse: collapse; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted-text); background: #f1f5f9; font-size: 12px; letter-spacing: .04em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; }
tbody tr:hover, tbody tr:focus-within { background: #f8fafc; }
.row-button { width: 100%; min-height: 44px; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; font-weight: 650; }
.level { display: inline-grid; min-width: 34px; height: 30px; place-items: center; border-radius: 8px; font-weight: 850; background: #fef3c7; color: #78350f; }
.lead-detail { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.lead-detail h3 { margin-bottom: 8px; font-size: 17px; }
.review-box { margin-top: 18px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: #f8fafc; }
.review-box h4 { margin: 0 0 6px; font-size: 16px; }
.review-box label { display: block; margin: 12px 0 6px; color: var(--muted-text); font-size: 13px; font-weight: 700; }
.review-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.review-actions .primary { color: #fff; border-color: var(--primary); background: var(--primary); }
.review-actions .danger { color: var(--danger); border-color: #fecaca; background: #fff7f7; }
.review-history { margin: 14px 0 0; padding-left: 20px; color: var(--muted-text); font-size: 14px; }
.review-status { color: var(--muted-text); }
.status-message.success { color: var(--success); border-color: #bbf7d0; background: #f0fdf4; }
.evidence-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.evidence-list li { padding: 12px 14px; border-left: 3px solid var(--primary); background: #f8fafc; }
.evidence-list strong { display: block; color: var(--primary-strong); font-size: 13px; }
.side-stack { display: grid; gap: 18px; }
.empty-state { padding: 20px 0 4px; color: var(--muted-text); }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--foreground); }
.run-detail { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; margin: 0; }
.run-detail dt { color: var(--muted-text); }
.run-detail dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.report-panel { margin-top: 18px; }
.candidate-panel { margin-top: 18px; }
.candidate-note { max-width: 76ch; color: var(--muted-text); }
.candidate-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.candidate-list article { min-width: 0; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: #f8fafc; }
.candidate-list article h3 { margin: 0; font-size: 16px; line-height: 1.45; }
.candidate-list article p { margin-bottom: 10px; color: var(--muted-text); }
.candidate-list article a { color: var(--primary); font-weight: 700; }
.candidate-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.candidate-status { flex: 0 0 auto; border-radius: 999px; padding: 3px 8px; background: #fef3c7; color: #78350f; font-size: 12px; font-weight: 800; }
.candidate-meta { font-size: 13px; }
.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.report-grid h3 { margin-bottom: 8px; font-size: 16px; }
.report-grid ol, .report-grid ul { margin: 0; padding-left: 22px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 820px) {
  .hero, .layout { grid-template-columns: 1fr; }
  .boundary-list { width: 100%; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .candidate-list { grid-template-columns: 1fr; }
}

@media (max-width: 540px) {
  .topbar { align-items: flex-start; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  .mode-badge { display: none; }
  main { width: min(calc(100% - 24px), 1180px); padding-top: 28px; }
  .boundary-list { grid-template-columns: 1fr; }
  .boundary-list div { border-left: 0; border-top: 1px solid var(--border); }
  .boundary-list div:first-child { border-top: 0; }
  .metric-grid, .report-grid { grid-template-columns: 1fr; }
  .metric-grid article { min-height: 112px; }
  .panel { padding: 18px; }
  .panel-heading { align-items: flex-start; }
  .lead-tools { align-items: flex-end; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
