/* ============================================================
   Financial Research Terminal — local dashboard
   No external assets. Works from file:// by double-clicking.

   Layered in this order:
     1. tokens        2. reset      3. layout      4. type
     5. primitives    6. charts     7. pages       8. responsive
   ============================================================ */

/* ---------- 1. TOKENS ---------------------------------------------------- */
:root {
  /* surfaces */
  --bg:          #f4f6f9;
  --surface:     #ffffff;
  --surface-2:   #eef1f5;
  --surface-3:   #e6eaf0;
  --border:      #e2e6ec;
  --border-2:    #ccd3dd;

  /* ink */
  --text:        #101419;
  --text-2:      #545e6d;
  --text-3:      #858e9d;

  --accent:      #2f5fe0;
  --accent-2:    #7ea0ff;
  --accent-soft: #e9eeff;
  --ring:        #2f5fe066;

  --bull:        #0e7a49;
  --bull-bg:     #e2f5ea;
  --bear:        #b8281f;
  --bear-bg:     #fdeae7;
  --neutral:     #545e6d;
  --neutral-bg:  #eaeef3;
  --unclear:     #8a6100;
  --unclear-bg:  #fcf2da;

  /* spacing scale — every gap in the page comes from here */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 28px; --s7: 40px; --s8: 56px;

  --radius:      14px;
  --radius-sm:   9px;
  --radius-xs:   6px;

  --shadow:      0 1px 2px rgba(16,24,40,.04), 0 2px 6px rgba(16,24,40,.05);
  --shadow-lg:   0 8px 24px rgba(16,24,40,.10), 0 2px 6px rgba(16,24,40,.05);

  --page:        1180px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #0d1016;
    --surface:     #161a21;
    --surface-2:   #1c212a;
    --surface-3:   #232935;
    --border:      #272e3a;
    --border-2:    #3a4250;
    --text:        #e9edf3;
    --text-2:      #9ba5b4;
    --text-3:      #737d8c;
    --accent:      #7c9dff;
    --accent-2:    #a7bcff;
    --accent-soft: #1a2340;
    --ring:        #7c9dff55;

    --bull:        #4fdc9c;
    --bull-bg:     #0f2a1f;
    --bear:        #ff8d82;
    --bear-bg:     #2d1613;
    --neutral:     #9ba5b4;
    --neutral-bg:  #212733;
    --unclear:     #f2c86a;
    --unclear-bg:  #2c2413;
    --shadow:      0 1px 2px rgba(0,0,0,.34);
    --shadow-lg:   0 10px 30px rgba(0,0,0,.46);
  }
}
:root[data-theme="dark"] {
  --bg:#0d1016; --surface:#161a21; --surface-2:#1c212a; --surface-3:#232935;
  --border:#272e3a; --border-2:#3a4250;
  --text:#e9edf3; --text-2:#9ba5b4; --text-3:#737d8c;
  --accent:#7c9dff; --accent-2:#a7bcff; --accent-soft:#1a2340; --ring:#7c9dff55;
  --bull:#4fdc9c; --bull-bg:#0f2a1f; --bear:#ff8d82; --bear-bg:#2d1613;
  --neutral:#9ba5b4; --neutral-bg:#212733; --unclear:#f2c86a; --unclear-bg:#2c2413;
  --shadow:0 1px 2px rgba(0,0,0,.34); --shadow-lg:0 10px 30px rgba(0,0,0,.46);
}

/* ---------- 2. RESET ----------------------------------------------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
img, svg { max-width: 100%; }

/* One focus treatment for the whole page. */
a:focus-visible, button:focus-visible, select:focus-visible,
summary:focus-visible, input:focus-visible, tr:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- 3. LAYOUT ---------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--page); margin: 0 auto;
  padding: var(--s3) var(--s5);
  display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap;
  min-height: 56px;
}
.brand {
  display: flex; align-items: baseline; gap: var(--s2);
  font-weight: 650; letter-spacing: -.012em; font-size: 15.5px;
}
.brand .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--bull);
  flex: none; align-self: center;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--bull) 18%, transparent);
}
.brand small { color: var(--text-3); font-weight: 450; font-size: 12px; letter-spacing: 0; }

