/* PaxOnBoard components. Plain CSS classes that the Svelte kit renders and the hosted booking page shares.
   Every component here is shown in ui/design/styleguide.html and specified in docs/design-standards.md.
   Rules: tokens only, logical properties only, no fixed widths around text, every state visible without colour alone.
   Contents: 1 buttons · 2 fields and forms · 3 choices (check, radio, switch, segmented, choice cards) · 4 tabs ·
   5 accordion · 6 tables · 7 chips and counts · 8 cards and panels · 9 dialogs and sheets · 10 alerts and toasts ·
   11 stat tiles and the capacity meter · 12 date picker · 13 time picker and slots · 14 app shell and navigation ·
   15 lists and avatars · 16 steps, pager, menu, tooltip · 17 empty states, skeletons, spinner · 18 print */

/* ---- 1. Buttons ------------------------------------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--control-h);
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid transparent;
  border-radius: var(--r-control);
  background: var(--surface-2);
  color: var(--fg);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-1) var(--ease-out), color var(--dur-1), border-color var(--dur-1),
              box-shadow var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out), filter var(--dur-1);
}
/* :where keeps this at the rank of the variants below, so a variant's own background (the primary gradient) is not replaced on hover */
:where(.btn):hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn .icon { color: inherit; }

.btn-primary {
  background: var(--grad-accent);
  color: var(--accent-fg);
  box-shadow: var(--shadow-1);
}
.btn-primary:hover { filter: brightness(1.07); transform: translateY(-1px); box-shadow: var(--shadow-2); }
.btn-primary:active { filter: brightness(0.96); transform: translateY(0); box-shadow: var(--shadow-1); }

.btn-pop {
  background: var(--grad-pop);
  color: var(--pop-fg);
  box-shadow: var(--shadow-1);
}
.btn-pop:hover { filter: brightness(1.05); transform: translateY(-1px); box-shadow: var(--shadow-2); }
.btn-pop:active { filter: brightness(0.97); transform: translateY(0); }

.btn-tonal { background: var(--accent-soft); color: var(--accent-text); }
.btn-tonal:hover { box-shadow: inset 0 0 0 999px rgb(var(--shadow-rgb) / 0.05); }

.btn-outline { background: transparent; border-color: var(--border-strong); color: var(--fg); }
.btn-outline:hover { background: var(--surface-2); }

.btn-ghost { background: transparent; color: var(--accent-text); }
.btn-ghost:hover { background: var(--accent-soft); }

.btn-danger { background: var(--bad); color: var(--bad-fg); }
.btn-danger:hover { filter: brightness(1.08); }
.btn-danger-soft { background: var(--bad-soft); color: var(--bad-text); }
.btn-danger-soft:hover { box-shadow: inset 0 0 0 999px rgb(var(--shadow-rgb) / 0.05); }

.btn-sm { min-height: var(--control-h-sm); padding: var(--sp-1) var(--sp-3); font-size: var(--fs-sm); border-radius: var(--r-sm); gap: var(--sp-1); }
.btn-lg { min-height: var(--control-h-lg); padding: var(--sp-3) var(--sp-6); font-size: var(--fs-lg); border-radius: var(--r-md); }
.btn-icon { width: var(--control-h); padding: 0; flex: none; }
.btn-icon.btn-sm { width: var(--control-h-sm); }
.btn-icon.btn-lg { width: var(--control-h-lg); }
.btn-round { border-radius: var(--r-pill); }
.btn-block { display: flex; width: 100%; }

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  filter: none;
}
.btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent); }

/* Loading: the label stays in place (no width jump) but is hidden; a spinner sits over it. */
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 1.1em;
  height: 1.1em;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-block-start-color: var(--fg);
  animation: spin 0.8s linear infinite;
}
.btn-primary.is-loading::after { border-color: rgb(var(--shadow-rgb) / 0.25); border-block-start-color: var(--accent-fg); }

/* A row of buttons that act as one control (view switches). */
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-start-start-radius: var(--r-control); border-end-start-radius: var(--r-control); }
.btn-group .btn:last-child { border-start-end-radius: var(--r-control); border-end-end-radius: var(--r-control); }
.btn-group .btn + .btn { margin-inline-start: -1px; }

/* ---- 2. Fields and forms -------------------------------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.field-label {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--fg);
  line-height: var(--lh-snug);
}
/* The asterisk is written inside the label's last word with a no-break space ("Name&nbsp;*"), so it never wraps alone. */
.req { color: var(--bad-text); font-weight: var(--fw-bold); white-space: nowrap; }
.field-label .optional { color: var(--hint); font-weight: var(--fw-regular); }
.field-label .btn-help { margin-inline-start: auto; }

.input {
  width: 100%;
  min-height: var(--control-h);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--fg);
  font-size: var(--fs-md);
  line-height: 1.3;
  appearance: none;
  transition: border-color var(--dur-1), box-shadow var(--dur-1), background var(--dur-1);
}
.input::placeholder { color: var(--hint); opacity: 1; }
.input:hover { border-color: var(--border-strong); }
.input:focus-visible { border-color: var(--accent); outline-offset: 1px; }
.input:disabled, .input[readonly] { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.input[readonly] { cursor: default; }
textarea.input { min-height: calc(var(--control-h) * 2.4); line-height: var(--lh-body); resize: vertical; }
.input[aria-invalid="true"] { border-color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad); }
.input-sm { min-height: var(--control-h-sm); font-size: var(--fs-sm); padding-block: var(--sp-1); border-radius: var(--r-sm); }
.input-lg { min-height: var(--control-h-lg); font-size: var(--fs-lg); }
.input-code { font-family: var(--font-mono); letter-spacing: 0.08em; }
.input-short { width: 7em; }      /* numbers, times, codes: the only inputs with a width */
.input-tiny { width: 4.5em; text-align: center; }

.field-help { font-size: var(--fs-sm); color: var(--muted); }
.field-error {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-1);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--bad-text);
}
.field-error .icon { width: var(--icon-sm); height: var(--icon-sm); margin-block-start: 0.15em; }
.field-ok { color: var(--ok-text); }

