/* ═══════════════════════════════════════════════════════════════════════════
   DABBA design system
   Warm, unhurried, premium. Saffron and cardamom against warm paper and ink.
   No web fonts (CSP-clean, instant first paint) — the system serif stack does
   the heavy lifting for display type.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* Brand */
  --saffron-50:  #fff8ed;
  --saffron-100: #ffefd4;
  --saffron-200: #ffdba8;
  --saffron-300: #ffc170;
  --saffron-400: #ff9d37;
  --saffron-500: #f97f12;
  --saffron-600: #ea6308;
  --saffron-700: #c24909;
  --saffron-800: #9a3a10;
  --saffron-900: #7c3110;

  --cardamom-50:  #f2f9f1;
  --cardamom-100: #e0f0de;
  --cardamom-300: #a4d3a0;
  --cardamom-500: #4f9d55;
  --cardamom-600: #3b7d43;
  --cardamom-700: #316237;

  --chilli-500: #dc2f28;
  --chilli-600: #bd1f1c;
  --chilli-50:  #fef3f2;

  --indigo-700: #35408e;
  --indigo-50:  #eef0fb;

  /* Neutrals — warm, never cold grey */
  --ink-950: #1a1512;
  --ink-900: #241d18;
  --ink-800: #352c25;
  --ink-700: #4a3f36;
  --ink-600: #6b5d51;
  --ink-550: #75665a;
  --ink-500: #8b7c6e;
  --ink-400: #ac9d8f;
  --ink-300: #cdc1b5;
  --ink-200: #e5ddd4;
  --ink-100: #f2ece5;
  --ink-50:  #faf7f3;
  --paper:   #fffdfa;

  /* Semantic */
  --bg: var(--ink-50);
  --surface: var(--paper);
  --surface-2: var(--ink-50);
  --surface-3: var(--ink-100);
  --border: var(--ink-200);
  --border-strong: var(--ink-300);
  --text: var(--ink-900);
  --text-muted: var(--ink-600);
  /* ink-500 measured 3.44:1 on --surface-3 and failed AA wherever secondary text
     sat on a panel. ink-550 clears 4.5:1 on every surface in the system. */
  --text-subtle: var(--ink-550);
  /* Accent is deliberately the 700 shade, not the brighter 600: white text on
     600 measures 3.34:1 and fails WCAG AA, while 700 reaches 4.94:1. The bright
     saffron is still used for large display numerals and meter fills, where the
     3:1 non-text threshold applies. */
  --accent: var(--saffron-700);
  --accent-hover: var(--saffron-800);
  --accent-bright: var(--saffron-500);   /* decorative only — never behind text */
  --accent-soft: var(--saffron-50);
  --accent-on-soft: var(--saffron-800);  /* 6.66:1 on --accent-soft */
  --on-accent: #fff;
  --good: var(--cardamom-700);
  --good-soft: var(--cardamom-50);
  --warn: var(--saffron-800);
  --warn-soft: var(--saffron-50);
  --bad: var(--chilli-600);
  --bad-soft: var(--chilli-50);
  --info: var(--indigo-700);
  --info-soft: var(--indigo-50);

  /* Type */
  --font-display: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* Space & shape */
  --r-xs: 6px; --r-sm: 9px; --r-md: 13px; --r-lg: 18px; --r-xl: 26px; --r-full: 999px;
  --shadow-xs: 0 1px 2px rgba(36, 29, 24, .06);
  --shadow-sm: 0 1px 3px rgba(36, 29, 24, .07), 0 1px 2px rgba(36, 29, 24, .04);
  --shadow-md: 0 4px 14px rgba(36, 29, 24, .08), 0 1px 3px rgba(36, 29, 24, .05);
  --shadow-lg: 0 12px 34px rgba(36, 29, 24, .12), 0 3px 8px rgba(36, 29, 24, .06);
  --shadow-xl: 0 28px 64px rgba(36, 29, 24, .18), 0 8px 20px rgba(36, 29, 24, .08);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);

  --nav-h: 66px;
  --ease: cubic-bezier(.32, .72, 0, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16120f;
    --surface: #1e1916;
    --surface-2: #241e1a;
    --surface-3: #2c2521;
    --border: #352d27;
    --border-strong: #473d35;
    --text: #f5efe8;
    --text-muted: #c2b4a7;
    /* 4.22:1 on --surface-3 previously; this clears 4.5:1 on every dark surface. */
    --text-subtle: #a2958a;
    --accent: var(--saffron-400);
    --accent-hover: var(--saffron-300);
    --accent-bright: var(--saffron-400);
    --accent-soft: #2c2018;
    --accent-on-soft: var(--saffron-300);
    --on-accent: #1a1512;
    --good: var(--cardamom-300);
    --good-soft: #1b2a1c;
    --warn: var(--saffron-300);
    --warn-soft: #2c2018;
    --bad: #f78d86;
    --bad-soft: #2e1917;
    --info: #a8b3f0;
    --info-soft: #1c1f33;
    --shadow-md: 0 4px 14px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 34px rgba(0, 0, 0, .5);
    --shadow-xl: 0 28px 64px rgba(0, 0, 0, .6);
  }
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: var(--ring);
  border-radius: var(--r-sm);
}
.skip-link {
  position: absolute; left: .5rem; top: -4rem; z-index: 100;
  padding: .6rem 1rem; border-radius: var(--r-sm);
  background: var(--ink-900); color: var(--ink-50); font-weight: 650;
  transition: top .15s var(--ease);
}
.skip-link:focus { top: .5rem; }
::selection { background: var(--saffron-200); color: var(--ink-900); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── Type ─────────────────────────────────────────────────────────────────── */
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.015em; line-height: 1.18; }
h1 { font-size: clamp(1.85rem, 4vw, 2.6rem); }
h2 { font-size: clamp(1.35rem, 2.6vw, 1.75rem); }
h3 { font-size: 1.14rem; }
/* A card heading is an h2 for document structure but reads at h3 scale. */
h2.card-title { font-size: 1.14rem; }
h4 { font-size: 1rem; }
.display { font-family: var(--font-display); }
.eyebrow {
  font-size: .69rem; font-weight: 700; letter-spacing: .13em; text-transform: uppercase;
  color: var(--text-subtle);
}
.lede { font-size: 1.06rem; color: var(--text-muted); }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.small { font-size: .82rem; }
.tiny { font-size: .74rem; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.wrap { width: min(1240px, 100% - 2.5rem); margin-inline: auto; }
.wrap-narrow { width: min(760px, 100% - 2.5rem); margin-inline: auto; }
.stack { display: flex; flex-direction: column; }
.stack-1 { gap: .3rem; } .stack-2 { gap: .6rem; } .stack-3 { gap: 1rem; }
.stack-4 { gap: 1.5rem; } .stack-5 { gap: 2.25rem; } .stack-6 { gap: 3.25rem; }
.row { display: flex; align-items: center; gap: .6rem; }
.row-3 { gap: 1rem; } .row-4 { gap: 1.5rem; }
.row-top { align-items: flex-start; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.wrapf { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.center { display: grid; place-items: center; }
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.auto-fit { grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); }
.auto-fit-sm { grid-template-columns: repeat(auto-fill, minmax(min(165px, 100%), 1fr)); }
.auto-fit-lg { grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); }
.section { padding-block: clamp(2rem, 5vw, 3.5rem); }
.hide { display: none !important; }
@media (max-width: 900px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } .hide-sm { display: none !important; } }