nav.tabs { display: flex; gap: var(--s1); flex-wrap: wrap; margin-left: auto; }
nav.tabs a {
  padding: 6px 12px; border-radius: 999px; color: var(--text-2);
  font-size: 13.5px; font-weight: 500; white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
nav.tabs a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
nav.tabs a.active {
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent);
}

.theme-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text-2);
  border-radius: 999px; width: 32px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 14px; line-height: 1;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.theme-btn:hover { background: var(--surface-2); border-color: var(--border-2); color: var(--text); }

main { max-width: var(--page); margin: 0 auto; padding: var(--s7) var(--s5) 96px; }

/* ---------- 4. TYPE ------------------------------------------------------ */
h1 { font-size: 28px; font-weight: 680; letter-spacing: -.025em; margin: 0 0 var(--s2); line-height: 1.2; }
h2 {
  font-size: 18.5px; font-weight: 650; letter-spacing: -.015em;
  margin: var(--s7) 0 var(--s3); line-height: 1.3;
}
h2:first-child { margin-top: 0; }
h3 { font-size: 15px; font-weight: 620; letter-spacing: -.01em; margin: 0 0 var(--s2); line-height: 1.35; }
/* A sub-heading sitting directly on the page needs air above it; one inside a
   card is already the first thing in its box. */
main > h3 { margin-top: var(--s6); }
p { margin: 0 0 var(--s3); }
.subtitle { color: var(--text-2); margin: 0 0 var(--s6); font-size: 14.5px; max-width: 78ch; }
.section-hint { color: var(--text-3); font-size: 13px; margin: calc(var(--s2) * -1) 0 var(--s3); }
.note { color: var(--text-3); font-size: 12.5px; line-height: 1.55; margin: 0 0 var(--s3); max-width: 84ch; }
h2 + .note, h3 + .note { margin-top: calc(var(--s2) * -1); }
.caption { color: var(--text-2); font-size: 13.5px; margin: 0 0 var(--s3); max-width: 84ch; }
.mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }

/* ---------- 5. PRIMITIVES ------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s4) var(--s5);
  box-shadow: var(--shadow);
}
.card > :last-child { margin-bottom: 0; }
.grid { display: grid; gap: var(--s4); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; line-height: 1.45;
  white-space: nowrap; border: 1px solid transparent;
}
.badge.buy   { background: var(--bull-bg);    color: var(--bull);    border-color: color-mix(in srgb, var(--bull) 26%, transparent); }
.badge.sell  { background: var(--bear-bg);    color: var(--bear);    border-color: color-mix(in srgb, var(--bear) 26%, transparent); }
.badge.wait  { background: var(--neutral-bg); color: var(--neutral); border-color: var(--border-2); }
.badge.warn  { background: var(--unclear-bg); color: var(--unclear); border-color: color-mix(in srgb, var(--unclear) 32%, transparent); }
.badge.plain { background: var(--surface-2);  color: var(--text-2);  border-color: var(--border); }
a.badge:hover { text-decoration: none; border-color: var(--border-2); color: var(--text); }
/* Emoji carry their own side bearing; giving them an element lets the flex gap
   do the spacing instead. */
.badge .ico, .legend-item .ico, h2 .ico { font-size: .95em; line-height: 1; flex: none; }

/* Strong Buy and Buy share a colour; Strong is filled so the two never rely on
   colour alone to be told apart. AGENTS.md > DASHBOARD STATUS INDICATORS. */
.badge.sig.strong.buy  { background: var(--bull); color: var(--surface); border-color: var(--bull); }
.badge.sig.strong.sell { background: var(--bear); color: var(--surface); border-color: var(--bear); }
:root[data-theme="dark"] .badge.sig.strong.buy,
:root[data-theme="dark"] .badge.sig.strong.sell { color: #0d1016; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge.sig.strong.buy,
  :root:not([data-theme="light"]) .badge.sig.strong.sell { color: #0d1016; }
}

/* Confidence reads as a word first; the number is a footnote. */
.conf { display: inline-flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.conf-word { font-weight: 600; font-size: 13.5px; }
.conf.hi  .conf-word { color: var(--text); }
.conf.mid .conf-word { color: var(--text-2); }
.conf.lo  .conf-word { color: var(--text-3); }
.conf-num {
  font-family: var(--mono); font-size: 11px; color: var(--text-3);
  background: var(--surface-2); border-radius: var(--radius-xs); padding: 1px 5px;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 720px; }
th, td { text-align: left; padding: 12px var(--s4); border-bottom: 1px solid var(--border); vertical-align: top; }
th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-3); font-weight: 650;
  background: var(--surface-2); white-space: nowrap;
  padding-top: 10px; padding-bottom: 10px;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: var(--surface-2); }