/* An input with an icon at its start, or a button at its end (clear, show PIN, open calendar). */
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > .icon { position: absolute; inset-inline-start: var(--sp-3); color: var(--muted); pointer-events: none; }
.input-wrap > .icon ~ .input { padding-inline-start: calc(var(--sp-3) * 2 + var(--icon)); }
.input-wrap > .btn-icon { position: absolute; inset-inline-end: 0.2rem; width: calc(var(--control-h) - 0.4rem); min-height: calc(var(--control-h) - 0.4rem); }
.input-wrap > .btn-icon ~ .input, .input-wrap.has-end > .input { padding-inline-end: calc(var(--control-h) + var(--sp-1)); }

/* Prefix and suffix cells: a currency, a unit, a fixed code. */
.input-group { display: flex; align-items: stretch; }
.input-group > .input { flex: 1; min-width: 0; border-radius: 0; }
.input-group > :first-child { border-start-start-radius: var(--r-control); border-end-start-radius: var(--r-control); }
.input-group > :last-child { border-start-end-radius: var(--r-control); border-end-end-radius: var(--r-control); }
.input-group > * + * { margin-inline-start: -1px; }
.input-affix {
  display: inline-flex;
  align-items: center;
  padding: 0 var(--sp-3);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--fs-sm);
  white-space: nowrap;
}
.input-group > .input:focus-visible { position: relative; z-index: 1; }

/* Selects keep the native menu (it is the best one on phones) and get our chevron. */
.select { position: relative; display: flex; }
.select > .input { padding-inline-end: calc(var(--sp-3) * 2 + var(--icon)); cursor: pointer; }
.select > .icon { position: absolute; inset-inline-end: var(--sp-3); inset-block-start: 50%; translate: 0 -50%; color: var(--muted); pointer-events: none; }

/* Form layout: one column; two for short related fields from tablet width up. */
.form { display: flex; flex-direction: column; gap: var(--sp-5); max-width: var(--form-max); }
.form-grid { display: grid; gap: var(--sp-5) var(--sp-4); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 48em) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .form-grid > .span-2 { grid-column: span 2; }
  .form-grid > .span-all { grid-column: 1 / -1; }
}
.form-section { display: flex; flex-direction: column; gap: var(--sp-4); }
.form-section + .form-section { padding-block-start: var(--sp-5); border-block-start: 1px solid var(--line); }
.form-section > legend, .form-section-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); margin-block-end: var(--sp-1); }
.form-note { font-size: var(--fs-sm); color: var(--muted); }
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  justify-content: flex-end;
  padding-block-start: var(--sp-2);
}
.form-actions > .start { margin-inline-end: auto; }
@media (max-width: 30em) {
  .form-actions.is-sticky {
    position: sticky;
    inset-block-end: 0;
    z-index: var(--z-sticky);
    margin-inline: calc(var(--gutter) * -1);
    padding: var(--sp-3) var(--gutter) calc(var(--sp-3) + env(safe-area-inset-bottom));
    background: var(--bg);
    border-block-start: 1px solid var(--line);
  }
  .form-actions .btn { flex: 1 1 auto; }
  .form-actions > .start { flex-basis: 100%; margin: 0; }
}

/* ---- 3. Choices: check, radio, switch, segmented, choice cards -------------------------------------------------- */

.check, .radio {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--sp-3);
  min-height: var(--control-h-sm);
  padding-block: var(--sp-1);
  cursor: pointer;
  line-height: var(--lh-snug);
}
.check input, .radio input {
  appearance: none;
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0.1em 0 0;
  border: 2px solid var(--border-strong);
  border-radius: var(--r-xs);
  background: var(--surface);
  display: grid;
  place-content: center;
  cursor: pointer;
  transition: background var(--dur-1), border-color var(--dur-1), box-shadow var(--dur-1);
}
.radio input { border-radius: 50%; }
.check input::before, .radio input::before {
  content: "";
  width: 0.7rem;
  height: 0.7rem;
  background: var(--accent-fg);
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
  transform: scale(0);
  transition: transform var(--dur-2) var(--ease-pop);
}
.radio input::before { width: 0.55rem; height: 0.55rem; border-radius: 50%; clip-path: none; }
.check input:checked, .radio input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::before, .radio input:checked::before { transform: scale(1); }
.check input:indeterminate { background: var(--accent); border-color: var(--accent); }
.check input:indeterminate::before { transform: scale(1); clip-path: inset(40% 12% 40% 12%); }
.check input:hover, .radio input:hover { border-color: var(--accent); }
.check input:disabled, .radio input:disabled { opacity: 0.5; cursor: not-allowed; }
.check:has(input:disabled), .radio:has(input:disabled) { color: var(--muted); cursor: not-allowed; }
.choice-text { display: flex; flex-direction: column; gap: 0.1em; }
.choice-text small { color: var(--muted); }
.choice-list { display: flex; flex-direction: column; gap: var(--sp-1); }
.choice-list.inline { flex-direction: row; flex-wrap: wrap; gap: var(--sp-1) var(--sp-6); }

.switch { display: inline-flex; align-items: center; gap: var(--sp-3); min-height: var(--control-h-sm); cursor: pointer; }
.switch input {
  appearance: none;
  position: relative;
  flex: none;
  width: 2.75rem;
  height: 1.5rem;
  border-radius: var(--r-pill);
  background: var(--border);
  cursor: pointer;
  transition: background var(--dur-2);
}
.switch input::before {
  content: "";
  position: absolute;
  inset-block-start: 0.125rem;
  inset-inline-start: 0.125rem;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-1);
  transition: inset-inline-start var(--dur-2) var(--ease-out);
}
.switch input:checked { background: var(--grad-accent); }
.switch input:checked::before { inset-inline-start: calc(100% - 1.375rem); }
.switch input:disabled { opacity: 0.5; cursor: not-allowed; }

