/* RSI Zone Dashboard — visual system
   A calm "trading instrument" panel. All data (tickers, prices, RSI, %) is set
   in monospace with tabular figures for precise alignment; UI text uses a
   geometric grotesque. Zone colour is the one bold accent per surface, on the
   Okabe-Ito colour-blind-safe palette (BLUE good vs VERMILLION bad, never
   green/red). Mobile-first: a thumb-reachable bottom tab bar becomes an inline
   nav on wider screens.

   The `hidden` HTML attribute must always win over layout classes. */
[hidden] { display: none !important; }

:root {
  /* type — Schibsted Grotesk (display/numbers) + Inter (UI) + JetBrains Mono (data) */
  --f-display: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* light theme (default; dark below via prefers-color-scheme) */
  --bg: #f5f6f9;
  --surface: #ffffff;
  --surface-2: #eef0f5;
  --line: #e4e7ee;
  --ink: #0c0f16;
  --ink-dim: #515a6b;
  --ink-faint: #8791a1;

  /* iris — the interactive/brand accent, distinct from the data semantics below */
  --accent: #5b58e0;
  --accent-ink: #ffffff;
  /* text on a solid semantic fill (pill/badge): white in light mode (fills are
     dark), near-black in dark mode (fills are bright) — keeps contrast in both. */
  --on-fill: #ffffff;
  /* per-section identity accents (used on the active tab + section headers) — kept
     distinct from each other and from the data-semantic colours above; the tab
     label always carries the meaning so colour is only a secondary cue. */
  --sec-market: #5b58e0;
  --sec-portfolio: #0d9488;
  --sec-lists: #b45309;
  --sec-journal: #db2777;
  --sec-impulse: #c2410c;
  --sec-activity: #5b6675;
  --section: var(--sec-market);

  /* zones — modernised Okabe-Ito (still colour-blind friendly, BLUE good / VERMILLION bad) */
  --buy: #08976a;
  --watch: #2f74e8;
  --hold: #2f74e8;
  --cut: #b5468a;
  --sell: #e0552b;
  --amber: #bd8400;
  --up: #08976a;
  --down: #d64550;
  /* financial-health "good" status in the stock-detail panel — blue instead of
     green/red so it stays colour-blind friendly (this panel pairs it directly
     against --sell "bad"); reuses the same blue as --watch. */
  --health-good: #2f74e8;

  --shadow-sm: 0 1px 2px rgba(12, 16, 26, 0.05);
  --shadow: 0 1px 2px rgba(12, 16, 26, 0.05), 0 10px 30px rgba(12, 16, 26, 0.09);
  --radius: 13px;
  --radius-sm: 9px;
  --maxw: 1180px;
  --navh: 64px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0d13;
    --surface: #131822;
    --surface-2: #1b2230;
    --line: #262f3f;
    --ink: #eef2f8;
    --ink-dim: #a6b0c0;
    --ink-faint: #7b8798;

    --accent: #8b88ff;
    --accent-ink: #0a0d13;
    --on-fill: #0a0d13;
    --sec-market: #8b88ff;
    --sec-portfolio: #2dd4bf;
    --sec-lists: #f59e0b;
    --sec-journal: #f472b6;
    --sec-impulse: #fb923c;
    --sec-activity: #94a3b8;

    --buy: #2ecfa1;
    --watch: #5aa2f5;
    --hold: #5aa2f5;
    --cut: #d488b4;
    --sell: #f2854e;
    --amber: #f0b429;
    --up: #2ecfa1;
    --down: #ef6b73;
    --health-good: #5aa2f5;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 16px 40px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  --bg: #0a0d13;
  --surface: #131822;
  --surface-2: #1b2230;
  --line: #262f3f;
  --ink: #eef2f8;
  --ink-dim: #a6b0c0;
  --ink-faint: #7b8798;
  --accent: #8b88ff;
  --accent-ink: #0a0d13;
  --on-fill: #0a0d13;
  --sec-market: #8b88ff;
  --sec-portfolio: #2dd4bf;
  --sec-lists: #f59e0b;
  --sec-journal: #f472b6;
  --sec-impulse: #fb923c;
  --sec-activity: #94a3b8;
  --buy: #2ecfa1;
  --watch: #5aa2f5;
  --hold: #5aa2f5;
  --cut: #d488b4;
  --sell: #f2854e;
  --amber: #f0b429;
  --up: #2ecfa1;
  --down: #ef6b73;
  --health-good: #5aa2f5;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 16px 40px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
/* Base type scale. rem tracks <html>; a slightly larger size on phones keeps
   the dense mono data legible without changing desktop density. */
html { -webkit-text-size-adjust: 100%; font-size: 16px; }
@media (max-width: 759px) { html { font-size: 17px; } }
body {
  margin: 0;
  font-family: var(--f-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  font-size: 1rem;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--navh) + env(safe-area-inset-bottom, 0px));
  /* Always at least a full (dynamic) viewport tall so a short page — e.g. the
     locked-portfolio card — doesn't collapse below the viewport and hide the
     fixed bottom nav until you scroll. dvh tracks the mobile chrome; vh is the
     fallback for browsers without dvh. */
  min-height: 100vh;
  min-height: 100dvh;
}
@media (min-width: 760px) {
  body { padding-bottom: 0; }
}

/* loading splash — an inspiring quote instead of a spinner while the board loads */
.splash {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 2rem calc(1.4rem + env(safe-area-inset-left, 0px));
  background: var(--bg);
  transition: opacity 0.45s ease;
}
.splash[hidden] { display: none; }
.splash.is-hiding { opacity: 0; pointer-events: none; }
.splash-inner {
  max-width: 34rem; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 1.15rem;
  animation: splash-rise 0.5s ease both;
}
.splash .brand-mark { width: 42px; height: 42px; border-radius: 12px; }
.splash-quote {
  margin: 0; font-family: var(--f-display); font-weight: 600;
  font-size: clamp(1.3rem, 4.5vw, 1.9rem); line-height: 1.32;
  letter-spacing: -0.02em; color: var(--ink);
  text-wrap: balance;
}
.splash-quote::before { content: "\201C"; }
.splash-quote::after { content: "\201D"; }
.splash-author {
  font-style: normal; font-size: 0.9rem; letter-spacing: 0.02em;
  color: var(--ink-dim);
}
@keyframes splash-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .splash { transition: none; }
  .splash-inner { animation: none; }
}
h1, h2, h3 { margin: 0; font-family: var(--f-display); letter-spacing: -0.02em; font-weight: 600; }
a { color: inherit; }
code { font-family: var(--f-mono); font-size: 0.92em; }
.mono, .card-sym, .card-price, .card-rsi, .sr-sym, .price, .sym { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 1.05rem; }
.hint { color: var(--ink-dim); font-size: 0.9rem; margin: 0.25rem 0 0; }

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 0.7rem;
  padding-bottom: 0.7rem;
}
.brand { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.brand-mark {
  width: 30px; height: 30px; flex: none; border-radius: 9px;
  background: linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--buy)));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.brand h1 { font-size: 1.05rem; line-height: 1.1; }
.tagline { display: none; margin: 0.1rem 0 0; color: var(--ink-dim); font-size: 0.78rem; }
@media (min-width: 620px) { .tagline { display: block; } }
.header-right { display: flex; align-items: center; gap: 0.5rem; }
.freshness {
  display: none; align-items: center; gap: 0.4rem;
  color: var(--ink-dim); font-size: 0.78rem; font-family: var(--f-mono);
}
@media (min-width: 900px) { .freshness { display: flex; } }
.freshness .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--buy); }
.freshness.stale .dot { background: var(--sell); }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--f-display);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}
.btn:hover { border-color: var(--ink-faint); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.06); border-color: var(--accent); }
.btn-danger { background: var(--sell); border-color: var(--sell); color: var(--on-fill); }
.btn-danger:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-refresh { font-size: 0.8rem; padding: 0.45rem 0.7rem; }
.btn-refresh.is-loading { opacity: 0.55; pointer-events: none; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:disabled:hover { border-color: var(--line); }
.refresh-group { display: inline-flex; align-items: center; gap: 0.35rem; }
.force-link { font-size: 0.72rem; color: var(--ink-faint); text-decoration: underline; cursor: pointer; }
.force-link:hover { color: var(--hold); }
.btn-icon { padding: 0.4rem 0.6rem; font-size: 1rem; line-height: 1; }
.btn-icon.is-active { border-color: var(--hold); color: var(--hold); }

/* push-alert settings, shown in-flow at the foot of the Notifications page */
.push-inline { margin-top: 1.6rem; padding: 0.9rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.push-head { display: flex; align-items: center; justify-content: space-between; font-weight: 600; }
.push-state {
  font-family: var(--f-mono); font-size: 0.7rem; letter-spacing: 0.03em;
  padding: 0.1rem 0.45rem; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-faint);
}
.push-state.is-on { background: color-mix(in srgb, var(--buy) 18%, transparent); color: var(--buy); }
.push-sub { margin: 0.35rem 0 0.7rem; color: var(--ink-dim); font-size: 0.8rem; line-height: 1.35; }
.push-rows { display: grid; gap: 0.15rem; }
.push-row {
  display: flex; align-items: flex-start; gap: 0.55rem;
  padding: 0.4rem 0.4rem; border-radius: 8px; cursor: pointer;
}
.push-row:hover { background: var(--surface-2); }
.push-row input { margin-top: 0.15rem; accent-color: var(--buy); width: 15px; height: 15px; flex: none; }
.push-row span { display: flex; flex-direction: column; }
.push-row b { font-weight: 600; font-size: 0.86rem; }
.push-row small { color: var(--ink-faint); font-size: 0.74rem; line-height: 1.3; }
.push-note { margin: 0.55rem 0 0; color: var(--sell); font-size: 0.75rem; min-height: 0; }
.push-note:empty { display: none; }
.push-toggle { width: 100%; margin-top: 0.7rem; justify-content: center; }

/* "hide details" mode — strip to section → ticker → name (+ price) for sharing */
body.clean .search-bar,
body.clean .tiles,
body.clean .card-rsi,
body.clean .card-foot,
body.clean .card-verdict,
body.clean .sample-banner,
body.clean .section-head .hint,
body.clean .notif-btn,
body.clean .site-footer { display: none; }
body.clean .card { cursor: default; }

:focus-visible { outline: 2px solid var(--hold); outline-offset: 2px; }

/* ---------- sign-in gate ---------- */
.signin {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 1.5rem;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px);
}
.signin-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 2rem 1.75rem; text-align: center; max-width: 340px; width: 100%;
}
.signin-card .brand-mark { width: 40px; height: 40px; margin: 0 auto 0.75rem; }
.signin-card h2 { font-size: 1.35rem; }
.signin-card .btn { margin-top: 1rem; width: 100%; }

/* ---------- sample banner ---------- */
.sample-banner {
  margin: 1rem auto 0; padding: 0.7rem 0.9rem;
  border: 1px solid color-mix(in srgb, var(--amber) 45%, var(--line));
  background: color-mix(in srgb, var(--amber) 12%, var(--surface));
  border-radius: var(--radius-sm); font-size: 0.85rem;
}

main.wrap { padding-top: 1rem; padding-bottom: 3rem; }

/* ---------- search ---------- */
.search-bar { position: relative; margin: 0.25rem 0 1.1rem; }
#tab-market > .search-bar { margin: 0 0 1.2rem; } /* above the Buy section on the Market board */
#ticker-search {
  width: 100%; padding: 0.8rem 1rem; font-size: 1rem;
  font-family: var(--f-body); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); outline: none;
}
#ticker-search::placeholder { color: var(--ink-faint); }
#ticker-search:focus { border-color: var(--hold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--hold) 22%, transparent); }
.search-results {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.sr-item {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 0.9rem; cursor: pointer; border-bottom: 1px solid var(--line);
}
.sr-item:last-child { border-bottom: none; }
.sr-item.is-active, .sr-item:hover { background: var(--surface-2); }
.sr-sym { font-weight: 700; min-width: 3.8rem; }
.sr-name { color: var(--ink-dim); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9rem; }
.sr-item .pill { flex: none; }
.sr-empty { padding: 0.8rem 0.9rem; color: var(--ink-dim); font-size: 0.88rem; }
/* "Force fetch from AlphaVantage" action shown in search for off-universe tickers */
.sr-fetch {
  display: flex; align-items: center; gap: 0.4rem; cursor: pointer;
  padding: 0.6rem 0.9rem; font-size: 0.88rem; color: var(--buy);
  border-top: 1px solid var(--line); background: color-mix(in srgb, var(--buy) 7%, transparent);
}
.sr-fetch:hover { background: color-mix(in srgb, var(--buy) 14%, transparent); }
.sr-fetch.is-loading { color: var(--ink-dim); cursor: default; background: none; }
.sr-fetch b { font-weight: 700; }

/* ---------- summary ladder (tiles) ---------- */
.tiles {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.6rem; margin-bottom: 1.2rem;
}
.tile {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0.85rem 0.95rem; overflow: hidden;
}
.tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--ink-faint); }
.tile.buy::before { background: var(--buy); }
.tile.watch::before { background: var(--watch); }
.tile.hold::before { background: var(--hold); }
.tile.sell::before { background: var(--sell); }
.tile .n { font-family: var(--f-mono); font-size: 1.9rem; font-weight: 700; line-height: 1; letter-spacing: -0.03em; }
.tile .l { margin-top: 0.35rem; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-dim); }
/* Phones: keep all four on one line — compact number, smaller label. */
@media (max-width: 620px) {
  .tiles { gap: 0.4rem; }
  .tile { padding: 0.5rem 0.35rem 0.55rem 0.55rem; border-radius: 10px; }
  .tile::before { width: 3px; }
  .tile .n { font-size: 1.4rem; }
  .tile .l { margin-top: 0.2rem; font-size: 0.54rem; letter-spacing: 0.02em; line-height: 1.2; }
}

/* ---------- tabs: bottom bar (mobile) / inline (desktop) ---------- */
.tabs {
  position: fixed; z-index: 40; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  border-top: 1px solid var(--line);
  padding: 0.35rem 0.25rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
  /* Own compositing layer so the bar doesn't jitter/repaint as the mobile
     address bar collapses & expands during scroll — it stays rock-steady. */
  transform: translateZ(0);
  will-change: transform;
  backface-visibility: hidden;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: none; background: none; cursor: pointer;
  color: var(--ink-faint); font-family: var(--f-display); font-size: 0.68rem; padding: 0.35rem 0.2rem;
  border-radius: 10px;
}
.tab-ico { font-size: 1.15rem; line-height: 1; }
.tab.is-active { color: var(--accent); }
.tab.is-active .tab-ico { transform: translateY(-1px); }
/* On mobile Activity lives in the ☰ menu, so the bottom nav is 4 primary tabs.
   Desktop (below) restores it as an inline tab. */
.tab[data-tab="activity"] { display: none; }
@media (min-width: 760px) {
  .tab[data-tab="activity"] { display: flex; }
  .tabs {
    position: static; justify-content: flex-start; gap: 0.4rem;
    background: none; backdrop-filter: none; border-top: none;
    border-bottom: 1px solid var(--line); padding: 0 0 0.1rem; margin-bottom: 1.4rem;
  }
  .tab {
    flex: none; flex-direction: row; gap: 0.4rem; font-size: 0.92rem; font-weight: 500;
    padding: 0.6rem 0.9rem; border-radius: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  }
  .tab .tab-ico { font-size: 0.95rem; }
  .tab.is-active { color: var(--ink); border-bottom-color: var(--accent); }
}

/* ---- per-section colour identity ---- */
body[data-section="market"] { --section: var(--sec-market); }
body[data-section="portfolio"] { --section: var(--sec-portfolio); }
body[data-section="lists"] { --section: var(--sec-lists); }
body[data-section="journal"] { --section: var(--sec-journal); }
body[data-section="impulse"] { --section: var(--sec-impulse); }
body[data-section="activity"] { --section: var(--sec-activity); }
/* the active tab glows its own section colour (bottom nav colour + desktop underline) */
.tab[data-tab="market"].is-active { color: var(--sec-market); }
.tab[data-tab="portfolio"].is-active { color: var(--sec-portfolio); }
.tab[data-tab="watchlists"].is-active { color: var(--sec-lists); }
.tab[data-tab="journal"].is-active { color: var(--sec-journal); }
.tab[data-tab="impulse"].is-active { color: var(--sec-impulse); }
.tab[data-tab="activity"].is-active { color: var(--sec-activity); }
@media (min-width: 760px) {
  .tab[data-tab="market"].is-active { color: var(--ink); border-bottom-color: var(--sec-market); }
  .tab[data-tab="portfolio"].is-active { color: var(--ink); border-bottom-color: var(--sec-portfolio); }
  .tab[data-tab="watchlists"].is-active { color: var(--ink); border-bottom-color: var(--sec-lists); }
  .tab[data-tab="journal"].is-active { color: var(--ink); border-bottom-color: var(--sec-journal); }
  .tab[data-tab="impulse"].is-active { color: var(--ink); border-bottom-color: var(--sec-impulse); }
  .tab[data-tab="activity"].is-active { color: var(--ink); border-bottom-color: var(--sec-activity); }
}
/* a subtle section-coloured accent bar on the main content headers */
.tabpanel .section-head h2, .acct-head .acct-name, .jr-sec > .section-head h2, .wl-section {
  border-left: 3px solid var(--section); padding-left: 0.55rem;
}

/* ---------- sort controls ---------- */
/* Desktop: strategy row above, sort row below (natural block stacking). */
.market-controls { margin: 0; }
.sort-bar { display: flex; align-items: center; gap: 0.4rem; margin: 0 0 1.1rem; flex-wrap: wrap; }
.legend-btn {
  font: 600 0.76rem/1 var(--f-display); color: var(--ink-dim);
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 0.4rem 0.7rem; border-radius: 999px; cursor: pointer; white-space: nowrap; margin: 0 0 1.1rem;
}
.legend-btn:hover { color: var(--ink); border-color: var(--ink-faint); }
.sort-label { font-size: 0.72rem; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.06em; margin-right: 0.15rem; }
.sort-toggle { display: none; }
.sort-btn {
  font-family: var(--f-display); font-size: 0.8rem; padding: 0.35rem 0.7rem;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--ink-dim); cursor: pointer; white-space: nowrap;
}
.sort-btn:hover { border-color: var(--ink-faint); }
.sort-btn.is-active { border-color: var(--hold); color: var(--hold); font-weight: 600; }
/* ★ filter — a switch next to Sort (on = starred only, off = all). */
.star-toggle {
  display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap; cursor: pointer;
  padding: 0.3rem 0.55rem; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink-dim); font: 600 0.78rem var(--f-display);
}
.star-switch { position: relative; width: 32px; height: 18px; border-radius: 999px; background: var(--line); transition: background 0.15s; flex: none; }
.star-knob { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,0.25); transition: transform 0.15s; }
.star-toggle.is-on { color: var(--accent); border-color: var(--accent); }
.star-toggle.is-on .star-switch { background: var(--accent); }
.star-toggle.is-on .star-knob { transform: translateX(14px); }
/* MACD Turn "best pick" toggle uses the buy-green accent; its caption wraps to its
   own line so it always reads as a description of the filter. */
.bestpick-toggle.is-on { color: var(--buy); border-color: var(--buy); }
.bestpick-toggle.is-on .star-switch { background: var(--buy); }
.bestpick-note { flex-basis: 100%; width: 100%; margin: 0.25rem 0 0; font: 500 0.72rem/1.35 var(--f-body); color: var(--ink-dim); }
body.clean .market-controls { display: none; }
/* Mobile: strategy chip + sort chip share one line; each expands its full list. */
@media (max-width: 760px) {
  .market-controls { display: flex; align-items: flex-start; gap: 0.5rem; flex-wrap: wrap; margin: 0 0 1.1rem; }
  .market-controls .strategy-bar, .market-controls .sort-bar { margin: 0; }
  .sort-label { display: none; }
  .sort-toggle {
    display: inline-flex; align-items: center; gap: 0.4rem;
    font-family: var(--f-display); font-size: 0.9rem; font-weight: 600;
    padding: 0.46rem 0.9rem; border: 1px solid var(--hold); border-radius: 999px;
    background: var(--surface); color: var(--hold); cursor: pointer; white-space: nowrap;
  }
  .sort-toggle-caret { font-size: 0.7rem; transition: transform 0.15s; }
  .sort-bar:not(.is-collapsed) .sort-toggle-caret { transform: rotate(180deg); }
  .sort-bar.is-collapsed .sort-btn { display: none; }
}

