/* Shared app components, built only from the tokens in tokens.css. Loaded after admin.css by every app
   page. Class names, markup and do/don't: docs/ui-components.md. Small JS builders for the ones that need
   behaviour (row menu, sheet, selection bar ...) are in web/js/ui-kit.js (window.Kit).

   Scope: the app bodies (admin, family account, chat, sign-in, /hq). Nothing here applies to a club's
   public site, which has its own look from base.css. */

/* =========================================================== buttons */
:is(body.admin, body.login-page, body.hq) .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 40px; padding: 8px 16px; border: 1px solid transparent; border-radius: var(--r-md);
  background: var(--c-brand); color: var(--c-brand-ink); font: inherit; font-weight: 600; line-height: 1.2;
  text-decoration: none; cursor: pointer; box-shadow: var(--sh-1);
  transition: background-color var(--dur-fast) var(--ease), filter var(--dur-fast) var(--ease);
}
:is(body.admin, body.login-page, body.hq) .btn:hover { filter: brightness(1.08); transform: none; }
:is(body.admin, body.login-page, body.hq) .btn:disabled, :is(body.admin, body.login-page, body.hq) .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; filter: none; }
/* Secondary: outlined. .btn-secondary is the new name; .btn-ghost (old) looks the same. */
:is(body.admin, body.login-page, body.hq) :is(.btn-ghost, .btn-secondary) { background: var(--c-surface); color: var(--c-ink); border-color: var(--c-border-strong); box-shadow: none; font-weight: 500; }
:is(body.admin, body.login-page, body.hq) :is(.btn-ghost, .btn-secondary):hover { background: var(--c-surface-hover); filter: none; }
/* Quiet: a text button for verbs in bars and menus. */
:is(body.admin, body.login-page, body.hq) .btn-quiet { background: transparent; color: var(--c-link); border-color: transparent; box-shadow: none; padding-left: 10px; padding-right: 10px; }
:is(body.admin, body.login-page, body.hq) .btn-quiet:hover { background: var(--c-surface-hover); filter: none; }
:is(body.admin, body.login-page, body.hq) .btn-danger { background: var(--c-danger-fill); color: #fff; border-color: transparent; }
:is(body.admin, body.login-page, body.hq) .btn-quiet.danger { background: transparent; color: var(--c-danger); }
:is(body.admin, body.login-page, body.hq) .btn-small { min-height: 32px; padding: 4px 12px; font-size: var(--t-small); }
:is(body.admin, body.login-page, body.hq) .btn-block { width: 100%; }
/* A square button with only an icon: it MUST carry an aria-label (and a title for mouse users). */
:is(body.admin, body.login-page, body.hq) .btn-icon { width: 40px; min-width: 40px; padding: 0; }
@media (pointer: coarse) {
  :is(body.admin, body.login-page, body.hq) .btn { min-height: var(--tap); }
  :is(body.admin, body.login-page, body.hq) .btn-small { min-height: 40px; }
  :is(body.admin, body.login-page, body.hq) .btn-icon { width: var(--tap); min-width: var(--tap); }
}

/* =========================================================== page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-3) var(--s-4); flex-wrap: wrap; margin: 0 0 var(--s-5); }
.page-head h1 { margin: 0; font-size: var(--t-h1); }
.page-head .page-sub { margin: var(--s-1) 0 0; color: var(--c-muted); }
.page-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }
body.admin .admin-main > h1, body.admin .admin-main > .page-head h1 { font-size: var(--t-h1); }
@media (max-width: 600px) { body.admin .admin-main h1 { font-size: 1.75rem; } }

/* =========================================================== cards */
body.admin .panel, body.hq .hq-card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-3); }
.card-head h2 { margin: 0; font-size: var(--t-h2); }
.card-link { font-weight: 600; font-size: var(--t-small); text-decoration: none; white-space: nowrap; }
.card-link:hover { text-decoration: underline; }
/* A card whose title is a name (team, athlete, event) uses the display face. */
/* body.admin h2/h3 would otherwise put a heading .name-title / .ev-title back in Inter. */
.name-title, body.admin :is(h2, h3, h4).name-title { font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; line-height: 1.05; letter-spacing: .005em; margin: 0; }