td.tkr a { font-weight: 650; }
td .co-sm { color: var(--text-3); font-size: 12px; display: block; margin-top: 1px; }

/* Filters */
.filters { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; margin-bottom: var(--s4); }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  border-radius: 999px; padding: 5px 13px; font-size: 13px; cursor: pointer; font-weight: 500;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.chip:hover { border-color: var(--border-2); color: var(--text); }
.chip.on {
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
  border-color: color-mix(in srgb, var(--accent) 38%, transparent);
}
select, input[type="search"] {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: var(--radius-sm); padding: 6px 10px; font-size: 13.5px; font-family: inherit;
}
.spacer { flex: 1; }

/* Stat tiles */
.stat { display: flex; flex-direction: column; }
.stat .k {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-3); font-weight: 650;
}
.stat .v {
  font-size: 26px; font-weight: 680; letter-spacing: -.025em;
  line-height: 1.2; margin-top: var(--s1); font-family: var(--mono);
}
.stat .n { font-size: 12.5px; color: var(--text-3); line-height: 1.5; }
.stat .n + .n { margin-top: var(--s1); }

/* Timeline */
.timeline { position: relative; padding-left: var(--s6); }
.timeline::before {
  content: ""; position: absolute; left: 5px; top: 8px; bottom: 8px;
  width: 2px; background: var(--border-2); border-radius: 2px;
}
.tl-item { position: relative; padding-bottom: var(--s5); }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ""; position: absolute; left: -27px; top: 6px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border-2);
}
.tl-item.bull::before { border-color: var(--bull); }
.tl-item.bear::before { border-color: var(--bear); }
.tl-date { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); letter-spacing: .01em; }
.tl-title { font-weight: 620; font-size: 14.5px; margin-top: 1px; }
.tl-body { font-size: 13.5px; color: var(--text-2); margin-top: 2px; }
/* Inside a timeline the rule above a "More" would draw a line across every
   entry, which reads as a divider between events that is not there. */
.tl-item details.detail { border-top: 0; padding-top: 0; margin-top: 6px; }
.tl-item .src { margin-top: 4px; }

/* Collapsed detail */
details.detail { margin-top: var(--s3); border-top: 1px solid var(--border); padding-top: var(--s2); }
details.detail summary {
  cursor: pointer; font-size: 13px; color: var(--accent); font-weight: 550;
  list-style: none; display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 0;
}
details.detail summary::-webkit-details-marker { display: none; }
details.detail summary::before { content: "▸"; font-size: 10px; transition: transform .15s ease; }
details.detail[open] summary::before { transform: rotate(90deg); }
details.detail summary:hover { color: var(--accent-2); }
details.detail .inner { padding-top: var(--s3); font-size: 13.5px; color: var(--text-2); }
details.detail .inner > :last-child { margin-bottom: 0; }

/* Lists, empties, callouts */
ul.tight { margin: var(--s2) 0; padding-left: var(--s5); }
ul.tight li { margin-bottom: var(--s1); }
ul.tight > :last-child { margin-bottom: 0; }

.empty {
  border: 1px dashed var(--border-2); border-radius: var(--radius);
  padding: var(--s6) var(--s5);
  text-align: center; color: var(--text-3); font-size: 14px; background: var(--surface);
}
.empty strong { display: block; color: var(--text-2); margin-bottom: var(--s1); font-size: 14.5px; }
/* An empty state inside a card must not draw a second box around itself. */
.card > .empty { border: 0; background: transparent; padding: var(--s5) 0; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: var(--s2) var(--s5); font-size: 14px; margin: 0; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; }
/* One sentence placing the stock in its five-year range. */
.price-range { margin: var(--s3) 0 0; font-size: 14px; color: var(--text-2); max-width: 60ch; }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: var(--s2); }
.src-list { font-size: 13px; }
.src-list li { margin-bottom: 6px; word-break: break-word; }

