/* ==========================================================================
   Design tokens: the ONLY place for colours, fonts, radii, spacing, shadows.
   Neutral base theme. Theme files (themes/a.css, b.css, c.css) override these
   variables; each shop's colours (shops.colors_json) override --c-accent*.
   No glass: solid surfaces, thin borders, soft shadows, no blur.
   ========================================================================== */
/* Figtree variable font (SIL OFL 1.1), self-hosted from public/fonts. */
@font-face { font-family: "Figtree"; font-style: normal; font-weight: 300 900; font-display: swap; src: url("/fonts/figtree-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Figtree"; font-style: normal; font-weight: 300 900; font-display: swap; src: url("/fonts/figtree-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  /* Type */
  --font-sans: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2.25rem;
  --weight-normal: 500;
  --weight-medium: 600;
  --weight-bold: 700;
  --weight-heavy: 800;
  --leading: 1.5;

  /* Colours (neutral grey base; contrast checked for WCAG 2.2 AA) */
  --c-bg: #f5f6f8;
  --c-surface: #ffffff;
  --c-surface-2: #f0f1f4;
  --c-border: #e2e4e9;
  --c-border-strong: #c9ccd3;
  --c-text: #1b1d22;
  --c-text-muted: #5b606b;
  --c-accent: #3a3f4b;
  --c-accent-strong: #23262e;
  --c-accent-soft: #e7e8ec;
  --c-on-accent: #ffffff;
  --c-success: #1c7a43;
  --c-success-soft: #e3f4ea;
  --c-danger: #b42318;
  --c-danger-soft: #fdeceb;
  --c-warning: #8a5a00;
  --c-warning-soft: #fdf3dc;
  --c-info: #1d5fa8;
  --c-info-soft: #e5effa;
  --c-focus: #2563eb;
  --chart-1: #3a3f4b;
  --chart-2: #8a90a0;
  --chart-3: #c3c7d1;
  --chart-4: #1c7a43;
  --chart-5: #b42318;

  /* Navigation (sidebar / rail / pills) */
  --c-sidebar-bg: #ffffff;
  --c-nav-text: #4a4f5a;
  --c-nav-heading: #6b7080;
  --c-nav-hover-bg: #f0f1f4;
  --c-nav-active-bg: #3a3f4b;
  --c-nav-active-text: #ffffff;
  --c-backdrop: rgba(16, 24, 40, 0.45);

  /* Shape */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --border-width: 1px;
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-pop: 0 8px 24px rgba(16, 24, 40, 0.10);

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Layout */
  --sidebar-width: 248px;
  --nav-item-height: 38px;
  --icon-size: 18px;
  --rail-width: 72px;
  --topbar-height: 60px;
  --content-max: 1280px;
}

/* Theme A "Clear blue": soft blue accent on pale grey, slim icon rail in HQ.
   Overrides src/ui/tokens.css variables only (no selectors, no layout).
   Contrast checked: node docs/design/contrast.mjs */
:root {

  --c-bg: #f3f5f9;
  --c-surface: #ffffff;
  --c-surface-2: #eef2f8;
  --c-border: #e3e8f0;
  --c-border-strong: #808ba0;
  --c-text: #131a29;
  --c-text-muted: #556076;
  --c-accent: #2d67e8;
  --c-accent-strong: #1d4fc4;
  --c-accent-soft: #e7eefd;
  --c-on-accent: #ffffff;
  --c-success: #157347;
  --c-success-soft: #e2f4ea;
  --c-danger: #be2430;
  --c-danger-soft: #fdebed;
  --c-warning: #8a5200;
  --c-warning-soft: #fdf1da;
  --c-info: #1d5cc0;
  --c-info-soft: #e7effc;
  --c-focus: #2d67e8;
  --chart-1: #2d67e8;
  --chart-2: #7fa3f2;
  --chart-3: #d4e0fb;
  --chart-4: #1a8a55;
  --chart-5: #d23a45;

  --c-sidebar-bg: #ffffff;
  --c-nav-text: #4b566b;
  --c-nav-heading: #66708a;
  --c-nav-active-bg: #2d67e8;
  --c-nav-active-text: #ffffff;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-card: 0 1px 2px rgba(19, 26, 41, 0.04), 0 2px 8px rgba(19, 26, 41, 0.03);
  --shadow-pop: 0 10px 28px rgba(19, 26, 41, 0.10);

  --sidebar-width: 240px;
  --rail-width: 72px;
  --topbar-height: 64px;
}

/* Shared components for the owner dashboard and the agency HQ.
   Uses tokens only (var(--...)); no raw colours here. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font-sans); font-size: var(--text-md); line-height: var(--leading); color: var(--c-text); background: var(--c-bg); }
a { color: var(--c-accent-strong); }
img, svg { max-width: 100%; }
:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 var(--space-3); }
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
.muted { color: var(--c-text-muted); }
.small { font-size: var(--text-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* App shell, sidebar, topbar: see nav.css */

/* Cards and grids */
.card { background: var(--c-surface); border: var(--border-width) solid var(--c-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); padding: var(--space-5); }
.card > h2, .card > h3 { font-size: var(--text-md); font-weight: var(--weight-bold); }
.grid { display: grid; gap: var(--space-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: grid; gap: var(--space-4); }
.row { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); }

/* Stat cards */
.stat { display: grid; gap: var(--space-1); }
.stat .label { color: var(--c-text-muted); font-size: var(--text-sm); }
.stat .value { font-size: var(--text-3xl); font-weight: var(--weight-bold); letter-spacing: -0.02em; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: var(--weight-medium); background: var(--c-surface-2); color: var(--c-text-muted); }
.badge.up, .pill.green { background: var(--c-success-soft); color: var(--c-success); }
.badge.down, .pill.red { background: var(--c-danger-soft); color: var(--c-danger); }
.pill { display: inline-block; padding: 2px 10px; border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: var(--weight-medium); background: var(--c-surface-2); color: var(--c-text-muted); }
.pill.amber { background: var(--c-warning-soft); color: var(--c-warning); }
.pill.blue { background: var(--c-info-soft); color: var(--c-info); }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th { text-align: left; color: var(--c-text-muted); font-weight: var(--weight-medium); padding: var(--space-2) var(--space-3); border-bottom: var(--border-width) solid var(--c-border); }
.table td { padding: var(--space-3); border-bottom: var(--border-width) solid var(--c-border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* Forms and buttons */
label { display: grid; gap: var(--space-1); font-size: var(--text-sm); font-weight: var(--weight-medium); }
input, select, textarea { font: inherit; color: var(--c-text); background: var(--c-surface); border: var(--border-width) solid var(--c-border-strong); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); min-height: 40px; width: 100%; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; }
textarea { min-height: 96px; }
.form { display: grid; gap: var(--space-4); max-width: 640px; }
.check { display: flex; gap: var(--space-2); align-items: center; font-weight: var(--weight-normal); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 40px; padding: var(--space-2) var(--space-4); border-radius: var(--radius-sm); border: var(--border-width) solid var(--c-border-strong); background: var(--c-surface); color: var(--c-text); font: inherit; font-weight: var(--weight-medium); font-size: var(--text-sm); text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--c-surface-2); }
.btn.primary { background: var(--c-accent); border-color: var(--c-accent); color: var(--c-on-accent); }
.btn.primary:hover { background: var(--c-accent-strong); }
.btn.danger { color: var(--c-danger); }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: var(--text-xs); }
.notice { padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--c-info-soft); color: var(--c-info); font-size: var(--text-sm); }
.notice.ok { background: var(--c-success-soft); color: var(--c-success); }
.notice.err { background: var(--c-danger-soft); color: var(--c-danger); }
.fake-tag { display: inline-block; font-size: var(--text-xs); padding: 1px 6px; border-radius: var(--radius-sm); background: var(--c-warning-soft); color: var(--c-warning); font-weight: var(--weight-medium); }

/* Charts (inline SVG) */
.chart { width: 100%; height: auto; display: block; }
.chart .line { fill: none; stroke: var(--chart-1); stroke-width: 2; }
.chart .area { fill: var(--c-accent-soft); }
.chart .bar { fill: var(--chart-1); }
.chart .bar.alt { fill: var(--chart-3); }
.chart .axis { stroke: var(--c-border); }
.chart text { fill: var(--c-text-muted); font-size: 11px; }

/* Login page */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: var(--space-5); }
.auth-card { width: 100%; max-width: 400px; }

/* Phone */
@media (max-width: 860px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .grid-4.keep-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat .value { font-size: var(--text-2xl); }
}

