/* ============================================================
   Theme tokens — light (default) + dark override
   ============================================================ */
:root {
  --bg: #f4f5f8;
  --bg-elev: #eef0f4;
  --card: #ffffff;
  --ink: #101322;
  --muted: #6b7280;
  --line: #e6e8ee;
  --accent: #5b5bd6;
  --accent-ink: #ffffff;
  --accent-soft: #ecebfb;
  --up: #12a150;
  --down: #e5484d;
  --teal: #0d9488;
  --shadow: 0 1px 2px rgba(16,19,34,.06), 0 6px 20px rgba(16,19,34,.06);
  --shadow-lg: 0 24px 60px rgba(16,19,34,.22);
  --radius: 16px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --skyline: #5b5bd6;
  --skyline-strength: .15;
}
[data-theme="dark"] {
  --bg: #0d1017;
  --bg-elev: #12161f;
  --card: #161b24;
  --ink: #e6edf5;
  --muted: #8b95a5;
  --line: #232a36;
  --accent: #8189ff;
  --accent-ink: #0d1017;
  --accent-soft: #1e2233;
  --up: #3fce75;
  --down: #ff6169;
  --teal: #2dd4bf;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  --shadow-lg: 0 24px 60px rgba(0,0,0,.6);
  --skyline: #8189ff;
  --skyline-strength: .24;
}

* { box-sizing: border-box; }
html { color-scheme: light dark; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); line-height: 1.55; letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   Skyline backdrop — decorative, sits behind all content
   ============================================================ */
.app-backdrop {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: 62vh; max-height: 560px;
  z-index: -1; pointer-events: none; overflow: hidden;
  opacity: var(--skyline-strength);
  -webkit-mask-image: linear-gradient(to top, #000 35%, transparent);
          mask-image: linear-gradient(to top, #000 35%, transparent);
}
.app-backdrop .skyline { width: 100%; height: 100%; display: block; }
.app-backdrop .sky-front { fill: var(--skyline); }
.app-backdrop .sky-back { fill: var(--skyline); opacity: .55; }

/* ============================================================
   Header
   ============================================================ */
header {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: .75rem; padding: .9rem 1.5rem; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 800; font-size: 1.15rem;
  color: var(--ink); text-decoration: none; letter-spacing: -0.02em; }
nav { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
nav a { position: relative; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .92rem; }
nav a:hover { color: var(--accent); }
nav a.active { color: var(--ink); }
nav a.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -.9rem; height: 2px;
  background: var(--accent); border-radius: 2px 2px 0 0; }
nav .user { display: inline-flex; align-items: center; gap: .45rem; color: var(--muted); font-size: .88rem;
  padding-left: .6rem; border-left: 1px solid var(--line); }
.user-email { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 26px; height: 26px; border-radius: 50%; }
.theme-toggle { background: var(--bg-elev); border: 1px solid var(--line); border-radius: 999px;
  width: 34px; height: 34px; cursor: pointer; font-size: 1rem; line-height: 1; display: grid; place-items: center; }
.theme-toggle:hover { border-color: var(--accent); }

main { max-width: 1000px; margin: 1.75rem auto; padding: 0 1.1rem; }
main.wide { max-width: 1240px; }

/* ============================================================
   Cards + forms
   ============================================================ */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.35rem 1.5rem; margin-bottom: 1.25rem; box-shadow: var(--shadow);
}
.card > h2 { margin-top: 0; font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; }
h2 .count { font-weight: 500; font-size: .85rem; color: var(--muted); }

form { display: flex; flex-wrap: wrap; gap: .55rem; }
input, select, button { font-family: inherit; font-size: .93rem; }
input, select {
  padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--ink);
}
input:focus, select:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: var(--muted); }
button { cursor: pointer; }
button[type="submit"], .btn {
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent);
  border-radius: 10px; padding: .6rem 1.1rem; font-weight: 700;
}
button[type="submit"]:hover, .btn:hover { filter: brightness(1.05); }

/* ============================================================
   Tables: sorting, sparklines, inline edit, actions
   ============================================================ */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-elev); }
th.num, td.num { text-align: right; }
td.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.ticker { font-weight: 700; }

