:root {
  color-scheme: dark;
  --bg: #0e1218;
  --panel: #161c24;
  --panel-soft: #1b2330;
  --line: #2a3442;
  --line-strong: #3a4656;
  --text: #f4f7f9;
  --muted: #929ca9;
  --teal: #18d49a;
  --cyan: #4bb6ff;
  --amber: #f1b922;
  --red: #ff626b;
  --violet: #b995ff;
  --radius: 6px;
  --header-h: 68px;
  --mono: "DIN Alternate", "Avenir Next Condensed", "Arial Narrow", sans-serif;
  --sans: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  padding-top: var(--header-h);
  color: var(--text);
  background:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.012) 1px, transparent 1px),
    var(--bg);
  background-size: 52px 52px;
  font-family: var(--sans);
  letter-spacing: 0;
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: 3px;
  z-index: 30;
  background: linear-gradient(90deg, var(--teal) 0 38%, var(--amber) 38% 63%, var(--red) 63% 100%);
}

a { color: inherit; text-decoration: none; }

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  height: var(--header-h);
  padding: 0 clamp(18px, 3vw, 46px);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 18, 24, .94);
  backdrop-filter: blur(16px);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 6px; height: 38px; background: var(--teal); box-shadow: 0 0 18px rgba(24,212,154,.3); }
.brand p { margin: 0 0 2px; color: var(--teal); font: 800 9px/1 var(--mono); letter-spacing: 1.5px; }
.brand h1 { margin: 0; font-size: 18px; line-height: 1.1; }
.asof { justify-self: end; color: var(--muted); font: 700 11px/1.3 var(--mono); text-align: right; }

.screen-nav { height: 100%; display: flex; align-items: stretch; }
.screen-nav a {
  min-width: 102px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  font-size: 12px;
  transition: color .18s ease, border-color .18s ease, background .18s ease;
}
.screen-nav a span { font: 800 9px/1 var(--mono); }
.screen-nav a:hover { color: var(--text); background: rgba(255,255,255,.025); }
.screen-nav a.active { color: var(--teal); border-bottom-color: var(--teal); }

main { width: min(1600px, calc(100% - 36px)); margin: 0 auto; }
.screen {
  min-height: calc(100svh - var(--header-h));
  padding: 24px 0 20px;
  display: flex;
  flex-direction: column;
  scroll-margin-top: var(--header-h);
  border-bottom: 1px solid var(--line);
}

.screen-heading { min-height: 40px; margin-bottom: 14px; display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.screen-heading > div { display: flex; align-items: center; gap: 12px; }
.screen-heading span { color: var(--teal); font: 800 10px/1 var(--mono); letter-spacing: 1px; }
.screen-heading h2 { margin: 0; font-size: 23px; line-height: 1; }
.screen-heading p { margin: 0; color: var(--muted); font-size: 11px; text-align: right; }

.panel { min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel-heading { min-height: 56px; padding: 13px 16px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); }
.panel-heading h3 { margin: 0 0 3px; font-size: 14px; }
.panel-heading p, .panel-heading > span { margin: 0; color: var(--muted); font-size: 10px; }

.business-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin-bottom: 12px; background: var(--line); border: 1px solid var(--line); }
.business-kpi { min-height: 96px; padding: 14px 17px; background: var(--panel); }
.business-kpi p { margin: 0 0 10px; color: var(--muted); font-size: 11px; }
.business-kpi strong { display: block; font: 800 clamp(24px, 2.1vw, 34px)/1 var(--mono); }
.business-kpi small { display: block; margin-top: 9px; color: var(--muted); font: 700 10px/1.2 var(--mono); }
.business-kpi small.good { color: var(--teal); }
.business-kpi small.warn { color: var(--amber); }
.business-kpi small.bad { color: var(--red); }