/* Segmented control: a radio group that looks like one pill. Two to five short options. */
.segmented {
  display: inline-flex;
  max-width: 100%;
  padding: 0.25rem;
  gap: 0.25rem;
  border-radius: var(--r-control);
  background: var(--surface-3);
  overflow-x: auto;
  scrollbar-width: none;
}
.segmented label {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: calc(var(--control-h) - 0.5rem);
  padding: 0 var(--sp-4);
  border-radius: calc(var(--r-control) - 0.2rem);
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur-2) var(--ease-out), color var(--dur-1), box-shadow var(--dur-2);
}
.segmented input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.segmented label:hover { color: var(--fg); }
.segmented label:has(input:checked) { background: var(--surface); color: var(--accent-text); box-shadow: var(--shadow-1); }
.segmented label:has(input:focus-visible) { outline: var(--focus-w) solid var(--focus); outline-offset: 1px; }
.segmented.is-full { display: flex; }
.segmented.is-full label { flex: 1; }

/* Choice cards: a radio or checkbox as a card, for products, packages, payment methods. */
.choice-cards { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr)); }
.choice-card {
  position: relative;
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  padding: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--dur-1), background var(--dur-2), box-shadow var(--dur-2), transform var(--dur-2) var(--ease-out);
}
.choice-card input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.choice-card:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow-1); }
.choice-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.choice-card:has(input:focus-visible) { outline: var(--focus-w) solid var(--focus); outline-offset: var(--focus-offset); }
.choice-card:has(input:disabled) { opacity: 0.55; cursor: not-allowed; transform: none; }
.choice-card > .icon { color: var(--accent-text); margin-block-start: 0.1em; }
.choice-card-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.15em; }
.choice-card-title { font-weight: var(--fw-semibold); }
.choice-card-meta { font-size: var(--fs-sm); color: var(--muted); }
.choice-card-end { font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; white-space: nowrap; }
.choice-card .check-mark {
  width: 1.25rem; height: 1.25rem; flex: none;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  display: grid; place-content: center;
  color: var(--accent-fg);
  transition: background var(--dur-1), border-color var(--dur-1);
}
.choice-card .check-mark .icon { width: 0.8rem; height: 0.8rem; stroke-width: 3; opacity: 0; transition: opacity var(--dur-1); }
.choice-card:has(input:checked) .check-mark { background: var(--accent); border-color: var(--accent); }
.choice-card:has(input:checked) .check-mark .icon { opacity: 1; }

/* ---- 4. Tabs ------------------------------------------------------------------------------------------------------ */

.tabs {
  display: flex;
  gap: var(--sp-1);
  border-block-end: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: var(--control-h);
  padding: 0 var(--sp-4);
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  color: var(--muted);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--dur-1), background var(--dur-1);
}
.tab:hover { color: var(--fg); background: var(--surface-2); }
.tab[aria-selected="true"] { color: var(--accent-text); }
.tab::after {
  content: "";
  position: absolute;
  inset-inline: var(--sp-2);
  inset-block-end: -1px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--grad-accent);
  transform: scaleX(0);
  transition: transform var(--dur-2) var(--ease-out);
}
.tab[aria-selected="true"]::after { transform: scaleX(1); }
.tab-panel { padding-block: var(--sp-5); }
.tabs-pills { border: 0; gap: var(--sp-2); }
.tabs-pills .tab { min-height: var(--control-h-sm); border-radius: var(--r-pill); font-size: var(--fs-sm); }
.tabs-pills .tab::after { display: none; }
.tabs-pills .tab[aria-selected="true"] { background: var(--accent-soft); }
.tabs-full .tab { flex: 1; justify-content: center; }

/* ---- 5. Accordion ------------------------------------------------------------------------------------------------- */

.accordion {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  overflow: clip;
}
.accordion > details + details { border-block-start: 1px solid var(--line); }
.accordion summary {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--row-h);
  padding: var(--sp-3) var(--sp-5);
  list-style: none;
  font-weight: var(--fw-semibold);
  transition: background var(--dur-1), color var(--dur-1);
}
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary:hover { background: var(--row-hover); }
.accordion summary .chev { margin-inline-start: auto; color: var(--muted); transition: transform var(--dur-2) var(--ease-out); }
.accordion details[open] > summary { color: var(--accent-text); }
.accordion details[open] > summary .chev { transform: rotate(180deg); }
.accordion summary .summary-meta { color: var(--muted); font-weight: var(--fw-regular); font-size: var(--fs-sm); }
.accordion-body { padding: 0 var(--sp-5) var(--sp-5); }
.accordion-body > * + * { margin-block-start: var(--sp-3); }

