/* ─────────────────────────────────────────────────────────────
   BursaEdge app — CD-83 "Blue Hour" (Dark first paint + Light "daylight").
   Values come only from docs/brand-kit/palette-v2-blue-hour.md.
   Lanes: gold = brand + Radar Score; cobalt = interactive; green/red = market
   direction; --c-data-1..6 = kinds of things (charts, categories).
   ───────────────────────────────────────────────────────────── */
@import url("/brand/palette.css");

:root {
  color-scheme: dark;
  /* Type system: one family everywhere (Instrument Sans, tabular figures). */
  --font-sans: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-features: "tnum";

  /* Type roles (page CSS consumes these; never restate sizes) */
  --t-title: 500 24px/1.2 var(--font-display);
  --t-section: 600 15px/1.35 var(--font-sans);
  --t-label: 500 12px/1.35 var(--font-sans);
  --t-kpi: 500 28px/1.1 var(--font-sans);
  --t-figure: 500 13px/1.4 var(--font-sans);
  --t-body: 400 14px/1.5 var(--font-sans);
  --t-small: 400 13px/1.45 var(--font-sans);
  --t-caption: 400 12px/1.4 var(--font-sans);
  --t-th: 500 12px/1.3 var(--font-sans);
  --t-td: 400 13px/1.4 var(--font-sans);
  --t-btn: 500 14px/1 var(--font-sans);
  --t-input: 400 14px/1.4 var(--font-sans);

  /* Spacing */
  --sp-0: 4px;
  --sp-1: 8px;
  --sp-2: 12px;
  --sp-3: 16px;
  --sp-4: 24px;
  --sp-5: 32px;
  --sp-6: 48px;
  --sp-7: 64px;

  /* Radii (palette-v2 §6): cards 16/12, controls fully rounded, tags 7, nav 10. */
  --r-card: 16px;
  --r-card-sm: 12px;
  --r-pill: 999px;
  --r-btn: 999px;
  --r-input: 999px;
  --r-chip: 7px;
  --r-nav: 10px;

  /* Motion tokens (--dur-*, --ease-*, --reveal-shift, --stagger) live in /shared/motion.css. */

  /* Layout */
  --sidebar-w: 232px;
  --rail-w: 320px;
  --shell-header-h: 64px;
  --topbar-h: var(--shell-header-h);
  --content-max: 1380px;
  --tabbar-h: 0px;

  /* Rule: opens a section across its full width. */
  --c-rule: var(--c-border-strong);

  /* Blue Hour (dark) is the first paint. */
  --c-bg: #13131c;
  --c-surface: #1c1c28;
  --c-surface-2: #222230;
  --c-surface-hover: #232333;

  --c-border: #2c2c3d;
  --c-border-warm: rgba(217,169,63,.32);
  --c-border-sky: rgba(82,102,235,.42);
  --c-border-soft: #272736;
  --c-border-strong: #3b3b51;
  --c-border-focus: var(--c-accent-line);

  --c-text: #ededf3;
  --c-text-muted: #9d9db0;
  --c-text-label: #8b8ba0;
  --c-text-inverse: #ffffff;

  /* Market direction only (green/red) */
  --c-up: #3DD68C;
  --c-down: #FF6B6B;
  --c-up-text: var(--c-up);
  --c-down-text: var(--c-down);
  --c-up-bg: rgba(61,214,140,.13);
  --c-down-bg: rgba(255,107,107,.13);
  --c-up-bg-soft: rgba(61,214,140,.06);
  --c-down-bg-soft: rgba(255,107,107,.06);

  /* Interactive (cobalt) */
  --c-accent: #5266eb;
  --c-accent-hover: #4658CA;
  --c-accent-soft: rgba(82,102,235,.17);
  --c-accent-text: var(--c-link);
  --c-accent-ink: #ffffff;
  --c-accent-line: #7d8cff;
  --c-link: #AEB8FF;
  --c-focus-ring: rgba(82,102,235,.35);

  /* Brand gold (G1) + Radar Score text shade. Never buttons, links or chart series. */
  --c-gold: var(--be-color-primary);
  --c-gold-bright: var(--be-color-primary);
  --c-gold-ink: var(--c-score-text);
  --c-gold-soft: rgba(217,169,63,.12);
  --c-gold-line: rgba(217,169,63,.32);
  --c-score-text: #E9C46A;

  /* Data hues: kinds of things (chart series, sector, category). Same order in both themes. */
  --c-data-1: #13D1CD;
  --c-data-2: #BCA7FF;
  --c-data-3: #FF9D3B;
  --c-data-4: #FE8DC3;
  --c-data-5: #60C2FE;
  --c-data-6: #C3B793;

  /* Selected pill / segment / tab (CD-83 lane 2: cobalt = selected). Phase 1c replaces the inverted text-colour pill. */
  --c-pill-on-bg: var(--c-accent);
  --c-pill-on-text: var(--c-accent-ink);
  --c-pill-on-border: var(--c-accent);

  /* Caution / flag (ember) and Shariah (teal) tags */
  --c-warning: #F0B884;
  --c-warning-soft: rgba(227,155,91,.12);
  --c-warning-bg: var(--c-warning-soft);
  --c-sc-bg: rgba(54,194,190,.12);
  --c-sc-text: #6FDCD8;
  --c-sc-border: rgba(54,194,190,.35);

  /* Legacy wash aliases: every consumer paints a flat surface. */
  --wash-cool: none;
  --wash-sky: none;
  --wash-warm: none;
  --wash-mint: none;

  /* Chrome surfaces */
  --c-top-bg: rgba(19,19,28,.82);
  --c-th-bg: #20202d;
  --c-input-bg: #1a1a26;
  --c-tabbar-bg: rgba(15,15,23,.94);
  --c-scrim: rgba(0,0,0,.5);
  --c-glow-page: rgba(82,102,235,.16);
  --c-glow-hero: rgba(82,102,235,.34);
  --bg-page: radial-gradient(1200px 600px at 75% -200px, var(--c-glow-page), transparent 70%), var(--c-bg);

  /* Skeleton shimmer image (page sheets reference the token, never a gradient literal) */
  --skeleton-shimmer: linear-gradient(90deg, var(--skeleton-base) 25%, var(--skeleton-shine) 50%, var(--skeleton-base) 75%);

  /* Depth: cards are cut out (border + inner highlight + soft drop shadow). */
  --shadow-hairline: inset 0 1px 0 rgba(255,255,255,.045);
  --shadow-card:
    inset 0 1px 0 rgba(255,255,255,.045),
    0 18px 40px -22px rgba(0,0,0,.8);
  --shadow-card-hover: 0 20px 40px -20px rgba(82,102,235,.45);
  --shadow-popover:
    0 24px 70px rgba(0,0,0,.55),
    0 0 0 1px rgba(255,255,255,.04);
  --shadow-btn: 0 8px 22px -8px rgba(82,102,235,.85), inset 0 1px 0 rgba(255,255,255,.18);

  /* Skeleton shimmer */
  --skeleton-base: var(--c-surface-2);
  --skeleton-shine: var(--c-border);

  /* Market-index / equity chart stroke: a data hue, not cobalt. */
  --klci-stroke: var(--c-data-1);
  --klci-stroke-soft: rgba(54,194,190,.18);

  /* Sidebar */
  --sidebar-grad: #0f0f17;
  --sidebar-ink: #ededf3;
  --sidebar-muted: #8b8ba0;
  --sidebar-label: #8b8ba0;
  --sidebar-line: #22222f;
  --sidebar-panel: #0f0f17;
  --sidebar-hover: #1a1a26;
  --sidebar-on-bg: linear-gradient(90deg, rgba(82,102,235,.28), rgba(82,102,235,.06));
  --sidebar-on-ring: inset 2px 0 0 var(--c-accent-line);

  /* Backward-compat aliases (auth pages reference old names) */
  --font: var(--font-sans);
  --c-accent-dim: var(--c-accent-hover);
  --c-danger: var(--c-down);
}

[data-theme="light"] {
  color-scheme: light;
  --c-bg: #f5f5f8;
  --c-surface: #ffffff;
  --c-surface-2: #f7f7fb;
  --c-surface-hover: #f3f4fb;

  --c-border: #e2e3ed;
  --c-border-warm: rgba(217,169,63,.28);
  --c-border-sky: rgba(82,102,235,.28);
  --c-border-soft: #ececf3;
  --c-border-strong: #c3c3cc;
  --c-border-focus: var(--c-accent-line);

  --c-text: #171721;
  --c-text-muted: #5f5f70;
  --c-text-label: #696979;
  --c-text-inverse: #ffffff;

  --c-up: #0B7744;
  --c-down: #BF2934;
  --c-up-text: var(--c-up);
  --c-down-text: var(--c-down);
  --c-up-bg: #E3F4EA;
  --c-down-bg: #FCE6E7;
  --c-up-bg-soft: rgba(11,119,68,.06);
  --c-down-bg-soft: rgba(191,41,52,.06);

  --c-accent: #5266eb;
  --c-accent-hover: #4658CA;
  --c-accent-soft: #eceffd;
  --c-accent-ink: #ffffff;
  --c-accent-line: #5266eb;
  --c-link: #3d50d6;
  --c-focus-ring: rgba(82,102,235,.22);

  --c-gold-soft: rgba(217,169,63,.12);
  --c-gold-line: rgba(217,169,63,.34);
  --c-score-text: #6B4E0E;

  --c-data-1: #028380;
  --c-data-2: #795AC4;
  --c-data-3: #A55D05;
  --c-data-4: #B3417D;
  --c-data-5: #007AB0;
  --c-data-6: #7B7153;

  /* Selected pill / segment / tab (CD-83 lane 2: cobalt = selected). Phase 1c replaces the inverted text-colour pill. */
  --c-pill-on-bg: var(--c-accent);
  --c-pill-on-text: var(--c-accent-ink);
  --c-pill-on-border: var(--c-accent);

  /* Caution / flag (ember) and Shariah (teal) tags */
  --c-warning: #8A4A1C;
  --c-warning-soft: #FCEBDD;
  --c-sc-bg: #E0F1F0;
  --c-sc-text: #16696A;
  --c-sc-border: #B7DEDC;

  --c-top-bg: rgba(245,245,248,.85);
  --c-th-bg: #f7f7fb;
  --c-input-bg: #ffffff;
  --c-tabbar-bg: rgba(255,255,255,.94);
  --c-scrim: rgba(0,0,0,.5);
  --c-glow-page: rgba(82,102,235,.10);
  --c-glow-hero: rgba(82,102,235,.14);

  --shadow-hairline: 0 1px 2px rgba(23,23,33,.04);
  --shadow-card: 0 1px 2px rgba(23,23,33,.04), 0 12px 32px -20px rgba(23,23,33,.25);
  --shadow-card-hover: 0 20px 40px -24px rgba(82,102,235,.45);
  --shadow-popover: 0 12px 32px rgba(23,23,33,.12), 0 0 0 1px rgba(23,23,33,.06);
  --shadow-btn: 0 8px 20px -10px rgba(82,102,235,.7);

  --skeleton-base: var(--c-border-soft);
  --skeleton-shine: var(--c-surface-2);

  --klci-stroke-soft: rgba(31,138,138,.18);

  --sidebar-grad: #ededf3;
  --sidebar-ink: #171721;
  --sidebar-muted: #696979;
  --sidebar-label: #696979;
  --sidebar-line: #e2e3ed;
  --sidebar-panel: #ffffff;
  --sidebar-hover: #e2e3ed;
  --sidebar-on-bg: #ffffff;
  --sidebar-on-ring: inset 2px 0 0 var(--c-accent-line), 0 1px 3px rgba(23,23,33,.08);
}