/* ── Surfaces ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 1.25rem; }
.card-pad-lg { padding: clamp(1.25rem, 3vw, 2rem); }
.card-hover { transition: transform .22s var(--ease), box-shadow .22s var(--ease), border-color .22s var(--ease); }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.panel { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 1rem; }
.divider { height: 1px; background: var(--border); border: 0; }

/* Cash due at the door. Loud on purpose: a driver who walks away from a cash
   stop without the cash has given the order away. */
.panel.cash-due {
  border-color: var(--warn);
  background: var(--warn-soft);
}
.dot { width: 4px; height: 4px; border-radius: 50%; background: var(--border-strong); flex: none; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--text); --btn-bd: var(--border);
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .6rem 1.05rem; border-radius: var(--r-full);
  background: var(--btn-bg); color: var(--btn-fg); border: 1px solid var(--btn-bd);
  font-size: .875rem; font-weight: 600; letter-spacing: -.005em;
  cursor: pointer; white-space: nowrap; user-select: none;
  transition: background .16s, border-color .16s, transform .1s var(--ease), box-shadow .16s, opacity .16s;
}
.btn:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface-3); }
.btn:active:not(:disabled) { transform: scale(.975); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { --btn-bg: var(--accent); --btn-fg: var(--on-accent); --btn-bd: transparent; box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { --btn-bg: var(--accent-hover); --btn-bd: transparent; box-shadow: var(--shadow-md); }
.btn-dark { --btn-bg: var(--ink-900); --btn-fg: var(--ink-50); --btn-bd: transparent; }
.btn-dark:hover:not(:disabled) { --btn-bg: var(--ink-800); --btn-bd: transparent; }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); --btn-bd: transparent; }
.btn-danger { --btn-bg: var(--bad-soft); --btn-fg: var(--bad); --btn-bd: transparent; }
.btn-sm { padding: .38rem .78rem; font-size: .8rem; }
.btn-xs { padding: .3rem .62rem; font-size: .73rem; min-height: 28px; }
.btn-lg { padding: .82rem 1.6rem; font-size: .95rem; }
.btn-block { width: 100%; }
.btn-icon { padding: .5rem; width: 2.2rem; height: 2.2rem; border-radius: var(--r-full); }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: .35rem; }
.label { font-size: .78rem; font-weight: 650; color: var(--text-muted); letter-spacing: .01em; }
.input, .select, .textarea {
  width: 100%; padding: .62rem .8rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  font-size: .9rem; transition: border-color .15s, box-shadow .15s, background .15s;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }
