/* TFRRS dashboard — tokens from the validated reference palette.
   Light values on :root; dark redefined under both the OS media query and the
   explicit [data-theme] scope so the toggle wins in either direction. */
:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;   /* outdoor */
  --series-2: #eb6834;   /* indoor  */
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --success-text: #006300;
  --wash: rgba(42, 120, 214, 0.08);
  --radius: 10px;
  --shadow: 0 1px 2px rgba(11,11,11,.04), 0 4px 12px rgba(11,11,11,.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #d95926;
    --success-text: #0ca30c;
    --wash: rgba(57, 135, 229, 0.14);
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --page: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-2: #d95926;
  --success-text: #0ca30c;
  --wash: rgba(57, 135, 229, 0.14);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--series-1); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- shell ---------------------------------------------------------------- */
header.top {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex; align-items: center; gap: 24px;
  min-height: 56px; flex-wrap: wrap;
}
.brand { font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; }
.brand span { color: var(--muted); font-weight: 450; }
nav.main { display: flex; gap: 4px; flex-wrap: wrap; }
nav.main a {
  color: var(--text-secondary); padding: 6px 11px;
  border-radius: 7px; font-size: 14px; font-weight: 500;
}
nav.main a:hover { background: var(--wash); text-decoration: none; }
nav.main a.active { background: var(--wash); color: var(--series-1); }
.spacer { flex: 1; }
.theme-toggle {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-secondary); border-radius: 7px;
  padding: 5px 10px; cursor: pointer; font-size: 13px; font-family: inherit;
}
.theme-toggle:hover { background: var(--wash); }

main { max-width: 1220px; margin: 0 auto; padding: 26px 24px 72px; }
h1 { font-size: 22px; margin: 0 0 3px; letter-spacing: -0.02em; }
h2 { font-size: 15px; margin: 30px 0 12px; letter-spacing: -0.01em; }
.sub { color: var(--text-secondary); font-size: 14px; margin: 0 0 22px; }

/* --- cards ---------------------------------------------------------------- */
.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.pad { padding: 18px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 12px; }
.tile { padding: 15px 16px; }
.tile .label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 600;
}
.tile .value {
  font-size: 27px; font-weight: 640; letter-spacing: -0.025em;
  margin-top: 5px; line-height: 1.12;
}
.tile .note { font-size: 12.5px; color: var(--text-secondary); margin-top: 3px; }

