/* JSE Scraper web app — "terminal" financial theme for public/index.html */

/* ============================================================ tokens === */

:root {
  /* light — institutional "tearsheet" */
  --bg: #f3f4f6;
  --bg-grid: rgba(16, 21, 28, .035);
  --panel: #ffffff;
  --panel-2: #eceef2;
  --border: #d7dbe1;
  --grid: #e7e9ee;
  --text: #0d1117;
  --muted: #5c6572;
  --accent: #1f5fd6;
  --accent-weak: rgba(31, 95, 214, .10);
  --up: #0b8a52;
  --down: #d22f2f;
  --up-bg: rgba(11, 138, 82, .12);
  --down-bg: rgba(210, 47, 47, .12);
  --flat: #6b7280;
  --flat-bg: #e6e8ec;
  --row-alt: #f7f8fa;
  --row-hover: #eaf1fd;
  --shadow: 0 1px 2px rgba(13, 17, 23, .06), 0 14px 34px rgba(13, 17, 23, .09);

  --r: 4px;
  --r-lg: 6px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", "Roboto Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* dark — trading terminal */
    --bg: #090c11;
    --bg-grid: rgba(255, 255, 255, .028);
    --panel: #0f141b;
    --panel-2: #161d27;
    --border: #212a37;
    --grid: #1a212c;
    --text: #e6e9ee;
    --muted: #8a93a2;
    --accent: #4d8dff;
    --accent-weak: rgba(77, 141, 255, .16);
    --up: #27b586;
    --down: #f0616d;
    --up-bg: rgba(39, 181, 134, .15);
    --down-bg: rgba(240, 97, 109, .15);
    --flat: #8a93a2;
    --flat-bg: #1b232f;
    --row-alt: #121822;
    --row-hover: #172334;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 18px 42px rgba(0, 0, 0, .58);
  }
}

/* ============================================================== base === */

* { box-sizing: border-box; }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

html, body { margin: 0; padding: 0; }
body {
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 44px 44px;
  background-position: -1px -1px;
  color: var(--text);
  font: 13px/1.5 var(--sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent); color: #fff; }

/* ============================================================ header === */

header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--panel);
  border-top: 2px solid var(--accent);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
}
.bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  max-width: 1240px;
  margin: 0 auto;
}
.brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-right: auto;
}
.bar h1 {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
}
.bar h1 .brand-sub {
  color: var(--muted);
  font-weight: 650;
  letter-spacing: .08em;
}
.bar h1 .brand-sub::before { content: "/ "; opacity: .55; }
.nav {
  display: flex;
  gap: 2px;
}
.nav a {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  text-decoration: none;
  padding: 4px 9px;
  border-radius: var(--r);
  border: 1px solid transparent;
}
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] {
  color: var(--text);
  border-color: var(--border);
  background: var(--panel-2);
}
.bar h1 .dot {
  width: 8px;
  height: 8px;
  border-radius: 1px;
  background: var(--accent);
  animation: blink 1.4s steps(1) infinite;
}
@keyframes blink { 50% { opacity: .28; } }

.field { display: flex; flex-direction: column; gap: 3px; }
.field label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
}
select, input[type="date"], button {
  font: 12px var(--sans);
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 6px 9px;
}
select:focus, input[type="date"]:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 650;
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 7px 15px;
}
button.primary:disabled { opacity: .5; cursor: default; }

/* ============================================================== main === */

