:root {
  --bg: #070b14;
  --bg2: #0d1424;
  --panel: #111a2e;
  --panel2: #162038;
  --border: #1e2d4a;
  --border2: #243656;
  --text: #e8eef9;
  --muted: #8b9bb8;
  --dim: #5c6d8a;
  --buy: #22c55e;
  --buy-bg: rgba(34, 197, 94, 0.14);
  --sell: #ef4444;
  --sell-bg: rgba(239, 68, 68, 0.14);
  --prepare: #f59e0b;
  --prepare-bg: rgba(245, 158, 11, 0.14);
  --hold: #3b82f6;
  --hold-bg: rgba(59, 130, 246, 0.14);
  --wait: #94a3b8;
  --wait-bg: rgba(148, 163, 184, 0.12);
  --accent: #38bdf8;
  --accent2: #818cf8;
  --pos: #34d399;
  --neg: #f87171;
  --shadow: 0 8px 32px rgba(0,0,0,.45);
  --radius: 14px;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(56,189,248,.08), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(129,140,248,.07), transparent 50%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell { max-width: 1440px; margin: 0 auto; padding: 0 20px 48px; }

/* Nav */
.topnav {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(14px);
  background: rgba(7,11,20,.82);
  border-bottom: 1px solid var(--border);
  margin: 0 -20px 22px;
  padding: 0 20px;
}
.topnav-inner {
  max-width: 1440px; margin: 0 auto;
  display: flex; align-items: center; gap: 18px;
  height: 58px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; letter-spacing: .02em;
  color: var(--text); text-decoration: none !important;
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 0 18px rgba(56,189,248,.35);
}
.brand span.sub { font-weight: 500; color: var(--muted); font-size: .78rem; margin-left: 4px; }
.navlinks { display: flex; gap: 4px; margin-left: 12px; flex-wrap: wrap; }
.navlinks a {
  color: var(--muted); padding: 7px 12px; border-radius: 8px;
  font-size: .9rem; font-weight: 500; text-decoration: none !important;
}
.navlinks a:hover, .navlinks a.active {
  color: var(--text); background: var(--panel2);
}
.nav-meta { margin-left: auto; color: var(--dim); font-size: .8rem; font-family: var(--mono); }

/* Cards / panels */
.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.panel h2 {
  margin: 0 0 14px; font-size: 1.05rem; font-weight: 650;
  display: flex; align-items: center; gap: 10px;
}
.panel h2 .chip {
  font-size: .72rem; font-weight: 600; color: var(--muted);
  background: var(--panel2); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 999px;
}

.hero {
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px;
  margin-bottom: 18px;
}
@media (max-width: 900px) { .hero { grid-template-columns: 1fr; } }

.tape {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px;
}
.tape-pill {
  background: var(--panel2); border: 1px solid var(--border2);
  border-radius: 12px; padding: 10px 14px; min-width: 110px;
}
.tape-pill .lbl { color: var(--dim); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; }
.tape-pill .val { font-family: var(--mono); font-size: 1.15rem; font-weight: 650; margin-top: 2px; }
.up { color: var(--pos); }
.down { color: var(--neg); }
.flat { color: var(--muted); }

.context { color: var(--muted); font-size: .95rem; margin-top: 10px; }

/* Filters */
.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 14px;
}
.filters input, .filters select, .form-grid input, .form-grid select {
  background: var(--bg); border: 1px solid var(--border2); color: var(--text);
  border-radius: 10px; padding: 8px 12px; font: inherit;
}
.filters label, .check {
  display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .88rem;
}
.btn {
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  color: white; border: none; border-radius: 10px;
  padding: 8px 14px; font-weight: 600; cursor: pointer; font: inherit;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost {
  background: transparent; border: 1px solid var(--border2); color: var(--text);
}
.btn.danger { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.btn.sm { padding: 5px 10px; font-size: .8rem; }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); }
table.data {
  width: 100%; border-collapse: collapse; font-size: .86rem;
  min-width: 980px;
}
table.data th {
  text-align: left; padding: 10px 12px;
  background: var(--panel2); color: var(--muted);
  font-weight: 600; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .04em; border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
}
table.data td {
  padding: 9px 12px; border-bottom: 1px solid rgba(30,45,74,.7);
  vertical-align: top;
}
table.data tr:hover td { background: rgba(56,189,248,.04); }
table.data td.num, table.data th.num { text-align: right; font-family: var(--mono); }
table.data td.ticker a {
  font-weight: 700; color: var(--text); font-family: var(--mono);
  text-decoration: none !important;
}
table.data td.ticker a:hover { color: var(--accent); }
table.data td.clip {
  max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--muted);
}
.under-yes { color: var(--prepare); font-weight: 600; }
.under-no { color: var(--dim); }