/* Team card: crest (logo or initials) in a club-colored ring, name, role chip, and the next event strip. */
.team-card { display: block; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-xl); box-shadow: var(--sh-1); overflow: hidden; color: var(--c-ink); text-decoration: none; }
a.team-card:hover { box-shadow: var(--sh-2); }
.team-card-main { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4); }
.team-card-text { flex: 1; min-width: 0; }
.team-card-text .name-title { overflow-wrap: anywhere; }
.team-card-text small { display: block; color: var(--c-muted); }
.next-strip { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-4); background: var(--c-surface-alt); border-top: 1px solid var(--c-border); }
.next-strip strong { display: block; font-variant-numeric: tabular-nums; }
.next-strip .muted { font-size: var(--t-small); }
.next-strip.is-empty { color: var(--c-muted); font-size: var(--t-small); }

/* Avatar / crest: initials or an image, with a club-colored ring for identity. */
.avatar { flex: none; width: 48px; height: 48px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--club-primary, #0b2545); color: var(--club-primary-ink, #fff); font-weight: 700; font-size: 1rem; overflow: hidden; box-shadow: 0 0 0 2px var(--c-surface), 0 0 0 4px var(--club-primary, #0b2545); }
.avatar img { width: 100%; height: 100%; object-fit: cover; background: #fff; }
.avatar.sm { width: 32px; height: 32px; font-size: .8rem; box-shadow: none; }

/* =========================================================== KPI tiles */
.kpi-grid { display: grid; gap: var(--s-3); grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0 0 var(--s-5); }
@media (max-width: 900px) { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; padding: var(--s-4); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--sh-1); color: var(--c-ink); text-decoration: none; }
a.kpi { transition: box-shadow var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease); }
body.admin a.kpi { color: var(--c-ink); }
a.kpi:hover { border-color: var(--c-brand); box-shadow: var(--sh-2); }
.kpi-label { font-size: var(--t-small); font-weight: 600; color: var(--c-muted); }
.kpi-value { font-family: var(--font-display); font-weight: 700; font-size: var(--t-kpi); line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: .005em; overflow-wrap: normal; white-space: nowrap; }   /* "$20,748.28" never breaks mid-number (the phone size below makes it fit) */
.kpi-sub { font-size: var(--t-small); color: var(--c-muted); }
.kpi.tone-danger .kpi-value { color: var(--c-danger); }
.kpi.tone-ok .kpi-value { color: var(--c-ok); }
/* Two KPI tiles side by side on a phone: the number shrinks to fit instead of breaking. */
@media (max-width: 480px) { .kpi-value { font-size: clamp(1.25rem, 6.4vw, var(--t-kpi)); } }
.kpi.is-club { border-top: 4px solid var(--club-primary, var(--c-brand)); }   /* identity accent (family Pay card) */
/* With the club's colors on, every tile gets a thin top edge in the (readable) club color, and the date
   block's weekday is drawn in it. Off, both stay neutral. */
:root[data-app-brand="club"] .kpi:not(.is-club) { border-top: 3px solid var(--c-brand); }
:root[data-app-brand="club"] .date-block .db-dow { color: var(--c-link); }
/* "Hide amounts" while screen-sharing: put .amounts-hidden on any ancestor. */
.amounts-hidden .kpi-value.money, .amounts-hidden .money { filter: blur(8px); user-select: none; }
/* The old .stat tiles pick up the KPI number style. */
body.admin .stat strong { font-family: var(--font-display); font-weight: 700; font-size: 2rem; line-height: 1.05; font-variant-numeric: tabular-nums; letter-spacing: .005em; }
body.admin .stat { border-radius: var(--r-lg); }

