:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f0eee8;
  --text: #1c1c1a;
  --muted: #6a6963;
  --border: #e2dfd7;
  --accent: #0f6e4a;
  --accent-soft: #dcefe6;
  --warn: #b4530b;
  --bad: #b3261e;
  --good: #0f7a4a;
  --seq-0: #eef3f0;
  --seq-1: #0f6e4a;
  --empty-land: #e7e4dc;
  --tier-money: #c28a12;
  --tier-firsthand: #2f6fb3;
  --tier-suppressed: #8a4fbf;
  --tier-other: #9a978d;
  --shadow: 0 1px 2px rgba(0,0,0,.04);
}
:root[data-theme="dark"] {
  --bg: #121311; --surface: #1b1c1a; --surface-2: #242522; --text: #ecebe6; --muted: #a2a097;
  --border: #33342f; --accent: #49c08b; --accent-soft: #1d3a2d; --warn: #e39a4b; --bad: #ef6b62; --good: #49c08b;
  --seq-0: #1f2a24; --seq-1: #5fd6a0; --empty-land: #2a2b28;
  --tier-money: #e0b247; --tier-firsthand: #6aa4e6; --tier-suppressed: #b98ae3; --tier-other: #77756d; --shadow: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121311; --surface: #1b1c1a; --surface-2: #242522; --text: #ecebe6; --muted: #a2a097;
    --border: #33342f; --accent: #49c08b; --accent-soft: #1d3a2d; --warn: #e39a4b; --bad: #ef6b62; --good: #49c08b;
    --seq-0: #1f2a24; --seq-1: #5fd6a0; --empty-land: #2a2b28;
    --tier-money: #e0b247; --tier-firsthand: #6aa4e6; --tier-suppressed: #b98ae3; --tier-other: #77756d; --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.55 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); }
button { font: inherit; color: inherit; }
.wrap { max-width: 1320px; margin: 0 auto; padding: 0 16px; }
.en { color: var(--muted); font-weight: 400; font-size: .6em; }
small { color: var(--muted); font-weight: 400; font-size: .78rem; }

/* header */
.top { background: var(--surface); border-bottom: 1px solid var(--border); padding: 16px 0 10px; }
.top-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
h1 { margin: 0; font-size: clamp(1.25rem, 3vw, 1.6rem); line-height: 1.3; }
.sub { margin: 4px 0 0; color: var(--muted); }
.live { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--surface-2); font-size: .85rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.live.ok .dot { background: var(--good); box-shadow: 0 0 0 0 var(--good); animation: pulse 2s infinite; }
.live.warn .dot { background: var(--warn); }
.live.bad .dot { background: var(--bad); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(15,122,74,.5); } 70% { box-shadow: 0 0 0 8px rgba(15,122,74,0); } 100% { box-shadow: 0 0 0 0 rgba(15,122,74,0); } }
@media (prefers-reduced-motion: reduce) { .live.ok .dot { animation: none; } }
.feeds { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.feed { font-size: .75rem; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.feed.ok::before { content: "● "; color: var(--good); }
.feed.warn::before { content: "● "; color: var(--warn); }
.feed.bad::before { content: "● "; color: var(--bad); }
.feed.idle::before { content: "○ "; }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 14px; padding-bottom: 6px;
  position: sticky; top: 0; z-index: 5; background: var(--bg); }
.filters input[type=search], .filters select {
  font: inherit; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); min-width: 0; }
.filters input[type=search] { flex: 1 1 240px; }
.filters select { flex: 0 1 auto; }
.check { display: flex; gap: 6px; align-items: center; color: var(--muted); }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; flex-basis: 100%; }
.crumbs:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px 3px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--text); font-size: .8rem; border: 0; cursor: pointer; }
.chip b { font-weight: 600; }
.chip .x { opacity: .6; padding: 0 4px; }
.chip.clear { background: transparent; color: var(--muted); text-decoration: underline; padding: 3px 4px; }

/* grid */
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding-top: 8px; padding-bottom: 24px; }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
@media (max-width: 1000px) { .grid { grid-template-columns: minmax(0, 1fr); } .span-2 { grid-column: auto; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
h2 { font-size: .98rem; margin: 0; }
.note { color: var(--muted); font-size: .78rem; margin: 6px 0 0; }
.empty { color: var(--muted); font-size: .85rem; padding: 18px 8px; text-align: center; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 3px 10px; font-size: .78rem; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--accent-soft); color: var(--text); }

/* kpis */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow); }
.kpi b { display: block; font-size: 1.5rem; line-height: 1.25; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: .78rem; }
.kpi i { font-style: normal; color: var(--muted); font-size: .72rem; display: block; }

/* charts */
.map svg { width: 100%; height: auto; display: block; }
.map path.land { stroke: var(--surface); stroke-width: .5; cursor: pointer; }
.map path.land.sel { stroke: var(--text); stroke-width: 1.2; }
.legend { display: flex; align-items: center; gap: 8px; font-size: .72rem; color: var(--muted); margin-top: 4px; }
.legend .ramp { width: 120px; height: 8px; border-radius: 4px; }
.bars { display: grid; gap: 4px; }
.bar { display: grid; grid-template-columns: 84px 1fr 36px; align-items: center; gap: 8px; cursor: pointer; border: 0;
  background: transparent; padding: 2px 0; text-align: left; font-size: .82rem; }
