/* Admin UI (docs/design/admin-ui.md).
   No inline styles, no JS, no external fonts/images/CDNs. Light + dark themes
   via prefers-color-scheme on custom properties. Palette adapted from the UD
   Las Palmas club colours (blue #0045AD, yellow #F2BC24) on a soft neutral
   ground, with card surfaces for every section.
   ------------------------------------------------------------------
   1. Tokens
   2. Reset / base / typography
   3. Utilities (visually-hidden, skip-link, muted, num, block)
   4. Shell: header, nav, session, main
   5. Flash / notes / empty states
   6. Cards: .panel, .table-scroll, page headers
   7. Buttons
   8. Badges and tags
   9. Facts list, inline list, details
   10. Tables
   11. Forms
   12. Page-specific hooks (embed preview, matchdays, endpoints, row actions)
   13. Responsive, reduced motion, forced colours
   ------------------------------------------------------------------ */

/* ---------- 1. Tokens ---------- */
:root {
  color-scheme: light dark;

  /* Brand */
  --c-brand: #0045ad;          /* club blue: surfaces */
  --c-brand-dark: #00347f;
  --c-brand-ink: #003c94;      /* club blue for text/links on light: 8.6:1 */
  --c-accent: #f2bc24;         /* club yellow: accents only, never body text */
  --c-on-brand: #ffffff;       /* 7.3:1 on --c-brand */
  --c-on-brand-muted: #d8e3f6; /* 5.5:1 on --c-brand */

  /* Neutrals */
  --c-bg: #f4f5f9;             /* application ground */
  --c-panel: #ffffff;          /* card surface */
  --c-panel-alt: #f8f9fc;      /* zebra / sub-surface */
  --c-text: #1f2937;           /* 13.6:1 on --c-panel */
  --c-heading: #111827;
  --c-muted: #4b5563;          /* 7.4:1 on --c-panel */
  --c-border: #dcdfe8;         /* decorative hairlines */
  --c-border-strong: #6b7280;  /* inputs, table rules: >= 3:1 */
  --c-primary: var(--c-brand-ink);
  --c-focus: #1d4ed8;
  --c-error: #b91c1c;
  --c-error-bg: #fef2f2;

  /* Status (run) */
  --queued-fg: #374151; --queued-bg: #e5e7eb;
  --running-fg: #1e3a8a; --running-bg: #dbeafe;
  --succeeded-fg: #14532d; --succeeded-bg: #dcfce7;
  --partial-fg: #78350f; --partial-bg: #fef3c7;
  --failed-fg: #7f1d1d; --failed-bg: #fee2e2;
  --abandoned-fg: #3f3f46; --abandoned-bg: #e4e4e7;

  /* Highlighted row (our team) */
  --c-ours-bg: #fff7e0;
  --c-ours-rule: var(--c-accent);

  /* Space scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;

  /* Radii + elevation */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 6px 18px rgba(16, 24, 40, 0.06);

  /* Type scale */
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-base: 0.9375rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.625rem;

  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: var(--fs-base);
  color: var(--c-text);
  background: var(--c-bg);
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

@media (prefers-color-scheme: dark) {
  :root {
    --c-brand: #0b3f8f;
    --c-brand-dark: #082d68;
    --c-brand-ink: #9cc0ff;      /* 7.4:1 on --c-panel */
    --c-accent: #f6c650;
    --c-on-brand: #ffffff;
    --c-on-brand-muted: #c9d8f2;

    --c-bg: #0e1320;
    --c-panel: #171d2c;
    --c-panel-alt: #1d2434;
    --c-text: #e7eaf2;           /* 13.2:1 on --c-panel */
    --c-heading: #f5f7fb;
    --c-muted: #a9b3c7;          /* 7.3:1 on --c-panel */
    --c-border: #2b3346;
    --c-border-strong: #8a94a8;
    --c-focus: #93c5fd;
    --c-error: #fca5a5;
    --c-error-bg: #33191b;

    --queued-fg: #d5d9e2; --queued-bg: #333a4c;
    --running-fg: #c3dcff; --running-bg: #1d3358;
    --succeeded-fg: #b7f2cb; --succeeded-bg: #13361f;
    --partial-fg: #fbdc8f; --partial-bg: #3e2f0c;
    --failed-fg: #ffc3c3; --failed-bg: #4a1d1d;
    --abandoned-fg: #d6d8de; --abandoned-bg: #383c46;

    --c-ours-bg: #33290c;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 18px rgba(0, 0, 0, 0.35);
  }
}

/* ---------- 2. Reset / base / typography ---------- */
*, *::before, *::after { box-sizing: border-box; }

body.admin {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  min-height: 100vh;
}

h1, h2, h3 { color: var(--c-heading); line-height: 1.25; text-wrap: balance; }
h1 { font-size: var(--fs-xl); margin: 0 0 var(--space-2); letter-spacing: -0.01em; }
h2 { font-size: var(--fs-lg); margin: 0 0 var(--space-3); letter-spacing: -0.005em; }
h3 { font-size: var(--fs-md); margin: 0 0 var(--space-2); }
p { margin: 0 0 var(--space-3); }
p:last-child { margin-bottom: 0; }

a { color: var(--c-primary); text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }

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

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875em;
  overflow-wrap: anywhere;
  background: var(--c-panel-alt);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 0.05em 0.35em;
}