/* Numbers in tables and lists: equal-width digits, right-aligned money. */
.num { font-variant-numeric: tabular-nums; text-align: right; }
.tnum { font-variant-numeric: tabular-nums; }

/* =========================================================== date block + event card */
.date-block { flex: none; width: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; line-height: 1.05; padding: var(--s-1) 0; }
.date-block .db-dow { font-size: var(--t-label); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--c-muted); }
.date-block .db-day { font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; font-variant-numeric: tabular-nums; color: var(--c-ink); }
.date-block .db-type { font-size: .6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--c-muted); margin-top: 2px; max-width: 56px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-card { --ev-edge: var(--club-primary, var(--c-brand)); display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s-1) var(--s-3); padding: var(--s-3) var(--s-4); background: var(--c-surface); border: 1px solid var(--c-border); border-left: 4px solid var(--ev-edge); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.ev-card .date-block { border-right: 1px solid var(--c-border); padding-right: var(--s-3); width: 68px; }
/* One flexible column: without the template the track took the min-content width of a long team chip (nowrap)
   and a 60-character team name pushed the whole page sideways on a phone. */
.ev-body { min-width: 0; display: grid; gap: 2px; align-content: center; grid-template-columns: minmax(0, 1fr); }
.ev-tags .team-chip { min-width: 0; }
/* A dialog titled with a long unbroken name (an athlete's surname) wraps instead of running off a phone screen. */
dialog h2, .ui-dialog h2 { overflow-wrap: anywhere; }
.ev-title, body.admin :is(h2, h3, h4).ev-title { font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; line-height: 1.1; margin: 0; overflow-wrap: anywhere; }
.ev-meta { color: var(--c-muted); font-size: var(--t-small); }
.ev-meta strong { color: var(--c-ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.ev-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; padding-top: var(--s-2); margin-top: var(--s-1); border-top: 1px solid var(--c-border); }
.ev-card.is-cancelled .ev-title { text-decoration: line-through; color: var(--c-muted); }
.ev-list { display: grid; gap: var(--s-3); }
.ev-group-head { display: flex; justify-content: space-between; align-items: baseline; margin: var(--s-5) 0 var(--s-2); }
.ev-group-head h3 { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; }
.ev-group-head .count { color: var(--c-muted); font-size: var(--t-small); font-weight: 600; }
/* Team tints (1..8 from Kit.teamTint) can color the edge instead of the club color. */
.ev-card[data-tint="1"] { --ev-edge: var(--team-1); } .ev-card[data-tint="2"] { --ev-edge: var(--team-2); }
.ev-card[data-tint="3"] { --ev-edge: var(--team-3); } .ev-card[data-tint="4"] { --ev-edge: var(--team-4); }
.ev-card[data-tint="5"] { --ev-edge: var(--team-5); } .ev-card[data-tint="6"] { --ev-edge: var(--team-6); }
.ev-card[data-tint="7"] { --ev-edge: var(--team-7); } .ev-card[data-tint="8"] { --ev-edge: var(--team-8); }

/* =========================================================== chips and badges */
/* Status chip: always words, never color alone. Tones: ok, warn, danger, info, neutral (default). */
/* :where() keeps this at one-class weight so the tone classes below (.chip.ok, .chip.danger ...) win. */
:where(body.admin, body.hq) .chip, .chip { display: inline-flex; align-items: center; gap: 4px; font-size: var(--t-label); line-height: 1.5; padding: 1px 9px; border-radius: var(--r-pill); background: var(--c-surface-alt); color: var(--c-muted); font-weight: 600; white-space: nowrap; }
.chip.ok, .chip.live { background: var(--c-ok-soft); color: var(--c-ok); }
.chip.warn, .chip.draft { background: var(--c-warn-soft); color: var(--c-warn-ink); }
.chip.danger { background: var(--c-danger-soft); color: var(--c-danger); }
.chip.info { background: var(--c-brand-soft); color: var(--c-link); }
/* A chip holding a sentence ("Not cleared: missing ...") wraps inside its box instead of pushing a phone screen sideways. */
.chip.chip-long { white-space: normal; max-width: 100%; overflow-wrap: anywhere; }
/* Team chip: fixed tint per team (Kit.teamTint), solid left edge, ink text: AA on every hue. */
.team-chip { --tc: var(--team-1); display: inline-flex; align-items: center; max-width: 100%; padding: 1px 8px 1px 6px; border-left: 3px solid var(--tc); border-radius: var(--r-sm); background: color-mix(in srgb, var(--tc) var(--tint), var(--c-surface)); color: var(--c-ink); font-size: var(--t-small); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-chip[data-tint="2"] { --tc: var(--team-2); } .team-chip[data-tint="3"] { --tc: var(--team-3); } .team-chip[data-tint="4"] { --tc: var(--team-4); }
.team-chip[data-tint="5"] { --tc: var(--team-5); } .team-chip[data-tint="6"] { --tc: var(--team-6); } .team-chip[data-tint="7"] { --tc: var(--team-7); } .team-chip[data-tint="8"] { --tc: var(--team-8); }
/* Count badge on a tab or nav item. Never truncated: short text ("12", "99+", "$40"). */
.count-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); background: var(--c-danger-fill); color: #fff; font-size: .72rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.count-badge.neutral { background: var(--c-brand); color: var(--c-brand-ink); }
/* A dot when a number would not fit or does not matter; it needs visually hidden text beside it. */
.dot-badge { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c-danger-fill); box-shadow: 0 0 0 2px var(--c-surface); }

