/* ===================== THEME TOKENS ===================== */
:root,
:root[data-theme="dark"] {
  --bg: #000000;
  --bg-elev: #0d0d0d;
  --bg-elev-2: #131313;
  --bg-row: #111111;
  --bg-row-alt: #161616;
  --bg-row-hover: #1f1408;
  --border: #232323;
  --border-strong: #2e2e2e;
  --fg: #ededed;
  --fg-dim: #9a9a9a;
  --fg-mute: #6b6b6b;
  --accent: #ff7a00;
  --accent-soft: #ff9a3c;
  --accent-glow: rgba(255, 122, 0, 0.18);
  --danger: #ff4d4d;
  --positive: #4ade80;
  --bar-fg: #ffffff;
  --chart-grid: #1f1f1f;
  --chart-fg-dim: #9a9a9a;
  --tooltip-bg: #000000;
}

:root[data-theme="light"] {
  --bg: #fafafa;
  --bg-elev: #ffffff;
  --bg-elev-2: #f5f5f5;
  --bg-row: #ffffff;
  --bg-row-alt: #f5f5f5;
  --bg-row-hover: #fff4e6;
  --border: #e5e5e5;
  --border-strong: #d4d4d4;
  --fg: #1a1a1a;
  --fg-dim: #525252;
  --fg-mute: #8a8a8a;
  --accent: #ff7a00;
  --accent-soft: #d96400;
  --accent-glow: rgba(255, 122, 0, 0.22);
  --danger: #dc2626;
  --positive: #16a34a;
  --bar-fg: #1a1a1a;
  --chart-grid: #e5e5e5;
  --chart-fg-dim: #6b6b6b;
  --tooltip-bg: #ffffff;
}

:root {
  --radius: 6px;
  --font:
    "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Pretendard", "Apple SD Gothic Neo", sans-serif;
  --mono:
    "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--fg);
  font-family: var(--font); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.18s, color 0.18s;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-soft); }
.dim { color: var(--fg-dim); }
.small { font-size: 11px; }
button { font-family: inherit; }

/* ===================== TOP BAR ===================== */
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 12px 24px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; letter-spacing: 0.02em;
  color: var(--fg);
  cursor: pointer;
}
.brand:hover { color: var(--accent); }
.brand-mark { color: var(--accent); font-size: 18px; text-shadow: 0 0 12px var(--accent-glow); }
.brand-name { font-size: 15px; }

.search-wrap { position: relative; max-width: 520px; width: 100%; justify-self: stretch; }
#search {
  width: 100%;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#search::placeholder { color: var(--fg-mute); }
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  max-height: 360px; overflow-y: auto;
  z-index: 40;
  box-shadow: 0 12px 28px rgba(0,0,0,0.35);
}
.suggest-item {
  display: grid; grid-template-columns: 80px 1fr auto; gap: 12px;
  padding: 9px 12px; cursor: pointer;
  border-bottom: 1px solid var(--bg-row-alt);
  font-size: 13px;
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item:hover, .suggest-item.active { background: var(--bg-row-hover); }
.suggest-item .ticker { color: var(--accent); font-family: var(--mono); font-weight: 600; }
.suggest-item .name { color: var(--fg-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-item .yield { color: var(--fg-dim); font-family: var(--mono); font-size: 12px; }
.suggest-empty { padding: 14px; color: var(--fg-mute); text-align: center; font-size: 13px; }

.toolbar { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; justify-content: flex-end; }
.watchlist-btn, .settings-btn { white-space: nowrap; }
.settings-btn[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); }

/* Settings popover — surfaces theme / lang / currency / tax toggles
   plus the FX & last-updated meta info, collapsed behind one button to
   keep the header from wrapping into 3 lines on mobile. */
.settings-pop {
  position: fixed;
  top: 56px;
  right: 12px;
  z-index: 40;
  width: 280px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0,0,0,0.35);
  padding: 8px 0;
}
.settings-pop-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 14px;
  font-size: 13px;
}
.settings-label { color: var(--fg-dim); font-size: 12px; }
.settings-value { color: var(--fg); font-family: var(--mono); font-size: 12px; }
.settings-divider { height: 1px; background: var(--border); margin: 4px 0; }
.settings-pop .toggle { margin: 0; }
.settings-pop .toggle-btn { padding: 5px 10px; min-width: 36px; font-size: 12px; }
.watchlist-btn.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}
.meta-item { font-family: var(--mono); font-size: 11px; white-space: nowrap; }

.toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev-2);
  overflow: hidden;
}
.toggle-btn {
  background: transparent; border: none; color: var(--fg-dim);
  padding: 6px 10px; font-size: 12px; cursor: pointer;
  font-family: var(--font); transition: background .12s, color .12s;
  min-width: 32px;
}
.toggle-btn:hover { color: var(--accent); }
.toggle-btn.active { background: var(--accent); color: #000; }

/* ===================== LAYOUT ===================== */
.container { max-width: 1280px; margin: 0 auto; padding: 22px 24px; }

/* ===================== BUTTONS ===================== */
.ghost {
  background: transparent; border: 1px solid var(--border);
  color: var(--fg-dim); padding: 7px 14px; border-radius: var(--radius);
  cursor: pointer; font-size: 12px;
  transition: color .15s, border-color .15s;
}
.ghost:hover { color: var(--accent); border-color: var(--accent); }
.cta {
  background: var(--accent); color: #000;
  padding: 8px 14px; border-radius: var(--radius);
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.cta:hover { background: var(--accent-soft); color: #000; }

/* ===================== LIST VIEW ===================== */
.controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 16px; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--fg-dim); }
.filter input[type="date"],
.filter .select {
  background: var(--bg-elev); border: 1px solid var(--border);
  color: var(--fg); padding: 7px 10px; border-radius: var(--radius);
  font-family: var(--mono); font-size: 12px;
}
:root[data-theme="dark"] .filter input[type="date"],
:root[data-theme="dark"] .filter .select { color-scheme: dark; }
.filter input[type="date"]:focus,
.filter .select:focus { border-color: var(--accent); outline: none; }

/* Dual-range yield slider */
.filter-slider { align-items: flex-start; gap: 6px; min-width: 220px; }
.filter-slider > span { display: flex; align-items: center; gap: 8px; }
.range-slider {
  position: relative;
  width: 200px;
  height: 22px;
}
.range-track {
  position: absolute; left: 0; right: 0; top: 9px;
  height: 4px;
  background: var(--bg-row-alt);
  border-radius: 2px;
}
.range-fill {
  position: absolute; top: 0; bottom: 0;
  background: var(--accent);
  border-radius: 2px;
}
.range-slider input[type="range"] {
  position: absolute; left: 0; right: 0; top: 0;
  width: 100%; height: 22px;
  margin: 0; padding: 0;
  background: transparent;
  -webkit-appearance: none; appearance: none;
  pointer-events: none;
}
.range-slider input[type="range"]::-webkit-slider-runnable-track {
  background: transparent; height: 22px;
}
.range-slider input[type="range"]::-moz-range-track {
  background: transparent; height: 22px;
}
.range-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  pointer-events: all;
  width: 14px; height: 14px;
  background: var(--accent);
  border: 2px solid var(--bg-elev);
  border-radius: 50%;
  cursor: pointer;
  margin-top: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.range-slider input[type="range"]::-moz-range-thumb {
  pointer-events: all;
  width: 14px; height: 14px;
  background: var(--accent);
  border: 2px solid var(--bg-elev);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--fg-mute); margin-bottom: 4px; }
.stat .value { font-family: var(--mono); font-size: 18px; color: var(--accent); }

/* ===================== Welcome card (first-time visitors) */
.welcome-card {
  position: relative;
  background: linear-gradient(135deg, rgba(255,122,0,0.10), rgba(255,154,60,0.04));
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 22px 24px 18px;
  margin-bottom: 18px;
}
.welcome-title {
  margin: 0 0 8px; font-size: 18px;
  color: var(--accent); letter-spacing: -0.01em;
}
.welcome-body {
  margin: 0 0 8px; font-size: 13px;
  color: var(--fg-dim); line-height: 1.6;
  max-width: 720px;
}
.welcome-meta {
  margin: 0 0 14px; font-size: 12px;
  color: var(--fg-dim); font-family: var(--mono);
}
.welcome-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.welcome-dismiss {
  position: absolute; top: 10px; right: 12px;
  background: transparent; border: none;
  color: var(--fg-mute); font-size: 16px; cursor: pointer;
  width: 28px; height: 28px; border-radius: 50%;
}
.welcome-dismiss:hover { background: var(--bg-elev-2); color: var(--accent); }
.welcome-dismiss-text {
  display: block;
  background: transparent; border: none;
  color: var(--fg-mute); font-size: 11px;
  cursor: pointer; margin-top: 12px;
  text-decoration: underline; padding: 0;
}
.welcome-dismiss-text:hover { color: var(--accent); }

