/* ──────────────────────────────────────────────────────────────────
   Symbol Screen — BROADSHEET stylesheet
   A warm-paper, ink-black, serif-headline financial system.

   Authored on top of tokens.css (the design-handoff source of truth).
   Components drawn as hairline-ruled broadsheet blocks, not boxed cards.
   ────────────────────────────────────────────────────────────────── */

/* ── Fonts ─────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,500;0,8..60,600;0,8..60,700;0,8..60,900;1,8..60,400;1,8..60,700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ═══════════════════════════════════════════════════════════════════
   1. TOKENS — single source of truth (copied from design_handoff tokens.css)
   ═══════════════════════════════════════════════════════════════════ */
:root {
  /* Paper & ink */
  --paper:       #f4efe6;   /* warm cream — default page */
  --paper-warm:  #ebe4d6;   /* darker paper band (mastheads, pullouts) */
  --paper-soft:  #faf7f0;   /* brightest — hover/card interiors */
  --paper-deep:  #e3dccc;   /* deepest paper — sidebars */

  --ink:        #1a1610;    /* primary text — warm near-black */
  --ink-soft:   #3d362a;    /* secondary */
  --ink-dim:    #756b58;    /* meta, labels */
  --ink-muted:  #9c9583;    /* fineprint */
  --rule:       #1a1610;    /* hairline rules in full ink */
  --rule-soft:  rgba(26,22,16,0.15);
  --rule-hair:  rgba(26,22,16,0.08);

  /* Spot colors — used sparingly, like a 2-color press run */
  --bull:       #1f6b3a;
  --bull-ink:   #0f4422;
  --bear:       #a81e1e;
  --bear-ink:   #6b0f0f;
  --warn:       #a56500;
  --accent:     #2b4a7a;    /* navy — editorial accent, links */
  --star:       #a56500;

  /* Sentiment margin band (left row rule) */
  --sentiment-bull: #1f6b3a;
  --sentiment-neu:  #9c9583;
  --sentiment-bear: #a81e1e;

  /* Tier background tints (paper-printed feel, not UI highlights) */
  --tier-base-bg:        rgba(31,107,58,0.08);
  --tier-base-fg:        #0f4422;
  --tier-stabilising-bg: rgba(165,101,0,0.10);
  --tier-stabilising-fg: #6b4200;
  --tier-danger-bg:      rgba(168,30,30,0.08);
  --tier-danger-fg:      #6b0f0f;
  --tier-pullback-bg:    rgba(43,74,122,0.08);
  --tier-pullback-fg:    #1c3354;
  --tier-accum-bg:       rgba(0,110,130,0.08);
  --tier-accum-fg:       #005566;
  --tier-jpattern-bg:    rgba(88, 56, 140, 0.08);
  --tier-jpattern-fg:    #3d1f7a;
  --tier-etf-bg:         rgba(26,22,16,0.05);
  --tier-etf-fg:         #3d362a;

  /* Fonts */
  --font-serif: 'Source Serif 4', 'Iowan Old Style', 'Charter', Georgia, serif;
  --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:  'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --num-features: 'tnum';

  /* Type scale */
  --fs-masthead: 42px;
  --fs-hero:     64px;
  --fs-display:  36px;
  --fs-h1:       22px;
  --fs-h2:       17px;
  --fs-body:     14px;
  --fs-read:     16px;
  --fs-sm:       13px;
  --fs-xs:       12px;
  --fs-2xs:      11px;
  --fs-caps:     10px;

  --lh-body:  1.55;
  --lh-read:  1.5;
  --lh-tight: 1.1;
  --tr-tight: -0.01em;
  --tr-caps:   0.12em;

  /* Spacing (4px grid) */
  --sp-1:  4px;  --sp-2:  8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px;  --sp-6: 24px;  --sp-8: 32px; --sp-10: 40px;
  --sp-12: 48px; --sp-16: 64px;

  /* Radii — tight */
  --r-xs:   2px;
  --r-sm:   3px;
  --r:      4px;
  --r-pill: 999px;

  /* Elevation — almost none */
  --shadow-card:   0 1px 0 rgba(26,22,16,0.06);
  --shadow-drawer: -8px 0 24px rgba(26,22,16,0.12);
}
/* ── Dark theme tokens ───────────────────────────── */
/* Applied via system preference OR explicit [data-theme="dark"] on <html>. */
@media (prefers-color-scheme: dark) { :root {
  --paper:      #1c1814;
  --paper-warm: #161310;
  --paper-soft: #211e18;
  --paper-deep: #120f0c;
  --ink:        #f0eadc;
  --ink-soft:   #d4ccbc;
  --ink-dim:    #9e9585;
  --ink-muted:  #6b6357;
  --rule:       rgba(240,234,220,0.80);
  --rule-soft:  rgba(240,234,220,0.12);
  --rule-hair:  rgba(240,234,220,0.07);
  --bull:            #2ea854;
  --bull-ink:        #2ea854;
  --bear:            #d44040;
  --bear-ink:        #d44040;
  --warn:            #c98a2a;
  --accent:          #5b8ec4;
  --star:            #c98a2a;
  --sentiment-bull:  #2ea854;
  --sentiment-bear:  #d44040;
  --tier-base-bg:        rgba(46,168,84,0.15);
  --tier-base-fg:        #2ea854;
  --tier-stabilising-bg: rgba(201,138,42,0.15);
  --tier-stabilising-fg: #c98a2a;
  --tier-danger-bg:      rgba(212,64,64,0.15);
  --tier-danger-fg:      #d44040;
  --tier-pullback-bg:    rgba(91,142,196,0.15);
  --tier-pullback-fg:    #5b8ec4;
  --tier-accum-bg:       rgba(0,175,204,0.12);
  --tier-accum-fg:       #1aafcc;
  --tier-jpattern-bg:    rgba(158,123,219,0.12);
  --tier-jpattern-fg:    #9e7bdb;
  --tier-etf-bg:         rgba(240,234,220,0.08);
  --tier-etf-fg:         #d4ccbc;
  --shadow-card:   0 1px 0 rgba(0,0,0,0.30);
  --shadow-drawer: -8px 0 24px rgba(0,0,0,0.50);
}}

[data-theme="dark"] {
  --paper:      #1c1814;
  --paper-warm: #161310;
  --paper-soft: #211e18;
  --paper-deep: #120f0c;
  --ink:        #f0eadc;
  --ink-soft:   #d4ccbc;
  --ink-dim:    #9e9585;
  --ink-muted:  #6b6357;
  --rule:       rgba(240,234,220,0.80);
  --rule-soft:  rgba(240,234,220,0.12);
  --rule-hair:  rgba(240,234,220,0.07);
  --bull:            #2ea854;
  --bull-ink:        #2ea854;
  --bear:            #d44040;
  --bear-ink:        #d44040;
  --warn:            #c98a2a;
  --accent:          #5b8ec4;
  --star:            #c98a2a;
  --sentiment-bull:  #2ea854;
  --sentiment-bear:  #d44040;
  --tier-base-bg:        rgba(46,168,84,0.15);
  --tier-base-fg:        #2ea854;
  --tier-stabilising-bg: rgba(201,138,42,0.15);
  --tier-stabilising-fg: #c98a2a;
  --tier-danger-bg:      rgba(212,64,64,0.15);
  --tier-danger-fg:      #d44040;
  --tier-pullback-bg:    rgba(91,142,196,0.15);
  --tier-pullback-fg:    #5b8ec4;
  --tier-accum-bg:       rgba(0,175,204,0.12);
  --tier-accum-fg:       #1aafcc;
  --tier-jpattern-bg:    rgba(158,123,219,0.12);
  --tier-jpattern-fg:    #9e7bdb;
  --tier-etf-bg:         rgba(240,234,220,0.08);
  --tier-etf-fg:         #d4ccbc;
  --shadow-card:   0 1px 0 rgba(0,0,0,0.30);
  --shadow-drawer: -8px 0 24px rgba(0,0,0,0.50);
}

[data-theme="light"] {
  --paper:      #f4efe6;
  --paper-warm: #ebe4d6;
  --paper-soft: #faf7f0;
  --paper-deep: #e3dccc;
  --ink:        #1a1610;
  --ink-soft:   #3d362a;
  --ink-dim:    #756b58;
  --ink-muted:  #9c9583;
  --rule:       #1a1610;
  --rule-soft:  rgba(26,22,16,0.15);
  --rule-hair:  rgba(26,22,16,0.08);
  --bull:            #1f6b3a;
  --bull-ink:        #0f4422;
  --bear:            #a81e1e;
  --bear-ink:        #6b0f0f;
  --warn:            #a56500;
  --accent:          #2b4a7a;
  --star:            #a56500;
  --sentiment-bull:  #1f6b3a;
  --sentiment-bear:  #a81e1e;
  --tier-base-bg:        rgba(31,107,58,0.08);
  --tier-base-fg:        #0f4422;
  --tier-stabilising-bg: rgba(165,101,0,0.10);
  --tier-stabilising-fg: #6b4200;
  --tier-danger-bg:      rgba(168,30,30,0.08);
  --tier-danger-fg:      #6b0f0f;
  --tier-pullback-bg:    rgba(43,74,122,0.08);
  --tier-pullback-fg:    #1c3354;
  --tier-accum-bg:       rgba(0,110,130,0.08);
  --tier-accum-fg:       #005566;
  --tier-jpattern-bg:    rgba(88,56,140,0.08);
  --tier-jpattern-fg:    #3d1f7a;
  --tier-etf-bg:         rgba(26,22,16,0.05);
  --tier-etf-fg:         #3d362a;
  --shadow-card:   0 1px 0 rgba(26,22,16,0.06);
  --shadow-drawer: -8px 0 24px rgba(26,22,16,0.12);
}


/* ═══════════════════════════════════════════════════════════════════
   2. BASE — reset, body, typography primitives
   ═══════════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* Kill iOS WKWebView pull-to-refresh: rubber-banding past the top of the
     page triggers a native reload, which on first launch yanks the user
     out of "Loading…" before Firestore can deliver data. */
  overscroll-behavior: none;
  /* Anchor the scroll root so WKWebView cannot rubber-band past the top.
     height:100% on both html and body gives the WebView a defined scroll
     boundary and ensures the paper background fills the full viewport,
     eliminating any dark WKWebView chrome bleeding through on overscroll. */
  height: 100%;
}

/* iOS/WKWebView: kill double-tap-zoom + 300ms delay + grey tap-flash.
   touch-action: manipulation disables double-tap-zoom on all descendants;
   paired with user-scalable=no in the viewport meta as belt-and-suspenders. */
body {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: var(--tr-tight);
  margin: 0;
  line-height: var(--lh-tight);
}
h1 { font-size: var(--fs-h1); font-weight: 700; }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h2); }
h4 { font-size: var(--fs-sm); font-family: var(--font-sans); text-transform: uppercase; letter-spacing: var(--tr-caps); color: var(--ink-dim); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Utility type classes */
.caps {
  font-family: var(--font-sans);
  font-size: var(--fs-caps);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  color: var(--ink-dim);
}
.kicker {
  font-family: var(--font-sans);
  font-size: var(--fs-caps);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  color: var(--ink-dim);
}
.kicker .sep { margin: 0 .4em; color: var(--ink-muted); }

.mono, .num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}
.serif { font-family: var(--font-serif); }
.serif-italic { font-family: var(--font-serif); font-style: italic; }

.pos, .up, .chg-pos { color: var(--bull-ink); }
.neg, .down, .chg-neg { color: var(--bear-ink); }
.dim { color: var(--ink-dim); }

.arrow-up::before { content: '▲\0020'; font-size: 0.78em; }
.arrow-down::before { content: '▼\0020'; font-size: 0.78em; }

/* Hairline rule primitives */
.rule       { border: 0; border-top: 1px solid var(--rule);      height: 0; margin: 0; }
.rule-soft  { border: 0; border-top: 1px solid var(--rule-soft); height: 0; margin: 0; }
.rule-hair  { border: 0; border-top: 1px solid var(--rule-hair); height: 0; margin: 0; }
.rule-double{ border: 0; border-top: 3px double var(--ink);      height: 3px; margin: 0; }

hr { border: 0; border-top: 1px solid var(--rule-soft); margin: var(--sp-4) 0; }

/* ═══════════════════════════════════════════════════════════════════
   3. LAYOUT — masthead + ribbon + 3-column page grid
   ═══════════════════════════════════════════════════════════════════ */

/* Outer page wrapper — only shown when signed-in. */
body.signed-in .page-wrap { display: grid; grid-template-rows: auto auto auto 1fr auto; min-height: 100vh; }
body.signed-out .page-wrap { display: none; }

/* ── Masthead ─────────────────────────────────────────────────── */
.masthead {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: var(--sp-5);
  /* env(safe-area-inset-top) keeps the wordmark out of the Dynamic Island
     on iOS; falls back to 0 on web and non-notched devices. */
  padding: calc(var(--sp-5) + env(safe-area-inset-top, 0px)) var(--sp-10) var(--sp-2);
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.masthead-left,
.masthead-right {
  font-family: var(--font-sans);
  font-size: var(--fs-2xs);
  color: var(--ink-dim);
  line-height: 1.5;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.masthead-right { text-align: right; }
.masthead-left .bold,
.masthead-right .bold { color: var(--ink); font-weight: 700; }

/* Screener commit SHA + staleness pill in masthead-left */
.masthead-sha { display: inline-block; }
.sha-link {
  color: var(--ink-dim);
  text-decoration: none;
  letter-spacing: 0.04em;
  font-family: var(--font-mono, monospace);
}
.sha-link:hover { color: var(--ink); text-decoration: underline; }
.sha-stale {
  display: inline-block;
  margin-left: 5px;
  color: #a0531a;
  font-family: var(--font-sans);
  letter-spacing: 0.06em;
  cursor: help;
}

.masthead-title { text-align: center; padding-bottom: 2px; }
.masthead-wordmark {
  font-family: var(--font-serif);
  font-weight: 900;
  font-style: italic;
  font-size: 48px;
  line-height: 0.9;
  letter-spacing: -0.025em;
  color: var(--ink);
}
.masthead-wordmark .the {
  font-weight: 700;
  font-style: normal;
  font-size: 0.42em;
  vertical-align: 0.85em;
  letter-spacing: 0.2em;
  margin-right: 6px;
  color: var(--ink-soft);
}
.masthead-motto {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  margin-top: 4px;
}

.masthead-auth {
  display: flex; align-items: center; gap: var(--sp-3);
  justify-content: flex-end;
  text-transform: none;
  letter-spacing: 0;
}

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0;
  border: none; background: transparent; cursor: pointer;
  color: var(--ink-dim);
  border-radius: var(--r);
  transition: color 0.15s, background 0.15s;
  text-transform: none; letter-spacing: 0;
  vertical-align: middle;
}
.theme-toggle:hover { color: var(--ink); background: var(--rule-hair); }
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: inline-block; }
@media (prefers-color-scheme: dark) {
  .theme-toggle .icon-sun  { display: inline-block; }
  .theme-toggle .icon-moon { display: none; }
}
[data-theme="dark"] .theme-toggle .icon-sun  { display: inline-block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun  { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: inline-block; }

/* ── Ribbon: static market indices + run status ───────────────── */
.ribbon {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: var(--sp-2) var(--sp-10);
  font-family: var(--font-sans);
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-dim);
  border-top: 3px double var(--ink);
  border-bottom: 3px double var(--ink);
  background: var(--paper-warm);
}
.ribbon-indices { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); justify-self: start; }
.ribbon-index {
  font-family: var(--font-mono);
  letter-spacing: 0;
  text-transform: none;
}
.ribbon-index .t { color: var(--ink); font-weight: 600; margin-right: 6px; font-family: var(--font-sans); font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: 0.1em; }
.ribbon-index .v { color: var(--ink); font-weight: 600; }
.ribbon-sep { margin: 0 var(--sp-2); color: var(--ink-muted); }

.ribbon-status { display: flex; align-items: center; gap: var(--sp-2); justify-self: center; }
.ribbon-sync::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--bull);
  margin-right: 4px;
  vertical-align: 1px;
}

/* ── 3-col page grid ──────────────────────────────────────────── */
.page {
  display: grid;
  grid-template-columns: 260px minmax(0,1fr) 300px;
  gap: 0;
  min-height: 0;
}
.page > .col {
  padding: var(--sp-5) var(--sp-5);
  min-width: 0;       /* allow center col to shrink + scroll */
}
.page > .col + .col { border-left: 1px solid var(--rule); }
.page > .col.center { padding: var(--sp-5) var(--sp-6); }

/* Right rail: Calendar/About hide it. Screener/Watchlist/Positions keep it. */
body.view-calendar .page > .col.right,
body.view-about    .page > .col.right { display: none; }

/* Positions: right rail shows earnings only (hide watchlist movers module) */
body.view-positions #rr-watchlist,
body.view-positions .rail-rule { display: none; }

