/* ==========================================================================
   g3-core.css — the shared design foundation (UI redesign Phase 1)

   One token set + one component kit for the staff dash, member portal,
   public site and kiosks. Approved at the Phase 1 design checkpoint
   (Figma "G3 Dash — Phase 1 Design Foundation", 2026-09-27).

   HOW IT LOADS
   Linked BEFORE g3.css (staff) and g3-mobile.css (portal). Those older
   sheets still win wherever a name collides (the --accent* family, which
   already means the same thing), and every class here is prefixed ui-, so
   existing pages keep their look. One deliberate side effect: a few staff
   partials that already read portal-style names with light-only
   fallbacks (var(--text, #1F2933) in interns/_snapshot_body.html,
   _storage_file_preview.html, admin/server_env.html) now get proper
   dark-mode values instead of light colors on a dark page. Pages adopt
   the kit as each redesign phase touches them; the living reference is
   /admin/ui.

   RULES
   - Classes are prefixed `ui-`. Never style a `ui-` class from a page.
   - No hex colors outside this token block. Components use tokens only.
   - Every component defines its own narrow-screen behavior here, once.
   - Status colors come from core/status_tones.py via the pill macro.
   ========================================================================== */

/* ---------- Tokens (light) ---------- */
:root {
  --bg: #FFFFFF;
  --bg-elev: #F8FAFB;          /* staff page background, table headers */
  --surface: #FFFFFF;          /* cards, dialogs, inputs */
  --border: #E5E9ED;           /* dividers + card edges */
  --border-strong: #8B95A1;    /* input + secondary-button edges — 3:1 on white (WCAG 1.4.11) */
  --text: #1F2933;
  --text-dim: #6B7280;         /* 4.8:1 on white, 4.6:1 on bg-elev */

  --accent: #F16B2C;           /* logo orange — marks + indicators only */
  --accent-strong: #C2410C;    /* primary buttons, links, focus (D1) — 5.2:1 w/ white */
  --accent-hover: #9A3412;
  --accent-soft: #FEF1E9;      /* hover + selected surfaces */
  --accent-fill: #C2410C;      /* legacy .pf-btn/.m-btn fill: white text in BOTH themes */
  --on-accent: #FFFFFF;
  --focus: #C2410C;

  --good: #15803D;
  --warn: #B45309;
  --alert: #B91C1C;
  --info: #0369A1;
  --inverse: #1F2933;          /* toasts, tooltips */
  --on-inverse: #FFFFFF;
  --scrim: rgba(15, 20, 25, 0.45);

  /* Status tones (pill fg/bg) — see core/status_tones.py */
  --tone-neutral-bg: #F3F4F6;  --tone-neutral-fg: #374151;
  --tone-info-bg: #E0F2FE;     --tone-info-fg: #075985;
  --tone-success-bg: #DCFCE7;  --tone-success-fg: #166534;
  --tone-warning-bg: #FEF3C7;  --tone-warning-fg: #92400E;
  --tone-danger-bg: #FEE2E2;   --tone-danger-fg: #991B1B;
  --tone-accent-bg: #FFEDD5;   --tone-accent-fg: #9A3412;

  /* Spacing (4px base) */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px;
  --s-5: 24px; --s-6: 32px; --s-7: 48px;

  /* Radius */
  --r-control: 8px;            /* buttons, inputs */
  --r-card: 12px;              /* cards, dialogs */
  --r-pill: 999px;

  /* Type */
  --font: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --fs-title: 24px;  --lh-title: 32px;
  --fs-section: 18px; --lh-section: 26px;
  --fs-card: 15px;   --lh-card: 22px;
  --fs-body: 14px;   --lh-body: 20px;
  --fs-small: 13px;  --lh-small: 18px;
  --fs-label: 12px;  --lh-label: 16px;

  /* Controls */
  --ctl-sm: 32px; --ctl-md: 40px; --ctl-lg: 48px;
  --tabbar-h: 0px;             /* portal's bottom tab bar; g3-mobile.css sets the real height */

  /* Today hero (Phase 3): warm orange -> cream -> green, the circular-economy loop */
  --hero-a: #FFE3D1; --hero-b: #FFF3EA; --hero-c: #EAF4E4;
  --hero-ring: rgba(241, 107, 44, 0.35); --hero-ring-2: rgba(76, 159, 56, 0.25);
  --tile-shadow: 0 1px 2px rgba(16, 24, 32, 0.06), 0 10px 28px -4px rgba(154, 52, 18, 0.12);
  --tile-shadow-hover: 0 1px 2px rgba(16, 24, 32, 0.06), 0 16px 32px -6px rgba(154, 52, 18, 0.18);

  --shadow-sm: 0 1px 2px rgba(16, 24, 32, 0.06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 32, 0.16);
  --t-fast: 120ms;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ---------- Tokens (dark) — same attribute both apps already use ---------- */
[data-theme="dark"] {
  --bg: #0F1419;
  --bg-elev: #1A2028;
  --surface: #232A33;
  --border: #2F3641;
  --border-strong: #707A89;    /* 3.3:1 on surface */
  --text: #E8EDF2;
  --text-dim: #9BA5B0;

  --accent: #FF8755;
  --accent-strong: #FF8755;    /* dark text on it: 7.8:1 */
  --accent-hover: #FFA27A;
  --accent-soft: #3B1F0F;
  --accent-fill: #C2410C;      /* unchanged in dark: legacy buttons keep white text */
  --on-accent: #0F1419;
  --focus: #FF8755;

  --good: #34D399;
  --warn: #FBBF24;
  --alert: #F87171;
  --info: #7DD3FC;
  --inverse: #E8EDF2;
  --on-inverse: #0F1419;
  --scrim: rgba(0, 0, 0, 0.6);

  --tone-neutral-bg: #2F3641;  --tone-neutral-fg: #D1D5DB;
  --tone-info-bg: #0C2A3E;     --tone-info-fg: #7DD3FC;
  --tone-success-bg: #0F2E1C;  --tone-success-fg: #86EFAC;
  --tone-warning-bg: #3A2A0A;  --tone-warning-fg: #FCD34D;
  --tone-danger-bg: #3B1414;   --tone-danger-fg: #FCA5A5;
  --tone-accent-bg: #3B1F0F;   --tone-accent-fg: #FDBA8C;

  --shadow-sm: none;
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
  --hero-a: #3B1F0F; --hero-b: #1A2028; --hero-c: #16261A;
  --hero-ring: rgba(255, 135, 85, 0.35); --hero-ring-2: rgba(52, 211, 153, 0.22);
  --tile-shadow: 0 10px 28px -6px rgba(0, 0, 0, 0.55);
  --tile-shadow-hover: 0 16px 32px -6px rgba(0, 0, 0, 0.65);
}

/* ==========================================================================
   Layout helpers — so pages never need inline grids or flex
   ========================================================================== */
.ui-page { background: var(--bg-elev); color: var(--text); font-family: var(--font); }
.ui-stack { display: flex; flex-direction: column; gap: var(--s-4); }
.ui-stack--sm { gap: var(--s-2); }
.ui-stack--lg { gap: var(--s-5); }
.ui-cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.ui-cluster--between { justify-content: space-between; }
.ui-split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--s-5); align-items: start; }
@media (max-width: 1100px) { .ui-split { grid-template-columns: minmax(0, 1fr) 290px; } }
@media (max-width: 860px)  { .ui-split { grid-template-columns: minmax(0, 1fr); } }
.ui-grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.ui-dim { color: var(--text-dim); }
.ui-sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ui-skip-link { position: absolute; left: var(--s-4); top: -60px; z-index: 1000; padding: var(--s-2) var(--s-4);
  background: var(--accent-strong); color: var(--on-accent); border-radius: var(--r-control); font-weight: 600; }