/* ===================== "Buyable ex-dates" hero (D-3+ business days) */
.hero-block {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 14px;
  margin-bottom: 18px;
}
.hero-head {
  display: flex; align-items: baseline; gap: 10px;
  flex-wrap: wrap; margin-bottom: 12px;
}
.hero-title { margin: 0; font-size: 14px; color: var(--fg); font-weight: 700; }
.hero-sub { font-size: 12px; color: var(--fg-dim); }
.hero-list {
  display: grid; gap: 8px;
}
.hero-row {
  display: grid;
  grid-template-columns: 26px 70px 1fr auto auto;
  gap: 10px; align-items: center;
  padding: 10px 12px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer; text-decoration: none; color: inherit;
  font-size: 13px;
  transition: border-color .12s, background .12s, transform .12s;
}
.hero-row:hover {
  border-color: var(--accent); background: var(--bg-row-hover);
  transform: translateY(-1px);
}
.hero-rank {
  font-family: var(--mono); font-weight: 700; color: var(--accent);
  font-size: 13px;
}
.hero-ticker {
  font-family: var(--mono); font-weight: 700; color: var(--accent);
  font-size: 15px;
}
.hero-name {
  color: var(--fg-dim); font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hero-dday {
  font-family: var(--mono); font-size: 12px; color: var(--fg);
  background: var(--bg-elev); border: 1px solid var(--border);
  padding: 3px 8px; border-radius: 12px;
}
.hero-yield {
  font-family: var(--mono); font-weight: 700; color: var(--accent);
  font-size: 14px; min-width: 56px; text-align: right;
}
.hero-empty {
  padding: 20px; text-align: center;
  color: var(--fg-mute); font-size: 13px;
}
.hero-note { margin-top: 10px; font-style: italic; }

/* ===================== PWA install banner (mobile sticky bottom) */
.install-banner {
  position: fixed; bottom: 12px; left: 12px; right: 12px;
  z-index: 50;
  background: var(--bg-elev);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex; gap: 10px; align-items: center;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
  max-width: 460px; margin: 0 auto;
}
.install-icon { font-size: 22px; }
.install-text { flex: 1; min-width: 0; }
.install-title { font-weight: 700; font-size: 13px; color: var(--fg); }
.install-sub { font-size: 11px; color: var(--fg-dim); margin-top: 2px; }
.install-banner .cta, .install-banner .ghost { padding: 7px 12px; font-size: 12px; }

/* FIRE calculator banner — high-CTR entry to /fire/ */
.fire-banner {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  margin-bottom: 18px;
  background: linear-gradient(135deg, rgba(255,122,0,0.12), rgba(255,154,60,0.04));
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  text-decoration: none; color: inherit;
  cursor: pointer;
  transition: transform .12s, border-color .12s, background .12s;
}
.fire-banner:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, rgba(255,122,0,0.18), rgba(255,154,60,0.08));
}
.fire-banner-icon { font-size: 28px; line-height: 1; }
.fire-banner-text { flex: 1; min-width: 0; }
.fire-banner-title {
  font-weight: 700; font-size: 14px;
  color: var(--accent); margin-bottom: 2px;
}
.fire-banner-sub {
  font-size: 12px; color: var(--fg-dim);
}
.fire-banner-cta {
  font-family: var(--mono); font-weight: 700;
  color: var(--accent); font-size: 13px;
  white-space: nowrap;
}
@media (max-width: 600px) {
  .fire-banner { gap: 10px; padding: 12px 14px; }
  .fire-banner-icon { font-size: 22px; }
  .fire-banner-title { font-size: 13px; }
  .fire-banner-sub { font-size: 11px; }
  .fire-banner-cta { font-size: 12px; }
}