/* Chart hover points, highlighted bar and tooltip (public/js/charts.js). */
.chart-box { position: relative; }
.chart .pt { fill: var(--c-surface); stroke: transparent; stroke-width: 18; paint-order: stroke; opacity: 0; cursor: pointer; }
.chart .pt.is-on { opacity: 1; fill: var(--chart-1); stroke: var(--c-surface); stroke-width: 3; }
.chart .bar { cursor: pointer; }
.chart.has-hi .bar:not(.hi) { fill: var(--chart-3); }
.chart .bar.is-on:not(.hi) { fill: var(--chart-2); }
.chart .bar-spark .bar, .chart.bar-spark .bar { cursor: default; }
.chart.bar-spark .bar.alt { fill: var(--chart-3); }
.chart-tip { position: absolute; z-index: 5; display: grid; gap: 2px; padding: 8px 12px; border-radius: var(--radius-md); background: var(--c-text); color: var(--c-surface); box-shadow: var(--shadow-pop); font-size: var(--text-xs); line-height: 1.3; white-space: nowrap; pointer-events: none; }
.chart-tip[hidden] { display: none; }
.chart-tip-value { font-size: var(--text-sm); font-variant-numeric: tabular-nums; }

/* App shell: grouped sidebar + topbar + main. Shared by the owner dashboard
   and the agency HQ. Tokens only. Desktop: full sidebar; 721-1024px: icon
   rail with tooltips; phone: hamburger + slide-out drawer (public/js/nav.js). */
.shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--c-sidebar-bg); border-right: var(--border-width) solid var(--c-border); padding: var(--space-4) var(--space-3); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-5); z-index: 50; }
.brand { display: flex; align-items: center; gap: var(--space-3); text-decoration: none; color: var(--c-text); padding: var(--space-1) var(--space-2); }
.brand-tile, .avatar { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: var(--radius-md); background: var(--c-nav-active-bg); color: var(--c-nav-active-text); font-weight: var(--weight-bold); }
.avatar { border-radius: var(--radius-pill); background: var(--c-accent-soft); color: var(--c-accent-strong); width: 34px; height: 34px; }
.brand-text, .user-text { display: grid; min-width: 0; line-height: 1.25; }
.brand-text b, .user-text b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: var(--text-sm); }
.brand-text small, .user-text small { color: var(--c-text-muted); font-size: var(--text-xs); }
.sidebar nav { display: grid; gap: var(--space-5); flex: 1; align-content: start; }
.nav-group { display: grid; gap: var(--space-1); }
.nav-heading { margin: 0 0 2px; padding: 0 var(--space-3); font-size: 11px; font-weight: var(--weight-bold); letter-spacing: 0.08em; text-transform: uppercase; color: var(--c-nav-heading); }
.nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav a { position: relative; display: flex; align-items: center; gap: var(--space-3); min-height: var(--nav-item-height); padding: 0 var(--space-3); border-radius: var(--radius-pill); color: var(--c-nav-text); text-decoration: none; font-size: var(--text-sm); font-weight: var(--weight-medium); }
.nav a .icon { width: var(--icon-size); height: var(--icon-size); flex: none; }
.nav a:hover { background: var(--c-nav-hover-bg); color: var(--c-text); }
.nav a:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 1px; }
.nav a[aria-current="page"] { background: var(--c-nav-active-bg); color: var(--c-nav-active-text); font-weight: var(--weight-bold); }
.nav a[aria-current="page"] .icon { stroke-width: 2.5; }
.nav-badge { margin-left: auto; min-width: 22px; height: 22px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: var(--radius-pill); background: var(--c-danger); color: #fff; font-size: var(--text-xs); font-weight: var(--weight-bold); }
.user-card { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3); border: var(--border-width) solid var(--c-border); border-radius: var(--radius-lg); background: var(--c-surface); }
.user-card .user-text { flex: 1; }
.user-card form { margin: 0; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-md); border: var(--border-width) solid var(--c-border); background: var(--c-surface); color: var(--c-text); cursor: pointer; position: relative; text-decoration: none; padding: 0; }
.icon-btn:hover { background: var(--c-surface-2); }
.icon-btn .icon { width: var(--icon-size); height: var(--icon-size); }
.dot-badge { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: var(--radius-pill); background: var(--c-danger); color: #fff; font-size: 11px; font-weight: var(--weight-bold); display: grid; place-items: center; }
.backdrop { position: fixed; inset: 0; background: var(--c-backdrop); z-index: 45; }
.backdrop[hidden] { display: none; }
.drawer-toggle { display: none !important; }
.main { min-width: 0; }
.topbar { min-height: var(--topbar-height); display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-6); background: var(--c-surface); border-bottom: var(--border-width) solid var(--c-border); position: sticky; top: 0; z-index: 40; }
.topbar .search { flex: 1; max-width: 460px; position: relative; display: flex; align-items: center; }
.topbar .search .icon { position: absolute; left: 14px; color: var(--c-text-muted); width: 16px; height: 16px; }
.topbar .search input { padding-left: 40px !important; border-radius: var(--radius-pill) !important; background: var(--c-surface-2) !important; border-color: var(--c-border) !important; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-3); }
.hello { font-size: var(--text-sm); color: var(--c-text-muted); white-space: nowrap; }
.content { padding: var(--space-6) var(--space-6) var(--space-8); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); flex-wrap: wrap; }
.page-head h1 { margin: 0; }

@media (max-width: 1024px) and (min-width: 721px) {
  .shell { grid-template-columns: var(--rail-width) minmax(0, 1fr); }
  .sidebar { padding: var(--space-3) var(--space-2); align-items: center; overflow: visible; gap: var(--space-3); }
  .brand-text, .nav-text, .nav-heading, .user-text, .nav-badge { display: none; }
  .brand { padding: 0; }
  .sidebar nav { gap: var(--space-2); }
  .nav-group { justify-items: center; padding-top: var(--space-2); border-top: var(--border-width) solid var(--c-border); }
  .nav-group:first-child { border-top: 0; padding-top: 0; }
  .nav a { width: 44px; height: 44px; min-height: 44px; padding: 0; justify-content: center; }
  .nav a::after, .user-card .icon-btn::after { content: attr(data-label); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%); background: var(--c-text); color: var(--c-surface); padding: 4px 10px; border-radius: var(--radius-sm); font-size: var(--text-xs); font-weight: var(--weight-medium); white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 60; }
  .nav a:hover::after, .nav a:focus-visible::after, .user-card .icon-btn:hover::after, .user-card .icon-btn:focus-visible::after { opacity: 1; }
  .user-card { flex-direction: column; padding: 0; border: 0; background: transparent; }
  .topbar { padding: var(--space-2) var(--space-4); }
  .content { padding: var(--space-5) var(--space-4) var(--space-7); }
}
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .drawer-toggle { display: inline-grid !important; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; height: 100%; width: min(300px, 86vw); transform: translateX(-102%); visibility: hidden; transition: transform .2s ease, visibility .2s; box-shadow: var(--shadow-pop); }
  body.nav-open .sidebar { transform: none; visibility: visible; }
  body.nav-open { overflow: hidden; }
  .topbar { padding: var(--space-2) var(--space-3); }
  .topbar .search { max-width: none; }
  .hello, .topbar-actions .btn { display: none; }
  .content { padding: var(--space-4) var(--space-3) var(--space-7); }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

/* ==========================================================================
   Component kit for the owner dashboard and agency HQ. Tokens only.
   Patterns referenced (no code or dependency taken): shadcn/ui (MIT) for
   switch / segmented / sheet / toast anatomy, Tabler (MIT) for tables,
   empty states and form layout. Every native control is restyled here so
   nothing looks like a browser default. Touch targets >= 44px on coarse
   pointers, visible focus rings everywhere.
   ========================================================================== */
:root {
  --ctl-h: 40px;
  --ctl-h-sm: 32px;
  --ctl-h-lg: 48px;
  --ring: 0 0 0 3px color-mix(in srgb, var(--c-focus) 35%, transparent);
  --ease: cubic-bezier(.2, .8, .2, 1);
}
@media (pointer: coarse) { :root { --ctl-h: 44px; --ctl-h-sm: 40px; } }

