/* BearBull Desk — base, components, shell. Tokens only (tokens.css).
   Rules: docs/UI_UX_RULES.md. Page-specific styles live in pages.css. */

/* ── base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 var(--fs-14)/var(--lh-14) var(--font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11" 1;
}
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: var(--fs-24); line-height: var(--lh-24); font-weight: 650; letter-spacing: -.015em; }
h2 { font-size: var(--fs-18); line-height: var(--lh-18); font-weight: 650; letter-spacing: -.01em; }
h3 { font-size: var(--fs-14); line-height: var(--lh-14); font-weight: 600; }
a { color: inherit; text-decoration: none; }
a.link, .link { color: var(--info); cursor: pointer; }
a.link:hover, .link:hover { text-decoration: underline; text-underline-offset: 3px; }
button.link, .linkish { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; color: var(--info); }
.linkish:hover { text-decoration: underline; text-underline-offset: 3px; }
.chip { flex: 0 0 auto; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
::selection { background: var(--brand-soft); }
.num, .tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: .92em; }
.up { color: var(--up); } .down { color: var(--down); } .warn-t { color: var(--warn); }
.faint { color: var(--ink-3); } .muted { color: var(--ink-2); }
.only-m { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.ic { flex: none; display: block; }
.row { display: flex; align-items: center; gap: var(--s2); }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ── buttons (§6) ───────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  height: var(--ctl-h); padding: 0 var(--s4); border-radius: var(--r); border: 1px solid transparent;
  font-size: var(--fs-14); font-weight: 600; white-space: nowrap; cursor: pointer; user-select: none;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.sm { height: var(--ctl-h-sm); padding: 0 var(--s3); font-size: var(--fs-13); border-radius: var(--r-sm); }
.btn.lg { height: var(--ctl-h-touch); padding: 0 var(--s5); font-size: var(--fs-16); }
.btn.icon-only { width: var(--ctl-h); padding: 0; }
.btn.sm.icon-only { width: var(--ctl-h-sm); }
.btn.primary { background: var(--brand); color: var(--on-brand); border-color: var(--brand-edge); box-shadow: inset 0 -1px 0 var(--brand-edge); }
.btn.primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn.secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn.secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--ink-3); }
.btn.quiet { background: transparent; color: var(--ink-2); }
.btn.quiet:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.btn.danger { background: transparent; color: var(--down); border-color: var(--line-strong); }
.btn.danger:hover:not(:disabled) { background: var(--down-soft); border-color: var(--down); }
.btn.danger-fill { background: var(--down); color: #fff; }
.btn.danger-fill:hover:not(:disabled) { filter: brightness(1.05); }
.btn.ink { background: var(--ink); color: var(--ink-inv); }

/* ── inputs ─────────────────────────────────────────── */
.input, .select {
  height: var(--ctl-h); width: 100%; padding: 0 var(--s3); border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input::placeholder { color: var(--ink-3); }
.input:hover, .select:hover { border-color: var(--ink-3); }
.input:focus, .select:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--brand-soft); }
.select { appearance: none; padding-right: var(--s8); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23696E82' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9.5 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
textarea.input { height: auto; min-height: 96px; padding: var(--s2) var(--s3); resize: vertical; line-height: var(--lh-14); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: var(--fs-13); font-weight: 500; color: var(--ink-2); }
.field .help { font-size: var(--fs-12); color: var(--ink-3); }
.field .err-t { font-size: var(--fs-12); color: var(--down); }
.fields { display: grid; gap: var(--s4); }
.fields.two { grid-template-columns: 1fr 1fr; }
.check { display: inline-flex; align-items: center; gap: var(--s2); cursor: pointer; font-size: var(--fs-13); color: var(--ink-2); }
.check input { width: 16px; height: 16px; accent-color: var(--ink); }

/* switch */
.switch { position: relative; width: 36px; height: 20px; flex: none; border-radius: var(--r-full); background: var(--line-strong); border: 0; cursor: pointer; transition: background var(--t-fast); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-1); transition: transform var(--t-med) var(--ease); }
.switch[aria-checked="true"] { background: var(--up); }
.switch[aria-checked="true"]::after { transform: translateX(16px); }