main { max-width: 1240px; margin: 0 auto; padding: 20px; }

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.chip {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 2px solid var(--border);
  border-radius: var(--r);
  padding: 7px 12px;
  display: flex;
  flex-direction: column;
  min-width: 92px;
}
.chip .k {
  font-size: 9.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.chip .v { font-family: var(--mono); font-size: 15px; font-weight: 650; margin-top: 1px; }
.chip .v.up { color: var(--up); }
.chip .v.down { color: var(--down); }
.chip .v.flat { color: var(--flat); }
.chip:has(.v.up) { border-left-color: var(--up); }
.chip:has(.v.down) { border-left-color: var(--down); }
.chip:has(.v.flat) { border-left-color: var(--flat); }

/* ============================================================ tables === */

section.tbl { margin-bottom: 26px; }
section.tbl h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted);
  margin: 0 0 8px;
  padding-left: 8px;
  border-left: 2px solid var(--accent);
}
.scroll {
  /* bounded box so the sticky <th> row anchors to the table, not the viewport
     (where it would slide under the sticky page header) */
  overflow: auto;
  max-height: min(78vh, 760px);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
table {
  border-collapse: collapse;
  width: 100%;
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
th, td {
  padding: 6px 11px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--grid);
  border-right: 1px solid var(--grid);
}
th:last-child, td:last-child { border-right: 0; }
th {
  font-family: var(--sans);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 3;
}
tbody tr:nth-child(even) { background: var(--row-alt); }
tbody tr:hover { background: var(--row-hover); }
tbody tr:last-child td { border-bottom: 0; }
td.sym-cell, th.sym-col { text-align: left; }
td.ind, th.ind {
  text-align: center;
  width: 40px; min-width: 40px; max-width: 40px;
  padding-left: 6px; padding-right: 6px;
}
td.num.neg { color: var(--down); }
td.num.pos { color: var(--up); }

th.sortable { cursor: pointer; user-select: none; -webkit-user-select: none; }
th.sortable:hover { color: var(--text); background: var(--panel); }
th.sorted { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.sort-ind { font-size: 9px; color: var(--accent); }

/* frozen left columns (movement indicator + symbol) */
th.ind, td.ind { position: sticky; left: 0; }
th.stick, td.stick {
  position: sticky;
  left: 40px;
  box-shadow: 9px 0 12px -9px rgba(0, 0, 0, .3);
}
td.ind, td.stick { z-index: 2; background: var(--panel); }
/* 4 keeps the corner header cells above the rest of the table but still
   below the sticky page header (z-index 5) */
th.ind, th.stick { z-index: 4; background: var(--panel-2); }
th.stick, td.stick { min-width: 92px; }
tbody tr:nth-child(even) td.ind,
tbody tr:nth-child(even) td.stick { background: var(--row-alt); }
tbody tr:hover td.ind,
tbody tr:hover td.stick { background: var(--row-hover); }

.glyph { font-size: 11px; }
.glyph.up { color: var(--up); }
.glyph.down { color: var(--down); }
.glyph.flat { color: var(--flat); }

button.sym {
  font: inherit;
  font-family: var(--mono);
  font-weight: 650;
  color: var(--accent);
  background: none;
  border: 0;
  border-bottom: 1px dotted currentColor;
  padding: 0;
  cursor: pointer;
}
button.sym:hover { border-bottom-style: solid; }

/* =========================================================== states === */

.msg { padding: 40px 0; text-align: center; color: var(--muted); font-family: var(--mono); font-size: 12px; }
.msg.err { color: var(--down); }
.spinner {
  display: inline-block; width: 16px; height: 16px; vertical-align: -3px; margin-right: 8px;
  border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==================================================== detail drawer === */

.overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .55);
  opacity: 0; pointer-events: none; transition: opacity .18s;
  z-index: 20;
}
.overlay.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: min(560px, 94vw);
  background: var(--panel); border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  transform: translateX(100%); transition: transform .22s ease;
  z-index: 21; display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer .dhead {
  padding: 15px 20px; border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  display: flex; align-items: flex-start; gap: 12px;
}
.drawer .dhead .close {
  margin-left: auto; background: none; border: 0; color: var(--muted);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.drawer .dhead .close:hover { color: var(--text); }

.dabout {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}
.dabout .about-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.dabout .tag {
  font-family: var(--sans);
  font-size: 10px; font-weight: 650; letter-spacing: .05em;
  text-transform: uppercase;
  padding: 2px 8px; border-radius: var(--r);
  background: var(--flat-bg); color: var(--muted);
}
.dabout .about-text { margin: 0; font-size: 13px; line-height: 1.55; }
.dabout .about-src { margin-top: 6px; font-size: 11.5px; color: var(--muted); font-family: var(--mono); }
.dabout .about-src a { color: var(--accent); text-decoration: none; }
.dabout .about-src a:hover { text-decoration: underline; }

.drawer .dbody { padding: 18px 20px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.drawer h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  margin: 22px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--border);
}
.drawer h3:first-child { margin-top: 0; }

.price-line { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.price-line .big { font-family: var(--mono); font-size: 25px; font-weight: 700; letter-spacing: -.01em; }

/* ============================================================= chart === */

.chart-wrap { margin: 16px 0 4px; }
.chart-ranges { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.chart-ranges button {
  font-family: var(--mono); font-size: 10px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .03em;
  padding: 3px 8px; border-radius: var(--r);
  border: 1px solid var(--border); background: var(--panel); color: var(--muted);
  cursor: pointer;
}
.chart-ranges button:hover { color: var(--text); border-color: var(--muted); }
.chart-ranges button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chart-box { position: relative; width: 100%; height: 190px; }
.chart-box svg { width: 100%; height: 100%; overflow: visible; display: block; }
.chart-box .c-area { fill: var(--accent); opacity: .09; }
.chart-box .c-line { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.chart-box .c-grid { stroke: var(--grid); stroke-width: 1; }
.chart-box .c-axis-label { fill: var(--muted); font-size: 9.5px; font-family: var(--mono); }
.chart-box .c-cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-box .c-dot { fill: var(--accent); }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 2;
  background: var(--text); color: var(--bg);
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  padding: 3px 7px; border-radius: var(--r);
  white-space: nowrap; transform: translate(-50%, -130%); opacity: 0; transition: opacity .1s;
}
.chart-meta { font-family: var(--mono); font-size: 10.5px; color: var(--muted); margin-top: 6px; }
.chart-msg { font-family: var(--mono); font-size: 12px; color: var(--muted); padding: 24px 0; text-align: center; }
.chart-msg.err { color: var(--down); }

/* =================================================== detail sections === */

.pill {
  font-family: var(--mono);
  padding: 2px 7px; border-radius: var(--r); font-weight: 650; font-size: 12px;
}
.pill.up { background: var(--up-bg); color: var(--up); }
.pill.down { background: var(--down-bg); color: var(--down); }
.pill.flat { background: var(--flat-bg); color: var(--flat); }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 4px 18px; }
.grid2 .row { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--grid); }
.grid2 .row .k { color: var(--muted); min-width: 0; }
.grid2 .row .v { font-family: var(--mono); font-weight: 600; text-align: right; white-space: nowrap; }

.mini-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 4px; }
.mini { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 12px; }
.mini th, .mini td { border-bottom: 1px solid var(--grid); padding: 6px 8px; }
.mini th { font-family: var(--sans); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.news a { color: var(--accent); text-decoration: none; font-weight: 600; }
.news a:hover { text-decoration: underline; }
.news .item { padding: 8px 0; border-bottom: 1px solid var(--grid); }
.news .item .when { color: var(--muted); font-size: 11px; margin-top: 2px; font-family: var(--mono); }

.subtle { color: var(--muted); font-size: 11px; }

/* =========================================================== screener === */

/* filter panel — a left-side sheet, same behaviour as the detail drawer */
.filters {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: min(320px, 92vw);
  z-index: 23;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow);
  transform: translateX(-100%);
  transition: transform .22s ease;
}
.filters.open { transform: translateX(0); }
#f-overlay { z-index: 22; }

