
:root {
  color-scheme: light dark;

  /* colour: light */
  --bg: #f5f8fd; --surface: #ffffff; --surface-2: #f0f5fc; --text: #0b2145; --muted: #4a5d80; --subtle: #5f6e8c;
  --border: #dbe5f3; --border-strong: #b9cbe6; --border-input: #7a8bab;
  --accent: #075bee; --accent-hover: #0447b8; --accent-text: #ffffff; --accent-soft: #eaf3ff; --accent-ring: rgba(7, 91, 238, .35);
  --ok: #0a7a43; --ok-soft: #e4f6ec; --ok-dot: #1fae69;
  --warn: #8a5a00; --warn-soft: #fff4d9; --warn-dot: #e0a106;
  --bad: #b3261e; --bad-soft: #fdeceb; --bad-dot: #e5484d; --on-bad: #ffffff;
  --info: #075bee; --info-soft: #eaf3ff; --info-dot: #4d8dff;
  --neutral-soft: #eef2f8; --neutral-dot: #8a99b4;
  --overlay: rgba(7, 22, 50, .45);
  --live: #44d596;

  /* legacy aliases (pre-redesign class names keep working while pages move over) */
  --brand: var(--accent); --brand-text: var(--accent-text); --brand-soft: var(--accent-soft);

  /* type */
  --font-head: "Avenir Next", "Segoe UI Variable Display", "Segoe UI", "Helvetica Neue", Roboto, Arial, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --text-xs: .78rem; --text-sm: .875rem; --text-base: 1rem; --text-md: 1.125rem; --text-lg: 1.35rem;
  --text-xl: clamp(1.5rem, 1.2rem + 1.2vw, 1.9rem); --text-2xl: clamp(1.8rem, 1.4rem + 1.8vw, 2.4rem);
  --leading: 1.6; --leading-tight: 1.2; --weight-bold: 750; --weight-heavy: 820; --tracking-tight: -.025em;

  /* space (4px base) */
  --space-1: .25rem; --space-2: .5rem; --space-3: .75rem; --space-4: 1rem; --space-5: 1.5rem; --space-6: 2rem;
  --space-7: 3rem; --space-8: 4rem;
  --gap: var(--space-4);
  --content: 60rem; --content-narrow: 28rem; --content-wide: 84rem;
  --tap: 44px;

  /* radius */
  --radius-sm: .5rem; --radius: .75rem; --radius-lg: 1.1rem; --radius-xl: 1.5rem; --radius-pill: 999px;

  /* shadow */
  --shadow-sm: 0 1px 2px rgba(11, 33, 69, .06);
  --shadow: 0 1px 2px rgba(11, 33, 69, .05), 0 6px 18px rgba(11, 33, 69, .07);
  --shadow-lg: 0 2px 6px rgba(11, 33, 69, .07), 0 18px 44px rgba(11, 33, 69, .14);

  /* motion */
  --ease: cubic-bezier(.2, .8, .2, 1); --ease-in: cubic-bezier(.4, 0, 1, 1);
  --dur-fast: 120ms; --dur: 200ms; --dur-slow: 320ms;

  /* layers */
  --z-nav: 20; --z-toast: 60; --z-modal: 70;

  font-family: var(--font-body); line-height: var(--leading); font-size: 100%;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #07132a; --surface: #0f1d38; --surface-2: #142445; --text: #e9effb; --muted: #a9b8d3; --subtle: #8798b8;
    --border: #22355a; --border-strong: #34507f; --border-input: #5d77a6;
    --accent: #6ea4ff; --accent-hover: #93bbff; --accent-text: #061430; --accent-soft: #15284d; --accent-ring: rgba(110, 164, 255, .45);
    --ok: #5fd89a; --ok-soft: #0f3324; --ok-dot: #44d596;
    --warn: #f3c66a; --warn-soft: #36290c; --warn-dot: #f0b429;
    --bad: #ff9b93; --bad-soft: #3d1717; --bad-dot: #ff6b6b; --on-bad: #2a0a08;
    --info: #8db8ff; --info-soft: #15284d; --info-dot: #6ea4ff;
    --neutral-soft: #1a2a4a; --neutral-dot: #7d8fb0;
    --overlay: rgba(2, 8, 20, .7);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 22px rgba(0, 0, 0, .3);
    --shadow-lg: 0 2px 8px rgba(0, 0, 0, .4), 0 20px 48px rgba(0, 0, 0, .45);
  }
}
@media (prefers-reduced-motion: reduce) {
  :root { --dur-fast: 0ms; --dur: 0ms; --dur-slow: 0ms; }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-tap-highlight-color: transparent; }
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  font-size: var(--text-base); text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; }
img, svg { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }
:focus:not(:focus-visible) { outline: none; }
h1, h2, h3 { font-family: var(--font-head); font-weight: var(--weight-heavy); letter-spacing: var(--tracking-tight); line-height: var(--leading-tight); margin: 0 0 var(--space-3); }
h1 { font-size: var(--text-xl); }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-md); }
p { margin: 0 0 var(--space-3); }
small, .muted { color: var(--muted); }
.subtle { color: var(--subtle); font-size: var(--text-sm); }
strong { font-weight: var(--weight-bold); }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--space-5) 0; }
code, .mono { font-family: var(--font-mono); font-size: .9em; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
.icon { width: 1.25rem; height: 1.25rem; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.skip-link { position: absolute; left: var(--space-3); top: -10rem; z-index: 100; background: var(--surface); color: var(--text); padding: var(--space-3) var(--space-4);
  border: 2px solid var(--accent); border-radius: var(--radius); font-weight: var(--weight-bold); }
.skip-link:focus { top: var(--space-3); }

/* ---------- app shell ---------- */
/* no backdrop-filter below 48rem: it would make the header the containing block of the fixed bottom tab bar */
.topbar { position: sticky; top: 0; z-index: var(--z-nav); background: var(--surface); border-bottom: 1px solid var(--border); }
@media (min-width: 48rem) {
  .topbar { background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); }
}
.topbar__inner { max-width: var(--content); margin-inline: auto; padding: var(--space-2) var(--space-4); min-height: 3.5rem;
  display: flex; align-items: center; gap: var(--space-3); }
.app--admin .topbar__inner { max-width: none; }
.brand { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text); text-decoration: none; font-family: var(--font-head);
  font-weight: var(--weight-heavy); font-size: 1.2rem; letter-spacing: -.03em; min-height: var(--tap); }