.ui-skip-link:focus { top: var(--s-4); }

/* Headings */
.ui-h1 { font-size: var(--fs-title); line-height: var(--lh-title); font-weight: 700; margin: 0; color: var(--text); }
.ui-h2 { font-size: var(--fs-section); line-height: var(--lh-section); font-weight: 600; margin: 0; color: var(--text); }
.ui-h3 { font-size: var(--fs-card); line-height: var(--lh-card); font-weight: 600; margin: 0; color: var(--text); }
.ui-label { font-size: var(--fs-label); line-height: var(--lh-label); font-weight: 600; letter-spacing: 0.02em;
  text-transform: uppercase; color: var(--text-dim); }

/* Links */
.ui-link { color: var(--accent-strong); font-weight: 600; text-decoration: none; }
.ui-link:hover { text-decoration: underline; }

/* One focus style for every interactive kit element */
.ui-btn:focus-visible, .ui-link:focus-visible, .ui-input:focus-visible, .ui-tabs__tab:focus-visible,
.ui-table__link:focus-visible, .ui-menu > summary:focus-visible, .ui-menu__item:focus-visible,
.ui-back:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ==========================================================================
   Button — primary / secondary / quiet / danger · sm / md / lg
   ========================================================================== */
.ui-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--ctl-md); padding: 0 var(--s-4);
  border: 1px solid transparent; border-radius: var(--r-control);
  font: 600 var(--fs-body)/1 var(--font); text-decoration: none; white-space: nowrap;
  cursor: pointer; transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.ui-btn svg { flex: none; }
