/* Layout: single centered column (max 720px) for runners; wider grid for admin.
   Identity: DeMolay crimson + royal blue + gold; registration number shown as a race bib. */
:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --ink: #1a1c24;
  --muted: #5d6172;
  --line: #dcdbe2;
  --crimson: #a8122b;
  --crimson-ink: #ffffff;
  --royal: #1f3a8f;
  --gold: #b98d17;
  --soft: #eef0f8;
  --ok: #1d7a46;
  --ok-bg: #e3f3e9;
  --warn: #8a5a00;
  --warn-bg: #fbf0d6;
  --bad: #a3271f;
  --bad-bg: #fbe5e2;
  --display: "Big Shoulders Display", "Arial Narrow", Impact, sans-serif;
  --body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12131a;
    --surface: #1b1d27;
    --ink: #ecebf2;
    --muted: #a3a6b8;
    --line: #2f3242;
    --crimson: #e0435c;
    --crimson-ink: #12131a;
    --royal: #8ea6f0;
    --gold: #e2b84a;
    --soft: #222637;
    --ok: #6fd39a;
    --ok-bg: #173325;
    --warn: #f0c062;
    --warn-bg: #362a10;
    --bad: #f08a80;
    --bad-bg: #3a1a17;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 var(--body);
}
a { color: var(--royal); }
img { max-width: 100%; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--display); line-height: 1.05; text-wrap: balance; margin: 0; letter-spacing: .01em; }
h1 { font-size: clamp(2.6rem, 9vw, 4.4rem); font-weight: 900; text-transform: uppercase; }
h2 { font-size: 1.9rem; font-weight: 800; text-transform: uppercase; }
h3 { font-size: 1.3rem; font-weight: 800; text-transform: uppercase; }
p { margin: 0; }

