/* Reclaim dashboard. The design system lives in docs/brand-guidelines.md; this file implements it.
 * Phone first (375 px, no sideways page scroll, 44 px tap targets). Dark whatever the device says;
 * <html data-theme="light"> switches to light and data-theme="auto" follows prefers-color-scheme (the
 * server writes the attribute from the `theme` cookie). No inline styles (CSP 'self'): every colour
 * comes from a token and a class.
 * Palette "Graphite": true black, Apple's dark greys, white for actions; colour only for meaning
 * (profit, loss, warning, modes). Flat (Revolut): no shadows on the page, pill buttons, 20 px cards. */

/* ==== 1. Tokens ================================================================================== */

:root {
  color-scheme: dark;

  /* neutrals (graphite): true black page, Apple's dark greys for layers */
  --bg: #000000;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --surface-3: #3a3a3c;
  --line: #2c2c2e;
  --line-strong: #48484a;
  --highlight: transparent;
  --bar-bg: rgba(0, 0, 0, 0.82);

  /* text */
  --text: #f5f5f7;
  --text-2: #d1d1d6;
  --muted: #a1a1a6;

  /* brand: white for actions and for the view; no hue in the brand at all */
  --primary: #f5f5f7;
  --on-primary: #000000;
  --primary-hover: #ffffff;
  --primary-tint: rgba(255, 255, 255, 0.22);
  --link: #f5f5f7;
  --focus: #f5f5f7;
  --accent: #ffffff;

  /* meaning */
  --profit: #30d158;
  --profit-bg: rgba(48, 209, 88, 0.14);
  --loss: #ff7a73;
  --loss-bg: rgba(255, 122, 115, 0.13);
  --loss-line: rgba(255, 122, 115, 0.5);
  --warn: #f5b53d;
  --warn-bg: #2a2213;
  --warn-line: rgba(245, 181, 61, 0.45);
  --halted: #b3141c;
  --on-halted: #ffffff;
  --kill: #c8161f;
  --kill-hover: #dd2a33;
  --kill-line: rgba(200, 22, 31, 0.5);
  --kill-glow: rgba(200, 22, 31, 0.35);
  --info: #7db4ff;
  --info-bg: rgba(125, 180, 255, 0.12);

  /* modes */
  --mode-dry-bg: #3a3a3c;
  --mode-dry-text: #f5f5f7;
  --mode-dry-line: #a1a1a6;
  --mode-demo-bg: #1f63d1;
  --mode-demo-text: #ffffff;
  --mode-live-bg: #c0121c;
  --mode-live-text: #ffffff;

  /* charts: real and shadow are the validated data-viz slots 1-2; the baseline is a dashed neutral */
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #aeaeb2;
  /* Mode race (Low, Medium, Higher, Gambling): validated all-pairs colour-blind safe, each with its own dash */
  --m1: #3987e5;
  --m2: #644fb1;
  --m3: #d95926;
  --m4: #c952a8;
  --grid: #262628;
  --axis: #48484a;
  --candle-up: #3fae6b;
  --candle-down: #e0605c;
  --lvl-support: #5aa2ff;
  --lvl-resist: #f08a4b;
  --lvl-both: #e07ab0;

  /* type: the device's own UI font, no web fonts */
  --font: -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI Variable Text", "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  /* four sizes (plus 11 px for chart axes and tab labels): small, body, title, hero */
  --fs-sm: 13px;
  --fs-md: 15px;
  --fs-xl: 22px;
  --fs-hero: 40px;

  /* space, shape, depth */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --r-sm: 10px;
  --r-md: 12px;
  --r-lg: 20px;
  --r-pill: 999px;
  --tap: 44px;
  /* flat: no shadow on anything that sits on the page; floating layers (menus, tooltips) only */
  --shadow-1: none;
  --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-3: 0 16px 40px rgba(0, 0, 0, 0.6);
  --blur: saturate(180%) blur(20px);
  --tabbar-h: 62px;
}

/* Light: chosen in the theme menu, or "Auto" on a device set to light. The two blocks must stay equal. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-2: #f5f5f7;
  --surface-3: #e5e5ea;
  --line: #e5e5ea;
  --line-strong: #c7c7cc;
  --highlight: transparent;
  --bar-bg: rgba(242, 242, 247, 0.85);
  --text: #1d1d1f;
  --text-2: #3a3a3c;
  --muted: #636366;
  --primary: #1d1d1f;
  --on-primary: #ffffff;
  --primary-hover: #000000;
  --primary-tint: rgba(0, 0, 0, 0.14);
  --link: #1d1d1f;
  --focus: #1d1d1f;
  --accent: #000000;
  --profit: #1d7a36;
  --profit-bg: #e5f4e8;
  --loss: #c2282b;
  --loss-bg: #fbe9e9;
  --loss-line: #e9a3a3;
  --warn: #8f5300;
  --warn-bg: #fff2d6;
  --warn-line: #e3b866;
  --kill-hover: #a8121a;
  --kill-glow: rgba(200, 22, 31, 0.25);
  --info: #1f5fc4;
  --info-bg: #e8effc;
  --mode-dry-bg: #48484a;
  --mode-dry-text: #ffffff;
  --mode-dry-line: #48484a;
  --mode-demo-bg: #1f5fc4;
  --mode-live-bg: #b3121b;
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #6e6e73;
  --m1: #2a78d6;
  --m2: #5b3bb3;
  --m3: #eb6834;
  --m4: #b8327a;
  --grid: #ebebf0;
  --axis: #c7c7cc;
  --candle-up: #2c9a57;
  --candle-down: #d4504c;
  --lvl-support: #2a6fd6;
  --lvl-resist: #c2560f;
  --lvl-both: #b8327a;
  --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-3: 0 16px 40px rgba(0, 0, 0, 0.14);
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    color-scheme: light;
    --bg: #f2f2f7;
    --surface: #ffffff;
    --surface-2: #f5f5f7;
    --surface-3: #e5e5ea;
    --line: #e5e5ea;
    --line-strong: #c7c7cc;
    --highlight: transparent;
    --bar-bg: rgba(242, 242, 247, 0.85);
    --text: #1d1d1f;
    --text-2: #3a3a3c;
    --muted: #636366;
    --primary: #1d1d1f;
    --on-primary: #ffffff;
    --primary-hover: #000000;
    --primary-tint: rgba(0, 0, 0, 0.14);
    --link: #1d1d1f;
    --focus: #1d1d1f;
    --accent: #000000;
    --profit: #1d7a36;
    --profit-bg: #e5f4e8;
    --loss: #c2282b;
    --loss-bg: #fbe9e9;
    --loss-line: #e9a3a3;
    --warn: #8f5300;
    --warn-bg: #fff2d6;
    --warn-line: #e3b866;
    --kill-hover: #a8121a;
    --kill-glow: rgba(200, 22, 31, 0.25);
    --info: #1f5fc4;
    --info-bg: #e8effc;
    --mode-dry-bg: #48484a;
    --mode-dry-text: #ffffff;
    --mode-dry-line: #48484a;
    --mode-demo-bg: #1f5fc4;
    --mode-live-bg: #b3121b;
    --s1: #2a78d6;
    --s2: #eb6834;
    --s3: #6e6e73;
    --m1: #2a78d6;
    --m2: #5b3bb3;
    --m3: #eb6834;
    --m4: #b8327a;
    --grid: #ebebf0;
    --axis: #c7c7cc;
    --candle-up: #2c9a57;
    --candle-down: #d4504c;
    --lvl-support: #2a6fd6;
    --lvl-resist: #c2560f;
    --lvl-both: #b8327a;
    --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-3: 0 16px 40px rgba(0, 0, 0, 0.14);
  }
}

/* ==== 2. 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(--text);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--sp-4));
  overflow-x: hidden;
}
h1, h2, h3, p, ul, ol, dl, figure { margin: 0; }
h1 { font-size: var(--fs-xl); line-height: 1.2; font-weight: 600; letter-spacing: -0.025em; }
h2 { font-size: var(--fs-md); line-height: 1.3; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: var(--fs-md); line-height: 1.35; font-weight: 600; }
a { color: var(--link); text-decoration-color: var(--muted); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
code, .mono { font-family: var(--mono); font-size: 0.86em; }
pre {
  font-family: var(--mono); font-size: var(--fs-sm); line-height: 1.5; margin: var(--sp-2) 0 0;
  padding: var(--sp-3); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm);
  overflow: auto; max-height: 420px; white-space: pre-wrap; word-break: break-word;
}
strong { font-weight: 600; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--primary-tint); }
.icon { width: 20px; height: 20px; flex: none; vertical-align: -4px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 50; background: var(--primary); color: var(--on-primary); padding: 8px 12px; border-radius: var(--r-sm); }
.skip-link:focus { left: 8px; }

/* text helpers */
.muted { color: var(--muted); }
.small, .help, .meta-line, .card-foot { font-size: var(--fs-sm); }
.help { color: var(--muted); margin-top: var(--sp-2); }
.meta-line { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--profit); }
.neg { color: var(--loss); }
.flat { color: var(--text); }
.ok-text { color: var(--profit); }
.warn-text { color: var(--warn); }

/* ==== 3. Shell: top bar, footer, bottom tabs ======================================================= */

.page { min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bar-bg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--line);
  padding: env(safe-area-inset-top) 0 0;
}
.topbar-row {
  position: relative; display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-4); min-height: 56px;
}
.brand { display: inline-flex; align-items: center; gap: var(--sp-2); text-decoration: none; color: var(--text); min-height: var(--tap); }
.brand-mark { display: block; width: 28px; height: 28px; }
.wordmark { font-weight: 600; letter-spacing: -0.025em; }