.filters .fhead {
  padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--panel-2);
  display: flex; align-items: center; gap: 12px;
}
.filters .fhead .ftitle {
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em;
}
.filters .fhead .close {
  margin-left: auto; background: none; border: 0; color: var(--muted);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.filters .fhead .close:hover { color: var(--text); }
.filters .fbody {
  flex: 1; overflow-y: auto; padding: 14px 16px;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}

.filters h3 {
  font-size: 10px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted);
  margin: 16px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--border);
}
.filters h3:first-child { margin-top: 0; }
.filters .frow { display: flex; flex-direction: column; gap: 3px; margin-bottom: 9px; }
.filters .frow label { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.filters .frow.inline { flex-direction: row; align-items: center; gap: 7px; }
.filters .frow.inline label { text-transform: none; letter-spacing: 0; font-size: 12px; color: var(--text); }
.filters .pair { display: flex; gap: 6px; }
.filters input[type="number"], .filters input[type="text"], .filters select { width: 100%; }
.filters input[type="range"] { width: 100%; accent-color: var(--accent); }
.filters .slabel { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); }
.filters .slabel b { color: var(--accent); font-family: var(--mono); }
.filters .btnrow { display: flex; gap: 6px; margin-top: 14px; }
.filters .btnrow button { flex: 1; }

