/* LBO Console — dense triage table.
 *
 * Design language ported from the FIFA LMS explorer (lms-explorer.html): system
 * sans for chrome, mono numerals for data, --band troughs with raised white
 * pills for controls, 4px-radius chips, and a 45° hatch for "hasn't happened
 * yet". Its base tokens are byte-identical to pentupinnovation.com's, so one
 * token layer serves both.
 *
 * Two rules make dark mode actually work:
 *   1. Every colour comes from a token. The FIFA renderers write
 *      style="background:rgb(...)" into markup, which cannot respond to a theme
 *      flip without a full re-render. Here every chip is a class bound to tokens.
 *   2. The sticky-header seam uses var(--bg), never a hard-coded white — that
 *      hard-code is what paints white gaps across every row in dark mode.
 */

:root {
  color-scheme: light dark;

  --bg: #ffffff;
  --surface: #f8fafc;
  --band: #eef2f6;
  --rule: #e2e8f0;
  --rule-strong: #94a3b8;

  --ink: #1a2332;
  --ink-2: #2d3748;
  --muted: #64748b;
  --muted-2: #94a3b8;

  --red: #c8102e;
  --red-deep: #a50d1f;
  --green: #00a651;
  --green-dark: #009146;
  --gold: #f5a623;
  --blue: #3b82f6;

  --tint-red: #fdecef;
  --tint-green: #e6f9ef;
  --tint-gold: #fef7e6;
  --tint-blue: #eff6ff;

  --shadow-pill: 0 1px 2px rgba(0, 0, 0, .08);
  --shadow-panel: 0 8px 24px rgba(0, 0, 0, .12);

  --row-h: 24px;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'SF Mono', Monaco, 'Cascadia Code', ui-monospace, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f151d;
    --surface: #151d27;
    --band: #1b2531;
    --rule: #2a3644;
    --rule-strong: #46586d;

    --ink: #e6edf5;
    --ink-2: #c4d0de;
    --muted: #8b9bb0;
    --muted-2: #6b7b8f;

    --red: #ff5c73;
    --red-deep: #ff8095;
    --green: #3ddc8a;
    --green-dark: #2fc077;
    --gold: #ffc457;
    --blue: #6ea8fe;

    --tint-red: #2a1720;
    --tint-green: #10281f;
    --tint-gold: #2b2113;
    --tint-blue: #142031;

    --shadow-pill: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-panel: 0 8px 24px rgba(0, 0, 0, .55);
  }
}

:root[data-theme="dark"] {
  --bg: #0f151d;
  --surface: #151d27;
  --band: #1b2531;
  --rule: #2a3644;
  --rule-strong: #46586d;
  --ink: #e6edf5;
  --ink-2: #c4d0de;
  --muted: #8b9bb0;
  --muted-2: #6b7b8f;
  --red: #ff5c73;
  --red-deep: #ff8095;
  --green: #3ddc8a;
  --green-dark: #2fc077;
  --gold: #ffc457;
  --blue: #6ea8fe;
  --tint-red: #2a1720;
  --tint-green: #10281f;
  --tint-gold: #2b2113;
  --tint-blue: #142031;
  --shadow-pill: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-panel: 0 8px 24px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* The WC26 stripe, reworked: red / gold / green reads as bad → middling → good,
 * which is the axis this whole table sorts on. */
.stripe {
  height: 4px;
  background: linear-gradient(90deg,
    var(--red) 0, var(--red) 33%, var(--gold) 33%,
    var(--gold) 66%, var(--green-dark) 66%, var(--green-dark) 100%);
}

/* ── header ───────────────────────────────────────────────────────────────── */
header {
  display: flex; align-items: baseline; gap: 12px;
  padding: 12px 20px 8px;
}
h1 { font-size: 17px; font-weight: 800; margin: 0; letter-spacing: -.3px; }
.sub { color: var(--muted); font-size: 12.5px; }
.spacer { flex: 1; }

/* ── controls ─────────────────────────────────────────────────────────────── */
.controls {
  display: flex; gap: 9px; align-items: center; flex-wrap: wrap;
  padding: 0 20px 10px;
}
.seg { display: inline-flex; background: var(--band); border-radius: 8px; padding: 2px; }
.seg button {
  border: 0; background: transparent; font: inherit; font-size: 12.5px;
  font-weight: 700; color: var(--muted); padding: 5px 10px;
  border-radius: 6px; cursor: pointer;
}
.seg button.on { background: var(--bg); color: var(--ink); box-shadow: var(--shadow-pill); }

.tog, .btn {
  border: 1px solid var(--rule); background: var(--bg); border-radius: 8px;
  padding: 5px 11px; font: inherit; font-size: 12.5px; font-weight: 700;
  color: var(--muted); cursor: pointer;
}
.tog[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); background: var(--surface); }
.tog:focus-visible, .btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }

input[type="search"] {
  font: inherit; font-size: 12.5px; border: 1px solid var(--rule);
  border-radius: 8px; padding: 5px 9px; min-width: 220px;
  background: var(--bg); color: var(--ink);
}

/* Dropdown panel — native <details>, marker suppressed. */
details.dd { position: relative; }
details.dd > summary {
  list-style: none; cursor: pointer; border: 1px solid var(--rule);
  border-radius: 8px; padding: 5px 12px; font-weight: 700; font-size: 12.5px;
  color: var(--ink); background: var(--bg); white-space: nowrap;
}
details.dd > summary::-webkit-details-marker { display: none; }
details.dd > summary::after { content: ' \25BE'; color: var(--muted); }
.panel {
  position: absolute; z-index: 30; margin-top: 4px; background: var(--bg);
  border: 1px solid var(--rule); border-radius: 9px; box-shadow: var(--shadow-panel);
  padding: 8px; min-width: 280px; max-height: 460px; overflow: auto;
}
.panel .row {
  display: flex; align-items: center; gap: 7px; padding: 3px 5px;
  border-radius: 5px; font-size: 13px; white-space: nowrap; cursor: pointer;
}
.panel .row:hover { background: var(--surface); }
.panel .ghead {
  font-weight: 800; color: var(--muted); font-size: 11px;
  text-transform: uppercase; padding: 8px 5px 2px; letter-spacing: .06em;
}
.panel .allnone { display: flex; gap: 6px; padding: 2px 4px 6px; }
.panel .allnone button {
  font: inherit; font-size: 12px; font-weight: 700; border: 1px solid var(--rule);
  background: var(--bg); border-radius: 6px; padding: 3px 9px; cursor: pointer;
  color: var(--green-dark);
}
.panel hr { border: 0; border-top: 1px solid var(--rule); margin: 8px 0 4px; }
.panel .hidden-head { color: var(--red); }

/* ── table ────────────────────────────────────────────────────────────────── */
#view { overflow: auto; padding: 0 20px 8px; }

/* border-spacing:0, NOT the FIFA file's 2px. That 2px gutter does not survive
 * column pinning: sticky left offsets stop being a clean sum of widths, the
 * gutters are transparent so rows bleed through beside a pinned cell, and the
 * box-shadow that plugs it only works for one hard-coded background colour. */
/* table-layout:fixed so a dragged width is obeyed rather than negotiated away by
 * content. Cells clip instead of pushing their neighbours around. */
table {
  border-collapse: separate; border-spacing: 0;
  font-family: var(--mono); table-layout: fixed;
}