/* ── segmented control ──────────────────────────────── */
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r); background: var(--sunken); }
.seg button {
  height: 28px; padding: 0 var(--s3); border: 0; border-radius: 7px; background: transparent; cursor: pointer;
  font-size: var(--fs-13); font-weight: 600; color: var(--ink-2); white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast);
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }
.seg .cnt { font-weight: 500; color: var(--ink-3); margin-left: 2px; }
.seg.sm button { height: 24px; padding: 0 var(--s2); font-size: var(--fs-12); }

/* ── tabs (max 5, one level) ────────────────────────── */
.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tabs button {
  position: relative; display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 var(--s3);
  border: 0; background: none; cursor: pointer; font-size: var(--fs-14); font-weight: 600; color: var(--ink-3); white-space: nowrap;
}
.tabs a:hover, .tabs button:hover { color: var(--ink); }
.tabs .on { color: var(--ink); }
.tabs .on::after { content: ""; position: absolute; left: var(--s3); right: var(--s3); bottom: -1px; height: 2px; border-radius: 2px; background: var(--ink); }

/* ── chips & dots ───────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 var(--s2); border-radius: var(--r-full);
  font-size: var(--fs-12); font-weight: 600; line-height: 1; white-space: nowrap;
  background: var(--sunken); color: var(--ink-2);
}
.chip.up { background: var(--up-soft); color: var(--up); }
.chip.down { background: var(--down-soft); color: var(--down); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.brand { background: var(--brand-soft); color: var(--brand-ink); }
.chip.outline { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }
.chip.st-backtest { background: var(--sunken); color: var(--ink-2); }
.chip.st-probation { background: var(--warn-soft); color: var(--warn); }
.chip.st-paper { background: var(--info-soft); color: var(--info); }
.chip.st-live { background: var(--up-soft); color: var(--up); }
.chip.st-parked { background: var(--sunken); color: var(--ink-3); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.dot.up { background: var(--up); } .dot.down { background: var(--down); } .dot.warn { background: var(--warn); } .dot.info { background: var(--info); }
.dot.pulse { box-shadow: 0 0 0 0 currentColor; animation: pulse 2s infinite; color: var(--up); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 45%, transparent); } 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.bk-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--book); flex: none; }
kbd { font: 600 11px/1 var(--font); padding: 3px 5px; border-radius: 5px; background: var(--sunken); color: var(--ink-3); border: 1px solid var(--line); }

/* ── cards ──────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); min-width: 0; }
.card-h { display: flex; align-items: center; gap: var(--s2); min-height: 44px; padding: var(--s2) var(--s2) var(--s2) var(--s4); }
.card-h h3 { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-h .sub { font-size: var(--fs-12); color: var(--ink-3); font-weight: 500; }
.card-b { padding: 0 var(--s4) var(--s4); }
.card-b.flush { padding: 0; }
.card-f { padding: var(--s3) var(--s4); border-top: 1px solid var(--line); font-size: var(--fs-13); }
.cards { display: grid; gap: var(--s4); }

/* ── KPIs ───────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s3); }
.kpi { padding: var(--s3) var(--s4); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.kpis.flat .kpi { border: 0; background: transparent; padding: var(--s2) 0; }
.kpi.clickable { cursor: pointer; transition: border-color var(--t-fast); }
.kpi.clickable:hover { border-color: var(--line-strong); }
.kpi-l { font-size: var(--fs-13); font-weight: 500; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-v { margin-top: 2px; font-size: var(--fs-24); line-height: var(--lh-24); font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-d { margin-top: 2px; display: flex; gap: 6px; font-size: var(--fs-12); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-s { margin-top: var(--s2); height: 28px; }

/* ── tables (§6) ────────────────────────────────────── */
/* Clean and calm (owner, 2026-11-27: "it feels like lines"): one hairline
   under the header only; rows are told apart by a soft alternate shade, not a
   line each; 16 px cell padding; number columns hug their numbers so the
   figures sit together on the right and the name column takes the rest;
   two-line cells (name + a quiet sub-line) get room to breathe. */