/* ── Reset ──────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Hero / first-KPI border (palette-v2 s6: #34345a dark / #d9dcf3 light). Derived from the themed border + accent tokens so one rule serves both themes
   (cobalt only as a 12% tint; the raw cobalt border token is for interactive elements). */
:root { --c-border-hero: color-mix(in srgb, var(--c-accent) 12%, var(--c-border)); }

/* ── Global keyboard focus ring ─────────────────────────────── */

:focus-visible {
  outline: 2px solid var(--c-border-focus);
  outline-offset: 2px;
  border-radius: inherit;
}

html {
  -webkit-tap-highlight-color: transparent; /* phones flash a rectangle on tap; rounded controls carry their own :active/:focus-visible states */
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

h1, h2 {
  font-family: var(--font-display);
  font-weight: 600;
}
h1 { font-weight: 500; letter-spacing: .005em; }
h3 {
  font-family: var(--font-sans);
  font-weight: 600;
}

body {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.55;
  color: var(--c-text);
  background: var(--bg-page);
  background-attachment: fixed;
  font-feature-settings: var(--font-features);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

/* Blue Hour shell (CD-83): Dark and Light run the same rules; every surface reads a token. */
.brand-wordmark span { color: var(--c-gold); }
.main-content { background: transparent; }
.card, .rail-card, .greeting-card, .metric-card, .tile { background: var(--c-surface); border-color: var(--c-border); box-shadow: var(--shadow-card); }
.card-title, .greeting { font-family: var(--font-display); letter-spacing: -.02em; }
.metric-value { font-family: var(--font-sans); letter-spacing: normal; font-variant-numeric: tabular-nums; }
.greeting { font: var(--t-title); letter-spacing: .005em; }
.tile-featured { border-color: var(--c-gold-line, var(--c-border-warm)); }
.tile-icon { color: var(--c-accent-text); background: var(--c-accent-soft); }
.tile-badge.badge-live { color: var(--c-text-label); background: var(--c-surface-hover); border-color: var(--c-border); }
.stock-table, .jv-table, .results-table { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.stock-table thead th, .jv-table thead th, .results-table th { color: var(--c-text-label); border-bottom-color: var(--c-border); }
.stock-table td, .jv-table td, .results-table td { border-bottom-color: var(--c-border-soft); }
.btn-primary, .button-primary, .jv-btn-primary { background: var(--c-accent); border-color: var(--c-accent); color: var(--c-text-inverse); }
.btn-primary, .button-primary, .jv-btn-primary { box-shadow: var(--shadow-btn); }
.btn-primary:hover, .button-primary:hover, .jv-btn-primary:hover { background: var(--c-accent-hover); }
.sidebar-brand { min-height: var(--shell-header-h); padding: 0 var(--sp-3); border-bottom: 1px solid var(--sidebar-line); }
.num, .currency, .score { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.ledger-pulse, .ledger-workbench { margin-bottom: var(--sp-5); }
.ledger-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.ledger-section-head h2 { font-family: var(--font-display); font-size: 1.35rem; font-weight: 500; }
.ledger-section-head a { color: var(--c-accent-text); font-size: .8rem; }
.ledger-kicker { color: var(--c-text-label); font: var(--t-label); letter-spacing: 0; text-transform: none; }
.ledger-status { color: var(--c-text-label); font-size: .76rem; }
.ledger-pulse-grid { display: grid; grid-template-columns: minmax(210px, 1.6fr) repeat(4, minmax(100px, 1fr)); gap: 1px; background: var(--c-border); border: 1px solid var(--c-border); border-radius: var(--r-card); overflow: hidden; box-shadow: var(--shadow-card); }
.ledger-radar, .ledger-pulse-item, .ledger-workbench-card { background: var(--c-surface); padding: var(--sp-4); }
.ledger-radar { background: var(--c-surface); border-left: 1px solid var(--c-border); }
.ledger-radar .ledger-kicker::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 8px; vertical-align: 1px; background: var(--c-gold); }
.ledger-radar strong { display: inline-block; font: var(--t-kpi); font-feature-settings: var(--font-features); font-variant-numeric: tabular-nums; letter-spacing: -.01em; color: var(--c-score-text); margin: var(--sp-2) 4px var(--sp-2) 0; }
.ledger-radar > span:not(.ledger-kicker) { color: var(--c-text-muted); font: var(--t-figure); font-feature-settings: var(--font-features); }
.ledger-radar p, .ledger-workbench-card p { color: var(--c-text-muted); font-size: .8rem; }
.ledger-pulse-item { display: grid; gap: var(--sp-2); align-content: center; }
.ledger-pulse-item span { color: var(--c-text-label); font-size: .74rem; }
.ledger-pulse-item strong { font-family: var(--font-sans); font-variant-numeric: tabular-nums; font-size: 1.8rem; font-weight: 500; }
.ledger-workbench { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); }
.ledger-workbench-card { border: 1px solid var(--c-border); border-radius: var(--r-card-sm); min-height: 150px; box-shadow: var(--shadow-card); }
.ledger-money, .ledger-streak { display: block; margin-bottom: var(--sp-2); color: var(--c-text); font-family: var(--font-sans); font-variant-numeric: tabular-nums; font-size: 1.65rem; font-weight: 500; }
.ledger-mono { font-family: var(--font-mono); font-size: .72rem !important; line-height: 1.8; }

@media (max-width: 760px) {
  .sidebar-brand { min-height: 64px; }
  .greeting { font-size: 2.1rem; }
  .ledger-pulse-grid, .ledger-workbench { grid-template-columns: 1fr; }
  .ledger-pulse-grid { gap: 1px; }
}

a {
  color: var(--c-accent-text);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}
a:hover { color: var(--c-link); text-decoration: underline; }

button { font-family: inherit; }

:where([hidden]:not([hidden="until-found"])) {
  display: none !important;
}

.hidden { display: none !important; }

/* Numerics: tabular alignment everywhere */
.num,
.tabular {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* Section labels (sentence case, label color) */
.section-label {
  font: var(--t-label);
  letter-spacing: 0;
  text-transform: none;
  color: var(--c-text-label);
}

/* ── Logo mark ──────────────────────────────────────────────── */

.logo-mark {
  width: 30px;
  height: 30px;
  background: url("/brand/be-icon.png") center / contain no-repeat;
  display: inline-flex;
  flex-shrink: 0;
  /* hide the legacy "B" text fallback; the monogram image is the mark now */
  color: transparent;
  font-size: 0;
}

.brand-wordmark {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--c-text);
  line-height: 1.25;
}
.brand-wordmark-sub {
  font-style: normal;
  color: var(--c-text-muted);
  font-weight: 500;
  font-size: 0.82rem;
  margin-left: 4px;
}

/* ── Buttons ────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 18px;
  /* Frozen B2 guard: 44px touch target (palette-v2 draws 38px; the guard wins, see CD-83 report). */
  min-height: 44px;
  border-radius: var(--r-btn);
  font-size: 0.88rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
  text-decoration: none;
  white-space: nowrap;
}
/* Press: scale in at --dur-instant, release at --dur-fast (SPEC v2 §2.4). */
.btn:active { transform: scale(.98); transition-duration: var(--dur-instant); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--c-accent);
  color: var(--c-text-inverse);
  border-color: var(--c-accent);
}
.btn-primary:hover { background: var(--c-accent-hover); border-color: var(--c-accent-hover); color: var(--c-text-inverse); text-decoration: none; }

.btn-secondary {
  background: var(--c-surface);
  color: var(--c-text);
  border-color: var(--c-border-strong);
}
.btn-secondary:hover { background: var(--c-surface-hover); border-color: var(--c-text-label); text-decoration: none; }

.btn-ghost {
  background: transparent;
  color: var(--c-text-muted);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--c-surface-hover); color: var(--c-text); text-decoration: none; }

.btn-logout {
  background: transparent;
  border: 1px solid var(--c-border);
  color: var(--c-text-muted);
  padding: 7px 14px;
  border-radius: var(--r-btn);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
  /* Fix 5: guarantee ≥44px touch height on all viewports */
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.btn-logout:hover {
  border-color: var(--c-border-strong);
  color: var(--c-text);
  background: var(--c-surface-hover);
}

/* ── Inputs ─────────────────────────────────────────────────── */

.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  background: var(--c-input-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--r-input);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--c-text);
  font-feature-settings: var(--font-features);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.input::placeholder { color: var(--c-text-label); }
.input:focus {
  border-color: var(--c-border-focus);
  box-shadow: 0 0 0 3px var(--c-focus-ring);
}
.input:focus:not(:focus-visible) { outline: none; }

.label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--c-text);
  margin-bottom: 6px;
  text-align: left;
}

/* ── Auth pages ─────────────────────────────────────────────── */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--sp-5) var(--sp-3);
  /* Mockup page glow (top right) plus a second one behind the card. */
  background:
    radial-gradient(820px 520px at 50% 34%, var(--c-glow-page), transparent 70%),
    var(--bg-page);
  background-attachment: fixed;
}

.auth-container { width: 100%; max-width: 440px; }

/* The auth card is a mockup card: surface, sky border, 16px radius, card shadow, soft cobalt glow at the top. */
.auth-card {
  background:
    radial-gradient(110% 80% at 50% 0%, color-mix(in srgb, var(--c-glow-hero) 55%, transparent), transparent 62%),
    var(--c-surface);
  border: 1px solid var(--c-border-sky);
  border-radius: var(--r-card);
  padding: var(--sp-5) var(--sp-4) var(--sp-4);
  text-align: center;
  box-shadow: var(--shadow-card);
}

/* The SC footer sits under the card as quiet text, not as a grey slab. */
.auth-container .sc-footer {
  margin-top: var(--sp-3);
  padding: var(--sp-2) var(--sp-1) 0;
  background: transparent;
  border-top: 0;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--sp-4);
}
.brand-name {
  display: block;
  font: 600 26px/1.15 var(--font-display);
  font-optical-sizing: auto;
  letter-spacing: -0.02em;
  color: var(--c-text);
}
/* Wordmark: the gold span is the one brand mark (same as the sidebar). */
.brand-name span { color: var(--c-gold); }
.brand-tag {
  font: var(--t-label);
  color: var(--c-text-label);
  text-transform: none;
  letter-spacing: 0;
}
.brand-logo {
  display: block;
  width: 56px;
  height: auto;
  margin-bottom: 2px;
}

.status-message { padding: var(--sp-3) 0; }
.status-message h2 {
  font: var(--t-section);
  letter-spacing: 0;
  color: var(--c-text);
  margin-bottom: var(--sp-1);
}
.status-message p {
  font: var(--t-body);
  color: var(--c-text-muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--c-border);
  border-top-color: var(--c-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto var(--sp-3);
}
.spinner--spaced { margin-top: 16px; }
@keyframes spin { to { transform: rotate(360deg); } }

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  text-align: left;
}
.auth-actions {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}
.auth-foot {
  margin-top: var(--sp-4);
  font-size: 0.82rem;
  color: var(--c-text-muted);
}