/* by-symbol view sort control (Losers first — vs. highest paid / vs. wEMA21) */
.sym-sort-bar { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; padding: 0.7rem 1rem 0; }
.sym-sort-lbl { font-size: 0.72rem; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.sym-sort-btn {
  font-family: var(--f-display); font-size: 0.78rem; padding: 0.28rem 0.65rem;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--ink-dim); cursor: pointer; white-space: nowrap;
}
.sym-sort-btn:hover { border-color: var(--ink-faint); }
.sym-sort-btn.is-active { border-color: var(--hold); color: var(--hold); font-weight: 600; }

/* Lists tab sub-nav: A/B-grade board (default) vs Watchlists */
/* scrolls sideways on a phone rather than squeezing the labels */
.lists-nav { display: flex; gap: 0.4rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; scrollbar-width: none; }
.lists-nav::-webkit-scrollbar { display: none; }
.lists-nav-btn { flex: none; white-space: nowrap; }
.fair-warn { color: var(--amber); margin: 0 0 0.9rem; }
.fair-outsized { margin-top: 1.6rem; }
.fair-outsized > summary { cursor: pointer; list-style: none; margin-bottom: 0.6rem; }
.fair-outsized > summary::-webkit-details-marker { display: none; }
.fair-outsized h3 { font: 700 0.98rem var(--f-display); color: var(--amber); }
.fair-outsized h3::after { content: " ▾"; color: var(--ink-faint); }
.fv-warn { color: var(--amber); font-weight: 600; }
.lists-nav-btn {
  font: 600 0.92rem/1 var(--f-display); color: var(--ink-faint);
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 0.6rem 0.4rem; margin-bottom: -1px; cursor: pointer;
}
.lists-nav-btn:hover { color: var(--ink-dim); }
.lists-nav-btn.is-active { color: var(--ink); border-bottom-color: var(--accent); }
/* A/B-grade board controls: count + sort */
.ab-controls { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; flex-wrap: wrap; margin: 0.2rem 0 0.9rem; }
.ab-count { font: 600 0.78rem/1 var(--f-mono); color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.ab-sort { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.ab-sort-lbl { font-size: 0.72rem; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.ab-sort-btn {
  font-family: var(--f-display); font-size: 0.78rem; padding: 0.28rem 0.65rem;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--ink-dim); cursor: pointer; white-space: nowrap;
}
.ab-sort-btn:hover { border-color: var(--ink-faint); }
.ab-sort-btn.is-active { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.ab-more { display: block; width: 100%; margin-top: 1rem; }

/* ---------- strategy switcher (Market + Holdings) ---------- */
.strategy-bar { display: flex; gap: 0.45rem; margin: 0 0 1rem; flex-wrap: wrap; }
.strat-btn {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-family: var(--f-display); font-size: 0.9rem; font-weight: 500;
  padding: 0.46rem 0.85rem; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink-dim); cursor: grab; white-space: nowrap;
  transition: background 0.12s, color 0.12s, border-color 0.12s, transform 0.08s;
  touch-action: none; /* let pointer-drag reorder work on touch instead of scrolling */
  user-select: none;
}
.strat-info { font-size: 0.78rem; line-height: 1; opacity: 0.5; cursor: help; }
.strat-info:hover { opacity: 1; }
.strat-btn.is-active .strat-info { opacity: 0.85; }
/* strategy definition popup */
.strat-info-overlay {
  position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, 0.5);
  display: flex; align-items: center; justify-content: center; padding: 1.2rem;
}
.strat-info-modal {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow);
  max-width: 440px; width: 100%; max-height: 82vh; overflow-y: auto;
  padding: 1.3rem 1.3rem 1.5rem; animation: drawer-in 0.16s ease;
}
.strat-info-close {
  position: absolute; top: 0.7rem; right: 0.7rem; width: 32px; height: 32px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-dim);
  font-size: 1.15rem; cursor: pointer;
}
.strat-info-title { margin: 0 0 0.6rem; font-family: var(--f-display); font-size: 1.15rem; color: var(--ink); }
.strat-info-body { color: var(--ink-dim); font-size: 0.9rem; line-height: 1.5; }
.strat-info-body p { margin: 0 0 0.6rem; }
.strat-info-body ul { margin: 0; padding-left: 1.05rem; display: flex; flex-direction: column; gap: 0.45rem; }
.strat-info-body b { color: var(--ink); }
/* legend rows (the ⓘ Legend overlay) — a marker beside its plain-language meaning */
.lg-list { display: flex; flex-direction: column; gap: 0.75rem; }
.lg-row { display: grid; grid-template-columns: minmax(70px, auto) 1fr; gap: 0.75rem; align-items: start; }
.lg-mk { display: flex; flex-wrap: wrap; gap: 0.25rem; align-items: center; padding-top: 0.1rem; }
.lg-tx { font: 500 0.85rem/1.45 var(--f-body); color: var(--ink-dim); }
.lg-tx b { color: var(--ink); font-weight: 700; }
.strat-btn:hover { border-color: var(--ink-faint); }
.strat-btn.is-active { background: var(--hold); border-color: var(--hold); color: var(--on-fill); font-weight: 600; }
/* while a tab is being dragged to reorder */
.strat-btn.dragging { cursor: grabbing; transform: scale(1.06); box-shadow: 0 3px 12px rgba(0, 0, 0, 0.22); opacity: 0.95; }
body.reordering { cursor: grabbing; user-select: none; }
body.clean .strategy-bar { display: none; }
/* mobile-only collapsed strategy picker: one chip that expands the full list */
.strat-toggle { display: none; }
@media (max-width: 760px) {
  .strat-toggle {
    display: inline-flex; align-items: center; gap: 0.4rem;
    font-family: var(--f-display); font-size: 0.9rem; font-weight: 600;
    padding: 0.46rem 0.9rem; border: 1px solid var(--hold); border-radius: 999px;
    background: var(--hold); color: var(--on-fill); cursor: pointer; white-space: nowrap;
  }
  .strat-toggle-caret { font-size: 0.7rem; transition: transform 0.15s; }
  .strategy-bar:not(.is-collapsed) .strat-toggle-caret { transform: rotate(180deg); }
  /* collapsed → the toggle chip + the "pinned" quick-select strategies (MACD Turn,
     Fast MACD) so both are one tap away; expanded → toggle + the full button list.
     The active strategy is already the toggle, so hide its pinned button (no dup). */
  .strategy-bar.is-collapsed .strat-btn { display: none; }
  .strategy-bar.is-collapsed .strat-btn.is-pinned { display: inline-flex; }
  .strategy-bar.is-collapsed .strat-btn.is-pinned.is-active { display: none; }
}

/* small per-strategy tag on a card (grade / stage), sits before the pill */
.card-verdict { display: inline-flex; align-items: center; gap: 0.35rem; }
.card-tag {
  font-family: var(--f-mono); font-size: 0.66rem; font-weight: 700; letter-spacing: 0.02em;
  color: var(--ink-dim); background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 0.08rem 0.32rem;
}

/* ---------- section headers ---------- */
.section-head { margin: 0 0 0.9rem; }
.section-head h2 { display: flex; align-items: center; gap: 0.5rem; font-size: 1.15rem; }
/* ⓘ next to a section title — reveals that section's (hidden-by-default) hint */
.hint-toggle {
  background: none; border: 0; padding: 0.1rem 0.2rem; cursor: pointer;
  font-size: 0.9rem; line-height: 1; color: var(--ink-faint); border-radius: 6px;
}
.hint-toggle:hover, .hint-toggle.is-open { color: var(--accent); }
.tabpanel > .section-head:not(:first-child) { margin-top: 2rem; }

/* collapsible sections (card lists) */
#tab-market .section-head { cursor: pointer; user-select: none; }
#tab-market .section-head h2::after {
  content: "▾"; margin-left: 0.4rem; font-size: 0.72em; color: var(--ink-faint);
  transition: transform 0.15s; display: inline-block;
}
#tab-market .section-head.collapsed h2::after { transform: rotate(-90deg); }
.section-head.collapsed + .cardgrid { display: none; }
.wl-section { cursor: pointer; user-select: none; }
.wl-section::before {
  content: "▾"; margin-right: 0.15rem; font-size: 0.85em; color: var(--ink-faint);
  transition: transform 0.15s; display: inline-block;
}
.wl-section.collapsed::before { transform: rotate(-90deg); }
.wl-section.collapsed + .cardgrid { display: none; }

/* ---------- pills ---------- */
.pill {
  display: inline-block; font-family: var(--f-display); font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.04em; padding: 0.18rem 0.5rem; border-radius: 999px;
  color: var(--on-fill); background: var(--ink-faint);
}
.pill-buy { background: var(--buy); }
.pill-watch { background: var(--watch); }
.pill-hold { background: var(--hold); }
.pill-cut { background: var(--cut); }
.pill-sell { background: var(--sell); }
.pill-none { background: var(--ink-faint); }
.pill-br { background: var(--amber); color: #1a1206; }
/* weekly-MACD-falling sell hint on portfolio positions — outlined so it reads as a
   secondary alert next to the primary manage badge */
.pill-macd {
  background: color-mix(in srgb, var(--sell) 14%, transparent); color: var(--sell);
  border: 1px solid color-mix(in srgb, var(--sell) 45%, var(--line)); margin-right: 0.3rem;
}

/* bottom-risers */
.card.z-BR { border-left-color: var(--amber); }
.br-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.85rem 1rem; }
.br-status { font-family: var(--f-display); font-weight: 700; font-size: 1.05rem; }
.br-box.br-DREAM { border-color: color-mix(in srgb, var(--amber) 55%, var(--line)); }
.br-box.br-DREAM .br-status,
.br-box.br-NEAR .br-status,
.br-box.br-WAIT_DAILY .br-status { color: var(--amber); }
.br-box.br-NONE .br-status,
.br-box.br-BASE .br-status { color: var(--ink-dim); }

/* ---------- cards ---------- */
.cardgrid { display: grid; grid-template-columns: 1fr; gap: 0.7rem; }
@media (min-width: 560px) { .cardgrid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .cardgrid { grid-template-columns: repeat(3, 1fr); } }
.card {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-left: 4px solid var(--ink-faint); border-radius: var(--radius);
  padding: 0.9rem 1rem; cursor: pointer; transition: border-color 0.15s, transform 0.06s, box-shadow 0.15s;
}
.card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.card.z-BUY { border-left-color: var(--buy); }
.card.z-WATCH { border-left-color: var(--watch); }
/* well-rated companies get a green wash so they're easy to spot; the left
   border still encodes the BUY/WATCH zone. A (below) gets a stronger wash. */
.card.fin-b {
  background: color-mix(in srgb, var(--buy) 7%, var(--surface));
  border-color: color-mix(in srgb, var(--buy) 22%, var(--line));
}
.card-fin {
  font-family: var(--f-display); font-size: 0.62rem; font-weight: 700; line-height: 1.2;
  border-radius: 5px; padding: 0 0.3rem; margin-left: 0.35rem; vertical-align: middle;
}
.card-fin.fin-strong { color: var(--on-fill); background: var(--buy); letter-spacing: -0.04em; }
.card.z-HOLD { border-left-color: var(--hold); }
.card.z-CUT { border-left-color: var(--cut); }
.card.z-SELL { border-left-color: var(--sell); }
.card-top { display: flex; align-items: flex-start; gap: 0.5rem; }
.card-sym { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.card-price { margin-left: auto; font-size: 0.95rem; color: var(--ink-dim); display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.card-chg { font-size: 0.74rem; font-weight: 600; margin-top: 0.08rem; }
/* name + verdict share one line, so the RSI/foot rows below read as clean data */
.card-name-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-top: 0.2rem; }
.card-name { color: var(--ink-dim); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.card-name-row .card-verdict { flex: none; }
.card-sector { color: var(--ink-faint); font-family: var(--f-mono, monospace); font-size: 0.72rem; letter-spacing: 0.02em; margin-top: 0.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-rsi { font-size: 0.8rem; color: var(--ink-dim); margin-top: 0.6rem; }
.card-rsi b { color: var(--ink); font-weight: 600; }
.card-foot { display: flex; align-items: center; gap: 0.55rem; margin-top: 0.4rem; flex-wrap: wrap; }
.card-e21 { font-family: var(--f-mono); font-size: 0.78rem; color: var(--ink-dim); }
/* Dividend yield + frequency chip in the card footer (income names). */
.card-div {
  font: 700 0.72rem/1.2 var(--f-mono); color: var(--health-good, var(--accent));
  background: color-mix(in srgb, var(--health-good, var(--accent)) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--health-good, var(--accent)) 30%, var(--line));
  border-radius: 5px; padding: 0.04rem 0.34rem; white-space: nowrap;
}
/* Washout sort: "↓ 34% below 52-wk high · high Nov 2024" under the RSI line */
.card-washout {
  margin-top: 0.4rem; font-size: 0.76rem; color: var(--down);
  font-variant-numeric: tabular-nums; line-height: 1.3;
}
.card-washout b { font-weight: 700; }
.card-washout .cw-when { color: var(--ink-dim); font-weight: 500; }
body.clean .card-washout { display: none; }
/* MACD momentum readout on every card (monthly·weekly histogram direction) */
.macd-chip {
  font-family: var(--f-mono); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.01em;
  padding: 0.05rem 0.4rem; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--line); color: var(--ink-dim);
}
.macd-chip.macd-up { color: var(--buy); border-color: color-mix(in srgb, var(--buy) 40%, var(--line)); background: color-mix(in srgb, var(--buy) 8%, transparent); }
.macd-chip.macd-dn { color: var(--sell); border-color: color-mix(in srgb, var(--sell) 40%, var(--line)); background: color-mix(in srgb, var(--sell) 8%, transparent); }
.macd-chip.macd-flat { color: var(--ink-faint); }
/* Above/below zero-line marker per leg: g (green) = above, r (red) = below.
   Rendered as a tiny filled pill so it reads clearly regardless of the chip's
   own direction tint. */
.macd-side {
  display: inline-block; font-weight: 800; font-size: 0.85em; line-height: 1;
  color: #fff; padding: 0.09em 0.28em; border-radius: 3px; margin: 0 0.12em;
  vertical-align: baseline;
}
.macd-side.macd-abv { background: var(--buy); }
.macd-side.macd-blw { background: var(--sell); }
/* Daily leg "bleeding" warning: daily histogram red AND falling — the higher timeframes
   may have turned, but the intraday entry isn't confirmed. Boxed in red so it stands out
   against an otherwise bullish (green) chip. */
.macd-day.macd-warn {
  color: var(--sell); font-weight: 800;
  border: 1px solid color-mix(in srgb, var(--sell) 55%, transparent);
  background: color-mix(in srgb, var(--sell) 14%, transparent);
  border-radius: 5px; padding: 0 0.22em; margin-left: 0.05em;
}
/* MACD histogram trend mini-charts in the drawer (monthly / weekly / daily) */
.macdbars {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 0.7rem 0.8rem; margin-bottom: 1rem;
  /* TradingView histogram palette */
  --mb-up: #26a69a; --mb-up-weak: #86cfc6; --mb-dn: #ef5350; --mb-dn-weak: #f2a7a4;
}
.mb-row { display: grid; grid-template-columns: 5.2rem 1fr 3.1rem; align-items: center; gap: 0.55rem; padding: 0.3rem 0; }
.mb-tf { display: flex; flex-direction: column; font: 700 0.78rem/1.15 var(--f-display); color: var(--ink); }
.mb-tf small { font: 500 0.6rem/1.2 var(--f-body); color: var(--ink-faint); }
.mb-chart { position: relative; display: flex; align-items: stretch; gap: 2px; height: 64px; }
.mb-chart::before { /* zero line */
  content: ""; position: absolute; left: 0; right: 0; top: 50%;
  border-top: 1px dashed color-mix(in srgb, var(--ink-faint) 60%, transparent);
}
.mb-col { flex: 1; display: flex; flex-direction: column; min-width: 3px; cursor: pointer; }
.mb-col:focus-visible { outline: 2px solid var(--watch); outline-offset: 2px; border-radius: 3px; }
.mb-half { height: 50%; display: flex; }
.mb-up { align-items: flex-end; }   /* positive bar grows up from the center line */
.mb-dn { align-items: flex-start; } /* negative bar grows down from the center line */
.mb-bar { width: 100%; border-radius: 2px; }
/* TradingView 4-colour histogram: deep = momentum strengthening in its
   direction, pale = fading. Position vs the dashed zero line also encodes the
   sign, so the up/down read never relies on colour alone. */
.mb-bar.mb-pos.mb-mom-up { background: var(--mb-up); }
.mb-bar.mb-pos.mb-mom-dn { background: var(--mb-up-weak); }
.mb-bar.mb-neg.mb-mom-dn { background: var(--mb-dn); }
.mb-bar.mb-neg.mb-mom-up { background: var(--mb-dn-weak); }
.mb-bar.mb-now { outline: 1.5px solid color-mix(in srgb, var(--ink) 55%, transparent); outline-offset: 1px; }
.mb-col.mb-active .mb-bar { filter: brightness(1.1) saturate(1.1); }
.mb-col.mb-active .mb-bar:not(.mb-now) { outline: 1.5px solid var(--ink-faint); outline-offset: 1px; }
.mb-latest { font: 700 0.82rem var(--f-mono); text-align: right; }
.mb-readout {
  font: 700 0.74rem/1.3 var(--f-mono); color: var(--ink); margin-top: 0.5rem;
  padding: 0.28rem 0.5rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: 7px; display: inline-block;
}
.mb-legend { font: 500 0.66rem/1.4 var(--f-body); color: var(--ink-faint); margin-top: 0.45rem; }
.mb-key { display: inline-flex; align-items: center; gap: 0.25rem; margin-right: 0.55rem; white-space: nowrap; }
.mb-sw { width: 0.6rem; height: 0.6rem; border-radius: 2px; display: inline-block; }
.mb-sw-up { background: var(--mb-up); }
.mb-sw-upw { background: var(--mb-up-weak); }
.mb-sw-dn { background: var(--mb-dn); }
.mb-sw-dnw { background: var(--mb-dn-weak); }
.mb-sw-now { background: transparent; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ink) 55%, transparent); }
/* Extended-hours (pre/after market) badge — drawer header + portfolio "Now" cell. */
.ext-quote {
  display: inline-flex; align-items: baseline; gap: 0.28rem; white-space: nowrap;
  font: 600 0.74rem var(--f-mono);
}
.ext-quote .ext-tag {
  font: 700 0.58rem/1 var(--f-body); text-transform: uppercase; letter-spacing: 0.03em;
  font-style: normal; color: var(--ink-faint); padding: 0.1rem 0.3rem;
  border: 1px solid var(--line); border-radius: 4px; background: var(--surface-2);
}
.ext-up { color: var(--buy); }
.ext-dn { color: var(--sell); }
.d-head .ext-quote { font-size: 0.82rem; margin-left: 0.15rem; }
.sym-ext { display: block; margin-top: 0.1rem; }
.sym-ext .ext-quote { font-size: 0.66rem; }
.sym-mob-metrics .sym-ext { display: inline; margin-top: 0; }
/* "Extended above wEMA9" chip (self-relative). Neutral by default; loud when hot. */
.ext-chip {
  font-family: var(--f-mono); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.01em;
  padding: 0.05rem 0.4rem; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--line); color: var(--ink-dim);
}
.ext-chip.ext-hot {
  color: var(--sell); font-weight: 700;
  border-color: color-mix(in srgb, var(--sell) 45%, var(--line));
  background: color-mix(in srgb, var(--sell) 10%, transparent);
}
.rsi-up { color: var(--buy); font-weight: 700; }
.rsi-down { color: var(--sell); font-weight: 700; }

/* favorite star */
.fav-star {
  background: none; border: none; cursor: pointer; color: var(--ink-faint);
  font-size: 1.05rem; line-height: 1; padding: 0; align-self: center;
}
.fav-star:hover, .fav-star.is-fav { color: var(--amber); }

/* delete / remove control on cards & rows */
.has-del { position: relative; }
.holding-del {
  position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; line-height: 1; padding: 0;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2);
  color: var(--ink-dim); cursor: pointer; font-size: 15px;
}
.holding-del:hover { color: var(--sell); border-color: var(--sell); }

.empty {
  grid-column: 1 / -1; padding: 1.25rem; text-align: center; color: var(--ink-dim);
  font-size: 0.9rem; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius);
}

