/* RankOps v2 design system — dark, one accent, no framework. */
:root {
  --bg: #0a0f0d;
  --bg-raise: #111a16;
  --line: #1f2d26;
  --text: #f2f7f4;
  --text-dim: #9db3a8;
  --accent: #22c55e;
  --accent-press: #16a34a;
  --danger: #f87171;
  --warn: #fbbf24;
  --radius: 12px;
  --space-1: .5rem; --space-2: 1rem; --space-3: 1.5rem; --space-4: 2.5rem; --space-5: 4rem;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}
* { box-sizing: border-box; margin: 0; }
html { scroll-behavior: smooth; }
body { background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.6; font-size: 17px; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 var(--space-3); }
main { display: block; }
img { max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: clamp(1.9rem, 4.5vw, 3rem); line-height: 1.15; letter-spacing: -.02em; }
h2 { font-size: clamp(1.35rem, 3vw, 1.9rem); line-height: 1.25; margin-bottom: var(--space-2); }
h3 { font-size: 1.15rem; }
p + p { margin-top: var(--space-2); }

/* nav */
.nav { position: sticky; top: 0; z-index: 50; background: rgba(10,15,13,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.nav-row { display: flex; align-items: center; justify-content: space-between; padding: .8rem var(--space-3); }
.brand { font-weight: 800; font-size: 1.25rem; color: var(--text); }
.brand span { color: var(--accent); }
.brand:hover { text-decoration: none; }
.nav-links { display: flex; gap: var(--space-3); align-items: center; }
.nav-links a { color: var(--text-dim); font-weight: 500; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-toggle { display: none; background: none; border: 0; color: var(--text); font-size: 1.5rem; cursor: pointer; }
@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .nav-links { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; background: var(--bg-raise); padding: var(--space-3); border-bottom: 1px solid var(--line); }
  .nav-links.open { display: flex; }
}

/* buttons — ONE primary weight; it is THE cta */
.btn-primary { display: inline-block; background: var(--accent); color: #04170c; font-weight: 700; padding: .9rem 1.6rem; border-radius: var(--radius); border: 0; cursor: pointer; font-size: 1.05rem; }
.btn-primary:hover { background: var(--accent-press); text-decoration: none; }
.btn-sm { padding: .5rem 1rem; font-size: .95rem; }
.btn-ghost { display: inline-block; color: var(--text-dim); padding: .9rem 1rem; }
.btn-block { display: block; width: 100%; text-align: center; }

/* sections + components */
section { padding: var(--space-5) 0; }
.hero { padding: var(--space-5) 0 var(--space-4); }
.eyebrow { color: var(--accent); font-weight: 700; text-transform: uppercase; font-size: .8rem; letter-spacing: .1em; }
.lead { font-size: 1.2rem; color: var(--text-dim); max-width: 46rem; margin-top: var(--space-2); }
.speakable { font-size: 1.05rem; }
.card { background: var(--bg-raise); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-3); }
.grid-3 { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-2 { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.proof-band { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; padding: var(--space-3); background: var(--bg-raise); border: 1px solid var(--line); border-radius: var(--radius); }
.proof-band strong { color: var(--accent); font-size: 1.3rem; display: block; }
.price { font-size: 2.2rem; font-weight: 800; }
.price small { font-size: 1rem; color: var(--text-dim); font-weight: 500; }
.check-list { list-style: none; padding: 0; }
.check-list li { padding: .4rem 0 .4rem 1.7rem; position: relative; }
.check-list li::before { content: "✓"; color: var(--accent); position: absolute; left: 0; font-weight: 700; }
.faq details { border-bottom: 1px solid var(--line); padding: var(--space-2) 0; }
.faq summary { font-weight: 600; cursor: pointer; }
.faq p { margin-top: var(--space-1); color: var(--text-dim); }
.note { color: var(--text-dim); font-size: .9rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .7rem; border-bottom: 1px solid var(--line); }
th { color: var(--text-dim); font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; }

/* forms */
input, select, textarea { background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: .8rem; font-size: 1rem; width: 100%; font-family: var(--font); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
.code-out { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 1rem; overflow-x: auto; font-size: .8rem; max-height: 320px; white-space: pre-wrap; word-break: break-word; }
.faq-row { display: flex; gap: .5rem; margin: .5rem 0; align-items: flex-start; }
.faq-row input, .faq-row textarea { flex: 1; }
.row-del { background: none; border: 0; color: var(--danger); font-size: 1.3rem; cursor: pointer; }
.check-form { display: grid; gap: var(--space-2); max-width: 30rem; }
.nl-form { display: flex; gap: var(--space-1); margin-top: var(--space-1); }

/* score gauge + reveal (track page) */
.gauge-wrap { display: grid; place-items: center; padding: var(--space-3); }
.gauge { position: relative; width: 180px; height: 180px; }
.gauge svg { transform: rotate(-90deg); }
.gauge-num { position: absolute; inset: 0; display: grid; place-items: center; font-size: 2.6rem; font-weight: 800; }
.tier-badge { display: inline-block; padding: .25rem .8rem; border-radius: 99px; background: var(--bg-raise); border: 1px solid var(--accent); color: var(--accent); font-weight: 700; }
.check-row { display: flex; gap: .6rem; padding: .45rem 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.check-row.pass::before { content: "✓"; color: var(--accent); font-weight: 700; }
.check-row.gated { color: var(--text-dim); font-style: italic; }
.check-row.gated::before { content: "🔒"; }
.kpi-row { display: grid; gap: var(--space-2); grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.kpi { background: var(--bg-raise); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-2); text-align: center; }
.kpi strong { display: block; font-size: 1.8rem; color: var(--accent); }
.kpi span { color: var(--text-dim); font-size: .85rem; }
.hidden { display: none !important; }
.status-cited { color: var(--accent); font-weight: 600; }
.status-miss { color: var(--danger); font-weight: 600; }
.status-retry { color: var(--warn); font-weight: 600; }
/* The AI's answer under each tracked prompt: clamped to 3 lines, click to
   toggle the full text. */
.ai-answer { margin: .35rem 0 0; color: var(--text-dim); font-size: .85rem; line-height: 1.5; cursor: pointer; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.ai-answer.open { display: block; overflow: visible; }
.ai-answer:hover { color: var(--text); }

/* footer */
.footer { border-top: 1px solid var(--line); margin-top: var(--space-5); padding: var(--space-4) 0 var(--space-2); color: var(--text-dim); font-size: .95rem; }
.footer-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.footer-grid a { display: block; color: var(--text-dim); padding: .15rem 0; }
.footer-h { font-weight: 700; color: var(--text); margin-bottom: var(--space-1); }
.footer-legal { margin-top: var(--space-4); padding-top: var(--space-2); border-top: 1px solid var(--line); font-size: .85rem; }

/* reveal on scroll */
.reveal { opacity: 0; transform: translateY(12px); transition: all .5s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } }

/* ── lead board (/track/) ──────────────────────────────────────────────── */
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.board-section { padding-top: var(--space-4); }
.board-title-row { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-3); }
.board-title-row .lead { margin-top: .6rem; font-size: 1.05rem; }
.board-actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; padding-bottom: .3rem; }
.btn-outline { border: 1px solid var(--line); border-radius: 8px; padding: .55rem 1rem; font-size: .95rem; color: var(--text-dim); background: var(--bg-raise); cursor: pointer; font-family: var(--font); }
.btn-outline:hover { color: var(--text); border-color: var(--text-dim); text-decoration: none; }
.tab-dot { display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; background: var(--accent); margin: 0 .35rem 0 .1rem; vertical-align: middle; }

/* summary tiles */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .6rem; margin-bottom: var(--space-2); }
.stat { background: var(--bg-raise); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem; }
.stat strong { display: block; font-size: 1.35rem; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat span { color: var(--text-dim); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
#st-hot { color: var(--warn); }
#st-sold { color: var(--accent); }

/* toolbar */
.board-toolbar { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin-bottom: .8rem; }
.toolbar-right { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.chip-row { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { background: var(--bg-raise); border: 1px solid var(--line); color: var(--text-dim); border-radius: 99px; padding: .35rem .85rem; font-size: .88rem; cursor: pointer; font-family: var(--font); }
.chip em { font-style: normal; opacity: .7; margin-left: .25rem; font-variant-numeric: tabular-nums; }
.chip:hover { color: var(--text); }
.chip[aria-pressed="true"] { background: rgba(34,197,94,.12); border-color: var(--accent); color: var(--accent); }
#board-search { max-width: 16rem; padding: .5rem .9rem; font-size: .92rem; border-radius: 99px; }

/* the table */
/* The board is wider than the page, so it scrolls sideways on desktop. Nobody
   discovers that on their own: .board-scroller is the positioned parent for a
   right-edge fade, toggled by updateBoardScroll() in track.js, paired with the
   #board-hint line. Below 760px the table stops being a table (see the mobile
   block) and neither cue applies. */
.board-scroller { position: relative; }
.board-scroller::after { content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: 3rem; pointer-events: none; opacity: 0; transition: opacity .2s ease; border-radius: 0 var(--radius) var(--radius) 0; background: linear-gradient(to right, rgba(17,26,22,0), rgba(17,26,22,.95)); }
.board-scroller.can-scroll-x::after { opacity: 1; }
.board-hint { margin-top: .5rem; }
.board-sort { display: none; }
.board-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: 65vh; background: var(--bg-raise); }
table.board { font-size: .93rem; }
/* Only the 11-column Lead Board needs the wide min-width; the war-room tables
   (2-col leaderboard, tracked prompts) should fit their container instead of
   forcing horizontal scroll that hides the count column. */
#board-table { min-width: 1080px; }
#wr-leaderboard td:first-child { white-space: normal; word-break: break-word; }
.board thead th { position: sticky; top: 0; background: var(--bg-raise); z-index: 2; border-bottom: 1px solid var(--line); padding: 0; }
.board thead th button { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text-dim); font-family: var(--font); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; padding: .65rem .7rem; cursor: pointer; white-space: nowrap; }
.board thead th button:hover { color: var(--text); }
.board th.sort-asc button::after { content: " ↑"; color: var(--accent); }
.board th.sort-desc button::after { content: " ↓"; color: var(--accent); }
.board td { padding: .45rem .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.board tbody tr:hover { background: rgba(255,255,255,.025); }
.board tbody tr:last-child td { border-bottom: 0; }
.board td.num { text-align: right; font-variant-numeric: tabular-nums; }
.board th.num button { text-align: right; }
.board .dim { color: var(--text-dim); }
.board .issue { max-width: 15rem; overflow: hidden; text-overflow: ellipsis; }
.board .site-link { color: var(--text-dim); }
.board .site-link:hover { color: var(--accent); }
.board-none { padding: var(--space-3); }
.linklike { background: none; border: 0; color: var(--text); font: inherit; font-family: var(--font); font-weight: 600; cursor: pointer; padding: 0; }
.linklike:hover { color: var(--accent); }

/* score + status pills */
.score-pill { display: inline-block; min-width: 2.5rem; text-align: center; padding: .12rem .5rem; border-radius: 99px; font-weight: 700; font-variant-numeric: tabular-nums; border: 1px solid var(--line); }
.score-pill.s-low { color: var(--danger); border-color: rgba(248,113,113,.4); background: rgba(248,113,113,.1); }
.score-pill.s-mid { color: var(--warn); border-color: rgba(251,191,36,.4); background: rgba(251,191,36,.1); }
.score-pill.s-high { color: var(--accent); border-color: rgba(34,197,94,.4); background: rgba(34,197,94,.1); }
.score-pill.s-none { color: var(--text-dim); }
select.status-pill { width: auto; padding: .28rem .6rem; font-size: .85rem; font-weight: 600; border-radius: 99px; background: var(--bg); cursor: pointer; }
select.status-pill[data-status="hot"] { color: var(--warn); border-color: rgba(251,191,36,.55); }
select.status-pill[data-status="pending"] { color: var(--text-dim); }
select.status-pill[data-status="completed"] { color: var(--text); border-color: var(--text-dim); }
select.status-pill[data-status="sold"] { color: var(--accent); border-color: rgba(34,197,94,.55); }
select.status-pill option { color: var(--text); background: var(--bg-raise); }

/* inline-edit cells */
.cell-edit { background: transparent; border: 1px solid transparent; padding: .3rem .5rem; font-size: .9rem; border-radius: 6px; width: 11rem; }
.cell-edit:hover { border-color: var(--line); }
.cell-edit:focus { background: var(--bg); }
.cell-edit::placeholder { color: var(--text-dim); opacity: .55; font-style: italic; }

/* row menu */
.actions-col { width: 2.6rem; }
.row-actions { text-align: right; }
.row-menu { position: relative; display: inline-block; }
.row-menu summary { list-style: none; cursor: pointer; color: var(--text-dim); padding: .1rem .55rem; border-radius: 6px; font-weight: 700; user-select: none; }
.row-menu summary::-webkit-details-marker { display: none; }
.row-menu summary:hover { color: var(--text); background: rgba(255,255,255,.05); }
/* fixed, not absolute: escapes .board-wrap's overflow:auto instead of being
   clipped by it; JS sets left/top from the summary's real viewport rect. */
.row-menu .menu { position: fixed; z-index: 95; background: var(--bg-raise); border: 1px solid var(--line); border-radius: 8px; padding: .3rem; min-width: 10.5rem; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.row-menu .menu button { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text); padding: .45rem .7rem; border-radius: 6px; cursor: pointer; font-size: .9rem; font-family: var(--font); }
.row-menu .menu button:hover { background: rgba(255,255,255,.06); }
.row-menu .menu button.danger { color: var(--danger); }
.row-menu .menu-confirm { padding: .4rem .7rem .55rem; margin: 0; font-size: .85rem; color: var(--text-dim); white-space: normal; }

/* audit panel + lead drawer */
.check-panel { background: var(--bg-raise); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-3); }
.check-panel.inline { max-width: 34rem; margin-top: var(--space-2); }
.check-panel.over { position: fixed; top: 0; right: 0; bottom: 0; width: min(26rem, 100%); z-index: 70; border-radius: 0; border: 0; border-left: 1px solid var(--line); transform: translateX(100%); visibility: hidden; transition: transform .25s ease, visibility 0s linear .25s; overflow-y: auto; }
.check-panel.over.open { transform: none; visibility: visible; transition: transform .25s ease, visibility 0s; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-2); }
.panel-close { background: none; border: 0; color: var(--text-dim); font-size: 1.6rem; cursor: pointer; line-height: 1; }
.panel-close:hover { color: var(--text); }
.field-2 { display: grid; gap: .8rem; grid-template-columns: 1fr 1fr; }
.prospect-toggle { display: flex; gap: .5rem; align-items: center; }
.prospect-toggle input { width: auto; }
.empty-intro { max-width: 34rem; margin-top: var(--space-3); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(28rem, 100%); z-index: 80; background: var(--bg-raise); border-left: 1px solid var(--line); overflow-y: auto; padding: var(--space-3); transform: translateX(100%); transition: transform .25s ease; }
.drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.drawer-head h2 { margin-bottom: .2rem; }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 60; }
/* Sticky, not just last-in-the-drawer: on a phone the results ended in nothing
   to do, and the page's "Citation Tracker" button sits behind the backdrop
   while the drawer is open. Negative margins bleed it through .drawer's padding. */
/* bottom is the negative of .drawer's padding, not 0: sticky measures from the
   scrollport's padding edge, so bottom:0 parks it 1.5rem short of the drawer's
   real bottom and leaves a gap under the buttons. */
.drawer-cta { position: sticky; bottom: calc(-1 * var(--space-3)); display: grid; gap: .6rem; margin: var(--space-3) calc(-1 * var(--space-3)) calc(-1 * var(--space-3)); padding: var(--space-3); background: var(--bg-raise); border-top: 1px solid var(--line); }
@media (max-width: 760px) {
  .board-title-row { align-items: flex-start; }
  #board-search { max-width: 100%; flex: 1; }
  .field-2 { grid-template-columns: 1fr; }
  .toolbar-right { width: 100%; }
  .board-sort { display: block; width: auto; }

  /* No sideways scrolling on a phone: the 11-column board becomes one stacked
     card per lead, every field labelled in place from its td[data-label] (set
     in buildRow). Scoped to #board-table so the war-room leaderboard and the
     tracked-prompts table stay real tables. */
  .board-scroller::after { display: none; }
  /* only the lead board's wrap sheds its frame — the war-room tables keep theirs */
  .board-scroller .board-wrap { overflow: visible; max-height: none; border: 0; background: none; border-radius: 0; }
  #board-table { min-width: 0; display: block; font-size: 1rem; }
  #board-table thead { display: none; }
  #board-table tbody { display: block; }
  #board-table tbody tr { display: block; position: relative; background: var(--bg-raise); border: 1px solid var(--line); border-radius: var(--radius); padding: .3rem .9rem .5rem; margin-bottom: .7rem; }
  #board-table tbody tr:hover { background: var(--bg-raise); }
  /* separators go between the stacked fields (border-top), not after the last
     one, so no card ends in a dangling rule */
  #board-table td { display: grid; grid-template-columns: 6.2rem 1fr; gap: .5rem; align-items: center; white-space: normal; overflow-wrap: anywhere; padding: .38rem 0; line-height: 1.4; text-align: left; border-bottom: 0; }
  #board-table td + td { border-top: 1px solid var(--line); }
  #board-table td::before { content: attr(data-label); color: var(--text-dim); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
  #board-table td:first-child { padding-right: 2.5rem; }
  #board-table td.num { text-align: left; }
  #board-table td.issue { max-width: none; overflow: visible; text-overflow: clip; }
  #board-table .cell-edit { width: 100%; border-color: var(--line); }
  /* the ⋯ menu pins to the card's top-right instead of taking a labelled row */
  #board-table td.row-actions { position: absolute; top: .5rem; right: .5rem; display: block; padding: 0; border: 0; }
  #board-table td.row-actions::before { content: none; }
  /* tracked prompts on the tracker dashboard: also no sideways scroll */
  #db-prompts td { white-space: normal; }
}
@media (prefers-reduced-motion: reduce) { .drawer, .check-panel.over { transition: none; } }

/* ── citation tracker war room ───────────────────────────────────────────── */
.wr-you-row td { color: var(--accent); font-weight: 700; }
.src-row { display: flex; justify-content: space-between; padding: .4rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.src-row:last-child { border-bottom: 0; }
.evt-row { padding: .5rem 0; border-bottom: 1px solid var(--line); font-size: .92rem; line-height: 1.5; }
.evt-row:last-child { border-bottom: 0; }
.wr-history { display: flex; gap: .28rem; align-items: center; }
.wr-dot { width: .5rem; height: .5rem; border-radius: 50%; flex: none; display: inline-block; }
.wr-dot.cited { background: var(--accent); }
.wr-dot.miss { background: var(--danger); opacity: .6; }
.wr-dot.error { background: var(--warn); opacity: .6; }
.wr-spark-empty { margin-top: .5rem; }