/* Auth form-* helpers (shared by login/signup/forgot/reset/confirm-email) */
.form-group {
  text-align: left;
  margin-bottom: var(--sp-2);
}
.form-label {
  display: block;
  font: var(--t-label);
  color: var(--c-text-label);
  margin-bottom: 8px;
  letter-spacing: 0;
}
.form-input {
  width: 100%;
  background: var(--c-input-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--r-input);
  color: var(--c-text);
  font: var(--t-input);
  font-feature-settings: var(--font-features);
  padding: 0 16px;
  height: 44px;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.form-input:focus {
  border-color: var(--c-border-focus);
  box-shadow: 0 0 0 3px var(--c-focus-ring);
}
.form-input:focus:not(:focus-visible) { outline: none; }
.form-input:read-only { background: var(--c-surface-2); color: var(--c-text-muted); cursor: default; }
.form-input::placeholder { color: var(--c-text-label); }
/* --r-input is fully rounded; a multi-line field keeps the small card radius. */
textarea, textarea.input, textarea.form-input, select[multiple] { border-radius: var(--r-card-sm); }

.pw-wrap { position: relative; }
.pw-wrap .form-input { padding-right: 48px; }
.pw-toggle {
  position: absolute; right: 0; top: 0;
  width: 44px; height: 44px;
  border-radius: var(--r-btn);
  background: none; border: none;
  cursor: pointer;
  color: var(--c-text-label);
  display: flex; align-items: center; justify-content: center;
  transition: color var(--dur-fast) var(--ease-out);
}
.pw-toggle:hover { color: var(--c-text); }

.btn-submit {
  width: 100%;
  height: 44px;
  background: var(--c-accent);
  color: var(--c-text-inverse);
  border: 1px solid var(--c-accent);
  border-radius: var(--r-btn);
  box-shadow: var(--shadow-btn);
  font: var(--t-btn);
  cursor: pointer;
  margin-top: var(--sp-3);
  padding: 0 16px;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), opacity var(--dur-fast) var(--ease-out);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none;
}
.btn-submit:hover:not(:disabled) {
  background: var(--c-accent-hover);
  border-color: var(--c-accent-hover);
  color: var(--c-text-inverse); text-decoration: none;
}
.btn-submit:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-submit[hidden] { display: none; }
/* Secondary treatment (Continue with Google): surface + line + text; blue stays on the one primary. */
.btn-submit--secondary {
  background: var(--c-surface);
  color: var(--c-text);
  border-color: var(--c-border);
  margin-top: var(--sp-2);
  box-shadow: none;
}
.btn-submit--secondary:hover:not(:disabled) {
  background: var(--c-surface-hover);
  border-color: var(--c-border-strong);
  color: var(--c-text);
}

.spinner-sm {
  width: 16px; height: 16px;
  border: 2px solid color-mix(in srgb, var(--c-bg) 25%, transparent);
  border-top-color: var(--c-text-inverse);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.spinner-lg {
  width: 36px; height: 36px;
  border: 3px solid var(--c-accent-soft);
  border-top-color: var(--c-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: var(--sp-3) auto var(--sp-2);
}

.form-error {
  margin-top: var(--sp-2);
  font: var(--t-small);
  color: var(--c-down-text);
  min-height: 20px;
  text-align: center;
}
.form-error:not(:empty) {
  background: var(--c-down-bg);
  border-radius: var(--r-chip);
  padding: var(--sp-1) var(--sp-2);
}

/* In-app browser hint above the Google button; tokens are theme-scoped. */
.auth-hint {
  margin-top: var(--sp-2);
  padding: var(--sp-1) var(--sp-2);
  font: var(--t-small);
  color: var(--c-text);
  text-align: center;
  background: var(--c-warning-bg);
  border: 1px solid var(--c-border-warm);
  border-radius: var(--r-chip);
}
.auth-hint a { color: var(--c-accent-text); font-weight: 500; text-decoration: underline; }

.auth-link {
  display: block;
  text-align: center;
  font: var(--t-small);
  color: var(--c-text-muted);
  margin-top: var(--sp-3);
}
.auth-link a { color: var(--c-accent-text); font-weight: 500; display: inline-flex; align-items: center; min-height: 44px; padding: 0 2px; }
.auth-link a:hover { text-decoration: underline; }
/* The "or" divider between the primary and the secondary sign-in. */
.auth-or {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font: var(--t-caption);
  color: var(--c-text-label);
  margin-top: var(--sp-2);
}
.auth-or::before,
.auth-or::after { content: ""; flex: 1; height: 1px; background: var(--c-border-soft); }

.helper-text {
  font: var(--t-body);
  color: var(--c-text-muted);
  margin-bottom: var(--sp-3);
  text-align: center;
}

.consent-note {
  text-align: center;
  font: var(--t-caption);
  color: var(--c-text-muted);
  margin-top: var(--sp-2);
}
.consent-note a { color: var(--c-accent-text); font-weight: 500; }

.divider {
  height: 1px;
  background: var(--c-border-soft);
  margin: var(--sp-3) 0 var(--sp-2);
}

.brand-tagline {
  display: block;
  font: var(--t-small);
  color: var(--c-text-muted);
  margin-top: 4px;
  letter-spacing: 0;
}

.validating {
  text-align: center;
  padding: var(--sp-3) 0;
  color: var(--c-text-muted);
  font-size: 0.88rem;
}

@keyframes auth-card-in {
  from { opacity: 0; transform: translateY(var(--reveal-shift)); }
  to   { opacity: 1; transform: translateY(0); }
}
.auth-card { animation: auth-card-in var(--dur-reveal) var(--ease-out) both; }
@media (prefers-reduced-motion: reduce) {
  .auth-card { animation: none; }
}

/* ── Skip link (a11y) ───────────────────────────────────────── */

.skip-link {
  position: absolute;
  top: -40px;
  left: 8px;
  z-index: 100;
  padding: 8px 16px;
  background: var(--c-accent);
  color: var(--c-text-inverse);
  border-radius: var(--r-card-sm);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
}
.skip-link:focus,
.skip-link:focus-visible {
  top: 8px;
  outline: 2px solid var(--c-text-inverse);
  outline-offset: 2px;
}

/* ── App layout (3-column) ──────────────────────────────────── */

.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* Fix: grid children default to min-width:auto which causes horizontal overflow.
   main-column must be constrained so it never exceeds its 1fr track width. */
.main-column {
  min-width: 0;
}

@media (min-width: 1280px) {
  .app-layout-with-rail {
    grid-template-columns: var(--sidebar-w) 1fr var(--rail-w);
  }
}

/* ── Sidebar ────────────────────────────────────────────────── */

.sidebar {
  background: var(--sidebar-grad);
  border-right: 1px solid var(--sidebar-line);
  display: flex;
  flex-direction: column;
  padding: 0 var(--sp-2) var(--sp-3);
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  margin-bottom: var(--sp-1);
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--sp-2) 0;
}

.sidebar-section + .sidebar-section {
  border-top: 1px solid var(--sidebar-line);
}

.sidebar-section-label {
  font: var(--t-label);
  letter-spacing: 0;
  text-transform: none;
  color: var(--sidebar-label);
  padding: 6px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-nav);
  min-height: 44px;
  font-size: 0.88rem;
  font-weight: 400;
  color: color-mix(in srgb, var(--sidebar-ink) 82%, transparent);
  text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
  position: relative;
}
.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-ink);
  text-decoration: none;
}
.nav-item .nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: currentColor;
  stroke-width: 1.8;
}
.nav-item .nav-label { flex: 1; }
.nav-item.active {
  background: var(--sidebar-on-bg);
  box-shadow: var(--sidebar-on-ring);
  color: var(--sidebar-ink);
  font-weight: 500;
}
.nav-item.locked {
  color: var(--sidebar-muted);
  cursor: not-allowed;
}
.nav-item.locked:hover {
  background: transparent;
  color: var(--sidebar-muted);
}
.nav-item .nav-badge {
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: var(--r-pill);
  background: transparent;
  border: 1px solid var(--sidebar-line);
  color: var(--sidebar-muted);
}

.sidebar-foot {
  margin-top: auto;
  padding: 12px;
  border-radius: var(--r-card-sm);
  background: var(--c-surface);
  border: 1px solid var(--sidebar-line);
  font-size: 0.76rem;
  color: var(--sidebar-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: none;
}
.sidebar-foot .live-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-weight: 500;
  color: var(--sidebar-ink);
}
.sidebar-foot .label-cap {
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--sidebar-label);
  margin-bottom: 2px;
}
.sidebar-foot .live-tag {
  color: var(--c-up);
  font-weight: 600;
  font-size: 0.78rem;
  margin-left: 4px;
}

/* ── Topbar ─────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-4);
  background: var(--c-top-bg);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: var(--shell-header-h);
  height: var(--shell-header-h);
}

.topbar-section {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--r-card-sm);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--c-text);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.topbar-section:hover { background: var(--c-surface-hover); }
.topbar-section .chev { color: var(--c-text-muted); }

.topbar-search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--c-input-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--r-input);
  max-width: 480px;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.topbar-search:focus-within {
  border-color: var(--c-border-focus);
  box-shadow: 0 0 0 3px var(--c-focus-ring);
}
.topbar-search .search-icon {
  color: var(--c-text-label);
  flex-shrink: 0;
}
.topbar-search input {
  flex: 1;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--c-text);
}
.topbar-search input:focus:not(:focus-visible) { outline: none; }
.topbar-search input::placeholder { color: var(--c-text-label); }

.kbd-hint {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border: 1px solid var(--c-border);
  border-radius: 4px;
  background: var(--c-surface);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--c-text-label);
  font-family: var(--font-sans);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  min-width: 0;
}

.topbar-icon-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: var(--r-btn);
  color: var(--c-text-muted);
  cursor: pointer;
  position: relative;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.topbar-icon-btn:hover { background: var(--c-surface-hover); color: var(--c-text); }

.topbar-icon-btn .dot-indicator {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-accent);
  border: 2px solid var(--c-bg);
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--c-accent-soft);
  color: var(--c-accent-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  flex-shrink: 0;
}

.user-email {
  font-size: 0.82rem;
  color: var(--c-text-muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Tier pill (top-right of topbar) ────────────────────────── */

.tier-pill {
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--c-surface-2);
  color: var(--c-text);
  border: 1px solid var(--c-border);
}

/* ── Markets status pill ────────────────────────────────────── */

.markets-pill {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--c-surface-2);
  color: var(--c-text-muted);
  border: 1px solid var(--c-border-soft);
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.markets-pill[data-status="open"] {
  background: var(--c-up-bg);
  color: var(--c-up);
  border-color: var(--c-up-bg);
}
.markets-pill[data-status="closed"] {
  background: var(--c-surface-2);
  color: var(--c-text-muted);
  border-color: var(--c-border-soft);
}

/* ── Topbar inline search ───────────────────────────────────── */

.topbar-search-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
  min-width: 0;
  flex: 0 1 auto;
}

@media (min-width: 880px) and (max-width: 920px) {
  .topbar-search-wrap { flex-shrink: 0; }
}

/* ── Notification dropdown ──────────────────────────────────── */

.topbar-notif-wrap {
  position: relative;
}

.notif-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 200;
  width: 300px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-popover);
  overflow: hidden;
}

.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--c-border-soft);
}
.notif-header-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--c-text-label);
}

.notif-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
}

.notif-empty {
  padding: 20px 14px;
  font-size: 0.83rem;
  color: var(--c-text-muted);
  text-align: center;
}

