/* ==========================================================================
   RideQuest admin — design system
   One stylesheet for club-admin and super-admin.

   Built mobile-first. The previous version had a single 760px breakpoint that
   turned an eleven-item sidebar into a wrapping row of links stacked above the
   content, which is what made the panel unusable on a phone. Here the sidebar
   IS a drawer below 1024px, off-canvas and reachable from a real header
   button, and the desktop rail is the enhancement rather than the default.

   Club branding: every accent resolves through --accent, which the layout
   overrides per club from the club's own primary colour. Nothing in this file
   hard-codes the brand blue except the fallback token itself.
   ========================================================================== */

:root {
  /* --- neutral ramp. Cool grey, so the club accent stays the only hue --- */
  --n-0:  #ffffff;
  --n-25: #fbfcfd;
  --n-50: #f6f8fa;
  --n-100:#eef1f5;
  --n-150:#e6eaf0;
  --n-200:#dce1e9;
  --n-300:#c3cbd7;
  --n-400:#98a2b3;
  --n-500:#6b7583;
  --n-600:#525a67;
  --n-700:#3c434e;
  --n-800:#252a33;
  --n-900:#14171d;

  --bg: var(--n-100);
  --surface: var(--n-0);
  --surface-2: var(--n-50);
  --surface-3: var(--n-100);
  --ink: var(--n-900);
  --ink-2: var(--n-700);
  --muted: var(--n-500);
  --faint: var(--n-400);
  --line: var(--n-200);
  --line-soft: var(--n-150);

  /* --- accent. Overridden per club by the layout. --- */
  --accent: #3a5bd9;
  --accent-ink: #ffffff;
  --accent-deep: #2c48b8;
  --accent-wash: rgba(58, 91, 217, .10);
  --accent-edge: rgba(58, 91, 217, .28);

  /* --- semantic --- */
  --good: #0f7a44; --good-wash: #e7f4ed; --good-edge: #b7dfc9;
  --warn: #8a5a06; --warn-wash: #fdf3e2; --warn-edge: #f0d6a4;
  --bad:  #bd2733; --bad-wash:  #fdedef; --bad-edge:  #f2c4c9;
  --info: #1c5f87; --info-wash: #e9f3f9; --info-edge: #bcdcee;

  /* --- shape --- */
  --r-xs: 6px;
  --r-sm: 9px;
  --r-md: 13px;
  --r-lg: 18px;
  --r-pill: 999px;

  /* --- elevation. Two layered shadows: a tight contact shadow plus a wide
         soft one. A single blur reads as a grey halo. --- */
  --sh-1: 0 1px 2px rgba(20,23,29,.05), 0 1px 3px rgba(20,23,29,.04);
  --sh-2: 0 1px 2px rgba(20,23,29,.05), 0 6px 18px -4px rgba(20,23,29,.10);
  --sh-3: 0 2px 4px rgba(20,23,29,.06), 0 18px 40px -10px rgba(20,23,29,.20);
  --sh-4: 0 4px 8px rgba(20,23,29,.08), 0 32px 64px -16px rgba(20,23,29,.28);

  --rail: 260px;
  --header-h: 60px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --ease: cubic-bezier(.4, 0, .2, 1);
}

/* --------------------------------------------------------------- reset --- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg { vertical-align: middle; }
img { max-width: 100%; }

/* ⛔ The `hidden` attribute must win over any author display rule.
   The browser's own `[hidden] { display: none }` lives in the UA stylesheet, so
   ANY author rule that sets display beats it — and `.logo-preview { display:
   inline-flex }` did. The result: a brand-new challenge showed a broken-image
   icon and a remove button for a logo that did not exist, and the admin had to
   dismiss two of them before uploading anything. Every `hidden` toggle in this
   app was quietly a no-op wherever the element also had a display rule. */
[hidden] { display: none !important; }