.ui-btn--primary   { background: var(--accent-strong); color: var(--on-accent); }
.ui-btn--primary:hover { background: var(--accent-hover); }
.ui-btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.ui-btn--secondary:hover { background: var(--bg-elev); }
.ui-btn--quiet     { background: transparent; color: var(--accent-strong); padding: 0 var(--s-2); }
.ui-btn--quiet:hover { background: var(--accent-soft); }
.ui-btn--danger    { background: var(--alert); color: var(--on-accent); }
.ui-btn--danger:hover { filter: brightness(0.92); }
.ui-btn--sm { min-height: var(--ctl-sm); padding: 0 var(--s-3); font-size: var(--fs-small); }
.ui-btn--lg { min-height: var(--ctl-lg); padding: 0 var(--s-5); font-size: 15px; }
.ui-btn--block { display: flex; width: 100%; }
.ui-btn--icon { width: var(--ctl-md); padding: 0; }
.ui-btn--icon.ui-btn--sm { width: var(--ctl-sm); }
.ui-btn[disabled], .ui-btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.ui-btn[aria-busy="true"] { opacity: 0.6; cursor: progress; pointer-events: none; }
/* Phones + touch tablets: primary actions get the 48px tap target (approved checkpoint call) */
@media (max-width: 640px), (pointer: coarse) {
  .ui-btn--primary:not(.ui-btn--sm) { min-height: var(--ctl-lg); }
}

/* ==========================================================================
   Status pill + count badge
   ========================================================================== */
.ui-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px;
  border-radius: var(--r-pill); font: 600 var(--fs-label)/var(--lh-label) var(--font); white-space: nowrap;
  background: var(--tone-neutral-bg); color: var(--tone-neutral-fg);
}
.ui-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.ui-pill--accent  { background: var(--tone-accent-bg);  color: var(--tone-accent-fg); }
.ui-pill--info    { background: var(--tone-info-bg);    color: var(--tone-info-fg); }
.ui-pill--success { background: var(--tone-success-bg); color: var(--tone-success-fg); }
.ui-pill--warning { background: var(--tone-warning-bg); color: var(--tone-warning-fg); }
.ui-pill--danger  { background: var(--tone-danger-bg);  color: var(--tone-danger-fg); }
.ui-pill--neutral { background: var(--tone-neutral-bg); color: var(--tone-neutral-fg); }

.ui-badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; padding: 2px 6px;
  border-radius: var(--r-pill); font: 700 11px/14px var(--font);
  background: var(--tone-accent-bg); color: var(--tone-accent-fg);
}
.ui-badge--neutral { background: var(--tone-neutral-bg); color: var(--tone-neutral-fg); }

/* ==========================================================================
   Card
   ========================================================================== */
.ui-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card);
  box-shadow: var(--shadow-sm); padding: var(--s-5);
}
.ui-card--flush { padding: 0; overflow: hidden; }
.ui-card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  margin-bottom: var(--s-4); }
.ui-card--flush > .ui-card__head { margin: 0; padding: var(--s-3) var(--s-5); border-bottom: 1px solid var(--border); }
@media (max-width: 640px) { .ui-card:not(.ui-card--flush) { padding: var(--s-4); } }

/* ==========================================================================
   Page header — back link, title + pill, facts, actions, ⋯ menu
   ========================================================================== */
.ui-back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: var(--s-2);
  font: 500 var(--fs-small)/1 var(--font); color: var(--text-dim); text-decoration: none; }
.ui-back:hover { color: var(--text); }
.ui-page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4);
  margin-bottom: var(--s-5); }
.ui-page-header__main { min-width: 0; }
.ui-page-header__title { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.ui-page-header__facts { margin-top: 6px; font-size: var(--fs-small); color: var(--text-dim); }
.ui-page-header__facts > * + *::before { content: "·"; margin: 0 var(--s-2); }
.ui-page-header__actions { display: flex; align-items: center; gap: var(--s-2); flex: none; }
@media (max-width: 640px) {
  .ui-page-header { flex-direction: column; align-items: stretch; }
  .ui-page-header__actions { justify-content: flex-end; }
  .ui-page-header__secondary { display: none; }   /* rare actions live in the ⋯ menu */
}

/* ⋯ menu — native <details>, no JS */
.ui-menu { position: relative; display: inline-block; }
.ui-menu > summary { list-style: none; }
.ui-menu > summary::-webkit-details-marker { display: none; }
.ui-menu__panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 220px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-lg);
}
.ui-menu__item {
  display: flex; align-items: center; gap: var(--s-3); width: 100%; padding: var(--s-2) 10px;
  border: 0; border-radius: var(--r-control); background: none; text-align: left; text-decoration: none;
  font: 500 var(--fs-body)/var(--lh-body) var(--font); color: var(--text); cursor: pointer;
}
.ui-menu__item:hover { background: var(--bg-elev); }
.ui-menu__item--danger { color: var(--alert); }
.ui-menu__sep { height: 1px; margin: 4px 0; background: var(--border); }

/* ==========================================================================
   Tabs — links with aria-current="page"; scroll sideways on phones
   ========================================================================== */
.ui-tabs { display: flex; gap: var(--s-5); border-bottom: 1px solid var(--border); margin-bottom: var(--s-5);
  overflow-x: auto; scrollbar-width: none; }
.ui-tabs::-webkit-scrollbar { display: none; }
.ui-tabs__tab { display: inline-flex; align-items: center; gap: 6px; padding: 0 0 var(--s-3);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
  font: 500 var(--fs-body)/var(--lh-body) var(--font); color: var(--text-dim); text-decoration: none; }