/* mode badge: always visible, LIVE unmistakable */
.mode-label {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 32px; padding: 4px 10px; border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: 700; letter-spacing: 0.04em; line-height: 1.2;
  background: var(--mode-dry-bg); color: var(--mode-dry-text);
  border: 1px dashed var(--mode-dry-line);
  max-width: 52vw; flex: none;
}
.mode-long { display: none; }
.mode-label.mode-live .mode-long { display: inline; }
.mode-label.mode-live .mode-short { display: none; }
.mode-label .mode-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; opacity: 0.7; }
.mode-label.mode-demo { background: var(--mode-demo-bg); color: var(--mode-demo-text); border: 1px solid transparent; }
.mode-label.mode-live {
  background: var(--mode-live-bg); color: var(--mode-live-text); border: 2px solid var(--mode-live-text);
  box-shadow: 0 0 0 2px var(--mode-live-bg);
  font-size: var(--fs-sm);
}
.mode-label.mode-live .mode-dot { opacity: 1; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.8); } }
body.mode-live .topbar { border-top: 4px solid var(--mode-live-bg); border-bottom: 2px solid var(--mode-live-bg); }
body.mode-live::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 60;
  border: 3px solid var(--mode-live-bg); box-shadow: inset 0 0 0 1px var(--mode-live-text);
}

/* kill switch: one tap, always in the bar */
.kill { display: grid; gap: var(--sp-2); margin: 0; }
.kill-button {
  display: flex; align-items: center; justify-content: center; width: 100%;
  min-height: 52px; padding: 0 var(--sp-4);
  border: 1.5px solid var(--kill); border-radius: var(--r-pill); cursor: pointer;
  background: transparent; color: var(--loss);
  font: 600 var(--fs-md)/1.2 var(--font);
}
.kill-button:hover { background: var(--kill); color: var(--on-halted); }
.kill-button:active { transform: translateY(1px); }
.kill-note { font-size: var(--fs-sm); color: var(--muted); line-height: 1.45; text-align: center; }

/* live status banners (from /partials/status) */
.status-region { padding: 0 var(--sp-4); }
.status-region:empty { display: none; }
.status-region .alert:last-child { margin-bottom: var(--sp-3); }
.alert {
  position: relative; margin: 0 0 var(--sp-2); padding: 10px 12px 10px 40px;
  border-radius: var(--r-md); font-size: var(--fs-sm); font-weight: 600; line-height: 1.4;
}
.alert::before {
  content: ""; position: absolute; left: 12px; top: 10px; width: 18px; height: 18px;
  background: currentColor;
  -webkit-mask: url("icons/alert.svg") center / contain no-repeat; mask: url("icons/alert.svg") center / contain no-repeat;
}
.alert-red { background: var(--halted); color: var(--on-halted); }
.alert-amber { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-line); }
.alert-info { background: var(--info-bg); color: var(--info); }
.alert-info::before { -webkit-mask-image: url("icons/info.svg"); mask-image: url("icons/info.svg"); }
.poll-failed { opacity: 0.6; }
/* two polls missed: the figures are old; dashed warning outline (the headline says since when) */
.poll-stale { outline: 2px dashed var(--warn-line); outline-offset: 4px; border-radius: var(--r-md); }

/* bottom tab bar (phone) */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(6, 1fr);
  min-height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 0 4px env(safe-area-inset-bottom);
  background: var(--bar-bg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: var(--tabbar-h); padding: 6px 2px; color: var(--muted); text-decoration: none;
  font-size: 11px; font-weight: 600; letter-spacing: 0.01em; cursor: pointer; list-style: none;
  border-radius: var(--r-md);
}
.tab::-webkit-details-marker { display: none; }
.tab .icon { width: 22px; height: 22px; }
.tab.active, .tab-more.active > .tab { color: var(--text); }
.tab.active .icon, .tab-more.active > .tab .icon { color: var(--primary); }
.tab-more { position: relative; }
.tab-more[open] > .tab { color: var(--text); }
.more-menu {
  position: absolute; right: 0; bottom: calc(100% + 8px); min-width: 200px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
}
.more-menu .logout { margin: 0; border-top: 1px solid var(--line); padding-top: 4px; margin-top: 4px; }
.more-link {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%; min-height: var(--tap);
  padding: 0 12px; border: 0; background: none; border-radius: var(--r-md);
  color: var(--text); text-decoration: none; font: 500 var(--fs-md) var(--font); cursor: pointer; text-align: left;
}
.more-link:hover, .more-link.active { background: var(--surface-2); }
.more-link.active .icon { color: var(--primary); }

/* page content */
.content { padding: var(--sp-4); max-width: 1180px; margin: 0 auto; }
.page-head { margin: var(--sp-1) 0 var(--sp-3); }
.page-head .sub { color: var(--muted); font-size: var(--fs-sm); margin-top: 2px; max-width: 70ch; }
.page-head-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2) var(--sp-3); }
.back {
  display: inline-flex; align-items: center; gap: 4px; min-height: var(--tap); margin-left: -6px; padding-right: 8px;
  color: var(--text-2); text-decoration: none; font-weight: 500; font-size: var(--fs-sm);
}
.section { margin: var(--sp-4) 0; }
/* card and section titles: a quiet label (13, semibold, muted, sentence case), not a shouting heading */
.section-title, .card > h2, .card-head h2, .label {
  font-size: var(--fs-sm); font-weight: 600; letter-spacing: 0; color: var(--muted); line-height: 1.4;
}
.section-title { margin-bottom: var(--sp-2); }
.card > h2 { margin-bottom: var(--sp-2); }
.count { color: var(--text-2); font-weight: 600; margin-left: 2px; }
.caption { font-size: var(--fs-sm); color: var(--muted); }
.updated { color: var(--muted); font-size: var(--fs-sm); margin: var(--sp-3) 0 var(--sp-4); }

/* ==== 4. Components ============================================================================== */

/* card */
.card {
  background: var(--surface); border: 1px solid transparent; border-radius: var(--r-lg);
  padding: var(--sp-4); margin-bottom: var(--sp-3); min-width: 0;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.card-head h2, .card-head h3 { font-size: var(--fs-md); font-weight: 600; }
.card-foot { color: var(--muted); margin-top: var(--sp-3); }
.card-danger { border-color: var(--kill-line); }
.card-warn { border-color: var(--warn-line); background: var(--warn-bg); }
.card-alert { border-color: var(--halted); }
.card-grid { display: grid; gap: var(--sp-4); grid-template-columns: 1fr; }
.card-grid > .card { margin-bottom: 0; }
.home-grid { display: grid; gap: 0 var(--sp-4); grid-template-columns: 1fr; }
.link-more { display: inline-flex; align-items: center; gap: 2px; min-height: var(--tap); font-weight: 600; font-size: var(--fs-sm); text-decoration: none; }
.link-more .icon { width: 16px; height: 16px; vertical-align: -3px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--tap); padding: 0 22px; border-radius: var(--r-pill); border: 1px solid transparent;
  font: 600 var(--fs-md)/1.1 var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: opacity 0.15s, background-color 0.15s;
}
.btn:active { opacity: 0.85; }
.btn .icon { width: 18px; height: 18px; vertical-align: 0; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-secondary:hover { background: var(--surface-3); }
.btn-quiet { background: transparent; color: var(--text-2); }
.btn-quiet:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--kill); color: var(--on-halted); }
.btn-danger:hover { background: var(--kill-hover); }
.btn-block { width: 100%; }
.button-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); }

/* notices and errors */
.notice, .error {
  display: flex; align-items: flex-start; gap: var(--sp-2); padding: 10px 12px; border-radius: var(--r-md);
  margin: 0 0 var(--sp-4); font-size: var(--fs-sm); line-height: 1.45;
}
.notice { background: var(--info-bg); color: var(--text); }
.notice .icon { color: var(--info); width: 18px; height: 18px; vertical-align: 0; margin-top: 1px; }
.notice-warn { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-line); }
.notice-warn .icon { color: var(--warn); }
.error { background: var(--loss-bg); color: var(--loss); font-weight: 600; }
.card .error:last-child, .card .notice:last-child { margin-bottom: 0; }

/* status pill (Home strip) */
.status-strip { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
.pill {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: var(--sp-2);
  align-items: center; padding: 10px 12px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid transparent; min-width: 0;
}
.pill .icon { grid-row: 1 / span 2; width: 22px; height: 22px; padding: 0; }
.pill-label { font-size: var(--fs-sm); color: var(--muted); font-weight: 600; letter-spacing: 0.02em; }
.pill-value { font-size: var(--fs-md); font-weight: 600; overflow-wrap: anywhere; line-height: 1.3; }
.pill-ok .icon { color: var(--profit); }
.pill-warn { border-color: var(--warn-line); }
.pill-warn .icon, .pill-warn .pill-value { color: var(--warn); }
.pill-bad { border-color: var(--loss-line); background: var(--loss-bg); }
.pill-bad .icon, .pill-bad .pill-value { color: var(--loss); }
.pill-neutral .icon { color: var(--muted); }

/* metric tile and hero figure */
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
.metric { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.metric-label { font-size: var(--fs-sm); color: var(--muted); font-weight: 600; }
.metric-value { font-size: var(--fs-xl); font-weight: 600; line-height: 1.25; font-variant-numeric: proportional-nums; overflow-wrap: anywhere; }
.metric-note { font-size: var(--fs-sm); color: var(--muted); }
.metric-note.pos { color: var(--profit); }
.metric-note.neg { color: var(--loss); }
.hero-figure { font-size: var(--fs-hero); font-weight: 600; line-height: 1.05; letter-spacing: -0.035em; font-variant-numeric: proportional-nums; }
.hero-sub { color: var(--muted); font-size: var(--fs-sm); margin-top: var(--sp-1); }
/* the Scorecard's key figures: one card, figures in a grid (not a card each) */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4) var(--sp-3); }
.summary-row .metric {
  background: var(--surface); border: 1px solid transparent; border-radius: var(--r-lg); padding: var(--sp-3) var(--sp-4);
}
.range-form { margin-bottom: var(--sp-3); }
.range-form input { min-height: var(--tap); }
.summary-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); margin-bottom: var(--sp-4); }
.summary-row .metric-value { font-size: var(--fs-md); }

