/* =========================================================================
   Sports Portal - design system
   Visual direction: an indoor court. Painted line-green, chalk-pale floor,
   scoreboard amber for the one action that matters on each screen. Times and
   money are set in a monospace face so a fixture list scans like a timetable.
   ========================================================================= */

:root {
  /* Surfaces */
  --paper: #f2f5f1;
  --card: #ffffff;
  --shell: #12241e;
  --shell-soft: #1c3329;
  --line: #dde5dd;
  --line-strong: #c6d2c6;

  /* Text */
  --ink: #0e1f19;
  --ink-soft: #48594f;
  --ink-faint: #75857a;
  --on-shell: #e8efe8;
  --on-shell-faint: #93a89a;

  /* Accent - scoreboard amber, used sparingly for the primary action */
  --accent: #f0a500;
  --accent-ink: #2a1e00;
  --accent-soft: #fdf0d0;

  /* Status */
  --free: #1f9e6e;
  --free-soft: #e2f4ec;
  --booked: #cf4141;
  --booked-soft: #fbe6e6;
  --pending: #d98b0b;
  --pending-soft: #fdf0d9;
  --special: #4560c8;
  --special-soft: #e6eaf9;
  --cancelled: #8a968e;
  --cancelled-soft: #eceeec;

  /* Type */
  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --body: "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Metrics */
  --rail: 232px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(14, 31, 25, 0.06), 0 8px 24px -12px rgba(14, 31, 25, 0.18);
  --shadow-lift: 0 2px 4px rgba(14, 31, 25, 0.08), 0 16px 32px -16px rgba(14, 31, 25, 0.28);
  --tap: 44px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0d1712;
    --card: #142019;
    --shell: #0a120e;
    --shell-soft: #16241c;
    --line: #26362c;
    --line-strong: #35493c;
    --ink: #e6ede7;
    --ink-soft: #a9bcaf;
    --ink-faint: #7d9184;
    --on-shell: #e6ede7;
    --on-shell-faint: #8ba394;
    --accent-soft: #3a2c05;
    --free-soft: #113026;
    --booked-soft: #3a1a1a;
    --pending-soft: #38290c;
    --special-soft: #1c2450;
    --cancelled-soft: #232b25;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.5), 0 16px 32px -16px rgba(0, 0, 0, 0.7);
  }
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.018em;
  margin: 0;
  line-height: 1.15;
}

h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.02rem; }

a { color: inherit; }

img, svg { max-width: 100%; }

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

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 12px 18px;
  z-index: 100;
  font-weight: 700;
}
.skip-link:focus { left: 8px; top: 8px; }

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

/* ------------------------------------------------------------- app shell */
.app { min-height: 100vh; }

.rail {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--rail);
  background: var(--shell);
  color: var(--on-shell);
  display: flex;
  flex-direction: column;
  padding: 22px 14px 16px;
  z-index: 30;
}

.rail__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  margin-bottom: 14px;
}

.rail__mark {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 800;
  font-size: 0.9rem;
  flex: none;
}

.rail__name {
  display: block;
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.rail__sub {
  display: block;
  font-size: 0.7rem;
  color: var(--on-shell-faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.rail__nav { display: flex; flex-direction: column; gap: 2px; }

.rail__link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--on-shell-faint);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.rail__link:hover { background: var(--shell-soft); color: var(--on-shell); }
.rail__link[aria-current="page"] {
  background: var(--shell-soft);
  color: var(--on-shell);
  box-shadow: inset 3px 0 0 var(--accent);
}
.rail__link svg { width: 18px; height: 18px; flex: none; }

.rail__foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  font-size: 0.8rem;
}
.rail__user { color: var(--on-shell); font-weight: 600; }
.rail__role { color: var(--on-shell-faint); font-size: 0.72rem; }

.linkbtn {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  background: none;
  border: 0;
  padding: 8px 0 0;
  color: var(--on-shell-faint);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.linkbtn:hover { color: var(--accent); }

/* Mobile top bar + bottom tabs */
.topbar { display: none; }
.tabbar { display: none; }

.main {
  margin-left: var(--rail);
  padding: 26px 30px 60px;
  max-width: 1320px;
}

/* ------------------------------------------------------------ page head */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}
.page-head__eyebrow {
  font-size: 0.7rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 700;
  margin-bottom: 4px;
}
.page-head__actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* -------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.06s ease;
}
.btn:hover { background: var(--paper); border-color: var(--ink-faint); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn--primary:hover { background: #e09800; border-color: #e09800; }

.btn--dark {
  background: var(--shell);
  border-color: var(--shell);
  color: var(--on-shell);
}
.btn--dark:hover { background: var(--shell-soft); border-color: var(--shell-soft); }

.btn--danger { color: var(--booked); border-color: var(--line-strong); }
.btn--danger:hover { background: var(--booked-soft); border-color: var(--booked); }

.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--card); border-color: var(--line); }

