  :root {
    --bg: #0a0e1a;
    --bg-card: #131826;
    --bg-card-soft: #1a2030;
    --border: rgba(255,255,255,0.08);
    --border-strong: rgba(255,255,255,0.16);
    --text: #e6edf3;
    --text-muted: #8b95a7;
    --text-dim: #5d6877;
    --accent: #7c8aff;

    --sell: #f85149;
    --sell-soft: rgba(248,81,73,0.12);
    --sell-light: #ff8a3d;
    --sell-light-soft: rgba(255,138,61,0.14);

    --buy: #3fb950;
    --buy-soft: rgba(63,185,80,0.14);
    --buy-light: #4ecdc4;
    --buy-light-soft: rgba(78,205,196,0.12);

    --alert: var(--sell);
    --ok: var(--buy);
  }
  * { box-sizing: border-box; }
  html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
  }
  a { color: var(--accent); text-decoration: none; }
  a:hover { text-decoration: underline; }
  code, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }

  .wrap { max-width: 1600px; margin: 0 auto; padding: 48px 28px 96px; }

  header.page {
    display: flex; flex-direction: column; align-items: center;
    text-align: center; gap: 6px; margin-bottom: 8px;
  }
  header.page h1 { font-size: 32px; margin: 0; font-weight: 700; letter-spacing: -0.02em; }
  header.page .meta { color: var(--text-muted); font-size: 13px; }
  header.page .meta .mono { color: var(--text); }

  .summary {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
    margin: 28px 0 24px;
  }
  .summary .stat {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 10px; padding: 16px 18px;
  }
  .summary .stat .label {
    color: var(--text-muted); font-size: 12px; text-transform: uppercase;
    letter-spacing: 0.05em; margin-bottom: 6px;
  }
  .summary .stat .value { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; }
  .summary .stat.buy .value { color: var(--buy); }
  .summary .stat.sell .value { color: var(--sell); }

  .tip-banner {
    background: var(--bg-card); border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 8px; padding: 12px 16px; margin-bottom: 36px;
    color: var(--text-muted); font-size: 13px;
  }
  .tip-banner code {
    background: var(--bg-card-soft); padding: 1px 6px; border-radius: 4px;
    color: var(--text);
  }

  .section-heading {
    font-size: 22px; font-weight: 600; letter-spacing: -0.01em;
    margin: 0 0 20px;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    text-align: center;
  }
  .section-heading .count {
    font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 999px;
    background: var(--bg-card-soft); color: var(--text-muted);
  }

  .sector-filter { margin-bottom: 36px; }
  .filter-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
  .filter-chips + .filter-chips { margin-top: 6px; }
  .chip {
    padding: 5px 13px; border-radius: 999px;
    font-size: 12px; cursor: pointer; user-select: none;
    border: 1px solid var(--border-strong);
    background: var(--bg-card); color: var(--text-muted);
    transition: background 0.12s, color 0.12s, border-color 0.12s;
  }
  .chip:hover { color: var(--text); border-color: var(--accent); }
  .chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
  .sub-chip.active { background: var(--bg-card); color: var(--accent); border-color: var(--accent); }

  section {
    margin-top: 48px;
    padding-top: 40px;
    border-top: 1px solid var(--border-strong);
  }
  .signals-section .side-by-side + .side-by-side { margin-top: 16px; }

  .side-by-side {
    display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start;
  }
  @media (max-width: 880px) {
    .side-by-side { grid-template-columns: 1fr; }
  }
  @media (max-width: 600px) {
    .wrap { padding: 24px 14px 60px; }
    header.page h1 { font-size: 22px; }
    header.page .meta { font-size: 12px; }
    .summary { grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 20px 0 18px; }
    .summary .stat { padding: 12px 14px; }
    .summary .stat .value { font-size: 20px; }
    .tip-banner { font-size: 12px; margin-bottom: 24px; }
    .section-heading { font-size: 18px; margin-bottom: 16px; }
    .box-heading { font-size: 14px; margin-bottom: 10px; }
    section { margin-top: 32px; padding-top: 28px; }
    .sector-filter { margin-bottom: 0; }
  }

  .oversold-box {
    border: 1.5px solid var(--buy); border-radius: 12px; padding: 16px;
    background: rgba(63, 185, 80, 0.04);
  }
  .overbought-box {
    border: 1.5px solid var(--sell); border-radius: 12px; padding: 16px;
    background: rgba(248, 81, 73, 0.04);
  }
  .watch-oversold-box {
    border: 1.5px solid var(--buy-light); border-radius: 12px; padding: 16px;
    background: rgba(78, 205, 196, 0.04);
  }
  .watch-overbought-box {
    border: 1.5px solid var(--sell-light); border-radius: 12px; padding: 16px;
    background: rgba(255, 138, 61, 0.04);
  }

  .box-heading {
    font-size: 17px; font-weight: 600; letter-spacing: -0.01em;
    margin: 0 0 14px;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    text-align: center;
  }
  .box-heading .count {
    font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 999px;
    background: var(--bg-card-soft); color: var(--text-muted);
  }
  .box-heading .count.buy { background: var(--buy-soft); color: var(--buy); }
  .box-heading .count.buy-light { background: var(--buy-light-soft); color: var(--buy-light); }
  .box-heading .count.sell { background: var(--sell-soft); color: var(--sell); }
  .box-heading .count.sell-light { background: var(--sell-light-soft); color: var(--sell-light); }

  .signal-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px;
  }
  .signal-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 7px; padding: 8px 10px;
    display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center;
  }
  .signal-card.oversold { border-left: 3px solid var(--buy); }
  .signal-card.overbought { border-left: 3px solid var(--sell); }
  .signal-card .lhs { min-width: 0; }
  .signal-card .lhs .ticker { font-weight: 700; font-size: 14px; letter-spacing: -0.01em; }
  .signal-card .lhs .company {
    font-size: 11px; color: var(--text-muted); margin-top: 1px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .signal-card .rhs { text-align: right; }
  .signal-card .rsi-val { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
  .signal-card.oversold .rsi-val { color: var(--buy); }
  .signal-card.overbought .rsi-val { color: var(--sell); }

  .watch-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px;
  }
  .watch-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 7px; padding: 8px 10px;
    display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center;
  }
  .watch-card.approaching-oversold { border-left: 3px solid var(--buy-light); }
  .watch-card.approaching-overbought { border-left: 3px solid var(--sell-light); }
  .watch-card .lhs { min-width: 0; }
  .watch-card .lhs .ticker { font-weight: 600; font-size: 13.5px; }
  .watch-card .lhs .company {
    font-size: 11px; color: var(--text-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .watch-card .rhs { text-align: right; }
  .watch-card .rsi-val { font-size: 14.5px; font-weight: 600; }
  .watch-card.approaching-oversold .rsi-val { color: var(--buy-light); }
  .watch-card.approaching-overbought .rsi-val { color: var(--sell-light); }

  /* Clickable ticker label inside signal/watch cards */
  .jump-link {
    background: none; border: none; padding: 0; margin: 0;
    font: inherit; color: inherit; cursor: pointer; text-align: left;
    display: block; width: 100%;
  }
  .jump-link:hover { text-decoration: underline; text-decoration-style: dotted; }

  .empty-state-compact {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 10px; padding: 18px; text-align: center;
    color: var(--text-muted); font-size: 13px;
  }

  /* Full Universe table */
  details.full-scan { margin-top: 16px; }
  details.full-scan > summary {
    cursor: pointer; padding: 12px 16px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 10px; user-select: none;
    color: var(--text-muted); font-size: 14px;
    display: flex; align-items: center;
  }
  details.full-scan[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
  .scan-search {
    background: var(--bg-card);
    border-left: 1px solid var(--border); border-right: 1px solid var(--border);
    padding: 12px 14px; display: flex; align-items: center; gap: 10px;
  }
  .scan-search input {
    flex: 1; background: var(--bg-card-soft); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text); padding: 9px 12px;
    font-size: 13.5px; font-family: inherit; outline: none;
    transition: border-color 0.15s, background 0.15s;
  }
  .scan-search input:focus { border-color: var(--accent); background: var(--bg-card); }
  .scan-search input::placeholder { color: var(--text-dim); }
  .scan-search .visible-count {
    color: var(--text-muted); font-size: 12px; white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }

  /* Table scroll container — max-height enables overflow:auto on BOTH axes,
     which lets position:sticky on <th> work relative to this container */
  .table-wrap {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    max-height: 80vh;
    border: 1px solid var(--border); border-top: none;
    border-bottom-left-radius: 10px; border-bottom-right-radius: 10px;
  }
  details.full-scan table {
    width: 100%; border-collapse: collapse;
    background: var(--bg-card); min-width: 480px;
  }
  details.full-scan .empty-search {
    background: var(--bg-card); border: 1px solid var(--border); border-top: none;
    border-bottom-left-radius: 10px; border-bottom-right-radius: 10px;
    padding: 24px; text-align: center; color: var(--text-muted); font-size: 13px;
    display: none;
  }
  details.full-scan th, details.full-scan td {
    padding: 6px 8px; text-align: left; font-size: 12px;
    border-bottom: 1px solid var(--border);
  }
  /* Tighter horizontal padding on fund-col cells to keep 16 columns in view */
  details.full-scan th.fund-col, details.full-scan td.fund-col {
    padding-left: 4px; padding-right: 4px;
  }
  details.full-scan tr:last-child td { border-bottom: none; }
  details.full-scan th {
    position: sticky; top: 0; z-index: 2;
    white-space: nowrap;
    color: var(--text-muted); font-weight: 500;
    text-transform: uppercase; letter-spacing: 0.05em; font-size: 11px;
    background: var(--bg-card-soft);
    box-shadow: inset 0 -1px 0 var(--border-strong);
  }
  details.full-scan th.sortable { cursor: pointer; user-select: none; transition: color 0.12s, background 0.12s; }
  details.full-scan th.sortable:hover { color: var(--text); background: var(--bg-card); }
  details.full-scan th .sort-arrow {
    display: inline-block; margin-left: 4px; font-size: 10px;
    color: var(--text-dim); transition: color 0.12s;
  }
  details.full-scan th.sort-asc .sort-arrow,
  details.full-scan th.sort-desc .sort-arrow { color: var(--accent); }
  details.full-scan th.sort-asc, details.full-scan th.sort-desc { color: var(--text); }
  details.full-scan td.numeric { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
  details.full-scan th.numeric { text-align: right; }
  /* Truncate wide text columns so they don't push numeric cols off-screen.
     Sector (child 3) is intentionally NOT truncated — values are short.
     Subsector (child 4) truncates but reveals full text via title= on hover. */
  details.full-scan td:nth-child(2) { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  details.full-scan td:nth-child(4) { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  details.full-scan td.ticker { font-weight: 600; }
  details.full-scan td.sector { color: var(--text-muted); font-size: 12px; }

  /* Row background tints */
  details.full-scan tr.row-oversold td       { background: var(--buy-soft); }
  details.full-scan tr.row-watch td          { background: var(--buy-light-soft); }
  details.full-scan tr.row-overbought td     { background: var(--sell-soft); }
  details.full-scan tr.row-watch-overbought td { background: var(--sell-light-soft); }
  details.full-scan tr.row-error td          { color: var(--text-dim); font-style: italic; }

  /* Left-border accent on highlighted rows — mirrors signal card left border */
  details.full-scan tr.row-oversold td:first-child       { border-left: 3px solid var(--buy); }
  details.full-scan tr.row-watch td:first-child          { border-left: 3px solid var(--buy-light); }
  details.full-scan tr.row-overbought td:first-child     { border-left: 3px solid var(--sell); }
  details.full-scan tr.row-watch-overbought td:first-child { border-left: 3px solid var(--sell-light); }

  details.full-scan .rsi-cell.oversold       { color: var(--buy); font-weight: 600; }
  details.full-scan .rsi-cell.watch          { color: var(--buy-light); font-weight: 500; }
  details.full-scan .rsi-cell.overbought     { color: var(--sell); font-weight: 600; }
  details.full-scan .rsi-cell.watch-overbought { color: var(--sell-light); font-weight: 500; }
  details.full-scan .change-pos { color: var(--buy); }
  details.full-scan .change-neg { color: var(--sell); }

  /* Flash animation when jumping to a row */
  @keyframes row-flash {
    0%, 25% { background-color: rgba(124, 138, 255, 0.28) !important; }
    100%    { background-color: transparent; }
  }
  .row-jump-flash td { animation: row-flash 2s ease-out forwards; }

  .fund-col { display: none; }
  .show-fundamentals .fund-col { display: table-cell; }
  .toggle-fund-btn {
    margin-left: auto; font-size: 12px; padding: 3px 10px; border-radius: 6px;
    border: 1px solid var(--border-strong); background: var(--bg-card-soft);
    color: var(--text-muted); cursor: pointer; white-space: nowrap;
  }
  .toggle-fund-btn:hover { color: var(--text); border-color: var(--accent); }

  footer.page {
    margin-top: 64px; padding-top: 24px; border-top: 1px solid var(--border);
    color: var(--text-dim); font-size: 12px;
    display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  }

  /* Context blurb (hover tooltip) */
  .blurb-trigger {
    position: relative;
    cursor: help;
  }
  .blurb-trigger:hover .blurb-pop,
  .blurb-trigger.blurb-open .blurb-pop {
    display: block;
  }
  .blurb-pop {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 10px 12px;
    width: 320px;
    max-width: 90vw;
    z-index: 10;
    text-align: left;
    box-shadow: 0 8px 28px rgba(0,0,0,0.5);
    font-size: 12px;
    line-height: 1.5;
    color: var(--text);
  }
  .blurb-pop .blurb-section {
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 10px;
    margin: 4px 0 2px;
  }
  .blurb-pop .blurb-section.first { margin-top: 0; }
  .blurb-pop ul {
    margin: 0; padding-left: 16px;
  }
  .blurb-pop li { margin: 2px 0; }
  .blurb-disclaimer {
    margin-top: 8px; padding-top: 6px;
    border-top: 1px solid var(--border);
    color: var(--text-dim); font-size: 10px;
  }
  /* Table ticker cell is at the left edge — anchor popup left so it doesn't bleed off-screen */
  td.ticker .blurb-pop {
    left: 0;
    transform: none;
  }
  @media (max-width: 600px) {
    .blurb-pop {
      width: 280px;
      left: 0;
      transform: none;
    }
  }

/* Sign-in + paywall cards */
.signin-card {
  max-width: 420px;
  margin: 80px auto;
  padding: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-align: center;
}
.signin-card h1 { font-size: 22px; margin: 0 0 12px; }
.signin-card p { color: var(--text-muted); font-size: 14px; }
.signin-card .legal { font-size: 11px; color: var(--text-dim, var(--text-muted)); margin-top: 24px; }
.signin-card button {
  display: inline-block;
  margin-top: 20px;
  padding: 10px 22px;
  font-size: 14px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.signin-card button.secondary {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border-strong, var(--border));
  margin-left: 8px;
}