/* ---- 6. Tables ---------------------------------------------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); }
.table th, .table td {
  padding: var(--sp-3) var(--sp-4);
  text-align: start;
  vertical-align: middle;
  border-block-end: 1px solid var(--line);
}
.table thead th {
  position: sticky;
  inset-block-start: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  white-space: nowrap;
}
.table tbody tr { height: var(--row-h); }
.table tbody td { background: var(--surface); transition: background var(--dur-1); }
.table tbody tr:hover td { background: var(--row-hover); }
.table tbody tr:last-child td { border-block-end: 0; }
.table tr.is-selected td { background: var(--accent-soft); }
.table tr.is-selected td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
[dir="rtl"] .table tr.is-selected td:first-child { box-shadow: inset -3px 0 0 var(--accent); }
.table tr.is-muted td { color: var(--muted); }
.table tr.is-cancelled td { color: var(--muted); text-decoration: line-through; }
.table .num { text-align: end; font-variant-numeric: tabular-nums; }
.table .td-title { font-weight: var(--fw-semibold); font-size: var(--fs-md); color: var(--fg); }
.table .td-sub { display: block; color: var(--muted); font-size: var(--fs-xs); font-weight: var(--fw-regular); }
.table tfoot td { background: var(--surface-2); font-weight: var(--fw-semibold); border-block-start: 2px solid var(--line); border-block-end: 0; }
.table-zebra tbody tr:nth-child(even) td { background: rgb(var(--shadow-rgb) / 0.025); }
.table-zebra tbody tr:hover td { background: var(--row-hover); }
.table-compact th, .table-compact td { padding: var(--sp-2) var(--sp-3); }
.table-compact tbody tr { height: var(--control-h); }
.table .row-actions { display: flex; gap: var(--sp-1); justify-content: flex-end; }
@media (hover: hover) {
  .table .row-actions .btn { opacity: 0; transition: opacity var(--dur-1); }
  .table tr:hover .row-actions .btn, .table tr:focus-within .row-actions .btn { opacity: 1; }
}
.th-sort { display: inline-flex; align-items: center; gap: var(--sp-1); color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; }
.th-sort .icon { width: var(--icon-sm); height: var(--icon-sm); opacity: 0.5; }
.th-sort[aria-sort] .icon { opacity: 1; color: var(--accent-text); }
.th-sort[aria-sort="descending"] .icon { transform: rotate(180deg); }
.table-sticky-col th:first-child, .table-sticky-col td:first-child {
  position: sticky;
  inset-inline-start: 0;
  z-index: 2;
  box-shadow: 1px 0 0 var(--line);
}
.table-sticky-col thead th:first-child { z-index: 3; }
.table-caption { padding: var(--sp-3) var(--sp-4); font-size: var(--fs-sm); color: var(--muted); text-align: start; caption-side: bottom; }

/* The card pattern: below tablet width a list table turns into stacked cards, each cell labelled by data-label. */
@media (max-width: 47.99em) {
  .table-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; }
  .table-cards tbody tr { height: auto; padding: var(--sp-3) var(--sp-4); border-block-end: 1px solid var(--line); }
  .table-cards tbody tr:last-child { border-block-end: 0; }
  .table-cards td { display: grid; grid-template-columns: minmax(5.5rem, 38%) 1fr; gap: var(--sp-3); padding: var(--sp-1) 0; border: 0; background: transparent !important; }
  .table-cards td::before { content: attr(data-label); color: var(--muted); font-size: var(--fs-2xs); font-weight: var(--fw-semibold); letter-spacing: var(--ls-caps); text-transform: uppercase; padding-block-start: 0.2em; }
  .table-cards td.num { text-align: start; }
  .table-cards td.td-title { grid-template-columns: 1fr; padding-block-end: var(--sp-2); }
  .table-cards td.td-title::before, .table-cards td.no-label::before { display: none; }
  .table-cards td.no-label { grid-template-columns: 1fr; }
  .table-cards .row-actions { justify-content: flex-start; padding-block-start: var(--sp-2); }
  .table-cards .row-actions .btn { opacity: 1; }
  .table-cards tfoot { display: block; }
  .table-cards tfoot tr { display: flex; justify-content: space-between; padding: var(--sp-3) var(--sp-4); }
  .table-cards tfoot td { padding: 0; border: 0; }
  .table-cards tr.is-selected { background: var(--accent-soft); }
  .table-cards tr.is-selected td:first-child { box-shadow: none; }
}

/* ---- 7. Chips, tags and counts ---------------------------------------------------------------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  min-height: 1.5rem;
  padding: 0.1rem var(--sp-2);
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--fg);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  line-height: 1.2;
  letter-spacing: 0.01em;
  white-space: nowrap;
  vertical-align: middle;
}
.chip .icon { width: var(--icon-sm); height: var(--icon-sm); }
.chip-dot::before { content: ""; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: currentColor; flex: none; }
.chip-ok { background: var(--ok-soft); color: var(--ok-text); }
.chip-warn { background: var(--warn-soft); color: var(--warn-text); }
.chip-bad { background: var(--bad-soft); color: var(--bad-text); }
.chip-info { background: var(--info-soft); color: var(--info-text); }
.chip-accent { background: var(--accent-soft); color: var(--accent-text); }
.chip-pop { background: var(--pop-soft); color: var(--pop-text); }
.chip-solid.chip-ok { background: var(--ok); color: var(--accent-fg); }
.chip-solid.chip-warn { background: var(--warn); color: var(--accent-fg); }
.chip-solid.chip-bad { background: var(--bad); color: var(--bad-fg); }
.chip-solid.chip-info { background: var(--info); color: var(--accent-fg); }
.chip-solid.chip-accent { background: var(--accent); color: var(--accent-fg); }
.chip-solid.chip-pop { background: var(--pop); color: var(--pop-fg); }
.chip-lg { min-height: 2rem; padding-inline: var(--sp-3); font-size: var(--fs-sm); }
.chip-outline { background: transparent; box-shadow: inset 0 0 0 1px currentColor; }
.chip .chip-x { display: inline-grid; place-items: center; width: 1.1rem; height: 1.1rem; margin-inline-end: -0.2rem; border-radius: 50%; color: inherit; opacity: 0.7; }
.chip .chip-x:hover { opacity: 1; background: rgb(var(--shadow-rgb) / 0.1); }
.count {
  display: inline-grid;
  place-items: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  border-radius: var(--r-pill);
  background: var(--pop);
  color: var(--pop-fg);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  line-height: 1;
}
.count-muted { background: var(--surface-3); color: var(--muted); }

/* ---- 8. Cards and panels ---------------------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.card-header { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-block-end: 1px solid var(--line); }
.card-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.card-header .actions { margin-inline-start: auto; display: flex; gap: var(--sp-2); flex: none; }
.card-body { padding: var(--sp-5); }
.card-body > * + * { margin-block-start: var(--sp-4); }
.card-footer { padding: var(--sp-4) var(--sp-5); border-block-start: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.card-interactive { cursor: pointer; text-decoration: none; color: inherit; transition: transform var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), border-color var(--dur-1); }
.card-interactive:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--border); }
.card-stripe { position: relative; overflow: clip; }
.card-stripe::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--grad-accent); }
.card-stripe.stripe-pop::before { background: var(--grad-pop); }
.card-hero {
  position: relative;
  overflow: clip;
  border: 0;
  background: var(--grad-accent);
  color: var(--accent-fg);
}
.card-hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, var(--sheen), transparent 45%); pointer-events: none; }
.card-hero > * { position: relative; }
.card-hero .muted, .card-hero .hint, .card-hero .caps-label { color: inherit; opacity: 0.85; }
.card-hero .card-header { border-color: rgb(var(--shadow-rgb) / 0.12); }
.card-hero .btn-primary { background: var(--surface); color: var(--accent-text); }
.card-pop { background: var(--grad-pop); color: var(--pop-fg); }
.panel { background: var(--surface-2); border-radius: var(--r-md); padding: var(--sp-4); }
.panel-soft { background: var(--accent-soft); color: var(--fg); }
.panel-pop { background: var(--pop-soft); }
.well { background: var(--bg); border: 1px dashed var(--border); border-radius: var(--r-md); padding: var(--sp-4); }
.card-grid { display: grid; gap: var(--sp-5); grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); }

/* ---- 9. Dialogs, sheets and drawers ----------------------------------------------------------------------------- */

