/* ============================================================================
   SCAN Central — dash.css
   The DASHBOARD layer, loaded after tokens.css by the five role pages:
   /player, /coach, /team, /parent, /admin.

   This is a different shape from app.css: wide, sidebar + topbar, tables,
   no floating tabbar. The two are never both required on one page, so the
   .topbar and .chip rules here are scoped under .shell to keep them apart if
   a page ever does load both.

   It imports nothing. tokens.css is loaded alongside it.
   ========================================================================= */

/* ---------------------------------------------------------------------------
   Shell — 240px sidebar over 900px, stacked topbar below
   ------------------------------------------------------------------------ */
.shell {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "brand topbar"
    "nav   page";
  min-height: 100dvh;
}

.brand-lockup { grid-area: brand; }
.topbar       { grid-area: topbar; }
.side-nav     { grid-area: nav; }
.page         { grid-area: page; }

/* ---------------------------------------------------------------------------
   Brand lockup
   ------------------------------------------------------------------------ */
.brand-lockup {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: calc(var(--safe-top) + var(--sp-3)) var(--sp-4) var(--sp-3);
  background: var(--surface);
  border-bottom: var(--hair);
  border-right: var(--hair);
  min-height: var(--topbar-h);
  text-decoration: none;
  color: inherit;
}
.brand-lockup:hover { text-decoration: none; }

.brand-lockup img,
.brand-lockup svg {
  width: 30px;
  height: auto;
  flex: 0 0 auto;
  filter: drop-shadow(0 3px 10px rgba(0, 0, 0, .5));
}

.brand-lockup .wm {
  font-family: var(--font-head);
  font-size: var(--fs-small);
  font-weight: var(--fw-black);
  letter-spacing: .06em;
  line-height: 1.1;
  white-space: nowrap;
}
.brand-lockup .wm b { color: var(--cyan); font-weight: inherit; }

.brand-lockup .tag {
  display: block;
  font-size: 9px;
  font-weight: var(--fw-bold);
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ---------------------------------------------------------------------------
   Topbar
   ------------------------------------------------------------------------ */
.shell .topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: calc(var(--safe-top) + var(--sp-2)) var(--sp-5) var(--sp-2);
  background: rgba(17, 19, 24, .9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: var(--hair);
  min-height: var(--topbar-h);
}

.topbar h1 {
  font-size: var(--fs-h2);
  font-weight: var(--fw-black);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar .sub {
  font-size: var(--fs-tiny);
  color: var(--text-muted);
}

.topbar .spacer,
.tb-spacer { flex: 1; }

.tb-right {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* Hamburger — only visible when the sidebar has collapsed. */
.nav-toggle {
  display: none;
  width: var(--tap);
  height: var(--tap);
  place-items: center;
  border-radius: var(--r-btn);
  border: var(--hair);
  color: var(--text-primary);
}
.nav-toggle:hover { border-color: var(--cyan); color: var(--cyan); }

/* Bell + avatar (markup is shared with app.css; these are the wide variants) */
.bell-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  border-radius: var(--r-btn);
  border: var(--hair);
  color: var(--text-muted);
}
.bell-btn:hover { color: var(--cyan); border-color: var(--cyan); }

.bell-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--red);
  color: #1B0A0A;
  font-size: 10px;
  font-weight: var(--fw-black);
  line-height: 18px;
  text-align: center;
  border: 2px solid var(--bg);
}
.bell-badge[hidden] { display: none; }

.menu-avatar {
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  border-radius: var(--r-pill);
  border: 2px solid var(--border);
  background: var(--surface-2);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.menu-avatar:hover { border-color: var(--cyan); }
.menu-avatar img { width: 100%; height: 100%; object-fit: cover; }
.menu-avatar span {
  font-family: var(--font-head);
  font-weight: var(--fw-black);
  font-size: var(--fs-small);
  color: var(--cyan);
}

/* ---------------------------------------------------------------------------
   Side navigation
   ------------------------------------------------------------------------ */
.side-nav {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-4) var(--sp-3) calc(var(--sp-6) + var(--safe-bottom));
  background: var(--surface);
  border-right: var(--hair);
  overflow-y: auto;
}