time { font-variant-numeric: tabular-nums; }

/* ---------- 3. Utilities ---------- */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.muted { color: var(--c-muted); }
.block { display: block; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.skip-link {
  position: absolute;
  left: -999px; top: 0;
  z-index: 20;
  background: var(--c-panel);
  color: var(--c-primary);
  font-weight: 600;
  padding: var(--space-3) var(--space);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.skip-link:focus { left: var(--space-2); top: var(--space-2); }

/* ---------- 4. Shell ---------- */
.admin-header {
  background: var(--c-brand);
  color: var(--c-on-brand);
  border-bottom: 4px solid var(--c-accent);
  box-shadow: var(--shadow-sm);
  /* Legacy flex properties kept so the header still lays out if the inner
     wrapper is ever absent. */
  display: block;
}

.admin-header-inner {
  max-width: 76rem;
  margin: 0 auto;
  padding: var(--space-3) var(--space);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-5);
}

.admin-header .brand {
  margin: 0;
  font-weight: 700;
  font-size: var(--fs-md);
  letter-spacing: 0.01em;
}
.admin-header .brand a {
  color: var(--c-on-brand);
  text-decoration: none;
  display: inline-block;
  padding: var(--space-1) 0;
}
.admin-header .brand a:hover { text-decoration: underline; text-decoration-color: var(--c-accent); text-decoration-thickness: 3px; }

.admin-header nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
}
.admin-header nav a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--c-on-brand-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: var(--fs-base);
  border: 1px solid transparent;
}
.admin-header nav a:hover {
  color: var(--c-on-brand);
  background: rgba(255, 255, 255, 0.12);
}
.admin-header nav a[aria-current="page"] {
  color: var(--c-accent);
  background: rgba(0, 0, 0, 0.22);
  border-color: rgba(255, 255, 255, 0.28);
  font-weight: 700;
  text-decoration: none;
}

/* The generic <details> card styling (section 10) must not reach the navbar menu:
   it painted a pale box behind the white email text. */


/* Account menu — the reference app's Bootstrap navbar dropdown, values copied from Bootstrap 5.3
   (navbar-nav, nav-link, dropdown-toggle caret, dropdown-menu/-end, dropdown-item, dropdown-divider)
   plus its theme.css overrides (no border, .5rem radius, soft shadow). A <details> element replaces
   data-bs-toggle, so the menu opens with no JavaScript. */
/* The generic <details> card styling (section 10) must not reach the navbar menu:
   it painted a pale box behind the white email text. */
.admin-header details.dropdown {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
}
.admin-header details.dropdown[open] > summary { margin-bottom: 0; }
.admin-header details.dropdown ul { margin: 0; padding-left: 0; }
.admin-header details.dropdown ul li { margin-bottom: 0; }

.admin-header .navbar-nav {
  display: flex;
  margin: 0 0 0 auto;
  padding: 0;
  list-style: none;
}
.admin-header .nav-item.dropdown { position: relative; }

.admin-header .nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.5rem var(--space-3);
  color: var(--c-on-brand);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-decoration: none;
  border-radius: 0.425rem;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.admin-header .nav-link:hover { background: rgba(255, 255, 255, 0.14); color: var(--c-on-brand); }

summary.nav-link { list-style: none; }
summary.nav-link::-webkit-details-marker { display: none; }