/* Pinned picks section */
.picks-block { margin-bottom: 18px; }
.picks-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  margin-bottom: 10px;
}
.picks-title {
  margin: 0; font-size: 11px; color: var(--fg-mute);
  text-transform: uppercase; letter-spacing: 0.12em; font-weight: 600;
  font-family: var(--mono);
}
.seg-wrap {
  flex-wrap: wrap;
  overflow: visible;
  border: none;
  background: transparent;
  gap: 4px;
}
.seg-wrap .seg-btn {
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.seg-wrap .seg-btn:hover { border-color: var(--accent); }
.seg-wrap .seg-btn.active { border-color: var(--accent); }
.picks-subtitle {
  font-size: 12px;
  color: var(--fg-dim);
  margin-bottom: 10px;
  font-style: italic;
}
.picks-subtitle:empty { display: none; }
.picks-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.pick-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 4px;
  transition: border-color .12s, background .12s, transform .12s;
}
.pick-card:hover {
  border-color: var(--accent);
  background: var(--bg-row-hover);
  transform: translateY(-1px);
}
.pick-card .pc-ticker {
  font-family: var(--mono); font-weight: 700;
  color: var(--accent); font-size: 15px;
  display: flex; justify-content: space-between; align-items: baseline;
}
.pick-card .pc-yield {
  font-size: 12px; color: var(--accent-soft); font-weight: 600;
}
.pick-card .pc-name {
  font-size: 12px; color: var(--fg-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pick-card .pc-foot {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--mono); font-size: 11px;
  color: var(--fg-mute); margin-top: 4px;
  border-top: 1px solid var(--border);
  padding-top: 6px;
}
.pick-card .pc-price { color: var(--fg); }
.pick-card .pc-ex { color: var(--fg-dim); }
.picks-empty {
  grid-column: 1 / -1;
  padding: 24px; text-align: center;
  color: var(--fg-mute); font-size: 13px;
  background: var(--bg-elev); border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.picks-note { margin-top: 8px; font-style: italic; }

.table-wrap { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; padding: 12px 14px;
  background: var(--bg-row-alt); color: var(--fg-dim);
  font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
thead th.num { text-align: right; }
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--accent); }
thead th.sortable::after {
  content: " \2195";  /* ↕ U+2195 — sort affordance shown on every sortable col */
  font-size: 10px; color: var(--fg-mute); margin-left: 2px;
}
thead th.sortable:hover::after { color: var(--accent); }
thead th.sortable.active { color: var(--accent); }
thead th.sortable.active::after { content: " ↑"; color: var(--accent); }
thead th.sortable.active.desc::after { content: " ↓"; color: var(--accent); }

tbody tr { border-bottom: 1px solid var(--bg-row-alt); transition: background-color .1s; cursor: pointer; }
tbody tr:nth-child(even) { background: var(--bg-row-alt); }
tbody tr:hover { background: var(--bg-row-hover); }
tbody td { padding: 11px 14px; vertical-align: middle; font-family: var(--mono); }
tbody td.num { text-align: right; }
tbody td.company { font-family: var(--font); color: var(--fg-dim); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tbody td.ticker { color: var(--accent); font-weight: 600; }
tbody td.ex-date { color: var(--fg); font-weight: 500; }
tbody td.dim { color: var(--fg-mute); }
tbody td.yield { color: var(--accent); }

/* Star (watchlist) column */
thead th.star-col, tbody td.star-col { width: 30px; padding: 8px 4px 8px 12px; }
tbody td.star-cell {
  font-size: 16px;
  color: var(--fg-mute);
  cursor: pointer;
  user-select: none;
  text-align: center;
  transition: color .12s, transform .12s;
}
tbody td.star-cell:hover { color: var(--accent-soft); transform: scale(1.15); }
tbody td.star-cell.starred { color: var(--accent); }

/* View toggle row (above table) */
.view-toggle-row {
  display: flex; justify-content: flex-end;
  margin-bottom: 10px;
}

/* Scope toggle row — appears below the list when the 30d default can expand to 90d */
.scope-row {
  display: flex; justify-content: center; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-elev-2);
}
.scope-row .ghost { font-size: 13px; padding: 7px 16px; }

/* Watchlist banner */
.watch-banner {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 12px;
}
.watch-summary { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.watch-total { color: var(--accent); font-family: var(--mono); font-weight: 700; font-size: 15px; }

/* Tax disclaimer (sticky bottom right) */
.tax-disclaimer {
  position: fixed; right: 16px; bottom: 16px; z-index: 20;
  max-width: 340px;
  background: var(--bg-elev);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--fg-dim);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  line-height: 1.5;
}
.tax-disclaimer strong { color: var(--accent); display: block; margin-bottom: 4px; font-size: 11px; }

/* Calendar view */
.calendar-wrap {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.cal-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px;
}
.cal-head h3 {
  margin: 0; flex: 1; text-align: center;
  font-size: 15px; font-weight: 600;
  font-family: var(--mono);
  color: var(--fg);
}
.cal-head .ghost { padding: 6px 10px; }

/* Calendar month summary (event count + watchlist income) */
.cal-summary {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-bottom: 14px;
}
.cal-summary-item {
  flex: 1 1 220px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
}
.cal-summary-label {
  font-size: 11px; color: var(--fg-mute);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.cal-summary-value {
  font-family: var(--mono); font-size: 15px; color: var(--fg);
  white-space: nowrap;
}
.cal-summary-value.accent { color: var(--accent); font-weight: 600; }
.cal-grid {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.cal-dowrow {
  display: grid; grid-template-columns: repeat(7, 1fr);
  background: var(--bg-row-alt);
  border-bottom: 1px solid var(--border-strong);
}
.cal-dow {
  padding: 8px 4px; text-align: center;
  font-size: 11px; color: var(--fg-mute);
  text-transform: uppercase; letter-spacing: 0.06em;
  font-family: var(--mono);
}
.cal-cells {
  display: grid; grid-template-columns: repeat(7, 1fr);
}
.cal-cell {
  min-height: 72px;
  border-right: 1px solid var(--bg-row-alt);
  border-bottom: 1px solid var(--bg-row-alt);
  padding: 6px 8px;
  cursor: default;
  display: flex; flex-direction: column;
  gap: 4px;
  position: relative;
  transition: background-color .1s;
}
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell.empty { background: transparent; cursor: default; }
.cal-cell.outside { color: var(--fg-mute); background: var(--bg-row); opacity: 0.5; }
.cal-cell.today { background: var(--bg-row-hover); }
.cal-cell.today .cal-day { color: var(--accent); font-weight: 700; }
.cal-cell.has-events { cursor: pointer; }
.cal-cell.has-events:hover { background: var(--bg-row-hover); }
.cal-cell.selected { background: var(--bg-row-hover); outline: 1px solid var(--accent); outline-offset: -1px; }
.cal-day { font-size: 12px; font-family: var(--mono); color: var(--fg-dim); }
.cal-dots { display: flex; flex-wrap: wrap; gap: 3px; align-content: flex-start; }
.cal-dot {
  display: inline-block;
  width: 7px; height: 7px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: transform .12s;
}
.cal-dot:hover { background: var(--accent-soft); transform: scale(1.4); }
/* Yahoo-sourced dates: hollow ring so users see "different source" at a glance */
.cal-dot.dot-yahoo {
  background: transparent;
  border: 1.5px solid var(--accent);
  width: 8px; height: 8px;
}
.cal-dot.dot-yahoo:hover { background: var(--accent-soft); }
.cal-tag {
  display: inline-block;
  font-size: 9px; font-family: var(--mono);
  background: rgba(255,122,0,0.15);
  color: var(--accent);
  padding: 1px 4px;
  border-radius: 3px;
  white-space: nowrap;
}
.cal-more {
  font-size: 9px; color: var(--fg-mute);
  font-family: var(--mono);
}
.cal-selected {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: none;
}
.cal-selected.active { display: block; }
.cal-selected-head {
  font-size: 12px; color: var(--fg-dim);
  margin-bottom: 8px; font-family: var(--mono);
}
.cal-selected-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
.cal-event-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  transition: border-color .1s;
}
.cal-event-item:hover { border-color: var(--accent); }
.cal-event-item .ticker { color: var(--accent); font-family: var(--mono); font-weight: 600; }
.cal-event-item .name { color: var(--fg-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font); }
.cal-event-item .yield { color: var(--fg); font-family: var(--mono); font-size: 11px; }
.cal-note { margin-top: 10px; font-style: italic; }

/* Tooltip for calendar dots (vanilla CSS) */
.cal-dot[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 4px); left: 0;
  background: var(--tooltip-bg);
  color: var(--fg);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  white-space: nowrap;
  z-index: 100;
  font-family: var(--mono);
  pointer-events: none;
}

/* Watchlist shares input */
tbody td.shares-cell {
  text-align: right;
  font-family: var(--mono);
  padding: 4px 8px;
}
tbody td.shares-cell input {
  width: 60px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 4px 6px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 12px;
  text-align: right;
  outline: none;
}
tbody td.shares-cell input:focus { border-color: var(--accent); }

/* Payout ratio colour coding */
tbody td.payout-green   { color: var(--positive); font-weight: 500; }
tbody td.payout-yellow  { color: #facc15; font-weight: 500; }
tbody td.payout-orange  { color: var(--accent); font-weight: 500; }
tbody td.payout-red     { color: var(--danger); font-weight: 600; }
:root[data-theme="light"] tbody td.payout-yellow { color: #b45309; }

/* 5Y growth colour coding */
tbody td.growth-pos { color: var(--positive); }
tbody td.growth-neg { color: var(--danger); }
tbody tr.empty, tbody tr.error { cursor: default; }
tbody tr.empty td, tbody tr.error td { text-align: center; padding: 24px 16px; color: var(--fg-mute); font-family: var(--font); }
tbody tr.error td { color: var(--danger); }

/* Empty / error state: stacked icon + message + CTA */
.state-block {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 16px;
}
.state-block .state-icon { font-size: 40px; opacity: 0.65; }
.state-block .state-msg { color: var(--fg-dim); font-size: 14px; }
.state-block .state-sub { color: var(--fg-mute); font-size: 12px; max-width: 360px; }
.state-block .ghost { margin-top: 4px; }

/* Skeleton loader rows */
@keyframes skel-pulse {
  0%, 100% { background-color: var(--bg-row-alt); }
  50%      { background-color: var(--bg-elev-2); }
}
.skel {
  display: inline-block;
  height: 11px;
  background: var(--bg-row-alt);
  border-radius: 3px;
  animation: skel-pulse 1.4s ease-in-out infinite;
}
.skel-w-40 { width: 40%; }
.skel-w-60 { width: 60%; }
.skel-w-80 { width: 80%; }
.skel-w-50 { width: 50%; }
.skel-w-30 { width: 30%; }
.skel-cell { padding: 12px 14px; }

/* ===================== DETAIL VIEW ===================== */
.detail-head {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 16px; margin-bottom: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.detail-title { flex: 1; min-width: 0; }
.detail-ticker { display: flex; gap: 10px; align-items: baseline; }
#d-symbol { font-family: var(--mono); font-size: 22px; font-weight: 700; color: var(--accent); }
#d-exchange { font-size: 12px; font-family: var(--mono); }
.detail-name { font-size: 13px; color: var(--fg-dim); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Quote block (top price chart + sidebar) */
.quote-block {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 14px;
  margin-bottom: 16px;
}
.quote-chart {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px 18px;
}
.chart-toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-bottom: 12px;
}
.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev-2);
  overflow: hidden;
}
.seg-btn {
  background: transparent;
  border: none;
  color: var(--fg-dim);
  padding: 6px 11px;
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  transition: color .12s, background .12s;
  border-right: 1px solid var(--border);
  min-width: 38px;
}
.seg-btn:last-child { border-right: none; }
.seg-btn:hover { color: var(--accent); }
.seg-btn.active { background: var(--accent); color: #000; font-weight: 600; }
.quote-price {
  margin-left: auto;
  display: flex; gap: 10px; align-items: baseline;
  font-family: var(--mono);
}
#quote-last { font-size: 18px; color: var(--accent); font-weight: 600; }
.quote-change { font-size: 12px; color: var(--fg-dim); }
.quote-change.positive { color: var(--positive); }
.quote-change.negative { color: var(--danger); }

.quote-meta {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
}

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin-bottom: 16px; }
.card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
}
.card h3, .chart-block h3 {
  margin: 0 0 12px; font-size: 13px; color: var(--fg-dim);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}
.kv { display: grid; grid-template-columns: 1fr auto; gap: 10px 16px; margin: 0; }
.kv dt { color: var(--fg-dim); font-size: 13px; }
.kv dd { margin: 0; font-family: var(--mono); font-size: 13px; color: var(--fg); text-align: right; }
.kv dd.accent { color: var(--accent); font-weight: 600; }

/* Explainable labels (clickable for popover) */
.explainable {
  cursor: help;
  display: inline-flex; align-items: center; gap: 5px;
  border-bottom: 1px dashed var(--border-strong);
  padding-bottom: 1px;
  user-select: none;
}
.explainable:hover { color: var(--accent); }
.explainable.active { color: var(--accent); }
.info-mark {
  font-size: 11px;
  color: var(--fg-mute);
  transition: color .12s;
}
.explainable:hover .info-mark,
.explainable.active .info-mark { color: var(--accent); }

/* Hover tooltip: lightweight CSS-only tooltip for column headers, badges */
.has-tip {
  position: relative;
  display: inline-block;
  margin-left: 4px;
  font-size: 10px;
  color: var(--fg-mute);
  cursor: help;
  font-weight: normal;
}
.has-tip:hover { color: var(--accent); }
.has-tip:hover::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elev);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--fg);
  white-space: normal;
  min-width: 200px;
  max-width: 280px;
  text-align: left;
  font-family: var(--font);
  text-transform: none;
  letter-spacing: 0;
  font-weight: normal;
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
  z-index: 100;
  pointer-events: none;
}
/* Keep tooltip inside viewport on right-edge columns */
thead th:nth-last-child(-n+3) .has-tip:hover::after {
  left: auto; right: 0; transform: none;
}

