/* ============================================================
   上海一手房 · 数据看板 — assets/styles.css
   气质：克制的数据终端 + 城市研究报告。浅 / 深两套主题。
   ============================================================ */

:root {
  --bg: #F5F6F8;
  --panel: #FFFFFF;
  --panel-2: #FAFBFC;
  --ink: #17202A;
  --muted: #667085;
  --line: #E4E7EC;
  --brand: #1264A3;
  --brand-2: #0E9384;
  --warn: #DC6803;
  --danger: #D92D20;
  --ok: #12B76A;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --radius: 12px;
  --header-h: 60px;
  --font-sans: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "SFMono-Regular", "Cascadia Mono", "Consolas", "Microsoft YaHei", monospace;
  --table-stripe: rgba(16, 24, 40, .018);
  --table-hover: rgba(18, 100, 163, .06);
}

html[data-theme="dark"] {
  --bg: #0F141A;
  --panel: #161D26;
  --panel-2: #1B2430;
  --ink: #E6EDF5;
  --muted: #8FA0B3;
  --line: #263140;
  --brand: #4E9BD6;
  --brand-2: #35BFAE;
  --warn: #E9A23B;
  --danger: #F97066;
  --ok: #32D583;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 4px 16px rgba(0, 0, 0, .3);
  --table-stripe: rgba(255, 255, 255, .022);
  --table-hover: rgba(78, 155, 214, .10);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, p, ul, ol { margin: 0; }
ul, ol { padding-left: 1.15em; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; padding: 0; }
svg { display: block; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

/* ---------- 顶栏 ---------- */
.top-shell {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.app-header { background: var(--panel); }

.header-inner {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 24px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 26px;
}

.brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 1px;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-title { font-size: 14.5px; font-weight: 650; letter-spacing: .2px; white-space: nowrap; }
.brand-sub { font-size: 11px; color: var(--muted); white-space: nowrap; }

.main-nav {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.main-nav::-webkit-scrollbar { display: none; }

.nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 100%;
  padding: 0 12px;
  font-size: 13.5px;
  color: var(--muted);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  text-decoration: none;
  transition: color .12s ease;
}
.nav-link:hover { color: var(--ink); text-decoration: none; }
.nav-link.is-active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.header-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: 0 0 auto; }

.snapshot-badge {
  font-size: 11.5px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  display: inline-grid;
  place-items: center;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  line-height: 1;
}
.icon-btn:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }

/* ---------- 全局筛选条 ---------- */
.filterbar { background: var(--panel-2); border-bottom: 1px solid var(--line); }
.filterbar-inner {
  max-width: 1480px;
  margin: 0 auto;
  padding: 9px 24px;
  display: flex;
  align-items: center;
  gap: 8px 14px;
  flex-wrap: wrap;
}
.filter-label { font-size: 11.5px; color: var(--muted); white-space: nowrap; flex: 0 0 auto; }
.filter-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.filter-actions { display: flex; align-items: center; gap: 4px; }
.filter-note {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.filter-note strong { color: var(--ink); font-weight: 600; }

/* ---------- 主区 ---------- */
.app-main {
  max-width: 1480px;
  margin: 0 auto;
  padding: 22px 24px 48px;
  min-height: 62vh;
}
.app-main:focus { outline: none; }

.view { display: flex; flex-direction: column; gap: 18px; }

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 20px;
  flex-wrap: wrap;
}
.view-title { font-size: 20px; font-weight: 650; letter-spacing: -.2px; }
.view-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.view-sub strong { color: var(--ink); font-weight: 600; }
.view-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.section { display: flex; flex-direction: column; gap: 10px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-title { font-size: 14.5px; font-weight: 650; }
.section-note { font-size: 12px; color: var(--muted); }

/* ---------- 栅格 ---------- */
.grid { display: grid; gap: 14px; min-width: 0; }
.grid > * { min-width: 0; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-kpi { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.cols-kpi.cols-kpi-nine { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.g-3-1 { grid-template-columns: minmax(0, 3fr) minmax(0, 1fr); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  min-width: 0;
}
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.card-titles { min-width: 0; }
.card-title { font-size: 13.5px; font-weight: 650; }
.card-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.card-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 0 0 auto; }
.card-body { min-width: 0; }
.card + .card { margin-top: 0; }

/* ---------- KPI ---------- */
.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 13px 15px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.kpi-label {
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  line-height: 1.4;
}
.kpi-value {
  font-size: 29px;
  font-weight: 650;
  line-height: 1.18;
  letter-spacing: -.4px;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kpi-value .kpi-unit {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
  margin-left: 4px;
}
.kpi-note { font-size: 11px; color: var(--muted); line-height: 1.45; }
.kpi-spark { height: 24px; display: flex; align-items: flex-end; margin-top: 2px; }
.kpi.is-accent { border-color: rgba(18, 100, 163, .35); }
.kpi-link { cursor: pointer; }
.kpi-link:hover { border-color: var(--brand); }
.kpi-link:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
html[data-theme="dark"] .kpi.is-accent { border-color: rgba(78, 155, 214, .4); }

/* ---------- chips / tags / 按钮 / 表单 ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 11.5px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  line-height: 1.65;
  white-space: nowrap;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.is-on {
  background: rgba(18, 100, 163, .10);
  border-color: var(--brand);
  color: var(--brand);
  font-weight: 600;
}
html[data-theme="dark"] .chip.is-on { background: rgba(78, 155, 214, .16); color: #9DCBEF; }
.chip-count { opacity: .7; margin-left: 3px; font-variant-numeric: tabular-nums; }
.chip:disabled { opacity: .45; cursor: not-allowed; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 6px;
  padding: 1px 4px 1px 8px;
  color: var(--ink);
  white-space: nowrap;
}
.tag > span { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.tag button { color: var(--muted); font-size: 14px; line-height: 1; padding: 0 3px; border-radius: 4px; }
.tag button:hover { color: var(--danger); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  padding: 4px 11px;
  font-size: 12.5px;
  line-height: 1.6;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { color: #fff; filter: brightness(1.06); }
.btn-sm { padding: 2px 8px; font-size: 11.5px; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--panel-2); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.seg-btn {
  padding: 4px 10px;
  font-size: 12px;
  color: var(--muted);
  border-right: 1px solid var(--line);
  white-space: nowrap;
  line-height: 1.6;
}
.seg-btn:last-child { border-right: 0; }
.seg-btn:hover { color: var(--brand); background: var(--panel-2); }
.seg-btn.is-on { background: var(--brand); color: #fff; font-weight: 600; }
.seg-btn.is-on:hover { color: #fff; }

.input, .select {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  padding: 4px 9px;
  font-size: 12.5px;
  line-height: 1.6;
  min-height: 28px;
  min-width: 0;
}
.input::placeholder { color: var(--muted); opacity: .8; }
.input:focus, .select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(18, 100, 163, .14);
}
.input-sm { width: 92px; }
.input-search { width: 250px; }
.select-sm { padding-right: 4px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.toolbar-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.field-label { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.toolbar-sep { width: 1px; height: 18px; background: var(--line); }

/* ---------- 表格 ---------- */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  max-height: var(--table-max, none);
}
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 600;
  font-size: 11.5px;
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  line-height: 1.5;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:nth-child(even) td { background: var(--table-stripe); }
.data-table tbody tr:hover td { background: var(--table-hover); }
.data-table tfoot td {
  background: var(--panel-2);
  font-weight: 650;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .nowrap { white-space: nowrap; }
.data-table td.cell-name { max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-table td.cell-addr { max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.data-table tbody tr.is-baseline td { color: var(--muted); }
.data-table tbody tr.row-click { cursor: pointer; }
.data-table tbody tr.is-selected td { background: rgba(18, 100, 163, .08); }
html[data-theme="dark"] .data-table tbody tr.is-selected td { background: rgba(78, 155, 214, .13); }

.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
  font-weight: 600;
  font-size: 11.5px;
}
.th-sort:hover { color: var(--brand); }
.sort-ind { font-size: 9px; color: var(--brand); line-height: 1; }

.link-btn {
  color: var(--brand);
  font-weight: 600;
  text-align: left;
  border-radius: 4px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding-top: 10px; }
.pager-info { margin-right: auto; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pager-page { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; padding: 0 2px; }
.pager .btn[disabled] { opacity: .38; }

/* ---------- 徽标 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 5px;
  background: rgba(102, 112, 133, .12);
  color: var(--muted);
  white-space: nowrap;
  line-height: 1.7;
}
.b-zaishou { background: rgba(14, 147, 132, .13); color: #0B7A6B; }
.b-shouwan { background: rgba(102, 112, 133, .14); color: #5B6472; }
.b-jiangyao { background: rgba(18, 100, 163, .12); color: #1264A3; }
.b-zanting { background: rgba(220, 104, 3, .14); color: #A35300; }
.b-kesou { background: rgba(18, 183, 106, .14); color: #0B8A50; }
.b-yiqian { background: rgba(247, 144, 9, .15); color: #A35300; }
.b-yidengji { background: rgba(240, 68, 56, .13); color: #C42B1C; }
.b-dingjin { background: rgba(238, 70, 188, .13); color: #C11574; }
.b-weina { background: rgba(152, 162, 179, .18); color: #5B6472; }
.b-ok { background: rgba(18, 183, 106, .14); color: #0B8A50; }
.b-warn { background: rgba(220, 104, 3, .14); color: #A35300; }
.b-error { background: rgba(217, 45, 32, .13); color: #C42B1C; }
.b-info { background: rgba(18, 100, 163, .10); color: #1264A3; }
.b-neutral { background: rgba(102, 112, 133, .12); color: var(--muted); }

html[data-theme="dark"] .b-zaishou { background: rgba(50, 213, 131, .16); color: #6FE3B0; }
html[data-theme="dark"] .b-shouwan { background: rgba(152, 162, 179, .16); color: #A7B0BE; }
html[data-theme="dark"] .b-jiangyao { background: rgba(78, 155, 214, .18); color: #9DCBEF; }
html[data-theme="dark"] .b-zanting { background: rgba(233, 162, 59, .18); color: #F3C27F; }
html[data-theme="dark"] .b-kesou { background: rgba(50, 213, 131, .16); color: #6FE3B0; }
html[data-theme="dark"] .b-yiqian { background: rgba(233, 162, 59, .18); color: #F3C27F; }
html[data-theme="dark"] .b-yidengji { background: rgba(249, 112, 102, .18); color: #FCA19A; }
html[data-theme="dark"] .b-dingjin { background: rgba(238, 70, 188, .18); color: #F3A7D9; }
html[data-theme="dark"] .b-weina { background: rgba(152, 162, 179, .16); color: #A7B0BE; }
html[data-theme="dark"] .b-ok { background: rgba(50, 213, 131, .16); color: #6FE3B0; }
html[data-theme="dark"] .b-warn { background: rgba(233, 162, 59, .18); color: #F3C27F; }
html[data-theme="dark"] .b-error { background: rgba(249, 112, 102, .18); color: #FCA19A; }
html[data-theme="dark"] .b-info { background: rgba(78, 155, 214, .18); color: #9DCBEF; }

/* ---------- 覆盖矩阵 ---------- */
.matrix { width: 100%; border-collapse: collapse; font-size: 12px; }
.matrix th, .matrix td { padding: 5px 8px; border-bottom: 1px solid var(--line); text-align: center; }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.matrix thead th { font-size: 11px; font-weight: 600; color: var(--muted); background: var(--panel-2); }
.matrix tbody th { font-weight: 500; white-space: nowrap; }
.matrix tbody tr:hover td { background: var(--table-hover); }
.matrix .cov {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  width: auto;
  height: auto;
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 11px;
  line-height: 1.5;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.matrix .cov.yes { background: rgba(18, 183, 106, .14); color: #0B8A50; }
.matrix .cov.no { color: #B0B7C3; background: transparent; padding: 0; min-width: 19px; }
html[data-theme="dark"] .matrix .cov.yes { color: #6FE3B0; }
html[data-theme="dark"] .matrix .cov.no { color: #5D6B7C; }

/* ---------- 空态 / 提示 ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 26px 16px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: var(--panel-2);
}
.empty-title { font-size: 13px; color: var(--ink); font-weight: 600; }
.empty-hint { font-size: 11.5px; }
.empty-sm { padding: 16px 12px; }

.note {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.6;
}
.note strong { color: var(--ink); font-weight: 600; }
.note-inline { display: inline; }
.note code, .chart-note code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 4px;
}
.mono { font-family: var(--font-mono); font-size: 11.5px; overflow-wrap: anywhere; }
.badge-wrap { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; }

.warn-list { display: flex; flex-direction: column; gap: 8px; }
.warn-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  font-size: 12px;
  line-height: 1.6;
}
.warn-item .badge { flex: 0 0 auto; margin-top: 1px; }
.warn-text { min-width: 0; }
.warn-code { color: var(--muted); font-family: var(--font-mono); font-size: 10.5px; margin-left: 6px; }

/* ---------- 图表挂载 ---------- */
.chart-host { position: relative; min-height: 24px; min-width: 0; }
.chart-host + .chart-host { margin-top: 10px; }
.chart-note { font-size: 11px; color: var(--muted); margin-top: 8px; line-height: 1.55; }
.chart-fallback {
  display: grid;
  place-items: center;
  min-height: 120px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  background: var(--panel-2);
  text-align: center;
  padding: 12px;
}

/* ---------- 度量小卡 ---------- */
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.metric-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  min-width: 0;
}
.metric-label { font-size: 11px; color: var(--muted); line-height: 1.4; }
.metric-value { font-size: 16px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; }
.metric-unit { font-size: 11px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.metric-note { font-size: 10.5px; color: var(--muted); }
.metric.is-best { border-color: rgba(18, 183, 106, .5); }
.metric.is-worst { border-color: rgba(240, 68, 56, .4); }

/* ---------- 对比工作台 ---------- */
.compare-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.compare-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.compare-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.compare-card-title { font-size: 14px; font-weight: 650; }
.compare-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.compare-kpi { min-width: 0; }
.compare-kpi-label { font-size: 10.5px; color: var(--muted); }
.compare-kpi-value { font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.compare-kpi-value.is-best { color: #0B8A50; }
.compare-kpi-value.is-worst { color: #C42B1C; }
html[data-theme="dark"] .compare-kpi-value.is-best { color: #6FE3B0; }
html[data-theme="dark"] .compare-kpi-value.is-worst { color: #FCA19A; }
.compare-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- 抽屉 ---------- */
.drawer-root { position: fixed; inset: 0; z-index: 80; pointer-events: none; }
.drawer-root:empty { display: none; }
.drawer-overlay {
  position: absolute;
  inset: 0;
  background: rgba(16, 24, 40, .34);
  pointer-events: auto;
}
.drawer {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(560px, 94vw);
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 32px rgba(16, 24, 40, .18);
  display: flex;
  flex-direction: column;
  pointer-events: auto;
}
.drawer.is-wide { width: min(880px, 96vw); }
.drawer-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 14px 20px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  flex: 0 0 auto;
}
.drawer-head-main { min-width: 0; flex: 1 1 auto; }
.drawer-title { font-size: 16px; font-weight: 650; line-height: 1.4; overflow-wrap: anywhere; }
.drawer-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.drawer-close { flex: 0 0 auto; }
.drawer-body { padding: 16px 20px 32px; overflow: auto; display: flex; flex-direction: column; gap: 20px; }
.drawer-section { display: flex; flex-direction: column; gap: 8px; }
.drawer-section-title {
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.drawer-section-title::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--line); }
.drawer-empty { font-size: 12px; color: var(--muted); padding: 8px 0; }
.drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 4px; }

/* ---------- 浮动对比条 / toast / 错误 ---------- */
.compare-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 18px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  padding: 6px 10px 6px 14px;
  font-size: 12px;
  max-width: calc(100vw - 32px);
}
.compare-bar .compare-bar-label { color: var(--muted); white-space: nowrap; }
.compare-bar .compare-bar-names { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 200;
  background: var(--ink);
  color: var(--bg);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 12.5px;
  box-shadow: var(--shadow);
  max-width: calc(100vw - 40px);
}

.error-badge {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 300;
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 11.5px;
  font-weight: 600;
  box-shadow: var(--shadow);
}
.error-panel {
  position: fixed;
  top: 42px;
  right: 10px;
  z-index: 300;
  width: min(380px, calc(100vw - 20px));
  max-height: 50vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--danger);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 11.5px;
  box-shadow: var(--shadow);
}
.error-panel h4 { font-size: 12px; margin-bottom: 6px; color: var(--danger); }
.error-panel ol { margin: 0; padding-left: 1.2em; }
.error-panel li + li { margin-top: 4px; }
.error-panel code { font-family: var(--font-mono); font-size: 10.5px; }

/* ---------- 加载 / 致命错误 ---------- */
.boot-placeholder { display: flex; align-items: center; gap: 9px; color: var(--muted); padding: 48px 4px; font-size: 13px; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.fatal { max-width: 760px; margin: 32px auto; }
.fatal-title { font-size: 16px; font-weight: 650; color: var(--danger); margin-bottom: 6px; }
.fatal-body { font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.fatal-body code { font-family: var(--font-mono); background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font-size: 11.5px; }
.fatal-body ol { margin: 8px 0 0; }

/* ---------- 内容排版 ---------- */
.prose { font-size: 13px; line-height: 1.8; }
.prose p + p { margin-top: 8px; }
.prose h4 { font-size: 13px; font-weight: 650; margin: 14px 0 6px; }
.prose ul, .prose ol { margin: 6px 0; }
.prose li + li { margin-top: 3px; }
.prose .kv { color: var(--muted); }
.prose strong { font-weight: 650; }
.about-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

.kv-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.kv-table th, .kv-table td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.kv-table th { color: var(--muted); font-weight: 600; width: 132px; white-space: nowrap; }
.kv-table td { overflow-wrap: anywhere; }

.data-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.data-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--panel-2);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.data-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.data-card-title { font-size: 13px; font-weight: 650; }
.data-card-rows { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.2; }
.data-card-meta { font-size: 10.5px; color: var(--muted); line-height: 1.5; overflow-wrap: anywhere; }

.list-rank { display: flex; flex-direction: column; }
.list-rank-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.list-rank-item:last-child { border-bottom: 0; }
.list-rank-idx { width: 18px; color: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.list-rank-main { flex: 1 1 auto; min-width: 0; }
.list-rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.list-rank-sub { font-size: 10.5px; color: var(--muted); }
.list-rank-value { flex: 0 0 auto; font-variant-numeric: tabular-nums; font-weight: 650; }

.mini-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.mini-kpi { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--panel-2); min-width: 0; }
.mini-kpi-label { font-size: 10.5px; color: var(--muted); }
.mini-kpi-value { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.3; }
.mini-kpi-note { font-size: 10.5px; color: var(--muted); }

/* ---------- 响应式 ---------- */
@media (max-width: 1360px) {
  .cols-kpi { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cols-kpi.cols-kpi-nine { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1200px) {
  .g-2-1, .g-1-2, .g-3-1 { grid-template-columns: minmax(0, 1fr); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .header-inner { gap: 16px; }
  .snapshot-badge { display: none; }
}

@media (max-width: 1024px) {
  .cols-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-kpi.cols-kpi-nine { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .header-inner { padding: 0 16px; gap: 12px; }
  .app-main { padding: 18px 16px 40px; }
  .filterbar-inner { padding: 8px 16px; }
  .filter-note { display: none; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .about-grid { grid-template-columns: minmax(0, 1fr); }
  .brand-sub { display: none; }
  .nav-link { padding: 0 9px; font-size: 13px; }
  .drawer { width: min(520px, 100vw); }
  .drawer.is-wide { width: 100vw; }
}

@media (max-width: 760px) {
  .brand-text { display: none; }
  .kpi-value { font-size: 24px; }
  .card { padding: 13px 14px; }
  .metric-grid, .compare-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mini-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .data-table th, .data-table td { padding: 6px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---------- 打印 ---------- */
@media print {
  :root { --bg: #fff; --panel: #fff; --panel-2: #fff; --shadow: none; }
  .top-shell, .filterbar, .pager, .btn, .seg, .input, .select, .compare-bar,
  .toast, .drawer-root, .error-badge, .error-panel, .th-sort, .icon-btn { display: none !important; }
  body { background: #fff; color: #000; font-size: 11px; }
  .app-main { max-width: none; padding: 0; }
  .card, .kpi, .data-card, .compare-card { box-shadow: none; break-inside: avoid; border-color: #ccc; }
  .table-wrap { max-height: none; overflow: visible; }
  .data-table th { position: static; }
  .app-footer { border-top: 1px solid #ccc; }
}


/* ---------- 新快照提示条（仅 http 模式出现，由自动刷新层写入 data/_version.json 触发） ---------- */
.refresh-banner {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  z-index: 60; display: flex; align-items: center; gap: 12px;
  max-width: min(920px, calc(100vw - 48px));
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); color: var(--ink);
  box-shadow: 0 8px 28px rgba(16, 24, 40, .18);
  font-size: 13px; line-height: 1.5;
}
.refresh-banner .refresh-text { flex: 1; min-width: 0; }
.refresh-banner strong { color: var(--brand); }
.refresh-banner .refresh-close {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 13px; padding: 4px 6px; border-radius: 6px;
}
.refresh-banner .refresh-close:hover { background: var(--panel-2); color: var(--ink); }
html[data-theme="dark"] .refresh-banner { box-shadow: 0 8px 28px rgba(0, 0, 0, .5); }
@media print { .refresh-banner { display: none !important; } }

/* =============================== 全局楼盘搜索（Ctrl+K 命令面板） =============================== */
.search-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(15, 23, 42, .38);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 9vh 16px 40px;
}
.search-overlay[hidden] { display: none; }
.search-box {
  width: min(680px, 96vw); background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 24px 60px rgba(16, 24, 40, .28);
  overflow: hidden;
}
.search-box-head { display: flex; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.search-box-head .input-search { flex: 1; font-size: 15px; padding: 10px 12px; }
.search-results { max-height: min(60vh, 460px); overflow-y: auto; padding: 6px; }
.search-result {
  width: 100%; display: block; text-align: left; border: 0; background: transparent;
  border-radius: 10px; padding: 9px 12px; cursor: pointer; color: var(--ink);
}
.search-result:hover, .search-result.is-active { background: var(--panel-2); }
.search-result-name { font-weight: 650; font-size: 14px; }
.search-result-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.search-empty { padding: 18px 14px; color: var(--muted); font-size: 13px; }
.search-empty strong { color: var(--ink); }
.search-hint { margin: 0; padding: 8px 16px 12px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }
html[data-theme="dark"] .search-overlay { background: rgba(0, 0, 0, .55); }