/* Bootstrap's caret, verbatim. */
.dropdown-toggle::after {
  display: inline-block;
  margin-left: 0.255em;
  vertical-align: 0.255em;
  content: "";
  border-top: 0.3em solid;
  border-right: 0.3em solid transparent;
  border-bottom: 0;
  border-left: 0.3em solid transparent;
}
.user-menu[open] > .dropdown-toggle::after { transform: rotate(180deg); }

.dropdown-menu {
  position: absolute;
  z-index: 1000;
  display: block;
  min-width: 12rem;
  margin: 0.125rem 0 0;
  padding: 0.5rem 0;
  list-style: none;
  font-size: var(--fs-sm);
  color: var(--c-text);
  text-align: left;
  background: var(--c-panel);
  background-clip: padding-box;
  border: 0;                                           /* theme.css */
  border-radius: 0.5rem;                               /* theme.css */
  box-shadow: 0 0.25rem 1rem rgba(75, 70, 92, 0.18);   /* theme.css */
}
.dropdown-menu-end { right: 0; left: auto; }

.dropdown-item {
  display: block;
  width: 100%;
  min-height: 2.5rem;
  padding: 0.5rem 1rem;
  clear: both;
  font: inherit;
  font-weight: 400;
  color: var(--c-text);
  text-align: inherit;
  text-decoration: none;
  white-space: nowrap;
  background: transparent;
  border: 0;
  cursor: pointer;
}
.dropdown-item:hover,
.dropdown-item:focus { background: rgba(0, 69, 173, 0.12); color: var(--c-brand-ink); }
.dropdown-menu form { margin: 0; }

.dropdown-divider {
  height: 0;
  margin: 0.5rem 0;
  overflow: hidden;
  border: 0;
  border-top: 1px solid var(--c-border);
}

@media (prefers-color-scheme: dark) {
  .dropdown-menu { box-shadow: 0 0.25rem 1rem rgba(0, 0, 0, 0.5); }
  .dropdown-item:hover,
  .dropdown-item:focus { background: rgba(110, 162, 255, 0.16); }
}

main {
  max-width: 76rem;
  margin: 0 auto;
  padding: var(--space-5) var(--space) var(--space-6);
}
main:focus { outline: none; } /* skip-link target, not an interactive control (UX3-6) */

main > section { margin-bottom: var(--space-5); }
main > section:last-child { margin-bottom: 0; }

