﻿/* ─────────────────────────────────────────────────────────────
   BursaEdge V2 — Pass 1 (Combo 5: Arc shell + TV data + Stripe type)
   Light mode active. Dark mode pre-defined under [data-theme="dark"]
   for future toggle — toggle button NOT shipped this pass.
   ───────────────────────────────────────────────────────────── */

:root {
  /* Type system */
  --font-sans: 'Segoe UI Variable Text', 'Segoe UI', -apple-system, system-ui, sans-serif;
  --font-display: 'Palatino Linotype', 'Iowan Old Style', Palatino, Georgia, serif;
  --font-mono: 'Cascadia Mono', Consolas, ui-monospace, monospace;
  --font-features: "tnum", "cv11", "ss01";

  /* Spacing */
  --sp-1: 8px;
  --sp-2: 12px;
  --sp-3: 16px;
  --sp-4: 24px;
  --sp-5: 32px;
  --sp-6: 48px;

  /* Radii */
  --r-card: 16px;
  --r-card-sm: 10px;
  --r-pill: 999px;
  --r-btn: 10px;
  --r-input: 8px;

  /* Layout */
  --sidebar-w: 240px;
  --rail-w: 320px;
  --topbar-h: 60px;
  --content-max: 1440px;

  /* Dark Ledger is the first paint. */
  --c-bg: #0C0B09;
  --c-surface: #17140F;
  --c-surface-2: #211C15;
  --c-surface-hover: #2A241B;

  --c-border: #3A3126;
  --c-border-warm: rgba(217,169,63,.32);
  --c-border-sky: rgba(108,155,255,.28);
  --c-border-soft: #292219;
  --c-border-focus: var(--c-accent);

  --c-text: #F2EDE3;
  --c-text-muted: #B5AA96;
  --c-text-label: #8A806F;
  --c-text-inverse: #0C0B09;

  /* Data colors (TradingView) */
  --c-up: #33C27D;
  --c-down: #E8505B;
  --c-up-bg: rgba(51,194,125,.12);
  --c-down-bg: rgba(232,80,91,.12);
  --c-up-bg-soft: rgba(51,194,125,.06);
  --c-down-bg-soft: rgba(232,80,91,.06);

  /* Accent (Stripe violet) */
  --c-accent: #6C9BFF;
  --c-accent-hover: #8BB1FF;
  --c-accent-soft: rgba(108,155,255,.12);
  --c-accent-text: #A9C3FF;
  --c-gold: #D9A93F;
  --c-gold-bright: #EFC463;

  --c-warning: #b45309;
  --c-warning-bg: #fef3c7;

  /* Gradient washes (Arc) */
  --wash-cool: linear-gradient(180deg, rgba(108,155,255,.08) 0%, rgba(20,18,14,0) 100%);
  --wash-sky: linear-gradient(180deg, rgba(108,155,255,.05) 0%, rgba(20,18,14,0) 100%);
  --wash-warm: linear-gradient(180deg, rgba(217,169,63,.08) 0%, rgba(20,18,14,0) 100%);
  --wash-mint: linear-gradient(180deg, rgba(51,194,125,.05) 0%, rgba(20,18,14,0) 100%);

  /* Logo mark gradient */
  --logo-gradient: linear-gradient(135deg, #6C9BFF 0%, #8B7CFF 100%);

  /* Dark Ledger shadows: neutral depth between page, cards, and popovers. */
  --shadow-hairline:
    0 1px 0 rgba(255,255,255,.025),
    0 4px 12px rgba(0,0,0,.18);
  --shadow-card:
    0 1px 0 rgba(255,255,255,.025),
    0 12px 32px rgba(0,0,0,.32);
  --shadow-card-hover:
    0 1px 0 rgba(255,255,255,.035),
    0 16px 42px rgba(0,0,0,.40);
  --shadow-popover:
    0 24px 70px rgba(0,0,0,.55),
    0 0 0 1px rgba(255,255,255,.025);

  /* Skeleton shimmer */
  --skeleton-base: #eef0f5;
  --skeleton-shine: #f7f8fb;

  /* KLCI chart stroke */
  --klci-stroke: #7b5cff;
  --klci-stroke-soft: rgba(123, 92, 255, 0.18);

  /* Sidebar gradient */
  --sidebar-grad: linear-gradient(180deg, #14120E 0%, #0C0B09 100%);

  /* 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"] {
  --c-bg: #F4F5F8;
  --c-surface: #FFFFFF;
  --c-surface-2: #EEF0F5;
  --c-surface-hover: #E3E6EE;

  --c-border: #D5D9E4;
  --c-border-warm: rgba(206,155,24,.50);
  --c-border-sky: rgba(46,91,255,.25);
  --c-border-soft: #E6E9F0;

  /* Warning — brighter amber text on low-alpha amber bg for dark surfaces */
  --c-warning: #fbbf24;
  --c-warning-bg: rgba(251, 191, 36, 0.10);

  /* Source badge text — lighter hues for dark surfaces */
  --c-source-momentum:    #6ea8fe;
  --c-source-btst:        #c084fc;
  --c-source-friday-pre:  #fcd34d;
  --c-source-friday-rule: #f87171;

  --c-text: #181A20;
  --c-text-muted: #565D6D;
  --c-text-label: #8A90A0;
  --c-text-inverse: #F4F5F8;

  --c-up: #0FA35E;
  --c-down: #E0333F;
  --c-up-bg: rgba(15,163,94,.13);
  --c-down-bg: rgba(224,51,63,.13);
  --c-up-bg-soft: rgba(15,163,94,.06);
  --c-down-bg-soft: rgba(224,51,63,.06);

  --c-accent: #2E5BFF;
  --c-accent-hover: #244BE0;
  --c-accent-soft: rgba(46,91,255,.14);
  --c-accent-text: #2E5BFF;
  --c-gold: #B98218;
  --c-gold-bright: #79520A;
  --c-gold-soft: rgba(185,130,24,.13);
  --c-gold-line: rgba(160,108,10,.34);
  --c-gold-glow: rgba(217,169,63,.16);

  --wash-cool: linear-gradient(180deg, rgba(123, 92, 255, 0.06) 0%, rgba(15, 22, 35, 0) 100%);
  --wash-sky: linear-gradient(180deg, rgba(76, 184, 255, 0.06) 0%, rgba(15, 22, 35, 0) 100%);
  --wash-warm: linear-gradient(180deg, rgba(255, 138, 76, 0.05) 0%, rgba(15, 22, 35, 0) 100%);
  --wash-mint: linear-gradient(180deg, rgba(28, 184, 120, 0.05) 0%, rgba(15, 22, 35, 0) 100%);

  --shadow-hairline: 0 1px 0 rgba(0, 0, 0, 0.4);
  --shadow-card: 0 1px 0 rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-card-hover: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-popover: 0 10px 40px rgba(0, 0, 0, 0.5);

  --skeleton-base: #161f30;
  --skeleton-shine: #1e2a40;

  /* KLCI chart stroke */
  --klci-stroke: #4fffb0;
  --klci-stroke-soft: rgba(79, 255, 176, 0.22);

  /* Light Ledger sidebar: mineral blue paper, not a dark slab. */
  --sidebar-grad:
    radial-gradient(circle at 0 0, var(--c-gold-glow) 0%, transparent 34%),
    linear-gradient(180deg, #EEF2F8 0%, #DCE5F2 100%);
  --sidebar-ink: #24324D;
  --sidebar-muted: #52627F;
  --sidebar-label: #71809A;
  --sidebar-line: #C4D0E2;
  --sidebar-panel: rgba(255,255,255,.72);
}

/* ── Reset ──────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Global keyboard focus ring ─────────────────────────────── */

:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
  border-radius: inherit;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.55;
  color: var(--c-text);
  background: var(--c-bg);
  font-feature-settings: var(--font-features);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

/* Dark Ledger V1 shell: reference composition, shared by every app surface. */
body { background: var(--c-bg); }
.sidebar { border-right-color: var(--c-border-soft); }
.sidebar-brand { min-height: 76px; padding: 0 var(--sp-3); border-bottom: 1px solid var(--c-border-soft); }
.logo-mark { background: var(--logo-gradient); box-shadow: none; color: #fff; border: 0; }
.brand-wordmark { font-family: var(--font-display); font-size: 1.32rem; letter-spacing: -.025em; }
.brand-wordmark span { color: var(--c-gold-bright); }
.brand-wordmark-sub, .sidebar-section-label { font-family: var(--font-sans); font-size: .61rem; letter-spacing: .18em; color: var(--c-text-label); }
.nav-item { border-radius: 6px; margin: 2px 10px; color: var(--c-text-muted); }
.nav-item:hover, .nav-item.active { background: var(--c-accent-soft); color: var(--c-accent); }
.nav-item.active::before { background: var(--c-accent); }
.nav-badge, .nav-badge--new { background: var(--c-surface-hover); border-color: var(--c-border); color: var(--c-text-label); }
[data-theme="light"] .sidebar {
  border-right-color: var(--sidebar-line);
  box-shadow: inset -1px 0 rgba(255,255,255,.72), 10px 0 32px rgba(47,65,96,.06);
}
[data-theme="light"] .sidebar-brand,
[data-theme="light"] .sidebar-section + .sidebar-section {
  border-color: color-mix(in srgb, var(--c-gold) 34%, var(--sidebar-line));
}
[data-theme="light"] .brand-wordmark { color: var(--sidebar-ink); }
[data-theme="light"] .brand-wordmark-sub,
[data-theme="light"] .sidebar-section-label { color: var(--c-gold-bright); }
[data-theme="light"] .nav-item { color: var(--sidebar-muted); }
[data-theme="light"] .nav-item:hover { background: rgba(255,255,255,.58); color: var(--sidebar-ink); }
[data-theme="light"] .nav-item.active {
  background: linear-gradient(90deg, var(--c-gold-soft), rgba(255,255,255,.44));
  color: #2448C7;
  box-shadow: inset 3px 0 var(--c-gold), inset 0 0 0 1px var(--c-gold-line);
}
[data-theme="light"] .nav-item.locked,
[data-theme="light"] .nav-item.locked:hover { color: #7A879D; background: transparent; }
[data-theme="light"] .sidebar-foot {
  color: var(--sidebar-muted);
  background:
    radial-gradient(circle at 100% 0, var(--c-gold-glow), transparent 44%),
    linear-gradient(145deg, rgba(255,255,255,.94), rgba(246,249,254,.76));
  border-color: var(--c-gold-line);
  box-shadow: 0 12px 28px rgba(47,65,96,.08), inset 0 1px rgba(255,255,255,.9);
}
[data-theme="light"] .sidebar-foot .live-row { color: var(--sidebar-ink); }
[data-theme="light"] .sidebar-foot .label-cap { color: var(--c-gold-bright); }
[data-theme="light"] .topbar {
  border-bottom-color: var(--c-gold-line);
  box-shadow: 0 1px 0 rgba(255,255,255,.8), 0 8px 24px rgba(121,82,10,.04);
}
[data-theme="light"] .tier-pill {
  color: var(--c-gold-bright);
  background: linear-gradient(135deg, rgba(255,250,235,.96), var(--c-gold-soft));
  border-color: var(--c-gold-line);
  box-shadow: inset 0 1px rgba(255,255,255,.9);
}
[data-theme="light"] .greeting-card {
  background:
    radial-gradient(circle at 92% 12%, var(--c-gold-glow), transparent 34%),
    linear-gradient(135deg, var(--c-surface), var(--c-surface-2));
  border-color: var(--c-gold-line);
}
[data-theme="light"] .ledger-kicker,
[data-theme="light"] .ledger-radar > span:not(.ledger-kicker) { color: var(--c-gold-bright); }
[data-theme="light"] .ledger-workbench-card,
[data-theme="light"] .metric-card { border-top-color: var(--c-gold-line); }
[data-theme="light"] .tile-featured {
  border-color: var(--c-gold-line);
  box-shadow: 0 12px 30px rgba(121,82,10,.07);
}
.topbar { background: color-mix(in srgb, var(--c-surface) 94%, transparent); border-bottom-color: var(--c-border-soft); }
.topbar-icon-btn, .theme-toggle { color: var(--c-text-muted); border-color: var(--c-border); background: var(--c-surface-2); }
.markets-pill { color: var(--c-text-muted); background: var(--c-surface-2); border-color: var(--c-border); }
.tier-pill { color: var(--c-gold-bright); background: color-mix(in srgb, var(--c-gold) 10%, var(--c-surface)); border-color: color-mix(in srgb, var(--c-gold) 32%, var(--c-border)); }
.main-content { background: var(--c-bg); }
.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, .metric-value { font-family: var(--font-display); letter-spacing: -.02em; }
.greeting { font-size: clamp(2rem, 4vw, 3.2rem); }
.greeting-card { background: linear-gradient(135deg, var(--c-surface), var(--c-surface-2)); }
.tile-featured { border-color: var(--c-gold-line, var(--c-border-warm)); }
.tile-icon { color: var(--c-accent); 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: #fff; }
.btn-primary:hover, .button-primary:hover, .jv-btn-primary:hover { background: var(--c-accent-hover); }
.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); font-size: .8rem; }
.ledger-kicker { color: var(--c-text-label); font-size: .64rem; font-weight: 700; letter-spacing: .18em; }
.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; }
.ledger-radar, .ledger-pulse-item, .ledger-workbench-card { background: var(--c-surface); padding: var(--sp-4); }
.ledger-radar { background: radial-gradient(circle at 72% 12%, rgba(217,169,63,.14), transparent 42%), var(--c-surface); border-left: 1px solid var(--c-border-warm); }
.ledger-radar strong { display: inline-block; font-family: var(--font-display); font-size: 3.1rem; font-weight: 500; color: var(--c-gold-bright); line-height: 1; margin: var(--sp-2) 4px var(--sp-2) 0; }
.ledger-radar > span:not(.ledger-kicker) { color: var(--c-gold); font-family: var(--font-mono); }
.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-display); 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; }
.ledger-money, .ledger-streak { display: block; margin-bottom: var(--sp-2); color: var(--c-text); font-family: var(--font-display); font-size: 1.65rem; font-weight: 500; }
.ledger-mono { font-family: var(--font-mono); font-size: .72rem !important; line-height: 1.8; }

/* Dark Ledger depth pass: neutral hierarchy only; Light Ledger stays frozen. */
:root:not([data-theme="light"]) .sidebar {
  border-right-color: var(--c-border);
  box-shadow: inset -1px 0 rgba(255,255,255,.02), 12px 0 32px rgba(0,0,0,.20);
}
:root:not([data-theme="light"]) .topbar {
  border-bottom-color: var(--c-border);
  box-shadow: 0 10px 28px rgba(0,0,0,.22);
}
:root:not([data-theme="light"]) .right-rail {
  border-left-color: var(--c-border);
  box-shadow: -10px 0 30px rgba(0,0,0,.16);
}
:root:not([data-theme="light"]) .main-column {
  background: radial-gradient(circle at 42% -8%, rgba(242,237,227,.025), transparent 34%), var(--c-bg);
}
:root:not([data-theme="light"]) .main-content {
  background: transparent;
}

:root:not([data-theme="light"]) .ledger-pulse {
  padding: var(--sp-4);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-hairline);
}
:root:not([data-theme="light"]) .ledger-pulse-grid,
:root:not([data-theme="light"]) .ledger-workbench-card {
  box-shadow: var(--shadow-card);
}