.explain-pop {
  position: absolute;
  z-index: 50;
  max-width: 320px;
  background: var(--bg-elev);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--fg);
  box-shadow: 0 10px 28px rgba(0,0,0,0.45);
}
.explain-pop .pop-title {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 6px;
  font-size: 12px;
}
.explain-pop .pop-formula {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--bg-elev-2);
  padding: 6px 8px;
  border-radius: 4px;
  margin: 8px 0;
  color: var(--fg-dim);
}
.explain-pop .pop-note {
  color: var(--fg-dim);
  font-size: 11px;
}

.chart-block {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px 18px; margin-bottom: 14px;
}
.chart-wrap { position: relative; height: 240px; }
.chart-wrap-tall { height: 320px; }

/* Dividend streak row + badges */
.streak-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--border);
}
.streak-text {
  font-size: 13px;
  color: var(--fg-dim);
  font-family: var(--mono);
}
.streak-years {
  color: var(--accent);
  font-weight: 700;
  font-size: 16px;
  margin: 0 4px 0 6px;
}
.streak-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font);
  margin-left: auto;
}
.streak-badge.badge-king {
  background: rgba(255, 122, 0, 0.18);
  color: var(--accent);
  border: 1px solid var(--accent);
}
.streak-badge.badge-aristocrat {
  background: rgba(255, 154, 60, 0.14);
  color: var(--accent-soft);
  border: 1px solid var(--accent-soft);
}
.streak-badge.badge-achiever {
  background: var(--bg-elev-2);
  color: var(--fg-dim);
  border: 1px solid var(--border-strong);
}
.streak-badge:empty { display: none; }
.streak-note { margin-top: 8px; font-style: italic; }