/* ---------- Buttons ---------- */
.btn, button.btn, a.btn, input[type="submit"].btn {
  --b-bg: var(--c-surface); --b-fg: var(--c-text); --b-bd: var(--c-border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--ctl-h); padding: 0 var(--space-4); border-radius: var(--radius-md);
  border: var(--border-width) solid var(--b-bd); background: var(--b-bg); color: var(--b-fg);
  font: inherit; font-size: var(--text-sm); font-weight: var(--weight-bold); line-height: 1; text-decoration: none; white-space: nowrap;
  cursor: pointer; user-select: none; transition: background .15s var(--ease), border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--c-surface-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn .icon { width: 16px; height: 16px; }
.btn.primary { --b-bg: var(--c-accent); --b-fg: var(--c-on-accent); --b-bd: var(--c-accent); box-shadow: var(--shadow-card); }
.btn.primary:hover { background: var(--c-accent-strong); border-color: var(--c-accent-strong); }
.btn.secondary { --b-bg: var(--c-accent-soft); --b-fg: var(--c-accent-strong); --b-bd: transparent; }
.btn.secondary:hover { background: color-mix(in srgb, var(--c-accent-soft) 70%, var(--c-accent) 12%); }
.btn.ghost { --b-bg: transparent; --b-bd: transparent; --b-fg: var(--c-text-muted); }
.btn.ghost:hover { background: var(--c-surface-2); color: var(--c-text); }
.btn.danger { --b-bg: var(--c-surface); --b-fg: var(--c-danger); --b-bd: color-mix(in srgb, var(--c-danger) 35%, var(--c-border)); }
.btn.danger:hover { background: var(--c-danger-soft); }
.btn.danger.solid { --b-bg: var(--c-danger); --b-fg: #fff; --b-bd: var(--c-danger); }
.btn.small, .btn.sm { min-height: var(--ctl-h-sm); padding: 0 var(--space-3); font-size: var(--text-xs); border-radius: var(--radius-sm); }
.btn.large, .btn.lg { min-height: var(--ctl-h-lg); padding: 0 var(--space-5); font-size: var(--text-md); }
.btn.block { width: 100%; }
.btn.icon-only { width: var(--ctl-h); padding: 0; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn.is-loading { color: transparent !important; position: relative; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--b-fg); border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-row { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }

/* ---------- Form fields ---------- */
.field { display: grid; gap: 6px; }
.field > label, .field-label, label:not(.check):not(.switch):not(.chip):not(.seg-item) { font-size: var(--text-sm); font-weight: var(--weight-bold); color: var(--c-text); }
.help { font-size: var(--text-xs); color: var(--c-text-muted); font-weight: var(--weight-normal); }
.error-text { font-size: var(--text-xs); color: var(--c-danger); font-weight: var(--weight-medium); }
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="hidden"]),
select, textarea {
  appearance: none; -webkit-appearance: none; width: 100%; min-height: var(--ctl-h);
  padding: 0 var(--space-3); border: var(--border-width) solid var(--c-border-strong); border-radius: var(--radius-md);
  background: var(--c-surface); color: var(--c-text); font: inherit; font-size: var(--text-sm); font-weight: var(--weight-normal);
  transition: border-color .15s, box-shadow .15s;
}
textarea { padding: var(--space-3); min-height: 104px; line-height: var(--leading); resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--c-text-muted); opacity: .8; }
input:hover, select:hover, textarea:hover { border-color: var(--c-text-muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--c-focus); box-shadow: var(--ring); }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--c-danger); }
input:disabled, select:disabled, textarea:disabled { background: var(--c-surface-2); color: var(--c-text-muted); cursor: not-allowed; }
select { padding-right: 36px; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7080' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
input[type="time"], input[type="date"], input[type="month"] { padding-right: var(--space-2); }
input[type="color"] { appearance: none; width: 56px; height: var(--ctl-h); padding: 4px; border: var(--border-width) solid var(--c-border-strong); border-radius: var(--radius-md); background: var(--c-surface); cursor: pointer; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: var(--radius-sm); }
input[type="file"] { font: inherit; font-size: var(--text-sm); color: var(--c-text-muted); max-width: 100%; }
input[type="file"]::file-selector-button { font: inherit; font-size: var(--text-xs); font-weight: var(--weight-bold); min-height: var(--ctl-h-sm); padding: 0 var(--space-3); margin-right: var(--space-3); border-radius: var(--radius-sm); border: var(--border-width) solid var(--c-border-strong); background: var(--c-surface); color: var(--c-text); cursor: pointer; }
input[type="file"]::file-selector-button:hover { background: var(--c-surface-2); }
.input-group { display: flex; align-items: stretch; }
.input-group .addon { display: grid; place-items: center; padding: 0 var(--space-3); border: var(--border-width) solid var(--c-border-strong); border-right: 0; border-radius: var(--radius-md) 0 0 var(--radius-md); background: var(--c-surface-2); color: var(--c-text-muted); font-size: var(--text-sm); }
.input-group input { border-radius: 0 var(--radius-md) var(--radius-md) 0 !important; }
.money-in { max-width: 120px; text-align: right; font-variant-numeric: tabular-nums; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-size: var(--text-sm); font-weight: var(--weight-bold); padding: 0; margin-bottom: var(--space-2); }
.form-section { display: grid; gap: var(--space-4); padding: var(--space-5) 0; border-top: var(--border-width) solid var(--c-border); }
.form-section:first-child { border-top: 0; padding-top: 0; }
.form-actions { display: flex; gap: var(--space-2); justify-content: flex-end; padding-top: var(--space-4); border-top: var(--border-width) solid var(--c-border); }

/* ---------- Checkbox & radio ---------- */
input[type="checkbox"]:not(.switch-input), input[type="radio"] {
  appearance: none; -webkit-appearance: none; flex: none; width: 18px; height: 18px; margin: 0;
  border: 1.5px solid var(--c-border-strong); background: var(--c-surface); border-radius: 5px; cursor: pointer;
  display: inline-grid; place-items: center; transition: background .12s, border-color .12s; vertical-align: middle;
}
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]:not(.switch-input):checked { background: var(--c-accent); border-color: var(--c-accent); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E"); background-size: 12px; background-repeat: no-repeat; background-position: center; }
input[type="checkbox"]:not(.switch-input):indeterminate { background: var(--c-accent); border-color: var(--c-accent); background-image: linear-gradient(#fff, #fff); background-size: 10px 2px; background-repeat: no-repeat; background-position: center; }
input[type="radio"]:checked { border-color: var(--c-accent); border-width: 5px; }
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outline: none; box-shadow: var(--ring); }
input[type="checkbox"]:disabled, input[type="radio"]:disabled { opacity: .5; cursor: not-allowed; }
.check { display: inline-flex; gap: var(--space-2); align-items: center; font-size: var(--text-sm); font-weight: var(--weight-medium); cursor: pointer; min-height: 32px; }

/* ---------- Toggle switch:
   <label class="switch"><input type="checkbox" class="switch-input" role="switch"><span class="switch-track"></span> Label</label> */
.switch { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; font-size: var(--text-sm); font-weight: var(--weight-medium); min-height: 32px; position: relative; }
.switch-input { position: absolute; opacity: 0; width: 36px; height: 20px; margin: 0; cursor: pointer; }
.switch-track { flex: none; width: 36px; height: 20px; border-radius: var(--radius-pill); background: color-mix(in srgb, var(--c-text-muted) 38%, var(--c-surface)); position: relative; transition: background .18s var(--ease); }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(16, 24, 40, .25); transition: transform .18s var(--ease); }
.switch-input:checked + .switch-track { background: var(--c-accent); }
.switch-input:checked + .switch-track::after { transform: translateX(16px); }
.switch-input:focus-visible + .switch-track { box-shadow: var(--ring); }
.switch-input:disabled + .switch-track { opacity: .5; }
.switch.danger .switch-input:checked + .switch-track { background: var(--c-danger); }
.switch.warn .switch-input:checked + .switch-track { background: var(--c-warning); }

/* ---------- Segmented control: <div class="seg" role="radiogroup"><label class="seg-item"><input type="radio" name=..>Day</label>... or links with aria-current */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--radius-md); background: var(--c-surface-2); border: var(--border-width) solid var(--c-border); }
.seg-item, .seg > a { position: relative; display: inline-flex; align-items: center; justify-content: center; min-height: calc(var(--ctl-h) - 8px); padding: 0 var(--space-3); border-radius: calc(var(--radius-md) - 3px); font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--c-text-muted); text-decoration: none; cursor: pointer; }
.seg-item input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-item:has(input:checked), .seg > a[aria-current], .seg > a.active { background: var(--c-surface); color: var(--c-text); box-shadow: var(--shadow-card); font-weight: var(--weight-bold); }
.seg-item:has(input:focus-visible), .seg > a:focus-visible { box-shadow: var(--ring); outline: none; }

/* ---------- Search field ---------- */
.search-field { position: relative; display: flex; align-items: center; min-width: 200px; }
.search-field .icon { position: absolute; left: 12px; width: 16px; height: 16px; color: var(--c-text-muted); pointer-events: none; }
.search-field input { padding-left: 38px !important; border-radius: var(--radius-pill) !important; }