.dialog {
  margin: auto;
  padding: 0;
  border: 0;
  width: min(100% - 2rem, 36rem);
  max-height: min(100dvh - 2rem, 48rem);
  border-radius: var(--r-xl);
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-3);
  display: none;
  flex-direction: column;
}
.dialog[open] { display: flex; animation: dialog-in var(--dur-3) var(--ease-out); }
.dialog::backdrop { background: var(--scrim); backdrop-filter: blur(4px); }
.dialog-header { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-5) var(--sp-6) 0; }
.dialog-title { font-size: var(--fs-xl); font-weight: var(--fw-semibold); line-height: var(--lh-tight); }
.dialog-header .dialog-close { margin-inline-start: auto; flex: none; margin-block-start: -0.25rem; }
.dialog-body { padding: var(--sp-4) var(--sp-6); overflow: auto; }
.dialog-body > * + * { margin-block-start: var(--sp-4); }
.dialog-footer { display: flex; flex-wrap: wrap; gap: var(--sp-3); justify-content: flex-end; padding: var(--sp-3) var(--sp-6) var(--sp-6); }
.dialog-footer > .start { margin-inline-end: auto; }
.dialog-sm { width: min(100% - 2rem, 26rem); }
.dialog-lg { width: min(100% - 2rem, 56rem); }
.dialog-danger .dialog-title { color: var(--bad-text); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
@keyframes sheet-in { from { transform: translateY(100%); } }

/* Phones: every dialog becomes a bottom sheet with a grab handle and full-width actions. */
@media (max-width: 30em) {
  .dialog, .dialog-sm, .dialog-lg {
    width: 100%;
    max-width: none;
    max-height: 92dvh;
    margin: auto 0 0;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
  }
  .dialog[open] { animation: sheet-in var(--dur-3) var(--ease-out); }
  .dialog::before { content: ""; display: block; width: 2.5rem; height: 0.3rem; margin: var(--sp-3) auto 0; border-radius: var(--r-pill); background: var(--border); }
  .dialog-footer { padding-block-end: calc(var(--sp-5) + env(safe-area-inset-bottom)); }
  .dialog-footer .btn { flex: 1 1 auto; }
  .dialog-footer > .start { flex-basis: 100%; margin: 0; }
}

/* A drawer slides in from the end edge (filters, a booking's detail) on tablets and desks. */
.dialog-drawer {
  margin: 0 0 0 auto;
  width: min(100%, 28rem);
  height: 100dvh;
  max-height: none;
  border-radius: 0;
  border-start-start-radius: var(--r-xl);
  border-end-start-radius: var(--r-xl);
}
[dir="rtl"] .dialog-drawer { margin: 0 auto 0 0; }
.dialog-drawer[open] { animation: drawer-in var(--dur-3) var(--ease-out); }
@keyframes drawer-in { from { transform: translateX(var(--drawer-from, 40px)); opacity: 0; } }
[dir="rtl"] .dialog-drawer { --drawer-from: -40px; }

/* ---- 10. Alerts and toasts -------------------------------------------------------------------------------------- */

.alert {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  padding: var(--sp-4);
  border-radius: var(--r-md);
  border-inline-start: 4px solid var(--info);
  background: var(--info-soft);
  color: var(--fg);
}
.alert > .icon { color: var(--info-text); margin-block-start: 0.1em; }
.alert-title { font-weight: var(--fw-semibold); }
.alert-body { flex: 1; min-width: 0; }
.alert-body > * + * { margin-block-start: var(--sp-1); }
.alert .actions { display: flex; gap: var(--sp-2); margin-block-start: var(--sp-3); }
.alert-ok { border-color: var(--ok); background: var(--ok-soft); }
.alert-ok > .icon { color: var(--ok-text); }
.alert-warn { border-color: var(--warn); background: var(--warn-soft); }
.alert-warn > .icon { color: var(--warn-text); }
.alert-bad { border-color: var(--bad); background: var(--bad-soft); }
.alert-bad > .icon { color: var(--bad-text); }
.alert-pop { border-color: var(--pop); background: var(--pop-soft); }
.alert-pop > .icon { color: var(--pop-text); }

.toast-stack {
  position: fixed;
  inset-block-end: var(--sp-4);
  inset-inline-end: var(--sp-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  width: min(100% - 2rem, 24rem);
}
.toast {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  border-inline-start: 4px solid var(--info);
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-3);
  animation: toast-in var(--dur-3) var(--ease-out);
}
.toast > .icon { color: var(--info-text); flex: none; margin-block-start: 0.1em; }
.toast-body { flex: 1; min-width: 0; font-size: var(--fs-sm); }
.toast-title { font-weight: var(--fw-semibold); font-size: var(--fs-md); }
.toast .btn-icon { margin: -0.4rem -0.5rem -0.4rem 0; }
.toast-ok { border-color: var(--ok); } .toast-ok > .icon { color: var(--ok-text); }
.toast-warn { border-color: var(--warn); } .toast-warn > .icon { color: var(--warn-text); }
.toast-bad { border-color: var(--bad); } .toast-bad > .icon { color: var(--bad-text); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (max-width: 30em) {
  .toast-stack { inset-block-end: auto; inset-block-start: var(--sp-3); inset-inline: var(--sp-3); width: auto; }
  @keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
}

/* ---- 11. Stat tiles and the capacity meter ---------------------------------------------------------------------- */

.stats { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); }
.stat {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  min-width: 0;
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.stat-label { font-size: var(--fs-2xs); font-weight: var(--fw-semibold); letter-spacing: var(--ls-caps); text-transform: uppercase; color: var(--muted); }
.stat-value { font-size: var(--fs-display); font-weight: var(--fw-bold); letter-spacing: var(--ls-tight); line-height: 1; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: var(--fs-lg); font-weight: var(--fw-medium); color: var(--muted); margin-inline-start: 0.15em; }
.stat-foot { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--muted); margin-block-start: var(--sp-1); }
.stat-hero { background: var(--grad-accent); color: var(--accent-fg); border: 0; position: relative; overflow: clip; }
.stat-hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, var(--sheen), transparent 50%); pointer-events: none; }
.stat-hero > * { position: relative; }
.stat-hero .stat-label, .stat-hero .stat-foot, .stat-hero .stat-value small, .stat-hero .caps-label { color: inherit; opacity: 0.85; }
.stat-sm .stat-value { font-size: var(--fs-2xl); }