.business-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.42fr) minmax(420px, .9fr); gap: 12px; }
.trend-panel, .quadrant-panel { display: flex; flex-direction: column; }
.legend { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 11px; }
.legend-item { color: var(--muted); font-size: 9px; white-space: nowrap; }
.legend-item::before { content: ""; display: inline-block; width: 14px; height: 2px; margin-right: 5px; vertical-align: middle; background: var(--legend-color); }
#finance-chart { width: 100%; flex: 1; min-height: 280px; }

.quality-strip { min-height: 52px; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }
.quality-item { padding: 9px 14px; border-right: 1px solid var(--line); }
.quality-item:last-child { border-right: 0; }
.quality-item span { display: block; margin-bottom: 3px; color: var(--muted); font-size: 9px; }
.quality-item strong { font: 800 16px/1 var(--mono); }

.quadrant-canvas-wrap { position: relative; flex: 1; min-height: 255px; }
#quadrant-chart { width: 100%; height: 100%; display: block; }
.chart-tooltip { position: absolute; z-index: 3; display: none; min-width: 138px; padding: 8px 10px; pointer-events: none; border: 1px solid var(--line-strong); background: rgba(10,14,20,.94); color: var(--text); font-size: 10px; line-height: 1.6; box-shadow: 0 8px 24px rgba(0,0,0,.35); }

.analysis-list { min-height: 112px; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }
.analysis-item { padding: 10px 12px; border-right: 1px solid var(--line); }
.analysis-item:last-child { border-right: 0; }
.analysis-item span { color: var(--teal); font: 800 9px/1 var(--mono); }
.analysis-item strong { display: block; margin: 5px 0 3px; font-size: 12px; }
.analysis-item p { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.5; }

.benchmark-bar { min-height: 58px; margin-bottom: 12px; padding: 8px 14px; display: flex; align-items: center; justify-content: space-between; gap: 20px; background: rgba(24,212,154,.08); border-left: 3px solid var(--teal); }
.benchmark-bar > div { display: flex; align-items: baseline; gap: 9px; }
.benchmark-bar span, .benchmark-bar small, .benchmark-bar p { color: var(--muted); font-size: 10px; }
.benchmark-bar strong { color: var(--teal); font: 800 25px/1 var(--mono); }
.benchmark-bar p { margin: 0; }

.region-city-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(450px, .78fr) minmax(0, 1.38fr); gap: 12px; }
.ranking-panel { min-height: 0; display: flex; flex-direction: column; }
.table-scroll { min-height: 0; overflow: auto; }
.region-scroll, .city-scroll { flex: 1; }