.scr-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.scr-toolbar .grow { margin-left: auto; }
.ghost-btn {
  font-family: var(--mono); font-size: 11px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .05em;
  padding: 6px 12px; border-radius: var(--r);
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  cursor: pointer;
}
.ghost-btn:hover { border-color: var(--muted); }
.ghost-btn .fcount {
  margin-left: 6px; color: var(--accent); font-weight: 700;
}
.scr-status { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.scr-empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.scr-empty p { margin: 0 0 14px; }

.progress { height: 6px; background: var(--panel-2); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; background: var(--accent); transition: width .3s; }

#scr-table th.stick, #scr-table td.stick { left: 0; }
#scr-table td, #scr-table th { border-right: 1px solid var(--grid); }
td.sc, th.sc { text-align: center; width: 42px; min-width: 42px; padding: 6px 4px; }
td.sc {
  font-family: var(--mono); font-weight: 650;
  background: hsl(var(--h, 0) 55% 50% / .16);
  color: hsl(var(--h, 0) 60% 38%);
}
@media (prefers-color-scheme: dark) {
  td.sc { color: hsl(var(--h, 0) 70% 68%); }
}
td.sc.ovr { font-size: 13px; }
td.grade { font-family: var(--mono); font-weight: 700; text-align: center; }

.scr-row { cursor: pointer; }
.scr-row:hover { background: var(--row-hover); }
.scr-row.open, .scr-row.open td.stick { background: var(--row-hover); }

/* expanded breakdown row — the content stays pinned to the viewport's left
   edge while the (wide) table scrolls horizontally underneath it. */
.scr-detail > td { padding: 0; background: var(--panel-2); border-bottom: 2px solid var(--accent); }
.scr-detail-inner {
  position: sticky;
  left: 0;
  width: min(1120px, calc(100vw - 44px));
  box-sizing: border-box;
  padding: 16px 18px;
  border-left: 3px solid var(--accent);
}
.scr-cats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(236px, 1fr));
  gap: 12px;
}
.scr-cat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 12px 11px;
}
.scr-cat-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 9px; padding-bottom: 7px; border-bottom: 1px solid var(--grid);
}
.scr-cat-head .nm { font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 650; }
.scr-cat-head .sq {
  font-family: var(--mono); font-weight: 700; font-size: 12px;
  padding: 1px 7px; border-radius: var(--r);
  background: hsl(var(--h, 0) 55% 50% / .18);
  color: hsl(var(--h, 0) 60% 36%);
}
@media (prefers-color-scheme: dark) { .scr-cat-head .sq { color: hsl(var(--h, 0) 70% 68%); } }