/* ---------- holdings editor ---------- */
.holdings-editor {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.1rem 1rem; margin-bottom: 1.2rem;
}
.holdings-editor label { font-family: var(--f-display); }
.add-holding { display: flex; gap: 0.5rem; margin: 0.6rem 0 0; flex-wrap: wrap; }
.add-holding input {
  flex: 1; min-width: 140px; padding: 0.65rem 0.85rem; font-size: 1rem; font-family: var(--f-body);
  color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); outline: none;
}
.add-holding input:focus { border-color: var(--hold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--hold) 20%, transparent); }
.bulk-holdings { margin-top: 0.7rem; }
.bulk-holdings summary { cursor: pointer; color: var(--ink-dim); font-size: 0.88rem; font-family: var(--f-display); }
.bulk-holdings textarea {
  width: 100%; margin-top: 0.5rem; padding: 0.6rem 0.8rem; font-family: var(--f-mono); font-size: 0.9rem;
  color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); resize: vertical;
}
.holdings-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; flex-wrap: wrap; }

.manage-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; margin-bottom: 1.1rem; }
.ms { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem 0.9rem; overflow: hidden; }
.ms::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.ms.sell::before { background: var(--sell); }
.ms.cut::before { background: var(--cut); }
.ms.hold::before { background: var(--hold); }
.ms .n { font-family: var(--f-mono); font-size: 1.5rem; font-weight: 700; line-height: 1; }
.ms .l { margin-top: 0.3rem; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-dim); }

/* inline "type to confirm" bars, missing-ticker rows */
.del-confirm { display: inline-flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; margin-top: 0.5rem; }
.del-confirm input {
  padding: 0.4rem 0.6rem; font-size: 0.9rem; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; outline: none; font-family: var(--f-body);
}
.missing-holdings { grid-column: 1 / -1; margin-top: 0.3rem; }
.miss-row {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 0.9rem;
  border: 1px dashed var(--line); border-radius: var(--radius); margin-top: 0.45rem; background: var(--surface);
}
.miss-sym { font-family: var(--f-mono); font-weight: 700; }

/* ---------- watchlists ---------- */
.wl-bar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; justify-content: space-between; margin: 0.2rem 0 0.6rem; }
.wl-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.wl-chip {
  padding: 0.45rem 0.8rem; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink); cursor: pointer; font-size: 0.88rem; font-family: var(--f-display);
}
.wl-chip.is-active { border-color: var(--hold); color: var(--hold); font-weight: 600; }
.wl-count { color: var(--ink-faint); font-size: 0.78rem; font-family: var(--f-mono); }
.wl-actions { display: flex; gap: 0.4rem; }
.wl-import { cursor: pointer; }
.wl-view-head { display: flex; gap: 0.7rem; align-items: center; flex-wrap: wrap; margin: 0.6rem 0 1rem; }
.wl-view-head .add-holding { flex: 1; margin: 0; min-width: 220px; }
.wl-section {
  margin: 1.3rem 0 0.6rem; font-family: var(--f-display); font-size: 0.78rem; font-weight: 600;
  color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.08em;
  display: flex; align-items: center; gap: 0.6rem;
}
.wl-section::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.wl-move {
  margin-top: 0.6rem; width: 100%; padding: 0.35rem 0.45rem; font-size: 0.8rem; font-family: var(--f-body);
  color: var(--ink-dim); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}

/* ---------- detail drawer ---------- */
.drawer-overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.5); }
.drawer {
  position: fixed; z-index: 70; top: 0; right: 0; height: 100dvh; width: min(460px, 100%);
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow);
  overflow-y: auto; padding: 1.4rem 1.3rem calc(2rem + env(safe-area-inset-bottom, 0px));
  animation: drawer-in 0.22s ease;
}
@keyframes drawer-in { from { transform: translateX(20px); opacity: 0.4; } to { transform: none; opacity: 1; } }
.drawer-close {
  position: absolute; top: 0.9rem; right: 0.9rem; width: 34px; height: 34px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-dim); font-size: 1.2rem; cursor: pointer;
}
.d-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; padding-right: 2.5rem; }
.d-head .sym { font-size: 1.6rem; font-weight: 700; }
.d-head .price { font-size: 1.2rem; color: var(--ink-dim); }
#drawer-fav {
  margin-left: auto; font-family: var(--f-display); font-size: 0.82rem; padding: 0.35rem 0.65rem; line-height: 1;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--ink-dim); cursor: pointer;
}
#drawer-fav.is-fav { border-color: var(--amber); color: var(--amber); }
.d-name { color: var(--ink-dim); font-size: 0.9rem; margin-top: 0.2rem; }
.d-stats { display: flex; gap: 1.4rem; margin: 0.55rem 0 0.2rem; font-size: 0.95rem; }
.d-stats .k { color: var(--ink-dim); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; margin-right: 0.35rem; }
.d-stats b { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }

/* ---- drawer hero: ticker + price + the quality score, front and centre ---- */
.d-hero {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 16px; padding: 1rem 1.1rem; margin: 0.1rem 0 1.1rem;
}
.d-hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.d-hero-id { min-width: 0; }
.d-hero-marks { display: inline-flex; align-items: center; flex-wrap: wrap; font-size: 1rem; letter-spacing: 0; }
.d-hero-sym { display: flex; align-items: center; flex-wrap: wrap; gap: 0.45rem; font: 800 1.75rem/1 var(--f-display); color: var(--ink); letter-spacing: -0.015em; }
.d-hero-name { font: 500 0.82rem/1.35 var(--f-body); color: var(--ink-dim); margin-top: 0.35rem; }
.d-hero-price { display: flex; flex-direction: column; align-items: flex-end; gap: 0.25rem; text-align: right; font: 700 1.3rem/1.05 var(--f-mono); color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* the score row */
.d-hero-score { display: flex; align-items: center; gap: 1.05rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.d-hero-meta { min-width: 0; display: flex; flex-direction: column; gap: 0.32rem; }
.d-hero-grade { font: 700 1.05rem/1.2 var(--f-display); color: var(--ink); display: flex; align-items: center; gap: 0.45rem; }
.d-hero-grade.hx-good { color: var(--buy); }
.d-hero-grade.hx-bad { color: var(--sell); }
.d-hero-pass { font: 500 0.75rem var(--f-mono); color: var(--ink-dim); }
.d-hero-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin-top: 0.1rem; }
.d-hero-chips-solo { margin-top: 0.9rem; }
.d-hero-stats { display: flex; gap: 1.4rem; margin-top: 0.9rem; padding-top: 0.85rem; border-top: 1px solid var(--line); }
.d-hero-stats span { display: flex; flex-direction: column; gap: 0.18rem; }
.d-hero-stats .k { font: 600 0.62rem/1 var(--f-display); text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); }
.d-hero-stats b { font: 700 0.95rem var(--f-mono); color: var(--ink); font-variant-numeric: tabular-nums; }
/* the circular score dial */
.score-ring { position: relative; width: 84px; height: 84px; flex: none; }
.score-ring svg { width: 84px; height: 84px; display: block; }
.score-ring .sr-track { fill: none; stroke: color-mix(in srgb, var(--ink) 12%, transparent); stroke-width: 7; }
.score-ring .sr-arc { fill: none; stroke-width: 7; stroke-linecap: round; transition: stroke-dasharray 0.4s ease; }
.score-ring.sr-a .sr-arc { stroke: var(--buy); }
.score-ring.sr-b .sr-arc { stroke: var(--health-good); }
.score-ring.sr-c .sr-arc { stroke: var(--amber); }
.sr-num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; font: 800 1.55rem/1 var(--f-display); color: var(--ink); font-variant-numeric: tabular-nums; }
.sr-num small { font: 700 0.5rem/1 var(--f-display); color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 0.2rem; }
.score-ring.sr-a .sr-num { color: var(--buy); }
.score-ring.sr-b .sr-num { color: var(--health-good); }
.score-ring.sr-c .sr-num { color: var(--amber); }
.d-hero .ext-quote { font-size: 0.72rem; }

/* 52-week range bar at the top of the drawer */
.r52 { margin: 0.85rem 0 0.3rem; }
.r52-lbl { font: 600 0.66rem/1 var(--f-display); text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-dim); margin-bottom: 0.55rem; }
.r52-bar {
  position: relative; height: 6px; border-radius: 999px; border: 1px solid var(--line);
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--down) 40%, var(--surface-2)),
    var(--surface-2) 42%, var(--surface-2) 58%,
    color-mix(in srgb, var(--up) 40%, var(--surface-2)));
}
.r52-dot {
  position: absolute; top: 50%; width: 13px; height: 13px; border-radius: 50%;
  background: var(--watch); border: 2px solid var(--surface); transform: translate(-50%, -50%);
  box-shadow: 0 1px 3px rgba(0,0,0,.22);
}
.r52-ends { display: flex; justify-content: space-between; margin-top: 0.55rem; gap: 1rem; }
.r52-end { display: flex; flex-direction: column; font-family: var(--f-mono); }
.r52-end b { font-size: 0.94rem; color: var(--ink); }
.r52-end small { font: 500 0.68rem/1.3 var(--f-body); color: var(--ink-faint); text-transform: none; letter-spacing: 0; margin-top: 0.12rem; }
.r52-hi { text-align: right; align-items: flex-end; }
.d-fetched { color: var(--ink-faint); font-size: 0.82rem; margin: 0.35rem 0 0.9rem; font-family: var(--f-mono); }
.d-fetched .hint { display: inline; color: var(--ink-faint); }
/* Add-to-watchlist — prominent, full-width, right under the hero. */
.d-addwl { display: flex; align-items: center; gap: 0.6rem; margin: 0 0 0.75rem; }
.d-addwl select {
  flex: 1 1 auto; width: 100%; padding: 0.6rem 0.9rem; font: 600 0.9rem var(--f-display);
  color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); border-radius: 10px; cursor: pointer;
}
.d-addwl select:hover { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.btn-pull { margin: 0; font-size: 0.85rem; }

/* Fetch time — right in the hero, under the name. */
.d-hero-fetched { font: 500 0.68rem/1 var(--f-mono); color: var(--ink-faint); margin-top: 0.4rem; }

/* Last-earnings panel — reported EPS vs Street + revenue/YoY, two cards. */
.le-pending { margin: 0 0 0.6rem; padding: 0.55rem 0.7rem; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--accent) 10%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); font: 600 0.82rem/1.4 var(--f-body); color: var(--ink); }
.le-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin: 0 0 1rem; }
.le-cell { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 0.7rem 0.85rem; min-width: 0; }
.le-k { font: 600 0.62rem/1 var(--f-display); text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); }
.le-v { font: 800 1.35rem/1.1 var(--f-mono); color: var(--ink); font-variant-numeric: tabular-nums; margin: 0.32rem 0 0.22rem; }
.le-sub { font: 500 0.74rem/1.35 var(--f-mono); color: var(--ink-dim); }

/* Fair-value panel — earnings-multiple estimate (fwd EPS × normal P/E) with a
   low→high band and today's price marked on it. */
.fv-panel {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 0.85rem 0.95rem 0.9rem; margin: 0 0 1rem;
}
.fv-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem; }
.fv-fair { font: 800 1.7rem/1 var(--f-mono); color: var(--ink); font-variant-numeric: tabular-nums; }
.fv-up { font: 700 0.82rem/1 var(--f-mono); white-space: nowrap; }
.fv-bar { position: relative; height: 9px; margin: 0.9rem 0 0.45rem; }
.fv-track {
  position: absolute; inset: 0; border-radius: 999px;
  background: color-mix(in srgb, var(--ink-faint) 22%, transparent);
}
/* the estimated fair-value range, highlighted green within the track */
.fv-band {
  position: absolute; top: 0; bottom: 0; border-radius: 999px;
  background: color-mix(in srgb, var(--buy) 60%, transparent);
}
.fv-dot {
  position: absolute; top: 50%; width: 13px; height: 13px; border-radius: 50%;
  background: var(--ink); border: 2px solid var(--surface-2);
  transform: translate(-50%, -50%); box-shadow: 0 0 0 1px var(--line); z-index: 1;
}
.fv-scale {
  display: flex; justify-content: space-between; gap: 0.4rem;
  font: 500 0.68rem/1.3 var(--f-mono); color: var(--ink-faint); font-variant-numeric: tabular-nums;
}
.fv-scale .fv-now { color: var(--ink); font-weight: 700; }
.fv-math {
  margin: 0.7rem 0 0; font: 500 0.78rem/1.5 var(--f-mono); color: var(--ink-dim);
}
.fv-math b { color: var(--ink); font-weight: 800; }
.fv-times { color: var(--ink-faint); margin: 0 0.15rem; }
.fv-note {
  margin: 0.6rem 0 0; font: 500 0.7rem/1.4 var(--f-body); color: var(--ink-faint);
}

/* Condensed action row — small pills so the links don't dominate on mobile. */
.d-actions-tight { gap: 0.4rem; margin: 0 0 1rem; }
.d-actions-tight:has(+ .d-xreply-row) { margin-bottom: 0.4rem; }
/* "Last shared: …" history line under the drawer actions (max 3 timestamps). */
/* editable Research / News prompt, opened in place under the stock's buttons */
.d-ask { margin: -0.3rem 0 1rem; padding: 0.7rem 0.75rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); display: grid; gap: 0.5rem; }
.d-ask-btn.is-on { border-color: var(--accent); color: var(--accent); }
.d-ask-h { font: 700 0.86rem/1.35 var(--f-display); color: var(--ink); }
.d-ask-h .hint { font: 500 0.78rem/1.35 var(--f-body); margin: 0; }
.d-ask-text {
  width: 100%; min-height: 7.5rem; max-height: 13rem; field-sizing: content; resize: vertical; overflow-y: auto;
  padding: 0.6rem 0.7rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); font: 500 16px/1.5 var(--f-body); /* 16px: no iOS zoom */
}
.d-ask-text:focus { outline: none; border-color: var(--accent); }
.d-ask-acts { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.d-ask-go { text-decoration: none; padding-inline: 1.3rem; }

/* past shares in the stock's details: when · price then → now · move since */
.d-sharelog { margin: 0 0 1rem; padding: 0.3rem 0.75rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.shr-row { display: grid; grid-template-columns: 1fr auto; gap: 0 0.7rem; align-items: baseline; padding: 0.45rem 0; }
.shr-row + .shr-row { border-top: 1px solid var(--line); }
.shr-when { font: 600 0.84rem/1.4 var(--f-body); color: var(--ink); }
.shr-pct { font: 700 0.84rem var(--f-mono); white-space: nowrap; }
.shr-px { grid-column: 1 / -1; font: 500 0.78rem/1.4 var(--f-mono); color: var(--ink-dim); }
.shr-none { font-family: var(--f-body); color: var(--ink-faint); }
/* Ownership & insiders drawer block. */
.own-body { margin: 0 0 1rem; display: flex; flex-direction: column; gap: 0.4rem; }
.own-row { font: 500 0.82rem/1.45 var(--f-body); color: var(--ink-dim); }
.own-row b { color: var(--ink); font-weight: 700; }
.own-top { font: 500 0.74rem/1.4 var(--f-mono); color: var(--ink-faint); }
.own-loading, .own-empty { font: 500 0.78rem/1.4 var(--f-body); color: var(--ink-faint); }
.d-actions-tight .btn { font-size: 0.78rem; padding: 0.32rem 0.6rem; }
.d-actions-tight .btn-pull { padding: 0.32rem 0.55rem; }
.btn-pull.is-loading { opacity: 0.6; pointer-events: none; }
/* ---------- financial-health panel ---------- */
.health-head {
  font-family: var(--f-display); font-size: 0.92rem; font-weight: 600;
  padding: 0.5rem 0.75rem; border-radius: 10px; margin: 0 0 0.6rem;
  border: 1px solid var(--line);
}
.health-head b { font-weight: 700; }
/* Reconciling note shown when the raw 6-check header and the sector-adjusted
   Q-score disagree — keeps a red header next to a good Q-score from reading as a bug. */
.health-note {
  font-size: 0.8rem; line-height: 1.4; color: var(--ink-dim);
  margin: -0.2rem 0 0.7rem; padding: 0 0.15rem;
}
/* grade legend: reset the badge's list-spacing margin so A/B sit inline in the sentence */
.grade-legend .fin-badge { margin: 0 0.15rem; }
/* Cycle position (margin peak/trough) note — coloured chip by tone. */
.cycle-note {
  font-weight: 500; border-radius: 8px; padding: 0.4rem 0.55rem; margin: 0 0 0.8rem;
  border: 1px solid var(--line); background: var(--surface-2);
}
.cycle-note .hint { font-weight: 400; }
/* "good" = good time to invest → blue (accent), distinct from the green pass tags */
.cyc-good { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.cyc-watch { color: var(--amber); background: color-mix(in srgb, var(--amber) 9%, transparent); border-color: color-mix(in srgb, var(--amber) 28%, var(--line)); }
.cyc-bad { color: var(--sell); background: color-mix(in srgb, var(--sell) 9%, transparent); border-color: color-mix(in srgb, var(--sell) 28%, var(--line)); }
.cyc-neutral { color: var(--ink-dim); }
/* limited-data warning + partial Q-score marker */
.data-warn { color: var(--amber); font-weight: 500; border-radius: 8px; padding: 0.4rem 0.55rem; margin: 0 0 0.8rem; border: 1px solid color-mix(in srgb, var(--amber) 28%, var(--line)); background: color-mix(in srgb, var(--amber) 9%, transparent); }
.q-chip.q-partial { position: relative; }
/* Circled "C" on a card — cyclical marker, coloured by investment timing. */
.cyc-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.05rem; height: 1.05rem; margin-left: 0.28rem; flex: none; vertical-align: middle;
  border-radius: 50%; border: 1.5px solid currentColor; font: 800 0.6rem/1 var(--f-display);
}
.cyc-badge.cyc-good { color: var(--accent); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.cyc-badge.cyc-bad { color: var(--sell); border-color: var(--sell); background: color-mix(in srgb, var(--sell) 12%, transparent); }
.cyc-badge.cyc-watch { color: var(--amber); border-color: var(--amber); background: color-mix(in srgb, var(--amber) 12%, transparent); }
.cyc-badge.cyc-neutral { color: var(--ink-faint); border-color: var(--ink-faint); background: transparent; }
/* Financial star: blue = all 5 checks green, red = 4 of 5. */
.fin-star { margin-left: 0.35rem; font-size: 1.25rem; line-height: 1; vertical-align: middle; }
.fin-star-blue { color: var(--accent); }
.fin-star-red { color: var(--sell); }
/* Below the 200-week SMA → enclose the star in a circle (same colour as the star). */
.fin-star-circled {
  display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box;
  width: 1.5rem; height: 1.5rem; border: 1.6px solid currentColor; border-radius: 50%;
  font-size: 0.98rem;
}
/* cyclical-sector caveat: a muted amber note so it reads as "context", not a red flag */
.cyclical-note {
  color: var(--amber); font-weight: 500;
  background: color-mix(in srgb, var(--amber) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--amber) 28%, var(--line));
  border-radius: 8px; padding: 0.4rem 0.55rem; margin: 0 0 0.8rem;
}
.hx-head-good { color: var(--health-good); background: color-mix(in srgb, var(--health-good) 10%, transparent); border-color: color-mix(in srgb, var(--health-good) 35%, var(--line)); }
.hx-head-watch { color: var(--amber); background: color-mix(in srgb, var(--amber) 10%, transparent); border-color: color-mix(in srgb, var(--amber) 35%, var(--line)); }
.hx-head-bad { color: var(--sell); background: color-mix(in srgb, var(--sell) 10%, transparent); border-color: color-mix(in srgb, var(--sell) 35%, var(--line)); }
.health-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin: 0 0 1rem; }
@media (max-width: 380px) { .health-grid { grid-template-columns: repeat(2, 1fr); } }
.health-chip {
  border: 1px solid var(--line); border-left-width: 3px; border-radius: 9px;
  padding: 0.45rem 0.55rem; background: var(--surface-2); min-width: 0;
}
.health-chip.hx-good { border-left-color: var(--health-good); }
.health-chip.hx-watch { border-left-color: var(--amber); }
.health-chip.hx-bad { border-left-color: var(--sell); }
.health-chip.hx-na { border-left-color: var(--ink-faint); opacity: 0.6; }
/* PEG is not part of the quality score → render neutral ("full white"): no coloured
   status strip, plain surface, hollow dot. */
.health-chip.hx-off { border-left-color: var(--line); background: var(--surface); }
/* "Strong" growth — a hotter green than a normal pass: tinted fill, green ring +
   value. Fires when Revenue growth > 15% or EPS growth > 25%. */
.health-chip.hx-strong {
  border-color: color-mix(in srgb, var(--health-good) 55%, var(--line));
  border-left-color: var(--health-good);
  background: color-mix(in srgb, var(--health-good) 13%, var(--surface-2));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--health-good) 32%, transparent);
}
.health-chip.hx-strong .hx-val { color: var(--health-good); }
.hx-toprow { display: flex; align-items: center; gap: 0.3rem; }
.hx-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--ink-faint); }
.hx-dot.hx-good { background: var(--health-good); }
.hx-dot.hx-watch { background: var(--amber); }
.hx-dot.hx-bad { background: var(--sell); }
.hx-dot.hx-off { background: transparent; border: 1px solid var(--line); }
/* Per-cell pass/watch/fail word, coloured to match the check's status. */
.hx-status { font: 700 0.56rem/1 var(--f-display); text-transform: uppercase; letter-spacing: 0.04em; padding: 0.1rem 0.32rem; border-radius: 999px; }
.hx-status.hx-good { color: var(--health-good); background: color-mix(in srgb, var(--health-good) 15%, transparent); }
.hx-status.hx-watch { color: var(--amber); background: color-mix(in srgb, var(--amber) 15%, transparent); }
.hx-status.hx-bad { color: var(--sell); background: color-mix(in srgb, var(--sell) 15%, transparent); }
.hx-status.hx-na { color: var(--amber); background: color-mix(in srgb, var(--amber) 15%, transparent); }
/* missing-data box: dashed amber accent so it clearly reads "no data", not a status */
.health-chip.hx-na { border-left-color: var(--amber); border-left-style: dashed; opacity: 1; }
.hx-label { font-size: 0.66rem; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hx-info { margin-left: auto; flex: none; }
.hx-val { font-family: var(--f-mono); font-variant-numeric: tabular-nums; font-size: 1.02rem; font-weight: 600; color: var(--ink); margin-top: 0.15rem; }
.hx-sub { font-size: 0.66rem; color: var(--ink-faint); margin-top: 0.05rem; }
/* Expandable metric chips (ROIC / Op margin / Rev growth / FCF) → history bars */
.health-chip.hx-expandable { cursor: pointer; }
.health-chip.hx-expandable:hover { border-color: color-mix(in srgb, var(--ink) 22%, var(--line)); }
.health-chip.is-open { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 18%, transparent); }
.hx-caret { display: inline-block; margin-left: 0.25rem; font-size: 0.58rem; color: var(--ink-faint); transition: transform 0.15s ease; }
.health-chip.is-open .hx-caret { transform: rotate(180deg); color: var(--ink-dim); }
.hx-detail { margin: -0.5rem 0 1rem; padding: 0.55rem 0.7rem 0.65rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  /* Same TradingView histogram palette the MACD chart (.macdbars) defines — the bar
     fills use these vars, which aren't inherited outside .macdbars. */
  --mb-up: #26a69a; --mb-up-weak: #86cfc6; --mb-dn: #ef5350; --mb-dn-weak: #f2a7a4; }
.hx-detail-head { display: flex; align-items: center; gap: 0.35rem; font: 500 0.8rem/1.2 var(--f-body); color: var(--ink-dim); margin-bottom: 0.15rem; }
.hx-detail-head b { color: var(--ink); font-weight: 700; }
.hx-detail-close { margin-left: auto; border: none; background: transparent; color: var(--ink-faint); font-size: 1.15rem; line-height: 1; cursor: pointer; padding: 0 0.15rem; }
.hx-detail-close:hover { color: var(--ink); }
.empty-mini { display: flex; align-items: center; justify-content: center; height: 64px; color: var(--ink-faint); font: italic 0.72rem/1.2 var(--f-body); }
.hx-detail .mb-readout { margin-top: 0.5rem; }
.hx-detail-hint { margin-top: 0.35rem; font: 0.66rem/1.3 var(--f-body); color: var(--ink-faint); }
/* pull + Yahoo Finance actions row in the detail drawer */
.d-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin: 0 0 1rem; }
.d-actions .btn-pull { margin: 0; }
.btn-yf { font-size: 0.85rem; color: var(--ink-dim); text-decoration: none; }
.btn-yf:hover { border-color: var(--buy); color: var(--buy); }
/* floating jump-to-top / jump-to-bottom buttons inside the detail drawer */
.drawer-jump {
  position: fixed; z-index: 75; right: 1rem;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 0.4rem;
}
.drawer-jump-btn {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  font-size: 1.05rem; line-height: 1; cursor: pointer; box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
  opacity: 0.9; transition: opacity 0.12s, transform 0.05s, border-color 0.12s;
}
.drawer-jump-btn:hover { opacity: 1; border-color: var(--ink-faint); }
.drawer-jump-btn:active { transform: scale(0.94); }
/* close sits above the jump arrows for easy thumb reach; solid red + white glyph
   so it's unmistakable and high-contrast (was a faint tint that was easy to miss) */