.ui-tabs__tab:hover { color: var(--text); }
.ui-tabs__tab[aria-current="page"], .ui-tabs__tab.is-active { color: var(--text); font-weight: 600;
  border-bottom-color: var(--accent-strong); }
@media (max-width: 640px) { .ui-tabs { gap: 18px; } }

/* ==========================================================================
   Table — real row links; stacked cards on phones (cells need data-label)
   ========================================================================== */
.ui-table { width: 100%; border-collapse: collapse; font-size: var(--fs-body); }
.ui-table th { padding: 10px var(--s-5); text-align: left; background: var(--bg-elev);
  font: 600 var(--fs-label)/var(--lh-label) var(--font); color: var(--text-dim); border-bottom: 1px solid var(--border); }
.ui-table td { padding: var(--s-3) var(--s-5); border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.ui-table tbody tr:last-child td { border-bottom: 0; }
.ui-table tbody tr { position: relative; }
.ui-table tbody tr:hover td { background: var(--bg-elev); }
.ui-table__link { font-weight: 600; color: var(--text); text-decoration: none; }
.ui-table__link::after { content: ""; position: absolute; inset: 0; }      /* whole row is the link */
.ui-table__sub { display: block; margin-top: 2px; font-size: var(--fs-label); color: var(--text-dim); font-weight: 400; }
.ui-table td .ui-menu, .ui-table td .ui-btn { position: relative; z-index: 1; }  /* stay clickable above the row link */
.ui-table__num { text-align: right; font-variant-numeric: tabular-nums; }
.ui-table__actions { width: 1%; white-space: nowrap; text-align: right; }
@media (max-width: 640px) {
  .ui-table thead { display: none; }
  .ui-table, .ui-table tbody, .ui-table tr, .ui-table td { display: block; width: 100%; }
  .ui-table tbody tr { margin: 0 0 var(--s-3); padding: var(--s-3) var(--s-4); background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--r-card); }
  .ui-table td { padding: 2px 0; border: 0; }
  .ui-table td[data-label]:not(:first-child)::before { content: attr(data-label) " · "; color: var(--text-dim);
    font-size: var(--fs-small); }
  .ui-table__num { text-align: left; }
  .ui-table__actions { width: auto; padding: var(--s-2) 0 0; text-align: left; }
  .ui-table__actions:has(> .ui-menu) { position: absolute; top: var(--s-2); right: var(--s-2); padding: 0; }
  .ui-table tbody tr:has(.ui-table__actions > .ui-menu) td:first-child { padding-right: 44px; }
  .ui-card--flush .ui-table { padding: 0 var(--s-3); }
}

/* ==========================================================================
   Form field — label above, help below, error replaces help
   ========================================================================== */
.ui-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ui-field__label { font: 600 var(--fs-small)/var(--lh-small) var(--font); color: var(--text); }
.ui-field__req { color: var(--alert); margin-left: 2px; }
.ui-field__help { font-size: var(--fs-label); line-height: var(--lh-label); color: var(--text-dim); }
.ui-field__error { display: flex; align-items: center; gap: 6px; font-size: var(--fs-label);
  line-height: var(--lh-label); color: var(--alert); }
