:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --wash: rgba(11, 11, 11, 0.04);
  --up: #e34948;      /* 流入 / 上涨（A 股习惯：红） */
  --down: #008300;    /* 流出 / 下跌（绿） */
  --up-text: #c42e2e;
  --down-text: #006300;
  --s1: #2a78d6;      /* 宽基 */
  --s2: #eb6834;      /* 行业主题 */
  --accent: #2a78d6;
  --hot: #eb6834;
  --mid: #eda100;
  --cool: #c3c2b7;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --wash: rgba(255, 255, 255, 0.05);
    --up: #e66767;
    --down: #0ca30c;
    --up-text: #f08080;
    --down-text: #2fc02f;
    --s1: #3987e5;
    --s2: #d95926;
    --accent: #3987e5;
    --hot: #d95926;
    --mid: #c98500;
    --cool: #383835;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --wash: rgba(255, 255, 255, 0.05);
  --up: #e66767;
  --down: #0ca30c;
  --up-text: #f08080;
  --down-text: #2fc02f;
  --s1: #3987e5;
  --s2: #d95926;
  --accent: #3987e5;
  --hot: #d95926;
  --mid: #c98500;
  --cool: #383835;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
h1 { font-size: 20px; margin: 0; font-weight: 650; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
h3 { font-size: 13px; margin: 16px 0 4px; font-weight: 600; color: var(--ink-2); }
.sub, .hint { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

.top { position: sticky; top: 0; z-index: 5; background: var(--page); border-bottom: 1px solid var(--border); }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap; }

.seg { display: inline-flex; background: var(--wash); border-radius: 8px; padding: 2px; gap: 2px; }
.seg button {
  border: 0; background: transparent; color: var(--ink-2); font: inherit; font-size: 13px;
  padding: 4px 10px; border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--border); }
.seg button:disabled { opacity: .4; cursor: default; }

main { padding-top: 16px; padding-bottom: 32px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.controls { display: flex; gap: 8px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 > .card { margin-bottom: 16px; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; gap: 0; } }

.chart { width: 100%; height: 420px; }
.chart-md { height: 300px; }
.chart-sm { height: 220px; }

/* 指标卡 */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 860px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.tile .label { color: var(--ink-2); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.tile .label i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.tile .value { font-size: 24px; font-weight: 650; margin-top: 4px; white-space: nowrap; }
.tile .foot { color: var(--muted); font-size: 12px; margin-top: 2px; }
@media (max-width: 420px) { .tile .value { font-size: 19px; } }

.pos { color: var(--up-text); }
.neg { color: var(--down-text); }

/* 表格 */
#q { font: inherit; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--page); color: var(--ink); width: 220px; max-width: 100%; }
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { border-collapse: collapse; width: 100%; min-width: 880px; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 8px; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--surface); }
th:hover { color: var(--ink); }
th.sorted { color: var(--ink); }
th.sorted::after { content: attr(data-dir); margin-left: 2px; }
th.l, td.l { text-align: left; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--wash); }
td .code { color: var(--muted); font-size: 12px; margin-left: 6px; }
td .theme-tag { color: var(--ink-2); }
td .grp { color: var(--muted); font-size: 12px; margin-left: 4px; }

.notes ul { margin: 8px 0 0; padding-left: 18px; color: var(--ink-2); font-size: 13px; }
.notes li { margin: 4px 0; }

dialog {
  width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
  border: 1px solid var(--border); border-radius: 12px; padding: 16px;
  background: var(--surface); color: var(--ink);
}
dialog::backdrop { background: rgba(0, 0, 0, .4); }
.d-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.close { border: 0; background: var(--wash); color: var(--ink); width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 14px; }

.empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--muted); font-size: 13px; text-align: center; padding: 0 16px; }

/* ── 页头：标签页 + 实时状态 ── */
.tabs { display: inline-flex; gap: 4px; }
.tabs button {
  border: 0; background: transparent; color: var(--ink-2); font: inherit; font-size: 14px;
  padding: 6px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.tabs button:hover { background: var(--wash); color: var(--ink); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--border); }
.bar-row { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.sub { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.live-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.live-badge i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; }
.live-badge.live i { background: var(--up); animation: pulse 2s infinite; }
.live-badge.live { color: var(--ink); }
.live-badge.warn i { background: var(--mid); }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .live-badge.live i { animation: none; } }

/* ── 国家队结论卡 ── */
.verdict { position: relative; overflow: hidden; padding-left: 20px; }
.verdict::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--cool); }
.verdict.hot::before { background: var(--hot); }
.verdict.mid::before { background: var(--mid); }
.v-label { font-size: 12px; color: var(--muted); }
.v-title { font-size: 28px; font-weight: 700; margin: 6px 0 4px; }
.verdict.cool .v-title { color: var(--ink-2); }
.v-reason { margin: 0; color: var(--ink-2); max-width: 820px; }
.v-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--grid); border: 1px solid var(--grid); border-radius: 8px; overflow: hidden; margin-top: 16px; }
.v-grid > div { background: var(--surface); padding: 12px 14px; min-width: 0; }
.v-grid .k { font-size: 12px; color: var(--muted); }
.v-grid .v { font-size: 20px; font-weight: 650; margin-top: 2px; white-space: nowrap; }
.v-grid .n { font-size: 12px; color: var(--muted); margin-top: 2px; }
.meter { height: 6px; border-radius: 3px; background: var(--wash); margin-top: 8px; overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 3px; background: var(--hot); }
.v-caveat { margin-top: 12px; }
@media (max-width: 860px) { .v-grid { grid-template-columns: repeat(2, 1fr); } .v-title { font-size: 23px; } }
.th-sub { font-size: 11px; color: var(--muted); font-weight: 400; }
tr.total td { font-weight: 600; border-top: 1px solid var(--axis); background: var(--wash); }
tr.total { cursor: default; }
.ratio-hot { color: var(--ink); font-weight: 650; }