/* --- status --------------------------------------------------------------- */
.status { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: 14px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.status.good .dot { background: var(--good); }
.status.warning .dot { background: var(--warning); }
.status.critical .dot { background: var(--critical); }
.status.good { color: var(--success-text); }
.status.warning { color: #8a6100; }
.status.critical { color: var(--critical); }
:root[data-theme="dark"] .status.warning { color: var(--warning); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .status.warning { color: var(--warning); }
}

/* --- chart ---------------------------------------------------------------- */
.legend { display: flex; gap: 16px; align-items: center; font-size: 13px; color: var(--text-secondary); margin-bottom: 14px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: -1px; }
.bars { display: grid; gap: 13px; }
.bar-row { display: grid; grid-template-columns: 92px 1fr 104px; gap: 12px; align-items: center; }
/* School names are long; give them room and clip rather than wrapping to a
   second line, which would make the bar rows uneven heights. */
.bars.wide-labels .bar-row { grid-template-columns: 152px 1fr 74px; }
.bars.wide-labels .bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-label { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.bar-track { display: flex; gap: 2px; height: 19px; align-items: stretch; }
.bar-seg { border-radius: 0; min-width: 2px; position: relative; }
.bar-seg:first-child { border-radius: 4px 0 0 4px; }
.bar-seg:last-child { border-radius: 0 4px 4px 0; }
.bar-seg:only-child { border-radius: 4px; }
.bar-value { font-size: 13px; color: var(--text-secondary); text-align: right; font-variant-numeric: tabular-nums; }

/* --- tables --------------------------------------------------------------- */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); font-weight: 600;
  padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 9px 12px; border-bottom: 1px solid var(--grid); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--wash); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mark { font-variant-numeric: tabular-nums; font-weight: 600; }
.place { color: var(--muted); font-variant-numeric: tabular-nums; width: 30px; }
.place.win { color: var(--series-1); font-weight: 650; }
.dim { color: var(--text-secondary); }
.tiny { font-size: 12.5px; }

/* --- controls ------------------------------------------------------------- */
.filters { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
input[type=text], input[type=search], input[type=number], select {
  background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 11px; font: inherit; font-size: 14px; min-width: 120px;
}
input:focus, select:focus { outline: 2px solid var(--series-1); outline-offset: -1px; }
button.btn {
  background: var(--series-1); color: #fff; border: 0; border-radius: 8px;
  padding: 8px 15px; font: inherit; font-size: 14px; font-weight: 550; cursor: pointer;
}
button.btn:hover { filter: brightness(1.07); }
.chip {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  background: var(--wash); color: var(--series-1);
  font-size: 11.5px; font-weight: 600;
}
.chip.grey { background: var(--grid); color: var(--text-secondary); }
.toggle-group { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.toggle-group a {
  padding: 7px 14px; font-size: 14px; color: var(--text-secondary);
  background: var(--surface-1); font-weight: 500;
}
.toggle-group a.active { background: var(--series-1); color: #fff; }
.toggle-group a:hover { text-decoration: none; }
.toggle-group a:not(.active):hover { background: var(--wash); }

/* --- estimator ------------------------------------------------------------ */
.result-hero { font-size: 42px; font-weight: 660; letter-spacing: -0.03em; line-height: 1; }
.result-band { font-size: 15px; font-weight: 600; margin-top: 8px; }
.meter { height: 9px; border-radius: 5px; background: var(--grid); overflow: hidden; margin: 16px 0 6px; }
.meter > i { display: block; height: 100%; background: var(--series-1); border-radius: 5px; }
.explain { margin: 0; padding-left: 18px; color: var(--text-secondary); font-size: 13.5px; }
.explain li { margin: 4px 0; }
.grid2 { display: grid; grid-template-columns: minmax(280px, 340px) 1fr; gap: 18px; align-items: start; }
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 5px; }
.field select, .field input { width: 100%; }
.banner {
  padding: 11px 14px; border-radius: 9px; font-size: 14px;
  background: var(--wash); border: 1px solid var(--border); color: var(--text-secondary);
}
.banner.err { border-color: var(--critical); color: var(--critical); background: transparent; }
.event-block { margin-bottom: 26px; }
.event-block h3 { font-size: 14px; margin: 0 0 8px; letter-spacing: -0.01em; }
.empty { color: var(--text-secondary); padding: 34px; text-align: center; }
@media (max-width: 760px) {
  .grid2 { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 74px 1fr 78px; }
  main { padding: 20px 14px 60px; }
}

/* --- pagination ----------------------------------------------------------- */
.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-top: 14px;
}
.pager-count { font-size: 13px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.pager-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pager-nav a, .pager-nav span {
  min-width: 32px; height: 32px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 7px; font-size: 13.5px; font-variant-numeric: tabular-nums;
  border: 1px solid transparent; color: var(--text-secondary);
}
.pager-nav a:hover { background: var(--wash); text-decoration: none; color: var(--series-1); }
.pager-nav .current {
  background: var(--series-1); color: #fff; font-weight: 600;
  border-color: var(--series-1);
}
.pager-nav .disabled { color: var(--muted); opacity: .45; }
.pager-nav .gap { color: var(--muted); min-width: 20px; padding: 0 2px; }
.per-page { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-secondary); }
.per-page select { min-width: 74px; padding: 5px 9px; font-size: 13px; }

/* --- scrape control ------------------------------------------------------- */
.scrape-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.scrape-head h2 { margin: 0; }
.chip.ok { background: rgba(12,163,12,.12); color: var(--success-text); }
.chip.bad { background: rgba(208,59,59,.12); color: var(--critical); }
.scrape-form { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.scrape-form select, .scrape-form input { min-width: 104px; }
.btn.ghost { background: transparent; color: var(--critical); border: 1px solid var(--border); }
.btn.ghost:hover { background: rgba(208,59,59,.08); filter: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.progress {
  height: 10px; border-radius: 5px; background: var(--grid);
  overflow: hidden; margin: 16px 0 8px;
}
.progress > i {
  display: block; height: 100%; width: 0; border-radius: 5px;
  background: var(--series-1); transition: width .35s ease;
}
[data-status="failed"] .progress > i { background: var(--critical); }
[data-status="done"] .progress > i,
[data-status="partial"] .progress > i { background: var(--good); }
.progress-meta {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 13px; color: var(--text-secondary); flex-wrap: wrap;
}
.progress-meta .num { font-variant-numeric: tabular-nums; }
.scrape-log {
  margin-top: 14px; padding: 11px 13px; max-height: 190px; overflow-y: auto;
  background: var(--page); border: 1px solid var(--border); border-radius: 9px;
  font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text-secondary); white-space: pre-wrap; word-break: break-word;
}

/* --- login ---------------------------------------------------------------- */
.login-wrap { max-width: 380px; margin: 0 auto; padding: 12vh 20px 40px; }
.login-card { padding: 26px; }
.login-card .field input { width: 100%; }
input[type=password] {
  background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 11px; font: inherit; font-size: 14px;
}
.user-chip { font-size: 13px; color: var(--text-secondary); display: inline-flex; gap: 9px; align-items: center; }
.user-chip a { color: var(--text-secondary); }
.user-chip a:hover { color: var(--series-1); }

/* Wind that put a mark outside the legal limit. The chip in the Flags column
   says so in words; this makes the number itself readable as the reason. */
.wind-illegal { color: var(--critical); font-variant-numeric: tabular-nums; }
/* Wind and dates are compared down the column, so the digits must line up. */
td.num, .mark { font-variant-numeric: tabular-nums; }

/* Collapse a column to its content. Must be on the <td> as well as the <th>:
   nowrap on a header alone leaves the cells below it free to wrap, which turned
   "NCAA D-III" and a timestamp into two-line rows. */
th.shrink, td.shrink { width: 1%; white-space: nowrap; }

/* Job log. Levels are coloured so a failure is not buried in 300 grey lines. */
.log-line { white-space: pre-wrap; }
.log-warn  { color: var(--warning); }
.log-error { color: var(--critical); font-weight: 600; }
/* The progress bar animates so a slow step still looks alive. */
.meter > i { transition: width .4s ease; }

/* Division picker: a checkbox list in a dropdown. */
.checkdrop { position: relative; display: inline-block; }
.checkdrop > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface-1);
  font-size: 13px; white-space: nowrap;
}
.checkdrop > summary::-webkit-details-marker { display: none; }
.checkdrop > summary::after { content: "▾"; color: var(--muted); font-size: 11px; }
.checkdrop > summary:hover { border-color: var(--text-secondary); }
.checkdrop-label { color: var(--text-secondary); }
.checkdrop-value { color: var(--text-primary); font-weight: 600; }
.checkdrop-menu {
  position: absolute; z-index: 30; top: calc(100% + 4px); left: 0;
  min-width: 220px; max-height: 300px; overflow-y: auto;
  padding: 6px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface-1);
  box-shadow: var(--shadow);
}
/* Scoped to the menu so it outranks the inherited `.field label { display:
   block }` — a descendant selector at 0,1,1 that reaches these rows whenever a
   picker sits inside a .field wrapper, and stacked each checkbox above its
   own text. */
