/* ==========================================================================
   Design tokens
   Light and dark are both first-class — a coach entering a squad at 11pm on
   deadline night should not get a face full of white.
   ========================================================================== */

:root {
  color-scheme: light dark;

  --red-500: #c8323a;
  --red-600: #a4262c;
  --red-700: #7d1d22;

  --ink-900: #10161d;
  --ink-800: #1b232c;
  --ink-700: #2b3742;
  --ink-500: #55636f;
  --ink-300: #96a2ad;

  --paper:      #f4f6f8;
  --surface:    #ffffff;
  --surface-2:  #f8fafb;
  --line:       #dfe5ea;
  --line-strong:#c6d0d8;

  --text:       var(--ink-900);
  --text-muted: var(--ink-500);
  --accent:     var(--red-600);
  --accent-hover: var(--red-700);
  --on-accent:  #ffffff;

  /* Focus is deliberately NOT the accent colour. The accent is red, red means
     error, and the club-name field is autofocused — so a red focus ring made a
     perfectly valid field look like it had failed validation. */
  --focus: #2f6fd0;

  --ok-bg: #e4f3ea;   --ok-fg: #14603c;   --ok-line: #b9dfc9;
  --warn-bg: #fdf4e3; --warn-fg: #855000;  --warn-line: #ecd9b0;
  --err-bg: #fceceb;  --err-fg: #a4262c;   --err-line: #f0c6c4;
  --info-bg: #e9f0f8; --info-fg: #1c4f86;  --info-line: #c3d7ec;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow-1: 0 1px 2px rgb(16 22 29 / 6%), 0 1px 3px rgb(16 22 29 / 4%);
  --shadow-2: 0 4px 16px rgb(16 22 29 / 8%);

  --step: 0.25rem;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Cards have to read as raised objects on a dark page, so the gap between
       --paper and --surface is deliberately wide and the borders are bright
       enough to see. Shadows barely register on dark, so borders do the work. */
    --paper:      #080b0f;
    --surface:    #1a232e;
    --surface-2:  #232e3b;
    --line:       #35424f;
    --line-strong:#4b5b6b;

    --focus:      #6ba4f0;

    --text:       #eef2f6;
    --text-muted: #9fb0c0;
    --accent:     #ff5f68;
    --accent-hover: #ff7a82;

    --ok-bg: #12301f;   --ok-fg: #7fd6a4;   --ok-line: #1f5236;
    --warn-bg: #322510; --warn-fg: #f0c67a;  --warn-line: #574019;
    --err-bg: #351a1c;  --err-fg: #f3999e;   --err-line: #5c2a2e;
    --info-bg: #14263a; --info-fg: #8fc0f0;  --info-line: #234a70;

    --shadow-1: 0 1px 2px rgb(0 0 0 / 40%);
    --shadow-2: 0 4px 20px rgb(0 0 0 / 45%);
  }
}

/* ==========================================================================
   Base
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.25; text-wrap: balance; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2rem); margin: 0 0 calc(var(--step) * 2); letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; margin: calc(var(--step) * 8) 0 calc(var(--step) * 3); letter-spacing: -0.01em; }
h3 { font-size: 1rem; margin: calc(var(--step) * 5) 0 calc(var(--step) * 2); }

a { color: var(--accent); text-underline-offset: 2px; }

p { margin: 0 0 calc(var(--step) * 3); }
p.lede { color: var(--text-muted); font-size: 1.05rem; margin-top: 0; }

.muted { color: var(--text-muted); }
.code, code { font-family: var(--mono); font-size: 0.875em; }
.small { font-size: 0.875rem; }

/* Visible only to screen readers. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   Layout
   ========================================================================== */