.brand:hover { color: var(--text); }
.brand__mark { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .65rem; background: var(--accent); color: var(--accent-text);
  font-size: .82rem; letter-spacing: -.02em; }
.brand__name span { color: var(--accent); }
.brand__tag { font-family: var(--font-body); font-size: var(--text-xs); font-weight: var(--weight-bold); letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: .1rem .5rem; }
.topbar__end { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }

/* main nav: a bottom tab bar on phones (customer), inline in the top bar from 48rem */
.app-nav ul { list-style: none; margin: 0; padding: 0; display: flex; }
.app-nav a { display: flex; align-items: center; gap: var(--space-2); color: var(--muted); text-decoration: none; font-weight: 650;
  border-radius: var(--radius); transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease); }
.app-nav a:hover { color: var(--text); background: var(--surface-2); }
.app-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.app--customer .app-nav { position: fixed; inset: auto 0 0 0; z-index: var(--z-nav); background: var(--surface); border-top: 1px solid var(--border);
  padding: var(--space-1) var(--space-2) calc(var(--space-1) + env(safe-area-inset-bottom)); box-shadow: 0 -6px 18px rgba(11, 33, 69, .06); }
.app--customer .app-nav ul { justify-content: space-around; }
.app--customer .app-nav li { flex: 1; }
.app--customer .app-nav a { flex-direction: column; gap: 2px; justify-content: center; min-height: 3.25rem; font-size: var(--text-xs); }
.app--customer.has-nav { padding-bottom: calc(4.25rem + env(safe-area-inset-bottom)); }
@media (min-width: 48rem) {
  .app--customer .app-nav { position: static; background: none; border: 0; box-shadow: none; padding: 0; margin-left: var(--space-4); }
  .app--customer .app-nav ul { gap: var(--space-1); }
  .app--customer .app-nav li { flex: none; }
  .app--customer .app-nav a { flex-direction: row; font-size: var(--text-sm); min-height: 2.5rem; padding: 0 var(--space-3); }
  .app--customer .app-nav .icon { width: 1.1rem; height: 1.1rem; }
  .app--customer.has-nav { padding-bottom: 0; }
}

