/* ===========================================================================
   Swellendam Show — design system
   ===========================================================================

   Organised as:
     1. Fonts
     2. Tokens (light)
     3. Tokens (dark)
     4. Base & typography
     5. Layout
     6. Navbar
     7. Buttons
     8. Forms
     9. Cards & surfaces
    10. Tables
    11. Status pills & placings
    12. Notices & alerts
    13. Invoice
    14. Landing page
    15. Feature-specific (signup, extras, admin, results, schedule)
    16. Utilities
    17. Motion & print

   Colour, spacing, radius and elevation are all token-driven. Change a token
   here rather than hard-coding a value in a component.
   ========================================================================== */

/* ---------- 1. FONTS ------------------------------------------------------
   Self-hosted. The previous @import from fonts.googleapis.com is blocked by
   the Content-Security-Policy, which silently dropped the site to system
   fonts. See tools/_vendor_fonts.js.                                       */
/* (loaded via <link> in _head.ejs so it does not block on an @import chain) */

/* ---------- 2. TOKENS (LIGHT) -------------------------------------------- */
/* Bootstrap draws hint text (.form-text), input placeholders and other
   secondary text from --bs-secondary-color, a fixed dark grey. On the dark
   theme that was nearly invisible. Pointing it at the theme's own subtle text
   colour makes it follow light and dark like everything else. */
:root {
  --bs-secondary-color: var(--text-subtle);
}

:root {
  color-scheme: light;

  /* Brand — deep walnut/umber on white, Swellendam's colours. Muted and
     earthy rather than orange, so it reads as polished leather. */
  --brown-950: #120b07;
  --brown-900: #1b110b;
  --brown-800: #291a11;
  --brown-700: #3b2719;
  --brown-600: #4c3221;
  --brown-500: #684a31;
  --brown-400: #8a6a4c;
  --brown-300: #ad8f70;
  --brown-200: #d2bba1;
  --brown-100: #e9ddcd;
  --brown-50:  #f6f0e8;

  /* Accent — antique gold. Awards, championships and placings, and the
     fine rules that trim the brand (navbar, footer, hero). */
  --brass-700: #7a5c2e;
  --brass-600: #9a7843;
  --brass-500: #b39260;
  --brass-400: #c9ab7c;
  --brass-300: #dcc49e;
  --brass-100: #f3eadb;

  /* Neutrals — warm, so white pages read as paper and sit with the brown */
  --n-950: #18130f;
  --n-900: #211a14;
  --n-800: #33291f;
  --n-700: #4a3e33;
  --n-600: #66594c;
  --n-500: #807262;
  --n-400: #a59886;
  --n-300: #cbc0b0;
  --n-200: #e6e0d2;
  --n-100: #f3f0e7;
  --n-50:  #faf8f2;

  /* Semantic status */
  --success-600: #1e7a3c; --success-100: #dbf0e2;
  --warning-600: #9a6a10; --warning-100: #fbeecd;
  --danger-600:  #a52a2a; --danger-100:  #fadede;
  --info-600:    #1f5f8b; --info-100:    #dceaf5;

  /* Surfaces */
  /* Eggshell page: off-white with its warmth on the yellow side, not the red
     (a redder cream reads pink). Cards, panels and fields a lighter eggshell
     on top of it, never pure white. */
  --bg:            #f6f3ea;
  --bg-elevated:   #fdfcf8;
  --surface:       #fcfbf6;
  --surface-sunken: #efebdf;
  --surface-hover: var(--brown-50);
  /* Tinted band behind alternating home page sections */
  --band:          #ede8db;

  /* Text */
  --text:          var(--n-900);
  --text-muted:    var(--n-600);
  --text-subtle:   var(--n-500);
  --text-inverse:  #ffffff;

  /* Lines */
  --border:        #e2dccd;
  --border-strong: var(--n-300);
  --divider:       #e2dccd;

  /* Actions */
  --primary:          var(--brown-600);
  --primary-hover:    var(--brown-700);
  --primary-active:   var(--brown-800);
  --primary-contrast: #ffffff;
  --primary-soft:     var(--brown-50);
  --accent:           var(--brass-600);
  --link:             var(--brown-700);
  --link-hover:       var(--brown-900);
  --focus-ring:       0 0 0 3px rgba(76, 50, 33, 0.32);

  /* Tables */
  --table-head-bg:  #f1ede3;
  --table-row-alt:  rgba(0, 0, 0, 0.016);
  --table-row-hover: var(--brown-50);

  /* Navbar — white, with a brown rule along the bottom */
  --nav-bg:          #faf8f1;
  --nav-rule:        var(--brass-500);
  --nav-line:        rgba(41, 26, 17, 0.12);
  --nav-brand:       var(--brown-800);
  --nav-brand-hover: var(--brown-950);
  --nav-link:        var(--brown-700);
  --nav-link-hover:  var(--brown-950);
  --nav-active-fg:   var(--brown-900);
  --nav-muted:       var(--n-600);
  --nav-strong:      var(--brown-900);
  --nav-active-bg:   var(--brown-50);
  --nav-control-border: rgba(41, 26, 17, 0.28);
  --nav-control-fg:     var(--brown-700);
  --nav-control-hover:  var(--brown-50);
  --nav-btn-hover-bg:   var(--brown-700);
  --nav-btn-hover-fg:   #ffffff;
  --nav-toggler-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%233b2719' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");

  /* Dropdown */
  --dropdown-bg:         #fcfbf6;
  --dropdown-text:       var(--brown-900);
  --dropdown-hover-fg:   var(--brown-950);
  --dropdown-hover-bg:   var(--brown-50);
  --dropdown-active-bg:  var(--brown-100);
  --dropdown-divider:    rgba(41, 26, 17, 0.12);
  --dropdown-border:     rgba(41, 26, 17, 0.12);
  --dropdown-nested-bg:  #f6f3ea;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(27, 17, 11, 0.05);
  --shadow-sm: 0 1px 2px rgba(27, 17, 11, 0.06), 0 1px 3px rgba(27, 17, 11, 0.07);
  --shadow-md: 0 2px 4px rgba(27, 17, 11, 0.05), 0 6px 16px rgba(27, 17, 11, 0.08);
  --shadow-lg: 0 8px 24px rgba(27, 17, 11, 0.10), 0 2px 6px rgba(27, 17, 11, 0.06);
  --shadow-focus: var(--focus-ring);

  /* Radius */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-pill: 999px;

  /* Spacing scale */
  --sp-1: 0.25rem; --sp-2: 0.5rem;  --sp-3: 0.75rem; --sp-4: 1rem;
  --sp-5: 1.5rem;  --sp-6: 2rem;    --sp-7: 3rem;    --sp-8: 4rem;

  /* Type */
  --font-display: "Quintessential", Georgia, "Times New Roman", serif;
  --font-body: "Roboto Flex", system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* Layout */
  --nav-height: 68px;
  --content-max: 1320px;
  --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- 3. TOKENS (DARK) ---------------------------------------------
   Applied via data-theme="dark" on <html>, which _head.ejs sets before paint
   so there is no flash. Deep leather-charcoal rather than pure black, which
   keeps the brand present and is easier on the eye in a dim ring office.   */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg:            #15100c;
  --bg-elevated:   #1c1611;
  --surface:       #1e1813;
  --surface-sunken: #120e0a;
  --surface-hover: #2a2018;
  --band:          #1a1410;

  --text:          #efe8df;
  --text-muted:    #b8aa99;
  --text-subtle:   #9a8c7c;
  --text-inverse:  #15100c;

  --border:        #352a21;
  --border-strong: #46382c;
  --divider:       #2d241c;

  --primary:          var(--brown-400);
  --primary-hover:    var(--brown-300);
  --primary-active:   var(--brown-200);
  --primary-contrast: #1f120a;
  --primary-soft:     rgba(173, 143, 112, 0.14);
  --accent:           var(--brass-400);
  --link:             var(--brown-300);
  --link-hover:       var(--brown-200);
  --focus-ring:       0 0 0 3px rgba(173, 143, 112, 0.40);

  --success-600: #5fce8a; --success-100: rgba(95, 206, 138, 0.14);
  --warning-600: #e0b455; --warning-100: rgba(224, 180, 85, 0.14);
  --danger-600:  #ef8080; --danger-100:  rgba(239, 128, 128, 0.14);
  --info-600:    #7cb8e0; --info-100:    rgba(124, 184, 224, 0.14);

  --table-head-bg:   #241c16;
  --table-row-alt:   rgba(255, 255, 255, 0.022);
  --table-row-hover: #2c2219;

  /* In the dark theme the navbar turns to dark leather with light text. */
  --nav-bg:          linear-gradient(100deg, #120b07, #1b110b);
  --nav-rule:        var(--brass-600);
  --nav-line:        rgba(255, 255, 255, 0.08);
  --nav-brand:       #f3e6d6;
  --nav-brand-hover: #ffffff;
  --nav-link:        #dcc8b0;
  --nav-link-hover:  #ffffff;
  --nav-active-fg:   #ffffff;
  --nav-muted:       #c0ac95;
  --nav-strong:      #ffffff;
  --nav-active-bg:   rgba(255, 255, 255, 0.10);
  --nav-control-border: rgba(255, 255, 255, 0.30);
  --nav-control-fg:     #f3e6d6;
  --nav-control-hover:  rgba(255, 255, 255, 0.12);
  --nav-btn-hover-bg:   #f3e6d6;
  --nav-btn-hover-fg:   var(--brown-900);
  --nav-toggler-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%23f3e6d6' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");

  --dropdown-bg:         #1a110b;
  --dropdown-text:       #efe4d6;
  --dropdown-hover-fg:   #ffffff;
  --dropdown-hover-bg:   rgba(255, 255, 255, 0.08);
  --dropdown-active-bg:  rgba(255, 255, 255, 0.14);
  --dropdown-divider:    rgba(255, 255, 255, 0.12);
  --dropdown-border:     rgba(255, 255, 255, 0.09);
  --dropdown-nested-bg:  rgba(255, 255, 255, 0.04);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.6);
}