.btn--sm { min-height: 32px; padding: 5px 11px; font-size: 0.8rem; }
.btn--block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.card__head > * { min-width: 0; }
.card__body { padding: 18px; }
.card__foot {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: var(--paper);
  border-radius: 0 0 var(--radius) var(--radius);
}

.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); }
.grid--halves { grid-template-columns: repeat(auto-fit, minmax(min(330px, 100%), 1fr)); }

/* Stat tile: the number leads, the label is a quiet caption underneath. */
.stat {
  min-width: 0;
  overflow-wrap: anywhere;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat__value {
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.stat__label {
  margin-top: 7px;
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 700;
}
.stat__meta { margin-top: 5px; font-size: 0.8rem; color: var(--ink-soft); }
.stat--due .stat__value { color: var(--booked); }
.stat--paid .stat__value { color: var(--free); }

/* --------------------------------------------------------------- badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge--booked { background: var(--booked-soft); color: var(--booked); }
.badge--pending { background: var(--pending-soft); color: var(--pending); }
.badge--special { background: var(--special-soft); color: var(--special); }
.badge--free { background: var(--free-soft); color: var(--free); }
.badge--cancelled { background: var(--cancelled-soft); color: var(--cancelled); }
.badge--paid { background: var(--free-soft); color: var(--free); }
.badge--partial { background: var(--pending-soft); color: var(--pending); }
.badge--unpaid { background: var(--booked-soft); color: var(--booked); }

/* ------------------------------------------------------------- calendar */
.cal {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.cal__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}
.cal__month {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.cal__nav { display: flex; gap: 6px; }

.cal__weekdays,
.cal__week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.cal__weekdays {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.cal__weekday {
  padding: 8px 6px;
  text-align: center;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.cal__day {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 104px;
  padding: 8px 8px 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--card);
  color: inherit;
  text-decoration: none;
  transition: background 0.13s ease;
}
.cal__day:nth-child(7n) { border-right: 0; }
.cal__day:hover { background: var(--accent-soft); }
.cal__day--outside { background: var(--paper); opacity: 0.55; }
.cal__day--weekend { background: color-mix(in srgb, var(--free-soft) 45%, var(--card)); }
.cal__day--past .cal__ticks { opacity: 0.42; }
.cal__day--today { box-shadow: inset 0 0 0 2px var(--accent); }

.cal__date {
  font-family: var(--mono);
  font-size: 0.86rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.cal__day--today .cal__date {
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 6px;
  padding: 0 5px;
  align-self: flex-start;
}

.cal__holiday {
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--booked);
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Signature element: one tick per slot, so a whole month's shape is legible
   at a glance without reading a single number. */
.cal__ticks {
  display: flex;
  gap: 2px;
  margin-top: auto;
}
.cal__tick {
  flex: 1;
  height: 7px;
  border-radius: 2px;
  background: var(--line);
}
.cal__tick--booked { background: var(--booked); }
.cal__tick--pending { background: var(--pending); }
.cal__tick--special { background: var(--special); }
.cal__tick--free { background: color-mix(in srgb, var(--free) 22%, transparent); }

.cal__count {
  font-size: 0.7rem;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}
.cal__count strong { color: var(--free); font-weight: 700; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--paper);
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.legend__item { display: inline-flex; align-items: center; gap: 6px; }
.legend__swatch { width: 14px; height: 7px; border-radius: 2px; }

/* ------------------------------------------------- day board (the ladder) */
.ladder { display: flex; flex-direction: column; }

.ladder__row {
  display: grid;
  grid-template-columns: 88px 10px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  transition: background 0.13s ease;
}
.ladder__row:last-child { border-bottom: 0; }
.ladder__row:hover { background: var(--paper); }

.ladder__time {
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* The chevron is the status: colour + shape, never colour alone. */
.ladder__mark {
  width: 10px;
  align-self: stretch;
  min-height: 34px;
  border-radius: 3px;
  background: var(--line);
}
.ladder__row--free .ladder__mark { background: var(--free); }
.ladder__row--booked .ladder__mark { background: var(--booked); }
.ladder__row--pending .ladder__mark { background: var(--pending); }
.ladder__row--special .ladder__mark { background: var(--special); }
.ladder__row--past { opacity: 0.5; }

.ladder__body { min-width: 0; }
.ladder__name {
  font-weight: 600;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ladder__meta {
  font-size: 0.8rem;
  color: var(--ink-faint);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.ladder__free { color: var(--free); font-weight: 600; font-size: 0.9rem; }
.ladder__side { display: flex; align-items: center; gap: 8px; }

/* --------------------------------------------------------------- tables */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table { font-size: 0.88rem; }
.table thead th {
  position: sticky;
  top: 0;
  background: var(--paper);
  text-align: left;
  padding: 10px 14px;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 700;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--paper); }
.table tbody tr.is-cancelled td { color: var(--ink-faint); }
.table tbody tr.is-cancelled .cell-name { text-decoration: line-through; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.cell-actions { white-space: nowrap; display: flex; gap: 6px; justify-content: flex-end; }

.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--ink-faint);
}
.empty__title { font-family: var(--display); font-size: 1.05rem; color: var(--ink); margin-bottom: 6px; }

/* ---------------------------------------------------------------- forms */
.field { margin-bottom: 16px; }
.field__label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.field__req { color: var(--booked); }

.field__control {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* keeps iOS from zooming on focus */
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}
.field__control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}
.field__control[disabled] {
  background: var(--paper);
  color: var(--ink-faint);
  cursor: not-allowed;
}
textarea.field__control { min-height: 80px; resize: vertical; }
select.field__control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%2348594f' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 11px;
  padding-right: 34px;
}

.field__help { font-size: 0.79rem; color: var(--ink-faint); margin-top: 5px; }
.field__error { font-size: 0.82rem; color: var(--booked); margin-top: 5px; font-weight: 600; }
.field--invalid .field__control { border-color: var(--booked); }

.field-row {
  display: grid;
  gap: 0 16px;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
}

.choices { display: flex; flex-direction: column; gap: 8px; }
.choices label {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.88rem;
}
.choices label:hover { background: var(--paper); }
.choices input { margin-top: 3px; accent-color: var(--accent); flex: none; }
.choices--inline { flex-direction: row; flex-wrap: wrap; }
.choices--inline label { flex: 1 1 190px; }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.filters {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
  align-items: end;
}
.filters .field { margin-bottom: 0; }
.filters__actions { display: flex; gap: 8px; }

/* -------------------------------------------------------------- messages */
.messages { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.msg {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 0.9rem;
  box-shadow: var(--shadow);
}
.msg::before { content: ""; width: 4px; align-self: stretch; border-radius: 2px; background: var(--ink-faint); flex: none; }
.msg--success::before { background: var(--free); }
.msg--error::before { background: var(--booked); }
.msg--warning::before { background: var(--pending); }
.msg--info::before { background: var(--special); }

.notice {
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  font-size: 0.88rem;
}

/* ------------------------------------------------------- ranked bar list */
.rank { display: flex; flex-direction: column; gap: 10px; }
.rank__row { display: grid; grid-template-columns: 78px 1fr 34px; gap: 10px; align-items: center; }
.rank__label { font-family: var(--mono); font-size: 0.8rem; }
.rank__track { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.rank__fill { height: 100%; background: var(--free); border-radius: 4px; }
.rank__value { font-family: var(--mono); font-size: 0.8rem; text-align: right; color: var(--ink-soft); }

/* ------------------------------------------------------------- key/value */
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); gap: 16px; }
.kv__key {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 700;
  margin-bottom: 3px;
}
.kv__value { font-size: 1rem; font-weight: 600; }
.kv__value--mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------- import steps */
.steps { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 100px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-faint);
}
.step__num {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--line);
  color: var(--ink-soft);
  display: grid; place-items: center;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
}
.step--active { border-color: var(--accent); color: var(--ink); background: var(--accent-soft); }
.step--active .step__num { background: var(--accent); color: var(--accent-ink); }
.step--done .step__num { background: var(--free); color: #fff; }

.map-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }
.map-item { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 13px; }
.map-item__header {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin-bottom: 7px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tally { display: flex; flex-wrap: wrap; gap: 10px; }
.tally__item {
  flex: 1 1 110px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card);
}
.tally__num { font-family: var(--display); font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.tally__label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-faint); font-weight: 700; margin-top: 5px; }
.tally__item--create .tally__num { color: var(--free); }
.tally__item--update .tally__num { color: var(--special); }
.tally__item--skip .tally__num { color: var(--pending); }
.tally__item--error .tally__num { color: var(--booked); }

.row-action { font-family: var(--mono); font-size: 0.74rem; font-weight: 700; text-transform: uppercase; }
.row-action--create { color: var(--free); }
.row-action--update { color: var(--special); }
.row-action--skip { color: var(--pending); }
.row-action--error { color: var(--booked); }

/* ------------------------------------------------------------ pagination */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
}
.pager__info { font-size: 0.84rem; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.pager__links { display: flex; gap: 6px; }

/* ---------------------------------------------------------------- login */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at top, color-mix(in srgb, var(--free) 12%, transparent), transparent 60%),
    var(--paper);
}
.login__card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 30px 26px;
  box-shadow: var(--shadow-lift);
}
.login__mark {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--shell);
  color: var(--accent);
  display: grid; place-items: center;
  font-family: var(--display);
  font-weight: 800;
  margin-bottom: 16px;
}
.login__title { font-size: 1.45rem; margin-bottom: 4px; }
.login__sub { color: var(--ink-faint); font-size: 0.9rem; margin: 0 0 22px; }