.drawer-jump-close {
  font-size: 1.5rem; font-weight: 700; color: #fff; opacity: 1;
  background: var(--sell);
  border-color: color-mix(in srgb, var(--sell) 80%, #000);
}
.drawer-jump-close:hover { background: color-mix(in srgb, var(--sell) 85%, #000); border-color: color-mix(in srgb, var(--sell) 65%, #000); }
/* Bigger + bolder on mobile — the primary way to dismiss the drawer by thumb. */
@media (max-width: 760px) {
  .drawer-jump-close { width: 56px; height: 56px; font-size: 2rem; box-shadow: 0 3px 10px rgba(0,0,0,0.28); }
}

/* activity / fetch log */
.activity { display: flex; flex-direction: column; gap: 0.4rem; }
.activity-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 0.9rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.activity-row.is-tappable { cursor: pointer; transition: border-color 0.12s, transform 0.06s; }
.activity-row.is-tappable:hover { border-color: var(--ink-faint); transform: translateY(-1px); }
.act-sym { font-family: var(--f-mono); font-weight: 700; }
.act-when { color: var(--ink-dim); font-size: 0.85rem; font-family: var(--f-mono); }
/* "Oldest data" panel: the 3 stalest names + one-tap refetch. */
.act-stale { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem; }
.act-stale-hd { font: 700 0.72rem/1 var(--f-display); text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); margin-bottom: 0.15rem; }
.act-stale-row {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 0.9rem; background: var(--surface-2);
  border: 1px solid var(--line); border-left: 3px solid var(--amber); border-radius: var(--radius-sm);
}
.act-stale-sym { font-family: var(--f-mono); font-weight: 700; }
.act-stale-name { color: var(--ink-dim); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.act-stale-when { color: var(--ink-faint); font-size: 0.78rem; font-family: var(--f-mono); white-space: nowrap; }
.act-refetch { padding: 0.32rem 0.7rem; font-size: 0.8rem; white-space: nowrap; }
.act-log-hd { font: 700 0.72rem/1 var(--f-display); text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); margin: 0.4rem 0 0.15rem; }

/* Notification history: last 10 days of pushes, grouped by day. */
.act-notifs { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1.1rem; }
.notif-day { font: 600 0.78rem/1 var(--f-display); color: var(--ink-dim); margin: 0.55rem 0 0.1rem; }
.notif-day:first-of-type { margin-top: 0.1rem; }
.notif-row {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.55rem 0.8rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.notif-row.is-tappable { cursor: pointer; transition: border-color 0.12s, transform 0.06s; }
.notif-row.is-tappable:hover { border-color: var(--ink-faint); transform: translateY(-1px); }
.notif-ico { font-size: 0.95rem; line-height: 1; }
.notif-sym { font-family: var(--f-mono); font-weight: 700; }
.notif-kind { color: var(--ink-dim); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.notif-when { color: var(--ink-faint); font-size: 0.78rem; font-family: var(--f-mono); white-space: nowrap; }

.verdict-banner { border-radius: var(--radius); padding: 0.9rem 1rem; margin: 0.4rem 0 1.2rem; color: var(--on-fill); }
.verdict-banner .v { font-family: var(--f-display); font-weight: 700; font-size: 1.25rem; letter-spacing: 0.02em; }
.verdict-banner .sub { font-size: 0.85rem; opacity: 0.92; margin-top: 0.15rem; }
.vb-BUY { background: var(--buy); }
.vb-WATCH { background: var(--watch); }
.vb-HOLD { background: var(--hold); }
.vb-CUT { background: var(--cut); }
.vb-SELL { background: var(--sell); }
.vb-NONE { background: var(--ink-faint); }

/* drawer: verdict-by-strategy chips */
.d-strats { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.2rem 0 0.4rem; }
.d-strat {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.35rem;
  flex: 1 1 28%; min-width: 96px; padding: 0.55rem 0.6rem; text-align: left;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer;
}
.d-strat:hover { border-color: var(--ink-faint); }
.d-strat.is-active { border-color: var(--hold); box-shadow: inset 0 0 0 1px var(--hold); }
.d-strat-label { font-size: 0.72rem; font-weight: 600; color: var(--ink-dim); }
.d-strat-verdict { display: inline-flex; align-items: center; gap: 0.3rem; }

/* drawer: Stan Weinstein stage panel */
.wein-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.85rem 1rem; }
.wein-stage { font-family: var(--f-display); font-weight: 700; font-size: 1.05rem; }
.wein-s2 { border-color: color-mix(in srgb, var(--buy) 45%, var(--line)); }
.wein-s3 { border-color: color-mix(in srgb, var(--amber) 45%, var(--line)); }
.wein-s4 { border-color: color-mix(in srgb, var(--sell) 45%, var(--line)); }
.wein-s2 .wein-stage { color: var(--buy); }
.wein-s1 .wein-stage { color: var(--ink-dim); }
.wein-s3 .wein-stage { color: var(--amber); }
.wein-s4 .wein-stage { color: var(--sell); }
.wein-table { width: 100%; margin-top: 0.55rem; border-collapse: collapse; }
.wein-table th { text-align: left; font-weight: 500; color: var(--ink-dim); font-size: 0.85rem; padding: 0.15rem 0; }
.wein-table td { text-align: right; font-family: var(--f-mono); font-variant-numeric: tabular-nums; }

.d-section-title {
  font-family: var(--f-display); font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--ink-dim); margin: 1.3rem 0 0.6rem;
}
.rsi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; }
.rsi-cell { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.6rem 0.4rem; text-align: center; }
.rsi-cell .k { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-dim); }
.rsi-cell .v { font-family: var(--f-mono); font-size: 1.15rem; font-weight: 700; margin-top: 0.15rem; }
.rsi-cell .v.rsi-hot { color: var(--sell); }
.rsi-cell .v.rsi-cold { color: var(--watch); }

.gates { display: flex; flex-direction: column; gap: 0.4rem; }
.gate { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 0.6rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.55rem 0.75rem; }
.g-label { font-size: 0.85rem; }
.g-val { font-family: var(--f-mono); font-size: 0.85rem; color: var(--ink-dim); }
.g-flag { font-family: var(--f-display); font-size: 0.66rem; font-weight: 700; padding: 0.12rem 0.4rem; border-radius: 6px; }
.g-yes { background: color-mix(in srgb, var(--buy) 20%, transparent); color: var(--buy); }
.g-no { background: color-mix(in srgb, var(--sell) 18%, transparent); color: var(--sell); }

.levels { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.86rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.levels th { text-align: left; font-family: var(--f-display); font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); padding: 0.55rem 0.85rem; border-bottom: 1px solid var(--line); }
.levels th:nth-child(2), .levels th:nth-child(3) { text-align: right; }
.levels td { padding: 0.55rem 0.85rem; border-bottom: 1px solid var(--line); font-family: var(--f-mono); font-variant-numeric: tabular-nums; text-align: right; }
.levels td:first-child { font-family: var(--f-body); color: var(--ink); text-align: left; }
.levels tr:last-child td { border-bottom: 0; }
/* timeframe group headers (Daily / Weekly) inside the levels table */
.levels tr.lvl-group td { font: 700 0.62rem/1 var(--f-display); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); padding: 0.7rem 0.85rem 0.25rem; border-bottom: 0; background: color-mix(in srgb, var(--ink) 4%, transparent); text-align: left; }
.levels .above { color: var(--buy); }
.levels .below { color: var(--sell); }
/* EMA-21 exit lines: bold, whole row blue (price above) / red (below). */
.levels tr.lvl-ema21 td { font-weight: 700; }
.levels tr.lvl-ema21.above td { color: var(--accent); }
.levels tr.lvl-ema21.below td { color: var(--sell); }

.plan { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1rem; font-size: 0.9rem; }
.plan .lvl { font-family: var(--f-mono); }
.macd-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem 1rem; font-size: 0.9rem; }
.macd-box.macd-alert { background: color-mix(in srgb, var(--sell) 10%, var(--surface-2)); border-color: color-mix(in srgb, var(--sell) 40%, var(--line)); }
.macd-row b { font-family: var(--f-mono); }
.macd-warn { margin-top: 0.5rem; color: var(--sell); font-weight: 600; line-height: 1.4; }

/* ---------- footer ---------- */
.site-footer { margin: 2.5rem auto 1rem; color: var(--ink-faint); font-size: 0.8rem; }

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