.callout {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  padding: var(--s3) var(--s4);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 14px; line-height: 1.6;
}
.callout.warn { border-left-color: var(--unclear); background: var(--unclear-bg); }

.disclaimer {
  margin-top: var(--s8); padding: var(--s4) var(--s5);
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); font-size: 12.5px; color: var(--text-3); line-height: 1.65;
}
.back {
  font-size: 13.5px; margin-bottom: var(--s3); display: inline-flex; align-items: center; gap: 5px;
  color: var(--text-2); font-weight: 500;
}
.back:hover { color: var(--accent); text-decoration: none; }
.pre { white-space: pre-wrap; font-size: 13px; line-height: 1.65; color: var(--text-2); }
td.nw, .nw { white-space: nowrap; }
td.wide { max-width: 460px; }
.src { margin-top: 6px; font-size: 12.5px; }

/* ---------- 6. CHARTS ---------------------------------------------------- */
/* Every chart sits in the same wrapper, so heading, plot, key and the one
   plain sentence underneath always line up the same way. */
.chartwrap { display: flex; flex-direction: column; gap: var(--s4); }
.chart-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s2) var(--s3); }
.chart-head .ch-main { font-size: 15px; font-weight: 620; letter-spacing: -.01em; }
.chart-head .ch-sub { font-size: 13px; color: var(--text-3); }
.chart-foot { font-size: 12.5px; color: var(--text-3); line-height: 1.55; margin: 0; }

svg.chart { display: block; width: 100%; height: auto; overflow: visible; }
svg.chart text { font-family: var(--sans); fill: var(--text-3); font-size: 11px; }
svg.chart .axis { stroke: var(--border-2); stroke-width: 1; }
svg.chart .gridline { stroke: var(--border); stroke-width: 1; }
svg.chart .gridline.dashed { stroke-dasharray: 3 4; }
svg.chart .lbl-val { fill: var(--text-2); font-size: 10.5px; font-weight: 650; }
svg.chart .lbl-axis { fill: var(--text-3); font-size: 10.5px; }
svg.chart .lbl-strong { fill: var(--text-2); font-weight: 600; }

/* One bar, one hundred per cent of the predictions. */
.bar {
  display: flex; width: 100%; height: 30px;
  border-radius: 999px; overflow: hidden;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
}
.bar-seg {
  display: flex; align-items: center; justify-content: center;
  min-width: 3px; position: relative;
  transition: filter .15s ease;
}
.bar-seg + .bar-seg { box-shadow: inset 1px 0 0 color-mix(in srgb, var(--surface) 55%, transparent); }
.bar-seg:hover { filter: brightness(1.08); }
.bar-seg-v {
  font-size: 11.5px; font-weight: 700; color: var(--surface);
  letter-spacing: .01em; padding: 0 4px;
  text-shadow: 0 1px 1px rgba(0,0,0,.22);
}
:root[data-theme="dark"] .bar-seg-v { color: #0d1016; text-shadow: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .bar-seg-v { color: #0d1016; text-shadow: none; }
}

