/* Korgi Screener — shell + shared design system (monochrome, as BVOL).
   Module-specific styles live in modules/<id>/module.css, scoped under .m-<id>. */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --panel: #fafafa;
  --ink: #0a0a0a;
  --ink-2: #3d3d3d;
  --muted: #6b6b6b;
  --faint: #a3a3a3;
  --line: #e6e6e6;
  --line-2: #d4d4d4;
  --band: rgba(10, 10, 10, 0.07);
  --s-main: #0a0a0a;
  --s-ref: #7a7a7a;
  --s-3: #4a4a4a;
  --s-blue: #1f6fd6;         /* second and third chart series */
  --s-amber: #b7791f;
  --hover: #f2f2f2;
  --pos: #1d7a46;            /* use sparingly: PnL, deltas */
  --neg: #b42318;
  --warn: #9a6700;
  --pos-bg: rgba(29, 122, 70, 0.09);
  --neg-bg: rgba(180, 35, 24, 0.08);
  --warn-bg: rgba(154, 103, 0, 0.10);
  /* importance of a news event: text, marks (bars, stripes), tint. Text passes AA on surface, panel, hover and its own tint */
  --imp-high: #c4231a; --imp-high-fill: #dc2f26; --imp-high-bg: rgba(220, 47, 38, 0.10);
  --imp-med: #a84600;  --imp-med-fill: #d65c00;  --imp-med-bg: rgba(227, 102, 0, 0.10);
  --imp-low: #17753f;  --imp-low-fill: #1b8f4d;  --imp-low-bg: rgba(31, 154, 84, 0.10);
  --shadow: 0 10px 32px rgba(0, 0, 0, .12);
  /* roles: filled and selected marks, text on them. Equal to ink/bg in light and dark; the colour theme gives them hue */
  --sel: var(--ink); --sel-2: var(--ink-2); --on-sel: var(--bg); --on-neg: #fff; --scrim: rgba(0, 0, 0, .45); --gridline: var(--line);
  --radius: 14px;
  --radius-sm: 10px;
  --head-h: 60px;
  --tabbar-h: 0px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0a; --surface: #111111; --panel: #151515;
    --ink: #f5f5f5; --ink-2: #cfcfcf; --muted: #9a9a9a; --faint: #5e5e5e;
    --line: #242424; --line-2: #333333; --band: rgba(245, 245, 245, 0.09);
    --s-main: #f5f5f5; --s-ref: #8f8f8f; --s-3: #c2c2c2; --s-blue: #6aa9ff; --s-amber: #e3b341; --hover: #1c1c1c;
    --pos: #4cc38a; --neg: #ff7b72; --warn: #e3b341;
    --pos-bg: rgba(76, 195, 138, 0.12); --neg-bg: rgba(255, 123, 114, 0.12); --warn-bg: rgba(227, 179, 65, 0.12);
    --imp-high: #ff8077; --imp-high-fill: #f4544a; --imp-high-bg: rgba(244, 84, 74, 0.16);
    --imp-med: #ffa24d; --imp-med-fill: #f59331; --imp-med-bg: rgba(245, 147, 49, 0.16);
    --imp-low: #54d28f; --imp-low-fill: #35b873; --imp-low-bg: rgba(53, 184, 115, 0.16);
    --shadow: 0 10px 32px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0a0a; --surface: #111111; --panel: #151515;
  --ink: #f5f5f5; --ink-2: #cfcfcf; --muted: #9a9a9a; --faint: #5e5e5e;
  --line: #242424; --line-2: #333333; --band: rgba(245, 245, 245, 0.09);
  --s-main: #f5f5f5; --s-ref: #8f8f8f; --s-3: #c2c2c2; --s-blue: #6aa9ff; --s-amber: #e3b341; --hover: #1c1c1c;
  --pos: #4cc38a; --neg: #ff7b72; --warn: #e3b341;
  --pos-bg: rgba(76, 195, 138, 0.12); --neg-bg: rgba(255, 123, 114, 0.12); --warn-bg: rgba(227, 179, 65, 0.12);
  --imp-high: #ff8077; --imp-high-fill: #f4544a; --imp-high-bg: rgba(244, 84, 74, 0.16);
  --imp-med: #ffa24d; --imp-med-fill: #f59331; --imp-med-bg: rgba(245, 147, 49, 0.16);
  --imp-low: #54d28f; --imp-low-fill: #35b873; --imp-low-bg: rgba(53, 184, 115, 0.16);
  --shadow: 0 10px 32px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--head-h) + 64px); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased;
  min-height: 100vh; display: flex; flex-direction: column;
  padding-bottom: var(--tabbar-h);
  overflow-x: hidden;
}
a { color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 24px; width: 100%; }
h1 { font-size: clamp(30px, 5vw, 50px); line-height: 1.05; letter-spacing: -0.035em; font-weight: 700; margin: 0 0 14px; }
h1 span { color: var(--muted); }
h2 { font-size: 18px; letter-spacing: -0.015em; margin: 0; font-weight: 600; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 600; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--sel); outline-offset: 2px;
}