/* ---------- 4. BASE & TYPOGRAPHY ----------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-height) + var(--sp-4));
}

body {
  min-height: 100%;
  margin: 0;
  padding-top: var(--nav-height);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  font-variation-settings: "opsz" 16;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition), color var(--transition);
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--sp-3);
  color: var(--text);
  font-weight: 650;
  line-height: 1.22;
  letter-spacing: -0.011em;
  font-variation-settings: "opsz" 32;
  text-wrap: balance;
}
h1, .h1 { font-size: clamp(1.9rem, 1.4rem + 2.2vw, 2.9rem); }
h2, .h2 { font-size: clamp(1.5rem, 1.2rem + 1.3vw, 2.1rem); }
h3, .h3 { font-size: clamp(1.25rem, 1.1rem + 0.7vw, 1.6rem); }
h4, .h4 { font-size: 1.2rem; }
h5, .h5 { font-size: 1.05rem; }
h6, .h6 { font-size: 0.95rem; letter-spacing: 0.01em; }

/* The display face is decorative — brand and section headings only, never
   body copy, where it hurts legibility. */
.display-face,
.navbar-brand,
legend,
.section-title {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.005em;
}

p { margin: 0 0 var(--sp-4); text-wrap: pretty; }
p:last-child { margin-bottom: 0; }

.lead {
  font-size: 1.09rem;
  line-height: 1.65;
  color: var(--text-muted);
  font-weight: 400;
}

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 0.16em; }
a:hover { color: var(--link-hover); }

hr { border: 0; border-top: 1px solid var(--divider); margin: var(--sp-5) 0; opacity: 1; }

code, kbd, pre, .mono { font-family: var(--font-mono); font-size: 0.9em; }

::selection { background: var(--brown-200); color: var(--brown-950); }
:root[data-theme="dark"] ::selection { background: var(--brown-700); color: #fff; }

/* One consistent, visible focus ring — keyboard only. */
:focus-visible {
  outline: 2px solid transparent;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-xs);
}
.btn:focus-visible,
.form-control:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ---------- 5. LAYOUT ---------------------------------------------------- */
main, .page-wrap {
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--sp-4);
}
.container { max-width: var(--content-max); margin: 0 auto; padding-inline: var(--sp-4); }
@media (min-width: 1600px) { .container, main:not(.home), .page-wrap { max-width: 1440px; } }

.page-section { margin-block: var(--sp-6); }

.section-title {
  font-size: 1.35rem;
  margin-bottom: var(--sp-2);
}
.section-subtitle { color: var(--text-muted); margin-bottom: var(--sp-5); }

/* A page header block: title left, actions right. */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--divider);
}
.page-head h1, .page-head h2 { margin: 0; }
.page-head .page-head-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

/* ---------- 6. NAVBAR ---------------------------------------------------- */
#mainNav.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  min-height: var(--nav-height);
  height: var(--nav-height);
  padding-block: 0;
  background: var(--nav-bg);
  border-bottom: 3px solid var(--nav-rule);
  box-shadow: var(--shadow-sm);
  z-index: 1040;
  --bs-navbar-toggler-icon-bg: var(--nav-toggler-icon);
}
#mainNav .container { display: flex; align-items: center; gap: var(--sp-3); height: 100%; }

#mainNav .navbar-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--nav-brand) !important;
  font-family: var(--font-display);
  font-size: 1.4rem;
  line-height: 1;
  padding-block: 0;
}
#mainNav .navbar-brand:hover { color: var(--nav-brand-hover) !important; }

.nav-logo-wrapper { background: transparent; box-shadow: none; padding: 0; display: flex; }
.nav-logo-img { height: 50px; width: auto; display: block; }
.nav-brand-text { line-height: 1; }

#mainNav .navbar-nav { align-items: center; gap: 0.15rem; }
#mainNav .nav-link {
  position: relative;
  white-space: nowrap;
  color: var(--nav-link) !important;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.045em;
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition), color var(--transition);
}
#mainNav .nav-link:hover,
#mainNav .nav-link:focus-visible {
  color: var(--nav-link-hover) !important;
  background: var(--nav-active-bg);
}
/* Between 1200 and 1400px every item, the language switch and an admin's
   extra menu share one row: tighten the spacing rather than wrap. */
@media (min-width: 1200px) and (max-width: 1399.98px) {
  #mainNav .nav-link { padding-inline: 0.45rem; letter-spacing: 0.02em; }
}
#mainNav .nav-link.active { color: var(--nav-active-fg) !important; background: var(--nav-active-bg); }

#mainNav .navbar-text.user-greeting { color: var(--nav-muted) !important; font-weight: 500; }
#mainNav .navbar-text.user-greeting strong { color: var(--nav-strong) !important; font-weight: 700; }

#mainNav .navbar-toggler {
  border: 1.5px solid var(--nav-control-border);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.55rem;
}
#mainNav .navbar-toggler:focus { box-shadow: var(--focus-ring); }
#mainNav .navbar-toggler-icon { width: 1.4em; height: 1.4em; }

/* Nav buttons (Logout) */
#mainNav .btn-outline-primary {
  border-color: var(--nav-control-border) !important;
  color: var(--nav-control-fg) !important;
  font-weight: 600;
  background: transparent !important;
}
#mainNav .btn-outline-primary:hover,
#mainNav .btn-outline-primary:focus-visible {
  background: var(--nav-btn-hover-bg) !important;
  color: var(--nav-btn-hover-fg) !important;
  border-color: var(--nav-btn-hover-bg) !important;
}

/* Language switch (EN | AF) */
.lang-switch {
  display: inline-flex;
  height: 36px;
  padding: 2px;
  border: 1.5px solid var(--nav-control-border);
  border-radius: var(--radius-sm);
}
.lang-option {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px;
  padding: 0 0.45rem;
  border-radius: calc(var(--radius-sm) - 3px);
  font-size: 0.74rem; font-weight: 700; letter-spacing: 0.06em;
  color: var(--nav-control-fg);
  text-decoration: none;
  transition: background-color var(--transition), color var(--transition);
}
.lang-option:hover { color: var(--nav-control-fg); background: var(--nav-control-hover); }
.lang-option.active,
.lang-option.active:hover { background: var(--nav-btn-hover-bg); color: var(--nav-btn-hover-fg); }
.lang-option:focus-visible { box-shadow: var(--focus-ring); outline: none; }

/* Theme toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  padding: 0;
  border: 1.5px solid var(--nav-control-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--nav-control-fg);
  cursor: pointer;
  transition: background-color var(--transition), border-color var(--transition);
}
.theme-toggle:hover { background: var(--nav-control-hover); }
.theme-toggle:focus-visible { box-shadow: var(--focus-ring); outline: none; }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* Dropdown */
#mainNav, #mainNav .navbar-collapse { overflow: visible; }
#mainNav .dropdown-menu {
  z-index: 3000 !important;
  margin-top: 0.4rem;
  min-width: 224px;
  padding: var(--sp-1);
  border-radius: var(--radius);
  background: var(--dropdown-bg);
  border: 1px solid var(--dropdown-border);
  box-shadow: var(--shadow-lg);
  color: var(--dropdown-text);
}
#mainNav .dropdown-menu .dropdown-item {
  color: var(--dropdown-text);
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius-xs);
  font-size: 0.92rem;
  transition: background-color var(--transition);
}
#mainNav .dropdown-menu .dropdown-item:hover,
#mainNav .dropdown-menu .dropdown-item:focus {
  background: var(--dropdown-hover-bg);
  color: var(--dropdown-hover-fg);
}
#mainNav .dropdown-menu .dropdown-item.active,
#mainNav .dropdown-menu .dropdown-item:active { background: var(--dropdown-active-bg); color: var(--dropdown-hover-fg); }
#mainNav .dropdown-menu .dropdown-divider { border-top: 1px solid var(--dropdown-divider); margin: var(--sp-1) 0; }

@media (max-width: 991.98px) {
  #mainNav .navbar-collapse {
    position: absolute;
    left: 0; right: 0; top: var(--nav-height);
    background: var(--dropdown-bg);
    padding: var(--sp-3) var(--sp-4) var(--sp-4);
    border-radius: 0 0 var(--radius) var(--radius);
    border-bottom: 1px solid var(--dropdown-border);
    box-shadow: var(--shadow-lg);
    max-height: calc(100vh - var(--nav-height));
    overflow-y: auto;
  }
  #mainNav .navbar-nav { align-items: stretch; gap: 0.1rem; }
  #mainNav .nav-link { padding: 0.6rem 0.75rem; font-size: 0.9rem; }
  #mainNav .dropdown-menu { position: static; box-shadow: none; border: 0; background: var(--dropdown-nested-bg); }
}

/* ---------- 7. BUTTONS --------------------------------------------------- */
.btn {
  --btn-bg: transparent;
  --btn-fg: var(--text);
  --btn-bd: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 1rem;
  border: 1px solid var(--btn-bd);
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--transition), border-color var(--transition),
    color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.btn:active { transform: translateY(1px); }
/* Bootstrap's own .btn:disabled sets background and border colours, and being
   the more specific rule it won - every disabled primary button in the app
   turned Bootstrap blue. Keep the button's own colours and just fade it. */