:root:not([data-theme="light"]) .greeting,
:root:not([data-theme="light"]) .ledger-section-head h2,
:root:not([data-theme="light"]) .jv-page-title {
  text-shadow: 0 2px 16px rgba(0,0,0,.72), 0 1px 0 rgba(255,255,255,.025);
}
:root:not([data-theme="light"]) .ledger-radar strong {
  text-shadow: 0 3px 20px rgba(0,0,0,.68);
}
/* End Dark Ledger depth pass. */

@media (max-width: 760px) {
  .sidebar-brand { min-height: 64px; }
  .greeting { font-size: 2.1rem; }
  .main-content { padding: var(--sp-3); }
  .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 0.15s ease;
}
a:hover { color: var(--c-accent-hover); text-decoration: underline; }

button { font-family: inherit; }

.hidden { display: none !important; }

/* Numerics: tabular alignment everywhere */
.num,
.tabular {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* Section labels (small caps, label color) */
.section-label {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  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: 9px 16px;
  border-radius: var(--r-btn);
  font-size: 0.88rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.05s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--c-accent);
  color: #ffffff;
  border-color: var(--c-accent);
}
.btn-primary:hover { background: var(--c-accent-hover); border-color: var(--c-accent-hover); color: #ffffff; text-decoration: none; }

.btn-secondary {
  background: var(--c-surface);
  color: var(--c-text);
  border-color: var(--c-border);
}
.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 0.15s ease, color 0.15s ease, background 0.15s ease;
  /* 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-down);
  color: var(--c-down);
  background: var(--c-down-bg-soft);
}

/* ── Inputs ─────────────────────────────────────────────────── */

.input {
  width: 100%;
  padding: 10px 12px;
  background: var(--c-surface);
  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 0.15s ease, box-shadow 0.15s ease;
}
.input::placeholder { color: var(--c-text-label); }
.input:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px var(--c-accent-soft);
}
.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);
  background: var(--c-bg);
  background-image: var(--wash-cool);
  background-attachment: fixed;
}