.side-nav .nav-group {
  margin-top: var(--sp-4);
  padding: 0 var(--sp-3) var(--sp-1);
  font-size: 10px;
  font-weight: var(--fw-black);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.side-nav .nav-group:first-child { margin-top: 0; }

.side-nav a {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--tap);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-btn);
  color: var(--text-muted);
  font-size: var(--fs-small);
  font-weight: var(--fw-med);
  text-decoration: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.side-nav a:hover {
  background: var(--surface-2);
  color: var(--text-primary);
  text-decoration: none;
}
.side-nav a[aria-current="page"] {
  background: var(--cyan-soft);
  color: var(--cyan);
  font-weight: var(--fw-bold);
  box-shadow: inset 3px 0 0 var(--cyan);
}
.side-nav .nav-ic {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
}

/* ---------------------------------------------------------------------------
   Page body
   ------------------------------------------------------------------------ */
.page {
  padding: var(--sp-6) var(--sp-5) calc(var(--sp-8) + var(--safe-bottom));
  max-width: var(--page-max);
  width: 100%;
  min-width: 0;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
.page-head h2 { font-size: var(--fs-h1); }
.page-head .sub { font-size: var(--fs-small); color: var(--text-muted); margin-top: var(--sp-1); }

.section { margin-bottom: var(--sp-7); }
.section > h3 {
  font-size: var(--fs-h3);
  margin-bottom: var(--sp-3);
}

/* ---------------------------------------------------------------------------
   Grid + cards
   ------------------------------------------------------------------------ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--sp-4);
}
.grid.tight { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--sp-3); }
.grid.wide  { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.span-2 { grid-column: span 2; }

.card {
  background: var(--surface);
  border: var(--hair);
  border-radius: var(--r-card);
  padding: var(--sp-5);
  min-width: 0;
}
.card > h3 {
  font-size: var(--fs-h3);
  margin-bottom: var(--sp-1);
}
.card > .csub {
  font-size: var(--fs-tiny);
  color: var(--text-muted);
  margin-bottom: var(--sp-4);
}
.card.raised {
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

/* ---------------------------------------------------------------------------
   KPI hero + stat tiles
   ------------------------------------------------------------------------ */
.kpi-hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}

.stat-tile {
  position: relative;
  overflow: hidden;
  padding: var(--sp-5);
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: var(--hair);
  border-radius: var(--r-card);
}
.stat-tile::after {
  content: "";
  position: absolute;
  right: -30px;
  top: -30px;
  width: 90px;
  height: 90px;
  border-radius: var(--r-pill);
  background: radial-gradient(circle, var(--cyan-soft), transparent 70%);
  pointer-events: none;
}

.stat-tile .lab {
  font-size: var(--fs-tiny);
  font-weight: var(--fw-bold);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat-tile .val {
  font-family: var(--font-head);
  font-size: var(--fs-display);
  font-weight: var(--fw-black);
  line-height: 1;
  margin-top: var(--sp-2);
  font-variant-numeric: tabular-nums;
}
.stat-tile .val small {
  font-size: var(--fs-h3);
  font-weight: var(--fw-bold);
  color: var(--text-muted);
}

.stat-tile .delta {
  margin-top: var(--sp-2);
  min-height: 16px;
  font-size: var(--fs-tiny);
  font-weight: var(--fw-bold);
  color: var(--text-muted);
}
.stat-tile .delta.up   { color: var(--green); }
.stat-tile .delta.down { color: var(--red); }

.stat-tile .bar-mini {
  height: 5px;
  margin-top: var(--sp-3);
  border-radius: var(--r-pill);
  background: var(--surface-3);
  overflow: hidden;
}
.stat-tile .bar-mini i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--cyan);
  transition: width var(--dur-slow) var(--ease);
}

/* ---------------------------------------------------------------------------
   Score ring
   ------------------------------------------------------------------------ */
.ring {
  display: block;
  width: 140px;
  height: 140px;
  margin: 0 auto;
}
.ring circle { transition: stroke-dashoffset var(--dur-slow) var(--ease); }
.ring .ring-track { stroke: var(--surface-3); }
.ring .ring-val   { stroke: var(--cyan); stroke-linecap: round; }
.ring .ring-num {
  font-family: var(--font-head);
  font-weight: var(--fw-black);
  fill: var(--text-primary);
}
.ring .ring-sub { fill: var(--text-muted); }