table.holdings th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
table.holdings th.sortable:hover { color: var(--accent); }
table.holdings th.sortable::after { content: " ⇅"; opacity: .5; font-size: .8em; }
table.holdings th.sortable.sorted::after { content: " ↕"; color: var(--accent); opacity: 1; }
.ticker-link { font-weight: 700; color: var(--ink); text-decoration: none; cursor: pointer;
  border-bottom: 2px solid transparent; }
.ticker-link:hover { color: var(--accent); border-bottom-color: var(--accent); }
.co-name { display: block; font-size: .72rem; font-weight: 500; color: var(--muted);
  max-width: 15ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: .1rem; }
.spark-cell { width: 96px; }
.spark { display: block; width: 100%; height: 30px; }
input.mini { width: 4.5rem; padding: .35rem .45rem; text-align: right; font-family: var(--mono); font-size: .88rem; }
td.actions { white-space: nowrap; text-align: right; }
.link-btn { background: var(--bg-elev); border: 1px solid var(--line); color: var(--muted);
  border-radius: 8px; font-size: .74rem; font-weight: 600; padding: .28rem .5rem; }
.link-btn:hover { color: var(--accent); border-color: var(--accent); }
.link-danger { background: none; border: none; color: var(--down); font-size: 1rem; padding: .2rem .4rem; cursor: pointer; }
.link-danger:hover { filter: brightness(1.1); }

.up { color: var(--up); } .down { color: var(--down); }
.muted { color: var(--muted); }

/* ============================================================
   App shell — page header, metric cards, compact add bar
   ============================================================ */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; margin: .25rem 0 1.25rem; }
.ph-title { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.025em; margin: 0; }
.ph-sub { color: var(--muted); font-size: .9rem; margin: .1rem 0 0; }
.ph-action { display: inline-flex; align-items: center; gap: .45rem; }
.detail-page-head { align-items: flex-start; }
.detail-page-head .ph-title { margin-top: .3rem; }

.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.06); }
a.btn { display: inline-flex; align-items: center; gap: .45rem; text-decoration: none; }

/* Portfolio totals — metric cards */
.metric-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: .85rem; margin-bottom: 1.25rem; }
.metric { background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: .95rem 1.1rem; box-shadow: var(--shadow); }
.metric-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 700; }
.metric-val { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 1.6rem;
  font-weight: 700; margin-top: .3rem; letter-spacing: -0.02em; }
.metric-pct { font-size: .92rem; font-weight: 600; }
.metric-note { grid-column: 1 / -1; font-size: .82rem; color: var(--muted); margin-top: -.5rem; }

/* Compact add bar (expands to show shares/cost) */
.add-card { padding: .8rem .9rem; }
.add-bar { align-items: center; gap: .5rem; }
.add-primary { display: flex; gap: .5rem; flex: 1; min-width: 240px; align-items: center; }
.add-primary input[name="ticker"] { flex: 1; min-width: 8rem; }
.add-toggle { background: var(--bg-elev); border: 1px solid var(--line); color: var(--muted);
  border-radius: 10px; padding: .55rem .7rem; font-size: .85rem; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: .3rem; }
.add-toggle:hover { color: var(--accent); border-color: var(--accent); }
.add-more { display: none; gap: .5rem; flex-basis: 100%; margin-top: .1rem; }
.add-bar.expanded .add-more { display: flex; }

/* Ticker/company autocomplete dropdown */
.autocomplete { position: relative; flex: 1 1 100%; min-width: 0; }
.autocomplete input[name="ticker"] { width: 100%; }
.suggest { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 40;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-lg); max-height: 280px; overflow-y: auto; padding: .25rem; }
.suggest:empty { display: none; }
.suggest-item { display: flex; align-items: baseline; gap: .5rem; width: 100%; text-align: left;
  background: none; border: none; border-radius: 8px; padding: .5rem .6rem; cursor: pointer; color: var(--ink); }