.textarea { min-height: 6.5rem; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 2.1rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%238b7c6e' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .8rem center; }
.search { position: relative; }
.search .input { padding-left: 2.35rem; border-radius: var(--r-full); }
.search::before {
  content: ''; position: absolute; left: .85rem; top: 50%; width: 15px; height: 15px;
  transform: translateY(-50%); opacity: .5; pointer-events: none;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%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='%23000' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") center/contain no-repeat;
}
.check { display: flex; align-items: flex-start; gap: .55rem; cursor: pointer; font-size: .875rem; }
.check input { margin-top: .18rem; accent-color: var(--accent); width: 1rem; height: 1rem; flex: none; }

/* ── Chips, badges, pills ─────────────────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .32rem .72rem; border-radius: var(--r-full);
  background: var(--surface); border: 1px solid var(--border);
  font-size: .78rem; font-weight: 600; color: var(--text-muted);
  cursor: pointer; white-space: nowrap; transition: all .15s;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip[aria-pressed="true"], .chip.active {
  background: var(--ink-900); border-color: var(--ink-900); color: var(--ink-50);
}
@media (prefers-color-scheme: dark) {
  .chip[aria-pressed="true"], .chip.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
}
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .18rem .5rem; border-radius: var(--r-xs);
  font-size: .7rem; font-weight: 700; letter-spacing: .02em;
  background: var(--surface-3); color: var(--text-muted);
}
/* Inline status text. --good and --warn are both AA-contrast against the page
   surface in light and dark; the audit checks these two selectors directly. */
/* Demo-mode banner. Deliberately not dismissible: a visitor must never be
   unsure whether the order they just placed was real. */
.demo-bar {
  background: var(--ink-900); color: var(--ink-50);
  padding: .45rem 1rem; font-size: .78rem; font-weight: 600;
  display: flex; gap: .5rem; align-items: center; justify-content: center;
  text-align: center; flex-wrap: wrap;
}
.demo-bar b { color: var(--saffron-300); }

.good-text { color: var(--good); }
.warn-text { color: var(--warn); }

.badge-good { background: var(--good-soft); color: var(--good); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad  { background: var(--bad-soft);  color: var(--bad); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-accent { background: var(--accent-soft); color: var(--accent-on-soft); }
.badge-solid { background: var(--ink-900); color: var(--ink-50); }
.veg-mark, .nonveg-mark {
  width: 13px; height: 13px; border-radius: 2px; flex: none;
  border: 1.5px solid var(--cardamom-600); display: grid; place-items: center;
}
.veg-mark::after, .nonveg-mark::after {
  content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--cardamom-600);
}
.nonveg-mark { border-color: var(--chilli-600); }
.nonveg-mark::after { background: var(--chilli-600); }

/* ── Status dots ──────────────────────────────────────────────────────────── */
.status { display: inline-flex; align-items: center; gap: .4rem; font-size: .78rem; font-weight: 600; }
.status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--text-subtle); flex: none; }
.status-good::before { background: var(--good); }
.status-warn::before { background: var(--warn); }
.status-bad::before  { background: var(--bad); }
.status-live::before { background: var(--good); box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 60%, transparent); animation: pulse 2.2s infinite; }
@keyframes pulse {
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ── Meters & bars ────────────────────────────────────────────────────────── */
.meter { height: 7px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: inherit; background: var(--accent-bright);
  transition: width .6s var(--ease); }
.meter-good > i { background: var(--good); }
.meter-warn > i { background: var(--warn); }
.meter-bad  > i { background: var(--bad); }
.meter-track { position: relative; }
.meter-track::after {
  content: ''; position: absolute; top: -2px; bottom: -2px; width: 2px;
  background: var(--text); opacity: .35; left: var(--target, 100%);
}

.ring { --p: 0; --size: 96px; --thick: 8px; width: var(--size); height: var(--size); position: relative; flex: none; }
.ring::before {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(var(--ring-color, var(--accent)) calc(var(--p) * 1%), var(--surface-3) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - var(--thick)), #000 calc(100% - var(--thick)));
  mask: radial-gradient(farthest-side, transparent calc(100% - var(--thick)), #000 calc(100% - var(--thick)));
}
.ring > span { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
table.dt { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.dt th {
  text-align: left; padding: .65rem .85rem; font-size: .7rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--text-subtle);
  background: var(--surface-2); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 1;
}
table.dt td { padding: .65rem .85rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.dt tr:last-child td { border-bottom: 0; }
table.dt tbody tr { transition: background .12s; }
table.dt tbody tr:hover { background: var(--surface-2); }
table.dt td.num, table.dt th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Nav ──────────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50; height: var(--nav-h);
  display: flex; align-items: center;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .6rem; font-family: var(--font-display);
  font-size: 1.32rem; font-weight: 700; letter-spacing: -.02em; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 10px; flex: none;
  background: linear-gradient(145deg, var(--saffron-400), var(--saffron-700));
  display: grid; place-items: center; color: #fff; font-size: 1rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), var(--shadow-sm);
}
.navlinks { display: flex; gap: .15rem; }
.navlink {
  padding: .45rem .8rem; border-radius: var(--r-full); font-size: .86rem; font-weight: 600;
  color: var(--text-muted); transition: background .15s, color .15s; cursor: pointer;
}
.navlink:hover { background: var(--surface-3); color: var(--text); }
.navlink.active { background: var(--surface-3); color: var(--text); }
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 50; display: none;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px); border-top: 1px solid var(--border);
  padding: .4rem .5rem calc(.4rem + env(safe-area-inset-bottom));
}
.tabbar .navlink { flex: 1; text-align: center; font-size: .7rem; padding: .4rem .2rem; border-radius: var(--r-md); }
@media (max-width: 760px) {
  .tabbar { display: flex; gap: .2rem; }
  .topbar .navlinks { display: none; }
  body.has-tabbar { padding-bottom: 4.6rem; }
}

/* ── Toast / dialog ───────────────────────────────────────────────────────── */
.toasts { position: fixed; z-index: 200; right: 1rem; bottom: 1rem; display: flex; flex-direction: column;
  gap: .5rem; align-items: flex-end; pointer-events: none; max-width: min(400px, calc(100vw - 2rem)); }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: .6rem;
  padding: .75rem 1rem; border-radius: var(--r-md);
  background: var(--ink-900); color: var(--ink-50);
  box-shadow: var(--shadow-lg); font-size: .87rem; font-weight: 500;
  animation: toast-in .32s var(--ease);
}
.toast-good { background: var(--cardamom-700); }
.toast-bad { background: var(--chilli-600); }
/* saffron-900 rather than the --warn token: toast text is white, and 800
   measures 4.3:1 against white where 900 clears 5.9:1. */