.meter { display: flex; flex-direction: column; gap: var(--sp-2); }
.meter-head { display: flex; justify-content: space-between; gap: var(--sp-3); font-size: var(--fs-sm); }
.meter-head strong { font-variant-numeric: tabular-nums; }
.meter-track { display: flex; gap: 2px; height: 0.75rem; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.meter-fill { height: 100%; background: var(--accent); transition: width var(--dur-3) var(--ease-out); }
.meter-fill.is-online { background: var(--chart-6); }
.meter-fill.is-held { background: repeating-linear-gradient(135deg, var(--warn) 0 4px, var(--warn-soft) 4px 8px); }
.meter-fill.is-over { background: var(--bad); }
.meter-track.is-full .meter-fill { background: var(--bad); }
.meter-sm .meter-track { height: 0.4rem; }
.meter-legend { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); font-size: var(--fs-xs); color: var(--muted); }
.meter-legend span { display: inline-flex; align-items: center; gap: var(--sp-1); }
.meter-legend i { width: 0.6rem; height: 0.6rem; border-radius: 2px; background: var(--accent); display: inline-block; }
.meter-legend i.is-online { background: var(--chart-6); }
.meter-legend i.is-held { background: repeating-linear-gradient(135deg, var(--warn) 0 2px, var(--warn-soft) 2px 4px); }

/* ---- 12. Date picker ------------------------------------------------------------------------------------------------ */

.datepicker {
  width: min(100%, 21rem);
  padding: var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
}
.datepicker.is-inline { box-shadow: var(--shadow-1); }
.dp-head { display: flex; align-items: center; gap: var(--sp-1); padding: 0 0 var(--sp-2); }
.dp-title { flex: 1; text-align: center; font-weight: var(--fw-semibold); }
.dp-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.dp-dow { padding-block: var(--sp-1); text-align: center; font-size: var(--fs-2xs); font-weight: var(--fw-semibold); letter-spacing: var(--ls-caps); text-transform: uppercase; color: var(--muted); }
.dp-day {
  position: relative;
  aspect-ratio: 1;
  min-height: 2.25rem;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  color: var(--fg);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background var(--dur-1), color var(--dur-1), box-shadow var(--dur-1);
}
.dp-day:hover { background: var(--row-hover); }
.dp-day.is-other { color: var(--hint); }
.dp-day:disabled, .dp-day.is-past { color: var(--hint); cursor: not-allowed; text-decoration: line-through; }
.dp-day.is-today { box-shadow: inset 0 0 0 1.5px var(--accent); font-weight: var(--fw-semibold); }
.dp-day.in-range { background: var(--selection); border-radius: 0; }
.dp-day.is-selected, .dp-day.is-range-start, .dp-day.is-range-end { background: var(--grad-accent); color: var(--accent-fg); font-weight: var(--fw-semibold); box-shadow: var(--shadow-1); border-radius: var(--r-sm); }
.dp-day .dot { position: absolute; inset-block-end: 0.3rem; width: 0.3rem; height: 0.3rem; border-radius: 50%; background: var(--pop); }
.dp-day.is-low .dot { background: var(--warn); }
.dp-day.is-full .dot { background: var(--bad); }
.dp-day.is-selected .dot { background: var(--accent-fg); }
.dp-foot { display: flex; flex-wrap: wrap; gap: var(--sp-2); padding-block-start: var(--sp-3); margin-block-start: var(--sp-2); border-block-start: 1px solid var(--line); }
.dp-legend { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-3); margin-inline-start: auto; font-size: var(--fs-2xs); color: var(--muted); align-items: center; }
.dp-legend i { display: inline-block; width: 0.4rem; height: 0.4rem; border-radius: 50%; background: var(--pop); margin-inline-end: 0.3rem; }
.dp-legend i.is-low { background: var(--warn); }
.dp-legend i.is-full { background: var(--bad); }
.dp-popover { position: absolute; z-index: var(--z-dropdown); margin-block-start: var(--sp-1); }

/* ---- 13. Time picker and departure slots --------------------------------------------------------------------------- */

.slots { display: grid; gap: var(--sp-2); grid-template-columns: repeat(auto-fill, minmax(min(100%, 6rem), 1fr)); }
.slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  min-height: var(--control-h-lg);
  padding: var(--sp-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--dur-1), background var(--dur-2), box-shadow var(--dur-2);
}
.slot input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.slot-time { font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }
.slot-left { font-size: var(--fs-xs); color: var(--muted); }
.slot.is-low .slot-left { color: var(--warn-text); font-weight: var(--fw-semibold); }
.slot.is-full { opacity: 0.55; cursor: not-allowed; }
.slot.is-full .slot-time { text-decoration: line-through; }
.slot:hover { border-color: var(--border-strong); }
.slot:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); box-shadow: inset 0 0 0 1px var(--accent); }
.slot:has(input:focus-visible) { outline: var(--focus-w) solid var(--focus); outline-offset: var(--focus-offset); }