.ring-row {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------------------
   Tables
   ------------------------------------------------------------------------ */
.table-wrap {
  overflow-x: auto;
  border: var(--hair);
  border-radius: var(--r-card);
  background: var(--surface);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-small);
}

.table caption {
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  font-size: var(--fs-tiny);
  color: var(--text-muted);
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: var(--fs-tiny);
  font-weight: var(--fw-black);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Sortable headers. The button carries the click; aria-sort carries state. */
.table thead th.sortable { padding: 0; }
.table thead th.sortable > button {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  min-height: 44px;
  padding: var(--sp-3) var(--sp-4);
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  text-align: left;
}
.table thead th.sortable > button:hover { color: var(--text-primary); }
.table thead th.sortable > button::after {
  content: "\2195";                 /* up-down arrow, the neutral state */
  margin-left: auto;
  opacity: .35;
  font-size: 11px;
}
.table thead th[aria-sort="ascending"]  > button::after { content: "\2191"; opacity: 1; color: var(--cyan); }
.table thead th[aria-sort="descending"] > button::after { content: "\2193"; opacity: 1; color: var(--cyan); }

.table tbody td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid rgba(43, 48, 58, .6);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--surface-2); }

.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: var(--fw-bold);
}
.table .nowrap { white-space: nowrap; }

.table th:focus-visible,
.table td:focus-visible { box-shadow: var(--focus); }

/* ---------------------------------------------------------------------------
   Chips + badges (dashboard variants)
   ------------------------------------------------------------------------ */
.shell .chip,
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 5px var(--sp-3);
  border: var(--hair);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: var(--fs-tiny);
  font-weight: var(--fw-bold);
  white-space: nowrap;
}
.chip.on,
.chip.active { border-color: var(--cyan); background: var(--cyan-soft); color: var(--cyan); }
.chip .lv {
  width: 7px;
  height: 7px;
  border-radius: var(--r-pill);
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}
.chip .lv.nodata { background: var(--text-dim); box-shadow: none; }
.chip b { color: var(--text-primary); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 3px var(--sp-2);
  border-radius: var(--r-sm);
  font-size: 10px;
  font-weight: var(--fw-black);
  letter-spacing: .05em;
  text-transform: uppercase;
  background: var(--surface-3);
  color: var(--text-muted);
}
.badge.green  { background: var(--green-soft);  color: var(--green); }
.badge.amber  { background: var(--amber-soft);  color: var(--amber); }
.badge.orange { background: var(--orange-soft); color: var(--orange); }
.badge.red    { background: var(--red-soft);    color: var(--red); }
.badge.cyan   { background: var(--cyan-soft);   color: var(--cyan); }
.badge.gold   { background: var(--gold-soft);   color: var(--gold); }

/* Score band pills, driven by score_band()'s key. */
.badge.band-start      { background: rgba(248,113,113,.14); color: var(--band-start); }
.badge.band-developing { background: rgba(251,146,60,.14);  color: var(--band-developing); }
.badge.band-building   { background: rgba(232,255,58,.14);  color: var(--band-building); }
.badge.band-consistent { background: rgba(95,209,243,.14);  color: var(--band-consistent); }
.badge.band-advanced   { background: rgba(74,222,128,.14);  color: var(--band-advanced); }
.badge.band-mastered   { background: rgba(201,163,107,.16); color: var(--band-mastered); }
.badge.band-unscored   { background: var(--surface-3);      color: var(--band-unscored); }