/* Screener: right rail shows watchlist + callout only — hide earnings module */
body.view-screen #rr-earnings,
body.view-screen .rail-rule:has(+ #rr-earnings) { display: none; }

/* Left column: uniform 260px on all pages so section-nav items are the same size.
   Filter rail sections are hidden on non-screener pages, but the column width stays
   consistent so the nav doesn't jump. */
body.view-watchlist .page,
body.view-positions .page { grid-template-columns: 260px minmax(0, 1fr) 300px; }
body.view-about    .page { grid-template-columns: 260px minmax(0, 1fr); }
/* Calendar: full-width — left nav hides, bottom tabs take over navigation */
body.view-calendar .page { grid-template-columns: 1fr; }
body.view-calendar .page > .col.left { display: none; }
body.view-calendar .bottom-tabs { display: flex; }
body.view-calendar.signed-in { padding-bottom: calc(57px + env(safe-area-inset-bottom, 0px)); }
body.view-calendar .page > .col.center { padding-left: 0; padding-right: 0; }
body.view-calendar .center-head { padding: 0 var(--sp-6) var(--sp-3); }
body.view-calendar .cal-sub-wrap { padding: 0 var(--sp-6); }

/* Filter rail: visible by default (screener is the landing tab).
   Hidden on every non-screener view. */
body.view-watchlist .page > .col.left .rail-section,
body.view-calendar  .page > .col.left .rail-section,
body.view-positions .page > .col.left .rail-section,
body.view-about     .page > .col.left .rail-section,
body.view-watchlist .page > .col.left #prefs-sync-status,
body.view-calendar  .page > .col.left #prefs-sync-status,
body.view-positions .page > .col.left #prefs-sync-status,
body.view-about     .page > .col.left #prefs-sync-status { display: none; }

/* ── Footer ───────────────────────────────────────────────────── */
.page-footer {
  border-top: 1px solid var(--rule);
  padding: 6px var(--sp-4);
  font-size: 10px;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px;
  background: var(--paper);
}
.footer-disclaimer {
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
}
.page-footer a { color: var(--ink-soft); }
.footer-about-btn {
  background: none; border: none; padding: 0;
  font: inherit; font-size: 0.78rem;
  color: var(--ink-soft);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.footer-about-btn:hover { color: var(--ink); }

/* Phone-only account row — email + sign-out. Hidden ≥761px (auth pill
   in the masthead covers it there). */
.footer-account {
  display: none;
  align-items: center; justify-content: center; gap: var(--sp-3);
  width: 100%;
  padding-top: 4px;
  text-transform: none; letter-spacing: 0;
  font-size: var(--fs-xs);
  color: var(--ink-soft);
}
.footer-account-email { font-weight: 500; color: var(--ink); }
.footer-signout-btn {
  background: none; border: 1px solid var(--rule);
  padding: 4px var(--sp-3);
  font-family: var(--font-sans); font-size: var(--fs-xs);
  color: var(--ink-soft); cursor: pointer;
  border-radius: var(--r-xs);
}
.footer-signout-btn:hover { color: var(--accent); border-color: var(--accent); }
@media (max-width: 760px) {
  body.signed-in .footer-account { display: flex !important; }
}

/* ═══════════════════════════════════════════════════════════════════
   4. LEFT RAIL — section nav + filters
   ═══════════════════════════════════════════════════════════════════ */
.rail-kicker {
  font-family: var(--font-sans);
  font-weight: 700;
  letter-spacing: 0.14em;
  font-size: 10px;
  color: var(--ink-muted);
  margin-bottom: var(--sp-2);
  text-transform: uppercase;
}

/* ── Section nav: vertical activity-bar rail ──────────────────────
   Items are full-width rows: a fixed 36×36 icon cell on the left,
   then a label that fades in when the whole nav group is hovered.
   Active item gets a 2px accent left-border + tinted background.
   Separated from the filters below by a double rule. */
.section-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-top: none;
  border-bottom: 3px double var(--ink);
  padding: 4px 0 0;
  margin-bottom: 6px;
}
.section-nav .nav-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0;
  width: 100%;
  height: 36px;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  background: transparent;
  border: none;
  border-left: 2px solid transparent;
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  text-align: left;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.section-nav .nav-item:hover {
  color: var(--ink);
  background: var(--paper-soft);
  border-left-color: var(--rule);
}
.section-nav .nav-item.active {
  color: var(--ink);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-left-color: var(--accent);
}
.section-nav .nav-item.active:hover { background: color-mix(in srgb, var(--accent) 15%, transparent); }
/* Icon wrapper: fixed 36×36 square */
.section-nav .nav-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  pointer-events: none;
}
.section-nav .nav-item.active .nav-icon { stroke: var(--accent); }
.section-nav .nav-item:hover .nav-icon { stroke: var(--ink); }
/* Label: always visible */
.section-nav .nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  padding-right: 8px;
  line-height: 1;
}
/* Count badge */
.section-nav .nav-item .nav-count {
  display: none;
  flex-shrink: 0;
  padding: 0 5px;
  margin-right: 6px;
  height: 16px;
  line-height: 16px;
  font-size: 9px;
  font-weight: 700;
  background: var(--paper-deep);
  border-radius: 8px;
  color: var(--ink-dim);
  white-space: nowrap;
}
.section-nav .nav-item .nav-count:not(:empty) { display: block; }
.section-nav .nav-item .count { display: none; }

/* Range mode toggle (52w / 26w) */
.range-mode-toggle {
  display: flex;
  gap: 2px;
  margin-bottom: var(--sp-4);
  background: var(--surface-2, #f0f0f0);
  border-radius: 6px;
  padding: 2px;
}
.range-mode-btn {
  flex: 1;
  padding: 4px 0;
  font-size: var(--fs-xs);
  font-family: var(--font-sans);
  font-weight: 600;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.range-mode-btn.active {
  background: var(--surface, #fff);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.range-mode-btn:not(.active):hover { color: var(--ink); }

.rail-section { margin-bottom: var(--sp-5); }
.rail-section-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: var(--sp-2);
}
.rail-section-head h4 {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: var(--fs-sm);
  text-transform: none;
  letter-spacing: var(--tr-tight);
  color: var(--ink);
}
.rail-section-head .clear {
  font-size: var(--fs-2xs);
  color: var(--ink-dim);
  cursor: pointer;
  background: none; border: 0; padding: 0;
  font-family: var(--font-sans);
}
.rail-section-head .clear:hover { color: var(--accent); text-decoration: underline; }

/* Filter rows — label-on-left, value-right */
.filter-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 0;
  font-size: var(--fs-sm);
  border-bottom: 1px dotted var(--rule-soft);
  gap: var(--sp-2);
}
.filter-row:last-child { border-bottom: 0; }
.filter-row .k { color: var(--ink-soft); white-space: nowrap; display: flex; align-items: center; gap: 4px; }

/* ⓘ tooltip icon next to filter labels */
.filter-tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 13px; height: 13px; flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--ink-muted);
  color: var(--ink-muted);
  font-size: 9px; font-style: normal; font-weight: 600; line-height: 1;
  cursor: help;
  position: relative;
}
.filter-tip::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%; transform: translateY(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 6px 9px;
  border-radius: 5px;
  font-size: 11px; font-weight: 400; font-style: normal;
  white-space: normal; width: 190px; line-height: 1.45;
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity 0.15s;
}
.filter-tip:hover::after { opacity: 1; }
/* On narrow left rails, flip to right side only — left side has no room */
.col.left .filter-tip::after { left: calc(100% + 8px); right: auto; }
.check-row .filter-tip { margin-left: 2px; }

/* ── Dossier sidebar info tips (tooltip floats left, toward article body) ── */
.info-tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 13px; height: 13px; flex-shrink: 0; margin-left: 3px;
  border-radius: 50%;
  border: 1px solid var(--ink-muted);
  color: var(--ink-muted);
  font-size: 9px; font-weight: 600; line-height: 1; font-style: normal;
  cursor: help;
  position: relative;
  vertical-align: middle;
}
.info-tip::after {
  content: attr(data-tip);
  position: absolute;
  right: calc(100% + 8px);
  top: 50%; transform: translateY(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 6px 9px;
  border-radius: 5px;
  font-size: 11px; font-weight: 400;
  white-space: normal; width: 210px; line-height: 1.45;
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity 0.15s;
}
.info-tip:hover::after { opacity: 1; }

.filter-row select, .filter-row input[type="text"], .filter-row input[type="number"] {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  padding: 2px 4px;
  text-align: right;
  min-width: 0;
  max-width: 120px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
/* Pin select width so dropdowns line up in a clean column on the right —
   without this, each <select> auto-sizes to its widest <option>, producing
   a ragged left edge across rows. Inputs (price range, search) keep their
   own widths set elsewhere. */
.filter-row select {
  width: 120px;
  flex-shrink: 0;
}
.filter-row select:hover, .filter-row select:focus,
.filter-row input:hover, .filter-row input:focus {
  outline: none; border-bottom-color: var(--accent); color: var(--ink);
}

.filter-price-range {
  display: flex; align-items: center; gap: 4px;
  justify-content: flex-end;
}
.filter-price-range input { width: 48px; text-align: right; }
.filter-price-range .sep { color: var(--ink-muted); }

/* Check rows (inline checkbox label) */
.check-row {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-1) 0;
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  cursor: pointer;
}
.check-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border: 1px solid var(--rule);
  background: var(--paper-soft);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  margin: 0;
}
.check-row input[type="checkbox"]:checked {
  background: var(--ink);
  border-color: var(--ink);
}
.check-row input[type="checkbox"]:checked::after {
  content: '✓';
  color: var(--paper);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

/* ═══════════════════════════════════════════════════════════════════
   5. CENTER — screener head, preset chips, story banner, quote board
   ═══════════════════════════════════════════════════════════════════ */
.center-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--sp-4);
  margin-bottom: var(--sp-3);
}
.center-head h2 {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.015em;
  line-height: 1;
}
.center-head .sub {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--ink-soft);
  font-size: var(--fs-sm);
  margin-top: 6px;
}
.center-head .actions { display: flex; gap: var(--sp-1); align-items: center; }

/* Column picker — same dropdown pattern as presets */
.col-picker-wrap {
  position: relative;
}
.col-picker[hidden] { display: none !important; }
.col-picker {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 210;
  min-width: 340px;
  max-width: 520px;
  background: var(--paper-soft);
  border: 1px solid var(--rule-soft);
  border-radius: var(--r-sm);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.col-picker-group {
  min-width: 120px;
  flex: 1 1 120px;
}
.col-picker-group-label {
  font-family: var(--font-sans);
  font-size: var(--fs-2xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  color: var(--ink-dim);
  margin-bottom: var(--sp-1);
  padding-bottom: var(--sp-1);
  border-bottom: 1px solid var(--rule-hair);
}
.col-picker-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  color: var(--ink-soft);
  padding: 2px 0;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.col-picker-item:hover { color: var(--ink); }
.col-picker-item input[type="checkbox"] { cursor: pointer; }

/* Profile badge inside the column picker — shows "Mobile profile" or "Desktop profile" */
.col-picker-profile-badge {
  width: 100%;
  font-family: var(--font-sans);
  font-size: var(--fs-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  color: var(--accent, #4f8ef7);
  margin-bottom: var(--sp-2);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--rule-hair);
  cursor: default;
}

/* Preset views dropdown trigger wrapper */
.preset-views-wrap {
  position: relative;
}

/* Preset chip row — hidden by default, shown as a dropdown panel.
   The [hidden] override is required: display:flex here beats the UA-sheet
   display:none that the hidden attribute would normally produce. */
.presets[hidden] { display: none !important; }
.presets {
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--sp-1) 0;
  /* dropdown panel positioning */
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 200;
  min-width: 220px;
  background: var(--paper-soft);
  border: 1px solid var(--rule-soft);
  border-radius: var(--r-sm, 6px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.preset {
  padding: 7px var(--sp-3);
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap;
  width: 100%;
  text-align: left;
}
.preset:hover { background: var(--paper-warm, var(--paper)); color: var(--ink); }
.preset.active { background: var(--ink); color: var(--paper); }
.preset .em { color: var(--accent); font-weight: 700; flex-shrink: 0; }
.preset.active .em { color: var(--paper); }
.preset.custom { border-style: dashed; }
.preset.preset-save { color: var(--ink-dim); }
.preset.preset-clear { border-top: 1px solid var(--rule); margin-top: var(--sp-1); color: var(--ink-dim); }

/* Preset hint — description line inside the dropdown on hover */
.preset-hint {
  margin: 0;
  padding: var(--sp-1) var(--sp-3) var(--sp-2);
  font-size: var(--fs-2xs);
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--ink-muted);
  border-top: 1px solid var(--rule-soft);
  min-height: 2.6em;
  line-height: 1.4;
}

/* Active-preset bar — shown below the toolbar when a preset is applied */
.preset-active-bar {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  padding: 5px var(--sp-4);
  background: var(--paper-soft);
  border-bottom: 1px solid var(--rule-soft);
  font-size: var(--fs-2xs);
}
.preset-active-bar[hidden] { display: none; }
.preset-active-label {
  flex: 1;
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--ink-dim);
  line-height: 1.4;
}
.preset-active-label::before {
  content: 'View: ';
  font-style: normal;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: var(--fs-3xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-right: 4px;
}
.preset-active-clear {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-muted);
  font-size: 1rem;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
}
.preset-active-clear:hover { color: var(--ink); }

/* Story banner — editor's pick */
.story {
  border: 1px solid var(--rule);
  border-top: 3px solid var(--accent);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-3);
  background: var(--paper-soft);
  display: grid; grid-template-columns: 1fr auto; gap: var(--sp-5);
  align-items: center;
}
.story .k {
  color: var(--accent);
  font-weight: 700;
  font-size: var(--fs-2xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: var(--font-sans);
}
.story h3 {
  margin: 4px 0 2px;
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
.story .l {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--ink-soft);
  font-size: var(--fs-sm);
}
.story .stat { text-align: right; }
.story .stat .big {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 26px;
  letter-spacing: -0.01em;
}
.story .stat .lbl {
  font-size: var(--fs-2xs);
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: var(--font-sans);
  margin-top: 2px;
}

/* ── Filter toolbar (legacy container — now empty, kept for sync-status) ── */
.toolbar { display: none; }

/* ── Inline search in center-head ──────────────────────────────── */
.center-head-right {
  display: flex; flex-direction: column; align-items: flex-end; gap: var(--sp-2);
  flex-shrink: 0;
}
.search-wrap {
  display: flex; align-items: center;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--paper-soft);
  padding: 3px 6px;
  gap: 4px;
  cursor: text;
  transition: border-color 0.15s;
}
.search-wrap:focus-within { border-color: var(--ink-soft); }
.search-icon {
  font-size: 14px; color: var(--ink-muted); line-height: 1;
  pointer-events: none; user-select: none;
}
.search-wrap .search {
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  background: transparent;
  border: 0;
  color: var(--ink);
  width: 90px;
}
.search-wrap .search:focus { outline: none; }
.search-wrap .search::placeholder { color: var(--ink-muted); }

.sync-status {
  font-size: var(--fs-2xs);
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--font-sans);
}
.sync-status.sync-synced  { color: var(--bull-ink); }
.sync-status.sync-pending { color: var(--warn); }
.sync-status.sync-local   { color: var(--ink-dim); }

/* Filter profile badge — shows "Mobile" or "Desktop" next to sync status */
.filter-profile-badge {
  font-size: var(--fs-2xs);
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent, #4f8ef7);
  background: color-mix(in srgb, var(--accent, #4f8ef7) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent, #4f8ef7) 30%, transparent);
  border-radius: 3px;
  padding: 1px 5px;
  cursor: default;
}

/* ═══════════════════════════════════════════════════════════════════
   6. QUOTE BOARD — the broadsheet table
   ═══════════════════════════════════════════════════════════════════ */
.table-wrapper {
  overflow-x: auto;
  position: relative;
  scroll-behavior: smooth;
  /* slim scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--rule) var(--paper-warm);
}
.table-wrapper::-webkit-scrollbar { height: 5px; }
.table-wrapper::-webkit-scrollbar-track { background: var(--paper-warm); }
.table-wrapper::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 3px; }
/* right-edge fade when more columns exist off-screen */
.table-wrapper.can-scroll-right {
  box-shadow: inset -40px 0 20px -10px var(--paper);
}

table.quotes, #results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
table.quotes thead th,
#results-table thead th {
  font-family: var(--font-sans);
  font-size: var(--fs-caps);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  color: var(--ink-dim);
  text-align: right;
  padding: var(--sp-2) var(--sp-2);
  border-top: 3px double var(--ink);
  border-bottom: 1px solid var(--ink);
  background: var(--paper-warm);
  white-space: nowrap;
  user-select: none;
}
table.quotes thead th.first,
table.quotes thead th:first-child,
#results-table thead th:nth-child(-n+2) { text-align: left; }

/* Watchlist section-divider rows (Watchlist / Held positions) */
.wl-section-row { background: transparent; }
.wl-section-label {
  padding: 10px var(--sp-2) 4px !important;
  font-family: var(--font-sans);
  font-size: var(--fs-caps);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  color: var(--ink-muted);
  border-bottom: 1px solid var(--rule);
}
#results-table thead th[data-sort] { cursor: pointer; }
#results-table thead th.sort-asc::after { content: ' ↑'; font-family: var(--font-mono); color: var(--ink); }
#results-table thead th.sort-desc::after { content: ' ↓'; font-family: var(--font-mono); color: var(--ink); }

/* ── Drag-and-drop column reordering ────────────────────────── */
/* Cursor hint — grab handle for draggable column headers */
#results-table thead th.col-draggable { cursor: grab; }
#results-table thead th.col-draggable[data-sort] { cursor: grab; }
#results-table thead th.col-draggable:active { cursor: grabbing; }

/* Grip dots — subtle 2×3 dot grid shown left of label on draggable headers */
#results-table thead th .col-grip {
  display: inline-block;
  width: 8px;
  height: 12px;
  margin-right: 5px;
  vertical-align: middle;
  opacity: 0.22;
  background-image:
    radial-gradient(circle, var(--ink) 1px, transparent 1px),
    radial-gradient(circle, var(--ink) 1px, transparent 1px);
  background-size: 4px 4px;
  background-position: 0 0, 4px 0;
  background-repeat: repeat-y;
  pointer-events: none;
  flex-shrink: 0;
}
#results-table thead th.col-draggable:hover .col-grip { opacity: 0.5; }

/* Resize handle — right-edge drag zone on every header */
#results-table thead th {
  position: relative; /* ensure handle can be positioned absolutely */
}
#results-table thead th .col-resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: col-resize;
  user-select: none;
  z-index: 1;
}
#results-table thead th .col-resize-handle::after {
  content: '';
  position: absolute;
  right: 2px;
  top: 25%;
  bottom: 25%;
  width: 2px;
  border-radius: 1px;
  background: var(--rule-soft);
  transition: background 0.15s;
}
#results-table thead th:hover .col-resize-handle::after { background: var(--ink-dim); }

/* Column being dragged: dim + slight scale so user knows it's "in motion" */
#results-table thead th.col-drag-source {
  opacity: 0.45;
  background: var(--paper-deep);
}

/* Drop target highlight: left-edge accent bar + brightened background */
#results-table thead th.col-drag-over {
  background: color-mix(in srgb, var(--accent) 12%, var(--paper-warm));
  box-shadow: inset 3px 0 0 var(--accent);
  outline: none;
}

/* ── Drag ghost tooltip element (touch) ──────────────────────── */
#col-drag-ghost {
  /* Inline styles set by JS; these provide the fallback for browsers
     that don't support CSS custom properties in inline style. */
  background: var(--paper-warm);
  border: 2px solid var(--accent);
  color: var(--ink);
  border-radius: 3px;
  padding: 4px 10px;
  font-size: var(--fs-caps);
  font-family: var(--font-sans);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  white-space: nowrap;
  pointer-events: none;
  position: fixed;
  opacity: 0.85;
  z-index: 9999;
}

/* Column header tooltips — hover over the <th> text directly (no "i" icon) */
#results-table thead th[data-tip] {
  cursor: help;
  position: relative;
}
#results-table thead th[data-sort][data-tip] { cursor: pointer; }
#results-table thead th[data-tip]::before {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 6px);
  left: 50%; transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 6px 9px;
  border-radius: 5px;
  font-size: 11px; font-weight: 400; font-style: normal; font-family: var(--font-sans);
  text-transform: none; letter-spacing: 0;
  white-space: normal; width: 200px; line-height: 1.45;
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity 0.15s;
}
#results-table thead th[data-tip]:hover::before { opacity: 1; }

table.quotes tbody td,
#results-table tbody td {
  padding: var(--sp-2) var(--sp-2);
  border-bottom: 1px solid var(--rule-hair);
  vertical-align: middle;
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  color: var(--ink);
  white-space: nowrap;
}
table.quotes tbody td.first,
table.quotes tbody td:first-child,
#results-table tbody td:first-child,
#results-table tbody td:nth-child(2) {
  text-align: left;
  font-family: var(--font-sans);
}
table.quotes tbody tr,
#results-table tbody tr { cursor: pointer; transition: background 120ms ease; }
table.quotes tbody tr:hover,
#results-table tbody tr:hover { background: var(--paper-soft); }
table.quotes tbody tr.row-active,
#results-table tbody tr.row-active { background: var(--paper-warm); }