/* Action pills */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; letter-spacing: .02em;
  white-space: nowrap;
}
.act-buy { background: var(--buy-bg); color: var(--buy); border: 1px solid rgba(34,197,94,.35); }
.act-sell { background: var(--sell-bg); color: var(--sell); border: 1px solid rgba(239,68,68,.35); }
.act-prepare { background: var(--prepare-bg); color: var(--prepare); border: 1px solid rgba(245,158,11,.35); }
.act-hold { background: var(--hold-bg); color: var(--hold); border: 1px solid rgba(59,130,246,.35); }
.act-wait { background: var(--wait-bg); color: var(--wait); border: 1px solid rgba(148,163,184,.3); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.day-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px; transition: border-color .15s, transform .15s;
}
.day-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.day-card h3 { margin: 0 0 6px; font-size: 1.05rem; }
.day-card h3 a { color: var(--text); text-decoration: none !important; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.mono { font-family: var(--mono); }
.kpi { font-family: var(--mono); font-size: 1.35rem; font-weight: 700; }
.kpi-row { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 10px; }
.kpi-box .lbl { font-size: .7rem; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; }

.flip-row.action-flip { background: rgba(245,158,11,.06); }
.flip-row.lean-only { }

.form-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px; align-items: end;
}
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: .78rem; color: var(--muted); }
.msg {
  background: var(--buy-bg); border: 1px solid rgba(34,197,94,.3);
  color: var(--buy); padding: 10px 14px; border-radius: 10px; margin-bottom: 14px;
}
.chart-box {
  height: 280px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px; margin-bottom: 16px;
}
.footer {
  margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--border);
  color: var(--dim); font-size: .78rem; text-align: center;
}
.empty {
  text-align: center; padding: 80px 20px; color: var(--muted);
}

/* Google Finance deep link next to ticker */
a.gf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.35rem;
  padding: 0.05rem 0.35rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #8ab4f8;
  background: rgba(138, 180, 248, 0.12);
  border: 1px solid rgba(138, 180, 248, 0.35);
  border-radius: 4px;
  text-decoration: none;
  vertical-align: middle;
}
a.gf:hover { background: rgba(138, 180, 248, 0.25); color: #c2d7fc; }
a.gf-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: 0.75rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #e8eaed;
  background: #1a73e8;
  border-radius: 6px;
  text-decoration: none;
}
a.gf-btn:hover { background: #1765cc; }


/* ── Compact section tables (Today landing) ── */
.tape-panel { margin-bottom: 14px; }

.sec { padding-top: 14px; padding-bottom: 14px; }
.sec-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 10px;
}
.sec-head h2 {
  margin: 0; font-size: 1.02rem; font-weight: 650;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.sec-head .chip,
.panel h2 .chip {
  font-size: .72rem; font-weight: 600; color: var(--muted);
  background: var(--panel2); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 999px; text-decoration: none !important;
}
.sec-head .chip.act-buy,
.chip.act-buy {
  background: var(--buy-bg); color: var(--buy); border-color: rgba(34,197,94,.35);
}
.sec-head .chip.act-sell,
.chip.act-sell {
  background: var(--sell-bg); color: var(--sell); border-color: rgba(239,68,68,.35);
}

table.data.dense { font-size: .82rem; min-width: 0; }
table.data.dense th { padding: 7px 10px; }
table.data.dense td { padding: 6px 10px; }

tr.row-near-gtc td { background: rgba(239,68,68,.08); }
tr.row-under td { background: rgba(245,158,11,.06); }
tr.row-er td { box-shadow: inset 3px 0 0 var(--prepare); }
tr.row-held td { }
tr.row-missing td { opacity: .55; }
td.warn { color: var(--prepare); font-weight: 700; }

.wg-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: end;
  margin-bottom: 8px;
}
.wg-select label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: .78rem; color: var(--muted);
}
.wg-select select {
  background: var(--bg); border: 1px solid var(--border2); color: var(--text);
  border-radius: 10px; padding: 8px 12px; font: inherit; min-width: 200px;
}
.wg-manage { margin-top: 6px; }
.wg-manage > summary {
  cursor: pointer; color: var(--muted); font-size: .82rem; font-weight: 600;
  list-style: none;
}
.wg-manage > summary::-webkit-details-marker { display: none; }
.wg-manage > summary::before { content: '▸ '; color: var(--dim); }
.wg-manage[open] > summary::before { content: '▾ '; }
.wg-forms {
  display: flex; flex-direction: column; gap: 12px;
  margin-top: 10px; padding: 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
}