.btn:disabled, .btn.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  background-color: var(--btn-bg);
  border-color: var(--btn-bd);
  color: var(--btn-fg);
}

.btn-primary {
  --btn-bg: var(--primary);
  --btn-fg: var(--primary-contrast);
  --btn-bd: var(--primary);
  box-shadow: var(--shadow-xs);
}
.btn-primary:hover { --btn-bg: var(--primary-hover); --btn-bd: var(--primary-hover); color: var(--primary-contrast); }
.btn-primary:active { --btn-bg: var(--primary-active); }

.btn-outline-primary { --btn-fg: var(--primary); --btn-bd: var(--primary); }
.btn-outline-primary:hover { --btn-bg: var(--primary); --btn-fg: var(--primary-contrast); }

.btn-secondary {
  --btn-bg: var(--surface); --btn-fg: var(--text); --btn-bd: var(--border-strong);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { --btn-bg: var(--surface-hover); --btn-bd: var(--primary); --btn-fg: var(--primary); }

.btn-outline-secondary { --btn-fg: var(--text-muted); --btn-bd: var(--border-strong); }
.btn-outline-secondary:hover { --btn-bg: var(--surface-hover); --btn-fg: var(--text); --btn-bd: var(--border-strong); }

.btn-success { --btn-bg: var(--success-600); --btn-fg: #fff; --btn-bd: var(--success-600); }
.btn-danger  { --btn-bg: var(--danger-600);  --btn-fg: #fff; --btn-bd: var(--danger-600); }
.btn-warning { --btn-bg: var(--warning-600); --btn-fg: #fff; --btn-bd: var(--warning-600); }
.btn-outline-danger { --btn-fg: var(--danger-600); --btn-bd: var(--danger-600); }
.btn-outline-danger:hover { --btn-bg: var(--danger-600); --btn-fg: #fff; }

/* Quiet button for row actions */
.btn-ghost { --btn-fg: var(--text-muted); --btn-bd: transparent; padding: 0.35rem 0.6rem; }
.btn-ghost:hover { --btn-bg: var(--surface-hover); --btn-fg: var(--primary); }

.btn-sm { padding: 0.34rem 0.66rem; font-size: 0.85rem; border-radius: var(--radius-xs); }
.btn-lg { padding: 0.75rem 1.4rem; font-size: 1.03rem; border-radius: var(--radius); }
.btn-block, .w-100.btn { width: 100%; }

.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-start-start-radius: var(--radius-sm); border-end-start-radius: var(--radius-sm); }
.btn-group .btn:last-child  { border-start-end-radius: var(--radius-sm);  border-end-end-radius: var(--radius-sm); }

/* ---------- 8. FORMS ----------------------------------------------------- */
fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-4);
  margin-bottom: var(--sp-5);
  background: var(--surface);
}
legend {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--text);
  padding-inline: var(--sp-2);
  width: auto;
  margin-bottom: 0;
}

label, .form-label {
  display: block;
  margin: 0 0 0.35rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.005em;
}
.form-hint { display: block; margin-top: -0.2rem; margin-bottom: var(--sp-3); font-size: 0.82rem; color: var(--text-subtle); }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="tel"], input[type="search"],
select, textarea, .form-control, .form-select {
  display: block;
  width: 100%;
  padding: 0.55rem 0.75rem;
  margin-bottom: var(--sp-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.45;
  transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
}
input:hover, select:hover, textarea:hover,
.form-control:hover, .form-select:hover { border-color: var(--n-400); }

input:focus, select:focus, textarea:focus,
.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}
input:disabled, select:disabled, textarea:disabled,
.form-control:disabled { background: var(--surface-sunken); color: var(--text-subtle); cursor: not-allowed; }

::placeholder { color: var(--text-subtle); opacity: 1; }

select, .form-select {
  appearance: none;
  padding-right: 2.2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%235a6156'%3E%3Cpath d='M8 11.5 3.5 7h9z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  background-size: 15px;
}
:root[data-theme="dark"] select,
:root[data-theme="dark"] .form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23a8b1a2'%3E%3Cpath d='M8 11.5 3.5 7h9z'/%3E%3C/svg%3E");
}

input[type="checkbox"], input[type="radio"] {
  width: 1.05rem; height: 1.05rem;
  margin: 0 0.45rem 0 0;
  accent-color: var(--primary);
  vertical-align: -2px;
  cursor: pointer;
}
.form-check { display: flex; align-items: center; gap: 0.15rem; margin-bottom: 0.4rem; }
.form-check label, .form-check .form-check-label { margin: 0; font-weight: 500; cursor: pointer; }

input[type="file"] {
  padding: 0.45rem;
  background: var(--surface-sunken);
  border: 1px dashed var(--border-strong);
  cursor: pointer;
}
input[type="file"]:hover { border-color: var(--primary); background: var(--primary-soft); }

/* Validation */
.is-invalid, input.error, select.error {
  border-color: var(--danger-600) !important;
  background: var(--danger-100);
}
.field-error { display: block; margin: -0.4rem 0 var(--sp-3); font-size: 0.82rem; color: var(--danger-600); font-weight: 600; }

/* ---------- 9. CARDS & SURFACES ------------------------------------------ */
.card, .form-card, .live-summary, .invoice-card, .event-card, .result-class-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: var(--sp-5);
  color: var(--text);
}
.card { padding: 0; }
.card-body { padding: var(--sp-5); }
.card-header {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--divider);
  background: var(--surface-sunken);
  font-weight: 650;
  border-radius: var(--radius) var(--radius) 0 0;
}

.form-card { width: 100%; margin: 0 auto var(--sp-5); }
.form-card.auth { max-width: 460px; margin-inline: auto; padding: var(--sp-6); }
.form-card.auth fieldset { border: 0; padding: 0; margin: 0; background: transparent; }
.form-card.auth legend { font-size: 1.5rem; margin-bottom: var(--sp-4); padding: 0; }
.form-card.signup { max-width: 980px; }
.form-card.extras { max-width: 820px; }
.form-card.extras input[type="number"] { width: 110px; display: inline-block; }

/* Horse card — one per horse on the signup form */
.horse-card {
  position: relative;
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: var(--sp-4);
  padding-right: var(--sp-6);
  margin-bottom: var(--sp-4);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition), border-color var(--transition);
}
.horse-card:hover { box-shadow: var(--shadow-sm); }

.remove-btn {
  position: absolute;
  right: var(--sp-3); top: var(--sp-3);
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-subtle);
  font-size: 1.1rem; line-height: 1;
  cursor: pointer;
  transition: background-color var(--transition), color var(--transition);
}
.remove-btn:hover { background: var(--danger-100); color: var(--danger-600); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: var(--sp-7) var(--sp-4);
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-sunken);
}
.empty-state h3 { color: var(--text); font-size: 1.1rem; margin-bottom: var(--sp-2); }
.empty-state p { margin-bottom: var(--sp-4); }

/* ---------- 10. TABLES --------------------------------------------------- */
.table-wrap, #adminTableContainer {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table, .table {
  width: 100%;
  margin: 0;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--text);
  font-size: 0.92rem;
}

/* Bootstrap 5.3 paints every table CELL with --bs-table-bg (white) and draws
   its stripe and hover tints over the cell. That covered the row colours set
   above, so every table in the app showed white rows in dark mode. Hand the
   colouring back to the rows: Bootstrap's cell layer is made transparent, and
   striping and hover come only from the theme rules below. */
.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  --bs-table-striped-bg: transparent;
  --bs-table-striped-color: var(--text);
  --bs-table-hover-bg: transparent;
  --bs-table-hover-color: var(--text);
  --bs-table-active-bg: transparent;
  --bs-table-border-color: var(--divider);
}
/* Bootstrap's "light" rows (fee lines, some table heads) as a theme tint, so
   they stay a quiet emphasis in dark mode rather than a white bar. */
.table-light,
.table .table-light {
  --bs-table-bg: var(--surface-sunken);
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--divider);
}

thead th, .table thead th, .admin-table thead th {
  position: sticky; top: 0;
  z-index: 2;
  background: var(--table-head-bg);
  border-bottom: 1px solid var(--border-strong);
  padding: 0.7rem 0.85rem;
  text-align: left;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.055em;
  color: var(--text-muted);
  white-space: nowrap;
}

tbody td, .table tbody td, .admin-table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--divider);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:nth-child(even), .admin-table tbody tr:nth-child(even) { background: var(--table-row-alt); }
.table tbody tr:hover, .admin-table tbody tr:hover { background: var(--table-row-hover); }

/* Numeric columns align right and use tabular figures so they line up. */
td.amount, th.amount, .num, .text-right, .text-end {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Wide admin tables become stacked cards on narrow screens. Each cell shows
   its column name from data-label, so the data stays readable on a phone at
   the ringside instead of forcing a horizontal scroll. */
@media (max-width: 767.98px) {
  .table-stack thead { display: none; }
  .table-stack tbody tr {
    display: block;
    margin: 0 0 var(--sp-3);
    padding: var(--sp-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
  }
  .table-stack tbody td {
    display: flex;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: 0.4rem 0.5rem;
    border: 0;
    text-align: right;
  }
  .table-stack tbody td::before {
    content: attr(data-label);
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-subtle);
    text-align: left;
  }
  .table-stack tbody td:empty { display: none; }
}

/* ---------- 11. STATUS PILLS & PLACINGS ---------------------------------- */
.pill, .badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.16rem 0.55rem;
  border-radius: var(--radius-pill);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.025em;
  line-height: 1.5;
  white-space: nowrap;
}
.pill-draft     { background: var(--n-100); color: var(--text-muted); }
.pill-submitted { background: var(--info-100); color: var(--info-600); }
.pill-paid      { background: var(--success-100); color: var(--success-600); }
.pill-partial   { background: var(--warning-100); color: var(--warning-600); }
.pill-unpaid    { background: var(--danger-100); color: var(--danger-600); }
.pill-locked    { background: var(--n-200); color: var(--n-700); }
.pill-withdrawn { background: var(--n-200); color: var(--n-700); }
.pill-credit    { background: var(--success-100); color: var(--success-600); }