/* ================= shell: header ================= */
.top {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.top-row { display: flex; align-items: center; gap: 22px; height: var(--head-h); max-width: 1680px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: 17px; letter-spacing: -0.01em; flex: none; }
.brand svg { width: 30px; height: 30px; flex: none; }
.brand .logo-bg { fill: var(--ink); }
.brand .logo-fg { fill: none; stroke: var(--bg); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.brand .logo-ear { fill: var(--ink); }
.brand b { font-weight: 700; }
.brand small { font: 500 11px var(--mono); color: var(--muted); letter-spacing: .06em; text-transform: uppercase; margin-left: 2px; }
.tabs { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--muted);
  padding: 7px 12px; border-radius: 9px; font-size: 14px; font-weight: 500; white-space: nowrap;
}
.tab svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.tab:hover { color: var(--ink); background: var(--hover); }
.tab.on { color: var(--on-sel); background: var(--sel); }
.top-right { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: none; }
.icon-btn {
  position: relative; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; display: grid; place-items: center; padding: 0; flex: none;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .dot {
  position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--sel); color: var(--on-sel); font: 600 10px/18px var(--mono); text-align: center; border: 2px solid var(--bg);
}
.theme-dark-icon, .theme-color-icon { display: none; }
:root[data-theme="dark"] .theme-dark-icon { display: block; }
:root[data-theme="dark"] .theme-light-icon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-dark-icon { display: block; }
  :root:not([data-theme="light"]) .theme-light-icon { display: none; }
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--panel);
  display: grid; place-items: center; overflow: hidden; cursor: pointer; padding: 0; color: var(--ink);
  font: 600 13px var(--sans); flex: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.mock-badge { font: 600 11px var(--mono); letter-spacing: .06em; }

/* dropdown panels (bell, profile) */
.pop-anchor { position: relative; }
.pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; width: min(380px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
.pop-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.pop-head b { font-size: 14px; }
.pop-body { max-height: min(460px, 70vh); overflow-y: auto; overscroll-behavior: contain; }
.pop-foot { padding: 10px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.menu-item {
  display: flex; width: 100%; align-items: center; gap: 10px; padding: 10px 14px; border: 0; background: none;
  color: var(--ink); font: inherit; font-size: 14px; text-align: left; cursor: pointer; text-decoration: none;
}
.menu-item:hover { background: var(--hover); }
.menu-item svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.profile-card { padding: 14px; display: flex; gap: 12px; align-items: center; border-bottom: 1px solid var(--line); }
.profile-card .avatar { cursor: default; width: 42px; height: 42px; }
.profile-card small { display: block; color: var(--muted); font: 12px var(--mono); }

.alert-item { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; cursor: pointer; }
.alert-item:last-child { border-bottom: 0; }
.alert-item:hover { background: var(--hover); }
.alert-item.unread { background: var(--panel); }
.alert-item.unread .alert-title::after { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--sel); margin-left: 6px; vertical-align: 2px; }
.alert-item .chip { grid-row: span 2; align-self: start; }
.alert-title { font-size: 13px; font-weight: 600; line-height: 1.35; }
.alert-text { font-size: 12px; color: var(--ink-2); line-height: 1.4; overflow-wrap: anywhere; }
.alert-time { grid-column: 2; font: 11px var(--mono); color: var(--faint); }

/* ================= shell: main view + mobile tab bar ================= */
main.view { flex: 1; padding-bottom: 32px; min-width: 0; }
.tabbar {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-row {   /* every tab keeps its full label; what does not fit scrolls sideways, the active tab is brought into view */
  display: flex; height: 58px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.tabbar-row::-webkit-scrollbar { display: none; }
.tabbar a {
  flex: 1 0 auto; min-width: 62px; padding: 0 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 500;
}
.tabbar a span { padding: 0 2px; white-space: nowrap; letter-spacing: -0.01em; }
.tabbar a svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.on { color: var(--ink); }
.tabbar a.on svg { stroke-width: 2.3; }
.foot { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 22px 24px 32px; color: var(--muted); font-size: 12px; font-family: var(--mono); border-top: 1px solid var(--line); }

/* page header inside a module */
.page-head { padding: 36px 0 22px; }
.page-head .eyebrow, .eyebrow { font: 500 12px var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 12px; }
.lede { max-width: 680px; color: var(--ink-2); margin: 0; font-size: 16px; }
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 0; margin-bottom: 18px;
  position: sticky; top: var(--head-h); z-index: 10; background: var(--bg); border-bottom: 1px solid var(--line);
}
.toolbar .spacer { flex: 1; }
.subnav { display: flex; gap: 4px; flex-wrap: wrap; margin: 0 0 6px; }
.subnav a, .subnav button {
  text-decoration: none; color: var(--muted); padding: 5px 10px; border-radius: 8px; font: 500 13px var(--sans);
  background: none; border: 0; cursor: pointer; white-space: nowrap;
}
.subnav a:hover, .subnav button:hover { color: var(--ink); background: var(--hover); }
.subnav .on { color: var(--ink); background: var(--hover); }

/* ================= components ================= */
/* segmented control */
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; max-width: 100%; }
.seg button {
  font: 500 13px var(--sans); color: var(--muted); background: transparent; border: 0;
  padding: 6px 12px; border-radius: 7px; cursor: pointer; white-space: nowrap;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--sel); color: var(--on-sel); }
