:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --text-1: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-wash: rgba(42, 120, 214, 0.10);
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --hl: rgba(237, 161, 0, 0.22);
  --star: #c98500;
  --good: #006300;
  --bad: #c03030;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --text-1: #f0efec;
    --text-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-wash: rgba(57, 135, 229, 0.16);
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --hl: rgba(201, 133, 0, 0.32);
    --star: #eda100;
    --good: #0ca30c;
    --bad: #e66767;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --text-1: #f0efec;
  --text-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;
  --accent-wash: rgba(57, 135, 229, 0.16);
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --hl: rgba(201, 133, 0, 0.32);
  --star: #eda100;
  --good: #0ca30c;
  --bad: #e66767;
  --shadow: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--text-1);
  font: 14px/1.55 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, select, input { font: inherit; color: inherit; }
h2 { font-size: 15px; font-weight: 600; margin: 0; }
h3 { font-size: 14px; font-weight: 600; margin: 0; }

/* ---------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 24px; height: 56px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; white-space: nowrap; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; background: var(--accent);
  mask: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><rect width='32' height='32' rx='7'/></svg>");
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 0;
  background: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><path d='M7 22l6-7 5 4 7-9' stroke='white' stroke-width='3' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>") center/contain no-repeat;
}
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs button {
  border: 0; background: none; padding: 7px 12px; border-radius: 8px; cursor: pointer;
  color: var(--text-2); white-space: nowrap;
}
.tabs button:hover { background: var(--surface-2); color: var(--text-1); }
.tabs button[aria-selected="true"] { background: var(--accent-wash); color: var(--text-1); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.updated { color: var(--muted); font-size: 12px; white-space: nowrap; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; display: grid; place-items: center; color: var(--text-2);
}
.icon-btn:hover { color: var(--text-1); }
.icon-btn svg { width: 16px; height: 16px; }

main { max-width: 1280px; margin: 0 auto; padding: 20px; }
.panel { display: flex; flex-direction: column; gap: 16px; }

/* ---------- cards */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 18px; box-shadow: var(--shadow); min-width: 0;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.more { color: var(--text-2); font-size: 12px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.more:hover { color: var(--text-1); text-decoration: underline; }
.two-col { display: grid; grid-template-columns: 1.35fr 1fr; gap: 16px; }
.chart-lg { height: 320px; }

/* ---------- KPI tiles */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px 8px; box-shadow: var(--shadow); cursor: pointer; text-align: left;
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.kpi:hover { border-color: var(--axis); }
.kpi-label { color: var(--text-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-label .flag { color: var(--muted); margin-right: 4px; }
.kpi-value { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
.kpi-value .unit { font-size: 13px; font-weight: 500; color: var(--text-2); margin-left: 2px; }
.kpi-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.kpi-spark { height: 34px; margin: 4px -4px 0; }
.delta { color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- filters */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: none; padding: 5px 11px; border-radius: 7px; cursor: pointer; color: var(--text-2); font-size: 13px;
}
.seg button.on { background: var(--surface); color: var(--text-1); font-weight: 600; box-shadow: 0 0 0 1px var(--border); }
select, input[type="search"] {
  height: 32px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 0 10px;
}
input[type="search"] { min-width: 220px; flex: 1; max-width: 360px; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; cursor: pointer; }
.count, .hint { color: var(--muted); font-size: 12px; }
.hint { margin: 0; }
.hint:empty { display: none; }

/* ---------- news */
.news-list { list-style: none; margin: 0; padding: 0; }
.news-item { padding: 12px 0; border-top: 1px solid var(--grid); display: grid; grid-template-columns: 44px 1fr; gap: 10px; }
.news-list > .news-item:first-child { border-top: 0; }
.stars { color: var(--star); font-size: 12px; letter-spacing: -1px; padding-top: 2px; white-space: nowrap; }
.stars .off { color: var(--grid); }
.news-title { font-weight: 600; font-size: 15px; line-height: 1.45; text-decoration: none; }
.news-title:hover { text-decoration: underline; text-underline-offset: 3px; }
.imp-3 .news-title { font-size: 15.5px; }
.news-orig { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.news-sum { color: var(--text-2); margin: 4px 0 0; }
.news-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.tag { display: inline-block; padding: 0 7px; border-radius: 5px; background: var(--surface-2); color: var(--text-2); font-size: 11.5px; line-height: 20px; }
.tag.cat { background: var(--accent-wash); color: var(--text-1); }
.tag.ai { border: 1px solid var(--border); background: none; }
mark { background: var(--hl); color: inherit; border-radius: 3px; padding: 0 1px; }
.day-head {
  position: sticky; top: 56px; z-index: 2; background: var(--page);
  padding: 14px 0 6px; font-size: 13px; font-weight: 600; color: var(--text-2);
}
.news-day { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 2px 18px; }
.news-list.compact .news-item { padding: 9px 0; grid-template-columns: 38px 1fr; }
.news-list.compact .news-title { font-size: 14px; }
.news-list.compact .news-sum { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13px; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }

/* ---------- calendar */
.cal-day { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.cal-day + .cal-day { margin-top: 12px; }
.cal-day.past { opacity: 0.78; }
.cal-day-head { padding: 10px 16px; font-weight: 600; display: flex; gap: 10px; align-items: center; border-bottom: 1px solid var(--grid); }
.cal-day-head .today-pill { background: var(--accent); color: #fff; font-size: 11px; padding: 1px 8px; border-radius: 99px; font-weight: 600; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--grid); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th { font-size: 12px; font-weight: 500; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.time { color: var(--text-2); font-variant-numeric: tabular-nums; width: 56px; }
td.region { white-space: nowrap; width: 64px; color: var(--text-2); }
td.stars-cell { width: 52px; }
.beat, .miss { font-size: 11.5px; margin-left: 4px; }
.beat, .miss { color: var(--text-2); } /* 高于预期不一定是好事(如 CPI)，不用红绿 */
.upcoming-row { display: grid; grid-template-columns: 74px 1fr auto; gap: 8px; padding: 7px 0; border-top: 1px solid var(--grid); font-size: 13px; }
.upcoming-row:first-child { border-top: 0; }
.upcoming-row .when { color: var(--muted); font-variant-numeric: tabular-nums; }
.upcoming-row .vals { color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 12px; }

/* ---------- indicator grid */
.group-title { margin-top: 6px; color: var(--text-2); }
.ind-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.ind { padding: 14px 16px 8px; scroll-margin-top: 72px; }
.ind.flash { box-shadow: 0 0 0 2px var(--accent); transition: box-shadow 0.2s; }
.ind-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ind-name { font-weight: 600; font-size: 13.5px; }
.ind-src { font-size: 11.5px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.ind-src:hover { text-decoration: underline; }
.ind-value { font-size: 22px; font-weight: 600; margin-top: 2px; }
.ind-value .unit { font-size: 13px; font-weight: 500; color: var(--text-2); margin-left: 2px; }
.ind-meta { font-size: 12px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.ind-chart { height: 150px; margin: 4px -6px 0; }

.footer { color: var(--muted); font-size: 12px; text-align: center; margin: 28px 0 8px; }
.tooltip-err {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); max-width: 90vw;
  background: var(--surface); border: 1px solid var(--border); padding: 10px 14px; border-radius: 10px; font-size: 13px;
}

@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
  .topbar-inner { gap: 12px; }
  .updated { display: none; }
}
@media (max-width: 640px) {
  main { padding: 16px; }
  .topbar-inner { padding: 0 16px; height: auto; flex-wrap: wrap; padding-top: 8px; }
  .tabs { order: 3; width: 100%; padding-bottom: 6px; }
  .day-head { top: 96px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ind-grid { grid-template-columns: 1fr; }
  input[type="search"] { min-width: 0; max-width: none; width: 100%; }
  td.region, th.region { display: none; }
  .news-day { padding: 2px 14px; }
}