/* ============================================================ portfolio */
:root { --up: var(--buy); --down: #d64545; }
:root[data-theme="dark"], html { }
@media (prefers-color-scheme: dark) { :root { --down: #ef6b6b; } }
:root[data-theme="dark"] { --down: #ef6b6b; }
.pl-up { color: var(--up); }
.pl-down { color: var(--down); }
.pl-flat { color: var(--ink-faint); }

/* --- totals bar --- */
.totals-bar { margin: 0.25rem 0 1rem; }
.totals-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; margin-bottom: 0.6rem; flex-wrap: wrap;
}
.owner-chips { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.owner-chip {
  font: 600 0.8rem/1 var(--f-display); color: var(--ink-dim);
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 0.4rem 0.75rem; border-radius: 999px; cursor: pointer;
}
.owner-chip.is-active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.totals-asof { display: flex; flex-direction: column; align-items: flex-end; gap: 0.28rem; font: 500 0.72rem/1.1 var(--f-mono); color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.04em; text-align: right; }
.totals-priced { text-transform: none; letter-spacing: 0; color: var(--ink-dim); font-weight: 600; }
.totals-priced::before { content: "◷ "; color: var(--ink-faint); }
/* Totals: four squares — a filled hero (Total portfolio) + Retirement / Regular /
   Cash tiles with colour-coded top accents. Mobile stacks them 2-up (hero full). */
.totals-grid {
  display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 0.7rem;
}
.total-tile {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 0.9rem 1.05rem; box-shadow: var(--shadow-sm);
}
.total-tile.total-hero {
  color: var(--accent-ink);
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 60%),
    linear-gradient(150deg, var(--accent), color-mix(in srgb, var(--accent) 62%, #1a1630));
  border-color: transparent;
}
.total-tile.total-hero .tt-l { color: color-mix(in srgb, var(--accent-ink) 78%, transparent); }
.total-tile.total-hero .tt-n { color: var(--accent-ink); letter-spacing: -0.02em; }
.total-tile.total-hero .tt-sub { color: color-mix(in srgb, var(--accent-ink) 88%, transparent); }
.total-tile.ret { border-top: 3px solid var(--hold); }
.total-tile.reg { border-top: 3px solid var(--watch); }
.total-tile.cash { border-top: 3px solid var(--amber); }
.tt-l { font: 600 0.7rem/1 var(--f-display); color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.06em; }
.tt-n { font: 800 1.7rem/1.05 var(--f-display); color: var(--ink); margin-top: 0.3rem; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.tt-sub { font: 500 0.78rem/1.2 var(--f-mono); margin-top: 0.3rem; color: var(--ink-dim); }
/* "today" leads the hero sub-lines — a hair bolder/brighter than unrealized */
.tt-today { font-weight: 700; }
.total-tile.total-hero .tt-today { color: var(--accent-ink); }
/* Small explicit pre/after-hours total, below the (regular-close) total on the hero. */
.tt-ext { font: 600 0.7rem/1.25 var(--f-mono); margin-top: 0.32rem; display: flex; align-items: baseline; gap: 0.4rem; flex-wrap: wrap; }
.tt-ext .tt-ext-chg { font-weight: 500; }
.total-tile.total-hero .tt-ext { color: color-mix(in srgb, var(--accent-ink) 82%, transparent); }
.total-tile.total-hero .tt-ext .tt-ext-chg { color: color-mix(in srgb, var(--accent-ink) 70%, transparent); }
.tile-split { font: 500 0.72rem/1.3 var(--f-mono); color: var(--ink-dim); margin-top: 0.3rem; }
.tt-caret { font-size: 0.6em; opacity: 0.55; vertical-align: middle; }
.total-tile.is-clickable { cursor: pointer; transition: box-shadow 0.12s ease, transform 0.12s ease; }
.total-tile.is-clickable:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.total-tile.is-clickable:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
@media (max-width: 760px) {
  .totals-grid { grid-template-columns: 1fr 1fr; }
  .total-tile.total-hero { grid-column: 1 / -1; }
}
.cash-breakdown {
  margin-top: 0.7rem; background: var(--surface); border: 1px solid var(--line);
  border-top: 3px solid var(--amber); border-radius: var(--radius-sm);
  padding: 0.55rem 0.95rem; box-shadow: var(--shadow-sm);
}
.cb-head { font: 600 0.7rem/1 var(--f-display); color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.35rem; }
.cb-row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: 0.4rem 0; border-top: 1px solid var(--line); }
.cb-row:first-of-type { border-top: 0; }
.cb-acct { font: 600 0.9rem var(--f-display); color: var(--ink); }
.cb-owner { font: 500 0.72rem var(--f-mono); color: var(--ink-dim); text-transform: capitalize; margin-left: 0.15rem; }
.cb-amt { font: 700 0.95rem var(--f-mono); color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cb-empty { font: 500 0.85rem var(--f-mono); color: var(--ink-dim); }

/* --- portfolio sub-tabs: Holdings / Snapshots / Sold --- */
.pf-subtabs {
  display: flex; gap: 0.25rem; margin: 0 0 1rem; padding: 0.25rem;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
}
.pf-subtab {
  flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  padding: 0.5rem 0.4rem; border: 0; border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--ink-dim); font: 600 0.86rem/1 var(--f-display);
  transition: color 0.12s ease, background 0.12s ease;
}
.pf-subtab:hover { color: var(--ink); }
.pf-subtab.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.pf-subtab-n {
  font: 700 0.66rem/1 var(--f-mono); padding: 0.12rem 0.36rem; border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 10%, transparent); color: var(--ink-dim);
}
.pf-subtab.is-active .pf-subtab-n { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }

/* --- portfolio tab --- */
.pf-controls { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.9rem; flex-wrap: wrap; }
/* "Needs attention" — three colour-coded buckets pulled above the holdings */
.manage-alerts { margin: 0 0 1rem; display: flex; flex-direction: column; gap: 0.6rem; }
.ma-title { font: 700 0.78rem/1 var(--f-display); color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.ma-box { padding: 0.7rem 0.85rem; border-radius: 12px; border: 1px solid var(--line); border-left-width: 4px; }
/* a) both signals — red · b) below wEMA21 — amber · c) MACD down — magenta */
/* Strong Sell — the primary exit, a hair bolder than the softer buckets below it */
.ma-box.ma-strong { color: var(--sell); background: color-mix(in srgb, var(--sell) 14%, transparent); border-color: color-mix(in srgb, var(--sell) 45%, var(--line)); border-left-color: var(--sell); border-left-width: 5px; }
.ma-box.ma-both { color: var(--sell); background: color-mix(in srgb, var(--sell) 9%, transparent); border-color: color-mix(in srgb, var(--sell) 32%, var(--line)); border-left-color: var(--sell); }
.ma-box.ma-ema { color: var(--amber); background: color-mix(in srgb, var(--amber) 9%, transparent); border-color: color-mix(in srgb, var(--amber) 32%, var(--line)); border-left-color: var(--amber); }
.ma-box.ma-macd { color: var(--cut); background: color-mix(in srgb, var(--cut) 9%, transparent); border-color: color-mix(in srgb, var(--cut) 32%, var(--line)); border-left-color: var(--cut); }
.ma-head {
  font: 700 0.85rem/1.2 var(--f-display); color: inherit;
  display: flex; align-items: baseline; gap: 0.45rem; flex-wrap: wrap; margin-bottom: 0.55rem;
}
.ma-count { font: 700 0.7rem/1 var(--f-mono); padding: 0.12rem 0.4rem; border-radius: 999px; background: color-mix(in srgb, currentColor 16%, transparent); }
.ma-sub { font-weight: 500; font-size: 0.75rem; color: var(--ink-dim); letter-spacing: 0; }
.ma-list { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.ma-chip {
  display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer;
  padding: 0.3rem 0.5rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
}
.ma-chip:hover { border-color: color-mix(in srgb, currentColor 45%, var(--line)); }
.ma-chip .ma-sym { font: 700 0.82rem/1 var(--f-display); color: var(--ink); }
.ma-chip .pill { margin-right: 0; }
.pill-ema { background: var(--amber); color: #1a1206; }
.ma-pl { font: 600 0.76rem/1 var(--f-mono, monospace); }
/* Overextended box — a "heads up, wait to add" note, blue accent (not a loss). */
.ma-box.ma-ext { color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, transparent); border-color: color-mix(in srgb, var(--accent) 32%, var(--line)); border-left-color: var(--accent); }
.pill-ext { background: var(--accent); color: var(--on-fill, #fff); }
.ma-buytarget { font: 700 0.74rem/1 var(--f-mono, monospace); color: var(--accent); }

/* "Previously sold · rising now" — an opportunity, so a green accent (not a warning) */
.ma-box.ma-sold { color: var(--buy); background: color-mix(in srgb, var(--buy) 8%, transparent); border-color: color-mix(in srgb, var(--buy) 32%, var(--line)); border-left-color: var(--buy); }
.ma-sold-list { flex-direction: column; align-items: stretch; }
.ma-sold-chip {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.25rem;
  border-radius: 12px; padding: 0.55rem 0.7rem; text-align: left; width: 100%;
}
.ma-chip-top { display: inline-flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.pill-rising { background: var(--buy); color: #04120b; }
.ma-sold-meta { font: 500 0.72rem/1.2 var(--f-mono); color: var(--ink-dim); }
.ma-sold-note { font: 500 0.82rem/1.35 var(--f-body); color: var(--ink); font-style: italic; }

/* ---- Stop-loss bookkeeping ---- */
/* Needs-attention nudge box: indigo accent, distinct from the red/amber/magenta
   sell buckets — this is a to-do (log your broker stop), not a sell signal. */
.ma-box.ma-stop {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  border-color: color-mix(in srgb, var(--accent) 32%, var(--line));
  border-left-color: var(--accent);
}
.sl-due-chip {
  display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer;
  padding: 0.3rem 0.55rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
}
.sl-due-chip:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.sl-due-sym { font: 700 0.82rem/1 var(--f-display); color: var(--ink); }
.sl-due-acct { font: 500 0.72rem/1 var(--f-body); color: var(--ink-dim); }
.sl-due-age {
  font: 700 0.68rem/1 var(--f-mono); color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  padding: 0.12rem 0.36rem; border-radius: 999px;
}

/* Expanded-panel editor (one block per account holding the symbol) */
.sl-section { margin-top: 0.7rem; border-top: 1px dashed var(--line); padding-top: 0.6rem; }
.sl-title {
  font: 700 0.78rem/1.2 var(--f-display); color: var(--ink-dim);
  display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: baseline; margin-bottom: 0.5rem;
}
.sl-title small { font: 500 0.68rem/1.3 var(--f-body); color: var(--ink-faint); }
.sl-acct {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 0.55rem 0.65rem; margin-bottom: 0.5rem;
}
.sl-acct:last-child { margin-bottom: 0; }
.sl-acct-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 0.5rem; margin-bottom: 0.45rem;
}
.sl-acct-name { font: 700 0.82rem/1.1 var(--f-display); color: var(--ink); }
.sl-acct-name small { font: 500 0.68rem/1 var(--f-body); color: var(--ink-faint); margin-left: 0.3rem; }
.sl-status { font: 600 0.72rem/1 var(--f-body); white-space: nowrap; }
.sl-status.sl-due { color: var(--sell); }
.sl-status.sl-ok { color: var(--buy); }
.sl-edit { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: stretch; }
.sl-date, .sl-val {
  font: 600 0.85rem var(--f-mono); padding: 0.4rem 0.5rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.sl-date { flex: 1 1 130px; min-width: 0; }
.sl-val-wrap { position: relative; flex: 2 1 120px; display: inline-flex; align-items: center; }
.sl-cur { position: absolute; left: 0.55rem; color: var(--ink-faint); font: 600 0.85rem var(--f-mono); pointer-events: none; }
.sl-val { width: 100%; padding-left: 1.3rem; }
.sl-val.sl-err { border-color: var(--sell); box-shadow: 0 0 0 2px color-mix(in srgb, var(--sell) 22%, transparent); }
.sl-save { flex: 0 0 auto; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.sl-save:hover { filter: brightness(1.06); }
.sl-hint { font: 500 0.68rem/1.35 var(--f-body); color: var(--ink-faint); margin-top: 0.4rem; }
.sl-hint b { color: var(--ink-dim); font-weight: 700; }
/* daily-EMA21 chip inside the stop hint — tap to fill the input with a tighter stop */
.sl-use-d {
  font: 700 0.68rem var(--f-mono); color: var(--accent, var(--buy));
  background: none; border: 0; padding: 0 0.15rem; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}
.sl-use-d:hover { color: var(--ink); }
.sl-hist { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.45rem; }
.sl-h {
  display: inline-flex; align-items: baseline; gap: 0.28rem;
  font: 600 0.74rem/1 var(--f-mono); color: var(--ink-dim);
  background: var(--surface); border: 1px solid var(--line);
  padding: 0.18rem 0.4rem; border-radius: 6px;
}
.sl-h small { font: 500 0.64rem/1 var(--f-body); color: var(--ink-faint); }
.sl-h-none { color: var(--ink-faint); border-style: dashed; }
.sl-h-skip { color: var(--ink-faint); border-style: dashed; }
/* "won't do" acknowledgement */
.sl-skip, .sl-last {
  display: flex; align-items: center; gap: 0.4rem; margin-top: 0.5rem;
  font: 500 0.74rem/1.3 var(--f-body); color: var(--ink-dim); cursor: pointer; user-select: none;
}
.sl-skip input, .sl-last input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; cursor: pointer; }
.sl-last { color: var(--ink); }
.sl-last b { color: var(--ink); font-weight: 700; }
.sl-acct.sl-skipping .sl-val-wrap { opacity: 0.4; }
.sl-val:disabled { cursor: not-allowed; }
.sl-status.sl-skip { color: var(--ink-dim); }
.pf-view { margin-left: auto; display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.pf-view-btn { font: 600 0.78rem/1 var(--f-display); padding: 0.45rem 0.85rem; background: var(--surface); color: var(--ink-dim); border: 0; cursor: pointer; }
.pf-view-btn.is-active { background: var(--ink); color: var(--surface); }
@media (max-width: 760px) {
  /* On phones the group/by toggle spans the row instead of floating right. */
  .pf-controls .pf-view { margin-left: 0; width: 100%; }
  .pf-controls .pf-view-btn { flex: 1 1 0; }
}
.pf-add-form { margin-bottom: 1rem; }
.mini-form { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.7rem; }
.pf-in { font: 500 0.85rem var(--f-body); padding: 0.45rem 0.6rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
#pf-sym { width: 6.5rem; } #pf-qty, #pf-price { width: 6rem; }

.acct { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 1rem; overflow: hidden; }
.acct-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; padding: 0.85rem 1rem; border-bottom: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.acct-id { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.acct-name { font: 700 1.02rem var(--f-display); color: var(--ink); }
.acct-add { font: 600 0.75rem var(--f-display); padding: 0.25rem 0.6rem; border: 1px solid var(--accent); border-radius: 999px; background: var(--surface); color: var(--accent); cursor: pointer; white-space: nowrap; }
.acct-add:hover { background: var(--accent); color: var(--surface); }
.acct-val { text-align: right; }
.acct-total { font: 700 1.1rem var(--f-display); color: var(--ink); font-variant-numeric: tabular-nums; }
.acct-break { display: block; font: 500 0.74rem var(--f-mono); color: var(--ink-faint); margin-top: 0.15rem; }
.badge { font: 600 0.66rem/1 var(--f-display); padding: 0.25rem 0.5rem; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.03em; }
.badge-ret { background: color-mix(in srgb, var(--hold) 18%, transparent); color: var(--hold); }
.badge-reg { background: color-mix(in srgb, var(--watch) 18%, transparent); color: var(--watch); }
.badge-owner { background: var(--surface); border: 1px solid var(--line); color: var(--ink-dim); }

.pos-table { display: block; }
.pos-row { display: grid; grid-template-columns: minmax(120px, 2.4fr) 0.8fr 0.9fr 0.9fr 1fr 1.1fr 1.2fr; gap: 0.5rem; align-items: center; padding: 0.55rem 1rem; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.pos-row:last-child { border-bottom: 0; }
.pos-head { font: 600 0.68rem/1 var(--f-display); color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.04em; background: transparent; }
.pos-row .num { text-align: right; font: 500 0.86rem var(--f-mono); }
.pos-row .num small { display: block; font-size: 0.7rem; opacity: 0.8; }
.pos-sym { display: flex; flex-direction: column; min-width: 0; }
.pos-sym .lnk { font: 700 0.92rem var(--f-display); color: var(--ink); background: none; border: 0; padding: 0; text-align: left; cursor: pointer; }
.pos-sym .lnk:hover { color: var(--watch); }
.pos-name { font: 500 0.72rem var(--f-body); color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pos-sig { display: flex; align-items: center; gap: 0.4rem; justify-content: flex-end; flex-wrap: wrap; }
/* by-symbol Signal cell: stack the verdict + MACD chip vertically so the narrow
   column reads cleanly, right-aligned (esp. on mobile where it's the last column). */
.sym-row .pos-sig { flex-direction: column; align-items: flex-end; gap: 0.3rem; }
.sym-row .pos-sig .macd-chip { white-space: nowrap; }
/* momentum chips (MACD readout + wEMA9 extension) share one line under the verdict,
   so the signal cell is two tidy rows instead of three. */
.pos-mom { display: flex; flex-wrap: wrap; gap: 0.3rem; justify-content: flex-end; }
.pos-empty, .pos-head + .pos-empty { padding: 0.8rem 1rem; color: var(--ink-faint); font: 500 0.82rem var(--f-body); }
.mini-btn { font: 600 0.72rem/1 var(--f-display); padding: 0.3rem 0.55rem; border-radius: 7px; }
.cash-edit { background: none; border: 0; color: var(--ink-dim); cursor: pointer; font: inherit; padding: 0; text-decoration: underline dotted; }
.cash-editor { display: inline-flex; gap: 0.3rem; align-items: center; }
.cash-editor input { width: 7rem; font: 500 0.8rem var(--f-mono); padding: 0.3rem 0.4rem; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); }
.cash-editor .cash-kind { font: 500 0.78rem var(--f-body); padding: 0.28rem 0.35rem; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); cursor: pointer; }
.sell-form { padding: 0.3rem 1rem 0.7rem; border-bottom: 1px solid var(--line); }
.sell-lbl { font: 600 0.8rem var(--f-display); color: var(--ink-dim); }
.lnk { color: var(--watch); }

@media (max-width: 760px) {
  .pos-row { grid-template-columns: 1.6fr 0.8fr 1fr 1.1fr; grid-auto-rows: auto; }
  /* by-account/sold view: hide Avg + Price on narrow. Direct children only, and
     never the by-symbol .sym-row (it has its own column rules below) — otherwise
     this leaks into .pos-sym and hides the mobile price sub-line + the stop cell. */
  .pos-row:not(.sym-row) > span:nth-child(3),
  .pos-row:not(.sym-row) > span:nth-child(4) { display: none; }
}

/* delete affordances */
.pos-del { color: var(--down); border-color: color-mix(in srgb, var(--down) 40%, var(--line)); }
.pos-del:hover { background: color-mix(in srgb, var(--down) 12%, transparent); }

/* --- position tax chip + kebab --- */
.pos-sym-top { display: inline-flex; align-items: center; gap: 0.4rem; }
.tax-chip { font: 700 0.6rem/1 var(--f-display); padding: 0.16rem 0.36rem; border-radius: 5px; letter-spacing: 0.03em; white-space: nowrap; }
.tax-lt { background: color-mix(in srgb, var(--up) 18%, transparent); color: var(--up); }
.tax-st { background: color-mix(in srgb, var(--amber) 22%, transparent); color: var(--amber); }
.tax-mix { background: color-mix(in srgb, var(--ink-faint) 20%, transparent); color: var(--ink-dim); }
.pos-menu-btn { font-size: 1rem; line-height: 0.6; padding: 0.28rem 0.5rem; }

/* --- page view (no popups) ---
   What used to be a dialog is a full page in the normal flow: openModal() adds it
   to <main> and hides the rest, so it scrolls like any other screen. The class
   names are the old modal ones. */
body.has-page main.wrap { padding-top: 0; }
body.has-page main.wrap > :not(.page-view):not(.tabs) { display: none !important; }
.page-view { overflow-wrap: anywhere; }
.modal-card { max-width: 820px; margin: 0 auto; }
.modal-head { display: flex; align-items: center; gap: 0.6rem; padding: 0.65rem 0; border-bottom: 1px solid var(--line); position: sticky; top: var(--hdr-h, 0px); z-index: 5; background: var(--bg); }
.modal-head h3 { flex: 1 1 auto; min-width: 0; font: 700 1.1rem/1.3 var(--f-display); color: var(--ink); }
.modal-sub { font: 500 0.8rem var(--f-body); color: var(--ink-faint); margin-left: 0.4rem; }
/* the Back button: first in the head, whatever its place in the markup */
.modal-close { order: -1; flex: none; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 0.4rem 0.75rem; font: 600 0.85rem var(--f-display); color: var(--ink-dim); cursor: pointer; white-space: nowrap; }
.modal-close:hover { color: var(--ink); border-color: var(--ink-faint); }
.modal-body { padding: 1rem 0 1.2rem; }

/* --- lot list inside the actions popup --- */
.lot-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.9rem; }
.lot-line { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.6rem 0.75rem; flex-wrap: wrap; }
.lot-main { font: 600 0.92rem var(--f-display); color: var(--ink); display: flex; align-items: center; gap: 0.4rem; }
.lot-sub { font: 500 0.76rem var(--f-mono); color: var(--ink-faint); margin-top: 0.15rem; }
.lot-actions { display: flex; gap: 0.35rem; }
.lot-form { width: 100%; }
.lot-form label { font: 600 0.7rem var(--f-display); color: var(--ink-dim); display: inline-flex; flex-direction: column; gap: 0.2rem; }
.lot-form .pf-in { width: 7rem; }
.lot-form-btns { display: inline-flex; gap: 0.4rem; align-self: flex-end; }
.pm-add { width: 100%; }

/* --- settings modal --- */
.set-sec { margin-bottom: 1.4rem; }
.set-sec h4 { font: 700 0.95rem var(--f-display); color: var(--ink); margin-bottom: 0.15rem; }
.set-sec .hint { margin-bottom: 0.6rem; }
.set-list { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.6rem; }
.set-person { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; align-items: center; }
.set-acct { display: grid; grid-template-columns: 1.6fr 1fr auto auto auto; gap: 0.5rem; align-items: center; }
.set-acct-head { font: 600 0.66rem var(--f-display); color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.04em; }
.set-acct-head span { padding: 0 0.2rem; }
.set-acct .pf-in { width: 100%; }
.set-acct .acct-cash { width: 6.5rem; }
.set-ret { font: 600 0.72rem var(--f-display); color: var(--ink-dim); display: inline-flex; align-items: center; gap: 0.3rem; white-space: nowrap; }
@media (max-width: 620px) {
  .set-acct { grid-template-columns: 1fr 1fr; }
  .set-acct .acct-del { grid-column: 1 / -1; }
}

/* --- sold / realized history (its own sub-tab) — one card per sale --- */
.sold-sec { margin-top: 0.25rem; }
.sold-head-row .hint b { font-variant-numeric: tabular-nums; }
.sold-list { display: flex; flex-direction: column; gap: 0.7rem; }
.sold-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 0.95rem 1rem;
}
.sc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.sc-sym { display: flex; flex-direction: column; gap: 0.18rem; min-width: 0; }
.sc-sym b { font: 800 1.1rem/1 var(--f-display); color: var(--ink); }
.sc-acct { font: 500 0.76rem/1 var(--f-body); color: var(--ink-faint); }
.sc-realized { display: flex; flex-direction: column; align-items: flex-end; text-align: right; white-space: nowrap; font: 800 1.15rem/1.1 var(--f-mono); font-variant-numeric: tabular-nums; }
.sc-realized small { font: 600 0.7rem/1.2 var(--f-mono); margin-top: 0.18rem; opacity: 0.9; }
.sc-realized.pl-up, .sc-held-val.pl-up { color: var(--up); }
.sc-realized.pl-down, .sc-held-val.pl-down { color: var(--down); }
.sc-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.7rem 0.75rem;
  margin-top: 0.9rem; padding-top: 0.9rem; border-top: 1px solid var(--line);
}
.sc-cell { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.sc-lbl { font: 600 0.62rem/1 var(--f-display); text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-faint); white-space: nowrap; }
.sc-val { font: 700 0.98rem/1.1 var(--f-mono); color: var(--ink); font-variant-numeric: tabular-nums; }
.sc-held {
  display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem;
  margin-top: 0.8rem; padding-top: 0.65rem; border-top: 1px dashed var(--line);
}
.sc-held-lbl { font: 600 0.8rem/1.2 var(--f-body); color: var(--ink-dim); }
.sc-held-val { font: 800 1.1rem/1 var(--f-mono); font-variant-numeric: tabular-nums; }
.sc-held-val.sc-na { color: var(--ink-faint); }
.sc-held-val small { font: 600 0.74rem/1 var(--f-mono); opacity: 0.9; margin-left: 0.2rem; }
.sold-note { margin-top: 0.7rem; padding-top: 0.6rem; border-top: 1px solid var(--line); font: 500 0.85rem/1.45 var(--f-body); color: var(--ink-dim); font-style: italic; }
.sold-empty { font: 500 0.9rem/1.5 var(--f-body); color: var(--ink-faint); padding: 1rem 0; }

/* Realized P/L roll-up at the top of the Sold tab: total / retirement / regular,
   all-time and year-to-date, each as $ over its return %. */
.rs-panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 0.35rem 1rem 0.65rem; margin-bottom: 1rem;
}
.rs-row {
  display: grid; grid-template-columns: 1.15fr 1fr 1fr; gap: 0.5rem; align-items: baseline;
  padding: 0.6rem 0; border-top: 1px solid var(--line);
}
.rs-head { border-top: 0; padding-bottom: 0.35rem; }
.rs-lbl { overflow-wrap: anywhere; min-width: 0; }
.rs-sub { border-top: 0; padding: 0 0 0.55rem; }
/* deposits: money put in, kept apart from trading */
.acct-deposit-row { display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.25rem; }
.acct-dep { font: 500 0.76rem var(--f-mono); color: var(--ink-dim); }
.acct-dep-add { border: 1px dashed var(--line); background: none; color: var(--accent); font: 600 0.74rem var(--f-display); padding: 0.2rem 0.55rem; border-radius: 999px; cursor: pointer; }
.acct-dep-form { display: block; width: 100%; margin-top: 0.5rem; }
.dep-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.45rem; text-align: left; }
.dep-form .pf-in { width: 100%; font-size: 16px; }
.dep-note, .dep-btns, .dep-msg { grid-column: 1 / -1; }
.dep-btns { display: flex; gap: 0.4rem; }
.dep-panel { margin-top: 1rem; }
.dep-ledger summary { cursor: pointer; font: 600 0.8rem var(--f-display); color: var(--ink-dim); padding: 0.5rem 0 0.2rem; }
.dep-line { display: grid; grid-template-columns: 5.6rem 1fr auto auto; gap: 0.5rem; align-items: baseline; padding: 0.35rem 0; border-top: 1px dashed var(--line); font: 500 0.8rem var(--f-body); }
.dep-date { font-family: var(--f-mono); color: var(--ink-dim); }
.dep-acct { min-width: 0; overflow-wrap: anywhere; color: var(--ink); }
.dep-del { border: 0; background: none; color: var(--ink-faint); cursor: pointer; font-size: 0.78rem; }
.dep-del.is-armed { color: var(--down); }
.perf-dep { margin-top: 0.8rem; }
.snap-delta { margin-top: 0.35rem; font: 500 0.82rem/1.4 var(--f-body); color: var(--ink-dim); }
.rs-sub .rs-lbl { font: 500 0.8rem/1.3 var(--f-body); color: var(--ink-dim); padding-left: 0.7rem; }
.rs-sub .rs-val { font-size: 0.86rem; }
.perf-tag { font: 600 0.66rem var(--f-display); color: var(--ink-faint); border: 1px solid var(--line); border-radius: 999px; padding: 0.05rem 0.4rem; margin-left: 0.25rem; white-space: nowrap; }
.perf-note { margin-top: 0.5rem; color: var(--amber); }
.rs-head .rs-lbl { font: 700 0.72rem/1 var(--f-display); text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-dim); }
.rs-col { text-align: right; font: 600 0.64rem/1 var(--f-display); text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-faint); }
.rs-lbl { font: 600 0.88rem/1.15 var(--f-body); color: var(--ink); }
.rs-total .rs-lbl { font-weight: 800; }
.rs-val { display: flex; flex-direction: column; align-items: flex-end; text-align: right; font: 700 0.98rem/1.1 var(--f-mono); font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink); }
.rs-val small { font: 600 0.74rem/1.2 var(--f-mono); opacity: 0.9; margin-top: 0.12rem; }
.rs-val.pl-up { color: var(--up); }
.rs-val.pl-down { color: var(--down); }
.rs-total .rs-val { font-size: 1.05rem; }

/* ---- portfolio snapshots ---- */
.snap-sec { margin-top: 0.25rem; }
.snap-capture { display: flex; gap: 0.6rem; align-items: center; margin: 0.6rem 0 0.9rem; flex-wrap: wrap; }
.snap-note-in {
  flex: 1 1 260px; min-width: 0; padding: 0.55rem 0.7rem; font: 500 0.9rem var(--f-body);
  color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.snap-note-in:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.snap-list {
  display: flex; flex-direction: column; gap: 0.55rem;
  max-height: 26rem; overflow-y: auto; padding-right: 0.2rem;
}
.snap-card {
  display: flex; align-items: flex-start; gap: 0.6rem;
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 0.7rem 0.85rem;
}
.snap-body { flex: 1 1 auto; min-width: 0; }
.snap-when { font: 500 0.76rem var(--f-mono); color: var(--ink-dim); display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.snap-scope { font: 600 0.66rem var(--f-body); color: var(--ink-faint); border: 1px solid var(--line); border-radius: 999px; padding: 0.02rem 0.4rem; }
.snap-total { font: 800 1.35rem var(--f-display); color: var(--ink); letter-spacing: -0.01em; margin: 0.15rem 0 0.1rem; font-variant-numeric: tabular-nums; }
.snap-break { font: 500 0.76rem var(--f-mono); color: var(--ink-dim); }
.snap-note { margin-top: 0.4rem; font: 500 0.85rem/1.4 var(--f-body); color: var(--ink); white-space: pre-wrap; word-break: break-word; }
.snap-del {
  flex: 0 0 auto; width: 1.7rem; height: 1.7rem; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-faint);
  font-size: 1.1rem; line-height: 1; cursor: pointer;
}
.snap-del:hover { color: var(--down); border-color: var(--down); }
.snap-empty { font: 500 0.85rem var(--f-body); color: var(--ink-faint); padding: 0.4rem 0; }

.card-sold { margin-top: 0.45rem; padding-top: 0.4rem; border-top: 1px dashed var(--line); font: 500 0.78rem/1.4 var(--f-body); color: var(--ink-dim); overflow-wrap: anywhere; }
.sold-partial { display: inline-block; font: 700 0.66rem/1 var(--f-display); color: var(--amber); border: 1px solid color-mix(in srgb, var(--amber) 45%, var(--line)); background: color-mix(in srgb, var(--amber) 12%, transparent); border-radius: 5px; padding: 0.15rem 0.35rem; margin-right: 0.2rem; }
.over-fair { display: inline-block; margin-left: 0.3rem; font: 700 0.62rem/1 var(--f-display); color: var(--sell); border: 1px solid color-mix(in srgb, var(--sell) 45%, var(--line)); background: color-mix(in srgb, var(--sell) 10%, transparent); border-radius: 5px; padding: 0.16rem 0.32rem; vertical-align: middle; white-space: nowrap; }
.pill-sold { background: color-mix(in srgb, var(--ink-dim) 18%, transparent); color: var(--ink); border: 1px solid var(--line); }

/* status line for the home Refresh (what it did, or what failed) */
.refresh-status { display: flex; align-items: flex-start; gap: 0.6rem; margin: 0.6rem 0 0.2rem; padding: 0.55rem 0.75rem; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); font: 500 0.84rem/1.4 var(--f-body); color: var(--ink-dim); }
.refresh-status span { flex: 1 1 auto; min-width: 0; }
.refresh-status.rs-ok { border-color: color-mix(in srgb, var(--buy) 35%, var(--line)); color: var(--ink); }
.refresh-status.rs-err { border-color: color-mix(in srgb, var(--sell) 45%, var(--line)); background: color-mix(in srgb, var(--sell) 9%, var(--surface)); color: var(--ink); }
.rs-x { flex: none; border: 0; background: none; color: var(--ink-faint); cursor: pointer; font-size: 0.85rem; }

/* --- notifications: the bell + its page --- */
.notif-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-dim); }
.notif-btn:hover { color: var(--ink); }
.notif-badge {
  position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px;
  display: grid; place-items: center; border-radius: 999px;
  background: var(--sell); color: var(--on-fill); font: 700 0.62rem/1 var(--f-display);
  box-shadow: 0 0 0 2px var(--bg);
}
.notif-list { display: flex; flex-direction: column; gap: 0.45rem; }
.notif-tabs { display: flex; gap: 0.3rem; background: var(--surface-2); border-radius: 10px; padding: 3px; margin: 0 0 1rem; }
.notif-tab { flex: 1 1 0; border: 0; background: none; color: var(--ink-dim); font: 600 0.9rem var(--f-display); padding: 0.5rem; border-radius: 8px; cursor: pointer; }
.notif-tab.is-on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.shared-pct { flex: none; font: 700 0.95rem var(--f-mono); align-self: center; white-space: nowrap; }
.notif-intro { margin: 0 0 0.2rem; }
.notif-list .notif-day { margin: 0.8rem 0 0.1rem; }
.notif-list .notif-intro + .notif-day { margin-top: 0.3rem; }
.nt-row {
  display: flex; align-items: flex-start; gap: 0.7rem; cursor: pointer;
  padding: 0.7rem 0.8rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.nt-row:hover { border-color: var(--ink-faint); }
.nt-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* arrived since you last opened the bell */
.nt-row.is-new { border-left: 3px solid var(--accent); padding-left: calc(0.8rem - 2px); }
.nt-ico { flex: none; width: 1.4rem; text-align: center; font-size: 1rem; line-height: 1.45; }
.nt-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 0.35rem; }
.nt-line { font: 500 0.92rem/1.45 var(--f-body); color: var(--ink-dim); }
.nt-sym { font: 700 0.95rem var(--f-mono); color: var(--ink); margin-right: 0.15rem; }
.nt-when { flex: none; font: 500 0.75rem/1.9 var(--f-mono); color: var(--ink-faint); white-space: nowrap; }
.nt-share { font: 600 0.74rem/1 var(--f-display); padding: 0.3rem 0.55rem; border-radius: 999px; }
.nt-share.is-ready { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); }
.nt-share.is-shared { color: var(--buy); background: color-mix(in srgb, var(--buy) 12%, transparent); border: 1px solid color-mix(in srgb, var(--buy) 30%, var(--line)); }

/* MACD Turn history (Lists) */
.turn-filters { display: flex; gap: 0.4rem; flex-wrap: wrap; margin: 0 0 0.8rem; }
.turn-filter { border: 1px solid var(--line); background: var(--surface); color: var(--ink-dim); font: 600 0.8rem var(--f-display); padding: 0.35rem 0.8rem; border-radius: 999px; cursor: pointer; }
.turn-filter.is-on { border-color: var(--accent); color: var(--accent); }
.turn-pill { flex: none; min-width: 3.6rem; text-align: center; font: 700 0.68rem/1 var(--f-display); padding: 0.32rem 0.4rem; border-radius: 6px; margin-top: 0.15rem; border: 1px solid var(--line); color: var(--ink-dim); }
.turn-BUY { color: var(--buy); border-color: color-mix(in srgb, var(--buy) 40%, var(--line)); background: color-mix(in srgb, var(--buy) 12%, transparent); }
.turn-WATCH, .turn-OLDER { color: var(--watch); border-color: color-mix(in srgb, var(--watch) 40%, var(--line)); background: color-mix(in srgb, var(--watch) 12%, transparent); }
.turn-NONE { color: var(--ink-faint); background: var(--surface-2); }
.turn-px { font: 500 0.78rem/1.4 var(--f-mono); color: var(--ink-dim); }
.turn-px b { font-weight: 700; }

/* beat / miss vs the analysts' estimate (Financial cards) */
.hx-beat { margin-top: 0.3rem; font: 700 0.7rem/1.2 var(--f-display); }
.bm-beat { color: var(--buy); }
.bm-miss { color: var(--sell); }
.bm-inline { color: var(--ink-dim); }
.bm-list { margin-top: 0.8rem; border-top: 1px solid var(--line); padding-top: 0.6rem; display: grid; gap: 0.1rem; }
.bm-head { font: 700 0.72rem var(--f-display); color: var(--ink-dim); margin-bottom: 0.25rem; }
.bm-row { display: grid; grid-template-columns: 3.6rem 4.4rem 1fr auto; gap: 0.5rem; align-items: baseline; padding: 0.3rem 0; border-bottom: 1px dashed var(--line); font: 500 0.8rem/1.3 var(--f-body); }
.bm-row:last-child { border-bottom: 0; }
.bm-q { font: 600 0.78rem var(--f-mono); color: var(--ink); }
.bm-tag { font: 700 0.68rem var(--f-display); }
.bm-nums { font: 500 0.76rem var(--f-mono); color: var(--ink-dim); min-width: 0; overflow-wrap: anywhere; }
.bm-pct { font: 700 0.78rem var(--f-mono); white-space: nowrap; }

/* --- VIX market-context gauge --- */
.vix-chip {
  display: inline-flex; align-items: baseline; gap: 0.35rem; text-decoration: none;
  padding: 0.3rem 0.6rem; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-family: var(--f-mono); line-height: 1;
}
.vix-chip .vix-k { font: 700 0.62rem/1 var(--f-display); letter-spacing: 0.06em; color: var(--ink-faint); text-transform: uppercase; }
.vix-chip .vix-v { font-size: 0.95rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.vix-chip .vix-chg { font-size: 0.68rem; color: var(--ink-faint); }
.vix-low  { border-color: color-mix(in srgb, var(--amber) 55%, var(--line)); background: color-mix(in srgb, var(--amber) 12%, var(--surface)); }
.vix-low .vix-v { color: var(--amber); }
.vix-high { border-color: color-mix(in srgb, var(--buy) 55%, var(--line)); background: color-mix(in srgb, var(--buy) 12%, var(--surface)); }
.vix-high .vix-v { color: var(--buy); }
@media (max-width: 620px) { .vix-chip .vix-chg { display: none; } }

.vix-warn {
  margin: 0 0 1rem; padding: 0.7rem 0.9rem; border-radius: var(--radius-sm);
  font: 500 0.86rem/1.45 var(--f-body); border: 1px solid var(--line);
}
.vix-warn b { font-family: var(--f-mono); }
.vix-warn-low { background: color-mix(in srgb, var(--amber) 12%, var(--surface)); border-color: color-mix(in srgb, var(--amber) 40%, var(--line)); color: var(--ink); }
.vix-warn-high { background: color-mix(in srgb, var(--buy) 10%, var(--surface)); border-color: color-mix(in srgb, var(--buy) 40%, var(--line)); color: var(--ink); }

/* --- theme picker (light / dark / system) --- */
.theme-wrap { position: relative; display: inline-flex; }
.theme-menu {
  position: absolute; right: 0; top: calc(100% + 0.45rem); z-index: 60;
  min-width: 168px; padding: 0.35rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.theme-opt {
  display: flex; align-items: center; gap: 0.6rem; width: 100%;
  padding: 0.5rem 0.6rem; border: 0; border-radius: 8px; cursor: pointer;
  background: none; color: var(--ink); font: 500 0.88rem var(--f-body); text-align: left;
}
.theme-opt:hover { background: var(--surface-2); }
.theme-opt.is-active { color: var(--accent); font-weight: 600; }
.theme-opt .theme-ico { width: 1.2rem; text-align: center; }
.theme-opt .theme-check { margin-left: auto; color: var(--accent); }

/* --- by-symbol view: Symbol | Highest paid | Now | Stop(wEMA21) | Signal --- */
.pos-table.by-sym .sym-row {
  grid-template-columns: minmax(120px, 2fr) 1fr 1fr 1.3fr 0.9fr;
}
.sym-caret { font-size: 0.7rem; color: var(--ink-faint); transition: transform 0.15s; display: inline-block; }
.sym-row[aria-expanded="true"] .sym-caret { transform: rotate(90deg); }
/* whole by-symbol row is a tap target that expands the per-account breakdown */
.sym-clickable { cursor: pointer; }
.sym-clickable:hover { background: color-mix(in srgb, var(--watch) 5%, transparent); }
.sym-clickable:focus-visible { outline: 2px solid var(--watch); outline-offset: -2px; }
/* current ("Now") price — blue + a touch larger so it reads at a glance */
.sym-now { color: var(--watch); font-size: 0.98rem; font-weight: 700; }
.stop-h { border-left: 1px solid var(--line); padding-left: 0.6rem; }
.stop-cell {
  display: flex; flex-direction: column; align-items: flex-end; text-align: right;
  font-family: var(--f-mono); font-variant-numeric: tabular-nums;
  border-left: 1px solid var(--line); padding-left: 0.6rem;
}
.stop-lvl { font-size: 0.86rem; color: var(--ink); }
.stop-pct { font-size: 0.72rem; font-weight: 700; margin-top: 0.1rem; }
.stop-ok .stop-pct { color: var(--up); }
.stop-breach .stop-pct { color: var(--down); }
/* which stop rule is in force (EMA 9 − gap, or EMA 9) */
.stop-rule { font: 600 0.6rem/1.1 var(--f-display); color: var(--ink-faint); margin-top: 0.15rem; white-space: nowrap; }
.sm-sub.sm-rule { color: var(--ink-faint); font-weight: 600; }
.stop-breach .stop-lvl { color: var(--down); }
/* On desktop the table columns (with the header row) carry these numbers; the
   labelled mobile grid is hidden there. */
.sym-metrics { display: none; }
@media (max-width: 760px) {
  /* Portrait: each position is a labelled card — ticker + verdict on top, then a
     three-up metric grid where every figure states what it is (Now / Paid up to /
     Stop). No more guessing which number is which. */
  .pos-table.by-sym .sym-row {
    grid-template-columns: 1fr auto;
    grid-template-areas: "sym sig" "mom mom" "met met";
    align-items: center; gap: 0.5rem 0.7rem; padding: 1.05rem 1.1rem;
  }
  /* Each position is its own free-standing card: drop the outer container chrome
     so the cards float on the page background with clear boundaries between them. */
  .acct-symview { background: transparent; border: 0; box-shadow: none; overflow: visible; margin-bottom: 0; }
  .acct-symview .acct-head { background: transparent; border-bottom: 0; padding: 0 0.15rem 0.4rem; }
  .acct-symview .sym-sort-bar { padding: 0 0.15rem; }
  .acct-symview .pos-table.by-sym { padding: 0.7rem 0.15rem 0; }
  .acct-symview .pos-head { display: none; }
  .acct-symview .sym-row {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 0.7rem;
  }
  /* When a card is expanded, join it to its detail panel as one rounded unit. */
  .acct-symview .sym-row[aria-expanded="true"] {
    margin-bottom: 0; border-bottom-color: transparent;
    border-radius: var(--radius) var(--radius) 0 0;
  }
  .acct-symview .sym-expand-row {
    border: 1px solid var(--line); border-top: 0;
    border-radius: 0 0 var(--radius) var(--radius);
    margin-bottom: 0.7rem; overflow: hidden;
  }
  .pos-table.by-sym .sym-row > .pos-sym { grid-area: sym; align-self: center; }
  /* Expose the verdict pill + momentum chips as grid items: the verdict stays on
     the symbol's line (top-right); the MACD / E9 chips drop to their own full-width
     row so there's no empty gap under the ticker. */
  .pos-table.by-sym .sym-row > .pos-sig { display: contents; }
  .pos-table.by-sym .sym-row > .pos-sig > .pill { grid-area: sig; justify-self: end; align-self: center; }
  .pos-table.by-sym .sym-row > .pos-sig > .pos-mom { grid-area: mom; justify-content: flex-start; }
  .pos-table.by-sym .sym-row > .sym-metrics { grid-area: met; }
  /* the raw table cells fold into the labelled grid below */
  .pos-table.by-sym .sym-row > .num,
  .pos-table.by-sym .sym-row > .stop-cell { display: none; }

  .sym-metrics {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.55rem 0.75rem;
    margin-top: 0.15rem; padding-top: 0.85rem; border-top: 1px solid var(--line);
  }
  .sm-cell { display: flex; flex-direction: column; gap: 0.34rem; min-width: 0; }
  .sm-lbl { font: 600 0.64rem/1 var(--f-display); text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-faint); white-space: nowrap; }
  .sm-val { font: 700 1.05rem/1.15 var(--f-mono); color: var(--ink); font-variant-numeric: tabular-nums; }
  .sm-val.sym-now { color: var(--watch); font-size: 1.1rem; }
  .sm-sub { font: 500 0.72rem/1.35 var(--f-mono); color: var(--ink-dim); }
  .sm-sub.stop-ok, .sm-sub.pl-up { color: var(--up); }
  .sm-sub.stop-breach, .sm-sub.pl-down { color: var(--down); }
  /* let the pre/after-hours badge wrap gracefully inside the narrow "Now" cell */
  .sm-sub .ext-quote { flex-wrap: wrap; gap: 0.15rem 0.28rem; font-size: 0.66rem; }
  .sm-sub .ext-quote .ext-tag { font-size: 0.54rem; padding: 0.06rem 0.24rem; }
}

/* by-symbol inline expansion (per-account holdings) */
.sym-expand-row { background: var(--surface-2); border-bottom: 1px solid var(--line); }
.sym-expand-panel { padding: 0.6rem 1rem 0.8rem; }
.sxp-head, .sxp-lot {
  display: grid; grid-template-columns: 1.6fr 0.8fr 0.9fr 1fr 1fr 1fr; gap: 0.5rem;
  align-items: center; font-variant-numeric: tabular-nums;
}
.sxp-head { font: 600 0.64rem/1 var(--f-display); color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.04em; padding-bottom: 0.35rem; }
.sxp-lot { padding: 0.35rem 0; border-top: 1px solid var(--line); font: 500 0.82rem var(--f-mono); }
.sxp-acct { font-family: var(--f-body); font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sxp-owner { display: block; font-family: var(--f-body); font-weight: 500; font-size: 0.74rem; color: var(--ink-dim); }
.sxp-date { font-size: 0.76rem; color: var(--ink-faint); }
.sxp-lot .num { text-align: right; }
.sxp-drawer { display: inline-block; margin-top: 0.6rem; font: 600 0.82rem var(--f-display); cursor: pointer; }
.sxp-total {
  display: flex; align-items: baseline; gap: 0.6rem; margin-top: 0.4rem; padding-top: 0.45rem;
  border-top: 2px solid var(--line); font: 600 0.9rem var(--f-mono); font-variant-numeric: tabular-nums;
}
.sxp-total-lbl { flex: 1; font: 700 0.68rem/1 var(--f-display); color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.05em; }
.sxp-total .num { text-align: right; }
.sxp-total-pct { font-size: 0.82rem; font-weight: 500; }
@media (max-width: 620px) {
  .sxp-head { display: none; }
  .sxp-lot { grid-template-columns: 1fr auto; grid-auto-rows: auto; row-gap: 0.1rem; }
  .sxp-lot .num, .sxp-date { text-align: left; }
}

/* --- portfolio lock --- */
.pf-lock { display: flex; justify-content: center; padding: 2.5rem 1rem; }
.pf-lock-card {
  width: 100%; max-width: 360px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 2rem 1.5rem 1.5rem;
}
.pf-lock-ico { font-size: 2.4rem; line-height: 1; }
.pf-lock-title { margin: 0.6rem 0 0.3rem; font: 700 1.15rem var(--f-display); color: var(--ink); }
.pf-lock-sub { margin: 0 0 1.1rem; font-size: 0.86rem; color: var(--ink-dim); }
.pf-lock-form { display: flex; gap: 0.5rem; }
.pf-lock-input { flex: 1; text-align: center; letter-spacing: 0.35em; font-size: 1.1rem; }
.pf-lock-msg { min-height: 1.1em; margin: 0.6rem 0 0.2rem; font-size: 0.8rem; color: var(--down); }
.pf-lock-forgot { display: inline-block; margin-top: 0.4rem; font: 600 0.82rem var(--f-display); cursor: pointer; }

/* --- settings: lock section --- */
.set-lock .lock-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.set-lock .lock-status { margin: 0 0 0.6rem; font-weight: 600; color: var(--ink); }
.set-lock .lock-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.6rem; }
.set-lock .lk-danger { color: var(--down); }
.set-lock .hint { display: block; margin-top: 0.4rem; }

/* --- mobile header: collapse actions into one ☰ menu --- */
.hdr-more { position: relative; display: none; } /* shown on mobile only */
.more-menu {
  position: absolute; right: 0; top: calc(100% + 0.5rem); z-index: 70;
  width: 232px; max-width: calc(100vw - 1.5rem); padding: 0.4rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 13px; box-shadow: var(--shadow);
}
.mm-status {
  font: 600 0.72rem/1 var(--f-mono); color: var(--ink-faint);
  padding: 0.5rem 0.6rem 0.55rem; text-transform: uppercase; letter-spacing: 0.03em;
}
.mm-item {
  display: flex; align-items: center; gap: 0.55rem; width: 100%; text-align: left;
  padding: 0.6rem 0.6rem; border: 0; border-radius: 9px; cursor: pointer;
  background: none; color: var(--ink); font: 500 0.92rem var(--f-body);
}
.mm-item:hover { background: var(--surface-2); }
.mm-item.is-active { color: var(--accent); font-weight: 600; }
.mm-item .theme-ico { width: 1.25rem; text-align: center; }
.mm-item .theme-check { margin-left: auto; color: var(--accent); }
.mm-signout { color: var(--sell); font-weight: 600; }
.mm-label { font: 600 0.68rem/1 var(--f-display); color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.05em; padding: 0.45rem 0.6rem 0.3rem; }
.mm-sep { height: 1px; background: var(--line); margin: 0.35rem 0.3rem; }

@media (max-width: 760px) {
  .header-inner { gap: 0.5rem; }
  .brand { min-width: 0; flex: 1 1 auto; }
  .brand h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .header-right { gap: 0.4rem; flex: 0 0 auto; }
  /* everything except VIX + the menu moves into the ☰ sheet */
  .header-right .theme-wrap,
  .header-right #settings-btn,
  .header-right #hide-btn,
  .header-right .refresh-group,
  .header-right #signout { display: none; }
  .hdr-more { display: inline-flex; }
  .vix-chip { padding: 0.28rem 0.5rem; }
}

/* --- settings: account cards + sticky footer (mobile-friendly) --- */
.set-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.set-count {
  font: 600 0.72rem/1 var(--f-mono); color: var(--ink-faint);
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 0.15rem 0.45rem; border-radius: 999px; vertical-align: middle;
}
.acct-card {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 0.7rem 0.75rem; margin-bottom: 0.6rem;
}
.acct-card-top { display: flex; align-items: center; gap: 0.5rem; }
.acct-card-top .acct-name { flex: 1 1 auto; font: 600 0.95rem var(--f-body); }
.icon-del {
  flex: none; width: 2rem; height: 2rem; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-faint);
  font-size: 0.95rem; line-height: 1;
}
.icon-del:hover { color: var(--down); border-color: color-mix(in srgb, var(--down) 45%, var(--line)); }
.acct-card-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; margin-top: 0.6rem; }
.acf { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.acf-l { font: 600 0.66rem/1 var(--f-display); color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.04em; }
.acf .pf-in { width: 100%; }
.acf-check { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 0.5rem; font: 500 0.86rem var(--f-body); color: var(--ink-dim); cursor: pointer; }
.acf-check input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.acct-del-confirm { display: flex; flex-direction: column; gap: 0.6rem; }
.acct-del-btns { display: flex; gap: 0.4rem; }

.set-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap;
  margin: 1rem 0 0; padding: 0.8rem 0 0;
  border-top: 1px solid var(--line);
}
.set-saved { font: 500 0.8rem var(--f-body); color: var(--buy); }
.set-footer .btn-primary { padding: 0.55rem 1.4rem; }

@media (max-width: 620px) {
  .acct-card-fields { grid-template-columns: 1fr; }
}

/* --- A / B financial rating badge (shown everywhere a symbol appears) --- */
.card.fin-a {
  background: color-mix(in srgb, var(--buy) 11%, var(--surface));
  border-color: color-mix(in srgb, var(--buy) 32%, var(--line));
}
.fin-badge {
  font: 800 0.66rem/1.2 var(--f-display); border-radius: 5px; padding: 0.02rem 0.34rem;
  margin-left: 0.35rem; vertical-align: middle; white-space: nowrap;
}
/* A = premium grade (filled green); B = value grade (outlined green).
   Scope to .fin-badge so these don't also style the card div (which shares the
   fin-a/fin-b class) — otherwise the card's symbol text inherits the badge colour. */
.fin-badge.fin-a { color: var(--on-fill); background: var(--buy); border: 1px solid var(--buy); }
.fin-badge.fin-b { color: var(--buy); border: 1px solid color-mix(in srgb, var(--buy) 45%, var(--line)); background: color-mix(in srgb, var(--buy) 10%, transparent); }
/* R / E growth letters next to the ★ — latest quarter's YoY growth. R = revenue >12%,
   E = EPS >25%. Blue = still accelerating vs the prior quarter, red = decelerating. */
.growth-badge {
  font: 800 0.6rem/1.2 var(--f-display); border-radius: 5px; padding: 0.02rem 0.28rem;
  margin-left: 0.28rem; vertical-align: middle; white-space: nowrap;
  border: 1px solid transparent;
}
.growth-badge.gb-blue {
  color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.growth-badge.gb-red {
  color: var(--sell); border-color: color-mix(in srgb, var(--sell) 45%, var(--line));
  background: color-mix(in srgb, var(--sell) 12%, transparent);
}
/* Retail-favorite ⚡ — a user tag, blue like the accent star. */
.retail-badge { margin-left: 0.3rem; font-size: 0.95rem; line-height: 1; vertical-align: middle; color: var(--accent); filter: drop-shadow(0 0 3px color-mix(in srgb, var(--accent) 55%, transparent)); }
.btn.d-retail.is-on { color: var(--accent); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
/* financial-quality score chip — colour scales with the score (green→amber→red) */
.q-chip {
  font: 700 0.62rem/1.2 var(--f-mono); border-radius: 5px; padding: 0.02rem 0.32rem;
  margin-left: 0.35rem; vertical-align: middle; white-space: nowrap; letter-spacing: -0.02em;
}
.q-chip.q-hi { color: var(--buy); background: color-mix(in srgb, var(--buy) 12%, transparent); border: 1px solid color-mix(in srgb, var(--buy) 40%, var(--line)); }
.q-chip.q-mid { color: var(--amber); background: color-mix(in srgb, var(--amber) 14%, transparent); border: 1px solid color-mix(in srgb, var(--amber) 40%, var(--line)); }
.q-chip.q-lo { color: var(--sell); background: color-mix(in srgb, var(--sell) 12%, transparent); border: 1px solid color-mix(in srgb, var(--sell) 40%, var(--line)); }
/* Recovery-rating chip — same footprint as the quality chip, colour by rating. */
.rec-chip {
  font: 700 0.62rem/1.2 var(--f-mono); border-radius: 5px; padding: 0.02rem 0.32rem;
  margin-left: 0.35rem; vertical-align: middle; white-space: nowrap; letter-spacing: -0.02em;
}
.rec-chip.rec-hi { color: var(--buy); background: color-mix(in srgb, var(--buy) 12%, transparent); border: 1px solid color-mix(in srgb, var(--buy) 40%, var(--line)); }
.rec-chip.rec-mid { color: var(--amber); background: color-mix(in srgb, var(--amber) 14%, transparent); border: 1px solid color-mix(in srgb, var(--amber) 40%, var(--line)); }
.rec-chip.rec-lo { color: var(--sell); background: color-mix(in srgb, var(--sell) 12%, transparent); border: 1px solid color-mix(in srgb, var(--sell) 40%, var(--line)); }

/* research (Google) icon next to a symbol in the portfolio rows */
.pos-research { text-decoration: none; font-size: 0.8rem; margin-left: 0.3rem; opacity: 0.55; }
.pos-research:hover { opacity: 1; }

/* --- A-grade setups digest (top of page, above the search bar) --- */
.agrade-panel {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 10%, var(--surface)), var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--line));
  border-radius: var(--radius); padding: 0.85rem 0.95rem 0.95rem; margin: 0 0 1rem;
  box-shadow: var(--shadow-sm);
}
.ag-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.75rem; }
/* A-grade panel title is now a collapse toggle (collapsed by default) */
.ag-title { display: flex; align-items: center; min-width: 0; background: none; border: 0; padding: 0; cursor: pointer; color: inherit; text-align: left; }
.ag-caret { margin-left: 0.4rem; color: var(--ink-faint); font-size: 0.85em; }
.ag-groups[hidden] { display: none; }
.ag-title .fin-badge { margin-left: 0; }
.ag-title-txt { font-family: var(--f-display); font-weight: 600; font-size: 0.98rem; margin-left: 0.45rem; }
.ag-title .hint { font-family: var(--f-body); font-weight: 500; margin-left: 0.45rem; white-space: nowrap; }
.ag-share {
  display: inline-flex; align-items: center; gap: 0.3rem; white-space: nowrap; cursor: pointer;
  font: 600 0.82rem var(--f-display); color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 38%, var(--line));
  padding: 0.32rem 0.75rem; border-radius: 999px;
}
.ag-share:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.ag-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.35rem 1rem; }
.ag-strat { font: 700 0.64rem/1 var(--f-display); text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); margin: 0.2rem 0 0.35rem; }
.ag-row {
  display: flex; align-items: baseline; gap: 0.45rem; width: 100%; text-align: left;
  background: none; border: 0; border-radius: 7px; padding: 0.28rem 0.35rem; cursor: pointer; color: var(--ink);
}
.ag-row:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.ag-sym { font-family: var(--f-mono); font-weight: 700; font-size: 0.88rem; }
.ag-name { font-size: 0.78rem; color: var(--ink-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* mobile: two tidy columns, share stays pinned top-right */
@media (max-width: 620px) {
  .agrade-panel { padding: 0.75rem 0.8rem 0.85rem; }
  .ag-groups { grid-template-columns: 1fr 1fr; gap: 0.3rem 0.7rem; }
  .ag-title-txt { font-size: 0.92rem; }
  .ag-name { display: none; }
}

/* --- journal: notes + reading list --- */
.jr-sec { margin-bottom: 1.6rem; }
.jr-load-more { display: block; margin: 0.7rem auto 0; }
.jr-add { display: grid; gap: 0.5rem; margin: 0.6rem 0 1rem; }
.jr-add .btn { justify-self: start; }
.jr-text { width: 100%; resize: vertical; min-height: 2.6rem; font: 500 0.92rem var(--f-body); }
.jr-sym { width: 10rem; }
@media (min-width: 620px) {
  .jr-sec:first-child .jr-add { grid-template-columns: 10rem 1fr auto; align-items: start; }
  .jr-sec:last-child .jr-add { grid-template-columns: 1fr 1fr auto; align-items: center; }
  .jr-add .btn { justify-self: stretch; }
}
.jr-list { display: flex; flex-direction: column; gap: 0.5rem; }
.jr-empty { padding: 0.5rem 0; }
.jr-item {
  display: flex; align-items: flex-start; gap: 0.6rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem; box-shadow: var(--shadow-sm);
}
.jr-item-body { flex: 1 1 auto; min-width: 0; }
.jr-meta { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.15rem; }
.jr-tag { font: 700 0.66rem/1 var(--f-mono); color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line)); padding: 0.12rem 0.4rem; border-radius: 5px; letter-spacing: 0.03em; }
.jr-date { font: 500 0.72rem var(--f-mono); color: var(--ink-faint); }
.jr-note-text { font: 500 0.92rem/1.45 var(--f-body); color: var(--ink); white-space: pre-wrap; word-break: break-word; }
.jr-note-title { font: 700 1rem/1.3 var(--f-display); color: var(--ink); margin-bottom: 0.15rem; word-break: break-word; }
.jr-note-open { cursor: pointer; border-radius: var(--radius-sm); }
.jr-note-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
/* card preview: clamp long bodies to a few lines; full text lives in the reader */
.jr-note-preview { display: -webkit-box; -webkit-line-clamp: 4; line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.jr-pin-flag { font-size: 0.8rem; }
.note-item.is-pinned { border-color: color-mix(in srgb, var(--amber) 45%, var(--line)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--amber) 22%, transparent), var(--shadow-sm); }
.jr-pin { flex: none; width: 1.9rem; height: 1.9rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 0.85rem; line-height: 1; filter: grayscale(1); opacity: 0.55; }
.jr-pin:hover { opacity: 1; filter: none; border-color: color-mix(in srgb, var(--amber) 45%, var(--line)); }
.jr-pin.is-on { opacity: 1; filter: none; border-color: color-mix(in srgb, var(--amber) 55%, var(--line)); background: color-mix(in srgb, var(--amber) 12%, var(--surface)); }
/* bold / italic toolbar above a note textarea */
.jr-fmt { display: flex; align-items: center; gap: 0.35rem; }
.jr-fmt-b { width: 2rem; height: 1.9rem; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; font-size: 0.9rem; line-height: 1; }
.jr-fmt-b:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); color: var(--accent); }
.jr-fmt-b b { font-weight: 800; } .jr-fmt-b i { font-style: italic; }
.jr-fmt-hint { font-size: 0.72rem; margin-left: 0.2rem; }
.jr-title { width: 100%; font: 600 0.95rem var(--f-display); }
.jr-edit-title { width: 100%; margin-bottom: 0.4rem; font: 600 0.95rem var(--f-display); }
.jr-edit-box .jr-fmt { margin-bottom: 0.35rem; }
/* full-page note reader */
.note-read-meta { margin-bottom: 0.7rem; }
.note-read-body { font: 500 1rem/1.6 var(--f-body); color: var(--ink); white-space: pre-wrap; word-break: break-word; }
.note-read-body strong { font-weight: 800; } .note-read-body em { font-style: italic; }
.note-read-actions { margin-top: 1.1rem; }
/* bullets inside a rendered note: hanging indent, --d = nesting depth */
.md-li { display: block; position: relative; padding-left: calc(1.15em + var(--d, 0) * 1.1em); }
.md-bul { position: absolute; left: calc(var(--d, 0) * 1.1em); width: 1.15em; text-align: center; color: var(--ink-dim); }
/* the note editor is one plain writing surface: no boxes, and the text area
   grows with the text so the page itself scrolls */
