:root {
  --navy-950: #050f26;
  --navy-900: #0a1b3f;
  --navy-800: #0f2a5f;
  --blue-700: #1746b5;
  --blue-600: #1f5fd6;
  --blue-500: #2f74f0;
  --blue-400: #5c97ff;
  --blue-300: #93bbff;
  --blue-100: #e3edff;
  --blue-50: #f2f6ff;
  --gold: #f2b632;
  --ok: #138a52;
  --warn: #c27a00;
  --bad: #c8372f;

  --bg: #f4f7fd;
  --surface: #ffffff;
  --surface-2: #f2f6ff;
  --border: #dbe4f5;
  --text: #0c1a36;
  --muted: #5a6a8a;
  --bar-bat: var(--blue-600);
  --bar-bowl: #19a7c9;
  --shadow: 0 1px 2px rgba(10, 27, 63, 0.06), 0 8px 24px rgba(10, 27, 63, 0.06);
  --radius: 14px;

  --display: 'Barlow Condensed', 'Arial Narrow', system-ui, sans-serif;
  --body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #071027;
    --surface: #0d1a39;
    --surface-2: #112352;
    --border: #1f3266;
    --text: #e6eeff;
    --muted: #96a8cf;
    --bar-bat: var(--blue-400);
    --bar-bowl: #3cc6e6;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    --blue-50: #0f2049;
    --blue-100: #16306b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue-500); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ------------------------------------------------------------------ hero */
.hero {
  position: relative;
  color: #fff;
  background:
    radial-gradient(1200px 400px at 85% -10%, rgba(92, 151, 255, 0.45), transparent 60%),
    radial-gradient(800px 300px at -10% 110%, rgba(31, 95, 214, 0.5), transparent 60%),
    linear-gradient(160deg, var(--navy-800), var(--navy-950));
  overflow: hidden;
  padding: 36px 0 28px;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.035) 0 2px, transparent 2px 22px);
  pointer-events: none;
}
.hero-inner { position: relative; display: flex; align-items: center; gap: 22px; }
.crest { width: 88px; height: auto; flex: none; filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.35)); }
.eyebrow {
  margin: 0 0 2px;
  font: 600 12px/1 var(--body);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--blue-300);
}
.hero h1 {
  margin: 0;
  font: 800 clamp(34px, 6vw, 58px)/0.95 var(--display);
  letter-spacing: 0.01em;
  text-transform: uppercase;
}
.hero h1 span { color: var(--blue-300); }
.hero .sub { margin: 8px 0 0; color: #c9d8f7; max-width: 52ch; }

.kpis {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 26px;
}
.kpi {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 12px 14px;
  backdrop-filter: blur(4px);
}
.kpi .v { font: 700 30px/1 var(--display); letter-spacing: 0.01em; }
.kpi .v small { font-size: 16px; color: var(--blue-300); font-weight: 600; }
.kpi .l { font-size: 12px; color: #b8c9ee; margin-top: 4px; }
.kpi .meter { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.15); margin-top: 8px; overflow: hidden; }
.kpi .meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue-400), #8fd3ff); border-radius: 4px; }