.suggest-item:hover, .suggest-item.active { background: var(--accent-soft); }
.s-sym { font-family: var(--mono); font-weight: 700; font-size: .9rem; min-width: 3.5rem; }
.s-name { flex: 1; font-size: .85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s-exch { font-size: .72rem; color: var(--muted); white-space: nowrap; }
.add-error { margin-top: .6rem; }
.add-error:empty { display: none; }

@media (max-width: 620px) { .metric-cards { grid-template-columns: 1fr; } }

/* Two-column dashboard: holdings main + utilities sidebar */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1.25rem; align-items: start; }
.dash-main { min-width: 0; }
.dash-side { display: flex; flex-direction: column; gap: 1rem; }
.side-card { margin-bottom: 0; padding: 1rem 1.1rem; }
.side-title { margin: 0 0 .7rem; font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; }
/* Tables can exceed the main column — scroll inside the card instead of bleeding out. */
.table-scroll { overflow-x: auto; margin: 0 -.25rem; }
@media (max-width: 860px) { .dash-grid { grid-template-columns: 1fr; } }

/* Sidebar add-stock form: stacked so nothing is cramped/clipped */
.side-card .add-bar { flex-direction: column; align-items: stretch; }
.side-card .add-primary { flex-wrap: wrap; min-width: 0; }
.side-card .add-primary input[name="ticker"] { flex: 1 1 100%; min-width: 0; }
.side-card .add-primary select { flex: 1 1 auto; }
.side-card .add-toggle { white-space: nowrap; }
.side-card .add-more { flex-direction: column; }
.side-card .add-more input { width: 100%; }

/* Market list (sidebar) */
.market-side { display: flex; flex-direction: column; }
.mkt-row { display: grid; grid-template-columns: 1fr auto auto; gap: .6rem; align-items: baseline;
  padding: .4rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.mkt-row:last-child { border-bottom: none; }
.mkt-row .mkt-label { color: var(--muted); }
.mkt-chg { font-size: .82rem; font-weight: 600; text-align: right; min-width: 4.2rem; }

/* Upcoming earnings */
.earnings-card .digest-preview-head { margin-bottom: .5rem; }
.earnings-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.earnings-list li { display: flex; align-items: center; gap: .75rem; padding: .5rem 0;
  border-bottom: 1px solid var(--line); }
.earnings-list li:last-child { border-bottom: none; }
.earnings-tk { font-weight: 700; min-width: 4rem; }
.earnings-date { font-family: var(--mono); font-size: .85rem; min-width: 4rem; }
.earnings-soon { margin-left: auto; font-size: .74rem; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); border-radius: 999px; padding: .18rem .6rem; }
.earnings-head { display: flex; align-items: center; gap: .75rem; width: 100%; }
.earnings-head .muted.small { margin-left: auto; }
.ep-toggle { margin-left: .25rem; }
.earnings-head .earnings-soon + .ep-toggle { margin-left: auto; }
.earnings-list li { flex-wrap: wrap; }
.ep-slot:not(:empty) { flex-basis: 100%; margin-top: .5rem; }

/* Earnings preview body */
.earnings-preview { background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px;
  padding: .85rem 1rem; }