/* Sign-in and other "bare" pages: no header, one card centred on the page (layout shared with ScoutR). */
body.admin-bare main {
  max-width: 30rem;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-top: var(--space-5);
}
.login-card {
  background: var(--c-panel);
  border: 3px solid var(--c-brand);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.login-card-header {
  display: flex;
  align-items: center;
  gap: var(--space);
  padding: var(--space-5);
  background: var(--c-brand);
  color: var(--c-on-brand);
}
.login-shield { flex: none; width: 4rem; height: 4rem; object-fit: contain; }
.login-app { margin: 0; font-size: var(--fs-xl); font-weight: 700; line-height: 1.15; letter-spacing: -0.01em; }
.login-card-header h1 { margin: var(--space-1) 0 0; font-size: var(--fs-md); font-weight: 500; color: var(--c-on-brand-muted); }
.login-card-body { padding: var(--space-5) var(--space-5) var(--space-2); }
.login-card-body .flash { margin-bottom: var(--space); }
.login-card-footer {
  padding: var(--space) var(--space-5) var(--space-5);
  background: var(--c-panel-alt);
  border-top: 1px solid var(--c-border);
}
.btn-block { display: flex; width: 100%; }

/* ---------- 5. Flash, notes, empty states ---------- */
.flash {
  padding: var(--space-3) var(--space);
  border-radius: var(--radius);
  margin-bottom: var(--space-5);
  border: 1px solid currentColor;
  box-shadow: var(--shadow-sm);
}
.flash strong { margin-right: var(--space-1); }
.flash-notice { background: var(--succeeded-bg); color: var(--succeeded-fg); }
.flash-alert { background: var(--failed-bg); color: var(--failed-fg); }

.note {
  padding: var(--space-3) var(--space);
  border-left: 4px solid var(--c-border-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--c-panel-alt);
  margin-bottom: var(--space);
}
.note-alert, .note-failed { border-color: var(--failed-fg); background: var(--failed-bg); color: var(--failed-fg); }
.note-partial { border-color: var(--partial-fg); background: var(--partial-bg); color: var(--partial-fg); }
.note-abandoned { border-color: var(--abandoned-fg); background: var(--abandoned-bg); color: var(--abandoned-fg); }

.empty {
  padding: var(--space-5);
  background: var(--c-panel);
  border: 1px dashed var(--c-border-strong);
  border-radius: var(--radius);
  color: var(--c-muted);
  text-align: center;
}

/* ---------- 6. Cards ---------- */
.panel {
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}
.panel > h2,
.panel > h3 { margin-top: 0; }

/* Page intro block: h1 + supporting copy, above the cards. */
.page-header { margin-bottom: var(--space-5); }
.page-header > p { color: var(--c-muted); margin-bottom: 0; max-width: 60ch; }
.page-header .back-link {
  display: inline-flex;
  font-size: var(--fs-sm);
  font-weight: 600;
}
/* The paragraph holding the back link carries the gap, so the heading below never sits on top of it. */
.page-header > p:has(> .back-link) { margin-bottom: var(--space-3); }

/* Table cards: .table-scroll is the card itself outside a panel, and a plain
   scroller when nested inside one. */
.table-scroll {
  overflow-x: auto;
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel .table-scroll {
  background: none;
  border: 1px solid var(--c-border);
  box-shadow: none;
}

/* ---------- 7. Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 2.75rem;
  padding: var(--space-2) var(--space);
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-primary);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.btn-primary {
  background: var(--c-brand);
  border-color: var(--c-brand);
  color: var(--c-on-brand);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--c-brand-dark); border-color: var(--c-brand-dark); }
.btn-secondary {
  background: var(--c-panel);
  color: var(--c-primary);
  border-color: var(--c-border-strong);
}
.btn-secondary:hover { background: var(--c-panel-alt); border-color: var(--c-primary); }
.btn[disabled] {
  background: var(--queued-bg);
  color: var(--queued-fg);
  border-color: var(--queued-fg);
  box-shadow: none;
  cursor: not-allowed;
}

/* ---------- 8. Badges and tags ---------- */
.badge, .tag {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: var(--radius-pill);
  border: 1px solid;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  vertical-align: baseline;
}
.badge-queued, .tag-unresolved { color: var(--queued-fg); background: var(--queued-bg); }
.badge-running { color: var(--running-fg); background: var(--running-bg); }
.badge-succeeded, .tag-verified { color: var(--succeeded-fg); background: var(--succeeded-bg); }
.badge-partial, .tag-ambiguous { color: var(--partial-fg); background: var(--partial-bg); }
.badge-failed, .tag-not_in_source, .tag-not_published { color: var(--failed-fg); background: var(--failed-bg); }
.badge-abandoned, .tag-no_current_competition { color: var(--abandoned-fg); background: var(--abandoned-bg); }
.tag + .muted { margin-top: var(--space-1); font-size: var(--fs-sm); }

/* ---------- 9. Facts, inline lists, details ---------- */
dl.facts {
  display: grid;
  grid-template-columns: 16rem 1fr;
  gap: 0;
  margin: 0;
}
dl.facts dt,
dl.facts dd {
  padding: var(--space-3) 0;
  border-top: 1px solid var(--c-border);
}
dl.facts dt:first-of-type,
dl.facts dt:first-of-type + dd { border-top: 0; padding-top: 0; }
dl.facts dt { font-weight: 600; color: var(--c-muted); padding-right: var(--space); }
dl.facts dd { margin: 0; }
dl.facts dd.num { text-align: left; }

.inline-list { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space); list-style: none; padding: 0; margin: 0; }
.inline-list li { margin: 0; }

details {
  margin: var(--space) 0 0;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-panel-alt);
  padding: var(--space-2) var(--space-3);
}
details summary {
  cursor: pointer;
  font-weight: 600;
  min-height: 1.75rem;
  padding: var(--space-1) 0;
}
details[open] summary { margin-bottom: var(--space-2); }
details ul { overflow-wrap: anywhere; margin: 0; padding-left: 1.25rem; }
details ul li { margin-bottom: var(--space-1); }
details dl.facts { margin-top: var(--space-2); }
main > details { background: var(--c-panel); box-shadow: var(--shadow-sm); padding: var(--space-3) var(--space); }

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space);
  margin-top: var(--space-5);
  padding-top: var(--space);
  border-top: 1px solid var(--c-border);
}
.actions form { margin: 0; }
.actions p { flex-basis: 100%; margin: 0; }
.hint { color: var(--c-muted); font-size: var(--fs-sm); margin: var(--space-1) 0 0; }