.bar .track { height: 14px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--accent); border-radius: 4px; }
.bar.sel { font-weight: 600; }
.bar.dim { opacity: .45; }
.bar .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.matrix { display: grid; grid-template-columns: 52px repeat(4, 1fr); gap: 3px; font-size: .75rem; }
.matrix .lab { color: var(--muted); display: flex; align-items: center; justify-content: center; text-align: center; }
.matrix button.cell { border: 0; border-radius: 6px; aspect-ratio: 1.6; cursor: pointer; font-variant-numeric: tabular-nums;
  font-weight: 600; min-height: 34px; }
.matrix button.cell.sel { outline: 2px solid var(--text); }
.tl svg { width: 100%; display: block; }
.tl rect { cursor: pointer; }
.tl .axis text { fill: var(--muted); font-size: 10px; }
.tl .axis path, .tl .axis line { stroke: var(--border); }
.tiers { display: flex; gap: 12px; flex-wrap: wrap; font-size: .75rem; color: var(--muted); margin-top: 4px; }
.tiers span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; background: var(--c); vertical-align: -1px; }

/* tables */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .82rem; }
.tbl th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl tr.row { cursor: pointer; }
.tbl tr.row:hover td { background: var(--surface-2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .title { min-width: 220px; }
.tbl .title small { display: block; }
.pips { display: inline-flex; gap: 2px; vertical-align: middle; }
.pips i { width: 7px; height: 10px; border-radius: 2px; background: var(--surface-2); }
.pips i.on { background: var(--accent); }
.score { display: inline-block; min-width: 2.2em; text-align: center; padding: 1px 6px; border-radius: 6px; font-weight: 600; background: var(--accent-soft); }
.tag { display: inline-block; font-size: .7rem; padding: 0 6px; border-radius: 999px; background: var(--surface-2); color: var(--muted); margin: 1px 2px 1px 0; white-space: nowrap; }
.tag.new { background: var(--accent); color: var(--surface); }
.t-money { color: var(--tier-money); } .t-firsthand { color: var(--tier-firsthand); } .t-suppressed { color: var(--tier-suppressed); }

/* health */
.src { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: .82rem; }
.src:last-child { border-bottom: 0; }
.src .meta { color: var(--muted); font-size: .74rem; grid-column: 1 / -1; }
.funnel { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 6px 0 10px; text-align: center; font-size: .72rem; color: var(--muted); }
.funnel b { display: block; font-size: 1rem; color: var(--text); font-variant-numeric: tabular-nums; }

/* hypotheses */
.hyp { padding: 10px 0; border-bottom: 1px solid var(--border); }
.hyp:last-child { border-bottom: 0; }
.hyp-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.verdict { font-size: .74rem; padding: 2px 8px; border-radius: 999px; white-space: nowrap; font-weight: 600; }
.v-supported { background: var(--accent-soft); color: var(--good); }
.v-refuted { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }
.v-inconclusive { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.v-insufficient { background: var(--surface-2); color: var(--muted); }
.ci { position: relative; height: 18px; margin: 8px 0 4px; background: var(--surface-2); border-radius: 4px; }
.ci .band { position: absolute; top: 4px; height: 10px; background: color-mix(in srgb, var(--accent) 35%, transparent); border-radius: 3px; }
.ci .pt { position: absolute; top: 2px; width: 2px; height: 14px; background: var(--accent); }
.ci .th { position: absolute; top: -2px; width: 2px; height: 22px; background: var(--text); }
.hyp-meta { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: .74rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.strip { display: flex; gap: 2px; }
.strip i { width: 10px; height: 10px; border-radius: 2px; }
.strip .s-supported { background: var(--good); } .strip .s-refuted { background: var(--bad); }
.strip .s-inconclusive { background: var(--warn); } .strip .s-insufficient { background: var(--surface-2); }

/* stream */
.stream { list-style: none; padding: 0; margin: 0; max-height: 520px; overflow-y: auto; }
.stream li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .82rem; }
.stream li.fresh { animation: flash 2.5s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }
.stream .txt { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.stream .row2 { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: .74rem; margin-top: 2px; }

/* drawer */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface);
  border-left: 1px solid var(--border); transform: translateX(100%); transition: transform .2s ease; z-index: 20;
  display: flex; flex-direction: column; box-shadow: -8px 0 24px rgba(0,0,0,.08); }
.drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { font-size: 1.05rem; }
.drawer-body { overflow-y: auto; padding: 12px 16px 32px; }
.icon { border: 0; background: var(--surface-2); border-radius: 8px; width: 32px; height: 32px; cursor: pointer; flex: none; }
.sig { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.sig h3 { font-size: .92rem; margin: 0 0 4px; }
.sig p { margin: 6px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.sig dl { display: grid; grid-template-columns: max-content 1fr; gap: 3px 10px; margin: 6px 0 0; font-size: .8rem; }
.sig dt { color: var(--muted); }
.sig dd { margin: 0; overflow-wrap: anywhere; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 80px); background: var(--text); color: var(--bg);
  padding: 8px 14px; border-radius: 999px; font-size: .85rem; transition: transform .25s, opacity .25s; z-index: 30; pointer-events: none; opacity: 0; visibility: hidden; }
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
.foot { color: var(--muted); font-size: .76rem; padding-bottom: 40px; }
.tip { position: fixed; pointer-events: none; background: var(--text); color: var(--bg); padding: 6px 10px; border-radius: 8px;
  font-size: .78rem; z-index: 40; max-width: 240px; display: none; }