/* ---------------------------------------------------------------------------
   Buttons (dashboard sizing)
   ------------------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--tap);
  padding: var(--sp-2) var(--sp-5);
  border: 1px solid transparent;
  border-radius: var(--r-btn);
  background: var(--cyan);
  color: var(--on-cyan);
  font-family: var(--font-head);
  font-size: var(--fs-small);
  font-weight: var(--fw-black);
  text-decoration: none;
  transition: filter var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.btn:hover:not(:disabled) { filter: brightness(1.08); text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-primary);
}
.btn.ghost:hover:not(:disabled) { border-color: var(--cyan); color: var(--cyan); filter: none; }
.btn.secondary {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-primary);
}
.btn.secondary:hover:not(:disabled) { border-color: var(--cyan); filter: none; }
.btn.danger { background: var(--red); color: #2A0B0B; }
.btn.small { min-height: 36px; padding: var(--sp-1) var(--sp-3); font-size: var(--fs-tiny); }

/* ---------------------------------------------------------------------------
   Form controls
   ------------------------------------------------------------------------ */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}
.field label {
  font-size: var(--fs-tiny);
  font-weight: var(--fw-bold);
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: var(--tap);
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-3);
  border: var(--hair);
  border-radius: var(--r-btn);
  color: var(--text-primary);
  font-size: var(--fs-small);
}
.field textarea { min-height: 110px; resize: vertical; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px var(--cyan-soft);
}
.field .hint { font-size: var(--fs-tiny); color: var(--text-muted); }
.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-4);
}

.selwrap {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--tap);
  padding: var(--sp-1) var(--sp-3);
  background: var(--surface-2);
  border: var(--hair);
  border-radius: var(--r-btn);
}
.selwrap label {
  font-size: var(--fs-tiny);
  font-weight: var(--fw-bold);
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.selwrap select {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-weight: var(--fw-med);
  outline: none;
}
.selwrap select option { background: var(--surface-2); }

/* Toggle switch, used by the settings sheet. */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  min-height: var(--tap);
  padding: var(--sp-2) 0;
}
.switch-row .switch-label { font-size: var(--fs-small); font-weight: var(--fw-med); }
.switch-row .switch-hint  { font-size: var(--fs-tiny); color: var(--text-muted); }

.switch { position: relative; flex: 0 0 auto; width: 52px; height: 30px; }
.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.switch .track {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  border: var(--hair);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
  pointer-events: none;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: var(--r-pill);
  background: var(--text-muted);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.switch input:checked + .track { background: var(--cyan-soft); border-color: var(--cyan); }
.switch input:checked + .track::after { transform: translateX(22px); background: var(--cyan); }
.switch input:focus-visible + .track { box-shadow: var(--focus); }

/* ---------------------------------------------------------------------------
   Bottom sheet.

   Every old page hand-rolled this, five slightly different ways. One
   implementation now, opened and closed by SCAN.sheet.
   ------------------------------------------------------------------------ */
.sheet {
  position: fixed;
  inset: 0;
  z-index: var(--z-sheet);
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(8, 10, 13, .72);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.sheet.open { display: flex; }

.sheet-panel {
  width: min(480px, 100%);
  max-height: 88dvh;
  overflow-y: auto;
  padding: var(--sp-4) var(--sp-4) calc(var(--sp-5) + var(--safe-bottom));
  background: var(--surface);
  border: var(--hair);
  border-bottom: none;
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  box-shadow: var(--shadow-lg);
  animation: sheet-up var(--dur) var(--ease);
}

@keyframes sheet-up {
  from { transform: translateY(34px); opacity: .4; }
  to   { transform: none; opacity: 1; }
}

.sheet-grip {
  width: 40px;
  height: 4px;
  margin: 0 auto var(--sp-3);
  border-radius: var(--r-pill);
  background: var(--border-strong);
}

.sheet-title {
  margin-bottom: var(--sp-3);
  font-size: var(--fs-tiny);
  font-weight: var(--fw-black);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
}

.sheet-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  min-height: var(--tap);
  margin-bottom: var(--sp-2);
  padding: var(--sp-3);
  text-align: left;
  background: var(--bg);
  border: var(--hair);
  border-radius: var(--r-btn);
  color: var(--text-primary);
  text-decoration: none;
}
.sheet-item:hover { border-color: var(--cyan); text-decoration: none; }
.sheet-item .si-ic { flex: 0 0 auto; width: 24px; text-align: center; font-size: 1.05rem; }
.sheet-item b { display: block; font-size: var(--fs-small); font-weight: var(--fw-black); }
.sheet-item .si-sub { display: block; font-size: var(--fs-tiny); color: var(--text-muted); }
.sheet-item.danger { border-color: rgba(248, 113, 113, .4); }
.sheet-item.danger b { color: var(--red); }

.sheet-section {
  margin: var(--sp-4) 0 var(--sp-2);
  font-size: 10px;
  font-weight: var(--fw-black);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.sheet-cancel {
  width: 100%;
  min-height: var(--tap);
  margin-top: var(--sp-2);
  padding: var(--sp-3);
  background: transparent;
  border: var(--hair);
  border-radius: var(--r-btn);
  color: var(--text-primary);
  font-family: var(--font-head);
  font-size: var(--fs-small);
  font-weight: var(--fw-black);
}
.sheet-cancel:hover { border-color: var(--cyan); }

/* ---------------------------------------------------------------------------
   Modal — centred, for confirmations
   ------------------------------------------------------------------------ */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  background: rgba(8, 10, 13, .74);
}
.modal.open { display: flex; }

.modal-panel {
  width: min(520px, 100%);
  max-height: 86dvh;
  overflow-y: auto;
  padding: var(--sp-5);
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: var(--hair);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-lg);
  animation: modal-in var(--dur) var(--ease);
}
@keyframes modal-in {
  from { transform: scale(.97); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.modal-head h3 { font-size: var(--fs-h2); }

.modal-close {
  width: var(--tap);
  height: var(--tap);
  display: grid;
  place-items: center;
  border-radius: var(--r-btn);
  color: var(--text-muted);
  font-size: 1.35rem;
  line-height: 1;
}
.modal-close:hover { color: var(--text-primary); background: var(--surface-3); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  margin-top: var(--sp-5);
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------------------
   Empty state
   ------------------------------------------------------------------------ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-8) var(--sp-5);
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-card);
  background: var(--surface);
}
.empty-state .es-ic {
  font-size: 2.25rem;
  line-height: 1;
  opacity: .7;
}
.empty-state h3 { font-size: var(--fs-h3); }
.empty-state p {
  max-width: 44ch;
  font-size: var(--fs-small);
  color: var(--text-muted);
}