/* admin: a scrolling pill row under the top bar on phones, a sticky sidebar from 64rem */
.shell { flex: 1; display: flex; flex-direction: column; width: 100%; }
.app--admin .app-nav { border-bottom: 1px solid var(--border); background: var(--surface); overflow-x: auto; scrollbar-width: none; }
.app--admin .app-nav ul { gap: var(--space-1); padding: var(--space-2) var(--space-3); width: max-content; }
.app--admin .app-nav a { padding: 0 var(--space-3); min-height: 2.5rem; font-size: var(--text-sm); white-space: nowrap; }
.app--admin .app-nav .icon { width: 1.1rem; height: 1.1rem; }
@media (min-width: 64rem) {
  .shell { flex-direction: row; align-items: flex-start; }
  .app--admin .app-nav { position: sticky; top: 3.5rem; flex: none; width: 15rem; height: calc(100vh - 3.5rem); border-bottom: 0; border-right: 1px solid var(--border); overflow: auto; }
  .app--admin .app-nav ul { flex-direction: column; width: auto; padding: var(--space-4) var(--space-3); }
  .app--admin .app-nav a { min-height: 2.6rem; }
  .shell > main { min-width: 0; }
}

/* account menu: a <details> popover, works without JavaScript */
.menu { position: relative; }
.menu > summary { list-style: none; display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--tap); padding: 0 var(--space-3);
  border-radius: var(--radius-pill); border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font-weight: 650; font-size: var(--text-sm); }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover { background: var(--surface-2); }
.menu[open] > summary { background: var(--accent-soft); border-color: var(--accent); }
.menu__panel { position: absolute; right: 0; top: calc(100% + var(--space-2)); min-width: 14rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: var(--space-2); display: grid; gap: 2px; z-index: var(--z-nav); }
.menu__panel form { margin: 0; }
.menu__head { padding: var(--space-2) var(--space-3); font-size: var(--text-sm); color: var(--muted); overflow-wrap: anywhere; border-bottom: 1px solid var(--border); margin-bottom: var(--space-1); }
.menu__item { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: var(--tap); padding: 0 var(--space-3);
  border: 0; border-radius: var(--radius); background: none; color: var(--text); font: inherit; font-size: var(--text-sm); text-align: left; cursor: pointer; text-decoration: none; }
.menu__item:hover { background: var(--surface-2); color: var(--text); }
.switch { flex: none; position: relative; width: 2.4rem; height: 1.4rem; border-radius: var(--radius-pill); background: var(--border-input); transition: background-color var(--dur) var(--ease); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: calc(1.4rem - 6px); height: calc(1.4rem - 6px); border-radius: 50%; background: #fff;
  box-shadow: var(--shadow-sm); transition: transform var(--dur) var(--ease); }
[aria-pressed="true"] > .switch, [aria-checked="true"] > .switch { background: var(--accent); }
[aria-pressed="true"] > .switch::after, [aria-checked="true"] > .switch::after { transform: translateX(1rem); }