/* Ticker cell — serif ticker on top, sans company name underneath.
   The ticker-line wraps the ticker + inline ETF chip + held badge so
   they all sit on the same baseline. */
.ticker-cell .ticker-line {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}
.ticker-cell .ticker {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: var(--fs-h2);
  letter-spacing: -0.005em;
  color: var(--ink);
}
.ticker-cell .name {
  display: block;
  font-family: var(--font-sans);
  font-size: var(--fs-2xs);
  color: var(--ink-dim);
  margin-top: 1px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
/* Inline ETF chip — shown next to the ticker. On desktop the full-width
   Type column already labels this, so we hide the inline chip there and
   rely on the column. On phone (≤500px) the column is hidden and the
   chip is the sole indicator. */
.type-chip {
  display: none;
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
  padding: 1px 5px;
  border: 1px solid var(--rule-soft);
  border-radius: var(--r-xs);
  background: var(--paper-warm);
  white-space: nowrap;
}
@media (max-width: 500px) { .type-chip { display: inline-flex; align-items: center; } }

/* Star button */
.star-btn {
  background: none; border: 0; cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: var(--ink-muted);
  padding: 2px 4px;
}
.star-btn:hover { color: var(--star); }
.star-btn.starred { color: var(--star); }

/* Empty state in table */
.empty, #results-table tbody td.empty {
  text-align: center;
  padding: var(--sp-10) var(--sp-4);
  color: var(--ink-dim);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-read);
  line-height: 1.5;
  border-bottom: 0;
}
.empty-kicker {
  display: block;
  font-family: var(--font-sans);
  font-style: normal;
  font-size: var(--fs-caps);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  color: var(--ink-dim);
  margin-bottom: var(--sp-2);
}

/* Watchlist view — presets don't apply (they're screener recipes).
   Hide the preset chip row and the action buttons that only make sense
   on the screener. Filter rail sections are hidden globally for all
   non-screener views via the rule above. */
body.view-watchlist #presets-row { display: none !important; }
body.view-watchlist .preset-views-wrap { display: none; }
body.view-watchlist #save-preset-btn,
body.view-watchlist #reset-btn { display: none !important; }

/* Row meta indicators */
.held-badge {
  display: inline-block;
  margin-left: 6px;
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  padding: 1px 4px;
  border: 1px solid var(--rule-soft);
  background: var(--paper-soft);
  color: var(--ink-soft);
  border-radius: var(--r-xs);
  white-space: nowrap;
}
.held-badge.held-pos { color: var(--bull-ink); border-color: rgba(31,107,58,0.25); }
.held-badge.held-neg { color: var(--bear-ink); border-color: rgba(168,30,30,0.25); }
.held-badge.held-known {
  background: rgba(43,74,122,0.10);
  color: var(--accent);
  border: 1px solid rgba(43,74,122,0.25);
}

/* ═══════════════════════════════════════════════════════════════════
   7. BADGES — signal tiers + LEAPS rec
   ═══════════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 6px;
  font-family: var(--font-sans);
  font-size: var(--fs-caps);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-radius: var(--r-xs);
  border: 1px solid currentColor;
  background: transparent;
  white-space: nowrap;
}
.badge svg { width: 1em; height: 1em; flex-shrink: 0; }
/* Outline-only badges — no fill, just colored border + text (newspaper style) */
.tier-base       { background: transparent; color: var(--tier-base-fg);        border-color: var(--tier-base-fg); }
.tier-stabilising{ background: transparent; color: var(--tier-stabilising-fg); border-color: var(--tier-stabilising-fg); }
.tier-danger     { background: transparent; color: var(--tier-danger-fg);      border-color: var(--tier-danger-fg); }
.tier-pullback   { background: transparent; color: var(--tier-pullback-fg);    border-color: var(--tier-pullback-fg); }
.tier-accum      { background: transparent; color: var(--tier-accum-fg);       border-color: var(--tier-accum-fg); }
.tier-jpattern   { background: transparent; color: var(--tier-jpattern-fg);    border-color: var(--tier-jpattern-fg); }
.tier-etf, .badge.etf {
  background: transparent; color: var(--tier-etf-fg); border-color: var(--rule);
}
/* Pullback badge — app.js renders <span class="badge pullback"> directly. */
.badge.pullback {
  background: transparent;
  color: var(--tier-pullback-fg);
  border-color: var(--tier-pullback-fg);
}
/* Non-ETF "Stock" type indicator (plain text, dim). */
.type-stock {
  color: var(--ink-dim);
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--font-sans);
}
/* News-sentiment cell tints (used on the Sentiment column). */
.sent-bullish { color: var(--bull-ink); }
.sent-bearish { color: var(--bear-ink); }
.sent-mixed   { color: var(--ink-soft); }

/* Vehicle rec — icon + text inline */
.veh-rec { display: inline-flex; align-items: center; gap: 4px; }
/* LEAPS rec text cell (no chip — just colored bold text) */
.rec-LEAPS, .rec-leaps, .rec-leaps.veh-rec { color: var(--bull-ink); font-weight: 700; font-family: var(--font-sans); }
.rec-STOCK, .rec-stock, .rec-stock.veh-rec { color: var(--accent); font-weight: 700; font-family: var(--font-sans); }
.rec-NEUTRAL, .rec-neutral, td.rec-neutral { color: var(--ink-dim); font-weight: 600; font-family: var(--font-sans); }
.rec-WAIT, .rec-wait, td.rec-wait { color: var(--warn); font-weight: 600; font-family: var(--font-sans); }

/* Sentiment margin band — 4px colored left bar on each screener row.
   5-tier intensity: strong variants use full colour; regular = 60% opacity. */
.sentiment-bull-strong td:first-child { box-shadow: inset 4px 0 0 var(--sentiment-bull);              padding-left: 14px; }
.sentiment-bull        td:first-child { box-shadow: inset 4px 0 0 color-mix(in srgb, var(--sentiment-bull) 55%, transparent); padding-left: 14px; }
.sentiment-neu         td:first-child { box-shadow: inset 4px 0 0 var(--sentiment-neu);               padding-left: 14px; }
.sentiment-bear        td:first-child { box-shadow: inset 4px 0 0 color-mix(in srgb, var(--sentiment-bear) 55%, transparent); padding-left: 14px; }
.sentiment-bear-strong td:first-child { box-shadow: inset 4px 0 0 var(--sentiment-bear);              padding-left: 14px; }

/* Sentiment sort column — styled like other sortable numeric headers */
.sentiment-th { /* inherits col-p4 sizing; no width/font-size overrides */ }

/* Sentiment bar legend */
/* Signal key — mobile-only legend above the table */
.signal-key-mobile {
  display: none;
  padding: 4px var(--sp-3) 2px;
  font-family: var(--font-sans);
}
.signal-key-grid {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 4px 0;
}
/* Legend badges always show their label (the table-cell hide rule is scoped there, not here) */
.signal-key-grid .badge-label { display: inline; }
.signal-key-grid .badge { gap: 4px; }
@media (max-width: 500px) {
  .signal-key-mobile { display: block; }
}

.sentiment-legend {
  display: flex; align-items: center; gap: 6px;
  padding: 4px var(--sp-3) 6px;
  font-family: var(--font-sans); font-size: 10px;
  color: var(--ink-muted); letter-spacing: 0.04em;
}
.sleg {
  display: inline-block; width: 4px; height: 12px;
  border-radius: 1px; flex-shrink: 0;
}
.sleg-label { margin-right: 6px; }
.sleg-note  { text-transform: uppercase; letter-spacing: 0.1em; opacity: 0.7; }
.sleg-bull-strong { background: var(--sentiment-bull); }
.sleg-bull        { background: color-mix(in srgb, var(--sentiment-bull) 55%, transparent); }
.sleg-neu         { background: var(--sentiment-neu); }
.sleg-bear        { background: color-mix(in srgb, var(--sentiment-bear) 55%, transparent); }
.sleg-bear-strong { background: var(--sentiment-bear); }

/* Earnings cell color tiers */
.earnings-warn     { color: var(--warn); font-weight: 600; }
.earnings-imminent { color: #b94040; font-weight: 700; }
.earnings-soon     { color: var(--warn); font-weight: 600; }

/* ═══════════════════════════════════════════════════════════════════
   8. BUTTONS
   ═══════════════════════════════════════════════════════════════════ */
.btn, button.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px var(--sp-3);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
  background: var(--paper-soft);
  border: 1px solid var(--rule);
  border-radius: var(--r-xs);
  cursor: pointer;
  letter-spacing: -0.005em;
  text-decoration: none;
}
.btn:hover { background: var(--paper-warm); border-color: var(--ink); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn-primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.btn-primary:hover { background: var(--ink-soft); border-color: var(--ink-soft); }

.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--paper-warm); border-color: var(--rule-soft); }

.btn-sm { padding: 4px var(--sp-2); font-size: var(--fs-xs); }
.btn-icon { padding: 8px; width: 40px; height: 40px; justify-content: center; }
.btn-icon-danger { color: var(--bear); border-color: var(--bear); }

@keyframes spin { to { transform: rotate(360deg); } }
.spinning svg { animation: spin 0.8s linear infinite; }
.btn-icon-danger:hover { background: var(--tier-danger-bg); border-color: var(--bear); }

.rr-offscreen-label { font-size: 0.72rem; color: var(--muted); margin: 0.6rem 0 0.3rem; }
.rr-offscreen-tag { display: inline-flex; align-items: center; gap: 2px; background: var(--bg2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 4px; margin: 2px 2px 0 0; font-size: 0.75rem; }
.rr-offscreen-remove { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 0.85rem; line-height: 1; padding: 0 1px; }
.rr-offscreen-remove:hover { color: var(--bear); }

/* Watchlist tab: stub row for tickers added after the last screener run */
.wl-pending-row { opacity: 0.6; }
.wl-pending-cell { vertical-align: middle; padding: 0.45rem var(--sp-3); }
.wl-pending-msg {
  display: inline-block;
  font-size: var(--fs-caps);
  font-family: var(--font-sans);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  color: var(--ink-dim);
  background: var(--bg2);
  border: 1px dashed var(--border);
  border-radius: 3px;
  padding: 1px 6px;
}

.btn-danger { color: var(--bear); }
.btn-danger:hover { background: var(--tier-danger-bg); border-color: var(--bear); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* Apple / Google sign-in buttons (kept for auth gate) */
/* ── Auth gate: paired sign-in buttons (web) ──────────────────── */
/* Both use .btn-oauth for identical box geometry; colour variant applied
   by the modifier class. Perfectly square corners = border-radius 0. */
.btn-oauth {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%;
  padding: 11px var(--sp-4);
  border: 1.5px solid var(--ink);
  border-radius: 0;          /* square corners — editorial look */
  font-family: var(--font-sans); font-weight: 600; font-size: var(--fs-sm);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  letter-spacing: 0.02em;
}
.btn-oauth:disabled { opacity: 0.5; cursor: wait; }
.btn-oauth-google {
  background: var(--paper); color: var(--ink);
}
.btn-oauth-google:hover { background: var(--paper-soft); }
.btn-oauth-apple {
  background: var(--ink); color: var(--paper);
}
.btn-oauth-apple:hover { background: #1a1a1a; }

/* Legacy native-button styles kept for Capacitor iOS native flow */
.btn-apple {
  background: var(--ink); color: var(--paper); border: 1.5px solid var(--ink);
  padding: 11px var(--sp-4);
  font-family: var(--font-sans); font-weight: 600; font-size: var(--fs-sm);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 0;
  cursor: pointer; width: 100%;
}
.btn-apple:hover { background: #1a1a1a; }
.btn-google {
  background: var(--paper); color: var(--ink); border: 1.5px solid var(--ink);
  padding: 11px var(--sp-4);
  font-family: var(--font-sans); font-weight: 600; font-size: var(--fs-sm);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 0;
  cursor: pointer; width: 100%;
}
.btn-google:hover { background: var(--paper-soft); }

/* Auth section in masthead (signed-in) */
.auth-pill {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: 4px var(--sp-2);
  border: 1px solid var(--rule);
  border-radius: var(--r-pill);
  background: var(--paper-soft);
  font-family: var(--font-sans);
  font-size: var(--fs-2xs);
  color: var(--ink-soft);
}
.auth-pill .user-email { font-weight: 500; color: var(--ink); text-transform: none; letter-spacing: 0; }
.auth-pill button {
  background: none; border: 0;
  font-family: var(--font-sans); font-size: var(--fs-2xs);
  color: var(--ink-dim); cursor: pointer;
  padding: 0 var(--sp-1);
}
.auth-pill button:hover { color: var(--accent); text-decoration: underline; }

/* ═══════════════════════════════════════════════════════════════════
   9. RIGHT SIDEBAR — watchlist mini + earnings
   ═══════════════════════════════════════════════════════════════════ */
.side-h {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: var(--fs-h2);
  margin: 0 0 4px;
  letter-spacing: -0.005em;
  color: var(--ink);
}
.side-sub {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--ink-dim);
  font-size: var(--fs-xs);
  margin-bottom: var(--sp-2);
}

.mini {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: var(--sp-2);
  padding: 6px 0;
  border-bottom: 1px dotted var(--rule-soft);
  font-size: var(--fs-sm);
  align-items: baseline;
}
.mini .t { font-family: var(--font-serif); font-weight: 700; color: var(--ink); }
.mini .p, .mini .c { font-family: var(--font-mono); font-size: var(--fs-xs); }

/* ═══════════════════════════════════════════════════════════════════
   10. AUTH GATE — broadsheet rebuild
   ═══════════════════════════════════════════════════════════════════ */
body.signed-out > #auth-gate { display: flex; }
body.signed-in  > #auth-gate { display: none; }

/* Hide app chrome when signed out */
body.signed-out .page-wrap { display: none; }

.auth-gate {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-6);
  background: var(--paper);
  z-index: 100;
  overflow: auto;
}
.auth-gate-inner {
  max-width: 460px; width: 100%;
  text-align: center;
  padding: var(--sp-8) var(--sp-6);
}
.auth-gate-kicker {
  font-family: var(--font-sans);
  font-size: var(--fs-caps);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-dim);
  margin-bottom: var(--sp-3);
}
.auth-gate-masthead {
  font-family: var(--font-serif);
  font-weight: 900;
  font-style: italic;
  font-size: 52px;
  line-height: 0.9;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin-bottom: var(--sp-2);
}
.auth-gate-masthead .the {
  font-weight: 700;
  font-style: normal;
  font-size: 0.38em;
  vertical-align: 0.85em;
  letter-spacing: 0.2em;
  margin-right: 6px;
  color: var(--ink-soft);
}
.auth-gate-motto {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-read);
  color: var(--ink-soft);
  line-height: 1.5;
  max-width: 36ch;
  margin: 0 auto var(--sp-6);
}
.auth-gate-hr {
  border: 0;
  border-top: 3px double var(--ink);
  margin: var(--sp-4) auto;
  width: 60%;
}
.auth-gate-blurb {
  font-family: var(--font-serif);
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  line-height: 1.55;
  max-width: 40ch;
  margin: 0 auto var(--sp-5);
}
.auth-gate-actions {
  display: flex; flex-direction: column; gap: var(--sp-2);
  max-width: 280px;
  margin: 0 auto var(--sp-5);
  min-height: 44px;
}
.auth-gate-actions #signed-out-ui,
.auth-gate-actions .signed-out-native {
  display: flex; flex-direction: column; gap: var(--sp-2);
  width: 100%;
}
.auth-gate-fineprint {
  font-family: var(--font-sans);
  font-size: var(--fs-2xs);
  color: var(--ink-muted);
  line-height: 1.5;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.auth-gate-disclaimer {
  max-width: 420px;
  margin: 0 auto var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--rule);
  border-radius: var(--r-xs);
  background: var(--paper);
  text-align: left;
}
.auth-gate-disclaimer-h {
  font-family: var(--font-sans);
  font-size: var(--fs-2xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink);
  margin-bottom: 4px;
}
.auth-gate-disclaimer p {
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0;
}
.auth-gate-disclaimer strong {
  color: var(--ink);
}
@media (max-width: 480px) {
  .auth-gate-masthead { font-size: 40px; }
  .auth-gate-motto { font-size: var(--fs-sm); }
}

/* ═══════════════════════════════════════════════════════════════════
   11. DRAWER — ticker detail (Step 2 keeps drawer; Step 3 → full page)
   ═══════════════════════════════════════════════════════════════════ */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(26,22,16,0.35);
  opacity: 0; visibility: hidden;
  transition: opacity 280ms cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 280ms;
  z-index: 200;
}
.drawer-backdrop.open { opacity: 1; visibility: visible; transition: opacity 280ms cubic-bezier(0.4, 0, 0.2, 1); }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(640px, 92vw);
  background: var(--paper);
  border-left: 1px solid var(--ink);
  box-shadow: var(--shadow-drawer);
  transform: translateX(100%);
  transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 300;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.drawer.open { transform: translateX(0); }
.drawer.maximized { width: 100vw; max-width: 100vw; }

.drawer-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 3px double var(--ink);
  background: var(--paper-warm);
}
.drawer-ticker {
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: var(--fs-display);
  letter-spacing: -0.02em;
  color: var(--ink);
}
.drawer-header-actions { display: flex; gap: var(--sp-2); }
.drawer-action-btn, .drawer-close {
  background: none; border: 0; cursor: pointer;
  color: var(--ink-soft);
  padding: var(--sp-1);
  font-family: var(--font-sans);
  font-size: 18px; line-height: 1;
}
.drawer-action-btn:hover, .drawer-close:hover { color: var(--ink); }

.drawer-content {
  flex: 1; overflow-y: auto;
  padding: var(--sp-5) var(--sp-6);
}
.drawer-content .d-section { margin-bottom: var(--sp-5); }
.drawer-content .d-section h4 {
  font-family: var(--font-sans);
  font-size: var(--fs-caps);
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  color: var(--ink-dim);
  font-weight: 700;
  margin-bottom: var(--sp-2);
  padding-bottom: var(--sp-1);
  border-bottom: 1px solid var(--rule);
}
.drawer-content .d-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: var(--sp-4);
  row-gap: 4px;
  margin: 0;
}
.drawer-content .d-grid dt {
  color: var(--ink-soft);
  font-size: var(--fs-sm);
}
.drawer-content .d-grid dd {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  font-size: var(--fs-sm);
  color: var(--ink);
  margin: 0;
  text-align: right;
}
.drawer-content .d-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); margin-top: var(--sp-2); }
.drawer-content .d-table th, .drawer-content .d-table td { padding: 5px var(--sp-2); border-bottom: 1px solid var(--rule-hair); text-align: right; }
.drawer-content .d-table th { font-family: var(--font-sans); font-size: var(--fs-caps); text-transform: uppercase; letter-spacing: var(--tr-caps); color: var(--ink-dim); font-weight: 700; background: var(--paper-warm); }
.drawer-content .d-table th:first-child, .drawer-content .d-table td:first-child { text-align: left; }
.drawer-content .d-table td.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }

.drawer-content .tv-chart { width: 100%; height: 360px; border: 1px solid var(--rule); background: var(--paper); margin-bottom: var(--sp-4); }
.drawer-content .payoff-chart { background: var(--paper-soft); border: 1px solid var(--rule-soft); }