.site-header {
  background:
    radial-gradient(120% 180% at 0% 0%, rgb(200 50 58 / 45%) 0%, transparent 55%),
    linear-gradient(180deg, #1b2431 0%, var(--ink-900) 100%);
  color: #fff;
  border-bottom: 1px solid rgb(255 255 255 / 8%);
  box-shadow: inset 0 -3px 0 0 var(--accent);
}
@media (prefers-color-scheme: dark) {
  .site-header {
    background:
      radial-gradient(120% 180% at 0% 0%, rgb(255 95 104 / 28%) 0%, transparent 55%),
      linear-gradient(180deg, #16202c 0%, #0b1016 100%);
  }
}
.site-header .brand { font-size: 1.05rem; }
.site-header .inner {
  max-width: 62rem; margin: 0 auto;
  padding: calc(var(--step) * 3.5) calc(var(--step) * 5);
  display: flex; align-items: center; gap: calc(var(--step) * 3); flex-wrap: wrap;
}
.site-header a.brand {
  color: #fff; text-decoration: none; font-weight: 650; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: calc(var(--step) * 3);
}
.site-header .brand-mark {
  /* The crest is a red circle on white, so it needs its own light disc to sit
     on rather than being punched into the dark header. */
  border-radius: 50%; background: #fff; padding: 2px;
  box-shadow: 0 0 0 1px rgb(255 255 255 / 25%);
  flex: 0 0 auto;
}
.site-header .brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.site-header .sub { color: #a7b4c1; font-size: 0.8rem; font-weight: 400; }
.site-header .club-name { margin-left: auto; }

/* --- Footer, with the optional supplier credit --- */

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  margin-top: calc(var(--step) * 12);
}
/* Same vertical rhythm as the header, so the page is bookended evenly. */
.site-footer .inner {
  max-width: 62rem; margin: 0 auto;
  padding: calc(var(--step) * 3.5) calc(var(--step) * 5);
  display: flex; gap: calc(var(--step) * 4);
  align-items: center; justify-content: space-between; flex-wrap: wrap;
  min-height: 3.25rem;
}
.site-footer .legal { font-size: 0.78rem; color: var(--text-muted); line-height: 1.45; }
.site-footer .legal strong { color: var(--text); font-weight: 600; }

/* The supplier credit. Reads as a link — underlined wordmark, an arrow that
   travels on hover, and an accent border — rather than a box you might not
   realise is clickable. */
.supplier {
  display: inline-flex; align-items: center; gap: calc(var(--step) * 2.5);
  text-decoration: none; color: var(--text);
  padding: calc(var(--step) * 1.5) calc(var(--step) * 3) calc(var(--step) * 1.5) calc(var(--step) * 1.5);
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface-2);
  transition: border-color 140ms ease, background-color 140ms ease, transform 140ms ease;
}
.supplier img {
  display: block; height: 30px; width: auto; border-radius: 5px; flex: 0 0 auto;
}
.supplier .lines { display: flex; flex-direction: column; line-height: 1.2; }
.supplier .eyebrow {
  font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.09em;
  font-weight: 700; color: var(--text-muted);
}
.supplier .name {
  font-size: 0.85rem; font-weight: 600;
  text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  text-underline-offset: 2px; text-decoration-thickness: 1.5px;
}
.supplier .arrow { transition: transform 140ms ease; color: var(--accent); font-size: 0.9rem; }

.supplier:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface-2));
  transform: translateY(-1px);
}
.supplier:hover .name { text-decoration-color: var(--accent); }
.supplier:hover .arrow { transform: translate(2px, -2px); }

.kit-promo {
  display: flex; gap: calc(var(--step) * 5); align-items: center; flex-wrap: wrap;
}
.kit-promo img { flex: 0 0 auto; border-radius: var(--radius-sm); }
.kit-promo .body { flex: 1 1 16rem; }

main { max-width: 62rem; margin: 0 auto; padding: calc(var(--step) * 7) calc(var(--step) * 5) calc(var(--step) * 20); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: calc(var(--step) * 5);
  margin-bottom: calc(var(--step) * 4);
  box-shadow: var(--shadow-1);
}
/* A hairline of accent along the top edge, so a card reads as a deliberate
   panel rather than a slightly different shade of the page. */
.card.feature {
  position: relative; overflow: hidden;
  padding-top: calc(var(--step) * 6);
}
.card.feature::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 35%, transparent));
}

/* Money, big. Used on the landing page and every total. */
.price { display: flex; flex-direction: column; gap: 2px; }
.price .figure {
  font-size: 2rem; font-weight: 750; letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums; line-height: 1;
}
.price .figure .cur { font-size: 1rem; font-weight: 600; color: var(--text-muted); }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