.auth-container { width: 100%; max-width: 420px; }

.auth-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-card);
  padding: var(--sp-5);
  text-align: center;
  box-shadow: var(--shadow-card);
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--sp-5);
}
.brand-name {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--c-text);
}
.brand-tag {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--c-text-label);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.brand-logo {
  display: block;
  width: 56px;
  height: auto;
  margin-bottom: 2px;
}

.status-message { padding: var(--sp-3) 0; }
.status-message h2 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--c-text);
  margin-bottom: var(--sp-1);
}
.status-message p {
  font-size: 0.88rem;
  color: var(--c-text-muted);
  line-height: 1.6;
}

.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-size: 0.78rem;
  font-weight: 500;
  color: var(--c-text);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}
.form-input {
  width: 100%;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-input);
  color: var(--c-text);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-feature-settings: var(--font-features);
  padding: 0 12px;
  height: 44px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-input:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px var(--c-accent-soft);
}
.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); }

.pw-wrap { position: relative; }
.pw-wrap .form-input { padding-right: 44px; }
.pw-toggle {
  position: absolute; right: 0; top: 0;
  width: 44px; height: 44px;
  background: none; border: none;
  cursor: pointer;
  color: var(--c-text-label);
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s ease;
}
.pw-toggle:hover { color: var(--c-text); }