.chart-error {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft);
  font-size: 0.875rem;
  font-style: italic;
  padding: var(--sp-3);
  text-align: center;
}

.drawer-content .held-section { background: var(--paper-soft); border: 1px solid var(--rule); padding: var(--sp-3); border-left: 3px solid var(--accent); }
.drawer-content .held-total-row td { border-top: 1px solid var(--ink); font-weight: 700; padding-top: var(--sp-1); }
.held-pos { color: var(--bull-ink); }
.held-neg { color: var(--bear-ink); }

/* ═══════════════════════════════════════════════════════════════════
   11.5  DOSSIER — full-page ticker detail
   The dossier slides in from the right as a fixed overlay. It starts
   off-screen (translateX 100%) and slides to translateX(0) when
   body.view-dossier is added. The transition fires on both open and
   close; real-time swipe dragging temporarily disables the transition
   so the panel tracks the finger, then re-enables it for the snap.
   ═══════════════════════════════════════════════════════════════════ */

/* Slide-in overlay — always in the DOM, off-screen when closed */
#dossier-panel {
  position: fixed;
  inset: 0;
  z-index: 500;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  background: var(--paper-warm);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

/* Slide in when active */
body.view-dossier #dossier-panel {
  transform: translateX(0);
}

/* While dragging, disable the transition so panel tracks finger */
#dossier-panel.is-dragging {
  transition: none;
}

body.view-dossier .page > .col.left,
body.view-dossier .page > .col.right { display: none; }
body.view-dossier .page { grid-template-columns: 1fr; }
body.view-dossier #screen-panel,
body.view-dossier #calendar-panel,
body.view-dossier #positions-panel { display: none !important; }

.dossier { padding: 0 !important; }

.dossier-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-3) var(--sp-6);
  border-bottom: 3px double var(--ink);
  background: var(--paper-warm);
}
.dossier-back-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0;
  transition: color 0.15s;
}
.dossier-back-btn:hover { color: var(--accent); }
.dossier-actions { display: flex; gap: var(--sp-2); justify-content: flex-end; }

/* Masthead wordmark becomes a pointer when in dossier */
.view-dossier .masthead-wordmark { cursor: pointer; }
.view-dossier .masthead-wordmark:hover { opacity: 0.7; }

.dossier-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  min-height: 0;
}

.dossier-article {
  padding: var(--sp-8) var(--sp-10) var(--sp-4);
  min-width: 0;
}
.dossier-sidebar {
  padding: var(--sp-6) var(--sp-6) var(--sp-10);
  border-left: 1px solid var(--rule);
  background: var(--paper-warm);
}

/* ── Hero ─────────────────────────────────────────────────────── */
.dossier-kicker {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--sp-3);
}
.dossier-kicker-meta { display: flex; gap: var(--sp-2); align-items: center; }
.dossier-article-watch-btn {
  background: none; border: 0; cursor: pointer;
  font-size: 20px; line-height: 1;
  color: var(--ink-muted);
  padding: 2px 6px;
  transition: color 0.15s;
  flex-shrink: 0;
}
.dossier-article-watch-btn:hover,
.dossier-article-watch-btn.starred { color: var(--star, #f59e0b); }
.dossier-kicker .k-red {
  color: var(--accent);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.dossier-kicker .k-caps {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: var(--fs-caps);
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  color: var(--ink-dim);
}

.dossier-hero {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--sp-5);
  margin-bottom: var(--sp-2);
}
.dossier-hero-sym {
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: 88px;
  line-height: 0.9;
  letter-spacing: -0.04em;
  color: var(--ink);
}
.dossier-hero-price {
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: var(--fs-hero);
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.dossier-hero-change {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  margin-top: 4px;
}

.dossier-company {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 18px;
  color: var(--ink-soft);
  margin-bottom: var(--sp-1);
}

.dossier-bylines {
  display: flex; gap: var(--sp-3); align-items: center;
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--sp-2) 0;
  border-top: 1px solid var(--rule-soft);
  border-bottom: 1px solid var(--rule-soft);
  margin-bottom: var(--sp-5);
}
.dossier-bylines .sep { color: var(--ink-muted); }

/* ── Headline + lede ─────────────────────────────────────────── */
.dossier-headline {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 32px;
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin: var(--sp-5) 0 var(--sp-2);
  color: var(--ink);
}
.dossier-lede {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-read);
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0 0 var(--sp-5);
  max-width: 64ch;
}

/* ── Chart block ──────────────────────────────────────────────── */
.dossier-chart-section {
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: var(--sp-4) 0;
  margin-bottom: var(--sp-5);
}
.dossier-chart-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: var(--sp-3);
}
.dossier-chart-head h4 {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: var(--fs-h2);
  letter-spacing: -0.005em;
  color: var(--ink);
  text-transform: none;
}
.chart-range-btns {
  display: flex; gap: 2px;
}
.chart-range-btn {
  background: none; border: 1px solid var(--rule);
  font-family: var(--font-mono); font-size: 10px;
  font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--ink-dim); padding: 2px 7px; cursor: pointer;
  border-radius: 2px; transition: background 0.1s, color 0.1s;
}
.chart-range-btn:hover   { background: var(--paper-soft); color: var(--ink); }
.chart-range-btn.active  { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chart-range-btn.intraday-failed { opacity: 0.45; }
.chart-agg-label {
  font-family: var(--font-mono); font-size: 10px; color: var(--ink-dim);
  margin-left: 6px; align-self: center; letter-spacing: 0.03em;
}
.chart-agg-label.fallback { color: var(--warn, #b45309); }

/* Lines toggle button — same shape as range buttons but with colored accent */
.chart-lines-btn {
  background: none; border: 1px solid var(--rule);
  font-family: var(--font-mono); font-size: 10px;
  font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--ink-dim); padding: 2px 7px; cursor: pointer;
  border-radius: 2px; transition: background 0.1s, color 0.1s, border-color 0.1s;
  margin-left: 6px;
}
.chart-lines-btn:hover                 { background: var(--paper-soft); color: var(--ink); }
.chart-lines-btn.active                { background: #1a4a1a; color: #7ecf7e; border-color: #3a7d44; }
.chart-lines-btn:not(.active)          { color: var(--ink-dim); }

/* Drawer chart header bar */
.drawer-chart-wrap  { position: relative; }
.drawer-chart-head  {
  display: flex; justify-content: flex-end; align-items: center;
  padding: 2px 4px 0;
}

.dossier-chart-caption {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  color: var(--ink-dim);
  margin-top: var(--sp-2);
}
.dossier-chart-caption em {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--ink-soft);
  font-size: var(--fs-sm);
}

/* Chart + stat card side-by-side layout */
.dossier-chart-body {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: var(--sp-3);
  align-items: start;
}
.dossier-chart-frame { min-width: 0; }

.tv-frame {
  background: #f4efe4;  /* matches TradingView config backgroundColor */
  border: 1px solid var(--rule);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
  min-height: 420px;
  box-shadow: 0 2px 8px rgba(20,17,12,0.08), 0 0 0 1px rgba(20,17,12,0.04);
}
.tv-frame .tradingview-widget-container { background: inherit; width: 100%; }

/* Compact stat card that fills the chart's top-right dead space */
.chart-stat-card {
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--paper-soft);
  padding: var(--sp-3);
  display: flex; flex-direction: column; gap: var(--sp-1);
  max-height: 420px;
  overflow-y: auto;
}
/* Price / company header block — replaces TradingView's hidden header */
.cs-price-block {
  margin-bottom: var(--sp-2);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--rule);
}
.cs-ticker   { font-family: var(--font-sans); font-weight: 800; font-size: 18px; color: var(--ink); line-height: 1.1; }
.cs-price    { font-family: var(--font-mono); font-size: 15px; font-variant-numeric: tabular-nums; color: var(--ink); }
.cs-change   { font-family: var(--font-sans); font-size: 12px; font-weight: 600; }
.cs-change.cs-up   { color: var(--sentiment-bull); }
.cs-change.cs-down { color: var(--sentiment-bear); }
.cs-company  { font-family: var(--font-sans); font-size: 10px; color: var(--ink-muted); margin-top: 2px;
               white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cs-divider { border-top: 1px solid var(--rule); margin-bottom: var(--sp-2); }

.chart-stat-rec {
  font-family: var(--font-sans);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1;
}
.chart-stat-rec-label {
  font-family: var(--font-sans);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  margin-bottom: var(--sp-2);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--rule);
}
.chart-stat-rows { display: flex; flex-direction: column; gap: 3px; }
.chart-stat-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--font-sans); font-size: var(--fs-xs);
  padding: 2px 0;
  border-bottom: 1px solid var(--rule-hair);
}
.chart-stat-row:last-child { border-bottom: 0; }
.chart-stat-k { color: var(--ink-muted); }
.chart-stat-v { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .dossier-chart-body { grid-template-columns: 1fr; }
  .dossier-chart-stats { display: none; }
}
.tv-frame iframe { display: block !important; background: inherit !important; }

/* ── Body prose ──────────────────────────────────────────────── */
.dossier-body {
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
}
.dossier-body p { margin: 0 0 var(--sp-3); }
.dossier-body p:first-of-type::first-letter {
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: 64px;
  line-height: 0.85;
  float: left;
  padding: 4px var(--sp-2) 0 0;
  color: var(--accent);
}

/* ── Sidebar blocks ──────────────────────────────────────────── */
.dossier-side-h {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: var(--fs-h1);
  letter-spacing: -0.01em;
  border-bottom: 3px double var(--ink);
  padding-bottom: var(--sp-2);
  margin: 0 0 var(--sp-3);
  color: var(--ink);
}

.signal-box {
  background: var(--paper-soft);
  border: 1px solid var(--rule-soft);
  border-left: 3px solid var(--accent);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-5);
}
.signal-box-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: var(--sp-2);
}
.signal-box-head h4 {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: var(--fs-h2);
  text-transform: none;
  letter-spacing: -0.005em;
  color: var(--ink);
}
.signal-box .row {
  display: flex; justify-content: space-between;
  padding: 4px 0;
  font-size: var(--fs-sm);
}
.signal-box .row + .row { border-top: 1px dotted var(--rule-soft); }
.signal-box .k { color: var(--ink-soft); }
.signal-box .v {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  font-weight: 600;
  color: var(--ink);
}

/* LEAPS ladder */
table.ladder {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-3);
}
table.ladder th {
  font-family: var(--font-sans);
  font-size: var(--fs-caps);
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  color: var(--ink-dim);
  text-align: right;
  padding: 6px 4px;
  border-bottom: 1px solid var(--ink);
  font-weight: 700;
}
table.ladder th:first-child { text-align: left; }
table.ladder td {
  padding: 6px 4px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  font-size: var(--fs-xs);
  text-align: right;
  border-bottom: 1px dotted var(--rule-soft);
}
table.ladder td:first-child {
  text-align: left;
  font-family: var(--font-sans);
  font-weight: 500;
  font-variant-numeric: normal;
}
table.ladder tr.rec { background: var(--paper-soft); }
table.ladder tr.rec td:first-child::after {
  content: ' ★';
  color: var(--star);
  font-weight: 700;
}
.ladder-note {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-xs);
  color: var(--ink-dim);
  margin: var(--sp-2) 0 var(--sp-5);
  line-height: 1.45;
}

/* LEAPS rationale bullet list */
.leaps-rationale {
  list-style: none; margin: 0 0 var(--sp-3); padding: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.leaps-rationale li {
  font-family: var(--font-sans); font-size: var(--fs-xs); color: var(--ink-soft);
  padding-left: 12px; position: relative; line-height: 1.35;
}
.leaps-rationale li::before { content: '→'; position: absolute; left: 0; color: var(--accent); font-weight: 700; }

/* Collapsed ladder for non-LEAPS recs */
.ladder-details { margin-bottom: var(--sp-5); }
.ladder-summary {
  font-family: var(--font-sans); font-size: var(--fs-xs); font-weight: 600;
  letter-spacing: 0.05em; color: var(--ink-muted);
  cursor: pointer; list-style: none; padding: 4px 0;
  border-top: 1px solid var(--rule-hair); border-bottom: 1px solid var(--rule-hair);
}
.ladder-summary:hover { color: var(--ink); }
.ladder-summary::-webkit-details-marker { display: none; }
.ladder-summary::before { content: '▸ '; color: var(--ink-dim); }
.ladder-details[open] .ladder-summary::before { content: '▾ '; }

/* ── News block: inside dossier-article, below body prose ───────── */
.dossier-news-block {
  border-top: 3px double var(--ink);
  margin-top: var(--sp-5);
  padding-bottom: var(--sp-4);
}

/* ── News block: full-width row below article + sidebar grid ──────── */
.dossier-news-full {
  grid-column: 1 / -1;
  padding: var(--sp-5) var(--sp-10) var(--sp-6);
  border-top: 3px double var(--ink);
  margin-top: 0;
}
@media (max-width: 760px) {
  .dossier-news-full { padding: var(--sp-5) var(--sp-4) var(--sp-6); }
}

/* ── Article headlines block (inside news block) ────────────────── */
.article-headlines {
  margin: var(--sp-4) 0 var(--sp-6);
  border-bottom: 1px solid var(--rule);
}
.ah-rule-head {
  display: flex; align-items: center;
  padding: 5px 0 6px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 0;
}
.ah-label {
  font-family: var(--font-sans);
  font-size: var(--fs-caps);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.ah-list {
  display: flex; flex-direction: column;
}
.ah-row {
  display: flex; align-items: baseline; gap: var(--sp-3);
  padding: 9px 0;
  border-bottom: 1px solid var(--rule-hair);
}
.ah-row:last-child { border-bottom: 0; }

/* Sentiment tag pill */
.ah-tag {
  flex-shrink: 0;
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 5px;
  border-radius: 2px;
  min-width: 52px;
  text-align: center;
}
.ah-tag-bull, .hl-tag-bull { background: color-mix(in srgb, var(--sentiment-bull) 12%, transparent); color: var(--sentiment-bull); }
.ah-tag-bear, .hl-tag-bear { background: color-mix(in srgb, var(--sentiment-bear) 12%, transparent); color: var(--sentiment-bear); }
.ah-tag-neu,  .hl-tag-neu  { background: var(--paper-soft); color: var(--ink-muted); border: 1px solid var(--rule); }

.ah-body { min-width: 0; flex: 1; }
.ah-title {
  font-family: var(--font-serif);
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink);
  text-decoration: none;
}
.ah-title:hover { color: var(--accent); text-decoration: underline; }
.ah-meta {
  display: block;
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--ink-dim);
  margin-top: 2px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.factbox {
  border: 1px solid var(--rule-soft);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-5);
  background: var(--paper-soft);
}
.factbox h5 {
  font-family: var(--font-sans);
  font-size: var(--fs-caps);
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  color: var(--ink-dim);
  margin: 0 0 var(--sp-2);
  font-weight: 700;
}
.factbox .row {
  display: flex; justify-content: space-between;
  font-size: var(--fs-sm);
  padding: 3px 0;
}
.factbox .k { color: var(--ink-soft); }
.factbox .v {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  font-weight: 600;
  color: var(--ink);
}