/* =========================================================== tables */
body.admin .table th { font-size: var(--t-label); text-transform: uppercase; letter-spacing: .06em; color: var(--c-muted); font-weight: 600; background: var(--c-surface-alt); white-space: nowrap; }
body.admin .table td { font-size: var(--t-body); }
.table-wrap.sticky-head { max-height: 70vh; overflow: auto; }
.table-wrap.sticky-head thead th { position: sticky; top: 0; z-index: 1; }
/* Two-line cell: the main text and a muted second line (team under name, type under title). */
.cell-main { display: block; font-weight: 600; color: var(--c-ink); }
/* A .visually-hidden header label ("Actions") is absolutely positioned: without a positioned .table-wrap it escapes
   the scroll box and the whole page scrolls sideways. One unbroken 80-character name must not stretch its column. */
.table-wrap { position: relative; }
/* A ⋯ menu open in a table with nothing to scroll (ui-kit.js wireMenu): a passing state, so it beats every page's own
   overflow rule for its table (team-screens.css, admin.css flush panels). */
.table-wrap.menu-escape { overflow: visible !important; }
.table .cell-main, .table td.col-main { overflow-wrap: anywhere; }
a.cell-main { text-decoration: none; }
a.cell-main:hover { text-decoration: underline; }
.cell-sub { display: block; font-size: var(--t-small); color: var(--c-muted); }
.table .col-check { width: 40px; padding-right: 0; }
.table .col-menu { width: 48px; text-align: right; }
.table tr.is-selected td { background: var(--c-brand-soft); }
.table tr[data-href] { cursor: pointer; }
.table.comfortable td, .table.comfortable th { padding: 14px 16px; }
@media (pointer: coarse) { .table td, .table th { padding: 12px 12px; } }

