/* Club Admin. WCAG 2.2 AA: text contrast of at least 4.5:1, a visible
   focus ring on everything focusable, and touch targets of 44 x 44 px.
   No inline styles are used (the Content Security Policy forbids them). */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1a1d23;
  --muted: #4b5262;      /* 7.4:1 on white */
  --border: #c9ced8;
  --primary: #1d4ed8;    /* 6.7:1 on white */
  --primary-dark: #1e3a8a;
  --danger: #b42318;     /* 6.0:1 on white */
  --ok: #12663a;         /* 6.6:1 on white */
  --warn-bg: #fff7e0;
  --warn-border: #b25e09;
  --error-bg: #fdecea;
  --focus: #1d4ed8;
  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html { font-size: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; margin-top: 1rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--primary); }
a:hover { color: var(--primary-dark); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.95em; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 0.5rem; top: -4rem;
  background: var(--surface); padding: 0.75rem 1rem;
  border: 2px solid var(--primary); border-radius: var(--radius); z-index: 10;
}
.skip-link:focus { top: 0.5rem; }

.muted { color: var(--muted); }

/* Layout */
.page { max-width: 72rem; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.page--narrow { max-width: 28rem; margin: 0 auto; padding: 2rem 1rem; }
main:focus { outline: none; }
.stack > * + * { margin-top: 1rem; }
.grid { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); }
.heading { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.heading h1 { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 0.75rem; }

/* Top bar */
.topbar { background: var(--primary-dark); color: #fff; }
.topbar__inner { max-width: 72rem; margin: 0 auto; padding: 0.5rem 1rem; display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.topbar__brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 1.1rem; min-height: 44px; display: inline-flex; align-items: center; }
.topbar__brand:hover { color: #fff; text-decoration: underline; }
.topbar :focus-visible { outline-color: #fff; }
.topbar__user { margin-left: auto; display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.topbar__email { font-size: 0.9rem; }
.switcher { display: flex; gap: 0.5rem; align-items: center; }
.switcher label { font-size: 0.9rem; }
.switcher select { min-height: 44px; border-radius: var(--radius); border: 1px solid #fff; padding: 0 0.5rem; }

/* Club bar and navigation */
.club__bar { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; padding-bottom: 0.5rem; }
.club__name { margin: 0; font-weight: 600; }
.club__nav, .subnav { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.club__nav a, .subnav a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 0.75rem;
  border-radius: var(--radius); text-decoration: none; color: var(--text);
}
.club__nav a:hover, .subnav a:hover { background: #e8ecf5; }
.club__nav a[aria-current="page"], .subnav a[aria-current="page"] {
  background: var(--primary); color: #fff; font-weight: 600;
}
.subnav { margin-bottom: 1rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; }

/* Cards and panels */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.cards { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: 1rem; }
.card__head { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: baseline; justify-content: space-between; }
.card__head h2 { margin: 0; }
fieldset.card { margin: 0; }
legend { font-weight: 700; padding: 0 0.25rem; }
details > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; color: var(--primary); }
details[open] > summary { margin-bottom: 0.75rem; }
.club-list { list-style: none; padding: 0; display: grid; gap: 0.75rem; }
.club-list a { font-size: 1.15rem; font-weight: 600; }

.panel { border-radius: var(--radius); padding: 1rem; margin: 0 0 1rem; border: 1px solid var(--border); background: var(--surface); }
.panel p:last-child { margin-bottom: 0; }
.panel ul { margin: 0.25rem 0 0; padding-left: 1.25rem; }
.panel__title { font-weight: 700; }
.panel--error { background: var(--error-bg); border-color: var(--danger); border-left-width: 6px; }
.panel--warn { background: var(--warn-bg); border-color: var(--warn-border); border-left-width: 6px; }
.panel--empty { text-align: center; padding: 2rem 1rem; }
.panel .btn { margin-top: 0.5rem; }

.notice { color: var(--ok); font-weight: 600; min-height: 1.5rem; margin: 0.25rem 0; }
.notice:empty { min-height: 0; margin: 0; }
.summary { font-weight: 600; }

/* Facts */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; margin: 0.75rem 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* Badges and statuses (always with text, never color alone) */
.badge { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px; border: 1px solid var(--muted); font-size: 0.85rem; color: var(--muted); }
.badge--ok { border-color: var(--ok); color: var(--ok); font-weight: 600; }
.badge--env { border-color: #fff; color: #fff; text-transform: uppercase; letter-spacing: 0.05em; }
.status { font-weight: 600; }
.status--paid, .status--active { color: var(--ok); }
.status--cancelled, .status--refunded, .status--voided, .status--expired { color: var(--danger); }
.status--pending, .status--redeemed { color: var(--muted); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.25rem;
  min-height: 44px; min-width: 44px; padding: 0 1rem;
  border-radius: var(--radius); border: 1px solid var(--primary);
  background: var(--surface); color: var(--primary);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { background: #e8ecf5; color: var(--primary-dark); }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-dark); color: #fff; }
.btn--danger { border-color: var(--danger); color: var(--danger); }
.btn--danger:hover { background: var(--error-bg); color: var(--danger); }
.btn--small { padding: 0 0.75rem; font-size: 0.9rem; }
.btn--wide { width: 100%; }
.btn[disabled] { opacity: 0.6; cursor: not-allowed; }
.topbar .btn { background: transparent; color: #fff; border-color: #fff; }
.topbar .btn:hover { background: rgba(255, 255, 255, 0.15); }

/* Forms */
.field { margin-bottom: 0.75rem; display: flex; flex-direction: column; gap: 0.25rem; }
.field label { font-weight: 600; }
.field__required { font-weight: 400; color: var(--muted); }
.field__hint { margin: 0; color: var(--muted); font-size: 0.9rem; }
.field__error { margin: 0; color: var(--danger); font-weight: 600; }
.field__error::before { content: "Error: "; }
.field input, .field select, .field textarea {
  min-height: 44px; padding: 0.5rem 0.75rem; font: inherit; color: var(--text);
  background: #fff; border: 1px solid #6b7280; border-radius: var(--radius); width: 100%;
}
.field--invalid input, .field--invalid select, .field--invalid textarea { border: 2px solid var(--danger); }
.field--check { flex-direction: row; align-items: center; gap: 0.5rem; min-height: 44px; }
.field--check input { width: 1.5rem; height: 1.5rem; min-height: 0; margin: 0; }
.field--check label { font-weight: 400; }
.filters { display: flex; flex-wrap: wrap; gap: 0 1rem; align-items: flex-end; margin: 1rem 0; }
.filters .field { min-width: 12rem; }
.tier { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem; }
.divider { display: flex; align-items: center; gap: 0.75rem; margin: 1rem 0; color: var(--muted); }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

/* Rows inside a card */
.rows { list-style: none; padding: 0; margin: 0; }
.row { border-top: 1px solid var(--border); padding: 0.75rem 0; }
.row__title { margin: 0; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
thead th { background: #eef1f6; font-size: 0.9rem; }
tbody th { font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-sub { display: block; font-weight: 400; font-size: 0.85rem; }
.cell-wrap { max-width: 18rem; }
.role-actions { display: flex; flex-wrap: wrap; gap: 0.25rem; }

/* Athlete */
.athlete { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: flex-start; margin-bottom: 1rem; }
.photo { width: 10rem; height: 10rem; border-radius: var(--radius); object-fit: cover; border: 1px solid var(--border); background: #e8ecf5; }
.photo--placeholder { display: flex; align-items: center; justify-content: center; text-align: center; }
.photo--placeholder svg { width: 60%; height: 60%; fill: #9aa3b5; }
.photo__note { font-size: 0.85rem; color: var(--muted); padding: 0.5rem; }

/* Loading */
.skeleton { display: grid; gap: 0.75rem; margin: 1rem 0; }
.skeleton__row { height: 3rem; border-radius: var(--radius); background: linear-gradient(90deg, #e3e7ee 25%, #eef1f6 50%, #e3e7ee 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
.spinner { width: 2rem; height: 2rem; border: 3px solid #c9ced8; border-top-color: var(--primary); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .skeleton__row, .spinner { animation: none; }
}

/* Dialog */
.modal { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; max-width: min(32rem, calc(100vw - 2rem)); }
.modal::backdrop { background: rgba(17, 24, 39, 0.55); }
.modal__title { font-size: 1.25rem; }

@media (max-width: 40rem) {
  h1 { font-size: 1.4rem; }
  .facts { grid-template-columns: 1fr; }
  .facts dd { margin-bottom: 0.5rem; }
  .topbar__user { margin-left: 0; }
}
.break-anywhere { overflow-wrap: anywhere; }