a { color: var(--accent-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

/* One focus ring for everything keyboard-reachable, and only for keyboards. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

h1, h2, h3, h4 { margin: 0; font-weight: 640; letter-spacing: -.011em; }
h1 { font-size: 1.5rem; letter-spacing: -.022em; }
h2 { font-size: 1.0625rem; }
h3 { font-size: .9375rem; }
p { margin: 0 0 .8rem; }
p:last-child { margin-bottom: 0; }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.hint { color: var(--muted); font-size: .8125rem; font-weight: 400; line-height: 1.45; }
.nowrap { white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }

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

/* ============================================================ app shell ===
   Mobile is the base case: one column, a fixed header, and the nav off-canvas.
   ========================================================================= */

.shell { min-height: 100vh; }

/* --- the mobile header. Gone on desktop, where the rail carries identity. */
.appbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: .75rem;
  height: var(--header-h);
  padding: 0 .75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.appbar-title {
  min-width: 0;
  font-weight: 640;
  font-size: .9375rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.appbar-title small { display: block; font-size: .75rem; font-weight: 400; color: var(--muted); }
.appbar .club-logo { height: 30px; width: auto; max-width: 92px; object-fit: contain; flex: none; }

/* The drawer trigger. 44px, because it is the one control a thumb must find. */
.nav-toggle {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
}
.nav-toggle:hover { background: var(--surface-2); }
.nav-toggle svg { width: 20px; height: 20px; }

/* --- the rail / drawer ------------------------------------------------- */
.rail {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  width: min(84vw, 300px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  transform: translateX(-100%);
  transition: transform .24s var(--ease);
  overscroll-behavior: contain;
}
.rail[data-open="true"] { transform: none; box-shadow: var(--sh-4); }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(20,23,29,.44);
  opacity: 0;
  pointer-events: none;
  transition: opacity .24s var(--ease);
}
.scrim[data-open="true"] { opacity: 1; pointer-events: auto; }

.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .9rem 1rem;
  border-bottom: 1px solid var(--line-soft);
}
/* The product logo. This was set as text — "Ride" in ink, "Quest" in
   var(--accent) — which meant a club's own colour repainted half of the
   PRODUCT's name, so RideQuest appeared in a different colour in every club's
   panel. It is real artwork now, and the club's identity is carried by its own
   logo and accent everywhere else. */
.brand {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  color: var(--ink);
}
.brand-logo {
  display: block;
  height: 32px;
  width: auto;
  /* The intrinsic width/height on the tag stops the header reflowing while it
     loads; this keeps it honest if a caller asks for another height. */
  max-width: 100%;
}
.brand span {
  font-size: .625rem;
  font-weight: 680;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .09em;
}
.rail-close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0;
  border: 0; border-radius: var(--r-sm);
  background: none; color: var(--muted); cursor: pointer;
}
.rail-close:hover { background: var(--surface-2); color: var(--ink); }
.rail-close svg { width: 18px; height: 18px; }

/* The club identity block. This is where a club sees itself in the product. */
.rail-club {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .8rem 1rem;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-2);
}
.rail-club .club-logo {
  flex: none;
  width: 38px; height: 38px;
  object-fit: contain;
  background: var(--n-0);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 2px;
}
.rail-club .club-mark {
  flex: none;
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 720;
  font-size: .9375rem;
}
.rail-club .who { min-width: 0; }
.rail-club .who b {
  display: block;
  font-size: .875rem;
  font-weight: 640;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rail-club .who span { font-size: .75rem; color: var(--muted); }

.nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: .6rem .6rem 1rem;
  -webkit-overflow-scrolling: touch;
}
.nav-group {
  padding: .85rem .8rem .3rem;
  font-size: .6875rem;
  font-weight: 680;
  text-transform: uppercase;
  letter-spacing: .075em;
  color: var(--faint);
}
.nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: .65rem;
  min-height: 42px;
  padding: .5rem .8rem;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-weight: 540;
  font-size: .9063rem;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.nav a.active { background: var(--accent-wash); color: var(--accent-deep); font-weight: 640; }
/* The active marker is a bar on the leading edge, not a full-width fill —
   it survives the club accent being pale. */