/* Toolbar: [scope] [Filters (2)] 23 athletes ........ [search] [Bulk actions] [+ Add] */
.tbl-toolbar { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; margin: 0 0 var(--s-3); }
.tbl-toolbar .tb-count { color: var(--c-muted); font-size: var(--t-small); font-weight: 600; white-space: nowrap; }
.tbl-toolbar .tb-spacer { flex: 1 1 auto; }
.tbl-toolbar .tb-search { width: 220px; max-width: 100%; }
.tbl-toolbar select { width: auto; min-width: 0; max-width: 100%; }   /* a long team name in a filter must not widen the page */
.tbl-toolbar { min-width: 0; max-width: 100%; }
.tbl-toolbar .tb-filters .count-badge { background: var(--c-brand); color: var(--c-brand-ink); }
@media (max-width: 640px) { .tbl-toolbar .tb-search { flex: 1 1 100%; width: auto; order: 10; } .tbl-toolbar .tb-spacer { display: none; } }
/* Active filters as removable chips under the toolbar. */
.filter-chips { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: 0 0 var(--s-3); }
.filter-chip { display: inline-flex; align-items: center; gap: 2px; padding: 0 2px 0 10px; min-height: 30px; border: 1px solid var(--c-border-strong); border-radius: var(--r-pill); background: var(--c-surface); color: var(--c-ink); font-size: var(--t-small); font-weight: 500; }
.filter-chip button { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border: 0; border-radius: 50%; background: none; color: var(--c-muted); font: inherit; font-size: 1rem; cursor: pointer; }
.filter-chip button:hover { background: var(--c-surface-hover); color: var(--c-ink); }
.filter-chips .clear-all { font-size: var(--t-small); }

/* Selection bar: takes the toolbar's place while rows are ticked. */
.sel-bar { position: sticky; top: var(--sticky-top, 0); z-index: 6; display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; margin: 0 0 var(--s-3); padding: var(--s-2) var(--s-3); min-height: 48px; background: var(--c-brand-soft); color: var(--c-ink); border: 1px solid color-mix(in srgb, var(--c-brand) 35%, transparent); border-radius: var(--r-md); }
.sel-bar[hidden] { display: none; }
.sel-bar .sel-count { font-weight: 700; margin-right: var(--s-2); font-variant-numeric: tabular-nums; }
.sel-bar .sel-clear { margin-left: auto; }

/* Row actions: one primary action is the row link; the rest sit in a ⋯ menu (Kit.rowMenu). */
.menu-wrap { position: relative; display: inline-block; }
.row-menu-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 1px solid transparent; border-radius: var(--r-md); background: none; color: var(--c-muted); font: inherit; font-size: 1.25rem; line-height: 1; cursor: pointer; }
.row-menu-btn:hover, .row-menu-btn[aria-expanded="true"] { background: var(--c-surface-hover); color: var(--c-ink); border-color: var(--c-border); }
@media (pointer: coarse) { .row-menu-btn { width: var(--tap); height: var(--tap); } }
.menu { position: absolute; z-index: 60; top: calc(100% + 4px); right: 0; min-width: 200px; max-width: min(320px, calc(100vw - 32px)); padding: var(--s-1); background: var(--c-surface); color: var(--c-ink); border: 1px solid var(--c-border); border-radius: var(--r-md); box-shadow: var(--sh-3); text-align: left; animation: kit-pop var(--dur-fast) var(--ease); }
.menu[hidden] { display: none; }
.menu.up { top: auto; bottom: calc(100% + 4px); }
.menu [role="menuitem"] { display: flex; align-items: center; gap: var(--s-2); width: 100%; min-height: 40px; padding: 8px 12px; border: 0; border-radius: var(--r-sm); background: none; color: var(--c-ink); font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.menu [role="menuitem"]:hover, .menu [role="menuitem"]:focus { background: var(--c-surface-hover); outline: none; }
.menu [role="menuitem"]:focus-visible { box-shadow: inset 0 0 0 2px var(--c-focus); }
.menu [role="menuitem"].danger { color: var(--c-danger); }
.menu hr { border: 0; border-top: 1px solid var(--c-border); margin: var(--s-1) 0; }
@keyframes kit-pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* Phone card rows: a table becomes one card per row under 640px (cells need data-label). Same idea as the
   older .table-stack; use .table-cards on new tables. */
@media (max-width: 640px) {
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards thead { display: none; }
  .table-cards tr { position: relative; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--c-border); }
  .table-cards td { padding: 2px 0; border: 0; text-align: left; }
  .table-cards td[data-label]::before { content: attr(data-label) ": "; color: var(--c-muted); font-size: var(--t-small); }
  .table-cards td.col-main::before, .table-cards td.col-check::before, .table-cards td.col-menu::before { content: none; }
  .table-cards td.col-check { position: absolute; left: var(--s-4); top: var(--s-3); width: auto; }
  .table-cards tr:has(td.col-check) { padding-left: 52px; }
  .table-cards td.col-menu { position: absolute; right: var(--s-2); top: var(--s-2); width: auto; }
  .table-cards tr:has(td.col-menu) { padding-right: 56px; }
  .table-cards td:empty { display: none; }
}