.tbl-wrap { overflow: auto; max-width: 100%; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-14); line-height: var(--lh-14); }
.tbl.compact { font-size: var(--fs-13); line-height: var(--lh-13); }
.tbl th {
  position: sticky; top: 0; z-index: 1; height: 40px; padding: 0 var(--s4); text-align: left; white-space: nowrap; vertical-align: middle;
  font-size: var(--fs-12); font-weight: 500; color: var(--ink-3); background: var(--surface); border-bottom: 1px solid var(--line);
}
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--ink); }
.tbl th .sort-ic { display: inline-block; vertical-align: -2px; margin-left: 2px; opacity: 0; }
.tbl th.sorted .sort-ic, .tbl th.sortable:hover .sort-ic { opacity: 1; }
.tbl td { height: 44px; padding: var(--s2) var(--s4); white-space: nowrap; vertical-align: middle; color: var(--ink); }
.tbl.compact td { height: 40px; padding-top: var(--s1); padding-bottom: var(--s1); }
.tbl tbody tr:nth-child(even) { background: var(--surface-2); }
.tbl tbody tr { transition: background var(--t-fast); }
.tbl tbody tr:hover td { background-image: linear-gradient(var(--hover), var(--hover)); }
.tbl tbody tr[data-go], .tbl tbody tr[data-row], .tbl tbody tr[data-key] { cursor: pointer; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl th.num, .tbl td.num { width: 1%; padding-left: var(--s6); }
.tbl.compact th.num, .tbl.compact td.num { padding-left: var(--s4); }
.tbl.compact th, .tbl.compact td { padding-left: var(--s3); padding-right: var(--s3); }
.tbl.compact th:first-child, .tbl.compact td:first-child { padding-left: var(--s4); }
.tbl.compact th:last-child, .tbl.compact td:last-child { padding-right: var(--s4); }
.tbl th:first-child, .tbl td:first-child { padding-left: var(--s5); }
.tbl th:last-child, .tbl td:last-child { padding-right: var(--s5); }
.tbl td b, .tbl .sym { font-weight: 600; color: var(--ink); }
.tbl .sub-l { display: block; margin-top: 2px; font-size: var(--fs-12); font-weight: 400; color: var(--ink-3); line-height: var(--lh-12); }
.tbl td.wrap { white-space: normal; }
.tbl-empty { padding: var(--s8) var(--s4); text-align: center; color: var(--ink-3); font-size: var(--fs-13); }

/* ── states ─────────────────────────────────────────── */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s2); padding: var(--s8) var(--s4); text-align: center; color: var(--ink-3); min-height: 120px; }
.empty .ic { color: var(--ink-3); }
.empty-t { font-size: var(--fs-14); font-weight: 600; color: var(--ink-2); }
.empty-b { font-size: var(--fs-13); max-width: 360px; }
.empty.err .ic { color: var(--warn); }
.empty .btn { margin-top: var(--s1); }
.sk { background: var(--sunken); border-radius: var(--r-sm); animation: skp 1.4s ease-in-out infinite; }
@keyframes skp { 50% { opacity: .55; } }
.sk-rows { display: flex; flex-direction: column; gap: var(--s3); padding: var(--s2) 0; }
.sk-row { height: 14px; }
.sk-t { height: 12px; width: 60%; } .sk-t.short { width: 35%; margin-top: 8px; }
.sk-v { height: 24px; width: 80%; margin-top: 8px; }
.sk-block { height: 180px; border-radius: var(--r); }
.banner { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r-lg); font-size: var(--fs-13); background: var(--surface-2); border: 1px solid var(--line); }
.banner.warn { background: var(--warn-soft); border-color: transparent; color: var(--ink); }
.banner.warn .ic { color: var(--warn); }
.banner.bad { background: var(--down-soft); border-color: transparent; }
.banner.bad .ic { color: var(--down); }
.banner .grow b { font-weight: 650; }