.rank-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.rank-table thead { position: sticky; top: 0; z-index: 2; }
.rank-table th { height: 39px; padding: 0 10px; color: #dce2e8; background: var(--panel-soft); border-bottom: 1px solid var(--line-strong); text-align: left; font-weight: 700; white-space: nowrap; }
.rank-table td { height: 38px; padding: 0 10px; color: #c3cad3; border-bottom: 1px solid var(--line); white-space: nowrap; }
.rank-table tbody tr:hover { background: #202937; }
.rank-table .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.rank-table .rank { color: var(--muted); font: 800 10px/1 var(--mono); }
.rank-table strong { color: var(--text); }
.metric-main { color: var(--teal) !important; font-weight: 800; }
.metric-weak { color: var(--red) !important; font-weight: 800; }
.delta-up { color: var(--teal) !important; }
.delta-down { color: var(--red) !important; }
.row-bottom { background: rgba(255,98,107,.11); }
.row-bottom td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.status-pill { display: inline-block; padding: 3px 6px; border-radius: 3px; font-size: 8px; font-weight: 800; }
.status-pill.good { color: var(--teal); background: rgba(24,212,154,.1); }
.status-pill.watch { color: var(--amber); background: rgba(241,185,34,.11); }
.status-pill.focus { color: var(--red); background: rgba(255,98,107,.12); }

.people-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.people-panel { min-height: 0; display: flex; flex-direction: column; }
.people-heading { min-height: 64px; padding: 11px 13px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); }
.people-heading h3 { margin: 0 0 4px; font-size: 15px; }
.people-heading p { margin: 0; color: var(--muted); font-size: 10px; }
.dot { display: inline-block; width: 6px; height: 6px; margin-right: 8px; vertical-align: 2px; border-radius: 50%; }
.dot.teal { background: var(--teal); }
.dot.amber { background: var(--amber); }
.search-box { width: min(240px, 42%); display: flex; align-items: center; gap: 7px; padding: 0 9px; border: 1px solid var(--line-strong); background: #10161e; border-radius: 4px; }
.search-box span { color: var(--teal); font-size: 9px; font-weight: 800; }
.search-box input { width: 100%; height: 31px; border: 0; outline: 0; color: var(--text); background: transparent; font: 10px var(--sans); }
.search-box input::placeholder { color: #626d7b; }
.people-scroll { flex: 1; }
.people-table { min-width: 690px; }
.people-table td { height: 37px; }
.people-table canvas { display: block; width: 66px; height: 24px; }

@media (min-width: 1121px) {
  .screen {
    height: calc(100svh - var(--header-h));
    min-height: calc(100svh - var(--header-h));
    overflow: hidden;
  }
  .region-city-grid, .people-grid { overflow: hidden; }
  .ranking-panel, .people-panel { height: 100%; overflow: hidden; }
}

footer { width: min(1600px, calc(100% - 36px)); margin: 0 auto; padding: 16px 0 28px; display: flex; justify-content: space-between; gap: 18px; color: var(--muted); font-size: 9px; }
footer p { margin: 0; }

.loading { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--bg); transition: opacity .25s ease, visibility .25s ease; }
.loading.hidden { opacity: 0; visibility: hidden; }
.loading span { width: 56px; height: 3px; overflow: hidden; background: var(--line); }
.loading span::after { content: ""; display: block; width: 24px; height: 3px; background: var(--teal); animation: loading 1s infinite ease-in-out; }
.loading p { margin-top: 13px; color: var(--muted); font-size: 10px; }
@keyframes loading { from { transform: translateX(-24px); } to { transform: translateX(56px); } }

@media (max-width: 1120px) {
  .topbar { grid-template-columns: 1fr auto; }
  .screen-nav { display: none; }
  .business-grid, .region-city-grid { grid-template-columns: 1fr; }
  .screen { min-height: auto; }
  .trend-panel, .quadrant-panel { min-height: 520px; }
  .ranking-panel { height: 520px; min-height: 520px; }
  .people-grid { grid-template-columns: 1fr; }
  .people-panel { height: 620px; min-height: 620px; }
}

@media (max-width: 680px) {
  html { scroll-snap-type: none; }
  :root { --header-h: 62px; }
  .topbar { padding: 0 13px; }
  .brand p { display: none; }
  .brand h1 { font-size: 16px; }
  .brand-mark { height: 32px; }
  .asof { max-width: 120px; font-size: 9px; }
  main, footer { width: calc(100% - 22px); }
  .screen { padding: 20px 0 24px; }
  .screen-heading { align-items: flex-start; flex-direction: column; gap: 7px; }
  .screen-heading p { text-align: left; }
  .business-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .business-kpi { min-height: 90px; }
  .business-grid { grid-template-columns: 1fr; }
  .trend-panel, .quadrant-panel { min-height: 480px; }
  #finance-chart { min-height: 250px; }
  .analysis-list { grid-template-columns: 1fr; }
  .analysis-item { border-right: 0; border-bottom: 1px solid var(--line); }
  .benchmark-bar { align-items: flex-start; flex-direction: column; }
  .region-city-grid { grid-template-columns: 1fr; }
  .ranking-panel { min-height: 520px; }
  .people-grid { grid-template-columns: 1fr; }
  .people-heading { align-items: stretch; flex-direction: column; }
  .search-box { width: 100%; }
  .people-panel { min-height: 620px; }
  footer { flex-direction: column; }
}

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