/* key-value grid */
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2) var(--sp-3); }
.kv-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kv-wide { grid-template-columns: 1fr; }
.kv-wide > div { display: flex; justify-content: space-between; gap: var(--sp-3); padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv-wide > div:last-child { border-bottom: 0; }
.kv dt, .kv-label { font-size: var(--fs-sm); color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.kv-wide dd { text-align: right; }

/* chips */
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: 700; line-height: 1.6; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.chip-accepted, .chip-pass, .chip-taken { background: var(--profit-bg); color: var(--profit); }
.chip-failed { background: var(--loss-bg); color: var(--loss); }
.chip-skipped_cap, .chip-skipped, .chip-warn, .chip-high { background: var(--warn-bg); color: var(--warn); }
.chip-medium { background: var(--info-bg); color: var(--info); }
.chip-neutral { background: var(--surface-3); color: var(--text-2); }
.bias {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: var(--r-pill);
  font-weight: 700; font-size: var(--fs-sm); background: var(--surface-3); color: var(--text);
  border: 1px solid var(--line-strong);
}
.bias::before { font-size: 10px; line-height: 1; }
.bias-long_only::before { content: "\25B2"; color: var(--profit); }
.bias-short_only::before { content: "\25BC"; color: var(--loss); }
.bias-both::before { content: "\25C6"; color: var(--info); }
.bias-flat::before { content: "\25A0"; color: var(--muted); }
.side {
  display: inline-flex; align-items: center; gap: 2px; margin-left: 4px; padding: 0 8px 0 4px; border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; vertical-align: 2px;
  background: var(--surface-3); color: var(--text-2);
}
.side .icon { width: 14px; height: 14px; vertical-align: 0; }
.side-long .icon { color: var(--profit); }
.side-short .icon { color: var(--loss); }
.level-chip {
  display: inline-flex; padding: 1px 8px; margin: 2px 4px 2px 0; border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: 600; background: var(--surface-2); border: 1px solid var(--line);
}
.level-chip::before { content: ""; width: 8px; height: 2px; margin: auto 6px auto 0; background: var(--muted); }
.level-chip.level-support::before { background: var(--lvl-support); }
.level-chip.level-resistance::before { background: var(--lvl-resist); }
.level-chip.level-both::before { background: var(--lvl-both); }
.levels-line { margin-top: var(--sp-3); line-height: 2; }
.levels-line .kv-label { margin-right: 6px; }

/* filter chips and switches */
.filters { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.chip-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.filter-chip, .switch-item {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 16px; border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid transparent; color: var(--text-2);
  font-weight: 600; font-size: var(--fs-sm); text-decoration: none;
}
.filter-chip:hover, .switch-item:hover { color: var(--text); background: var(--surface-3); }
.filter-chip.current, .switch-item.current { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.switch-sep { width: 1px; height: 24px; background: var(--line-strong); margin: 0 4px; }
.jump { margin-bottom: var(--sp-4); }
.jump .filter-chip { min-height: 36px; padding: 0 12px; font-size: var(--fs-sm); }
.more-filters > summary, .disclosure > summary, .setting-edit > summary {
  display: inline-flex; align-items: center; gap: var(--sp-2); min-height: var(--tap); cursor: pointer;
  font-weight: 600; font-size: var(--fs-sm); color: var(--text-2); list-style: none;
}
.more-filters > summary::-webkit-details-marker, .disclosure > summary::-webkit-details-marker,
.setting-edit > summary::-webkit-details-marker { display: none; }
.disclosure > summary::after, .setting-edit > summary::after {
  content: ""; width: 16px; height: 16px; background: currentColor;
  -webkit-mask: url("icons/chevron.svg") center / contain no-repeat; mask: url("icons/chevron.svg") center / contain no-repeat;
  transition: transform 0.15s;
}
.disclosure[open] > summary::after, .setting-edit[open] > summary::after { transform: rotate(90deg); }
.disclosure { margin-top: var(--sp-2); }
.filter-form { display: grid; gap: var(--sp-3); padding: var(--sp-3) 0; }
.filter-form.filter-inline { display: flex; flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: var(--sp-3); padding: 0; }
.filter-inline .field { flex: 1 1 140px; }
.filter-inline .button-row { margin: 0; }

/* forms */
.stack { display: grid; gap: var(--sp-4); }
.field { display: grid; gap: 6px; min-width: 0; }
.field-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
input, select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; border-radius: var(--r-md);
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line-strong);
  font: 400 16px/1.4 var(--font); font-variant-numeric: tabular-nums;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 1px; border-color: transparent; }
.form-title { font-size: var(--fs-md); margin-top: var(--sp-4); padding-top: var(--sp-4); border-top: 1px solid var(--line); }

/* empty state */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--sp-2);
  padding: var(--sp-6) var(--sp-4); color: var(--muted); font-size: var(--fs-sm);
}
.empty > .icon { display: none; } /* minimalist: words, not decoration */
.empty p { max-width: 36ch; }
.empty-small { padding: var(--sp-3) var(--sp-2); flex-direction: row; text-align: left; }
.empty-small > .icon { width: 32px; height: 32px; padding: 7px; }
.empty-inline { color: var(--muted); font-size: var(--fs-sm); margin-top: var(--sp-3); }

/* tables */
.table-wrap { overflow-x: auto; margin: var(--sp-2) 0; border: 1px solid var(--line); border-radius: var(--r-md); }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th, td { padding: 10px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child, th:nth-child(2):not(:last-child) { text-align: left; }
th { font-size: var(--fs-sm); font-weight: 700; color: var(--muted); background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tr.total td { font-weight: 700; background: var(--surface-2); }

/* ==== 5. Screens ================================================================================= */

/* Home */
.spark { margin-top: var(--sp-3); }
.spark-svg { display: block; overflow: visible; }
.spark-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark-line.pos { stroke: var(--profit); }
.spark-line.neg { stroke: var(--loss); }
.spark-area { stroke: none; opacity: 0.12; }
.spark-area.pos { fill: var(--profit); }
.spark-area.neg { fill: var(--loss); }
.spark-dot { stroke: var(--surface); stroke-width: 2; }
.spark-dot.pos { fill: var(--profit); }
.spark-dot.neg { fill: var(--loss); }
.spark figcaption { font-size: var(--fs-sm); color: var(--muted); margin-top: var(--sp-1); }
.pl { font-size: var(--fs-md); font-weight: 700; text-align: right; line-height: 1.2; white-space: nowrap; }
.pl-r { display: block; font-size: var(--fs-sm); font-weight: 600; opacity: 0.9; }
.view-now .card-head h3 { font-size: var(--fs-md); }
.view-line { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.age { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); font-weight: 600; color: var(--muted); white-space: nowrap; }
.age .icon { width: 14px; height: 14px; vertical-align: 0; }
.reason { margin-top: var(--sp-3); color: var(--text-2); font-size: var(--fs-sm); font-style: italic; }
.stale { border-color: var(--warn-line); }
.age-stale { color: var(--warn); }
.stale-note {
  display: flex; gap: 6px; align-items: flex-start; margin-top: var(--sp-3); padding: 8px 10px; border-radius: var(--r-sm);
  background: var(--warn-bg); color: var(--warn); font-size: var(--fs-sm); font-weight: 600;
}
.stale-note .icon { width: 16px; height: 16px; margin-top: 2px; vertical-align: 0; }
.countdown { font-size: var(--fs-xl); font-weight: 600; color: var(--accent); line-height: 1.2; }
.countdown-in { font-size: var(--fs-md); color: var(--muted); font-weight: 500; }
.countdown-what { margin-top: var(--sp-1); color: var(--text-2); font-size: var(--fs-sm); }
.feed { list-style: none; padding: 0; display: grid; gap: 2px; }
.feed-item { display: flex; gap: var(--sp-3); padding: 8px 0; border-bottom: 1px solid var(--line); }
.feed-item:last-child { border-bottom: 0; }
.feed-icon {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); color: var(--text-2);
}
.feed-icon .icon { width: 16px; height: 16px; vertical-align: 0; }
.feed-entry .feed-icon { color: var(--info); }
.feed-exit .feed-icon { color: var(--profit); }
.feed-stop .feed-icon { color: var(--loss); }
.feed-skip { opacity: 0.75; }
.feed-body { min-width: 0; flex: 1; }
.feed-title { font-weight: 600; font-size: var(--fs-sm); }
.feed-detail { color: var(--muted); font-size: var(--fs-sm); }
.lock-list { list-style: none; padding: 0; display: grid; gap: var(--sp-2); }
.lock { display: flex; gap: var(--sp-2); align-items: center; font-weight: 600; color: var(--loss); }

/* Views */
.timeline { list-style: none; padding: 0 0 0 20px; position: relative; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 8px; bottom: 8px; width: 2px; background: var(--line); border-radius: 2px; }
.timeline-item { position: relative; }
.timeline-dot {
  position: absolute; left: -20px; top: 22px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--profit); box-shadow: 0 0 0 3px var(--bg);
}
.status-failed .timeline-dot { background: var(--loss); }
.status-skipped_cap .timeline-dot { background: var(--warn); }
.view-time { font-size: var(--fs-md); }
.view-card .meta-line { margin-top: calc(-1 * var(--sp-2)); }
.view-inst { margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--line); }
.view-inst-head { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-2); }
.view-inst-head h3 { font-size: var(--fs-md); margin-right: 4px; }
.view-inst .levels-line + .small, .view-inst .small { margin-top: var(--sp-2); }
.reasons { margin: var(--sp-3) 0 0; padding-left: 18px; color: var(--text-2); }
.reasons li + li { margin-top: 4px; }
.problems { padding-left: 0; list-style: none; }
.scores { list-style: none; padding: 0; margin-top: var(--sp-3); display: flex; flex-wrap: wrap; gap: 6px; }
.score {
  padding: 3px 10px; border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: 600;
  background: var(--surface-2); color: var(--muted); border: 1px dashed var(--line-strong);
}
.score-right { background: var(--profit-bg); color: var(--profit); border: 1px solid transparent; }
.score-wrong { background: var(--loss-bg); color: var(--loss); border: 1px solid transparent; }
.score-abstained { border-style: solid; color: var(--text-2); }
.pager { margin: var(--sp-4) 0; }