/* ── layers: menu, tooltip, toast, sheet, dialog ────── */
.menu {
  position: fixed; z-index: 90; min-width: 200px; max-width: 320px; max-height: 70vh; overflow: auto; padding: var(--s1);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-3);
  opacity: 0; transform: translateY(-4px); transition: opacity var(--t-fast), transform var(--t-fast) var(--ease);
}
.menu.open { opacity: 1; transform: none; }
.menu-item { display: flex; align-items: center; gap: var(--s2); width: 100%; height: 36px; padding: 0 var(--s2); border: 0; border-radius: var(--r-sm); background: none; cursor: pointer; text-align: left; font-size: var(--fs-13); font-weight: 500; color: var(--ink); }
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); box-shadow: none; }
.menu-item .ic { color: var(--ink-3); }
.menu-item.danger, .menu-item.danger .ic { color: var(--down); }
.menu-item:disabled { opacity: .45; cursor: not-allowed; }
.menu-item .mi-l { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item .mi-h { font-size: var(--fs-12); color: var(--ink-3); }
.menu-item .mi-c { color: var(--ink); }
.menu-item .ic-sp { width: 16px; }
.menu-sep { height: 1px; margin: var(--s1) var(--s2); background: var(--line); }
.menu-head { padding: var(--s2) var(--s2) var(--s1); font-size: var(--fs-12); font-weight: 600; color: var(--ink-3); }
.tip {
  position: fixed; z-index: 100; max-width: 280px; padding: 6px 10px; border-radius: var(--r-sm); pointer-events: none;
  background: var(--ink); color: var(--ink-inv); font-size: var(--fs-12); line-height: 16px; font-weight: 500;
  opacity: 0; transition: opacity var(--t-fast);
}
.tip.show { opacity: 1; }
.toast {
  position: fixed; z-index: 95; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translate(-50%, 16px);
  display: flex; align-items: center; gap: var(--s2); max-width: min(560px, calc(100vw - 32px)); padding: var(--s2) var(--s2) var(--s2) var(--s4);
  min-height: 44px; border-radius: var(--r-lg); background: var(--ink); color: var(--ink-inv); box-shadow: var(--shadow-3);
  font-size: var(--fs-13); font-weight: 500; opacity: 0; pointer-events: none; transition: opacity var(--t-med), transform var(--t-med) var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast.good .ic { color: var(--up); } .toast.bad .ic { color: var(--down); }
:root:not([data-theme="dark"]) .toast.good .ic { color: #6EE7B0; }
:root:not([data-theme="dark"]) .toast.bad .ic { color: #FF9C9C; }
.toast .btn.quiet { color: var(--brand); }
.layer { position: fixed; inset: 0; z-index: 80; }
.scrim { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity var(--t-med); }
.layer.open .scrim { opacity: 1; }
.sheet {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(var(--w, 480px), 100vw); display: flex; flex-direction: column;
  background: var(--surface); box-shadow: var(--shadow-3); transform: translateX(24px); opacity: 0;
  transition: transform var(--t-med) var(--ease), opacity var(--t-med);
}
.layer.open .sheet { transform: none; opacity: 1; }
.sheet-h { display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s5) var(--s4) var(--s4) var(--s6); border-bottom: 1px solid var(--line); }
.sheet-h > div { flex: 1; min-width: 0; }
.sheet-sub { margin-top: 2px; font-size: var(--fs-13); color: var(--ink-3); }
.sheet-b { flex: 1; overflow: auto; padding: var(--s6); }
.sheet-f { display: flex; justify-content: flex-end; gap: var(--s2); padding: var(--s4) var(--s6); border-top: 1px solid var(--line); }
.dialog {
  position: absolute; left: 50%; top: 50%; width: min(440px, calc(100vw - 32px)); padding: var(--s6); border-radius: var(--r-xl);
  background: var(--surface); box-shadow: var(--shadow-3); transform: translate(-50%, -48%) scale(.98); opacity: 0;
  transition: transform var(--t-med) var(--ease), opacity var(--t-med); display: flex; flex-direction: column; gap: var(--s4);
}
.layer.open .dialog { transform: translate(-50%, -50%); opacity: 1; }
.dialog-b { color: var(--ink-2); font-size: var(--fs-14); }
.dialog-b > * + * { margin-top: var(--s3); }
.dialog-f { display: flex; justify-content: flex-end; gap: var(--s2); }

/* ── shell ──────────────────────────────────────────── */
.shell { min-height: 100vh; display: grid; grid-template-columns: var(--rail-w) 1fr; grid-template-rows: var(--topbar-h) 1fr; }
.shell.rail-min { grid-template-columns: var(--rail-w-min) 1fr; }
.shell.no-rail { grid-template-columns: 1fr; }
.shell > * { min-width: 0; }
.shell.no-rail .rail { display: none; }
body.live::before { content: ""; position: fixed; z-index: 70; top: var(--safe-t); left: 0; right: 0; height: 2px; background: var(--live); }

.topbar {
  grid-column: 1 / -1; position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: var(--s2); min-width: 0; overflow: hidden;
  height: var(--topbar-h); padding: 0 var(--s3) 0 var(--s4); background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 var(--s2) 0 0; border-radius: var(--r); flex: none; }
.logo .mark { width: 28px; height: 28px; }
.logo .wm { font-weight: 750; font-size: 17px; letter-spacing: -.02em; }
.shell:not(.no-rail) .logo { width: calc(var(--rail-w) - var(--s4) - var(--s2)); }
.shell.rail-min .logo { width: auto; }
.shell.rail-min .logo .wm { display: none; }
.book-btn {
  display: inline-flex; align-items: center; gap: var(--s2); height: 36px; padding: 0 var(--s2) 0 var(--s3); flex: none;
  border-radius: var(--r); border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-weight: 600;
}
.book-btn:hover { border-color: var(--ink-3); }
.book-btn .ic { color: var(--ink-3); }

/* ticker */
.ticker { position: relative; flex: 1 1 0; min-width: 0; height: 36px; display: flex; align-items: center; overflow: hidden; border-radius: var(--r); }
.ticker-track { display: flex; gap: var(--s6); width: max-content; padding-left: var(--s4); will-change: transform; }
/* Moved by shell.js: drag or swipe to scroll, flick to fling. */
.ticker { cursor: grab; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.ticker.dragging { cursor: grabbing; }
.ticker.dragging .tk { cursor: grabbing; }
.ticker::before, .ticker::after { content: ""; position: absolute; z-index: 1; top: 0; bottom: 0; width: 32px; pointer-events: none; }
.ticker::before { left: 0; background: linear-gradient(90deg, var(--bg), transparent); }
.ticker::after { right: 0; background: linear-gradient(270deg, var(--bg), transparent); }
.tk { display: inline-flex; align-items: baseline; gap: 6px; font-size: var(--fs-13); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tk b { font-weight: 600; color: var(--ink-2); }
.tk .v { font-weight: 600; }
.tk .c { font-size: var(--fs-12); font-weight: 600; }
.ticker-src { flex: none; }

.tb-search {
  display: inline-flex; align-items: center; gap: var(--s2); height: 36px; width: 180px; padding: 0 var(--s2) 0 var(--s3); flex: none;
  border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); color: var(--ink-3); cursor: pointer; font-size: var(--fs-13);
}
.tb-search:hover { border-color: var(--line-strong); color: var(--ink-2); }
.tb-search span { flex: 1; text-align: left; }
.kite-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 var(--s3); border-radius: var(--r-full); flex: none;
  border: 0; cursor: pointer; font-size: var(--fs-13); font-weight: 650; background: var(--warn-soft); color: var(--warn);
}
.kite-pill.bad { background: var(--down-soft); color: var(--down); }
.kite-pill .kt-short { display: none; }
.kite-pill:hover { filter: brightness(.97); }
.mode-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 var(--s3); border-radius: var(--r-full); flex: none;
  border: 0; cursor: pointer; font-size: var(--fs-13); font-weight: 650; background: var(--paper-soft); color: var(--paper);
}
.mode-btn.live { background: var(--live-soft); color: var(--live); }
.mode-btn .dot { background: currentColor; }
.bell { position: relative; }
.bell .badge {
  position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--down); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; pointer-events: none;
}
.avatar { width: 32px; height: 32px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; background: var(--brand-soft); color: var(--brand-ink); font-weight: 700; font-size: var(--fs-13); flex: none; }

/* rail */
.rail {
  position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); display: flex; flex-direction: column; gap: 2px;
  padding: var(--s3) var(--s3); border-right: 1px solid var(--line); background: var(--bg); overflow-y: auto;
}
.rail-book { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s2) var(--s3); font-size: var(--fs-12); font-weight: 600; color: var(--ink-3); }
.rail a, .rail button.ri {
  position: relative; display: flex; align-items: center; gap: var(--s3); height: 40px; padding: 0 var(--s3); border-radius: var(--r);
  border: 0; background: none; cursor: pointer; font-size: var(--fs-14); font-weight: 550; color: var(--ink-2); text-align: left; width: 100%;
  transition: background var(--t-fast), color var(--t-fast);
}
.rail a:hover, .rail button.ri:hover { background: var(--hover); color: var(--ink); }
.rail a.on { background: var(--brand-soft); color: var(--ink); font-weight: 650; }
.rail a.on::before { content: ""; position: absolute; left: -12px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }
.rail a .ic { color: var(--ink-3); }
.rail a.on .ic { color: var(--ink); }
.rail .rail-sp { flex: 1; }
.rail .rail-n { margin-left: auto; font-size: var(--fs-12); color: var(--ink-3); font-weight: 600; }
.shell.rail-min .rail { padding: var(--s3) var(--s2); align-items: center; }
.shell.rail-min .rail a, .shell.rail-min .rail button.ri { width: 44px; padding: 0; justify-content: center; }
.shell.rail-min .rail .lbl, .shell.rail-min .rail .rail-book span, .shell.rail-min .rail .rail-n { display: none; }
.shell.rail-min .rail a.on::before { left: -8px; }

