/* Home (scan) page: base layout, R1 fluid layout and Z1 enlarged chart; the /lab pages keep
   the R2/R3 and Z2/Z3 alternatives on the same markup. No inline styles (CSP): geometry
   comes from scan.js through element.style. */
:root {
  --bg: #0a1017; --bg-2: #0d141c; --panel: #101922; --panel-2: #141f2a; --panel-3: #1b2836;
  --line: #1a2633; --line-2: #243444; --text: #e3ecf4; --text-2: #b3c2d0; --muted: #8295a7; --faint: #536679;
  --ice: #7dd3fc; --ice-soft: rgba(125, 211, 252, .12);
  --up: #34d399; --up-soft: rgba(52, 211, 153, .13); --down: #fb7185; --down-soft: rgba(251, 113, 133, .13);
  --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, .1); --neutral: #6aa8ff; --gray: #8391a0;
  --tick: "DIN Condensed", "DIN Alternate", "Avenir Next Condensed", "PingFang SC", sans-serif;
  --num: "DIN Alternate", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  --ui: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --bar: 56px;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body { display: grid; grid-template-rows: var(--bar) 1fr; grid-template-columns: minmax(0, 1fr); overflow: hidden; color: var(--text); font: 13px/1.5 var(--ui);
  background: radial-gradient(1100px 380px at 18% -120px, rgba(125, 211, 252, .07), transparent 70%), var(--bg); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; text-align: left; }