.counts-strip {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
@media (max-width: 800px) { .counts-strip { grid-template-columns: 1fr; } }
.counts-title { font-size: .75rem; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.counts-pills { display: flex; flex-wrap: wrap; gap: 6px; }

details.details-set { padding-top: 12px; }
details.details-set > summary {
  cursor: pointer; list-style: none; margin-bottom: 10px;
}
details.details-set > summary::-webkit-details-marker { display: none; }
details.details-set > summary h2 { margin: 0; display: inline-flex; align-items: center; gap: 10px; }
details.details-set > summary::before {
  content: '▸'; color: var(--muted); margin-right: 6px; font-size: .9rem;
}
details.details-set[open] > summary::before { content: '▾'; }

/* Legacy DO NOW cards — de-emphasized / unused */
.do-now, .do-now-grid, .do-card, .do-now-pulse, .rest-label { display: none !important; }

.muted { color: var(--muted); }
.dim { color: var(--dim); }

/* ══════════════════════════════════════════════════════════════
   Mobile / phone layout (≈360–430px). Everything below is either
   display:none on desktop or scoped to max-width:700px, so the
   desktop (>=1024px) layout is unchanged.
   ══════════════════════════════════════════════════════════════ */
.pill .lbl-short { display: none; }
.more-cols { display: none; }

@media (max-width: 700px) {
  html { -webkit-text-size-adjust: 100%; }
  body { overflow-x: hidden; }
  .shell { padding: 0 12px 32px; }

  /* Nav: brand + date on row 1, links spread full-width on row 2 */
  .topnav { margin: 0 -12px 14px; padding: 0 12px; }
  .topnav-inner {
    height: auto; flex-wrap: wrap; gap: 6px 10px; padding: 8px 0;
  }
  .brand { flex: 1 1 auto; min-width: 0; min-height: 40px; }
  .brand span.sub { display: none; }
  .nav-meta { font-size: 13px; }
  .navlinks { order: 3; width: 100%; margin-left: 0; gap: 4px; flex-wrap: nowrap; }
  .navlinks a {
    flex: 1 1 0; min-height: 40px; padding: 8px 4px; font-size: 14px;
    display: flex; align-items: center; justify-content: center; text-align: center;
  }

  /* Panels */
  .panel { padding: 14px 12px; border-radius: 12px; margin-bottom: 14px; }
  .panel h2, .sec-head h2 { font-size: 1rem; flex-wrap: wrap; }
  .sec-head { flex-wrap: wrap; }
  .panel h2 .chip, .sec-head .chip, .chip { font-size: 13px; }
  a.chip { min-height: 40px; display: inline-flex; align-items: center; padding: 2px 12px; }

  /* Tape wraps into three equal pills */
  .tape { gap: 8px; }
  .tape-pill { flex: 1 1 90px; min-width: 0; padding: 8px 10px; }
  .tape-pill .lbl { font-size: 13px; }
  .tape-pill .val { font-size: 1.05rem; }
  .context { font-size: 14px; }

  /* Readable small text */
  .form-grid label, .wg-select label, .counts-title, .kpi-box .lbl,
  .footer, .filters label, .check { font-size: 13px; }
  .day-card .dim.mono, p.dim.mono, .wg-forms p.muted { font-size: 13px !important; }
  .pill { font-size: 13px; padding: 3px 8px; }

  /* Tap targets ≥40px */
  .btn, .btn.sm, .more-cols {
    min-height: 40px; font-size: 14px; padding: 8px 14px;
    display: inline-flex; align-items: center; justify-content: center;
  }
  select, input:not([type=checkbox]):not([type=radio]):not([type=hidden]) {
    min-height: 40px; font-size: 16px !important; /* 16px avoids iOS focus-zoom */
  }
  input[type=checkbox] { width: 20px; height: 20px; }
  .check, .filters label.check { min-height: 40px; }
  .wg-manage > summary, details.details-set > summary {
    min-height: 40px; display: flex; align-items: center; font-size: 14px;
  }
  details.details-set > summary h2 { flex-wrap: wrap; }

  /* Forms stack full-width */
  .filters { flex-direction: column; align-items: stretch; }
  .filters label { width: 100%; }
  .filters label select, .filters label input:not([type=checkbox]) { flex: 1 1 auto; min-width: 0; width: 100%; }
  .filters .btn { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid label { grid-column: auto !important; }
  .form-grid label.check { flex-direction: row !important; }
  .form-grid input, .form-grid select { width: 100%; }
  .form-grid .btn { width: 100%; }
  .wg-bar { flex-direction: column; align-items: stretch; }
  .wg-bar form, .wg-select select { width: 100%; min-width: 0; }
  .wg-bar .btn { width: 100%; }
  .wg-forms { padding: 10px; }
  .wg-forms form .btn { width: 100%; }
  .grid-2 { grid-template-columns: 1fr; gap: 0; }

  /* Tables: own horizontal scroller, sticky first (Ticker) column */
  .table-wrap {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    max-width: 100%; overscroll-behavior-x: contain;
  }
  table.data, table.data.dense { min-width: 0 !important; width: 100%; font-size: 13px; }
  table.data th { font-size: 13px; padding: 8px 8px; letter-spacing: .02em; white-space: nowrap; }
  table.data td, table.data.dense td { padding: 7px 8px; white-space: nowrap; vertical-align: middle; }
  table.data.dense th { padding: 8px 8px; }
  table.data td.clip { max-width: 160px; }
  table.data .lo { display: none; }
  .table-wrap.show-lo table.data .lo { display: table-cell; }

  table.data th.stick, table.data td.stick {
    position: sticky; left: 0;
    box-shadow: 1px 0 0 var(--border);
  }
  table.data th.stick { z-index: 3; background: var(--panel2); }
  table.data td.stick { z-index: 1; background: var(--panel); }
  tr.row-under td.stick { background: linear-gradient(rgba(245,158,11,.06), rgba(245,158,11,.06)), var(--panel); }
  tr.row-near-gtc td.stick { background: linear-gradient(rgba(239,68,68,.08), rgba(239,68,68,.08)), var(--panel); }
  tr.flip-row.action-flip td.stick { background: linear-gradient(rgba(245,158,11,.06), rgba(245,158,11,.06)), var(--panel); }
  tr.row-er td.stick { box-shadow: inset 3px 0 0 var(--prepare), 1px 0 0 var(--border); }

  table.data td.ticker a:not(.gf) { display: inline-flex; align-items: center; min-height: 40px; }
  a.gf { min-height: 32px; min-width: 32px; padding: 0 6px; font-size: 13px; margin-left: 6px; }
  a.gf-btn { margin-left: 0; min-height: 40px; }

  /* Compact action badges */
  .pill .lbl-full { display: none; }
  .pill .lbl-short { display: inline; }

  /* 'More columns' toggle (inserted by base.html JS) */
  .more-cols {
    background: var(--panel2); color: var(--muted);
    border: 1px solid var(--border2); border-radius: 10px;
    font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
    margin: 0 0 8px; padding: 6px 12px;
  }
  .more-cols[aria-pressed="true"] { color: var(--text); border-color: var(--accent); }

  /* Pending orders table → stacked cards with full-width Cancel/Fill */
  table.stack-m thead { display: none; }
  table.stack-m, table.stack-m tbody, table.stack-m tr, table.stack-m td { display: block; width: 100%; }
  table.stack-m tr { border-bottom: 1px solid var(--border); padding: 8px 0; }
  table.stack-m td {
    display: flex !important; justify-content: space-between; align-items: center;
    gap: 10px; border-bottom: 0; padding: 4px 10px; white-space: normal;
  }
  table.stack-m td[data-label]:not([data-label=""])::before {
    content: attr(data-label); color: var(--dim); font-size: 13px; font-family: var(--sans);
    text-transform: uppercase; letter-spacing: .04em;
  }
  table.stack-m td.order-actions { flex-direction: column; align-items: stretch !important; padding-top: 8px; }
  table.stack-m td.order-actions::before { display: none; }
  table.stack-m td.order-actions form { width: 100%; flex-wrap: wrap; }
  table.stack-m td.order-actions form .btn { width: 100%; }
  table.stack-m td.order-actions input { flex: 1 1 130px; width: auto !important; min-width: 0; }
  table.stack-m td[colspan] { display: block !important; }

  .cards { grid-template-columns: 1fr; }
  .chart-box { height: 240px; padding: 8px; }
}
@media (max-width: 700px) {
  .wg-manage > summary::before { margin-right: 6px; }
  .wg-manage + .more-cols { margin-top: 12px; }
}

/* ── Phone: tight grids so the default columns fit 360–430px without swiping ── */
th .h-short { display: none; }
@media (max-width: 700px) {
  th .h-full { display: none; }
  th .h-short { display: inline; }

  .shell { padding-left: 8px; padding-right: 8px; }
  .topnav { margin-left: -8px; margin-right: -8px; padding-left: 8px; padding-right: 8px; }
  .panel { padding-left: 10px; padding-right: 10px; }
  /* Table bleeds to the card edges (drops the card's side padding around tables) */
  .panel .table-wrap {
    margin-left: -10px; margin-right: -10px;
    border-radius: 0; border-left: 0; border-right: 0;
  }

  table.data, table.data.dense { font-size: 12.5px; }
  table.data th, table.data.dense th {
    font-size: 12px; padding: 6px 5px; letter-spacing: 0; text-transform: uppercase;
  }
  table.data td, table.data.dense td { padding: 5px 5px; }
  table.data td.num, table.data th.num {
    font-family: var(--sans); font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
  }
  table.data th:first-child, table.data td:first-child { padding-left: 8px; }
  table.data th:last-child, table.data td:last-child { padding-right: 8px; }

  /* Ticker cell: symbol on line 1, compact GF chip (and 'held') on line 2 */
  table.data td.ticker { line-height: 1.15; }
  table.data td.ticker a:not(.gf) {
    display: block; min-height: 0; padding: 3px 0 1px; font-size: 12.5px;
  }
  table.data td.ticker a.gf {
    position: relative; display: inline-flex;
    min-height: 0; min-width: 0; margin: 1px 0 2px; padding: 0 4px;
    font-size: 10px; line-height: 14px; border-radius: 3px;
  }
  /* invisible enlarged tap area (≈32px+) around the small GF chip */
  table.data td.ticker a.gf::after {
    content: ""; position: absolute; left: -8px; right: -8px; top: -9px; bottom: -9px;
  }
  table.data td.ticker .chip {
    display: inline-block; font-size: 10px; line-height: 14px; padding: 0 4px; margin-left: 2px;
    vertical-align: middle;
  }

  table.data .pill { font-size: 12px; padding: 2px 6px; }
}
@media (max-width: 700px) {
  .panel .table-wrap { max-width: none; }
  table.data th, table.data.dense th { text-transform: none; font-size: 12px; padding: 6px 4px; }
  table.data td, table.data.dense td { padding: 5px 4px; }
  table.data th:first-child, table.data td:first-child { padding-left: 7px; }
  table.data th:last-child, table.data td:last-child { padding-right: 7px; }
  table.data td.num { letter-spacing: -0.02em; }
  table.data .pill { padding: 2px 5px; }
}
@media (max-width: 380px) {
  .shell { padding-left: 4px; padding-right: 4px; }
  .topnav { margin-left: -4px; margin-right: -4px; padding-left: 8px; padding-right: 8px; }
  table.data th, table.data.dense th { padding-left: 3px; padding-right: 3px; }
  table.data td, table.data.dense td { padding-left: 3px; padding-right: 3px; }
  table.data th:first-child, table.data td:first-child { padding-left: 6px; }
  table.data th:last-child, table.data td:last-child { padding-right: 6px; }
}

/* Trade history + realized P&L summary */
.trades-pnl table.pnl-summary tbody tr:last-child td { border-bottom: 0; }
@media (max-width: 700px) {
  .trades-pnl p.dim { font-size: 13px !important; }
  .trades-pnl td.stick strong { font-weight: 600; }
}

/* watch-group caveats (short history / invalid symbol) */
sup.wnote { color: #f59e0b; font-weight: 700; margin-left: 2px; cursor: help; }
.wnotes { font-size: .78rem; margin-top: 6px; line-height: 1.45; }
.wnotes b { color: #f59e0b; }

/* Quality Score 0–100 */
td.score, th.score { font-family: var(--mono); font-weight: 700; }
td.score.score-hi { color: var(--buy); }
td.score.score-mid { color: var(--prepare); }
td.score.score-lo { color: var(--sell); }
td.score.score-na { color: var(--dim); }
td.why { max-width: 220px; color: var(--muted); font-size: .85em; }
@media (max-width: 700px) {
  td.score { font-size: 13px; }
  /* Score stays visible (not .lo); Why is .lo behind More columns */
}

/* Clickable Score chip (action-pill aesthetic, not a form button) */
button.score-btn {
  -webkit-appearance: none; appearance: none;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 2.15em;
  margin: 0; padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent; /* band classes set tinted fill — never white */
  font-family: var(--mono); font-weight: 700; font-size: .78rem;
  line-height: 1.25; letter-spacing: .02em;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
  vertical-align: middle;
  transition: filter .12s, border-color .12s, box-shadow .12s;
}
button.score-btn:hover, button.score-btn:focus-visible {
  filter: brightness(1.18);
  outline: none;
  box-shadow: 0 0 0 2px rgba(56,189,248,.28);
}
button.score-btn.score-hi {
  color: var(--buy); background: var(--buy-bg);
  border-color: rgba(34,197,94,.35);
}
button.score-btn.score-mid {
  color: var(--prepare); background: var(--prepare-bg);
  border-color: rgba(245,158,11,.35);
}
button.score-btn.score-lo {
  color: var(--sell); background: var(--sell-bg);
  border-color: rgba(239,68,68,.35);
}
button.score-btn.score-na {
  color: var(--dim); background: var(--wait-bg);
  border-color: rgba(148,163,184,.3);
}
/* td.score text color is for dash/na; chip owns its own colors */
td.score:has(button.score-btn) { color: inherit; }


/* Lock page scroll while score modal is open */
html.score-modal-open, body.score-modal-open { overflow: hidden; }
/* Score detail modal */
.score-modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(3, 8, 18, .72);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  opacity: 0; pointer-events: none;
  transition: opacity .18s ease;
}
.score-modal-backdrop.open {
  opacity: 1; pointer-events: auto;
}
.score-modal {
  width: min(560px, 100%);
  max-height: min(88vh, 820px);
  overflow: auto;
  background: linear-gradient(180deg, #152038, #0d1424);
  border: 1px solid var(--border2);
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(0,0,0,.55), 0 0 0 1px rgba(56,189,248,.08);
  padding: 0;
  transform: translateY(10px) scale(.98);
  transition: transform .18s ease;
}
.score-modal-backdrop.open .score-modal {
  transform: translateY(0) scale(1);
}
.score-modal-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: linear-gradient(180deg, #152038, rgba(21,32,56,.92));
  backdrop-filter: blur(8px);
  z-index: 1;
}
.score-modal-head .titles { flex: 1; min-width: 0; }
.score-modal-head .ticker {
  font-size: 1.25rem; font-weight: 700; letter-spacing: .03em;
  font-family: var(--mono);
}
.score-modal-head .meta {
  color: var(--muted); font-size: .82rem; margin-top: 2px;
}
.score-badge {
  font-family: var(--mono); font-weight: 800; font-size: 1.35rem;
  min-width: 52px; height: 52px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid transparent;
}
.score-badge.score-hi { color: var(--buy); background: var(--buy-bg); border-color: rgba(34,197,94,.35); }
.score-badge.score-mid { color: var(--prepare); background: var(--prepare-bg); border-color: rgba(245,158,11,.35); }
.score-badge.score-lo { color: var(--sell); background: var(--sell-bg); border-color: rgba(239,68,68,.35); }
.score-badge.score-na { color: var(--dim); background: var(--panel2); }
.score-modal-close {
  appearance: none; border: 1px solid var(--border);
  background: var(--panel2); color: var(--muted);
  width: 36px; height: 36px; border-radius: 10px;
  font-size: 1.2rem; line-height: 1; cursor: pointer;
}
.score-modal-close:hover { color: var(--text); border-color: var(--border2); }
.score-modal-body { padding: 14px 18px 20px; }

.score-company {
  background: rgba(56,189,248,.06);
  border: 1px solid rgba(56,189,248,.22);
  border-radius: 12px;
  padding: 10px 12px 12px;
  margin-bottom: 14px;
}
.score-company-name {
  font-weight: 650; font-size: .92rem; margin-bottom: 4px;
}
.score-company-what {
  color: var(--text); font-size: .88rem; line-height: 1.35;
}
.score-company-si {
  margin-top: 6px; color: var(--muted); font-size: .78rem;
  font-family: var(--mono);
}
.score-company-sub {
  margin-top: 10px;
  font-size: .7rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--dim); font-weight: 650;
}
.score-company-list {
  margin: 4px 0 0; padding-left: 1.1rem;
  color: var(--text); font-size: .82rem; line-height: 1.35;
}
.score-company-list li { margin-bottom: 3px; }
.score-verdict {
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 12px; margin-bottom: 14px;
}
.score-verdict .lbl { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--dim); font-weight: 600; }
.score-verdict .txt { margin-top: 4px; color: var(--text); font-size: .92rem; }
.score-factors { display: flex; flex-direction: column; gap: 10px; }
.score-factor {
  background: rgba(13,20,36,.55);
  border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 12px;
}
.score-factor.holdings-extra {
  border-color: rgba(245,158,11,.28);
  background: rgba(245,158,11,.06);
}
.score-factor-top {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  margin-bottom: 6px;
}
.score-factor-name { font-weight: 600; font-size: .9rem; }
.score-factor-weight { color: var(--dim); font-size: .75rem; font-family: var(--mono); }
.score-factor-bar {
  height: 8px; border-radius: 999px; background: rgba(30,45,74,.9);
  overflow: hidden; margin-bottom: 6px;
}
.score-factor-bar > span {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  transition: width .25s ease;
}
.score-factor-bar.hi > span { background: linear-gradient(90deg, #16a34a, var(--buy)); }
.score-factor-bar.mid > span { background: linear-gradient(90deg, #d97706, var(--prepare)); }
.score-factor-bar.lo > span { background: linear-gradient(90deg, #dc2626, var(--sell)); }
.score-factor-meta {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: .78rem; color: var(--muted);
}
.score-factor-meta .contrib { font-family: var(--mono); white-space: nowrap; }
.score-factor-reason { margin-top: 4px; font-size: .8rem; color: var(--muted); }
.score-section-label {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--dim); font-weight: 650; margin: 14px 0 8px;
}
.score-news {
  display: flex; flex-direction: column; gap: 7px;
}
.score-news-item {
  padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 10px; background: rgba(13,20,36,.55);
}
.score-news-title { font-size: .84rem; line-height: 1.3; }
.score-news-title a { color: var(--accent); text-decoration: none; }
.score-news-title a:hover { text-decoration: underline; }
.score-news-meta { margin-top: 3px; color: var(--dim); font-size: .72rem; }
.score-news-empty { color: var(--muted); font-size: .82rem; padding: 6px 0; }
.score-modal-loading, .score-modal-error {
  padding: 28px 12px; text-align: center; color: var(--muted);
}
.score-modal-error { color: var(--sell); }

@media (max-width: 700px) {
  .score-modal-backdrop {
    align-items: flex-end; padding: 0;
  }
  .score-modal {
    width: 100%; max-height: 92vh;
    border-radius: 18px 18px 0 0;
    transform: translateY(24px);
  }
  .score-modal-backdrop.open .score-modal {
    transform: translateY(0);
  }
  button.score-btn { padding: 3px 9px; font-size: .8rem; }
}

/* AH (after-hours) next to Price/Mark on all Today grids — keep visible on mobile (not .lo) */
.ah-pct { font-size: .78em; font-weight: 600; margin-left: 4px; white-space: nowrap; }
td.ah-cell { white-space: nowrap; }

/* Analysis page */
.analysis-legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px 14px;
  margin: 0 0 14px;
  padding: 10px 12px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: .82rem;
}
.analysis-legend-item { display: flex; flex-direction: column; gap: 2px; }
.analysis-legend-item strong { color: var(--text); font-size: .85rem; }
.analysis-disclaimer {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.08);
  color: var(--muted);
  font-size: .86rem;
  line-height: 1.4;
  max-width: 980px;
}
.analysis-alloc-kpis {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin: 0 0 14px;
}
.analysis-alloc-kpis .kpi-box {
  flex: 1 1 120px;
  min-width: 110px;
  padding: 10px 12px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.analysis-alloc-kpis .kpi-box .lbl {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--dim); margin-bottom: 4px;
}
.analysis-alloc-kpis .kpi-box .val {
  font-family: var(--mono); font-weight: 600; font-size: 1.05rem;
}
.analysis-alloc td.thesis { max-width: 420px; }
.chip.score-inline {
  display: inline-flex; align-items: center;
  margin: 0 4px 0 0; vertical-align: middle;
}
table.analysis-returns td.num { font-variant-numeric: tabular-nums; }
@media (max-width: 700px) {
  .analysis-legend { grid-template-columns: 1fr; font-size: 13px; }
  .analysis-alloc-kpis .kpi-box { flex: 1 1 45%; }
  .navlinks a { font-size: 12px; padding: 8px 2px; }
}

/* Paper sim on Analysis */
.analysis-sim .sim-sub {
  margin: 18px 0 8px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.analysis-sim .chip.sell-chip {
  border-color: rgba(239, 68, 68, 0.45);
  color: var(--sell);
  background: var(--sell-bg);
}
.analysis-sim-days td.num { font-variant-numeric: tabular-nums; }
.analysis-sim code {
  font-family: var(--mono);
  font-size: .78em;
  background: var(--panel2);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* ── Paper sim pages (Sim 10 / Sim 5) ───────────────────────────── */
.sim-tabs { display: flex; gap: 8px; margin: 0 0 14px; flex-wrap: wrap; }
.sim-tabs a {
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--panel); color: var(--muted); font-weight: 600; text-decoration: none !important;
}
.sim-tabs a.active { color: var(--text); background: var(--panel2); border-color: var(--accent); }
.sim-hero-head h2 { margin-bottom: 4px; }
.sim-hero-head .dim { font-size: .85rem; }
.sim-kpis { display: grid; grid-template-columns: 1.5fr repeat(4, 1fr); gap: 12px; margin-top: 16px; }
.sim-kpi { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.sim-kpi .lbl { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.sim-kpi .val { font-family: var(--mono); font-size: 1.55rem; font-weight: 700; margin-top: 4px; }
.sim-kpi.big .val { font-size: 2.1rem; }
.sim-kpi .sub { font-family: var(--mono); font-size: .9rem; margin-top: 2px; }
.sim-moves .move {
  display: grid; grid-template-columns: 84px auto 1fr; gap: 12px; align-items: baseline;
  padding: 10px 12px; border-radius: 10px; background: var(--bg2); border: 1px solid var(--border);
  margin-bottom: 8px; font-size: 1rem;
}
.move-tag { font-weight: 700; font-size: .75rem; letter-spacing: .06em; padding: 3px 8px; border-radius: 6px; text-align: center; }
.move-sell .move-tag { background: var(--sell-bg); color: var(--sell); }
.move-buy .move-tag, .move-add .move-tag { background: var(--buy-bg); color: var(--buy); }
.move-hold .move-tag { background: var(--hold-bg); color: var(--hold); }
.move-hold { grid-template-columns: 84px 1fr !important; }
.move-why { font-size: .82rem; }
table.data.sim-table { min-width: 0; font-size: .95rem; }
table.data.sim-table td { padding: 11px 12px; vertical-align: middle; }
table.data.sim-table .pct { font-size: .82em; opacity: .9; margin-left: 4px; }
table.data.sim-table tr.pos-up td:first-child { box-shadow: inset 3px 0 0 var(--pos); }
table.data.sim-table tr.pos-down td:first-child { box-shadow: inset 3px 0 0 var(--neg); }
td.sim-actions { color: var(--muted); font-size: .88rem; }
.sim-foot { font-size: .8rem; margin-top: 10px; }
.sim-chart { width: 100%; height: auto; max-height: 300px; display: block; }
.sim-chart .grid { stroke: var(--border); stroke-width: 1; }
.sim-chart .base { stroke: var(--dim); stroke-dasharray: 4 4; stroke-width: 1; }
.sim-chart .axis { fill: var(--dim); font-size: 11px; font-family: var(--mono); }
.sim-chart .eq { fill: none; stroke-width: 2; opacity: .55; }
.sim-chart .eq.active { stroke-width: 3; opacity: 1; }
.sim-chart .eq.sim10, .sim-chart .dot.sim10 { stroke: var(--accent); fill: var(--accent); }
.sim-chart .eq.sim5, .sim-chart .dot.sim5 { stroke: var(--prepare); fill: var(--prepare); }
.sim-chart polyline.eq { fill: none !important; }
.sim-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin-top: 6px; }
.sim-legend .lg i { display: inline-block; width: 18px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.sim-legend .lg.sim10 i { background: var(--accent); }
.sim-legend .lg.sim5 i { background: var(--prepare); }
.sim-legend .lg.base i { background: var(--dim); }
.sim-compare a { font-size: 1rem; }
.sim-more summary { cursor: pointer; color: var(--muted); }
.sim-more[open] summary { margin-bottom: 8px; }
.sim-sub { font-size: .95rem; margin: 16px 0 8px; }
.sim-list { margin: 0; padding-left: 18px; color: var(--muted); font-size: .88rem; line-height: 1.6; }
@media (max-width: 900px) {
  .sim-kpis { grid-template-columns: 1fr 1fr; }
  .sim-kpi.big { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  .sim-kpi .val { font-size: 1.3rem; }
  .sim-kpi.big .val { font-size: 1.8rem; }
  .sim-moves .move { grid-template-columns: 70px 1fr; }
  .sim-moves .move .move-why { grid-column: 1 / -1; }
  table.data.sim-table { font-size: 14px; }
  .navlinks { overflow-x: auto; scrollbar-width: none; }
  .navlinks a { flex: 0 0 auto; padding: 8px 9px; }
}

/* ── Avg up/down streak columns ─────────────────────────────── */
td.streak small.streak-now { display: block; font-size: .72em; opacity: .85; line-height: 1.1; }
.streak-panel .up { color: var(--pos); } .streak-panel .down { color: var(--neg); }

/* ── Holdings move alert banner ─────────────────────────────── */
.alert-banner { margin: 0 0 14px; border-radius: 12px; border: 1px solid var(--border); }
.ab-quiet { padding: 8px 14px; font-size: .85rem; color: var(--muted); background: var(--panel); display: flex; align-items: center; gap: 8px; }
.ab-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: 0 0 auto; }
.ab-dot.ok { background: var(--pos); opacity: .8; }
.ab-alert { background: linear-gradient(180deg, rgba(245,158,11,.10), var(--panel)); border-color: rgba(245,158,11,.55); padding: 12px 14px; }
.ab-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.ab-title { font-weight: 700; font-size: 1.05rem; }
.ab-meta { color: var(--muted); font-size: .82rem; font-family: var(--mono); }
.ab-row { background: var(--bg2); border: 1px solid var(--border); border-left: 4px solid var(--dim); border-radius: 10px; padding: 10px 12px; margin-top: 8px; }
.ab-row.ab-up { border-left-color: var(--pos); }
.ab-row.ab-down { border-left-color: var(--neg); }
.ab-main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ab-arrow { font-size: 1.1rem; }
.ab-up .ab-arrow, .ab-up .ab-pct { color: var(--pos); }
.ab-down .ab-arrow, .ab-down .ab-pct { color: var(--neg); }
.ab-pct { font-family: var(--mono); font-weight: 700; font-size: 1.35rem; }
.ab-lbl { color: var(--muted); font-size: .85rem; }
.ab-facts { display: flex; gap: 6px 16px; flex-wrap: wrap; margin-top: 6px; font-size: .9rem; font-family: var(--mono); }
@media (max-width: 700px) { .ab-pct { font-size: 1.2rem; } .ab-facts { font-size: .85rem; gap: 4px 12px; } }