/* ---------- page ---------- */
main { width: 100%; max-width: var(--content); margin-inline: auto; padding: var(--space-5) var(--space-4) var(--space-7); flex: 1; }
main.narrow { max-width: calc(var(--content-narrow) + 2 * var(--space-4)); }
main.wide { max-width: var(--content-wide); }
@media (min-width: 48rem) { main { padding: var(--space-6) var(--space-5) var(--space-8); } }
.site-footer { padding: var(--space-5) var(--space-4); text-align: center; color: var(--muted); font-size: var(--text-sm); }
.site-footer p { margin: 0; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-3) var(--space-4); margin: 0 0 var(--space-5); }
.page-head h1 { margin: 0; }
.page-head__text { min-width: 0; flex: 1 1 18rem; }
.page-head .eyebrow { margin-bottom: var(--space-2); }
.page-head .lead { margin: var(--space-2) 0 0; color: var(--muted); font-size: var(--text-md); max-width: 40rem; }
.page-head__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.eyebrow { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-xs); font-weight: var(--weight-heavy); letter-spacing: .12em;
  text-transform: uppercase; color: var(--accent); }
.back-link { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--text-sm); font-weight: 650; text-decoration: none; margin-bottom: var(--space-3); min-height: var(--tap); }
.stack-lg > * + * { margin-top: var(--space-5); }
.grid { display: grid; gap: var(--gap); }
@media (min-width: 40rem) { .grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 56rem) { .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---------- card ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-5); margin: 0 0 var(--gap); box-shadow: var(--shadow-sm); }
.card > :last-child { margin-bottom: 0; }
.card.primary, .card--accent { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent), var(--shadow); }
.card h2 { font-size: var(--text-md); margin-top: 0; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.card__head h2 { margin: 0; }
.card--flat { box-shadow: none; background: var(--surface-2); }
.card--link { display: block; color: inherit; text-decoration: none; transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.card--link:hover { color: inherit; border-color: var(--border-strong); box-shadow: var(--shadow); }
.card .note, .note { background: var(--warn-soft); color: var(--text); border-radius: var(--radius); padding: var(--space-3) var(--space-4); margin-top: var(--space-3); }
.facts { margin: 0 0 var(--space-4); padding-left: 1.2rem; }
.facts li { margin-bottom: var(--space-1); }

/* ---------- stat tile ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: var(--space-3); margin: 0 0 var(--gap); padding: 0; list-style: none; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4); box-shadow: var(--shadow-sm); }
.stat__label { display: block; color: var(--muted); font-size: var(--text-sm); font-weight: 600; }
.stat__value { display: block; font-family: var(--font-head); font-size: 1.75rem; font-weight: var(--weight-heavy); letter-spacing: -.03em; line-height: 1.2;
  font-variant-numeric: tabular-nums; margin-top: var(--space-1); }
.stat__hint { display: block; color: var(--subtle); font-size: var(--text-xs); margin-top: var(--space-1); }
.stat--ok { border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }
.stat--warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); }
.stat--bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.stat--bad .stat__value { color: var(--bad); }
a.stat { color: inherit; text-decoration: none; }
a.stat:hover { border-color: var(--border-strong); box-shadow: var(--shadow); color: inherit; }

/* ---------- status badge ---------- */
.badges { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0 0 var(--gap); }
.badge { display: inline-flex; align-items: center; gap: .4rem; font-size: var(--text-xs); font-weight: var(--weight-bold); line-height: 1.2; padding: .3rem .65rem;
  border-radius: var(--radius-pill); background: var(--neutral-soft); color: var(--muted); white-space: nowrap; letter-spacing: .01em; }
.badge::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--neutral-dot); flex: none; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.ok::before { background: var(--ok-dot); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.warn::before { background: var(--warn-dot); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.bad::before { background: var(--bad-dot); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.info::before { background: var(--info-dot); }
.badge.live::before { background: var(--live); }
@media (prefers-reduced-motion: no-preference) {
  .badge.live::before, .badge.pulse::before { animation: s49-pulse 1.8s var(--ease) infinite; }
}
@keyframes s49-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 45%, transparent); } 70%, 100% { box-shadow: 0 0 0 .4rem transparent; } }

/* ---------- buttons ---------- */
.button { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--tap); padding: .6rem 1.15rem;
  font: inherit; font-weight: var(--weight-bold); font-size: var(--text-base); line-height: 1.2; text-align: center; text-decoration: none; cursor: pointer;
  background: var(--accent); color: var(--accent-text); border: 1px solid var(--accent); border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(7, 91, 238, .25); transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease); }