.time-field { display: inline-flex; align-items: center; gap: var(--sp-1); }
.time-field .colon { font-weight: var(--fw-semibold); color: var(--muted); }
.time-stepper { display: inline-flex; flex-direction: column; gap: 2px; }
.time-stepper .btn { min-height: 0; height: calc(var(--control-h) / 2 - 1px); width: 1.75rem; padding: 0; border-radius: var(--r-xs); }

/* ---- 14. App shell and navigation ------------------------------------------------------------------------------- */

.app { min-height: 100dvh; display: flex; flex-direction: column; }
.app-main { flex: 1; padding-block-end: var(--sp-10); }
.appbar {
  position: sticky;
  inset-block-start: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 3.5rem;
  padding-inline: var(--gutter);
  background: var(--surface);
  border-block-end: 1px solid var(--line);
}
.appbar::after { content: ""; position: absolute; inset: auto 0 -1px 0; height: 3px; background: var(--grad-accent); }
.appbar .appbar-end { margin-inline-start: auto; display: flex; align-items: center; gap: var(--sp-2); }
.brand { display: inline-flex; align-items: center; gap: var(--sp-2); font-weight: var(--fw-bold); letter-spacing: var(--ls-tight); color: inherit; text-decoration: none; }
.brand .logo { width: 1.75rem; height: 1.75rem; }
.brand .brand-sub { font-weight: var(--fw-regular); color: var(--muted); font-size: var(--fs-sm); }
.brand { white-space: nowrap; }
@media (max-width: 47.99em) { .brand .brand-sub { display: none; } }

.app-body { display: flex; flex: 1; align-items: stretch; }
.sidenav { display: none; }
@media (min-width: 64em) {
  .sidenav {
    position: sticky;
    inset-block-start: 3.5rem;
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    flex: none;
    width: 15rem;
    height: calc(100dvh - 3.5rem);
    padding: var(--sp-4) var(--sp-3);
    overflow: auto;
    background: var(--surface);
    border-inline-end: 1px solid var(--line);
  }
  .sidenav.is-rail { width: 4.25rem; align-items: center; }
  .sidenav.is-rail .nav-label, .sidenav.is-rail .nav-section { display: none; }
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--control-h);
  padding: 0 var(--sp-3);
  border-radius: var(--r-control);
  color: var(--muted);
  font-weight: var(--fw-medium);
  text-decoration: none;
  transition: background var(--dur-1), color var(--dur-1);
}
.nav-item:hover { background: var(--row-hover); color: var(--fg); }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); }
.nav-item .count { margin-inline-start: auto; }
.nav-section { padding: var(--sp-4) var(--sp-3) var(--sp-1); font-size: var(--fs-2xs); font-weight: var(--fw-semibold); letter-spacing: var(--ls-caps); text-transform: uppercase; color: var(--hint); }

.tabbar {
  position: fixed;
  inset-block-end: 0;
  inset-inline: 0;
  z-index: var(--z-sticky);
  display: flex;
  background: var(--surface);
  border-block-start: 1px solid var(--line);
  padding-block-end: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-height: 3.5rem;
  padding-block: var(--sp-1);
  color: var(--muted);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-medium);
  text-decoration: none;
}
.tabbar a .pill { display: grid; place-items: center; width: 3.25rem; height: 1.75rem; border-radius: var(--r-pill); transition: background var(--dur-2); }
.tabbar a[aria-current="page"] { color: var(--accent-text); }
.tabbar a[aria-current="page"] .pill { background: var(--accent-soft); }
.has-tabbar { padding-block-end: calc(4rem + env(safe-area-inset-bottom)); }
@media (min-width: 64em) { .tabbar { display: none; } .has-tabbar { padding-block-end: 0; } }

.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--sp-3) var(--sp-4); padding-block: var(--sp-6) var(--sp-5); }
.page-header .page-title { font-size: var(--fs-3xl); }
.page-header .page-sub { color: var(--muted); margin-block-start: var(--sp-1); }
.page-actions { margin-inline-start: auto; display: flex; flex-wrap: wrap; gap: var(--sp-2); }
@media (max-width: 30em) {
  .page-actions { width: 100%; margin: 0; }
  .page-actions .btn { flex: 1 1 auto; }
}
.hero {
  background: var(--grad-hero);
  border-block-end: 1px solid var(--line);
}
.hero .page-header { padding-block: var(--sp-8) var(--sp-6); }
.breadcrumbs { display: flex; flex-wrap: wrap; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--muted); list-style: none; padding: 0; margin: 0; }
.breadcrumbs a { color: inherit; text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent-text); text-decoration: underline; }
.breadcrumbs li + li::before { content: "/"; margin-inline-end: var(--sp-2); color: var(--hint); }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--sp-3); padding: var(--sp-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.filters .field { flex: 1 1 11rem; }

/* ---- 15. Lists and avatars --------------------------------------------------------------------------------------- */

.list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); overflow: clip; }
.list-item {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  min-height: var(--row-h);
  padding: var(--sp-3) var(--sp-4);
  border-block-end: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
  transition: background var(--dur-1);
}
.list-item:last-child { border-block-end: 0; }
a.list-item:hover, button.list-item:hover { background: var(--row-hover); }
.list-item .lead { flex: none; display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: var(--r-md); background: var(--accent-soft); color: var(--accent-text); }
.list-item .lead.is-pop { background: var(--pop-soft); color: var(--pop-text); }
.list-main { flex: 1; min-width: 0; }
.list-title { display: block; font-weight: var(--fw-semibold); }
.list-meta { display: block; font-size: var(--fs-sm); color: var(--muted); }
.list-end { margin-inline-start: auto; display: flex; align-items: center; gap: var(--sp-2); flex: none; text-align: end; }
.list-item .chev { color: var(--hint); }
.list-item.is-selected { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
[dir="rtl"] .list-item.is-selected { box-shadow: inset -3px 0 0 var(--accent); }

.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  letter-spacing: 0.02em;
}
.avatar-2 { background: var(--pop-soft); color: var(--pop-text); }
.avatar-3 { background: var(--info-soft); color: var(--info-text); }
.avatar-4 { background: var(--ok-soft); color: var(--ok-text); }
.avatar-5 { background: var(--warn-soft); color: var(--warn-text); }
.avatar-sm { width: 1.75rem; height: 1.75rem; font-size: 0.6rem; letter-spacing: 0; }
.avatar-lg { width: 3.5rem; height: 3.5rem; font-size: var(--fs-lg); }
.avatar-stack { display: flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar + .avatar { margin-inline-start: -0.35rem; }

/* ---- 16. Steps, pager, menu, tooltip ---------------------------------------------------------------------------- */

.steps { display: flex; gap: var(--sp-2); list-style: none; padding: 0; margin: 0; counter-reset: step; }
.steps li { flex: 1; display: flex; align-items: center; gap: var(--sp-2); min-width: 0; font-size: var(--fs-sm); color: var(--muted); counter-increment: step; }
.steps li::before {
  content: counter(step);
  flex: none;
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-xs);
}
.steps li::after { content: ""; flex: 1; height: 2px; background: var(--line); border-radius: 2px; }
.steps li:last-child { flex: none; }
.steps li:last-child::after { display: none; }
.steps li.is-done { color: var(--fg); }
.steps li.is-done::before { content: "✓"; background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.steps li.is-done::after { background: var(--accent); }
.steps li.is-current { color: var(--accent-text); font-weight: var(--fw-semibold); }
.steps li.is-current::before { border-color: var(--accent); color: var(--accent-text); box-shadow: 0 0 0 4px var(--accent-soft); }
.steps .step-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 40em) {
  .steps li:not(.is-current) .step-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .steps li.is-current { flex: 4; }
}