/* ---------- 10. Tables ---------- */
table.data {
  border-collapse: collapse;
  width: 100%;
  min-width: 44rem;
  font-size: var(--fs-base);
}
table.data caption {
  text-align: left;
  font-weight: 700;
  color: var(--c-heading);
  padding: var(--space-3) var(--space);
  border-bottom: 1px solid var(--c-border);
}
table.data thead th {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--c-muted);
  font-weight: 700;
  background: var(--c-panel-alt);
  border-bottom: 1px solid var(--c-border-strong);
  white-space: nowrap;
}
table.data th,
table.data td {
  padding: var(--space-3) var(--space);
  border-bottom: 1px solid var(--c-border);
  text-align: left;
  vertical-align: top;
}
table.data tbody tr:last-child th,
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:nth-child(even) { background: var(--c-panel-alt); }
table.data tbody tr:hover { background: color-mix(in srgb, var(--c-brand) 7%, transparent); }
table.data tbody th[scope="row"] { font-weight: 600; color: var(--c-heading); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data code { background: none; border: 0; padding: 0; }

tr.is-ours th, tr.is-ours td {
  background: var(--c-ours-bg);
  font-weight: 700;
}
tr.is-ours th:first-child, tr.is-ours td:first-child { box-shadow: inset 3px 0 0 var(--c-ours-rule); }

/* ---------- 11. Forms ---------- */
.narrow-form, .form-stack { max-width: 34rem; }
.field { margin-bottom: var(--space); }
.field label { display: block; font-weight: 600; margin-bottom: var(--space-1); color: var(--c-heading); }
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field select {
  width: 100%;
  min-height: 2.75rem;
  padding: var(--space-2) var(--space-3);
  /* Native caret: leave room so a long team name never runs under it. */
  padding-right: 2.5rem;
  font: inherit;
  color: var(--c-text);
  background: var(--c-panel);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-sm);
}
.field input:focus-visible,
.field select:focus-visible { border-color: var(--c-focus); }
.field-checkbox { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.field-checkbox input[type="checkbox"] { width: 1.5rem; height: 1.5rem; margin: 0; accent-color: var(--c-brand); }
.field-checkbox label { display: inline; margin: 0; }
.field-checkbox .hint { flex-basis: 100%; }
.field-invalid { border-left: 4px solid var(--c-error); padding-left: var(--space-3); }
.field-error { color: var(--c-error); font-weight: 600; margin: 0 0 var(--space-1); }

.error-summary {
  border: 2px solid var(--c-error);
  background: var(--c-error-bg);
  padding: var(--space);
  margin-bottom: var(--space-5);
  border-radius: var(--radius);
}
.error-summary h2 { margin-top: 0; color: var(--c-error); font-size: var(--fs-md); }
.error-summary a { color: var(--c-error); }
.error-summary ul { margin: 0; padding-left: 1.25rem; }

input[type="submit"].btn { -webkit-appearance: none; appearance: none; }

/* ---------- 12. Page-specific hooks ---------- */
.embed-preview {
  width: 100%;
  height: 30rem;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  display: block;
}

nav.matchdays {
  margin: 0 0 var(--space-5);
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: var(--space-2) var(--space-3);
}
nav.matchdays .inline-list { gap: var(--space-1); }
nav.matchdays .inline-list li a,
nav.matchdays .inline-list li strong {
  display: inline-flex;
  align-items: center;
  min-height: 2.25rem;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}
nav.matchdays .inline-list li a:hover { background: var(--c-panel-alt); text-decoration: underline; }
nav.matchdays .inline-list li strong {
  background: var(--c-brand);
  color: var(--c-on-brand);
}

.endpoint-list { margin: 0; padding-left: var(--space); list-style: none; }
.endpoint-list li { margin-bottom: var(--space-1); }
.endpoint-list li:last-child { margin-bottom: 0; }

.row-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.row-actions form { margin: 0; }
.row-actions .btn { min-height: 2.25rem; padding: var(--space-1) var(--space-3); font-size: var(--fs-sm); }

/* ---------- 13. Responsive / motion / forced colours ---------- */
@media (max-width: 640px) {
  :root { --fs-xl: 1.375rem; --fs-lg: 1.125rem; }
  .admin-header-inner { gap: var(--space-2); }
  .panel { padding: var(--space); }
  dl.facts { grid-template-columns: 1fr; }
  dl.facts dt { padding-bottom: 0; border-top: 1px solid var(--c-border); }
  dl.facts dd { padding-top: var(--space-1); border-top: 0; }
  dl.facts dt:first-of-type + dd { padding-top: var(--space-1); }
  .actions > .btn,
  .actions > form,
  .actions > form > .btn,
  .narrow-form .btn,
  .form-stack .btn { width: 100%; justify-content: center; }
  .row-actions .btn { width: auto; }
}

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

@media (forced-colors: active) {
  .badge, .tag, .btn, .panel, .table-scroll, .empty, .flash, details, nav.matchdays {
    border: 1px solid CanvasText;
  }
  .admin-header nav a[aria-current="page"] { outline: 2px solid CanvasText; }
  tr.is-ours th, tr.is-ours td { outline: 1px solid CanvasText; }
  :focus-visible { outline: 3px solid CanvasText; }
}

/* Club shield in the header, in place of the wordmark. */
.brand { display: flex; align-items: center; margin: 0; }
.brand a { display: inline-flex; align-items: center; padding: 0.25rem; border-radius: 6px; }
.brand-shield { display: block; width: 40px; height: 40px; object-fit: contain; }
@media (min-width: 640px) { .brand-shield { width: 48px; height: 48px; } }

/* Page header with an action on the right (e.g. the embed preview button). */
.page-header-actions { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 0.75rem 1rem; }
.page-header-actions .header-actions { margin: 0; }

/* Inline selector form (team picker above the standings): fills the page width. */
.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-2) var(--space-3);
  width: 100%;
  margin-bottom: var(--space-4);
}
.inline-form .field { flex: 1 1 22rem; min-width: 0; margin: 0; }
/* The selected team's heading needs air under the picker. */
.inline-form + h2 { margin-top: var(--space-5); }
.inline-form .field select { max-width: none; }
.inline-form .btn { flex: 0 0 auto; }
@media (max-width: 639px) {
  .inline-form .field { flex-basis: 100%; }
  .inline-form .btn { width: 100%; }
}
.badge-link { text-decoration: none; }
.badge-link:hover .badge { text-decoration: underline; }