/* ── Options flow badges ─────────────────────────────────────── */
.of-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  vertical-align: middle;
}
.of-bull { background: #dcfce7; color: #15803d; }
.of-bear { background: #fee2e2; color: #b91c1c; }
.of-neu  { background: #f1f5f9; color: #64748b; }

/* ── News sentiment tags ─────────────────────────────────────── */
.news-sent-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: capitalize;
  vertical-align: middle;
}
.sent-tag-bull    { background: #dcfce7; color: #15803d; }
.sent-tag-bear    { background: #fee2e2; color: #b91c1c; }
.sent-tag-sbull   { background: #d1fae5; color: #047857; }
.sent-tag-sbear   { background: #fce7f3; color: #9d174d; }
.sent-tag-neutral { background: #f1f5f9; color: #64748b; }

.events-list { list-style: none; padding: 0; margin: 0; }
.events-list li {
  padding: var(--sp-2) 0;
  font-size: var(--fs-sm);
  border-bottom: 1px dotted var(--rule-soft);
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: var(--sp-2);
}
.events-list .d {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-dim);
}
.events-list .t {
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--ink);
}
.events-list .s {
  color: var(--ink-soft);
  font-size: var(--fs-xs);
  display: block;
  margin-top: 1px;
}

/* ── Sensitivity table (LEAPS sidebar) ──────────────────────── */
.sens-pos { color: var(--sentiment-bull); }
.sens-neg { color: var(--sentiment-bear); }
.sens-dim { color: var(--ink-dim); }
.sens-details { margin-bottom: var(--sp-4); }
table.sens-table { font-size: var(--fs-xs); }

/* ── Earnings history (article column) ──────────────────────── */
.dossier-earnings-section {
  margin: var(--sp-6) 0 var(--sp-4);
  border-top: 1px solid var(--rule-soft);
  padding-top: var(--sp-4);
}
.dossier-section-label {
  font-family: var(--font-sans);
  font-size: var(--fs-caps);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  color: var(--ink-dim);
  margin: 0 0 var(--sp-3);
}
table.eh-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-3);
}
table.eh-table th {
  font-family: var(--font-sans);
  font-size: var(--fs-caps);
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  color: var(--ink-dim);
  text-align: right;
  padding: 6px 4px;
  border-bottom: 2px solid var(--ink);
  font-weight: 700;
}
table.eh-table th:first-child { text-align: left; }
table.eh-table td {
  text-align: right;
  padding: 5px 4px;
  border-bottom: 1px solid var(--rule-soft);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}
table.eh-table td:first-child {
  text-align: left;
  font-family: var(--font-sans);
  color: var(--ink-soft);
}
.eh-beat { color: var(--sentiment-bull); font-weight: 600; }
.eh-miss { color: var(--sentiment-bear); font-weight: 600; }
.eh-warn {
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  color: var(--bear-ink);
  background: rgba(168, 30, 30, 0.07);
  border-left: 3px solid var(--sentiment-bear);
  padding: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-3);
}

/* ── Insider sidebar section ─────────────────────────────────── */
.factbox .v.ins-name {
  font-family: var(--font-sans);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
  font-size: var(--fs-xs);
}
.factbox-sub {
  font-weight: 400;
  font-size: var(--fs-xs);
  color: var(--ink-dim);
  text-transform: none;
  letter-spacing: 0;
}
.factbox .v .badge {
  font-family: var(--font-sans);
  vertical-align: middle;
  font-size: 10px;
  padding: 1px 5px;
}

/* ── Dossier responsive ──────────────────────────────────────── */
@media (max-width: 1000px) {
  .dossier-grid { grid-template-columns: minmax(0, 1fr) 340px; }
  .dossier-article { padding: var(--sp-6) var(--sp-6) var(--sp-8); }
  .dossier-hero-sym { font-size: 72px; }
  .dossier-headline { font-size: 28px; }
}
@media (max-width: 760px) {
  .dossier-topbar { display: none; }
  /* Push dossier content below the Dynamic Island / notch on iOS.
     The panel is position:fixed inset:0 and the topbar is hidden on mobile,
     so without this the first article content sits under the status bar.
     !important required: #dossier-panel also carries .dossier which has
     padding:0 !important — ID + !important beats class + !important. */
  #dossier-panel { padding-top: env(safe-area-inset-top, 0px) !important; }
  .dossier-grid { grid-template-columns: 1fr; }
  .dossier-article { padding: var(--sp-5) var(--sp-4); }
  .dossier-sidebar {
    border-left: 0;
    border-top: 3px double var(--ink);
    padding: var(--sp-5) var(--sp-4);
  }
  .dossier-sidebar .info-tip::after {
    right: auto;
    left: calc(100% + 8px);
  }
  .dossier-hero-sym { font-size: 52px; letter-spacing: -0.035em; }
  .dossier-hero-price { font-size: 36px; }
  .dossier-headline { font-size: 22px; }
  .dossier-body p:first-of-type::first-letter { font-size: 48px; }
  .dossier-company { font-size: 14px; }
  .dossier-bylines { font-size: 10px; flex-wrap: wrap; gap: 6px; }
  .tv-frame { min-height: 280px; }
  .tv-frame .tradingview-widget-container,
  .tv-frame iframe { height: 280px !important; }
}

/* ═══════════════════════════════════════════════════════════════════
   12. MODAL (strategy help)
   ═══════════════════════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(26,22,16,0.35);
  opacity: 0; visibility: hidden;
  transition: opacity 200ms ease, visibility 0s linear 200ms;
  z-index: 400;
}
.modal-backdrop.open { opacity: 1; visibility: visible; transition: opacity 200ms ease; }
.modal {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  opacity: 0; visibility: hidden;
  transition: opacity 200ms ease, transform 200ms ease, visibility 0s linear 200ms;
  background: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: 0 12px 40px rgba(26,22,16,0.2);
  max-width: 560px; width: 92vw;
  max-height: 86vh;
  display: flex; flex-direction: column;
  z-index: 401;
}
.modal.open { opacity: 1; visibility: visible; transform: translate(-50%, -50%) scale(1); transition: opacity 200ms ease, transform 200ms ease; }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--ink);
  background: var(--paper-warm);
}
.modal-title { font-family: var(--font-serif); font-weight: 700; font-size: var(--fs-h1); }
.modal-content { padding: var(--sp-5); overflow-y: auto; font-family: var(--font-serif); font-size: var(--fs-read); line-height: var(--lh-read); color: var(--ink); }
/* ── First-sign-in disclaimer full-page screen ───────────────────────────── */
.disclaimer-page {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
           env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
.disclaimer-page[hidden] { display: none; }
.disclaimer-page-inner {
  max-width: 520px;
  width: 100%;
  padding: var(--sp-7) var(--sp-5);
}
.disclaimer-page-wordmark {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: var(--fs-h2);
  color: var(--ink-dim);
  letter-spacing: 0.02em;
  margin-bottom: var(--sp-5);
}
.disclaimer-page-title {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 var(--sp-5);
  line-height: 1.2;
}
.disclaimer-page-body {
  font-family: var(--font-serif);
  font-size: var(--fs-read);
  line-height: var(--lh-read);
  color: var(--ink-soft);
  margin-bottom: var(--sp-6);
}
.disclaimer-page-body p { margin: 0 0 var(--sp-3); }
.disclaimer-page-body p:last-child { margin-bottom: 0; }
.disclaimer-page-body strong { color: var(--ink); }
.disclaimer-page-btn { width: 100%; justify-content: center; }
.modal-content h4 { font-family: var(--font-serif); font-weight: 700; font-size: var(--fs-h2); margin: var(--sp-4) 0 var(--sp-2); }
.modal-content .modal-dl { display: grid; grid-template-columns: auto 1fr; column-gap: var(--sp-3); row-gap: var(--sp-2); margin: var(--sp-2) 0; }
.modal-content .modal-dl dt { align-self: center; }
.modal-content .modal-dl dd { margin: 0; align-self: center; color: var(--ink-soft); font-size: var(--fs-sm); }

/* ═══════════════════════════════════════════════════════════════════
   13. SECONDARY PANELS — calendar / positions / alerts placeholders
   Full styling lands in Step 3. These keep things usable meanwhile.
   ═══════════════════════════════════════════════════════════════════ */
#calendar-panel, #positions-panel, #watchlist-alerts { display: none; }
body.view-calendar #calendar-panel { display: block; }
body.view-positions #positions-panel { display: block; }


.connect-card, .alerts-panel {
  background: var(--paper-soft);
  border: 1px solid var(--rule);
  padding: var(--sp-5);
  margin-bottom: var(--sp-4);
}

/* ═══════════════════════════════════════════════════════════════════
   CALENDAR — subscribe card + custom month grid + agenda list
   ═══════════════════════════════════════════════════════════════════ */

/* ── Subscribe card ── */
.cal-sub-wrap { margin-bottom: var(--sp-4); }

.cal-sub-cta {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  background: var(--paper-soft);
  border: 1px solid var(--rule-soft);
  border-left: 3px solid var(--accent);
  padding: 10px var(--sp-5);
}
.cal-sub-cta-icon {
  color: var(--accent);
  flex: 0 0 auto;
  opacity: 0.7;
}
.cal-sub-cta-body { flex: 1 1 auto; min-width: 0; }
.cal-sub-cta-title {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: var(--fs-xs);
  color: var(--ink);
  margin: 0 0 2px;
}
.cal-sub-cta-desc {
  font-family: var(--font-sans);
  font-size: var(--fs-2xs);
  color: var(--ink-dim);
  margin: 0;
  line-height: 1.3;
}

.cal-sub-active {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  background: var(--paper-soft);
  border: 1px solid var(--rule-soft);
  border-left: 3px solid var(--bull-ink);
  padding: 10px var(--sp-5);
}
.cal-sub-active-check {
  color: var(--bull-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.cal-sub-active-label {
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--bull-ink);
  flex: 0 0 auto;
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
}
.cal-url-row { display: flex; gap: var(--sp-2); align-items: center; flex: 1 1 auto; min-width: 0; }
.cal-url {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  background: var(--paper);
  padding: 3px 8px;
  border: 1px solid var(--rule-soft);
  border-radius: var(--r-xs);
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 0;
}
.cal-icon-btn { display: inline-flex; align-items: center; justify-content: center; padding: 5px 7px; }

@media (max-width: 760px) {
  .cal-sub-cta-desc { display: none; }
}

/* ── Main layout ── */
#cal-main {
  display: flex;
  gap: var(--sp-5);
  align-items: flex-start;
  width: 100%;
}

/* Month panel */
#cal-month-panel {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid var(--rule);
  overflow: hidden;
  background: var(--paper-soft);
}

/* Navigation bar */
#cal-nav {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--rule);
  background: var(--paper-warm);
}
.cal-month-title {
  font-family: var(--font-serif);
  font-size: var(--fs-h2);
  font-weight: 700;
  color: var(--ink);
  margin: 0;
  flex: 1 1 auto;
  text-align: center;
  letter-spacing: -0.01em;
}
.cal-nav-btn {
  background: none;
  border: 1px solid var(--rule);
  border-radius: var(--r-xs);
  color: var(--ink-dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  font-size: 16px;
  line-height: 1;
  transition: background 80ms, color 80ms;
}
.cal-nav-btn:hover { background: var(--rule-soft); color: var(--ink); }
.cal-today-btn {
  background: none;
  border: 1px solid var(--rule);
  border-radius: var(--r-xs);
  color: var(--ink-dim);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: var(--fs-caps);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  padding: 4px 10px;
  height: 28px;
  transition: background 80ms, color 80ms;
}
.cal-today-btn:hover { background: var(--rule-soft); color: var(--ink); }

/* Day-of-week header row */
#cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-top: 1px solid var(--rule);
}
.cal-dow {
  background: var(--paper-warm);
  text-align: center;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  padding: 6px 0 5px;
  border-bottom: 1px solid var(--rule);
  border-right: 1px solid var(--rule-hair);
}
.cal-dow:nth-child(1),
.cal-dow:nth-child(7) { color: var(--ink-dim); }
.cal-dow:last-child { border-right: none; }

/* Day cells */
.cal-cell {
  background: var(--paper-soft);
  min-height: 108px;
  padding: 5px 6px 4px;
  border-right: 1px solid var(--rule-hair);
  border-bottom: 1px solid var(--rule-hair);
  cursor: pointer;
  overflow: hidden;
  transition: background 60ms ease;
  box-sizing: border-box;
  position: relative;
}
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell:hover { background: var(--paper-warm); }
.cal-cell.weekend { background: color-mix(in srgb, var(--paper-warm) 60%, var(--paper-soft)); }
.cal-cell.weekend:hover { background: var(--paper-warm); }
.cal-cell.other-month { background: var(--paper); opacity: 0.55; }
.cal-cell.other-month.weekend { background: var(--paper); }
.cal-cell.today { background: rgba(43,74,122,0.06); }
.cal-cell.today:hover { background: rgba(43,74,122,0.11); }
.cal-cell.today { border-top: 2px solid var(--accent); margin-top: -1px; }

.cal-day-num {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  display: block;
  text-align: right;
  line-height: 1;
  margin-bottom: 4px;
}
.cal-cell.today .cal-day-num {
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  width: 20px; height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  float: right;
  font-weight: 700;
  font-size: 10px;
}
.cal-cell.weekend .cal-day-num { color: var(--ink-dim); }

/* Event pills — styled by data-cat */
.cal-event {
  display: block;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 2px 5px;
  margin-bottom: 2px;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  clear: both;
}
.cal-event[data-cat="earnings"] { background: rgba(42,91,154,0.14);  color: #2a5b9a; }
.cal-event[data-cat="fomc"]     { background: rgba(124,92,191,0.14); color: #6b4db8; }
.cal-event[data-cat="cpi"]      { background: rgba(180,110,20,0.14); color: #8a5200; }
.cal-event[data-cat="leaps"]    { background: rgba(26,107,58,0.14);  color: #165f35; }
.cal-event[data-cat="expiry"]   { background: rgba(180,90,20,0.14);  color: #a04800; }
@media (prefers-color-scheme: dark) {
  .cal-event[data-cat="earnings"] { background: rgba(42,91,154,0.28);  color: #85b8f0; }
  .cal-event[data-cat="fomc"]     { background: rgba(124,92,191,0.28); color: #bca8f5; }
  .cal-event[data-cat="cpi"]      { background: rgba(201,124,38,0.28); color: #e8b860; }
  .cal-event[data-cat="leaps"]    { background: rgba(26,107,58,0.28);  color: #6ed48a; }
  .cal-event[data-cat="expiry"]   { background: rgba(212,120,42,0.28); color: #f0aa60; }
}
.cal-more {
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 500;
  color: var(--ink-muted);
  padding: 1px 5px;
  clear: both;
}

/* ── Agenda panel ── */
#cal-agenda {
  flex: 0 0 210px;
  border: 1px solid var(--rule);
  max-height: 560px;
  overflow-y: auto;
  background: var(--paper-soft);
}
.cal-agenda-head {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  padding: 9px var(--sp-4) 8px;
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  background: var(--paper-warm);
}
.cal-agenda-group { padding: var(--sp-3) var(--sp-3) var(--sp-2); }
.cal-agenda-group + .cal-agenda-group {
  border-top: 1px solid var(--rule-hair);
}
.cal-agenda-date {
  font-family: var(--font-sans);
  font-size: var(--fs-2xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  margin: 0 0 5px;
}
/* Agenda event rows */
.cal-agenda-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 3px;
  margin-bottom: 2px;
  line-height: 1.2;
}
.cal-agenda-item[data-cat="earnings"] { background: rgba(42,91,154,0.09); }
.cal-agenda-item[data-cat="fomc"]     { background: rgba(124,92,191,0.09); }
.cal-agenda-item[data-cat="cpi"]      { background: rgba(180,110,20,0.09); }
.cal-agenda-item[data-cat="leaps"]    { background: rgba(26,107,58,0.09); }
.cal-agenda-item[data-cat="expiry"]   { background: rgba(180,90,20,0.09); }
@media (prefers-color-scheme: dark) {
  .cal-agenda-item[data-cat="earnings"] { background: rgba(42,91,154,0.20); }
  .cal-agenda-item[data-cat="fomc"]     { background: rgba(124,92,191,0.20); }
  .cal-agenda-item[data-cat="cpi"]      { background: rgba(201,124,38,0.20); }
  .cal-agenda-item[data-cat="leaps"]    { background: rgba(26,107,58,0.20); }
  .cal-agenda-item[data-cat="expiry"]   { background: rgba(212,120,42,0.20); }
}
.cal-agenda-type {
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 1px 5px;
  border-radius: 2px;
}
.cal-agenda-item[data-cat="earnings"] .cal-agenda-type { background: rgba(42,91,154,0.15);  color: #2a5b9a; }
.cal-agenda-item[data-cat="fomc"]     .cal-agenda-type { background: rgba(124,92,191,0.15); color: #6b4db8; }
.cal-agenda-item[data-cat="cpi"]      .cal-agenda-type { background: rgba(180,110,20,0.15); color: #8a5200; }
.cal-agenda-item[data-cat="leaps"]    .cal-agenda-type { background: rgba(26,107,58,0.15);  color: #165f35; }
.cal-agenda-item[data-cat="expiry"]   .cal-agenda-type { background: rgba(180,90,20,0.15);  color: #a04800; }
@media (prefers-color-scheme: dark) {
  .cal-agenda-item[data-cat="earnings"] .cal-agenda-type { background: rgba(42,91,154,0.30);  color: #85b8f0; }
  .cal-agenda-item[data-cat="fomc"]     .cal-agenda-type { background: rgba(124,92,191,0.30); color: #bca8f5; }
  .cal-agenda-item[data-cat="cpi"]      .cal-agenda-type { background: rgba(201,124,38,0.30); color: #e8b860; }
  .cal-agenda-item[data-cat="leaps"]    .cal-agenda-type { background: rgba(26,107,58,0.30);  color: #6ed48a; }
  .cal-agenda-item[data-cat="expiry"]   .cal-agenda-type { background: rgba(212,120,42,0.30); color: #f0aa60; }
}
.cal-agenda-name {
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  color: var(--ink);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-agenda-empty {
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  color: var(--ink-muted);
  padding: var(--sp-6) var(--sp-4);
  margin: 0;
  text-align: center;
  font-style: italic;
}

/* At medium widths, collapse agenda below the grid so the grid gets full width */
@media (max-width: 900px) {
  #cal-main { flex-direction: column; align-items: stretch; }
  #cal-agenda { flex: none; width: 100%; max-height: 300px; }
  #cal-month-panel { width: 100%; }
}
@media (max-width: 760px) {
  .cal-cell { min-height: 72px; padding: 4px 5px; }
  .cal-event { font-size: 9px; padding: 1px 4px; margin-bottom: 1px; }
  .cal-month-title { font-size: var(--fs-h2); }
}

/* ═══════════════════════════════════════════════════════════════════
   14. RESPONSIVE — collapse 3-col to single col, column-priority hides
   ═══════════════════════════════════════════════════════════════════ */

/* Global overflow guard — nothing should cause horizontal page scroll.
   Individual scrollable regions opt in via overflow-x: auto locally. */
html, body { overflow-x: hidden; max-width: 100vw; }

/* ── Hide right rail below 1180px ─────────────────────────────── */
@media (max-width: 1180px) {
  .page { grid-template-columns: 240px minmax(0,1fr); }
  .page > .col.right { display: none; }
}

/* ── Tablet: compress left-rail padding ───────────────────────── */
@media (max-width: 1000px) {
  .page { grid-template-columns: 220px minmax(0,1fr); }
  .page > .col { padding: var(--sp-4) var(--sp-3); }
  .masthead { padding: var(--sp-4) var(--sp-5) var(--sp-2); }
  .ribbon { padding: 6px var(--sp-5); }
}

/* ── Phone (≤760px) ──────────────────────────────────────────────
   At phone width the 3-col grid collapses to a single column.
   The left-rail nav is lifted out to a sticky top tab strip below
   the masthead so users can still switch sections. Filter rail
   hides; search input in the center stays as the primary find tool.
   ────────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  /* Single-col page — override any higher-specificity view-* rules too */
  .page,
  body.view-watchlist .page,
  body.view-calendar  .page,
  body.view-positions .page,
  body.view-about     .page,
  body.view-settings  .page,
  body.view-dossier   .page { grid-template-columns: 1fr; }
  .page > .col + .col { border-left: 0; }
  .page > .col.left {
    /* On mobile the left rail becomes a slide-in drawer rather than hiding.
       It starts off-screen left and slides in when .drawer-open is added. */
    display: block;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 88%;
    max-width: 320px;
    z-index: 401;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--paper);
    border-right: 1px solid var(--rule);
    padding: calc(var(--sp-5) + env(safe-area-inset-top, 0px)) var(--sp-4) calc(var(--sp-6) + env(safe-area-inset-bottom, 0px));
    transform: translateX(-105%);
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
  }
  .page > .col.left.drawer-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.18);
  }
  .page > .col { padding: var(--sp-3) var(--sp-4); }
  .page > .col.center { padding: var(--sp-3) var(--sp-4); }

  /* Masthead stacks vertically, wordmark scales down to fit 390px viewport.
     Top padding uses only env(safe-area-inset-top) for the Dynamic Island /
     notch — no extra base offset added on top, which was doubling the gap on
     iOS (the WKWebView already accounts for the status-bar height via the
     safe-area env variable). A 4px floor ensures a hair of breathing room on
     web / non-notched devices where the env() resolves to 0. */
  .masthead {
    grid-template-columns: 1fr;
    padding: max(var(--sp-1), env(safe-area-inset-top, 0px)) var(--sp-3) var(--sp-2);
    gap: var(--sp-1);
    text-align: center;
  }
  .masthead-left, .masthead-right {
    display: none;  /* phone: collapse the Vol/No/date flanking columns */
  }
  .masthead-title { padding-bottom: 0; }
  .masthead-wordmark { font-size: 28px; letter-spacing: -0.02em; }
  .masthead-wordmark .the { font-size: 0.5em; vertical-align: 0.6em; margin-right: 3px; }
  .masthead-motto { font-size: var(--fs-2xs); margin-top: 2px; }

  /* Ribbon — smaller, tighter, internally scrollable if it still overflows */
  .ribbon {
    padding: 5px var(--sp-3);
    font-size: var(--fs-2xs);
    gap: var(--sp-2);
    flex-wrap: wrap;
  }
  .ribbon-indices {
    gap: var(--sp-1);
    overflow-x: auto;
    flex-wrap: nowrap;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    min-width: 0;
  }
  .ribbon-indices::-webkit-scrollbar { display: none; }
  .ribbon-status { flex-shrink: 0; font-size: var(--fs-2xs); }
  .ribbon-sep { margin: 0 4px; }

  /* Center head */
  .center-head { flex-direction: column; align-items: flex-start; gap: var(--sp-2); }
  .center-head h2 { font-size: 22px; }
  .center-head-right { align-items: flex-start; }
  .search-wrap .search { width: 120px; }
  .search-wrap .search { min-width: 0; width: 100%; }
  /* Equal-size action buttons on mobile.
     Grid 1fr columns guarantee equal widths regardless of content or element
     type — flex was distributing unequally between display:block wrappers and
     the display:flex reset button. grid-auto-columns adapts when Save view
     appears as a 4th column. */
  .center-head .actions {
    width: 100%;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: var(--sp-1);
    align-items: stretch;
  }
  .center-head .actions > .btn { justify-content: center; }
  .center-head .actions .col-picker-wrap > .btn,
  .center-head .actions .preset-views-wrap > .btn { width: 100%; height: 100%; justify-content: center; }

  /* Preset dropdown — keep same on mobile */
  .presets { min-width: 180px; }
  .preset { font-size: var(--fs-xs); }

  /* Footer — stack */
  .page-footer {
    flex-direction: column;
    gap: 4px;
    padding: 6px var(--sp-3);
    text-align: center;
  }

  /* Auth-pill in masthead is hidden on phone (sign-out lives elsewhere);
     instead show it below the mobile tabs. We don't render it yet — auth
     pill stays in place on phone but the masthead-right column is hidden
     so it's effectively invisible. Promote it into a visible slot: */
  #signed-in-ui { display: none !important; }
}

/* ── Bottom tab bar (phone-only) ──────────────────────────────────
   iOS-native-style sticky footer with 4 section tabs. Replaces the
   earlier top .mobile-tabs strip, which the user (reasonably) noted
   is redundant when the bottom bar does the same job.

   Tab icons are editorial serif glyphs (§ ★ ▦ ◎) matching the ios-
   screener.html mock. Active tab gets the accent color, inactive
   tabs sit in ink-dim so the active state reads clearly.

   Respects iOS safe-area-inset-bottom so it sits above the home
   indicator on notched devices in the Capacitor WKWebView. ──── */
.bottom-tabs {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  background: var(--paper-warm);
  border-top: 3px double var(--ink);
  padding: 0 0 env(safe-area-inset-bottom, 0px);
  /* Horizontal scroll: show 4 tabs at a time, the rest scroll into view.
     Each tab is sized to 25vw so exactly 4 fit across the viewport width.
     Replaces the prior auto-fit grid that crammed all 6 signed-in tabs
     into the visible width. */
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-snap-type: x mandatory;
}
.bottom-tabs::-webkit-scrollbar { display: none; }
.bottom-tabs .tab-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: 0;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-dim);
  cursor: pointer;
  padding: 2px 0;
  flex: 0 0 25vw;
  scroll-snap-align: start;
}
.bottom-tabs .tab-item .ico {
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: 20px;
  line-height: 1;
}
.bottom-tabs .tab-item.active { color: var(--accent); }
.bottom-tabs .tab-item:hover { color: var(--ink-soft); }
.bottom-tabs .tab-item.active:hover { color: var(--accent); }

/* Scroll-edge fade indicators — sibling divs injected by JS */
.tabs-fade {
  display: none;
  position: fixed;
  bottom: 0;
  height: calc(53px + env(safe-area-inset-bottom, 0px));
  width: 44px;
  pointer-events: none;
  z-index: 55;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s, visibility 0s 0.18s;
}
.tabs-fade-left  { left: 0;  background: linear-gradient(to left,  transparent, var(--paper-warm) 85%); }
.tabs-fade-right { right: 0; background: linear-gradient(to right, transparent, var(--paper-warm) 85%); }
@media (max-width: 760px) {
  .tabs-fade { display: block; }
  .tabs-fade.visible { opacity: 1; visibility: visible; transition: opacity 0.18s, visibility 0s; }
}

/* Filter drawer backdrop — hidden until drawer opens */
.filter-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(20, 17, 12, 0.45);
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);
}
.filter-backdrop.open { display: block; }

/* Filter button — mobile only; styled as a thin vertical tab on the left edge */
.filter-drawer-btn { display: none; }

/* Close button inside the drawer — mobile only */
.filter-drawer-close {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--fs-xs);
  font-family: var(--font-sans);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  padding: 0 0 var(--sp-4) 0;
  text-align: left;
}

@media (max-width: 760px) {
  /* Make the html root match the tab-bar colour so WKWebView rubber-band
     bounce at the bottom never exposes the native dark background. */
  html { background: var(--paper-warm); }
  .bottom-tabs { display: flex; }
  /* Ensure the page content doesn't sit under the fixed bar. */
  body.signed-in { padding-bottom: calc(57px + env(safe-area-inset-bottom, 0px)); }
  /* Filter tab: thin strip pinned to the left edge, text runs top-to-bottom */
  .filter-drawer-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    writing-mode: vertical-rl;
    width: 22px;
    padding: 12px 0;
    height: auto;
    z-index: 399;
    border-radius: 0 4px 4px 0;
    border: 1px solid var(--rule);
    border-left: 0;
    background: var(--paper);
    box-shadow: 2px 0 8px rgba(0,0,0,0.07);
    font-size: 10px;
    font-family: var(--font-sans);
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-muted);
    cursor: pointer;
  }
  .filter-drawer-btn:hover { color: var(--accent); }
  /* Hide the tab when the drawer is open (drawer covers the left edge anyway) */
  .col.left.drawer-open ~ * .filter-drawer-btn,
  body:has(.col.left.drawer-open) .filter-drawer-btn { opacity: 0; pointer-events: none; }
  /* Hide the filter tab on non-screener pages — filters only apply to the screener */
  body.view-watchlist .filter-drawer-btn,
  body.view-calendar  .filter-drawer-btn,
  body.view-positions .filter-drawer-btn,
  body.view-about     .filter-drawer-btn,
  body.view-settings  .filter-drawer-btn { display: none; }
  .filter-drawer-close { display: block; }
  /* Bottom tabs replace the section-nav — hide it inside the filter drawer
     so navigation doesn't appear twice when the drawer slides in. */
  .section-nav { display: none; }
}

/* Column-priority hiding on results table */
@media (max-width: 1200px) { #results-table .col-p4 { display: none; } }
@media (max-width: 900px)  { #results-table .col-p3 { display: none; } }
@media (max-width: 500px)  { #results-table .col-p2 { display: none; } }

/* ── Phone table: card-style 2-line rows ────────────────────────
   At ≤500px we reflow each <tr> into a 2-line "card": top line has
   star / ticker / price; bottom line folds Signal + Earnings + LEAPS
   under the ticker. The table DOM is untouched so sort + filters keep
   working; CSS grid rearranges the cells visually.
   ────────────────────────────────────────────────────────────── */
@media (max-width: 500px) {
  .table-wrapper { overflow-x: visible; }
  #results-table { display: block; }
  #results-table thead { display: none; } /* column headers don't map to cards */
  #results-table tbody { display: block; }

  /* Grid: 4 columns. Col 1 = star (spans both rows), col 2 = ticker / signal,
     col 3 = earnings date (row 1) — fixed width so all cards align even when
     a ticker has no upcoming earnings, col 4 = price / 1d change.
     Star column is wider (28px) to leave room for the sentiment bar. */
  #results-table tbody tr {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) 3rem auto;
    column-gap: 6px;
    row-gap: 2px;
    padding: 10px var(--sp-3) 10px var(--sp-2);
    border-bottom: 1px solid var(--rule-hair);
    position: static !important;
    background: transparent !important;
  }
  #results-table tbody tr:hover { background: var(--paper-soft) !important; }

  /* Hide every cell by default; selectively re-show + place by nth-child.
     Avoids touching the renderer. */
  #results-table tbody td {
    display: none;
    padding: 0;
    border: 0;
    text-align: left;
    position: static !important;
    background: transparent !important;
  }

  /* 1 — star · spans both rows. padding-left restores the breathing room that
     the mobile td { padding:0 } reset removes from the sentiment bar rule. */
  #results-table tbody td:nth-child(1) {
    display: flex; align-items: center; justify-content: center;
    grid-column: 1; grid-row: 1 / span 2;
    align-self: center;
    padding-left: 5px;
  }
  /* 2 — ticker cell · top-left, col 2 only. Shows ticker + inline
     ETF chip on line 1, company name on line 2 (gray, single-line,
     ellipsis on overflow). Col 3 is now the earnings date. */
  #results-table tbody td:nth-child(2) {
    display: block;
    grid-column: 2; grid-row: 1;
    color: var(--ink);
    line-height: 1.15;
    min-width: 0;
  }
  #results-table tbody td:nth-child(2) .ticker {
    font-family: var(--font-serif);
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.01em;
  }
  #results-table tbody td:nth-child(2) .name {
    display: block;
    font-family: var(--font-sans);
    font-size: 11px;
    color: var(--ink-dim);
    margin-top: 2px;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* 4 — price · top-right */
  #results-table tbody td:nth-child(4) {
    display: block;
    grid-column: 4; grid-row: 1;
    justify-self: end;
    align-self: start;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 15px;
    color: var(--ink);
  }
  /* 5 — 1d change · bottom-right */
  #results-table tbody td:nth-child(5) {
    display: inline-flex; align-items: center;
    grid-column: 4; grid-row: 2;
    justify-self: end;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: var(--fs-2xs);
    white-space: nowrap;
  }
  /* 9 — signal badge · bottom row, spans cols 2-3 (earnings moved to row 1) */
  #results-table tbody td:nth-child(9) {
    display: flex; align-items: center;
    grid-column: 2 / span 2; grid-row: 2;
    font-size: var(--fs-2xs);
    overflow: hidden;
    min-width: 0;
  }
  /* 10 — earnings date · top-right of ticker, col 3 row 1.
     Aligned to the bottom of the ticker so it sits on the same baseline
     as the company name. justify-content: flex-end keeps the date
     right-justified inside the fixed-width 3rem column. */
  #results-table tbody td:nth-child(10) {
    display: flex; align-items: flex-end; justify-content: flex-end;
    grid-column: 3; grid-row: 1;
    font-family: var(--font-mono);
    font-size: var(--fs-2xs);
    color: var(--ink-dim);
    white-space: nowrap;
    padding-bottom: 2px;
  }

  /* Signal column — icon only, slightly larger than surrounding text */
  #results-table tbody td:nth-child(9) .badge {
    font-size: 11px;
    padding: 1px 4px;
    letter-spacing: 0.06em;
    white-space: nowrap;
    gap: 0;
  }
  #results-table tbody td:nth-child(9) .badge-label { display: none; }
  /* On mobile suppress the ⚠ prefix — it's a text node from the renderer so we
     can't remove it via CSS alone. Instead hide the entire cell content and
     re-render just the date portion via a data attribute. The renderer sets
     data-date on the td; we show only that on mobile. */
  #results-table tbody td:nth-child(10) {
    font-size: 0;   /* collapse the ⚠ text node to 0px */
  }
  #results-table tbody td:nth-child(10)::after {
    content: attr(data-short);
    font-size: var(--fs-2xs);
    font-family: var(--font-mono);
    color: var(--ink-dim);
  }
  #results-table tbody td:nth-child(10).earnings-warn::after {
    color: var(--warn);
    font-weight: 600;
  }

  .held-badge { margin-left: 4px; font-size: 10px; }

  /* Empty-state row — a single colspan=11 td. The card-grid rules above
     collapse normal rows into a 4-col grid; empty rows need to escape that
     treatment and span full width, centered. */
  #results-table tbody tr:has(td.empty) {
    display: block !important;
    grid: none !important;
    padding: var(--sp-6) var(--sp-4) !important;
    text-align: center;
  }
  #results-table tbody tr td.empty {
    display: block !important;
    grid-column: auto !important;
    grid-row: auto !important;
    padding: 0 !important;
    text-align: center;
    font-family: var(--font-serif);
    font-style: italic;
    font-size: var(--fs-sm);
    color: var(--ink-dim);
    line-height: 1.5;
  }
  #results-table tbody tr td.empty .empty-kicker {
    display: block;
    text-align: center;
    margin-bottom: var(--sp-2);
  }
}