/* ---------------------------------------------------------------- utils */
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.muted { color: var(--ink-faint); }
.small { font-size: 0.82rem; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.nowrap { white-space: nowrap; }
.hide-sm { display: initial; }

/* =========================================================================
   Responsive - the rail becomes a bottom tab bar, tables become cards.
   ========================================================================= */

@media (max-width: 1024px) {
  .main { padding: 22px 20px 60px; }
}

@media (max-width: 860px) {
  .rail { display: none; }

  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 25;
    padding: 10px 14px;
    background: var(--shell);
    color: var(--on-shell);
  }
  .topbar .rail__brand { border: 0; margin: 0; padding: 0; }
  .topbar .rail__sub { display: none; }

  .tabbar {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    position: fixed;
    inset: auto 0 0 0;
    z-index: 40;
    background: var(--card);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar__link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 56px;
    text-decoration: none;
    color: var(--ink-faint);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.02em;
  }
  .tabbar__link svg { width: 21px; height: 21px; }
  .tabbar__link[aria-current="page"] { color: var(--ink); box-shadow: inset 0 2px 0 var(--accent); }

  .main {
    margin-left: 0;
    padding: 18px 14px calc(76px + env(safe-area-inset-bottom));
  }

  h1 { font-size: 1.35rem; }

  .cal__day { min-height: 74px; padding: 6px 5px 8px; gap: 4px; }
  .cal__count { display: none; }
  .cal__tick { height: 5px; }
  .cal__holiday { -webkit-line-clamp: 1; font-size: 0.6rem; }
  .cal__date { font-size: 0.78rem; }
  .cal__weekday { font-size: 0.6rem; letter-spacing: 0.06em; padding: 7px 2px; }

  .ladder__row { grid-template-columns: 72px 8px 1fr; gap: 10px; padding: 10px 12px; }
  .ladder__side { grid-column: 3; justify-content: flex-start; }

  .page-head { align-items: flex-start; flex-direction: column; }
  .page-head__actions { width: 100%; }
  .page-head__actions .btn { flex: 1 1 auto; }

  .grid--stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 13px 14px; }
  .stat__value { font-size: 1.55rem; }

  .hide-sm { display: none; }

  /* Tables reflow into stacked cards; each cell carries its own label. */
  .table--stack thead { display: none; }
  .table--stack tbody tr {
    display: block;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
  }
  .table--stack tbody tr:hover { background: transparent; }
  .table--stack tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 4px 0;
    border: 0;
    text-align: right;
  }
  .table--stack tbody td::before {
    content: attr(data-label);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-faint);
    font-weight: 700;
    text-align: left;
    flex: none;
  }
  .table--stack tbody td.cell-actions { justify-content: flex-end; padding-top: 10px; }
  .table--stack tbody td.cell-actions::before { display: none; }
  .table--stack .num { text-align: right; }

  .filters { grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr)); }
  .form-actions .btn { flex: 1 1 auto; }
}

@media (max-width: 860px) {
  .linkbtn { min-height: var(--tap); padding: 0 4px; }
}

@media (max-width: 420px) {
  .grid--stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat__value { font-size: 1.25rem; letter-spacing: -0.02em; }
  .stat { padding: 11px 12px; }
  .cal__day { min-height: 62px; }
  .tabbar__link { font-size: 0.6rem; }
  .main { padding-left: 10px; padding-right: 10px; }
  .card__body, .card__head, .card__foot { padding-left: 13px; padding-right: 13px; }
  .table--stack tbody tr { padding-left: 13px; padding-right: 13px; }
  .badge { font-size: 0.68rem; }
}

@media print {
  .rail, .tabbar, .topbar, .page-head__actions, .form-actions, .pager { display: none !important; }
  .main { margin: 0; padding: 0; }
  .card, .stat { box-shadow: none; border-color: #999; }
  body { background: #fff; }
}

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