.toast-warn { background: var(--saffron-900); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }

dialog.sheet {
  border: 0; padding: 0; background: transparent; max-width: min(640px, calc(100vw - 2rem)); width: 100%;
}
dialog.sheet::backdrop { background: rgba(26, 21, 18, .55); backdrop-filter: blur(3px); }
dialog.sheet .card { box-shadow: var(--shadow-xl); animation: sheet-in .28s var(--ease); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(14px) scale(.985); } }
dialog.wide { max-width: min(960px, calc(100vw - 2rem)); }

/* ── Skeleton & empty ─────────────────────────────────────────────────────── */
.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 300% 100%; animation: shimmer 1.35s infinite linear;
}
@keyframes shimmer { to { background-position: -300% 0; } }
.empty { text-align: center; padding: 3rem 1.5rem; color: var(--text-muted); }
.empty .emoji { font-size: 2.4rem; margin-bottom: .6rem; opacity: .8; }

/* ── Product card ─────────────────────────────────────────────────────────── */
.product {
  display: flex; flex-direction: column; gap: .55rem; padding: .9rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  transition: border-color .18s, box-shadow .18s, transform .18s var(--ease);
  position: relative;
}
.product:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.product .thumb {
  aspect-ratio: 1.45; border-radius: var(--r-sm); display: grid; place-items: center;
  font-size: 2.5rem; background: linear-gradient(150deg, var(--surface-2), var(--surface-3));
  border: 1px solid var(--border);
}
.product .name { font-weight: 650; font-size: .89rem; line-height: 1.3; }
.product .price { font-family: var(--font-display); font-size: 1.06rem; font-weight: 650; }
.product .oos { position: absolute; inset: 0; border-radius: inherit; display: grid; place-items: center;
  background: color-mix(in srgb, var(--surface) 78%, transparent); font-weight: 700; font-size: .8rem;
  color: var(--text-muted); }