/* ---------------------------------------------------------------------------
   Skeleton loaders
   ------------------------------------------------------------------------ */
.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 400% 100%;
  animation: skeleton-slide 1.4s linear infinite;
  color: transparent;
  user-select: none;
}
.skeleton.line  { height: 12px; margin-bottom: var(--sp-2); }
.skeleton.title { height: 20px; width: 52%; margin-bottom: var(--sp-3); }
.skeleton.tile  { height: 120px; border-radius: var(--r-card); }
.skeleton.row   { height: 44px; margin-bottom: var(--sp-2); border-radius: var(--r-btn); }

@keyframes skeleton-slide {
  from { background-position: 100% 0; }
  to   { background-position: 0 0; }
}

/* ---------------------------------------------------------------------------
   Toasts — the aria-live region lives here on dashboards too
   ------------------------------------------------------------------------ */
.toast-wrap {
  position: fixed;
  right: var(--sp-5);
  bottom: calc(var(--sp-5) + var(--safe-bottom));
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  width: min(380px, calc(100vw - var(--sp-7)));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2);
  border: 1px solid var(--cyan);
  border-left-width: 4px;
  border-radius: var(--r-btn);
  color: var(--text-primary);
  font-size: var(--fs-small);
  font-weight: var(--fw-med);
  box-shadow: var(--shadow);
  animation: toast-slide var(--dur) var(--ease);
  transition: opacity var(--dur-slow) var(--ease);
}
.toast.success { border-color: var(--green); }
.toast.warn    { border-color: var(--orange); }
.toast.error   { border-color: var(--red); }
.toast.info    { border-color: var(--cyan); }

@keyframes toast-slide {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: none; }
}

/* ---------------------------------------------------------------------------
   Misc dashboard pieces
   ------------------------------------------------------------------------ */
.banner {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4);
  border: var(--hair);
  border-left: 3px solid var(--cyan);
  border-radius: var(--r-btn);
  background: var(--surface-2);
  font-size: var(--fs-small);
}
.banner.warn  { border-left-color: var(--amber); }
.banner.error { border-left-color: var(--red); }
.banner.ok    { border-left-color: var(--green); }