:root[data-theme="dark"] .pill-draft     { background: rgba(255,255,255,.07); color: var(--text-muted); }
:root[data-theme="dark"] .pill-locked    { background: rgba(255,255,255,.09); color: var(--text-muted); }
:root[data-theme="dark"] .pill-withdrawn { background: rgba(255,255,255,.09); color: var(--text-muted); }

/* A withdrawn horse stays on the table so the entrant can see what was pulled
   and what it credited. It is dimmed rather than removed, and the horse name is
   struck through so the state reads at a glance without relying on colour. */
tr.row-withdrawn > td,
.card.row-withdrawn > .card-header,
.card.row-withdrawn > .card-body { opacity: 0.62; }
tr.row-withdrawn .horse-name { text-decoration: line-through; }

/* A small dot before the label, so status is not colour-only (colour-blind
   users and greyscale printouts still read correctly via the text). */
.pill::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

/* Placings — first three get a medal treatment */
.placing {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px; height: 26px;
  padding-inline: 0.35rem;
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: var(--surface-sunken);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.placing-1 { background: linear-gradient(160deg, var(--brass-300), var(--brass-500)); color: #3a2a05; border-color: var(--brass-500); }
.placing-2 { background: linear-gradient(160deg, #e6e8ea, #b9c0c6); color: #2b3136; border-color: #b9c0c6; }
.placing-3 { background: linear-gradient(160deg, #e3b98e, #c08552); color: #3d2612; border-color: #c08552; }

.champion-flag {
  display: inline-flex; align-items: center; gap: 0.3rem;
  color: var(--accent); font-weight: 700; font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* ---------- 12. NOTICES & ALERTS ----------------------------------------- */
.notice, .alert {
  position: relative;
  padding: 0.75rem 1rem;
  padding-left: 2.4rem;
  margin-bottom: var(--sp-3);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  line-height: 1.5;
}
.notice::before, .alert::before {
  content: "";
  position: absolute;
  left: 0.9rem; top: 1.05rem;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.notice.error-n, .alert-danger  { background: var(--danger-100);  border-color: var(--danger-600);  color: var(--danger-600); }
.notice.info-n,  .alert-info    { background: var(--info-100);    border-color: var(--info-600);    color: var(--info-600); }
.alert-success                  { background: var(--success-100); border-color: var(--success-600); color: var(--success-600); }
.notice.warn-n, .alert-warning  { background: var(--warning-100); border-color: var(--warning-600); color: var(--warning-600); }
.alert-secondary                { background: var(--surface-sunken); border-color: var(--border-strong); color: var(--text-muted); }
.notice strong, .alert strong { color: inherit; }

/* ---------- 13. INVOICE -------------------------------------------------- */
.invoice-card { margin-top: var(--sp-4); }
.invoice-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: var(--sp-4); flex-wrap: wrap;
  padding-bottom: var(--sp-4); margin-bottom: var(--sp-4);
  border-bottom: 2px solid var(--primary);
}
.invoice-table { width: 100%; border-collapse: collapse; margin-top: var(--sp-3); font-size: 0.92rem; }
.invoice-table th, .invoice-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--divider);
  text-align: left;
}
.invoice-table thead th {
  background: var(--table-head-bg);
  font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted);
}
.invoice-table td.amount, .invoice-table th.amount { text-align: right; font-variant-numeric: tabular-nums; }
.invoice-total-row td {
  font-weight: 800; font-size: 1rem;
  background: var(--primary-soft);
  border-top: 2px solid var(--primary);
  border-bottom: 0;
}

.live-summary { position: sticky; top: calc(var(--nav-height) + var(--sp-4)); }
.live-summary-table { width: 100%; font-size: 0.9rem; }
.live-summary-stack { display: grid; gap: var(--sp-2); }

/* ---------- 14. LANDING PAGE ---------------------------------------------
   A split hero (text panel beside the show's photo), an at-a-glance strip
   that overlaps it, then
   alternating white and tinted bands, closing on a brown contact band.     */
/* The home page runs edge to edge; each section brings its own .container.
   Overrides the generic main width and gutter. */
main.home { max-width: none; margin: 0; padding: 0; overflow-x: clip; }
.home ~ .site-footer { margin-top: 0; }

.home-hero {
  /* Lines the text up with the page's content column on wide screens. */
  --hero-gutter: max(var(--sp-4), calc((100vw - var(--content-max)) / 2 + var(--sp-4)));
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  min-height: clamp(460px, 66vh, 620px);
  color: #fff;
  background: linear-gradient(140deg, var(--brown-950) 0%, var(--brown-900) 45%, var(--brown-700) 100%);
}
.home-hero-text {
  display: flex;
  align-items: center;
  padding: var(--sp-7) var(--sp-6) calc(var(--sp-8) + 2.5rem) var(--hero-gutter);
}
.home-hero-media {
  position: relative;
  margin: 0;
  min-height: 100%;
  background: var(--brown-900);
}
.home-hero-media img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  /* Keeps the horse and rider in frame as the column narrows. */
  object-position: 35% 50%;
}
/* Fades the photo's left edge into the panel so the two read as one band. */
.home-hero-media::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, var(--brown-700) 0%, rgba(59, 39, 25, 0) 12%);
  pointer-events: none;
}
.home-hero-inner { width: 100%; max-width: 36rem; }
@media (max-width: 991.98px) {
  .home-hero { grid-template-columns: 1fr; min-height: 0; }
  .home-hero-media { order: -1; aspect-ratio: 1408 / 896; }
  .home-hero-media::after { background: linear-gradient(0deg, var(--brown-950) 0%, rgba(18, 11, 7, 0) 18%); }
  .home-hero-text { padding: var(--sp-6) var(--sp-4) calc(var(--sp-7) + 2.5rem); }
  .home-hero-inner { max-width: 40rem; }
}
.home-eyebrow {
  display: inline-block;
  margin-bottom: var(--sp-4);
  padding: 0.3rem 0.8rem;
  border: 1px solid rgba(201, 171, 124, 0.55);
  border-radius: var(--radius-pill);
  font-size: 0.74rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--brass-300);
}
.home-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.3rem, 1.6rem + 2.6vw, 3.6rem);
  line-height: 1.05;
  color: #fff;
  margin-bottom: var(--sp-4);
}
.home-lead { font-size: 1.12rem; line-height: 1.6; color: rgba(255, 255, 255, 0.86); margin-bottom: var(--sp-5); }
.home-actions { margin-bottom: var(--sp-4); }
.home-hero-note { font-size: 0.9rem; color: rgba(255, 255, 255, 0.72); }
.home-hero-note a { color: #fff; }

/* Buttons for dark backgrounds (hero, contact band) */
.btn-light { --btn-bg: #fff; --btn-fg: var(--brown-800); --btn-bd: #fff; }
.btn-light:hover { --btn-bg: var(--brown-50); --btn-fg: var(--brown-950); --btn-bd: var(--brown-50); }
.btn-ghost-light { --btn-bg: transparent; --btn-fg: #fff; --btn-bd: rgba(255, 255, 255, 0.55); }
.btn-ghost-light:hover { --btn-bg: rgba(255, 255, 255, 0.12); --btn-fg: #fff; --btn-bd: #fff; }

.home-callout { margin-top: var(--sp-5); }

/* At a glance — pulled up over the bottom of the hero */
.home-glance {
  position: relative;
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: var(--sp-4);
  margin-top: calc(-1 * var(--sp-8));
  margin-bottom: var(--sp-7);
}
.home-callout + .home-glance { margin-top: var(--sp-5); }
.glance-card {
  display: flex; flex-direction: column;
  padding: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--brass-500);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.glance-label {
  margin-bottom: var(--sp-1);
  font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--primary);
}
.glance-value { margin-bottom: var(--sp-2); font-size: 1.25rem; font-weight: 700; line-height: 1.25; color: var(--text); }
.glance-meta { font-size: 0.9rem; color: var(--text-muted); margin-bottom: var(--sp-3); }
.glance-link { margin-top: auto; font-weight: 600; font-size: 0.92rem; text-decoration: none; }
.glance-link:hover { text-decoration: underline; }
@media (max-width: 991.98px) {
  .home-glance { grid-template-columns: 1fr 1fr; }
  .glance-date { grid-column: 1 / -1; }
}
@media (max-width: 575.98px) {
  .home-glance { grid-template-columns: 1fr; margin-top: calc(-1 * var(--sp-6)); }
}

/* Countdown (inside the show-day card) */
.countdown-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-2);
  margin-top: auto;
}
.countdown-item {
  text-align: center;
  padding: var(--sp-2) var(--sp-1);
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
}
.countdown-value { font-size: 1.5rem; font-weight: 800; line-height: 1.05; color: var(--primary); font-variant-numeric: tabular-nums; }
.countdown-label { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
#eventCountdown.event-passed .countdown-grid { opacity: 0.45; }
#eventCountdown.event-passed::after {
  content: attr(data-passed-label);
  display: block; margin-top: var(--sp-3);
  font-size: 0.82rem; color: var(--text-muted);
}

/* Section scaffolding */
.home-section-head { max-width: 36rem; margin: 0 auto var(--sp-6); text-align: center; }
.home-section-head .section-title { font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2.2rem); }
.home-section-head p { color: var(--text-muted); }
.home .section-title { color: var(--brown-800); }
:root[data-theme="dark"] .home .section-title { color: var(--brown-200); }