/* Trades */
.trade-list { list-style: none; padding: 0; display: grid; gap: var(--sp-3); }
.trade-list .card { margin: 0; }
.trade-title { font-size: var(--fs-md); }
.trade-setup { color: var(--text-2); font-size: var(--fs-sm); margin: calc(-1 * var(--sp-2)) 0 var(--sp-3); }
.trade .kv + .small { margin-top: var(--sp-2); }
.trade-skipped { background: transparent; border-style: dashed; border-color: var(--line-strong); color: var(--text-2); }
.trade-skipped .trade-title, .trade-skipped .kv dd { color: var(--text-2); font-weight: 500; }
.skip-reason { display: flex; gap: 6px; align-items: flex-start; margin-top: var(--sp-2); font-size: var(--fs-sm); color: var(--muted); }
.skip-reason .icon { width: 16px; height: 16px; margin-top: 2px; vertical-align: 0; }

/* Charts (shared) */
.chart-frame { position: relative; margin: var(--sp-2) 0; touch-action: pan-y; }
.chart, .viz-svg { display: block; overflow: visible; font-family: var(--font); }
.grid { stroke: var(--grid); stroke-width: 1; }
.axis, .tick { stroke: var(--axis); stroke-width: 1; }
.axis-label {
  fill: var(--muted); font-size: 11px; font-weight: 500;
  paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round;
}
.price-label { text-anchor: end; }
.time-label { text-anchor: middle; }
.time-label.edge-start { text-anchor: start; }
.time-label.edge-end { text-anchor: end; }
.y-label { text-anchor: start; }
.crosshair { stroke: var(--text-2); stroke-width: 1; opacity: 0; pointer-events: none; }
.chart-frame.hovering .crosshair { opacity: 0.6; }
.chart-tip {
  position: absolute; top: 0; left: 0; z-index: 5; display: none; pointer-events: none;
  max-width: 240px; padding: 8px 10px; border-radius: var(--r-sm);
  background: var(--surface-3); border: 1px solid var(--line-strong); box-shadow: var(--shadow-2);
  font-size: var(--fs-sm); font-weight: 600; color: var(--text); line-height: 1.45;
}
.chart-frame.hovering .chart-tip { display: block; }
.legend { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: var(--sp-3); font-size: var(--fs-sm); color: var(--text-2); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend-values { font-size: var(--fs-sm); margin: var(--sp-2) 0 0; }
.legend-values strong { color: var(--text); }
.key { display: inline-block; flex: none; }
.key-line { width: 16px; height: 0; border-top: 2px solid var(--muted); }
.key-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.key-line.level-support { border-color: var(--lvl-support); }
.key-line.level-resistance { border-color: var(--lvl-resist); }
.key-line.level-both { border-color: var(--lvl-both); }
.key-line.weak-key { border-top-style: dashed; border-color: var(--muted); }
.key-line.vlevel-key { border-top-style: dotted; border-top-width: 3px; border-color: var(--accent); }
.key-line.stop-key { border-top-style: dashed; border-color: var(--loss); }
.key-line.series-s1 { border-color: var(--s1); }
.key-line.series-s2 { border-color: var(--s2); }
.key-line.series-s3 { border-color: var(--s3); border-top-style: dashed; }
.key-dot.mark-entry { background: var(--text); }
.key-dot.mark-exit-win { background: var(--profit); }
.key-dot.mark-exit-loss { background: var(--loss); }
.viz { margin: var(--sp-4) 0 var(--sp-2); }
.viz-title { font-size: var(--fs-sm); font-weight: 600; }

/* Chart screen: candles and levels */
.chart-symbol { font-size: var(--fs-md); }
.chart-last { font-size: var(--fs-md); font-weight: 700; color: var(--accent); white-space: nowrap; }
.candle .wick { stroke-width: 1; }
.candle.up .wick { stroke: var(--candle-up); }
.candle.up .body { fill: var(--candle-up); }
.candle.down .wick { stroke: var(--candle-down); }
.candle.down .body { fill: var(--candle-down); }
.gap-mark { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; opacity: 0.6; }
.level { stroke-width: 1; opacity: 0.85; }
.level-support { stroke: var(--lvl-support); }
.level-resistance { stroke: var(--lvl-resist); }
.level-both { stroke: var(--lvl-both); }
.level.weak { stroke-dasharray: 4 3; opacity: 0.6; }
.vlevel { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 1 3; stroke-linecap: round; }
.level-label {
  font-size: 10.5px; font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round;
}
text.level-support { fill: var(--lvl-support); }
text.level-resistance { fill: var(--lvl-resist); }
text.level-both { fill: var(--lvl-both); }
text.level-label.from-view { fill: var(--accent); }
.last-line { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 2 2; opacity: 0.8; }
.stop-line { stroke: var(--loss); stroke-width: 1.5; stroke-dasharray: 4 3; }
.trade-mark { stroke: var(--surface); stroke-width: 2; }
.mark-entry { fill: var(--text); }
.mark-exit-win { fill: var(--profit); }
.mark-exit-loss { fill: var(--loss); }
.mark-exit-flat { fill: var(--muted); }
.level-list { list-style: none; padding: 0; }
.level-row {
  display: grid; grid-template-columns: auto 1fr; column-gap: var(--sp-3); align-items: baseline;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.level-row:last-child { border-bottom: 0; }
.level-row.off-chart { opacity: 0.7; }
.level-price { font-weight: 700; grid-row: 1 / span 2; min-width: 6.5ch; }
.level-price.level-support { color: var(--lvl-support); }
.level-price.level-resistance { color: var(--lvl-resist); }
.level-price.level-both { color: var(--lvl-both); }
.level-name { font-weight: 500; }
.level-meta { font-size: var(--fs-sm); color: var(--muted); grid-column: 2; }

/* Scorecard */
.series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.series-s1 { stroke: var(--s1); }
.series-s2 { stroke: var(--s2); }
.series-s3 { stroke: var(--s3); }
.series-line.series-s3 { stroke-dasharray: 6 4; }
.end-dot { stroke: var(--surface); stroke-width: 2; }
circle.series-s1 { fill: var(--s1); }
circle.series-s2 { fill: var(--s2); }
circle.series-s3 { fill: var(--s3); }
/* Mode race: four books, colour plus a dash pattern each (Low solid, Medium long dash, Higher solid, Gambling dotted) */
.series-m1 { stroke: var(--m1); }
.series-m2 { stroke: var(--m2); }
.series-m3 { stroke: var(--m3); }
.series-m4 { stroke: var(--m4); }
.series-line.series-m2 { stroke-dasharray: 9 4; }
.series-line.series-m4 { stroke-dasharray: 1 4; stroke-width: 2.5; }
circle.series-m1 { fill: var(--m1); }
circle.series-m2 { fill: var(--m2); }
circle.series-m3 { fill: var(--m3); }
circle.series-m4 { fill: var(--m4); }
.key-line.series-m1 { border-color: var(--m1); }
.key-line.series-m2 { border-color: var(--m2); border-top-style: dashed; }
.key-line.series-m3 { border-color: var(--m3); }
.key-line.series-m4 { border-color: var(--m4); border-top-style: dotted; border-top-width: 3px; }
.race-table .key-line { display: inline-block; width: 18px; margin-right: var(--sp-2); vertical-align: middle; }
.race-lock { display: inline-flex; align-items: center; gap: 4px; color: var(--warn); }
.race-lock .icon { width: 16px; height: 16px; }
.hit { fill: transparent; cursor: crosshair; }
.verdict { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-2); font-size: var(--fs-md); }
.verdict-icon { display: inline-flex; width: 28px; height: 28px; border-radius: 50%; align-items: center; justify-content: center; flex: none; }
.verdict-icon .icon { width: 16px; height: 16px; vertical-align: 0; }
.verdict-pos .verdict-icon, .verdict.pos .verdict-icon { background: var(--profit-bg); color: var(--profit); }
.verdict-neg .verdict-icon, .verdict.neg .verdict-icon { background: var(--warn-bg); color: var(--warn); }
.verdict.pos, .verdict.neg { color: var(--text); }
.bars { list-style: none; padding: 0; display: grid; gap: var(--sp-3); margin-top: var(--sp-2); }
.bar-row { display: grid; grid-template-columns: 44px 1fr 48px; column-gap: var(--sp-3); align-items: center; }
.bar-label { font-weight: 700; font-size: var(--fs-sm); }
.bar-svg { display: block; overflow: visible; }
.bar-track { fill: var(--surface-3); }
.bar-fill { fill: var(--s1); }
.bar-ref { stroke: var(--text-2); stroke-width: 1; }
.bar-value { font-weight: 700; text-align: right; }
.bar-note { grid-column: 2 / span 2; font-size: var(--fs-sm); color: var(--muted); }
.bar-row:hover .bar-fill { opacity: 0.85; }
.checklist { list-style: none; padding: 0; margin-top: var(--sp-3); border: 1px solid var(--line); border-radius: var(--r-md); }
.check-row { display: grid; grid-template-columns: auto 1fr auto; gap: var(--sp-3); align-items: center; padding: 12px; border-bottom: 1px solid var(--line); }
.check-row:last-child { border-bottom: 0; }
.check-icon { display: inline-flex; width: 28px; height: 28px; border-radius: 50%; align-items: center; justify-content: center; }
.check-icon .icon { width: 16px; height: 16px; vertical-align: 0; }
.pass .check-icon { background: var(--profit-bg); color: var(--profit); }
.fail .check-icon { background: var(--warn-bg); color: var(--warn); }
.check-body { display: flex; flex-direction: column; min-width: 0; }
.check-detail { font-size: var(--fs-sm); color: var(--muted); }
.check-state { font-size: var(--fs-sm); font-weight: 700; white-space: nowrap; }
.pass .check-state { color: var(--profit); }
.fail .check-state { color: var(--warn); }

/* Settings */
.settings { list-style: none; padding: 0; }
.setting { padding: var(--sp-3) 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; padding-bottom: 0; }
.setting:first-child { padding-top: 0; }
.setting-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-3); }
.setting-name { min-width: 0; }
.setting-label { font-weight: 500; }
.setting .key { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.setting .value {
  flex: none; max-width: 45%; padding: 4px 10px; border-radius: var(--r-sm); background: var(--surface-2);
  border: 1px solid var(--line); font-weight: 700; font-size: var(--fs-sm); text-align: right; overflow-wrap: anywhere;
}
.changed { color: var(--muted); font-size: var(--fs-sm); margin-top: 2px; }
.setting-form { display: grid; gap: var(--sp-3); padding: var(--sp-2) 0 var(--sp-1); }
.setting-form .btn { justify-self: start; }
.has-error { background: var(--loss-bg); margin: 0 calc(-1 * var(--sp-4)); padding-left: var(--sp-4); padding-right: var(--sp-4); }
.pending-row { padding: var(--sp-2) 0; }
.row-head { display: flex; justify-content: space-between; gap: var(--sp-3); align-items: baseline; }
.audit { list-style: none; padding: 0; }
.audit > li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.audit > li:last-child { border-bottom: 0; }
.audit-head { display: flex; justify-content: space-between; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--muted); }
.what { font-weight: 500; font-size: var(--fs-sm); overflow-wrap: anywhere; }