/* Embed snippet: read-only code the user copies into the club site. */
.snippet {
  width: 100%;
  min-height: 5rem;
  padding: var(--space-2) var(--space-3);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--fs-sm);
  color: var(--c-text);
  background: var(--c-panel-alt);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-sm);
  resize: vertical;
}

/* Embed snippet panel: give the picker, the code and the feedback line room to breathe. */
.inline-form + .panel { margin-top: var(--space-6); }
[data-controller="embed-snippet"] > .hint { margin: var(--space-2) 0 var(--space-4); }
[data-controller="embed-snippet"] .inline-form { margin-bottom: var(--space-6); }
[data-controller="embed-snippet"] .inline-form .field label { margin-bottom: var(--space-2); }
[data-controller="embed-snippet"] .snippet { margin-bottom: var(--space-3); }
[data-controller="embed-snippet"] .snippet + .hint { margin: 0; min-height: 1.25rem; }
[data-controller="embed-snippet"] + h2 { margin-top: var(--space-6); }
[data-controller="embed-snippet"] h3 { margin: var(--space-5) 0 var(--space-2); }
[data-controller="embed-snippet"] .embed-preview { margin-bottom: var(--space-3); }
.snippet-preview { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin: var(--space-5) 0 0; }
.snippet-preview .hint { margin: 0; }

/* Generated password, shown once so it can be copied before saving. */
.generated { margin: var(--space-2) 0 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--fs-base);
  color: var(--c-brand-ink); overflow-wrap: anywhere; }
fieldset.field { border: 1px solid var(--c-border); border-radius: var(--radius-sm); padding: var(--space-3) var(--space); }
fieldset.field legend { font-weight: 600; padding: 0 var(--space-2); }
/* Team standings source (D-52): the provider choice, then only that provider's parameters. */
.choice-list { display: grid; gap: var(--space-2); margin: var(--space-2) 0 var(--space); }
.choice-list input[type="radio"] { width: 1.25rem; height: 1.25rem; margin: 0; accent-color: var(--c-brand); }
.source-panel { border-top: 1px solid var(--c-border); padding-top: var(--space); }
.source-panel[hidden] { display: none; }
.field input[type="url"] {
  width: 100%;
  min-height: 2.75rem;
  padding: var(--space-2) var(--space-3);
  font: inherit;
  color: var(--c-text);
  background: var(--c-panel);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-sm);
}