.checkdrop-menu .check-row {
  display: flex; align-items: center; gap: 8px; margin: 0;
  padding: 6px 8px; border-radius: 6px; cursor: pointer;
  font-size: 13px; font-weight: 400; color: var(--text-primary);
}
.checkdrop-menu .check-row:hover { background: var(--wash); }
.checkdrop-menu .check-row input { margin: 0; cursor: pointer; flex: none; }
.checkdrop-menu .check-row span { flex: 1; }
.checkdrop-rule { height: 1px; margin: 5px 2px; background: var(--border); }

/* Job control panel. Fixed columns so the two rows align rather than wrapping
   wherever a control happens to run out of room. */
.job-form {
  display: grid; gap: 12px 14px; align-items: end;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 14px 0 18px;
}
.job-form .jobfield { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.job-form .jobfield > label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted);
}
/* Mode carries the longest text of any control, so it gets two columns. */
.job-form .jobfield.wide { grid-column: span 2; }
.job-form .jobfield select,
.job-form .jobfield .checkdrop,
.job-form .jobfield .checkdrop > summary { width: 100%; }
.job-form .jobfield .checkdrop > summary { justify-content: space-between; }
/* The action row spans the grid and centres, rather than being stranded in
   whichever column the field count happens to leave it in. */
.job-form .actions {
  grid-column: 1 / -1; flex-direction: row; justify-content: center;
  align-items: center; gap: 10px; margin-top: 4px;
}
.job-form .actions .btn { flex: 0 1 300px; padding: 10px 18px; font-weight: 600; }
@media (max-width: 860px) {
  .job-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .job-form .jobfield.wide { grid-column: span 2; }
}