.wrap { max-width: 720px; margin: 0 auto; padding-inline: 16px; }
.wrap.wide { max-width: 1180px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack.lg { gap: 28px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.eyebrow { font: 700 .75rem/1 var(--body); letter-spacing: .14em; text-transform: uppercase; color: var(--crimson); }

/* Top bar */
.topbar { background: var(--royal); color: #fff; }
@media (prefers-color-scheme: dark) { .topbar { background: #18244f; } }
.topbar .wrap { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-block: 12px; }
.brand { font: 900 1.25rem/1 var(--display); text-transform: uppercase; letter-spacing: .04em; color: #fff; text-decoration: none; }
.brand span { color: #f2cf6b; }
.nav { display: flex; gap: 16px; flex-wrap: wrap; }
.nav a { color: #fff; text-decoration: none; font-weight: 600; font-size: .9rem; opacity: .9; }
.nav a:hover, .nav a[aria-current] { opacity: 1; text-decoration: underline; text-underline-offset: 4px; }

/* Hero */
.hero { padding-block: 40px 28px; border-bottom: 4px solid var(--crimson); background: var(--surface); }
.hero .tag { font: 800 1.35rem/1.2 var(--display); text-transform: uppercase; color: var(--royal); letter-spacing: .03em; }
.hero h1 .year { color: var(--crimson); }
.dates { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.date { border-left: 4px solid var(--gold); padding: 4px 12px; }
.date b { display: block; font: 800 1.3rem/1.1 var(--display); text-transform: uppercase; }

/* Panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; }
.panel > h2, .panel > h3 { margin-bottom: 4px; }
section.block { padding-block: 28px; }

/* Forms */
label.f { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .92rem; min-width: 0; }
label.f .hint { font-weight: 400; color: var(--muted); font-size: .82rem; }
.req::after { content: " *"; color: var(--crimson); }
input[type=text], input[type=email], input[type=tel], input[type=url], input[type=number], input[type=date], input[type=password], textarea, select {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 11px 12px; width: 100%; min-width: 0;
}
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, .choice:has(input:focus-visible) {
  outline: 3px solid color-mix(in srgb, var(--royal) 55%, transparent); outline-offset: 2px;
}
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 560px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 10px; font: 800 1.3rem/1.1 var(--display); text-transform: uppercase; }
.sec-num { color: var(--crimson); margin-right: 6px; }

/* Selectable cards */
.choices { display: grid; gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choices.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choices.sizes { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 620px) { .choices { grid-template-columns: 1fr; } .choices.sizes { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.choice { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 14px; border: 2px solid var(--line); border-radius: var(--r); cursor: pointer; background: var(--bg); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice:has(input:checked) { border-color: var(--crimson); background: color-mix(in srgb, var(--crimson) 7%, var(--surface)); }
.choice .cname { font: 800 1.1rem/1.1 var(--display); text-transform: uppercase; color: var(--royal); }
.choice .ckm { font: 900 2.4rem/1 var(--display); }
.choice .ckm small { font-size: 1rem; margin-left: 2px; }
.choice .cfee { font-weight: 700; color: var(--crimson); font-variant-numeric: tabular-nums; }
.choices.sizes .choice { align-items: center; padding: 10px 4px; font-weight: 700; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; }
.check input { margin-top: 4px; width: 18px; height: 18px; flex: none; accent-color: var(--crimson); }

/* Buttons */
.btn { font: 700 1rem/1 var(--body); border: 0; border-radius: 8px; padding: 14px 20px; cursor: pointer; background: var(--crimson); color: var(--crimson-ink); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.blue { background: var(--royal); color: var(--surface); }
.btn.ok { background: var(--ok); color: var(--surface); }
.btn.sm { padding: 9px 12px; font-size: .88rem; }

.alert { padding: 12px 14px; border-radius: 8px; font-size: .94rem; }
.alert.err { background: var(--bad-bg); color: var(--bad); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }

/* Race bib */
.bib {
  position: relative; background: #fff; color: #14161d; border: 2px solid #14161d; border-radius: 12px;
  padding: 22px 26px 18px; text-align: center; max-width: 420px; margin-inline: auto; width: 100%;
  box-shadow: 0 10px 30px -18px rgba(0,0,0,.5);
}
.bib::before, .bib::after, .bib .pins::before, .bib .pins::after {
  content: ""; position: absolute; width: 12px; height: 12px; border-radius: 50%; background: var(--bg); border: 2px solid #14161d;
}
.bib::before { top: 10px; left: 10px; } .bib::after { top: 10px; right: 10px; }
.bib .pins::before { bottom: 10px; left: 10px; } .bib .pins::after { bottom: 10px; right: 10px; }
.bib .bib-top { font: 800 .8rem/1 var(--body); letter-spacing: .16em; text-transform: uppercase; color: #a8122b; }
.bib .bib-no { font: 900 clamp(3rem, 15vw, 4.6rem)/1 var(--display); letter-spacing: .02em; margin-block: 6px; font-variant-numeric: tabular-nums; }
.bib .bib-cat { font: 800 1rem/1.2 var(--display); text-transform: uppercase; color: #1f3a8f; }
.bib .bib-stripe { height: 8px; background: linear-gradient(90deg, #a8122b 0 33%, #f2cf6b 33% 66%, #1f3a8f 66%); margin: 12px -26px -18px; border-radius: 0 0 10px 10px; }

.steps { counter-reset: s; display: flex; flex-direction: column; gap: 14px; padding: 0; margin: 0; list-style: none; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: start; }
.steps li::before { content: counter(s); width: 34px; height: 34px; border-radius: 50%; background: var(--royal); color: var(--surface); display: grid; place-items: center; font: 800 1.1rem/1 var(--display); }
.msg-sample { font-family: var(--mono); font-size: .88rem; background: var(--soft); border-radius: 8px; padding: 12px 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.copyrow { display: flex; gap: 8px; align-items: stretch; }
.copyrow code { flex: 1; min-width: 0; font: 600 1rem var(--mono); background: var(--soft); padding: 10px 12px; border-radius: 8px; overflow-wrap: anywhere; }

/* Progress */
.progress { height: 18px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--royal), var(--crimson)); border-radius: 99px; transition: width .6s ease; }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.kpi { border-left: 4px solid var(--gold); padding: 2px 10px; }
.kpi b { display: block; font: 900 1.9rem/1.05 var(--display); font-variant-numeric: tabular-nums; }
.kpi span { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
@media (max-width: 480px) { .kpis { grid-template-columns: 1fr 1fr; } }

.pill { display: inline-block; font: 700 .72rem/1 var(--body); text-transform: uppercase; letter-spacing: .08em; padding: 5px 8px; border-radius: 99px; white-space: nowrap; }
.pill.pending { background: var(--warn-bg); color: var(--warn); }
.pill.approved, .pill.verified, .pill.finished { background: var(--ok-bg); color: var(--ok); }
.pill.rejected { background: var(--bad-bg); color: var(--bad); }
.pill.pending_payment { background: var(--soft); color: var(--muted); }

.runs { display: flex; flex-direction: column; gap: 10px; }
.run { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.run img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; background: var(--soft); }
.run .km { font: 900 1.4rem/1 var(--display); font-variant-numeric: tabular-nums; }
.run > div { min-width: 0; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); background: var(--soft); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--soft); }

.footer { padding-block: 32px; color: var(--muted); font-size: .85rem; text-align: center; }
.tagline { font: 800 1.1rem/1 var(--display); text-transform: uppercase; color: var(--crimson); letter-spacing: .05em; }

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