.ui-input {
  width: 100%; min-height: var(--ctl-md); padding: 0 var(--s-3); box-sizing: border-box;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--r-control);
  font: 400 var(--fs-body)/var(--lh-body) var(--font);
}
textarea.ui-input { min-height: 96px; padding: 10px var(--s-3); resize: vertical; }
.ui-input::placeholder { color: var(--text-dim); }
.ui-input:focus { border-color: var(--accent-strong); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.ui-field--error .ui-input { border-color: var(--alert); border-width: 1.5px; }
.ui-form-grid { display: grid; gap: var(--s-4) var(--s-5); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ui-form-grid > .ui-field--wide { grid-column: 1 / -1; }
@media (max-width: 640px) {
  .ui-form-grid { grid-template-columns: minmax(0, 1fr); }
  .ui-input { min-height: var(--ctl-lg); font-size: 16px; }   /* 16px stops iOS zoom-on-focus */
}

/* ==========================================================================
   Callout (inline message) — tone variants
   ========================================================================== */
.ui-callout { display: flex; gap: var(--s-3); padding: 14px var(--s-4); border-radius: 10px;
  background: var(--tone-info-bg); color: var(--tone-info-fg); font-size: var(--fs-small); line-height: var(--lh-small); }
.ui-callout svg { flex: none; margin-top: 1px; }
.ui-callout__title { display: block; font-size: var(--fs-body); font-weight: 600; margin-bottom: 2px; }
.ui-callout--success { background: var(--tone-success-bg); color: var(--tone-success-fg); }
.ui-callout--danger  { background: var(--tone-danger-bg);  color: var(--tone-danger-fg); }
.ui-callout--warning { background: var(--tone-warning-bg); color: var(--tone-warning-fg); }
.ui-callout--accent  { background: var(--tone-accent-bg);  color: var(--tone-accent-fg); }
.ui-callout--neutral { background: var(--tone-neutral-bg); color: var(--tone-neutral-fg); }

/* ==========================================================================
   Toast — bottom-center; behavior (auto-dismiss, undo) wires up in 1b
   ========================================================================== */
.ui-toast-region { position: fixed; left: 50%; bottom: var(--s-5); transform: translateX(-50%); z-index: 1000;
  display: flex; flex-direction: column; align-items: center; gap: var(--s-2); pointer-events: none; }
.ui-toast { display: inline-flex; align-items: center; gap: 14px; padding: var(--s-3) var(--s-4); pointer-events: auto;
  background: var(--inverse); color: var(--on-inverse); border-radius: 10px; box-shadow: var(--shadow-lg);
  font: 400 var(--fs-body)/var(--lh-body) var(--font); max-width: min(560px, calc(100vw - 32px)); }
.ui-toast__action { background: none; border: 0; padding: 0; color: inherit; font: 700 var(--fs-body)/1 var(--font);
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.ui-toast__close { background: none; border: 0; padding: 0; color: inherit; opacity: 0.8; cursor: pointer; display: inline-flex; }
.ui-toast__form { display: inline; margin: 0; }
.ui-toast--warning { background: var(--tone-warning-bg); color: var(--tone-warning-fg); border: 1px solid currentColor; }
.ui-toast--danger  { background: var(--tone-danger-bg);  color: var(--tone-danger-fg);  border: 1px solid currentColor; }
@media (max-width: 640px) {
  /* Portal tab bar sits at the bottom — keep toasts clear of it. */
  .ui-toast-region { bottom: calc(var(--tabbar-h, 0px) + env(safe-area-inset-bottom, 0px) + var(--s-4)); width: calc(100vw - 32px); }
  .ui-toast { width: 100%; box-sizing: border-box; }
}

/* ==========================================================================
   Dialog — native <dialog>; bottom sheet on phones
   ========================================================================== */
.ui-dialog { width: min(440px, calc(100vw - 32px)); padding: var(--s-5); border: 1px solid var(--border);
  border-radius: var(--r-card); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.ui-dialog::backdrop { background: var(--scrim); }
.ui-dialog__title { margin: 0 0 var(--s-3); font: 600 var(--fs-section)/var(--lh-section) var(--font); }
.ui-dialog__body { margin: 0 0 var(--s-2); font-size: var(--fs-body); line-height: var(--lh-body); }
.ui-dialog__note { margin: 0 0 var(--s-5); font-size: var(--fs-small); line-height: var(--lh-small); color: var(--text-dim); }
.ui-dialog__actions { display: flex; justify-content: flex-end; gap: var(--s-2); }
@media (max-width: 640px) {
  .ui-dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 16px 16px 0 0; padding-bottom: var(--s-6); }
  .ui-dialog__actions { flex-direction: column-reverse; }
  .ui-dialog__actions .ui-btn { width: 100%; min-height: var(--ctl-lg); }
}

/* ==========================================================================
   Empty state
   ========================================================================== */
.ui-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: var(--s-6) var(--s-5);
  text-align: center; }
.ui-empty__icon { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); }
.ui-empty__title { font: 600 16px/22px var(--font); color: var(--text); margin: 0; }
.ui-empty__body { max-width: 420px; margin: 0; font-size: var(--fs-body); line-height: var(--lh-body); color: var(--text-dim); }

/* ==========================================================================
   Key-value list
   ========================================================================== */
.ui-kv { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 10px var(--s-4); margin: 0; }
.ui-kv dt { font-size: var(--fs-small); color: var(--text-dim); }
.ui-kv dd { margin: 0; font-size: var(--fs-body); font-weight: 500; color: var(--text); }
@media (max-width: 640px) {
  .ui-kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .ui-kv dd { margin-bottom: var(--s-2); }
}

/* ==========================================================================
   Staff shell (Phase 2) — top bar, dropdowns, account menu, phone drawer.
   Markup: ui/templates/_staff_shell.html · items: core/nav.py
   ========================================================================== */
/* Not sticky on purpose: existing page bars (.pf-action-bar, .pf-settings-tabs,
   .g3-detail__actionbar, .g3i-subnav) are sticky at top:0 and would slide under it. */
.ui-shell { position: relative; z-index: 100; background: var(--surface);
  border-bottom: 1px solid var(--border); font-family: var(--font); }
.ui-shell__bar { display: flex; align-items: center; gap: var(--s-5); height: 60px; padding: 0 var(--s-6);
  max-width: 1600px; margin: 0 auto; box-sizing: border-box; }
.ui-shell__brand { display: flex; align-items: center; gap: 10px; flex: none; color: var(--text);
  text-decoration: none; font: 700 15px/1 var(--font); }
.ui-shell__logo { width: 32px; height: 32px; border-radius: 50%; display: block; }
.ui-shell__nav { display: flex; align-items: center; gap: 2px; min-width: 0; }
.ui-shell__link { display: inline-flex; align-items: center; gap: 6px; padding: var(--s-2) var(--s-3);
  border-radius: var(--r-control); color: var(--text-dim); text-decoration: none; white-space: nowrap;
  font: 500 var(--fs-body)/var(--lh-body) var(--font); cursor: pointer; list-style: none; }
.ui-shell__link::-webkit-details-marker { display: none; }
.ui-shell__link:hover { color: var(--text); background: var(--bg-elev); }
.ui-shell__link.is-active { color: var(--accent-strong); background: var(--accent-soft); font-weight: 600; }
.ui-shell__menu { position: relative; }
.ui-shell__menu[open] > .ui-shell__link { background: var(--bg-elev); color: var(--text); }
.ui-shell__chev { transition: transform var(--t-fast) var(--ease); }
.ui-shell__menu[open] .ui-shell__chev { transform: rotate(180deg); }
.ui-shell__panel { left: 0; right: auto; min-width: 270px; }
.ui-shell__panel--right { left: auto; right: 0; min-width: 290px; }
.ui-shell__item-text { display: flex; flex-direction: column; min-width: 0; }
.ui-shell__item-text small { font-size: var(--fs-label); line-height: var(--lh-label); color: var(--text-dim); font-weight: 400; }
.ui-menu__item.is-active { background: var(--accent-soft); color: var(--accent-strong); }
.ui-menu__item .ui-badge { margin-left: auto; }
.ui-shell__tools { display: flex; align-items: center; gap: var(--s-3); margin-left: auto; flex: none; }
.ui-shell__search { display: inline-flex; align-items: center; gap: var(--s-2); height: 36px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--r-control); background: var(--bg-elev); color: var(--text-dim);
  font: 400 var(--fs-body)/1 var(--font); cursor: pointer; }