/* =========================================================== empty states */
/* Inside the card, not a dashed grey box: icon, one-line headline, one sentence, one next action. */
.empty-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s-2); padding: var(--s-8) var(--s-4); color: var(--c-ink); }
.empty-card .empty-icon { width: 40px; height: 40px; color: var(--c-muted); stroke-width: 1.5; }
.empty-card .empty-title { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; line-height: 1.1; color: var(--c-ink); }
.empty-card .empty-text { margin: 0; max-width: 46ch; color: var(--c-muted); }
.empty-card .empty-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; justify-content: center; margin-top: var(--s-2); }
.empty-card.compact { padding: var(--s-5) var(--s-3); }
.empty-card.compact .empty-title { font-size: 1.2rem; }

/* =========================================================== forms */
body.admin .field, body.login-page .field { display: block; margin-bottom: var(--s-4); }
body.admin .field > span:first-child, body.login-page .field > span:first-child, .field-label { display: block; font-weight: 600; font-size: .875rem; margin-bottom: var(--s-1); color: var(--c-ink); }
:is(body.admin, body.login-page) :is(input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="search"], input[type="number"], input[type="date"], input[type="time"], input[type="datetime-local"], input[type="tel"], select) { min-height: 40px; border-radius: var(--r-md); }
:is(body.admin, body.login-page) textarea { border-radius: var(--r-md); }
@media (pointer: coarse) { :is(body.admin, body.login-page) :is(input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="search"], input[type="number"], input[type="date"], input[type="time"], input[type="datetime-local"], input[type="tel"], select) { min-height: var(--tap); } }
.field-help { display: block; margin-top: var(--s-1); font-size: var(--t-small); color: var(--c-muted); }
.field-error { display: flex; gap: 6px; align-items: baseline; margin-top: var(--s-1); font-size: var(--t-small); font-weight: 600; color: var(--c-danger); }
.field-error::before { content: "!"; flex: none; display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; background: var(--c-danger-fill); color: #fff; font-size: .7rem; font-weight: 800; }
.field-error:empty { display: none; }
/* "(required)" after a field's label (Kit.markRequired): said in words, not only with a symbol. */
.req-mark { font-weight: 400; color: var(--c-muted); font-size: var(--t-small); }
/* A page's error repeated at the top of an open sheet or dialog (UI.say), so it is not hidden behind the backdrop. */
.dialog-status:empty { display: none; }
.dialog-status { margin: 0 0 var(--s-3); }
:is(body.admin, body.login-page) [aria-invalid="true"] { border-color: var(--c-danger) !important; box-shadow: 0 0 0 1px var(--c-danger); }
.form-section { border: 0; padding: 0; margin: 0 0 var(--s-6); }
.form-section > legend, .form-section > h3 { font-weight: 600; font-size: var(--t-h3); margin-bottom: var(--s-3); padding: 0; }
/* Sticky footer for long forms: Back (left) ... Save draft, Primary (right). */
.form-footer { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; margin: var(--s-4) calc(-1 * var(--s-5)) 0; padding: var(--s-3) var(--s-5); background: var(--c-surface); border-top: 1px solid var(--c-border); }
.form-footer .spacer { flex: 1; }

/* =========================================================== dialogs and sheets */
body.admin dialog, body.login-page dialog { border: 1px solid var(--c-border); border-radius: var(--r-xl); padding: var(--s-6); background: var(--c-surface); color: var(--c-ink); box-shadow: var(--sh-3); }
body.admin dialog::backdrop, body.login-page dialog::backdrop { background: var(--c-scrim); }
body.admin dialog[open] { animation: kit-pop var(--dur-fast) var(--ease); }
body.admin dialog > h2:first-child { margin-top: 0; font-size: var(--t-h2); }
/* Buttons: secondary left, primary right; a destructive primary is .btn-danger and names the verb + count. */
.dialog-actions { display: flex; gap: var(--s-2); justify-content: flex-end; flex-wrap: wrap; margin-top: var(--s-5); }
.dialog-actions .spacer { flex: 1; }
@media (max-width: 600px) {
  /* Phones: dialogs are bottom sheets with a grab-handle look. */
  body.admin dialog:not(.qs-dialog), body.login-page dialog:not(.qs-dialog) { padding-top: calc(var(--s-6) + 6px); border-radius: var(--r-xl) var(--r-xl) 0 0; max-height: 92vh; }
  body.admin dialog:not(.qs-dialog)::before, body.login-page dialog:not(.qs-dialog)::before { content: ""; position: absolute; top: 8px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--c-border-strong); }
  .dialog-actions { position: sticky; bottom: calc(-1 * var(--s-6)); background: var(--c-surface); padding: var(--s-3) 0 var(--s-4); margin-bottom: calc(-1 * var(--s-6)); }
  .dialog-actions .btn { flex: 1 1 auto; }
}
/* Right-hand sheet (filters, editors): Kit.sheet(). Becomes a bottom sheet on phones. */
body.admin dialog.sheet { margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(420px, 100vw); max-width: none; border-radius: 0; border-width: 0 0 0 1px; padding: 0; display: none; flex-direction: column; animation: kit-slide var(--dur-med) var(--ease); }
body.admin dialog.sheet[open] { display: flex; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--c-border); }
.sheet-head h2 { margin: 0; font-size: var(--t-h2); }
.sheet-body { flex: 1; overflow: auto; padding: var(--s-5); }
.sheet-foot { display: flex; gap: var(--s-2); justify-content: flex-end; padding: var(--s-3) var(--s-5); border-top: 1px solid var(--c-border); }
@keyframes kit-slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 600px) {
  body.admin dialog.sheet { margin: auto 0 0; width: 100%; height: auto; max-height: 92vh; border-radius: var(--r-xl) var(--r-xl) 0 0; border-width: 1px 0 0; padding-top: 10px; animation-name: kit-pop; }
}