/* The key. Same colour, same wording, same order as the bar itself — otherwise
   the reader has to guess which block is which. */
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2); }
.legend-item {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface-2);
  border-radius: 999px; padding: 4px 11px 4px 8px; font-size: 12.5px;
}
.legend-swatch { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.legend-label { color: var(--text-2); }
.legend-v { font-family: var(--mono); font-weight: 700; color: var(--text); font-size: 12px; }
.legend-pct { color: var(--text-3); font-size: 11.5px; }
.legend-item.is-zero { opacity: .5; }
.legend-item.is-zero .legend-v { color: var(--text-3); font-weight: 600; }
/* Tinted key: same colour as the block it stands for. */
.legend-item.tinted {
  background: color-mix(in srgb, var(--c) 13%, transparent);
  border-color: color-mix(in srgb, var(--c) 34%, transparent);
  padding-left: 11px;
}
.legend-item.tinted .legend-label { color: var(--text); }
.legend-item.tinted .legend-v { color: var(--c); }

/* ---------- 7. PAGES ----------------------------------------------------- */

/* --- 7a. The two signal tables: the first screen. AGENTS.md --- */
/* Always stacked, one above the other, at every width. The Buy table reads
   first and the Sell-or-wait table follows it, so the "Why" column gets the
   full page width and the two are read in order rather than compared across.
   minmax(0,…) so a wide table scrolls inside its own wrapper instead of
   pushing the grid past the page. */
.tables { display: grid; gap: var(--s7); grid-template-columns: minmax(0, 1fr); margin-bottom: var(--s2); }

.table-block h2 {
  margin: 0 0 var(--s1); display: flex; align-items: center; gap: var(--s2); font-size: 19px;
}
.table-block h2 .ico { font-size: 15px; line-height: 1; }
.count {
  font-family: var(--mono); font-size: 11.5px; font-weight: 650; color: var(--text-3);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
  padding: 1px 8px;
}
h2 > .count { margin-left: var(--s2); vertical-align: 2px; }
.table-block h2 > .count { margin-left: 0; vertical-align: baseline; }
.table-block.buy  h2 { color: var(--bull); }
.table-block.sell h2 { color: var(--text); }

table.signals { min-width: 620px; font-size: 13.5px; }
table.signals th, table.signals td { padding: 13px var(--s4); }
table.signals td.tkr .t { font-weight: 700; font-size: 14.5px; display: block; letter-spacing: -.015em; }
table.signals .why-cell { color: var(--text-2); min-width: 220px; width: 44%; line-height: 1.5; }
table.signals .when-cell { white-space: nowrap; }
.when { display: block; font-size: 13px; font-weight: 550; }
.when-sub { display: block; font-size: 11.5px; color: var(--text-3); }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--accent-soft); }
.table-block .table-wrap { border-top: 3px solid var(--border-2); }
.table-block.buy  .table-wrap { border-top-color: var(--bull); }
.table-block.sell .table-wrap { border-top-color: var(--bear); }

/* Why this date, and not another one. Quiet by default — it is a footnote on
   the date, not a second signal. */
.basis {
  display: inline-block; margin-top: 4px; font-size: 10px; letter-spacing: .04em;
  text-transform: uppercase; font-weight: 700; border-radius: var(--radius-xs);
  padding: 1px 6px; cursor: help;
}
.basis.event   { color: var(--bull); background: var(--bull-bg); }
.basis.capped  { color: var(--unclear); background: var(--unclear-bg); }
.basis.default { color: var(--text-3); background: var(--surface-2); border: 1px solid var(--border); }
.basis-note { margin-top: 6px; line-height: 1.45; }
.basis-note.default, .basis-note.weekly { color: var(--text-3); font-style: italic; }
.basis-note.event { color: var(--bull); }
.basis-note.capped { color: var(--unclear); }
.when-sub.overdue { color: var(--bear); font-weight: 650; }

/* --- 7b. Stock page --- */
.stock-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s4); flex-wrap: wrap; }
.stock-head h1 { margin-bottom: 2px; }
.stock-head h1 .co { font-weight: 450; color: var(--text-2); font-size: 20px; letter-spacing: -.01em; }
.stock-head .subtitle { margin-bottom: 0; }
.stock-head-right { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; padding-top: 6px; }
.lede { font-size: 17.5px; line-height: 1.5; color: var(--text); margin: var(--s5) 0 var(--s6); max-width: 68ch; }

/* Four facts, one row, one set of column edges. Splitting them across two
   grids of different widths made the cards look misaligned. */
.facts { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.facts .card { padding: var(--s3) var(--s4) var(--s4); }
.facts .stat .v { font-size: 18px; font-family: var(--sans); font-weight: 640; letter-spacing: -.015em; }
/* A label that wraps onto two lines must not push its own number out of line
   with the numbers beside it. */
.facts .stat .k { margin-bottom: 2px; line-height: 1.35; min-height: calc(2 * 1.35em); }
.facts-note {
  display: flex; gap: var(--s3); align-items: flex-start;
  margin-top: var(--s3); padding: var(--s3) var(--s4);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-2); line-height: 1.55;
}
.facts-note strong { color: var(--text); }

/* The generic stat grid keeps its big mono numbers. */
.grid.slim .stat .v { font-size: 18px; font-family: var(--sans); font-weight: 640; }
.grid.slim .stat .v.big { font-size: 28px; font-family: var(--mono); }
.card-text { font-size: 14px; color: var(--text-2); }