.button:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
.button:active { transform: translateY(1px); }
.button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.button.secondary { background: var(--surface); color: var(--accent); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.button.secondary:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.button.ghost { background: transparent; color: var(--text); border-color: transparent; box-shadow: none; }
.button.ghost:hover { background: var(--surface-2); color: var(--text); }
.button.danger { background: var(--bad); border-color: var(--bad); color: var(--on-bad); box-shadow: none; }
.button.danger:hover { background: var(--bad); color: var(--on-bad); filter: brightness(1.08); }
.button.link { background: none; border: 0; padding: 0; min-height: 0; color: var(--accent); text-decoration: underline; font-weight: 600; box-shadow: none; }
.button.small { min-height: 2.25rem; padding: .35rem .8rem; font-size: var(--text-sm); }
.button.block { width: 100%; }
.button[disabled], .button[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.button[aria-busy="true"]::after { content: ""; width: 1em; height: 1em; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; }
@media (prefers-reduced-motion: no-preference) { .button[aria-busy="true"]::after { animation: s49-spin .7s linear infinite; } }
@keyframes s49-spin { to { transform: rotate(360deg); } }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-4); }
.actions--end { justify-content: flex-end; }
.inline-form { display: inline; margin: 0; }

/* ---------- forms ---------- */
form.stack { display: grid; gap: var(--space-4); }
.field { display: grid; gap: var(--space-1); min-width: 0; }
.field label, .field legend { font-weight: 650; font-size: var(--text-sm); }
.field input, .field select, .field textarea, .input {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-input); border-radius: var(--radius);
  padding: .65rem .8rem; width: 100%; min-height: var(--tap); transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease); }
.field textarea { min-height: 7rem; resize: vertical; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--subtle); }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible, .input:focus-visible {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.field input[aria-invalid="true"], .field select[aria-invalid="true"], .field textarea[aria-invalid="true"] { border-color: var(--bad); }
.field input[aria-invalid="true"]:focus-visible, .field textarea[aria-invalid="true"]:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 30%, transparent); }
.field input[type="checkbox"], .field input[type="radio"] { width: 1.15rem; height: 1.15rem; min-height: 0; accent-color: var(--accent); padding: 0; }
.field .hint { color: var(--muted); font-size: var(--text-sm); margin: 0; }
.field .field-error { color: var(--bad); font-size: var(--text-sm); margin: 0; font-weight: 650; display: flex; gap: var(--space-1); align-items: baseline; }
.field .field-error::before { content: "!"; display: inline-grid; place-items: center; flex: none; width: 1rem; height: 1rem; border-radius: 50%; background: var(--bad); color: var(--on-bad); font-size: .7rem; font-weight: 800; }
.check { display: flex; align-items: flex-start; gap: var(--space-2); font-weight: 500; }
.check input { margin-top: .2rem; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }

/* ---------- flash, form error, toast ---------- */
.flash, .form-error, .alert { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius);
  margin: 0 0 var(--gap); border: 1px solid transparent; font-weight: 550; }