.home-band {
  padding-block: var(--sp-7);
  background: var(--band);
  border-block: 1px solid var(--divider);
}

/* How to enter — a numbered timeline joined by a rule */
.home-steps {
  list-style: none; margin: 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-5);
  counter-reset: none;
}
.home-steps li { position: relative; text-align: center; padding-inline: var(--sp-2); }
.home-steps li:not(:last-child)::after {
  content: ""; position: absolute;
  top: 24px; left: calc(50% + 32px); right: calc(-50% - var(--sp-5) + 32px);
  border-top: 2px dashed var(--brown-200);
}
:root[data-theme="dark"] .home-steps li:not(:last-child)::after { border-color: var(--border-strong); }
.home-step-no {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px;
  margin-bottom: var(--sp-3);
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: var(--primary-contrast);
  font-weight: 800; font-size: 1.15rem;
  box-shadow: 0 0 0 6px var(--band);
}
.home-steps h3 { font-size: 1.05rem; margin-bottom: var(--sp-2); }
.home-steps p { font-size: 0.92rem; color: var(--text-muted); margin: 0; }
@media (max-width: 767.98px) {
  .home-steps { grid-template-columns: 1fr 1fr; row-gap: var(--sp-6); }
  .home-steps li::after { display: none; }
}
@media (max-width: 459.98px) { .home-steps { grid-template-columns: 1fr; } }

/* About — text beside a three-photo mosaic */
.home-about {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: var(--sp-7);
  align-items: center;
  padding-block: var(--sp-8);
}
.home-gallery {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}
.home-gallery img {
  display: block; width: 100%; height: 100%;
  aspect-ratio: 4 / 3; object-fit: cover;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: var(--surface-sunken);
}
.home-gallery .home-gallery-main { grid-column: 1 / -1; aspect-ratio: 16 / 9; }
@media (max-width: 991.98px) {
  .home-about { grid-template-columns: 1fr; gap: var(--sp-5); padding-block: var(--sp-7); }
}

/* For competitors — whole-card links */
.home-competitors { padding-bottom: var(--sp-8); }
.home-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: var(--sp-4); }
.home-tile {
  display: flex; flex-direction: column; gap: var(--sp-2);
  padding: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.home-tile:hover { color: var(--text); transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--brown-300); }
.home-tile-icon { font-size: 1.8rem; line-height: 1; }
.home-tile-title { font-weight: 700; font-size: 1.05rem; }
.home-tile-text { font-size: 0.92rem; color: var(--text-muted); }
.home-tile-go { margin-top: auto; padding-top: var(--sp-2); font-weight: 600; font-size: 0.9rem; color: var(--link); }

/* Contact — closing brown band */
.home-contact {
  padding-block: var(--sp-7);
  background: linear-gradient(110deg, var(--brown-900), var(--brown-700));
  border-top: 2px solid var(--brass-500);
  color: rgba(255, 255, 255, 0.86);
}
:root[data-theme="dark"] .home-contact { background: linear-gradient(110deg, var(--brown-900), var(--brown-800)); }
.home-contact-inner {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: var(--sp-6);
  align-items: center;
}
.home .home-contact .section-title { color: #fff; font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2.2rem); }
.home-contact p { margin: 0; max-width: 38rem; }
.home-contact-links { display: flex; flex-direction: column; gap: var(--sp-3); align-items: stretch; }
.home-contact-links .btn { justify-content: center; overflow-wrap: anywhere; }
@media (max-width: 767.98px) { .home-contact-inner { grid-template-columns: 1fr; } }

/* ---------- 15. FEATURE-SPECIFIC ----------------------------------------- */

/* Camping: stand kinds, booking form, the entrant's bookings */
.camp-types {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}
.camp-type {
  padding: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}
.camp-type.is-out, .camp-type.is-off { border-top-color: var(--border-strong); }
.camp-type.is-out .camp-type-price, .camp-type.is-off .camp-type-price { color: var(--text-subtle); }
.camp-type-head { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.camp-type-icon { font-size: 1.3rem; line-height: 1; }
.camp-type-title { font-size: 1.05rem; margin: 0; }
.camp-type-price { font-size: 1.7rem; font-weight: 800; color: var(--primary); margin: 0; line-height: 1.2; }
.camp-type-meta { font-size: 0.88rem; color: var(--text-muted); margin: var(--sp-1) 0 var(--sp-3); }
.camp-type-left { margin: 0; font-size: 0.95rem; }
.camp-type.is-out .camp-type-left strong { color: var(--danger-600); }
@media (max-width: 575.98px) { .camp-types { grid-template-columns: 1fr; } }

.camp-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20rem;
  gap: var(--sp-5);
  align-items: start;
}
.camp-layout > .camp-rules:only-child { grid-column: 1 / -1; }
@media (max-width: 991.98px) { .camp-layout { grid-template-columns: 1fr; } }
.camp-rules { position: sticky; top: calc(var(--nav-height) + var(--sp-4)); }
.camp-rules-list { margin: 0; padding-left: 1.1rem; display: grid; gap: var(--sp-2); font-size: 0.92rem; color: var(--text-muted); }
.camp-rules-list strong { color: var(--text); }
.choice-chip.is-disabled { opacity: 0.55; cursor: not-allowed; }
.camp-quote { font-size: 0.95rem; color: var(--text-muted); }
.camp-quote strong { color: var(--text); }

.camp-bookings { display: grid; gap: var(--sp-4); }
.camp-booking {
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.camp-booking.is-cancelled { opacity: 0.7; }
.camp-booking-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.camp-booking-ref { font-size: 1.1rem; font-weight: 700; }
.camp-booking-facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: var(--sp-2) var(--sp-4);
  margin: 0;
}
.camp-booking-facts dt { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-subtle); }
.camp-booking-facts dd { margin: 0; font-size: 0.95rem; }
.camp-booking-actions { margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--divider); }
.camp-bank {
  display: grid; gap: 2px var(--sp-3);
  grid-template-columns: max-content minmax(0, 1fr);
  margin: 0 0 var(--sp-3);
  padding: var(--sp-3);
  background: var(--surface-sunken);
  border-left: 3px solid var(--brass-500);
  font-size: 0.9rem;
}
.camp-bank > div { display: contents; }
.camp-bank dt { color: var(--text-subtle); font-weight: 600; }
.camp-bank dd { margin: 0; font-weight: 600; }

/* Show & home page: the home page photos */
.site-photos { display: grid; gap: var(--sp-4); }
.site-photo {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  gap: var(--sp-4);
  padding: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.site-photo.is-custom { border-left: 3px solid var(--brass-500); }
.site-photo-preview {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-sunken);
}
.site-photo-preview.is-hero { aspect-ratio: 16 / 10; }
.site-photo-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.site-photo-title { font-size: 1rem; margin-bottom: var(--sp-1); }
.site-photo-upload .form-control { max-width: 28rem; }
@media (max-width: 767.98px) { .site-photo { grid-template-columns: 1fr; } }

/* Entrant accounts (admin) */
.account-list { display: grid; gap: var(--sp-3); }
.account-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 14rem;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.account-card.is-unconfirmed { border-left: 3px solid var(--warning-600); }
.account-name { font-weight: 700; font-size: 1.05rem; }
.account-username { margin: var(--sp-1) 0 var(--sp-3); font-size: 1.15rem; }
.account-label {
  margin-right: var(--sp-2);
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-subtle);
}
.account-facts { display: grid; gap: var(--sp-1); margin: 0; font-size: 0.9rem; }
.account-facts > div { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: var(--sp-2); }
.account-facts dt { color: var(--text-subtle); font-weight: 600; }
.account-facts dd { margin: 0; overflow-wrap: anywhere; }
.account-actions { display: grid; gap: var(--sp-2); align-content: start; }
.account-actions form { margin: 0; }
.account-actions .form-control { margin-bottom: var(--sp-1); }
.reset-link-panel { border-color: var(--brass-500); }
.reset-link-panel textarea { white-space: pre-wrap; }
@media (max-width: 767.98px) { .account-card { grid-template-columns: 1fr; } }

/* Camping admin */
.stat-of { font-size: 0.85rem; font-weight: 500; color: var(--text-muted); }
.filter-tabs { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.filter-tab {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 0.85rem; font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
}
.filter-tab:hover { color: var(--primary); border-color: var(--primary); }
.filter-tab.active { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.filter-count { font-variant-numeric: tabular-nums; opacity: 0.8; }
.camp-admin-table td { vertical-align: top; }
.camp-admin-actions { min-width: 11rem; }
.camp-confirm-fields { display: grid; gap: var(--sp-1); }


/* Stat tiles — the "at a glance" row on dashboards.
   auto-fit keeps them on one row on a laptop and reflows to two columns on a
   phone without a separate breakpoint per count. */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--sp-3);
}
.stat {
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}
.stat-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-subtle);
}
.stat-value {
  margin-top: 0.15rem;
  font-size: clamp(1.4rem, 1.1rem + 1vw, 1.8rem);
  font-weight: 750;
  line-height: 1.15;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.015em;
}
.stat-meta { margin-top: 0.1rem; font-size: 0.8rem; color: var(--text-muted); }

.stat-good { border-left-color: var(--success-600); }
.stat-good .stat-value { color: var(--success-600); }
.stat-warn { border-left-color: var(--warning-600); }
.stat-warn .stat-value { color: var(--warning-600); }
.stat-bad  { border-left-color: var(--danger-600); }
.stat-bad  .stat-value { color: var(--danger-600); }