/* ── Right rail on mobile: opt-in per view, not blanket re-enable ──
   Watchlist page: show both modules (watchlist + earnings).
   Positions page: show earnings only (hide watchlist module).
   All other views: right rail stays hidden. */
@media (max-width: 760px) {
  body.view-watchlist .page > .col.right,
  body.view-positions .page > .col.right {
    display: block;
    border-left: 0;
    border-top: 1px solid var(--rule);
    padding-top: var(--sp-5);
    margin-top: var(--sp-3);
  }
  body.view-positions #rr-watchlist,
  body.view-positions .rail-rule { display: none; }
}

/* Sticky first two columns on all non-mobile widths */
@media (min-width: 501px) {
  #results-table td:nth-child(-n+2) {
    position: sticky;
    background: var(--paper);
    z-index: 2;
  }
  #results-table th:nth-child(-n+2) {
    position: sticky;
    background: var(--paper-warm);
    z-index: 3;
  }
  #results-table th:nth-child(1), #results-table td:nth-child(1) { left: 0; }
  #results-table th:nth-child(2), #results-table td:nth-child(2) { left: 30px; }
  #results-table tbody tr:hover td:nth-child(-n+2) { background: var(--paper-soft); }
  #results-table tbody tr.row-active td:nth-child(-n+2) { background: var(--paper-warm); }
}

/* ═══════════════════════════════════════════════════════════════════
   15. LEGACY class bridges — keep existing app.js selectors working
   (These are used by older render paths we haven't rewritten yet.)
   ═══════════════════════════════════════════════════════════════════ */

/* Small modal doc links / emphasized code */
code { font-family: var(--font-mono); font-size: 0.9em; background: var(--paper-warm); padding: 1px 4px; border-radius: var(--r-xs); }
strong { font-weight: 700; }

/* Tab badge (legacy) */
.tab-badge {
  display: inline-block;
  margin-left: 4px;
  font-family: var(--font-sans);
  font-size: var(--fs-2xs);
  color: var(--ink-dim);
  font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════════════
   POSITIONS — summary tiles + per-account broadsheet card
   Treat the connected-broker view as a portfolio tear-sheet: a strip of
   summary tiles across the top, then one hairline-ruled card per account
   with its own holdings table.
   ═══════════════════════════════════════════════════════════════════ */

/* Header row — h2 + meta, actions on the right */
.positions-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 3px double var(--ink);
  flex-wrap: wrap;
}
.positions-header-left { min-width: 0; }
.positions-h2 {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: var(--fs-h1);
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0;
}
.positions-meta {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  margin: 4px 0 0;
}
.positions-actions {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
}
.positions-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-sans); font-size: var(--fs-xs);
  color: var(--ink-soft); cursor: pointer;
  margin-right: var(--sp-2);
}
.positions-toggle input[type="checkbox"] { cursor: pointer; }

.broker-status {
  padding: var(--sp-2) var(--sp-3);
  background: var(--paper-warm);
  border-left: 3px solid var(--accent);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  margin-bottom: var(--sp-3);
}
.broker-status-stale {
  border-left-color: var(--ink-muted);
  background: var(--paper);
}
.broker-status-loading {
  border-left-color: var(--accent);
  background: var(--paper-warm);
}
.broker-spinner {
  display: inline-block;
  width: 11px;
  height: 11px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: broker-spin 0.65s linear infinite;
  margin-right: 7px;
  vertical-align: middle;
  opacity: 0.6;
}
@keyframes broker-spin {
  to { transform: rotate(360deg); }
}

/* ── Summary tiles strip ──────────────────────────────────────── */
.portfolio-summary {
  display: grid;
  grid-template-columns: 2fr 2fr 1fr 1fr;
  gap: 0;
  margin-bottom: var(--sp-5);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  background: var(--paper-soft);
}
.pf-tile {
  padding: var(--sp-3) var(--sp-4);
  border-right: 1px solid var(--rule-soft);
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0;
}
.pf-tile:last-child { border-right: 0; }

.pf-tile-label {
  font-family: var(--font-sans);
  font-size: var(--fs-caps);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  color: var(--ink-dim);
}
.pf-tile-val {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  font-weight: 600;
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.pf-tile-big .pf-tile-val { font-size: 30px; }
.pf-tile-val-small { font-size: 18px; font-weight: 500; }
.pf-tile-sub {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--ink-dim);
  margin-top: 2px;
}
.pos-pnl-pos { color: var(--bull-ink); }
.pos-pnl-neg { color: var(--bear-ink); }

@media (max-width: 1000px) {
  .portfolio-summary { grid-template-columns: 1fr 1fr; }
  .pf-tile { border-bottom: 1px solid var(--rule-soft); }
  .pf-tile:nth-child(2) { border-right: 0; }
  .pf-tile:nth-child(3), .pf-tile:nth-child(4) { border-bottom: 0; }
}
@media (max-width: 500px) {
  .portfolio-summary { grid-template-columns: 1fr; }
  .pf-tile { border-right: 0 !important; border-bottom: 1px solid var(--rule-soft); }
  .pf-tile:last-child { border-bottom: 0; }
  .pf-tile-val, .pf-tile-big .pf-tile-val { font-size: 22px; }
}

/* ── Account card ─────────────────────────────────────────────── */
.account-card {
  background: var(--paper-soft);
  border: 1px solid var(--rule);
  margin-bottom: var(--sp-4);
}
.account-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--paper-warm);
  border-bottom: 1px solid var(--ink);
}
.account-card-title {
  display: flex; align-items: center; gap: var(--sp-3);
  min-width: 0;
}
.account-card-name {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: var(--fs-h2);
  letter-spacing: -0.005em;
  color: var(--ink);
  line-height: 1.2;
}
.account-card-sub {
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}
.account-card-totals {
  text-align: right;
  display: flex; flex-direction: column; align-items: flex-end;
}
.account-card-mv {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  font-weight: 600;
  font-size: 20px;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.account-card-pnl {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  font-size: var(--fs-sm);
  font-weight: 600;
  margin-top: 2px;
}
.account-card-pct {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--ink-dim);
  margin-left: 4px;
}
.account-card-body { padding: var(--sp-2) 0; }
.account-card-empty {
  padding: var(--sp-4);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-sm);
  color: var(--ink-dim);
  text-align: center;
}

/* Per-account holdings table */
.pos-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.account-pos-table {
  width: 100%;
  min-width: 680px; /* 130+140+90+80+110+130 */
  table-layout: fixed;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.account-pos-table thead th {
  font-family: var(--font-sans);
  font-size: var(--fs-caps);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  color: var(--ink-dim);
  text-align: right;
  padding: 6px var(--sp-3);
  border-bottom: 1px solid var(--rule);
  background: transparent;
  white-space: nowrap;
  overflow: hidden;
}
.account-pos-table thead th:first-child,
.account-pos-table thead th:nth-child(2) { text-align: left; }
.account-pos-table tbody td {
  padding: 8px var(--sp-3);
  border-bottom: 1px solid var(--rule-hair);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  text-align: right;
  color: var(--ink);
  overflow: hidden;
  white-space: nowrap;
}
.account-pos-table tbody td:first-child,
.account-pos-table tbody td:nth-child(2) {
  text-align: left;
  font-family: var(--font-sans);
}
.account-pos-table tbody tr:hover { background: var(--paper); cursor: pointer; }
.account-pos-table tbody tr:last-child td { border-bottom: 0; }

/* Kind pill (STK / OPT) */
.pos-kind {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 1px 5px;
  border: 1px solid var(--rule-soft);
  border-radius: var(--r-xs);
  margin-right: 6px;
  vertical-align: 1px;
}
.pos-kind-stock  { color: var(--ink-soft); background: var(--paper); }
.pos-kind-option { color: var(--accent); background: var(--paper); border-color: var(--accent); }

.pos-expiry {
  display: inline-block;
  margin-left: 6px;
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  color: var(--ink-dim);
}
.pos-ret-pct {
  display: block;
  margin-left: 0;
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink-dim);
}