.est-row { display: flex; gap: 1.25rem; margin-bottom: .5rem; font-family: var(--mono); font-size: .9rem; }
.est-label { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.ep-body { font-size: .92rem; }
.ep-body h2 { font-size: .95rem; margin: .8rem 0 .3rem; } .ep-body h3 { font-size: .9rem; }
.ep-body ul { margin: .2rem 0 .5rem; padding-left: 1.1rem; }
.ep-sources { margin-top: .4rem; } .ep-sources a { color: var(--accent); }
.ep-meta { margin-top: .5rem; }
.ep-box { margin-top: 1.25rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.ep-box h3 { margin: 0 0 .6rem; font-size: .95rem; }

/* Sector allocation doughnut */
.sector-card .digest-preview-head { margin-bottom: .6rem; }
.sector-grid { display: grid; grid-template-columns: 200px 1fr; gap: 1.25rem; align-items: center; }
.sector-chart-wrap { position: relative; height: 200px; }
.sector-center { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none; }
.sc-total { font-family: var(--mono); font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; }
.sc-sub { font-size: .78rem; }
.sector-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.sector-legend li { display: flex; align-items: center; gap: .6rem; font-size: .88rem; }
.sl-swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.sl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sl-count { font-size: .8rem; }
.sl-value { font-family: var(--mono); font-size: .82rem; min-width: 5rem; text-align: right; }
.sl-pct { font-family: var(--mono); font-weight: 700; min-width: 3.2rem; text-align: right; }
@media (max-width: 560px) { .sector-grid { grid-template-columns: 1fr; } }

/* Portfolio heatmap */
.heatmap-card .digest-preview-head { margin-bottom: .6rem; }
.heatmap { display: flex; flex-wrap: wrap; gap: 6px; }
.hm-tile { flex: 1 1 92px; min-width: 92px; min-height: 60px; border-radius: 10px; padding: .5rem .6rem;
  display: flex; flex-direction: column; justify-content: space-between; text-decoration: none;
  transition: transform .1s ease; }
.hm-tile:hover { transform: translateY(-2px); }
.hm-tk { font-weight: 700; }
.hm-chg { font-family: var(--mono); font-size: .8rem; font-weight: 600; }
.hm-up-3 { background: var(--up); color: #ffffff; }
.hm-up-2 { background: color-mix(in srgb, var(--up) 72%, #ffffff); color: #08331d; }
.hm-up-1 { background: color-mix(in srgb, var(--up) 42%, var(--card)); color: var(--ink); }
.hm-flat { background: var(--bg-elev); color: var(--muted); }
.hm-down-1 { background: color-mix(in srgb, var(--down) 42%, var(--card)); color: var(--ink); }
.hm-down-2 { background: color-mix(in srgb, var(--down) 72%, #ffffff); color: #4a1111; }
.hm-down-3 { background: var(--down); color: #ffffff; }

/* Import from screenshot */
.import-form { margin-top: .85rem; padding-top: .85rem; border-top: 1px solid var(--line); }
.import-pick input[type="file"] { width: 100%; font-size: .8rem; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 10px; padding: .5rem; background: var(--bg); }
.import-pick input[type="file"]::file-selector-button { margin-right: .6rem; padding: .3rem .6rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg-elev);
  color: var(--ink); font: inherit; font-size: .78rem; cursor: pointer; }
.import-row { display: flex; align-items: center; gap: .6rem; margin-top: .5rem; }
.import-btn { font-size: .82rem; }
.import-modal { max-width: 640px; }
.import-note { margin: .2rem 0 .8rem; }
.import-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.import-table th { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 700; }
.import-table td { padding: .35rem .4rem; border-bottom: 1px solid var(--line); }
.import-table .mini-ticker { width: 6rem; font-family: var(--mono); text-transform: uppercase; }
.import-table .row-bad { opacity: .55; }
.import-status { white-space: nowrap; max-width: 12rem; overflow: hidden; text-overflow: ellipsis; }
.import-actions { display: flex; align-items: center; gap: .6rem; margin-top: 1rem; }

/* Performance strip (stock modal) */
.perf-strip { display: grid; grid-template-columns: repeat(6, 1fr); gap: .5rem; margin-top: 1rem; }
.perf-pill { display: flex; flex-direction: column; gap: .1rem; align-items: center;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px; padding: .5rem .35rem; }
.perf-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.perf-val { font-size: .92rem; font-weight: 600; font-variant-numeric: tabular-nums; }
@media (max-width: 520px) { .perf-strip { grid-template-columns: repeat(3, 1fr); } }

/* About the company (stock modal) */
.about-box { margin-top: 1.25rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.about-box h3 { margin: 0 0 .5rem; font-size: .95rem; }
.about-text { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.about-text.expanded { -webkit-line-clamp: unset; }
.about-toggle { margin-top: .4rem; background: none; border: none; padding: 0; cursor: pointer;
  color: var(--accent); font-weight: 600; font-size: .82rem; font-family: inherit; }
.about-toggle:hover { text-decoration: underline; }

/* Analyst view + headlines (stock modal) */
.analyst-box, .news-box { margin-top: 1.25rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.analyst-box h3, .news-box h3 { margin: 0 0 .6rem; font-size: .95rem; }
.analyst-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .65rem; }
.analyst-grid > div { display: flex; flex-direction: column; gap: .15rem; background: var(--bg-elev);
  border: 1px solid var(--line); border-radius: 12px; padding: .6rem .7rem; }
.news-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .55rem; }
.news-list li { line-height: 1.35; }
.news-list a { color: var(--ink); text-decoration: none; font-weight: 600; font-size: .92rem; }
.news-list a:hover { color: var(--accent); }

/* Price alerts (stock modal) */
.alerts-box { margin-top: 1.25rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.alerts-box h3 { margin: 0 0 .6rem; font-size: .95rem; }
.alert-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.alert-form select, .alert-form input { padding: .4rem .55rem; border: 1px solid var(--line);
  border-radius: 8px; background: var(--bg-elev); color: var(--ink); }
.alert-form input { width: 8rem; }
.alert-list { list-style: none; margin: .75rem 0 0; padding: 0; display: flex;
  flex-direction: column; gap: .4rem; }
.alert-list li { display: flex; justify-content: space-between; align-items: center;
  gap: .75rem; font-size: .9rem; padding: .35rem .6rem; background: var(--bg-elev);
  border-radius: 8px; }

/* ============================================================
   Badges + feed
   ============================================================ */
.badge { display: inline-block; font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; padding: .18rem .5rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); }
.badge.weekly { background: color-mix(in srgb, var(--teal) 18%, transparent); color: var(--teal); }

ul.feed { list-style: none; padding: 0; margin: 0; }
ul.feed li { padding: .75rem 0; border-bottom: 1px solid var(--line); display: flex;
  flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; }
ul.feed li:last-child { border-bottom: none; }
ul.feed a { text-decoration: none; color: var(--ink); display: flex; gap: .55rem; align-items: center; }
.feed-title { color: var(--accent); font-weight: 600; }

/* Latest-digest preview */
.digest-preview-head { display: flex; justify-content: space-between; align-items: baseline; }
.digest-preview-head h2 { margin: 0; }
.digest-preview-head a { color: var(--accent); text-decoration: none; font-size: .9rem; font-weight: 600; }
.digest-preview-body { display: block; text-decoration: none; color: var(--ink); margin-top: .6rem; }
.digest-preview-body:hover strong { color: var(--accent); }
.digest-preview-body p { margin: .45rem 0 0; }

/* ============================================================
   Digest feed
   ============================================================ */
.small { font-size: .82rem; }
.btn.ghost { background: var(--bg-elev); color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); filter: none; }

.banner { border-radius: 10px; padding: .6rem .85rem; margin-bottom: .9rem; font-size: .9rem; font-weight: 500; }
.banner.warn { background: color-mix(in srgb, #d97706 16%, transparent); color: #b45309; }
.banner.error { background: color-mix(in srgb, var(--down) 16%, transparent); color: var(--down); }
.banner.ok { background: color-mix(in srgb, var(--up) 16%, transparent); color: var(--up); }
.banner.info { background: var(--bg-elev); color: var(--muted); }
[data-theme="dark"] .banner.warn { color: #fbbf24; }

/* Generate panel */
.gen-head { display: flex; align-items: center; gap: .75rem; }
.gen-head h2 { margin: 0; }
.spinner { color: var(--accent); font-weight: 600; font-size: .85rem; }
#gen-spinner.htmx-request, .htmx-request #gen-spinner { display: inline; }
.gen-row { display: flex; gap: .55rem; margin: .4rem 0 .8rem; flex-wrap: wrap; }
.cats { border: 1px solid var(--line); border-radius: 12px; padding: .7rem .9rem; margin: 0 0 .5rem;
  display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; }
.cats legend { padding: 0 .3rem; }
.chk { display: inline-flex; align-items: center; gap: .35rem; font-size: .9rem; cursor: pointer; }
.chk input { accent-color: var(--accent); }

/* Filter toolbar */
.feed-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.feed-toolbar h2 { margin: 0; }
.filters { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.filters input { padding: .45rem .6rem; }
.chips { display: inline-flex; gap: .3rem; background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 999px; padding: .2rem; }
.chip { font-size: .82rem; font-weight: 600; color: var(--muted); padding: .28rem .7rem; border-radius: 999px; cursor: pointer; }
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip.on { background: var(--accent); color: var(--accent-ink); }

.feed-count { margin-bottom: .6rem; }

/* Digest cards */
.digest-card { display: flex; justify-content: space-between; gap: 1rem; padding: .9rem .8rem;
  border: 1px solid var(--line); border-radius: 12px; margin-bottom: .6rem; background: var(--bg);
  transition: border-color .12s ease, background .12s ease; }
.digest-card:last-of-type { margin-bottom: 0; }
.digest-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.digest-card.unread { border-left: 3px solid var(--accent); }
.dc-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }
.dc-title { font-weight: 700; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.dc-title:hover { color: var(--accent); }
.dc-meta { margin-top: .2rem; }
.dc-snippet { margin: .5rem 0 .4rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chips-row { display: flex; flex-wrap: wrap; gap: .35rem; }
.tchip { font-family: var(--mono); font-size: .72rem; font-weight: 600; padding: .12rem .45rem;
  border-radius: 6px; background: var(--bg-elev); border: 1px solid var(--line); color: var(--muted); }
.dc-actions { display: flex; flex-direction: column; align-items: flex-end; gap: .4rem; white-space: nowrap; }
.load-more { display: block; margin: 1rem auto 0; }
.empty { padding: 1.5rem 0; text-align: center; }

/* Digest detail */
.back-link { display: inline-block; margin-bottom: .5rem; text-decoration: none; }
.detail-head { margin-bottom: .3rem; }
table.snapshot { margin: 1rem 0 1.25rem; }
.detail-actions { margin-top: 1.5rem; display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }

/* Email controls */
.email-pref { margin-top: .4rem; }
.feed-flash:not(:empty) { margin-bottom: .8rem; }
.flash { display: inline-block; font-size: .85rem; font-weight: 600; padding: .35rem .7rem; border-radius: 8px; }
.flash.ok { background: color-mix(in srgb, var(--up) 16%, transparent); color: var(--up); }
.flash.warn { background: color-mix(in srgb, #d97706 16%, transparent); color: #b45309; }
.flash.error { background: color-mix(in srgb, var(--down) 16%, transparent); color: var(--down); }
[data-theme="dark"] .flash.warn { color: #fbbf24; }

/* ============================================================
   Settings — schedule
   ============================================================ */
.sched-block { border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1.1rem;
  margin-bottom: 1rem; background: var(--bg-elev); }
.sched-toggle { font-size: 1rem; margin-bottom: .6rem; }
.sched-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding-left: 1.6rem; }
.sched-row label { display: inline-flex; align-items: center; gap: .4rem; color: var(--muted); font-size: .9rem; }
.sched-row select { padding: .4rem .5rem; }
.days { display: inline-flex; gap: .3rem; flex-wrap: wrap; }
.chip.day { position: relative; }
.chip.day input { position: absolute; opacity: 0; width: 0; height: 0; }
.sched-actions { display: flex; align-items: center; gap: .8rem; margin-top: .5rem; }
.sched-note { margin-top: 1rem; }

/* ============================================================
   Login hero
   ============================================================ */
.btn-google { display: inline-flex; align-items: center; gap: .6rem; background: #fff; color: #1a1d21;
  border: 1px solid #dadce0; border-radius: 10px; padding: .7rem 1.2rem; text-decoration: none;
  font-weight: 700; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.btn-google:hover { box-shadow: 0 2px 8px rgba(0,0,0,.12); }

/* ============================================================
   Landing page
   ============================================================ */
.landing-hero { display: grid; grid-template-columns: 1.1fr .9fr; gap: 2.5rem;
  align-items: center; padding: 2.5rem 0 1rem; }
.eyebrow { display: inline-block; font-family: var(--mono); font-size: .72rem;
  letter-spacing: .08em; text-transform: uppercase; color: var(--accent);
  background: var(--accent-soft); border-radius: 999px; padding: .35rem .8rem; margin-bottom: 1.1rem; }
.landing-copy h1 { margin: 0; font-size: 2.55rem; line-height: 1.1; letter-spacing: -0.03em; }
.lede { font-size: 1.1rem; color: var(--muted); max-width: 30rem; margin: 1.1rem 0 1.6rem; }
.cta-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.cta-note { font-size: .9rem; }

.preview-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; box-shadow: var(--shadow-lg); }
.preview-head { display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: .8rem; font-size: .82rem; }
.preview-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  background: var(--bg-elev); border-radius: 10px; padding: .55rem .75rem; margin-bottom: .5rem; }
.preview-tk { font-weight: 700; font-size: .9rem; }
.preview-digest { margin-top: .8rem; background: var(--accent-soft); color: var(--accent);
  border-radius: 10px; padding: .6rem .75rem; font-size: .84rem; font-weight: 600; }

.landing-pills { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center;
  padding: 1.75rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  margin: 1.5rem 0; }
.pill { background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: .5rem 1rem; font-size: .85rem; color: var(--ink); }

.landing-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.1rem; }
.step { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.35rem 1.4rem; }
.step-num { display: inline-flex; align-items: center; justify-content: center; width: 1.9rem;
  height: 1.9rem; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  font-family: var(--mono); font-weight: 600; margin-bottom: .8rem; }
.step h3 { margin: 0 0 .35rem; font-size: 1.05rem; }
.step p { margin: 0; font-size: .92rem; }

.landing-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; margin: 2.5rem 0 1rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }

@media (max-width: 720px) {
  .landing-hero { grid-template-columns: 1fr; gap: 1.75rem; padding-top: 1.5rem; }
  .landing-copy h1 { font-size: 2.05rem; }
  .landing-steps { grid-template-columns: 1fr; }
}

/* ============================================================
   Prose (digest detail)
   ============================================================ */
.prose h2 { margin-top: 1.5rem; font-size: 1.15rem; } .prose h3 { margin-top: 1rem; }
.prose a { color: var(--accent); }
.sources { word-break: break-all; font-size: .85rem; }

/* ============================================================
   Loading indicator (htmx)
   ============================================================ */
.htmx-indicator { display: none; }
#modal-loading.htmx-request, .htmx-request #modal-loading { display: block; }
#modal-loading { position: fixed; top: 1rem; right: 1rem; z-index: 60; background: var(--ink);
  color: var(--card); padding: .45rem .85rem; border-radius: 10px; font-size: .85rem; font-weight: 600; }

/* ============================================================
   Stock detail modal
   ============================================================ */
.modal-backdrop { position: fixed; inset: 0; background: rgba(8,10,18,.55); backdrop-filter: blur(2px);
  z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 3vh 1rem; overflow: auto; }
.modal { background: var(--card); border: 1px solid var(--line); border-radius: 20px; width: min(780px, 100%);
  padding: 1.6rem; box-shadow: var(--shadow-lg); position: relative; }
.modal-close { position: absolute; top: .9rem; right: .9rem; background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 999px; width: 30px; height: 30px; color: var(--muted); font-size: .95rem; cursor: pointer; }
.modal-close:hover { color: var(--down); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding-right: 2rem; }
.modal-head h2 { margin: 0 0 .2rem; font-size: 1.3rem; letter-spacing: -0.02em; }
.modal-price { text-align: right; }
.modal-price .big { font-family: var(--mono); font-size: 1.7rem; font-weight: 600; }
.modal-price .cur { font-size: .8rem; color: var(--muted); font-weight: 400; }
.chart-ranges { display: flex; gap: .4rem; margin: 1.1rem 0 .6rem; }
.range-btn { background: var(--bg-elev); border: 1px solid var(--line); border-radius: 8px; padding: .3rem .8rem;
  font-size: .82rem; font-weight: 600; cursor: pointer; color: var(--muted); }
.range-btn.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chart-wrap { position: relative; height: 280px; }
.fund-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: .65rem; margin-top: 1.4rem; }
.fund-grid > div { display: flex; flex-direction: column; gap: .15rem; background: var(--bg-elev);
  border: 1px solid var(--line); border-radius: 12px; padding: .6rem .7rem; }
.fund-label { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.fund-val { font-family: var(--mono); font-size: 1.02rem; font-weight: 600; }

@media (max-width: 560px) {
  .user-email { display: none; }
  main { margin: 1.1rem auto; }
}
