/* ============================================================
   CSS Variables — Themes
   Dark is the base palette; <html data-theme="light"> overrides it.
   data-theme always holds the *resolved* theme (utils/theme.js turns
   the "System" preference into dark/light), so no media query here.
   ============================================================ */
:root {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #3b82d4;
  --accent-hover: #5b9cf6;
  --positive: #3fb950;
  --negative: #f85149;
  --warning: #d29922;
  --warning-bg: rgba(210, 153, 34, 0.08);
  --negative-bg: rgba(248, 81, 73, 0.08);
  --positive-fill: rgba(63, 185, 80, 0.18);
  --negative-fill: rgba(248, 81, 73, 0.18);
  --radius: 6px;
  --font: -apple-system, "Segoe UI", system-ui, sans-serif;
  --transition: 0.15s ease;
  /* Categorical chart slots (allocation donut), in fixed order — the dark
     steps of the validated reference palette, checked against --surface. */
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --series-other: #6e7681;
  /* Ink for % labels drawn on each slot (white or near-black, whichever
     contrasts more — all ≥ 4.6:1 on these dark-theme steps). */
  --series-1-ink: #111111; --series-2-ink: #111111; --series-3-ink: #111111; --series-4-ink: #111111;
  --series-5-ink: #111111; --series-6-ink: #ffffff; --series-7-ink: #111111; --series-8-ink: #111111;
  --series-other-ink: #ffffff;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --border: #d0d7de;
  --text: #1f2328;
  --text-muted: #59636e;
  --accent: #0969da;
  --accent-hover: #0550ae;
  --positive: #1a7f37;
  --negative: #cf222e;
  --warning: #9a6700;
  --warning-bg: rgba(154, 103, 0, 0.08);
  --negative-bg: rgba(207, 34, 46, 0.07);
  --positive-fill: rgba(26, 127, 55, 0.16);
  --negative-fill: rgba(207, 34, 46, 0.14);
  /* Light steps of the same slots. Three sit under 3:1 on white, so the
     chart always shows its legend table with names and values. */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
  --series-other: #8c959f;
  --series-1-ink: #ffffff; --series-2-ink: #111111; --series-3-ink: #111111; --series-4-ink: #111111;
  --series-5-ink: #111111; --series-6-ink: #ffffff; --series-7-ink: #ffffff; --series-8-ink: #111111;
  --series-other-ink: #111111;
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

button {
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  padding: 5px 12px;
  transition: background var(--transition), border-color var(--transition);
}
button:hover { background: var(--border); border-color: var(--text-muted); }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { background: transparent; border-color: var(--negative); color: var(--negative); }
button.danger:hover { background: var(--negative); color: #fff; }

input, select, textarea {
  font-family: var(--font);
  font-size: 13px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 10px;
  outline: none;
  transition: border-color var(--transition);
}
/* iPhone Safari zooms the page in when a field under 16px gets focus (and
   stays zoomed). 16px on touch screens prevents it without disabling
   pinch-zoom for everyone. */
@media (pointer: coarse) {
  input, select, textarea { font-size: 16px; }
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }

label { font-size: 12px; color: var(--text-muted); display: block; margin-bottom: 4px; }

/* ============================================================
   Layout
   ============================================================ */
#app { display: flex; flex-direction: column; min-height: 100vh; }

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  flex-shrink: 0;
  /* Frozen at the top while the page scrolls; below the article viewer
     overlay (z-index 100), above dragged watchlist cards (z-index 1). */
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header .logo {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
  cursor: pointer;
  border-radius: 6px;
}
/* The logo is the link home (Markets). */
.app-header .logo:hover { text-decoration: none; opacity: .85; }
.app-header .logo:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.app-header .logo-accent { color: var(--accent); }
.app-header .logo-icon { display: none; border-radius: 6px; }

.tab-bar {
  margin-left: auto;
  display: flex;
  gap: 2px;
  align-items: center;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 14px 14px 12px;
  font-size: 13px;
  color: var(--text-muted);
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn:hover { background: transparent; color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Secondary tab strip nested inside a page (e.g. Oil & Gas Markets'
   Oil/Retail Gas split) — same underline-on-active language as the main
   .tab-bar, sized down and without its own background since it lives in
   the content area, not the app header. */
.subtab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.label-short { display: none; }
/* App subheader (app.js): My Account + Markets' sections, and Markets'
   "Updated …" on the right — full width and frozen right under the app
   header (52px tall), on every page. The first tab's label lines up with
   the logo (same side padding as the header). */
.app-subheader {
  position: sticky;
  top: 52px;
  z-index: 9; /* under the app header and its menus */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.app-subheader .subtab-bar { border-bottom: none; margin-bottom: 0; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.app-subheader .subtab-btn { white-space: nowrap; flex-shrink: 0; }
.app-subheader .subtab-btn:first-child { padding-left: 0; }
.app-subheader .subtab-account { margin-right: 10px; } /* a little apart from Markets' sections */
.subheader-updated { white-space: nowrap; flex-shrink: 0; }
/* Right end of the subheader: Markets' "Updated …" and the theme button. */
.subheader-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; margin-left: auto; }
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0; border-radius: 50%;
  border: 1px solid var(--border); background: transparent; color: var(--text-muted);
  font-size: 15px; line-height: 1;
}
.theme-toggle:hover:not(:disabled) { background: var(--surface-2); color: var(--accent); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.subheader-updated-below { display: none; margin: -8px 0 12px; text-align: right; }
@media (max-width: 900px) {
  .subheader-updated { display: none; }
  .subheader-updated-below { display: block; }
}
@media (max-width: 768px) {
  .app-subheader { padding: 0 12px; }
}
/* Sticky bars inside pages stop under the subheader (52px header + ~41px subheader). */
.tab-content .wl-bulk-bar { top: 101px; }
@media (max-width: 480px) {
  /* Short labels sharing the row; it scrolls sideways only if they can't fit. */
  .app-subheader { padding: 0 8px 0 4px; gap: 6px; }
  .theme-toggle { width: 28px; height: 28px; font-size: 14px; }
  .app-subheader .subtab-bar { flex: 1; }
  .app-subheader .subtab-btn { flex: 1 0 auto; }
  .app-subheader .subtab-btn:first-child { padding-left: 4px; }
  .app-subheader .subtab-account { margin-right: 0; }
}
/* Markets sub-tab change by swipe: the new section slides in from the side
   the finger came from. */
.markets-content.slide-from-right { animation: slide-from-right 180ms ease-out; }
.markets-content.slide-from-left  { animation: slide-from-left 180ms ease-out; }
@keyframes slide-from-right { from { transform: translateX(24px); opacity: 0.4; } to { transform: none; opacity: 1; } }
@keyframes slide-from-left  { from { transform: translateX(-24px); opacity: 0.4; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .markets-content.slide-from-right, .markets-content.slide-from-left { animation: none; }
}
.subtab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  transition: color var(--transition), border-color var(--transition);
}
.subtab-btn:hover { background: transparent; color: var(--text); }
.subtab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content {
  flex: 1;
  padding: 24px 20px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.app-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  padding: 12px 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 16px;
  flex-shrink: 0;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.card-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.section-header {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

/* ============================================================
   Price Cards Grid
   ============================================================ */
.price-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.price-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.price-card .label { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.price-card .price { font-size: 22px; font-weight: 600; }
.price-card .change { font-size: 12px; margin-top: 2px; }

/* ============================================================
   Change Colors
   ============================================================ */
.positive { color: var(--positive); }
.negative { color: var(--negative); }
.neutral  { color: var(--text-muted); }

/* ============================================================
   Tables
   ============================================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-2); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ============================================================
   Spread Widget
   ============================================================ */
.spread-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.spread-widget select { min-width: 120px; }
.spread-widget .spread-vs { color: var(--text-muted); font-size: 13px; }
.spread-result { font-size: 20px; font-weight: 600; }
.spread-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* ============================================================
   Loading / Skeleton
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
  height: 14px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.loading-text { color: var(--text-muted); font-size: 13px; padding: 24px 0; }

/* ============================================================
   Error / Notice Banners
   ============================================================ */
.notice {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.notice.warn {
  border-color: var(--warning);
  color: var(--warning);
  background: var(--warning-bg);
}
.notice.error {
  border-color: var(--negative);
  color: var(--negative);
  background: var(--negative-bg);
}

/* ============================================================
   Settings
   ============================================================ */
.settings-section {
  margin-bottom: 28px;
}
.settings-section h3 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.settings-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.settings-row input { flex: 1; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tag {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 10px 2px 12px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tag .remove-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.tag .remove-btn:hover { color: var(--negative); }

/* ============================================================
   News
   ============================================================ */
.news-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.news-search {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}
.news-filters select { min-width: 140px; }
.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.news-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition);
}
.news-card:hover { border-color: var(--text-muted); }
.news-card-image {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--surface-2);
}
.news-card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 12px 14px 14px;
}
.news-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.source-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--text-muted);
}
.news-date { font-size: 11px; color: var(--text-muted); }
.news-title { font-size: 14px; font-weight: 600; line-height: 1.35; margin-bottom: 6px; }
.news-title a { color: var(--text); text-decoration: none; }
.news-title a:hover { color: var(--accent-hover); text-decoration: underline; }
.news-snippet {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================================
   Documents / Accordion
   ============================================================ */
.accordion-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
}
.accordion-header {
  background: var(--surface);
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 14px;
  user-select: none;
}
.accordion-header:hover { background: var(--surface-2); }
.accordion-header .chevron { transition: transform var(--transition); color: var(--text-muted); }
.accordion-header.open .chevron { transform: rotate(90deg); }
.accordion-body { background: var(--surface-2); border-top: 1px solid var(--border); }
/* SEC filings' accordion bodies (Stocks tab) pad their own children (tables,
   tabs) instead so those can run edge-to-edge; Settings' accordion bodies
   want uniform padding around plain form rows, hence this opt-in modifier. */
.accordion-body.padded { padding: 16px; }

.filing-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); }
.filing-tab {
  background: transparent;
  border: none;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--text-muted);
}
.filing-tab:hover { color: var(--text); background: transparent; }
.filing-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Second-level tab row — the doc-type tabs (10-K/10-Q/...) nested inside
   the Documents tab of a stock's detail panel. Smaller and set against a
   recessed background so it reads as a sub-level, not a sibling, of the
   Historical Chart/Documents tabs above it. */
.filing-tabs.nested { background: var(--surface); padding: 0 8px; }
.filing-tabs.nested .filing-tab { font-size: 11px; padding: 7px 10px; }

/* Stock Watchlist row — accordion header doubling as the old table row, so
   its columns need to line up across every ticker the way table cells did. */
.stock-row-header { padding: 10px 16px; }
.stock-row-header .chevron { margin-left: 20px; }
.stock-row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1;
  gap: 16px;
  min-width: 0;
}
.stock-row-id { display: flex; align-items: baseline; gap: 8px; min-width: 0; overflow: hidden; }
.stock-row-id > .text-muted { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stock-row-ticker { font-weight: 700; flex: none; }
/* Portfolio holdings: % of the Holdings' market value */
.stock-row-id.has-weight { flex-wrap: wrap; row-gap: 4px; }
.holding-weight { flex-basis: 100%; display: flex; align-items: center; gap: 8px; font-size: 12px; font-variant-numeric: tabular-nums; }
.holding-weight-bar { flex: none; width: 90px; height: 6px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.holding-weight-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.holding-weight-pct { font-weight: 700; min-width: 42px; }
.holding-weight-value { color: var(--text-muted); }
.stock-row-metrics {
  display: grid;
  grid-template-columns: 76px 76px 64px 64px 80px;
  gap: 12px;
  align-items: center;
  flex: none;
}
.stock-row-num { text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 600; }
.stock-row-num > span { display: block; }
.stock-row-label { font-size: 10px; font-weight: 400; color: var(--text-muted); line-height: 1.2; }
.stock-row-sparkline { display: flex; justify-content: flex-end; width: 80px; flex: none; }

/* Portfolio page: 52-week range bar inside each card's header row */
.range52 {
  /* Fixed width, pushed against the price column, so bars line up row to row
     (long names truncate instead). Stacked: avg / "52W" + 52-wk high above
     the track, 52-wk low below it. */
  flex: 0 0 300px;
  margin-left: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 10px;
  line-height: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.range52-row { position: relative; height: 12px; }
.range52-row > span { position: absolute; top: 0; white-space: nowrap; }
.range52-caption { left: 0; color: var(--text); font-weight: 600; }
.range52-track { position: relative; height: 12px; }
.range52-track > span { position: absolute; top: 50%; transform: translateY(-50%); }
.range52-line { height: 2px; background: var(--text-muted); border-radius: 1px; opacity: 0.6; }
.range52-outside { height: 0; border-top: 1px dashed var(--text-muted); opacity: 0.6; }
.range52-band { height: 4px; border-radius: 2px; opacity: 0.35; }
.range52-band.gain, .range52-price.gain { background: var(--positive); }
.range52-band.loss, .range52-price.loss { background: var(--negative); }
.range52-price.neutral { background: var(--accent); }
.range52-tag { color: var(--text-muted); font-weight: 600; letter-spacing: 0.04em; }
.range52-avg { width: 2px; height: 12px; margin-left: -1px; background: var(--text); border-radius: 1px; }
.range52-price {
  width: 9px;
  height: 9px;
  margin-left: -4.5px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--surface); /* ring keeps it distinct where it overlaps the avg tick */
}

/* Tablet widths: no room for name + bar + all the columns in one row —
   name and numbers stay on top, the bar drops to its own line beneath. */
@media (min-width: 769px) and (max-width: 1000px) {
  .stock-row-main { flex-wrap: wrap; row-gap: 4px; }
  /* The name keeps room for itself, which pushes the bar onto the next line. */
  .stock-row-id { flex: 1 1 220px; min-width: 220px; }
  .range52 { order: 3; flex: 0 1 360px; margin-left: 0; }
}

/* Portfolio page: Holdings — one collapsible card. The header is its top
   row; each stock is a row inside, split by dividers instead of having its
   own border and gap, so the expanded list reads as part of the card. */
.holdings-card {
  margin: 4px 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.holdings-toggle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  width: 100%;
  margin: 0;
  padding: 12px 16px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}
.holdings-toggle:hover { background: var(--surface-2); }
.holdings-card .watchlist-item {
  margin: 0;
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0;
}
.holdings-chevron { font-size: 10px; color: var(--text-muted); transition: transform var(--transition); }
.holdings-toggle[aria-expanded="true"] .holdings-chevron { transform: rotate(90deg); }
.holdings-title { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.holdings-count {
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
}
.holdings-heading { display: inline-flex; align-items: baseline; gap: 8px; }
/* Totals in the header: label over value, like the stock rows' Last / Chg */
.holdings-stats { display: flex; flex-wrap: wrap; gap: 6px 24px; }
.holdings-stat { display: flex; flex-direction: column; align-items: flex-end; }
.holdings-stat-label { font-size: 10px; color: var(--text-muted); line-height: 1.3; }
.holdings-stat-value { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) {
  .holdings-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; gap: 8px 16px; }
  .holdings-stat { align-items: flex-start; }
}

/* Top movers card (Markets → Stocks, Portfolio page) */
.movers-card { margin-bottom: 16px; }
.movers-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.movers-lists { margin: -2px 0 12px; }
.movers-lists .note-chip:disabled { opacity: 1; cursor: default; }
.movers-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 28px; }
.movers-side-title { margin: 0 0 4px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.movers-list { list-style: none; margin: 0; padding: 0; }
.movers-row {
  display: grid;
  grid-template-columns: minmax(44px, max-content) minmax(0, 1fr) auto 64px;
  grid-template-areas: "sym name price pct" "bar bar bar bar";
  align-items: baseline;
  column-gap: 10px;
  row-gap: 3px;
  width: 100%;
  padding: 6px 4px;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 13px;
}
.movers-list li:last-child .movers-row { border-bottom: none; }
.movers-row:hover { background: var(--surface-2); }
.movers-sym { grid-area: sym; font-weight: 700; white-space: nowrap; }
.movers-name { grid-area: name; color: var(--text-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.movers-price { grid-area: price; font-variant-numeric: tabular-nums; }
.movers-pct { grid-area: pct; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.movers-bar { grid-area: bar; display: block; height: 3px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.movers-bar > span { display: block; height: 100%; border-radius: 2px; }
.movers-bar > .up { background: var(--positive); }
.movers-bar > .down { background: var(--negative); margin-left: auto; }
.movers-empty { margin: 6px 0 0; }
.movers-note { margin: 10px 0 0; }
@media (max-width: 600px) {
  .movers-cols { grid-template-columns: 1fr; }
}

/* Portfolio page: allocation donut + legend table */
.allocation-card { margin-bottom: 10px; }
.allocation-head { margin-bottom: 12px; }
/* Two panels side by side; each stacks its donut above its legend. */
.allocation-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px 32px; }
.allocation-panel { min-width: 0; }
.allocation-panel-title { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.allocation { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
.allocation-donut-wrap { position: relative; width: 180px; height: 180px; align-self: center; }
.allocation-donut { width: 180px; height: 180px; display: block; }
.allocation-slice { stroke: var(--surface); stroke-width: 2; stroke-linejoin: round; cursor: pointer; transition: opacity var(--transition); }
.allocation-slice.dim, .allocation-slice-label.dim { opacity: 0.35; }
.allocation-slice-label { font-size: 11px; font-weight: 700; pointer-events: none; font-variant-numeric: tabular-nums; }
/* HTML over the donut's hole so long names and holdings can wrap. */
.allocation-center {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 96px;
  height: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
  line-height: 1.25;
}
.allocation-center-label { color: var(--text-muted); font-size: 11px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.allocation-center-value { color: var(--text); font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.allocation-center-symbols {
  color: var(--text-muted);
  font-size: 10px;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* Two-column legend: ● Name  32%  $6.6K */
.allocation-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 12px;
  width: 100%;
  max-width: 400px;
  align-self: center;
  font-size: 12px;
}
.allocation-legend li {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 3px 4px;
  border-radius: 4px;
  cursor: pointer;
  transition: opacity var(--transition);
}
.allocation-legend li.dim { opacity: 0.45; }
.allocation-legend li.active { background: var(--surface-2); }
.allocation-swatch { flex: none; width: 9px; height: 9px; border-radius: 2px; align-self: center; }
.allocation-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.allocation-pct { font-weight: 700; font-variant-numeric: tabular-nums; }
.allocation-value { color: var(--text-muted); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
/* Phones: name + % only — tap an item for its exact $ value in the center. */
@media (max-width: 420px) {
  .allocation-value { display: none; }
}
.allocation-skeleton { width: 100%; height: 180px; }
.allocation-note { margin: 10px 0 0; }
.portfolio-auto { font-weight: 400; }
.link-button {
  border: none;
  background: none;
  padding: 0 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
}
.link-button:hover { text-decoration: underline; background: none; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


/* Portfolio tab in a stock's detail panel */
.portfolio { padding: 14px 16px 16px; }
.portfolio-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 16px; }
.portfolio-fields label { display: flex; flex-direction: column; gap: 4px; margin: 0; font-size: 12px; color: var(--text-muted); }
.portfolio-fields input { width: 100%; }
.portfolio-error { margin: 10px 0 0; }
.portfolio-actions { display: flex; gap: 8px; margin-top: 12px; }
.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  column-gap: 32px;
}
.portfolio-stat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.portfolio-label { color: var(--text-muted); white-space: nowrap; }
.portfolio-value { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.portfolio-note { margin: 10px 0 0; }
.purchase-preview { margin: 10px 0 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.purchase-cash-hint { margin: 6px 0 0; }
.tx-from { font-size: 11px; color: var(--text-muted); }
.sale-qty { display: flex; align-items: center; gap: 8px; }
.sale-qty input { flex: 1; min-width: 0; }
.sale-qty .link-button { padding: 0; }
/* Closed positions (Portfolio page) — shares the Holdings card look */
.closed-card { margin-top: 12px; }
.closed-list { list-style: none; margin: 0; padding: 0; }
.closed-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto auto;
  align-items: center;
  gap: 8px 24px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}
.closed-id { min-width: 0; }
.closed-name { margin-left: 6px; }
.closed-nums { display: grid; grid-template-columns: repeat(6, auto); gap: 4px 20px; }
.closed-actions { display: flex; gap: 12px; }
.closed-actions .link-button { padding: 0; }
@media (max-width: 900px) {
  .closed-row { grid-template-columns: 1fr auto; }
  .closed-nums { grid-column: 1 / -1; grid-row: 2; grid-template-columns: repeat(3, auto); justify-content: start; }
}
@media (max-width: 480px) {
  .closed-nums { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .closed-nums .stock-row-num { text-align: left; }
}
.transactions { margin-top: 16px; }
.transactions-title { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.transactions-table td, .transactions-table th { padding-left: 8px; padding-right: 8px; }
.transactions-table th:last-child, .transactions-table td:last-child { width: 1%; }
.transactions-table .link-button { padding: 0 4px; }
/* Keep every column on phones (data tables otherwise hide columns 4+ there). */
.transactions .data-table.transactions-table th, .transactions .data-table.transactions-table td { display: table-cell; }
.portfolio-actions .link-button { align-self: center; }
/* Phones: drop Amount (shares × price) so the sale columns and ✕ fit */
@media (max-width: 480px) {
  .transactions .data-table.transactions-table .tx-amount { display: none; }
  .transactions-table td, .transactions-table th { padding-left: 4px; padding-right: 4px; }
  .transactions-table td:first-child { white-space: nowrap; }
  .transactions-table .tx-from { white-space: normal; }
}

/* Watchlist picker, list actions, search (Markets → Stocks) */
.watchlist-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 10px;
}
.watchlist-picker { display: flex; align-items: center; gap: 10px; min-width: 0; }
.watchlist-picker select { max-width: 240px; }
.watchlist-name { font-weight: 600; }
.watchlist-actions { display: flex; align-items: center; gap: 6px; }
.watchlist-actions > button:not(.wl-icon-button) { padding: 5px 10px; font-size: 12px; }
.watchlist-form { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.watchlist-form input { flex: 1 1 200px; min-width: 0; }
.watchlist-form-error { flex-basis: 100%; margin: 0; }
.watchlist-search { position: relative; display: flex; gap: 6px; margin-bottom: 10px; }
.watchlist-search input { flex: 1; min-width: 0; }
.watchlist-search-close { flex: none; padding: 0 12px; }
/* The ✕ next to the box closes search; the browser's own clear-text ✕
   inside it would read as a second, different close button. */
.watchlist-search input::-webkit-search-cancel-button { display: none; }
.wl-menu { position: relative; }
.wl-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 32px;
  padding: 0;
  color: var(--text-muted);
}
.wl-icon-button:hover:not(:disabled), .wl-icon-button[aria-expanded="true"] { color: var(--text); background: var(--surface-2); }
.wl-icon-button.active { color: var(--accent); border-color: var(--accent); }
.wl-menu-panel { min-width: 230px; }
.user-menu-item:disabled { color: var(--text-muted); cursor: default; background: transparent; opacity: 1; }
.user-menu-item.danger-item { color: var(--negative); }
.watchlist-search-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 15;
  list-style: none;
  margin: 0;
  padding: 4px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.watchlist-search-status { padding: 8px 10px; color: var(--text-muted); font-size: 13px; }
.watchlist-search-result {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "sym name add" "sym meta add";
  column-gap: 10px;
  align-items: center;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.watchlist-search-result.active { background: var(--surface-2); }
.watchlist-search-result.added { cursor: default; }
.watchlist-search-symbol { grid-area: sym; font-weight: 700; min-width: 56px; }
.watchlist-search-name { grid-area: name; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watchlist-search-meta { grid-area: meta; font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watchlist-search-add { grid-area: add; font-size: 12px; font-weight: 600; color: var(--accent); white-space: nowrap; }
.watchlist-search-result.added .watchlist-search-add { color: var(--text-muted); font-weight: 400; }
.watchlist-remove {
  flex: none;
  margin-left: 12px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--negative);
  font-size: 12px;
  line-height: 1.2;
}
.watchlist-remove:hover { background: var(--negative); border-color: var(--negative); color: #fff; }
/* Edit mode: copy / move to another watchlist */
.watchlist-item { position: relative; }
.watchlist-item.transfer-open { overflow: visible; z-index: 30; }
.wl-select { flex: none; width: 18px; height: 18px; margin: 0 10px 0 0; cursor: pointer; }
.stock-row-header.selected { background: var(--surface-2); }
.watchlist-transfer {
  flex: none; margin-left: 12px; padding: 4px 9px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text); font-size: 14px; line-height: 1; cursor: pointer;
}
.watchlist-transfer:hover, .watchlist-transfer[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.watchlist-transfer + .watchlist-remove { margin-left: 6px; }
.wl-bulk-bar {
  position: sticky; top: 60px; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px 12px; margin-bottom: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.wl-bulk-all { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; cursor: pointer; }
.wl-bulk-all input { width: 18px; height: 18px; margin: 0; }
.wl-bulk-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.wl-bulk-actions button { padding: 5px 12px; }
.wl-transfer-backdrop { position: fixed; inset: 0; z-index: 40; cursor: default; }
.wl-transfer {
  position: absolute; right: 12px; top: calc(100% - 6px); z-index: 41; width: 270px; max-height: 60vh; overflow-y: auto;
  padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18); cursor: default; text-align: left;
}
.stock-row-header .wl-transfer { top: 48px; }
.wl-transfer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; font-size: 13px; }
.wl-transfer-head .link-button { padding: 0 4px; }
.wl-transfer-label { margin: 8px 0 2px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.wl-transfer-item {
  display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 8px;
  border: none; border-radius: 6px; background: none; color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer;
}
.wl-transfer-item:hover:not(:disabled) { background: var(--surface-2); }
.wl-transfer-item:disabled { color: var(--text-muted); cursor: default; }
.wl-transfer-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl-transfer-note { flex: none; font-size: 11px; color: var(--text-muted); }
.wl-transfer-new { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.wl-transfer-new .link-button { padding: 0; font-size: 13px; }
.wl-transfer-new input { width: 100%; }
.wl-transfer-new-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.wl-transfer-new-actions button { padding: 4px 10px; font-size: 12px; }
.wl-transfer-error { margin: 8px 0 0; }
.wl-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; display: flex; align-items: center; gap: 12px;
  max-width: calc(100vw - 32px); padding: 10px 14px; border-radius: var(--radius); background: var(--text); color: var(--bg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25); font-size: 13px;
}
.wl-toast .link-button { padding: 0; color: var(--bg); font-weight: 700; text-decoration: underline; }
@media (max-width: 600px) {
  /* The picker becomes a sheet from the bottom of the screen */
  .wl-transfer, .stock-row-header .wl-transfer {
    position: fixed; left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 70vh;
    border-radius: 14px 14px 0 0; padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  }
  .wl-transfer-backdrop { background: rgba(0, 0, 0, .35); }
  .wl-transfer-item { padding: 11px 8px; font-size: 15px; }
  .wl-bulk-bar { top: 56px; }
  /* Editing on a phone: checkbox, ⇄ and ✕ need the room the sparkline used */
  .watchlist.editing .stock-row-sparkline { display: none; }
  .watchlist.editing .stock-row-metrics { grid-template-columns: max-content repeat(2, minmax(0, 1fr)); }
}
.watchlist-item.just-added { border-color: var(--accent); transition: border-color 0.6s; }

/* Watchlist reordering — drag handle + the card being dragged */
.drag-handle {
  flex: none;
  margin: -4px 10px -4px -8px;
  padding: 4px 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: grab;
  touch-action: none; /* let pointer events drive the drag on touch screens */
}
.drag-handle:hover { background: var(--border); color: var(--text); }
/* Touch screens: a ~44px hit area (Apple/Google's minimum touch target);
   the negative margins keep the row from growing to fit it. Also no
   text-selection callout when long-pressing a card to pick it up. */
@media (pointer: coarse) {
  .drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    margin: -10px 2px -10px -12px;
    font-size: 20px;
  }
  .drag-handle:hover { background: transparent; color: var(--text-muted); }
  .stock-row-header { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
}
.drag-handle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.watchlist.is-dragging { user-select: none; }
.watchlist.is-dragging, .watchlist.is-dragging * { cursor: grabbing !important; }
.watchlist-item.dragging {
  position: relative;
  z-index: 1;
  border-color: var(--accent);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.watchlist-item.dragging .accordion-header { background: var(--surface-2); }

/* ============================================================
   Sparkline SVG
   ============================================================ */
.sparkline { display: block; }

/* ============================================================
   Crack Spread Card
   ============================================================ */
.crack-spread-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
}
.crack-spread-card .crack-value { font-size: 28px; font-weight: 700; }
.crack-spread-card .crack-formula { font-size: 11px; color: var(--text-muted); margin-top: 6px; }
.crack-value-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.crack-indicator-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.crack-indicator-dot.tier-modest { background: var(--text-muted); }
.crack-indicator-dot.tier-healthy { background: var(--positive); }
.crack-indicator-dot.tier-very-strong { background: var(--warning); }
.crack-indicator-dot.tier-extremely-strong { background: var(--negative); }
.crack-tier-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.crack-tier-label.tier-modest { color: var(--text-muted); }
.crack-tier-label.tier-healthy { color: var(--positive); }
.crack-tier-label.tier-very-strong { color: var(--warning); }
.crack-tier-label.tier-extremely-strong { color: var(--negative); }

/* ============================================================
   Historical Price Chart
   ============================================================ */
.chart-filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.range-btn-group { display: flex; flex-wrap: wrap; gap: 4px; }
.range-btn {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
}
.range-btn:hover { background: var(--border); }
.range-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.history-chart-wrap { position: relative; }
.history-chart-svg {
  width: 100%;
  height: auto;
  display: block;
  /* Touch: a sideways drag scrubs the crosshair (pointer events), an up/down
     swipe still scrolls the page — the browser then sends pointercancel. */
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.chart-gridline { stroke: var(--border); stroke-width: 1; }
.chart-axis-label { fill: var(--text-muted); font-size: 10px; }
.chart-line { stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-baseline { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 4 4; opacity: 0.7; }
.chart-end-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart-crosshair { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-hover-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart-corner-label {
  position: absolute;
  top: 6px;
  left: 6px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  pointer-events: none;
}
.chart-corner-value { font-size: 14px; font-weight: 700; color: var(--text); }
.chart-corner-change { font-size: 12px; font-weight: 600; }

/* Two-line spread chart — Index A / Index B price lines with the gap
   between them filled, colored by which line is on top at each point */
.chart-line-a { stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-line-b { stroke: var(--warning); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-area-positive { fill: var(--positive-fill); }
.chart-area-negative { fill: var(--negative-fill); }
.chart-legend { display: flex; gap: 16px; margin-bottom: 10px; font-size: 12px; color: var(--text-muted); }
.chart-legend .legend-item { display: flex; align-items: center; gap: 6px; }
.chart-legend .legend-swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.chart-tooltip {
  position: absolute;
  top: 4px;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 10px;
  pointer-events: none;
  white-space: nowrap;
}
.chart-tooltip-value { font-size: 13px; font-weight: 700; color: var(--text); }
.chart-tooltip-date { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.chart-tooltip-row { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-muted); }
.chart-tooltip-row .legend-swatch { width: 8px; height: 8px; border-radius: 2px; display: inline-block; flex: none; }

/* ============================================================
   Utility
   ============================================================ */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
  /* Logo on its own row; tabs scroll sideways instead of overflowing. */
  /* One row: logo, tabs, account menu (theme switch moves into the menu —
     see the media query after the .user-menu rules). */
  .app-header { padding: 0 12px; }
  .tab-bar { overflow-x: auto; scrollbar-width: none; }
  .tab-btn { padding: 14px 10px 12px; font-size: 12px; white-space: nowrap; flex-shrink: 0; }
  .tab-content { padding: 16px 12px; }
  .app-footer { padding: 12px; }
  .price-grid { grid-template-columns: repeat(2, 1fr); }
  .spread-widget { flex-direction: column; align-items: flex-start; }
  .data-table th:nth-child(n+4),
  .data-table td:nth-child(n+4) { display: none; }

  /* Stock Watchlist: the fixed-width metric columns don't fit beside the
     ticker on a phone, so stack name above metrics, let the columns flex,
     and drop volume. Tab rows scroll sideways rather than clip. */
  .stock-row-header { padding: 10px 12px; }
  .stock-row-main { flex-direction: column; align-items: stretch; gap: 6px; }
  .range52 { flex: none; margin-left: 0; }
  /* Price column sizes to its content so a large price ($86,030.47) can't run into Chg. */
  .stock-row-metrics { grid-template-columns: max-content repeat(2, minmax(0, 1fr)) 80px; gap: 8px; }
  .stock-row-vol { display: none; }
  .stock-row-header .chevron { margin-left: 14px; }
  .filing-tabs, .subtab-bar { overflow-x: auto; scrollbar-width: none; }
  .filing-tab, .subtab-btn { white-space: nowrap; flex-shrink: 0; }
}

@media (max-width: 480px) {
  .price-grid { grid-template-columns: 1fr 1fr; }
  /* Markets sub-tabs: short labels sharing the full width, no scrolling. */
  .subtab-bar-fit { gap: 0; }
  .subtab-bar-fit .subtab-btn { flex: 1 1 0; padding: 10px 4px; text-align: center; }
  .subtab-bar-fit .label-full { display: none; }
  .subtab-bar-fit .label-short { display: inline; }
  /* Chart range buttons (1D…5Y): one full-width row of equal buttons
     instead of wrapping the last one onto a line of its own. */
  .chart-filters { width: 100%; }
  .range-btn-group { flex-wrap: nowrap; width: 100%; gap: 3px; }
  .range-btn { flex: 1 1 0; min-width: 0; padding: 5px 0; text-align: center; }
  .app-header .logo { font-size: 13px; }
  /* Room for the tabs + the account menu on one row. */
  .app-header .logo-accent { display: none; }
}
/* Narrow phones: the drop icon stands in for the name, so up to four tabs
   (Account · Inbox · 🏆) fit beside the account menu. */
@media (max-width: 420px) {
  .app-header .logo-text { display: none; }
  .app-header .logo-icon { display: block; }
  .tab-btn { padding-left: 8px; padding-right: 8px; }
}
@media (max-width: 360px) {
  .range-btn-group { gap: 2px; }
  .range-btn { font-size: 11px; }
  .tab-btn { padding-left: 4px; padding-right: 4px; font-size: 11.5px; }
  .tab-btn .count-badge { min-width: 15px; height: 15px; padding: 0 4px; margin-left: 3px; font-size: 10px; line-height: 15px; }
}

/* ============================================================
   Account (sign in / register / profile)
   ============================================================ */
.account-page { max-width: 480px; margin: 0 auto; }
.account-page.signed-in { max-width: 860px; }
/* Signed-in profile: side navigation + section content */
.profile-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; align-items: start; }
.profile-nav { position: sticky; top: 109px; /* under the header + subheader */ display: flex; flex-direction: column; gap: 2px; }
.profile-nav-user { padding: 4px 10px 12px; margin-bottom: 6px; border-bottom: 1px solid var(--border); min-width: 0; }
.profile-nav-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-nav-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  text-align: left;
}
.profile-nav-item:hover { background: var(--surface-2); color: var(--text); }
.profile-nav-item.active { background: var(--surface-2); color: var(--accent); font-weight: 600; }
.profile-nav-icon { width: 18px; text-align: center; }
.profile-content { min-width: 0; }
/* Phones: the side nav becomes a tab row above the section. */
@media (max-width: 700px) {
  .profile-layout { grid-template-columns: 1fr; gap: 14px; }
  .profile-nav { position: static; flex-direction: row; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
  .profile-nav-user { display: none; }
  .profile-nav-item { width: auto; flex: none; border-radius: 0; border-bottom: 2px solid transparent; padding: 10px 12px; }
  .profile-nav-item.active { background: transparent; border-bottom-color: var(--accent); }
}
/* Profile → Labels */
/* Label color dot (filters, note form) */
.label-dot { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; vertical-align: 0; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12); }
.note-chip.selected .label-dot { box-shadow: 0 0 0 1.5px #fff; }

/* Modal dialog (label editor) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh 16px 16px;
  overflow-y: auto;
}
.modal {
  width: min(460px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-close { border: none; background: transparent; color: var(--text-muted); padding: 4px 6px; font-size: 14px; }
.modal-close:hover { color: var(--text); background: var(--surface-2); }
.modal-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.modal-field { display: flex; flex-direction: column; gap: 6px; margin: 0; font-size: 13px; font-weight: 600; color: var(--text); }
.modal-field input, .modal-field textarea { width: 100%; font-weight: 400; }
.modal-field textarea { resize: vertical; min-height: 72px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 16px 16px; }
.modal-kbd { margin-left: 8px; padding: 0 5px; border-radius: 4px; background: rgba(255, 255, 255, 0.2); font-family: var(--font); font-size: 11px; }
.label-preview { display: flex; justify-content: center; align-items: center; min-height: 56px; border-radius: 8px; background: var(--surface-2); }
.label-chip-lg { padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; max-width: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.label-color-row { display: flex; align-items: center; gap: 8px; }
.label-color-cycle { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 32px; padding: 0; border: none; border-radius: 6px; }
.label-color-cycle:hover { filter: brightness(1.08); }
.label-color-input { width: 180px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.label-color-input.valid { border-color: var(--positive); }
.label-color-input.invalid { border-color: var(--negative); }

.labels-head { gap: 12px; }
.labels-head button { padding: 5px 12px; }
.labels-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.labels-description { font-size: 13px; overflow-wrap: anywhere; }
.labels-add { display: flex; gap: 8px; }
.labels-add input { flex: 1; min-width: 0; }
.labels-list { list-style: none; margin: 14px 0 0; padding: 0; }
.labels-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 9px 0; border-top: 1px solid var(--border); }
.labels-name { font-size: 12px; }
.labels-usage { flex: 1; }
.labels-actions { display: flex; gap: 14px; }
.labels-actions .link-button { padding: 0; }
.labels-rename { display: flex; gap: 8px; flex: 1; }
.labels-rename input { flex: 1; min-width: 0; }
.labels-row-error { flex-basis: 100%; margin: 4px 0 0; }
.account-card { padding: 20px; }
.account-form { display: flex; flex-direction: column; gap: 14px; }
.account-form input { width: 100%; }
.account-form input:disabled { opacity: 0.6; cursor: not-allowed; }
.account-form button[type="submit"] { align-self: flex-start; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Header light/dark/system switch */
.theme-switch {
  display: inline-flex;
  flex-shrink: 0;
  margin-left: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.theme-switch button {
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 3px 9px;
  font-size: 13px;
  line-height: 1.4;
}
.theme-switch button + button { border-left: 1px solid var(--border); }
.theme-switch button:hover { background: var(--surface-2); color: var(--text); }
.theme-switch button[aria-pressed="true"] { background: var(--surface-2); color: var(--accent); }

/* Header account menu (components/UserMenu.js) — Profile / Sign in,
   Settings, Sign out; plus the theme switch on phones. */
.user-menu { position: relative; flex-shrink: 0; margin-left: 12px; }
.user-menu-button {
  /* Just a circle: the profile picture (signed in) or a person icon. */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  overflow: hidden;
  background: transparent;
  color: var(--text-muted);
  line-height: 1;
}
.user-menu-button:hover,
.user-menu-button[aria-expanded="true"] { background: var(--surface-2); color: var(--text); }
.user-menu-button.active { border-color: var(--accent); color: var(--accent); }
/* Signed in: the picture fills the circle; hover / open / current page show as a ring. */
.user-menu-button.signed-in { border: none; }
.user-menu-button.signed-in:hover,
.user-menu-button.signed-in[aria-expanded="true"] { background: transparent; box-shadow: 0 0 0 2px var(--border); }
.user-menu-button.signed-in.active { box-shadow: 0 0 0 2px var(--accent); }
.user-menu-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.user-menu-icon { display: block; margin: 2px; }
.user-menu-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  max-width: calc(100vw - 24px);
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 20;
}
.user-menu-identity { padding: 6px 10px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.user-menu-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-identity .text-sm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
}
.user-menu-item:hover, .user-menu-item:focus-visible { background: var(--surface-2); outline: none; }
.user-menu-item.current { color: var(--accent); }
.user-menu-sep { height: 1px; background: var(--border); margin: 4px 0; }
.user-menu-label { padding: 4px 10px 6px; font-size: 11px; color: var(--text-muted); }
@media (max-width: 768px) {
  .user-menu { margin-left: 8px; }
}


/* ============================================================
   Article popup viewer (News / Economic Indicators news cards)
   ============================================================ */
.article-viewer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}
.article-viewer {
  width: min(1100px, 100%);
  height: 100%;
  max-height: 900px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.article-viewer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  border-bottom: 1px solid var(--border);
}
.article-viewer-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.article-viewer-heading { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.article-viewer-host { flex: none; }
.article-viewer-body { position: relative; flex: 1; background: #fff; }
.article-viewer-body iframe { width: 100%; height: 100%; border: 0; display: block; }
.article-viewer-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  pointer-events: none;
}
.article-viewer-blocked {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  background: var(--surface-2);
}
.article-viewer-blocked-title { font-size: 16px; font-weight: 600; }

/* An <a> styled like the app's buttons */
.button-link {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  padding: 5px 12px;
  white-space: nowrap;
}
.button-link:hover { background: var(--border); color: var(--text); text-decoration: none; }
.button-link.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button-link.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }

@media (max-width: 768px) {
  .article-viewer-backdrop { padding: 0; }
  .article-viewer { max-height: none; border-radius: 0; border: none; }
  .article-viewer-host { display: none; }
}

.article-viewer-hint {
  padding: 6px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--warning-bg);
  color: var(--text-muted);
}

/* ============================================================
   Stock Key Statistics (under the historical chart)
   ============================================================ */
.key-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  column-gap: 24px;
  padding: 4px 16px 16px;
}
.key-stat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.key-stat-label { color: var(--text-muted); white-space: nowrap; }
.key-stat-value { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.key-stat-skeleton { width: 48px; height: 12px; }

/* ============================================================
   Stock News (per-ticker tab in the watchlist card)
   ============================================================ */
.stock-news { padding: 4px 16px 8px; }
.stock-news-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.stock-news-item:last-child { border-bottom: none; }
.stock-news-thumb {
  width: 56px;
  height: 56px;
  flex: none;
  object-fit: cover;
  border-radius: 6px;
  background: var(--surface);
}
.stock-news-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.stock-news-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.stock-news-meta .link-button { padding: 0; font-size: 12px; }
.note-saved { color: var(--positive); }
.icon-bookmark { vertical-align: -2px; margin-right: 4px; }

/* Note form (save from News / edit on Notes) */
.note-form {
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.note-form-heading { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.note-form-labels { display: flex; flex-direction: column; gap: 6px; }
.note-form textarea { display: block; width: 100%; margin-top: 4px; resize: vertical; min-height: 64px; font-weight: 400; }
.note-form-error { margin: 0; }
.note-form-actions { display: flex; gap: 8px; }
.note-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.note-chip {
  padding: 3px 10px;
  font-size: 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
}
.note-chip:hover:not(:disabled) { color: var(--text); }
.note-chip.selected { background: var(--accent); border-color: var(--accent); color: #fff; }
.note-chip:disabled { opacity: 0.45; cursor: default; }
.note-new-label { flex: 1 1 140px; min-width: 120px; padding: 3px 10px; border-radius: 999px; font-size: 12px; }
.note-chip-count { opacity: 0.7; margin-left: 2px; font-variant-numeric: tabular-nums; }

/* Notes page */
.notes-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.notes-filters input[type="search"] { flex: 1 1 200px; min-width: 0; }
.notes-label-filter { margin-bottom: 14px; }
.note-card { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.note-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.note-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.note-symbol {
  font-weight: 700;
  font-size: 12px;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.note-saved-at { margin-left: auto; }
.notes-head-right { display: flex; align-items: center; gap: 12px; }

/* Stock card 🔔 tab + alerts panel */
.alerts-tab { display: inline-flex; align-items: center; gap: 5px; }
.icon-bell { flex: none; }
.alerts-tab-count {
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 10px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
}
.alerts-tab.active .alerts-tab-count { border-color: var(--accent); color: var(--accent); }
@media (max-width: 480px) {
  .alerts-tab-text { display: none; }  /* phones: just the bell (+ count) */
  /* Stock detail tabs (Charts · News · Docs · Portfolio · 🔔) fit one row. */
  .accordion-body > .filing-tabs .filing-tab { padding-left: 9px; padding-right: 9px; }
  .accordion-body > .filing-tabs .label-full { display: none; }
  .accordion-body > .filing-tabs .label-short { display: inline; }
}
.alerts-panel { padding: 12px 16px 14px; }
.alert-presets { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
.alert-presets-label { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-right: 2px; }
.alert-custom { border-style: dashed; }
.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-item { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); }
.alert-item.inactive .alert-item-title { color: var(--text-muted); }
.alert-dot { flex: none; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; }
.alert-dot.on { background: var(--positive); }
.alert-dot.off { background: var(--text-muted); opacity: 0.5; }
.alert-item-body { flex: 1; min-width: 0; }
.alert-item-title { font-weight: 600; font-size: 13px; }
.alert-item-note { font-size: 12px; color: var(--text-muted); font-style: italic; overflow-wrap: anywhere; }
.alert-item-actions { flex: none; display: flex; gap: 12px; }
.alert-item-actions .link-button { padding: 0; }
/* Options (stock card → Portfolio tab; Portfolio page) */
.options-section { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.options-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.options-head button { padding: 5px 12px; }
.option-form { margin-bottom: 12px; }
.option-toggles { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 10px; }
.option-check { margin: 10px 0 0; font-size: 13px; color: var(--text-muted); }
.option-check.ok { color: var(--positive); }
.option-check.missing { color: var(--negative); }
.option-empty { margin: 0; }
.option-list { list-style: none; margin: 0; padding: 0; }
.option-item { border-top: 1px solid var(--border); padding: 10px 0; }
.option-item:first-child { border-top: none; }
.option-row { display: grid; grid-template-columns: minmax(180px, 1fr) auto auto; align-items: center; gap: 8px 20px; }
.option-id { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.option-name { font-weight: 700; font-size: 14px; }
.option-side, .option-money, .option-days {
  font-size: 11px; font-weight: 700; line-height: 16px; padding: 1px 7px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text-muted); background: var(--surface-2); white-space: nowrap;
}
.option-side.long { color: var(--positive); border-color: currentColor; background: transparent; }
.option-side.short { color: var(--negative); border-color: currentColor; background: transparent; }
.option-money.itm { color: var(--text); }
.option-days.soon { color: var(--warning); background: var(--warning-bg); border-color: transparent; }
.option-days.expired { color: var(--negative); background: var(--negative-bg); border-color: transparent; }
.option-nums { display: grid; grid-template-columns: repeat(5, auto); gap: 4px 18px; }
.option-actions { display: flex; align-items: center; gap: 12px; }
.option-actions .link-button { padding: 0; white-space: nowrap; }
.option-sub { margin: 4px 0 0; }
.option-close, .option-panel { margin-top: 10px; padding: 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.option-panel.transactions { padding: 4px 8px; }
.closed-id .option-side { margin-right: 6px; }
.option-cover { margin: 12px 0 0; padding: 10px 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.option-cover-check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; cursor: pointer; }
.option-cover-check input { width: auto; margin: 0; }
.option-cover-detail { margin: 6px 0 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.option-cover-fields { margin-top: 8px; }
.warning-text { color: var(--warning); }
.option-cover-badge { font-size: 11px; font-weight: 700; line-height: 16px; padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.option-cover-badge.cash, .option-cover-badge.shares { color: var(--accent); background: var(--surface-2); border: 1px solid currentColor; }
.option-cover-badge.naked { color: var(--warning); background: var(--warning-bg); }
.cash-reserve-line { margin: -4px 16px 10px; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Stock card → Summary tab */
.summary-panel { padding: 14px 16px 16px; }
.company-name { margin: 0 0 6px; font-size: 15px; }
.company-summary { margin: 0; font-size: 14px; line-height: 1.55; max-width: 80ch; }
.company-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px 20px; margin: 14px 0 0; }
.company-facts dt { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.company-facts dd { margin: 2px 0 0; font-size: 13px; font-weight: 600; }
.company-sources { margin: 10px 0 0; }
.perf-section { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.perf-title { margin: 0 0 6px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.perf-table { max-width: 640px; }
.perf-table td, .perf-table th { padding-left: 8px; padding-right: 8px; }
/* Keep every column on phones (data tables otherwise hide columns 4+) */
.summary-panel .data-table.perf-table th, .summary-panel .data-table.perf-table td { display: table-cell; }
.perf-note { margin: 8px 0 0; }
.perf-table td.num, .perf-table th { white-space: nowrap; }
.perf-short { display: none; }
@media (max-width: 480px) {
  .summary-panel { padding: 12px; }
  .perf-table td, .perf-table th { padding-left: 4px; padding-right: 4px; font-size: 12px; }
  .perf-table th { letter-spacing: 0; }
  .perf-long { display: none; }
  .perf-short { display: inline; }
}

/* Earnings badge (stock card) and Summary → Upcoming events */
.earnings-badge {
  font-size: 11px; font-weight: 700; line-height: 16px; padding: 1px 7px; margin: 0 6px 0 2px; border-radius: 999px;
  color: var(--accent); border: 1px solid currentColor; white-space: nowrap; vertical-align: 1px;
}
.earnings-badge.estimated { border-style: dashed; }
.events-section { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.events-list { list-style: none; margin: 0; padding: 0; max-width: 760px; }
.event-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto 80px; align-items: baseline; gap: 4px 14px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.event-row:last-child { border-bottom: none; }
.event-date { font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.event-what { display: flex; flex-direction: column; min-width: 0; }
.event-title { font-weight: 600; font-size: 13px; }
.event-detail { font-size: 12px; }
.event-tag { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.event-tag.estimated { border-style: dashed; color: var(--text-muted); }
.event-days { text-align: right; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.event-days.soon { color: var(--warning); font-weight: 700; }
.events-note { margin: 8px 0 0; }
@media (max-width: 480px) {
  .event-row { grid-template-columns: auto 1fr auto; }
  .event-what { grid-column: 1 / -1; grid-row: 2; }
  .event-tag { justify-self: end; }
}

/* Account → Summary: cash and deposits */
.cash-card { margin-bottom: 12px; }
.acct-head { margin-bottom: 6px; }
.acct-sub { font-weight: 500; font-size: 13px; }
.acct-main { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 20px; }
.acct-main .pf-card-stats { font-size: 14px; }
.acct-breakdown { margin: 6px 0 0; font-variant-numeric: tabular-nums; }
.acct-cash { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.acct-cash .cash-balance { font-size: 18px; }
.cash-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px; }
.cash-balance { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.deposit-form { margin-top: 12px; }
.deposit-list { list-style: none; margin: 12px 0 0; padding: 0; }
.deposit-row { display: grid; grid-template-columns: 100px minmax(0, 1fr) auto auto; align-items: baseline; gap: 4px 12px; padding: 7px 0; border-top: 1px solid var(--border); font-size: 13px; }
.deposit-date { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.deposit-amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.deposit-row .link-button { padding: 0 4px; }
.deposit-more { margin-top: 6px; padding: 0; font-size: 13px; }
.cash-note { margin: 10px 0 0; }
@media (max-width: 480px) {
  .deposit-row { grid-template-columns: 1fr auto auto; }
  .deposit-date { grid-column: 1 / -1; font-size: 12px; }
}

/* Account → Portfolios: cards, an opened portfolio, its chart */
.pf-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 16px; }
.pf-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin: 0; padding: 16px; text-align: left;
  font: inherit; color: var(--text); cursor: pointer; transition: border-color var(--transition), box-shadow var(--transition);
}
button.pf-card:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgba(0, 0, 0, .08); }
.pf-card-name { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.pf-card-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.pf-card-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pf-card-stats { display: flex; gap: 16px; font-size: 13px; font-variant-numeric: tabular-nums; margin: 2px 0; }
.pf-card-new { justify-content: center; align-items: stretch; border-style: dashed; cursor: default; }
.pf-card-new-btn { border: none; background: none; color: var(--accent); font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; padding: 18px 0; }
.pf-card-new input { width: 100%; }
.pf-card-id { font-size: 11px; font-weight: 600; color: var(--text-muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; vertical-align: 2px; }
.pf-id-field { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--text-muted); font-weight: 600; }
.pf-id-field input { flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.pf-id-hint { display: block; margin-top: 4px; }
.pf-card-new-actions { display: flex; gap: 8px; margin-top: 8px; }
.pf-card-new-actions button { padding: 5px 12px; }
.pf-cards-note { grid-column: 1 / -1; margin: 0; }
.pf-detail-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 12px; }
.pf-detail-head .link-button { padding: 0; }
.pf-detail-name { margin: 0; font-size: 18px; }
.pf-detail-actions { display: flex; gap: 12px; margin-left: auto; }
.pf-rename { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pf-rename button { padding: 5px 12px; }
.pf-chart-card { margin-bottom: 12px; }
.pf-chart-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px; }
.pf-chart-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pf-chart-ranges { flex-wrap: nowrap; }
.pf-chart-note { margin: 8px 0 0; }
/* An opened portfolio's overview card: Performance · Holdings · Sectors */
.pf-overview { margin-bottom: 12px; }
.pf-overview-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 12px; }
.pf-overview-tabs { margin: 0; flex: 1; min-width: 0; }
.pf-overview-mode { flex-wrap: nowrap; }
.pf-overview-mode .range-btn { min-width: 38px; }
.pf-chart-embedded .pf-chart-head { margin-top: 2px; }
.hbar-caption { font-size: 13px; margin: 6px 0 8px; min-height: 18px; font-variant-numeric: tabular-nums; }
/* One 100% stacked bar: 2px surface gaps between segments, rounded ends */
.hbar { display: flex; gap: 2px; height: 36px; border-radius: 6px; overflow: hidden; background: var(--surface); }
.hbar-seg { display: flex; align-items: center; justify-content: center; min-width: 3px; flex-basis: 0; cursor: pointer; transition: opacity var(--transition); overflow: hidden; }
.hbar-seg.dim { opacity: .35; }
.hbar-label { font-size: 11px; font-weight: 700; white-space: nowrap; padding: 0 4px; font-variant-numeric: tabular-nums; }
.hlist { list-style: none; margin: 14px 0 0; padding: 0; }
.hlist-row { display: grid; grid-template-columns: 10px 20px minmax(0, 1fr) 120px 90px 90px; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--border); font-size: 13px; transition: opacity var(--transition); }
.hlist-row.dim { opacity: .45; }
.hlist-swatch { width: 10px; height: 10px; border-radius: 3px; }
.hlist-rank { color: var(--text-muted); font-variant-numeric: tabular-nums; text-align: right; }
.hlist-id { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hlist-minibar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.hlist-minibar > span { display: block; height: 100%; border-radius: 3px; }
.hlist-main { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.hlist-second { text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; }
.hlist-note { margin: 10px 0 0; }
.pf-sectors-view .allocation { margin-top: 4px; }
@media (max-width: 600px) {
  .hlist-minibar { display: none; }
  .hlist-second { display: none; }
  .hlist-row { grid-template-columns: 10px 18px minmax(0, 1fr) auto; }
  /* Narrow bar: only segments with room keep a label (the list below names them all) */
  .hbar-seg:not(.wide) .hbar-label { display: none; }
  .pf-overview-tabs { flex-basis: 100%; }
  .pf-overview-tabs .subtab-btn { padding-left: 10px; padding-right: 10px; }
  .pf-overview-tabs .label-full { display: none; }
  .pf-overview-tabs .label-short { display: inline; }
  .pf-overview-mode { width: auto; margin-left: auto; }
  .pf-overview-mode .range-btn { flex: none; min-width: 44px; padding: 5px 12px; }
}

/* Portfolio visibility */
.pf-visibility { display: flex; gap: 14px; margin-top: 8px; font-size: 13px; }
.pf-visibility label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.pf-visibility input { width: auto; margin: 0; }
.pf-visibility-note { flex-basis: 100%; }
.pf-vis-badge { font-size: 11px; font-weight: 600; color: var(--text-muted); vertical-align: 2px; }
.pf-vis-badge.public { color: var(--accent); }
/* Account → Leaderboard */
@media (max-width: 480px) {
  .tab-btn .label-full { display: none; }
  .tab-btn .label-short { display: inline; }
  .account-tabs .label-full { display: none; }
  .account-tabs .label-short { display: inline; }
  /* Four sub-tabs (Summary · Watchlist · Portfolios · Transactions) share the row. */
  .account-tabs { gap: 0; }
  .account-tabs .subtab-btn { flex: 1 1 auto; padding-left: 4px; padding-right: 4px; }
  .account-tabs { overflow-x: auto; scrollbar-width: none; } /* the narrowest phones: scroll rather than overflow */
}
.lb-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px; }
.lb-periods { flex-wrap: nowrap; }
.lb-join { margin: 12px 0 0; }
.lb-list { list-style: none; margin: 12px 0 0; padding: 0; transition: opacity var(--transition); }
.lb-list.busy { opacity: .55; }
.lb-row { display: grid; grid-template-columns: 30px 52px 36px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 9px 8px; border-top: 1px solid var(--border); }
.lb-row.mine { background: var(--surface-2); border-radius: 8px; }
.lb-rank { font-weight: 800; font-size: 15px; text-align: right; font-variant-numeric: tabular-nums; }
.lb-row.podium .lb-rank { color: var(--accent); }
.lb-move { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lb-move.up { color: var(--positive); }
.lb-move.down { color: var(--negative); }
.lb-move.same { color: var(--text-muted); }
.lb-move.new { color: var(--accent); font-size: 10px; letter-spacing: .04em; }
.lb-thumb { width: 36px; height: 36px; margin: 0; font-size: 13px; }
.lb-names { display: flex; flex-direction: column; min-width: 0; }
.lb-portfolio { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-owner { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-you { margin-left: 6px; font-size: 10px; font-weight: 700; color: var(--accent); border: 1px solid currentColor; border-radius: 999px; padding: 0 6px; vertical-align: 1px; }
.lb-return { font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums; text-align: right; }
.lb-note { margin: 12px 0 0; }
@media (max-width: 480px) {
  .lb-periods { width: 100%; }
  .lb-periods .range-btn:last-child { flex: 1.8 1 0; }
  .lb-row { grid-template-columns: 22px 40px 30px minmax(0, 1fr) auto; gap: 8px; padding: 9px 4px; }
  .lb-thumb { width: 32px; height: 32px; font-size: 12px; }
}

/* Markets → a stock's Portfolio tab: which portfolio */
.pf-choice { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 14px; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.pf-choice-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-muted); font-weight: 600; }
.pf-choice-field select, .pf-choice-field input { min-width: 180px; }
.pf-choice-hint { padding-bottom: 6px; }
/* Activity: portfolio filter and tag */
.activity-filters { display: flex; flex-wrap: wrap; gap: 8px; flex: 0 1 auto; }
.activity-portfolio { font-size: 11px; color: var(--text-muted); border: 1px solid var(--border); border-radius: 999px; padding: 0 6px; }
@media (max-width: 480px) {
  .pf-cards { grid-template-columns: 1fr; }
  .pf-chart-ranges { width: 100%; }
  .pf-chart-ranges .range-btn:last-child { flex: 1.7 1 0; }
  .pf-choice-field, .pf-choice-field select, .pf-choice-field input { width: 100%; min-width: 0; }
}

/* Portfolio page: sorting Holdings and Options */
.sort-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.sort-bar-inset { padding: 10px 0 2px; border-bottom: none; background: none; }
.sort-bar-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-right: 2px; }
.sort-chip {
  padding: 3px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2);
  color: var(--text-muted); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.sort-chip:hover { color: var(--text); }
.sort-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.sort-dir { margin-left: 4px; }
.option-list-flat { margin-top: 8px; }
@media (max-width: 600px) {
  /* One scrollable row of chips rather than three wrapped ones */
  .sort-bar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-left: 12px; padding-right: 12px; }
  .sort-bar-inset { padding-left: 0; padding-right: 0; }
}

/* Portfolio page: net value line and the Options card */
.portfolio-net { margin: 0 0 10px; font-size: 14px; font-variant-numeric: tabular-nums; }
.options-card { margin-top: 12px; }
.options-body { padding: 4px 16px 12px; border-top: 1px solid var(--border); }
.options-add-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0 4px; }
.options-add-bar input { width: 150px; text-transform: uppercase; }
.options-add-bar button { padding: 5px 12px; }
.options-add-title { font-weight: 600; font-size: 13px; margin: 12px 0 8px; }
.option-group { margin-top: 12px; }
.option-group-head { margin: 0 0 2px; padding: 6px 0; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); }
.option-group-head span { font-weight: 600; color: var(--text-muted); text-transform: none; letter-spacing: 0; }
.option-group-head.soon span { color: var(--warning); }
.option-group-head.expired span { color: var(--negative); }
.option-underlying { font-weight: 800; font-size: 14px; }
@media (max-width: 900px) {
  .option-row { grid-template-columns: 1fr auto; }
  .option-nums { grid-column: 1 / -1; grid-row: 2; grid-template-columns: repeat(5, auto); justify-content: start; }
}
@media (max-width: 480px) {
  .option-row { grid-template-columns: 1fr; }
  .option-nums { grid-column: auto; grid-row: auto; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .option-nums .stock-row-num { text-align: left; }
  .option-actions { flex-wrap: wrap; }
  .option-close, .option-panel { padding: 10px 8px; }
  .option-panel.transactions { padding: 2px 0; }
}

/* Portfolio → Activity */
.activity-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.activity-search { flex: 0 1 260px; min-width: 0; }
.activity-empty { margin: 14px 0 0; }
.activity-totals { margin: 12px 0 0; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.activity-totals strong { font-weight: 700; }
.activity-month { margin-top: 14px; }
.activity-month-head { margin: 0; padding: 6px 0; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) 120px 110px; align-items: center; gap: 4px 16px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.activity-row:last-child { border-bottom: none; }
.activity-date { font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.activity-what { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; min-width: 0; }
.activity-action { font-size: 11px; font-weight: 700; line-height: 16px; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.activity-action.in { color: var(--positive); border-color: currentColor; background: transparent; }
.activity-action.out { color: var(--accent); border-color: currentColor; background: transparent; }
.activity-action.transfer { color: var(--text); border-style: dashed; }
.move-form .move-options { margin-top: 10px; }
.activity-action.expired { color: var(--negative); background: var(--negative-bg); border-color: transparent; }
.activity-title { font-weight: 700; font-size: 14px; }
.activity-closed { font-size: 11px; color: var(--text-muted); border: 1px dashed var(--border); border-radius: 999px; padding: 0 6px; }
.activity-detail { flex-basis: 100%; font-size: 12px; font-variant-numeric: tabular-nums; }
.activity-num { text-align: right; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.activity-num > span { display: block; }
.activity-label { font-size: 11px; font-weight: 500; color: var(--text-muted); }
.activity-more { margin-top: 12px; width: 100%; }
@media (max-width: 600px) {
  .activity-row { grid-template-columns: 1fr auto auto; }
  .activity-date { grid-column: 1 / -1; font-size: 12px; }
  .activity-search { flex-basis: 100%; }
}

@media (max-width: 480px) {
  .profile-nav-item .label-full { display: none; }
  .profile-nav-item .label-short { display: inline; }
}
/* Portfolio pictures (cards, header, Edit) and the shared image picker */
.pf-thumb { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: none; border-radius: 10px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.pf-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pf-thumb-lg { width: 56px; height: 56px; font-size: 18px; margin-bottom: 0; border-radius: 12px; }
.pf-image-field { flex-basis: 100%; display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.pf-image-new { margin: 12px 0 4px; }
.pf-image-new .image-picker-actions button { padding: 4px 10px; font-size: 12px; }
.image-picker-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.image-picker-actions button { padding: 5px 12px; }
.image-picker-actions .link-button { padding: 0 4px; }
.avatar-camera-frame.square::after { border-radius: 0; box-shadow: none; }
.avatar-camera-frame.square video:not(.mirror) { transform: none; }

/* Avatars */
.avatar { display: inline-flex; flex: none; align-items: center; justify-content: center; border-radius: 50%; overflow: hidden; line-height: 1; user-select: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-initials { font-weight: 700; font-size: .6em; }
.user-menu-avatar-img { box-shadow: 0 0 0 2px var(--surface); }
.profile-nav-avatar { margin-bottom: 6px; }
.avatar-editor-row { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.avatar-editor-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.avatar-editor-actions button { padding: 6px 12px; }
.avatar-editor-actions .link-button { padding: 0 4px; }
.avatar-picker { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.avatar-picker-preview { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.avatar-emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; }
.avatar-emoji { height: 40px; font-size: 22px; line-height: 1; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; }
.avatar-emoji.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.avatar-colors { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.avatar-color { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); padding: 0; cursor: pointer; }
.avatar-color.selected { box-shadow: 0 0 0 2px var(--accent); }
.avatar-camera { width: min(420px, calc(100vw - 32px)); }
.avatar-camera-frame { position: relative; width: 100%; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #000; }
.avatar-camera-frame video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
/* the avatar's circle, over the square frame */
.avatar-camera-frame::after { content: ''; position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 999px rgba(0, 0, 0, .45); pointer-events: none; }

/* Profile → Bank accounts */
.bank-form { margin-top: 12px; }
.bank-list { list-style: none; margin: 12px 0 0; padding: 0; }
.bank-item { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 0; border-top: 1px solid var(--border); }
.bank-icon { font-size: 18px; }
.bank-info { display: flex; flex-direction: column; flex: 1; min-width: 140px; }
.bank-name { font-weight: 700; font-size: 14px; }
.bank-status { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor; }
.bank-status.connected { color: var(--positive); }
.bank-status.disconnected { color: var(--text-muted); border-style: dashed; }
.bank-actions { display: flex; gap: 12px; }
.bank-actions .link-button { padding: 0; }
.bank-row-error { flex-basis: 100%; margin: 4px 0 0; }

/* Profile → Alerts */
.alerts-filters { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-top: 14px; }
.alerts-search { flex: 0 1 220px; min-width: 0; }
.alerts-group { margin-top: 16px; }
.alerts-group-title { display: flex; align-items: center; gap: 8px; margin: 0 0 2px; font-size: 14px; font-weight: 700; }
.alerts-manager .alert-item.editing { display: block; }
.alerts-manager .alert-composer, .alerts-manager .alert-form { margin-top: 12px; }
@media (max-width: 480px) { .alerts-search { flex-basis: 100%; } }
.alert-empty { margin: 0; }
@media (max-width: 480px) {
  .alert-item { flex-wrap: wrap; }
  .alert-item-actions { flex-basis: 100%; padding-left: 18px; }
}
/* Alert form */
.alert-form { display: flex; flex-direction: column; gap: 10px; }
.alert-field { display: flex; align-items: center; gap: 10px; margin: 0; }
.alert-field select { flex: 0 1 240px; }
.alert-field-label { font-size: 12px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.alert-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.alert-seg { width: auto !important; flex-wrap: nowrap; }
.alert-seg .range-btn { flex: none !important; padding: 5px 12px !important; }
.alert-amount { display: inline-flex; align-items: center; gap: 6px; }
.alert-amount input { width: 96px; }
.alert-unit { font-size: 12px; color: var(--text-muted); }
.alert-helper { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.alert-note { width: 100%; }
.alert-error { margin: 0; }
.alert-actions { display: flex; gap: 8px; }

/* Unread counts: on the Inbox top tab and its Alerts / Messages sub-tabs */
.count-badge {
  display: inline-block;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 5px;
  border-radius: 999px;
  background: var(--negative);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  vertical-align: 1px;
  font-variant-numeric: tabular-nums;
}
/* Inbox: alerts / messages list */
.inbox-list-head { display: flex; justify-content: flex-end; align-items: center; gap: 14px; margin-bottom: 8px; }
.inbox-new-alert { padding: 5px 12px; }
.inbox-created { position: relative; padding-right: 32px; }
.inbox-created .link-button { position: absolute; top: 8px; right: 8px; padding: 0 4px; }
.alert-composer { margin-bottom: 14px; }
.alert-composer-section { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.alert-groups { margin-bottom: 2px; }
.inbox-list { list-style: none; margin: 0; padding: 0; }
.inbox-item { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; cursor: pointer; }
.inbox-item.unread { border-left: 3px solid var(--accent); }
.inbox-dot { flex: none; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--accent); }
.inbox-item-body { flex: 1; min-width: 0; }
.inbox-item-title { font-weight: 600; }
.inbox-item.unread .inbox-item-title { font-weight: 700; }
.inbox-item-text { font-size: 13px; color: var(--text-muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.inbox-item-time { flex: none; }
.inbox-item-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.inbox-ack { padding: 0; font-size: 12px; white-space: nowrap; }
.inbox-acked { margin-top: 16px; }
#inbox-acked-list { margin-top: 8px; }
.inbox-item.acked { cursor: default; opacity: .8; }
.inbox-ack-mark { color: var(--positive); font-weight: 700; line-height: 1.4; }
.notes-head-right button:not(.link-button) { padding: 5px 12px; }
.note-new { margin-bottom: 14px; }
.note-new .note-form { border: none; padding: 0; margin: 0; background: transparent; }
.note-kind {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 4px;
  color: var(--accent);
  border: 1px solid var(--accent);
}
.note-text-main { font-size: 14px; color: var(--text); }
.note-link { font-size: 12px; overflow-wrap: anywhere; }
.note-optional { font-weight: 400; }
.note-link-input { display: block; width: 100%; margin-top: 4px; font-weight: 400; }
.note-symbol-chip { display: inline-flex; align-items: center; gap: 4px; padding-right: 4px; font-weight: 700; }
.note-symbol-remove {
  border: none;
  background: transparent;
  color: inherit;
  padding: 0 4px;
  font-size: 10px;
  line-height: 1;
  opacity: 0.8;
}
.note-symbol-remove:hover { opacity: 1; background: transparent; }
.note-new-symbol { text-transform: uppercase; }
.note-new-symbol::placeholder { text-transform: none; }
.note-labels { display: flex; flex-wrap: wrap; gap: 6px; }
.note-label {
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.note-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.5; }
.note-actions { display: flex; align-items: baseline; gap: 14px; }
.notes-archived { margin-top: 18px; }
.notes-archived-toggle {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 0; border: none; background: none; cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted);
}
.notes-archived-toggle .holdings-chevron { transition: transform var(--transition); }
.notes-archived-toggle[aria-expanded="true"] .holdings-chevron { transform: rotate(90deg); }
#notes-archived-list { margin-top: 8px; }
.note-card.archived { opacity: .8; }
.note-actions .link-button { padding: 0; }
.link-button.danger-link { color: var(--negative); }
.stock-news-title { font-size: 14px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }

/* ── Social: Share update (Transactions), Inbox → Activity feed, Discover ── */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; max-width: calc(100vw - 32px);
  background: var(--text); color: var(--bg); padding: 9px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; box-shadow: 0 4px 16px rgba(0,0,0,.25); }

/* Transactions → Share update */
.share-composer { margin-top: 12px; padding: 12px; border: 1px solid var(--accent); border-radius: var(--radius); background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; }
.share-composer textarea { width: 100%; resize: vertical; font: inherit; }
.share-composer-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.share-composer-buttons { margin-left: auto; display: flex; gap: 8px; }
.share-private { color: var(--warning); }
.share-done { margin-top: 12px; }
.activity-row.sharing { grid-template-columns: 22px 96px minmax(0, 1fr) 120px 110px; cursor: pointer; }
.activity-row.sharing.unpickable { opacity: .45; cursor: default; }
.activity-row.picked { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
.share-check { margin: 0; width: 16px; height: 16px; }
@media (max-width: 600px) {
  .activity-row.sharing { grid-template-columns: 22px 1fr auto auto; }
  .activity-row.sharing .activity-date { grid-column: 2 / -1; }
  .activity-row.sharing .share-check { grid-row: span 2; }
}

/* Post header: BUY/SELL chips + tickers, then the @handle */
.post-head { display: flex; flex-direction: column; gap: 6px; }
.post-trades { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.post-trade { display: inline-flex; align-items: center; gap: 6px; }
.post-action { font-size: 11px; font-weight: 800; letter-spacing: .04em; padding: 1px 7px; border-radius: 4px; line-height: 16px; }
.post-action.buy { color: var(--positive); background: var(--positive-fill); }
.post-action.sell { color: var(--negative); background: var(--negative-fill); }
.post-ticker { font-weight: 800; font-size: 15px; }
.post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.post-handle { color: var(--accent); font-weight: 700; background: color-mix(in srgb, var(--accent) 12%, transparent); padding: 0 6px; border-radius: 4px; white-space: nowrap; }
.post-thumb { width: 24px; height: 24px; font-size: 10px; border-radius: 6px; margin: 0; }
.post-time { margin-left: auto; white-space: nowrap; }
.post-private { color: var(--warning); white-space: nowrap; }

/* Inbox → Activity */
.activity-feed-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 12px; }
.activity-feed-links { display: flex; align-items: center; gap: 12px; }
.activity-feed .note-chip .count-badge { margin-left: 6px; }
.post-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.post-card { padding: 14px; margin: 0; }
.post-message { margin: 10px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.post-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.post-btn { background: transparent; border: 1px solid transparent; color: var(--text-muted); padding: 4px 8px; border-radius: 999px; font-size: 13px; font-variant-numeric: tabular-nums; }
.post-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.post-btn:disabled { opacity: .55; cursor: default; }
.post-btn.liked { color: var(--negative); }
.post-delete { margin-left: auto; font-size: 13px; }
.post-focus { margin-bottom: 14px; }
.post-focus .post-card { border-color: var(--accent); }
.post-focus-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.post-thread { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.reply-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.reply { display: flex; gap: 8px; align-items: flex-start; }
.reply-body { min-width: 0; flex: 1; }
.reply-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; margin-top: 2px; }
.reply-delete { margin-left: 6px; font-size: 12px; }
.post-owner-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--accent); border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; margin-left: 4px; }
.reply-form textarea { width: 100%; resize: vertical; font: inherit; }
.reply-form-foot { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 6px; }

/* Account → Portfolios → Discover */
.discover { margin-top: 24px; }
.discover-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.discover-title { margin: 0; font-size: 16px; }
.discover-search { flex: 0 1 340px; min-width: 0; }
.discover-note { margin: 6px 0 12px; }
.discover-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.discover-list.stale { opacity: .6; }
.discover-item { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 12px; margin: 0; }
.discover-item .pf-thumb { margin: 0; }
.discover-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.discover-return { text-align: right; font-variant-numeric: tabular-nums; }
.discover-return .pf-card-label { display: block; }
.discover-actions { display: flex; align-items: center; gap: 6px; }
.following-btn { color: var(--positive); border-color: var(--positive); background: transparent; }
@media (max-width: 600px) {
  .discover-search { flex-basis: 100%; }
  .discover-item { grid-template-columns: 40px minmax(0, 1fr) auto; }
  .discover-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .post-time { margin-left: 0; }
}
@media (max-width: 360px) {
  .account-tabs .subtab-btn { font-size: 11.5px; padding-left: 3px; padding-right: 3px; }
}
/* Markets → Energy: Oil Price Indexes · Retail Gas Prices */
@media (max-width: 480px) {
  .energy-tabs .label-full { display: none; }
  .energy-tabs .label-short { display: inline; }
  .energy-tabs .subtab-btn { flex: 1 1 0; text-align: center; }
}
/* My Account → ✉ (Inbox): an icon tab with its unread badge */
.subtab-icon .subtab-icon-glyph { font-size: 21px; line-height: 1; vertical-align: -3px; }
.account-tabs .subtab-btn.subtab-icon { flex: 0 0 auto; }
/* Leaderboard rows open the portfolio's profile */
.lb-row.linked { cursor: pointer; }
.lb-row.linked:hover { background: var(--surface-2); border-radius: 8px; }
.lb-row.linked:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 8px; }
/* A public portfolio's profile (Leaderboard → a portfolio) */
.pf-profile-back { margin-bottom: 12px; }
.pf-profile-head { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto auto; align-items: center; gap: 14px; margin-bottom: 16px; }
.pf-profile-name { margin: 0 0 2px; font-size: 20px; }
.pf-profile-return { text-align: right; font-variant-numeric: tabular-nums; font-size: 20px; }
.pf-profile-return .pf-card-label { display: block; font-size: 11px; }
.pf-profile-actions { display: flex; align-items: center; gap: 6px; }
.pf-profile-note { margin-top: 12px; }
@media (max-width: 600px) {
  .pf-profile-head { grid-template-columns: 56px minmax(0, 1fr) auto; }
  .pf-profile-actions { grid-column: 1 / -1; justify-content: flex-end; }
}
/* Copies of others' portfolios (Leaderboard → Invest) */
.pf-vis-badge.copy { color: var(--accent); font-weight: 700; }
.pf-copy-note { flex-basis: 100%; margin: 6px 0 0; color: var(--text-muted); }
.invest-dialog { max-width: 520px; }
.invest-choice { border: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.invest-choice label { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; font-weight: 400; margin: 0; }
.invest-choice label.selected { border-color: var(--accent); background: var(--surface-2); }
.invest-choice input { width: auto; margin-top: 3px; }
.invest-balance { margin: -6px 0 0; }
.invest-actions { display: flex; justify-content: flex-end; gap: 8px; }
/* A copy's link to the original (My Account → Portfolios → a copy) */
.copy-link { flex-basis: 100%; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.copy-link-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); }
.copy-link-row { display: flex; gap: 12px; align-items: flex-start; }
.copy-link-thumb { margin: 0; }
.copy-link-who { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.copy-link-status { color: var(--text-muted); }
.copy-link-status.warn { color: var(--warning); }
.copy-link-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.copy-link-sync { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; font-weight: 500; cursor: pointer; }
.copy-link-sync input { width: auto; margin: 0; }
.copy-link-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
/* Copy an invested portfolio into your own (CopyPortfolioDialog) */
.copy-dialog { max-width: 600px; }
.copy-steps { list-style: none; display: flex; gap: 4px; margin: 0; padding: 10px 16px 0; font-size: 12px; font-weight: 600; color: var(--text-muted); flex-wrap: wrap; }
.copy-steps li { padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); }
.copy-steps li.active { color: #fff; background: var(--accent); border-color: var(--accent); }
.copy-steps li.past { color: var(--accent); border-color: var(--accent); }
.copy-assets, .copy-alloc { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.copy-assets li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.copy-assets li.off { opacity: .5; }
.copy-assets label { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 400; min-width: 0; cursor: pointer; }
.copy-assets input[type=checkbox] { width: auto; margin: 0; }
.copy-asset-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-new-tag { font-size: 11px; font-weight: 700; color: var(--accent); text-transform: uppercase; }
.copy-add { display: flex; gap: 8px; }
.copy-add input { flex: 1; min-width: 0; }
.copy-alloc-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.copy-alloc li { display: grid; grid-template-columns: minmax(0, 1fr) 90px auto 88px; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.copy-alloc-sym { min-width: 0; display: flex; gap: 6px; align-items: baseline; overflow: hidden; }
.copy-alloc-bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.copy-alloc-bar span { display: block; height: 100%; background: var(--accent); }
.copy-alloc-input { display: flex; align-items: center; gap: 4px; margin: 0; font-weight: 600; }
.copy-alloc-input input { width: 72px; text-align: right; }
.copy-alloc-usd { text-align: right; font-variant-numeric: tabular-nums; }
.copy-total { margin: 0; font-weight: 700; text-align: right; }
.copy-plan { margin: 0; }
.copy-foot { padding-top: 0; }
.copy-actions { display: flex; justify-content: flex-end; gap: 8px; }
@media (max-width: 480px) {
  .copy-alloc li { grid-template-columns: minmax(0, 1fr) auto; }
  .copy-alloc-bar, .copy-alloc-usd { display: none; }
}