.grid2 { display: grid; gap: 0 calc(var(--step) * 4); grid-template-columns: 1fr 1fr; }
@media (max-width: 40rem) { .grid2 { grid-template-columns: 1fr; } }

.row { display: flex; gap: calc(var(--step) * 2); flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.spread { display: flex; justify-content: space-between; align-items: baseline; gap: calc(var(--step) * 3); flex-wrap: wrap; }

/* ==========================================================================
   Progress steps
   ========================================================================== */

.steps { display: flex; gap: calc(var(--step) * 2); list-style: none; padding: 0; margin: 0 0 calc(var(--step) * 5); flex-wrap: wrap; }
.steps li {
  display: flex; align-items: center; gap: calc(var(--step) * 1.5);
  font-size: 0.85rem; color: var(--text-muted);
}
.steps li::before {
  content: attr(data-n);
  width: 1.5rem; height: 1.5rem; flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 50%; font-size: 0.75rem; font-weight: 650;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text-muted);
}
.steps li[aria-current] { color: var(--text); font-weight: 600; }
.steps li[aria-current]::before { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.steps li.done::before { content: "✓"; background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-fg); }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn, button {
  display: inline-flex; align-items: center; justify-content: center;
  gap: calc(var(--step) * 1.5);
  background: var(--accent); color: var(--on-accent);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: calc(var(--step) * 2.5) calc(var(--step) * 4);
  font: inherit; font-weight: 550; line-height: 1.2;
  text-decoration: none; cursor: pointer;
  transition: background-color 120ms ease, transform 60ms ease, box-shadow 120ms ease;
}
.btn:hover, button:hover { background: var(--accent-hover); }
.btn:active, button:active { transform: translateY(1px); }

.btn.secondary, button.secondary {
  background: var(--surface); color: var(--text); border-color: var(--line-strong);
}
.btn.secondary:hover, button.secondary:hover { background: var(--surface-2); }

.btn.small, button.small { padding: calc(var(--step) * 1.5) calc(var(--step) * 2.5); font-size: 0.85rem; }

button.link {
  background: none; border: 0; color: var(--accent); padding: 0;
  font-size: 0.85rem; text-decoration: underline; text-underline-offset: 2px;
}
button.link:hover { background: none; color: var(--accent-hover); }

form.inline { display: inline; }

/* ==========================================================================
   Forms
   ========================================================================== */

.field { margin-bottom: calc(var(--step) * 4); }
.field label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: calc(var(--step) * 1.5); }

input[type=text], input[type=email], input[type=tel], input[type=date],
input[type=number], select, textarea {
  width: 100%;
  padding: calc(var(--step) * 2.5) calc(var(--step) * 3);
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
input:hover, select:hover { border-color: var(--ink-300); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent);
}
select { appearance: none; background-image:
  linear-gradient(45deg, transparent 50%, currentColor 50%),
  linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% + 2px), calc(100% - 13px) calc(50% + 2px);
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
  padding-right: calc(var(--step) * 9);
}

.field .help { color: var(--text-muted); font-size: 0.85rem; margin-top: calc(var(--step) * 1.5); }

/* An input with a fixed prefix baked into the same visual box, used for the
   phone dialling code so the coach only types their local number. */
.input-prefixed { display: flex; align-items: stretch; }
.input-prefixed .prefix {
  display: flex; align-items: center;
  padding: 0 calc(var(--step) * 3);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-right: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  color: var(--text-muted); font-variant-numeric: tabular-nums;
  font-weight: 600; white-space: nowrap;
}
.input-prefixed input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-prefixed:focus-within .prefix { border-color: var(--focus); }
.has-error .input-prefixed .prefix { border-color: var(--err-fg); }

.field.has-error input, .field.has-error select,
input[aria-invalid="true"], select[aria-invalid="true"] {
  border-color: var(--err-fg);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--err-fg) 15%, transparent);
}
/* Even when focused, a genuinely invalid field stays red — but a valid focused
   field never goes red. */
input[aria-invalid="true"]:focus, select[aria-invalid="true"]:focus {
  border-color: var(--err-fg);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--err-fg) 25%, transparent);
}
ul.errors {
  color: var(--err-fg); font-size: 0.875rem;
  margin: calc(var(--step) * 1.5) 0 0; padding-left: 1.1rem;
}

