:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --wash: rgba(11, 11, 11, 0.04);
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --good-text: #006300;
  --bad-text: #d03b3b;
  --shadow: 0 6px 24px rgba(11, 11, 11, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --wash: rgba(255, 255, 255, 0.05);
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --good-text: #0ca30c;
    --bad-text: #e66767;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --text: #ffffff;
  --text-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --wash: rgba(255, 255, 255, 0.05);
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --good-text: #0ca30c;
  --bad-text: #e66767;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

h2, h3 { margin: 0; font-size: 15px; font-weight: 600; }
p { margin: 0; }
button { font: inherit; color: inherit; }

.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 20px;
  padding: 12px 24px;
  background: var(--page);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 650; font-size: 16px; white-space: nowrap; }
.tag { margin-left: 8px; font-size: 12px; font-weight: 400; color: var(--text-2); }

.ghost {
  border: 1px solid var(--border); background: transparent; border-radius: 8px;
  padding: 5px 10px; cursor: pointer; color: var(--text-2); white-space: nowrap;
}
.ghost:hover { background: var(--wash); color: var(--text); }
.ghost.small { padding: 2px 8px; font-size: 12px; }
:focus-visible { outline: 2px solid var(--s1); outline-offset: 2px; }

main { max-width: 1240px; margin: 0 auto; padding: 20px 24px 56px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.page { display: grid; gap: 16px; min-width: 0; }
.spacer { flex: 1; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; min-width: 0; margin: 0;
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.sub { color: var(--text-2); font-size: 12.5px; margin-top: 2px; }
.section { font-size: 17px; margin-top: 12px; }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid2 > * { min-width: 0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.kpi .label { color: var(--text-2); font-size: 12.5px; }
.kpi .value { font-size: 26px; font-weight: 600; line-height: 1.3; margin-top: 2px; }
.kpi .note { color: var(--muted); font-size: 12px; }

.callout {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--axis);
  border-radius: 8px; padding: 12px 16px; color: var(--text); line-height: 1.7;
}
.callout b { font-weight: 600; }

.table-wrap { overflow-x: auto; }
.scroll-y { max-height: 420px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; color: var(--text-2); font-weight: 500; font-size: 12px;
  padding: 6px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap;
  position: sticky; top: 0; background: var(--surface);
}
td { padding: 7px 8px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.q { max-width: 420px; }
td.nowrap { white-space: nowrap; }
td .n { display: block; font-size: 11px; }
.muted { color: var(--muted); }
.dim { color: var(--text-2); }
.pos { color: var(--good-text); }
.neg { color: var(--bad-text); }
.pill {
  display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px;
  background: var(--wash); color: var(--text-2); white-space: nowrap;
}

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key-line { display: inline-block; width: 14px; height: 2px; border-radius: 1px; }
.key-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.key-rect { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }

.chart .plot { width: 100%; min-height: 40px; }

.bars { display: grid; gap: 4px; }
.bar-row {
  display: grid; grid-template-columns: minmax(90px, 38%) 1fr; align-items: center; gap: 10px;
  padding: 3px 4px; border-radius: 6px; cursor: default;
}
.bar-row:hover, .bar-row:focus-visible { background: var(--wash); }
.bar-label { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar { height: 14px; border-radius: 0 4px 4px 0; background: var(--s1); min-width: 2px; }
.bar-value { font-size: 12px; color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }


.empty { color: var(--text-2); padding: 20px 8px; text-align: center; }
.empty code, code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px;
  background: var(--wash); padding: 1px 6px; border-radius: 4px;
}
.loading { opacity: 0.55; transition: opacity 0.2s; }
.error { color: var(--bad-text); font-size: 12.5px; }

#tooltip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
  padding: 8px 10px; font-size: 12px; max-width: 300px;
}
#tooltip .tip-title { color: var(--text-2); margin-bottom: 4px; }
#tooltip .tip-row { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
#tooltip .tip-row strong { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
#tooltip .tip-label { color: var(--text-2); }

@media (max-width: 900px) {
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .top { padding: 10px 16px; gap: 10px; flex-wrap: wrap; }
  main { padding: 14px 16px 40px; }
  .kpi .value { font-size: 22px; }
  td.q { max-width: 220px; }
}