.nav a.active::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  width: 3px; height: 20px;
  margin-top: -10px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .78; }
.nav a.active svg { opacity: 1; }
.nav a .count {
  margin-left: auto;
  font-size: .75rem;
  font-weight: 640;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.rail-foot {
  padding: .75rem 1rem 1rem;
  border-top: 1px solid var(--line-soft);
}
.rail-foot .who {
  display: block;
  font-size: .8125rem;
  color: var(--muted);
  margin-bottom: .55rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* --- the content column ------------------------------------------------ */
.main { min-width: 0; }
/* The cap only exists to stop a table spanning an ultrawide desktop; on any
   ordinary screen the column is the full width of the shell.
   ⚠️ This has been raised twice. 1180px left a third of a 1920px screen empty;
   1560px still left an eighth, and it was reported again. Prose keeps its own
   measure (see .lede, .empty p) — it is the tables and photo grids that wanted
   the room, and they should have all of it. */
.content {
  width: 100%;
  max-width: 2200px;
  padding: 1.1rem;
}
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .9rem;
  flex-wrap: wrap;
  margin-bottom: 1.15rem;
}
.page-head .lede { color: var(--muted); font-size: .9063rem; margin: .25rem 0 0; max-width: 62ch; }
.page-head .actions { flex: none; }

/* --- desktop: the drawer becomes a permanent rail ---------------------- */
@media (min-width: 1024px) {
  .shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); }
  .appbar { display: none; }
  .rail {
    position: sticky;
    top: 0;
    height: 100vh;
    width: auto;
    transform: none;
    box-shadow: none;
  }
  .rail-close { display: none; }
  .scrim { display: none; }
  .content { padding: 1.9rem 2rem 3rem; }
}

/* On a phone, a drawer that is open must not let the page behind it scroll. */
body.nav-open { overflow: hidden; }
@media (min-width: 1024px) {
  body.nav-open { overflow: auto; }
}

/* ================================================================ cards === */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-1);
  padding: 1.15rem;
  margin-bottom: 1.1rem;
}
@media (min-width: 640px) { .card { padding: 1.35rem 1.45rem; } }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.card-head > :first-child { min-width: 0; }
.card-head .hint { margin-top: .15rem; }
.card > h2:first-child { margin-bottom: .9rem; }

/* A card whose content runs edge to edge — tables, media grids. */
.card-flush { padding: 0; overflow: hidden; }
.card-flush > .card-head,
.card-flush > h2:first-child { padding: 1.15rem 1.2rem 0; margin-bottom: .9rem; }
.card-flush > .card-foot { padding: .85rem 1.2rem; border-top: 1px solid var(--line-soft); background: var(--surface-2); }

.card-accent { border-top: 3px solid var(--accent); }

.grid { display: grid; gap: 1.1rem; }
@media (min-width: 900px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  /* 320px could not hold two photographs side by side with their captions,
     which is what the overview's side column is mostly for. */
  .grid-sidebar { grid-template-columns: minmax(0, 1fr) 420px; align-items: start; }
  .grid-sidebar-left { grid-template-columns: 300px minmax(0, 1fr); align-items: start; }
}
@media (min-width: 1400px) {
  .grid-sidebar { grid-template-columns: minmax(0, 1fr) 480px; }
}