.qty { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: var(--r-full);
  background: var(--surface); overflow: hidden; }
.qty button { width: 2.1rem; height: 2.1rem; min-width: 34px; min-height: 34px; border: 0; background: transparent; cursor: pointer;
  font-size: 1rem; line-height: 1; color: var(--text-muted); transition: background .12s; }
.qty button:hover { background: var(--surface-3); color: var(--text); }
.qty span { min-width: 1.7rem; text-align: center; font-size: .84rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── Timeline ─────────────────────────────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-step { display: grid; grid-template-columns: 22px 1fr; gap: .8rem; }
.tl-step .marker { position: relative; display: grid; place-items: start center; }
.tl-step .marker i {
  width: 11px; height: 11px; border-radius: 50%; background: var(--surface-3);
  border: 2px solid var(--border-strong); margin-top: 5px; z-index: 1;
}
.tl-step:not(:last-child) .marker::after {
  content: ''; position: absolute; top: 14px; bottom: -6px; width: 2px; background: var(--border);
}
.tl-step .body { padding-bottom: 1.05rem; }
.tl-done .marker i { background: var(--good); border-color: var(--good); }
.tl-done:not(:last-child) .marker::after { background: var(--good); }
.tl-current .marker i { background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.tl-pending .body { opacity: .5; }

/* ── Charts (pure CSS/SVG) ────────────────────────────────────────────────── */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 84px; }
.bars > i { flex: 1; background: var(--accent-bright); border-radius: 3px 3px 0 0; min-height: 2px;
  opacity: .85; transition: opacity .15s, height .5s var(--ease); }
.bars > i:hover { opacity: 1; }
.spark { width: 100%; height: 42px; overflow: visible; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark .area { fill: color-mix(in srgb, var(--accent) 12%, transparent); stroke: none; }

/* ── Utilities ────────────────────────────────────────────────────────────── */
.pill-group { display: inline-flex; align-self: flex-start; max-width: 100%; overflow-x: auto;
  padding: 3px; background: var(--surface-3); border-radius: var(--r-full); gap: 2px; }
.pill-group button { border: 0; background: transparent; padding: .32rem .8rem; border-radius: var(--r-full);
  font-size: .8rem; font-weight: 650; color: var(--text-muted); cursor: pointer; transition: all .15s; }
.pill-group button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }
.scroll-x { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .35rem;
  scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.scroll-x::-webkit-scrollbar { height: 5px; }
.scroll-x::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.sticky-bottom { position: sticky; bottom: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border); padding: .85rem 0 calc(.85rem + env(safe-area-inset-bottom)); }
/* Vertical padding on an inline element grows the hit area without changing
   the line box, so a 15px-tall link in a footer still clears the 24×24 target
   minimum without pushing the text around. */
.link {
  color: var(--accent); font-weight: 600; cursor: pointer;
  padding-block: .32rem;
}
.link:hover { text-decoration: underline; text-underline-offset: 2px; }
.tag-row { display: flex; flex-wrap: wrap; gap: .35rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; font-size: .85rem; }
.kv dt { color: var(--text-muted); }
.kv dd { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.aspect-map { aspect-ratio: 16/9; border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--border);
  background: var(--surface-2); }
.textured {
  background-image:
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--ink-400) 22%, transparent) 1px, transparent 0);
  background-size: 22px 22px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Touch and small screens
   ═════════════════════════════════════════════════════════════════════════════
   Everything below came out of `npm run test:responsive`, which drives every
   screen at seven widths from 320px up and measures what a thumb actually gets.
   Each rule fixes something it found; none of it is speculative polish.
   ═══════════════════════════════════════════════════════════════════════════ */