/* ---------- Filter chips ---------- */
.chips { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: var(--ctl-h-sm); padding: 0 var(--space-3); border-radius: var(--radius-pill); border: var(--border-width) solid var(--c-border-strong); background: var(--c-surface); color: var(--c-text-muted); font-size: var(--text-sm); font-weight: var(--weight-medium); text-decoration: none; cursor: pointer; position: relative; }
.chip:hover { border-color: var(--c-text-muted); color: var(--c-text); }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip[aria-pressed="true"], .chip[aria-current], .chip:has(input:checked) { background: var(--c-accent); border-color: var(--c-accent); color: var(--c-on-accent); }
.chip .count { font-size: var(--text-xs); padding: 0 6px; border-radius: var(--radius-pill); background: var(--c-surface-2); color: var(--c-text-muted); }
.chip[aria-pressed="true"] .count, .chip[aria-current] .count { background: color-mix(in srgb, var(--c-on-accent) 22%, transparent); color: var(--c-on-accent); }
.chip:focus-visible { outline: none; box-shadow: var(--ring); }

/* ---------- Badges & status pills (pill / badge already in app.css: extended) ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; font-weight: var(--weight-bold); }
.pill.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.grey { background: var(--c-surface); color: var(--c-text-muted); box-shadow: inset 0 0 0 1px var(--c-border); }
.pill.accent { background: var(--c-accent-soft); color: var(--c-accent-strong); }

/* ---------- Tables ---------- */
.table-card { background: var(--c-surface); border: var(--border-width) solid var(--c-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); overflow: hidden; }
.table-card .table-wrap { overflow-x: auto; }
.table thead th { position: sticky; top: 0; z-index: 1; background: var(--c-surface); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .05em; font-weight: var(--weight-bold); padding: var(--space-3); white-space: nowrap; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--c-surface-2); }
.table tbody tr.is-selected { background: var(--c-accent-soft); }
.table td { padding: var(--space-3); }
.table .actions { text-align: right; white-space: nowrap; }
.table .cell-main { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.table .cell-main b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 720px) {
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { padding: var(--space-3) var(--space-4); border-bottom: var(--border-width) solid var(--c-border); }
  .table.responsive td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: var(--space-3); text-align: right; }
  .table.responsive td::before { content: attr(data-label); color: var(--c-text-muted); font-size: var(--text-xs); font-weight: var(--weight-bold); text-transform: uppercase; letter-spacing: .04em; text-align: left; }
  .table.responsive td.cell-full { display: block; text-align: left; }
  .table.responsive td.cell-full::before { content: none; }
  .table.responsive .num { text-align: right; }
}

/* ---------- Cards ---------- */
.card { border-radius: var(--radius-lg); }
.card.flush { padding: 0; overflow: hidden; }
.card.hoverable { transition: box-shadow .15s, border-color .15s; }
.card.hoverable:hover { box-shadow: var(--shadow-pop); border-color: var(--c-border-strong); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: var(--border-width) solid var(--c-border); }
.card-header h2, .card-header h3 { margin: 0; font-size: var(--text-md); }
.card-body { padding: var(--space-5); }
.card-footer { padding: var(--space-3) var(--space-5); border-top: var(--border-width) solid var(--c-border); background: var(--c-surface-2); }
.toolbar { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; padding: var(--space-3) var(--space-4); border-bottom: var(--border-width) solid var(--c-border); }
.toolbar .grow { flex: 1; }

/* ---------- Tabs: <nav class="tabs"><a aria-current="page">..</a></nav> ---------- */
.tabs { display: flex; gap: var(--space-1); border-bottom: var(--border-width) solid var(--c-border); margin-bottom: var(--space-5); overflow-x: auto; }
.tabs a, .tabs button { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 var(--space-3); border: 0; border-bottom: 2px solid transparent; background: none; color: var(--c-text-muted); font: inherit; font-size: var(--text-sm); font-weight: var(--weight-medium); text-decoration: none; white-space: nowrap; cursor: pointer; margin-bottom: -1px; }
.tabs a:hover, .tabs button:hover { color: var(--c-text); }
.tabs a[aria-current], .tabs button[aria-selected="true"] { color: var(--c-accent-strong); border-bottom-color: var(--c-accent); font-weight: var(--weight-bold); }
.tabs a:focus-visible, .tabs button:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }

/* ---------- Slide-over (sheet) and modal: native <dialog> ---------- */
dialog.sheet, dialog.modal { border: 0; padding: 0; color: var(--c-text); background: var(--c-surface); box-shadow: var(--shadow-pop); }
dialog.sheet::backdrop, dialog.modal::backdrop { background: var(--c-backdrop); }
dialog.sheet { position: fixed; inset: 0 0 0 auto; margin: 0; width: min(480px, 100vw); height: 100%; max-height: 100%; border-radius: var(--radius-lg) 0 0 var(--radius-lg); }
dialog.sheet[open] { display: flex; flex-direction: column; overflow-y: auto; animation: sheet-in .22s var(--ease); }
dialog.sheet .sheet-head { position: sticky; top: 0; z-index: 2; background: var(--c-surface); }
dialog.sheet .sheet-foot { position: sticky; bottom: 0; z-index: 2; margin-top: auto; }
dialog.sheet .sheet-body { flex: none; overflow: visible; }
@keyframes sheet-in { from { transform: translateX(40px); opacity: 0; } }
dialog.modal { width: min(520px, calc(100vw - 32px)); border-radius: var(--radius-lg); }
dialog.modal[open] { animation: modal-in .18s var(--ease); }
@keyframes modal-in { from { transform: scale(.97); opacity: 0; } }
.sheet-head, .modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: var(--border-width) solid var(--c-border); }
.sheet-head h2, .modal-head h2 { margin: 0; font-size: var(--text-lg); }
.sheet-body { padding: var(--space-5); overflow-y: auto; flex: 1; display: grid; gap: var(--space-4); align-content: start; }
.modal-body { padding: var(--space-5); }
.sheet-foot, .modal-foot { display: flex; gap: var(--space-2); justify-content: flex-end; padding: var(--space-3) var(--space-5); border-top: var(--border-width) solid var(--c-border); background: var(--c-surface-2); }
@media (max-width: 720px) { dialog.sheet { width: 100vw; border-radius: 0; } }

/* ---------- Toast ---------- */
.toasts { position: fixed; right: var(--space-5); bottom: var(--space-5); z-index: 100; display: grid; gap: var(--space-2); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: var(--space-3); min-width: 240px; max-width: 380px; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--c-text); color: var(--c-surface); font-size: var(--text-sm); font-weight: var(--weight-medium); box-shadow: var(--shadow-pop); animation: toast-in .2s var(--ease); }
.toast.err { background: var(--c-danger); color: #fff; }
.toast .icon { width: 16px; height: 16px; flex: none; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
@media (max-width: 720px) { .toasts { left: var(--space-3); right: var(--space-3); bottom: var(--space-3); } .toast { max-width: none; } }

/* ---------- Empty state & skeleton ---------- */
.empty { display: grid; justify-items: center; gap: var(--space-2); padding: var(--space-7) var(--space-5); text-align: center; color: var(--c-text-muted); }
.empty .empty-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: var(--radius-pill); background: var(--c-surface-2); color: var(--c-text-muted); margin-bottom: var(--space-2); }
.empty .empty-icon .icon { width: 24px; height: 24px; }
.empty h3 { margin: 0; color: var(--c-text); font-size: var(--text-md); }
.empty p { margin: 0; max-width: 40ch; font-size: var(--text-sm); }
.skeleton { display: block; border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--c-surface-2) 25%, var(--c-border) 50%, var(--c-surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; min-height: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Bulk action bar ---------- */
.bulkbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: var(--space-4); width: min(760px, calc(100vw - 24px)); z-index: 60; display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg); background: var(--c-text); color: var(--c-surface); box-shadow: var(--shadow-pop); }
.bulkbar[hidden] { display: none; }
.bulkbar .btn { --b-bg: transparent; --b-fg: var(--c-surface); --b-bd: color-mix(in srgb, var(--c-surface) 35%, transparent); }
.bulkbar .btn:hover { background: color-mix(in srgb, var(--c-surface) 14%, transparent); }
.bulkbar select { width: auto; min-height: var(--ctl-h-sm); }

/* ---------- Notices (restyled) ---------- */
.notice { display: flex; gap: var(--space-2); align-items: center; border: var(--border-width) solid color-mix(in srgb, currentColor 20%, transparent); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---------- Disclosure (<details>) ---------- */
details { border: var(--border-width) solid var(--c-border); border-radius: var(--radius-md); background: var(--c-surface); }
details + details { margin-top: var(--space-2); }
details > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: 44px; padding: 0 var(--space-4); cursor: pointer; font-weight: var(--weight-bold); font-size: var(--text-sm); border-radius: var(--radius-md); }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: ""; width: 16px; height: 16px; flex: none; background: currentColor; opacity: .6; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat; transition: transform .15s var(--ease); }
details[open] > summary::after { transform: rotate(180deg); }
details > summary:hover { background: var(--c-surface-2); }
details > summary:focus-visible { outline: none; box-shadow: var(--ring); }
details > :not(summary) { padding: 0 var(--space-4) var(--space-4); }