.scr-factor { margin-top: 8px; }
.scr-factor:first-of-type { margin-top: 0; }
.scr-factor-top { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.scr-factor-top .fl { font-size: 11.5px; line-height: 1.35; color: var(--text); }
.scr-factor-top .fl small { color: var(--muted); }
.scr-factor-top .fv { font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.scr-factor .fbar { height: 3px; margin-top: 4px; background: var(--panel-2); border-radius: 2px; overflow: hidden; }
.scr-factor .fbar > div { height: 100%; background: var(--accent); }

.scr-metrics {
  margin-top: 14px; padding-top: 11px; border-top: 1px solid var(--border);
  font-family: var(--mono); font-size: 11px; color: var(--muted); line-height: 1.75;
}
.scr-note { margin-top: 8px; font-size: 11px; color: var(--muted); font-style: italic; }
.scr-dq { margin-top: 6px; font-size: 10.5px; font-family: var(--mono); color: var(--down); }

/* ============================================================== guide === */

/* the guide is a slide-over panel, like the detail drawer but a touch wider,
   and always the topmost sheet */
.guide-drawer { width: min(680px, 96vw); z-index: 27; }
#guide-overlay { z-index: 26; }

.guide { max-width: 760px; margin: 0 auto; }
.guide h2:first-of-type { margin-top: 6px; }
.guide .lead { font-size: 14px; line-height: 1.65; margin: 0 0 16px; }
.guide p { line-height: 1.6; }
.guide h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  margin: 30px 0 10px; padding-left: 9px; border-left: 3px solid var(--accent);
}
.guide h3 {
  font-size: 13px; margin: 0 0 4px;
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.guide ul, .guide ol { margin: 6px 0 12px; padding-left: 20px; line-height: 1.6; }
.guide li { margin: 3px 0; }
.guide .mono { font-family: var(--mono); font-size: .92em; }

.callout {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  background: var(--panel);
  border-radius: var(--r);
  padding: 12px 14px;
  font-size: 12.5px; line-height: 1.6; color: var(--muted);
}

.guide .how { counter-reset: step; list-style: none; padding-left: 0; }
.guide .how > li {
  position: relative; padding-left: 30px; margin: 8px 0;
}
.guide .how > li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 1px;
  width: 20px; height: 20px; border-radius: var(--r);
  background: var(--accent); color: #fff;
  font: 650 11px/20px var(--mono); text-align: center;
}

.dim {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--panel);
  padding: 13px 15px;
  margin: 10px 0;
}
.dim .src { font-size: 11px; color: var(--muted); margin: 0 0 6px; font-style: italic; }
.dim ul { margin-bottom: 2px; }
.tagpill {
  font-family: var(--mono); font-size: 9.5px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .04em;
  padding: 1px 7px; border-radius: 999px;
  background: var(--flat-bg); color: var(--muted);
}

.gradekey { max-width: 240px; }
.gradekey td:first-child { font-family: var(--mono); font-weight: 700; }

.gloss { margin: 8px 0 0; }
.gloss dt { font-weight: 650; font-family: var(--mono); font-size: 12px; margin-top: 10px; }
.gloss dt:first-child { margin-top: 0; }
.gloss dd { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.5; }

/* ============================================================== rules === */

.rules-title { font-size: 21px; margin: 4px 0 8px; }
.rules-lead { max-width: 740px; font-size: 13.5px; line-height: 1.65; margin: 0 0 14px; }
.rules-h2 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  margin: 26px 0 10px; padding-left: 9px; border-left: 3px solid var(--accent);
}

.rules-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 6px; }
#rules-search {
  flex: 1 1 220px; max-width: 340px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r);
  color: var(--text); font: 12px var(--sans); padding: 7px 10px;
}
#rules-search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.rules-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.rules-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r);
  padding: 12px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: border-color .12s, box-shadow .12s;
}
.rules-card:hover { border-color: var(--muted); box-shadow: var(--shadow); }
.rules-card.pdf-only { border-left-color: var(--muted); }