.btn-submit {
  width: 100%;
  height: 44px;
  background: var(--c-accent);
  color: #ffffff;
  border: none;
  border-radius: var(--r-btn);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: var(--sp-3);
  transition: background 0.15s ease, opacity 0.15s ease;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none;
}
.btn-submit:hover:not(:disabled) {
  background: var(--c-accent-hover);
  color: #ffffff; text-decoration: none;
}
.btn-submit:disabled { opacity: 0.55; cursor: not-allowed; }

.spinner-sm {
  width: 16px; height: 16px;
  border: 2px solid color-mix(in srgb, var(--c-bg) 25%, transparent);
  border-top-color: #ffffff;
  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-size: 0.82rem;
  color: var(--c-down);
  min-height: 20px;
  text-align: center;
  line-height: 1.5;
}

.auth-link {
  display: block;
  text-align: center;
  font-size: 0.82rem;
  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; }

.helper-text {
  font-size: 0.85rem;
  color: var(--c-text-muted);
  line-height: 1.6;
  margin-bottom: var(--sp-3);
  text-align: center;
}

.consent-note {
  text-align: center;
  font-size: 0.74rem;
  color: var(--c-text-muted);
  margin-top: var(--sp-2);
  line-height: 1.55;
}
.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-size: 0.78rem;
  color: var(--c-text-muted);
  margin-top: 6px;
  letter-spacing: 0.005em;
  line-height: 1.5;
}