.ui-shell__search:hover { color: var(--text); }
.ui-shell__search kbd { padding: 2px 6px; border: 1px solid var(--border); border-radius: 4px;
  font: 600 11px/1 var(--font); color: var(--text-dim); background: var(--surface); }
.ui-shell__avatar-btn { position: relative; display: inline-flex; align-items: center; gap: 4px; padding: 2px;
  border-radius: var(--r-pill); color: var(--text-dim); cursor: pointer; list-style: none; }
.ui-shell__avatar-btn::-webkit-details-marker { display: none; }
.ui-shell__avatar { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  border-radius: 50%; background: var(--tone-accent-bg); color: var(--tone-accent-fg); font: 700 12px/1 var(--font); }
.ui-shell__avatar--lg { width: 38px; height: 38px; font-size: 13px; }
.ui-shell__dot { position: absolute; top: 0; left: 24px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent-strong); border: 2px solid var(--surface); }
[class^="ui-"][hidden], [class*=" ui-"][hidden] { display: none !important; }
.ui-shell__who { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) 10px; }
.ui-shell__account form { margin: 0; }
.ui-shell__menu > summary:focus-visible, .ui-shell__link:focus-visible, .ui-shell__search:focus-visible,
.ui-shell__drawer > summary:focus-visible, .ui-shell__drawer-link:focus-visible, .ui-shell__icon-btn:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px; }

/* Phone drawer (hidden on desktop) */
.ui-shell__drawer { display: none; }
.ui-shell__drawer > summary { list-style: none; }
.ui-shell__drawer > summary::-webkit-details-marker { display: none; }
.ui-shell__icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
  border: 0; border-radius: var(--r-control); background: none; color: var(--text); cursor: pointer; }
.ui-shell__scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 200; }
.ui-shell__drawer-panel { position: fixed; top: 0; left: 0; bottom: 0; z-index: 201; width: min(304px, 86vw);
  overflow-y: auto; padding: var(--s-4) var(--s-3) var(--s-6); background: var(--surface); box-shadow: var(--shadow-lg);
  box-sizing: border-box; }
.ui-shell__drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 0 0 var(--s-3) var(--s-2); }
.ui-shell__drawer-title { font: 700 16px/1 var(--font); color: var(--text); }
.ui-shell__drawer-group { margin: var(--s-4) 0 var(--s-1); padding-left: 10px; font: 600 11px/1 var(--font);
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-dim); }
.ui-shell__drawer-link { display: flex; align-items: center; gap: var(--s-3); width: 100%; min-height: 44px; padding: 0 10px;
  border: 0; border-radius: var(--r-control); background: none; color: var(--text); text-decoration: none; text-align: left;
  font: 500 15px/1.2 var(--font); cursor: pointer; box-sizing: border-box; }
.ui-shell__drawer-link .ui-badge { margin-left: auto; }
.ui-shell__drawer-link.is-active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.ui-shell__drawer-link--danger { color: var(--alert); }
.ui-shell__drawer-form { margin: 0; }

