:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e7;
  --text: #1b1f24;
  --muted: #5d6673;
  --accent: #1f6feb;
  --ok: #1a7f37;
  --ok-bg: #dafbe1;
  --warn: #9a6700;
  --warn-bg: #fff4d4;
  --bad: #cf222e;
  --bad-bg: #ffebe9;
  --info: #0969da;
  --info-bg: #ddf4ff;
  --made: #1a7f37;
  --missed: #cf222e;
  --court: #fbf6ee;
  --court-line: #b9a58a;
  --highlight: #fff8c5;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --surface: #161b22; --surface-2: #1f2630; --border: #30363d; --text: #e6edf3;
    --muted: #8d96a0; --accent: #4493f8; --ok: #3fb950; --ok-bg: #12261e; --warn: #d29922;
    --warn-bg: #272115; --bad: #f85149; --bad-bg: #2d1517; --info: #58a6ff; --info-bg: #121d2f;
    --made: #3fb950; --missed: #f85149; --court: #1c1a17; --court-line: #6e6250; --highlight: #2e2a14;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117; --surface: #161b22; --surface-2: #1f2630; --border: #30363d; --text: #e6edf3;
  --muted: #8d96a0; --accent: #4493f8; --ok: #3fb950; --ok-bg: #12261e; --warn: #d29922;
  --warn-bg: #272115; --bad: #f85149; --bad-bg: #2d1517; --info: #58a6ff; --info-bg: #121d2f;
  --made: #3fb950; --missed: #f85149; --court: #1c1a17; --court-line: #6e6250; --highlight: #2e2a14;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 24px 0 8px; }
h3 { font-size: 14px; margin: 16px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

header.top {
  display: flex; align-items: center; gap: 20px; padding: 10px 24px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
header.top .brand { font-weight: 700; display: inline-flex; align-items: center; gap: 8px; }
header.top .brand img { border-radius: 6px; }
header.top nav a { color: var(--text); margin-right: 14px; padding: 4px 0; }
header.top nav a.active { border-bottom: 2px solid var(--accent); }
header.top .ver { margin-left: auto; color: var(--muted); font-size: 12px; }
main { padding: 20px 24px 60px; max-width: 1500px; margin: 0 auto; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; }
.grid { display: grid; gap: 12px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.funnel { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.funnel .stat { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.stat .n { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { font-weight: 600; }
.stat .d { color: var(--muted); font-size: 12px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions form { margin: 0; }
button, .btn {
  font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.small { padding: 2px 8px; font-size: 12px; }
button.danger { color: var(--bad); }
.job-link { font-size: 13px; background: var(--info-bg); padding: 5px 10px; border-radius: 6px; }

table { border-collapse: collapse; width: 100%; background: var(--surface); }
th, td { padding: 5px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
/* header stays visible while scrolling inside a table box (sticky is relative to .table-wrap) */
.table-wrap th { position: sticky; top: 0; z-index: 1; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:hover td { background: var(--surface-2); }
.table-wrap { border: 1px solid var(--border); border-radius: 8px; overflow: auto; max-height: 78vh; }
.table-wrap tr:last-child td { border-bottom: 0; }
td form, td .actions { margin: 0; }
td .actions { flex-wrap: nowrap; gap: 4px; }
.table-wrap table { border: 0; }
.dense td { padding: 3px 6px; font-size: 12.5px; }

.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.b-ok { background: var(--ok-bg); color: var(--ok); }
.b-warn { background: var(--warn-bg); color: var(--warn); }
.b-bad { background: var(--bad-bg); color: var(--bad); }
.b-info { background: var(--info-bg); color: var(--info); }
.b-muted { background: var(--surface-2); color: var(--muted); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 12px; }
.filters label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
select, input[type=text] {
  font: inherit; font-size: 13px; padding: 5px 8px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
}

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 16px 0 14px; overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--text); border-color: var(--accent); font-weight: 600; }
.tabs a .badge { margin-left: 4px; }

.game-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; justify-content: space-between; }
.score { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

tr.fail td { background: var(--bad-bg); }
tr.flagged td { background: var(--highlight); }
tr.anomaly td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
tr.period-row td { background: var(--surface-2); font-weight: 600; }
tr:target td { outline: 2px solid var(--accent); outline-offset: -2px; }
.lineup { font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.team-1 { color: var(--accent); }
.team-2 { color: var(--warn); }
.diff { color: var(--bad); font-weight: 600; }
.sc-adjusted { font-style: italic; }
.sc-anchored { text-decoration: underline; }
.sc-off { color: var(--muted); }

pre.log {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px;
  font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; max-height: 70vh; overflow: auto;
}

.shots-layout { display: grid; grid-template-columns: minmax(300px, 520px) 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .shots-layout { grid-template-columns: 1fr; } }
svg.court { width: 100%; height: auto; background: var(--court); border: 1px solid var(--border); border-radius: 8px; }
svg.court .line { fill: none; stroke: var(--court-line); stroke-width: 0.05; }
svg.court .made { fill: var(--made); fill-opacity: .8; stroke: var(--surface); stroke-width: .03; }
svg.court .missed { fill: none; stroke: var(--missed); stroke-width: .07; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }

@media (max-width: 700px) {
  main { padding: 14px 16px 40px; }
  header.top { padding: 8px 16px; gap: 10px; flex-wrap: wrap; }
  .grid.cols-2 { grid-template-columns: 1fr; }
}

/* sign-in (admins only) */
.login-body { min-height: 100vh; display: grid; place-items: center; margin: 0; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 28px; width: min(380px, calc(100vw - 32px)); }
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card label { display: grid; gap: 4px; margin: 12px 0; font-weight: 600; font-size: 14px; }
.login-card input { padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 16px; background: var(--surface); color: var(--text); }
.login-card button { width: 100%; margin-top: 8px; padding: 10px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 700; font-size: 15px; cursor: pointer; }
.login-error { color: var(--bad); background: var(--bad-bg); padding: 8px 10px; border-radius: 8px; font-weight: 600; }
header.top .who { display: inline-flex; gap: 8px; align-items: center; margin-left: 12px; font-size: 13px; }
header.top .who button { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 6px; padding: 3px 8px; cursor: pointer; font-size: 12.5px; }