/* "Copiado" confirmation: the button turns green for a moment, the line beside it fades in. */
.btn.is-copied {
  background: var(--succeeded-bg);
  border-color: var(--succeeded-fg);
  color: var(--succeeded-fg);
}
.hint.is-copied { color: var(--succeeded-fg); font-weight: 600; animation: copied-in 180ms ease-out; }
.hint.is-failed { color: var(--c-error); font-weight: 600; }
@keyframes copied-in {
  from { opacity: 0; transform: translateY(-2px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .hint.is-copied { animation: none; }
}
@media (forced-colors: active) {
  .btn.is-copied { border: 2px solid CanvasText; }
}

/* ---------- 14. Icons (Bootstrap Icons, inline) ---------- */
.bi { flex: none; width: 1em; height: 1em; fill: currentColor; }
/* Icon and label share one line and one baseline, and the label never wraps under the icon. */
.btn, .dropdown-item, .admin-header nav a, .back-link, .row-actions .btn, .endpoint-list li, a.badge-link {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  line-height: 1.2;
  white-space: nowrap;
}
.btn > span, .dropdown-item > span, .admin-header nav a > span, .back-link > span { white-space: normal; }
/* Outside flex containers (plain text links inside a paragraph) the icon needs the optical nudge instead. */
p .bi, td .bi, li .bi, caption .bi { vertical-align: -0.125em; }
.dropdown-item, .admin-header nav a { justify-content: flex-start; }
td .btn, td a { vertical-align: middle; }
.btn .bi { font-size: 1.05em; }

/* ---------- 15. Small screens ---------- */
@media (max-width: 900px) {
  main { padding-inline: var(--space-3); }
  .page-header-actions { flex-direction: column; align-items: stretch; }
  .page-header-actions .header-actions .btn { width: 100%; justify-content: center; }
}

@media (max-width: 640px) {
  .admin-header nav ul { width: 100%; }
  .admin-header nav ul li { flex: 1 1 8rem; }
  .admin-header nav a { justify-content: center; width: 100%; }
  .data { font-size: var(--fs-sm); }
  .data th, .data td { padding: var(--space-2); }
  .row-actions { flex-direction: column; align-items: stretch; }
  .row-actions .btn { width: 100%; justify-content: center; }
  .inline-form .btn { width: 100%; justify-content: center; }
  .snippet { font-size: 0.75rem; }
  .facts dd .badge { display: inline-flex; }
}

/* A table is the one thing allowed to be wider than the screen, and only inside its own scroller. */
.table-scroll { max-width: 100%; }
.table-scroll .data { min-width: 34rem; }
@media (max-width: 480px) {
  .table-scroll .data { min-width: 28rem; }
}
.field input[type="time"] { width: auto; min-width: 9rem; padding-right: var(--space-2); }

/* ---------- 16. Switches and paired fields ---------- */
/* Two controls on one line, stacking on a phone. */
.field-row { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.field-row > .field { flex: 1 1 12rem; margin-bottom: var(--space); }
.field-row select,
.field-row input[type="time"] { width: 100%; min-height: 2.75rem; }

/* A checkbox rendered as a switch: same input, same semantics (role="switch"), no JavaScript. */
.field-switch { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.field-switch label { margin: 0; }
.field-switch .hint { flex-basis: 100%; margin: 0; }
input.switch {
  appearance: none;
  flex: none;
  width: 3rem;
  height: 1.75rem;
  margin: 0;
  padding: 0;
  border: 1px solid var(--c-border-strong);
  border-radius: 999px;
  background: var(--c-panel-alt);
  cursor: pointer;
  transition: background-color 120ms ease-in-out, border-color 120ms ease-in-out;
}
input.switch::before {
  content: "";
  display: block;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0.1875rem;
  border-radius: 50%;
  background: var(--c-muted);
  transition: transform 120ms ease-in-out, background-color 120ms ease-in-out;
}
input.switch:checked { background: var(--c-brand); border-color: var(--c-brand); }
input.switch:checked::before { background: #ffffff; transform: translateX(1.25rem); }
input.switch:disabled { opacity: 0.6; cursor: not-allowed; }
@media (prefers-reduced-motion: reduce) {
  input.switch, input.switch::before { transition: none; }
}
@media (forced-colors: active) {
  input.switch { border: 2px solid CanvasText; }
  input.switch:checked::before { background: CanvasText; }
}

/* Per-row action menu: the navbar dropdown, sized for a table cell. */
.row-menu { position: relative; margin: 0; padding: 0; border: 0; background: none; }
.row-menu > summary { cursor: pointer; list-style: none; min-height: 2.25rem; padding: var(--space-1) var(--space-3); font-size: var(--fs-sm); }
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu[open] > summary { background: var(--c-panel-alt); }
.row-menu .dropdown-menu { min-width: 13rem; font-size: var(--fs-sm); }
.row-menu[open] > summary .dropdown-toggle::after { transform: rotate(180deg); }
@media (max-width: 640px) {
}

/* Competition line with its "see the group" button pushed to the right. */
.standings-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-3); }
.standings-meta p { margin: 0; }
.btn-sm { min-height: 2.25rem; padding: var(--space-1) var(--space-3); font-size: var(--fs-sm); }
.btn-sm .bi { font-size: 1em; }
.btn-icon { min-width: 2.25rem; padding-inline: var(--space-2); }

/* Section title with an action beside it (dashboard "Ejecuciones recientes"). */
.section-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); }
.section-header h2 { margin: 0; }
.section-header form { margin: 0; }
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--space-3); margin-top: var(--space); }
.pagination .is-disabled { opacity: 0.55; cursor: default; }