.flash { background: var(--ok-soft); color: var(--text); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.flash::before, .form-error::before, .alert::before { content: ""; flex: none; width: .6rem; height: .6rem; border-radius: 50%; margin-top: .5rem; background: var(--ok-dot); }
.form-error { background: var(--bad-soft); color: var(--text); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.form-error::before { background: var(--bad-dot); }
.alert--info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.alert--info::before { background: var(--info-dot); }
.alert--warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.alert--warn::before { background: var(--warn-dot); }
@media (prefers-reduced-motion: no-preference) {
  .flash, .form-error { animation: s49-rise var(--dur-slow) var(--ease) both; }
}
@keyframes s49-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.toast-region { position: fixed; z-index: var(--z-toast); left: var(--space-3); right: var(--space-3); bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
  display: grid; gap: var(--space-2); justify-items: center; pointer-events: none; }
.app--customer.has-nav .toast-region { bottom: calc(4.75rem + env(safe-area-inset-bottom)); }
@media (min-width: 48rem) {
  .toast-region { left: auto; right: var(--space-5); bottom: var(--space-5); justify-items: end; width: 24rem; }
  .app--customer.has-nav .toast-region { bottom: var(--space-5); }
}
.toast { pointer-events: auto; width: 100%; max-width: 24rem; display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  background: var(--text); color: var(--bg); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); font-weight: 550; font-size: var(--text-sm); }
.toast::before { content: ""; flex: none; width: .6rem; height: .6rem; border-radius: 50%; margin-top: .45rem; background: var(--ok-dot); }
.toast--error::before { background: var(--bad-dot); }
.toast--info::before { background: var(--info-dot); }
.toast__text { flex: 1; padding-top: .15rem; }
.toast__close { flex: none; width: 2rem; height: 2rem; display: grid; place-items: center; border: 0; border-radius: var(--radius-sm); background: transparent; color: inherit; cursor: pointer; font: inherit; font-size: 1.2rem; line-height: 1; opacity: .75; }
.toast__close:hover { opacity: 1; background: color-mix(in srgb, var(--bg) 15%, transparent); }
.toast__close:focus-visible { outline-color: var(--bg); }
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: s49-rise var(--dur-slow) var(--ease) both; }
  .toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity var(--dur) var(--ease-in), transform var(--dur) var(--ease-in); }
}

/* ---------- modal / confirm (<dialog>) ---------- */
dialog.modal { border: 0; padding: 0; background: var(--surface); color: var(--text); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
  width: min(28rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); }
dialog.modal::backdrop { background: var(--overlay); }
.modal__body { padding: var(--space-5) var(--space-5) var(--space-4); }
.modal__body h2 { font-size: var(--text-lg); margin-bottom: var(--space-2); }
.modal__body p { color: var(--muted); margin: 0; white-space: pre-line; }
.modal__actions { display: flex; flex-direction: column-reverse; gap: var(--space-2); padding: 0 var(--space-5) var(--space-5); }
@media (min-width: 30rem) { .modal__actions { flex-direction: row; justify-content: flex-end; } }
@media (prefers-reduced-motion: no-preference) {
  dialog.modal[open] { animation: s49-pop var(--dur-slow) var(--ease) both; }
  dialog.modal[open]::backdrop { animation: s49-fade var(--dur) var(--ease) both; }
}
@keyframes s49-pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes s49-fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- stepper / progress ---------- */
.stepper { list-style: none; margin: 0 0 var(--space-5); padding: 0; display: flex; gap: var(--space-2); counter-reset: step; overflow-x: auto; scrollbar-width: none; }
.stepper li { counter-increment: step; flex: 1 0 auto; min-width: 0; display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); font-weight: 650; color: var(--subtle);
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-2); border-radius: var(--radius-pill); background: var(--surface); border: 1px solid var(--border); white-space: nowrap; }
.stepper li::before { content: counter(step); display: grid; place-items: center; flex: none; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--surface-2); color: var(--muted); font-size: var(--text-xs); font-weight: 800; }
.stepper li a { color: inherit; text-decoration: none; }
.stepper li.is-done { color: var(--text); }
.stepper li.is-done::before { content: "\2713"; background: var(--ok-soft); color: var(--ok); }
.stepper li[aria-current="step"] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.stepper li[aria-current="step"]::before { background: var(--accent); color: var(--accent-text); }
.progress { display: grid; gap: var(--space-1); margin: 0 0 var(--gap); }
.progress__label { display: flex; justify-content: space-between; font-size: var(--text-sm); color: var(--muted); font-weight: 600; }
progress, .progress__bar { appearance: none; -webkit-appearance: none; width: 100%; height: .5rem; border: 0; border-radius: var(--radius-pill); background: var(--surface-2); overflow: hidden; color: var(--accent); }
progress::-webkit-progress-bar { background: var(--surface-2); border-radius: var(--radius-pill); }
progress::-webkit-progress-value { background: var(--accent); border-radius: var(--radius-pill); transition: width var(--dur) var(--ease); }
progress::-moz-progress-bar { background: var(--accent); border-radius: var(--radius-pill); }