input[type=checkbox] { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }
.checkbox-row { display: flex; gap: calc(var(--step) * 2); align-items: flex-start; }
.checkbox-row label { font-weight: 400; }

/* Team members: a searchable, scrolling list with aligned columns. */
.member-search { margin-bottom: calc(var(--step) * 2); }
.member-list {
  max-height: 24rem; overflow-y: auto;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.field .member {
  display: grid; grid-template-columns: 1.5rem 1fr 3rem 6.5rem 4rem;
  align-items: center; gap: calc(var(--step) * 2); margin: 0;
  padding: .5rem .75rem; border-bottom: 1px solid var(--line);
  font-weight: 400; cursor: pointer;
}
.field .member:last-child { border-bottom: 0; }
.field .member:hover { background: var(--surface-2); }
.field .member:has(input:checked) {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}
.field .member-head {
  position: sticky; top: 0; z-index: 1; cursor: default;
  background: var(--surface-2); color: var(--text-muted);
  font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
}
.member-name { font-weight: 600; }
.member > span:not(.member-name) { color: var(--text-muted); font-size: .9rem; }
@media (max-width: 480px) {
  .field .member { grid-template-columns: 1.5rem 1fr 2.5rem 5.5rem; }
  .field .member > :nth-child(5) { display: none; }
}

/* ==========================================================================
   Tables
   ========================================================================== */

.table-wrap { overflow-x: auto; margin: 0 calc(var(--step) * -5); padding: 0 calc(var(--step) * 5); }
table { width: 100%; border-collapse: collapse; font-size: 0.925rem; }
th, td { text-align: left; padding: calc(var(--step) * 3) calc(var(--step) * 2); vertical-align: top; }
thead th {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); font-weight: 650;
  border-bottom: 1px solid var(--line-strong); white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--line); }
tbody tr:last-child { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ==========================================================================
   Tags, alerts, totals
   ========================================================================== */

.tag {
  display: inline-block;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: calc(var(--step) * 0.5) calc(var(--step) * 2);
  font-size: 0.8rem; font-weight: 600; font-family: var(--mono);
  margin: 0 calc(var(--step)) calc(var(--step)) 0;
}
.tag.up { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-fg); }
.tag.team { background: var(--info-bg); border-color: var(--info-line); color: var(--info-fg); }

.msg, .banner {
  border: 1px solid; border-radius: var(--radius-sm);
  padding: calc(var(--step) * 3) calc(var(--step) * 4);
  margin-bottom: calc(var(--step) * 4);
  font-size: 0.925rem;
}
.msg > :last-child, .banner > :last-child { margin-bottom: 0; }
.msg.success { background: var(--ok-bg);   border-color: var(--ok-line);   color: var(--ok-fg); }
.msg.warning, .banner { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-fg); }
.msg.error   { background: var(--err-bg);  border-color: var(--err-line);  color: var(--err-fg); }
.banner.info { background: var(--info-bg); border-color: var(--info-line); color: var(--info-fg); }

.warnrow { color: var(--warn-fg); font-size: 0.85rem; margin-top: calc(var(--step)); }

.total-bar {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: calc(var(--step) * 4); flex-wrap: wrap;
}
.total-bar .amount {
  font-size: 2.1rem; font-weight: 750; letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums; line-height: 1.1;
  color: var(--text);
}

/* Landing hero — the first thing a coach sees, so it earns some weight. */
.hero {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: calc(var(--step) * 8) calc(var(--step) * 6);
  margin-bottom: calc(var(--step) * 5);
  background:
    radial-gradient(90% 140% at 100% 0%, color-mix(in srgb, var(--accent) 16%, transparent) 0%, transparent 60%),
    var(--surface);
}
.hero h1 { font-size: clamp(1.8rem, 1.3rem + 2.4vw, 2.75rem); margin-bottom: calc(var(--step) * 2); }
.hero .kicker {
  text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.72rem;
  font-weight: 700; color: var(--accent); margin-bottom: calc(var(--step) * 2);
}