.notif-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--c-border-soft);
  font-size: 0.82rem;
  line-height: 1.45;
  cursor: default;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--c-surface-hover); }

.notif-item-stock {
  font-weight: 600;
  color: var(--c-text);
}
.notif-item-scan {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.73rem;
  color: var(--c-text-label);
  margin-top: 2px;
}
.notif-item-time {
  font-size: 0.71rem;
  color: var(--c-text-muted);
  margin-top: 1px;
}

/* ── Main content scaffold ──────────────────────────────────── */

.main-content {
  padding: var(--sp-4) var(--sp-5);
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

/* ── Ledger sections + 12-column grid (SPEC v2 §2.1-2.2) ────── */
/* A section is: rule + 16px + title row + 16px + content. Never a rule and a box for the same group. */

.be-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--sp-4);
  align-items: start;
}
.be-col-8 { grid-column: span 8; min-width: 0; }
.be-col-4 { grid-column: span 4; min-width: 0; }
.be-col-12 { grid-column: 1 / -1; min-width: 0; }
@media (max-width: 1179px) {
  .be-col-8,
  .be-col-4 { grid-column: 1 / -1; }
}

.be-stack {
  display: grid;
  gap: var(--sp-5);
  min-width: 0;
}

.be-section {
  border-top: 1px solid var(--c-rule);
  padding-top: var(--sp-3);
  min-width: 0;
}
.be-section-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--sp-0) var(--sp-2);
  margin-bottom: var(--sp-3);
}
.be-section-head h2 {
  margin: 0;
  font: var(--t-section);
  letter-spacing: 0;
  color: var(--c-text);
}
.be-section-meta {
  font: var(--t-small);
  font-feature-settings: var(--font-features);
  color: var(--c-text-muted);
}
.be-section-link {
  margin-left: auto;
  font: 500 13px/1.45 var(--font-sans);
  color: var(--c-accent-text);
  white-space: nowrap;
}

/* Data band: labels over values on one ruled band, vertical soft dividers, no tiles. */
.be-band {
  display: grid;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
}
.be-band-cell {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px;
  border-left: 1px solid var(--c-border-soft);
}
.be-band-cell:first-child { border-left: 0; }
.be-band-label {
  color: var(--c-text-label);
  font: var(--t-label);
  letter-spacing: 0;
  text-transform: none;
}
.be-band-value {
  color: var(--c-text);
  font: var(--t-kpi);
  font-feature-settings: var(--font-features);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
.be-band-meta {
  color: var(--c-text-muted);
  font: var(--t-caption);
}

/* Ruled list rows: one soft rule between rows, ring on hover, no boxes. */
.be-rows {
  display: flex;
  flex-direction: column;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
}
.be-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 48px;
  padding: 0 var(--sp-3);
  border-bottom: 1px solid var(--c-border-soft);
  color: var(--c-text);
  font: 500 14px/1.4 var(--font-sans);
  text-decoration: none;
}
.be-row:last-child { border-bottom: 0; }
.be-row:first-child { border-top-left-radius: inherit; border-top-right-radius: inherit; }
.be-row:last-child { border-bottom-left-radius: inherit; border-bottom-right-radius: inherit; }
.be-row:hover { color: var(--c-text); text-decoration: none; }
.be-row:focus-visible { border-radius: var(--r-nav); }

.greeting-card {
  background: var(--wash-cool), var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-card);
  padding: 22px 24px 20px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.greeting-card .metric-strip { margin-top: 0; }

.greeting-block { display: flex; flex-direction: column; gap: 6px; }
.greeting {
  font-size: 1.55rem;
  font-weight: 600;
  letter-spacing: -0.018em;
  color: var(--c-text);
  line-height: 1.2;
}
.greeting-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--c-text-muted);
}

/* Status dot: static (nothing loops, SPEC v2 §2.4); colour is state, not motion. */
.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-up);
  flex-shrink: 0;
}

/* ── Card primitive ─────────────────────────────────────────── */

.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-card);
  padding: var(--sp-3);
  box-shadow: var(--shadow-card);
}
.card-wash-cool   { background: var(--wash-cool), var(--c-surface); border-color: var(--c-border); }
.card-wash-sky    { background: var(--wash-sky), var(--c-surface); border-color: var(--c-border-sky); }
.card-wash-warm   { background: var(--wash-warm), var(--c-surface); border-color: var(--c-border-warm); }
.card-wash-mint   { background: var(--wash-mint), var(--c-surface); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}
.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--c-text);
}
.card-sub {
  font-size: 0.78rem;
  color: var(--c-text-muted);
  margin-top: 2px;
  margin-bottom: var(--sp-2);
}
.chart-meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
}
.chart-meta .price {
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--c-text);
}
.chart-meta .delta {
  font-size: 0.92rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.chart-meta .delta.up { color: var(--c-up); }
.chart-meta .delta.down { color: var(--c-down); }
.chart-meta .label-row {
  color: var(--c-text-muted);
  font-size: 0.78rem;
}
.card-action {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--c-accent-text);
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.card-action:hover { background: var(--c-accent-soft); }

/* ── Metric strip ───────────────────────────────────────────── */

.metric-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-3);
}

.metric-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-card);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-card);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.metric-card:hover { border-color: var(--c-border-strong); box-shadow: var(--shadow-card); }

.metric-label {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-text-label);
}
.metric-value {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--c-text);
  font-variant-numeric: tabular-nums;
}
.metric-sub {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--c-text-muted);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: 6px;
}
.metric-sub.up   { color: var(--c-up); }
.metric-sub.down { color: var(--c-down); }

.metric-progress {
  margin-top: 4px;
  height: 4px;
  border-radius: 2px;
  background: var(--c-surface-2);
  overflow: hidden;
}
.metric-progress-fill {
  height: 100%;
  background: var(--c-data-1);
  border-radius: 2px;
}

/* ── Change pill (TV style) ─────────────────────────────────── */

.change-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.change-pill.up   { background: var(--c-up-bg);   color: var(--c-up-text); }
.change-pill.down { background: var(--c-down-bg); color: var(--c-down-text); }

/* ── Status badges ──────────────────────────────────────────── */

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  white-space: nowrap;
}
.status-live    { background: var(--c-up-bg);     color: var(--c-up); }
.status-soon    { background: var(--c-surface-2); color: var(--c-text-muted); border: 1px solid var(--c-border-soft); }
.status-phase2  { background: var(--c-accent-soft); color: var(--c-accent-text); }
.status-phase3  { background: var(--c-warning-soft); color: var(--c-warning); border: 1px solid var(--c-border-warm); }
.status-locked  { background: var(--c-surface-2); color: var(--c-text-label); border: 1px solid var(--c-border-soft); }

/* ── Tab bar ────────────────────────────────────────────────── */

.tab-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-pill);
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab {
  padding: 6px 14px;
  border-radius: var(--r-pill);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--c-text-muted);
  cursor: pointer;
  border: none;
  background: transparent;
  font-family: inherit;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
  flex-shrink: 0;
}
.tab:hover { color: var(--c-text); }
.tab.active {
  background: var(--c-pill-on-bg);
  color: var(--c-pill-on-text);
}

/* ── Stock table ────────────────────────────────────────────── */

.mobile-scroll-hint {
  display: none;
  margin: 0 0 var(--sp-2);
  color: var(--c-text-muted);
  font-size: 0.78rem;
}

.stock-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Dashboard match empty state lives outside the horizontally scrolling table. */
.dashboard-matches-empty {
  padding: var(--sp-3);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-card-sm);
  background: var(--c-surface-2);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
  color: var(--c-text);
}
.dashboard-matches-empty[hidden] { display: none; }
.dashboard-matches-empty strong { font-size: 0.9rem; }
.dashboard-matches-empty span { flex-basis: 100%; color: var(--c-text-muted); font-size: 0.82rem; }
.mobile-scroll-hint[hidden] { display: none; }
.dashboard-card-header { align-items: flex-start; }
.dashboard-card-header > div { min-width: 0; }
.dashboard-card-header .section-label {
  margin: 4px 0 0;
  color: var(--c-text-muted);
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: normal;
  line-height: 1.4;
  text-transform: none;
}
.dashboard-card-header > a { flex: 0 0 auto; white-space: nowrap; }

.stock-table {
  width: 100%;
  border-collapse: collapse;
  font: var(--t-td);
  font-feature-settings: var(--font-features);
}
.stock-table th,
.stock-table td {
  height: 40px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--c-border-soft);
  vertical-align: middle;
}
.stock-table tr:last-child td { border-bottom: none; }
.stock-table th {
  text-align: left;
  font: var(--t-th);
  letter-spacing: 0;
  text-transform: none;
  color: var(--c-text-label);
  background: var(--c-th-bg);
  border-bottom: 1px solid var(--c-border-strong);
}
.stock-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--c-text);
  font-weight: 400;
}
.stock-table .ticker {
  font-weight: 600;
  color: var(--c-text);
}
.stock-table .ticker-name {
  display: block;
  font-weight: 400;
  font-size: 0.76rem;
  color: var(--c-text-muted);
  margin-top: 2px;
}
.stock-table .volume,
.stock-table .sector {
  color: var(--c-text-muted);
  font-weight: 400;
  font-size: 0.82rem;
}
.stock-table tbody tr {
  transition: background-color var(--dur-fast) var(--ease-out);
}
.stock-table tbody tr:hover { background: var(--c-surface-hover); }

/* ── Sparkline ──────────────────────────────────────────────── */

.sparkline {
  display: inline-block;
  width: 60px;
  height: 22px;
  vertical-align: middle;
}
.sparkline path { fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sparkline .up   { stroke: var(--c-up); }
.sparkline .down { stroke: var(--c-down); }

/* ── Right rail rows ────────────────────────────────────────── */

.rail-list {
  display: flex;
  flex-direction: column;
}
.rail-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--c-border-soft);
}
.rail-row:last-child { border-bottom: none; }
.rail-row .ticker {
  font-weight: 600;
  color: var(--c-text);
  font-size: 0.88rem;
}
.rail-row .left-cell {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}
.rail-row .left-cell .sym {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--c-text);
}
.rail-row .left-cell .full {
  font-size: 0.7rem;
  color: var(--c-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rail-row .price {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: 0.86rem;
  color: var(--c-text);
  text-align: right;
}
.rail-row .meta {
  font-size: 0.76rem;
  color: var(--c-text-muted);
}

.rail-change-pill {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}
.rail-change-pill.up   { background: color-mix(in srgb, var(--c-up) 14%, transparent); color: var(--c-up); }
.rail-change-pill.down { background: color-mix(in srgb, var(--c-down) 14%, transparent); color: var(--c-down); }

.recent-hit-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 4px 10px;
  padding: 8px 0;
  align-items: center;
  border-bottom: 1px solid var(--c-border-soft);
}
.recent-hit-row:last-child { border-bottom: none; }
.recent-hit-row .recent-hit-context {
  grid-column: 1 / -1;
  font-size: 0.78rem;
  color: var(--c-text-muted);
  margin-top: -2px;
}
.recent-hit-row .time {
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  color: var(--c-text-muted);
  font-weight: 500;
}
.recent-hit-row .ticker { font-weight: 600; font-size: 0.88rem; color: var(--c-text); }
.recent-hit-row .scan-pill {
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: var(--r-pill);
}

/* ── Right rail ─────────────────────────────────────────────── */

.right-rail {
  border-left: 1px solid var(--c-border);
  background: var(--c-surface);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  position: sticky;
  top: 0;
  align-self: start;
}

@media (max-width: 1279px) and (min-width: 880px) {
  .app-layout-with-rail {
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: auto auto;
  }
  .main-column { grid-column: 2; grid-row: 1; min-width: 0; }
  .sidebar { grid-row: 1 / 3; }
  .right-rail {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    grid-column: 2;
    grid-row: 2;
    gap: var(--sp-3);
    position: static;
    height: auto;
    border-left: none;
    border-top: 1px solid var(--c-border-soft);
  }
}

@media (max-width: 879px) {
  .right-rail { display: none; }
  .mobile-scroll-hint { display: block; }
  .dashboard-card-header { flex-wrap: wrap; gap: 6px 12px; }
  .dashboard-card-header > div { flex: 1 1 100%; }
}

/* ── Tile grid (modules) ────────────────────────────────────── */

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-3);
}