/* ---------- timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.timeline li { position: relative; padding: 0 0 var(--space-4) var(--space-6); }
.timeline li::before { content: ""; position: absolute; left: .45rem; top: .35rem; width: .8rem; height: .8rem; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); }
.timeline li::after { content: ""; position: absolute; left: .82rem; top: 1.3rem; bottom: .1rem; width: 2px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline li.is-done::before { background: var(--ok-dot); border-color: var(--ok-dot); }
.timeline li.is-current::before { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.timeline__title { font-weight: var(--weight-bold); display: block; }
.timeline__meta { color: var(--subtle); font-size: var(--text-sm); }
.timeline li p { margin: var(--space-1) 0 0; color: var(--muted); font-size: var(--text-sm); }

/* ---------- empty state ---------- */
.empty-state { text-align: center; padding: var(--space-6) var(--space-4); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); margin: 0 0 var(--gap); }
.empty-state__art { display: inline-grid; place-items: center; width: 3.5rem; height: 3.5rem; border-radius: 1.1rem; background: var(--accent-soft); color: var(--accent); margin-bottom: var(--space-3); }
.empty-state__art .icon { width: 1.6rem; height: 1.6rem; }
.empty-state h2, .empty-state h3 { font-size: var(--text-md); margin-bottom: var(--space-1); }
.empty-state p { color: var(--muted); max-width: 30rem; margin-inline: auto; }
.empty-state .actions { justify-content: center; margin-top: var(--space-4); }
.empty { color: var(--muted); margin: 0 0 var(--gap); }

/* ---------- file uploader ---------- */
.dropzone { display: grid; justify-items: center; gap: var(--space-2); text-align: center; padding: var(--space-6) var(--space-4); border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg); background: var(--surface); transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease); }
.dropzone.is-over, .dropzone:focus-within { border-color: var(--accent); background: var(--accent-soft); }
.dropzone__icon { display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: 1rem; background: var(--accent-soft); color: var(--accent); }
.dropzone__title { font-weight: var(--weight-bold); font-size: var(--text-md); margin: 0; }
.dropzone__hint { color: var(--muted); font-size: var(--text-sm); margin: 0; }
.file-list { list-style: none; margin: var(--space-4) 0 0; padding: 0; display: grid; gap: var(--space-2); }
.file-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-1) var(--space-3); padding: var(--space-3) var(--space-4);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.file-row__name { font-weight: 600; overflow-wrap: anywhere; }
.file-row__meta { grid-column: 1; color: var(--subtle); font-size: var(--text-sm); }
.file-row progress { grid-column: 1 / -1; }