.empty { text-align: center; padding: calc(var(--step) * 8) calc(var(--step) * 4); color: var(--text-muted); }
.empty p { margin-bottom: calc(var(--step) * 4); }

/* ==========================================================================
   The live age readout
   ========================================================================== */

.age-readout {
  border: 1px solid var(--info-line); background: var(--info-bg); color: var(--info-fg);
  border-radius: var(--radius-sm);
  padding: calc(var(--step) * 3) calc(var(--step) * 4);
  margin-bottom: calc(var(--step) * 4);
}
.age-readout .age-number {
  font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.age-readout.is-error { border-color: var(--err-line); background: var(--err-bg); color: var(--err-fg); }
.age-readout ul { margin: calc(var(--step) * 2) 0 0; padding-left: 1.1rem; font-size: 0.875rem; }

/* htmx sets this while a request is in flight. */
.htmx-request .age-readout { opacity: 0.55; transition: opacity 120ms ease; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* Alpine sets x-cloak on elements that must not flash before it initialises. */
[x-cloak] { display: none !important; }

/* Demo banner. Uses the warning tokens so it inherits dark mode along with
 * everything else, and sits above the header rather than inside it — the point of
 * this element is that it cannot be scrolled past or mistaken for site chrome. */
.demo-banner {
  background: var(--warn-bg);
  color: var(--warn-fg);
  border-bottom: 1px solid var(--warn-line);
  padding: .6rem 1.25rem;
  font-size: .9rem;
  text-align: center;
}

.demo-banner strong { letter-spacing: .01em; }

/* --- Submit page: the review summary ---------------------------------------
 * The last look before the indemnity is accepted, so it is figures and tables
 * rather than an illustration: this page has to be read, not enjoyed.
 *
 * No belt colours anywhere. data/grades.csv records kyu and dan only, on purpose
 * — entering clubs come from federations whose belt colours differ for the same
 * kyu, and showing a visiting coach the wrong colour for their own student would
 * be confidently wrong.
 */
.tally {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.25rem;
}

.tally-item {
  background: var(--surface-2);
  padding: 1.15rem 1rem;
  text-align: center;
}

/* The money is the figure a coach is looking for, so it gets the accent bar
 * rather than being one number among five. */
.tally-item.accent {
  background: color-mix(in srgb, var(--accent) 7%, var(--surface-2));
  box-shadow: inset 0 -3px 0 0 var(--accent);
}

.tally-figure {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.05;
  /* Tabular figures, so a number ticking 9 -> 10 doesn't shuffle the layout
   * sideways as glyph widths change. */
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.tally-label {
  margin-top: .4rem;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}

/* The full cost, under "left to pay" on an amended entry. Its own line so the
   uppercase label above it stays scannable. */
.tally-sub {
  display: block;
  margin-top: .2rem;
  text-transform: none;
  letter-spacing: 0;
  opacity: .75;
}

.step-up-note { margin: -0.5rem 0 1.25rem; }

table.summary-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

table.summary-table th,
table.summary-table td {
  padding: .6rem .7rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

table.summary-table thead th {
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  border-bottom-width: 2px;
}

table.summary-table tbody tr:hover { background: var(--surface-2); }
table.summary-table tbody tr:last-child td { border-bottom: 0; }

table.summary-table tfoot th {
  border-top: 2px solid var(--line);
  border-bottom: 0;
  font-size: .85rem;
}

table.summary-table .num { text-align: right; }
table.summary-table .nowrap { white-space: nowrap; }
table.summary-table td .small { margin-left: .4rem; }

/* A competitor with no categories is the one thing on this page that blocks
 * submitting, so the row says so rather than only the problems list below. */
table.summary-table tr.incomplete {
  background: var(--warn-bg);
}
table.summary-table tr.incomplete:hover { background: var(--warn-bg); }

.pill-warn {
  display: inline-block;
  padding: .1rem .5rem;
  border-radius: 999px;
  border: 1px solid var(--warn-line);
  background: var(--warn-bg);
  color: var(--warn-fg);
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}

.legend { margin: .85rem 0 0; }

.declaration {
  white-space: pre-line;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

/* Motion is decoration here; the figures are already in the HTML. */
@media (prefers-reduced-motion: reduce) {
  .tally-figure { transition: none; }
}

/* Category cells on the review table: the code, then a short description built
 * from the category's own fields. The full label goes on the tooltip — it repeats
 * the sex and discipline the row and column already carry, and at that width it
 * pushes the cost column off a phone screen. */
table.summary-table td.cat-cell { min-width: 11rem; }

.cat {
  display: flex;
  align-items: baseline;
  gap: .4rem;
}

.cat + .cat { margin-top: .3rem; }

.cat-desc {
  font-size: .72rem;
  line-height: 1.25;
  color: var(--muted);
  /* Wraps rather than truncating: a coach checking an entry needs to read it,
   * and an ellipsis on a phone would hide the weight class. */
  overflow-wrap: anywhere;
}

@media (max-width: 720px) {
  .cat { flex-direction: column; gap: .1rem; }
}

/* Fixed layout for the review tables. With automatic widths the two category
 * columns stretched to fill the row, leaving a short description marooned a long
 * way from the next column — the table read as two unrelated halves. */
table.summary-table.fixed { table-layout: fixed; }

table.summary-table.fixed td,
table.summary-table.fixed th { overflow-wrap: anywhere; }

/* Team members sit under the team name, so both tables put the people on the
 * left and the money on the right. They used to be a column of their own on the
 * far right, which had the names at opposite ends of the two tables. */
.member-list {
  margin-top: .2rem;
  font-size: .78rem;
  line-height: 1.35;
  color: var(--muted);
}

/* A colour swatch instead of an example category code. */
.legend { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.legend .legend-swatch {
  width: 1.6rem;
  padding: 0;
  height: 1rem;
}
.legend .legend-swatch + * { margin-right: .6rem; }

/* The code box on the verification page: big, spaced, and unambiguous to type. */
input.code-input {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 1.5rem;
  letter-spacing: .3em;
  text-transform: uppercase;
  text-align: center;
  max-width: 9em;
}

/* The "you've added to this entry" panel. Two tables rather than one: what was
 * added, then the arithmetic. A coach seeing a bigger number wants to know what
 * changed before they want the total. */
table.additions,
table.money-summary { width: 100%; border-collapse: collapse; }

table.additions td {
  padding: .5rem .1rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

table.additions td:first-child { font-weight: 600; }
table.additions .small { margin-left: .4rem; }

table.money-summary { margin-top: 1rem; max-width: 24rem; }

table.money-summary th,
table.money-summary td {
  padding: .35rem 0;
  text-align: left;
  font-weight: 400;
}

table.money-summary .num { text-align: right; font-variant-numeric: tabular-nums; }

/* The figure they act on, so it gets the weight and a rule above it. */
table.money-summary tr.owing th,
table.money-summary tr.owing td {
  border-top: 2px solid var(--line);
  padding-top: .55rem;
  font-weight: 700;
  font-size: 1.15rem;
}

/* Dated payments, under the arithmetic in the money panel and under "Paid in
   full" in the total bar. One flat line each — an earlier version panelled every
   row and turned four figures into a wall. */
.payments-received { margin-top: 1.1rem; max-width: 26rem; }

.payments-received .label {
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: .7rem;
  margin-bottom: .3rem;
}

table.payments { width: 100%; border-collapse: collapse; }

table.payments td {
  padding: .3rem 0;
  vertical-align: middle;
}

table.payments td:nth-child(2) { padding-left: .5rem; }
table.payments td:nth-child(3) { padding-left: .6rem; width: 100%; }

table.payments .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Stripe's wordmark plus a tick, on the payment's own line. The tick is green;
   the wordmark keeps Stripe's colour, because a brand mark recoloured to match
   a page stops being the brand mark. */
.payments .verified {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  color: var(--ok-fg);
}

.payments .stripe-mark {
  display: block;
  height: 17px;
  width: auto;
}

/* Slate on light, white on dark — chosen by <picture> in the template, not here.
   CSS could only hide one after both had been downloaded. */
.payments picture { display: block; }

/* Why the team step-up dropdown has nothing to pick. */
.step-up-note {
  color: var(--accent); font-weight: 700;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-left: 3px solid var(--accent); border-radius: var(--radius-sm);
  padding: .5rem .75rem; margin: .25rem 0 .5rem;
}