/* Week ahead */
.event-list { list-style: none; padding: 0; }
.event-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.event-row:last-child { border-bottom: 0; }
.switch-state { font-size: var(--fs-md); }
.playbook.skipped { opacity: 0.75; border-style: dashed; }
.buckets { list-style: none; padding: 0; margin-top: var(--sp-3); display: grid; gap: var(--sp-2); }
.bucket { padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); font-size: var(--fs-sm); }
.body-view { margin-top: var(--sp-2); }
dl.body { margin: 0; }
dl.body > div { padding: 6px 0; }
dl.body dt { font-weight: 700; font-size: var(--fs-sm); color: var(--muted); letter-spacing: 0.03em; }
dl.body dd { margin: 0 0 0 var(--sp-3); }
dl.body-0 > div { border-bottom: 1px solid var(--line); }
dl.body-0 > div:last-child { border-bottom: 0; }
.body-list { margin: 4px 0; padding-left: 18px; }

/* Confirm, login, setup */
.confirm-lines { display: grid; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.confirm { max-width: 560px; }
.auth-page { padding-bottom: 0; }
.auth-page .page { min-height: 100vh; display: flex; flex-direction: column; }
.auth-page .topbar { position: static; background: transparent; border: 0; }
.auth-page .topbar .brand { display: none; }
.auth-page .content { flex: 1; display: flex; align-items: flex-start; justify-content: center; width: 100%; padding-top: 6vh; }
.auth { width: 100%; max-width: 400px; padding: var(--sp-6); }
.auth-brand { text-align: center; margin-bottom: var(--sp-6); }
.auth-mark { display: block; margin: 0 auto var(--sp-3); }
.auth-brand h1 { font-size: var(--fs-xl); }
.tagline { color: var(--accent); font-weight: 500; font-size: var(--fs-sm); margin-top: 2px; }

/* Usability pass (docs/design/ux-review.md) */

/* Home: one sentence that answers "is it working?" (word + icon, never colour alone) */
.headline {
  display: flex; align-items: flex-start; gap: 6px; padding: 0 2px; margin: 0 0 var(--sp-3);
  border-radius: var(--r-pill); border: 1px solid transparent;
  font-weight: 600; font-size: var(--fs-sm); line-height: 1.45; color: var(--text-2);
}
.headline .icon { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.headline-warn, .headline-bad { padding: 6px 12px; border-radius: var(--r-md); }
.headline-ok .icon { color: var(--profit); }
.headline-warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.headline-bad { background: var(--loss-bg); border-color: var(--loss-line); color: var(--loss); }

/* the Trading pill is a link to arm / disarm (with its own confirmation) */
.pill-link { color: inherit; text-decoration: none; min-height: var(--tap); }
.pill-link:hover { border-color: var(--muted); }
.pill-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* swing / scalp: a word in a pill. Neutral for swing, info blue for scalp (not a state colour) */
.family {
  display: inline-flex; align-items: center; padding: 0 8px; border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: 700; line-height: 1.6; letter-spacing: 0.02em; vertical-align: 2px;
  white-space: nowrap;
}
.family-swing { background: var(--surface-3); color: var(--text-2); border: 1px solid var(--line-strong); }
.family-scalp { background: var(--info-bg); color: var(--info); border: 1px solid transparent; }
.feed-title .family { margin-left: 2px; }
.family-split { list-style: none; margin: var(--sp-3) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-4); }
.family-split li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px var(--sp-2); font-size: var(--fs-sm); }
.family-split li .family { min-width: 52px; justify-content: center; }
.family-split-row { margin: calc(-1 * var(--sp-2)) 0 var(--sp-4); padding: var(--sp-3) var(--sp-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.family-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-2); }
.family-card { display: grid; gap: 4px; align-content: start; padding: var(--sp-3); background: var(--surface-2); border-radius: var(--r-md); }

/* section heading with an action beside it (Home: "Ask Claude now") */
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.section-head .section-title { margin-bottom: 0; }
.chip-note { flex-basis: 100%; font-size: var(--fs-sm); color: var(--muted); }
.control-state { margin-bottom: var(--sp-2); }