.pager { display: flex; align-items: center; gap: var(--sp-1); flex-wrap: wrap; }
.pager .btn-icon { border-radius: var(--r-pill); }
.pager .pager-info { padding-inline: var(--sp-3); font-size: var(--fs-sm); color: var(--muted); font-variant-numeric: tabular-nums; }

.menu {
  margin: 0;
  padding: var(--sp-2);
  min-width: 12rem;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-3);
  inset: auto;
}
.menu:popover-open { animation: dialog-in var(--dur-2) var(--ease-out); }
.menu-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  min-height: var(--control-h-sm);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-sm);
  color: inherit;
  text-decoration: none;
  text-align: start;
  font-size: var(--fs-sm);
  cursor: pointer;
}
.menu-item:hover { background: var(--row-hover); }
.menu-item .icon { color: var(--muted); }
.menu-item.is-danger { color: var(--bad-text); }
.menu-item.is-danger .icon { color: inherit; }
.menu-item kbd { margin-inline-start: auto; }
.menu hr { margin-block: var(--sp-2); }

[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  inset-block-end: calc(100% + 6px);
  inset-inline-start: 50%;
  translate: -50% 0;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-xs);
  background: var(--surface-inverse);
  color: var(--fg-inverse);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  display: none;   /* not laid out until shown: an invisible tooltip must never widen a page */
  pointer-events: none;
  z-index: var(--z-tooltip);
}
[dir="rtl"] [data-tip]::after { translate: 50% 0; }
[data-tip]:hover::after, [data-tip]:focus-visible::after { display: block; animation: tip-in var(--dur-1) var(--ease-out); }
@keyframes tip-in { from { opacity: 0; } }

/* ---- 17. Empty states, skeletons, spinner ----------------------------------------------------------------------- */

.empty { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); padding: var(--sp-10) var(--sp-6); text-align: center; }
.empty .illus { width: min(100%, 13rem); height: auto; margin-block-end: var(--sp-2); }
.empty p { color: var(--muted); max-width: 36ch; }
.empty .actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; justify-content: center; margin-block-start: var(--sp-2); }

.skeleton {
  display: block;
  min-height: 1em;
  border-radius: var(--r-sm);
  color: transparent;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.skeleton-text { height: 0.9em; margin-block: 0.3em; }
.skeleton-round { border-radius: 50%; }
@keyframes shimmer { to { background-position: -200% 0; } }

.spinner { animation: spin 0.9s linear infinite; }
.spinner circle { stroke-dasharray: 40 60; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-bar { position: fixed; inset-block-start: 0; inset-inline: 0; height: 3px; z-index: var(--z-tooltip); background: var(--grad-pop); animation: loading-bar 1.2s var(--ease-in-out) infinite; transform-origin: 0 50%; }
@keyframes loading-bar { 0% { transform: scaleX(0); } 60% { transform: scaleX(0.8); } 100% { transform: scaleX(1); opacity: 0; } }

/* ---- 18. Print --------------------------------------------------------------------------------------------------- */

@media print {
  /* Flat page: tokens.css already zeroes shadows and gradients; the loading shimmer needs its own rule. The held hatch stays, it carries meaning. */
  .skeleton { background: var(--surface-2); animation: none; }
  /* Tables stay readable at arm's length: 1rem is 11pt here, which is above the 14px minimum. */
  .table { font-size: var(--fs-md); }
  .table-wrap { overflow: visible; }
  .appbar, .sidenav, .tabbar, .page-actions, .toast-stack, .form-actions, .filters, .btn, .tabs, .skip-link { display: none !important; }
  .app-main { padding: 0; }
  .card, .table-wrap, .list, .stat, .accordion { box-shadow: none; border-color: var(--line); break-inside: avoid; }
  .card-hero, .stat-hero { background: var(--surface); color: var(--fg); border: 1px solid var(--line); }
  .table thead th { position: static; }
  .table th, .table td { padding: var(--sp-2) var(--sp-3); }
  .table tbody tr:hover td { background: var(--surface); }
  .table-cards thead { position: static; width: auto; height: auto; clip: auto; }
  .table-cards, .table-cards tbody { display: table; width: 100%; }
  .table-cards tr { display: table-row; }
  .table-cards td { display: table-cell; }
  .table-cards td::before { display: none; }
  .tab-panel[hidden] { display: none; }
  .chip { border: 1px solid var(--border); }
  .dialog { display: none; }
}