/* =========================================================== stat tiles === */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .8rem;
  margin-bottom: 1.1rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-1);
  padding: .95rem 1.05rem;
}
.stat .label {
  display: block;
  font-size: .6875rem;
  font-weight: 680;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
}
.stat .value {
  display: block;
  margin-top: .3rem;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat .value small { font-size: .5em; font-weight: 600; color: var(--faint); letter-spacing: 0; }
.stat .sub { display: block; margin-top: .15rem; font-size: .8125rem; color: var(--muted); }
.stat.is-accent .value { color: var(--accent-deep); }
.stat.is-good .value { color: var(--good); }
.stat.is-bad .value { color: var(--bad); }

/* A tile whose value is a word or a date rather than a figure. Without this
   a plan name or an ISO date overflows its tile on a narrow phone, and it is
   why dashboard.php was carrying an inline font-size. */
.stat .value.sm, .value.sm { font-size: 1.25rem; letter-spacing: -.018em; }

/* A logo shown for review — settings, an email preview. Bounded, and
   object-fit contain so a wordmark is not cropped to one letter. */
.logo-shot {
  max-height: 80px;
  max-width: 220px;
  width: auto;
  object-fit: contain;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: .35rem .5rem;
}

/* Standalone figure typography, for numbers inside a card body. */
.value { font-size: 1.75rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.label { font-size: .6875rem; font-weight: 680; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }

/* =============================================================== meters === */
.meter { margin-bottom: .95rem; }
.meter:last-child { margin-bottom: 0; }
.meter-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .6rem;
  margin-bottom: .35rem;
}
.meter-top b { font-weight: 580; font-size: .9063rem; }
.meter-top .n { font-size: .8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.meter-track { height: 7px; border-radius: var(--r-pill); background: var(--n-150); overflow: hidden; }
.meter-fill { height: 100%; border-radius: var(--r-pill); background: var(--accent); transition: width .3s var(--ease); }
.meter-fill.is-warn { background: var(--warn); }
.meter-fill.is-bad { background: var(--bad); }

/* A meter inside a table cell needs a floor width and a number beside it.
   Auto table layout gives a column whose only content is a zero-intrinsic-width
   bar exactly zero width, so the bar disappears — and a bar with no figure
   next to it is decoration anyway. */
.meter-inline { display: flex; align-items: center; gap: .55rem; min-width: 112px; }
.meter-inline .meter-track { flex: 1; min-width: 56px; }
.meter-inline .pct {
  flex: none;
  min-width: 2.7em;
  text-align: right;
  font-size: .8125rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* =============================================================== tables ===
   A table is the right shape for scanning many rows on a wide screen and the
   wrong shape on a phone. Both are here: below 720px each row restacks into a
   labelled block, driven by data-label on the cells.
   ========================================================================= */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; font-size: .9063rem; }
thead th {
  position: relative;
  text-align: left;
  padding: .65rem 1rem;
  font-size: .6875rem;
  font-weight: 680;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td { padding: .75rem 1rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-25, var(--n-25)); }
/* Unscoped: this was `td .subtle`, a descendant selector, so seven views that
   put the class on the element itself got nothing at all. It is a secondary
   line under a primary one — inside a cell, and everywhere else. */
.subtle { display: block; color: var(--muted); font-size: .8125rem; font-weight: 400; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.tight { white-space: nowrap; }

@media (max-width: 719px) {
  table.stack thead { display: none; }
  table.stack tbody tr {
    display: block;
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--line);
  }
  table.stack tbody tr:last-child { border-bottom: 0; }
  table.stack tbody td {
    display: flex;
    align-items: baseline;
    gap: .75rem;
    padding: .2rem 0;
    border: 0;
  }
  table.stack tbody td::before {
    content: attr(data-label);
    flex: none;
    width: 8.5rem;
    font-size: .6875rem;
    font-weight: 680;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted);
  }
  /* Long values — an email, an address — do not fit beside a 136px label on a
     narrow phone, and the row ends up scrolling inside its own wrapper. Below
     420px the label goes ABOVE the value and the value gets the full width. */
  @media (max-width: 419px) {
    table.stack tbody td {
      display: block;
      padding: .3rem 0;
    }
    table.stack tbody td::before {
      display: block;
      width: auto;
      margin-bottom: .1rem;
    }
  }
  table.stack tbody td > * { min-width: 0; }
  /* The first cell is the row's identity: full width, no label, and heavier. */
  table.stack tbody td.row-title { display: block; font-weight: 640; font-size: .9375rem; padding-bottom: .45rem; }
  table.stack tbody td.row-title::before { content: none; }
  table.stack tbody td.row-actions { padding-top: .6rem; }
  table.stack tbody td.row-actions::before { content: none; }
}

/* ============================================================== buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 40px;
  padding: .5rem .95rem;
  font: inherit;
  font-size: .9063rem;
  font-weight: 620;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--sh-1);
  transition: background .13s var(--ease), border-color .13s var(--ease), box-shadow .13s var(--ease), transform .06s var(--ease);
}
.btn:hover { background: var(--accent-deep); border-color: var(--accent-deep); text-decoration: none; color: var(--accent-ink); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn svg { width: 17px; height: 17px; }

.btn.ghost { background: var(--surface); color: var(--accent-deep); border-color: var(--accent-edge); }
.btn.ghost:hover { background: var(--accent-wash); border-color: var(--accent); color: var(--accent-deep); }
.btn.neutral { background: var(--surface); color: var(--ink-2); border-color: var(--line); }
.btn.neutral:hover { background: var(--surface-2); border-color: var(--n-300); color: var(--ink); }
.btn.danger { background: var(--surface); color: var(--bad); border-color: var(--bad-edge); }
.btn.danger:hover { background: var(--bad-wash); border-color: var(--bad); color: var(--bad); }
.btn.danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger-solid:hover { background: #a01f29; border-color: #a01f29; }
.btn.sm { min-height: 32px; padding: .3rem .6rem; font-size: .8125rem; border-radius: var(--r-xs); }
.btn.lg { min-height: 46px; padding: .65rem 1.3rem; font-size: .9688rem; }
.btn.block { width: 100%; }
.btn.link { background: none; border-color: transparent; box-shadow: none; color: var(--accent-deep); padding-inline: .25rem; }
.btn.link:hover { background: var(--accent-wash); }
.btn:disabled, .btn.disabled {
  opacity: .48;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none;
}

/* An icon-only control. Needs an aria-label; the title alone is not enough. */
.btn.icon { width: 36px; min-height: 36px; padding: 0; }
.btn.icon.sm { width: 30px; min-height: 30px; }

.actions { display: flex; gap: .45rem; align-items: center; flex-wrap: wrap; }
.actions.end { justify-content: flex-end; }
form.inline { display: inline; }

/* ================================================================ pills === */
.pill {
  display: inline-flex;
  align-items: center;
  gap: .32rem;
  padding: .15rem .5rem;
  border-radius: var(--r-pill);
  font-size: .75rem;
  font-weight: 620;
  line-height: 1.5;
  white-space: nowrap;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-2);
}
.pill.good  { color: var(--good); background: var(--good-wash); border-color: var(--good-edge); }
.pill.warn  { color: var(--warn); background: var(--warn-wash); border-color: var(--warn-edge); }
.pill.bad   { color: var(--bad);  background: var(--bad-wash);  border-color: var(--bad-edge); }
.pill.info  { color: var(--info); background: var(--info-wash); border-color: var(--info-edge); }
.pill.brand { color: var(--accent-deep); background: var(--accent-wash); border-color: var(--accent-edge); }
.pill.plain { background: none; }
.pill.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill-row { display: flex; flex-wrap: wrap; gap: .35rem; }