/* Quick-action tiles */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--sp-3);
}
.quick-tile {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  text-decoration: none;
  color: var(--text);
  transition: transform var(--transition), box-shadow var(--transition),
    border-color var(--transition);
}
.quick-tile:hover,
.quick-tile:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
  color: var(--text);
}
.quick-tile-title { font-weight: 650; color: var(--primary); }
.quick-tile-desc { font-size: 0.84rem; color: var(--text-muted); }

/* Admin toolbar */
.admin-toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--sp-4);
  align-items: end;
  position: sticky;
  top: calc(var(--nav-height) + 8px);
  z-index: 1020;
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
/* Search, then Group by, then Per page (the Entries page). */
.admin-fields { display: grid; grid-template-columns: minmax(220px, 1fr) 210px 120px; gap: var(--sp-3); }
.admin-fields input, .admin-fields select { margin-bottom: 0; }
.admin-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); justify-content: flex-end; }
.admin-actions .btn-group, .admin-actions .btn { white-space: nowrap; }
@media (max-width: 992px) {
  .admin-toolbar { grid-template-columns: 1fr; position: static; }
  .admin-fields { grid-template-columns: 1fr; }
  .admin-actions { justify-content: stretch; }
  .admin-actions .btn, .admin-actions .btn-group .btn { flex: 1 1 auto; }
}

/* ---------- Form panels -------------------------------------------------
   The signup and extras forms were previously one large white card divided by
   <hr> rules, with nested plain-bordered boxes inside it. On a white page that
   reads as a stack of featureless rectangles. A panel gives each section its
   own heading and a quiet header band, so the page has structure without
   adding more borders. */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--sp-4);
  overflow: hidden;
}
.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--divider);
}
.panel-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.panel-hint { font-size: 0.82rem; color: var(--text-muted); }
.panel-body { padding: var(--sp-5); }

/* Responsive field grid. Fields size themselves rather than relying on w-50,
   which produced half-width inputs inside already-narrow columns. */
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-4);
}
.field-grid.narrow { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.field { min-width: 0; }
.field > label,
.field > .form-label { margin-bottom: 0.3rem; }
.field input,
.field select,
.field textarea { margin-bottom: 0; }
/* A single field that should not stretch the full width of a wide panel. */
.field-limit { max-width: 26rem; }

/* Quantity input with its unit price alongside, so the price is not buried in
   the label text. */
.qty-field .qty-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.qty-field input[type="number"] {
  width: 5.5rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
  margin-bottom: 0;
}
.qty-unit {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Automatically-charged fees. Deliberately not styled as an input: these are
   derived from the entry and cannot be edited, and showing them as a disabled
   text box invites people to try. */
.auto-fee {
  padding: var(--sp-3) var(--sp-4);
  background: var(--primary-soft);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
}
.auto-fee-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
}
.auto-fee-value {
  margin-top: 0.15rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}
.auto-fee-note { margin-top: 0.2rem; font-size: 0.78rem; color: var(--text-muted); line-height: 1.4; }

/* Gate-ticket day cards */
.day-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--sp-3);
}
.day-card {
  padding: var(--sp-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.day-card-title {
  font-weight: 700;
  font-size: 0.9rem;
  padding-bottom: var(--sp-2);
  margin-bottom: var(--sp-3);
  border-bottom: 1px solid var(--divider);
}
.day-card .qty-field + .qty-field { margin-top: var(--sp-3); }

/* Segmented choice chips, replacing loose inline radio labels. */
.choice-chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.choice-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color var(--transition), border-color var(--transition),
    color var(--transition);
  margin-bottom: 0;
}
.choice-chip:hover { border-color: var(--primary); color: var(--primary); }
.choice-chip input { margin: 0; }
/* :has lets the whole chip react to its own radio. Browsers without it simply
   show the radio, which is still perfectly usable. */
.choice-chip:has(input:checked) {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}
.choice-chip:has(input:focus-visible) { box-shadow: var(--focus-ring); }

/* Horse card: a numbered, clearly separated block per horse. */
.horse-card .horse-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding-bottom: var(--sp-3);
  margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--divider);
}
.horse-card .horse-card-title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}
.horse-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: var(--radius-pill);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 800;
}
.horse-card .form-section + .form-section { margin-top: var(--sp-4); }

/* Sticky action bar at the foot of a long form. */
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: var(--sp-4);
}
.form-actions .actions-right { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

/* Signup: class rows */
.class-id, .code-cell { font-family: var(--font-mono); font-size: 0.85rem; color: var(--text-muted); white-space: nowrap; }
.class-remove { color: var(--text-subtle); }
.class-remove:hover { color: var(--danger-600); }
.sp-reg-row { padding: var(--sp-3); background: var(--primary-soft); border-radius: var(--radius-sm); margin-bottom: var(--sp-3); }
.nameStatus { font-size: 0.82rem; font-weight: 600; }
.nameStatus.error { color: var(--danger-600); }

/* Ring numbers */
.rn-input { max-width: 110px; margin-bottom: 0; font-variant-numeric: tabular-nums; text-align: center; }
.rn-err { color: var(--danger-600); font-size: 0.8rem; font-weight: 600; }

/* Results / judging */
.result-class-card { margin-bottom: var(--sp-4); }

/* Results search. Matches are marked in a tint of the brand colour rather than
   the browser's default yellow, which is glaring on the dark theme. */
mark {
  padding: 0 0.1em;
  border-radius: 3px;
  background: var(--warning-100);
  color: inherit;
  box-shadow: inset 0 -2px 0 var(--warning-600);
}
.result-number {
  margin-left: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
}
/* A placing found by a horse or rider search, shown without the rest of its
   class, gets an edge so it reads as the answer rather than a fragment. */
tr.result-row-match > td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
.result-toggle { margin-top: var(--sp-2); padding-left: 0; }
.placing-input, .placingInput { max-width: 84px; margin-bottom: 0; text-align: center; font-variant-numeric: tabular-nums; }
.noteInput { margin-bottom: 0; }

/* Schedule drag handle */
.handle {
  cursor: grab;
  color: var(--text-subtle);
  user-select: none;
  padding-inline: var(--sp-2);
}
.handle:active { cursor: grabbing; }
tr.dragging { opacity: 0.5; background: var(--primary-soft) !important; }

/* Expandable detail rows */
.details-row > td { background: var(--surface-sunken); padding: var(--sp-4) var(--sp-5); }

/* Payments */
.payments-container { display: grid; gap: var(--sp-3); }

/* Upload proof */
.upload-proof-form { padding: var(--sp-4); background: var(--surface-sunken); border-radius: var(--radius-sm); margin-top: var(--sp-3); }

/* Site footer */
.site-footer {
  margin-top: var(--sp-8);
  padding-block: var(--sp-5);
  border-top: 2px solid var(--brass-500);
  background: var(--brown-950);
  color: var(--brown-200);
  font-size: 0.88rem;
}
.site-footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
.footer-brand { font-family: var(--font-display); color: #fff; font-size: 1rem; }
.site-footer .text-subtle { color: var(--brown-300) !important; }
.footer-links { display: flex; flex-wrap: wrap; gap: var(--sp-4); }
.footer-links a { color: var(--brown-200); text-decoration: none; }
.footer-links a:hover { color: #fff; text-decoration: underline; }

/* List groups (championships, judge class lists). Never themed, so they kept
   Bootstrap's white rows and blue badges - glaring in dark mode. */
.list-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.list-group-item {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  padding: var(--sp-3) var(--sp-4);
}
.list-group-item + .list-group-item { border-top: 1px solid var(--border); }
.list-group-item-action:hover,
.list-group-item-action:focus { background: var(--surface-hover); color: var(--text); }
.list-group-item .badge.bg-primary {
  background: var(--primary) !important;
  color: var(--primary-contrast);
}

/* Prize money (admin only) ------------------------------------------------ */
/* The budget bar stays in view while a class's prize money is being typed, so
   what is still available is always visible during the assigning itself. */
.prize-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.prize-bar-cell { padding: var(--sp-3) var(--sp-4); background: var(--surface); }
.prize-bar-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-subtle);
}
.prize-bar-value {
  margin-top: 0.1rem;
  font-size: 1.25rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.prize-bar-meta { font-size: 0.78rem; color: var(--text-muted); }
.prize-bar-result { background: var(--success-100); }
.prize-bar-result .prize-bar-value { color: var(--success-600); }
.prize-bar.is-over .prize-bar-result { background: var(--danger-100); }
.prize-bar.is-over .prize-bar-result .prize-bar-value,
.prize-bar.is-over .prize-bar-result .prize-bar-label { color: var(--danger-600); }

.prize-sticky {
  position: sticky;
  top: calc(var(--nav-height, 68px) + var(--sp-2));
  z-index: 5;
}

.prize-placings {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--sp-2) var(--sp-3);
}
.prize-placing { display: flex; align-items: center; gap: var(--sp-2); margin: 0; }
.prize-placing-label {
  min-width: 2.6rem;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-muted);
}
/* A rand amount field: the "R" sits inside the box rather than in a Bootstrap
   input-group addon, which this design system does not theme (it rendered as a
   bright white block in dark mode). */
.money-input { position: relative; flex: 1; }
.money-input .form-control {
  margin-bottom: 0;
  padding-left: 1.7rem;
  font-variant-numeric: tabular-nums;
}
.money-input .form-control-sm { padding-left: 1.5rem; }
.money-prefix {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-subtle);
  pointer-events: none;
}
.money-input .form-control-sm + .money-prefix,
.money-input .money-prefix.sm { left: 0.55rem; font-size: 0.8rem; }
.prize-placing .form-control.is-warn { border-color: var(--warning-600); background: var(--warning-100); }