/* --- 7c. Mistakes and rules --- */
.card.lesson { margin-bottom: var(--s4); }
.card.danger { border-color: color-mix(in srgb, var(--bear) 42%, var(--border)); }
.lesson-head { display: flex; justify-content: space-between; gap: var(--s3); align-items: flex-start; flex-wrap: wrap; }
.lesson-head h3 { margin: 0; }
.lesson .kv { margin-top: var(--s3); }
.lesson .pill-row { margin-top: 0; }
.why-detail { margin-top: 6px; color: var(--text-2); }

/* The rule is the point of the whole mistakes section, so it is set apart. */
.rule {
  margin-top: var(--s4); padding: var(--s3) var(--s4);
  border-radius: var(--radius-sm);
  background: var(--accent-soft); border-left: 3px solid var(--accent);
}
.rule.idle { background: var(--surface-2); border-left-color: var(--border-2); }
.rule-tag { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; color: var(--accent); }
.rule.idle .rule-tag { color: var(--text-3); }
.rule-check { font-size: 14px; font-weight: 550; margin: 3px 0 5px; }
.rule-meta { font-size: 12.5px; color: var(--text-2); }
.rule-meta.fired { color: var(--bull); font-weight: 550; }
.rule-meta.idle { color: var(--text-3); }

/* --- 7d. History cards --- */
.stock-card { display: block; color: inherit; transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease; }
.stock-card:hover {
  text-decoration: none; transform: translateY(-2px);
  box-shadow: var(--shadow-lg); border-color: var(--border-2);
}
.stock-card { display: flex; flex-direction: column; }
.stock-card .row1 {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s2); margin-bottom: 2px; flex-wrap: wrap;
}
.stock-card .tkr { font-weight: 700; font-size: 15px; letter-spacing: -.015em; white-space: nowrap; }
/* Footers line up across a row of cards even when the summaries differ in
   length. */
.stock-card .meta { margin-top: auto; }
.stock-card .co { color: var(--text-3); font-size: 12.5px; margin-bottom: var(--s3); }
.stock-card .reason { font-size: 13.5px; color: var(--text-2); margin: var(--s2) 0 var(--s3); }
.stock-card .meta {
  display: flex; justify-content: space-between; align-items: center; gap: var(--s2);
  border-top: 1px solid var(--border); padding-top: var(--s2);
  font-size: 12px; color: var(--text-3);
}
.quiet-list { font-size: 13px; list-style: none; padding-left: 0; }
.quiet-list li { margin-bottom: 6px; display: flex; gap: var(--s3); align-items: baseline; }
.quiet-list .mono { flex: none; }

/* --- 7e. New stock findings --- */
/* A reader's first question is "should I buy these?". The explainer answers it
   before the cards, so nobody has to infer it from a table. */
.explainer {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--s5); margin: var(--s4) 0 var(--s7);
}
.explainer h3 { margin: 0 0 var(--s2); font-size: 16.5px; }
.explainer p { margin: 0 0 var(--s2); line-height: 1.65; color: var(--text-2); max-width: 88ch; }
.explainer p:last-child { margin-bottom: 0; }
.explainer strong { color: var(--text); }
.explainer .explainer-foot {
  font-size: 13px; color: var(--text-3);
  border-top: 1px solid var(--border); padding-top: var(--s3); margin-top: var(--s3);
}

/* One card per candidate. The two-column body puts the case for and the case
   against side by side, which is the comparison the reader actually needs. */
.cand-list { display: grid; gap: var(--s4); }
.cand {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--s4) var(--s5) var(--s5);
  border-left: 3px solid var(--bull);
  box-shadow: var(--shadow);
}
.cand.is-test { border-left-color: var(--text-3); }

.cand-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s2) var(--s3); justify-content: space-between; }
.cand-id { display: flex; align-items: baseline; gap: var(--s2); flex-wrap: wrap; }
.cand-tkr { font-family: var(--mono); font-size: 16.5px; font-weight: 700; letter-spacing: -.01em; }
.cand-co { color: var(--text-3); font-size: 13px; }
.cand-tags { display: flex; gap: 6px; flex-wrap: wrap; }

.cand-lede { margin: var(--s2) 0 var(--s4); font-size: 15.5px; line-height: 1.5; color: var(--text); max-width: 80ch; }