.rc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rc-kind {
  font-family: var(--mono); font-size: 9px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .06em;
  padding: 2px 7px; border-radius: 999px;
  background: var(--accent-weak); color: var(--accent);
}
.rc-fmt { font-family: var(--mono); font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.pdf-only .rc-fmt { color: var(--down); }

.rc-title { font-weight: 650; font-size: 13.5px; line-height: 1.35; color: var(--text); text-decoration: none; }
.rc-title.stretch::after { content: ""; position: absolute; inset: 0; border-radius: var(--r); }
.rules-card:hover .rc-title { color: var(--accent); }
.rc-blurb { margin: 0; font-size: 12px; line-height: 1.5; color: var(--muted); }

.rc-foot { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 3px; }
.rc-meta { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.rc-pdf {
  position: relative; z-index: 1;
  font-family: var(--mono); font-size: 10.5px; font-weight: 650;
  color: var(--muted); text-decoration: none;
}
.rc-pdf:hover { color: var(--accent); }

/* ------------------------------------------- auto-converted doc pages --- */

html { scroll-padding-top: 74px; }

.rules-crumb { font-family: var(--mono); font-size: 11px; color: var(--muted); margin: 0 0 12px; }
.rules-crumb a { color: var(--accent); text-decoration: none; }

.rules-doc-head { margin-bottom: 12px; }
.rules-doc-head .rules-title { margin: 0 0 8px; }
.rules-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip-sm {
  font-family: var(--mono); font-size: 9.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  padding: 2px 8px; border-radius: 999px;
  background: var(--flat-bg); color: var(--muted);
}
.chip-sm.accent { background: var(--accent-weak); color: var(--accent); }
.pdf-btn {
  display: inline-block;
  font-family: var(--mono); font-size: 11px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .04em;
  padding: 7px 13px; border-radius: var(--r);
  border: 1px solid var(--accent); color: var(--accent); text-decoration: none;
}
.pdf-btn:hover { background: var(--accent); color: #fff; }

.rules-note {
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  background: var(--panel); border-radius: var(--r);
  padding: 10px 12px; margin: 0 0 20px;
  font-size: 11.5px; line-height: 1.55; color: var(--muted);
}

.rules-doc-layout {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 30px;
  align-items: start;
  max-width: 1080px;
}
.doc-toc {
  position: sticky;
  top: 74px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  overscroll-behavior: contain;
  font-size: 12px;
  padding-right: 6px;
  border-right: 1px solid var(--border);
}
.doc-toc-head {
  font-family: var(--mono); font-size: 9.5px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  margin-bottom: 8px;
}
.doc-toc a {
  display: block; color: var(--muted); text-decoration: none;
  padding: 3px 8px 3px 0; line-height: 1.35;
  border-left: 2px solid transparent; padding-left: 8px; margin-left: -1px;
}
.doc-toc a:hover { color: var(--text); }
.doc-toc a.active { color: var(--accent); border-left-color: var(--accent); }

.rules-doc { max-width: 760px; }
.rules-doc h2 {
  font-size: 14.5px; margin: 26px 0 6px; padding-top: 4px;
  border-top: 1px solid var(--grid);
}
.rules-doc h2:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.rules-doc h3 {
  font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  margin: 18px 0 4px;
}
.rules-doc p { font-size: 13px; line-height: 1.68; margin: 8px 0; }

.doc-pager { display: flex; gap: 12px; margin: 36px 0 12px; max-width: 1080px; }
.doc-pager .pg-slot { flex: 1; }
.doc-pager a {
  flex: 1; display: flex; flex-direction: column; gap: 2px;
  border: 1px solid var(--border); border-radius: var(--r);
  padding: 10px 12px; text-decoration: none; background: var(--panel);
}
.doc-pager a:hover { border-color: var(--accent); }
.doc-pager .pg-next { text-align: right; }
.pg-rel { font-family: var(--mono); font-size: 9px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.pg-title { font-size: 12px; font-weight: 600; color: var(--text); }

.to-top {
  position: fixed; right: 18px; bottom: 18px; z-index: 6;
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  font-size: 16px; cursor: pointer;
  opacity: 0; pointer-events: none; transition: opacity .16s;
  box-shadow: var(--shadow);
}
.to-top.show { opacity: 1; pointer-events: auto; }
.to-top:hover { border-color: var(--accent); color: var(--accent); }

@media (max-width: 900px) {
  .rules-doc-layout { grid-template-columns: 1fr; gap: 14px; }
  .doc-toc {
    position: static; max-height: 240px;
    border: 1px solid var(--border); border-radius: var(--r); padding: 10px 12px;
  }
}

/* =============================================================== news === */

.news-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.news-toolbar .grow { margin-left: auto; }
.news-toolbar #news-search {
  flex: 0 1 240px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r);
  color: var(--text); font: 12px var(--sans); padding: 7px 10px;
}
.news-toolbar #news-search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.news-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.news-chip {
  font-family: var(--mono); font-size: 10px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .04em;
  padding: 5px 9px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--panel); color: var(--muted);
  cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
}
.news-chip:hover { color: var(--text); }
.news-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.news-chip.off { opacity: .45; cursor: not-allowed; }
.news-chip .nc-count {
  font-size: 9px; padding: 0 4px; border-radius: 999px;
  background: rgba(128, 128, 128, .22);
}
.news-chip.active .nc-count { background: rgba(255, 255, 255, .25); }