.prize-field .form-hint { margin-top: 0.4rem; margin-bottom: 0; }
.prize-budget-row { display: flex; gap: var(--sp-2); align-items: stretch; }
.prize-budget-row .btn { white-space: nowrap; }

.prize-split {
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  font-size: 0.9rem;
  color: var(--text-muted);
}
.prize-split.is-good    { background: var(--success-100); color: var(--success-600); }
.prize-split.is-partial { background: var(--warning-100); color: var(--warning-600); }
.prize-split.is-bad     { background: var(--danger-100);  color: var(--danger-600); }

/* An unsaved allocation is marked so it is not mistaken for the saved one. */
#prizeClassEditor.is-dirty { box-shadow: inset 3px 0 0 var(--warning-600); }

/* Prize payouts (admin only) */
.payout-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.payout-card .table-wrap { border: 0; border-radius: 0; box-shadow: none; }
.payout-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface-sunken);
}
.payout-card-foot {
  padding: var(--sp-2) var(--sp-4);
  border-top: 1px solid var(--border);
}
tr.payout-empty > td { color: var(--text-subtle); }
tr.payout-tied > td { background: var(--danger-100); }

/* ---------- Admin console -------------------------------------------------
   Every admin page shares one frame: the grouped side menu on the left and
   the page on the right. The menu is views/partials/_admin-nav.ejs. Below the
   large breakpoint it folds into a single "Admin menu" button above the page. */
.admin-layout {
  max-width: var(--content-max);
  margin: var(--sp-6) auto;
  padding-inline: var(--sp-4);
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: var(--sp-6);
  align-items: start;
}
@media (min-width: 1600px) { .admin-layout { max-width: 1440px; } }
.admin-layout > .admin-main { max-width: none; margin: 0; padding: 0; min-width: 0; }

/* Admin pages are working screens: a smaller title than the public pages. */
.admin-main h1 { font-size: clamp(1.45rem, 1.2rem + 0.9vw, 1.9rem); }
.admin-main .page-head { align-items: flex-end; }

/* The menu section a page belongs to, above its title. */
.page-eyebrow {
  display: block;
  margin-bottom: 0.2rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
}
.page-eyebrow a { color: inherit; text-decoration: none; }
.page-eyebrow a:hover { text-decoration: underline; }

.admin-side {
  position: sticky;
  top: calc(var(--nav-height) + var(--sp-4));
  max-height: calc(100vh - var(--nav-height) - var(--sp-5));
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.admin-side-toggle { display: none; }
.admin-side-inner { display: grid; gap: var(--sp-4); padding-bottom: var(--sp-4); }

.admin-side-status {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-left: 0.6rem;
  padding: 0.28rem 0.75rem;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 650;
  text-decoration: none;
}
.admin-side-status.is-open   { background: var(--success-100); color: var(--success-600); }
.admin-side-status.is-locked { background: var(--n-200); color: var(--n-700); }
:root[data-theme="dark"] .admin-side-status.is-locked { background: rgba(255, 255, 255, 0.09); color: var(--text-muted); }
.admin-side-status:hover { filter: brightness(0.97); }
.admin-side-status-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* Each section is a block of its own: a divider above it, a heading in full
   strength with the section's icon in a tinted chip, and its pages hung from
   a guide line beneath that icon, so where one group ends and the next begins
   is obvious at a glance. */
.admin-side-group { display: grid; gap: 0.35rem; }
.admin-side-group + .admin-side-group { padding-top: var(--sp-4); border-top: 1px solid var(--divider); }
.admin-side-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: 0 0.5rem 0 0.4rem;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
}
.admin-side-heading-main { display: inline-flex; align-items: center; gap: 0.55rem; min-width: 0; }
.admin-icon { flex-shrink: 0; width: 16px; height: 16px; }
.admin-side-heading .admin-icon {
  width: 26px;
  height: 26px;
  padding: 5px;
  border-radius: 7px;
  background: var(--primary-soft);
  color: var(--primary);
}
.admin-side-hint {
  padding: 0.04rem 0.42rem;
  border-radius: var(--radius-pill);
  background: var(--warning-100);
  color: var(--warning-600);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: none;
  white-space: nowrap;
}
/* The guide line sits under the middle of the heading's icon chip. */
.admin-side-list {
  list-style: none;
  margin: 0 0 0 calc(0.4rem + 12px);
  padding: 0;
  display: grid;
  gap: 1px;
  border-left: 2px solid var(--border);
}
.admin-side-link {
  display: block;
  margin-left: -2px;
  padding: 0.38rem 0.75rem 0.38rem 0.95rem;
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 550;
  line-height: 1.35;
  text-decoration: none;
  transition: background-color var(--transition), color var(--transition), border-color var(--transition);
}
.admin-side-link:hover { background: var(--surface-hover); color: var(--text); border-left-color: var(--border-strong); }
.admin-side-link.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 650;
  border-left-color: var(--primary);
}

@media (max-width: 991.98px) {
  .admin-layout { grid-template-columns: minmax(0, 1fr); gap: var(--sp-4); margin-top: var(--sp-4); }
  .admin-side { position: static; max-height: none; overflow: visible; }
  .admin-side-toggle {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: 0.55rem 0.9rem;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    text-align: left;
    cursor: pointer;
  }
  .admin-side-toggle svg { flex-shrink: 0; color: var(--text-subtle); transition: transform var(--transition); }
  .admin-side-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
  .admin-side-inner {
    margin-top: var(--sp-2);
    padding: var(--sp-4) var(--sp-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
  }
}
@media (min-width: 576px) and (max-width: 991.98px) {
  .admin-side-inner { grid-template-columns: 1fr 1fr; column-gap: var(--sp-4); }
  .admin-side-status { grid-column: 1 / -1; }
}
.admin-side-toggle-label { display: grid; line-height: 1.25; min-width: 0; }
.admin-side-toggle-eyebrow {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-subtle);
}
.admin-side-toggle-current { font-weight: 650; }

/* The navbar's Admin dropdown: the same sections, two columns on a laptop. */
#mainNav .dropdown-menu .dropdown-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0.35rem 0.2rem;
  padding: 0.5rem 0.35rem 0.35rem;
  border-bottom: 1px solid var(--dropdown-divider);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #fff;
}
#mainNav .dropdown-header .admin-icon { width: 15px; height: 15px; color: var(--brass-300); }
.admin-menu-section { padding-bottom: var(--sp-2); }
@media (min-width: 768px) {
  #mainNav .dropdown-menu.admin-menu { columns: 2; column-gap: var(--sp-1); min-width: 470px; }
  .admin-menu-section { break-inside: avoid; }
}

/* ---- Dashboard: entries status ---- */
.status-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3) var(--sp-5);
  padding: var(--sp-4) var(--sp-5);
  margin-bottom: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--success-600);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.status-card.is-locked { border-left-color: var(--n-500); }
.status-card-title { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 0.2rem; font-size: 1.05rem; }
.status-card-text { margin: 0; max-width: 62ch; color: var(--text-muted); font-size: 0.92rem; }
.status-card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }

/* ---- Dashboard: one card per menu section ---- */
.area-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: var(--sp-4);
}
.area-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.area-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--divider);
  background: var(--surface-sunken);
}
.area-card-title { display: flex; align-items: center; gap: 0.55rem; margin: 0; font-size: 1rem; font-weight: 750; }
.area-card-title .admin-icon {
  width: 28px;
  height: 28px;
  padding: 5px;
  border-radius: 7px;
  background: var(--primary-soft);
  color: var(--primary);
}
.area-card-note { font-size: 0.78rem; color: var(--text-subtle); }
.area-facts { list-style: none; margin: 0; padding: var(--sp-3) var(--sp-4) 0; display: grid; gap: 0.3rem; font-size: 0.88rem; }
.area-facts li { display: flex; justify-content: space-between; gap: var(--sp-3); }
.area-facts .area-fact-label { color: var(--text-muted); }
.area-facts .area-fact-value { font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }
.area-fact-value.is-warn { color: var(--warning-600); }
.area-fact-value.is-good { color: var(--success-600); }
.area-fact-value.is-bad  { color: var(--danger-600); }
.area-links { list-style: none; margin: auto 0 0; padding: var(--sp-3) var(--sp-2) var(--sp-2); display: grid; }
.area-links a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-2);
  padding: 0.4rem var(--sp-2);
  border-radius: var(--radius-xs);
  color: var(--link);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
}
.area-links a:hover { background: var(--surface-hover); color: var(--link-hover); }
.area-links a::after { content: "\2192"; color: var(--text-subtle); font-weight: 400; }
.area-links .area-link-desc { display: block; font-weight: 400; font-size: 0.78rem; color: var(--text-muted); }

/* ---- Tabs inside a page (Entries / Drafts) ---- */
.page-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  margin: 0 0 var(--sp-4);
  padding: 0;
  list-style: none;
  border-bottom: 1px solid var(--divider);
}
.page-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: -1px;
  padding: 0.55rem 0.9rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
}
.page-tab:hover { color: var(--text); }
.page-tab[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.page-tab .count {
  min-width: 1.5rem;
  padding: 0 0.4rem;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.page-tab[aria-selected="true"] .count { background: var(--primary-soft); color: var(--primary); }

/* ---- Entries table: two lines per cell instead of sixteen columns ---- */
.admin-table td, .admin-table th { vertical-align: top; }
.cell-main { font-weight: 600; }
.cell-sub { display: block; margin-top: 0.1rem; font-size: 0.8rem; color: var(--text-muted); font-weight: 400; }
.cell-codes { max-width: 16rem; font-size: 0.86rem; }
.cell-actions { white-space: nowrap; text-align: right; }
.cell-actions .btn + .btn, .cell-actions .btn + .dropdown, .cell-actions .dropdown + .btn { margin-left: 0.25rem; }
.cell-links a { margin-right: 0.6rem; white-space: nowrap; font-size: 0.86rem; }
.selection-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2) var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-3);
  border: 1px solid var(--danger-600);
  border-radius: var(--radius-sm);
  background: var(--danger-100);
  color: var(--danger-600);
  font-weight: 600;
  font-size: 0.9rem;
}
.selection-bar[hidden] { display: none; }