@media (max-width: 1180px) {
  .ui-shell__bar { gap: var(--s-3); padding: 0 var(--s-5); }
  .ui-shell__brand-name, .ui-shell__search-label { display: none; }
}
@media (max-width: 900px) {
  .ui-shell__bar { padding: 0 var(--s-3); height: 56px; }
  .ui-shell__nav { display: none; }
  .ui-shell__drawer { display: block; }
  .ui-shell__brand-name { display: inline; }
  .ui-shell__search kbd { display: none; }
  .ui-shell__search { width: 40px; justify-content: center; padding: 0; border-color: transparent; background: none; }
}

/* ==========================================================================
   Today (Phase 3) — hero, raised tiles, floor timeline, stat cards, rail.
   Markup: ui/templates/today.html · data: core/today.py
   ========================================================================== */
.ui-today { display: flex; flex-direction: column; gap: var(--s-5); }
.ui-hero { position: relative; overflow: hidden; display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--s-4); padding: var(--s-6) var(--s-6) calc(var(--s-7) + var(--s-6)); border-radius: 16px;
  background: linear-gradient(90deg, var(--hero-a), var(--hero-b) 55%, var(--hero-c)); }
.ui-hero::before, .ui-hero::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; }
.ui-hero::before { width: 340px; height: 340px; right: 60px; top: -120px; border: 2px dashed var(--hero-ring); }
.ui-hero::after { width: 200px; height: 200px; right: 130px; top: -50px; border: 10px solid var(--hero-ring-2); }
.ui-hero__text, .ui-hero__actions { position: relative; z-index: 1; }
.ui-hero__date { margin: 0 0 6px; font: 700 12px/1 var(--font); letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent-strong); }
.ui-hero__title { margin: 0; font: 700 32px/40px var(--font); color: var(--text); }
.ui-hero__sub { margin: 6px 0 0; font: 500 15px/22px var(--font); color: var(--text-dim); }
.ui-hero__sub > span::before { content: "·"; margin: 0 var(--s-2); }

.ui-tiles { display: grid; gap: var(--s-4); grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: calc(-1 * (var(--s-7) + var(--s-5))) var(--s-5) 0; position: relative; z-index: 2; }
.ui-tiles--clear { grid-template-columns: minmax(0, 1fr); }
.ui-tile { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 18px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; color: var(--text); text-decoration: none;
  box-shadow: var(--tile-shadow); transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease); }
.ui-tile:hover { transform: translateY(-2px); box-shadow: var(--tile-shadow-hover); }
.ui-tile:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.ui-tile::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--tile-bar); }
.ui-tile__top { display: flex; align-items: center; justify-content: space-between; color: var(--text-dim); }
.ui-tile__icon { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px;
  border-radius: 12px; background: var(--tile-bg); color: var(--tile-fg); }
.ui-tile__num { padding-top: 6px; font: 600 15px/1.2 var(--font); }
.ui-tile__num strong { font-size: 34px; line-height: 40px; font-weight: 700; margin-right: 6px; }
.ui-tile__sub { font-size: var(--fs-label); line-height: var(--lh-label); color: var(--text-dim); }
.ui-tile--orders  { --tile-bar: var(--accent-strong); --tile-bg: var(--tone-accent-bg);  --tile-fg: var(--tone-accent-fg); }
.ui-tile--members { --tile-bar: var(--info);          --tile-bg: var(--tone-info-bg);    --tile-fg: var(--tone-info-fg); }
.ui-tile--interns { --tile-bar: var(--good);          --tile-bg: var(--tone-success-bg); --tile-fg: var(--tone-success-fg); }
.ui-tile--money   { --tile-bar: var(--warn);          --tile-bg: var(--tone-warning-bg); --tile-fg: var(--tone-warning-fg); }
.ui-tile--admin   { --tile-bar: var(--text-dim);      --tile-bg: var(--tone-neutral-bg); --tile-fg: var(--tone-neutral-fg); }
.ui-today__more { margin: 0; padding: var(--s-3) var(--s-5); border-top: 1px solid var(--border); font-size: var(--fs-small); }

.ui-today__down .ui-callout { flex: 1; }

/* Floor timeline — one row per machine; blocks positioned by % of the day */
.ui-floor__scroll { overflow-x: auto; }
.ui-floor__grid { position: relative; display: grid; grid-template-columns: 150px minmax(480px, 1fr);
  --hours: 9; /* overridden inline with today's open hours */ }
.ui-floor__corner { height: 24px; }
.ui-floor__hours { display: grid; grid-template-columns: repeat(var(--hours), 1fr); height: 24px;
  font: 500 11px/1 var(--font); color: var(--text-dim); }
.ui-floor__hours > span { padding-left: 4px; border-left: 1px solid var(--border); }
.ui-floor__name { display: flex; align-items: center; height: 46px; padding-right: var(--s-3); border-top: 1px solid var(--border);
  font: 600 13px/1.2 var(--font); color: var(--text); text-decoration: none; }
.ui-floor__track { position: relative; height: 46px; border-top: 1px solid var(--border);
  background-image: linear-gradient(to right, var(--border) 1px, transparent 1px);
  background-size: calc(100% / var(--hours)) 100%; }