/* ================================================================ forms === */
.field { margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }
label {
  display: block;
  font-weight: 600;
  font-size: .875rem;
  margin-bottom: .3rem;
  color: var(--ink-2);
}
label .req { color: var(--bad); font-weight: 700; }
input, textarea, select {
  font: inherit;
  font-size: .9375rem;
  width: 100%;
  min-height: 42px;
  padding: .5rem .65rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--n-300);
  border-radius: var(--r-sm);
  transition: border-color .13s var(--ease), box-shadow .13s var(--ease);
}
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; }
input[type="color"] { padding: .2rem; height: 42px; cursor: pointer; }
input[type="file"] { padding: .4rem; background: var(--surface-2); border-style: dashed; cursor: pointer; }
textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
select {
  appearance: none;
  padding-right: 2.1rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236b7583' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M4 6.5l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .6rem center;
  background-size: 16px;
}
input:hover, textarea:hover, select:hover { border-color: var(--n-400); }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}
input:disabled, textarea:disabled, select:disabled {
  background: var(--surface-3);
  color: var(--muted);
  cursor: not-allowed;
}
input.is-bad, textarea.is-bad, select.is-bad { border-color: var(--bad); }
.field .err { display: block; margin-top: .3rem; font-size: .8125rem; color: var(--bad); font-weight: 550; }
.field .hint { margin-top: .3rem; }