.cand-cols { display: grid; gap: var(--s4); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 860px) { .cand-cols { grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: var(--s6); } }
.cand-col { border-top: 2px solid var(--border); padding-top: var(--s2); }
.cand-col.up { border-top-color: var(--bull); }
.cand-col.down { border-top-color: var(--bear); }
.cand.is-test .cand-col.up { border-top-color: var(--text-3); }
.cand-col p { margin: 0; line-height: 1.65; color: var(--text-2); font-size: 14px; }

.cand-k {
  font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 5px;
}

.cand-settle {
  margin-top: var(--s4); padding: var(--s3) var(--s4);
  background: var(--surface-2); border-radius: var(--radius-sm);
}
.cand-settle p { margin: 0; line-height: 1.65; color: var(--text-2); font-size: 14px; }

.cand-foot {
  display: flex; flex-wrap: wrap; gap: var(--s1) var(--s5); margin-top: var(--s4);
  padding-top: var(--s3); border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-3);
}
.found-via { margin-top: 5px; font-size: 11.5px; color: var(--text-3); font-style: italic; }
table.candidates { min-width: 580px; }
table.candidates td.wide { max-width: 260px; }

/* The turned-down list is a reasoning record, not a footnote — each entry needs
   room for its ticker, its badge and the sentence saying why it was not taken. */
ul.tight.decided { list-style: none; padding-left: 0; margin: 0; }
ul.tight.decided li {
  padding: var(--s3) 0; margin: 0; border-bottom: 1px solid var(--border);
  display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s2);
}
ul.tight.decided li:last-child { border-bottom: 0; padding-bottom: 2px; }
ul.tight.decided li:first-child { padding-top: 2px; }
ul.tight.decided li > strong { font-family: var(--mono); font-size: 13px; }
ul.tight.decided li .muted { flex: 1 1 100%; margin-top: 1px; line-height: 1.55; }

/* --- 7f. Dashboard (home) --- */
/* A summary page earns its place only if it can be read without stopping. Every
   tile and card here is a link, and nothing on it is longer than a line. */
.dash-stat { color: inherit; transition: border-color .14s ease, transform .14s ease, box-shadow .14s ease; }
.dash-stat:hover {
  text-decoration: none; border-color: var(--border-2);
  transform: translateY(-1px); box-shadow: var(--shadow-lg);
}
.dash-stat .k { color: var(--text-3); }
.dash-stat:hover .k { color: var(--text-2); }

/* Buy sits beside Strong Buy in the same colour, so the plain signal is paler.
   Same for Sell. Weight, not hue, is what separates them. */
.bar-seg.is-soft { opacity: .55; }

table.dash-table { min-width: 640px; font-size: 13.5px; }
table.dash-table th, table.dash-table td { padding: 11px var(--s4); vertical-align: middle; }
table.dash-table td.tkr .t { font-weight: 700; font-size: 14.5px; display: block; letter-spacing: -.015em; }
.graded-cell { min-width: 124px; }
.graded-cell .when { font-size: 13px; font-weight: 550; }
.graded-cell .when-sub { display: flex; align-items: baseline; gap: 6px; margin-top: 1px; }
.graded-cell .conf-word { font-size: 12px; }
.graded-cell .also { font-size: 11.5px; color: var(--text-3); }
/* A signal with no prediction under it reads quiet rather than alarming, but it
   is never left blank — the gap is the thing worth seeing. */
.none-due { color: var(--text-3); font-size: 13px; font-style: italic; }
/* The year's move is written by hand, so it is sometimes a number and
   sometimes a sentence. The column has to hold both without stretching. */
.move-cell { max-width: 240px; }
.move { font-weight: 550; }
.move.up { color: var(--bull); }
.move.down { color: var(--bear); }

.more { font-size: 13.5px; margin: var(--s3) 0 0; }

.dash-cand { display: flex; flex-direction: column; color: inherit; transition: border-color .14s ease, transform .14s ease, box-shadow .14s ease; }
.dash-cand:hover {
  text-decoration: none; border-color: var(--border-2);
  transform: translateY(-2px); box-shadow: var(--shadow-lg);
}
.dash-cand .row1 { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; }
.dash-cand .cand-tkr { font-size: 15px; }
.dash-cand .co { color: var(--text-3); font-size: 12.5px; margin-top: 1px; }
.dash-cand .reason { font-size: 13.5px; color: var(--text-2); margin-top: var(--s2); }

