/* Capital Flow Terminal — design system
   Layout: sticky top header (brand · navigation · status/actions) + ticker, then a two-column shell:
   left sidebar (news feed + live TV player; docked ≥1200px, off-canvas below) and the main content column. Dark-first palette. */

:root {
  color-scheme: dark;
  --bg: #000000;
  --surface: #0b0b0d;
  --surface-2: #121215;
  --raised: #1a1a1f;
  --line: #222227;
  --line-2: #303037;
  --fg: #f2f2f2;
  --fg-2: #b4b4ba;
  --fg-3: #7c7c85;
  --accent: #e8ecf2;
  --accent-ink: #0b0e14;
  --accent-soft: rgba(232, 236, 242, .07);
  --logo-bg: linear-gradient(145deg, #3a4253, #161b25);
  --logo-fg: #ffffff;
  /* brand palette: black #000000 · red #ff433d · blue #0068ff · mint #4af6c3 · orange #fb8b1e */
  --c1: #ff433d; --c2: #0068ff; --c3: #fb8b1e; --c4: #4af6c3;
  --blue: #0068ff;
  --blue-text: #4d94ff;
  --violet: #4d94ff;
  --teal: #4af6c3;
  --up: #4af6c3;
  --down: #ff433d;
  --warn: #fb8b1e;
  --shadow: 0 18px 40px rgba(0, 0, 0, .45);
  --font: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --r-lg: 14px; --r: 10px; --r-sm: 7px; --r-pill: 7px;
  --gap: 16px; --pad: 18px;
  --side-w: 312px; --top-h: 58px;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f4f4f5; --surface: #ffffff; --surface-2: #f8f8f9; --raised: #efeff1; --line: #e4e4e7; --line-2: #d0d0d6;
    --fg: #0a0a0b; --fg-2: #3d3d44; --fg-3: #6e6e78; --accent: #111827; --accent-ink: #ffffff; --accent-soft: rgba(17, 24, 39, .06); --logo-bg: linear-gradient(145deg, #2a3140, #0b0e14); --logo-fg: #ffffff;
    --blue: #0068ff; --blue-text: #0058d6; --violet: #0058d6; --teal: #0b9e72; --up: #0b9e72; --down: #e6302a; --warn: #c86a00; --c4: #12c08e; --shadow: 0 18px 40px rgba(15, 25, 40, .14);
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f4f5; --surface: #ffffff; --surface-2: #f8f8f9; --raised: #efeff1; --line: #e4e4e7; --line-2: #d0d0d6;
  --fg: #0a0a0b; --fg-2: #3d3d44; --fg-3: #6e6e78; --accent: #111827; --accent-ink: #ffffff; --accent-soft: rgba(17, 24, 39, .06); --logo-bg: linear-gradient(145deg, #2a3140, #0b0e14); --logo-fg: #ffffff;
  --blue: #0068ff; --blue-text: #0058d6; --violet: #0058d6; --teal: #0b9e72; --up: #0b9e72; --down: #e6302a; --warn: #c86a00; --c4: #12c08e; --shadow: 0 18px 40px rgba(15, 25, 40, .14);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--fg); font-family: var(--font); font-size: calc(12.5px * var(--fs, 1)); line-height: 1.55; -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums slashed-zero; font-feature-settings: 'zero' 1, 'calt' 0; letter-spacing: -.005em; }
a { color: var(--blue-text); text-decoration: none; } a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; text-wrap: balance; }
p { margin: 0; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
[data-icon] { display: inline-flex; align-items: center; justify-content: center; }
.btn, .pill, .chip, .cchip, .badge, .peer, .nav button, .side-h h2, .card-h .t, .callout, .check, .reading .lab, .test-out, .legend span, .health-row, .live { align-items: center; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* text utilities */
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { text-align: right; white-space: nowrap; }
.up { color: var(--up); } .down { color: var(--down); } .warn-c { color: var(--warn); }
.muted { color: var(--fg-3); } .dim { color: var(--fg-2); }
.xs { font-size: calc(11.5px * var(--fs, 1)); } .sm { font-size: calc(12.5px * var(--fs, 1)); }
.nowrap { white-space: nowrap; }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ───────── banners ───────── */
.banner { padding: 8px max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px)); font-size: calc(12.5px * var(--fs, 1)); text-align: center; }
.banner.info { background: color-mix(in srgb, var(--blue) 18%, var(--surface)); color: var(--fg); border-bottom: 1px solid color-mix(in srgb, var(--blue) 35%, transparent); }
.banner.warn { background: var(--warn); color: #1b1104; font-weight: 600; }

/* ───────── shell: top header (brand · nav · actions), ticker, then sidebar (news + TV) and main ───────── */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 31; background: var(--bg); }
.top-row { display: flex; align-items: center; gap: 18px; min-height: var(--top-h); padding: 0 max(20px, env(safe-area-inset-right, 0px)) 0 max(20px, env(safe-area-inset-left, 0px)); }
.brand { display: flex; align-items: center; gap: 10px; flex: none; color: inherit; text-decoration: none !important; }
.logo { width: 32px; height: 32px; border-radius: 9px; flex: none; display: grid; place-items: center; background: var(--logo-bg); color: var(--logo-fg); box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.logo svg.i { width: 18px; height: 18px; stroke-width: 2.2; }
.brand-t { line-height: 1.15; min-width: 0; }
.brand-t b { display: block; font-size: calc(14px * var(--fs, 1)); letter-spacing: .01em; }
.brand-t span { font-size: calc(11px * var(--fs, 1)); color: var(--fg-3); white-space: nowrap; }
.nav { display: flex; align-items: center; gap: 2px; min-width: 0; flex: 1 1 auto; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav button { position: relative; display: inline-flex; align-items: center; gap: 7px; flex: none; border: 0; background: transparent; color: var(--fg-2); padding: 8px 11px; border-radius: var(--r-sm); font-weight: 500; white-space: nowrap; transition: background .15s, color .15s; }
.nav button:hover { background: var(--raised); color: var(--fg); }
.nav button.active { color: var(--fg); font-weight: 600; background: var(--raised); }
.nav button.active::after { content: ""; position: absolute; left: 11px; right: 11px; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background: var(--fg); }
.nav button.active svg.i { stroke-width: 2.1; }
.nav button .tag { font-size: calc(9.5px * var(--fs, 1)); font-family: var(--mono); padding: 1px 5px; border-radius: 5px; background: var(--surface); border: 1px solid var(--line-2); color: var(--fg-3); }
.nav-sep { width: 1px; height: 18px; background: var(--line-2); margin: 0 6px; flex: none; }
.nav-mobile { display: none; }
.top-actions { display: flex; align-items: center; gap: 8px; flex: none; margin-left: auto; }
.pill { display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px; border-radius: var(--r-pill); border: 1px solid var(--line-2); font-size: calc(11.5px * var(--fs, 1)); font-weight: 600; letter-spacing: 0; white-space: nowrap; background: var(--surface); color: var(--fg-2); cursor: pointer; }
.pill .dot { width: 6px; height: 6px; }
.pill.on { color: var(--up); border-color: color-mix(in srgb, var(--up) 45%, transparent); } .pill.on .dot { background: var(--up); }
.pill.off { color: var(--down); border-color: color-mix(in srgb, var(--down) 45%, transparent); } .pill.off .dot { background: var(--down); }
.pill.mid { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); } .pill.mid .dot { background: var(--warn); }
.live { display: inline-flex; align-items: center; gap: 7px; font-family: var(--mono); font-size: calc(11.5px * var(--fs, 1)); color: var(--fg-3); white-space: nowrap; padding: 0 4px; }
.live .dot { background: var(--up); animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--surface); color: var(--fg-2); padding: 0; transition: color .15s, border-color .15s; }
.icon-btn:hover { color: var(--fg); border-color: var(--fg-3); }
.icon-btn.on { color: var(--up); border-color: color-mix(in srgb, var(--up) 50%, transparent); }
.icon-btn.sm { width: 28px; height: 28px; } .icon-btn.sm svg.i { width: 14px; height: 14px; }
#side-btn { display: none; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--fg-3); }
.dot.ok { background: var(--up); box-shadow: 0 0 0 3px color-mix(in srgb, var(--up) 20%, transparent); }
.dot.bad { background: var(--down); }

.connect-box { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 24px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.connect-box input { flex: 1 1 260px; min-width: 0; }

.ticker { overflow: hidden; border-bottom: 1px solid var(--line); background: var(--surface); height: 34px; mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent); }
.ticker-inner { display: flex; gap: 28px; padding: 8px 24px; width: max-content; animation: scroll 120s linear infinite; font-family: var(--mono); font-size: calc(12px * var(--fs, 1)); white-space: nowrap; }
.ticker:hover .ticker-inner { animation-play-state: paused; }
@keyframes scroll { to { transform: translateX(-50%); } }
.tk { display: inline-flex; gap: 7px; cursor: pointer; color: var(--fg-2); }
.tk b { color: var(--fg); font-weight: 600; }

.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); align-items: start; }
.sidebar { position: sticky; top: calc(var(--top-h) + env(safe-area-inset-top, 0px)); height: calc(100vh - var(--top-h) - env(safe-area-inset-top, 0px)); display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); min-width: 0; }
.side-resize { position: absolute; top: 0; right: -4px; bottom: 0; width: 8px; z-index: 5; cursor: col-resize; touch-action: none; }
.side-resize::after { content: ""; position: absolute; top: 0; bottom: 0; left: 3px; width: 2px; background: transparent; transition: background .15s; }
.side-resize:hover::after, .side-resize.active::after, .side-resize:focus-visible::after { background: var(--fg-3); }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing iframe { pointer-events: none; }
.side-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px 8px; }
.side-h h2 { font-size: calc(13px * var(--fs, 1)); font-weight: 600; display: flex; align-items: center; gap: 8px; letter-spacing: .01em; line-height: 1; }
.side-h h2 svg.i { width: 15px; height: 15px; color: var(--fg-2); }
.side-tools { display: flex; align-items: center; gap: 6px; }
.side-close { display: none; }
.side-news { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.side-filters { display: flex; flex-direction: column; gap: 8px; padding: 0 14px 10px; border-bottom: 1px solid var(--line); }
.side-filters .seg { align-self: stretch; } .side-filters .seg button { flex: 1 1 0; }
.chip-row { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { border: 1px solid var(--line-2); background: var(--surface-2); color: var(--fg-3); border-radius: 6px; padding: 3px 9px; font-size: calc(11px * var(--fs, 1)); font-weight: 500; }
.chip:hover { color: var(--fg); } .chip.active { color: var(--fg); border-color: var(--fg-3); background: var(--raised); }
.chip.ai.active { color: var(--violet); border-color: color-mix(in srgb, var(--violet) 50%, transparent); background: color-mix(in srgb, var(--violet) 10%, transparent); }
.side-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.news-day { position: sticky; top: 0; z-index: 1; font-size: calc(10.5px * var(--fs, 1)); font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--fg-3); background: var(--surface); padding: 8px 14px 4px; border-bottom: 1px solid var(--line); }
.news-item { display: block; padding: 10px 14px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none !important; transition: background .1s; }
.news-item { position: relative; transition: background .15s, box-shadow .15s; }
.news-item:hover { background: color-mix(in srgb, var(--warn) 9%, var(--surface)); box-shadow: inset 3px 0 0 var(--warn); }
.news-item:hover .nt { color: color-mix(in srgb, var(--warn) 55%, var(--fg)); }
.news-item:focus-visible { outline: none; background: color-mix(in srgb, var(--warn) 12%, var(--surface)); box-shadow: inset 3px 0 0 var(--warn); }
.news-item .nt { font-size: calc(12.5px * var(--fs, 1)); line-height: 1.4; font-weight: 500; color: var(--fg); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.news-item .nm { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 5px; font-size: calc(11px * var(--fs, 1)); color: var(--fg-3); }
.news-item .nm .src { color: var(--fg-2); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.news-item .nm .ct { font-family: var(--mono); font-size: calc(9.5px * var(--fs, 1)); text-transform: none; letter-spacing: 0; padding: 0 5px; border-radius: 4px; border: 1px solid var(--line-2); }
.news-item .nm .ct.geopolitical { color: var(--c1); border-color: color-mix(in srgb, var(--c1) 50%, transparent); }
.news-item .nm .ct.financial { color: var(--c4); border-color: color-mix(in srgb, var(--c4) 50%, transparent); }
.news-item .nm .rg { font-family: var(--mono); font-size: calc(9.5px * var(--fs, 1)); text-transform: none; letter-spacing: 0; }
.news-item .why { margin-top: 5px; font-size: calc(11.5px * var(--fs, 1)); color: var(--fg-2); line-height: 1.4; padding-left: 8px; border-left: 2px solid color-mix(in srgb, var(--violet) 60%, transparent); }
.news-item .assets { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 5px; }
.news-item .assets span { font-family: var(--mono); font-size: calc(10px * var(--fs, 1)); padding: 0 5px; border-radius: 4px; background: var(--raised); color: var(--fg-2); }
.news-item.pick { border-left: 2px solid var(--violet); }
.news-foot { padding: 10px 14px 12px; font-size: calc(11px * var(--fs, 1)); color: var(--fg-3); line-height: 1.5; }
.side-tv { flex: none; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; background: var(--surface); }
.side-tv .side-h { padding-bottom: 2px; }
.side-tv select { margin: 0 14px; height: 32px; font-size: calc(12.5px * var(--fs, 1)); }
.tv-frame { position: relative; margin: 0 14px; aspect-ratio: 16 / 9; max-height: 46vh; border-radius: var(--r-sm); overflow: hidden; background: #000; border: 1px solid var(--line-2); }
.tv-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.tv-poster { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: #fff; background: radial-gradient(ellipse at center, #1c2433, #090c12); cursor: pointer; text-align: center; padding: 12px; }
.tv-poster b { font-size: calc(13px * var(--fs, 1)); }
.tv-poster .play { width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.35); display: grid; place-items: center; }
.tv-poster .play svg.i { width: 20px; height: 20px; fill: #fff; stroke: none; margin-left: 2px; }
.tv-poster span { font-size: calc(11px * var(--fs, 1)); color: rgba(255,255,255,.7); }
.tv-poster a { color: #fff; text-decoration: underline; font-size: calc(11.5px * var(--fs, 1)); }
.side-tv .xs { padding: 0 14px; }
.tv-modal { position: fixed; z-index: 55; inset: 0; background: rgba(4, 7, 12, .92); display: flex; flex-direction: column; padding: max(16px, env(safe-area-inset-top, 0px)) 16px 16px; gap: 12px; }
.tv-modal-h { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.tv-modal-h select { flex: 1 1 220px; max-width: 360px; background-color: var(--surface); }
.tv-modal-h .row-actions { margin-left: auto; }
.tv-modal-b { flex: 1 1 auto; min-height: 0; display: grid; place-items: center; }
.tv-modal-b iframe { width: min(100%, calc((100vh - 110px) * 16 / 9)); aspect-ratio: 16 / 9; height: auto; max-height: 100%; border: 0; border-radius: var(--r); background: #000; }
.tv-modal-b .tv-poster { position: static; width: min(100%, 720px); aspect-ratio: 16 / 9; border-radius: var(--r); }

.main-col { min-width: 0; display: flex; flex-direction: column; min-height: calc(100vh - var(--top-h)); }
main { flex: 1; width: 100%; max-width: 1640px; margin: 0 auto; padding: 18px max(24px, env(safe-area-inset-right, 0px)) 32px 24px; }
.page-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; padding: 2px 0 16px; }
.page-head h1 { font-size: calc(20px * var(--fs, 1)); letter-spacing: -.01em; }
.page-head p { font-size: calc(12.5px * var(--fs, 1)); color: var(--fg-3); }
.view { display: none; flex-direction: column; gap: var(--gap); }
.view.active { display: flex; animation: fade .2s ease-out; }
@keyframes fade { from { opacity: .4; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.footer { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; padding: 16px max(24px, env(safe-area-inset-right, 0px)) 22px 24px; border-top: 1px solid var(--line); color: var(--fg-3); font-size: calc(11.5px * var(--fs, 1)); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .dot.rt { background: var(--up); } .legend .dot.dl { background: var(--blue); } .legend .dot.eod { background: var(--fg-2); } .legend .dot.slow { background: var(--fg-3); } .legend .dot.st { background: var(--down); }
.foot-health { display: inline-flex; flex-wrap: wrap; gap: 4px 12px; }
.health-row { display: inline-flex; align-items: center; gap: 6px; }
.health-row b { font-family: var(--mono); font-weight: 500; color: var(--fg-2); }
.footer .disc { margin-left: auto; }

/* ───────── grids ───────── */
.grid { display: grid; gap: var(--gap); min-width: 0; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); }
.g-kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-auto { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.span-all { grid-column: 1 / -1; }

/* ───────── cards ───────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); display: flex; flex-direction: column; min-width: 0; }
.card-h { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 14px var(--pad); border-bottom: 1px solid var(--line); }
.card-h .t { display: flex; align-items: center; gap: 11px; min-width: 0; flex: 1 1 220px; }
.card-h .ic { display: grid; place-items: center; color: var(--fg-2); flex: none; }
.card-h .ic svg.i { width: 20px; height: 20px; stroke-width: 1.7; }
.card-h h3 { font-size: calc(14.5px * var(--fs, 1)); line-height: 1.3; }
.card-h .t p { font-size: calc(12px * var(--fs, 1)); color: var(--fg-3); line-height: 1.35; }
.card-h .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; max-width: 100%; }
.card-b { padding: var(--pad); min-width: 0; }
.card-b.flush { padding: 0; }
.card-b.stack { display: flex; flex-direction: column; gap: 14px; }
.card-f { margin-top: auto; padding: 11px var(--pad) 13px; border-top: 1px solid var(--line); color: var(--fg-3); font-size: calc(11.5px * var(--fs, 1)); line-height: 1.55; }
.card-f b { color: var(--fg-2); font-weight: 600; }

/* ───────── badges / chips ───────── */
.badge { display: inline-flex; align-items: center; height: 19px; font-family: var(--mono); font-size: calc(10px * var(--fs, 1)); font-weight: 500; padding: 0 7px; border-radius: 5px; border: 1px solid var(--line-2); color: var(--fg-2); text-transform: none; letter-spacing: 0; white-space: nowrap; }
.badge.realtime, .badge.measured { color: var(--up); border-color: color-mix(in srgb, var(--up) 45%, transparent); background: color-mix(in srgb, var(--up) 8%, transparent); }
.badge.delayed, .badge.reference { color: var(--blue-text); border-color: color-mix(in srgb, var(--blue) 45%, transparent); background: color-mix(in srgb, var(--blue) 8%, transparent); }
.badge.eod { color: var(--fg-2); }
.badge.weekly, .badge.monthly { color: var(--fg-3); }
.badge.stale, .badge.error, .badge.bad { color: var(--down); border-color: color-mix(in srgb, var(--down) 45%, transparent); background: color-mix(in srgb, var(--down) 8%, transparent); }
.badge.estimate, .badge.demo, .badge.mid { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: color-mix(in srgb, var(--warn) 8%, transparent); }
.badge.ai { color: var(--violet); border-color: color-mix(in srgb, var(--violet) 45%, transparent); background: color-mix(in srgb, var(--violet) 8%, transparent); }

/* ───────── controls ───────── */
.seg { display: inline-flex; max-width: 100%; overflow-x: auto; scrollbar-width: none; padding: 3px; gap: 2px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: none; border: 0; background: transparent; color: var(--fg-2); padding: 4px 10px; border-radius: 6px; font-size: calc(12px * var(--fs, 1)); font-weight: 500; white-space: nowrap; }
.seg button:hover { color: var(--fg); }
.seg button.active { background: var(--raised); color: var(--fg); box-shadow: 0 1px 0 var(--line-2), inset 0 0 0 1px var(--line-2); }
.seg.mono button { font-family: var(--mono); font-size: calc(11.5px * var(--fs, 1)); }
.input, select, input[type=text], input[type=password], input[type=number] { height: 34px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 0 10px; color: var(--fg); font-size: calc(13px * var(--fs, 1)); min-width: 0; }
select { padding-right: 28px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--fg-3) 50%), linear-gradient(135deg, var(--fg-3) 50%, transparent 50%); background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; background-size: 5px 5px; background-repeat: no-repeat; }
.search { position: relative; display: inline-flex; align-items: center; flex: 1 1 180px; max-width: 280px; }
.search svg.i { position: absolute; left: 10px; color: var(--fg-3); pointer-events: none; }
.search input { width: 100%; padding-left: 32px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid transparent; background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: calc(13px * var(--fs, 1)); white-space: nowrap; }
.btn:hover { filter: brightness(1.06); }
.btn.ghost { background: var(--surface-2); color: var(--fg); border-color: var(--line-2); }
.btn.ghost:hover { border-color: var(--fg-3); filter: none; }
.btn.ghost.on { color: var(--fg); border-color: var(--fg-3); background: var(--raised); }
.btn:disabled { opacity: .55; cursor: default; }
.btn .count { font-family: var(--mono); font-size: calc(11px * var(--fs, 1)); padding: 0 6px; border-radius: 5px; background: var(--raised); color: var(--fg-2); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px var(--pad); border-bottom: 1px solid var(--line); }
.toolbar .grow { flex: 1 1 auto; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: calc(11.5px * var(--fs, 1)); color: var(--fg-3); font-weight: 500; text-transform: none; letter-spacing: 0; }
.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; align-items: end; }
input[type=range] { width: 100%; accent-color: var(--fg-2); height: 34px; }

/* ───────── tables ───────── */
.tbl { overflow-x: auto; min-width: 0; -webkit-overflow-scrolling: touch; }
.tbl.scroll-y { max-height: 640px; overflow-y: auto; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: calc(13px * var(--fs, 1)); }
table.t th, table.t td { padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; text-align: left; }
table.t th { position: sticky; top: 0; z-index: 2; background: var(--surface); font-size: calc(11px * var(--fs, 1)); font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--fg-3); }
table.t th.num, table.t td.num { text-align: right; }
table.t th.sortable { cursor: pointer; user-select: none; }
table.t th.sortable:hover { color: var(--fg-2); }
table.t th.sorted { color: var(--fg); }
table.t th.sorted::after { content: " ↓"; } table.t th.sorted.asc::after { content: " ↑"; }
table.t tbody tr { transition: background .1s; }
table.t tbody tr[data-id] { cursor: pointer; }
table.t tbody tr:hover td { background: var(--surface-2); }
table.t tbody tr:last-child td { border-bottom: 0; }
table.t td.stick, table.t th.stick { position: sticky; left: 0; z-index: 1; background: var(--surface); }
table.t th.stick { z-index: 3; }
table.t tbody tr:hover td.stick { background: var(--surface-2); }
.inst { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.inst b { font-family: var(--mono); font-size: calc(12px * var(--fs, 1)); font-weight: 600; }
.inst span { font-size: calc(12px * var(--fs, 1)); color: var(--fg-3); max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.star { border: 0; background: none; padding: 2px; color: var(--fg-3); display: inline-grid; }
.star.on { color: var(--warn); } .star.on svg.i { fill: currentColor; }
.hcell { border-radius: 5px; padding: 3px 7px; display: inline-block; min-width: 62px; text-align: right; }
.rangebar { position: relative; display: inline-block; width: 70px; height: 6px; border-radius: 999px; background: var(--raised); vertical-align: middle; }
.rangebar i { position: absolute; top: -3px; width: 4px; height: 12px; border-radius: 2px; background: var(--fg); transform: translateX(-50%); }
.meter { position: relative; display: block; height: 6px; border-radius: 999px; background: var(--raised); overflow: hidden; }
.meter i { position: absolute; inset: 0 auto 0 0; border-radius: 999px; }
.spark { width: 76px; height: 22px; display: block; }

/* ───────── KPI ───────── */
.kpi { padding: 15px 16px 12px; cursor: pointer; transition: border-color .15s, transform .15s; }
.kpi:hover { border-color: var(--line-2); transform: translateY(-1px); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.kpi-top span { font-size: calc(12px * var(--fs, 1)); color: var(--fg-2); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-val { font-family: var(--mono); font-size: calc(25px * var(--fs, 1)); font-weight: 600; letter-spacing: -.02em; margin: 6px 0 2px; white-space: nowrap; }
.kpi-val small { font-size: calc(12px * var(--fs, 1)); color: var(--fg-3); font-weight: 400; margin-left: 4px; letter-spacing: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 4px 10px; font-family: var(--mono); font-size: calc(11.5px * var(--fs, 1)); color: var(--fg-3); }
.chips b { font-weight: 500; }
.kpi svg.area { display: block; width: 100%; height: 42px; margin-top: 10px; }
.kpi-foot { font-size: calc(11px * var(--fs, 1)); color: var(--fg-3); margin-top: 6px; }

/* ───────── overview specifics ───────── */
.size-strip { display: flex; gap: 4px; height: 52px; }
.strip-seg { min-width: 6px; border-radius: var(--r-sm); color: #fff; padding: 6px 10px; display: flex; flex-direction: column; justify-content: center; overflow: hidden; white-space: nowrap; font-size: calc(11.5px * var(--fs, 1)); line-height: 1.3; }
.strip-seg b { font-family: var(--mono); font-weight: 600; font-size: calc(12px * var(--fs, 1)); overflow: hidden; text-overflow: ellipsis; }
.strip-seg span { opacity: .9; overflow: hidden; text-overflow: ellipsis; }
.strip-seg.narrow span, .strip-seg.narrow b { display: none; }
.regime-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.regime-head .big { font-family: var(--mono); font-size: calc(28px * var(--fs, 1)); font-weight: 700; letter-spacing: -.02em; }
.gauge { position: relative; height: 8px; border-radius: 999px; background: linear-gradient(90deg, var(--down), var(--warn) 50%, var(--up)); opacity: .9; }
.gauge i { position: absolute; top: -4px; width: 4px; height: 16px; border-radius: 2px; background: var(--fg); transform: translateX(-50%); box-shadow: 0 0 0 3px var(--surface); }
.gauge-l { display: flex; justify-content: space-between; font-size: calc(10.5px * var(--fs, 1)); color: var(--fg-3); font-family: var(--mono); margin-top: 6px; }
.comp-list { display: flex; flex-direction: column; }
.comp { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.comp:last-child { border-bottom: 0; }
.comp .l { font-size: calc(12.5px * var(--fs, 1)); }
.comp .d { font-size: calc(11.5px * var(--fs, 1)); color: var(--fg-3); grid-column: 1; }
.comp .s { font-family: var(--mono); font-weight: 600; grid-row: 1 / span 2; grid-column: 2; align-self: center; }
.heat { display: flex; flex-direction: column; gap: 14px; }
.heat-row { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; align-items: start; }
.heat-row .cls { font-size: calc(11px * var(--fs, 1)); font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--fg-3); padding-top: 10px; display: flex; align-items: center; gap: 7px; }
.heat-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 6px; }
.tile { border-radius: var(--r-sm); padding: 9px 11px; min-height: 60px; display: flex; flex-direction: column; justify-content: space-between; gap: 4px; cursor: pointer; border: 1px solid transparent; transition: border-color .12s, transform .12s; min-width: 0; }
.tile:hover { border-color: var(--fg-3); transform: translateY(-1px); }
.tile .a { display: flex; justify-content: space-between; gap: 6px; align-items: baseline; }
.tile .a b { font-family: var(--mono); font-size: calc(11.5px * var(--fs, 1)); font-weight: 600; }
.tile .n { font-size: calc(11px * var(--fs, 1)); color: var(--fg-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .v { font-family: var(--mono); font-size: calc(13.5px * var(--fs, 1)); font-weight: 600; }
.mini { display: grid; gap: 10px; }
.mini-item { display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 4px 12px; align-items: center; padding: 12px 14px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); }
.mini-item .lab { font-size: calc(11.5px * var(--fs, 1)); color: var(--fg-3); text-transform: none; letter-spacing: 0; }
.mini-item .v { font-family: var(--mono); font-size: calc(18px * var(--fs, 1)); font-weight: 600; }
.mini-item .chips { grid-column: 1; }
.mini-item .ch-mini { grid-column: 2; grid-row: 1 / span 3; height: 46px; }

/* lists (signals / anomalies) */
.list { display: flex; flex-direction: column; }
.li { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; padding: 11px var(--pad); border-bottom: 1px solid var(--line); cursor: pointer; transition: background .1s; }
.li:hover { background: var(--surface-2); }
.li:last-child { border-bottom: 0; }
.li.sel { background: var(--raised); box-shadow: inset 3px 0 0 var(--fg); }
.li .ico { width: 32px; height: 32px; display: grid; place-items: center; grid-row: 1 / span 2; }
.li .ico svg.i { width: 20px; height: 20px; }
.li .ico.up { color: var(--up); }
.li .ico.down { color: var(--down); }
.li .ico.mid { color: var(--warn); }
.li .ti { font-weight: 600; font-size: calc(13px * var(--fs, 1)); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .ti span { font-family: var(--mono); font-weight: 500; color: var(--fg-3); font-size: calc(11.5px * var(--fs, 1)); margin-left: 6px; }
.li .de { font-size: calc(12px * var(--fs, 1)); color: var(--fg-3); grid-column: 2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .rt { grid-row: 1 / span 2; grid-column: 3; text-align: right; font-family: var(--mono); font-size: calc(12px * var(--fs, 1)); display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.empty { padding: 28px var(--pad); text-align: center; color: var(--fg-3); }
.empty svg.i { width: 26px; height: 26px; display: block; margin: 0 auto 8px; color: var(--fg-3); }

/* patterns / AI */
.pattern { border: 1px solid var(--line); border-radius: var(--r); padding: 16px; background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; }
.pattern-h { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.pattern-h b { font-size: calc(14px * var(--fs, 1)); }
.pattern .meter i { background: var(--warn); }
.check { display: flex; gap: 8px; font-size: calc(12.5px * var(--fs, 1)); align-items: flex-start; }
.check i { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--fg-3); margin-top: 6px; flex: none; }
.check.hit { color: var(--warn); } .check.hit i { background: var(--warn); border-color: var(--warn); }
.check.miss { color: var(--fg-3); }
.callout { display: flex; gap: 10px; align-items: flex-start; border-radius: var(--r); padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line); font-size: calc(13px * var(--fs, 1)); color: var(--fg-2); }
.callout svg.i { margin-top: 2px; color: var(--blue); }
.callout.warn svg.i { color: var(--warn); } .callout.err svg.i { color: var(--down); }
.callout.err { border-color: color-mix(in srgb, var(--down) 40%, transparent); }
.ai-row { display: flex; flex-wrap: wrap; gap: 10px; }
.ai-row input { flex: 1 1 260px; }
.finding { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); overflow: hidden; }
.finding h4 { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: calc(14px * var(--fs, 1)); }
.finding .row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 6px 14px; padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: calc(13px * var(--fs, 1)); }
.finding .row:last-child { border-bottom: 0; }
.finding .row > b { color: var(--fg-3); font-size: calc(11px * var(--fs, 1)); text-transform: none; letter-spacing: 0; padding-top: 2px; }
.finding ul { margin: 0; padding-left: 18px; }

/* analysis */
.reading { display: flex; flex-direction: column; gap: 10px; font-size: calc(13px * var(--fs, 1)); color: var(--fg-2); line-height: 1.55; }
.reading .hl { color: var(--fg); font-weight: 600; font-size: calc(13.5px * var(--fs, 1)); line-height: 1.45; }
.reading ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.reading .lab { font-size: calc(10.5px * var(--fs, 1)); font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--fg-3); margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.reading .lab svg.i { width: 13px; height: 13px; }
.reading .foot { font-size: calc(11.5px * var(--fs, 1)); color: var(--fg-3); }
.peers { display: flex; flex-wrap: wrap; gap: 6px; }
.peer { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: calc(11.5px * var(--fs, 1)); padding: 3px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); }
.peer i { width: 6px; height: 6px; border-radius: 50%; }
.anom { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); overflow: hidden; }
.anom-h { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 4px 14px; align-items: center; padding: 14px 16px; }
.anom-h .ico { width: 36px; height: 36px; display: grid; place-items: center; grid-row: 1 / span 2; }
.anom-h .ico svg.i { width: 22px; height: 22px; }
.anom-h .ico.up { color: var(--up); }
.anom-h .ico.down { color: var(--down); }
.anom-h .ico.mid { color: var(--warn); }
.anom-h .ti { font-weight: 600; min-width: 0; }
.anom-h .ti span { font-family: var(--mono); font-size: calc(11.5px * var(--fs, 1)); color: var(--fg-3); font-weight: 500; margin-left: 6px; }
.anom-h .m { grid-column: 2; display: flex; flex-wrap: wrap; gap: 4px 12px; font-family: var(--mono); font-size: calc(11.5px * var(--fs, 1)); color: var(--fg-3); }
.anom-h .m b { font-weight: 500; }
.anom-h .rt { grid-row: 1 / span 2; grid-column: 3; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.anom-b { padding: 14px 16px 16px; border-top: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; }
.anom-b .side { display: flex; flex-direction: column; gap: 14px; }
.hl-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.hl-item { display: grid; grid-template-columns: 34px minmax(0, 1fr); align-content: start; gap: 4px 12px; padding: 14px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); border-left: 3px solid var(--fg-3); cursor: default; }
.hl-item.high { border-left-color: var(--down); } .hl-item.elevated { border-left-color: var(--warn); } .hl-item.info { border-left-color: var(--c4); }
.hl-item .ico { width: 34px; height: 34px; display: grid; place-items: center; color: var(--fg-2); grid-row: 1 / span 3; }
.hl-item .ico svg.i { width: 20px; height: 20px; }
.hl-item.high .ico { color: var(--down); } .hl-item.elevated .ico { color: var(--warn); } .hl-item.info .ico { color: var(--c4); }
.hl-item b { font-size: calc(13.5px * var(--fs, 1)); }
.hl-item p { font-size: calc(12.5px * var(--fs, 1)); color: var(--fg-2); line-height: 1.5; }
.hl-item .ids { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.hl-item .ids button { font-family: var(--mono); font-size: calc(11px * var(--fs, 1)); padding: 2px 7px; border-radius: 5px; border: 1px solid var(--line-2); background: var(--surface); color: var(--fg-2); }
.hl-item .ids button:hover { color: var(--fg); border-color: var(--fg-3); }
.li-x { display: none; grid-column: 1 / -1; padding: 6px 0 2px; }
.li.open .li-x { display: block; }
.li .chev { transition: transform .15s; color: var(--fg-3); }
.li.open .chev { transform: rotate(180deg); }
.test-out { grid-column: 2; font-size: calc(12px * var(--fs, 1)); display: flex; align-items: center; gap: 6px; }
.test-out.ok { color: var(--up); } .test-out.bad { color: var(--down); } .test-out.run { color: var(--fg-3); }
.reading-cell { white-space: normal !important; min-width: 180px; max-width: 260px; font-size: calc(12px * var(--fs, 1)); color: var(--fg-2); }

/* pre-crash conditions */
.pre-common { border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; }
.pre-common-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.chips-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.cchip { display: inline-flex; align-items: center; gap: 7px; font-size: calc(12px * var(--fs, 1)); padding: 5px 10px; border-radius: var(--r-pill); border: 1px solid var(--line-2); color: var(--fg-3); background: var(--surface); }
.cchip i { width: 7px; height: 7px; border-radius: 50%; background: var(--line-2); }
.cchip.on { color: var(--fg); border-color: color-mix(in srgb, var(--warn) 55%, transparent); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.cchip.on i { background: var(--warn); }
.cchip.na { border-style: dashed; }
.pre-grid { align-items: start; }
.episode { border: 1px solid var(--line); border-radius: var(--r); padding: 16px; background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.ep-h { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.ep-h > div > b { font-size: calc(15px * var(--fs, 1)); }
.ep-score { text-align: right; flex: none; }
.ep-score > b { font-family: var(--mono); font-size: calc(22px * var(--fs, 1)); font-weight: 600; display: block; line-height: 1; }
.ep-score > b span { font-size: calc(13px * var(--fs, 1)); color: var(--fg-3); font-weight: 500; }
.episode .meter i { background: var(--warn); }
.cond-list { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.cond { display: grid; grid-template-columns: 10px minmax(0, 1fr); gap: 2px 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.cond i { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; background: var(--line-2); }
.cond.hit i { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 20%, transparent); }
.cond.na i { background: transparent; border: 1.5px dashed var(--fg-3); }
.cond .cl { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cond .cl b { font-size: calc(12.5px * var(--fs, 1)); font-weight: 600; }
.cond.miss .cl b { color: var(--fg-2); font-weight: 500; }
.cond.na .cl b { color: var(--fg-3); font-weight: 500; }
.cond .then { font-size: calc(11.5px * var(--fs, 1)); color: var(--fg-3); line-height: 1.45; }
.cond .cn { grid-column: 2; font-family: var(--mono); font-size: calc(11.5px * var(--fs, 1)); color: var(--fg); padding: 4px 8px; border-radius: 5px; background: var(--surface); border: 1px solid var(--line); margin-top: 3px; overflow-wrap: anywhere; }
.cond.miss .cn, .cond.na .cn { color: var(--fg-2); }
@media (max-width: 1199px) { .pre-grid { grid-template-columns: minmax(0, 1fr); } }

/* forms (admin) */
.form-row { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 6px 16px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.form-row:last-of-type { border-bottom: 0; }
.form-row > label { font-weight: 500; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.form-row .help { grid-column: 2; color: var(--fg-3); font-size: calc(12px * var(--fs, 1)); }
.form-row .inline { display: flex; gap: 8px; flex-wrap: wrap; min-width: 0; }
.form-row .inline input { flex: 1 1 120px; }
code { font-family: var(--mono); font-size: calc(12px * var(--fs, 1)); background: var(--raised); padding: 1px 5px; border-radius: 4px; }

/* charts */
.ch { width: 100%; height: 320px; min-width: 0; }
.ch-lg { height: 400px; } .ch-sm { height: 240px; } .ch-xl { height: 520px; }

/* ───────── popover / drawer / sheet ───────── */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(4, 7, 12, .5); backdrop-filter: blur(2px); }
.popover { position: fixed; z-index: 50; width: 360px; max-width: calc(100vw - 24px); max-height: min(560px, 75vh); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.pop-h { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.pop-h .search { max-width: none; }
.pop-b { overflow-y: auto; padding: 6px 12px 12px; }
.pop-g { font-size: calc(10.5px * var(--fs, 1)); font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--fg-3); padding: 12px 2px 6px; }
.pop-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; }
.pop-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: calc(12.5px * var(--fs, 1)); min-width: 0; }
.pop-item:hover { background: var(--surface-2); }
.pop-item input { accent-color: var(--fg); margin: 0; flex: none; }
.pop-item b { font-family: var(--mono); font-size: calc(11.5px * var(--fs, 1)); font-weight: 600; }
.pop-item span { color: var(--fg-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: calc(11.5px * var(--fs, 1)); }
.pop-f { display: flex; gap: 8px; justify-content: flex-end; padding: 12px; border-top: 1px solid var(--line); }

.drawer { position: fixed; z-index: 45; top: 0; right: 0; bottom: 0; width: min(600px, 100vw); display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line-2); box-shadow: var(--shadow); padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); animation: slidein .2s ease-out; }
@keyframes slidein { from { transform: translateX(24px); opacity: .5; } to { transform: none; opacity: 1; } }
.drawer-h { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-h .t { flex: 1; min-width: 0; }
.drawer-h h3 { font-size: calc(16px * var(--fs, 1)); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.drawer-h p { font-family: var(--mono); font-size: calc(12px * var(--fs, 1)); color: var(--fg-3); }
.drawer-b { overflow-y: auto; padding: 18px 20px 28px; display: flex; flex-direction: column; gap: 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.stat { background: var(--surface-2); padding: 10px 12px; min-width: 0; }
.stat span { display: block; font-size: calc(10.5px * var(--fs, 1)); color: var(--fg-3); text-transform: none; letter-spacing: 0; }
.stat b { font-family: var(--mono); font-size: calc(13.5px * var(--fs, 1)); font-weight: 600; white-space: nowrap; }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 16px; font-size: calc(12.5px * var(--fs, 1)); }
.kv dt { color: var(--fg-3); } .kv dd { margin: 0; text-align: right; font-family: var(--mono); overflow-wrap: anywhere; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }


.toast { position: fixed; z-index: 60; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--raised); border: 1px solid var(--line-2); color: var(--fg); padding: 10px 16px; border-radius: var(--r); box-shadow: var(--shadow); font-size: calc(13px * var(--fs, 1)); }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--fg-3); padding: 36px; }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--fg); animation: rot .8s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
.skeleton { border-radius: var(--r-lg); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: sh 1.4s infinite; border: 1px solid var(--line); }
@keyframes sh { to { background-position: -200% 0; } }

/* ───────── responsive ─────────
   ≥1200: sidebar docked left. 760–1199: sidebar off-canvas (News & TV button in the header). <760: compact header,
   scrollable nav row under it, off-canvas sidebar. */
@media (max-width: 1600px) { .live { display: none; } .brand-t span { display: none; } }
@media (max-width: 1440px) {
  .kpi-val { font-size: calc(22px * var(--fs, 1)); }
  .nav button { padding: 8px 9px; }
}
@media (max-width: 1500px) { .nav button:not(.active) .lbl { display: none; } .nav button:not(.active) .tag { display: none; } }
@media (max-width: 1199px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 50; top: 0; left: 0; bottom: 0; height: 100vh; width: min(360px, 92vw); transform: translateX(-102%); transition: transform .22s ease-out; box-shadow: var(--shadow); padding-top: env(safe-area-inset-top, 0px); }
  .sidebar.open { transform: none; }
  .side-close { display: inline-grid; }
  .side-resize { display: none; }
  #side-btn { display: inline-grid; }
  .g-main, .g-3 { grid-template-columns: minmax(0, 1fr); }
  .g-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .live { display: none; }
  .nav button .tag { display: none; }
}
@media (max-width: 900px) {
  .g-2 { grid-template-columns: minmax(0, 1fr); }
  .top-row .nav { display: none; }
  .nav-mobile { display: flex; padding: 0 max(10px, env(safe-area-inset-right, 0px)) 0 max(10px, env(safe-area-inset-left, 0px)); border-top: 1px solid var(--line); }
  .nav-mobile button { padding: 9px 10px; font-size: calc(12.5px * var(--fs, 1)); }
  .nav-mobile button.active::after { bottom: 0; }
  .nav-mobile .nav-sep { display: none; }
  .nav-mobile button .lbl { display: inline !important; }
  .nav-mobile { mask-image: linear-gradient(90deg, #000 92%, transparent); }
}
@media (max-width: 759px) {
  :root { --gap: 12px; --pad: 14px; --top-h: 50px; }
  body { font-size: calc(13px * var(--fs, 1)); }
  .brand-t { display: none; }
  .top-row { padding: 0 max(12px, env(safe-area-inset-right, 0px)) 0 max(12px, env(safe-area-inset-left, 0px)); gap: 10px; }
  .logo { width: 30px; height: 30px; border-radius: 8px; }
  #stress-pill, #connect-btn { display: none; }
  .pill { height: 28px; padding: 0 10px; font-size: calc(10.5px * var(--fs, 1)); }
  .icon-btn { width: 32px; height: 32px; }
  .ticker { height: 30px; } .ticker-inner { padding: 6px 14px; font-size: calc(11.5px * var(--fs, 1)); }
  main { padding: 12px max(14px, env(safe-area-inset-right, 0px)) 24px max(14px, env(safe-area-inset-left, 0px)); }
  .page-head { padding-bottom: 12px; } .page-head h1 { font-size: calc(17px * var(--fs, 1)); } .page-head p { display: none; }
  .footer { padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px)); }
  .footer .disc { margin-left: 0; }
  .card { border-radius: 12px; }
  .card-h { padding: 12px var(--pad); }
  .card-h .t { flex-basis: 100%; }
  .card-h .actions { width: 100%; }
  .kpi { padding: 12px; }
  .kpi-val { font-size: calc(19px * var(--fs, 1)); }
  .kpi svg.area { height: 34px; }
  .chips { font-size: calc(10.5px * var(--fs, 1)); gap: 2px 8px; }
  .heat-row { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .heat-row .cls { padding-top: 0; }
  .heat-tiles { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .tile { min-height: 54px; padding: 8px 9px; }
  .ch { height: 280px; } .ch-lg { height: 320px; } .ch-xl { height: 440px; }
  .hide-sm { display: none !important; }
  table.t th, table.t td { padding: 9px 10px; }
  .inst span { max-width: 130px; }
  .form-row { grid-template-columns: minmax(0, 1fr); }
  .form-row .help { grid-column: 1; }
  .finding .row { grid-template-columns: minmax(0, 1fr); }
  .anom-b { grid-template-columns: minmax(0, 1fr); }
  .hl-list { grid-template-columns: minmax(0, 1fr); }
  .test-out { grid-column: 1; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .drawer { width: 100vw; top: auto; height: 92vh; border-radius: 18px 18px 0 0; border-left: 0; border-top: 1px solid var(--line-2); animation: up .2s ease-out; }
  @keyframes up { from { transform: translateY(30px); opacity: .5; } to { transform: none; opacity: 1; } }
  .popover { left: 0 !important; right: 0; top: auto !important; bottom: 0; width: 100vw; max-width: 100vw; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .search { max-width: none; }
  .sidebar { width: 100vw; }
  .tv-modal { padding: max(10px, env(safe-area-inset-top, 0px)) 10px 10px; }
  .tv-modal-h .row-actions { margin-left: 0; width: 100%; }
}

/* admin: TV channel editor */
.tv-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.tv-row input { flex: 1 1 140px; height: 32px; font-size: calc(12.5px * var(--fs, 1)); }
.tv-row input.mono { flex: 2 1 220px; font-family: var(--mono); font-size: calc(12px * var(--fs, 1)); }

/* ───────── terminal typography: one narrow monospace face, Title Case labels, tabular/slashed numerals ───────── */
.nav button, .card-h h3, .side-h h2, .page-head h1, .pill, .btn, .seg button, .chip, .pop-g, .finding h4, .drawer-h h3, .tabbar button { text-transform: none; letter-spacing: 0; }
.nav button { font-size: calc(12px * var(--fs, 1)); }
.card-h h3 { font-size: calc(13px * var(--fs, 1)); font-weight: 700; }
.card-h .t p { font-size: calc(11.5px * var(--fs, 1)); }
.side-h h2 { font-size: calc(12px * var(--fs, 1)); font-weight: 700; }
.page-head h1 { font-size: calc(18px * var(--fs, 1)); font-weight: 700; letter-spacing: -.01em; }
.page-head p { font-size: calc(11.5px * var(--fs, 1)); }
.btn { font-size: calc(12px * var(--fs, 1)); } .seg button { font-size: calc(11px * var(--fs, 1)); } .chip { font-size: calc(10.5px * var(--fs, 1)); }
.kpi-val { font-size: calc(23px * var(--fs, 1)); font-weight: 700; letter-spacing: -.01em; }
.kpi-top span { font-size: calc(11.5px * var(--fs, 1)); text-transform: none; letter-spacing: 0; }
.regime-head .big { letter-spacing: 0; }
.news-item .nt { font-size: calc(12px * var(--fs, 1)); font-weight: 500; line-height: 1.45; }
.hl-item b, .li .ti, .anom-h .ti, .pattern-h b, .ep-h > div > b { letter-spacing: -.01em; }
.reading, .hl-item p, .callout { font-size: calc(12px * var(--fs, 1)); }
table.t { font-size: calc(12px * var(--fs, 1)); }
.brand-t b { text-transform: none; letter-spacing: 0; font-size: calc(13px * var(--fs, 1)); }
.brand-t span { letter-spacing: .02em; }
@media (max-width: 759px) { .kpi-val { font-size: calc(18px * var(--fs, 1)); } .card-h h3 { font-size: calc(12.5px * var(--fs, 1)); } }
.chip-row { gap: 4px; }
.chip { padding: 3px 8px; letter-spacing: 0; }
.badge { letter-spacing: 0; font-size: calc(10.5px * var(--fs, 1)); }
@media (max-width: 759px) {
  .badge { padding: 0 5px; font-size: calc(9.5px * var(--fs, 1)); letter-spacing: 0; }
  .kpi-top { gap: 6px; }
  .kpi-top .badge { flex: none; }
}

/* header: its own band, set apart from the page */
:root { --head-bg: #141418; --head-line: #26262c; }
:root[data-theme="light"] { --head-bg: #ffffff; --head-line: #e4e4e7; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) { --head-bg: #ffffff; --head-line: #e4e4e7; } }
.topbar { background: linear-gradient(180deg, color-mix(in srgb, var(--head-bg) 100%, transparent), color-mix(in srgb, var(--head-bg) 94%, var(--bg))); border-bottom: 1px solid var(--head-line); box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--warn) 85%, transparent), 0 6px 18px rgba(0, 0, 0, .28); }
.topbar .logo { background: #fb8b1e; color: #000; box-shadow: none; }
.topbar .nav button:hover { background: color-mix(in srgb, var(--fg) 7%, transparent); }
.topbar .nav button.active { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--fg); }
.topbar .nav button.active::after { background: var(--warn); }
.topbar .icon-btn { background: transparent; }
.ticker { background: var(--bg); }

/* status pills: filled with the palette, ink chosen for contrast */
.pill { border-width: 0; font-weight: 700; }
.pill .dot { background: currentColor !important; opacity: .55; }
.pill.on { background: #4af6c3; color: #000; }
.pill.mid { background: #fb8b1e; color: #000; }
.pill.off { background: #ff433d; color: #fff; }
.pill:not(.on):not(.mid):not(.off) { background: var(--raised); color: var(--fg-2); }
.pill:hover { filter: brightness(1.08); }

/* regime readout: label and score share one size */
.regime-head { align-items: baseline; gap: 14px; }
.regime-head .big, .regime-head .score { font-family: var(--mono); font-size: calc(26px * var(--fs, 1)); font-weight: 700; line-height: 1.1; letter-spacing: -.01em; }
.regime-head .score { color: var(--fg-2); }
@media (max-width: 759px) { .regime-head .big, .regime-head .score { font-size: calc(21px * var(--fs, 1)); } }

/* real-time ticks */
@keyframes flash-up { from { background: color-mix(in srgb, var(--up) 35%, transparent); } to { background: transparent; } }
@keyframes flash-down { from { background: color-mix(in srgb, var(--down) 35%, transparent); } to { background: transparent; } }
.tick-up { animation: flash-up .9s ease-out; border-radius: 4px; }
.tick-down { animation: flash-down .9s ease-out; border-radius: 4px; }
body.rt-on .live .dot { background: var(--up); box-shadow: 0 0 0 3px color-mix(in srgb, var(--up) 25%, transparent); }
body.rt-on .live { color: var(--up); }

/* ───────── mobile refinements ───────── */
@media (max-width: 759px) {
  /* KPI cards: let names wrap to two lines instead of truncating; badge stays top-right */
  .kpi-top { align-items: flex-start; }
  .kpi-top > span:first-child { white-space: normal; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.3; min-height: 2.6em; }
  .kpi-val { margin-top: 4px; }
  .kpi-val small { display: block; margin: 0; font-size: calc(10.5px * var(--fs, 1)); }
  /* nav row: fade both edges so it reads as scrollable */
  .nav-mobile { mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 24px), transparent); }
  /* card toolbars and segmented controls wrap cleanly */
  .toolbar { gap: 8px; }
  .toolbar .seg { max-width: 100%; }
  .seg { mask-image: linear-gradient(90deg, #000 calc(100% - 18px), transparent); }
  .seg:not(:has(button:nth-child(5))) { mask-image: none; }
  /* lists: tighter icon column, keep metadata from colliding */
  .li { grid-template-columns: 26px minmax(0, 1fr) auto; gap: 2px 10px; padding: 10px var(--pad); }
  .li .ico { width: 26px; height: 26px; }
  .anom-h { grid-template-columns: 28px minmax(0, 1fr) auto; gap: 4px 10px; padding: 12px 14px; }
  .anom-h .ico { width: 28px; height: 28px; }
  .hl-item { grid-template-columns: 26px minmax(0, 1fr); padding: 12px; }
  .hl-item .ico { width: 26px; height: 26px; }
  /* tables: smaller cells, readable sticky first column */
  table.t { font-size: calc(11.5px * var(--fs, 1)); }
  table.t th, table.t td { padding: 8px 9px; }
  .hcell { min-width: 54px; padding: 2px 5px; }
  /* header pills: a touch smaller */
  .top-actions { gap: 6px; }
  .pill { height: 26px; padding: 0 9px; font-size: calc(10.5px * var(--fs, 1)); }
  /* page head + footer spacing */
  .footer { gap: 6px 14px; font-size: calc(11px * var(--fs, 1)); }
  .regime-head { gap: 10px; }
  /* drawer stat grid and kv rows */
  .kv { font-size: calc(12px * var(--fs, 1)); }
  .stat b { font-size: calc(12.5px * var(--fs, 1)); }
}
@media (max-width: 380px) {
  .g-kpi { grid-template-columns: minmax(0, 1fr); }
  .top-row .brand { display: none; }
}

/* live indicator: compact dot + "Live" on narrower screens when real-time is on */
@media (max-width: 1599px) {
  body.rt-on .live { display: inline-flex; padding: 0 2px; gap: 5px; font-size: calc(11px * var(--fs, 1)); }
  body.rt-on .live #updated { display: none; }
  body.rt-on .live::after { content: "Live"; font-weight: 700; }
}

/* ═════════════════════ phone app shell (<760px) ═════════════════════ */
.tabbar, .app-title, .ptr, .news-tv-btn { display: none; }
.sheet { position: fixed; z-index: 52; left: 0; right: 0; bottom: 0; max-height: 86vh; overflow-y: auto; overscroll-behavior: contain; background: var(--surface); border-top: 1px solid var(--line-2); border-radius: 22px 22px 0 0; padding: 6px 16px calc(18px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -18px 48px rgba(0, 0, 0, .45); animation: sheet-up .24s cubic-bezier(.2, .8, .2, 1); transition: transform .2s ease-out; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet .grab { width: 40px; height: 5px; border-radius: 999px; background: var(--line-2); margin: 6px auto 14px; }
.sh-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 2px 2px 6px; }
.sh-sec { font-size: calc(11.5px * var(--fs, 1)); font-weight: 700; color: var(--fg-3); padding: 16px 2px 8px; }
.sh-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.sh-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 84px; padding: 12px 6px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); color: var(--fg); font-size: calc(12px * var(--fs, 1)); font-weight: 600; -webkit-tap-highlight-color: transparent; transition: transform .12s, background .12s; }
.sh-tile .sh-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--raised); color: var(--fg-2); }
.sh-tile .sh-ic svg.i { width: 21px; height: 21px; }
.sh-tile.active { border-color: color-mix(in srgb, #fb8b1e 60%, transparent); }
.sh-tile.active .sh-ic { background: color-mix(in srgb, #fb8b1e 20%, transparent); color: #fb8b1e; }
.sh-tile:active { transform: scale(.96); background: var(--raised); }
.sh-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--surface-2); }
.sh-list button { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 14px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--fg); font-size: calc(13px * var(--fs, 1)); text-align: left; -webkit-tap-highlight-color: transparent; }
.sh-list button:last-child { border-bottom: 0; }
.sh-list button:active { background: var(--raised); }
.sh-list .sh-ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--raised); color: var(--fg-2); flex: none; }
.sh-list b { margin-left: auto; font-weight: 500; font-size: calc(12px * var(--fs, 1)); color: var(--fg-3); }
.sh-foot { display: flex; flex-wrap: wrap; gap: 6px 12px; padding: 16px 2px 4px; font-size: calc(11px * var(--fs, 1)); color: var(--fg-3); }
.sh-foot p { width: 100%; }

@media (max-width: 759px) {
  :root { --tab-h: 60px; }
  body { overscroll-behavior-y: contain; -webkit-tap-highlight-color: transparent; }
  /* compact header: logo · collapsing title · status */
  .nav-mobile, #side-btn, #refresh-btn, #theme-btn, #connect-btn, #stress-pill { display: none !important; }
  .top-row { min-height: 52px; gap: 10px; padding-top: 2px; padding-bottom: 2px; }
  .topbar { box-shadow: inset 0 -2px 0 color-mix(in srgb, #fb8b1e 85%, transparent); }
  .app-title { display: block; flex: 1 1 auto; min-width: 0; font-size: calc(15px * var(--fs, 1)); font-weight: 700; opacity: 0; transform: translateY(6px); transition: opacity .18s, transform .18s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar.titled .app-title { opacity: 1; transform: none; }
  .top-actions { margin-left: auto; }
  .pill { height: 28px; }
  /* large page title, iOS-style */
  .page-head { flex-direction: column; gap: 2px; padding: 6px 0 14px; }
  .page-head h1 { font-size: calc(26px * var(--fs, 1)); font-weight: 800; letter-spacing: -.02em; }
  .page-head p { display: block; font-size: calc(12px * var(--fs, 1)); color: var(--fg-3); }
  main { padding-bottom: calc(var(--tab-h) + 24px + env(safe-area-inset-bottom, 0px)); }
  .footer { padding-bottom: calc(var(--tab-h) + 22px + env(safe-area-inset-bottom, 0px)); }

  /* bottom tab bar */
  .tabbar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; z-index: 46; left: 0; right: 0; bottom: 0; height: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px)); padding: 4px max(6px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(6px, env(safe-area-inset-left, 0px)); background: color-mix(in srgb, var(--head-bg) 86%, transparent); backdrop-filter: blur(20px) saturate(1.5); -webkit-backdrop-filter: blur(20px) saturate(1.5); border-top: 1px solid var(--head-line); }
  .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0; border: 0; background: none; color: var(--fg-3); font-size: calc(10.5px * var(--fs, 1)); font-weight: 600; padding: 2px 0; -webkit-tap-highlight-color: transparent; }
  .tab-ic { width: 54px; height: 30px; border-radius: 15px; display: grid; place-items: center; transition: background .2s, color .2s, transform .12s; }
  .tab-ic svg.i { width: 21px; height: 21px; }
  .tabbar button.active { color: var(--fg); }
  .tabbar button.active .tab-ic { background: color-mix(in srgb, #fb8b1e 22%, transparent); color: #fb8b1e; }
  .tabbar button.active .tab-ic svg.i { stroke-width: 2.1; }
  .tabbar button:active .tab-ic { transform: scale(.9); }

  /* News: a full-screen tab between header and tab bar */
  .sidebar { top: var(--hdr-h, 54px); bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px)); height: auto; width: 100vw; padding-top: 0; border-right: 0; box-shadow: none; z-index: 40; transform: translateY(14px); opacity: 0; pointer-events: none; visibility: hidden; transition: opacity .2s ease-out, transform .2s ease-out, visibility 0s .2s; }
  .sidebar.open { transform: none; opacity: 1; pointer-events: auto; visibility: visible; transition: opacity .2s ease-out, transform .2s ease-out; }
  .side-close { display: none !important; }
  body.news-open, body.sheet-open { overflow: hidden; }
  .side-news .side-h { padding-top: 14px; }
  .side-news .side-h h2 { font-size: calc(20px * var(--fs, 1)); font-weight: 800; }
  .side-news .side-h h2 svg.i { display: none; }
  .news-item { padding: 12px 16px; }
  .news-item .nt { font-size: calc(13px * var(--fs, 1)); -webkit-line-clamp: 4; }
  .side-tv { display: none; }
  .news-tv-btn { display: inline-grid; color: #fb8b1e; border-color: color-mix(in srgb, #fb8b1e 45%, transparent); }
  .side-tools .icon-btn.sm { width: 34px; height: 34px; }

  /* overlays sit above the tab bar */
  .scrim { z-index: 50; }
  .drawer { z-index: 55; border-radius: 22px 22px 0 0; height: 90vh; transition: transform .2s ease-out; }
  .drawer::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 999px; background: var(--line-2); margin: 8px auto 0; flex: none; }
  .drawer-h { touch-action: none; }
  .popover { z-index: 56; }
  .tv-modal { z-index: 60; }
  .toast { z-index: 65; bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom, 0px)); border-radius: 999px; padding: 10px 18px; }

  /* pull to refresh */
  .ptr { display: grid; place-items: center; position: fixed; z-index: 44; left: 50%; top: calc(var(--hdr-h, 54px) - 34px); width: 34px; height: 34px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow); transform: translate(-50%, 0); opacity: 0; transition: transform .2s ease-out, opacity .2s; pointer-events: none; }
  .ptr-ring { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--fg-2); }
  .ptr.ready .ptr-ring { border-top-color: #fb8b1e; border-right-color: #fb8b1e; }
  .ptr.busy { opacity: 1 !important; }
  .ptr.busy .ptr-ring { border-top-color: #fb8b1e; animation: rot .7s linear infinite; }

  /* touch feedback instead of hover */
  .card { border-radius: 16px; }
  .kpi:active, .tile:active, .li:active, .news-item:active, table.t tbody tr[data-id]:active td { transform: scale(.985); background: var(--surface-2); }
  .kpi, .tile, .li { transition: transform .1s ease-out; }
  .btn, .icon-btn, .seg button, .chip { min-height: 36px; }
  .seg button { padding: 6px 12px; }
  .chip { display: inline-flex; align-items: center; padding: 4px 11px; }
  input[type=text], input[type=password], input[type=number], select { height: 40px; font-size: max(16px, calc(16px * var(--fs, 1))); } /* 16px stops iOS zoom on focus */
}
@media (hover: none) {
  .kpi:hover, .tile:hover { transform: none; }
  .news-item:hover { background: transparent; box-shadow: none; }
  .news-item:hover .nt { color: var(--fg); }
  .news-item:active { background: color-mix(in srgb, var(--warn) 10%, var(--surface)); box-shadow: inset 3px 0 0 var(--warn); }
}

@media (max-width: 759px) {
  .tv-modal { padding: calc(10px + env(safe-area-inset-top, 0px)) 12px calc(14px + env(safe-area-inset-bottom, 0px)); background: #000; }
  .tv-modal-h { flex-wrap: nowrap; gap: 8px; }
  .tv-modal-h select { flex: 1 1 auto; max-width: none; }
  .tv-modal-h .row-actions { position: fixed; left: 12px; right: 12px; width: auto; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .tv-modal-h .row-actions .btn { height: 44px; }
  .tv-modal-b iframe { width: 100%; border-radius: 12px; }
}

/* ═════════════════════ glossary ═════════════════════ */
.gl-hero .card-b { display: flex; flex-direction: column; gap: 14px; }
.gl-intro { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; align-items: start; }
.gl-intro .gl-ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, #fb8b1e 18%, transparent); color: #fb8b1e; }
.gl-intro .gl-ic svg.i { width: 21px; height: 21px; }
.gl-intro b { font-size: calc(14px * var(--fs, 1)); }
.gl-intro p { margin-top: 3px; max-width: 900px; line-height: 1.6; }
.gl-search { max-width: none; flex: none; }
.gl-search input { height: 42px; font-size: calc(14px * var(--fs, 1)); }
.gl-cats .chip .muted { margin-left: 4px; }
.gl-sec { display: flex; flex-direction: column; gap: 10px; }
.gl-sec-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 8px 2px 0; }
.gl-sec-h h3 { font-size: calc(15px * var(--fs, 1)); font-weight: 700; }
.gl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; align-items: start; }
.gl-term { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; cursor: pointer; transition: border-color .15s, background .15s, box-shadow .3s; }
.gl-term:hover { border-color: var(--line-2); }
.gl-term.open { border-color: color-mix(in srgb, #fb8b1e 45%, var(--line)); background: color-mix(in srgb, #fb8b1e 4%, var(--surface)); }
.gl-term.flash { box-shadow: 0 0 0 3px color-mix(in srgb, #fb8b1e 55%, transparent); }
.gl-h { all: unset; display: flex; align-items: flex-start; gap: 10px; width: 100%; cursor: pointer; }
.gl-h:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; border-radius: 4px; }
.gl-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.gl-t b { font-size: calc(13.5px * var(--fs, 1)); }
.gl-aka { font-size: calc(11px * var(--fs, 1)); color: var(--fg-3); }
.gl-chev { color: var(--fg-3); transition: transform .15s; display: grid; }
.gl-term.open .gl-chev { transform: rotate(180deg); color: #fb8b1e; }
.gl-s { font-size: calc(12.5px * var(--fs, 1)); color: var(--fg-2); margin-top: 6px; line-height: 1.5; }
.gl-d { display: none; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line-2); font-size: calc(12.5px * var(--fs, 1)); line-height: 1.6; color: var(--fg); flex-direction: column; gap: 10px; cursor: default; }
.gl-term.open .gl-d { display: flex; }
.gl-x { padding: 8px 10px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); }
.gl-x .lab { display: block; font-size: calc(10.5px * var(--fs, 1)); font-weight: 700; color: #fb8b1e; margin-bottom: 2px; }
.gl-x p { color: var(--fg-2); }
.gl-links { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.gl-see { border: 1px solid var(--line-2); background: var(--surface-2); color: var(--fg-2); border-radius: 6px; padding: 3px 8px; font-size: calc(11.5px * var(--fs, 1)); }
.gl-see:hover { color: var(--fg); border-color: var(--fg-3); }
.gl-go { height: 30px; font-size: calc(11.5px * var(--fs, 1)); margin-left: auto; }
.gl-go svg.i { width: 14px; height: 14px; }
@media (max-width: 759px) {
  .gl-grid { grid-template-columns: minmax(0, 1fr); }
  .gl-intro { grid-template-columns: minmax(0, 1fr); }
  .gl-intro .gl-ic { display: none; }
  .gl-cats { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent); }
  .gl-cats .chip { flex: none; }
  .gl-term { padding: 14px; }
  .gl-go { margin-left: 0; }
}

/* ═════════════════════ live TV player (HLS) ═════════════════════ */
.tv-frame video, .tv-modal-b video { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; object-fit: contain; }
.tv-modal-b { position: relative; display: block; }
.tv-modal-b video { position: absolute; }
.tv-status { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: rgba(255, 255, 255, .8); font-size: calc(12px * var(--fs, 1)); text-align: center; padding: 16px; background: radial-gradient(ellipse at center, rgba(28, 28, 34, .6), rgba(0, 0, 0, .85)); pointer-events: none; }
.tv-status .spin { border-color: rgba(255, 255, 255, .2); border-top-color: #fb8b1e; }
.tv-status.err { color: rgba(255, 255, 255, .7); }
.tv-ui { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 8px; padding: 18px 10px 8px; background: linear-gradient(transparent, rgba(0, 0, 0, .75)); color: #fff; font-size: calc(11.5px * var(--fs, 1)); opacity: 0; transition: opacity .2s; }
.tv-frame:hover .tv-ui, .tv-modal-b .tv-ui, .tv-frame:focus-within .tv-ui { opacity: 1; }
@media (hover: none) { .tv-ui { opacity: 1; } }
.tv-live { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; color: #fff; background: #ff433d; border-radius: 4px; padding: 1px 6px; font-size: calc(10px * var(--fs, 1)); }
.tv-live i { width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: pulse 1.6s infinite; }
.tv-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.tv-btn { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 6px; border: 0; background: rgba(255, 255, 255, .14); color: #fff; padding: 0; }
.tv-btn:hover { background: rgba(255, 255, 255, .26); }
.tv-btn svg.i { width: 16px; height: 16px; }
.tv-links { padding: 0 14px; color: var(--fg-3); }
.tv-links a { color: var(--fg-2); }
.tv-poster span { color: rgba(255, 255, 255, .65); }
.tv-row .tv-relay { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
@media (max-width: 759px) {
  .tv-modal-h .row-actions { grid-template-columns: 1fr; }
  .tv-modal-b { margin-bottom: 64px; }
}

/* ═════════════════════ header v3: flat band, hairline, underline tabs ═════════════════════ */
:root { --head-bg: #0b0b0d; --head-line: #232328; }
:root[data-theme="light"] { --head-bg: #ffffff; --head-line: #e4e4e7; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) { --head-bg: #ffffff; --head-line: #e4e4e7; } }
.topbar { background: color-mix(in srgb, var(--head-bg) 94%, transparent); backdrop-filter: saturate(1.5) blur(14px); -webkit-backdrop-filter: saturate(1.5) blur(14px); border-bottom: 1px solid var(--head-line); box-shadow: none !important; }
.top-row { min-height: 56px; gap: 0; align-items: stretch; }
.top-row > .brand, .top-row > .top-actions, .top-row > .app-title { align-self: center; }
.brand { gap: 10px; padding-right: 18px; margin-right: 8px; border-right: 1px solid var(--head-line); }
.topbar .logo { width: 28px; height: 28px; border-radius: 7px; background: #fb8b1e; color: #000; box-shadow: none; }
.topbar .logo svg.i { width: 16px; height: 16px; stroke-width: 2.4; }
.brand-t b { font-size: calc(13px * var(--fs, 1)); font-weight: 700; letter-spacing: .01em; }
.top-row .nav { align-self: stretch; align-items: stretch; gap: 0; }
.nav button { border-radius: 0; padding: 0 12px; color: var(--fg-3); font-weight: 500; font-size: calc(12.5px * var(--fs, 1)); transition: color .15s; }
.nav button:hover { background: transparent; color: var(--fg); }
.topbar .nav button:hover { background: transparent; }
.nav button.active, .topbar .nav button.active { background: transparent; color: var(--fg); font-weight: 600; }
.nav button.active::after, .topbar .nav button.active::after { left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background: #fb8b1e; }
.nav button svg.i { width: 15px; height: 15px; opacity: .85; }
.nav button.active svg.i { color: #fb8b1e; opacity: 1; }
.nav .nav-sep { height: 16px; align-self: center; margin: 0 6px; background: var(--head-line); }
.top-actions { gap: 4px; padding-left: 12px; }
.top-actions .pill { height: 28px; margin-right: 2px; }
.top-actions .live { margin: 0 6px 0 4px; }
.top-actions .icon-btn { width: 32px; height: 32px; border-color: transparent; background: transparent; color: var(--fg-3); border-radius: 8px; }
.top-actions .icon-btn:hover { background: var(--raised); color: var(--fg); border-color: transparent; }
.top-actions .icon-btn.on { color: var(--up); }
#connect-btn { margin-left: 6px; position: relative; }
#connect-btn::before { content: ""; position: absolute; left: -6px; top: 7px; bottom: 7px; width: 1px; background: var(--head-line); }
.ticker { background: var(--bg); border-bottom: 1px solid var(--head-line); }
.nav-mobile button { padding: 10px 12px; }
.nav-mobile button.active::after { bottom: 0; }
@media (max-width: 759px) {
  .top-row { min-height: 52px; align-items: center; }
  .brand { border-right: 0; padding-right: 0; margin-right: 0; }
  .top-actions { padding-left: 0; }
  #connect-btn::before { display: none; }
}

/* ───────── comment round: header status pills removed, logo white on black, aligned news filters ───────── */
/* The pills stay in the DOM (hidden) so the phone "More" sheet can still show regime and stress. */
.top-actions #regime-pill, .top-actions #stress-pill { display: none !important; }
.topbar .logo { background: #000; color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22); }
:root[data-theme="light"] .topbar .logo { box-shadow: none; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .topbar .logo { box-shadow: none; } }
/* category chips span the same width as the region switch above, equal columns, same height */
.side-filters .chip-row { display: flex; flex-wrap: nowrap; gap: 4px; }
.side-filters .chip-row .chip { flex: 1 1 auto; min-width: 0; height: 30px; padding: 0 6px; letter-spacing: -.01em; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 6px; }
.side-filters .chip-row .chip[hidden] { display: none; }
.side-filters .seg { padding: 3px; }
.side-filters .seg button { height: 26px; }
@media (max-width: 759px) { .side-filters .chip-row .chip { height: 36px; font-size: calc(11px * var(--fs, 1)); } }

/* ═════════════════════ appearance (admin setting): font family and text size ═════════════════════
   data-font on <html>: terminal (JetBrains Mono, default) · classic (IBM Plex Sans + Plex Mono, the original) ·
   modern (Inter for text, JetBrains Mono for figures). --fs scales every text size. */
:root { --fs: 1; }
:root[data-font="classic"] { --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; }
:root[data-font="modern"] { --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; }
:root[data-font="classic"] body, :root[data-font="modern"] body { letter-spacing: 0; font-feature-settings: 'tnum' 1, 'cv11' 1; }
:root[data-font="modern"] body { font-feature-settings: 'tnum' 1, 'cv11' 1, 'ss01' 1; }
:root[data-font="classic"] .card-h h3, :root[data-font="modern"] .card-h h3 { font-size: calc(14px * var(--fs, 1)); font-weight: 600; }
:root[data-font="classic"] .page-head h1, :root[data-font="modern"] .page-head h1 { font-size: calc(20px * var(--fs, 1)); font-weight: 700; letter-spacing: -.015em; }
:root[data-font="classic"] .nav button, :root[data-font="modern"] .nav button { font-size: calc(13px * var(--fs, 1)); }
:root[data-font="classic"] .news-item .nt, :root[data-font="modern"] .news-item .nt { font-size: calc(13px * var(--fs, 1)); }
@media (max-width: 759px) { :root[data-font="classic"] .page-head h1, :root[data-font="modern"] .page-head h1 { font-size: calc(26px * var(--fs, 1)); font-weight: 800; } }
/* admin appearance picker: one row per font, live sample on the right */
.ui-fonts { display: flex; flex-direction: column; gap: 6px; }
.ui-font { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface-2); color: var(--fg); text-align: left; transition: border-color .15s, background .15s; }
.ui-font:hover { border-color: var(--line-2); }
.ui-font.on { border-color: #fb8b1e; background: color-mix(in srgb, #fb8b1e 7%, var(--surface-2)); }
.ui-radio { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--fg-3); display: grid; place-items: center; }
.ui-font.on .ui-radio { border-color: #fb8b1e; }
.ui-font.on .ui-radio::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #fb8b1e; }
.ui-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ui-meta b { font-size: calc(13px * var(--fs, 1)); }
.ui-prev { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; white-space: nowrap; }
.ui-prev .ui-sample { font-size: calc(15px * var(--fs, 1)); font-weight: 600; letter-spacing: -.01em; }
.ui-prev .ui-num { font-size: calc(12px * var(--fs, 1)); color: var(--fg-2); }
.ui-prev .ui-num i { font-style: normal; }
@media (max-width: 420px) { .ui-font { grid-template-columns: 18px minmax(0, 1fr); } .ui-prev { grid-column: 2; align-items: flex-start; text-align: left; } }

/* ═════════════════════ market hours chips (header, desktop) ═════════════════════ */
.sessions { display: flex; align-items: center; gap: 4px; margin-right: 6px; }
.ses { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--head-line); font-size: calc(11px * var(--fs, 1)); font-weight: 600; color: var(--fg-2); white-space: nowrap; }
.ses i { width: 6px; height: 6px; border-radius: 50%; background: var(--fg-3); opacity: .6; }
.ses em { font-style: normal; font-weight: 500; color: var(--fg-3); }
.ses.open { color: var(--fg); }
.ses.open i { background: var(--up); opacity: 1; box-shadow: 0 0 0 3px color-mix(in srgb, var(--up) 22%, transparent); }
.ses.open em { color: var(--up); }
.ses.lunch i { background: var(--warn); opacity: 1; }
.ses.lunch em { color: var(--warn); }
@media (max-width: 1360px) { .ses em { display: none; } }
@media (max-width: 1199px) { .sessions { display: none; } }

/* ═════════════════════ search palette ═════════════════════ */
.search-pane { position: fixed; z-index: 58; left: 50%; top: 72px; transform: translateX(-50%); width: min(640px, calc(100vw - 32px)); max-height: min(70vh, 640px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: 0 24px 64px rgba(0, 0, 0, .5); overflow: hidden; animation: fade .15s ease-out; }
.sp-h { display: flex; align-items: center; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); }
.sp-field { flex: 1 1 auto; max-width: none; }
.sp-field input { height: 42px; font-size: calc(14px * var(--fs, 1)); border-radius: 10px; }
.sp-b { overflow-y: auto; overscroll-behavior: contain; padding: 4px 6px 10px; }
.sp-sec { font-size: calc(11px * var(--fs, 1)); font-weight: 700; color: var(--fg-3); padding: 12px 8px 4px; }
.sp-item { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; border-radius: 8px; background: transparent; color: var(--fg); text-align: left; }
.sp-item:hover, .sp-item:focus-visible { background: var(--surface-2); }
.sp-item > svg.i { color: var(--fg-3); }
.sp-ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--raised); color: var(--fg-2); }
.sp-t { display: flex; flex-direction: column; min-width: 0; }
.sp-t b { font-size: calc(13px * var(--fs, 1)); }
.sp-t span { font-size: calc(11.5px * var(--fs, 1)); color: var(--fg-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-r { display: flex; flex-direction: column; align-items: flex-end; font-size: calc(12px * var(--fs, 1)); }
.app-title .at-sub { display: none; }

/* ═════════════════════ phone header v2: brand + market hours, collapsing page title, search ═════════════════════ */
@media (max-width: 759px) {
  .topbar { background: var(--head-bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .top-row { gap: 10px; min-height: 56px; padding-top: 4px; padding-bottom: 4px; }
  .top-row .brand { display: flex !important; flex: none; }
  .topbar .logo { width: 34px; height: 34px; border-radius: 9px; }
  .topbar .logo svg.i { width: 18px; height: 18px; }
  .app-title { display: flex; flex-direction: column; justify-content: center; gap: 2px; flex: 1 1 auto; min-width: 0; opacity: 1; transform: none; }
  .at-main { position: relative; display: block; height: 1.3em; overflow: hidden; font-size: calc(15px * var(--fs, 1)); line-height: 1.3; }
  .at-main b { position: absolute; inset: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; transition: transform .22s ease, opacity .22s ease; }
  .at-page { transform: translateY(100%); opacity: 0; }
  .topbar.titled .at-brand { transform: translateY(-100%); opacity: 0; }
  .topbar.titled .at-page { transform: none; opacity: 1; }
  .app-title .at-sub { display: flex; gap: 10px; font-size: calc(10.5px * var(--fs, 1)); color: var(--fg-3); white-space: nowrap; overflow: hidden; }
  .at-sub span { display: inline-flex; align-items: center; gap: 4px; }
  .at-sub i { width: 5px; height: 5px; border-radius: 50%; background: var(--fg-3); opacity: .6; }
  .at-sub .open { color: var(--fg-2); }
  .at-sub .open i { background: var(--up); opacity: 1; }
  .at-sub .lunch i { background: var(--warn); opacity: 1; }
  .top-actions { gap: 6px; }
  #search-btn { width: 38px; height: 38px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--head-line); color: var(--fg); }
  #search-btn svg.i { width: 18px; height: 18px; }
  .top-actions .live { margin: 0; }
  body.rt-on .live::after { content: ""; }
  body.rt-on .live { padding: 0 4px; }
  .live .dot { width: 8px; height: 8px; }
  .sessions { display: none; }
  /* search goes full screen on phones */
  .search-pane { inset: 0; top: 0; left: 0; transform: none; width: 100vw; max-height: none; height: 100%; border-radius: 0; border: 0; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); animation: sheet-up .2s ease-out; }
  .sp-h { padding: 10px 12px; }
  .sp-item { padding: 10px 8px; }
}
@media (max-width: 380px) { .at-sub span:nth-child(3) { display: none; } }
.sp-field input { background: var(--surface-2); border: 1px solid var(--line-2); }
.sp-field input:focus, .sp-field input:focus-visible { outline: none; border-color: #fb8b1e; box-shadow: 0 0 0 3px color-mix(in srgb, #fb8b1e 18%, transparent); }
/* admin real-time routing */
.rt-prio { display: flex; flex-wrap: wrap; gap: 6px; }
.rt-p { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface-2); font-size: calc(12px * var(--fs, 1)); }
.rt-p b { font-family: var(--mono); color: #fb8b1e; }
.rt-p i { font-style: normal; color: var(--fg-3); font-size: calc(10.5px * var(--fs, 1)); }
.rt-p.off { opacity: .6; }
.rt-p .icon-btn.sm { width: 24px; height: 24px; font-size: 12px; }
.rt-p .icon-btn:disabled { opacity: .3; cursor: default; }
.rt-tbl select { height: 28px; font-size: calc(12px * var(--fs, 1)); padding-right: 24px; }
.rt-h { text-align: center !important; }
.rt-c { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; font-size: 11px; font-weight: 700; color: var(--fg-3); }
.rt-c.ok { background: color-mix(in srgb, var(--up) 18%, transparent); color: var(--up); }
.rt-c.ok.dl { background: color-mix(in srgb, var(--blue) 18%, transparent); color: var(--blue-text); }
.rt-c.no { background: color-mix(in srgb, var(--down) 12%, transparent); color: var(--down); }
.rt-c.err { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.rt-c.na { opacity: .4; }

/* ───────── comment round 3 ───────── */
/* Market Regime readout: slightly smaller */
.regime-head .big, .regime-head .score { font-size: calc(21px * var(--fs, 1)); }
@media (max-width: 759px) { .regime-head .big, .regime-head .score { font-size: calc(18px * var(--fs, 1)); } }

/* AI card: centered empty state instead of a boxed callout inside the card */
.ai-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 26px 16px; text-align: center; color: var(--fg-3); }
.ai-empty svg.i { width: 26px; height: 26px; color: var(--violet); margin-bottom: 4px; }
.ai-empty b { color: var(--fg); font-size: calc(13.5px * var(--fs, 1)); }
.ai-empty p { font-size: calc(12.5px * var(--fs, 1)); max-width: 520px; }
#ai-ctl { margin-bottom: 4px; }
#ai-body:empty { display: none !important; }
#view-intel .card-h .actions:has(#ai-meta:empty) { gap: 0; }
#ai-meta:empty { display: none; }

/* News: region switch icons, time on each headline */
#news-region button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
#news-region button svg.i { width: 14px; height: 14px; }
.news-item .nh { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: start; }
.news-item .ntime { font-family: var(--mono); font-size: calc(11px * var(--fs, 1)); color: var(--fg-3); padding-top: 1px; font-variant-numeric: tabular-nums; }
.news-item:hover .ntime { color: var(--fg-2); }
.news-item .nm .ago { color: var(--fg-3); }

/* Glossary: full-width intro; each section is one card with a tidy dictionary list */
.gl-intro p { max-width: none; }
.gl-sec { gap: 0; }
.gl-sec .gl-sec-h { display: flex; align-items: baseline; gap: 6px 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.gl-sec .gl-sec-h h3 { font-size: calc(14px * var(--fs, 1)); font-weight: 700; padding: 0; }
.gl-count { margin-left: auto; font-family: var(--mono); font-size: calc(11px * var(--fs, 1)); color: var(--fg-3); padding: 1px 8px; border-radius: 6px; border: 1px solid var(--line-2); }
.gl-list { display: flex; flex-direction: column; }
.gl-sec .gl-term { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 0; background: transparent; }
.gl-sec .gl-term:last-child { border-bottom: 0; border-radius: 0 0 var(--r-lg) var(--r-lg); }
.gl-sec .gl-term:hover { background: var(--surface-2); }
.gl-sec .gl-term.open { background: color-mix(in srgb, #fb8b1e 5%, var(--surface)); box-shadow: inset 3px 0 0 #fb8b1e; }
.gl-sec .gl-term.flash { box-shadow: inset 3px 0 0 #fb8b1e, 0 0 0 2px color-mix(in srgb, #fb8b1e 45%, transparent); }
.gl-sec .gl-h { display: grid; grid-template-columns: minmax(170px, 260px) minmax(0, 1fr) 20px; gap: 16px; align-items: center; padding: 12px 18px; min-height: 52px; box-sizing: border-box; }
.gl-sec .gl-t { gap: 1px; }
.gl-sec .gl-s { margin: 0; color: var(--fg-2); font-size: calc(12.5px * var(--fs, 1)); line-height: 1.45; }
.gl-sec .gl-d { margin: 0; padding: 4px 18px 16px calc(18px + min(260px, max(170px, 25%)) + 16px); border-top: 0; }
@media (max-width: 1199px) { .gl-sec .gl-d { padding-left: 18px; } }
@media (max-width: 759px) {
  .gl-sec .gl-h { grid-template-columns: minmax(0, 1fr) 20px; gap: 4px 10px; padding: 12px 14px; }
  .gl-sec .gl-t { grid-column: 1; }
  .gl-sec .gl-s { grid-column: 1; grid-row: 2; }
  .gl-sec .gl-chev { grid-column: 2; grid-row: 1 / span 2; }
  .gl-sec .gl-d { padding: 2px 14px 14px; }
  .gl-sec .gl-sec-h { padding: 12px 14px; }
}
.rt-ws { display: flex; flex-direction: column; gap: 4px; }
.rt-w { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: calc(12px * var(--fs, 1)); color: var(--fg-2); }
.rt-w i { width: 7px; height: 7px; border-radius: 50%; background: var(--fg-3); }
.rt-w.live i { background: var(--up); box-shadow: 0 0 0 3px color-mix(in srgb, var(--up) 22%, transparent); animation: pulse 1.6s infinite; }
.rt-w.subscribed i, .rt-w.open i, .rt-w.connecting i, .rt-w.reconnecting i { background: var(--warn); }
.rt-w.error i { background: var(--down); }

/* flat Indonesian flag on the news region switch */
.flag-id { width: 16px; height: 11px; border-radius: 2px; flex: none; box-shadow: 0 0 0 1px var(--line-2); }

/* ═════════════════════ modern dropdowns (all selects), matched to the theme ═════════════════════ */
select, .input-select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  height: 36px; padding: 0 34px 0 12px; border-radius: 8px;
  border: 1px solid var(--line-2); background-color: var(--surface-2); color: var(--fg);
  font: inherit; font-size: calc(12.5px * var(--fs, 1)); font-weight: 500; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237c7c85' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 14px 14px;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
  text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
}
select:hover { border-color: var(--fg-3); background-color: var(--raised); }
select:focus, select:focus-visible { outline: none; border-color: #fb8b1e; box-shadow: 0 0 0 3px color-mix(in srgb, #fb8b1e 18%, transparent); }
select:disabled { opacity: .5; cursor: default; }
select option, select optgroup { background: var(--surface); color: var(--fg); font-weight: 400; }
select optgroup { color: var(--fg-3); font-weight: 600; }
:root[data-theme="light"] select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e6e78' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
.rt-tbl select, .tv-modal-h select { height: 30px; }
@media (max-width: 759px) { select { height: 40px; font-size: max(16px, calc(14px * var(--fs, 1))); } }

/* ───────── Admin: usage & API logs ───────── */
.us-card { grid-column: 1 / -1; }
.us { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.us-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.us-bar select { width: auto; min-width: 150px; }
.us-bar input[type="search"] { flex: 1 1 220px; max-width: 360px; height: 34px; }
.us-chk { display: inline-flex; align-items: center; gap: 6px; font-size: calc(12px * var(--fs, 1)); color: var(--fg-2); white-space: nowrap; }
.us-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.us-kpis > div { background: var(--surface); padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.us-kpis span { font-size: calc(11.5px * var(--fs, 1)); color: var(--fg-3); }
.us-kpis b { font-family: var(--mono); font-size: calc(20px * var(--fs, 1)); font-weight: 600; letter-spacing: -.01em; color: var(--fg); }
.us-kpis small { font-size: calc(11px * var(--fs, 1)); color: var(--fg-3); line-height: 1.35; }
.us-chart-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.us-chart { height: 220px; }
.us-chart .empty { height: 100%; }
.us-svc .us-row { cursor: pointer; }
.us-svc .us-row:hover td { background: var(--surface-2); }
.us-tog { border: 0; background: transparent; color: var(--fg-3); padding: 0 6px 0 0; vertical-align: middle; display: inline-flex; }
.us-tog svg { width: 14px; height: 14px; transition: transform .15s ease; transform: rotate(-90deg); }
.us-row.open .us-tog svg { transform: none; }
.us-op-row td { background: var(--surface-2); font-size: calc(12px * var(--fs, 1)); color: var(--fg-2); }
.us-op-row td:first-child { padding-left: 28px; }
.us-log { max-height: 460px; }
.us-log td { font-size: calc(12px * var(--fs, 1)); }
.us-op { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.us-note { max-width: 320px; }
.us-bad td:first-child { box-shadow: inset 2px 0 0 var(--down); }
.nowrap { white-space: nowrap; }
.us-rates summary { cursor: pointer; padding: 4px 0; }
.us-rates-b { display: flex; flex-direction: column; gap: 14px; padding-top: 10px; }
.us-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 14px; }
.us-grid label { display: flex; flex-direction: column; gap: 4px; font-size: calc(12px * var(--fs, 1)); color: var(--fg-2); }
.us-grid input { height: 34px; font-family: var(--mono); }
.us-meter { line-height: 1.5; }
@media (max-width: 760px) {
  .us-kpis { grid-template-columns: 1fr 1fr; }
  .us-kpis b { font-size: calc(17px * var(--fs, 1)); }
  .us-bar input[type="search"] { max-width: none; }
  .us-op, .us-note { max-width: 200px; }
  .us-svc .us-hide { display: none; }
}

/* ───────── roles: member sign-in button, ticker tag, PIN dialog ───────── */
.member-btn { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 10px 0 8px; border-radius: 9px; border: 1px solid var(--line-2); background: transparent; color: var(--fg-2); font: 500 calc(12.5px * var(--fs, 1)) var(--font); cursor: pointer; white-space: nowrap; margin-left: 4px; }
.member-btn:hover { background: var(--raised); color: var(--fg); }
.member-btn svg { width: 15px; height: 15px; }
.member-btn.on { border-color: color-mix(in srgb, var(--up) 45%, var(--line-2)); color: var(--fg); }
.mb-av { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--up); color: #000; font: 700 calc(11px * var(--fs, 1)) var(--font); flex: none; }
.mb-av.sm { width: 22px; height: 22px; margin-right: 8px; vertical-align: middle; }
.ticker { display: flex; align-items: stretch; mask-image: none; -webkit-mask-image: none; }
.ticker-track { flex: 1; min-width: 0; overflow: hidden; mask-image: linear-gradient(90deg, transparent, #000 3%, #000 96%, transparent); -webkit-mask-image: linear-gradient(90deg, transparent, #000 3%, #000 96%, transparent); }
.ticker-tag { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 0 12px 0 14px; border: 0; border-right: 1px solid var(--line); background: var(--surface-2); color: var(--fg-3); font: 600 calc(10.5px * var(--fs, 1)) var(--mono); letter-spacing: .06em; text-transform: uppercase; cursor: pointer; white-space: nowrap; }
.ticker-tag .tt-cta { color: var(--accent); text-transform: none; letter-spacing: 0; font-weight: 500; font-family: var(--font); font-size: calc(11.5px * var(--fs, 1)); }
.ticker-tag:hover .tt-cta { text-decoration: underline; }
.ticker-tag.is-live { color: var(--up); }
.ticker-tag.is-live i { width: 7px; height: 7px; border-radius: 50%; background: var(--up); box-shadow: 0 0 0 0 color-mix(in srgb, var(--up) 60%, transparent); animation: tt-pulse 1.8s ease-out infinite; }
@keyframes tt-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--up) 55%, transparent); } 100% { box-shadow: 0 0 0 7px transparent; } }
.pin-ov { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: pin-in .16s ease-out; }
@keyframes pin-in { from { opacity: 0; } }
.pin-card { position: relative; width: min(360px, 100%); background: var(--surface); border: 1px solid var(--line-2); border-radius: 16px; padding: 26px 22px 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; box-shadow: 0 24px 60px rgba(0, 0, 0, .45); }
.pin-card h3 { margin: 4px 0 0; font-size: calc(18px * var(--fs, 1)); }
.pin-card p { margin: 0; }
.pin-x { position: absolute; top: 10px; right: 10px; }
.pin-ic, .pin-av { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line-2); color: var(--fg-2); }
.pin-ic svg { width: 20px; height: 20px; }
.pin-av { border-radius: 50%; background: var(--up); color: #000; border: 0; font-weight: 700; font-size: calc(19px * var(--fs, 1)); }
.pin-form { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 4px; }
.pin-in { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.pin-dots { display: flex; gap: 10px; justify-content: center; min-height: 14px; }
.pin-dots i { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--fg-3); transition: background .12s, border-color .12s; }
.pin-dots i.on { background: var(--fg); border-color: var(--fg); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; max-width: 270px; }
.pin-pad button { height: 50px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--fg); font: 500 calc(19px * var(--fs, 1)) var(--mono); cursor: pointer; }
.pin-pad button.fn { font: 500 calc(12.5px * var(--fs, 1)) var(--font); color: var(--fg-2); }
.pin-pad button:hover { background: var(--raised); }
.pin-pad button:active { transform: scale(.97); }
.pin-err { min-height: 18px; color: var(--down); font-size: calc(12.5px * var(--fs, 1)); }
.pin-go { width: 100%; max-width: 270px; height: 42px; }
.pin-out { width: 100%; height: 40px; margin-top: 6px; }
.pin-kv { width: 100%; text-align: left; margin-top: 6px; }
.shake { animation: shake .36s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }

/* ───────── dedicated admin console ───────── */
.admin-exit, .admin-lock { display: none !important; }
body.admin-mode .admin-exit { display: inline-flex !important; height: 32px; gap: 6px; }
body.admin-mode .admin-exit svg { width: 15px; height: 15px; }
body.admin-mode[data-role="admin"] .admin-lock { display: inline-flex !important; }
body.admin-mode .ticker, body.admin-mode .sidebar, body.admin-mode .side-resize, body.admin-mode #nav, body.admin-mode .nav-mobile, body.admin-mode .tabbar,
body.admin-mode #sessions, body.admin-mode #search-btn, body.admin-mode .top-actions .live, body.admin-mode #side-btn, body.admin-mode #connect-btn, body.admin-mode #refresh-btn,
body.admin-mode #member-btn, body.admin-mode .page-head, body.admin-mode #ptr, body.admin-mode .footer { display: none !important; }
body.admin-mode .shell { grid-template-columns: minmax(0, 1fr); }
body.admin-mode main { max-width: 1480px; padding-top: 20px; }
#view-admin:not(.unlocked) .adm { display: none; }
#view-admin.unlocked .adm-lock { display: none; }
.adm-lock { min-height: calc(100vh - 160px); display: grid; place-items: center; }
.adm-lock-card { width: min(400px, 100%); display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 30px 26px 22px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 16px; }
.adm-lock-card h2 { margin: 2px 0 0; font-size: calc(20px * var(--fs, 1)); }
.adm-lock-card p { margin: 0; }
.adm-lock-card input { width: 100%; height: 42px; text-align: center; font-family: var(--mono); letter-spacing: .08em; }
.adm-lock-card .btn { width: 100%; height: 42px; }
.adm { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 22px; align-items: start; }
.adm-nav { position: sticky; top: calc(var(--top-h) + 20px); display: flex; flex-direction: column; gap: 2px; padding: 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.adm-nav button { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent; color: var(--fg-2); font: 500 calc(13px * var(--fs, 1)) var(--font); text-align: left; cursor: pointer; white-space: nowrap; }
.adm-nav button svg { width: 16px; height: 16px; flex: none; color: var(--fg-3); }
.adm-nav button:hover { background: var(--surface-2); color: var(--fg); }
.adm-nav button.active { background: var(--raised); color: var(--fg); box-shadow: inset 2px 0 0 var(--accent); }
.adm-nav button.active svg { color: var(--accent); }
.adm-body { min-width: 0; }
.adm-sec { display: none; flex-direction: column; gap: var(--gap); min-width: 0; }
.adm-sec.active { display: flex; animation: pin-in .14s ease-out; }
.adm-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); align-items: start; }
.adm-sec .us-card { grid-column: auto; }
.adm-hero h2 { margin: 0 0 4px; font-size: calc(22px * var(--fs, 1)); }
.adm-hero p { margin: 0; max-width: 640px; }
.adm-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 18px 0 22px; }
.adm-tile { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "ic l" "ic v" "ic n"; column-gap: 12px; row-gap: 2px; align-items: center; text-align: left; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--fg); cursor: pointer; font: inherit; }
.adm-tile:hover { border-color: var(--fg-3); background: var(--surface-2); }
.adm-tile-ic { grid-area: ic; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); color: var(--fg-2); align-self: start; }
.adm-tile-ic svg { width: 17px; height: 17px; }
.adm-tile-l { grid-area: l; font-size: calc(12px * var(--fs, 1)); color: var(--fg-3); }
.adm-tile b { grid-area: v; font: 600 calc(17px * var(--fs, 1)) var(--mono); }
.adm-tile small { grid-area: n; font-size: calc(11.5px * var(--fs, 1)); color: var(--fg-3); }
.adm-roles td:first-child { color: var(--fg-3); white-space: nowrap; }
.mem { display: flex; flex-direction: column; gap: 14px; }
.mem-add { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) auto; gap: 12px; align-items: end; }
.mem-add .field { margin: 0; }
.mem-add .btn { height: 38px; }
.mem-acts { display: inline-flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; align-items: center; }
.mem-acts .btn.sm { height: 28px; padding: 0 10px; font-size: calc(12px * var(--fs, 1)); }
.mem-acts .mem-newpin { width: 110px; height: 28px; font-family: var(--mono); }
.btn.danger { background: var(--down); color: #fff; border-color: transparent; }
.linkish { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline; }
@media (max-width: 1100px) { .adm-2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) {
  .adm { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .adm-nav { position: sticky; top: calc(var(--top-h) + env(safe-area-inset-top, 0px)); z-index: 20; flex-direction: row; overflow-x: auto; scrollbar-width: none; border-radius: 12px; padding: 5px; margin: 0 -2px; }
  .adm-nav::-webkit-scrollbar { display: none; }
  .adm-nav button { flex: none; height: 34px; padding: 0 12px; }
  .adm-nav button.active { box-shadow: inset 0 -2px 0 var(--accent); }
  .mem-add { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .member-btn .mb-t { display: none; }
  .member-btn { padding: 0 6px; height: 32px; border-color: transparent; }
  body.admin-mode main { padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
  body.admin-mode .admin-exit span:last-child { display: none; }
  body.admin-mode .admin-exit { padding: 0 8px; }
  .ticker-tag .tt-cta { display: none; }
  .adm-tiles { grid-template-columns: 1fr 1fr; gap: 8px; }
  .adm-tile { grid-template-columns: 1fr; grid-template-areas: "ic" "l" "v" "n"; padding: 12px; }
  .adm-tile-ic { width: 32px; height: 32px; margin-bottom: 6px; }
  .mem-t td:nth-child(3), .mem-t th:nth-child(3), .mem-t td:nth-child(4), .mem-t th:nth-child(4) { display: none; }
}

.mem-add .field > label { min-height: 18px; display: flex; align-items: flex-end; }
.mem-add .inline { gap: 8px; }

/* ───────── consistency pass: one control height, one radius, one focus ring, aligned cards and tables ───────── */
:root { --ctl-h: 36px; --ctl-r: 8px; }
.input, select, input[type=text], input[type=password], input[type=number], input[type=search], .btn { height: var(--ctl-h); border-radius: var(--ctl-r); }
.input, input[type=text], input[type=password], input[type=number], input[type=search] { font-size: calc(13px * var(--fs, 1)); background: var(--surface-2); border: 1px solid var(--line-2); color: var(--fg); transition: border-color .15s, box-shadow .15s; }
.input:hover, input[type=text]:hover, input[type=password]:hover, input[type=number]:hover, input[type=search]:hover { border-color: var(--fg-3); }
.input:focus, input[type=text]:focus, input[type=password]:focus, input[type=number]:focus, input[type=search]:focus { outline: none; border-color: #fb8b1e; box-shadow: 0 0 0 3px color-mix(in srgb, #fb8b1e 18%, transparent); }
.btn { padding: 0 14px; }
.btn.sm, .mem-acts .btn.sm { height: 28px; padding: 0 10px; border-radius: 7px; }
.seg { align-items: center; }
.seg button { height: 28px; display: inline-flex; align-items: center; }
.icon-btn { border-radius: var(--ctl-r); }
.inline { gap: 8px; }
.field > label, .form-row > label { margin-bottom: 6px; }
.row-actions { gap: 8px; }
/* cards: same header height whether or not there is a subtitle, equal heights within a row */
.card-h { min-height: 62px; }
.grid:not(.pre-grid):not(.gl-grid) { align-items: stretch; }
.adm-2 { align-items: stretch; }
.adm-2 > .card, .grid > .card { height: auto; }
/* tables: descriptions wrap instead of pushing columns out of narrow cards */
table.t th, table.t td { padding-left: 12px; padding-right: 12px; }
table.t td .inst span, table.t td > .xs, table.t td > div.xs { white-space: normal; }
#sh-table .inst span, #corr-shift .inst span, #macro-table .inst span { max-width: 190px; }
#sh-table td, #corr-shift td { padding-left: 10px; padding-right: 10px; }
/* heat tiles: the tile colour carries the sign, so the figure stays in the ink colour for contrast */
.tile .v.up, .tile .v.down { color: var(--fg); }
html[data-theme="light"] .tile .v.up, html[data-theme="light"] .tile .v.down { color: var(--fg); }
/* admin: no glossary shortcut inside the console */
body.admin-mode #help-btn { display: none !important; }
.adm-lock-card input { height: 42px; }
@media (max-width: 760px) {
  :root { --ctl-h: 40px; }
  .btn.sm, .mem-acts .btn.sm { height: 32px; }
  .seg button { height: 32px; }
  .card-h { min-height: 0; }
}
.rt-tbl select { min-width: 118px; padding-right: 30px; background-position: right 9px center; }
#adm-fields select { min-width: 220px; }
.rt-p .icon-btn.sm { width: 24px; height: 24px; }
#ai-meta { display: inline-flex; align-items: center; gap: 8px; }

/* ───────── AI market intelligence: tidy findings ───────── */
#ai-body { display: flex; flex-direction: column; gap: 12px; }
#ai-body > .callout { margin: 0; }
#ai-body > p.xs { margin: 2px 0 0; }
.finding h4 { padding: 14px 18px; line-height: 1.4; gap: 10px; }
.finding .row { grid-template-columns: 136px minmax(0, 1fr); gap: 4px 18px; padding: 12px 18px; line-height: 1.55; align-items: start; }
.finding .row > b { padding-top: 3px; font-weight: 600; line-height: 1.4; }
.finding ul { padding-left: 16px; display: flex; flex-direction: column; gap: 3px; }
.finding li::marker { color: var(--fg-3); }
.cls-list { display: flex; flex-direction: column; gap: 8px; font-size: calc(12.5px * var(--fs, 1)); }
.cls-item { display: grid; grid-template-columns: 172px minmax(0, 1fr); gap: 12px; align-items: start; }
.cls-item > .badge { justify-self: start; margin-top: 1px; }
#ai-ctl { margin-bottom: 4px; }
@media (max-width: 760px) {
  .finding .row { grid-template-columns: minmax(0, 1fr); padding: 12px 14px; }
  .finding h4 { padding: 12px 14px; }
  .cls-item { grid-template-columns: minmax(0, 1fr); gap: 4px; }
}

/* ───────── 2020–2023 episodes card ───────── */
.rc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); align-items: start; }
.rc-ep { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.rc-t { display: flex; gap: 12px; align-items: center; }
.rc-t b { font-size: calc(15px * var(--fs, 1)); letter-spacing: -.01em; }
.rc-yr { display: grid; place-items: center; min-width: 58px; height: 38px; padding: 0 8px; border-radius: 9px; background: var(--surface); border: 1px solid var(--line-2); font: 600 calc(12.5px * var(--fs, 1)) var(--mono); color: var(--accent); }
.rc-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.rc-facts > div { background: var(--surface); padding: 9px 11px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.rc-facts span { font-size: calc(11px * var(--fs, 1)); color: var(--fg-3); }
.rc-facts b { font-size: calc(12px * var(--fs, 1)); font-weight: 500; line-height: 1.4; }
.rc-story { margin: 0; font-size: calc(12.5px * var(--fs, 1)); color: var(--fg-2); line-height: 1.6; }
.rc-tabs { align-self: flex-start; }
.rc-n { margin-left: 6px; font: 600 calc(10.5px * var(--fs, 1)) var(--mono); padding: 1px 6px; border-radius: 5px; background: var(--surface); color: var(--fg-3); }
.rc-n.hot { color: var(--warn); }
.rc-q { margin: 0; font-size: calc(12.5px * var(--fs, 1)); color: var(--fg-2); }
.rc-impact { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: calc(12.5px * var(--fs, 1)); line-height: 1.55; }
.rc-impact li::marker { color: var(--fg-3); font-family: var(--mono); }
.rc-ep .callout { margin: 0; }
.rc-src a { color: var(--fg-2); }
.rc-src a:hover { color: var(--accent); }
@media (max-width: 1200px) { .rc-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) { .rc-facts { grid-template-columns: minmax(0, 1fr); } .rc-ep { padding: 14px; } .rc-tabs { align-self: stretch; } }
.rc-yr { white-space: nowrap; }
.rc-dates { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 3px; }
.rc-dates span { white-space: nowrap; }

/* ───────── anomaly scan ───────── */
.an-meta { max-width: 520px; text-align: right; line-height: 1.4; }
.an-new { font-style: normal; margin-left: 8px; padding: 1px 6px; border-radius: 5px; font: 600 calc(10.5px * var(--fs, 1)) var(--mono); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 10%, transparent); vertical-align: middle; }
.an-new.up { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.anx { display: flex; flex-direction: column; gap: 16px; }
.anx-modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.anx-mode { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 12px 14px 12px 40px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface-2); cursor: pointer; }
.anx-mode input { position: absolute; left: 14px; top: 14px; accent-color: #fb8b1e; width: 15px; height: 15px; }
.anx-mode b { font-size: calc(13px * var(--fs, 1)); }
.anx-mode span { font-size: calc(12px * var(--fs, 1)); color: var(--fg-3); line-height: 1.45; }
.anx-mode.on { border-color: #fb8b1e; background: color-mix(in srgb, #fb8b1e 7%, var(--surface-2)); }
.an-chip { display: inline-block; margin: 0 4px 2px 0; padding: 1px 7px; border-radius: 5px; font: 500 calc(11px * var(--fs, 1)) var(--mono); background: var(--surface-2); border: 1px solid var(--line-2); }
.an-chip.add { color: var(--accent); } .an-chip.clr { color: var(--fg-3); } .an-chip.esc { color: var(--warn); }
@media (max-width: 900px) { .anx-modes { grid-template-columns: minmax(0, 1fr); } .an-meta { text-align: left; } }

/* ───────── dropdowns: one simple, clean style for every select, and the menu it opens ───────── */
select, .input-select {
  height: var(--ctl-h); border-radius: var(--ctl-r); border: 1px solid var(--line-2); background-color: var(--surface-2);
  padding: 0 32px 0 12px; font-size: calc(12.5px * var(--fs, 1)); font-weight: 500; color: var(--fg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8a93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 14px 14px; box-shadow: none;
}
select:hover { border-color: var(--fg-3); background-color: var(--surface-2); }
select.dd-open, select:focus-visible { outline: none; border-color: #fb8b1e; box-shadow: 0 0 0 3px color-mix(in srgb, #fb8b1e 16%, transparent); }
.dd-menu { position: fixed; z-index: 120; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: 0 14px 40px rgba(0, 0, 0, .38), 0 2px 6px rgba(0, 0, 0, .2); overflow: hidden; animation: dd-in .12s ease-out; transform-origin: top; }
.dd-menu.up { transform-origin: bottom; }
@keyframes dd-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.dd-menu.up { animation-name: dd-in-up; } @keyframes dd-in-up { from { opacity: 0; transform: translateY(4px) scale(.98); } }
.dd-search { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); color: var(--fg-3); }
.dd-search svg { width: 14px; height: 14px; flex: none; }
.dd-search input { flex: 1; min-width: 0; height: 28px !important; border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 0 !important; font-size: calc(12.5px * var(--fs, 1)); color: var(--fg); }
.dd-list { overflow-y: auto; padding: 4px; overscroll-behavior: contain; }
.dd-group { padding: 8px 10px 4px; font-size: calc(10.5px * var(--fs, 1)); font-weight: 600; color: var(--fg-3); letter-spacing: .02em; }
.dd-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 32px; padding: 6px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--fg-2); font: 500 calc(12.5px * var(--fs, 1)) var(--font); text-align: left; cursor: pointer; }
.dd-item .dd-l { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-item.active { background: var(--raised); color: var(--fg); }
.dd-item.on { color: var(--fg); font-weight: 600; }
.dd-item:disabled { opacity: .45; cursor: default; }
.dd-ck { display: inline-flex; color: #fb8b1e; } .dd-ck svg { width: 14px; height: 14px; stroke-width: 2.4; }

/* rolling correlation: instrument pickers in one row, chart fills the card */
.roll-ctl { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; align-items: center; margin-bottom: 12px; }
.roll-ctl select { width: 100%; min-width: 0; }
.roll-vs { font-size: calc(12px * var(--fs, 1)); color: var(--fg-3); }
.card-b.grow { flex: 1 1 auto; display: flex; flex-direction: column; }
.card-b.grow > .ch { flex: 1 1 auto; min-height: 360px; height: auto; }