button:focus-visible, input:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--ice); outline-offset: 2px; }
a { color: var(--ice); text-decoration: none; }
::selection { background: rgba(125, 211, 252, .28); }
.up, .dir-positive { color: var(--up); } .down, .dir-negative { color: var(--down); } .dir-mixed { color: var(--warn); }
.dir-neutral { color: var(--neutral); } .dir-unassessed { color: var(--gray); } .muted { color: var(--muted); }
[hidden] { display: none !important; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { flex-shrink: 0; }

/* ---------- Top bar ---------- */
.top { position: relative; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--line); background: rgba(10, 16, 23, .72); backdrop-filter: blur(12px); }
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); font: 600 15px var(--ui); white-space: nowrap; }
.logo { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid rgba(125, 211, 252, .28); border-radius: 8px; background: linear-gradient(140deg, #14344b, #0c1d2b); }
.logo svg { width: 17px; height: 17px; fill: none; stroke: var(--ice); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.brand small { padding-left: 9px; border-left: 1px solid var(--line-2); color: var(--muted); font-size: 12.5px; font-weight: 400; }
.mkts { display: flex; gap: 6px; min-width: 0; }
.mkt { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px 0 8px; border: 1px solid var(--line-2); border-radius: 999px; color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.mkt i { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.mkt b { color: var(--text-2); font-weight: 500; }
.mkt.live { border-color: rgba(52, 211, 153, .32); background: rgba(52, 211, 153, .06); }
.mkt.live i { background: var(--up); animation: pulse 2.2s ease-out infinite; }
.mkt.live > span:not(.at) { color: var(--up); }
.mkt.small { height: 22px; margin-top: 8px; font-size: 11px; }
.mkt.small:empty { display: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, .55); } 70%, 100% { box-shadow: 0 0 0 6px rgba(52, 211, 153, 0); } }
.brk { display: none; }
.search { display: flex; align-items: center; gap: 8px; width: clamp(210px, 21vw, 320px); height: 34px; margin-left: auto; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--panel); transition: border-color .15s, box-shadow .15s; }
.search:focus-within { border-color: rgba(125, 211, 252, .6); box-shadow: 0 0 0 3px rgba(125, 211, 252, .12); }
.search svg { width: 15px; height: 15px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: 13px var(--ui); }
.search input::placeholder { color: var(--faint); }
.search input::-webkit-search-cancel-button { filter: invert(.6); }
.search kbd { padding: 0 5px; border: 1px solid var(--line-2); border-radius: 4px; color: var(--muted); font: 11px/16px var(--num); }
.status { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.status i.ok { background: var(--up); } .status i.bad { background: var(--down); }
.actions { display: flex; gap: 6px; }
.tbtn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 11px; border: 1px solid var(--line-2); border-radius: 9px; color: var(--text-2); font-size: 12.5px; white-space: nowrap; transition: border-color .15s, background .15s, color .15s; }
.tbtn:hover { border-color: rgba(125, 211, 252, .5); background: var(--panel-2); color: var(--text); }
.tbtn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tbtn.icon { width: 32px; padding: 0; font-weight: 600; }
#openStats { color: var(--ice); }

/* ---------- Layout ---------- */
.main { display: grid; grid-template-columns: minmax(0, 1fr) 500px; min-height: 0; }
/* Table columns drop by priority as the board narrows (container queries below). */
.board { container: board / inline-size; display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 14px 18px 16px; }

/* KPI cards double as quick filters. */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpis button { display: flex; flex-direction: column; min-width: 0; padding: 10px 13px 11px; border: 1px solid var(--line); border-radius: 12px; background: linear-gradient(180deg, var(--panel-2), var(--panel)); transition: border-color .15s, transform .15s, box-shadow .15s; }
.kpis button:hover { border-color: var(--line-2); transform: translateY(-1px); }
.kpis button.on { border-color: rgba(125, 211, 252, .6); box-shadow: inset 0 0 0 1px rgba(125, 211, 252, .2), 0 8px 24px -14px rgba(125, 211, 252, .55); }
.kpis small { overflow: hidden; color: var(--muted); font-size: 11.5px; white-space: nowrap; text-overflow: ellipsis; }
.kpis strong { display: flex; align-items: baseline; gap: 5px; margin-top: 3px; font: 400 26px/1.05 var(--tick); white-space: nowrap; }
.kpis strong em { font-style: normal; }
.kpis strong span { color: var(--muted); font: 11.5px var(--num); }
.kpis strong span.up { color: var(--up); } .kpis strong span.down { color: var(--down); }
.kbar { display: flex; height: 4px; margin-top: 9px; overflow: hidden; border-radius: 2px; background: var(--line); }
.kbar i { min-width: 0; }
.k-up { background: var(--up); } .k-down { background: var(--down); } .k-warn { background: var(--warn); }
.k-ice { background: var(--ice); } .k-gray { background: #5b6f82; } .k-rest { background: #223140; }

/* Skeletons while the first response loads. */
.skel { border-radius: 10px; background: linear-gradient(90deg, var(--panel) 0, var(--panel-3) 40%, var(--panel) 80%) 0 0 / 200% 100%; animation: shimmer 1.3s linear infinite; }
.skel.kpi { height: 72px; border-radius: 12px; }
.skel.line { height: 30px; margin: 12px 16px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.seg { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.seg button { padding: 4px 10px; border-radius: 7px; color: var(--muted); font-size: 12.5px; white-space: nowrap; transition: color .12s, background .12s; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--panel-3); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .35); }
.seg b { margin-left: 5px; color: var(--faint); font: 400 11.5px var(--num); }
.seg button.on b { color: var(--ice); }
.key { display: flex; align-items: center; gap: 5px; margin-left: auto; color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.key b { margin-right: 2px; font-weight: 500; }
.keyHelp { display: grid; place-items: center; width: 18px; height: 18px; margin-left: 2px; border: 1px solid var(--line-2); border-radius: 50%; color: var(--muted); font: 600 10.5px var(--num); text-align: center; }
.keyHelp:hover { border-color: var(--ice); color: var(--ice); }

/* ---------- Table ---------- */
.table { flex: 1; min-height: 0; overflow: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .025); scrollbar-width: thin; scrollbar-color: #2a3a4b transparent; }
.thead, .tr { display: flex; align-items: center; gap: 10px; padding: 0 16px; }
/* Columns are sized by class so any of them can be hidden without re-flowing the rest. */
.c-sym { flex: 0 0 132px; min-width: 0; } .c-price { flex: 0 0 84px; } .c-chg { flex: 0 0 78px; } .c-spark { flex: 0 0 88px; }
.c-pos { flex: 0 0 120px; } .c-t1, .c-t4 { flex: 0 0 30px; } .c-news { flex: 0 0 104px; } .c-conf { flex: 0 0 114px; }
.c-head { display: none; flex: 1 1 0; min-width: 0; overflow: hidden; color: var(--text-2); font-size: 12.5px; white-space: nowrap; text-overflow: ellipsis; }
.c-head time, .sub time { margin-right: 8px; color: var(--faint); font: 11px var(--num); }
.thead { position: sticky; top: 0; z-index: 2; height: 46px; border-bottom: 1px solid var(--line); background: rgba(17, 26, 36, .94); backdrop-filter: blur(8px); color: var(--muted); font-size: 11.5px; line-height: 1.3; }
.thead button { color: inherit; font-size: 11.5px; line-height: 1.3; transition: color .12s; }
.thead button:hover { color: var(--text); }
.thead small { display: block; color: var(--faint); font-size: 10.5px; white-space: nowrap; }
.thead .sorted { color: var(--ice); }
.thead .sorted.asc::before { content: "↑ "; } .thead .sorted.desc::before { content: "↓ "; }
.thead .numc { text-align: right; }
.thead .c-t1, .thead .c-t4 { text-align: center; }
.row { border-bottom: 1px solid var(--line); cursor: pointer; transition: background .12s; }
.row:last-child { border-bottom: 0; }
.row:hover { background: rgba(255, 255, 255, .025); }
.row.on { background: linear-gradient(90deg, rgba(125, 211, 252, .11), rgba(125, 211, 252, .03) 55%, transparent); box-shadow: inset 3px 0 0 var(--ice); }
.tr { height: 46px; }
.sym b { display: block; font: 400 19px/1 var(--tick); letter-spacing: .01em; }
.sym small { display: block; margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.numc { font: 13.5px var(--num); font-variant-numeric: tabular-nums; text-align: right; }
.c-price { border-radius: 5px; }
.flash-up { animation: flashUp 1.8s ease-out; } .flash-down { animation: flashDown 1.8s ease-out; }
@keyframes flashUp { from { background: rgba(52, 211, 153, .3); } to { background: transparent; } }
@keyframes flashDown { from { background: rgba(251, 113, 133, .3); } to { background: transparent; } }
.c-chg { display: flex; justify-content: flex-end; }
.chg { min-width: 66px; padding: 2px 7px; border-radius: 6px; background: rgba(131, 145, 160, .1); color: var(--muted); font: 500 12.5px/18px var(--num); font-variant-numeric: tabular-nums; text-align: right; }
.chg.up { background: var(--up-soft); color: var(--up); } .chg.down { background: var(--down-soft); color: var(--down); }
.spark polyline { fill: none; stroke-width: 1.4; stroke-linejoin: round; stroke-linecap: round; }
.spark .area { stroke: none; }
.spark .up { stroke: var(--up); } .spark .down { stroke: var(--down); }
.rngWrap { display: flex; align-items: center; gap: 8px; }
.rng { position: relative; flex: 1; height: 4px; border-radius: 2px; background: linear-gradient(90deg, rgba(251, 113, 133, .6), rgba(83, 102, 121, .55) 50%, rgba(52, 211, 153, .6)); }
.rng i { position: absolute; top: -3px; width: 10px; height: 10px; margin-left: -4px; border-radius: 50%; background: var(--text); box-shadow: 0 0 0 2px var(--panel), 0 1px 4px rgba(0, 0, 0, .5); }
.rngWrap span { width: 32px; color: var(--muted); font: 11.5px var(--num); text-align: right; }
.arrow { display: grid; place-items: center; height: 22px; border-radius: 6px; font-size: 14px; }
.trend-up { color: var(--up); } .trend-down { color: var(--down); } .trend-flat { color: var(--muted); }
.arrow.trend-up { background: var(--up-soft); } .arrow.trend-down { background: var(--down-soft); } .arrow.trend-flat { background: rgba(131, 145, 160, .1); }
.c-news { display: flex; flex-direction: column; gap: 4px; }
.ncount { display: flex; align-items: baseline; gap: 6px; color: var(--muted); font: 11px var(--num); }
.ncount b { color: var(--text); font: 500 13px var(--num); }
.ncount.none { color: var(--faint); }
.nbar { display: flex; height: 4px; overflow: hidden; border-radius: 2px; }
.nbar i:nth-child(1) { background: var(--up); } .nbar i:nth-child(2) { background: var(--down); } .nbar i:nth-child(3) { background: #5b6f82; }
/* Confirmation pills: only "met" is solid, so a column of waiting rows stays calm. */
.conf { display: flex; gap: 3px; }
.conf i, .key i { display: inline-grid; place-items: center; min-width: 23px; height: 19px; padding: 0 4px; border: 1px solid transparent; border-radius: 5px; font: normal 600 10.5px/1 var(--num); }
.key i { padding: 0 6px; font-family: var(--ui); font-weight: 500; }
.conf i.met, .key i.met { background: var(--up); color: #052016; }
.conf i.pending, .key i.pending { border-color: #34475a; color: #8fa3b6; }
.conf i.conflict, .key i.conflict { border-color: rgba(251, 113, 133, .5); background: var(--down-soft); color: var(--down); }
.conf i.unavailable, .key i.unavailable { border: 1px dashed #33475b; color: var(--faint); }
.sub { margin-top: -7px; padding: 0 16px 8px 158px; overflow: hidden; color: var(--text-2); font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.dot { display: inline-block; width: 6px; height: 6px; margin: 0 7px 1px 0; border-radius: 50%; background: var(--gray); vertical-align: middle; }
.dot.dir-positive { background: var(--up); } .dot.dir-negative { background: var(--down); } .dot.dir-mixed { background: var(--warn); } .dot.dir-neutral { background: var(--neutral); }
.sub .none, .c-head .none { color: var(--faint); }
.compact .sub { display: none; }
.compact .tr { height: 40px; }
.empty { display: grid; place-items: center; gap: 12px; padding: 48px 20px; color: var(--muted); text-align: center; }
.ghost { padding: 5px 14px; border: 1px solid var(--line-2); border-radius: 8px; color: var(--ice); font-size: 12.5px; }
.ghost:hover { border-color: var(--ice); }

/* ---------- Drawer ---------- */
.drawer { container: drawer / inline-size; display: flex; flex-direction: column; min-height: 0; overflow: auto; border-left: 1px solid var(--line); background: var(--bg-2); scrollbar-width: thin; scrollbar-color: #2a3a4b transparent; }
/* The drawer scrolls; its children must keep their own height (the chart would collapse). */
.drawer > * { flex-shrink: 0; }
.drawer.swap > :not(.dh) { animation: rise .28s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.dh { position: sticky; top: 0; z-index: 6; display: flex; align-items: flex-start; gap: 12px; padding: 16px 20px 13px; border-bottom: 1px solid var(--line); background: rgba(13, 20, 28, .94); backdrop-filter: blur(10px); }
.who { flex: 1; min-width: 0; }
.who > b { font: 400 36px/1 var(--tick); letter-spacing: .01em; }
.dh .name { margin-top: 4px; overflow: hidden; color: var(--muted); font-size: 12.5px; white-space: nowrap; text-overflow: ellipsis; }
.dh .px { flex-shrink: 0; text-align: right; }
.dh .px strong { display: block; font: 500 26px/1.1 var(--num); font-variant-numeric: tabular-nums; }
#dChg { display: inline-block; margin-top: 5px; padding: 1px 8px; border-radius: 6px; font: 500 12.5px/20px var(--num); }
#dChg.up { background: var(--up-soft); } #dChg.down { background: var(--down-soft); }
.dh .px small { display: block; margin-top: 5px; color: var(--faint); font: 11px var(--ui); }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 14px 20px 0; }
.metrics > div { min-width: 0; padding: 9px 11px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.metrics small { display: block; overflow: hidden; color: var(--muted); font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.metrics strong { display: block; margin-top: 2px; font: 500 15px var(--num); white-space: nowrap; }
.metrics .rng { margin-top: 8px; height: 3px; }
.metrics .rng i { top: -3px; width: 9px; height: 9px; box-shadow: 0 0 0 2px var(--panel); }
.ctl { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 20px 0; }
.tf { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); }
.tf button { padding: 3px 10px; border-radius: 6px; color: var(--muted); font: 12px var(--num); transition: color .12s, background .12s; }
.tf button:hover { color: var(--text); }
.tf button.on { background: var(--panel-3); color: var(--ice); }
.expand { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border: 1px solid rgba(125, 211, 252, .35); border-radius: 9px; background: var(--ice-soft); color: var(--ice); font-size: 12.5px; transition: background .15s, border-color .15s; }
.expand:hover { border-color: var(--ice); background: rgba(125, 211, 252, .2); }
.expand svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 10px 20px 0; color: var(--muted); font-size: 11.5px; }
.legend span::before { content: "N"; display: inline-grid; place-items: center; width: 15px; height: 15px; margin-right: 4px; border: 1.5px solid currentColor; border-radius: 50%; font: 700 8.5px/1 var(--num); vertical-align: -3px; }
.legend em { margin-left: auto; color: var(--faint); font-style: normal; }
.chartBox { position: relative; height: clamp(260px, 32vh, 520px); margin: 6px 8px 0 14px; }
.chartBox svg { display: block; }
.chartBox .mk, .chartBox .flag { cursor: pointer; }
.chartBox .mk circle { stroke-width: 1.6; }
.chartBox .mk:hover circle { stroke-width: 2.6; }
.chartBox .mk.on circle { stroke-width: 3; }
.chartBox .more-mk { fill: var(--muted); }
.chartBox.interactive { cursor: grab; touch-action: none; }
.chartBox.interactive:active { cursor: grabbing; }
.chartMsg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.tip { position: absolute; z-index: 3; padding: 7px 10px; border: 1px solid var(--line-2); border-radius: 9px; background: rgba(9, 14, 20, .94); box-shadow: 0 12px 30px -12px #000; font: 11.5px/1.6 var(--num); white-space: nowrap; pointer-events: none; }
.chartNote { padding: 4px 20px 0; color: var(--faint); font-size: 11px; }
.section { padding: 20px 20px 0; }
.section h2 { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .12em; }
.section h2 small { display: flex; align-items: center; gap: 12px; font-size: 11.5px; font-weight: 400; letter-spacing: 0; }
.linkBtn { color: var(--ice); font-size: 11.5px; }
.linkBtn:hover { text-decoration: underline; }
.steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 6px; }
.step { position: relative; min-width: 0; padding-top: 22px; color: var(--muted); font-size: 11.5px; }
.step::before { content: ""; position: absolute; top: 6px; left: 16px; right: -4px; height: 2px; border-radius: 1px; background: var(--line-2); }
.step:last-child::before { display: none; }
.step::after { content: ""; position: absolute; top: 0; left: 0; width: 14px; height: 14px; border: 2px solid var(--faint); border-radius: 50%; background: var(--bg-2); color: #052016; font: 700 9px/10px var(--num); text-align: center; }
.step.met::before { background: rgba(52, 211, 153, .45); }
.step.met::after { content: "✓"; border-color: var(--up); background: var(--up); }
.step.pending::after { border-color: #6b8197; }
.step.conflict::after { border-color: var(--down); background: var(--down); }
.step.unavailable::after { border-style: dashed; }
.step b { display: block; color: var(--text); font-size: 12.5px; font-weight: 500; }
.step span { display: block; margin-top: 1px; }
.step.met span { color: var(--up); } .step.pending span { color: var(--muted); } .step.conflict span { color: var(--down); } .step.unavailable span { color: var(--faint); }
.step p { display: none; margin-top: 4px; color: var(--faint); font-size: 11px; line-height: 1.5; }
.steps.details .step p { display: block; }
.plan { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--muted); font-size: 12.5px; line-height: 1.75; }
.plan b { color: var(--text); font-weight: 500; }
.news { padding-bottom: 4px; }
.nday { margin: 14px 0 4px 8px; color: var(--faint); font-size: 11px; font-weight: 600; letter-spacing: .08em; }
.nday:first-child { margin-top: 0; }
.n { border-radius: 10px; }
.n > button { display: grid; grid-template-columns: 3px minmax(0, 1fr); gap: 11px; width: 100%; padding: 9px 10px 9px 8px; border-radius: 10px; transition: background .12s; }
.n > button:hover { background: rgba(255, 255, 255, .03); }
.n > button > i { border-radius: 2px; background: var(--gray); }
.n > button > i.dir-positive { background: var(--up); } .n > button > i.dir-negative { background: var(--down); }
.n > button > i.dir-mixed { background: var(--warn); } .n > button > i.dir-neutral { background: var(--neutral); }
.n time { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--faint); font: 11px var(--num); }
.n .src { min-width: 0; overflow: hidden; color: var(--muted); font-family: var(--ui); white-space: nowrap; text-overflow: ellipsis; }
.badge { flex-shrink: 0; padding: 1px 6px; border-radius: 5px; background: rgba(131, 145, 160, .12); font: 500 10.5px/16px var(--ui); }
.badge.dir-positive { background: var(--up-soft); } .badge.dir-negative { background: var(--down-soft); } .badge.dir-mixed { background: var(--warn-soft); }
.badge.dup { margin-left: -2px; background: rgba(125, 211, 252, .1); color: var(--ice); }
.zCard .badge { margin-left: 8px; }
.n h3 { margin-top: 3px; color: var(--text); font-size: 13px; font-weight: 500; line-height: 1.55; }
.n.on { background: rgba(125, 211, 252, .06); }
.n .more { padding: 0 12px 12px 22px; color: #a9bccd; font-size: 12.5px; line-height: 1.65; }
.n .more p { margin-bottom: 6px; }
.n .more .why, .zCard .why { padding-left: 9px; border-left: 2px solid var(--line-2); color: var(--muted); }
.n .links, .zCard .links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; font-size: 12px; }
.n .links a, .zCard .links a { padding: 2px 8px; border: 1px solid var(--line-2); border-radius: 6px; }
.n .links a:hover, .zCard .links a:hover { border-color: var(--ice); }
.disclaimer { padding: 16px 20px 20px; color: var(--faint); font-size: 11px; line-height: 1.6; }
.back { display: none; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--panel); }
.back svg { width: 18px; height: 18px; fill: none; stroke: var(--text); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Overlays: enlarged chart, statistics, help ---------- */
.zoom { position: fixed; inset: 0; z-index: 60; padding: 2vh 2vw; background: rgba(4, 8, 12, .72); backdrop-filter: blur(4px); animation: fade .16s ease-out; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.99); } }
.zoomPanel { display: flex; flex-direction: column; height: 100%; overflow: hidden; border: 1px solid var(--line-2); border-radius: 16px; background: var(--bg-2); box-shadow: 0 30px 80px -20px #000; animation: pop .2s ease-out; }
.zoomHead { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.zoomHead b { font: 400 28px/1 var(--tick); }
.zoomHint { margin-left: auto; color: var(--faint); font-size: 11px; }
.zoomClose { flex-shrink: 0; width: 32px; height: 32px; margin-left: auto; border: 1px solid var(--line-2); border-radius: 9px; background: var(--panel); color: var(--muted); font-size: 14px; text-align: center; }
.zoomClose:hover { border-color: var(--ice); color: var(--text); }
.zoomHint + .zoomClose { margin-left: 0; }
.zoomBody { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.zoom[data-variant="z1"] .zoomBody { grid-template-columns: minmax(0, 1fr) clamp(320px, 26vw, 440px); }
.zoomMain { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 10px 10px 10px 16px; }
.zoomChart { position: relative; flex: 1; min-height: 240px; }
.zoomTip { padding-top: 4px; color: var(--faint); font-size: 11px; }
.zoomSide { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); }
.zDetail { max-height: 58%; overflow: auto; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.zEmpty { font-size: 12px; }
.zList { flex: 1; min-height: 0; overflow: auto; padding: 6px 12px 12px; scrollbar-width: thin; scrollbar-color: #2a3a4b transparent; }
.zList h4 { padding: 6px 4px; color: var(--muted); font-size: 11px; font-weight: 500; }
.zItem { display: grid; grid-template-columns: 30px 1fr; gap: 6px; width: 100%; padding: 8px 6px; border-radius: 8px; font-size: 12.5px; line-height: 1.5; transition: background .12s; }
.zItem:hover { background: rgba(255, 255, 255, .03); }
.zItem.on { background: rgba(125, 211, 252, .1); }
.zItem time { display: block; color: var(--faint); font: 10.5px var(--num); }
.num { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-right: 6px; padding: 0 4px; border: 1.5px solid currentColor; border-radius: 10px; font: 600 10px var(--num); }
.zCard time { display: flex; align-items: center; color: var(--muted); font: 11px var(--num); }
.zCard h3 { margin: 6px 0; font-size: 15px; font-weight: 600; line-height: 1.5; }
.zCard p { margin-bottom: 6px; color: #a9bccd; font-size: 12.5px; }
.obs { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--panel); color: var(--muted); font-size: 12px; }
.obs b { color: var(--text); font: 500 13px var(--num); }
.obs b.up { color: var(--up); } .obs b.down { color: var(--down); }
.obs em { width: 100%; color: var(--faint); font-size: 10.5px; font-style: normal; }
.callout { position: absolute; z-index: 5; max-height: 72%; overflow: auto; padding: 12px 14px; border: 1px solid rgba(125, 211, 252, .33); border-radius: 12px; background: rgba(11, 17, 24, .96); box-shadow: 0 16px 40px -10px #000; }
.calloutNav { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; color: var(--muted); font-size: 12px; }
.calloutNav button { padding: 3px 10px; border: 1px solid var(--line); border-radius: 6px; }
.calloutNav button:disabled { opacity: .35; cursor: default; }
.minimap { height: 48px; margin-top: 8px; margin-right: 56px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; touch-action: none; }
.minimap .brush { fill: rgba(125, 211, 252, .13); stroke: var(--ice); }
.lane { position: relative; height: 26px; margin-right: 56px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.laneDot { position: absolute; top: 6px; width: 12px; height: 12px; border: 2px solid currentColor; border-radius: 50%; background: var(--bg); transform: translateX(-50%); }
.laneDot.on { background: currentColor; box-shadow: 0 0 0 4px rgba(125, 211, 252, .13); }
.laneDetail { max-height: 34%; overflow: auto; padding-top: 10px; }
body.zoom-open { overflow: hidden; }

.statsBody { flex: 1; min-height: 0; overflow: auto; padding: 14px 20px 22px; }
.statsBanner { margin-bottom: 10px; padding: 8px 12px; border: 1px solid rgba(251, 191, 36, .35); border-radius: 9px; background: var(--warn-soft); color: #f2d48b; font-size: 12.5px; }
#sVersions { margin-left: auto; }
#sVersions:empty { display: none; }
#sVersions + .zoomClose { margin-left: 0; }
.statsBody h3 { margin: 18px 0 8px; color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: .1em; }
.statsMeta { display: flex; flex-wrap: wrap; gap: 6px 22px; color: var(--muted); font-size: 12px; }
.statsMeta b { color: var(--text); font: 500 14px var(--num); }
.statsTable { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.sRow { display: grid; grid-template-columns: minmax(230px, 2.4fr) repeat(8, minmax(78px, 1fr)); align-items: center; gap: 8px; min-width: 980px; padding: 8px 14px; border-bottom: 1px solid var(--line); font: 13px var(--num); }
.sRow > span:first-child { font: 13px var(--ui); }
.sRow em { margin-left: 6px; padding: 0 5px; border-radius: 4px; background: rgba(251, 191, 36, .13); color: var(--warn); font: normal 10.5px var(--ui); }
.sRow small { margin-left: 4px; color: var(--faint); font: 10.5px var(--ui); }
.sRow.small { opacity: .7; }
.sHead { position: sticky; top: 0; background: #121c27; color: var(--muted); font: 11px/1.35 var(--ui); }
.statsStates { display: flex; flex-wrap: wrap; gap: 8px; }
.statsStates span { padding: 6px 10px; border-radius: 8px; background: var(--panel); color: var(--muted); font-size: 12px; }
.statsStates b { margin-right: 6px; color: var(--text); font: 500 14px var(--num); }
.statsNotes { margin-top: 14px; padding-left: 18px; color: var(--faint); font-size: 12px; line-height: 1.8; }

.zoom.help { display: grid; place-items: center; }
.helpPanel { width: min(600px, 100%); height: auto; max-height: 92vh; }
.helpPanel .zoomHead b, .zoom.stats .zoomHead b { font: 600 16px var(--ui); }
.loading::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; border: 2px solid var(--line-2); border-top-color: var(--ice); border-radius: 50%; vertical-align: -2px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.helpBody { overflow: auto; padding: 4px 22px 22px; }
.helpBody h3 { margin: 16px 0 10px; color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .12em; }
.helpBody dl { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 18px; }
.helpBody dl div { display: flex; align-items: center; gap: 10px; }
.helpBody dt { flex: 0 0 46px; }
.helpBody dd { color: var(--text-2); font-size: 12.5px; }
.helpBody kbd { display: inline-block; min-width: 28px; padding: 2px 7px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 6px; background: var(--panel-2); color: var(--text); font: 12px var(--num); text-align: center; }
.helpBody ul { padding-left: 18px; color: var(--text-2); font-size: 12.5px; line-height: 1.85; }
.helpBody ul b { color: var(--text); font-weight: 500; }
.helpBody > p { margin-top: 14px; font-size: 11.5px; }

/* ---------- Lab lenses for the enlarged chart (Z4–Z6) ---------- */
.lensSide .lensHead { flex: 0 0 auto; padding: 12px 16px 10px; border-bottom: 1px solid var(--line); }
.lensSide .lensHead:empty { display: none; }
.lensSide h4, .curve h4 { margin-bottom: 8px; color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .06em; }
.lensSide .zDetail { max-height: 46%; }
.lensSide .zItem { grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; }
.lensNote { margin-top: 8px; color: var(--faint); font-size: 11px; line-height: 1.5; }
.mv { color: var(--muted); font: 500 12px var(--num); text-align: right; white-space: nowrap; }
.mv.up { color: var(--up); } .mv.down { color: var(--down); }
.itable { display: grid; grid-template-columns: minmax(48px, 1fr) 34px repeat(3, minmax(54px, auto)); gap: 6px 10px; align-items: center; font-size: 12px; }
.itable > span:not(.mv) { color: var(--faint); font-size: 10.5px; line-height: 1.25; text-align: right; }
.itable > span:first-child { text-align: left; }
.itable b { font-weight: 500; }
.curve { padding: 10px 10px 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.curve svg { display: block; overflow: visible; }
.machine { display: flex; align-items: center; gap: 10px; margin: 8px 56px 0 0; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.machine .play { display: grid; place-items: center; flex: 0 0 30px; height: 30px; border-radius: 50%; background: var(--ice); color: #0a1017; font-size: 12px; text-align: center; }
.machine input { flex: 1; min-width: 80px; accent-color: var(--ice); }
.machine span { min-width: 168px; color: var(--text-2); font: 12px var(--num); text-align: right; white-space: nowrap; }
.ruleKey { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 6px 56px 0 2px; color: var(--muted); font-size: 11px; }
.ruleKey span::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 5px; border-radius: 2px; background: var(--c, #263241); vertical-align: -1px; }
.ruleNow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.stateBadge { padding: 3px 9px; border-radius: 6px; background: var(--c, #263241); color: #f4f8fb; font-size: 12.5px; font-weight: 600; }
.statusTag { padding: 2px 8px; border: 1px solid rgba(125, 211, 252, .5); border-radius: 6px; color: var(--ice); font-size: 12px; font-weight: 500; }
.ruleNow .conf { margin-left: auto; }
.ruleWhy { margin-top: 8px; color: var(--text-2); font-size: 12.5px; line-height: 1.6; }
.ruleWhy .muted { font-size: 12px; }
.tfNote { padding: 3px 4px; color: var(--muted); font-size: 12px; }
.lensTabs button { font-family: var(--ui); }
.lensTabs button.on { background: var(--ice-soft); color: var(--ice); box-shadow: inset 0 0 0 1px rgba(125, 211, 252, .35); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
/* With chips the header is full; the hint moves to the chip titles. */
.zoom[data-lens="z6"] .zoomHint { display: none; }
.curve { margin: 0 0 12px; }
.chips button { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border: 1px solid var(--line-2); border-radius: 999px; color: var(--muted); font-size: 12px; }
.chips button[data-color]::before { content: ""; width: 10px; height: 2px; background: var(--c); }
.chips button.on { border-color: rgba(125, 211, 252, .55); background: var(--ice-soft); color: var(--text); }
.ctxGrid { display: grid; grid-template-columns: repeat(3, auto minmax(48px, 1fr)); gap: 6px 10px; align-items: baseline; font-size: 12px; }
.ctxGrid > span:not(.mv) { color: var(--muted); }
.ctxGrid b { font: 500 12.5px var(--num); text-align: right; }
@media (max-width: 760px) {
  .machine, .ruleKey { margin-right: 48px; }
  .machine span { min-width: 0; }
  .lensSide .zDetail { max-height: 34vh; }
  .chips { width: 100%; }
}

/* ---------- Lab chrome, cards and tab bar (lab variants) ---------- */
.variants { display: none; }
body.lab .variants { display: flex; flex: 0 1 auto; min-width: 0; gap: 2px; padding: 3px; border-radius: 9px; background: var(--panel); overflow-x: auto; scrollbar-width: none; }
body.lab .mkts { flex-shrink: 1; overflow: hidden; }
.variants a { padding: 3px 9px; border-radius: 7px; color: var(--muted); font: 12px var(--num); white-space: nowrap; }
.variants a.on { background: var(--panel-2); color: var(--ice); }
.cards, .tabbar, .scrim { display: none; }
.card { display: flex; flex-direction: column; gap: 5px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.card.on { border-color: var(--ice); box-shadow: 0 0 0 1px var(--ice); }
.cards > .card, .card > * { min-width: 0; }
.cardTop { display: flex; align-items: baseline; gap: 10px; }
.cardTop b { flex: 1; font: 400 22px/1 var(--tick); }
/* Inside a vertical card the table's column basis would become a height. */
.card .spark { display: block; flex: 0 0 26px; width: 100%; height: 26px; }
.cardRow { display: flex; align-items: center; gap: 10px; font-size: 11px; }
.cardRow .rngWrap { flex: 1; }
.cardNews { min-width: 90px; margin-left: auto; }
.cardHead { overflow: hidden; color: var(--text-2); font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }

/* Lab index */
body.labIndex { display: block; overflow: auto; }
body.labIndex .top { height: var(--bar); }
.backLink { margin-left: auto; color: var(--muted); font-size: 12px; }
.labGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; max-width: 1200px; margin: 0 auto; padding: 20px; }
.labGrid h1 { grid-column: 1 / -1; margin-top: 10px; font-size: 16px; font-weight: 600; }
.labCard { display: block; padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); }
.labCard:hover { border-color: var(--ice); }
.labCard b { color: var(--ice); font-size: 15px; }
.labCard p { margin-top: 6px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.labNote { grid-column: 1 / -1; color: var(--faint); font-size: 12px; }

/* ---------- Responsive: shared ---------- */
@media (max-width: 1240px) { .status span { display: none; } }
@media (max-width: 1150px) {
  /* Narrow screens scroll as a normal page: list first, then the detail. */
  body { display: block; overflow: auto; }
  .main { display: block; }
  .board { height: 80vh; }
  .drawer { border-top: 1px solid var(--line); border-left: 0; overflow: visible; }
  .tbtn:not(.icon) { width: 32px; padding: 0; } .tbtn span { display: none; }
  .filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .filters .seg { flex-shrink: 0; }
  .key { display: none; }
  /* KPI cards become a swipeable strip when the board is narrow. */
  .kpis { grid-template-columns: none; grid-auto-columns: minmax(150px, 1fr); grid-auto-flow: column; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; }
  .kpis > * { scroll-snap-align: start; }
}
@media (max-width: 1000px) { .mkt .at { display: none; } }
@media (max-width: 760px) {
  :root { --bar: auto; }
  .top { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .actions { display: contents; }
  .brand { order: 1; } .mkts { order: 2; overflow-x: auto; scrollbar-width: none; } .status { order: 3; margin-left: auto; }
  #openHelp { order: 4; } .brk { display: block; order: 5; flex-basis: 100%; height: 0; }
  .search { order: 6; flex: 1 1 200px; width: auto; margin-left: 0; }
  #openStats { order: 7; } .classicLink { order: 8; } .variants { order: 9; }
  .brand small { display: none; }
  .mkt { height: 22px; padding: 0 8px 0 7px; font-size: 11px; }
  .board { height: auto; padding: 10px; }
  .kpis { grid-auto-columns: minmax(138px, 42%); gap: 8px; margin-bottom: 10px; }
  .kpis button { padding: 9px 11px 10px; }
  .kpis strong { font-size: 23px; }
  /* The list grows with the page (no nested scroll); the header row still sticks. */
  .table { flex: none; height: auto; overflow: clip; }
  .thead { height: 36px; }
  .thead, .tr { gap: 6px; padding: 0 10px; }
  .sub { padding: 0 10px 8px; }
  .zoom { padding: 0; }
  .zoomPanel { border: 0; border-radius: 0; }
  .zoomHint { display: none; }
  .zoomHead { padding: 8px 10px; }
  .zoomHead b { font-size: 22px; }
  .zoom[data-variant="z1"] .zoomBody { grid-template-columns: 1fr; grid-template-rows: 52vh minmax(0, 1fr); }
  .zoomSide { overflow: hidden; border-top: 1px solid var(--line); border-left: 0; }
  .zDetail { flex: 0 0 auto; max-height: 42vh; }
  .zList { flex: 1 1 auto; }
  .zoomMain { padding: 6px 4px 6px 8px; }
  .minimap, .lane { margin-right: 48px; }
  .callout { top: auto !important; right: 8px; bottom: 8px; left: 8px !important; width: auto !important; max-height: 60%; }
  .statsBody { padding: 10px 12px 18px; }
  .sRow { grid-template-columns: minmax(150px, 1.6fr) repeat(8, minmax(70px, 1fr)); min-width: 780px; }
  .zoom.help { padding: 12px; }
  .zoom.help .zoomPanel { border: 1px solid var(--line-2); border-radius: 14px; }
  .helpBody { padding: 2px 16px 18px; }
  .helpBody dl { grid-template-columns: 1fr; }
  .dh { padding: 12px 14px 11px; }
  .who > b { font-size: 30px; }
  .dh .px strong { font-size: 22px; }
  .metrics { gap: 6px; padding: 12px 14px 0; }
  .metrics > div { padding: 7px 8px 8px; }
  .metrics strong { font-size: 13.5px; }
  .ctl, .section, .chartNote, .disclaimer, .legend { padding-right: 14px; padding-left: 14px; }
  .chartBox { height: 260px; margin: 6px 4px 0 10px; }
}
@container drawer (max-width: 360px) { .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } .legend em { display: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- R1 · fluid (the home page): drawer scales with the screen, columns drop by priority ---------- */
[data-layout="r1"] .main { grid-template-columns: minmax(0, 1fr) clamp(340px, 31vw, 680px); }
@container board (max-width: 900px) { .c-spark { display: none; } }
@container board (max-width: 800px) { .c-t4 { display: none; } }
@container board (max-width: 720px) { .c-t1, .c-news { display: none; } .thead small { display: none; } .thead button, .thead span { white-space: nowrap; } }
@container board (max-width: 600px) {
  .rngWrap .rng { display: none; }
  .c-sym { flex: 1 1 70px; } .c-price { flex-basis: 60px; } .c-chg { flex-basis: 64px; } .c-pos { flex-basis: 34px; } .c-conf { flex-basis: 89px; }
  .numc { font-size: 12.5px; }
  .chg { width: 100%; min-width: 0; padding: 2px 5px; font-size: 12px; }
  .rngWrap span { width: auto; }
  .conf { gap: 2px; } .conf i { min-width: 20px; padding: 0 3px; }
  .sym b { font-size: 17px; }
}
@container board (max-width: 1080px) { .key { display: none; } }
@container board (min-width: 1240px) { .c-head { display: block; } .row .sub { display: none; } }
@media (min-width: 1800px) { [data-layout="r1"] .chartBox { height: clamp(360px, 40vh, 620px); } [data-layout="r1"] .kpis strong { font-size: 30px; } }
@media (max-width: 1150px) and (min-width: 761px) {
  [data-layout="r1"] { display: grid; overflow: hidden; }
  [data-layout="r1"] .main { display: grid; }
  [data-layout="r1"] .board { height: auto; }
  [data-layout="r1"] .drawer { border-top: 0; border-left: 1px solid var(--line); overflow: auto; }
}
@media (max-width: 760px) {
  [data-layout="r1"] .drawer { position: fixed; inset: 0; z-index: 40; overflow: auto; border: 0; transform: translateX(105%); transition: transform .24s cubic-bezier(.2, .8, .2, 1); box-shadow: -20px 0 60px -20px #000; }
  [data-layout="r1"].detail-open { overflow: hidden; }
  [data-layout="r1"].detail-open .drawer { transform: none; }
  [data-layout="r1"] .back { display: grid; }
  [data-layout="r1"] .main { display: block; }
}

/* ---------- R2 · tiered: 3 columns on large, drawer on tablets, bottom sheet on phones ---------- */
@media (min-width: 1800px) {
  [data-layout="r2"] .main { grid-template-columns: minmax(0, 1fr) min(56vw, 1180px); }
  [data-layout="r2"] .drawer { display: grid; grid-template-columns: minmax(0, 1fr) 400px; grid-auto-rows: min-content; align-content: start; }
  [data-layout="r2"] .drawer > * { grid-column: 1; }
  [data-layout="r2"] .drawer > .news { position: sticky; top: 0; grid-column: 2; grid-row: 1 / span 9; max-height: calc(100vh - 56px); overflow: auto; border-left: 1px solid var(--line); }
  [data-layout="r2"] .chartBox { height: 46vh; }
}
@media (max-width: 1100px) {
  [data-layout="r2"] .main { display: block; }
  [data-layout="r2"] .board { height: auto; min-height: calc(100vh - 56px); }
  [data-layout="r2"] .scrim { display: block; position: fixed; inset: 0; z-index: 39; background: rgba(0, 0, 0, .55); opacity: 0; pointer-events: none; transition: opacity .2s; }
  [data-layout="r2"].detail-open .scrim { opacity: 1; pointer-events: auto; }
  [data-layout="r2"] .drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 40; width: min(560px, 92vw); overflow: auto; border-top: 0; border-left: 1px solid var(--line); transform: translateX(105%); transition: transform .24s ease; box-shadow: -20px 0 50px -20px #000; }
  [data-layout="r2"].detail-open .drawer { transform: none; }
  [data-layout="r2"] .back { display: grid; }
}
@media (max-width: 760px) {
  [data-layout="r2"] .drawer { top: auto; left: 0; width: 100%; height: 86vh; border-top: 1px solid var(--line); border-left: 0; border-radius: 16px 16px 0 0; transform: translateY(105%); }
  [data-layout="r2"] .drawer::before { content: ""; display: block; width: 44px; height: 4px; margin: 8px auto 0; border-radius: 2px; background: var(--faint); }
}

/* ---------- R3 · mobile-first cards with a bottom tab bar on phones ---------- */
@media (min-width: 1800px) { [data-layout="r3"] .main { grid-template-columns: minmax(0, 1fr) clamp(500px, 34vw, 760px); } [data-layout="r3"] .chartBox { height: 44vh; } }
@media (max-width: 1150px) {
  [data-layout="r3"] { display: grid; overflow: hidden; }
  [data-layout="r3"] .main { display: grid; grid-template-columns: minmax(0, 1fr) 400px; }
  [data-layout="r3"] .board { height: auto; min-height: 0; overflow: auto; }
  [data-layout="r3"] .table, [data-layout="r3"] .key, [data-layout="r3"] .density { display: none; }
  [data-layout="r3"] .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
  [data-layout="r3"] .drawer { border-top: 0; border-left: 1px solid var(--line); overflow: auto; }
}
@media (max-width: 760px) {
  [data-layout="r3"] { display: block; overflow: auto; padding-bottom: 64px; }
  [data-layout="r3"] .main { display: block; }
  [data-layout="r3"] .cards { grid-template-columns: 1fr; }
  [data-layout="r3"] .tabbar { display: flex; position: fixed; right: 0; bottom: 0; left: 0; z-index: 30; padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: rgba(13, 21, 30, .95); backdrop-filter: blur(8px); }
  [data-layout="r3"] .tabbar button { flex: 1; padding: 12px 0; color: var(--muted); font-size: 13px; text-align: center; }
  [data-layout="r3"] .tabbar button.on { color: var(--ice); }
  [data-layout="r3"][data-tab="list"] .drawer { display: none; }
  [data-layout="r3"][data-tab="chart"] .board, [data-layout="r3"][data-tab="news"] .board { display: none; }
  [data-layout="r3"][data-tab="chart"] .drawer > .news { display: none; }
  [data-layout="r3"][data-tab="news"] .drawer > :not(.dh):not(.news) { display: none; }
  [data-layout="r3"] .drawer { border: 0; }
}

/* ---------- News balance (/lab/b1 … b3) ---------- */
.balance { padding-bottom: 2px; }
.bHead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bState { padding: 3px 10px; border-radius: 999px; background: var(--panel-3); color: var(--text-2); font-size: 13px; font-weight: 600; }
.bState.s-positive { background: var(--up-soft); color: var(--up); } .bState.s-negative { background: var(--down-soft); color: var(--down); }
.bState.s-split { background: var(--warn-soft); color: var(--warn); }
.bNums { display: flex; align-items: baseline; gap: 6px; font: 12.5px var(--num); }
.bNums i { color: var(--faint); font-style: normal; }
.bHead .linkBtn { margin-left: auto; }
.bHow { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text-2); font-size: 12px; line-height: 1.7; }
.bHow p + p { margin-top: 6px; }
.bHow b { color: var(--text); font-weight: 500; }
.bMarket { margin-top: 10px; padding: 8px 11px; border: 1px solid var(--line); border-left: 3px solid var(--faint); border-radius: 8px; background: var(--panel); color: var(--text-2); font-size: 12.5px; }
.bMarket b { margin-right: 8px; color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .1em; }
.bMarket small { display: block; margin-top: 2px; color: var(--faint); font-size: 11px; }
.bMarket.v-agree { border-left-color: var(--ice); } .bMarket.v-disagree { border-left-color: var(--warn); color: var(--text); }
.bMarket.v-sides_positive { border-left-color: var(--up); } .bMarket.v-sides_negative { border-left-color: var(--down); }
.bEmpty { margin-top: 8px; font-size: 12.5px; }
.bFoot { margin-top: 10px; color: var(--faint); font-size: 11px; line-height: 1.6; }
.bSub { margin: 14px 0 2px; color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .08em; }
.bTopics { margin: 10px 0 0; padding: 0; list-style: none; }
.bt { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 9px; padding: 9px 8px; border-radius: 10px; cursor: pointer; transition: background .12s; }
.bt:hover { background: rgba(255, 255, 255, .03); }
.bt .bn { grid-row: span 2; display: grid; place-items: center; width: 20px; height: 20px; border: 1px solid var(--line-2); border-radius: 50%; color: var(--text-2); font: 600 10.5px var(--num); }
.bt:has(.bn) .ba { display: none; }
.bt .ba { grid-row: span 2; padding-top: 1px; font-size: 11px; }
.bt.dir-split .ba, .bt.dir-split .bn { color: var(--warn); }
.bt h4 { color: var(--text); font-size: 13px; font-weight: 500; line-height: 1.5; }
.bt small { display: block; margin-top: 1px; color: var(--muted); font-size: 11.5px; }
.bt small small { display: inline; margin: 0; color: var(--faint); }
.rx { display: inline-flex; align-items: baseline; gap: 6px; margin-top: 5px; padding: 1px 8px; border-radius: 6px; white-space: nowrap; background: rgba(131, 145, 160, .12); color: var(--text-2); font-size: 11.5px; }
.rx em { color: var(--muted); font: 11px var(--num); font-style: normal; }
.rx.m-up, .badge.brx.m-up { background: var(--up-soft); color: var(--up); } .rx.m-down, .badge.brx.m-down { background: var(--down-soft); color: var(--down); }
.rx.m-up em, .rx.m-down em { color: inherit; opacity: .8; }
.rx.v-pending, .rx.v-unavailable { background: transparent; border: 1px dashed var(--line-2); color: var(--faint); }
.vs { display: flex; gap: 6px; margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.vs i { flex: none; width: 16px; color: var(--faint); font-style: normal; text-align: center; }
.vs.v-overturned { color: var(--text); } .vs.v-overturned i { color: var(--warn); }
.badge.bw { background: rgba(167, 139, 250, .12); color: #c4b5fd; }
.badge.brx { background: rgba(131, 145, 160, .12); color: var(--text-2); }
.badge.bout { background: transparent; border: 1px dashed var(--line-2); color: var(--faint); line-height: 14px; }
/* B1 · scale */
.tug { position: relative; display: flex; height: 14px; margin-top: 14px; overflow: hidden; border-radius: 7px; background: var(--panel-3); }
.tug .seg { height: 100%; border-right: 1px solid var(--bg-2); }
.tug .seg:last-of-type { border-right: 0; }
.tug .seg.dir-positive { background: linear-gradient(180deg, #4ade9f, #23a979); } .tug .seg.dir-negative { background: linear-gradient(180deg, #fd8a9b, #e1566d); }
.tug .mid { position: absolute; top: -2px; bottom: -2px; left: calc(50% - 1px); width: 2px; background: var(--bg); box-shadow: 0 0 0 1px rgba(227, 236, 244, .5); }
.tugAxis { display: flex; justify-content: space-between; margin-top: 4px; color: var(--faint); font-size: 10.5px; }
/* B2 · timeline */
.bChart { display: block; margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); font-family: var(--num); }
.bChart .bmk { cursor: pointer; }
.bTopics.timeline .bt { border-left: 2px solid var(--line-2); border-radius: 0 10px 10px 0; }
.bTopics.timeline .bt.dir-positive { border-left-color: rgba(52, 211, 153, .55); } .bTopics.timeline .bt.dir-negative { border-left-color: rgba(251, 113, 133, .55); }
/* B3 · duel */
.duelCard { margin-top: 10px; padding: 11px 12px 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.dverdict { margin-bottom: 6px; color: var(--text-2); font-size: 12.5px; line-height: 1.6; }
.dverdict b { display: inline-flex; align-items: center; gap: 5px; margin-right: 8px; color: var(--text); font-weight: 600; }
.dverdict b i { color: var(--muted); font-style: normal; }
.dverdict.v-overturned b, .dverdict.v-overturned b i { color: var(--warn); }
.dverdict.v-tangled, .dverdict.v-same_event, .dverdict.v-pending, .dverdict.v-unmeasured { color: var(--muted); }
.drow { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 10px; padding: 8px 0 8px 9px; border-top: 1px solid var(--line); border-left: 2px solid var(--line-2); }
.drow[data-topic] { cursor: pointer; }
.drow.dir-positive { border-left-color: var(--up); } .drow.dir-negative { border-left-color: var(--down); }
.dtag { color: var(--muted); font-size: 11.5px; line-height: 1.5; }
.dtag b { display: block; color: var(--text); font-size: 12px; }
.drow.dir-positive .dtag { color: var(--up); } .drow.dir-negative .dtag { color: var(--down); }
.dtag time { display: block; color: var(--faint); font: 10.5px var(--num); }
.dbody h4 { color: var(--text); font-size: 12.5px; font-weight: 500; line-height: 1.5; }
.dbody > small { display: block; margin-top: 1px; color: var(--muted); font-size: 11px; }
.dreact { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 5px; }
.dreact .rx { margin-top: 0; }
.dbar { position: relative; flex: 0 0 38%; height: 8px; border-radius: 4px; background: var(--panel-3); }
.dbar .mid { position: absolute; top: -3px; bottom: -3px; left: calc(50% - .5px); width: 1px; background: var(--muted); }
.dbar i { position: absolute; top: 0; bottom: 0; }
.dbar i.pos { left: 50%; border-radius: 0 4px 4px 0; background: var(--up); } .dbar i.neg { right: 50%; border-radius: 4px 0 0 4px; background: var(--down); }
@container drawer (max-width: 380px) {
  .drow { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .dtag b, .dtag time { display: inline; margin-right: 6px; }
  .dbar { flex-basis: 30%; }
}
.bNote { margin-top: 2px; color: var(--faint); font-size: 11px; }
.bMore { margin-top: 4px; }
.bMore > summary { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; border-radius: 7px; color: var(--ice); font-size: 12px; cursor: pointer; list-style: none; }
.bMore > summary::-webkit-details-marker { display: none; }
.bMore > summary::after { content: "▾"; font-size: 10px; }
.bMore[open] > summary::after { content: "▴"; }
.bMore > summary:hover { background: var(--ice-soft); }
/* Balance lab pages: the scale sits first in the detail panel. */
.drawer > .balance { padding-top: 16px; }
.bViews { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel); }
.bViews button { padding: 2px 10px; border-radius: 6px; color: var(--muted); font-size: 12px; letter-spacing: 0; }
.bViews button:hover { color: var(--text); }
.bViews button.on { background: var(--ice-soft); color: var(--ice); font-weight: 600; }
/* Home detail panel: the balance summary above the chart, opposite pairs above the news. */
.scale { padding: 14px 20px 0; }
.bSum .bHead { gap: 8px; }
.bLabel { color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .12em; }
.bSum .bState { padding: 1px 9px; font-size: 12px; }
.bSum .bNums { font-size: 12px; }
.bSum.none .bHead > .muted { font-size: 12px; }
.bSum .tug { height: 10px; margin-top: 8px; border-radius: 5px; }
.bLine { margin-top: 7px; padding-left: 8px; border-left: 2px solid var(--faint); color: var(--text-2); font-size: 12.5px; line-height: 1.55; }
.bLine b { margin-right: 6px; color: var(--muted); font-size: 11.5px; font-weight: 600; }
.bLine small { color: var(--faint); font-size: 11px; white-space: nowrap; }
.bLine.v-agree { border-left-color: var(--ice); } .bLine.v-disagree { border-left-color: var(--warn); color: var(--text); }
.bLine.v-sides_positive { border-left-color: var(--up); } .bLine.v-sides_negative { border-left-color: var(--down); }
.bDuels { margin-bottom: 12px; }
.bDuels .bSub { margin-top: 0; }
/* Zoom 多空 lens: the same summary and pairs beside the chart. */
.zBalance .bDuels { margin-top: 14px; }
.zBalance .duelCard { padding: 9px 10px 4px; }
.zBalance .drow { grid-template-columns: 54px minmax(0, 1fr); }
.zChips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
@media (max-width: 760px) { .scale { padding: 12px 14px 0; } }
/* Stats: news judgment scorecard. */
#sTabs { margin-left: 4px; }
.jHead { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-bottom: 12px; }
.jBig { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.jBig small { display: block; color: var(--muted); font-size: 12px; }
.jBig b { display: block; margin: 4px 0 2px; color: var(--text); font: 600 30px var(--num); }
.jBig span { color: var(--faint); font-size: 11.5px; }
.jTable { border: 1px solid var(--line); border-radius: 10px; }
.jGroup { padding: 9px 14px 4px; color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .08em; }
.jRow { display: grid; grid-template-columns: minmax(150px, 1.6fr) 54px 120px minmax(90px, 1.2fr) 48px 84px; align-items: center; gap: 10px; padding: 6px 14px; border-top: 1px solid var(--line); font: 12.5px var(--num); }
.jRow > span:first-child { font: 13px var(--ui); }
.jRow em { margin-left: 6px; padding: 0 5px; border-radius: 4px; background: rgba(251, 191, 36, .13); color: var(--warn); font: normal 10.5px var(--ui); }
.jRow.small { opacity: .65; }
.jRow small { color: var(--faint); }
.jBar { position: relative; display: block; height: 8px; border-radius: 4px; background: var(--panel-3); }
.jBar i { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 4px; }
.jBar i.pos { background: var(--up); } .jBar i.neg { background: var(--down); }
.jBar .mid { position: absolute; top: -3px; bottom: -3px; left: calc(50% - .5px); width: 1px; background: var(--muted); }
.jTrend { display: block; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); font-family: var(--num); }
.jMisses { margin: 0; padding: 0; list-style: none; }
.jMisses li { display: grid; grid-template-columns: auto auto auto 1fr; align-items: baseline; gap: 4px 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 12.5px; }
.jMisses li b { font: 600 13px var(--num); }
.jMisses time { justify-self: end; color: var(--faint); font: 11px var(--num); }
.jMisses p { grid-column: 1 / -1; color: var(--text); }
.jMisses small { grid-column: 1 / -1; color: var(--muted); font-size: 11.5px; }
@media (max-width: 760px) {
  .jHead { grid-template-columns: 1fr; }
  .jRow { grid-template-columns: minmax(100px, 1.3fr) 36px minmax(70px, 1fr) 42px; }
  .jRow > span:nth-child(3), .jRow small { display: none; }
}
.dTable { border: 1px solid var(--line); border-radius: 10px; }
.dRow { display: grid; grid-template-columns: minmax(150px, 1.6fr) 110px 110px 80px minmax(150px, 1.4fr); align-items: center; gap: 10px; padding: 7px 14px; border-top: 1px solid var(--line); font: 12.5px var(--num); }
.dRow:first-child { border-top: 0; }
.dRow > span:first-child { font: 13px var(--ui); }
.dRow small { color: var(--faint); }
.dHead { color: var(--muted); font: 11.5px var(--ui) !important; }
@media (max-width: 760px) { .dRow { grid-template-columns: minmax(100px, 1.2fr) 70px 70px 54px; } .dRow > span:last-child { display: none; } }