.seg button:disabled { opacity: .35; cursor: not-allowed; }
.seg.small button { padding: 4px 9px; font-size: 12px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: 500 13px var(--sans); color: var(--ink); background: var(--surface); text-decoration: none;
  border: 1px solid var(--line-2); border-radius: 9px; padding: 7px 13px; cursor: pointer; white-space: nowrap; line-height: 1.3;
}
.btn:hover { background: var(--hover); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn.primary { background: var(--sel); color: var(--on-sel); border-color: var(--sel); }
.btn.primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { color: var(--neg); border-color: color-mix(in srgb, var(--neg) 45%, var(--line-2)); }
.btn.danger:hover { background: var(--neg-bg); }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 8px; }
.btn.mono { font-family: var(--mono); font-size: 12px; }
.btn.block { width: 100%; }
.btn.loading { pointer-events: none; opacity: .6; }

/* chips / badges */
.chip {
  display: inline-flex; align-items: center; gap: 5px; font: 500 11px var(--mono); letter-spacing: .03em;
  padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--ink-2); background: var(--surface);
  white-space: nowrap; line-height: 1.6;
}
.chip.solid { background: var(--sel); color: var(--on-sel); border-color: var(--sel); }
.chip.pos { color: var(--pos); background: var(--pos-bg); border-color: transparent; }
.chip.neg { color: var(--neg); background: var(--neg-bg); border-color: transparent; }
.chip.warn { color: var(--warn); background: var(--warn-bg); border-color: transparent; }
.chip.muted { color: var(--muted); }
button.chip { cursor: pointer; }
button.chip:enabled:not(.solid, .on):hover { background: var(--hover); }
button.chip:enabled:not(.solid, .on):active { background: var(--line-2); }
button.chip.on { background: var(--sel); color: var(--on-sel); border-color: var(--sel); }
/* filled chips keep their --bg text, so every state must stay filled too */
button.chip.solid:enabled:hover, button.chip.on:enabled:hover { background: var(--ink-2); border-color: var(--ink-2); }
button.chip.solid:enabled:active, button.chip.on:enabled:active { background: var(--muted); border-color: var(--muted); }
button.chip:disabled { opacity: .45; cursor: not-allowed; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.imp { display: inline-flex; gap: 2px; vertical-align: middle; }
.imp i { width: 6px; height: 12px; border-radius: 2px; background: var(--line-2); }
.imp i.on { background: var(--sel); }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 22px 18px; margin-bottom: 18px; min-width: 0; }
.card.flat { padding: 0; overflow: hidden; }
.card.hover:hover { border-color: var(--line-2); }
.card-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head > div:first-child { flex: 1; min-width: 200px; }
.card-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sub { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.grid-2 > .card, .grid-3 > .card { margin-bottom: 0; }
.stack { display: grid; gap: 18px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }

/* stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.stat-label { font: 500 12px var(--mono); color: var(--muted); letter-spacing: .04em; display: flex; justify-content: space-between; gap: 8px; }
.stat-value { font-size: 30px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.15; margin: 8px 0 2px; overflow-wrap: anywhere; }
.stat-value small { font-size: 16px; color: var(--muted); font-weight: 500; margin-left: 2px; }
.stat-sub { font-size: 13px; color: var(--muted); }
.delta.up::before { content: "▲ "; font-size: 9px; vertical-align: 1px; }
.delta.down::before { content: "▼ "; font-size: 9px; vertical-align: 1px; }

/* key-value */
.kv { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 14px; margin: 14px 0 0; }
.kv div { border-top: 1px solid var(--line); padding-top: 8px; min-width: 0; }
.kv dt { font: 11px var(--mono); color: var(--muted); }
.kv dd { margin: 2px 0 0; font: 500 15px var(--mono); overflow-wrap: anywhere; }

/* tables */
.table-wrap { overflow: auto; max-height: 560px; border-top: 1px solid var(--line); -webkit-overflow-scrolling: touch; }
.table-wrap.free { max-height: none; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  position: sticky; top: 0; z-index: 1; background: var(--surface); text-align: right; font: 500 11px var(--mono);
  color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { text-align: right; padding: 8px 12px; border-bottom: 1px solid var(--line); font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.data th:first-child, table.data td:first-child, table.data .l { text-align: left; }
table.data td.text { font-family: var(--sans); }
table.data tr:hover td { background: var(--hover); }
table.data tr.clickable { cursor: pointer; }
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--ink); }
table.data th.sort-asc::after { content: " ▲"; font-size: 9px; }
table.data th.sort-desc::after { content: " ▼"; font-size: 9px; }
table.data.min { min-width: 620px; }

/* forms */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > label, .label { font: 500 12px var(--mono); color: var(--muted); letter-spacing: .03em; }
.hint { font-size: 12px; color: var(--faint); margin: 8px 0 0; }
.input, .select, .textarea {
  width: 100%; font: 14px var(--sans); color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-2); border-radius: 9px; padding: 8px 11px; min-height: 36px;
}
.input.mono { font-family: var(--mono); font-size: 13px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--sel); box-shadow: 0 0 0 3px var(--band); }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.textarea { min-height: 84px; resize: vertical; }
.select { appearance: none; -webkit-appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.search { position: relative; min-width: 0; }
.search svg { position: absolute; left: 10px; top: 50%; width: 15px; height: 15px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search .input { padding-left: 32px; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); cursor: pointer; user-select: none; }
.check input { accent-color: var(--ink); margin: 0; width: 15px; height: 15px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch i { width: 36px; height: 20px; border-radius: 10px; background: var(--line-2); position: relative; transition: background .15s; flex: none; }
.switch i::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + i { background: var(--sel); }
.switch input:checked + i::after { transform: translateX(16px); }
.switch input:focus-visible + i { outline: 2px solid var(--sel); outline-offset: 2px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }

/* modal */
.modal-back {
  position: fixed; inset: 0; z-index: 80; background: var(--scrim); display: grid; place-items: center; padding: 16px;
  animation: fade .15s ease-out; overscroll-behavior: contain; touch-action: none;
}
/* an open dialog owns the scroll: the page behind stays put, the scrollbar keeps its width */
body:has(> .modal-back) { overflow: hidden; }
html:has(> body > .modal-back) { scrollbar-gutter: stable; }
.modal {
  width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 16px; box-shadow: var(--shadow); padding: 22px;
  max-height: calc(100dvh - 32px); overscroll-behavior: contain;
}
.modal.wide { width: min(820px, 100%); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.modal-head h2 { font-size: 19px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* toasts */
.toasts { position: fixed; z-index: 90; right: 16px; bottom: calc(16px + var(--tabbar-h)); display: grid; gap: 8px; width: min(360px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; background: var(--sel); color: var(--on-sel);
  border-radius: 12px; padding: 11px 14px; font-size: 14px; box-shadow: var(--shadow); animation: toast-in .18s ease-out;
}
.toast.error { background: var(--neg); color: var(--on-neg); }
.toast.ok::before { content: "✓"; font-weight: 700; }
.toast.error::before { content: "!"; font-weight: 700; }
.toast span { flex: 1; overflow-wrap: anywhere; }
.toast button { background: none; border: 0; color: inherit; opacity: .7; cursor: pointer; font-size: 16px; line-height: 1; padding: 0; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* states: skeleton / empty / error / login required */
.skeleton { position: relative; overflow: hidden; background: var(--panel); border-radius: 8px; min-height: 14px; }
.skeleton::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--line) 70%, transparent), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-line { height: 12px; margin: 10px 0; }
.sk-block { height: 180px; border-radius: var(--radius); }
.sk-card { height: 120px; border-radius: var(--radius); }
.state {
  display: grid; justify-items: center; text-align: center; gap: 8px; padding: 40px 20px; color: var(--muted);
  border: 1px dashed var(--line-2); border-radius: var(--radius); background: var(--surface);
}
.state.plain { border: 0; background: none; padding: 24px 12px; }
.state svg { width: 34px; height: 34px; fill: none; stroke: var(--faint); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.state b { color: var(--ink); font-size: 16px; font-weight: 600; }
.state p { margin: 0; max-width: 460px; font-size: 14px; }
.state .btn { margin-top: 8px; }
.state.error svg { stroke: var(--neg); }

/* charts (uPlot + shell/charts.js) */
.plot { width: 100%; position: relative; transition: opacity .2s; min-height: 40px; }
.plot.loading { opacity: .45; }
.uplot { font-family: var(--mono); }
.u-legend { display: none; }
.u-select { background: var(--band); }
.u-cursor-x { border-right: 1px solid var(--muted) !important; }
.u-cursor-y { display: none; }
.empty { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: 14px; position: absolute; inset: 0; }
.legend { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend svg { width: 22px; height: 8px; overflow: visible; }
.tip, .k-tip {
  position: fixed; z-index: 95; pointer-events: none; min-width: 170px;   /* above .modal-back (80) and toasts (90) */
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px;
  padding: 10px 12px; box-shadow: 0 8px 28px rgba(0,0,0,.12); font-size: 12px;
}
.tip .t-time, .k-tip .t-time { color: var(--muted); font: 11px var(--mono); margin-bottom: 6px; }
.tip .t-row, .k-tip .t-row { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.tip .t-row svg, .k-tip .t-row svg { width: 16px; height: 6px; flex: none; overflow: visible; }
.tip .t-val, .k-tip .t-val { font: 600 13px var(--mono); color: var(--ink); }
.tip .t-name, .k-tip .t-name { color: var(--muted); }

/* misc */
.addr { font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }
.copy { cursor: pointer; border-bottom: 1px dashed var(--line-2); }
.divider { height: 1px; background: var(--line); margin: 16px 0; border: 0; }
.list { display: grid; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.list-item:last-child { border-bottom: 0; }
.countdown { font: 600 28px var(--mono); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

/* ================= responsive ================= */
/* the header row is wider than .wrap so all tabs fit on big screens; below that drop the icons, not the labels */
@media (min-width: 761px) and (max-width: 1680px) {
  .top-row { gap: 14px; }
  .brand small { display: none; }
  .tab { padding: 7px 9px; font-size: 13.5px; }
  .tab svg { display: none; }
}
@media (max-width: 1000px) {
  .grid-2, .grid-3, .split { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  :root { --tabbar-h: calc(58px + env(safe-area-inset-bottom)); --head-h: 56px; }
  .wrap { padding: 0 16px; }
  .top .tabs { display: none; }
  .tabbar { display: block; }
  .brand small { display: none; }
  .top-row { gap: 12px; }
  .page-head { padding: 22px 0 14px; }
  .card { padding: 16px 14px; }
  .toolbar { gap: 8px; }
  .seg { overflow-x: auto; scrollbar-width: none; }
  .seg button { padding: 6px 9px; }
  .stat-value { font-size: 24px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .modal { padding: 18px 16px; }
  .foot { padding: 18px 16px 24px; }
  .pop { position: fixed; left: 12px; right: 12px; top: calc(var(--head-h) + 6px); width: auto; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .skeleton::after, .toast, .modal-back { animation: none; }
}

/* account status line in the profile popover (accounts / approval gate) */
.pop-foot.account-status { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pop-foot.account-status a.chip { text-decoration: none; }