/* =========================================================== tabs and segmented control */
/* Underline tabs (role="tablist", buttons role="tab" aria-selected). Scrolls sideways with a fade, never clips. */
.tabbar { display: flex; gap: var(--s-1); overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--c-border); margin: 0 0 var(--s-4); -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent); padding-right: 24px; }
.tabbar::-webkit-scrollbar { display: none; }
.tabbar > :is(button, a) { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); padding: 0 var(--s-3); border: 0; border-bottom: 3px solid transparent; background: none; color: var(--c-muted); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.tabbar > :is(button, a):hover { color: var(--c-ink); }
.tabbar > [aria-selected="true"], .tabbar > [aria-current="page"], .tabbar > .on { color: var(--c-ink); border-bottom-color: var(--c-brand); }
/* Segmented control (List / Calendar, Upcoming / Past): buttons with aria-pressed, or role="tab" + aria-selected. */
.seg-control { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r-pill); background: var(--c-surface-alt); border: 1px solid var(--c-border); max-width: 100%; overflow-x: auto; }
.seg-control > button { flex: none; min-height: 34px; padding: 0 var(--s-4); border: 0; border-radius: var(--r-pill); background: none; color: var(--c-muted); font: inherit; font-weight: 600; font-size: .875rem; cursor: pointer; white-space: nowrap; }
.seg-control > button:hover { color: var(--c-ink); }
.seg-control > button[aria-pressed="true"], .seg-control > button[aria-selected="true"] { background: var(--c-surface); color: var(--c-ink); box-shadow: var(--sh-1), 0 0 0 1px var(--c-border); }
@media (pointer: coarse) { .seg-control > button { min-height: 40px; } }