.ne-save { padding: 0.5rem 1rem; font-size: 0.85rem; }
.ne-fields { display: flex; align-items: center; gap: 0.5rem; }
.ne-title, .ne-sym, .ne-text { border: 0; outline: 0; background: transparent; color: var(--ink); }
.ne-title::placeholder, .ne-sym::placeholder, .ne-text::placeholder { color: var(--ink-faint); }
/* 16px+ everywhere so iOS doesn't zoom the page when a field is focused */
.ne-title { flex: 1 1 auto; min-width: 0; padding: 0; font: 700 1.25rem/1.3 var(--f-display); }
.ne-sym { flex: none; width: 5.5rem; padding: 0.25rem 0.5rem; border-radius: 7px; background: var(--surface-2); font: 600 16px var(--f-mono); text-transform: uppercase; text-align: center; }
.note-editor .jr-fmt { margin: 0.6rem 0 0.2rem; padding-bottom: 0.6rem; border-bottom: 1px solid var(--line); }
.note-editor .jr-fmt-b { width: 2.6rem; height: 2.2rem; font-size: 1rem; border-color: transparent; background: var(--surface-2); }
.ne-text {
  display: block; width: 100%; min-height: 55vh; resize: none; overflow: hidden;
  field-sizing: content;
  padding: 0.6rem 0 30vh; /* room below the last line, so it never sits on the keyboard edge */
  font: 500 1.05rem/1.6 var(--f-body);
}
.ne-discard { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.6rem; padding: 0.55rem 0.8rem; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--sell) 9%, var(--surface)); font: 600 0.85rem var(--f-body); color: var(--ink); }
.ne-discard span { flex: 1 1 0; min-width: 9rem; }
.jr-note-btns { display: flex; gap: 0.5rem; flex-wrap: wrap; }
@media (max-width: 620px) {
  .jr-fmt-hint { display: none; }
}
.jr-link { font: 600 0.92rem var(--f-display); color: var(--accent); text-decoration: none; word-break: break-all; }
.jr-link:hover { text-decoration: underline; }
.jr-item-actions { flex: none; display: flex; flex-direction: column; gap: 0.3rem; }
.jr-del, .jr-edit { flex: none; width: 1.9rem; height: 1.9rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-faint); cursor: pointer; font-size: 0.9rem; line-height: 1; }
.jr-del:hover { color: var(--down); border-color: color-mix(in srgb, var(--down) 45%, var(--line)); }
.jr-edit:hover { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.jr-edit-box { margin-top: 0.15rem; }
.jr-edit-text { width: 100%; resize: vertical; }
.jr-edit-actions { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.4rem; }
.jr-edit-hint { font-size: 0.72rem; }
.jr-del-confirm { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.5rem; }
.jr-del-confirm input { flex: 1 1 12rem; min-width: 8rem; padding: 0.35rem 0.5rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: 500 0.85rem var(--f-body); }

/* --- impulse: pre-trade check --- */
/* nothing on this tab or in its sheets may push the page wider than the phone */
#tab-impulse { overflow-wrap: anywhere; }
#tab-impulse .jr-item-body, .ip-fields > *, .ip-facts > * { min-width: 0; }
.ip-start { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.85rem; box-shadow: var(--shadow-sm); margin: 0.6rem 0 1.6rem; display: grid; gap: 0.7rem; }
.ip-seg { flex: 1 1 0; display: flex; background: var(--surface-2); border-radius: 9px; padding: 3px; }
.ip-seg-b { flex: 1 1 0; border: 0; background: none; color: var(--ink-dim); font: 600 0.88rem var(--f-display); padding: 0.5rem 0.4rem; border-radius: 7px; cursor: pointer; }
.ip-seg-b.is-on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.ip-segs { display: flex; gap: 0.5rem; }
.ip-opt { display: grid; gap: 0.6rem; }
.ip-opt .pf-in { font-size: 16px; width: 100%; }
.ip-opt-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
.ip-rule-allowed { display: grid; gap: 0.35rem; }
.ip-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; }
.ip-fields .pf-in { font-size: 16px; } /* no iOS zoom on focus */
.ip-acct { grid-column: 1 / -1; }
.ip-start-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.ip-err { margin: 0; color: var(--sell); font: 500 0.85rem var(--f-body); }
.ip-rec { cursor: pointer; }
.ip-rec-line { font: 500 0.9rem var(--f-body); color: var(--ink); margin: 0.1rem 0; }
.ip-flagged { color: var(--sell); font-weight: 700; white-space: nowrap; }
.ip-rec-out { font: 600 0.82rem var(--f-body); color: var(--ink-dim); }
.ip-out-open { color: var(--sec-impulse); }
.ip-out-skipped { color: var(--buy); }
.ip-rule.is-off { opacity: 0.55; }
.ip-rule-text { font: 600 0.95rem/1.4 var(--f-body); color: var(--ink); }
.ip-rule-meta { font: 500 0.8rem/1.45 var(--f-body); color: var(--ink-dim); margin-top: 0.15rem; }
/* My rules folds away once you have some, so the page stays short */
.ip-rules-sum { display: flex; align-items: baseline; gap: 0.6rem; cursor: pointer; list-style: none; margin-bottom: 0.6rem; }
.ip-rules-sum::-webkit-details-marker { display: none; }
.ip-rules-sum h2 { font-size: 1.15rem; border-left: 3px solid var(--section); padding-left: 0.55rem; }
.ip-rules-sum::after { content: "▾"; margin-left: auto; color: var(--ink-faint); transition: transform 0.15s; }
.ip-rules:not([open]) .ip-rules-sum::after { transform: rotate(-90deg); }
.ip-rules-hint { margin: 0 0 0.8rem; }
/* add-a-rule choices: full-width rows whose text wraps (a pill button can't) */
.ip-suggest { display: grid; gap: 0.5rem; margin-top: 0.7rem; }
.ip-sug { display: grid; gap: 0.15rem; text-align: left; width: 100%; padding: 0.65rem 0.8rem; border: 1px dashed var(--line); border-radius: var(--radius-sm); background: none; color: var(--ink); cursor: pointer; font: 500 0.82rem/1.45 var(--f-body); }
.ip-sug b { font: 600 0.9rem var(--f-display); color: var(--accent); }
.ip-sug span { color: var(--ink-dim); }
.ip-sug:hover { border-color: var(--accent); }
.ip-rule-del.is-armed { width: auto; padding: 0 0.5rem; color: var(--down); font-size: 0.72rem; }
.ip-rule-cmp { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.ip-rule-cmp .pf-in { width: 7rem; }
/* gated form + report (inside a .modal-full) */
.ip-h { font: 700 0.95rem var(--f-display); color: var(--ink); margin: 1.2rem 0 0.5rem; }
.ip-h .hint { font-weight: 500; }
.ip-snap { font: 500 0.85rem/1.5 var(--f-body); color: var(--ink-dim); background: var(--surface-2); border-radius: var(--radius-sm); padding: 0.6rem 0.75rem; }
.ip-snap b { color: var(--ink); }
.ip-q { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.ip-q-text { font: 500 0.92rem/1.35 var(--f-body); color: var(--ink); }
.ip-yn { flex: none; display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.ip-yn button { border: 0; background: var(--surface); color: var(--ink-dim); font: 600 0.82rem var(--f-display); padding: 0.45rem 0.8rem; cursor: pointer; }
.ip-yn button + button { border-left: 1px solid var(--line); }
.ip-yn button.is-on[data-v="yes"] { background: color-mix(in srgb, var(--buy) 18%, var(--surface)); color: var(--buy); }
.ip-yn button.is-on[data-v="no"] { background: color-mix(in srgb, var(--sell) 16%, var(--surface)); color: var(--sell); }
.ip-ack { align-items: flex-start; line-height: 1.4; }
.ip-coded { margin-top: 0.8rem; }
.modal-full .ck-in { font-size: 16px; }
.ip-rep-meta { margin: 0 0 0.6rem; font: 500 0.82rem/1.4 var(--f-body); color: var(--ink-dim); }
/* jump bar: stays under the page head while the report scrolls; scrolls sideways on its own if it must */
.ip-nav { position: sticky; top: calc(var(--hdr-h, 0px) + var(--ph-h, 0px)); z-index: 4; display: flex; gap: 0.4rem; overflow-x: auto; scrollbar-width: none; margin: 0 -1.05rem; padding: 0.55rem 1.05rem; background: var(--bg); border-bottom: 1px solid var(--line); }
.ip-nav::-webkit-scrollbar { display: none; }
.ip-nav button { flex: none; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-dim); font: 600 0.78rem var(--f-display); padding: 0.35rem 0.7rem; border-radius: 999px; cursor: pointer; }
.ip-nav b { color: var(--ink); margin-left: 0.15rem; }
.ip-h[id] { scroll-margin-top: calc(var(--hdr-h, 0px) + var(--ph-h, 0px) + 3.6rem); }
.ip-kind { font: 700 0.72rem var(--f-display); color: var(--sell); margin-bottom: 0.15rem; }
.ip-flag-unchecked .ip-kind { color: var(--amber); }
.ip-card { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.7rem 0.8rem; margin-bottom: 0.55rem; }
.ip-flag { border-left: 3px solid var(--sell); }
.ip-flag-unchecked { border-left-color: var(--amber); }
.ip-qcard { border-left: 3px solid var(--sec-impulse); }
.ip-card-t { font: 700 0.9rem/1.35 var(--f-display); color: var(--ink); }
.ip-card-d { font: 500 0.85rem/1.45 var(--f-body); color: var(--ink-dim); margin-top: 0.15rem; }
.ip-obs { font: 500 0.92rem/1.5 var(--f-body); color: var(--ink); }
.ip-flag .ip-obs { margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px dashed var(--line); }
.ip-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.4rem; }
.ip-chip { border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line)); background: color-mix(in srgb, var(--accent) 9%, transparent); color: var(--accent); font: 600 0.7rem var(--f-body); padding: 0.25rem 0.55rem; border-radius: 9px; cursor: pointer; max-width: 100%; text-align: left; line-height: 1.35; }
.ip-chip.is-on { background: var(--accent); color: var(--accent-ink); }
.ip-src { margin-top: 0.45rem; padding: 0.55rem 0.65rem; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.ip-src .note-read-body { font-size: 0.88rem; }
.ip-src-open, .ip-push-open, .ip-del { border: 0; background: none; padding: 0; color: var(--accent); font: 600 0.8rem var(--f-body); cursor: pointer; text-decoration: underline; }
.ip-src-open { margin-top: 0.4rem; }
.ip-push { margin-top: 0.55rem; }
.ip-push-acts { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.4rem; }
.ip-thread { margin-top: 0.6rem; padding-top: 0.55rem; border-top: 1px dashed var(--line); display: grid; gap: 0.5rem; font: 500 0.88rem/1.45 var(--f-body); color: var(--ink); }
.ip-find-h { display: block; font: 700 0.68rem var(--f-display); text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-faint); margin-bottom: 0.15rem; }
.ip-find-item + .ip-find-item { margin-top: 0.4rem; }
.ip-note { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.55rem 0.75rem; margin-bottom: 0.4rem; }
.ip-note > summary { cursor: pointer; font: 600 0.9rem var(--f-display); color: var(--ink); }
.ip-note .note-read-body { margin-top: 0.5rem; font-size: 0.92rem; }
.ip-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem 0.9rem; }
.ip-facts > span { display: flex; flex-direction: column; font: 500 0.88rem var(--f-body); color: var(--ink); min-width: 0; }
.ip-facts .k { font: 600 0.66rem var(--f-display); text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-faint); }
.ip-answers { margin-top: 0.9rem; }
.ip-cost { margin-top: 0.9rem; }
.ip-close { margin-top: 1.1rem; padding-top: 0.2rem; border-top: 1px solid var(--line); }
.ip-logged { margin: 0 0 0.5rem; font: 500 0.9rem var(--f-body); color: var(--ink); }
.ip-act-note { width: 100%; font-size: 16px; }
.ip-fill { margin-top: 0.8rem; padding: 0.75rem 0.8rem; background: var(--surface-2); border-radius: var(--radius-sm); }
.ip-fill-hint { margin: 0 0 0.55rem; }
.ip-fill-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.55rem; }
.ip-fill-grid .pf-in { width: 100%; font-size: 16px; }
.ip-fill-acct { grid-column: 1 / -1; }
.ip-filled { color: var(--buy); font-weight: 600; }
.ip-acts { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.55rem; }
.ip-acts .btn { flex: 1 1 auto; padding-block: 0.7rem; }
.ip-acts .btn:disabled { opacity: 0.45; cursor: not-allowed; }
.ip-cool { min-height: 1.1rem; margin-top: 0.4rem; }
.ip-del { display: block; margin-top: 0.9rem; color: var(--ink-faint); }
.ip-del.is-armed { color: var(--down); }
.d-impulse-row { cursor: pointer; }