/* ---------- Links inside data ---------- */
.table a:not(.btn):not(.chip) { color: var(--c-accent-strong); font-weight: var(--weight-bold); text-decoration: none; }
.table a:not(.btn):not(.chip):hover { text-decoration: underline; }
.content a:not(.btn):not(.chip):not([class]) { color: var(--c-accent-strong); text-underline-offset: 2px; }

/* ---------- Type weight + filled fields (heavier, friendlier look) ---------- */
body { font-weight: var(--weight-normal); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; letter-spacing: -0.005em; }
h1 { font-size: var(--text-3xl); font-weight: var(--weight-heavy); letter-spacing: -0.025em; }
h2, h3, .card-head h2 { font-weight: var(--weight-heavy); letter-spacing: -0.015em; }
.stat .value, .big-num, .spark-card b, .best-count b, .status-box .value { font-weight: var(--weight-heavy); letter-spacing: -0.025em; }
.table td { font-weight: var(--weight-normal); }
.table .cell-main b, .best-name b, .ocard b, .fav b { font-weight: var(--weight-bold); }
.nav a { font-weight: var(--weight-medium); }
.nav a[aria-current="page"] { font-weight: var(--weight-heavy); }
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="hidden"]),
select, textarea { background-color: var(--c-surface-2); border-color: transparent; border-radius: var(--radius-lg); font-weight: var(--weight-medium); font-size: var(--text-md); min-height: 46px; }
input:not([type="checkbox"]):not([type="radio"]):hover, select:hover, textarea:hover { border-color: var(--c-border-strong); }
input:not([type="checkbox"]):not([type="radio"]):focus, select:focus, textarea:focus { background-color: var(--c-surface); border-color: var(--c-focus); }
.input-group .addon { background: var(--c-surface-2); border-color: transparent; border-radius: var(--radius-lg) 0 0 var(--radius-lg); font-weight: var(--weight-bold); color: var(--c-text); padding-right: 0; }
.input-group input { border-radius: 0 var(--radius-lg) var(--radius-lg) 0 !important; }
.menu-table .money-in, .menu-table .price-group .addon { min-height: 40px; font-size: var(--text-sm); }
.btn { border-radius: var(--radius-pill); font-weight: var(--weight-bold); }
.btn.small, .btn.sm { border-radius: var(--radius-pill); }
.chip { font-weight: var(--weight-bold); }

/* Review fix: 44px touch targets on touch screens. */
@media (pointer: coarse) {
  :root { --ctl-h-sm: 44px; }
  .check, .switch, .chip { min-height: 44px; }
  .icon-btn, .topbar .icon-btn { width: 44px; height: 44px; }
  .content .card a:not(.btn):not(.chip) { display: inline-block; padding-block: 10px; margin-block: -10px; }
}

/* Review fix: grid/flex children may shrink so wide tables scroll inside their card. */
.content .card, .content .grid > *, .content .stack > *, .content section { min-width: 0; }
.content .table-wrap { max-width: 100%; }

/* ---------- Kit controls (public/js/ui-controls.mjs) ----------
   The native control stays in the form (hidden); these are the visible parts.
   Pattern matches the checkout pickup picker: popover on desktop, bottom sheet on phones. */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.kit-native { position: absolute !important; width: 1px !important; height: 1px !important; min-height: 0 !important; padding: 0 !important; margin: 0 !important; border: 0 !important; opacity: 0; pointer-events: none; clip: rect(0 0 0 0); overflow: hidden; }
.kit-select, .kit-field { position: relative; display: block; width: 100%; min-width: 0; }
.kit-select.is-inline, .kit-field.is-inline { display: inline-block; width: auto; vertical-align: middle; }
.kit-trigger {
  appearance: none; display: flex; align-items: center; gap: var(--space-2); width: 100%; min-height: 46px; padding: 0 var(--space-3);
  border: var(--border-width) solid transparent; border-radius: var(--radius-lg); background: var(--c-surface-2); color: var(--c-text);
  font: inherit; font-size: var(--text-md); font-weight: var(--weight-medium); text-align: left; cursor: pointer;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.kit-trigger:hover { border-color: var(--c-border-strong); }
.kit-trigger:focus-visible, .kit-trigger[aria-expanded="true"] { outline: none; background: var(--c-surface); border-color: var(--c-focus); box-shadow: var(--ring); }
.kit-trigger:disabled { cursor: not-allowed; color: var(--c-text-muted); border-color: transparent; }
.kit-trigger[aria-invalid="true"] { border-color: var(--c-danger); }
.kit-trigger-val { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kit-trigger.is-placeholder .kit-trigger-val { color: var(--c-text-muted); }
.kit-trigger .kit-ico { flex: none; color: var(--c-text-muted); transition: transform .15s var(--ease); }
.kit-select-btn[aria-expanded="true"] .kit-ico { transform: rotate(180deg); }
.is-sm > .kit-trigger { min-height: var(--ctl-h-sm); font-size: var(--text-sm); border-radius: var(--radius-md); }

.kit-pop {
  position: fixed; inset: auto; margin: 0; z-index: 90; max-width: min(360px, calc(100vw - 16px)); max-height: min(360px, 70vh); overflow: auto;
  padding: var(--space-2); border: var(--border-width) solid var(--c-border); border-radius: var(--radius-lg);
  background: var(--c-surface); color: var(--c-text); box-shadow: var(--shadow-pop);
}
.kit-pop::backdrop { background: transparent; }
.kit-pop.is-sheet { inset: auto 0 0 0; width: 100%; max-width: none; min-width: 0 !important; max-height: 78vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: 0 var(--space-3) calc(var(--space-4) + env(safe-area-inset-bottom)); animation: kit-up .2s var(--ease); }
.kit-pop.is-sheet::backdrop { background: var(--c-backdrop); }
@keyframes kit-up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .kit-pop.is-sheet { animation: none; } }
.kit-pop-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-1) var(--space-3); background: var(--c-surface); }
.kit-pop-head::before { content: ""; position: absolute; top: 6px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: var(--radius-pill); background: var(--c-border); }
.kit-pop-close { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: var(--radius-pill); background: var(--c-surface-2); color: var(--c-text); cursor: pointer; }
.kit-pop-close:focus-visible { outline: none; box-shadow: var(--ring); }

.kit-list { list-style: none; margin: 0; padding: 0; outline: none; }
.kit-group { padding: var(--space-3) var(--space-3) var(--space-1); font-size: 11px; font-weight: var(--weight-bold); letter-spacing: .06em; text-transform: uppercase; color: var(--c-text-muted); }
.kit-opt { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: 40px; padding: 0 var(--space-3); border-radius: var(--radius-sm); font-size: var(--text-sm); font-weight: var(--weight-medium); cursor: pointer; }
.kit-opt .kit-ico { visibility: hidden; color: var(--c-accent); flex: none; }
.kit-opt[aria-selected="true"] { color: var(--c-accent-strong); font-weight: var(--weight-bold); }
.kit-opt[aria-selected="true"] .kit-ico { visibility: visible; }
.kit-opt.is-active { background: var(--c-surface-2); }
.kit-list:focus-visible .kit-opt.is-active { box-shadow: inset 0 0 0 2px var(--c-focus); }
.kit-opt[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.is-sheet .kit-opt { min-height: 48px; font-size: var(--text-md); }

.kit-cal { width: 300px; padding: var(--space-3); }
.kit-pop.kit-cal { max-height: calc(100vh - 16px); }
.kit-pop.is-sheet.kit-cal { width: 100%; }
.kit-cal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-bottom: var(--space-2); }
.kit-cal-title { font-size: var(--text-md); font-weight: var(--weight-bold); }
.kit-cal-nav { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--c-text); cursor: pointer; }
.kit-cal-nav:hover { background: var(--c-surface-2); }
.kit-cal-nav:disabled { opacity: .35; cursor: not-allowed; }
.kit-cal-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.kit-cal-grid th { padding: var(--space-1) 0; font-size: var(--text-xs); font-weight: var(--weight-bold); color: var(--c-text-muted); text-align: center; }
.kit-cal-grid td { padding: 1px; text-align: center; }
.kit-day, .kit-mon { width: 100%; aspect-ratio: 1; max-width: 40px; display: inline-grid; place-items: center; border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--c-text); font: inherit; font-size: var(--text-sm); font-weight: var(--weight-medium); cursor: pointer; font-variant-numeric: tabular-nums; }
.kit-day:hover:not(:disabled), .kit-mon:hover:not(:disabled) { background: var(--c-surface-2); }
.kit-day.is-out { color: var(--c-text-muted); }
.kit-day.is-today, .kit-mon.is-today { box-shadow: inset 0 0 0 1.5px var(--c-accent); }
.kit-day[aria-pressed="true"], .kit-mon[aria-pressed="true"] { background: var(--c-accent); color: var(--c-on-accent); font-weight: var(--weight-bold); }
.kit-day:disabled, .kit-mon:disabled { opacity: .3; cursor: not-allowed; }
.kit-day:focus-visible, .kit-mon:focus-visible, .kit-cal-nav:focus-visible { outline: none; box-shadow: var(--ring); }
.is-sheet .kit-day { max-width: 48px; font-size: var(--text-md); }
.kit-cal-foot { display: flex; justify-content: space-between; gap: var(--space-2); margin-top: var(--space-2); padding-top: var(--space-2); border-top: var(--border-width) solid var(--c-border); }
.kit-month-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }
.kit-mon { aspect-ratio: auto; max-width: none; min-height: 44px; border-radius: var(--radius-md); }