#news-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.news-article {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--r);
  padding: 12px 14px 11px;
  display: flex; flex-direction: column; gap: 6px;
}
.news-article:hover { border-left-color: var(--accent); }
.na-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.na-src {
  font-family: var(--mono); font-size: 9px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--accent);
}
.na-time { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.na-title { font-weight: 650; font-size: 13.5px; line-height: 1.4; color: var(--text); text-decoration: none; }
.na-title:hover { color: var(--accent); }
.na-summary { margin: 0; font-size: 12px; line-height: 1.55; color: var(--muted); }
.na-foot { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 2px; }
.na-ticker {
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: var(--r);
  border: 1px solid var(--accent); background: var(--accent-weak); color: var(--accent);
  cursor: pointer;
}
.na-ticker:hover { background: var(--accent); color: #fff; }

/* related-news list inside the detail drawer */
.news .news-src {
  font-family: var(--mono); font-size: 9px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--accent); margin-right: 6px;
}

/* ============================================================= mobile === */

@media (max-width: 720px) {
  header { padding: 10px 12px; }
  .bar { gap: 8px 10px; align-items: center; }
  .bar h1 { letter-spacing: .08em; font-size: 12px; margin-bottom: 0; }
  .nav { margin: 0; }
  .nav a { padding: 7px 11px; }

  /* keep native form controls at >=16px so iOS doesn't zoom on focus */
  select, input, button { font-size: 16px; }
  .field label { font-size: 10px; }
  button.primary { padding: 10px 16px; }

  main { padding: 14px 12px; }
  .summary { gap: 6px; margin-bottom: 14px; }
  .chip { min-width: 0; flex: 1 1 88px; }

  section.tbl { margin-bottom: 20px; }
  .scroll { max-height: 72vh; }

  /* drawer becomes a full-width sheet */
  .drawer { width: 100vw; }
  .drawer .dhead, .dabout, .drawer .dbody { padding-left: 14px; padding-right: 14px; }
  .drawer h3 { margin-top: 18px; }
  .price-line .big { font-size: 22px; }
  .chart-ranges button { padding: 5px 10px; font-size: 11px; }

  /* screener */
  .scr-toolbar { gap: 6px 12px; }
  .scr-toolbar .grow { flex-basis: 100%; height: 0; margin: 0; }
  .scr-detail-inner { width: calc(100vw - 26px); padding: 14px 14px; }
  .scr-cats { grid-template-columns: 1fr; }
  .scr-metrics { line-height: 1.9; }

  /* guide */
  .guide h2 { margin-top: 24px; }
}

@media (max-width: 400px) {
  .bar h1 { letter-spacing: .04em; }
  main { padding: 12px 10px; }
}

/* ==================================================== accounts / watchlist === */

.auth-slot { display: inline-flex; align-items: center; margin-left: 6px; }

.auth-btn {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 3px 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}
.auth-btn:hover { color: var(--text); }
.auth-caret { font-size: 8px; opacity: .7; }
.auth-avatar { width: 18px; height: 18px; border-radius: 50%; object-fit: cover; }

.auth-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 60;
  min-width: 190px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.auth-menu-item {
  font: 12px var(--sans);
  text-align: left;
  color: var(--text);
  background: none;
  border: 0;
  border-radius: 0;
  padding: 9px 12px;
  cursor: pointer;
  text-decoration: none;
}
.auth-menu-item:hover { background: var(--row-hover); }

/* header "Sign in" call-to-action */
.auth-btn-in {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
.auth-btn-in:hover { color: #fff; filter: brightness(1.08); }

/* --------------------------------------------------- sign-in modal --- */

.auth-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(6, 9, 13, .62);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: auth-fade .14s ease-out;
}
.auth-modal-overlay[hidden] { display: none; }
@keyframes auth-fade { from { opacity: 0; } }

.auth-modal {
  position: relative;
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 26px 26px 22px;
  animation: auth-pop .16s ease-out;
}
@keyframes auth-pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }

.auth-modal-x {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 4px 8px;
  cursor: pointer;
}
.auth-modal-x:hover { color: var(--text); }

.auth-modal-brand {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
}
.auth-modal-brand .dot {
  width: 8px; height: 8px; border-radius: 1px; background: var(--accent);
}
.auth-modal h2 { margin: 12px 0 4px; font-size: 19px; }
.auth-modal-sub { margin: 0 0 18px; font-size: 12.5px; color: var(--muted); }

.auth-modal-btns { display: flex; flex-direction: column; gap: 9px; }
.auth-provider {
  display: flex;
  align-items: center;
  gap: 10px;
  font: 650 13px var(--sans);
  color: var(--text);
  text-decoration: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 14px;
}
.auth-provider:hover { background: var(--row-hover); }
.auth-provider:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.auth-provider-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  border-radius: 3px;
  font: 700 12px var(--mono);
  color: #fff;
}
.auth-provider-google .auth-provider-mark { background: #ea4335; }
.auth-provider-facebook .auth-provider-mark { background: #1877f2; }

.auth-modal-none { margin: 4px 0 0; font-size: 12px; color: var(--down); }
.auth-modal-fine { margin: 16px 0 0; font-size: 10.5px; color: var(--muted); text-align: center; }

/* star toggle in the detail drawer header */
.dhead-actions { display: flex; align-items: flex-start; gap: 4px; }
.wl-star {
  font-size: 17px;
  line-height: 1;
  color: var(--muted);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--r);
  padding: 2px 6px;
  cursor: pointer;
}
.wl-star:hover { color: var(--text); }
.wl-star.on { color: var(--accent); }

/* watchlist page */
.wl-gate { max-width: 460px; margin: 60px auto; text-align: center; }
.wl-gate h2 { margin: 0 0 8px; }
.wl-gate-btns { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.wl-gate-btns .primary { text-decoration: none; text-align: center; padding: 10px 14px; }

.wl-add { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.wl-add input {
  font: 12px var(--sans);
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 6px 9px;
  min-width: 200px;
}
.wl-msg { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.wl-msg.err { color: var(--down); }

.wl-remove {
  font-size: 15px;
  line-height: 1;
  color: var(--muted);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--r);
  padding: 1px 7px;
  cursor: pointer;
}
.wl-remove:hover { color: var(--down); border-color: var(--border); }

/* ================================================= legal / policy pages === */

.legal { max-width: 760px; margin: 0 auto; padding-bottom: 40px; }
.legal .legal-title { font-size: 22px; margin: 6px 0 2px; }
.legal .legal-meta { margin: 0 0 18px; font-size: 11px; color: var(--muted); font-family: var(--mono); }
.legal h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  margin: 30px 0 10px; padding-left: 9px; border-left: 3px solid var(--accent);
}
.legal h3 { font-size: 13.5px; margin: 18px 0 4px; }
.legal p { line-height: 1.65; font-size: 13.5px; margin: 0 0 12px; }
.legal ul { margin: 6px 0 14px; padding-left: 20px; line-height: 1.65; font-size: 13.5px; }
.legal li { margin: 4px 0; }
.legal a { color: var(--accent); }
.legal .mono { font-family: var(--mono); font-size: .92em; }
.legal .callout { margin: 14px 0 6px; }

.legal-foot {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  margin-top: 34px; padding-top: 16px; border-top: 1px solid var(--border);
  font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
}
.legal-foot a { color: var(--muted); text-decoration: none; }
.legal-foot a:hover { color: var(--text); }

/* privacy / terms links in the sign-in modal */
.auth-modal-legal { margin: 10px 0 0; font-size: 10.5px; color: var(--muted); text-align: center; }
.auth-modal-legal a { color: var(--muted); }