.main { min-width: 0; padding: var(--s6); grid-column: -2 / -1; }
.main.bleed { padding: 0; }
.page { max-width: 1680px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--s5); }
.page-h { display: flex; align-items: center; gap: var(--s3); min-height: 44px; flex-wrap: wrap; }
.page-h .titles { flex: 1 1 auto; min-width: 0; }
.page-h .titles p { margin-top: 2px; color: var(--ink-3); font-size: var(--fs-13); }
.page-h .acts { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; gap: 4px; font-size: var(--fs-13); color: var(--ink-3); margin-bottom: 2px; }
.crumbs a:hover { color: var(--ink); }
.filters { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.filters .sp { flex: 1; }
/* A labelled filter: "Stage [All | Live | …]" so two segmented controls never read as one row. */
.f-group { display: inline-flex; align-items: center; gap: var(--s2); min-width: 0; }
.f-lbl { font-size: var(--fs-13); font-weight: 500; color: var(--ink-3); white-space: nowrap; }
.filters .f-group + .f-group { margin-left: var(--s4); }

/* phone tab bar */
.tabbar { display: none; }

/* ── palette (⌘K) ───────────────────────────────────── */
.palette { position: absolute; left: 50%; top: 12vh; width: min(620px, calc(100vw - 32px)); transform: translateX(-50%) translateY(-6px); opacity: 0;
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-3); overflow: hidden; transition: opacity var(--t-med), transform var(--t-med) var(--ease); }
.layer.open .palette { opacity: 1; transform: translateX(-50%); }
.palette-in { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s4); height: 56px; border-bottom: 1px solid var(--line); color: var(--ink-3); }
.palette-in input { flex: 1; height: 100%; border: 0; background: none; outline: none; font-size: var(--fs-16); color: var(--ink); }
/* The search box sits inside the palette's own frame: no page focus ring on
   it (it drew a clipped black box over the field). */