/* Trades table: one row per signal. Phone shows Time, Instrument, Side, Result, R; a tap opens the rest. */
.table-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); margin-bottom: var(--sp-2); }
.toggle-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle {
  display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 0 14px; cursor: pointer;
  border-radius: var(--r-pill); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2);
  font-size: var(--fs-sm); font-weight: 600;
}
.toggle::before { content: ""; width: 14px; height: 14px; border-radius: 4px; border: 2px solid var(--muted); flex: none; }
.toggle-input:checked + .toggle { color: var(--text); border-color: var(--muted); }
.toggle-input:checked + .toggle::before { background: var(--primary); border-color: var(--primary); }
.toggle-input:focus-visible + .toggle { outline: 2px solid var(--focus); outline-offset: 2px; }
.trades-wrap:has(.toggle-input:not(:checked)) .row-skipped { display: none; }
.trades-scroll {
  max-height: 75vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface);
}
.trades-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.trades-table th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2); text-align: left; padding: 0 8px;
  font-size: var(--fs-sm); font-weight: 700; color: var(--muted); border-bottom: 1px solid var(--line-strong); white-space: nowrap;
}
.trades-table td { padding: 6px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
.trades-table .c-num { text-align: right; white-space: nowrap; }
.trades-table th.c-num { text-align: right; }
.th-sort {
  min-height: var(--tap); padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer;
}
.th-sort::after { content: ""; margin-left: 4px; }
th[aria-sort="ascending"] .th-sort::after { content: "\25B2"; font-size: 9px; }
th[aria-sort="descending"] .th-sort::after { content: "\25BC"; font-size: 9px; }
.row-main { cursor: pointer; }
.row-main:hover td { background: var(--surface-2); }
.row-toggle {
  min-height: 40px; padding: 0; border: 0; background: none; color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; white-space: nowrap; text-align: left;
}
.trade-group.row-skipped td { color: var(--muted); }
.trade-group.row-skipped .side { opacity: 0.75; }
.cell-note { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
.trades-table .pos { color: var(--profit); font-weight: 600; }
.trades-table .neg { color: var(--loss); font-weight: 600; }
.row-detail td { background: var(--surface-2); border-top: 0; padding: 8px 12px 12px; }
.kv-detail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.js .row-detail { display: none; }
.js .trade-group.open .row-detail { display: table-row; }
.js .trade-group.open .row-main td { background: var(--surface-2); }
.trades-table .c-wide { display: none; }
.family-inline .family { margin-left: 2px; font-size: 10px; }
@media (min-width: 720px) {
  .trades-table .c-wide { display: table-cell; }
  .family-inline { display: none; }
  .row-detail { display: none; }
  .kv-detail { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Chart screen, calmer: soft grid, zones for close levels, labels kept apart at the right edge */
.chart .grid { opacity: 0.55; }
.chart .level { opacity: 0.7; }
.zone { opacity: 0.12; }
.zone-support { fill: var(--lvl-support); }
.zone-resistance { fill: var(--lvl-resist); }
.zone-both { fill: var(--lvl-both); }
.zone-view { fill: var(--accent); }
.chart .level-label { text-anchor: end; font-size: 10.5px; }
.key-band { width: 16px; height: 8px; border-radius: 2px; background: var(--muted); opacity: 0.4; }

/* the price ladder: levels above and below the last price */
.ladder { list-style: none; padding: 0; margin: 0 0 var(--sp-3); }
.ladder-row {
  display: grid; grid-template-columns: auto 1fr; column-gap: var(--sp-3); align-items: baseline;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.ladder-price { font-weight: 700; min-width: 8ch; font-variant-numeric: tabular-nums; grid-row: 1 / span 2; }
.ladder-price.level-support { color: var(--lvl-support); }
.ladder-price.level-resistance { color: var(--lvl-resist); }
.ladder-price.level-both { color: var(--lvl-both); }
.ladder-price.level-view { color: var(--accent); }
.ladder-name { font-weight: 500; font-size: var(--fs-sm); }
.ladder-meta { grid-column: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: var(--fs-sm); color: var(--muted); }
.ladder-weak .ladder-name { color: var(--text-2); }
.ladder-now { background: var(--surface-2); border-radius: var(--r-sm); padding: 8px; border: 1px solid var(--accent); margin: 4px 0; }
.ladder-now .ladder-price { color: var(--accent); }
.ladder-now .ladder-name { grid-row: 1 / span 2; align-self: center; font-weight: 700; }
.src-chip { padding: 0 6px; border-radius: var(--r-pill); background: var(--surface-3); color: var(--text-2); font-weight: 700; }
.src-chip.src-claude { color: var(--accent); }
.strength { display: inline-flex; gap: 2px; }
.strength .dot { width: 6px; height: 6px; border-radius: 50%; border: 1px solid var(--muted); }
.strength .dot.on { background: var(--text-2); border-color: var(--text-2); }
.ladder-dist { margin-left: auto; }

/* Scorecard: result by day, the account switch and the Analysis section */
.day-bar.pos { fill: var(--profit); }
.day-bar.neg { fill: var(--loss); }
.day-bar.flat { fill: var(--muted); }
.zero-line { stroke: var(--axis); stroke-width: 1; }
.filter-chip-off { opacity: 0.55; cursor: default; }
.kpis .metric-value .pos { color: var(--profit); }
.kpis .metric-value .neg { color: var(--loss); }
.analysis { margin-top: var(--sp-6); border-top: 1px solid var(--line); padding-top: var(--sp-4); }
.analysis > summary {
  display: grid; gap: 2px; min-height: var(--tap); cursor: pointer; padding: var(--sp-2) 0; margin-bottom: var(--sp-3); list-style: none;
}
.analysis > summary::-webkit-details-marker { display: none; }
.analysis-title { font-size: var(--fs-md); font-weight: 700; }
.analysis-title::after { content: " \25B8"; color: var(--muted); }
.analysis[open] .analysis-title::after { content: " \25BE"; }
.analysis-sub { font-size: var(--fs-sm); color: var(--muted); }
.why { color: var(--text-2); font-size: var(--fs-sm); margin-bottom: var(--sp-2); }

/* ==== 6. Wider screens =========================================================================== */

@media (max-width: 399px) {
  .mode-label { font-size: 11px; padding: 4px 8px; }
  .menu-key { display: none; }
}

@media (min-width: 720px) {
  .content { padding: var(--sp-5) var(--sp-6); }
  .mode-long { display: inline; }
  .mode-short { display: none; }
  .status-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { flex-direction: row; flex-wrap: wrap; align-items: center; column-gap: var(--sp-4); }
  .more-filters { flex-basis: 100%; }
  .filter-form { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
  .filter-form .button-row { grid-column: 1 / -1; }
  .trade-list { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}

@media (min-width: 1024px) {
  body { padding-bottom: 0; }
  .tabbar { display: none; }
  .topbar-row, .page-foot { max-width: 1240px; margin: 0 auto; }
  .topbar-row { padding: var(--sp-2) var(--sp-8); }
  .status-region { padding: 0 var(--sp-8); max-width: 1240px; margin: 0 auto; }
  .mode-label { max-width: none; font-size: var(--fs-sm); padding: 6px 14px; }
  .content { padding: var(--sp-5) var(--sp-8) var(--sp-8); }
  .card { padding: var(--sp-5); }
  .view-insts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--sp-6); }
  .chart-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--sp-4); align-items: start; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
}

@media (min-width: 1280px) {
  .trade-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Live prices (web/live.py, app.js part 6): a brief green or red flash on a change; older than 15 s the
   figure turns grey and says when it is from. The reduced-motion rule below switches the flash off. */
.live-value { font-variant-numeric: tabular-nums; border-radius: 4px; }
.live-value.live-stale { color: var(--muted); }
.live-value.live-stale::after { content: " as of " attr(data-asof); font-size: var(--fs-xs); font-weight: 400; }
.live-line { margin-bottom: var(--sp-3); }
.live-line .kv-label { margin-right: 6px; }
.flash-up { animation: live-flash-up 0.9s ease-out; }
.flash-down { animation: live-flash-down 0.9s ease-out; }
@keyframes live-flash-up { from { background: var(--profit-bg); } to { background: transparent; } }
@keyframes live-flash-down { from { background: var(--loss-bg); } to { background: transparent; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (forced-colors: active) {
  .kill-button, .btn-danger { border: 2px solid ButtonText; }
  .mode-label { border: 2px solid CanvasText; }
}

/* Trades: a compact summary line above the table */
.trade-summary {
  display: grid; gap: 2px; margin-bottom: var(--sp-3); padding: var(--sp-3) var(--sp-4); font-size: var(--fs-sm);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
}
.trade-summary .family-split { margin-top: var(--sp-2); }
.more-filters .chip-row { margin: var(--sp-2) 0; }
@media (max-width: 719px) {
  /* five columns that always fit 375 px: no sideways scroll */
  .trades-table { table-layout: fixed; font-size: 13px; }
  .trades-table th, .trades-table td { padding-left: 6px; padding-right: 6px; }
  .trades-table th:nth-child(1) { width: 19%; }
  .trades-table th:nth-child(2) { width: 25%; }
  .trades-table th:nth-child(5) { width: 19%; }
  .trades-table th:nth-child(10) { width: 22%; }
  .trades-table th:nth-child(11) { width: 15%; }
  .trades-table .family-inline { display: block; }
  .trades-table .side { margin-left: 0; padding: 0 6px 0 2px; font-size: 10px; }
  .row-detail dd { overflow-wrap: anywhere; }
}
.trades-table td:nth-child(2) { text-align: left; }
.trades-table th, .trades-table td { text-align: left; white-space: normal; border-bottom: 0; }
.trades-table .c-num, .trades-table th.c-num { text-align: right; white-space: nowrap; }
.trades-table th { white-space: nowrap; }
/* entries as hollow rings, so a busy scalp day reads as outlines with the exits filled in */
.trade-mark.mark-entry { fill: var(--surface); stroke: var(--text-2); stroke-width: 1.5; }
.key-dot.mark-entry { background: transparent; border: 2px solid var(--text-2); }

/* Trading mode: the compact control on Home and the four cards on Settings (web/modes.py) */
.mode-bar { display: grid; gap: var(--sp-2) var(--sp-4); grid-template-columns: 1fr; align-items: center; }
.mode-bar-title { font-size: var(--fs-md); font-weight: 600; display: flex; align-items: baseline; gap: var(--sp-2); flex-wrap: wrap; }
.mode-bar-title .kv-label { text-transform: uppercase; letter-spacing: 0.08em; }
.mode-bar .help { margin-top: var(--sp-1); }
.mode-bar .help .icon { width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; }
.mode-bar-form { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.mode-bar-form select { flex: 1 1 140px; min-width: 0; }
.mode-cards { display: grid; gap: var(--sp-3); grid-template-columns: 1fr; margin-top: var(--sp-4); }
.mode-card {
  border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-4);
  background: var(--surface-2); display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0;
}
.mode-card .card-head { margin-bottom: 0; }
.mode-card form { margin-top: auto; padding-top: var(--sp-2); }
.mode-card-current { border: 2px solid var(--primary); background: var(--surface); }
.mode-numbers { grid-template-columns: 1fr; gap: 0; }
.mode-numbers > div { display: flex; justify-content: space-between; gap: var(--sp-3); padding: 6px 0; border-bottom: 1px solid var(--line); }
.mode-numbers > div:last-child { border-bottom: 0; }
.mode-numbers dd { text-align: right; font-variant-numeric: tabular-nums; }
.chip-current { background: var(--primary); color: var(--on-primary); }
.chip-current .icon { width: 14px; height: 14px; }
.confirm-warning .icon { width: 18px; height: 18px; flex: none; }
@media (min-width: 720px) {
  .mode-bar { grid-template-columns: 1fr auto; }
  .mode-bar .link-more { grid-column: 1 / -1; }
  .mode-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .mode-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ==== 7. Cleaner layout (docs/decisions.md "Cleaner layout") ===================================== */

/* small button: still a 44 px tap target, quieter text */
.btn-small { padding: 0 14px; font-size: var(--fs-sm); gap: 6px; }
.btn-small .icon { width: 16px; height: 16px; }

/* drop-down menus built on <details>: work without the script; app.js closes them on an outside tap */
.menu { position: static; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-button {
  display: inline-flex; align-items: center; gap: 4px; min-height: var(--tap); padding: 0 12px;
  border-radius: var(--r-pill); background: var(--surface-2); color: var(--text); cursor: pointer;
  font-size: var(--fs-sm); font-weight: 600; white-space: nowrap;
}
.menu-button:hover { background: var(--surface-3); }
.menu[open] > .menu-button { background: var(--surface-3); }
.menu-key { color: var(--muted); font-weight: 500; }
.menu-caret { width: 16px; height: 16px; vertical-align: 0; color: var(--muted); }
.menu-pending { width: 14px; height: 14px; vertical-align: 0; color: var(--warn); }
.menu-button.mode-gambling .mode-name { color: var(--loss); }
.menu-panel {
  position: absolute; z-index: 40; top: calc(100% - 2px); left: var(--sp-4); right: var(--sp-4);
  display: grid; gap: 2px; padding: 6px; max-height: calc(100vh - 140px); overflow: auto;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-3);
}
.menu-title { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); padding: 6px 10px 2px; }
.menu-item {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); min-height: var(--tap);
  padding: 8px 10px; border-radius: var(--r-md); color: var(--text); text-decoration: none;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item.current { background: var(--surface-2); }
.menu-item .icon { color: var(--primary); width: 18px; height: 18px; }
.menu-item-text { display: grid; gap: 1px; min-width: 0; }
.menu-item-label { font-weight: 600; }
.menu-item-help { font-size: var(--fs-sm); color: var(--muted); line-height: 1.35; }
.menu-note { font-size: var(--fs-sm); color: var(--muted); padding: 6px 10px; }
.menu-note.warn-text { color: var(--warn); }
.menu-foot {
  display: flex; align-items: center; gap: 2px; min-height: var(--tap); padding: 0 10px; margin-top: 2px;
  border-top: 1px solid var(--line); font-size: var(--fs-sm); font-weight: 600; text-decoration: none;
}
.menu-foot .icon { width: 16px; height: 16px; }

/* top bar: logo, account badge, the screens (desktop), then the mode menu and the theme button */
.brand .wordmark { display: none; font-size: var(--fs-md); }
.top-tabs { display: none; align-items: center; gap: 2px; margin-left: var(--sp-3); }
@media (min-width: 1024px) { .brand .wordmark { display: inline; } .top-tabs { display: flex; } }
.top-tab {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: var(--r-pill);
  color: var(--muted); text-decoration: none; font-size: var(--fs-sm); font-weight: 500;
}
.top-tab:hover { color: var(--text); }
.top-tab.active { color: var(--text); background: var(--surface-2); font-weight: 600; }
.topbar-end { display: flex; align-items: center; gap: var(--sp-1); margin-left: auto; }
.theme-toggle { margin: 0; }
.icon-button {
  display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap);
  border: 0; border-radius: 50%; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-button:hover { background: var(--surface-2); color: var(--text); }
.icon-button .icon { width: 20px; height: 20px; vertical-align: 0; }
.icon-moon { display: none; }
:root[data-theme="light"] .icon-sun { display: none; }
:root[data-theme="light"] .icon-moon { display: block; }
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] .icon-sun { display: none; }
  :root[data-theme="auto"] .icon-moon { display: block; }
}

/* the kill switch: at the foot of every screen, one tap, no confirmation */
.page-foot {
  display: grid; gap: var(--sp-3); padding: var(--sp-4) var(--sp-4) var(--sp-6); max-width: 640px; margin: 0 auto;
}
.page-foot .logout { justify-self: center; margin: 0; }
.page-foot .btn-quiet { color: var(--muted); }

/* Home: the money, Claude's lean, open trades. Everything else sits lower. */
/* phone order: the money, open trades, then Claude's lean; a desktop puts the lean in a right column */
.home-top { display: grid; gap: 0 var(--sp-3); }
.home-top > .money { order: 0; }
.home-top > .positions { order: 1; }
.home-top > .lean { order: 2; }
.money-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: var(--sp-1) var(--sp-4); }
.money-cell { min-width: 0; }
.money-equity { text-align: right; }
.money .hero-figure { margin-top: 2px; }
.equity-figure { font-size: var(--fs-xl); font-weight: 600; line-height: 1.2; letter-spacing: -0.02em; margin: 2px 0 4px; }
.money > .caption { margin-top: 2px; }
.money .family-split { margin-top: var(--sp-2); }
.spark { margin-top: var(--sp-2); }
.spark figcaption { font-size: 11px; }
@media (max-width: 399px) {
  .money .hero-figure { font-size: 36px; }
}
@media (max-width: 719px) {
  .fam-count, .spark figcaption, .wide-only { display: none; }
}
.lean .card-head, .positions .card-head { align-items: center; margin-bottom: var(--sp-1); }
.lean-list, .pos-list, .facts { list-style: none; padding: 0; margin: 0; }
.lean-row { padding: var(--sp-2) 0; border-top: 1px solid var(--line); }
.lean-row:first-child { border-top: 0; padding-top: 0; }
.lean-row.stale { border-color: var(--line); }
.lean-head {
  display: flex; align-items: center; gap: var(--sp-2); min-height: var(--tap); color: var(--text); text-decoration: none;
}
.lean-head .icon { width: 16px; height: 16px; color: var(--muted); }
.lean-name { font-weight: 600; }
.lean-head .bias { padding: 2px 10px; font-size: var(--fs-sm); }
.lean-head .age { margin-left: auto; }
.lean-meta { font-size: var(--fs-sm); color: var(--text-2); }
.lean .reason {
  margin-top: 4px; font-size: var(--fs-sm); color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.lean .stale-note { margin-top: var(--sp-2); }
.lean > .caption { margin-top: var(--sp-2); font-size: 11px; }
.position-card {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--sp-3); align-items: center;
  padding: var(--sp-2) 0; border-top: 1px solid var(--line);
}
.position-card:first-child { border-top: 0; padding-top: 0; }
.pos-title { font-weight: 600; }
.pos-title .side { margin-left: 2px; }
.pos-sub { font-size: var(--fs-sm); color: var(--muted); }
.pos-levels { grid-column: 1 / -1; font-size: var(--fs-sm); color: var(--muted); margin-top: 2px; }
.pos-levels .num { color: var(--text-2); }
.pl-r { display: block; font-size: var(--fs-sm); font-weight: 600; opacity: 0.9; }
.feed-item { align-items: center; }
.feed-value { font-size: var(--fs-sm); font-weight: 600; text-align: right; white-space: nowrap; }
.stack-col { display: grid; gap: var(--sp-3); align-content: start; margin-bottom: var(--sp-3); }
.stack-col > .card { margin: 0; }
.fact {
  display: flex; align-items: center; gap: var(--sp-2); min-height: 40px; border-top: 1px solid var(--line); font-size: var(--fs-sm);
}
.fact:first-child { border-top: 0; }
.fact > .icon { width: 18px; height: 18px; color: var(--muted); }
.fact-label { color: var(--muted); }
.fact .pill-value, .fact-link { margin-left: auto; font-size: var(--fs-sm); font-weight: 600; }
.fact-link { display: inline-flex; align-items: center; gap: 2px; min-height: var(--tap); color: var(--text); text-decoration: none; }
.fact-link .icon { width: 16px; height: 16px; color: var(--muted); }
.fact-ok > .icon { color: var(--profit); }
.fact-warn > .icon, .fact-warn .pill-value { color: var(--warn); }
.fact-bad > .icon, .fact-bad .pill-value { color: var(--loss); }
.system .caption { margin-top: var(--sp-1); }
.countdown { font-size: var(--fs-xl); }
.countdown-in { font-size: var(--fs-sm); }
.controls .button-row { margin-top: var(--sp-1); }
.controls .caption { margin-top: var(--sp-2); }
.empty-inline { margin-top: var(--sp-1); }
.chart-symbol, .view-time { color: var(--text); font-size: var(--fs-md); }

/* segmented switches (instrument, timeframe, account): one grey track, the chosen one lifted */
.seg-nav { display: inline-flex; flex-wrap: nowrap; gap: 2px; padding: 2px; border-radius: var(--r-pill); background: var(--surface-2); }
.seg-nav .switch-item {
  min-height: 40px; padding: 0 14px; border: 0; background: transparent; color: var(--text-2); font-size: var(--fs-sm);
}
.seg-nav .switch-item:hover { color: var(--text); }
.seg-nav .switch-item.current { background: var(--primary); color: var(--on-primary); }

/* Week ahead: expected outcome rows with a range bar, analysis, a calendar by day, the feed line */
.outcome-list, .risk-list, .change-list, .calendar, .cal-items { list-style: none; padding: 0; margin: 0; }
.outcome-row { padding: var(--sp-3) 0; border-top: 1px solid var(--line); }
.outcome-row:first-child { border-top: 0; padding-top: 0; }
.outcome-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); }
.outcome-name { font-weight: 600; }
.outcome-price { margin-left: auto; font-weight: 600; }
.outcome-head .direction { font-size: var(--fs-sm); padding: 2px 12px; }
.direction-up { background: var(--profit-bg); color: var(--profit); }
.direction-down { background: var(--loss-bg); color: var(--loss); }
.direction-sideways { background: var(--info-bg); color: var(--info); }
.outcome-case { margin: var(--sp-1) 0 var(--sp-2); color: var(--text-2); font-size: var(--fs-sm); }
.range-bar { display: block; overflow: visible; }
.rb-track { fill: var(--surface-3); }
.rb-range { fill: var(--s1); opacity: 0.55; }
.rb-wrong { stroke: var(--loss); stroke-width: 2; stroke-dasharray: 3 2; }
.rb-price { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.rb-price.outside { fill: var(--warn); }
.range-text { margin-top: 2px; }
.analysis-block { padding: var(--sp-2) 0; }
.analysis-name { font-size: var(--fs-sm); font-weight: 600; margin-bottom: 4px; }
.risk-list li { font-size: var(--fs-sm); color: var(--text-2); padding-left: 14px; position: relative; }
.risk-list li::before { content: ""; position: absolute; left: 2px; top: 0.6em; width: 5px; height: 5px; border-radius: 50%; background: var(--warn); }
.change-row { padding: var(--sp-2) 0; border-top: 1px solid var(--line); font-size: var(--fs-sm); }
.owner-view { margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--line); }
.momentum-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); margin-bottom: var(--sp-3); }
.momentum-line form { margin: 0; }
.calendar { display: grid; gap: var(--sp-2); }
.cal-day { padding: var(--sp-2) 0; border-top: 1px solid var(--line); }
.cal-day:first-child { border-top: 0; }
.cal-day.past { opacity: 0.6; }
.cal-day.today .cal-date { color: var(--text); }
.cal-date { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); margin-bottom: 4px; display: flex; gap: var(--sp-2); align-items: center; }
.cal-item { padding: 4px 0; }
.cal-item.past { opacity: 0.6; }
.cal-line { display: flex; align-items: center; gap: var(--sp-2); }
.cal-time { color: var(--text-2); min-width: 3.2em; font-size: var(--fs-sm); }
.cal-name { font-weight: 600; font-size: var(--fs-sm); }
.impact { display: inline-flex; gap: 2px; }
.impact .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--surface-3); }
.impact .dot.on { background: var(--muted); }
.impact-high .impact .dot.on { background: var(--warn); }
.cal-meta { font-size: 11px; color: var(--muted); margin-left: calc(3.2em + var(--sp-2)); }
.cal-item .disclosure { margin: 0 0 0 calc(3.2em + var(--sp-2)); }
.cal-item .disclosure > summary { min-height: 32px; font-size: var(--fs-sm); }
.cal-empty { font-size: var(--fs-sm); color: var(--muted); }
.feed-foot { margin: 0 0 var(--sp-3); padding: 0 var(--sp-1); }
.feed-foot .disclosure > summary { color: var(--muted); font-weight: 500; }
@media (min-width: 1024px) {
  .calendar { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--sp-3); }
  .cal-day { border-top: 0; border-left: 1px solid var(--line); padding: 0 var(--sp-3); }
  .cal-day:first-child { border-left: 0; padding-left: 0; }
  .cal-meta, .cal-item .disclosure { margin-left: 0; }
  .cal-line { flex-wrap: wrap; }
}