th, td {
  border-bottom: 1px solid var(--rule);
  padding: 0 8px; height: var(--row-h);
  font-size: 11.5px; text-align: left; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

/* Column resize grip: a 9px hit strip straddling the header's right edge. Wider
 * than it looks, because a 1px target is a fight. */
th .rz {
  position: absolute; top: 0; right: -4px; width: 9px; height: 100%;
  cursor: col-resize; z-index: 7;
}
th .rz::after {
  content: ""; position: absolute; left: 4px; top: 3px; bottom: 3px;
  width: 1px; background: transparent;
}
th:hover .rz::after { background: var(--rule-strong); }
th .rz:hover::after, th .rz.dragging::after { background: var(--blue); width: 2px; }
thead tr.cols th { position: sticky; }
body.resizing { cursor: col-resize; user-select: none; }
thead th {
  position: sticky; z-index: 3; background: var(--bg);
  font-family: var(--sans); font-weight: 800;
}
thead tr.grp th {
  z-index: 4; font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted);
  border-bottom: 2px solid var(--rule); background: var(--surface);
}
thead tr.grp th + th { border-left: 2px solid var(--rule-strong); }
thead tr.cols th { font-size: 11px; color: var(--ink); cursor: pointer; user-select: none; }
thead tr.cols th:hover { background: var(--surface); }
thead tr.cols th.sorted { color: var(--blue); }
thead tr.cols th.gstart, tbody td.gstart { border-left: 2px solid var(--rule-strong); }

.gtog {
  border: 0; background: transparent; font: inherit; font-weight: 800;
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); cursor: pointer; padding: 0;
}
.gtog:hover { color: var(--ink); }
.gtog .n { color: var(--muted-2); font-weight: 700; }

th.pin, td.pin { position: sticky; z-index: 2; background: var(--bg); }
thead th.pin { z-index: 5; }
thead tr.grp th.pin { z-index: 6; background: var(--surface); }
.pin-l.edge { box-shadow: 2px 0 0 var(--rule-strong); }
.pin-r.edge { box-shadow: -2px 0 0 var(--rule-strong); }

tbody tr:hover td { background: var(--surface); }
tbody tr:hover td.pin { background: var(--surface); }
tbody tr.sel td, tbody tr.sel td.pin { background: var(--tint-blue); }
tbody tr.trashed td { opacity: .42; }
tbody tr.trashed td.c-name { text-decoration: line-through; }