/* ── Connect (disconnected) empty state ─────────────────────── */
.connect-empty {
  padding: var(--sp-6) 0;
  display: flex; justify-content: center;
}
.connect-card {
  background: var(--paper-soft);
  border: 1px solid var(--rule);
  padding: var(--sp-8) var(--sp-6);
  max-width: 640px;
  width: 100%;
  text-align: center;
}
.connect-card::before {
  content: 'Editor\'s desk · Portfolio';
  display: block;
  font-family: var(--font-sans);
  font-size: var(--fs-caps);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  color: var(--ink-dim);
  margin-bottom: var(--sp-2);
}
.connect-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 0 0 var(--sp-2);
}
.connect-blurb {
  font-family: var(--font-serif);
  font-size: var(--fs-read);
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 52ch;
  margin: 0 auto var(--sp-5);
}
.connect-fineprint {
  font-family: var(--font-sans);
  font-size: var(--fs-2xs);
  color: var(--ink-muted);
  max-width: 52ch;
  margin: var(--sp-3) auto 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Broker logo chip (already exists below) — tighten for broadsheet */
.broker-logo {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--paper);
  border-radius: var(--r);
  border: 1px solid var(--rule-soft);
  overflow: hidden;
  flex-shrink: 0;
}

/* Positions responsive */
@media (max-width: 760px) {
  .positions-header { flex-direction: column; align-items: flex-start; }
  .positions-actions { width: 100%; flex-wrap: wrap; gap: 6px; }
  .account-card-header { flex-direction: column; align-items: flex-start; gap: var(--sp-2); }
  .account-card-totals { text-align: left; align-items: flex-start; }
  .connect-card { padding: var(--sp-5) var(--sp-4); }
  .connect-title { font-size: 22px; }
  /* Hide option expiry date in QTY cell on mobile — visible in dossier */
  .pos-expiry { display: none; }
}

/* Calendar subscribe card — thin single-row banner (see main block above) */

/* ═══════════════════════════════════════════════════════════════════
   ALERTS PANEL — settings card for watchlist movement alerts.
   Clean card with hairline border; no accent stripe (that reads as a
   notification banner, not a settings panel). Three-column rule grid
   with group headings, accent-colored checkboxes, chip-style selects.
   ═══════════════════════════════════════════════════════════════════ */
.alerts-panel {
  background: var(--paper-soft);
  border: 1px solid var(--rule-soft);
  border-radius: var(--r);
  padding: var(--sp-4) var(--sp-5) var(--sp-5);
  margin-bottom: var(--sp-5);
  transition: padding-bottom 280ms ease;
}
.alerts-panel:not([aria-expanded="true"]) { padding-bottom: var(--sp-3); }
.alerts-panel:not([aria-expanded="true"]) .alerts-panel-header {
  border-bottom: 0;
  padding-bottom: 0;
  margin-bottom: 0;
}
.alerts-toggle {
  background: none;
  border: 0;
  cursor: pointer;
  padding: 4px 8px;
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--ink-soft);
  transition: transform 200ms ease;
}
.alerts-toggle .alerts-toggle-chevron {
  display: inline-block;
  transition: transform 200ms ease;
}
.alerts-panel[aria-expanded="true"] .alerts-toggle-chevron { transform: rotate(90deg); }

/* Watchlist-tab "Today's moves" mini list — editorial pullout matching
   .alerts-panel. Hidden by default; shown only when body.view-watchlist. */
.watchlist-moves {
  display: none;
  background: var(--paper-soft);
  border: 1px solid var(--rule-soft);
  border-left: 3px solid var(--accent);
  padding: var(--sp-3) var(--sp-4) var(--sp-4);
  margin-bottom: var(--sp-4);
}
body.view-watchlist #watchlist-moves { display: block; }
.watchlist-moves-head { margin-bottom: var(--sp-2); padding-bottom: var(--sp-2); border-bottom: 1px solid var(--rule-soft); }
.watchlist-moves-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: var(--fs-h2);
  letter-spacing: -0.005em;
  color: var(--ink);
  margin: 4px 0 0;
  font-style: italic;
}
.watchlist-moves #watchlist-moves-list { max-height: 320px; overflow-y: auto; }
.alerts-panel-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: var(--sp-4);
  margin-bottom: var(--sp-3);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--rule-soft);
}
.alerts-panel-title {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: var(--fs-body);
  letter-spacing: 0;
  color: var(--ink);
  margin: 0 0 var(--sp-1);
}
.alerts-panel-sub {
  font-family: var(--font-sans);
  font-style: normal;
  color: var(--ink-muted);
  font-size: var(--fs-xs);
  line-height: 1.5;
  margin: 0;
  max-width: 60ch;
}

.alerts-body {
  margin: 0;
  overflow: hidden;
  max-height: 0;
  transition: max-height 280ms cubic-bezier(0.4, 0, 0.2, 1);
}
.alerts-panel[aria-expanded="true"] .alerts-body {
  max-height: 1200px;
}

/* Rule grid — 3 equal columns at wide widths, stacks to 1-col on phone.
   Each column is an .alert-group with its own small-caps heading. */
.alerts-rules {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  column-gap: var(--sp-5);
  row-gap: 0;
  margin-bottom: var(--sp-4);
}
/* Group column — stacks its rules vertically */
.alert-group {
  display: flex;
  flex-direction: column;
}
/* Small-caps group heading */
.alert-group-head {
  font-family: var(--font-sans);
  font-size: var(--fs-caps);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  color: var(--ink-dim);
  padding-bottom: var(--sp-1);
  margin-bottom: var(--sp-1);
  border-bottom: 1px solid var(--rule-soft);
}
.alert-rule {
  display: flex; gap: var(--sp-2); align-items: center;
  padding: 7px var(--sp-1);
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 120ms ease;
}
.alert-rule:hover { background: var(--paper-deep); }
/* Accent-colored checkbox when checked */
.alert-rule input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border: 1.5px solid var(--rule-soft);
  border-radius: var(--r-xs);
  background: var(--paper);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  margin: 0; flex-shrink: 0;
  transition: background 120ms ease, border-color 120ms ease;
}
.alert-rule input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.alert-rule input[type="checkbox"]:checked::after {
  content: '✓';
  color: var(--paper);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
}
/* Active label: ink-soft when rule is enabled (checked state on parent label) */
.alert-rule:has(input:checked) .alert-rule-label { color: var(--ink); }
.alert-rule-label {
  flex: 1;
  color: var(--ink-dim);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
}
/* Chip/pill style for threshold selects */
.alert-rule select {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  font-size: var(--fs-2xs);
  font-weight: 600;
  color: var(--accent);
  background: rgba(43,74,122,0.08);
  border: 1px solid rgba(43,74,122,0.2);
  border-radius: var(--r-pill);
  padding: 2px var(--sp-2);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  text-align: center;
  min-width: 0;
  transition: background 120ms ease, border-color 120ms ease;
}
.alert-rule select:hover,
.alert-rule select:focus { outline: none; background: rgba(43,74,122,0.14); border-color: var(--accent); }

/* Muted hint showing threshold range after a signal-badge rule label */
.alert-rule-hint {
  font-size: var(--fs-2xs);
  color: var(--ink-muted);
  margin-left: var(--sp-1);
}

/* Match-mode selector — "Alert when: [any / all]" */
.alerts-match {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) 0 var(--sp-2);
  border-top: 1px solid var(--rule-soft);
  margin-top: var(--sp-1);
  font-size: var(--fs-xs);
  color: var(--ink-muted);
}
.alerts-match-label {
  white-space: nowrap;
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  color: var(--ink-dim);
}
.alerts-match select {
  font-size: var(--fs-xs);
  font-family: var(--font-sans);
  color: var(--accent);
  background: rgba(43,74,122,0.08);
  border: 1px solid rgba(43,74,122,0.2);
  border-radius: var(--r-pill);
  padding: 2px var(--sp-2);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
.alerts-match select:hover,
.alerts-match select:focus { outline: none; background: rgba(43,74,122,0.14); border-color: var(--accent); }

/* iOS-style master switch — ink track by default, hunter-green when on.
   Same pattern as the mocks: round white thumb sliding across. */
.alerts-master-switch {
  position: relative; display: inline-block;
  width: 44px; height: 26px;
  flex-shrink: 0;
}
.alerts-master-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch-track {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--rule-soft);
  border-radius: var(--r-pill);
  transition: background 160ms ease;
}
.switch-thumb {
  position: absolute; left: 2px; top: 2px;
  width: 22px; height: 22px;
  background: var(--paper);
  border-radius: 50%;
  transition: transform 160ms ease;
  box-shadow: 0 1px 2px rgba(26,22,16,0.25);
}
.alerts-master-switch input:checked + .switch-track { background: var(--bull); }
.alerts-master-switch input:checked + .switch-track .switch-thumb { transform: translateX(18px); }