.tile {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-card);
  padding: var(--sp-3);
  min-height: 150px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-decoration: none;
  color: var(--c-text);
  position: relative;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
  box-shadow: var(--shadow-card);
}
.tile-active { cursor: pointer; }
.tile-active:hover {
  border-color: var(--c-accent-line);
  box-shadow: var(--shadow-card-hover);
  text-decoration: none;
}
.tile-featured {
  background: var(--wash-cool), var(--c-surface);
  border-color: var(--c-border);
}
.tile-featured:hover {
  border-color: var(--c-accent-line);
  box-shadow: var(--shadow-card-hover);
}

.tile-disabled {
  cursor: not-allowed;
  background: var(--c-surface-2);
  opacity: 0.85;
}

.tile-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--c-accent-soft);
  color: var(--c-accent-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tile-disabled .tile-icon {
  background: var(--c-surface);
  color: var(--c-text-label);
}

.tile-label {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--c-text);
}
.tile-disabled .tile-label { color: var(--c-text-muted); }

.tile-desc {
  font-size: 0.83rem;
  color: var(--c-text-muted);
  line-height: 1.5;
  flex: 1;
}

.tile-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  align-self: flex-start;
}
.badge-live    { background: var(--c-up-bg);     color: var(--c-up); }
.badge-soon    { background: var(--c-surface);   color: var(--c-text-muted); border: 1px solid var(--c-border-soft); }

/* ── Locked overlay (tier-aware) ────────────────────────────── */

.locked-card {
  position: relative;
  overflow: hidden;
}
.locked-card .locked-content {
  filter: blur(2px) saturate(0.6);
  opacity: 0.5;
  pointer-events: none;
  user-select: none;
}
.locked-overlay {
  display: none;
  position: absolute;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: var(--sp-3);
  background: linear-gradient(180deg, color-mix(in srgb, var(--c-bg) 55%, transparent) 0%, color-mix(in srgb, var(--c-bg) 92%, transparent) 100%);
  text-align: center;
}
.locked-card > .locked-overlay { display: flex; }
.locked-overlay .lock-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-muted);
  box-shadow: var(--shadow-card);
}
.locked-overlay .lock-msg {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--c-text);
}
.locked-overlay .lock-cta {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--c-accent-text);
  text-decoration: none;
}
.locked-overlay .lock-cta:hover { text-decoration: underline; }

/* ── Skeleton shimmer ───────────────────────────────────────── */

.skeleton {
  display: inline-block;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    var(--skeleton-base) 25%,
    var(--skeleton-shine) 50%,
    var(--skeleton-base) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  color: transparent;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.sk-email { width: 160px; height: 13px; vertical-align: middle; }
.sk-tier  { width: 60px;  height: 22px; border-radius: var(--r-pill); }

/* ── SC compliance footer ───────────────────────────────────── */

.sc-footer {
  font-size: 0.75rem;
  color: var(--c-text-muted);
  line-height: 1.6;
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--c-border-soft);
  text-align: center;
  background: var(--c-surface);
  margin-top: auto;
}
.sc-footer a { color: var(--c-text-muted); }
.sc-footer a:hover { color: var(--c-accent-text); }

/* Calculator page typography emphasis */
body.calc-page .tab-btn,
body.calc-page .section-label {
  font-weight: 700;
  letter-spacing: 0.06em;
}
body.calc-page .hero-label {
  font-weight: 700;
}
body.calc-page .breakdown-card .row > span:first-child {
  font-weight: 600;
}
body.calc-page .breakdown-card .row.row-total > span,
body.calc-page .breakdown-card .row.row-grand > span,
body.calc-page .breakdown-card .row.row-remain > span {
  font-weight: 700;
}

/* ── Reduced motion ─────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .live-dot { animation: none; }
  .skeleton { animation: none; }
  .skeleton {
    background: var(--skeleton-base);
  }
}

/* ── Mobile breakpoint (collapse sidebar) ───────────────────── */

@media (max-width: 879px) {
  .app-layout,
  .app-layout-with-rail {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform var(--dur-base) var(--ease-out);
    box-shadow: var(--shadow-popover);
  }
  .sidebar.open { transform: translateX(0); }
  .topbar { padding: 12px var(--sp-3); flex-wrap: wrap; }
  .topbar-search-wrap {
    min-width: 44px;
    flex: 0 1 auto;
  }
  .topbar-search { display: none; }
  .main-content { padding: var(--sp-3); gap: var(--sp-3); }
  .kbd-hint { display: none; }

  /* ── PG-15: 44×44px minimum tap targets on mobile (WCAG 2.5.5) ── */
  .theme-toggle {
    min-width: 44px;
    min-height: 44px;
  }
  .topbar-icon-btn {
    min-width: 44px;
    min-height: 44px;
  }
  .nav-item {
    min-height: 44px;
  }
  .btn {
    min-height: 44px;
  }
  .tab {
    min-height: 44px;
    padding-top: 12px;
    padding-bottom: 12px;
  }
  .scan-tab {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  .input {
    min-height: 44px;
  }
  .pulse-search,
  .pulse-source-select {
    min-height: 44px;
  }
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: var(--c-scrim);
  z-index: 25;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out);
}
.sidebar-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
@media (min-width: 880px) {
  .sidebar-backdrop { display: none; }
}

/* ── Phone bottom tab bar reserve (SPEC v2 R-A1) ───────────── */
/* The bar itself is structural (v3-shell.css); this token keeps the SC footer and tour clear of it. */
@media (max-width: 767px) {
  :root {
    --tabbar-h: calc(64px + env(safe-area-inset-bottom, 0px));
  }
  .main-column {
    padding-bottom: var(--tabbar-h);
  }
}

/* ── Volume Heatmap ─────────────────────────────────────────── */

.heatmap-card { padding: 16px; }
.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 4px;
  margin-top: 12px;
}
.heatmap-cell {
  aspect-ratio: 1;
  border-radius: 4px;
  background: var(--c-surface-2);
  font-size: 0.66rem;
  color: var(--c-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}
.heatmap-cell.h1 { background: color-mix(in srgb, var(--c-data-1) 10%, var(--c-surface-2)); }
.heatmap-cell.h2 { background: color-mix(in srgb, var(--c-data-1) 20%, var(--c-surface-2)); }
.heatmap-cell.h3 { background: color-mix(in srgb, var(--c-data-1) 30%, var(--c-surface-2)); color: var(--c-text); }
.heatmap-cell.h4 { background: color-mix(in srgb, var(--c-data-1) 38%, var(--c-surface-2)); color: var(--c-text); }
.heatmap-cell.h5 { background: color-mix(in srgb, var(--c-data-1) 45%, var(--c-surface-2)); color: var(--c-text); }
.heatmap-legend {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 12px;
  font-size: 0.78rem;
  color: var(--c-text-muted);
}

/* ── Market News panel ──────────────────────────────────────── */

.news-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 0;
  border-bottom: 1px solid var(--c-border-soft);
  cursor: pointer;
}
.news-row:last-child { border-bottom: none; }
.news-row:hover .news-head { color: var(--c-accent-text); }
.news-row .news-ago {
  font-size: 0.72rem;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.news-row .news-head {
  font-size: 0.88rem;
  color: var(--c-text);
  line-height: 1.4;
  transition: color var(--dur-fast) var(--ease-out);
}

/* ── Ticker-mark chips ──────────────────────────────────────── */

.ticker-mark {
  display: inline-flex;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--c-text);
  margin-right: 8px;
  flex-shrink: 0;
}
.ticker-mark.m1 { background: color-mix(in srgb, var(--c-data-1) 28%, var(--c-surface)); }
.ticker-mark.m2 { background: color-mix(in srgb, var(--c-data-2) 28%, var(--c-surface)); }
.ticker-mark.m3 { background: color-mix(in srgb, var(--c-data-3) 28%, var(--c-surface)); }
.ticker-mark.m4 { background: color-mix(in srgb, var(--c-data-4) 28%, var(--c-surface)); }
.ticker-mark.m5 { background: color-mix(in srgb, var(--c-data-5) 28%, var(--c-surface)); }

/* ── Smoke-mode ribbon ──────────────────────────────────────── */

.smoke-ribbon {
  position: sticky;
  top: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 16px;
  background: color-mix(in srgb, var(--c-warning) 18%, var(--c-bg));
  color: var(--c-warning);
  font-size: 0.86rem;
  font-weight: 600;
  border-bottom: 1px solid color-mix(in srgb, var(--c-warning) 45%, var(--c-bg));
}
/* [hidden] must win over the class's display:flex, else the preview ribbon
   renders in real production sessions (same specificity trap as the journal toast). */
.smoke-ribbon[hidden] { display: none; }
.smoke-ribbon .smoke-pill {
  background: color-mix(in srgb, currentColor 14%, transparent);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Theme toggle ───────────────────────────────────────────── */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--r-btn);
  border: 1px solid var(--c-border-soft);
  background: var(--c-surface);
  color: var(--c-text-muted);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.theme-toggle:hover { background: var(--c-surface-2); color: var(--c-text); }
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: inline-block; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: inline-block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ── Sub-nav groups ──────────────────────────────────────────────────── */

.nav-group {
  display: flex;
  flex-direction: column;
}