/* --- decision checklists --- */
.ck-launch { display: flex; gap: 0.5rem; margin: 0.6rem 0 1rem; flex-wrap: wrap; }
.ck-nudge {
  background: color-mix(in srgb, var(--buy) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--buy) 30%, var(--line));
  color: var(--ink); border-radius: var(--radius-sm); padding: 0.7rem 0.85rem;
  font: 500 0.88rem/1.45 var(--f-body); margin-bottom: 1rem;
}
.ck-items { display: flex; flex-direction: column; gap: 0.7rem; }
.ck-field { display: flex; flex-direction: column; gap: 0.25rem; }
.ck-in { width: 100%; }
.ck-check { display: flex; align-items: center; gap: 0.6rem; font: 500 0.92rem var(--f-body); color: var(--ink); cursor: pointer; padding: 0.15rem 0; }
.ck-check input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.ck-tag-buy { color: var(--buy); background: color-mix(in srgb, var(--buy) 14%, transparent); border-color: color-mix(in srgb, var(--buy) 32%, var(--line)); }
.ck-tag-sell { color: var(--sell); background: color-mix(in srgb, var(--sell) 14%, transparent); border-color: color-mix(in srgb, var(--sell) 32%, var(--line)); }
.ck-details > summary { cursor: pointer; font: 600 0.86rem var(--f-display); color: var(--ink-dim); margin-top: 0.15rem; }
.ck-rows { margin-top: 0.5rem; display: flex; flex-direction: column; gap: 0.35rem; }
.ck-row { display: grid; grid-template-columns: 1fr auto; gap: 0.75rem; align-items: baseline; padding-bottom: 0.3rem; border-bottom: 1px solid var(--line); }
.ck-q { font: 500 0.82rem var(--f-body); color: var(--ink-dim); }
.ck-a { font: 500 0.86rem var(--f-mono); color: var(--ink); text-align: right; }
.ck-a.ck-yes { color: var(--buy); } .ck-a.ck-no { color: var(--ink-faint); }