/* Delivery sub-block — tight single row: label · status chip · button */
.alerts-delivery {
  padding-top: var(--sp-3);
  border-top: 1px solid var(--rule-soft);
  margin-top: var(--sp-1);
}
/* Tight row: small-caps label + FCM chip + Re-register button */
.alerts-delivery-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-bottom: var(--sp-2);
}
.alerts-delivery-label {
  font-family: var(--font-sans);
  font-size: var(--fs-caps);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  color: var(--ink-dim);
  white-space: nowrap;
}
.alerts-delivery-intro {
  font-family: var(--font-sans);
  font-style: normal;
  font-size: var(--fs-xs);
  color: var(--ink-muted);
  line-height: 1.5;
  margin: 0 0 var(--sp-1);
  max-width: 60ch;
}
.alerts-delivery-web-note {
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  line-height: 1.5;
  margin: var(--sp-2) 0 var(--sp-1);
  max-width: 60ch;
  background: rgba(43,74,122,0.08);
  border-left: 3px solid var(--accent, #1a56db);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  padding: var(--sp-2) var(--sp-3);
  color: var(--ink);
}
.fcm-status {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: var(--fs-2xs);
  padding: 2px var(--sp-2);
  border: 1px solid var(--rule-soft);
  background: var(--paper);
  border-radius: var(--r-pill);
}
.fcm-status-ok,
.fcm-status-success { color: var(--bull-ink); border-color: rgba(31,107,58,0.3); background: rgba(31,107,58,0.06); }
.fcm-status-error   { color: var(--bear); border-color: rgba(168,30,30,0.3); background: rgba(168,30,30,0.06); }
.fcm-status-pending { color: var(--ink-muted); border-style: dashed; }
.alerts-delivery-note {
  font-size: var(--fs-xs);
  color: var(--ink-muted);
  margin-top: var(--sp-2);
}

/* Alert history panel */
/* ── Movement alerts collapsible (under chart) ──────────────────── */
.dossier-alerts-collapse {
  border-top: 1px solid var(--rule-soft);
  border-bottom: 1px solid var(--rule-soft);
  margin: var(--sp-4) 0;
}
.dossier-alerts-summary {
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
  padding: var(--sp-3) 0;
  cursor: pointer;
  list-style: none;
  display: flex; align-items: center; gap: var(--sp-2);
}
.dossier-alerts-summary::-webkit-details-marker { display: none; }
.dossier-alerts-summary::before {
  content: '▶';
  font-size: 0.6em;
  transition: transform 0.15s;
}
.dossier-alerts-collapse[open] .dossier-alerts-summary::before { transform: rotate(90deg); }
.dossier-alerts-collapse .dac { padding: 0 0 var(--sp-4); }

/* ── Dossier alert history collapse ────────────────────────────── */
.dossier-alert-history-collapse {
  border-top: 1px solid var(--rule-soft);
  border-bottom: 1px solid var(--rule-soft);
  margin: var(--sp-4) 0;
}
.dossier-alert-history-summary {
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
  padding: var(--sp-3) 0;
  cursor: pointer;
  list-style: none;
  display: flex; align-items: center; gap: var(--sp-2);
}
.dossier-alert-history-summary::-webkit-details-marker { display: none; }
.dossier-alert-history-summary::before {
  content: '▶';
  font-size: 0.6em;
  transition: transform 0.15s;
}
.dossier-alert-history-collapse[open] .dossier-alert-history-summary::before { transform: rotate(90deg); }

/* ── Dossier per-ticker alert history (.dah-*) ───────────────────── */
.dah-list  { display: flex; flex-direction: column; gap: 5px; padding: var(--sp-2) 0 var(--sp-4); }
.dah-empty { color: var(--ink-muted); font-size: .85rem; margin: 0; font-style: italic; }
.dah-row   { display: grid; grid-template-columns: 3.6rem 7.5rem 1fr; gap: 8px; align-items: baseline; font-size: .82rem; }
.dah-date  { color: var(--ink-muted); white-space: nowrap; }
.dah-badge { padding: 1px 5px; border-radius: 3px; font-size: .72rem; font-weight: 600; white-space: nowrap; text-align: center; }
.dah-msg   { color: var(--ink-secondary); line-height: 1.35; }
/* kind badge colours */
.ak-move-dn { background: var(--bear-bg, #fde8e8); color: var(--bear-ink, #9b1c1c); }
.ak-move-up { background: var(--bull-bg, #dcfce7); color: var(--bull-ink, #14532d); }
.ak-signal  { background: #e8f0fe; color: #1a56db; }
.ak-earnings{ background: #fef3c7; color: #92400e; }
.ak-tier    { background: #f3e8ff; color: #6b21a8; }
.ak-target  { background: #fefce8; color: #78350f; }

/* ── Dossier per-ticker alert config (.dac) ─────────────────────── */
.dac { font-size: 0.78rem; }
.dac-msg { color: var(--ink-muted, #6b7280); font-style: italic; }
.dac-header {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}
.dac-badge {
  font-size: 0.68rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1px var(--sp-1);
  border-radius: var(--r-xs);
}
.dac-badge-default { background: var(--rule-soft, #e5e7eb); color: var(--ink-muted, #6b7280); }
.dac-badge-custom  { background: rgba(26,86,219,0.1); color: #1a56db; }
.dac-reset {
  background: none; border: none; padding: 0;
  font-size: 0.72rem; color: var(--ink-muted, #6b7280);
  text-decoration: underline; cursor: pointer;
}
.dac-reset:hover { color: var(--bear-ink, #9b1c1c); }
/* dac-rules / dac-rule replaced by shared .alert-group / .alert-rule */
.dac-sel {
  font-size: 0.72rem; font-family: var(--font-sans);
  border: none; border-bottom: 1px solid var(--rule, #d1d5db);
  background: transparent; color: var(--text, #111);
  padding: 0 2px; cursor: pointer;
}
.dac-sel:focus { outline: none; border-bottom-color: var(--accent, #1a56db); }
/* pill style for the threshold selects inside alert-rule */
.alert-rule .dac-sel {
  border: none;
  background: rgba(43,74,122,0.08);
  border-radius: var(--r-pill);
  padding: 1px 6px;
  font-size: 0.7rem; font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}
.alert-rule .dac-sel:hover,
.alert-rule .dac-sel:focus { background: rgba(43,74,122,0.14); outline: none; }
.dac-price-row { justify-content: space-between; }
.dac-price-input {
  width: 72px; text-align: right;
  font-size: 0.72rem; font-family: var(--font-sans);
  border: none; border-bottom: 1px solid var(--rule, #d1d5db);
  background: transparent; color: var(--accent);
  font-weight: 600; padding: 1px 2px;
  -moz-appearance: textfield;
}
.dac-price-input::-webkit-outer-spin-button,
.dac-price-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.dac-price-input:focus { outline: none; border-bottom-color: var(--accent, #1a56db); }
.dac-snooze {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  border-top: 1px solid var(--rule-soft, #e5e7eb);
  padding-top: var(--sp-2); margin-top: var(--sp-1);
}
.dac-snooze-lbl { font-size: 0.75rem; color: var(--ink-muted, #6b7280); white-space: nowrap; }
.dac-snooze-btn {
  font-size: 0.7rem; font-weight: 600;
  background: rgba(43,74,122,0.08); color: var(--accent);
  border: none; border-radius: var(--r-pill);
  padding: 2px 8px; cursor: pointer;
}
.dac-snooze-btn:hover { background: rgba(43,74,122,0.18); }
.dac-snooze-status { font-size: 0.75rem; color: var(--orange, #ea580c); font-weight: 500; }
.dac-snooze-clear { font-size: 0.72rem; color: var(--ink-muted, #6b7280); cursor: pointer; background: none; border: none; text-decoration: underline; }
.dac-match {
  display: flex; align-items: center; gap: var(--sp-2);
  border-top: 1px solid var(--rule-soft, #e5e7eb);
  padding-top: var(--sp-2); margin-top: var(--sp-1);
  color: var(--ink-muted, #6b7280);
}
.dac-match-lbl { white-space: nowrap; font-size: 0.75rem; }
.alerts-match-sel {
  font-size: 0.72rem; font-family: var(--font-sans);
  border: 1px solid rgba(43,74,122,0.2);
  background: rgba(43,74,122,0.06);
  border-radius: var(--r-pill);
  padding: 2px 8px; color: var(--accent);
  font-weight: 600; cursor: pointer;
}
.alerts-match-sel:focus { outline: none; border-color: var(--accent); }

/* ── Alert history feed ─────────────────────────────────────────── */
.alerts-history {
  margin-top: var(--sp-4);
  border-top: 1px solid var(--rule-soft);
  padding-top: var(--sp-3);
}
.alerts-history-header {
  font-family: var(--font-sans);
  font-size: var(--fs-caps);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tr-caps);
  color: var(--ink-dim);
  margin-bottom: var(--sp-2);
}
.alerts-history-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 220px;
  overflow-y: auto;
}
.alerts-history-empty {
  font-size: var(--fs-xs);
  color: var(--ink-muted);
  font-style: italic;
}
/* History item: colored 3px bar + message + time */
.alerts-history-item {
  display: grid;
  grid-template-columns: 6px 1fr auto;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  line-height: 1.4;
  padding: 4px 0;
  cursor: pointer; border-radius: var(--r-sm);
}
.alerts-history-item:hover { background: var(--paper-deep); }
.alerts-history-item:active { opacity: 0.7; }
/* Colored left-bar keyed off data-kind */
.alerts-history-bar {
  width: 3px;
  height: 1.1em;
  border-radius: 2px;
  background: var(--ink-muted);
  flex-shrink: 0;
}
/* Bear kinds */
.alerts-history-item[data-kind="daily_drop"] .alerts-history-bar,
.alerts-history-item[data-kind="weekly_drop"] .alerts-history-bar,
.alerts-history-item[data-kind="gap_down"] .alerts-history-bar,
.alerts-history-item[data-kind="new_52w_low"] .alerts-history-bar,
.alerts-history-item[data-kind="signal_near_low"] .alerts-history-bar { background: var(--bear); }
/* Bull kinds */
.alerts-history-item[data-kind="daily_rise"] .alerts-history-bar,
.alerts-history-item[data-kind="weekly_rise"] .alerts-history-bar,
.alerts-history-item[data-kind="gap_up"] .alerts-history-bar,
.alerts-history-item[data-kind="new_52w_high"] .alerts-history-bar { background: var(--bull); }
/* Warn kinds */
.alerts-history-item[data-kind="rsi_oversold"] .alerts-history-bar,
.alerts-history-item[data-kind="rsi_overbought"] .alerts-history-bar,
.alerts-history-item[data-kind="unusual_vol"] .alerts-history-bar { background: var(--warn); }
/* Accent kinds */
.alerts-history-item[data-kind="earnings_soon"] .alerts-history-bar { background: var(--accent); }
/* Signal kinds */
.alerts-history-item[data-kind="signal_stabilising"] .alerts-history-bar,
.alerts-history-item[data-kind="signal_base"] .alerts-history-bar { background: var(--bull-ink); }
.alerts-history-item[data-kind="signal_pullback"] .alerts-history-bar { background: var(--tier-pullback-fg); }

.alerts-history-msg  { color: var(--ink-soft); font-size: var(--fs-xs); }
.alerts-history-time { color: var(--ink-muted); white-space: nowrap; font-size: var(--fs-2xs); }

/* Phone: single-column rule groups */
@media (max-width: 760px) {
  .alerts-panel { padding: var(--sp-3) var(--sp-4); }
  .alerts-panel-header { flex-wrap: wrap; gap: var(--sp-3); }
  .alerts-rules { grid-template-columns: 1fr; gap: var(--sp-4) 0; }
  .alert-rule { padding: 10px var(--sp-2); }
  .alerts-delivery-row { flex-wrap: wrap; }
  /* Restore horizontal breathing room stripped by the settings override */
  .settings-body .alerts-panel { padding: 0 var(--sp-3); }
}

/* Custom presets container inside preset row */
.custom-presets-container { display: contents; }
.preset-title { display: inline-flex; align-items: center; gap: 4px; }
.preset-desc { display: none; }

/* Signal help link (ℹ) */
.signal-help {
  display: inline-block;
  font-size: 11px;
  color: var(--ink-dim);
  margin-left: 4px;
  text-decoration: none;
}
.signal-help:hover { color: var(--accent); }

/* Sensitivity table in drawer */
.sens-note { font-family: var(--font-sans); font-size: var(--fs-2xs); color: var(--ink-dim); font-weight: 400; text-transform: none; letter-spacing: 0; }

/* Tab icon placeholder — we're not using icons much in broadsheet, but
   keep this as a no-op so existing markup doesn't blow out layout. */
.tab-icon, [data-icon] { display: none; }

/* ═══════════════════════════════════════════════════════════════════
   16. PRINT
   ═══════════════════════════════════════════════════════════════════ */
/* ── Right rail modules ───────────────────────────────────────── */
.col.right { padding: var(--sp-5) var(--sp-4); overflow-y: auto; }

.rail-module { margin-bottom: var(--sp-5); }
.rail-module-kicker {
  font-family: var(--font-sans);
  font-size: var(--fs-caps);
  font-weight: 700;
  letter-spacing: var(--tr-caps);
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: var(--sp-1);
}
.rail-module-head {
  font-family: var(--font-serif);
  font-size: var(--fs-h1);
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 var(--sp-1);
  line-height: 1.2;
}
.rail-module-sub {
  font-family: var(--font-serif);
  font-size: var(--fs-sm);
  font-style: italic;
  color: var(--ink-dim);
  margin: 0 0 var(--sp-3);
}
.rail-rule {
  border: 0; border-top: 1px solid var(--rule-soft);
  margin: var(--sp-4) 0;
}

/* Watchlist mover rows */
.rr-row {
  display: grid; grid-template-columns: 1fr auto auto;
  gap: var(--sp-2);
  padding: 5px 0;
  border-bottom: 1px dotted var(--rule-hair);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
}
.rr-row:last-child { border-bottom: 0; }
.rr-row:hover { background: var(--paper-soft); }
.rr-ticker { font-weight: 700; color: var(--ink); }
.rr-price { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.rr-chg { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }
.rr-up   { color: var(--bull); }
.rr-down { color: var(--bear); }

/* Editorial callout */
.rr-callout {
  margin: var(--sp-3) 0 0;
  padding: var(--sp-2) var(--sp-3);
  border-left: 3px solid var(--accent);
  background: rgba(43,74,122,0.05);
  font-family: var(--font-serif);
  font-size: var(--fs-sm);
  font-style: italic;
  color: var(--ink-soft);
  line-height: 1.5;
}
.rr-callout strong { font-style: normal; color: var(--ink); }

/* Earnings rows */
.rr-earn-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 5px 0;
  border-bottom: 1px dotted var(--rule-hair);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
}
.rr-earn-row:last-child { border-bottom: 0; }
.rr-earn-row:hover { background: var(--paper-soft); }
.rr-earn-ticker { font-weight: 700; color: var(--ink); }
.rr-earn-date { color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.rr-earn-when { font-size: var(--fs-2xs); background: var(--paper-warm); padding: 1px 4px; border-radius: 2px; margin-left: 4px; }
.rr-empty { font-family: var(--font-serif); font-style: italic; color: var(--ink-muted); font-size: var(--fs-sm); margin: var(--sp-2) 0; }

/* Vehicle score card */
.vs-card { margin-bottom: var(--sp-4); }
.vs-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: var(--sp-2); padding-bottom: var(--sp-2);
  border-bottom: 2px solid var(--ink);
}
.vs-total { font-family: var(--font-mono); font-size: 22px; font-weight: 700; }
.vs-rec   { font-family: var(--font-sans); font-size: 14px; font-weight: 700; }
.vs-dims  { display: flex; flex-direction: column; gap: 6px; }
.vs-dim   { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; gap: 0 var(--sp-2); }
.vs-dim-label  { font-family: var(--font-sans); font-size: var(--fs-xs); color: var(--ink-soft); }
.vs-dim-score  { font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 700; color: var(--ink); text-align: right; }
.vs-dim-detail { font-family: var(--font-sans); font-size: 10px; color: var(--ink-muted); grid-column: 1 / -1; }

/* PASS rec class */
.rec-pass, td.rec-pass { color: var(--ink-dim); font-weight: 500; font-family: var(--font-sans); }

/* ── About / methodology page ──────────────────────────────────── */
.about-article {
  max-width: 680px;
  padding: var(--sp-6) 0 var(--sp-16);
}
.about-kicker {
  font-family: var(--font-sans);
  font-size: var(--fs-caps);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: var(--sp-3);
}
.about-h1 {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 32px;
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin: 0 0 var(--sp-2);
  color: var(--ink);
}
.about-lede {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-read);
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0 0 var(--sp-5);
  max-width: 64ch;
}
.about-section {
  margin: var(--sp-8) 0;
}
.about-section-h {
  font-family: var(--font-sans);
  font-size: var(--fs-caps);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--rule-soft);
  padding-bottom: var(--sp-2);
  margin-bottom: var(--sp-4);
}
.about-section p {
  font-size: var(--fs-body);
  line-height: 1.65;
  color: var(--ink-soft);
  margin: 0 0 var(--sp-3);
}
/* Signal legend (icon badge + description rows) */
.about-signal-group-label {
  font-family: var(--font-sans);
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: var(--sp-2);
}
.about-signal-legend {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.about-signal-row {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  font-size: var(--fs-sm);
  line-height: 1.5;
  color: var(--ink-soft);
}
.about-signal-row .badge {
  flex-shrink: 0;
  min-width: 100px;
}
/* Signal cards (legacy — kept for any remaining references) */
.about-signal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
  margin-top: var(--sp-2);
}
.about-signal-card {
  border: 1px solid var(--rule-soft);
  padding: var(--sp-4);
  background: var(--paper-soft);
}
.about-signal-card h4 {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink);
  margin-bottom: var(--sp-3);
}
.about-signal-card p {
  font-size: var(--fs-sm);
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0 0 var(--sp-2);
}
.about-tier-list {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.about-tier-list li {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  padding-left: var(--sp-3);
  border-left: 2px solid var(--rule-hair);
}
/* Vehicle score dims */
.about-dims {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}
.about-dim {
  display: flex;
  gap: var(--sp-3);
  align-items: baseline;
}
.about-dim-score {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--ink-muted);
  flex-shrink: 0;
  width: 36px;
}
.about-dim-body h5 {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: var(--fs-sm);
  margin: 0 0 2px;
  color: var(--ink);
}
.about-dim-body p {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  line-height: 1.5;
  margin: 0;
}
/* Vehicle bucket descriptions (LEAPS / STOCK / PASS) */
.about-vehicle-buckets {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin: var(--sp-4) 0 0;
  padding: 0;
}
.about-vehicle-bucket {
  display: flex;
  gap: var(--sp-3);
  align-items: baseline;
}
.about-vehicle-bucket dt {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--ink);
  min-width: 80px;
  flex-shrink: 0;
}
.about-vehicle-bucket dd {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  line-height: 1.5;
  margin: 0;
}
/* Workflow steps */
.about-steps {
  counter-reset: about-step;
  list-style: none;
  padding: 0;
  margin: var(--sp-4) 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.about-steps li {
  counter-increment: about-step;
  display: flex;
  gap: var(--sp-3);
  align-items: baseline;
  font-size: var(--fs-body);
  line-height: 1.6;
  color: var(--ink-soft);
}
.about-steps li::before {
  content: counter(about-step);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--paper);
  background: var(--ink);
  min-width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  top: -1px;
}
/* Risk note */
.about-risk {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  border-left: 3px solid var(--rule-soft);
  padding-left: var(--sp-4);
  line-height: 1.6;
  margin: 0;
}
/* Data sources table */
.about-sources {
  border-collapse: collapse;
  width: 100%;
  margin-top: var(--sp-4);
}
.about-sources td,
.about-sources th {
  border-bottom: 1px solid var(--rule-hair);
  padding: 6px var(--sp-2);
  font-size: var(--fs-sm);
  text-align: left;
}
.about-sources th {
  font-family: var(--font-sans);
  font-size: var(--fs-caps);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 600;
}
.about-sources td {
  color: var(--ink-soft);
}

@media (max-width: 640px) {
  .about-h1 { font-size: 26px; }
  .about-signal-grid { grid-template-columns: 1fr; }
  .about-article { padding-bottom: var(--sp-12); }
}

@media print {
  body { background: #fff; color: #000; }
  .masthead-auth, .section-nav, .toolbar, .presets, .preset-views-wrap, .page > .col.right, .page-footer, .drawer, .drawer-backdrop, .modal, .modal-backdrop { display: none !important; }
  .page { grid-template-columns: 1fr !important; }
  .page > .col + .col { border-left: 0; }
  body.signed-in .page-wrap { display: block; }
}

/* ══════════════════════════════════════════════════════════════════
   API SETTINGS PANEL
   ══════════════════════════════════════════════════════════════════ */

.api-settings-body {
  max-width: 680px;
  padding: var(--sp-6) 0 var(--sp-12);
}

.api-card {
  border-top: 1px solid var(--rule-soft);
  padding: var(--sp-5) 0;
}

.api-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
}

.api-card-head h4 {
  font-family: var(--font-serif);
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}

/* ── Key row ── */
.api-key-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.api-key-code {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.05em;
  background: var(--paper-deep);
  padding: 4px 8px;
  border-radius: var(--r-sm);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-soft);
}

.api-key-meta {
  margin-top: var(--sp-2);
  font-size: var(--fs-2xs);
  color: var(--ink-muted);
}

/* ── Slim action buttons ── */
.api-btn {
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  font-weight: 500;
  padding: 3px 10px;
  border: 1px solid var(--rule-soft);
  border-radius: var(--r-sm);
  background: var(--paper-soft);
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
}

.api-btn:hover {
  background: var(--paper-deep);
  color: var(--ink);
}

.api-btn-warn {
  border-color: rgba(168,30,30,0.25);
  color: var(--bear);
}

.api-btn-warn:hover {
  background: rgba(168,30,30,0.06);
  color: var(--bear-ink);
}

/* ── Usage ── */
.api-usage-row {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  padding: 2px 0;
}

.api-usage-label {
  color: var(--ink-dim);
}

.api-usage-bar-wrap {
  height: 4px;
  background: var(--rule-soft);
  border-radius: var(--r-pill);
  overflow: hidden;
  margin-top: var(--sp-3);
}

.api-usage-bar {
  height: 100%;
  background: var(--accent);
  border-radius: var(--r-pill);
  transition: width 0.4s ease;
  width: 0%;
}

.api-usage-bar.over-limit {
  background: var(--bear);
}

/* ── URL inputs ── */
.api-url-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) 0;
  font-size: var(--fs-xs);
  color: var(--ink-dim);
  border-bottom: 1px dotted var(--rule-hair);
}

.api-url-row:last-child { border-bottom: 0; }

.api-url-row span {
  width: 72px;
  flex-shrink: 0;
}

.api-url-input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  border: 1px solid var(--rule-soft);
  border-radius: var(--r-sm);
  padding: 3px 7px;
  background: var(--paper-soft);
  color: var(--ink);
  min-width: 0;
}

.api-url-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Client snippet tabs ── */
.api-client-tabs {
  display: flex;
  gap: var(--sp-1);
  flex-wrap: wrap;
  margin-bottom: var(--sp-3);
}

.api-client-tab {
  font-family: var(--font-sans);
  font-size: var(--fs-2xs);
  font-weight: 500;
  padding: 3px 10px;
  border: 1px solid var(--rule-soft);
  border-radius: var(--r-pill);
  background: var(--paper-soft);
  color: var(--ink-dim);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}

.api-client-tab.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

/* ── Snippet block ── */
.api-snippet-wrap {
  position: relative;
}

.api-snippet {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  line-height: 1.6;
  background: var(--paper-deep);
  border: 1px solid var(--rule-hair);
  border-radius: var(--r-sm);
  padding: var(--sp-4);
  margin: 0;
  white-space: pre;
  overflow-x: auto;
  color: var(--ink-soft);
}

.api-snippet-copy-btn {
  position: absolute;
  top: var(--sp-2);
  right: var(--sp-2);
}

.api-snippet-hint {
  margin-top: var(--sp-2);
  font-size: var(--fs-2xs);
  color: var(--ink-muted);
  line-height: 1.5;
}

/* ── Sign-out gate ── */
.api-signed-out-gate {
  padding: var(--sp-8) 0;
  color: var(--ink-dim);
  font-size: var(--fs-sm);
}

/* ── API Mobile ── */
@media (max-width: 640px) {
  .api-key-row { gap: var(--sp-1); }
  .api-client-tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  .api-snippet { font-size: 10px; }
  .api-url-row { flex-direction: column; align-items: flex-start; gap: var(--sp-1); }
  .api-url-row span { width: auto; }
  .api-url-input { width: 100%; }
}

/* ═══════════════════════════════════════════════════════════════════
   SETTINGS PANEL
   Full-width center column, no right rail — mirrors about/api layout.
   ═══════════════════════════════════════════════════════════════════ */

body.view-settings .page > .col.right { display: none; }
body.view-settings .page { grid-template-columns: 260px minmax(0, 1fr); }
/* Override: on mobile the 260px nav column must collapse so settings
   fills the full viewport, not just the remaining ~130px. This rule
   must live AFTER the desktop rule above to win the cascade. */
@media (max-width: 760px) {
  body.view-settings .page { grid-template-columns: 1fr; }
}

.settings-body {
  max-width: 900px;
  padding: var(--sp-6) 0 var(--sp-12);
}

.settings-section {
  margin-bottom: var(--sp-8);
}
.settings-section-header {
  padding-bottom: var(--sp-3);
  margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--rule-soft);
}
.settings-section-title {
  font-family: var(--font-sans);
  font-size: var(--fs-label);
  font-weight: 700;
  letter-spacing: var(--tr-caps);
  text-transform: uppercase;
  margin: 0;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-2) 0;
}
.settings-row-action {
  justify-content: flex-start;
  padding-top: var(--sp-3);
}
.settings-row-label {
  font-size: var(--fs-body);
  color: var(--text-secondary);
}
.settings-account-email {
  font-size: var(--fs-body);
  color: var(--text-primary);
}

/* Strip the card chrome from alerts-panel when it lives inside settings */
.settings-body .alerts-panel {
  border: 0;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  margin-bottom: var(--sp-8);
}

/* Hide the redundant sub-heading — the settings page header already says it */
.settings-body .alerts-panel-sub { display: none; }

/* ═══════════════════════════════════════════════════════════════════
   Alerts history page
   ═══════════════════════════════════════════════════════════════════ */

body.view-alerts .page > .col.right { display: none; }
body.view-alerts .page { grid-template-columns: 260px minmax(0, 1fr); }
@media (max-width: 760px) {
  body.view-alerts .page { grid-template-columns: 1fr; }
}

.alerts-page-body {
  max-width: 900px;
  padding: var(--sp-4) 0 var(--sp-12);
}

.ap-filter-bar {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: var(--sp-5);
}

.ap-symbol-input {
  flex: 0 0 auto;
  width: 140px;
  padding: 6px var(--sp-3);
  border: 1px solid var(--rule-soft);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-primary);
  font-size: var(--fs-body);
}
.ap-symbol-input:focus { outline: none; border-color: var(--accent); }

.ap-kind-select {
  flex: 0 0 auto;
  padding: 6px var(--sp-3);
  border: 1px solid var(--rule-soft);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-primary);
  font-size: var(--fs-body);
  cursor: pointer;
}
.ap-kind-select:focus { outline: none; border-color: var(--accent); }

.ap-sort-btn { margin-left: auto; }
@media (max-width: 760px) { .ap-sort-btn { margin-left: 0; } }

.alerts-page-list { display: flex; flex-direction: column; gap: 2px; }

.ap-empty {
  padding: var(--sp-8) 0;
  text-align: center;
  color: var(--text-tertiary);
  font-size: var(--fs-body);
}

.ap-row {
  display: grid;
  grid-template-columns: 100px 60px auto 1fr;
  gap: var(--sp-3);
  align-items: center;
  padding: var(--sp-3) var(--sp-2);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
}
.ap-row:hover { background: var(--surface-hover); }
.ap-row:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

@media (max-width: 760px) {
  .ap-row {
    grid-template-columns: auto auto 1fr;
    grid-template-rows: auto auto;
  }
  .ap-date  { grid-column: 1; grid-row: 1; font-size: var(--fs-label); }
  .ap-ticker { grid-column: 2; grid-row: 1; }
  .ap-badge { grid-column: 3; grid-row: 1; justify-self: end; }
  .ap-msg   { grid-column: 1 / -1; grid-row: 2; }
}

.ap-date {
  font-size: var(--fs-label);
  color: var(--text-tertiary);
  white-space: nowrap;
}
.ap-ticker {
  font-family: var(--font-mono);
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--text-primary);
}
.ap-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: var(--fs-label);
  font-weight: 600;
  white-space: nowrap;
}
.ap-msg {
  font-size: var(--fs-body);
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