/* =========================================================== floating action button (phone only) */
.fab { position: fixed; right: var(--s-4); bottom: calc(var(--s-4) + var(--tabbar-h, 0px) + env(safe-area-inset-bottom, 0px)); z-index: 35; display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-width: 56px; height: 56px; padding: 0 var(--s-4); border: 0; border-radius: var(--r-pill); background: var(--c-energy); color: var(--c-on-energy); font: inherit; font-weight: 700; box-shadow: var(--sh-3); cursor: pointer; text-decoration: none; }
body.admin a.fab { color: var(--c-on-energy); }
.fab .icon { width: 24px; height: 24px; }
@media (min-width: 761px) { .fab { display: none; } }

/* =========================================================== small helpers */
.stack { display: grid; gap: var(--s-3); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (prefers-reduced-motion: reduce) {
  .menu, body.admin dialog[open], body.admin dialog.sheet { animation: none; }
  :is(body.admin, body.login-page, body.hq) .btn { transition: none; }
}

/* Fields line up with 40px buttons in a toolbar (base.css pads them for the public site's larger text). */
:is(body.admin, body.login-page) :is(input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="search"], input[type="number"], input[type="date"], input[type="time"], input[type="datetime-local"], input[type="tel"], select) { padding-top: 7px; padding-bottom: 7px; }
/* Quick search (Ctrl K) keeps its compact frame. */
body.admin dialog.qs-dialog { padding: var(--s-3); border-radius: var(--r-lg); }

/* =========================================================== copy the look from a website (web/js/look-import.js) */
.look-import .look-row { display: flex; gap: var(--s-2); align-items: flex-end; flex-wrap: wrap; }
.look-import .look-row .field { flex: 1 1 240px; margin: 0; }
.look-card { margin-top: var(--s-3); }
.look-card h3 { margin: 0 0 var(--s-3); }
.look-card h4 { margin: 0 0 var(--s-2); font-size: var(--t-small); text-transform: uppercase; letter-spacing: .06em; color: var(--c-muted); }
.look-bar { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 var(--s-4); border-radius: var(--r-md); margin-bottom: var(--s-4); }
.look-bar strong { font-family: var(--font-display); font-size: 1.3rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.look-bar-mark { width: 28px; height: 28px; border-radius: var(--r-sm); background: color-mix(in srgb, currentColor 20%, transparent); flex: none; }
.look-grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.look-swatch { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-2); }
.look-swatch input[type="color"] { width: 44px; height: 44px; padding: 2px; border: 1px solid var(--c-border-strong); border-radius: var(--r-sm); background: var(--c-surface); flex: none; }
.look-swatch span { display: flex; flex-direction: column; font-size: var(--t-small); }
.look-swatch code { color: var(--c-muted); }
.look-logo { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-2); }
.look-logo-img { max-width: 100%; max-height: 96px; object-fit: contain; background: #fff; padding: 6px; border: 1px solid var(--c-border); border-radius: var(--r-md); }
.look-fonts p { margin: 0 0 var(--s-1); }
.look-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-2); margin-top: var(--s-4); }
@media (max-width: 600px) { .look-actions > * { flex: 1 1 100%; } }