.muted { color: var(--text-muted); }
.tiny  { font-size: var(--fs-tiny); }
.num   { font-variant-numeric: tabular-nums; }
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.row   { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.right { margin-left: auto; }

.avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: var(--r-pill);
  object-fit: cover;
  background: var(--surface-3);
}

/* ---------------------------------------------------------------------------
   COLLAPSE — under 900px the sidebar becomes a slide-in drawer and the
   brand lockup joins the topbar row.
   ------------------------------------------------------------------------ */
@media (max-width: 900px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "topbar"
      "page";
  }

  .brand-lockup {
    display: none;                 /* the topbar carries its own copy */
  }

  .nav-toggle { display: grid; }

  .side-nav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: var(--z-sheet);
    width: min(300px, 84vw);
    padding-top: calc(var(--safe-top) + var(--sp-5));
    border-right: var(--hair);
    box-shadow: var(--shadow-lg);
    transform: translateX(-102%);
    transition: transform var(--dur) var(--ease);
  }
  .side-nav.open { transform: none; }

  /* Scrim, drawn by the nav itself so no extra markup is needed. */
  .side-nav.open::before {
    content: "";
    position: fixed;
    inset: 0 0 0 min(300px, 84vw);
    background: rgba(8, 10, 13, .6);
  }

  .page { padding: var(--sp-5) var(--sp-4) calc(var(--sp-8) + var(--safe-bottom)); }
  .shell .topbar { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .toast-wrap { right: var(--sp-4); left: var(--sp-4); width: auto; }
  .span-2 { grid-column: auto; }
}

@media (max-width: 560px) {
  .kpi-hero { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--sp-3); }
  .stat-tile { padding: var(--sp-4); }
  .stat-tile .val { font-size: var(--fs-h1); }
  .card { padding: var(--sp-4); }
  .topbar h1 { font-size: var(--fs-h3); }

  /* On a phone the two-line wordmark and a long page title ("Family view")
     were fighting over the same row and the title lost — screenshots showed
     them overlapping. The shield alone carries the brand at this width; the
     page title is what the person actually needs, and it truncates with an
     ellipsis instead of colliding when it is still too long. */
  .brand-mini .wm { display: none; }
  .tb-title { min-width: 0; }
  .topbar .tb-title h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* The drawer must not animate for players who asked for stillness; the
   body.rm / prefers-reduced-motion rules in tokens.css already neutralise the
   duration, and the drawer stays usable because it is transform-only. */

/* ---------------------------------------------------------------------------
   Compact brand mark inside the topbar.

   The sidebar's .brand-lockup disappears under 900px, so the topbar carries a
   small copy. Rendering both (rather than moving one with JS) keeps the markup
   static and the logo a single <img> reference either way.
   ------------------------------------------------------------------------ */
.brand-mini {
  display: none;
  align-items: center;
  gap: var(--sp-2);
  color: inherit;
  text-decoration: none;
}
.brand-mini:hover { text-decoration: none; }
.brand-mini img { width: 26px; height: auto; }
.brand-mini .wm {
  font-family: var(--font-head);
  font-size: var(--fs-tiny);
  font-weight: var(--fw-black);
  letter-spacing: .06em;
}
.brand-mini .wm b { color: var(--cyan); font-weight: inherit; }

@media (max-width: 900px) {
  .brand-mini { display: flex; }
}

/* The sign-in / reset / forgot cards and choose-view share this centred
   layout. They have no shell, so they set body.auth-page. */
body.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-top) + var(--sp-6)) var(--sp-5) calc(var(--safe-bottom) + var(--sp-6));
}