/* The toggle button inherits all .nav-item visuals */
.nav-group-toggle {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.nav-group-chevron {
  flex-shrink: 0;
  color: var(--c-text-label);
  transition: transform var(--dur-fast) var(--ease-out);
  margin-left: auto;
}

.nav-group--open .nav-group-chevron {
  transform: rotate(180deg);
}

/* Sub-list: collapsed by default */
.nav-sublist {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  max-height: 0;
  transition: max-height var(--dur-fast) var(--ease-out);
}

.nav-group--open .nav-sublist {
  /* Enough for ~10 items at ~36px each; was 200px which clipped larger groups */
  max-height: 400px;
}

.nav-subitem {
  display: block;
  padding: 6px 10px 6px 38px;
  border-radius: var(--r-card-sm);
  font-size: 0.84rem;
  font-weight: 400;
  color: var(--c-text-muted);
  text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-subitem:hover {
  background: var(--c-surface-hover);
  color: var(--c-text);
  text-decoration: none;
}

.nav-subitem.active {
  background: var(--c-accent-soft);
  color: var(--c-accent-text);
  font-weight: 500;
}

@media (max-width: 879px) {
  .nav-sublist {
    margin-left: 10px;
    margin-right: -10px;
  }

  .nav-subitem {
    min-height: 44px;
  }

  .nav-subitem.active {
    margin: 0;
  }
}

[data-theme="dark"] .nav-subitem.active {
  color: var(--c-accent-text);
}


/* ═══════════════════════════════════════════════════════════════
   Pulse module — screener dashboard, filter builder, results
   ═════════════════════════════════════════════════════════════== */

/* ── Nav badge — V2 new release ─────────────────────────────── */
.nav-item .nav-badge--new {
  background: var(--c-accent-soft);
  border-color: transparent;
  color: var(--c-link);
}

/* ── Pulse page wrapper ─────────────────────────────────────── */
.pulse-page {
  max-width: 1160px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}
.pulse-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.pulse-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pulse-title {
  font: var(--t-title);
  letter-spacing: -0.01em;
  color: var(--c-text);
  margin: 0;
}

/* ── Filter bar ─────────────────────────────────────────────── */
.pulse-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.pulse-search {
  flex: 1;
  min-width: 180px;
  max-width: 300px;
  padding: 8px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-input);
  background: var(--c-input-bg);
  color: var(--c-text);
  font-size: 0.88rem;
}
.pulse-search:focus,
.pulse-source-select:focus {
  border-color: var(--c-border-focus);
  box-shadow: 0 0 0 3px var(--c-focus-ring);
}
.pulse-search:focus:not(:focus-visible),
.pulse-source-select:focus:not(:focus-visible) { outline: none; }
.pulse-source-select {
  padding: 8px 14px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-input);
  background: var(--c-input-bg);
  color: var(--c-text);
  font-size: 0.88rem;
  cursor: pointer;
}

/* ── Scan grid ──────────────────────────────────────────────── */
.pulse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.pulse-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--c-text-muted);
  font-size: 0.95rem;
}

/* ── Scan card ──────────────────────────────────────────────── */
.scan-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: 18px 20px;
  cursor: pointer;
  transition: box-shadow var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
  text-decoration: none;
  display: block;
  color: inherit;
}
.scan-card:hover {
  box-shadow: var(--shadow-card-hover);
  border-color: var(--c-border-focus);
}
.scan-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.scan-card-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--c-text);
  line-height: 1.3;
}
.scan-card-meta {
  font-size: 0.78rem;
  color: var(--c-text-muted);
  margin-top: 6px;
}
.scan-card-stat {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--c-text-muted);
}
.scan-card-count {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--c-text);
  line-height: 1;
}

/* ── Scan source badge ──────────────────────────────────────── */
.scan-source-badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: var(--r-pill);
  font: 500 12px/1 var(--font-sans);
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  flex-shrink: 0;
}
/* Category hues (CD-83): ONE mapping, kinds of scan only. Chips = hue dot + faint tint, normal text colour.
   Dashboard, Journal and notifications tag the element with data-cat="<API slug>"; the Screener keeps its .source-* classes.
   Anything else (manual, own idea, unknown) falls back to --c-data-6 via var(--cat, ...). */
[data-cat="momentum"], .source-momentum { --cat: var(--c-data-1); }
[data-cat="btst"], .source-btst { --cat: var(--c-data-2); }
[data-cat="friday_prebreakout"], [data-cat="friday_pre_breakout"], .source-friday-pre { --cat: var(--c-data-3); }
[data-cat="friday_rule"], .source-friday-rule { --cat: var(--c-data-4); }
.scan-source-badge, .scan-run-src, .scan-pill, .jv-scan-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: color-mix(in srgb, var(--cat, var(--c-data-6)) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--cat, var(--c-data-6)) 30%, transparent);
  color: var(--c-text);
}
.scan-source-badge::before, .scan-run-src::before, .scan-pill::before, .jv-scan-chip::before, .notif-item-scan::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cat, var(--c-data-6));
  flex-shrink: 0;
}

/* ── Preset card ────────────────────────────────────────────── */
.preset-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: 18px 20px;
  transition: box-shadow var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.preset-card:hover {
  box-shadow: var(--shadow-card-hover);
  border-color: var(--c-border-focus);
}
.preset-card-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--c-text);
  margin: 0 0 6px;
}
.preset-card-desc {
  font-size: 0.83rem;
  color: var(--c-text-muted);
  line-height: 1.5;
  margin-bottom: 14px;
}
.preset-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Filter builder ─────────────────────────────────────────── */
.filter-builder { max-width: 720px; }
.filter-section {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}
.filter-section-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--c-text-label);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 14px;
}
.filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.filter-row label {
  font-size: 0.85rem;
  color: var(--c-text-muted);
  min-width: 140px;
}
.filter-row input[type="number"],
.filter-row select {
  flex: 1;
  min-width: 80px;
  max-width: 140px;
  padding: 7px 10px;
  border: 1px solid var(--c-border);
  border-radius: 7px;
  background: var(--c-surface-2);
  color: var(--c-text);
  font-size: 0.87rem;
}
.filter-row input[type="number"]:focus,
.filter-row select:focus {
  border-color: var(--c-border-focus);
  box-shadow: 0 0 0 3px var(--c-accent-soft);
}
.filter-row input[type="number"]:focus:not(:focus-visible),
.filter-row select:focus:not(:focus-visible) { outline: none; }
.filter-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--c-accent);
  cursor: pointer;
}
.filter-summary {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border-soft);
  border-radius: 10px;
  padding: 16px 18px;
  font-size: 0.85rem;
  color: var(--c-text-muted);
  line-height: 1.6;
  position: sticky;
  top: 80px;
}
.filter-summary-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--c-text-label);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.filter-preview-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 860px) {
  .filter-preview-layout { grid-template-columns: 1fr; }
  .filter-summary { position: static; }
}

/* ── Results table ──────────────────────────────────────────── */
.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.results-table th {
  padding: 8px 12px;
  text-align: left;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--c-text-label);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--c-th-bg);
  border-bottom: 1px solid var(--c-border-strong);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.results-table th.sorted-asc::after  { content: " ↑"; }
.results-table th.sorted-desc::after { content: " ↓"; }
.results-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--c-border-soft);
  vertical-align: middle;
}
.results-table tr:last-child td { border-bottom: none; }
.results-table tr:hover td { background: var(--c-surface-hover); }
/* Path-1 share-card gate: blur rows past the free limit until an early-access viewer is verified.
   Kept here (external same-origin sheet) rather than an inline <style> — CSP style-src-elem 'self'
   refuses inline <style> elements, which silently dropped this blur on the live /share/ card. */
#results-table tr.locked td { filter: blur(5px); opacity: 0.5; user-select: none; pointer-events: none; }

/* ── Score cell ─────────────────────────────────────────────── */
.score-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}
.score-num {
  font-size: 1.05rem;
  font-weight: 700;
  min-width: 28px;
  color: var(--c-text);
}
.score-bar-track {
  flex: 1;
  height: 6px;
  background: var(--c-border-soft);
  border-radius: 99px;
  overflow: hidden;
  min-width: 40px;
}
.score-bar-fill {
  height: 100%;
  border-radius: 99px;
  width: calc(var(--score, 0) * 20%);
  background: var(--c-gold);
}

/* ── Factor pillars ─────────────────────────────────────────── */
.factor-pillars {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pillar-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c-border);
  flex-shrink: 0;
}
.pillar-dot.on                    { background: var(--c-data-1); }
.pillar-dot.on[data-pillar="1"]   { background: var(--c-data-1); }
.pillar-dot.on[data-pillar="2"]   { background: var(--c-data-2); }
.pillar-dot.on[data-pillar="3"]   { background: var(--c-data-3); }
.pillar-dot.on[data-pillar="4"]   { background: var(--c-data-4); }
.pillar-dot.on[data-pillar="5"]   { background: var(--c-data-5); }

/* ── Risk flags ─────────────────────────────────────────────── */
.risk-flag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  background: var(--c-warning-soft);
  color: var(--c-warning);
  margin: 2px;
}

/* ── Shariah badge ──────────────────────────────────────────── */
.shariah-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  background: var(--c-sc-bg);
  color: var(--c-sc-text);
  border: 1px solid var(--c-sc-border);
}

/* ── History timeline ───────────────────────────────────────── */
.history-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.history-day {
  display: grid;
  grid-template-columns: 100px 1fr;
  align-items: start;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--c-border-soft);
}
.history-day:last-child { border-bottom: none; }
.history-date {
  font-size: 0.78rem;
  color: var(--c-text-muted);
  padding-top: 2px;
}
.history-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.history-chip {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--c-surface-2);
  color: var(--c-text);
  border: 1px solid var(--c-border-soft);
}

/* ── Pro-gate locked overlay ────────────────────────────────── */
.locked-overlay { position: relative; }
.locked-overlay-mask {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--c-bg) 88%, transparent);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 10;
  border-radius: var(--r-card);
  padding: 32px;
  text-align: center;
}
.locked-overlay-icon  { font-size: 2rem; margin-bottom: 4px; }
.locked-overlay-title { font-size: 1.05rem; font-weight: 700; color: var(--c-text); }
.locked-overlay-body  { font-size: 0.88rem; color: var(--c-text-muted); max-width: 320px; }

/* ── Scan detail header ─────────────────────────────────────── */
.scan-detail-header {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: 20px 24px;
  margin-bottom: 20px;
}
.scan-detail-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--c-text);
  margin: 0 0 6px;
}
.scan-detail-meta {
  font-size: 0.83rem;
  color: var(--c-text-muted);
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.scan-detail-nav {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
}
.scan-tab {
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--c-text-muted);
  text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.scan-tab:hover { background: var(--c-surface-2); color: var(--c-text); }
.scan-tab.active { background: var(--c-pill-on-bg); color: var(--c-pill-on-text); }

/* ── Flash banner (post-save redirect) ──────────────────────── */
.pulse-flash {
  padding: 10px 16px;
  background: var(--c-surface-2);
  color: var(--c-text);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-card-sm);
  font-size: 0.87rem;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.pulse-flash[hidden] { display: none; }

/* ── Welcome page ──────────────────────────────────────────── */
.welcome-page {
  min-height: 100vh;
  background: var(--bg-page);
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
}
/* The wordmark follows --font-display like the sidebar (CD-83: one family). */
.welcome-header .brand-wordmark {
  font: 600 16px/1.25 var(--font-display);
  letter-spacing: -0.01em;
  color: var(--c-text);
}

.welcome-shell {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--sp-4) var(--sp-3);
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.welcome-header {
  margin-bottom: var(--sp-5);
}

.welcome-main {
  flex: 1;
}

/* Same quiet footer as the auth card pages, not a grey slab under the steps card. */
.welcome-shell .sc-footer {
  margin-top: var(--sp-3);
  padding: var(--sp-2) var(--sp-1) 0;
  background: transparent;
  border-top: 0;
}

/* Hero card (mockup .hero): cobalt corner glow + faint teal bottom-right, sky border. */
.welcome-card {
  padding: 28px;
  border: 1px solid var(--c-border-sky);
  border-radius: var(--r-card);
  background:
    radial-gradient(90% 120% at 0% 0%, var(--c-glow-hero), transparent 55%),
    radial-gradient(60% 90% at 100% 100%, color-mix(in srgb, var(--c-data-1) 12%, transparent), transparent 60%),
    var(--c-surface);
  box-shadow: var(--shadow-card);
}

.welcome-heading {
  font: 500 34px/1.1 var(--font-display);
  font-optical-sizing: auto;
  letter-spacing: .005em;
  color: var(--c-text);
  margin: 0 0 var(--sp-2);
}

.welcome-subhead {
  font: var(--t-body);
  color: var(--c-text-muted);
  margin: 0 0 var(--sp-5);
}

/* Larger tap target for welcome CTAs */
.btn-lg {
  padding: 0 24px;
  font: var(--t-btn);
  min-height: 48px;
}

.welcome-hint {
  font: var(--t-small);
  color: var(--c-text-muted);
  margin: var(--sp-2) 0 0;
}

.welcome-dashboard-link {
  margin-top: var(--sp-3);
}

.welcome-status {
  margin-top: var(--sp-3);
  font: var(--t-small);
  color: var(--c-text-muted);
  min-height: 1.4em;
}

.welcome-guide { margin-top: var(--sp-3); }
.welcome-guide summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font: var(--t-small);
  font-weight: 500;
  color: var(--c-accent-text);
  cursor: pointer;
}
.welcome-guide summary:hover { text-decoration: underline; }
.welcome-guide p {
  font: var(--t-small);
  color: var(--c-text-muted);
  margin: var(--sp-0) 0 0;
}