/* ---------- 17. Phone layout: sections as a bottom bar ---------- */
/* One markup, two shapes: in the bar on desktop, fixed to the bottom of the screen on a phone,
   icon-only, the way a native app puts its tabs within thumb reach. */
@media (max-width: 900px) {
  .admin-header-inner { align-items: center; padding-block: var(--space-2); }
  .admin-header .brand { order: 1; }
  .admin-header .navbar-nav { order: 2; margin-left: auto; }
  .admin-header .user-email { display: none; }
  .admin-header .nav-link { padding: 0 var(--space-2); }
  .admin-header .nav-link .bi { width: 1.5rem; height: 1.5rem; }

  .admin-header nav {
    order: 3;
    position: fixed;
    inset: auto 0 0 0;
    z-index: 50;
    /* Club yellow with the blue on top: 8.6:1, and the same pairing the shirt uses. */
    background: var(--c-accent);
    border-top: 1px solid var(--c-brand-dark);
    box-shadow: 0 -0.125rem 0.75rem rgba(75, 70, 92, 0.24);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .admin-header nav ul.sections { display: flex; gap: 0; margin: 0; padding: 0; }
  .admin-header nav ul.sections li { flex: 1 1 0; }
  .admin-header nav a {
    width: 100%;
    min-height: 3.25rem;
    justify-content: center;
    border-radius: 0;
    color: var(--c-brand);
  }
  .admin-header nav a .bi { width: 1.5rem; height: 1.5rem; }
  /* Icon only: the label stays for screen readers. */
  .admin-header nav a > span {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .admin-header nav a:hover { background: rgba(0, 69, 173, 0.12); color: var(--c-brand-dark); }
  .admin-header nav a[aria-current="page"] {
    color: var(--c-brand-dark);
    background: rgba(0, 69, 173, 0.16);
    border: 0;
    box-shadow: inset 0 3px 0 var(--c-brand);
  }

  /* Nothing hides behind the bar. */
  main { padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px)); }
}

@media (max-width: 640px) {
  .admin-header .brand-shield { width: 36px; height: 36px; }
  .dropdown-menu { max-width: calc(100vw - 2rem); }
}

@media (prefers-color-scheme: dark) and (max-width: 900px) {
  /* The club pairing does not change in the dark theme: yellow bar, blue icons. */
  .admin-header nav { box-shadow: 0 -0.125rem 0.75rem rgba(0, 0, 0, 0.6); border-top-color: var(--c-brand); }
}

@media (forced-colors: active) and (max-width: 900px) {
  .admin-header nav { border-top: 2px solid CanvasText; }
  .admin-header nav a[aria-current="page"] { outline: 2px solid CanvasText; outline-offset: -2px; }
}