.kit-num { display: flex; align-items: stretch; gap: var(--space-1); width: 100%; min-width: 0; }
.kit-num.is-inline { display: inline-flex; width: auto; }
.kit-num > input { flex: 1; min-width: 56px; text-align: center; font-variant-numeric: tabular-nums; }
.kit-step { flex: none; display: grid; place-items: center; width: 46px; min-height: 46px; border: 0; border-radius: var(--radius-lg); background: var(--c-surface-2); color: var(--c-text); cursor: pointer; transition: background .15s; }
.kit-step:hover:not(:disabled) { background: var(--c-accent-soft); color: var(--c-accent-strong); }
.kit-step:disabled { opacity: .35; cursor: not-allowed; }
.kit-num.is-sm .kit-step { width: var(--ctl-h-sm); min-height: var(--ctl-h-sm); border-radius: var(--radius-md); }

.kit-drop { position: relative; display: block; width: 100%; border: 1.5px dashed var(--c-border-strong); border-radius: var(--radius-lg); background: var(--c-surface-2); transition: border-color .15s, background .15s; }
.kit-drop:hover, .kit-drop.is-over { border-color: var(--c-accent); background: var(--c-accent-soft); }
.kit-drop:focus-within { border-color: var(--c-focus); box-shadow: var(--ring); }
.kit-drop-body { display: grid; justify-items: center; gap: 4px; padding: var(--space-5) var(--space-4); text-align: center; color: var(--c-text-muted); font-size: var(--text-sm); font-weight: var(--weight-medium); pointer-events: none; }
.kit-drop-body .kit-ico { color: var(--c-accent); }
.kit-drop-text { color: var(--c-text); }
.kit-drop-text u { color: var(--c-accent-strong); text-underline-offset: 2px; }
.kit-drop-hint:empty, .kit-drop-file:empty { display: none; }
.kit-drop-hint { font-size: var(--text-xs); }
.kit-drop-file { margin-top: var(--space-1); padding: 2px var(--space-3); border-radius: var(--radius-pill); background: var(--c-surface); color: var(--c-text); font-weight: var(--weight-bold); font-size: var(--text-xs); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kit-drop-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.kit-drop-input::file-selector-button { cursor: pointer; }

.kit-swatch { flex: none; width: 22px; height: 22px; border-radius: var(--radius-sm); box-shadow: inset 0 0 0 1px var(--c-border-strong); }
.kit-colors { width: 248px; padding: var(--space-3); }
.kit-pop.is-sheet.kit-colors { width: 100%; }
.kit-swatch-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--space-2); margin-bottom: var(--space-3); }
.kit-swatch-btn { aspect-ratio: 1; width: 100%; min-height: 32px; border: 0; border-radius: var(--radius-sm); box-shadow: inset 0 0 0 1px var(--c-border-strong); cursor: pointer; }
.kit-swatch-btn[aria-pressed="true"] { box-shadow: inset 0 0 0 1px var(--c-border-strong), 0 0 0 2px var(--c-surface), 0 0 0 4px var(--c-accent); }
.kit-swatch-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.kit-hex { display: flex; gap: var(--space-2); margin: 0; }
.kit-hex input { min-height: var(--ctl-h-sm) !important; font-family: var(--font-mono); text-transform: uppercase; }

/* Owner dashboard layout (tokens only). Home follows the restaurant-admin
   reference: stat cards with rings, best-sellers list, charts, favourites,
   and a full-height right column of sparkline cards + activity timeline. */
.agency-bar { background: var(--c-warning-soft); color: var(--c-warning); padding: var(--space-2) var(--space-5); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); margin-bottom: var(--space-4); }
.card-head h2 { margin: 0; font-size: var(--text-lg); font-weight: var(--weight-bold); }

/* Home grid */
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--space-5); align-items: start; }
.home-main { display: grid; gap: var(--space-5); min-width: 0; }
.home-side { display: grid; gap: var(--space-4); position: sticky; top: calc(var(--topbar-height) + var(--space-4)); }
.home-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-5); }
.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }
.stat-card { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); padding: var(--space-4) var(--space-4) var(--space-4) var(--space-5); }
.stat-card .stat { min-width: 0; }
.stat-card .label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-card .value { font-size: var(--text-2xl); }
/* Narrow cards (4 across beside the side column): smaller ring and number so they never touch. */
.stat-card { container-type: inline-size; }
@container (max-width: 240px) { .stat-card .ring-wrap .ring { width: 40px; height: 40px; } .stat-card .value { font-size: var(--text-xl); } }
.stat-extra { display: flex; gap: 4px; align-items: center; margin-top: var(--space-1); white-space: nowrap; }
.ring-wrap { position: relative; display: grid; place-items: center; flex: none; }
.ring-icon { position: absolute; inset: 0; display: grid; place-items: center; color: var(--c-accent); }

/* Best sellers list */
.best-list { list-style: none; margin: 0; padding: 0; display: grid; }
.best-list li { display: grid; grid-template-columns: 32px 52px minmax(0, 1fr) 32px 72px; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: var(--border-width) solid var(--c-border); }
.best-list li:last-child { border-bottom: 0; }
.best-list .rank { color: var(--c-text-muted); font-weight: var(--weight-bold); }
.best-name { display: grid; min-width: 0; }
.best-name b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.best-name .price { font-weight: var(--weight-bold); color: var(--c-text); }
.best-name .cat { color: var(--c-accent-strong); }
.trend { display: grid; place-items: center; }
.trend.up { color: var(--c-success); }
.trend.down { color: var(--c-danger); }
.best-count { display: grid; text-align: right; }
.best-count b { font-size: var(--text-xl); line-height: 1.1; }

/* Charts */
.chart-big { display: grid; margin-bottom: var(--space-2); }
.big-num { font-size: var(--text-2xl); font-weight: var(--weight-bold); }
.status-split { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
.status-box { display: grid; padding: var(--space-4); border-radius: var(--radius-md); background: var(--c-surface-2); }
.status-box .value { font-size: var(--text-2xl); font-weight: var(--weight-bold); }
.status-box.new { background: var(--c-info-soft); }
.status-box.ready { background: var(--c-success-soft); }

/* Dish photos and favourites */
.dish-ph { border-radius: var(--radius-md); object-fit: cover; flex: none; display: inline-block; }
.dish-ph.tile { display: inline-grid; place-items: center; background: var(--c-surface-2); color: var(--c-text-muted); font-weight: var(--weight-bold); font-size: var(--text-lg); border: var(--border-width) solid var(--c-border); }
.fav-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }
.fav { display: grid; gap: var(--space-2); align-content: start; }
.fav .dish-ph { width: 100% !important; height: auto !important; aspect-ratio: 4 / 3; font-size: var(--text-3xl); }
.fav .pill { justify-self: start; display: inline-flex; gap: 4px; align-items: center; background: var(--c-accent-soft); color: var(--c-accent-strong); }

/* Right column */
.spark-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--space-2) var(--space-3); }
.spark-card > div { display: grid; }
.spark-card .label { color: var(--c-text-muted); font-size: var(--text-sm); }
.spark-card b { font-size: var(--text-2xl); }
.spark-card > a, .spark-card > .small, .spark-card .legend { grid-column: 1 / -1; padding-top: var(--space-2); border-top: var(--border-width) solid var(--c-border); }
.legend { display: flex; justify-content: space-between; font-size: var(--text-sm); }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; background: var(--c-accent-soft); border: 2px solid var(--c-accent); }
.lg.ret { background: var(--c-accent); }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.timeline li { display: grid; grid-template-columns: 48px 3px 1fr; gap: var(--space-3); align-items: stretch; }
.timeline .t-time { font-weight: var(--weight-bold); font-size: var(--text-sm); padding-top: 2px; }
.timeline .t-line { border-radius: 2px; background: var(--chart-1); }
.timeline li.catering .t-line { background: var(--c-warning); }
.timeline li.review .t-line { background: var(--c-success); }
.timeline li div { display: grid; }