.auth-card {
  width: min(430px, 100%);
  padding: var(--sp-7) var(--sp-6) var(--sp-6);
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: var(--hair);
  border-radius: var(--r-sheet);
  box-shadow: var(--shadow-lg);
}
.auth-card.wide { width: min(780px, 100%); }

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-6);
  text-align: center;
}
.auth-brand img { width: 72px; height: auto; filter: drop-shadow(0 6px 18px rgba(0, 0, 0, .55)); }
.auth-brand .wm {
  font-family: var(--font-head);
  font-size: var(--fs-h2);
  font-weight: var(--fw-black);
  letter-spacing: .06em;
}
.auth-brand .wm b { color: var(--cyan); font-weight: inherit; }
.auth-brand .tag {
  font-size: 10px;
  font-weight: var(--fw-bold);
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.auth-card h1 { font-size: var(--fs-h3); margin-bottom: var(--sp-1); }
.auth-card .sub {
  font-size: var(--fs-small);
  color: var(--text-muted);
  margin-bottom: var(--sp-5);
}

.auth-tabs {
  display: flex;
  gap: var(--sp-2);
  margin-bottom: var(--sp-5);
}
.auth-tabs button {
  flex: 1;
  min-height: var(--tap);
  border: var(--hair);
  border-radius: var(--r-btn);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-head);
  font-size: var(--fs-small);
  font-weight: var(--fw-black);
}
.auth-tabs button[aria-selected="true"] {
  color: var(--cyan);
  border-color: var(--cyan);
  background: var(--cyan-soft);
}

.auth-msg {
  min-height: 20px;
  margin-top: var(--sp-3);
  font-size: var(--fs-small);
  font-weight: var(--fw-med);
}
.auth-msg.err { color: var(--red); }
.auth-msg.ok  { color: var(--green); }

.auth-foot {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: var(--hair);
  font-size: var(--fs-tiny);
  color: var(--text-muted);
}

/* Role cards on choose-view.php */
.view-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--sp-4);
}

.view-card {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
  padding: var(--sp-5);
  background: var(--surface);
  border: var(--hair);
  border-radius: var(--r-card);
  color: inherit;
  text-decoration: none;
  min-height: 112px;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.view-card:hover {
  border-color: var(--cyan);
  transform: translateY(-2px);
  text-decoration: none;
}
.view-card .vc-ic {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--r-btn);
  background: var(--cyan-soft);
  color: var(--cyan);
}
.view-card .vc-name {
  font-family: var(--font-head);
  font-size: var(--fs-h3);
  font-weight: var(--fw-black);
}
.view-card .vc-desc {
  font-size: var(--fs-small);
  color: var(--text-muted);
  margin-top: var(--sp-1);
}

/* Tiny branded error documents (403/404/500) reuse .auth-card. */
.err-code {
  font-family: var(--font-head);
  font-size: var(--fs-display);
  font-weight: var(--fw-black);
  color: var(--cyan);
  line-height: 1;
}

/* ---------------------------------------------------------------------------
   Icon sizing is intrinsic, not contextual.

   These marks are <svg viewBox="0 0 24 24"> with no width/height attribute.
   An SVG like that has no intrinsic size, so with no CSS box the browser
   falls back to the replaced-element default and paints it at the full
   container width. Scoping the only size rule to `.side-nav .nav-ic` meant
   the same icon rendered at 20px in the sidebar and 1280px anywhere else.
   Size it wherever it appears.
--------------------------------------------------------------------------- */
.nav-ic,
.vc-ic > svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  display: inline-block;
  vertical-align: middle;
}
.vc-ic > svg { width: 28px; height: 28px; }

/* Tab strips scroll rather than clip. The admin console has 11 sections, which
   overflow 1280px — previously the last two were simply cut off at the edge
   with nothing to show more existed. */
.tabs, [role="tablist"] {
  --tabs-fade: 1;
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-right: var(--sp-6);
  mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent 100%);
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent 100%);
}
.tabs::-webkit-scrollbar, [role="tablist"]::-webkit-scrollbar { height: 0; }
.tabs > *, [role="tablist"] > * { flex: 0 0 auto; }

/* ---------------------------------------------------------------------------
   `hidden` must actually hide.

   The UA stylesheet's [hidden]{display:none} has the lowest possible
   specificity, so ANY rule that sets display on the same element beats it —
   and .panel.form sets display:grid. The result was that every panel marked
   hidden in the markup (add a team, add a person, coaching staff, squad,
   assign to squad) rendered permanently open on the admin console.

   Nothing should have to remember this, so it is enforced once, here.
   A panel that genuinely needs to override it can set display on a class that
   is only applied when it is open.
--------------------------------------------------------------------------- */
[hidden] { display: none !important; }