.row { display: grid; gap: 1rem; }
@media (min-width: 640px) {
  .row { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}

.check {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  margin-bottom: .9rem;
  font-weight: 500;
  font-size: .9063rem;
  cursor: pointer;
}
.check:last-child { margin-bottom: 0; }
.check input { margin-top: .28rem; flex: none; }
.check span small { display: block; color: var(--muted); font-size: .8125rem; font-weight: 400; }

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 1.1rem 1.15rem;
  margin: 0 0 1.1rem;
}
fieldset:disabled { opacity: .55; }
legend { font-weight: 640; font-size: .9063rem; padding: 0 .4rem; }

.form-foot {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 1.3rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line-soft);
}

/* A row of controls that filters a list. Scrolls sideways on a phone rather
   than stacking six selects into a wall. */
.filters {
  display: grid;
  gap: .7rem;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  align-items: end;
}
.filters label { font-size: .75rem; }

/* ================================================================ flash === */
.flash-stack { margin-bottom: 1.1rem; display: grid; gap: .6rem; }
.flash {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  padding: .7rem .9rem;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  border-left-width: 3px;
  font-size: .9063rem;
}
.flash svg { flex: none; width: 18px; height: 18px; margin-top: .1rem; }
.flash.success { background: var(--good-wash); border-color: var(--good-edge); border-left-color: var(--good); color: #0b5c33; }
.flash.error   { background: var(--bad-wash);  border-color: var(--bad-edge);  border-left-color: var(--bad);  color: #8f1d26; }
.flash.warn    { background: var(--warn-wash); border-color: var(--warn-edge); border-left-color: var(--warn); color: #6d4705; }
.flash.notice  { background: var(--info-wash); border-color: var(--info-edge); border-left-color: var(--info); color: #164b6b; }

/* ========================================================= empty states === */
.empty { text-align: center; padding: 2.75rem 1.25rem; }
.empty-mark {
  display: grid; place-items: center;
  width: 46px; height: 46px;
  margin: 0 auto .9rem;
  border-radius: var(--r-md);
  background: var(--accent-wash);
  color: var(--accent);
}
.empty-mark svg { width: 22px; height: 22px; }
.empty h3 { font-size: 1rem; margin-bottom: .3rem; }
.empty p { color: var(--muted); max-width: 44ch; margin: 0 auto 1.15rem; }

/* =============================================================== dialogs === */
dialog.rq-dialog {
  border: 0;
  border-radius: var(--r-lg);
  padding: 0;
  width: min(94vw, 520px);
  max-height: 88vh;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--sh-4);
}
dialog.rq-dialog::backdrop { background: rgba(20,23,29,.5); backdrop-filter: blur(2px); }
dialog.rq-dialog > form, dialog.rq-dialog > .dlg-body { margin: 0; padding: 1.35rem 1.4rem 1.4rem; }
.dlg-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .9rem;
}
.dlg-head .hint { margin-top: .2rem; }
.dlg-x {
  flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: var(--r-sm);
  background: none; color: var(--muted); cursor: pointer;
}
.dlg-x:hover { background: var(--surface-2); color: var(--ink); }
.dlg-x svg { width: 17px; height: 17px; }
.dlg-foot { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 1.3rem; }
.dlg-foot .btn { flex: 1 1 auto; }
@media (min-width: 480px) { .dlg-foot .btn { flex: 0 0 auto; } }

/* ============================================================== code/kbd === */
code {
  font-family: var(--mono);
  overflow-wrap: anywhere;
  font-size: .8125em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: .1rem .35rem;
  border-radius: var(--r-xs);
}
.code-block {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-family: var(--mono);
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: .06em;
  padding: .7rem .85rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow-wrap: anywhere;
}

/* =========================================================== media grids === */
.media-grid {
  display: grid;
  gap: .7rem;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.media-grid figure { margin: 0; }
.media-grid img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  border: 1px solid var(--line);
}
.media-grid figcaption { margin-top: .3rem; font-size: .75rem; color: var(--muted); }

.thumb {
  width: 44px; height: 44px;
  object-fit: cover;
  border-radius: var(--r-xs);
  border: 1px solid var(--line);
  background: var(--surface-3);
}

/* ================================================= submissions dialog === */
/* Wider than a confirm dialog because its subject is photographs, and it
   scrolls internally so the page behind never moves. */
dialog.rq-dialog.dialog-wide { width: min(96vw, 1000px); }
dialog.rq-dialog.dialog-wide > .dlg-body {
  display: flex;
  flex-direction: column;
  max-height: 86vh;
}
dialog.rq-dialog.dialog-wide [data-subs-body] {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -.35rem;
  padding: 0 .35rem;
  /* TWO tasks per row on anything but a phone. Each task holds its rider and
     motorcycle photo, so the dialog reads four photos across — which is what
     makes a twelve-task run reviewable by scrolling rather than by scrolling
     forever. */
  display: grid;
  gap: 0 1.2rem;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  dialog.rq-dialog.dialog-wide [data-subs-body] { grid-template-columns: 1fr 1fr; }
}
.subs-task {
  min-width: 0;
  padding: .7rem 0;
  border-top: 1px solid var(--line-soft);
}
/* With two columns the first ROW is two panels, so both need the border gone
   rather than only the first child. */
.subs-task:nth-child(-n+2) { border-top: 0; padding-top: 0; }
@media (max-width: 639px) {
  .subs-task:nth-child(2) { border-top: 1px solid var(--line-soft); padding-top: .7rem; }
}
.subs-task-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .4rem;
  flex-wrap: wrap;
  margin-bottom: .5rem;
}
.subs-task-title { font-weight: 600; font-size: .875rem; min-width: 0; }
.subs-task .pill { font-size: .6875rem; padding: .1rem .4rem; }
/* Two photos per check-in — a rider and a motorcycle — side by side. */
.subs-task .media-grid { grid-template-columns: 1fr 1fr; gap: .45rem; }
.subs-task .media-grid img { aspect-ratio: 3 / 4; border-radius: var(--r-xs); }
.subs-task figcaption { font-size: .6875rem; line-height: 1.45; }

/* ======================================================== mail preview === */
/* Sandboxed: the email is its own document with its own inline styles, so it
   must not inherit the panel's CSS — otherwise the preview shows something no
   rider will ever receive. */
.mail-frame {
  display: block;
  width: 100%;
  height: 620px;
  border: 0;
  background: var(--n-100);
}
.plain-mail {
  margin: 0;
  font-family: var(--mono);
  font-size: .8125rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--ink-2);
}