.palette-in input:focus, .palette-in input:focus-visible { outline: none; box-shadow: none; }
.palette-in:focus-within { color: var(--ink-2); }
.palette-list { max-height: 56vh; overflow: auto; padding: var(--s2); overscroll-behavior: contain; }
.palette-g { padding: var(--s3) var(--s3) var(--s1); font-size: var(--fs-12); font-weight: 600; color: var(--ink-3); }
.palette-g:first-child { padding-top: var(--s1); }
.palette-item { display: flex; align-items: center; gap: var(--s3); width: 100%; height: 40px; padding: 0 var(--s3); border: 0; border-radius: var(--r); background: none; cursor: pointer; text-align: left; font-size: var(--fs-14); color: var(--ink); transition: background var(--t-fast); }
.palette-item:focus-visible { box-shadow: none; }
.palette-item .ic { color: var(--ink-3); }
.palette-item .pl { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item .h { margin-left: auto; flex: none; font-size: var(--fs-12); color: var(--ink-3); }
.palette-item.on { background: var(--brand-soft); }
.palette-item.on .ic { color: var(--ink); }
.palette-item .bk-dot { margin: 0 4px; }
.palette-item[data-book="intraday"] { --book: var(--bk-intraday); }
.palette-item[data-book="swing"] { --book: var(--bk-swing); }
.palette-item[data-book="seasonal"] { --book: var(--bk-seasonal); }
.palette-item[data-book="options"] { --book: var(--bk-options); }
.palette-f { display: flex; gap: var(--s4); padding: var(--s2) var(--s4); border-top: 1px solid var(--line); background: var(--surface-2); font-size: var(--fs-12); color: var(--ink-3); }
.palette-f span { display: inline-flex; align-items: center; gap: 4px; }
@media (max-width: 767px) { .palette-f { display: none; } .palette { top: calc(var(--safe-t) + 12px); } }

/* ── responsive shell (§3, §8) ──────────────────────── */
@media (max-width: 1599px) {
  .tb-search { width: 40px; padding: 0; justify-content: center; }
  .tb-search span, .tb-search kbd { display: none; }
}
@media (max-width: 1199px) {
  .shell:not(.no-rail) { grid-template-columns: var(--rail-w-min) 1fr; }
  .shell .rail { padding: var(--s3) var(--s2); align-items: center; }
  .shell .rail a, .shell .rail button.ri { width: 44px; padding: 0; justify-content: center; }
  .shell .rail .lbl, .shell .rail .rail-book span, .shell .rail .rail-n { display: none; }
  .shell .rail a.on::before { left: -8px; }
  .shell:not(.no-rail) .logo { width: auto; }
  .tb-search { width: 40px; padding: 0; justify-content: center; }
  .tb-search span, .tb-search kbd { display: none; }
  .main { padding: var(--s4); }
}
@media (max-width: 1023px) {
  .logo .wm { display: none; }
  .mode-btn .lbl-long { display: none; }
}
@media (max-width: 767px) {
  body { font-size: var(--fs-16); line-height: var(--lh-16); }
  .shell, .shell:not(.no-rail), .shell.rail-min { grid-template-columns: 1fr; grid-template-rows: calc(var(--topbar-h) + var(--safe-t)) 1fr; }
  .topbar { padding: var(--safe-t) var(--s3) 0 var(--s4); height: calc(var(--topbar-h) + var(--safe-t)); }
  .rail { display: none; }
  .ticker, .tb-search, .book-btn .lbl, .avatar { display: none; }
  .kite-pill .kt-long, .topbar .bell { display: none; }
  .kite-pill .kt-short { display: inline; }
  .topbar { gap: var(--s1); }
  .topbar .sp-phone { flex: 1; }
  .logo .wm { display: inline; }
  .main { padding: var(--s4) var(--s4) calc(var(--tabbar-h) + var(--safe-b) + var(--s6)); }
  .tabbar {
    position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr);
    height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line);
  }
  .tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--ink-3); }
  .tabbar a.on { color: var(--ink); }
  .tabbar a.on .ic { color: var(--ink); }
  .tabbar .badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--down); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; }
  .btn { height: var(--ctl-h-touch); }
  .btn.sm { height: 36px; }
  .btn.icon-only { width: var(--ctl-h-touch); }
  .input, .select { height: var(--ctl-h-touch); font-size: var(--fs-16); }
  .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .seg::-webkit-scrollbar { display: none; }
  .seg button { height: 34px; flex: none; }
  .kpi-v { white-space: normal; overflow-wrap: anywhere; }
  .page { gap: var(--s4); }
  .page-h h1 { font-size: var(--fs-20); line-height: var(--lh-20); }
  .kpi-d { white-space: normal; flex-wrap: wrap; }
  .card-h { flex-wrap: wrap; }
  .only-m { display: revert !important; }
  .fields.two { grid-template-columns: 1fr; }
  .sheet { width: 100vw; }
  .sheet-b { padding: var(--s4); }
  .toast { bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px); }
  /* tables become two-line rows (§6) */
  .tbl.cards-m thead { display: none; }
  .tbl.cards-m, .tbl.cards-m tbody, .tbl.cards-m tr { display: block; }
  .tbl.cards-m tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--s3); padding: var(--s3) var(--s4); }
  .tbl.cards-m td { height: auto; padding: 0 !important; border: 0; width: auto; font-size: var(--fs-13); color: var(--ink-3); }
  .tbl.cards-m td:first-child { flex: 1 1 60%; font-size: var(--fs-16); color: var(--ink); }
  .tbl.cards-m td.key { flex: 0 0 auto; margin-left: auto; font-size: var(--fs-16); font-weight: 600; }
  .tbl.cards-m td.meta { flex-basis: 100%; order: 3; }
  .tbl.cards-m td.hide-m { display: none; }
}