.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(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.auth-card { animation: auth-card-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) 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;
  transition: top 0.15s ease;
}
.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;
  background: var(--c-bg);
  overflow-x: clip;
  /* Prevent sidebar fixed-width from forcing page wider than viewport on mobile */
  max-width: 100vw;
}

/* 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;
  overflow-x: hidden;
}

@media (min-width: 1281px) {
  .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(--c-border-soft);
  display: flex;
  flex-direction: column;
  padding: var(--sp-3) var(--sp-2);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px var(--sp-3);
  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(--c-border-soft);
}

.sidebar-section-label {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-text-label);
  padding: 6px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-card-sm);
  font-size: 0.88rem;
  font-weight: 400;
  color: var(--c-text-muted);
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease;
  position: relative;
}
.nav-item:hover {
  background: var(--c-surface-hover);
  color: var(--c-text);
  text-decoration: none;
}
.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: currentColor;
  stroke-width: 1.8;
}
.nav-item .nav-label { flex: 1; }
.nav-item.active {
  background: var(--c-accent-soft);
  color: var(--c-text);
  font-weight: 500;
}
[data-theme="dark"] .nav-item.active {
  color: var(--c-accent-text);
}
.nav-item.locked {
  color: var(--c-text-label);
  cursor: not-allowed;
}
.nav-item.locked:hover {
  background: transparent;
  color: var(--c-text-label);
}
.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: var(--c-surface-2);
  color: var(--c-text-label);
}
.nav-item .nav-badge-phase {
  background: #ece6ff;
  color: #5a3fd6;
}
[data-theme="dark"] .nav-item .nav-badge-phase {
  background: rgba(123, 92, 255, 0.18);
  color: #b8a3ff;
}

.sidebar-foot {
  margin-top: auto;
  padding: 12px;
  border-radius: 14px;
  background: var(--wash-cool), var(--c-surface);
  border: 1px solid var(--c-border);
  font-size: 0.76rem;
  color: var(--c-text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow-hairline);
}
.sidebar-foot .live-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-weight: 500;
  color: var(--c-text);
}
.sidebar-foot .label-cap {
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-text-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: 14px var(--sp-4);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border-soft);
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: var(--topbar-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 0.12s ease;
}
.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 12px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-card-sm);
  max-width: 480px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.topbar-search:focus-within {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px var(--c-accent-soft);
  background: var(--c-surface);
}
.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: 36px;
  height: 36px;
  min-width: 40px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: var(--r-card-sm);
  color: var(--c-text-muted);
  cursor: pointer;
  position: relative;
  transition: background 0.12s ease, color 0.12s ease;
}
.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-surface);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--logo-gradient);
  color: #ffffff;
  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-up-bg);
  color: var(--c-up);
  border: 1px solid var(--c-up-bg);
}

/* ── Markets status pill ────────────────────────────────────── */

.markets-pill {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  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 0.15s ease, color 0.15s ease;
}
.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;
}

.topbar-inline-search {
  width: 0;
  max-width: 0;
  padding: 0;
  border: none;
  background: transparent;
  font-size: 0.84rem;
  color: var(--c-text);
  outline: none;
  transition: width 0.18s ease, max-width 0.18s ease, padding 0.18s ease, border-color 0.18s ease;
  border-radius: var(--r-card-sm);
  overflow: hidden;
}
.topbar-inline-search::placeholder { color: var(--c-text-label); }
.topbar-inline-search:not([hidden]) {
  width: 160px;
  max-width: 160px;
  padding: 5px 10px;
  border: 1px solid var(--c-border);
  background: var(--c-surface);
}
.topbar-inline-search:focus { border-color: var(--c-accent); box-shadow: 0 0 0 2px var(--c-accent-soft); }

/* ── 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-card);
  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 {
  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);
}

.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);
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-up);
  flex-shrink: 0;
  animation: pulse-dot 2s ease-out infinite;
}
@keyframes pulse-dot {
  0%   { box-shadow: 0 0 0 0 rgba(10, 128, 80, 0.45); }
  70%  { box-shadow: 0 0 0 6px rgba(10, 128, 80, 0); }
  100% { box-shadow: 0 0 0 0 rgba(10, 128, 80, 0); }
}

/* ── Card primitive ─────────────────────────────────────────── */

.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border-soft);
  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 0.12s ease;
}
.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-soft);
  border-radius: var(--r-card);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-hairline);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.metric-card:hover { border-color: var(--c-border); 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-accent);
  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); }
.change-pill.down { background: var(--c-down-bg); color: var(--c-down); }