/* The summary lists every picked value, so it has to truncate rather than
   stretch its column. The full list stays on the tooltip. */
.checkdrop-value {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.checkdrop > summary { max-width: 100%; }

/* Destructive action. Reads as a warning without shouting. */
.btn.danger { background: var(--critical); border-color: var(--critical); color: #fff; }
.btn.danger:hover { filter: brightness(1.08); }
#wipe-preview strong { color: var(--critical); }

/* Collapsed panels on the manage page, and the read-only job strip that is the
   only trace of the machinery left on the landing page. */
#wipe-panel > summary {
  list-style: none; cursor: pointer; padding: 2px 0;
}
#wipe-panel > summary::-webkit-details-marker { display: none; }
#wipe-panel > summary::before { content: "▸ "; color: var(--muted); }
#wipe-panel[open] > summary::before { content: "▾ "; }
.job-strip { margin: 18px 0; }
.job-strip .scrape-head { display: flex; align-items: center; gap: 10px; }

/* Job log as a table. Rows are dense and monospaced in the numeric columns so
   times and sizes line up; the status column carries the meaning. */
.joblog { max-height: 340px; overflow-y: auto; border: 1px solid var(--border);
          border-radius: var(--radius); background: var(--page); }
.joblog table { font-size: 12.5px; }
.joblog td { padding: 3px 10px; border: 0; white-space: nowrap; }
.joblog .log-t, .joblog .log-detail { font-variant-numeric: tabular-nums; }
.joblog .log-t { color: var(--muted); width: 1%; }
.joblog .log-div { color: var(--text-secondary); width: 1%; }
.joblog .log-name { width: 40%; white-space: normal; }
.joblog .log-status { width: 1%; text-transform: uppercase; font-size: 10.5px;
                      letter-spacing: .05em; color: var(--text-secondary); }
.joblog .log-detail { color: var(--text-secondary); }
.joblog tr.log-dim td { opacity: .55; }
.joblog tr.log-warn .log-status, .joblog tr.log-warn .log-detail { color: var(--warning); }
.joblog tr.log-error .log-status, .joblog tr.log-error .log-detail { color: var(--critical); }
.joblog thead th {
  position: sticky; top: 0; z-index: 1;
  padding: 6px 10px; text-align: left; font-size: 10px;
  text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
  background: var(--page); border-bottom: 1px solid var(--border);
}
.joblog .log-year, .joblog .log-season { color: var(--text-secondary); width: 1%; }
.joblog .log-year { font-variant-numeric: tabular-nums; }
.joblog tr.log-summary td { padding: 6px 10px 10px; font-weight: 600; }
.joblog .log-stage { color: var(--muted); width: 1%; font-size: 11px;
                     text-transform: uppercase; letter-spacing: .05em; }

/* Events picker: group headers and their members. */
.checkdrop-menu .check-child { padding-left: 26px; }
.checkdrop-menu .check-group-row { margin-top: 4px; }
.checkdrop-menu .check-note {
  margin-left: auto; padding-left: 12px; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
}
.chip.warn { background: rgba(250,178,25,.14); color: var(--warning); }

/* ---------------------------------------------------------------- formulas */
/* An operation and a factor read as one value ("÷ 1.0737"), so they sit in one
   control rather than as two fields that happen to be adjacent. */
/* An operation and a factor read as one value ("÷ 1.0737"), so they share a
   control rather than sitting as two fields that happen to be adjacent. The
   selector has to outrank `.job-form .jobfield select { width: 100% }` above,
   which otherwise hands the whole cell to the dropdown and collapses the
   number input to zero width. */
.job-form .jobfield .pairfield { display: flex; gap: 6px; align-items: stretch; }
.job-form .jobfield .pairfield select {
  flex: 0 0 3.4rem; width: 3.4rem; min-width: 0;
  padding: 7px 4px; text-align: center;
}
.job-form .jobfield .pairfield input {
  flex: 1 1 auto; width: 100%; min-width: 0;
}

.editor { margin: 12px 0 26px; }
.editor > summary { cursor: pointer; font-weight: 600; }
.editor > summary::marker { color: var(--text-secondary); }

.btn.tiny { padding: 3px 9px; font-size: 12px; }

/* Feedback for a save sits above both tables, where the eye already is after
   pressing a button in either editor. */
.msg { padding: 9px 12px; border-radius: 8px; font-size: 14px; margin: 0 0 16px; }
.msg.ok   { background: rgba(12,163,12,.12);  color: var(--success-text); }
.msg.bad  { background: rgba(208,59,59,.12);  color: var(--critical); }
.msg.warn { background: rgba(250,178,25,.14); color: var(--warning); }

/* ------------------------------------------------------------- band results */
/* Three bands side by side rather than stacked: their whole meaning is
   comparative, and an athlete reading down one column at a time cannot see
   that the aid list is short and the walk-on list is long. */
.bandgrid {
  display: grid; gap: 14px; margin: 6px 0 18px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 860px) { .bandgrid { grid-template-columns: 1fr; } }

.band h3 { margin: 0 0 10px; font-size: 15px; display: flex;
           align-items: baseline; gap: 8px; }
.band h3 .dim { margin-left: auto; }
/* A left edge rather than a filled card: the bands are ordered, and a colour
   band reads as rank where three coloured cards read as three categories. */
.band { border-left: 3px solid var(--border); }
.band-aid    { border-left-color: var(--success-text); }
.band-roster { border-left-color: var(--series-1); }
.band-walkon { border-left-color: var(--warning); }

.conflist { list-style: none; margin: 0; padding: 0; }
.conflist li {
  display: flex; align-items: baseline; gap: 7px;
  padding: 5px 0; border-bottom: 1px solid var(--grid);
}
.conflist li:last-child { border-bottom: 0; }
.conflist .cname { flex: 1 1 auto; min-width: 0; }
.conflist.cols { columns: 2; column-gap: 26px; }
@media (max-width: 700px) { .conflist.cols { columns: 1; } }

.chip.tiny { padding: 1px 6px; font-size: 11px; }
.banner.warn { border-left: 3px solid var(--warning); }