/* ============================================================ pagination === */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  flex-wrap: wrap;
}
.pager a, .pager span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; min-height: 36px;
  padding: 0 .5rem;
  border-radius: var(--r-sm);
  font-size: .875rem;
  font-weight: 580;
  color: var(--ink-2);
}
.pager a:hover { background: var(--surface-2); text-decoration: none; }
.pager .on { background: var(--accent); color: var(--accent-ink); }
.pager .gap { color: var(--faint); min-width: 20px; }

/* ================================================================= auth === */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem 1.1rem;
  background:
    radial-gradient(1100px 520px at 15% -8%, var(--accent-wash), transparent 62%),
    linear-gradient(168deg, var(--n-100), var(--n-150));
}
.auth-card {
  width: min(94vw, 408px);
  padding: 1.9rem 1.7rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
}
.auth-card .brand { font-size: 1.3rem; margin-bottom: .5rem; }
.auth-card h1 { font-size: 1.25rem; margin-bottom: .3rem; }
.auth-card .sub { color: var(--muted); font-size: .9063rem; margin-bottom: 1.4rem; }
.auth-card .btn { width: 100%; margin-top: 1.2rem; }
.auth-card .links { margin-top: 1.05rem; text-align: center; font-size: .875rem; }
/* The card's brand row is an image now, not text — the font-size above did
   nothing for it, and the logo needs the row to size to its own height. */