/* Views: one block per instrument (the view, what changes it, levels), then the history table */
.view-blocks { display: grid; gap: 0 var(--sp-3); }
.view-block-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px var(--sp-3); margin-bottom: var(--sp-2); }
.view-block-name { font-size: var(--fs-md); color: var(--text); }
.view-block-price { font-weight: 600; }
.view-block-head .caption { margin-left: auto; }
.view-call { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); }
.direction {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 14px; border-radius: var(--r-pill);
  font-size: var(--fs-xl); font-weight: 600; letter-spacing: -0.01em; background: var(--surface-2);
}
.direction::before { font-size: 12px; }
.direction-long_only { background: var(--profit-bg); color: var(--profit); }
.direction-short_only { background: var(--loss-bg); color: var(--loss); }
.direction-both { background: var(--info-bg); color: var(--info); }
.direction-long_only::before, .direction-short_only::before, .direction-both::before { color: currentColor; }
.view-conf strong { font-size: var(--fs-xl); font-weight: 600; }
.view-does { margin: var(--sp-2) 0; font-size: var(--fs-sm); color: var(--text-2); }
.view-facts { margin-bottom: var(--sp-3); }
.view-block h3.label { margin: var(--sp-3) 0 var(--sp-1); }
.view-changes { margin: 0; padding-left: 18px; font-size: var(--fs-sm); color: var(--text-2); }
.view-changes li + li { margin-top: 2px; }
.view-block .levels-line { margin-top: 0; }
.view-history td { vertical-align: top; text-align: left; white-space: normal; }
.view-history th { text-align: left; }
.view-mini { display: inline-flex; align-items: center; gap: 4px; margin: 0 8px 4px 0; white-space: nowrap; }
.view-mini .bias { padding: 0 8px; font-size: 12px; font-weight: 600; }
.view-history .scored .cell-note { white-space: normal; }
@media (min-width: 1024px) {
  .view-blocks { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}

/* Chart: a toolbar, a compact canvas (static/chart.js) and a side panel. The SVG is the no-script view. */
.chart-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.tools-menu { display: none; position: relative; }
.js-chart .tools-menu { display: block; }
.tools-panel { left: auto; right: auto; width: min(320px, calc(100vw - 32px)); top: calc(100% + 6px); }
.tool {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; min-height: 40px; padding: 4px 10px;
  border-radius: var(--r-md); font-size: var(--fs-sm); font-weight: 500; color: var(--text); cursor: pointer;
}
.tool:hover { background: var(--surface-2); }
.tool input { width: 18px; height: 18px; min-height: 0; margin: 0; padding: 0; accent-color: var(--primary); }
.tool-help { flex-basis: 100%; margin-left: 28px; font-size: 11px; color: var(--muted); }
.chart-readout {
  display: none; flex: 1 1 100%; flex-wrap: wrap; gap: 2px 12px; min-height: 20px;
  font-size: var(--fs-sm); color: var(--text-2); font-variant-numeric: tabular-nums;
}
.ohlc-time { color: var(--muted); }
.ohlc-key { color: var(--muted); font-weight: 600; }
.ohlc-note { flex-basis: 100%; color: var(--muted); }
.chart-last { font-size: var(--fs-xl); font-weight: 600; color: var(--accent); letter-spacing: -0.02em; }
.lw { display: none; position: relative; height: 280px; touch-action: pan-y; }
.lw-canvas { display: block; outline: none; border-radius: var(--r-sm); cursor: crosshair; }
.lw-canvas:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.js-only { display: none; }
.js-chart .chart-readout { display: flex; }
.js-chart .lw { display: block; }
.js-chart .svg-fallback { display: none; }
.js-chart .js-only { display: inline; }
.chart-failed .lw { display: none; }
.chart-failed .svg-fallback { display: block; }
.chart-card { padding: var(--sp-2) var(--sp-2) var(--sp-3); }
.window-links { margin: var(--sp-2); }
.chart-note { margin: var(--sp-2) var(--sp-2) 0; font-size: 11px; }
.chart-side { display: grid; gap: var(--sp-4); }
.side-head .chart-symbol { color: var(--muted); font-size: var(--fs-sm); font-weight: 600; }
.side-section { border-top: 1px solid var(--line); padding-top: var(--sp-3); }
.side-section > .label { margin-bottom: var(--sp-2); }
.side-section .ladder { margin-bottom: var(--sp-1); }
.side-section .lean-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); min-height: 0; }
.levels-card .ladder-row { padding: 6px 0; }
.sizeup-list { list-style: none; padding: 0; margin: var(--sp-2) 0; font-size: var(--fs-sm); color: var(--text-2); }
.sizeup { display: grid; grid-template-columns: auto 1fr; column-gap: var(--sp-3); padding: 4px 0; }
.sizeup-price { font-weight: 700; color: var(--warn); min-width: 8ch; }
.sizeup.unused { color: var(--muted); }
.sizeup.unused .sizeup-price { color: var(--muted); text-decoration: line-through; }
.sizeup-reason { display: block; font-size: 11px; color: var(--muted); }
.ind-s1 .ohlc-key { color: var(--s1); }
.ind-s2 .ohlc-key { color: var(--s2); }
@media (min-width: 720px) {
  .chart-readout { flex: 1 1 auto; justify-content: flex-end; }
}
@media (min-width: 1024px) {
  .lw { height: 400px; }
  .chart-layout { grid-template-columns: minmax(0, 1fr) 340px; gap: var(--sp-3); }
}

@media (min-width: 720px) {
  .money-row { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: end; }
  .menu.mode-menu { position: relative; }
  .mode-menu .menu-panel { left: 0; right: auto; width: 340px; top: calc(100% + 6px); }
}
@media (min-width: 1024px) {
  .home-top { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); grid-template-areas: "money lean" "pos lean"; align-items: start; }
  .home-top > .money { grid-area: money; }
  .home-top > .positions { grid-area: pos; }
  .home-top > .lean { grid-area: lean; }
}