/* ------------------------------------------------------------------ toolbar */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.toolbar .wrap { display: flex; align-items: center; gap: 12px; min-height: 60px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.sections { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1 1 auto; min-width: 0; }
.sections::-webkit-scrollbar { display: none; }
.sections a {
  white-space: nowrap;
  text-decoration: none;
  color: var(--muted);
  font: 600 14px/1 var(--body);
  padding: 9px 11px;
  border-radius: 8px;
}
.sections a:hover, .sections a.active { color: var(--text); background: var(--surface-2); }
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.seg {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 600 13px/1 var(--body);
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.seg button[aria-pressed='true'] { background: var(--blue-600); color: #fff; box-shadow: 0 2px 6px rgba(31, 95, 214, 0.35); }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.switch input { appearance: none; width: 34px; height: 20px; border-radius: 999px; background: var(--border); position: relative; cursor: pointer; transition: background 0.15s; margin: 0; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); }
.switch input:checked { background: var(--blue-600); }
.switch input:checked::after { transform: translateX(14px); }

/* ------------------------------------------------------------------ sections */
main { padding: 26px 0 60px; }
section { margin-bottom: 40px; }
.sec-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.sec-head h2 { margin: 0; font: 800 30px/1 var(--display); text-transform: uppercase; letter-spacing: 0.02em; }
.sec-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; max-width: 70ch; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

/* slot planner */
.planner { padding: 18px; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 22px; margin-bottom: 16px; }
.planner h3 { margin: 0 0 10px; font: 700 18px/1.1 var(--display); text-transform: uppercase; letter-spacing: 0.03em; }
.stack { display: flex; height: 26px; border-radius: 8px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.stack i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.legend b { color: var(--text); font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.callout { border-radius: 10px; padding: 12px 14px; font-size: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.callout.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); background: color-mix(in srgb, var(--warn) 9%, var(--surface)); }
.callout.ok { border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); background: color-mix(in srgb, var(--ok) 8%, var(--surface)); }
.callout strong { display: block; margin-bottom: 2px; }

.quota-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.qcard { padding: 14px 14px 12px; position: relative; overflow: hidden; }
.qcard .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.qcard .name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qcard .count { margin-top: 10px; display: flex; align-items: baseline; gap: 6px; }
.qcard .count .big { font: 800 32px/1 var(--display); }
.qcard .count .of { color: var(--muted); font-size: 13px; }
.qbar { position: relative; height: 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); margin-top: 8px; overflow: visible; }
.qbar i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--blue-600), var(--blue-400)); }
.qbar .pace { position: absolute; top: -4px; width: 2px; height: 14px; background: var(--text); opacity: 0.55; border-radius: 1px; }
.qcard .foot { display: flex; justify-content: space-between; margin-top: 9px; font-size: 12.5px; color: var(--muted); }
.qcard .mini { display: flex; gap: 12px; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.qcard .mini b { color: var(--text); font-variant-numeric: tabular-nums; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font: 700 10.5px/1 var(--body);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 7px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.full { background: var(--blue-600); color: #fff; }
.badge.half { background: var(--blue-100); color: var(--blue-700); border: 1px solid var(--blue-300); }
.badge.none { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .badge.half { color: var(--blue-300); } }
.status { font-size: 12px; font-weight: 600; }
.status.due { color: var(--warn); }
.status.ok { color: var(--ok); }
.status.over, .status.cap { color: var(--bad); }

/* tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.stats { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
table.stats th, table.stats td { padding: 10px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
table.stats th:first-child, table.stats td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; }
table.stats thead th {
  font: 700 11.5px/1 var(--body);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  cursor: pointer;
  user-select: none;
  position: sticky;
  top: 0;
}
table.stats thead th:first-child { background: var(--surface-2); z-index: 2; }
table.stats thead th[aria-sort]::after { content: ' ▾'; color: var(--blue-500); }
table.stats thead th[aria-sort='ascending']::after { content: ' ▴'; }
table.stats tbody tr:hover td { background: var(--blue-50); }
table.stats tbody tr:last-child td { border-bottom: 0; }
table.stats td.player { min-width: 190px; }
table.stats td.player .pc { display: inline-flex; align-items: center; gap: 8px; }
table.stats td.hl { font-weight: 700; }
.cellbar { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; }
.cellbar i { display: inline-block; height: 6px; border-radius: 3px; background: var(--bar-bat); opacity: 0.85; }
.cellbar.bowl i { background: var(--bar-bowl); }
.zero { color: var(--muted); opacity: 0.6; }

/* workload */
.workload { padding: 16px 18px; }
.wl-head, .wl-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px minmax(0, 1fr); align-items: center; gap: 10px; }
.wl-head { font: 700 11.5px/1 var(--body); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding-bottom: 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.wl-head .l { text-align: right; }
.wl-row { padding: 5px 0; font-size: 13px; }
.wl-row .who { text-align: center; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl-row .who small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; }
.wl-side { display: flex; align-items: center; gap: 8px; }
.wl-side.l { flex-direction: row-reverse; }
.wl-side i { display: block; height: 14px; border-radius: 4px; min-width: 2px; }
.wl-side.l i { background: linear-gradient(270deg, var(--bar-bat), color-mix(in srgb, var(--bar-bat) 70%, #fff)); }
.wl-side.r i { background: linear-gradient(90deg, var(--bar-bowl), color-mix(in srgb, var(--bar-bowl) 70%, #fff)); }
.wl-side span { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; min-width: 2.5em; }
.wl-side.l span { text-align: right; }
.wl-note { font-size: 12.5px; color: var(--muted); margin-top: 10px; }

/* matches */
.match-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.mcard { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.mcard .row1 { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.mcard .vs { font: 700 22px/1.05 var(--display); text-transform: uppercase; letter-spacing: 0.01em; }
.mcard .vs span { color: var(--muted); font-weight: 600; font-size: 16px; }
.mcard .res { font-size: 13.5px; }
.mcard .res.win { color: var(--ok); font-weight: 600; }
.mcard .res.loss { color: var(--bad); font-weight: 600; }
.mcard .perf { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 13px; }
.mcard .perf div { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.mcard .perf small { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.mcard .links { font-size: 12.5px; display: flex; gap: 12px; }
.tbadge { font: 700 10.5px/1 var(--body); letter-spacing: 0.06em; padding: 4px 7px; border-radius: 6px; background: var(--navy-800); color: #fff; }
.tbadge.mcl { background: var(--blue-600); }
.tbadge.lakeshore { background: #0e7c9a; }

.empty { padding: 34px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); font: 700 20px/1.2 var(--display); text-transform: uppercase; margin-bottom: 4px; }

footer { border-top: 1px solid var(--border); padding: 22px 0 40px; color: var(--muted); font-size: 13px; }
footer .wrap { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

@media (max-width: 760px) {
  .hero { padding-top: 24px; }
  .crest { width: 64px; }
  .planner { grid-template-columns: 1fr; }
  .wl-head, .wl-row { grid-template-columns: minmax(0, 1fr) 96px minmax(0, 1fr); }
  .match-list { grid-template-columns: 1fr; }
  .toolbar .wrap { gap: 8px; }
  .filters { width: 100%; justify-content: space-between; }
}

/* ------------------------------------------------------------------ admin */
.admin-shell { max-width: 720px; margin: 0 auto; padding: 32px 16px 60px; }
.admin-shell .card { padding: 22px; margin-bottom: 18px; }
.admin-shell h2 { margin: 0 0 4px; font: 800 26px/1 var(--display); text-transform: uppercase; }
.field { display: grid; gap: 6px; margin: 14px 0; }
.field label { font-weight: 600; font-size: 13.5px; }
.field input, .field select {
  font: 15px var(--body);
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  width: 100%;
}
.field input:focus, .field select:focus { outline: 2px solid var(--blue-400); outline-offset: 1px; }
.btn {
  font: 700 14px/1 var(--body);
  border: 0;
  border-radius: 10px;
  padding: 12px 18px;
  background: var(--blue-600);
  color: #fff;
  cursor: pointer;
}
.btn:hover { background: var(--blue-700); }
.btn[disabled] { opacity: 0.6; cursor: progress; }
.btn.ghost { background: transparent; color: var(--blue-500); border: 1px solid var(--border); }
.msg { margin-top: 12px; }
.runs { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; }
.runs li { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.pill { align-self: center; white-space: nowrap; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--border); }
.pill.success { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.pill.failure { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.pill.in_progress, .pill.queued { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
code { font-size: 0.92em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

a.btn { display: inline-block; text-decoration: none; }
.add-btn { padding: 9px 14px; font-size: 13px; white-space: nowrap; }

/* ------------------------------------------------------------------ public leaders */
.leaders { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 960px) { .leaders { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .leaders { grid-template-columns: 1fr; } }
.leader { padding: 16px 16px 14px; position: relative; overflow: hidden; }
.leader::after { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, var(--blue-600), var(--gold)); }
.leader h3 { margin: 0 0 10px; font: 700 13px/1 var(--body); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.lead-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.lead-name { font: 800 24px/1.05 var(--display); text-transform: uppercase; letter-spacing: 0.01em; }
.lead-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.lead-v { font: 800 44px/0.9 var(--display); color: var(--blue-600); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .lead-v { color: var(--blue-300); } }
.lead-rest { list-style: none; margin: 12px 0 0; padding: 10px 0 0; border-top: 1px solid var(--border); display: grid; gap: 6px; font-size: 13.5px; counter-reset: r 1; }
.lead-rest li { display: flex; justify-content: space-between; counter-increment: r; }
.lead-rest li span::before { content: counter(r) '. '; color: var(--muted); }
.empty-leader p { margin: 0; }

/* ------------------------------------------------------------------ admin lock */
body.locked > :not(.lock):not(script) { display: none !important; }
.lock { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(160deg, var(--navy-800), var(--navy-950)); }
.lock[hidden] { display: none; }
.lock-card { width: min(380px, 100%); padding: 26px 24px; text-align: center; }
.lock-card h2 { margin: 10px 0 2px; font: 800 28px/1 var(--display); text-transform: uppercase; }
.lock-card .btn { width: 100%; }

/* ------------------------------------------------------------------ admin add match */
.add-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.add-card { padding: 18px; }
.add-card h3 { margin: 0 0 4px; font: 700 18px/1.1 var(--display); text-transform: uppercase; letter-spacing: 0.03em; }
.add-card .small, .small { font-size: 13px; }
.add-card details { margin-top: 10px; font-size: 13.5px; }
.add-card summary { cursor: pointer; font-weight: 600; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 10px; font-size: 14px; }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; min-width: 0; font: 15px var(--body); padding: 11px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
.inline .btn { white-space: nowrap; }
.btn.bm { cursor: grab; background: var(--gold); color: var(--navy-950); }
.linkbtn { border: 0; background: none; color: var(--blue-500); font: inherit; padding: 0; cursor: pointer; text-decoration: underline; }
.bad { color: var(--bad); }
.field input[type='date'] { max-width: 220px; }
#preview { margin-top: 14px; }
.pv-head { display: grid; gap: 4px; padding-bottom: 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
.pv-head .vs { font: 700 26px/1.05 var(--display); text-transform: uppercase; }
.pv-head .vs span { color: var(--muted); font-size: 17px; }
.pv-table { border: 1px solid var(--border); }
.pv-table small { color: var(--muted); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 4px 12px; margin-top: 8px; }
.checks label { display: flex; gap: 6px; align-items: center; font-size: 13.5px; }
.pv-actions { display: flex; gap: 8px; margin-top: 14px; }
.map { display: grid; gap: 8px; margin: 12px 0; }
.maprow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 10px; align-items: center; font-weight: 600; font-size: 14px; }
.maprow select { font: 14px var(--body); padding: 9px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
@media (max-width: 760px) {
  .add-grid { grid-template-columns: 1fr; }
  .inline { flex-wrap: wrap; }
  .inline .btn { width: 100%; }
  .maprow { grid-template-columns: 1fr; gap: 4px; }
}
.drop { display: grid; justify-items: center; gap: 4px; margin-top: 12px; padding: 26px 16px; border: 2px dashed var(--border); border-radius: 12px; background: var(--surface-2); cursor: pointer; text-align: center; transition: border-color 0.15s, background 0.15s; }
.drop:hover, .drop.over { border-color: var(--blue-500); background: var(--blue-50); }
.drop:focus-within { outline: 2px solid var(--blue-400); outline-offset: 2px; }
.drop-icon { font-size: 22px; color: var(--blue-500); }

/* ------------------------------------------------------------------ about (static text for readers and search engines) */
.about { color: var(--muted); font-size: 14px; max-width: 80ch; }
.about h2 { margin: 0 0 8px; font: 800 22px/1.1 var(--display); text-transform: uppercase; letter-spacing: 0.02em; color: var(--text); }
.about h3 { margin: 18px 0 6px; font: 700 15px/1.2 var(--body); color: var(--text); }
.about p { margin: 0 0 8px; }
.about ul { margin: 0; padding-left: 18px; }
.about li { margin: 2px 0; }