/* ── motion & polish (2026-11-22) ─────────────────────
   §7: 120 ms hovers, 200 ms panels, ease-out, nothing bouncy; every
   duration is a token, so prefers-reduced-motion (tokens.css) stops it. */

/* A new page eases in; the same page re-drawn doesn't (app.js route). */
@keyframes pageIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.main.enter > * { animation: pageIn var(--t-med) var(--ease) both; }
.main.bleed.enter > * { animation-name: fadeIn; }

/* Page code loading: a thin Sunbeam line under the top bar (after 150 ms). */
.route-bar { position: fixed; z-index: 60; top: calc(var(--topbar-h) + var(--safe-t) - 2px); left: 0; height: 2px; width: 0; background: var(--brand-edge); opacity: 0; pointer-events: none; }
.route-bar.run { opacity: 1; width: 72%; transition: width 1.6s cubic-bezier(.1, .7, .2, 1), opacity var(--t-fast); }
.route-bar.done { opacity: 0; width: 100%; transition: width var(--t-med) var(--ease), opacity var(--t-med) var(--t-fast); }

/* Re-reading after a filter change: keep the old numbers, dimmed, until the
   new ones land (no skeleton flash). */
.w-busy { opacity: .55; transition: opacity var(--t-fast); pointer-events: none; }
.w-root, .books, [id^="bk-"] { transition: opacity var(--t-med) var(--ease); }