/* ── 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(--wash-warm);   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-card-sm);
  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 12px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--c-text-muted);
  cursor: pointer;
  border: none;
  background: transparent;
  font-family: inherit;
  transition: background 0.12s ease, color 0.12s ease;
  flex-shrink: 0;
}
.tab:hover { color: var(--c-text); }
.tab.active {
  background: var(--c-surface);
  color: var(--c-text);
  box-shadow: var(--shadow-hairline);
}

/* ── Stock table ────────────────────────────────────────────── */

.stock-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.stock-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.stock-table th,
.stock-table td {
  padding: 10px 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-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-text-label);
  background: transparent;
  border-bottom: 1px solid var(--c-border-soft);
}
.stock-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--c-text);
  font-weight: 500;
}
.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 0.1s ease;
}
.stock-table tbody tr:hover { background: var(--c-surface-2); }

/* ── 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);
  background: var(--c-accent-soft);
  color: var(--c-accent-text);
}

/* Scan-pill type variants */
.scan-pill.momentum  { background: #ece6ff; color: #5a3fd6; }
.scan-pill.btst      { background: #fef0e0; color: #a26418; }
.scan-pill.prebreak  { background: #d9ecff; color: #1a5fb4; }
.scan-pill.friday-rule { background: #fde8f3; color: #a01b6b; }

[data-theme="dark"] .scan-pill.momentum  { background: rgba(123,92,255,0.18); color: #b8a3ff; }
[data-theme="dark"] .scan-pill.btst      { background: rgba(255,172,64,0.18); color: #ffc784; }
[data-theme="dark"] .scan-pill.prebreak  { background: rgba(76,184,255,0.18); color: #8fcdff; }
[data-theme="dark"] .scan-pill.friday-rule { background: rgba(255,82,164,0.18); color: #ff9bce; }

/* ── Right rail ─────────────────────────────────────────────── */

.right-rail {
  border-left: 1px solid var(--c-border-soft);
  background: var(--c-surface);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  overflow-y: auto;
}

@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; }
}

/* ── 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-soft);
  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 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
  box-shadow: var(--shadow-hairline);
}
.tile-active { cursor: pointer; }
.tile-active:hover {
  border-color: var(--c-accent);
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
  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);
  box-shadow: 0 6px 20px rgba(99, 91, 255, 0.12);
}

.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, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0.85) 100%);
  text-align: center;
}
.locked-card > .locked-overlay { display: flex; }
[data-theme="dark"] .locked-overlay {
  background: linear-gradient(180deg, color-mix(in srgb, var(--c-bg) 55%, transparent) 0%, color-mix(in srgb, var(--c-bg) 92%, transparent) 100%);
}
.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: 280px;
    height: 100vh;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-popover);
  }
  .sidebar.open { transform: translateX(0); }
  .topbar { padding: 12px var(--sp-3); flex-wrap: wrap; }
  .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: rgba(0, 0, 0, 0.5);
  z-index: 25;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.sidebar-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
@media (min-width: 880px) {
  .sidebar-backdrop { display: none; }
}

/* ── 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-accent) 14%, var(--c-surface-2)); }
.heatmap-cell.h2 { background: color-mix(in srgb, var(--c-accent) 28%, var(--c-surface-2)); }
.heatmap-cell.h3 { background: color-mix(in srgb, var(--c-accent) 42%, var(--c-surface-2)); color: var(--c-text); }
.heatmap-cell.h4 { background: color-mix(in srgb, var(--c-accent) 60%, var(--c-surface-2)); color: var(--c-text); }
.heatmap-cell.h5 { background: var(--c-accent); color: var(--c-surface); }
.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 120ms ease;
}

/* ── 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: #ffffff;
  margin-right: 8px;
  flex-shrink: 0;
}
.ticker-mark.m1 { background: linear-gradient(135deg, #7b5cff 0%, #4cb8ff 100%); }
.ticker-mark.m2 { background: linear-gradient(135deg, #ff8a4c 0%, #ff5c8a 100%); }
.ticker-mark.m3 { background: linear-gradient(135deg, #4fd896 0%, #4cb8ff 100%); }
.ticker-mark.m4 { background: linear-gradient(135deg, #ff5c8a 0%, #a04cff 100%); }
.ticker-mark.m5 { background: linear-gradient(135deg, #ffc744 0%, #ff8a4c 100%); }

/* ── 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: linear-gradient(90deg, #fde8a3 0%, #ffd47a 100%);
  color: #5a3a00;
  font-size: 0.86rem;
  font-weight: 600;
  border-bottom: 1px solid #e5b347;
}
/* [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; }
[data-theme="dark"] .smoke-ribbon {
  background: linear-gradient(90deg, #4a3a00 0%, #5a4400 100%);
  color: #ffd47a;
  border-bottom-color: #6a5500;
}
.smoke-ribbon .smoke-pill {
  background: rgba(0,0,0,0.12);
  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: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--c-border-soft);
  background: var(--c-surface);
  color: var(--c-text-muted);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.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 0.12s ease;
  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 0.12s ease;
}

.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 0.12s ease, color 0.12s ease;
  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;
}

[data-theme="dark"] .nav-subitem.active {
  color: var(--c-accent-text);
}


/* ═══════════════════════════════════════════════════════════════
   Pulse module — screener dashboard, filter builder, results
   ═════════════════════════════════════════════════════════════== */

/* ── Pulse source CSS vars ──────────────────────────────────── */
:root {
  --c-source-momentum:    #1a5fb4;
  --c-source-btst:        #7c3aed;
  --c-source-friday-pre:  #b45309;
  --c-source-friday-rule: #c0392b;
}

/* ── Nav badge — V2 new release ─────────────────────────────── */
.nav-item .nav-badge--new {
  background: #d1fae5;
  color: #065f46;
}
[data-theme="dark"] .nav-item .nav-badge--new {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
}

/* ── 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-size: 1.3rem;
  font-weight: 700;
  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: 8px;
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 0.88rem;
}
.pulse-search:focus,
.pulse-source-select:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px var(--c-accent-soft);
}
.pulse-search:focus:not(:focus-visible),
.pulse-source-select:focus:not(:focus-visible) { outline: none; }
.pulse-source-select {
  padding: 8px 12px;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  background: var(--c-surface);
  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: 12px;
  padding: 18px 20px;
  cursor: pointer;
  transition: box-shadow 150ms ease, border-color 150ms ease;
  text-decoration: none;
  display: block;
  color: inherit;
}
.scan-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  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;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}
.scan-source-badge.source-momentum {
  background: rgba(46, 123, 255, 0.12);
  color: var(--c-source-momentum);
}
.scan-source-badge.source-btst {
  background: rgba(180, 92, 255, 0.12);
  color: var(--c-source-btst);
}
.scan-source-badge.source-friday-pre {
  background: rgba(243, 156, 18, 0.12);
  color: var(--c-source-friday-pre);
}
.scan-source-badge.source-friday-rule {
  background: rgba(231, 76, 60, 0.12);
  color: var(--c-source-friday-rule);
}
[data-theme="dark"] .scan-source-badge.source-momentum  { background: rgba(46, 123, 255, 0.2); }
[data-theme="dark"] .scan-source-badge.source-btst       { background: rgba(180, 92, 255, 0.2); }
[data-theme="dark"] .scan-source-badge.source-friday-pre { background: rgba(243, 156, 18, 0.2); }
[data-theme="dark"] .scan-source-badge.source-friday-rule{ background: rgba(231, 76, 60, 0.2); }

/* ── Preset card ────────────────────────────────────────────── */
.preset-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: 18px 20px;
  transition: box-shadow 150ms ease, border-color 150ms ease;
}
.preset-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  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-accent);
  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;
  border-bottom: 2px solid var(--c-border);
  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-2); }
/* 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: linear-gradient(90deg, #2E7BFF 0%, #16a34a 100%);
  transition: width 300ms ease;
}

/* ── 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: #16a34a; }
.pillar-dot.on[data-pillar="1"]   { background: #2E7BFF; }
.pillar-dot.on[data-pillar="2"]   { background: #B45CFF; }
.pillar-dot.on[data-pillar="3"]   { background: #d97706; }
.pillar-dot.on[data-pillar="4"]   { background: #16a34a; }
.pillar-dot.on[data-pillar="5"]   { background: #E74C3C; }

/* ── Risk flags ─────────────────────────────────────────────── */
.risk-flag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  background: #fef2f2;
  color: #b91c1c;
  margin: 2px;
}
[data-theme="dark"] .risk-flag {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

/* ── 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: #f0fdf4;
  color: #15803d;
}
[data-theme="dark"] .shariah-badge {
  background: rgba(22, 163, 74, 0.15);
  color: #86efac;
}

/* ── 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: rgba(255,255,255,0.88);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 10;
  border-radius: 12px;
  padding: 32px;
  text-align: center;
}
[data-theme="dark"] .locked-overlay-mask { background: rgba(15, 20, 30, 0.88); }
.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: 12px;
  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 120ms ease, color 120ms ease;
}
.scan-tab:hover { background: var(--c-surface-2); color: var(--c-text); }
.scan-tab.active { background: var(--c-accent); color: #fff; }

/* ── Flash banner (post-save redirect) ──────────────────────── */
.pulse-flash {
  padding: 10px 16px;
  background: #d1fae5;
  color: #065f46;
  border-radius: 8px;
  font-size: 0.87rem;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
[data-theme="dark"] .pulse-flash {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
}
.pulse-flash[hidden] { display: none; }

/* ── Welcome page ──────────────────────────────────────────── */
.welcome-page {
  min-height: 100vh;
  background: var(--wash-cool);
  display: flex;
  flex-direction: column;
}

.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-6);
}

.welcome-main {
  flex: 1;
}

.welcome-heading {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--c-text);
  margin: 0 0 var(--sp-2);
}