/* ---------- table / list ---------- */
.table-wrap, .scroll { overflow-x: auto; margin: 0 0 var(--gap); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.table, table.admin { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table caption, table.admin caption { text-align: left; font-weight: var(--weight-bold); padding: var(--space-3) var(--space-4) var(--space-2); }
.table th, .table td, table.admin th, table.admin td { text-align: left; vertical-align: top; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
.table thead th, table.admin thead th { background: var(--surface-2); color: var(--muted); font-weight: 650; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.table tbody tr:last-child td, table.admin tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover, table.admin tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.table .num, table.admin .num { text-align: right; font-variant-numeric: tabular-nums; }
/* .table--stack: below 40rem each row becomes a card and each cell shows its data-label (CSS only). Add data-label="..." to the <td>s. */
@media (max-width: 39.99rem) {
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; width: 100%; }
  .table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .table--stack tbody tr { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
  .table--stack tbody tr:last-child { border-bottom: 0; }
  .table--stack td { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); padding: var(--space-1) 0; border: 0; text-align: right; overflow-wrap: anywhere; }
  .table--stack td::before { content: attr(data-label); flex: none; color: var(--muted); font-size: var(--text-xs); font-weight: 650; text-transform: uppercase; letter-spacing: .06em; text-align: left; }
  .table--stack td:not([data-label])::before { content: none; }
  .table--stack td:not([data-label]) { justify-content: flex-end; }
  .table--stack .num { text-align: right; }
}
.list { list-style: none; margin: 0 0 var(--gap); padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.list > li { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); min-height: 3.5rem; }
.list > li:last-child { border-bottom: 0; }
.list__main { flex: 1; min-width: 0; }
.list__title { display: block; font-weight: 650; overflow-wrap: anywhere; }
.list__meta { display: block; color: var(--subtle); font-size: var(--text-sm); }
dl.summary { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-1) var(--space-4); margin: 0 0 var(--space-4); }
dl.summary dt { color: var(--muted); font-size: var(--text-sm); }
dl.summary dd { margin: 0 0 var(--space-2); font-weight: 550; overflow-wrap: anywhere; }
@media (min-width: 36rem) { dl.summary { grid-template-columns: max-content minmax(0, 1fr); } dl.summary dd { margin: 0; } }

/* ---------- misc ---------- */
.suggestions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-1) 0 0; padding: 0; list-style: none; }
.suggestions form { margin: 0; }
.address { font-family: var(--font-mono); word-break: break-all; }
.skeleton { display: block; height: 1rem; border-radius: var(--radius-sm); background: var(--surface-2); }
@media (prefers-reduced-motion: no-preference) {
  .skeleton { background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: s49-shimmer 1.4s linear infinite; }
}
@keyframes s49-shimmer { to { background-position: -200% 0; } }

/* ---------- auth (login, sign-up, password) ---------- */
.app--auth { background: radial-gradient(60rem 30rem at 85% -10%, var(--accent-soft), transparent 60%), var(--bg); }
.auth { flex: 1; width: 100%; max-width: 64rem; margin-inline: auto; padding: var(--space-5) var(--space-4) var(--space-6); display: grid; gap: var(--space-6); align-content: start; }
.auth__panel { width: 100%; max-width: 27rem; margin-inline: auto; }
.auth__card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); padding: var(--space-5); }
@media (min-width: 30rem) { .auth__card { padding: var(--space-6); } }
.auth__card h1 { font-size: var(--text-xl); margin-bottom: var(--space-1); }
.auth__lead { color: var(--muted); margin-bottom: var(--space-5); }
.auth__alt { text-align: center; color: var(--muted); font-size: var(--text-sm); margin: var(--space-4) 0 0; }
.auth__row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); }
.auth__row a { font-size: var(--text-sm); font-weight: 600; }
.auth__pitch { display: none; }
@media (min-width: 60rem) {
  .auth { grid-template-columns: minmax(0, 1fr) 27rem; align-items: center; padding-top: var(--space-8); }
  .auth__panel { margin: 0; }
  .auth__pitch { display: block; padding-right: var(--space-6); }
  .auth__headline { font-family: var(--font-head); font-weight: var(--weight-heavy); letter-spacing: var(--tracking-tight); font-size: var(--text-2xl); line-height: 1.1; margin-bottom: var(--space-4); }
  .auth__headline em { font-style: normal; color: var(--accent); }
  .auth__pitch p { color: var(--muted); font-size: var(--text-md); max-width: 30rem; }
  .ticks { list-style: none; padding: 0; margin: var(--space-5) 0 0; display: grid; gap: var(--space-3); }
  .ticks li { display: flex; gap: var(--space-3); align-items: center; font-weight: 600; }
  .ticks li::before { content: "\2713"; display: grid; place-items: center; flex: none; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--ok-soft); color: var(--ok); font-size: var(--text-sm); font-weight: 800; }
}
@media (prefers-reduced-motion: no-preference) {
  .auth__card { animation: s49-rise var(--dur-slow) var(--ease) both; }
}

@media (max-width: 36rem) {
  .actions > .button, form.stack > .button { width: 100%; }
}
@media print {
  .topbar, .app-nav, .site-footer, .toast-region { display: none !important; }
  body { background: #fff; }
}