/* ---- Program & ring books: one card per download ---- */
.download-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--sp-3);
}
.download-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}
.download-card.is-featured { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset, var(--shadow-xs); }
.download-card h3 { margin: 0; font-size: 0.98rem; }
.download-card p { margin: 0; font-size: 0.85rem; color: var(--text-muted); flex: 1; }
.download-card .btn { align-self: flex-start; }

/* Collapsible sections (<details class="fold">): a rarely used tool or a long
   breakdown stays out of the way until it is wanted. */
details.fold {
  margin-bottom: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
details.fold > summary {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  background: var(--surface-sunken);
  cursor: pointer;
  list-style: none;
  font-weight: 700;
  font-size: 0.95rem;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before {
  content: "\25B8";
  display: inline-block;
  margin-right: -0.25rem;
  color: var(--text-subtle);
  transition: transform var(--transition);
}
details.fold[open] > summary::before { transform: rotate(90deg); }
details.fold[open] > summary { border-bottom: 1px solid var(--divider); }
details.fold > summary .fold-hint { margin-left: auto; font-size: 0.82rem; font-weight: 400; color: var(--text-muted); }
details.fold > .fold-body { padding: var(--sp-4) var(--sp-5); }

/* A grouped figure list (finance breakdown): label left, amount right. */
.figure-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.25rem; font-size: 0.9rem; }
.figure-list li { display: flex; justify-content: space-between; gap: var(--sp-3); }
.figure-list li > span:first-child { color: var(--text-muted); }
.figure-list li > span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }
.figure-list li.is-total { margin-top: 0.2rem; padding-top: 0.3rem; border-top: 1px solid var(--divider); }
.figure-list li.is-total > span { color: var(--text); font-weight: 700; }
.figure-group-title {
  margin: 0 0 var(--sp-2);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-subtle);
}

/* ---------- Live program ------------------------------------------------
   The public program page (views/program.ejs), the "live" marks that point
   to it, and the admin's control for the class in the ring. */
.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: live-pulse 1.8s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: 0.4rem;
  padding: 0.15rem 0.6rem;
  border-radius: var(--radius-pill);
  background: var(--success-100);
  color: var(--success-600);
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  vertical-align: middle;
}
.nav-live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 0.4rem;
  border-radius: 50%;
  background: #6fe39a;
  vertical-align: middle;
  animation: live-pulse 1.8s ease-in-out infinite;
}
.pill-live { background: var(--success-600); color: #fff; }
/* It carries its own pulsing dot, so not the plain one every pill has. */
.pill-live::before { display: none; }
:root[data-theme="dark"] .pill-live { color: var(--text-inverse); }

/* Home page: the program is live. */
.live-callout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2) var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--success-600);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--success-100);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow-xs);
}
.live-callout:hover { color: var(--text); box-shadow: var(--shadow-sm); }
.live-callout .live-badge { margin-left: 0; background: var(--success-600); color: #fff; }
:root[data-theme="dark"] .live-callout .live-badge { color: var(--text-inverse); }
.live-callout-text { flex: 1 1 20rem; }
/* The published PDF (no live program yet): the same banner in the award colour. */
.live-callout.is-pdf { border-color: var(--accent); background: var(--brass-100); }
:root[data-theme="dark"] .live-callout.is-pdf { background: rgba(201, 171, 124, 0.12); }
.live-callout-go { font-weight: 700; color: var(--link); white-space: nowrap; }

/* Program page: the published PDF, then the live program under its own heading. */
.program-pdf {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3) var(--sp-5);
  margin-bottom: var(--sp-5);
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.program-pdf-text { flex: 1 1 22rem; min-width: 0; }
.program-pdf-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.program-live-title { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem; margin: var(--sp-2) 0 var(--sp-3); font-size: 1.3rem; }

/* My program: an entrant's horses with their numbers. */
.program-pdf.is-mine { border-left-color: var(--primary); }
.my-horses { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.my-horses li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem var(--sp-3); }
.my-horse-no {
  min-width: 4.5rem;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* Program page: what is in the ring. */
.ring-now {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2) var(--sp-5);
  margin-bottom: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--success-600);
  border-left-width: 5px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.ring-now[hidden] { display: none; }
.ring-now-main { display: grid; gap: 0.15rem; min-width: 0; }
.ring-now-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--success-600);
}
.ring-now-class { font-size: clamp(1.1rem, 1rem + 0.6vw, 1.35rem); font-weight: 750; color: var(--text); text-decoration: none; }
.ring-now-class:hover { color: var(--link); text-decoration: underline; }
.ring-now-next { color: var(--text-muted); font-size: 0.92rem; }
.ring-now-next[hidden] { display: none; }

.program-class { scroll-margin-top: calc(var(--nav-height) + var(--sp-3)); }
.program-class-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-3);
}
.program-class-title { min-width: 0; }
.program-class-number {
  display: block;
  margin-bottom: 0.1rem;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.program-class-flags { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.program-class-flags [hidden] { display: none; }
.program-class.is-now { border-color: var(--success-600); box-shadow: 0 0 0 2px var(--success-600), var(--shadow-sm); }
.program-class.is-next { border-left: 4px solid var(--warning-600); }
.ring-no { font-weight: 700; font-variant-numeric: tabular-nums; }
tr.program-row-mine > td { background: var(--brass-100); }
:root[data-theme="dark"] tr.program-row-mine > td { background: rgba(201, 171, 124, 0.12); }
/* On a phone each row is a card of its own: shade the whole card. */
@media (max-width: 767.98px) {
  .table-stack tbody tr.program-row-mine { background: var(--brass-100); border-color: var(--brass-300); }
  :root[data-theme="dark"] .table-stack tbody tr.program-row-mine { background: rgba(201, 171, 124, 0.12); border-color: rgba(201, 171, 124, 0.35); }
  .table-stack tbody tr.program-row-mine > td,
  :root[data-theme="dark"] .table-stack tbody tr.program-row-mine > td { background: transparent; }
}

/* "Your horses": one line per horse, straight to its class. */
.mine-list { list-style: none; margin: 0; padding: var(--sp-2); display: grid; gap: 2px; }
.mine-list a {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--sp-3);
  padding: 0.5rem var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
}
.mine-list a:hover { background: var(--surface-hover); }
.mine-class { font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
@media (max-width: 575.98px) {
  .mine-list a { grid-template-columns: 5rem minmax(0, 1fr); }
  .mine-what { grid-column: 2; }
}

/* Admin: publishing, and the class in the ring. */
.live-state { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); }
.ring-control { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sp-3); }
.ring-box {
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-sunken);
}
.ring-box.is-now { border-color: var(--success-600); background: var(--success-100); }
.ring-box-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-subtle);
}
.ring-box.is-now .ring-box-label { color: var(--success-600); }
.ring-box-class { margin-top: 0.15rem; font-size: 1.1rem; font-weight: 700; color: var(--text); }

/* ---------- 16. UTILITIES ------------------------------------------------ */
.small-muted, .muted-small { color: var(--text-muted) !important; font-size: 0.88rem; }
.text-muted { color: var(--text-muted) !important; }
.text-subtle { color: var(--text-subtle) !important; }
.stack { display: grid; gap: var(--sp-4); }
.stack-sm { display: grid; gap: var(--sp-2); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.divider { height: 1px; background: var(--divider); margin-block: var(--sp-4); }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }

/* Bootstrap surface overrides so dark mode is consistent */
.bg-light { background: var(--surface-sunken) !important; color: var(--text) !important; }
.bg-white { background: var(--surface) !important; }
.border    { border-color: var(--border) !important; }
.text-dark { color: var(--text) !important; }
.dropdown-menu:not(#mainNav .dropdown-menu) {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); color: var(--text);
}
.dropdown-menu:not(#mainNav .dropdown-menu) .dropdown-item { color: var(--text); }
.dropdown-menu:not(#mainNav .dropdown-menu) .dropdown-item:hover { background: var(--surface-hover); color: var(--text); }

.modal-content { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); }
.modal-header, .modal-footer { border-color: var(--divider); }

/* ---------- 17. MOTION & PRINT ------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .step:hover { transform: none; }
}

/* Invoices and start lists get printed constantly at a show. */
@media print {
  :root { --nav-height: 0px; }
  body { padding-top: 0; background: #fff; color: #000; font-size: 11pt; }
  #mainNav, .navbar, .admin-toolbar, .theme-toggle,
  .btn, .no-print, footer { display: none !important; }
  main, .container { max-width: none; padding: 0; }
  /* The admin menu is not printed, so the page takes the full width rather
     than the first (menu-width) grid column. */
  .admin-layout { display: block; margin: 0; padding: 0; max-width: none; }
  .page-eyebrow { display: none; }
  .card, .form-card, .invoice-card, .table-wrap, #adminTableContainer {
    border: 1px solid #999; box-shadow: none; break-inside: avoid;
  }
  thead th { background: #eee !important; color: #000 !important; }
  table { font-size: 10pt; }
  tr, .horse-card, .result-class-card, .payout-card { break-inside: avoid; }
  .payout-card-head { background: #f1f1f1 !important; }
  a[href]::after { content: ""; }
}