.welcome-subhead {
  font-size: 0.95rem;
  color: var(--c-text-muted);
  line-height: 1.6;
  margin: 0 0 var(--sp-5);
}

/* Larger tap target for welcome CTAs */
.btn-lg {
  padding: 13px 24px;
  font-size: 0.95rem;
  min-height: 44px;
}

.welcome-hint {
  font-size: 0.85rem;
  color: var(--c-text-muted);
  margin: var(--sp-2) 0 0;
  line-height: 1.5;
}

.welcome-dashboard-link {
  margin-top: var(--sp-3);
}

.welcome-status {
  margin-top: var(--sp-3);
  font-size: 0.875rem;
  color: var(--c-text-muted);
  line-height: 1.5;
  min-height: 1.4em;
}

.welcome-steps {
  margin-top: var(--sp-6);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--c-border-soft);
}

.welcome-steps-heading {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--c-text-muted);
  margin: 0 0 var(--sp-3);
}

.welcome-steps-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.welcome-step {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  font-size: 0.92rem;
  color: var(--c-text);
  line-height: 1.55;
}

.welcome-step-num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: var(--r-pill);
  background: var(--c-accent-soft);
  color: var(--c-accent-text);
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

/* ── 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-size: 0.78rem;
  color: var(--c-text-muted);
  transition: color 0.15s ease;
}

.pw-rule-icon::before {
  content: '○';
  font-size: 0.7rem;
  color: var(--c-text-label);
}

.pw-rule[data-met="true"] {
  color: var(--c-up);
}

.pw-rule[data-met="true"] .pw-rule-icon::before {
  content: '✓';
  color: var(--c-up);
  font-weight: 700;
}

/* ── Confirm-password match indicator (signup) ──────────────── */