.auth-card .brand { display: flex; justify-content: center; }
.auth-card .brand-logo { height: 34px; }

/* The three steps on the public front page. Numbered because the order is the
   point: join, ride, prove. */
.how {
  margin: 1.1rem 0 0;
  padding-left: 1.35rem;
  color: var(--ink-2);
  font-size: .9063rem;
  line-height: 1.55;
}
.how li + li { margin-top: .5rem; }
.auth-foot { margin-top: .9rem; text-align: center; font-size: .875rem; }
.lang-picker {
  margin-top: 1.2rem;
  padding-top: .9rem;
  border-top: 1px solid var(--line-soft);
  text-align: center;
  font-size: .8125rem;
  color: var(--muted);
}
.lang-picker a { margin: 0 .2rem; }
.lang-picker strong { color: var(--ink); font-weight: 620; }

/* ============================================================== utility === */
.vstack { display: grid; gap: .55rem; }
.vstack-lg { display: grid; gap: 1.1rem; }
.between { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.divider { height: 1px; background: var(--line-soft); margin: 1.15rem 0; border: 0; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.text-bad { color: var(--bad); }
.text-good { color: var(--good); }

/* A club logo outside the shell — the QR landing page, an email preview.
   `contain`, because `cover` crops a wordmark to a slab of one letter. */
.club-logo {
  max-height: 64px;
  max-width: 180px;
  width: auto;
  object-fit: contain;
}

/* A card whose subject is destructive. The heading colour is what says so
   before the button does. */
.card-danger { border-color: var(--bad-edge); }
.card-danger > h2:first-child, .card-danger .card-head h2 { color: var(--bad); }

/* A definition list used for read-only detail panels. */
.facts { display: grid; gap: .8rem; margin: 0; }
@media (min-width: 560px) { .facts.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 860px) { .facts.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.facts > div { min-width: 0; }
.facts dt { font-size: .6875rem; font-weight: 680; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
/* `anywhere`, not `normal`: an email address with no hyphen in it has no break
   opportunity, so it overflows its column and paints over the value beside it. */
.facts dd { margin: .2rem 0 0; font-weight: 560; font-size: .9375rem; overflow-wrap: anywhere; }

/* Collapsible section built on <details>. */
details.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-1);
  margin-bottom: .8rem;
  overflow: hidden;
}
details.panel > summary {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .95rem 1.15rem;
  cursor: pointer;
  font-weight: 620;
  list-style: none;
}
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::after {
  content: "";
  margin-left: auto;
  width: 9px; height: 9px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform .18s var(--ease);
}
details.panel[open] > summary::after { transform: rotate(-135deg); }
details.panel > summary:hover { background: var(--surface-2); }
/* Unscoped: this was `details.panel > .panel-body`, so the same class inside a
   plain card-flush got no padding at all and its contents ran edge to edge. */
.panel-body { padding: 0 1.15rem 1.2rem; }
details.panel > summary .pill { margin-left: .1rem; }

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

/* =============================================================== print ==== */
@media print {
  .appbar, .rail, .scrim, .no-print { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
  .card, .stat, details.panel { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  a { color: #000; text-decoration: none; }
  .code-block { background: none; border: 1px solid #000; }
}

/* The certificate cell on the challenge list: the two download buttons, or a
   one-line reason there is nothing to download yet. */
.cert-cell .actions { gap: .35rem; flex-wrap: wrap; }
.cert-cell .sm-note { font-size: .8125rem; display: inline-block; max-width: 22ch; }