.ui-floor__block { position: absolute; top: 7px; bottom: 7px; display: flex; align-items: center; padding: 0 10px;
  overflow: hidden; white-space: nowrap; border-radius: var(--r-control); font: 600 12px/1 var(--font);
  text-decoration: none; box-sizing: border-box; min-width: 6px; }
.ui-floor__block--reserved { background: var(--tone-info-bg); color: var(--tone-info-fg); border: 1px solid var(--info); }
.ui-floor__block--in_use { background: var(--accent-strong); color: var(--on-accent); z-index: 1; }
.ui-floor__block--down { background: var(--tone-danger-bg); color: var(--tone-danger-fg); border: 1px dashed var(--alert); }
.ui-floor__free { position: absolute; left: 10px; top: 15px; font-size: var(--fs-label); color: var(--text-dim); }
.ui-floor__list { display: none; list-style: none; margin: 0; padding: 0; }
.ui-floor__list li + li { border-top: 1px solid var(--border); }
.ui-floor__list a { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: 10px 0;
  color: var(--text); text-decoration: none; font-size: var(--fs-small); }
.ui-floor__li-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ui-floor__nowlayer { position: absolute; top: 18px; bottom: 0; left: 150px; right: 0; pointer-events: none; }
.ui-floor__now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent-strong); }
.ui-floor__now > span { position: absolute; top: -2px; left: -22px; padding: 1px 5px; border-radius: var(--r-pill);
  background: var(--accent-strong); color: var(--on-accent); font: 700 10px/1.4 var(--font); white-space: nowrap; }

/* Stat cards */
.ui-stat { display: flex; flex-direction: column; gap: var(--s-2); align-items: flex-start; color: var(--text);
  text-decoration: none; padding: 18px; }
.ui-stat:hover { border-color: var(--border-strong); }
.ui-stat__head { display: flex; align-items: center; gap: 10px; font: 600 14px/1 var(--font); }
.ui-stat__icon { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 10px; }
.ui-stat__icon--info { background: var(--tone-info-bg); color: var(--tone-info-fg); }
.ui-stat__icon--warning { background: var(--tone-warning-bg); color: var(--tone-warning-fg); }
.ui-stat__value { font-size: var(--fs-small); color: var(--text-dim); }
.ui-stat__value strong { font-size: 26px; line-height: 32px; color: var(--text); margin-right: 4px; }

/* Ready for pickup */
.ui-ready { display: flex; align-items: center; gap: 14px; padding: var(--s-4); color: var(--text); text-decoration: none; }
.ui-ready__thumb { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 52px; height: 52px;
  border-radius: 10px; background: var(--tone-success-bg); color: var(--tone-success-fg); }
.ui-ready__text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.ui-ready__eyebrow { font: 700 12px/1 var(--font); color: var(--tone-success-fg); }

/* Rail */
.ui-avatars { display: flex; margin-bottom: var(--s-3); }
.ui-avatars__one { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; margin-right: -10px;
  border-radius: 50%; border: 2px solid var(--surface); font: 700 12px/1 var(--font); }
.ui-avatars__one--0 { background: var(--tone-accent-bg); color: var(--tone-accent-fg); }
.ui-avatars__one--1 { background: var(--tone-info-bg); color: var(--tone-info-fg); }
.ui-avatars__one--2 { background: var(--tone-success-bg); color: var(--tone-success-fg); }
.ui-avatars__one--3 { background: var(--tone-warning-bg); color: var(--tone-warning-fg); }
.ui-avatars__one--4 { background: var(--tone-neutral-bg); color: var(--tone-neutral-fg); }
.ui-list { list-style: none; margin: 0 0 var(--s-2); padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: var(--fs-small); }
.ui-list li { display: flex; flex-direction: column; gap: 1px; }
.ui-list a { color: var(--text); text-decoration: none; }
.ui-makes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ui-makes__one { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.ui-makes__one img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 12px; background: var(--bg-elev); }
.ui-makes__one figcaption { display: flex; flex-direction: column; font-size: var(--fs-label); line-height: var(--lh-label); }

@media (max-width: 1100px) { .ui-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .ui-hero { padding: var(--s-5) var(--s-4) calc(var(--s-7) + var(--s-5)); border-radius: 12px; }
  .ui-hero::before, .ui-hero::after { display: none; }
  .ui-hero__title { font-size: 24px; line-height: 30px; }
  .ui-hero { flex-direction: column; }
  .ui-tiles { margin: calc(-1 * var(--s-7)) var(--s-3) 0; gap: var(--s-3); }
  .ui-tile { padding: 14px; }
  .ui-tile__num strong { font-size: 28px; line-height: 32px; }
  .ui-floor__scroll { display: none; }
  .ui-floor__list { display: block; }
  .ui-floor .ui-card__head { flex-wrap: wrap; }
  .ui-today__down { flex-direction: column; align-items: stretch; }
}