/* A P&L figure that just moved gets a short tint of its direction. */
@keyframes tickUp { 0% { background: var(--up-soft); } 100% { background: transparent; } }
@keyframes tickDown { 0% { background: var(--down-soft); } 100% { background: transparent; } }
.tick-up, .tick-down { border-radius: var(--r-sm); margin-left: -4px; padding-left: 4px; margin-right: -4px; padding-right: 4px; display: inline-block; }
.tick-up { animation: tickUp 1.2s var(--ease) both; }
.tick-down { animation: tickDown 1.2s var(--ease) both; }
@media (prefers-reduced-motion: reduce) { .tick-up, .tick-down { animation: none; } }

/* Calmer surfaces: soft lift on things you can click, steady hairlines. */
.card { transition: border-color var(--t-fast), box-shadow var(--t-med) var(--ease); }
.kpi.clickable:hover { box-shadow: var(--shadow-2); }
.rail a.on::before { animation: fadeIn var(--t-med) var(--ease) both; }
.tabs a, .tabs button { transition: color var(--t-fast); }
.tabs .on::after { animation: fadeIn var(--t-med) var(--ease) both; }
.book-btn, .tb-search, .mode-btn, .kite-pill, .avatar { transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast), filter var(--t-fast); }
.avatar:hover { filter: brightness(.96); }
.btn.primary:focus-visible { box-shadow: var(--focus), inset 0 -1px 0 var(--brand-edge); }

/* Phone and the home-screen app: solid bars. A see-through blurred bar lets
   the page smear behind it (and behind the clock / home indicator), which
   reads as a blurry app on a phone. Desktop browsers keep the frosted bar. */
@media (max-width: 767px), (display-mode: standalone) {
  .topbar { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .tabbar { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