/* clickable ticker tag (journal → stock detail) */
.jr-tag-link { cursor: pointer; font-family: var(--f-mono); }
.jr-tag-link:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); text-decoration: underline; }

/* notes shown inside a stock's detail drawer */
.d-notes { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.4rem; }
.d-note-row { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.55rem 0.7rem; }
.d-note-txt { font: 500 0.9rem/1.45 var(--f-body); color: var(--ink); white-space: pre-wrap; word-break: break-word; }
.d-note-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 0.3rem; }
.d-note-del { background: none; border: 0; color: var(--ink-faint); cursor: pointer; font-size: 0.8rem; }
.d-note-del:hover { color: var(--down); }

/* ---- Favorites (♥) ---- */
.fav-badge { margin-left: 0.3rem; font-size: 0.9rem; line-height: 1; vertical-align: middle; color: #e0457b; }
.d-fav {
  margin-left: 0.5rem; padding: 0.1rem 0.45rem; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink-dim); font: 600 1.05rem/1.2 var(--f-body); cursor: pointer; vertical-align: middle;
}
.d-fav:hover { border-color: #e0457b; color: #e0457b; }
.d-fav.is-on { color: #e0457b; border-color: color-mix(in srgb, #e0457b 50%, transparent); background: color-mix(in srgb, #e0457b 10%, transparent); }
.pill-fav { background: color-mix(in srgb, #e0457b 14%, transparent); color: #e0457b; border: 1px solid color-mix(in srgb, #e0457b 40%, transparent); }
.fav-section { margin-bottom: 2rem; }
.fav-order-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
.fav-order-inline { display: inline-flex; flex-wrap: wrap; gap: 0.35rem; vertical-align: middle; }
.fav-plays { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.5rem; padding-top: 0.45rem; border-top: 1px dashed var(--line); }
.fav-plays.fav-none { font: 500 0.78rem/1.4 var(--f-body); color: var(--ink-dim); }
/* one strategy a favorite is in: the priority number in a solid disc, then the name */
.fav-play {
  display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.15rem 0.55rem 0.15rem 0.2rem;
  border-radius: 999px; font: 600 0.8rem/1.3 var(--f-body); color: var(--ink);
  background: color-mix(in srgb, var(--fp) 12%, transparent); border: 1px solid color-mix(in srgb, var(--fp) 40%, transparent);
}
.fav-play b {
  display: inline-grid; place-items: center; width: 1.25rem; height: 1.25rem; border-radius: 50%;
  background: var(--fp); color: #fff; font: 800 0.75rem/1 var(--f-mono, monospace);
}
.fav-play i { font-style: normal; color: var(--ink-dim); font-weight: 500; }
.fp-1 { --fp: #08976a; }  /* 1 VIX Day — first to buy */
.fp-2 { --fp: #2f74e8; }  /* 2 MACD Turn Watch */
.fp-3 { --fp: #7a5ae0; }  /* 3 Weekly Breakout */
.fp-4 { --fp: #c07a12; }  /* 4 Fast MACD */

/* ---- Lists → History ---- */
.fav-play.hist-num { padding: 0; border: 0; background: none; flex: none; }
.turn-filter .hist-num { margin-right: 0.3rem; vertical-align: -0.15rem; }
.turn-filter .hist-num b { width: 1.1rem; height: 1.1rem; font-size: 0.68rem; }
.hist-tools { margin-top: -0.3rem; align-items: center; }
.hist-sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 0.15rem; }
.hist-row { align-items: flex-start; }
.hist-row > .hist-num { margin-top: 0.1rem; }
.hist-row .nt-line .quality-chip, .hist-row .nt-line .q-chip { margin-left: 0.35rem; }
.hist-what { font-size: 0.84rem; color: var(--ink); }
.hist-row.is-exit { opacity: 0.72; }
.fav-drop { font-style: normal; font-weight: 700; color: var(--sell); }
.hist-search { margin: 0 0 0.6rem; }
.hist-search input {
  width: 100%; padding: 0.55rem 0.75rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font: 500 16px/1.4 var(--f-body); /* 16px: no iOS zoom */
}
.hist-search input:focus { outline: none; border-color: var(--accent); }
.hist-count { font-size: 0.76rem; font-weight: 600; color: var(--ink-dim); white-space: nowrap; }
.hist-count.is-repeat { color: var(--accent); }
.hist-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin: 0 0 0.6rem; font: 500 0.86rem/1.5 var(--f-body); color: var(--ink); }

/* ---- Portfolio → Monthly returns heatmap ---- */
:root { --mr-up: #12b886; --mr-down: #e0552b; }
.mr-panel { margin: 1rem 0; padding: 0.9rem 0.9rem 0.7rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.mr-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.7rem; }
.mr-head h3 { margin: 0; font: 800 1.05rem/1.2 var(--f-display); color: var(--ink); }
.mr-toggle { display: inline-flex; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.mr-mode { min-width: 2rem; padding: 0.2rem 0.5rem; border: 0; border-radius: 6px; background: none; color: var(--ink-dim); font: 700 0.85rem/1.2 var(--f-mono); cursor: pointer; }
.mr-mode.is-on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.mr-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -0.2rem; padding: 0 0.2rem 0.2rem; }
.mr-grid { display: grid; grid-template-columns: 2.6rem repeat(12, minmax(2.9rem, 1fr)) 3.6rem; gap: 4px; min-width: 44rem; align-items: center; }
.mr-h { text-align: center; font: 600 0.72rem/1.2 var(--f-body); color: var(--ink-dim); padding-bottom: 0.15rem; }
.mr-y { font: 700 0.76rem/1 var(--f-mono); color: var(--ink-dim); }
.mr-cell {
  display: grid; place-items: center; height: 2.1rem; border-radius: 6px; position: relative;
  font: 700 0.74rem/1 var(--f-mono); color: var(--ink); font-variant-numeric: tabular-nums;
}
.mr-cell.is-strong { color: #fff; }
.mr-cell i { position: absolute; top: 2px; right: 4px; font-style: normal; font-size: 0.65rem; opacity: 0.8; }
.mr-empty { background: var(--surface-2); opacity: 0.55; }
.mr-year { text-align: right; font: 700 0.78rem/1 var(--f-mono); font-variant-numeric: tabular-nums; }
.mr-avg-lbl { padding-top: 0.35rem; }
.mr-avg { text-align: center; font: 700 0.72rem/1 var(--f-mono); padding-top: 0.35rem; font-variant-numeric: tabular-nums; }
.mr-note { margin: 0.6rem 0 0; font-size: 0.74rem; }

/* ---- Portfolio → Performance: family page link ---- */
.fam-link { margin: 1rem 0; padding: 0.85rem 0.9rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); display: grid; gap: 0.6rem; }
.fam-link-h { font-size: 0.9rem; color: var(--ink); }
.fam-link-h .hint { display: block; margin-top: 0.15rem; font-size: 0.78rem; }
.fam-link-url input { width: 100%; padding: 0.5rem 0.65rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--ink); font: 500 0.82rem/1.3 var(--f-mono); }
.fam-link-acts { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.fam-link-acts .is-armed { border-color: var(--sell); color: var(--sell); }

/* ---- Notifications → Shared: today's "Share next" picks ---- */
.share-next { margin: 0 0 0.9rem; padding: 0.75rem 0.8rem; border-radius: var(--radius); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.share-next-h { font-size: 0.9rem; margin-bottom: 0.55rem; }
.share-next-h .hint { display: block; font-size: 0.76rem; margin-top: 0.1rem; }
.share-next-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 0.4rem; }
.share-next-item { display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 0.3rem 0.4rem; padding: 0.45rem 0.55rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); text-align: left; cursor: pointer; font: 600 0.86rem/1.2 var(--f-body); }
.share-next-item:hover { border-color: var(--accent); }
.share-next-item small { grid-column: 1 / -1; color: var(--ink-dim); font-weight: 500; font-size: 0.74rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-next-item .qchip { font: 700 0.7rem/1 var(--f-mono); padding: 0.15rem 0.3rem; border-radius: 5px; background: color-mix(in srgb, var(--buy) 14%, transparent); color: var(--buy); }
.share-next-copy { margin-top: 0.6rem; }
.sym-avg, .sm-avg { color: var(--ink-dim); font-weight: 500; }

/* stock page: recent listing notice */
.young-note { margin: 0 0 0.9rem; padding: 0.65rem 0.8rem; border-radius: var(--radius-sm); border: 1px solid color-mix(in srgb, #e0982a 45%, var(--line)); background: color-mix(in srgb, #e0982a 10%, var(--surface)); font: 500 0.84rem/1.45 var(--f-body); color: var(--ink); }

/* ---- stock page: Fibonacci levels ---- */
.fib-panel { margin: 0 0 1rem; padding: 0.75rem 0.85rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.fib-head { display: grid; grid-template-columns: auto auto 1fr; align-items: baseline; gap: 0.2rem 0.6rem; margin-bottom: 0.55rem; }
.fib-head span { font: 600 0.8rem/1.2 var(--f-body); color: var(--ink-dim); }
.fib-head b { font: 800 1.25rem/1 var(--f-display); color: var(--ink); }
.fib-head small { grid-column: 1 / -1; font-size: 0.78rem; color: var(--ink-dim); }
.fib-ladder { display: grid; gap: 1px; }
.fib-row { display: flex; justify-content: space-between; padding: 0.32rem 0.5rem; border-radius: 6px; font: 500 0.84rem/1.2 var(--f-body); color: var(--ink-dim); }
.fib-row b { font: 600 0.84rem/1.2 var(--f-mono); color: var(--ink); }
.fib-row.is-sup { background: color-mix(in srgb, var(--buy) 12%, transparent); color: var(--ink); font-weight: 700; }
.fib-row.fib-now { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); font-weight: 700; }
.fib-row.fib-now b { color: var(--accent); }

/* ---- Lists → FIB ---- */
.fib-add { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 0.9rem; }
.fib-add .pf-in { flex: 1 1 14rem; min-width: 0; }
.fib-ul { display: grid; gap: 2px; }
.fib-li { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 0.75rem; padding: 0.6rem 0.4rem; border-bottom: 1px solid var(--line); }
.fib-li-sym { text-align: left; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: none; border: 0; color: var(--ink); cursor: pointer; font: inherit; padding: 0; }
.fib-li-sym span { color: var(--ink-dim); font-size: 0.84rem; }
.fib-li-lv { display: grid; justify-items: end; text-align: right; }
.fib-li-lv b { font: 800 1rem/1.1 var(--f-mono); color: var(--buy); }
.fib-li-lv small { font-size: 0.74rem; color: var(--ink-dim); }
.fib-li-del { border: 0; background: none; color: var(--ink-dim); font-size: 1.1rem; cursor: pointer; padding: 0.2rem 0.4rem; border-radius: 6px; }
.fib-li-del:hover { color: var(--sell); background: var(--surface-2); }

.fib-grp { margin-bottom: 0.9rem; }
.fib-grp-h { margin: 0.2rem 0 0.25rem; font: 700 0.86rem/1.2 var(--f-body); color: var(--ink); }
button.fib-li { width: 100%; grid-template-columns: 1fr auto; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; color: var(--ink); cursor: pointer; font: inherit; }
button.fib-li:hover { background: var(--surface-2); }