.welcome-steps {
  margin-top: 14px;
  padding: 20px 24px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-card);
  background: var(--c-surface);
  box-shadow: var(--shadow-card);
}

/* Label role: Inter 12px/500, sentence case (text unchanged). */
.welcome-steps-heading {
  font: var(--t-label);
  letter-spacing: 0;
  text-transform: none;
  color: var(--c-text-label);
  margin: 0 0 var(--sp-3);
}

.welcome-steps-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.welcome-step {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  font: var(--t-body);
  color: var(--c-text);
}
.welcome-step strong { font-weight: 500; }

/* Plain numbered list: the number is a caption, not a badge. */
.welcome-step-num {
  flex-shrink: 0;
  min-width: 16px;
  background: none;
  color: var(--c-text-muted);
  font: var(--t-caption);
  font-feature-settings: var(--font-features);
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  line-height: 21px;
}

@media (max-width: 560px) {
  .welcome-card { padding: 22px 18px; }
  .welcome-heading { font-size: 28px; }
  .welcome-steps { padding: 18px; }
  .auth-card { padding: var(--sp-4) var(--sp-3) var(--sp-3); }
}

/* ── Screen-reader only utility (clip-rect pattern) ─────────── */

.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;
}

/* ── Password requirements checklist (signup) ───────────────── */

.pw-rules {
  list-style: none;
  margin: var(--sp-1) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pw-rule {
  display: flex;
  align-items: center;
  gap: 6px;
  font: var(--t-caption);
  color: var(--c-text-muted);
  transition: color var(--dur-fast) var(--ease-out);
}

.pw-rule-icon::before {
  content: '○';
  font-size: 0.7rem;
  color: var(--c-text-label);
}

.pw-rule[data-met="true"] {
  color: var(--c-up-text);
}

.pw-rule[data-met="true"] .pw-rule-icon::before {
  content: '✓';
  color: var(--c-up-text);
  font-weight: 700;
}

/* ── Confirm-password match indicator (signup) ──────────────── */

.pw-match-msg {
  margin-top: 4px;
  font: var(--t-caption);
  min-height: 18px;
  transition: color var(--dur-fast) var(--ease-out);
}

.pw-match-msg[data-state="match"]    { color: var(--c-up-text); }
.pw-match-msg[data-state="mismatch"] { color: var(--c-down-text); }

/* ─────────────────────────────────────────────────────────────
   Journal Lite — E-3 (append-only, .journal-* namespace)
   All colours use existing var(--c-*) tokens only.
   ───────────────────────────────────────────────────────────── */

/* ── Page scaffold ─────────────────────────────────────────── */

.journal-page {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.journal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.journal-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--c-text);
  margin: 0;
}

/* ── Live regions (visually hidden until populated) ─────────── */

.journal-live-region {
  font-size: 0.88rem;
  min-height: 1.4em;
  padding: 0;
}

.journal-live-region:not(:empty) {
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-card-sm);
  background: var(--c-accent-soft);
  color: var(--c-accent-text);
}

#journal-alert:not(:empty) {
  background: var(--c-down-bg-soft);
  color: var(--c-down);
}

/* ── Scorecard ─────────────────────────────────────────────── */

.journal-scorecard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
}

@media (max-width: 600px) {
  .journal-scorecard {
    grid-template-columns: 1fr;
  }
}

.journal-stat-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.journal-stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-text-muted);
}

.journal-stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--c-text);
  line-height: 1.1;
  min-height: 2rem;
}

.journal-stat-disclaimer {
  font-size: 0.72rem;
  color: var(--c-text-muted);
  margin-top: 2px;
  line-height: 1.4;
}

/* ── P&L colour modifiers ──────────────────────────────────── */

.journal-pnl-pos {
  color: var(--c-up);
}

.journal-pnl-neg {
  color: var(--c-down);
}

/* ── Monthly chart card ────────────────────────────────────── */

.journal-chart-card {
  overflow-x: auto;
}

.journal-chart-heading {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-text-muted);
  margin-bottom: var(--sp-2);
}

.journal-chart-wrap {
  min-height: 160px;
  display: flex;
  align-items: flex-end;
}

.journal-chart-svg {
  overflow: visible;
  display: block;
}

.journal-chart-label {
  font-size: 10px;
  fill: var(--c-text-muted);
  font-family: var(--font-sans);
}

.journal-chart-zero {
  stroke: var(--c-border);
  stroke-width: 1;
}

.journal-chart-empty {
  font-size: 0.88rem;
  color: var(--c-text-muted);
}

/* ── Trade entry form ─────────────────────────────────────── */

.journal-form-card {
  /* uses existing .card */
}

.journal-form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
}

@media (max-width: 560px) {
  .journal-form-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Mobile overrides ≤560px ────────────────────────────────── */

@media (max-width: 560px) {

  /* -- Topbar: tighten padding, stop overflow -- */
  .topbar {
    padding: 10px var(--sp-2);
    gap: 6px;
    flex-wrap: nowrap;
  }

  /* -- Markets dropdown: shrink + ellipsis -- */
  .topbar-section {
    max-width: 80px;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    padding: 6px 6px;
    font-size: 0.8rem;
  }

  /* -- Actions row: tighten gap, allow children to shrink -- */
  .topbar-actions {
    gap: 2px;
    flex-wrap: nowrap;
    min-width: 0;
  }

  /* -- Hide email label and tier pill on small phones -- */
  .user-email,
  .tier-pill { display: none; }

  /* -- Notification icon: hide on very small screens -- */
  .topbar-actions .topbar-icon-btn[aria-label="Notifications"] { display: none; }

  /* Keep the shared topbar within narrow phone viewports without shrinking
     Search/Help targets or truncating the market status / logout control. */
  @media (max-width: 375px) {
    .topbar {
      padding-left: 2px;
      padding-right: 2px;
      gap: 2px;
    }

    .topbar-actions { gap: 0; }

    #markets-pill {
      letter-spacing: 0.02em;
      padding-left: 4px;
      padding-right: 4px;
    }

    #btn-logout {
      white-space: nowrap;
      padding-left: 6px;
      padding-right: 6px;
    }

    @media (max-width: 340px) {
      #avatar { display: none; }
    }
  }

  /* -- Stock table: local horizontal containment remains intentional. */
  .stock-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
  }

  /* Right-edge scroll fade hint */
  .stock-table-wrap::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 28px;
    background: linear-gradient(to right, transparent, var(--c-surface));
    pointer-events: none;
    border-radius: 0 var(--r-card-sm) var(--r-card-sm) 0;
  }

  /* -- Stock table: enforce minimum readable width -- */
  .stock-table {
    min-width: 460px;
    font-size: 0.82rem;
  }

  .stock-table th,
  .stock-table td {
    padding: 8px 8px;
  }
}

/* -- Hamburger: hide on desktop, show on mobile -- */
@media (min-width: 880px) {
  #btn-mobile-menu { display: none; }
}
@media (max-width: 879px) {
  #btn-mobile-menu {
    display: inline-flex;
    flex-shrink: 0;
  }
}

.journal-form-full {
  grid-column: 1 / -1;
}

.journal-field-hint {
  font-size: 0.78rem;
  color: var(--c-text-muted);
  margin-top: 4px;
}

.journal-file-input {
  padding: var(--sp-1) var(--sp-2);
  cursor: pointer;
}

.journal-form-actions {
  margin-top: var(--sp-3);
  display: flex;
  gap: var(--sp-2);
}

/* ── Trade list ───────────────────────────────────────────── */

.journal-list-section {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.journal-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.journal-list-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-text-muted);
}

/* ── Empty state ──────────────────────────────────────────── */

.journal-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-6) var(--sp-4);
  background: var(--c-surface-2);
  border-radius: var(--r-card);
  border: 1px dashed var(--c-border);
  text-align: center;
}

.journal-empty-text {
  font-size: 1rem;
  color: var(--c-text-muted);
}

/* ── Trade table ─────────────────────────────────────────── */

.journal-table-wrap {
  overflow-x: auto;
  border-radius: var(--r-card);
  border: 1px solid var(--c-border);
}

.journal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  background: var(--c-surface);
}

.journal-table thead th {
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-text-muted);
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
  background: var(--c-th-bg);
}

.journal-table tbody td {
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--c-border-soft);
  color: var(--c-text);
  vertical-align: middle;
  white-space: nowrap;
}

.journal-table tbody tr:last-child td {
  border-bottom: none;
}

.journal-table tbody tr:hover td {
  background: var(--c-surface-hover);
}

.journal-delete-btn {
  font-size: 0.78rem;
  padding: 4px 10px;
  min-height: 28px;
  color: var(--c-down);
  border-color: var(--c-down-bg);
}

.journal-delete-btn:hover {
  background: var(--c-down-bg-soft);
  border-color: var(--c-down);
}

/* ── Usage meter (per-tier cap, CD-52/CD-53 §Wave-2) ──────────
   Four laws: neutral fill (never gold, never market up/down); the
   interactive CTA is the only blue thing. State is carried by copy +
   a restrained caution tone, not by market colour. */

.usage-meter {
  display: inline-flex;
  flex-direction: column;
  gap: 5px;
  max-width: 340px;
  vertical-align: middle;
}

.usage-meter-track {
  display: block;
  width: 100%;
  min-width: 160px;
  height: 6px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  overflow: hidden;
}

.usage-meter-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--c-text-muted);
}

.usage-meter[data-state="near"] .usage-meter-fill,
.usage-meter[data-state="full"] .usage-meter-fill {
  background: var(--c-warning);
}

.usage-meter-label {
  font-size: 0.82rem;
  color: var(--c-text-muted);
}

.usage-meter-note {
  font-size: 0.82rem;
  color: var(--c-text-muted);
}

/* Paid-only Telegram alerts: one line of copy plus the upgrade link, beside any locked alert switch. */
.telegram-lock-note {
  font-size: 0.82rem;
  color: var(--c-text-muted);
  margin: var(--sp-1) 0 var(--sp-2);
}

.usage-meter-cta {
  color: var(--c-accent-text);
  font-weight: 500;
  text-decoration: none;
}

.usage-meter-cta:hover {
  color: var(--c-link);
  text-decoration: underline;
}


/* Free tier: screener results stop at the previous trading day. One line of copy plus the upgrade link (static markup, shown by script). */
.screener-window-note {
  font-size: 0.82rem;
  color: var(--c-text-muted);
  margin: var(--sp-1) 0 var(--sp-2);
}