/* Orders board */
.board { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: var(--space-4); overflow-x: auto; padding-bottom: var(--space-2); }
.board .col { background: var(--c-surface); border: var(--border-width) solid var(--c-border); border-radius: var(--radius-lg); padding: var(--space-4); min-height: 320px; box-shadow: var(--shadow-card); }
.board .col h2 { font-size: var(--text-md); display: flex; gap: var(--space-2); align-items: center; margin-bottom: var(--space-4); }
.board .col h2::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--chart-2); }
.board .col[aria-label="New"] h2::before { background: var(--c-info); }
.board .col[aria-label="Making"] h2::before { background: var(--c-warning); }
.board .col[aria-label="Ready"] h2::before { background: var(--c-success); }
.olist { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.ocard { background: var(--c-surface-2); border: var(--border-width) solid var(--c-border); border-radius: var(--radius-md); padding: var(--space-4); display: grid; gap: var(--space-2); }
.ocard[data-status="new"] { background: var(--c-info-soft); }
.ocard .btn { width: 100%; }
.olines { margin: 0; padding-left: var(--space-4); font-size: var(--text-sm); }
.onote { background: var(--c-warning-soft); color: var(--c-warning); padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm); margin: 0; }
.inline-form { gap: var(--space-2); }
.price-in { max-width: 90px; }

@media (max-width: 1280px) {
  .home-grid { grid-template-columns: 1fr; }
  .home-side { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-side > .card:last-child { grid-column: 1 / -1; }
}
@media (max-width: 1100px) { .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } .home-pair { grid-template-columns: 1fr; } .fav-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) {
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
  .stat-card { padding: var(--space-4); }
  .stat-card .value { font-size: var(--text-xl); }
  .stat-card .ring-wrap { display: none; }
  .home-side { grid-template-columns: 1fr; }
  .best-list li { grid-template-columns: 24px 44px minmax(0, 1fr) 56px; }
  .best-list .trend { display: none; }
  .board { grid-template-columns: repeat(4, minmax(260px, 82vw)); scroll-snap-type: x mandatory; }
  .board .col { scroll-snap-align: start; }
}

/* Menu editor */
.menu-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: var(--space-5); align-items: start; }
.cat-list { display: grid; gap: 2px; padding: var(--space-3); position: sticky; top: calc(var(--topbar-height) + var(--space-4)); }
.cat-list .nav-heading { margin: var(--space-1) var(--space-2) var(--space-2); padding: 0; }
.content .cat-list a { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); min-height: 40px; padding: 0 var(--space-3); border-radius: var(--radius-md); color: var(--c-nav-text); text-decoration: none; font-size: var(--text-sm); font-weight: var(--weight-medium); }
.content .cat-list a:hover { background: var(--c-nav-hover-bg); }
.content .cat-list a[aria-current] { background: var(--c-accent-soft); color: var(--c-accent-strong); font-weight: var(--weight-bold); }
.cat-list .count { font-size: var(--text-xs); color: var(--c-text-muted); font-variant-numeric: tabular-nums; }
.menu-table th.sel, .menu-table td.sel { width: 44px; }
.menu-table .price-group { justify-content: flex-end; }
.menu-table .price-group .addon { padding: 0 var(--space-2); }
.menu-table .money-in { width: 84px; }
.menu-table tr.is-muted .cell-main { opacity: .55; }
.line-clamp { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; max-width: 42ch; }
.photo-row { display: flex; gap: var(--space-4); align-items: center; }
.option-row { align-items: flex-start; padding: var(--space-2) 0; }
.option-row input { margin-top: 3px; }
.photo-form { flex: none; border-top: var(--border-width) solid var(--c-border); }
@media (max-width: 1100px) {
  .menu-layout { grid-template-columns: 1fr; }
  .cat-list { position: static; display: flex; overflow-x: auto; padding: var(--space-2); }
  .cat-list .nav-heading { display: none; }
  .cat-list a { flex: none; white-space: nowrap; }
}
@media (max-width: 720px) {
  .menu-table td.sel { position: absolute; }
  .menu-table tr { position: relative; padding-left: 48px !important; }
  .menu-table td.sel { left: 14px; top: 18px; width: auto; }
  .menu-table td.sel::before, .menu-table td.actions::before { content: none; }
  .menu-table .price-group { justify-content: flex-end; }
}

/* QR print files: design preview (src/areas/reviews/index.js printsPage). */
.print-preview { display: block; justify-self: center; width: 100%; max-width: 240px; height: auto; border: var(--border-width) solid var(--c-border); background: var(--c-surface); }

/* Agency HQ layout only (tokens only). Buttons, fields, switches, chips, pills,
   tables, tabs, dialogs, toasts and empty states come from components.css.
   Look: flat light background, solid white cards, thin border, big clear numbers.
   Navigation per theme (body[data-theme]):
     a = grouped left sidebar, same as the owner dashboard (rail under 1024px, drawer on phones)  [default]
     b = no sidebar, pill navigation in the top bar
     c = pill navigation in the top bar + slim icon rail */

.area-hq { background: var(--c-bg); }
.hq-content { max-width: none; }
.hq-sub { margin: var(--space-1) 0 0; font-size: var(--text-sm); }
.hq-head h1 { font-size: var(--text-2xl); letter-spacing: -0.01em; }

/* ---------- Top bar pieces (hidden in theme a) ---------- */
.hq-top-brand { display: none; align-items: center; gap: var(--space-2); color: var(--c-text); text-decoration: none; flex: none; }
.hq-top-brand .brand-tile { width: 32px; height: 32px; }
.hq-pills { display: none; min-width: 0; }
.hq-pills ul { list-style: none; margin: 0; padding: 4px; display: flex; gap: 2px; border-radius: var(--radius-pill); background: var(--c-surface-2); border: var(--border-width) solid var(--c-border); overflow-x: auto; scrollbar-width: none; }
.hq-pills a { display: inline-flex; align-items: center; min-height: 34px; padding: 0 var(--space-4); border-radius: var(--radius-pill); color: var(--c-text-muted); text-decoration: none; font-size: var(--text-sm); font-weight: var(--weight-medium); white-space: nowrap; }
.hq-pills a:hover { color: var(--c-text); background: var(--c-surface); }
.hq-pills a[aria-current="page"] { background: var(--c-nav-active-bg); color: var(--c-nav-active-text); font-weight: var(--weight-bold); }
.hq-pills a:focus-visible { outline: none; box-shadow: var(--ring); }
.hq-search { max-width: 280px; }

/* Theme b: top pill navigation only. */
body[data-theme="b"] .shell.hq { grid-template-columns: minmax(0, 1fr); }
body[data-theme="b"] .shell.hq .hq-top-brand, body[data-theme="b"] .shell.hq .hq-pills { display: flex; }
@media (min-width: 721px) {
  body[data-theme="b"] .shell.hq > .sidebar, body[data-theme="b"] .shell.hq > .backdrop { display: none; }
}
/* Theme c: top pills + slim icon rail. */
body[data-theme="c"] .shell.hq .hq-top-brand, body[data-theme="c"] .shell.hq .hq-pills { display: flex; }
@media (min-width: 721px) {
  body[data-theme="c"] .shell.hq { grid-template-columns: var(--rail-width) minmax(0, 1fr); }
  body[data-theme="c"] .shell.hq .sidebar { padding: var(--space-3) var(--space-2); align-items: center; overflow: visible; gap: var(--space-3); }
  body[data-theme="c"] .shell.hq :is(.brand, .nav-heading, .nav-text, .user-text, .nav-badge, .brand-text) { display: none; }
  body[data-theme="c"] .shell.hq .sidebar nav { gap: var(--space-2); }
  body[data-theme="c"] .shell.hq .nav-group { justify-items: center; }
  body[data-theme="c"] .shell.hq .nav a { width: 44px; height: 44px; min-height: 44px; padding: 0; justify-content: center; }
  body[data-theme="c"] .shell.hq .user-card { flex-direction: column; padding: 0; border: 0; background: transparent; }
}
@media (max-width: 1100px) {
  body[data-theme="b"] .hq-search, body[data-theme="c"] .hq-search { display: none; }
}
@media (max-width: 720px) {
  body[data-theme="b"] .hq-pills, body[data-theme="c"] .hq-pills { display: none; }
  .hq-search { max-width: none; }
  .hq-top-brand b { display: none; }
}