/* ------------------------------------------------------------
   The summary table on a small screen.
   Scrolling sideways would hide the price and the move, which are
   the reason this page exists — so each row becomes a small card.
   ------------------------------------------------------------ */
@media (max-width: 760px) {
  .dash-wrap { overflow-x: visible; }
  table.dash-table { min-width: 0; display: block; }
  table.dash-table thead { display: none; }
  table.dash-table tbody { display: block; }
  table.dash-table tr {
    display: grid; grid-template-columns: 1fr auto; gap: 6px var(--s3);
    grid-template-areas: "tkr sig" "price move" "conf graded";
    padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); align-items: center;
  }
  table.dash-table tr:last-child { border-bottom: none; }
  table.dash-table td { display: block; padding: 0; border: none; }
  table.dash-table td.tkr          { grid-area: tkr; }
  table.dash-table td:nth-child(2) { grid-area: sig;  justify-self: end; }
  table.dash-table td:nth-child(3) { grid-area: conf; }
  table.dash-table td:nth-child(4) { grid-area: price; font-size: 15px; font-weight: 600; }
  table.dash-table td.move-cell    { grid-area: move; max-width: none; justify-self: end; text-align: right; }
  table.dash-table td.graded-cell  { grid-area: graded; min-width: 0; justify-self: end; text-align: right; }
  table.dash-table td.graded-cell .when-sub { justify-content: flex-end; }
}

/* ---------- 8. RESPONSIVE ------------------------------------------------ */
/* The three or four stat tiles belong on one row — wrapping one onto its own
   line makes it look like another is missing. */
@media (min-width: 720px) {
  .grid.cols-3.slim { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .grid.cols-4.slim { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .facts { grid-template-columns: repeat(4, minmax(0,1fr)); }
}
@media (min-width: 720px) and (max-width: 900px) {
  .facts { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 640px) {
  main { padding: var(--s5) var(--s4) 72px; }
  h1 { font-size: 23px; }
  h2 { margin-top: var(--s6); }
  .topbar-inner { padding: 10px var(--s4); gap: var(--s2); }
  /* one scrolling row of tabs rather than three wrapped lines */
  .brand { flex: 1 1 auto; }
  .theme-btn { order: 2; }
  nav.tabs {
    order: 3; margin-left: 0; width: 100%; flex-wrap: nowrap;
    overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
    padding-bottom: 2px;
  }
  nav.tabs::-webkit-scrollbar { display: none; }
  .stat .v, .grid.slim .stat .v.big { font-size: 23px; }
  .lede { font-size: 16px; margin: var(--s4) 0 var(--s5); }
  .card { padding: var(--s3) var(--s4); }
  .cand { padding: var(--s3) var(--s4) var(--s4); }
  .explainer { padding: var(--s4); }
  .bar { height: 26px; }
  table.signals { min-width: 460px; }
}

/* ------------------------------------------------------------
   Signal tables on a small screen.
   Sideways scrolling would hide the "Why" column, which is the
   whole point of the table — so each row becomes a stacked card.
   ------------------------------------------------------------ */
@media (max-width: 760px) {
  .table-block .table-wrap { overflow-x: visible; }
  table.signals { min-width: 0; display: block; }
  table.signals thead { display: none; }
  table.signals tbody { display: block; }
  table.signals tr {
    display: grid; grid-template-columns: 1fr auto; gap: 8px var(--s3);
    grid-template-areas: "tkr sig" "why why" "conf when";
    padding: var(--s4); border-bottom: 1px solid var(--border); align-items: start;
  }
  table.signals tr:last-child { border-bottom: none; }
  table.signals td { display: block; padding: 0; border: none; }
  table.signals td.tkr       { grid-area: tkr; }
  table.signals td:nth-child(2) { grid-area: sig; justify-self: end; }
  table.signals td:nth-child(3) { grid-area: conf; }
  table.signals td.why-cell  { grid-area: why; width: auto; min-width: 0; font-size: 14px; color: var(--text); }
  table.signals td.when-cell { grid-area: when; justify-self: end; text-align: right; }
  table.signals td.when-cell .basis { margin-top: 2px; }
}