/* Small footnote under a screener list: results are shown with the scan's current filters. */
.screener-window-note[hidden],
.screener-footnote[hidden] { display: none; }

.screener-footnote {
  font-size: 0.78rem;
  color: var(--c-text-muted);
  margin: var(--sp-2) 0 0;
}

/* ── Accessible visually-hidden utility ───────────────────── */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Product tour (in-house overlay, CD-52/CD-53 §Wave-2) ──────────
   Four laws: the primary Next/Start/Finish button is the only blue
   (interactive) element; the spotlight ring and dim are neutral —
   never gold, never market up/down. */

.tour-root { position: fixed; inset: 0; z-index: 2000; pointer-events: none; }

.tour-overlay {
  position: fixed;
  inset: 0;
  background: transparent;   /* click-blocker; dim comes from the ring or --dim */
  pointer-events: auto;
}
.tour-overlay--dim { background: var(--c-scrim); }

.tour-overlay-piece {
  position: fixed;
  background: var(--c-scrim);
  pointer-events: auto;
}

.tour-ring {
  position: fixed;
  border: 2px solid var(--c-border-strong);
  border-radius: var(--r-card-sm);
  box-shadow: 0 0 0 9999px var(--c-scrim);
  pointer-events: none;
  transition: top var(--dur-base) var(--ease-out), left var(--dur-base) var(--ease-out), width var(--dur-base) var(--ease-out), height var(--dur-base) var(--ease-out);
}
.tour-ring--interactive { box-shadow: none; }

/* Popover: the only floating chrome besides the help sheet, so it carries --shadow-popover.
   tour.js positions it 12px off its target; the size and surface are set here. */
.tour-popover {
  position: fixed;
  z-index: 2001;
  width: min(320px, calc(100vw - 32px));
  max-width: 320px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-popover);
  padding: var(--sp-4);
  color: var(--c-text);
  pointer-events: auto;
}
.tour-popover-center {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.tour-close {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 44px;
  min-height: 44px;
  background: none;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--c-text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--r-btn);
}
.tour-close:hover { color: var(--c-text); background: var(--c-surface-hover); }

.tour-progress {
  font: var(--t-label);
  letter-spacing: 0;
  text-transform: none;
  color: var(--c-text-label);
  margin: 0 0 6px;
  padding-right: 40px;
}
.tour-title {
  font: var(--t-section);
  margin: 0 0 8px;
  color: var(--c-text);
}
.tour-body {
  font: var(--t-body);
  color: var(--c-text-muted);
  margin: 0 0 var(--sp-3);
}

/* Step popover (CD-83 1e, Somad 2026-11-13: three mixed buttons wrapped out of line).
   Row 1: the primary action, full width (Back + Next share it equally).
   Row 2: Continue later | Skip guide as one matching pair of quiet text buttons, one each side.
   CSS order only: DOM order (and the focus trap's .tour-btn-primary lookup) is unchanged. */
.tour-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.tour-actions-left,
.tour-actions-right { display: flex; align-items: center; gap: var(--sp-2); }
.tour-actions-right { order: 1; }
.tour-actions-right > .tour-btn { flex: 1 1 0; }
.tour-actions-left { order: 2; justify-content: space-between; margin: 0 -8px; }
.tour-actions-left > .tour-btn { padding: 0 8px; border-color: transparent; background: transparent; color: var(--c-text-label); font-weight: 500; }
.tour-actions-left > .tour-btn:hover { color: var(--c-text); background: var(--c-surface-hover); }
/* Chapter-complete popover: two buttons on one row, primary right. */
.tour-actions--end { flex-direction: row; justify-content: flex-end; flex-wrap: wrap; gap: var(--sp-2); }

.tour-btn {
  font: var(--t-btn);
  padding: 0 14px;
  min-height: 44px;
  white-space: nowrap;
  border-radius: var(--r-btn);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.tour-btn-primary {
  background: var(--c-accent);
  color: var(--c-text-inverse);
  border-color: var(--c-accent);
}
.tour-btn-primary:hover {
  background: var(--c-accent-hover);
  border-color: var(--c-accent-hover);
}
.tour-btn-ghost {
  background: transparent;
  color: var(--c-text-muted);
  border-color: var(--c-border);
}
.tour-btn-ghost:hover { color: var(--c-text); background: var(--c-surface-hover); border-color: var(--c-border-strong); }
.tour-btn-quiet {
  background: transparent;
  color: var(--c-text-label);
  border-color: transparent;
}
.tour-btn-quiet:hover { color: var(--c-text); background: var(--c-surface-hover); }
.tour-btn-sm { padding: 0 10px; font-size: 13px; }
.tour-btn:focus-visible { outline: 2px solid var(--c-border-focus); outline-offset: 2px; }

/* Resume pill — shown when the user wanders off the active step mid-tour.
   44px tall, bottom-right 16px inset; hidden while a drawer or FAB owns that corner. */
.tour-pill {
  position: fixed;
  right: 16px;
  bottom: calc(var(--sc-footer-h, 0px) + 16px);
  z-index: 2000;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 44px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-pill);
  padding: 0 var(--sp-2) 0 var(--sp-3);
  box-shadow: var(--shadow-popover);
}
.tour-pill-label { font: var(--t-small); color: var(--c-text-muted); }
body:has(.manual-drawer.open) .tour-pill { display: none; }
/* Calculator: the 44px help FAB owns the corner, so the pill steps left of it. */
body:has(#btn-manual-fab) .tour-pill { right: 76px; }

/* Help-menu items (reuses the notif-dropdown shell for positioning). */
#help-dropdown {
  width: min(390px, calc(100vw - 24px));
  max-height: min(620px, calc(100vh - 84px));
  overflow-y: auto;
}

.help-tour-status,
.help-guide-heading {
  display: block;
  padding: 9px 14px;
  color: var(--c-text-label);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.help-guide-list { margin: 0; padding: 0 6px 7px; }
.help-guide-links { border-top: 1px solid var(--c-border-soft); }
.help-whats-new { border-top: 1px solid var(--c-border-soft); }

.help-guide-button {
  width: 100%;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 9px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--c-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.help-guide-button:hover { background: var(--c-surface-2); }
.help-guide-button:disabled { opacity: .55; cursor: wait; }
.help-guide-index {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  color: var(--c-text-label);
  font-size: .72rem;
}
.help-guide-copy { min-width: 0; display: flex; flex-direction: column; }
.help-guide-copy strong { font-size: .84rem; font-weight: 600; }
.help-guide-copy small { color: var(--c-text-muted); font-size: .73rem; }
.help-guide-action { color: var(--c-accent-text); font-size: .76rem; font-weight: 600; }
.help-guide-button--new { grid-template-columns: minmax(0, 1fr) auto; }
.help-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font: inherit;
  font-size: 0.86rem;
  color: var(--c-text);
  padding: 9px 14px;
  cursor: pointer;
  text-decoration: none;
}
.help-menu-item:hover { background: var(--c-surface-2); }
.help-menu-item:focus-visible { outline: 2px solid var(--c-border-focus); outline-offset: -2px; }

@media (max-width: 639px) {
  #help-dropdown {
    position: fixed;
    top: calc(var(--shell-header-h) + 8px);
    right: 12px;
    left: 12px;
    width: auto;
  }

  /* Phones: 16px inputs prevent iOS zoom on focus (3.1 input role). */
  .form-input { font-size: 16px; }

  /* Bottom sheet: docks above the SC footer (when the page reports its height) with a 12px inset. */
  .tour-popover,
  .tour-popover-center {
    top: auto !important;
    right: 12px;
    bottom: calc(var(--sc-footer-h, 0px) + var(--tabbar-h, 0px) + 12px);
    left: 12px !important;
    width: auto;
    max-width: none;
    max-height: min(76vh, 620px);
    overflow-y: auto;
    transform: none;
    border: 1px solid var(--c-border);
    border-radius: var(--r-card);
    padding: var(--sp-4) var(--sp-3) max(var(--sp-4), env(safe-area-inset-bottom));
  }
  .tour-actions--end { flex-direction: row; }
  .tour-pill {
    right: 12px;
    bottom: calc(var(--sc-footer-h, 0px) + var(--tabbar-h, 0px) + max(12px, env(safe-area-inset-bottom)));
    left: 12px;
    justify-content: center;
    flex-wrap: wrap;
    border-radius: var(--r-card);
    padding: var(--sp-1) var(--sp-2);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tour-ring { transition: none; }
}

/* Sector marker (kind of thing -> one of the six data hues). */
.sec-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 2px;
  vertical-align: 1px;
  background: var(--sd, var(--c-data-6));
  flex: none;
}
.sd1 { --sd: var(--c-data-1); } .sd2 { --sd: var(--c-data-2); } .sd3 { --sd: var(--c-data-3); }
.sd4 { --sd: var(--c-data-4); } .sd5 { --sd: var(--c-data-5); } .sd6 { --sd: var(--c-data-6); }

/* ── Rounded highlights (CD-83 A1, 2026-11-13) ──────────────────
   Every hover / selected wash follows the rounded language: no square full-bleed rectangles.
   List rows: the wash is an inset pseudo layer (3px 6px from the row edge, --r-nav radius), so row
   layout, rules and widths stay unchanged. Tables: separate borders (cells carry bottom rules only,
   so nothing doubles) and rounded end cells; desktop table layout only (journal/trades turn into
   cards at <=720px). The rule under and above the hovered row hides so the pill floats cleanly. */
.be-row, .notif-item, .help-menu-item { position: relative; isolation: isolate; }
.be-row::before, .notif-item::before, .help-menu-item::before {
  content: "";
  position: absolute;
  inset: 3px 6px;
  z-index: -1;
  border-radius: var(--r-nav);
  background: var(--c-surface-hover);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease-out);
}
.be-row:hover::before, .notif-item:hover::before, .help-menu-item:hover::before { opacity: 1; }
.notif-item:hover, .help-menu-item:hover { background: transparent; }
/* motion.css .ring draws its hover ring at border-radius: inherit; on a row that was a square box. Match the wash pill. */
.be-row.ring::after { inset: 3px 6px; border-radius: var(--r-nav); }
.help-menu-item:focus-visible { border-radius: var(--r-nav); }

@media (min-width: 721px) {
  .stock-table, .results-table, .journal-table, .jv-table, #trades-table { border-collapse: separate; border-spacing: 0; }
  .stock-table tbody tr:hover { background: transparent; }
  .stock-table tbody tr:hover > td { background: var(--c-surface-hover); }
  :is(.stock-table, .results-table, .journal-table, .jv-table) tbody tr:is(:hover, .sel) > td:first-child,
  #trades-table tbody tr:hover > td:first-child { border-top-left-radius: var(--r-nav); border-bottom-left-radius: var(--r-nav); }
  :is(.stock-table, .results-table, .journal-table, .jv-table) tbody tr:is(:hover, .sel) > td:last-child,
  #trades-table tbody tr:hover > td:last-child { border-top-right-radius: var(--r-nav); border-bottom-right-radius: var(--r-nav); }
  .results-table tbody tr.sel > td, .results-table tbody tr:has(+ tr.sel) > td { border-bottom-color: transparent; }
  :is(.stock-table, .results-table, .journal-table, .jv-table) tbody tr:is(:hover, :has(+ tr:hover)) > td,
  #trades-table tbody tr:is(:hover, :has(+ tr:hover)) > td { border-bottom-color: transparent; }
}