/* ---------- Stat cards ---------- */
.hq-stats { align-items: stretch; }
.hq-stat.stat-card { display: grid; align-content: space-between; gap: var(--space-3); padding: var(--space-5); }
.hq-stat .label { color: var(--c-text-muted); font-size: var(--text-sm); font-weight: var(--weight-medium); }
.hq-stat .stat-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-pill); background: var(--c-surface-2); color: var(--c-text-muted); flex: none; }
.hq-stat-row { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-3); }
.hq-stat .value { font-size: var(--text-3xl); font-weight: var(--weight-bold); letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hq-spark { flex: none; width: 96px; color: var(--chart-1); }
.hq-stat-foot { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.card.stat .value { font-variant-numeric: tabular-nums; }
.hq-value-sm { font-size: var(--text-xl) !important; }
.hq-big { margin: 0 0 var(--space-3); font-size: var(--text-2xl); font-weight: var(--weight-bold); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.hq-bad { color: var(--c-danger); }
.hq-change.good { color: var(--c-success); font-weight: var(--weight-bold); }
.hq-change.bad { color: var(--c-danger); font-weight: var(--weight-bold); }
.hq-done { text-decoration: line-through; color: var(--c-text-muted); }

/* ---------- Two-column chart areas ---------- */
.hq-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); align-items: start; }
.hq-two-wide { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.hq-two > .card, .hq-two > .table-card { min-width: 0; }
@media (max-width: 1024px) { .hq-two, .hq-two-wide { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Lists, meters, timeline ---------- */
.hq-list { list-style: none; margin: 0; padding: 0; display: grid; }
.hq-list > li { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: var(--border-width) solid var(--c-border); flex-wrap: wrap; }
.hq-list > li:last-child { border-bottom: 0; }
.hq-list form { margin: 0; }
.hq-breakdown { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); font-size: var(--text-sm); }
.hq-meter { display: block; height: 8px; margin-top: 6px; border-radius: var(--radius-pill); background: var(--c-surface-2); overflow: hidden; }
.hq-meter > span { display: block; height: 100%; border-radius: inherit; background: var(--chart-1); }
.area-hq .timeline li { grid-template-columns: 10px minmax(0, 1fr); gap: var(--space-3); }
.area-hq .timeline .dot { width: 10px; height: 10px; margin-top: 6px; border-radius: 50%; background: var(--chart-1); }
.area-hq .timeline .dot.email { background: var(--c-info); }
.area-hq .timeline .dot.visit { background: var(--c-success); }
.area-hq .timeline .dot.call { background: var(--c-warning); }
.area-hq .timeline li > div { display: grid; gap: 2px; min-width: 0; }

/* ---------- Forms laid out in cards ---------- */
.hq-form { display: grid; gap: var(--space-4); max-width: none; }
.hq-form h2 { margin: var(--space-2) 0 0; font-size: var(--text-md); }
.hq-form h2:first-child { margin-top: 0; }
.hq-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.hq-mini-form { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: flex-end; margin-top: var(--space-4); }
.hq-mini-form > input, .hq-mini-form > select { flex: 1 1 140px; width: auto; }
.hq-mini-form .hq-grow { flex: 1 1 220px; }
.hq-inline { display: flex; gap: var(--space-2); align-items: center; min-width: 240px; }
.hq-inline input { flex: 1; }
.hq-inline-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--space-3); align-items: end; max-width: none; margin-top: var(--space-4); }
.hq-toggle-form { margin: 0; display: inline-flex; }
.hq-sheet-form { display: contents; }
details.card > summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; }
@media (max-width: 720px) { .hq-pair { grid-template-columns: minmax(0, 1fr); } .hq-inline { min-width: 0; width: 100%; } }

/* ---------- Map box ---------- */
.hq-map { position: relative; height: 380px; border-radius: var(--radius-md); border: var(--border-width) solid var(--c-border); background: var(--c-surface-2); overflow: hidden; }
.hq-map-pick { height: 300px; cursor: crosshair; }
.hq-map.is-broken { display: grid; place-items: center; color: var(--c-text-muted); font-size: var(--text-sm); }
.hq-map .maplibregl-popup-content { border-radius: var(--radius-md); box-shadow: var(--shadow-pop); font: inherit; font-size: var(--text-sm); }
@media (max-width: 720px) { .hq-map { height: 280px; } }

/* ---------- Client header ---------- */
.hq-client-head { display: grid; gap: var(--space-4); }
.hq-client-head .stat { padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--c-surface-2); }
.hq-client-head .stat .value { font-size: var(--text-2xl); }

/* ---------- Contacts: duplicate pairs ---------- */
.hq-dups { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.hq-dups > li { display: grid; gap: var(--space-2); padding: var(--space-4); border: var(--border-width) solid var(--c-border); border-radius: var(--radius-md); }
.hq-dup-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
@media (max-width: 720px) { .hq-dup-pair { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Leads ---------- */
.hq-pitch-bar { padding-top: var(--space-4); border-top: var(--border-width) solid var(--c-border); align-items: flex-end; }
.hq-pitch-bar label { min-width: 200px; }
.hq-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.hq-chips > li { display: inline-flex; align-items: center; gap: var(--space-2); padding: 4px 4px 4px var(--space-3); border-radius: var(--radius-pill); border: var(--border-width) solid var(--c-border); font-size: var(--text-sm); }
.hq-chips form { margin: 0; }
.hq-stops { margin: 0; padding: 0 0 0 var(--space-5); display: grid; gap: var(--space-3); }
.hq-stops > li > * { vertical-align: middle; }
.hq-stops > li { padding: var(--space-3); border: var(--border-width) solid var(--c-border); border-radius: var(--radius-md); display: list-item; }
.hq-stops > li > div { display: inline-block; min-width: 60%; }
.hq-stops > li form { float: right; margin: 0; }
.hq-stops > li.done { background: var(--c-success-soft); }

/* ---------- Year plan ---------- */
.hq-roadmap { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-3); }
.hq-road-month { padding: var(--space-4); border: var(--border-width) solid var(--c-border); border-radius: var(--radius-md); background: var(--c-surface); display: grid; gap: var(--space-2); align-content: start; }
.hq-road-month h3 { margin: 0; font-size: var(--text-md); display: flex; align-items: center; gap: var(--space-2); }
.hq-road-month.is-now { border-color: var(--c-accent); box-shadow: var(--ring); }
.hq-road-month.is-past { background: var(--c-surface-2); }
.hq-road-items { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); font-size: var(--text-sm); }
.hq-road-items > li { display: flex; align-items: center; gap: var(--space-2); }

/* ---------- Outbox message ---------- */
.hq-pre { margin: 0; padding: var(--space-4); border-radius: var(--radius-md); background: var(--c-surface-2); font-family: var(--font-mono); font-size: var(--text-sm); white-space: pre-wrap; overflow-wrap: anywhere; }
.hq-message .card-header h2 { overflow-wrap: anywhere; }

/* Review fix: keep stat cards from squeezing the number, spark and icon. */
.hq-stat { min-width: 0; overflow: hidden; }
.hq-stat .spread { flex-wrap: nowrap; }
.hq-stat .spread .label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hq-stat-row { flex-wrap: wrap; row-gap: var(--space-2); }
.hq-stat .value { font-size: clamp(var(--text-2xl), 2.4vw, var(--text-3xl)); }
.hq-spark { flex: 1 1 72px; width: auto; max-width: 110px; min-width: 64px; }
.hq-spark svg { width: 100%; height: auto; }

/* ---------- Theme a: plain top bar ---------- */
.hq-top-title { display: none; font-size: var(--text-lg); font-weight: var(--weight-bold); white-space: nowrap; }
body[data-theme="a"] .hq-top-title { display: block; order: -1; }
body[data-theme="a"] .hq-top .hq-search { margin-left: auto; max-width: 340px; }
body[data-theme="a"] .hq-top .topbar-actions { margin-left: 0; }
@media (max-width: 720px) {
  body[data-theme="a"] .hq-top-title { display: none; }
  body[data-theme="a"] .hq-top .hq-search { margin-left: 0; }
}

/* ---------- Stat cards (theme a look; fine for b and c) ---------- */
.hq-stat .corner { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: var(--radius-sm); border: var(--border-width) solid var(--c-border); background: var(--c-surface); color: var(--c-text); }
.hq-stat .corner:hover { background: var(--c-surface-2); }
.hq-stat .corner:focus-visible { outline: none; box-shadow: var(--ring); }
.hq-stat-row { flex-wrap: nowrap; }
.hq-stat-side { display: grid; justify-items: end; gap: 4px; flex: none; }
.hq-stat-side .hq-spark { width: 84px; min-width: 0; max-width: none; flex: none; }
.hq-stat .value { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 720px) { .hq-stat-side .hq-spark { display: none; } }

/* ---------- Home: range switch, 60/40 chart row ---------- */
.hq-charts { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
@media (max-width: 1024px) { .hq-charts { grid-template-columns: minmax(0, 1fr); } }
.hq-chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.hq-chart-head .label { color: var(--c-text-muted); font-size: var(--text-sm); }
.hq-chart-head .hq-big { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin: var(--space-1) 0 var(--space-3); }
.hq-stat > .spread { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.hq-stat > .spread .label { flex: 1; }
.hq-stat.stat-card { justify-items: stretch; align-items: stretch; }
.hq-stat.stat-card { grid-template-columns: minmax(0, 1fr); }