td.c-name { font-family: var(--sans); font-weight: 700; font-size: 12px; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.txt { font-family: var(--sans); font-size: 11.5px; }
td.txt span { display: inline-block; max-width: 46ch; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.dim { color: var(--muted-2); }
a { color: var(--blue); }

/* ── chips ────────────────────────────────────────────────────────────────── */
.chip {
  display: inline-block; padding: 1px 6px; border-radius: 4px;
  font-family: var(--sans); font-size: 10.5px; font-weight: 700;
  letter-spacing: .02em;
}
.grade { min-width: 30px; text-align: center; color: #fff; }
.grade[data-v^="A"] { background: var(--green-dark); }
.grade[data-v^="B"] { background: var(--green); }
.grade[data-v^="C"] { background: var(--gold); color: #4a2d00; }
.grade[data-v^="D"] { background: var(--red); color: #fff; }
.grade[data-v="F"], .grade[data-v="NONE"] { background: var(--red-deep); color: #fff; }

.band[data-v="thriving"] { background: var(--tint-green); color: var(--green-dark); }
.band[data-v="active"]   { background: var(--tint-green); color: var(--green-dark); }
.band[data-v="quiet"]    { background: var(--tint-gold); color: #8a5b00; }
.band[data-v="dormant"]  { background: var(--tint-red); color: var(--red); }
.band[data-v="unknown"]  { background: var(--band); color: var(--muted); }

.pen { background: var(--tint-red); color: var(--red); }
.ok-mark { color: var(--green-dark); font-weight: 700; }
.no-mark { color: var(--muted-2); }

/* Screenshot / evidence absent — the FIFA "hasn't happened yet" idiom.
 * Deliberately not a colour: absence is a different kind of fact from a value. */
.hatch {
  display: inline-block; width: 16px; height: 11px; border-radius: 3px;
  background: var(--band);
  background-image: repeating-linear-gradient(45deg,
    var(--rule-strong) 0 3px, transparent 3px 6px);
  vertical-align: -1px;
}

/* ── disposition ──────────────────────────────────────────────────────────── */
td.c-disposition { padding: 0 6px; }
select.disp {
  font: inherit; font-family: var(--sans); font-size: 11px; font-weight: 700;
  border: 1px solid var(--rule); border-radius: 5px; padding: 1px 4px;
  background: var(--bg); color: var(--muted); cursor: pointer; width: 100%;
}
td.c-disposition[data-v="send"]                select.disp { background: var(--green-dark); color: #fff; border-color: transparent; }
td.c-disposition[data-v="maybe-send"]          select.disp { background: var(--tint-gold); color: #8a5b00; border-color: var(--gold); }
td.c-disposition[data-v="monitor"]             select.disp { background: var(--tint-blue); color: var(--blue); border-color: var(--blue); }
td.c-disposition[data-v="trash"]               select.disp { background: var(--tint-red); color: var(--red); border-color: var(--red); }
td.c-disposition[data-v="hold-until-complete"] select.disp {
  color: var(--ink-2); border-color: var(--rule-strong);
  background-image: repeating-linear-gradient(45deg,
    var(--rule) 0 3px, transparent 3px 6px);
}

/* ── context menu ─────────────────────────────────────────────────────────── */
.ctx {
  position: fixed; z-index: 60; background: var(--bg); border: 1px solid var(--rule);
  border-radius: 9px; box-shadow: var(--shadow-panel); padding: 5px; min-width: 240px;
}
.ctx button {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  font: inherit; font-family: var(--sans); font-size: 12.5px; color: var(--ink);
  padding: 5px 9px; border-radius: 5px; cursor: pointer;
}
.ctx button:hover, .ctx button:focus-visible { background: var(--surface); outline: none; }
.ctx button.danger { color: var(--red); }
.ctx hr { border: 0; border-top: 1px solid var(--rule); margin: 4px 2px; }

/* ── bulk bar, toast, banner ──────────────────────────────────────────────── */
.bulk {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  z-index: 50; display: flex; gap: 10px; align-items: center;
  background: var(--ink); color: var(--bg); border-radius: 10px;
  padding: 8px 14px; box-shadow: var(--shadow-panel);
  font-family: var(--sans); font-size: 13px; font-weight: 700;
}
.bulk select, .bulk button {
  font: inherit; font-size: 12.5px; border-radius: 6px; border: 0;
  padding: 4px 9px; cursor: pointer;
}

.toast {
  position: fixed; bottom: 18px; right: 18px; z-index: 70;
  background: var(--ink); color: var(--bg); border-radius: 9px;
  padding: 9px 14px; font-family: var(--sans); font-size: 13px;
  box-shadow: var(--shadow-panel); display: flex; gap: 12px; align-items: center;
}
.toast button {
  font: inherit; font-weight: 800; border: 0; background: transparent;
  color: var(--gold); cursor: pointer; padding: 0;
}

.banner {
  margin: 0 20px 10px; padding: 8px 12px; border-radius: 8px;
  background: var(--tint-gold); border: 1px solid var(--gold);
  border-left: 4px solid var(--gold); color: var(--ink);
  font-family: var(--sans); font-size: 12.5px;
}
.banner.err { background: var(--tint-red); border-color: var(--red); border-left-color: var(--red); }

/* ── sign-in ──────────────────────────────────────────────────────────────── */
.gate { max-width: 380px; margin: 14vh auto; text-align: center; font-family: var(--sans); }
.gate h2 { font-size: 20px; font-weight: 800; letter-spacing: -.4px; margin: 18px 0 6px; }
.gate p { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 0 0 20px; }
.gate .btn { font-size: 14px; padding: 10px 20px; color: var(--ink); }
.gate .bar { height: 4px; width: 58px; margin: 0 auto; border-radius: 3px;
  background: linear-gradient(90deg, var(--red), var(--gold), var(--green-dark)); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