/* iOS Safari zooms the viewport whenever a focused field is under 16px, and it
   does not zoom back out. The user is then stuck on a page they have to pinch
   to escape, having typed one character into a search box. This is the single
   highest-impact mobile rule in the file. */
@media (max-width: 900px), (pointer: coarse) {
  .input, .select, .textarea,
  input[type="text"], input[type="email"], input[type="password"],
  input[type="search"], input[type="number"], input[type="tel"],
  input[type="date"], input[type="time"], select, textarea {
    font-size: 16px;
  }
}

/* A finger is about 9mm across. Below roughly 44px people miss, and a driver
   holding two totes in the rain misses more than that — which is how an order
   gets marked delivered at the wrong house. Applied by pointer type rather than
   width, so a touchscreen laptop gets it too and a mouse keeps the tighter,
   denser layout it can actually use. */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn-sm { min-height: 44px; padding-block: .5rem; }
  .btn-xs { min-height: 44px; padding-block: .5rem; }
  .btn-icon { min-width: 44px; }
  .navlink { min-height: 44px; display: inline-flex; align-items: center; }
  .tabbar .navlink { min-height: 48px; flex-direction: column; justify-content: center; }
  .brand { min-height: 44px; }
  .check, .pill-group button { min-height: 44px; }
  /* Table rows are the exception: a 44px minimum on every cell turns a
     twelve-row table into a scroll marathon. The controls inside them still
     get the full target. */
  /* WCAG 2.2 AA (2.5.8) asks for 24×24; 44×44 is the AAA target and Apple's
     guideline. Inside a data table the AAA size turns twelve rows into a scroll
     marathon, so table controls sit at 40 — comfortably above the requirement,
     below the ideal, and a deliberate trade rather than an oversight. */
  table.dt .btn-xs { min-height: 40px; }
}

/* Nothing readable at arm's length is under 12px. These were 11–11.8px, which
   looked considered on a laptop and vanished on a phone. */
@media (max-width: 900px) {
  .tiny { font-size: .8rem; }        /* 12.8px */
  .eyebrow { font-size: .78rem; }    /* 12.5px */
  .badge { font-size: .78rem; }
  table.dt th, table.dt td { font-size: .82rem; }
  .tabbar .navlink { font-size: .76rem; }
  .btn-xs { font-size: .78rem; }
}

/* The topbar is a sticky flex row: a long nav plus a user block. Without
   min-width:0 the nav refuses to shrink, the row grows past the viewport, and
   the whole page scrolls sideways — which on a tablet showed up as a 1113px
   layout inside a 768px screen. */
.topbar .wrap { min-width: 0; }
.topbar .wrap > * { min-width: 0; }
.topbar .navlinks { min-width: 0; overflow-x: auto; scrollbar-width: none; }
.topbar .navlinks::-webkit-scrollbar { display: none; }

/* Big display numbers are the other overflow source: a stat tile at 320px had
   a headline figure 71px wider than the screen. Clamp them to the column. */
.display, .stat-value, .stat .num {
  overflow-wrap: anywhere;
  max-width: 100%;
}
@media (max-width: 380px) {
  .display { font-size: clamp(1.1rem, 7vw, 2rem); }
}

/* A footer nav of three links has to wrap on a 320px screen rather than push
   the document sideways. */
.footer .row { flex-wrap: wrap; }

/* A main-plus-sidebar split. It was written inline as a two-column template
   with no breakpoint, which on a 320px screen forced two columns into 280px
   and pushed the whole dashboard sideways. */
.split-2 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 900px) { .split-2 { grid-template-columns: 1fr; } }

/* The topbar is a flex row of flex rows. Every one of them has to be allowed
   to shrink, or the longest wins and the document scrolls. */
.topbar .row, .topbar .between { min-width: 0; }
.topbar .navlinks { flex: 1 1 0; }   /* basis 0, so it is the part that gives way */
.topbar .brand { flex: none; }
.topbar .between { gap: .5rem; }
.topbar .between > * { min-width: 0; }
.topbar .between > .row-4 { flex: 1 1 0; }
/* A nav in a fixed-height bar cannot wrap — it would grow the bar and push the
   page down — so it scrolls instead. Applies to the app shells and to the
   standalone legal page, whose three links were enough to overflow a 320px
   screen on their own. */
.topbar nav { overflow-x: auto; scrollbar-width: none; flex: 0 1 auto; }
.topbar nav::-webkit-scrollbar { display: none; }

.skip-link { min-height: 44px; display: inline-flex; align-items: center; }