/* ===================== FOOTER ===================== */
.footer { max-width: 1280px; margin: 0 auto; padding: 16px 24px 32px; font-size: 11px; color: var(--fg-mute); }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 980px) {
  .quote-block { grid-template-columns: 1fr; }
  .quote-meta { order: -1; }
}
@media (max-width: 980px) {
  .picks-grid { grid-template-columns: repeat(3, 1fr); }
  .picks-grid .pick-card:nth-child(n+4) { display: none; }
}

/* ===================== MOBILE CARD VIEW (≤ 640px) ===================== */
/* Reformats the dense 12-column table into one card per row so users can
   actually read the data on a phone without horizontal scroll. */
@media (max-width: 640px) {
  /* Hide the table header — labels move into each row's pseudo-element */
  #grid thead { display: none; }

  /* Turn the table into a stack of cards */
  #grid, #grid tbody, #grid tr, #grid td { display: block; width: 100%; }
  #grid { border-collapse: separate; }

  #grid tbody tr {
    background: var(--bg-elev);
    border: 1px solid var(--border) !important;
    border-radius: var(--radius);
    margin-bottom: 10px;
    padding: 12px 14px 10px;
    box-shadow: none;
  }
  #grid tbody tr:nth-child(even) { background: var(--bg-elev); }
  #grid tbody tr:hover { background: var(--bg-row-hover); }

  /* Each cell becomes a labeled row inside the card */
  #grid tbody td {
    text-align: right !important;
    padding: 4px 0 !important;
    border: none !important;
    font-size: 13px;
    display: flex; justify-content: space-between; align-items: baseline;
  }
  #grid tbody td::before {
    content: attr(data-label);
    color: var(--fg-dim);
    font-family: var(--font);
    font-size: 11px; font-weight: 500;
    margin-right: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }

  /* Star + ticker get special treatment — header row of the card */
  #grid tbody td.star-col {
    position: absolute; top: 10px; right: 14px;
    width: auto; padding: 0 !important;
  }
  #grid tbody td.star-col::before { display: none; }
  #grid tbody tr { position: relative; }

  #grid tbody td.ticker {
    padding-top: 0 !important;
    border-bottom: 1px solid var(--border) !important;
    padding-bottom: 8px !important;
    margin-bottom: 6px;
    justify-content: flex-start;
  }
  #grid tbody td.ticker::before { display: none; }
  #grid tbody td.ticker { font-size: 16px; }

  #grid tbody td.company {
    text-align: left !important;
    border-bottom: 1px solid var(--border) !important;
    padding-bottom: 8px !important;
    margin-bottom: 6px;
    max-width: none;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    justify-content: flex-start;
  }
  #grid tbody td.company::before { display: none; }

  /* Hide secondary columns to keep cards scannable */
  #grid tbody td.col-mobile-hidden,
  #grid thead th.col-mobile-hidden { display: none !important; }

  /* Empty / error states still show as single full-width message */
  #grid tbody tr.empty, #grid tbody tr.error {
    background: var(--bg-elev);
    padding: 16px;
  }
  #grid tbody tr.empty td, #grid tbody tr.error td {
    text-align: center !important;
    justify-content: center;
  }
  #grid tbody tr.empty td::before, #grid tbody tr.error td::before { display: none; }
}
@media (max-width: 820px) {
  .topbar { grid-template-columns: 1fr auto; padding: 12px 16px; row-gap: 8px; }
  .toolbar { grid-row: 1 / 2; grid-column: 2 / 3; flex-wrap: wrap; gap: 6px; }
  .toolbar .meta-item { display: none; }
  .toolbar .toggle-btn { padding: 5px 8px; min-width: 28px; font-size: 11px; }
  .search-wrap { grid-column: 1 / -1; order: 3; }
  .container { padding: 16px; }
  tbody td.company { max-width: 140px; }
  thead th, tbody td { padding: 10px 6px; }
  .detail-head { flex-wrap: wrap; }
  .cta { width: 100%; text-align: center; }
  .picks-grid { grid-template-columns: repeat(2, 1fr); }
  .picks-grid .pick-card:nth-child(n+5) { display: none; }
  .cal-cell { min-height: 56px; padding: 4px 5px; }
  .cal-day { font-size: 11px; }
  .cal-dot { width: 5px; height: 5px; }
  .tax-disclaimer { right: 8px; bottom: 8px; left: 8px; max-width: none; }
}
@media (max-width: 480px) {
  /* On very small screens, hide secondary columns to keep the row readable */
  thead th.col-secondary, tbody td.col-secondary { display: none; }
  .toolbar .toggle[aria-label="Currency"] .toggle-btn,
  .toolbar .toggle[aria-label="Tax"] .toggle-btn { padding: 5px 7px; }
}