.pw-match-msg {
  margin-top: 4px;
  font-size: 0.78rem;
  min-height: 18px;
  transition: color 0.15s ease;
}

.pw-match-msg[data-state="match"]    { color: var(--c-up); }
.pw-match-msg[data-state="mismatch"] { color: var(--c-down); }

/* ─────────────────────────────────────────────────────────────
   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; }

  /* -- Stock table: escape .main-column overflow-x:hidden clip -- */
  .stock-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* Negative margin trick to bust out of the hidden-overflow parent */
    margin-left: calc(-1 * var(--sp-3));
    margin-right: calc(-1 * var(--sp-3));
    padding-left: var(--sp-3);
    padding-right: var(--sp-3);
    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-surface-2);
}

.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);
  transition: width 0.3s ease;
}

.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);
}

.usage-meter-cta {
  color: var(--c-accent);
  font-weight: 500;
  text-decoration: none;
}

.usage-meter-cta:hover {
  color: var(--c-accent-hover);
  text-decoration: underline;
}

/* ── 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. Chrome stays in the UI sans;
   serif is reserved for the ledger's voice. */

.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: rgba(0, 0, 0, 0.5); }

.tour-overlay-piece {
  position: fixed;
  background: rgba(0, 0, 0, 0.5);
  pointer-events: auto;
}

.tour-ring {
  position: fixed;
  border: 2px solid var(--c-border-soft, var(--c-border));
  border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  transition: top 0.2s ease, left 0.2s ease, width 0.2s ease, height 0.2s ease;
}
.tour-ring--interactive { box-shadow: none; }

.tour-popover {
  position: fixed;
  z-index: 2001;
  width: min(360px, calc(100vw - 32px));
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  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: 8px;
  right: 10px;
  background: none;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--c-text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}
.tour-close:hover { color: var(--c-text); background: var(--c-surface-2); }

.tour-progress {
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--c-text-muted);
  margin: 0 0 6px;
}
.tour-title {
  font-size: 1.05rem;
  margin: 0 0 8px;
  color: var(--c-text);
}
.tour-body {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--c-text-muted);
  margin: 0 0 var(--sp-3);
}

.tour-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}
.tour-actions-left,
.tour-actions-right { display: inline-flex; align-items: center; gap: var(--sp-2); }

.tour-btn {
  font: inherit;
  font-size: 0.86rem;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
}
.tour-btn-primary {
  background: var(--c-accent);
  color: #fff;
  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-2); }
.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-2); }
.tour-btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.tour-btn:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }

/* Resume pill — shown when the user wanders off the active step mid-tour. */
.tour-pill {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 2000;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  padding: 8px 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}
.tour-pill-label { font-size: 0.82rem; color: var(--c-text-muted); }

/* 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-accent); outline-offset: -2px; }

@media (max-width: 639px) {
  .tour-popover,
  .tour-popover-center {
    top: auto !important;
    right: 0;
    bottom: 0;
    left: 0 !important;
    width: 100%;
    max-height: min(76vh, 620px);
    overflow-y: auto;
    transform: none;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 16px 16px 0 0;
    padding: var(--sp-4) var(--sp-3) max(var(--sp-4), env(safe-area-inset-bottom));
  }
  .tour-actions { align-items: stretch; flex-direction: column; }
  .tour-actions-left,
  .tour-actions-right { justify-content: space-between; flex-wrap: wrap; }
  .tour-actions--end { flex-direction: row; }
  .tour-pill {
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    left: 8px;
    justify-content: center;
    flex-wrap: wrap;
    border-radius: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tour-ring { transition: none; }
}
