/*
 * Supply Closet - design tokens.
 *
 * Blue and tan. The ground is sand, panels are a warm white that sits on it
 * without glowing, ink carries a navy cast rather than being flat black, and
 * blue is both the brand and the action colour. Bronze is the warm accent:
 * eyebrows, badges, the active rail. Nothing here is decorative.
 *
 * No web fonts by design. The app is a PWA that has to work in a store room
 * with no signal, and a blocked font request is a layout shift at best.
 */

:root {
  /* -- surfaces ---------------------------------------------------------- */
  --bg: #e8dfd0;
  --bg-alt: #ded2bf;
  --surface: #fcfaf6;
  --surface-2: #f2ebdf;
  --surface-3: #e6dac6;

  /* -- ink --------------------------------------------------------------- */
  --text: #151e2d;
  --text-2: #3a4759;
  --muted: #6d7585;
  --faint: #99a0ac;

  /* -- lines ------------------------------------------------------------- */
  --line: #d7c9b2;
  --line-strong: #bfae92;

  /* -- brand: blue is structural AND the action colour ------------------- */
  --accent: #1c4f8a;
  --accent-hover: #163e6d;
  --accent-soft: #e3ecf7;
  --accent-line: #a6c0dd;
  --accent-text: #ffffff;

  /* -- warm accent: bronze out of the tan, for eyebrows and active rails -- */
  --brand-warm: #b07c3a;
  --brand-warm-soft: #f5ead6;
  --brand-warm-line: #e0c79a;
  --brand-warm-ink: #6d4716;

  /* -- the dark bar the app hangs under ---------------------------------- */
  --header: #122742;
  --header-2: #0e1f36;
  --header-ink: #e8eef6;
  --header-muted: #9bb0c9;
  --header-line: #24405f;

  /* -- status ------------------------------------------------------------ */
  --danger: #b3261e;
  --danger-soft: #fbeceb;
  --danger-line: #eec4c1;
  --warn-bg: #fdf3e0;
  --warn-line: #e8caa0;
  --warn-text: #85560f;
  --ok: #1a7f4f;
  --ok-soft: #e6f4ec;

  /* -- type -------------------------------------------------------------- */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-num: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;

  --fs-display: clamp(2.35rem, 1.4rem + 3.6vw, 3.9rem);
  --fs-h1: clamp(1.85rem, 1.3rem + 2.1vw, 2.6rem);
  --fs-h2: clamp(1.4rem, 1.15rem + 1vw, 1.8rem);
  --fs-h3: 1.15rem;
  --fs-body: 1rem;
  --fs-sm: 0.9rem;
  --fs-xs: 0.8rem;

  /* -- space ------------------------------------------------------------- */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px; --s9: 96px;

  /* -- shape: deliberately tight. Rounded corners are the whole "bubble"
        tell, so the scale tops out well short of a pill. ------------------ */
  --r-sm: 3px;
  --r-md: 5px;
  --r-lg: 10px;
  --radius-sm: 3px;
  --radius: 5px;
  --radius-lg: 8px;
  --radius-xl: 10px;

  --shadow-sm: 0 1px 2px rgba(18, 26, 40, .06), 0 1px 3px rgba(18, 26, 40, .04);
  --shadow: 0 2px 4px rgba(18, 26, 40, .05), 0 6px 16px rgba(18, 26, 40, .07);
  --shadow-lg: 0 8px 20px rgba(18, 26, 40, .09), 0 24px 48px rgba(18, 26, 40, .11);

  --tabbar-h: 62px;
  --sidebar-w: 232px;
  --ease: cubic-bezier(.2, .7, .3, 1);

  color-scheme: light;
}

/*
 * Dark palette. Three states, not two: an explicit choice stamps data-theme on
 * <html>; with nothing stamped we follow the OS. The media query is guarded
 * against data-theme="light" so choosing light on a dark machine actually
 * sticks, which is the bug every two-state implementation has.
 *
 * The block is written twice on purpose. A CSS selector list cannot straddle an
 * @media boundary, and a build step to de-duplicate it would be a worse trade
 * than thirty lines that change together.
 */
:root[data-theme="dark"] {
  --bg: #0d1724;
  --bg-alt: #101d2d;
  --surface: #152436;
  --surface-2: #1b2d42;
  --surface-3: #23374f;

  --text: #e9eef5;
  --text-2: #b4c3d4;
  --muted: #8697aa;
  --faint: #64748b;

  --line: #26384f;
  --line-strong: #354c68;

  --accent: #5fa8f5;
  --accent-hover: #7cb9f7;
  --accent-soft: #11263d;
  --accent-line: #28456a;
  --accent-text: #05121f;

  --brand-warm: #d8a860;
  --brand-warm-soft: #2a2015;
  --brand-warm-line: #543f22;
  --brand-warm-ink: #f0d5a8;

  --header: #0a1420;
  --header-2: #060e17;
  --header-ink: #e4ecf5;
  --header-muted: #8ba0b8;
  --header-line: #1d3047;

  --danger: #f2777a;
  --danger-soft: #2b1514;
  --danger-line: #5c2b28;
  --warn-bg: #33291a;
  --warn-line: #6b5426;
  --warn-text: #f0c675;
  --ok: #4ec98d;
  --ok-soft: #10281d;

  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1724;
    --bg-alt: #101d2d;
    --surface: #152436;
    --surface-2: #1b2d42;
    --surface-3: #23374f;

    --text: #e9eef5;
    --text-2: #b4c3d4;
    --muted: #8697aa;
    --faint: #64748b;

    --line: #26384f;
    --line-strong: #354c68;

    --accent: #5fa8f5;
    --accent-hover: #7cb9f7;
    --accent-soft: #11263d;
    --accent-line: #28456a;
    --accent-text: #05121f;

    --brand-warm: #d8a860;
    --brand-warm-soft: #2a2015;
    --brand-warm-line: #543f22;
    --brand-warm-ink: #f0d5a8;

    --header: #0a1420;
    --header-2: #060e17;
    --header-ink: #e4ecf5;
    --header-muted: #8ba0b8;
    --header-line: #1d3047;

    --danger: #f2777a;
    --danger-soft: #2b1514;
    --danger-line: #5c2b28;
    --warn-bg: #33291a;
    --warn-line: #6b5426;
    --warn-text: #f0c675;
    --ok: #4ec98d;
    --ok-soft: #10281d;

    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

/* Author `display` rules outrank the UA stylesheet's [hidden] rule, so hiding a
   .field or .row would otherwise do nothing. Make the attribute authoritative. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body {
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}

svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ───────────────────────────────── top bar ─────────────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

/* Reads as the page title with a chooser attached, not as a form control
   sitting in a box. */
.site-select {
  flex: 1; min-width: 0;
  appearance: none;
  padding: 4px 30px 4px 2px;
  font: inherit; font-size: 19px; font-weight: 650; letter-spacing: -0.02em;
  color: var(--text);
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 6px center / 16px;
  border: 0;
  cursor: pointer;
}

.icon-btn {
  display: grid; place-items: center;
  width: 36px; height: 36px; flex: none;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { background: var(--line); }

/* ─────────────────────────────────── views ─────────────────────────────── */

#main { flex: 1; }
.view { padding: 14px; max-width: 720px; margin: 0 auto; }
.view[hidden] { display: none; }

.section-label { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); font-size: 14px; margin: 2px 0 0; }
.hint { margin: -2px 0 4px; font-size: 12.5px; color: var(--muted); }

/* ────────────────────────────────── scanner ────────────────────────────── */

.scanner {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #0b0e11;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
#video { width: 100%; height: 100%; object-fit: cover; display: block; }

.camera-idle {
  position: absolute; inset: 0;
  display: grid; place-content: center; justify-items: center; gap: 10px;
  padding: 24px; text-align: center;
  color: #9aa4b0;
}
.camera-idle p { margin: 0; font-size: 14.5px; max-width: 24ch; }
.big-icon { width: 44px; height: 44px; opacity: .75; }
.scanner.is-live .camera-idle { display: none; }

.reticle { position: absolute; inset: 16% 12%; opacity: 0; transition: opacity .2s; }
.scanner.is-live .reticle { opacity: 1; }
.reticle span { position: absolute; width: 26px; height: 26px; border: 3px solid rgba(255,255,255,.9); border-radius: 4px; }
.reticle span:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.reticle span:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.reticle span:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; }
.reticle span:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; }

.scan-status { margin: 12px 2px; min-height: 1.4em; font-size: 14.5px; color: var(--muted); }
.scan-status.is-error { color: var(--danger); }
.scan-status.is-busy::after { content: "…"; }

.scan-actions { display: flex; gap: 8px; }
.scan-actions .btn { flex: 1; justify-content: center; white-space: nowrap; padding-inline: 10px; }

.recent { margin-top: 22px; }
.recent-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.recent-list li {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 9px 12px; font-size: 14.5px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
}
.recent-list b { font-weight: 600; }
.recent-list span { color: var(--muted); flex: none; }

/* ────────────────────────────────── buttons ────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 11px 16px;
  font: inherit; font-weight: 600;
  border: 1px solid transparent; border-radius: var(--r-md);
  cursor: pointer;
}
.btn-sm { padding: 7px 12px; font-size: 14px; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn-danger { background: transparent; color: var(--danger); border-color: currentColor; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; pointer-events: none; }

/* ─────────────────────────────────── forms ─────────────────────────────── */

/* Filled, not outlined. A column of outlined boxes is the single biggest
   contributor to the generated-template look; a filled field reads as
   something to type in without drawing a frame around itself. */
.input {
  width: 100%; padding: 9px 11px;
  font: inherit; color: var(--text);
  background: var(--surface-2);
  border: 1px solid transparent; border-radius: var(--r-md);
}
.input::placeholder { color: var(--muted); opacity: .8; }
.input:hover { border-color: var(--line); }
.input:focus { outline: none; background: var(--surface); border-color: var(--accent); }
.input:focus-visible { outline: none; }

.field { display: grid; gap: 5px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.stepper {
  display: grid; grid-template-columns: 40px 1fr 40px; align-items: stretch;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  overflow: hidden; background: var(--surface);
}
.stepper button {
  font-size: 19px; font-weight: 500; color: var(--muted);
  background: none; border: 0; cursor: pointer;
}
.stepper button:first-child { border-right: 1px solid var(--line); }
.stepper button:last-child { border-left: 1px solid var(--line); }
.stepper button:hover { background: var(--surface-2); color: var(--text); }
.stepper button:active { background: var(--accent); color: var(--accent-text); }
.stepper-value { min-width: 0; padding: 11px 4px; font: inherit; font-weight: 700; text-align: center; color: var(--text); background: transparent; border: 0; -moz-appearance: textfield; }
.stepper-value::-webkit-outer-spin-button, .stepper-value::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper-value:focus-visible { outline: none; }

.filters { display: grid; gap: 9px; margin-bottom: 14px; }
/* Underlined rather than filled. A search box is a place to type, not a
   container that needs drawing. */
.filters .input {
  background: none; border: 0; border-bottom: 1px solid var(--line);
  border-radius: 0; padding: 7px 2px; font-size: 15px;
}
.filters .input:hover { border-bottom-color: var(--muted); }
.filters .input:focus { background: none; border-bottom-color: var(--accent); }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 14.5px; color: var(--muted); }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ─────────────────────────────────── lists ─────────────────────────────── */

/* One bordered surface for the whole list rather than a gap-separated stack
   of cards. */
.list {
  display: grid;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
/* An empty list is not a thing, so it should not draw a box around nothing.
   This has to target the parent: the card lives on .list, and the older
   `.list > .empty:only-child` rule stripped the child's border instead, which
   the child never had. */
.list:empty, .list:has(> .empty:only-child) { border: 0; background: none; }
.list > section + section { border-top: 1px solid var(--line); }
.group-label {
  margin: 0;
  padding: 7px 14px 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

/* The entire list is one surface and category labels live inside it, so a
   category with a single item is just a row. Wrapping each category in its own
   card is what put the bubbles back after the first pass. */
.rows { display: grid; }
.rows > * + * { border-top: 1px solid var(--line); }

.row {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
}
.row:hover { background: var(--surface-2); }
/* Low stock is marked with a left edge rather than by recolouring the whole
   card, so a shelf that is mostly low does not become a wall of amber. */
.row.is-low { background: var(--warn-bg); box-shadow: inset 3px 0 0 var(--warn-line); }
.row-main { min-width: 0; cursor: pointer; }
.row-name { font-size: 15px; font-weight: 600; letter-spacing: -0.005em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.is-low .row-meta { color: var(--warn-text); }

/* One bordered control with hairline splits, not two grey tiles either side of
   a number. This is the control used most often in the app, so it is the one
   that most needed to stop looking like a pair of bubbles. */
.row-qty {
  display: flex; align-items: stretch; flex: none;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  overflow: hidden; background: var(--surface);
}
.row-qty button {
  width: 36px; font-size: 18px; font-weight: 500; line-height: 1;
  color: var(--muted); background: none; border: 0; cursor: pointer;
}
.row-qty button:first-child { border-right: 1px solid var(--line); }
.row-qty button:last-child { border-left: 1px solid var(--line); }
.row-qty button:hover { background: var(--surface-2); color: var(--text); }
.row-qty button:active { background: var(--accent); color: var(--accent-text); }
.row-qty output { min-width: 3.4ch; display: grid; place-items: center; text-align: center; font-variant-numeric: tabular-nums; font-weight: 700; }

.shop-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.shop-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 11px; }
.shop-row input[type=checkbox] { width: 21px; height: 21px; accent-color: var(--accent); flex: none; }
.shop-row.is-checked .row-name, .shop-row.is-checked .row-meta { opacity: .45; text-decoration: line-through; }
.need { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; color: var(--warn-text); white-space: nowrap; }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty p { margin: 0 0 4px; }
/* When an empty state sits above real content it shouldn't dominate the screen. */
.empty.compact { padding: 4px 8px 18px; text-align: left; }

.shop-head .btn { white-space: nowrap; }

/* ─────────────────────────────────── usage ─────────────────────────────── */

.apply-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 16px; padding: 11px 12px 11px 14px;
  font-size: 14px;
  background: var(--warn-bg); color: var(--warn-text);
  border: 1px solid var(--warn-line); border-radius: var(--r-md);
}
.apply-bar[hidden] { display: none; }

.usage-row { grid-template-columns: 1fr auto; }
.rate { font-variant-numeric: tabular-nums; }
.par-change {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--warn-text); background: var(--warn-bg);
  border: 1px solid var(--warn-line); border-radius: 999px;
  white-space: nowrap;
}
.par-change s { opacity: .6; }
.usage-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.link-btn {
  font: inherit; font-size: 13.5px; font-weight: 600;
  color: var(--accent); background: none; border: 0; padding: 4px 2px; cursor: pointer;
}
.badge-quiet { background: var(--accent); color: var(--accent-text); }
.cycle-note { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }

/* ──────────────────────────────── crew view ────────────────────────────── */

body.crew { padding-bottom: env(safe-area-inset-bottom); }
.crew-title { flex: 1; min-width: 0; display: grid; line-height: 1.25; }
.crew-title strong { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crew-title small { font-size: 12.5px; }

/* share link row inside the sites sheet */
.prop-list li { flex-wrap: wrap; }
.share-row {
  flex-basis: 100%;
  display: flex; align-items: center; gap: 8px;
  margin-top: 8px; padding-top: 8px;
  border-top: 1px dashed var(--line);
}
.share-row code {
  flex: 1; min-width: 0;
  padding: 6px 8px; font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: var(--surface-2); border-radius: var(--r-sm); color: var(--muted);
}
.share-row button { color: var(--accent); }

/* ────────────────────────────────── tab bar ────────────────────────────── */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  /* Columns follow however many tabs there are. A hardcoded count silently
     wraps the last tab onto a second row the moment one is added, which is
     exactly what happened when Activity arrived. */
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tab {
  position: relative;
  display: grid; justify-items: center; gap: 2px;
  height: var(--tabbar-h);
  font: inherit; font-size: 11.5px; font-weight: 600;
  color: var(--muted); background: none; border: 0; cursor: pointer;
  padding-top: 9px;
}
.tab.is-active { color: var(--accent); }
.badge {
  position: absolute; top: 5px; left: 50%; margin-left: 5px;
  min-width: 18px; padding: 0 5px;
  font-size: 11px; font-style: normal; font-weight: 700; line-height: 18px; text-align: center;
  color: var(--accent-text); background: var(--danger); border-radius: var(--r-md);
}

/* ─────────────────────────────── sheets / dialogs ──────────────────────── */

.sheet {
  width: min(560px, 100%);
  margin: auto auto 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  color: var(--text); background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  max-height: 92dvh;
}
@media (min-width: 600px) {
  .sheet { margin: auto; border-radius: var(--r-lg); }
}
.sheet::backdrop { background: rgba(0, 0, 0, .5); }
/* The sheet scrolls, not the page behind it. Settings grew past a phone's
   height once it gained its sections, and with overflow visible the account
   row and Delete account were simply unreachable. */
.sheet form { overflow: visible; }
.sheet { overflow-y: auto; overscroll-behavior: contain; }
.sheet form { display: grid; gap: 13px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-head h2 { margin: 0; font-size: 21px; font-weight: 650; letter-spacing: -0.015em; }
.sheet-actions { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.spacer { flex: 1; }

.origin {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; font-size: 13.5px;
  background: var(--surface-2); border-radius: var(--r-md); color: var(--muted);
}
.origin img { width: 40px; height: 40px; object-fit: contain; border-radius: var(--r-sm); background: #fff; flex: none; }
.origin b { color: var(--text); font-weight: 600; }

.prop-list { list-style: none; margin: 14px 0; padding: 0; display: grid; gap: 7px; max-height: 46dvh; overflow-y: auto; }
.prop-list li { display: flex; align-items: center; gap: 8px; padding: 9px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.prop-list span { flex: 1; font-weight: 600; }
.prop-list button { color: var(--danger); background: none; border: 0; font: inherit; font-size: 13.5px; cursor: pointer; }
.prop-add { display: grid; grid-template-columns: 1fr auto; gap: 8px; }

/* ──────────────────────────────────── toast ────────────────────────────── */

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px);
  transform: translateX(-50%);
  z-index: 40; max-width: min(92vw, 420px);
  padding: 11px 16px; font-size: 14.5px; font-weight: 500;
  color: var(--accent-text); background: var(--text);
  border-radius: var(--r-md); box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.toast[hidden] { display: none; }
.toast.is-error { background: var(--danger); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ────────────────────────────── passcode gate ──────────────────────────── */

.sheet-center { margin: auto; border-radius: var(--r-lg); max-width: min(420px, 92vw); }
.lock-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.lock-head img { border-radius: var(--r-md); flex: none; }
.lock-head h2 { margin: 0 0 2px; font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.lock-head .hint { margin: 0; }
.login-error { margin: -4px 0 0; font-size: 13.5px; font-weight: 500; color: var(--danger); }
.login-error[hidden] { display: none; }
#login-form { display: grid; gap: 13px; }
#login-form .btn { justify-content: center; }
.lock-row { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.lock-row .btn { width: 100%; justify-content: center; }
.lock-row[hidden] { display: none; }

/* ──────────────────────────────── accounts ─────────────────────────────── */

.auth-switch { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.auth-switch .link-btn { padding: 0; }
.auth-note { margin: -2px 0 0; padding: 9px 11px; font-size: 13.5px; color: var(--warn-text); background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: var(--r-md); }
.auth-note[hidden] { display: none; }

.account-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.account-who { display: grid; min-width: 0; line-height: 1.3; }
.account-who strong { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-who small { font-size: 12.5px; }
.account-actions { display: flex; align-items: center; gap: 12px; flex: none; }

/* ─────────────────────────── consolidated shopping ─────────────────────── */

.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  gap: 3px; margin: -4px 0 14px; padding: 3px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md);
}
.segmented button {
  padding: 8px 10px;
  font: inherit; font-size: 14px; font-weight: 600;
  color: var(--muted); background: none; border: 0; border-radius: 8px; cursor: pointer;
}
.segmented button.is-on { color: var(--text); background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* Where each unit's share goes when you unpack. */
.split { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 5px; }
.split span {
  font-size: 12.5px; font-variant-numeric: tabular-nums;
  padding: 2px 7px; border-radius: 999px;
  color: var(--warn-text); background: var(--warn-bg); border: 1px solid var(--warn-line);
}
.split b { font-weight: 700; }

.putaway-bar {
  /* Sticky offsets are measured from the viewport edge, which is exactly where
     the fixed tab bar sits, so `bottom: 8px` parked this behind it and every
     tap on Put away activated the Activity tab instead. .toast and
     .staff-basket already clear the bar the same way. */
  position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 16px; padding: 11px 12px 11px 14px;
  font-size: 14px; font-weight: 500;
  color: var(--accent-text); background: var(--text);
  border-radius: var(--r-md); box-shadow: 0 6px 20px rgba(0,0,0,.22);
}
.putaway-bar .btn-primary { background: var(--accent); color: var(--accent-text); }

/* ────────────────────────────────── staff view ─────────────────────────── */

body.staff { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.staff-lede { margin: -2px 0 14px; font-size: 14.5px; color: var(--muted); }

.staff-row { grid-template-columns: 1fr auto; }
.staff-row.is-taken { background: var(--warn-bg); border-color: var(--warn-line); }
.staff-main {
  display: block; width: 100%; min-width: 0;
  padding: 0; text-align: left;
  font: inherit; color: inherit; background: none; border: 0; cursor: pointer;
}
.staff-side { flex: none; }

/* Deliberately large: this is tapped standing up, one-handed, holding things. */
.took-add, .took-badge {
  min-width: 76px; padding: 11px 14px;
  font: inherit; font-size: 15px; font-weight: 700;
  border-radius: var(--r-md); cursor: pointer;
}
.took-add { color: var(--accent-text); background: var(--accent); border: 0; }
.took-badge {
  color: var(--warn-text); background: var(--surface);
  border: 1px solid var(--warn-line);
  font-variant-numeric: tabular-nums;
}
.took-add:active, .took-badge:active { transform: translateY(1px); }

.quick-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 4px; }
.quick {
  padding: 16px 0;
  font: inherit; font-size: 19px; font-weight: 700;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-md); cursor: pointer;
}
.quick:active { background: var(--accent); color: var(--accent-text); }

.staff-basket { position: fixed; left: 14px; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); margin: 0; }
.basket-actions { display: flex; align-items: center; gap: 12px; flex: none; }
.link-btn.on-dark { color: var(--accent); }

/* ──────────────────────────── staff management (owner) ─────────────────── */

.staff-list { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 8px; }
.staff-list li { padding: 11px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.staff-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.staff-top strong { font-size: 15px; }
.staff-props { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.staff-props label {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; font-size: 13px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
}
.staff-props input { accent-color: var(--accent); }
.staff-empty { margin: 10px 0; font-size: 14px; color: var(--muted); }
.sheet-form { display: grid; gap: 12px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.sheet-form .btn { justify-content: center; }

/* ─────────────────────────────── marketing page ────────────────────────── */

body.marketing { padding-bottom: 0; display: block; }
.site-head, .site-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1040px; margin: 0 auto; padding: 18px 20px;
}
.site-foot { border-top: 1px solid var(--line); margin-top: 48px; color: var(--muted); font-size: 14px; }
.site-foot a { color: var(--accent); }
.brand { display: flex; align-items: center; gap: 9px; color: inherit; text-decoration: none; font-size: 17px; }
.brand img { border-radius: var(--r-sm); }

.page { max-width: 1040px; margin: 0 auto; padding: 0 20px; }
.hero { padding: 28px 0 8px; max-width: 62ch; }
.hero h1 { margin: 0 0 12px; font-size: clamp(28px, 6vw, 40px); line-height: 1.12; letter-spacing: -0.02em; }
.lede { margin: 0; font-size: 17px; line-height: 1.5; color: var(--muted); }
.trial-line { margin: 14px 0 0; font-size: 14.5px; font-weight: 600; color: var(--accent); }

.toggle-row {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  margin: 28px 0 18px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  font-weight: 600;
}
.stepper-inline { width: 150px; }

.plan-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.plan-card {
  position: relative; display: flex; flex-direction: column; gap: 10px;
  padding: 20px 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
}
.plan-card.is-best { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.plan-card.is-out { opacity: .55; }
.plan-card h2 { margin: 0; font-size: 17px; }
.plan-price { margin: 0; font-size: 15px; color: var(--muted); }
.plan-price strong { font-size: 30px; color: var(--text); letter-spacing: -0.02em; }
.plan-tagline { margin: 0; font-size: 14px; color: var(--muted); }
.plan-features { margin: 4px 0 0; padding-left: 18px; display: grid; gap: 6px; font-size: 14px; }
.plan-note { margin: 0; font-size: 13px; color: var(--muted); }
.plan-card .btn { margin-top: auto; justify-content: center; text-decoration: none; }
.plan-flag {
  position: absolute; top: -10px; left: 16px;
  padding: 3px 9px; font-size: 12px; font-weight: 700;
  color: var(--accent-text); background: var(--accent); border-radius: 999px;
}

.faq { margin-top: 44px; max-width: 66ch; }
.faq h2 { font-size: 21px; margin: 0 0 4px; }
.faq h3 { font-size: 15.5px; margin: 22px 0 4px; }
.faq p { margin: 0; color: var(--muted); line-height: 1.55; }

/* ───────────────────────────── plan & billing (app) ────────────────────── */

.plan-current { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.plan-current strong { font-size: 19px; }
.plan-current .muted { margin: 0; }
.plan-usage { display: grid; gap: 8px; margin: 14px 0 4px; }
.usage-line { display: grid; gap: 5px; }
.usage-line span { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--muted); }
.meter { height: 7px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); }
.meter.is-full i { background: var(--danger); }
.plan-options { display: grid; gap: 8px; margin-top: 14px; }
.plan-option {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; text-align: left;
  font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); cursor: pointer;
}
.plan-option.is-current { border-color: var(--accent); cursor: default; }
.plan-option b { display: block; font-size: 15px; }
.plan-option small { color: var(--muted); font-size: 13px; }
.plan-option .price { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.trial-banner {
  margin: 10px 0 0; padding: 9px 11px; font-size: 13.5px;
  color: var(--warn-text); background: var(--warn-bg);
  border: 1px solid var(--warn-line); border-radius: var(--r-md);
}

/* ──────────────────────────── category manager ─────────────────────────── */
/* Labels are edited in place: a rename is the common action, so it should not
   need a separate screen. The slug behind it never changes. */
#categories-list li { display: flex; align-items: center; gap: 8px; }
#categories-list .input-inline { flex: 1; min-width: 0; padding: 7px 10px; font-size: 14.5px; }

/* ───────────────────────────────── activity ────────────────────────────── */
/* The ledger, read rather than written. Deltas are the thing the eye should
   land on, so they carry the colour and everything else stays quiet. */
.mini-select {
  font: inherit; font-size: 13.5px;
  padding: 7px 10px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); color: var(--text);
  flex: none;
}

.glance { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.glance-cell {
  display: grid; gap: 1px; justify-items: center;
  padding: 10px 6px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface);
}
.glance-cell strong { font-size: 19px; font-variant-numeric: tabular-nums; }
.glance-cell small { font-size: 12px; color: var(--muted); }

.activity-row { align-items: center; }
.activity-delta {
  font-size: 15.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 4px 10px; border-radius: var(--r-md);
  flex: none;
}
.activity-delta.is-out { color: var(--danger); background: var(--warn-bg); }
.activity-delta.is-in { color: var(--accent); background: var(--accent-soft); }

/* Export sits at the bottom of Activity because it is an ending, not an action
   you reach for first. */
.export-row { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.export-row .btn { text-decoration: none; }

/* ─────────────────────────────── settings sheet ────────────────────────── */
/* One sheet, several concerns. Each gets a heading and one sentence saying
   what it is for, because a bare list of buttons reads as a developer menu. */
.menu-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.menu-section .section-label { margin-bottom: 6px; }
.menu-section .hint { margin: 0 0 12px; line-height: 1.45; }
.menu-section .prop-list { margin: 0 0 10px; }
.menu-section > .btn, .menu-actions .btn { width: 100%; justify-content: center; }
.menu-actions { display: grid; gap: 8px; }
.menu-actions .btn { text-decoration: none; }

/* ─────────────────────────────── theme picker ──────────────────────────── */
.theme-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.theme-row > span { font-size: 13.5px; color: var(--muted); margin-right: auto; }
.theme-choice {
  display: flex; gap: 2px; padding: 2px;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2);
}
.theme-choice button {
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 5px 11px; border: 0; border-radius: var(--r-md);
  background: none; color: var(--muted); cursor: pointer;
}
.theme-choice button.is-on { background: var(--surface); color: var(--text); }
.theme-choice button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ────────────────────────────────── legal ──────────────────────────────── */
/* Long prose, read once, usually on a phone. Narrow measure and generous
   leading matter more here than anywhere else in the app. */
.legal { max-width: 46rem; }
.legal h1 { font-size: 30px; letter-spacing: -0.01em; margin: 0 0 6px; }
.legal h2 {
  font-size: 17px; margin: 34px 0 8px;
  padding-top: 18px; border-top: 1px solid var(--line);
}
.legal p, .legal li { font-size: 15.5px; line-height: 1.65; color: var(--text); }
.legal ul { padding-left: 20px; display: grid; gap: 7px; }
.legal code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px; padding: 1px 5px;
  background: var(--surface-2); border-radius: var(--r-sm);
}
.legal a { color: var(--accent); }
.legal-meta { font-size: 13.5px; color: var(--muted); margin: 0 0 8px; }
/* Unfilled placeholders should be impossible to miss before launch. */
.legal strong:not(:empty) { font-weight: 650; }

/* ──────────────────────────────── landing page ─────────────────────────── */

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 20;
  background: var(--accent); color: var(--accent-text);
  padding: 10px 14px; border-radius: var(--r-sm); font-size: 14px;
}
.skip:focus { left: 12px; top: 12px; }

/* The ground carries a faint dot grid. It reads as paper rather than as a
   blank screen, and at this contrast it never competes with the text. */
body.marketing {
  background-image: radial-gradient(var(--line-strong) 0.5px, transparent 0.5px);
  background-size: 22px 22px;
  background-attachment: fixed;
}

.site-head {
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 10;
}
.site-nav { display: none; gap: 22px; margin-left: 30px; margin-right: auto; }
.site-nav a { font-size: 14.5px; color: var(--text-2); text-decoration: none; }
.site-nav a:hover { color: var(--accent); }
@media (min-width: 760px) { .site-nav { display: flex; } }

/* An eyebrow: small, spaced, bronze, with a rule running off it. Used above
   every section heading so the page has a spine instead of a stack of H2s. */
.eyebrow {
  display: flex; align-items: center; gap: 10px;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--brand-warm-ink);
  margin: 0 0 10px;
}
.eyebrow::after { content: ""; flex: 1; height: 1px; background: var(--brand-warm-line); }
:root[data-theme="dark"] .eyebrow { color: var(--brand-warm); }

/* ── hero ─────────────────────────────────────────────────────────────── */

.hero { display: grid; gap: 40px; align-items: center; padding: 44px 0 36px; max-width: none; }
@media (min-width: 940px) {
  .hero { grid-template-columns: minmax(0, 1fr) minmax(0, 420px); gap: 56px; padding: 64px 0 52px; }
}
.hero-copy { max-width: 34rem; }
/* Smaller than --fs-display: the hero shares its row with the preview panel,
   so the headline has a column to live in, not the full page. */
.hero h1 {
  margin: 0 0 14px; font-size: clamp(2.1rem, 1.3rem + 2.3vw, 3rem);
  line-height: 1.1; letter-spacing: -0.025em; font-weight: 800;
}
.hero .lede { font-size: 17.5px; line-height: 1.6; color: var(--text-2); margin: 0; }
.hero-actions { display: flex; gap: 10px; margin-top: 26px; flex-wrap: wrap; }
.hero-actions .btn { text-decoration: none; }
.hero-note { margin: 14px 0 0; font-size: 13.5px; color: var(--muted); }

/* A chip stating who it is for, above the headline. */
.hero-tag {
  display: inline-block; margin: 0 0 16px;
  background: var(--brand-warm-soft); color: var(--brand-warm-ink);
  border: 1px solid var(--brand-warm-line); border-radius: var(--r-sm);
  padding: 4px 9px; font-size: 12.5px; font-weight: 600;
}

/* ── the preview panel ────────────────────────────────────────────────── */
/* A still of the restock list. It shows the product rather than illustrating
   it, so the markup mirrors a real row: name, state, verdict. */

.preview {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden;
}
.preview-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.preview-head strong { font-size: 14.5px; }
.preview-head span { font-size: 12.5px; color: var(--muted); }
.preview-row {
  display: grid; grid-template-columns: 1fr auto; gap: 3px 12px;
  align-items: center; padding: 11px 14px; border-bottom: 1px solid var(--line);
}
.preview-row:last-child { border-bottom: 0; }
.preview-row b { grid-column: 1; font-weight: 600; font-size: 14.5px; }
.preview-row small { grid-column: 1; font-size: 12.5px; color: var(--muted); font-family: var(--font-num); }
/* The verdict spans both text rows in the second column. Without the explicit
   column it auto-places into the first and stretches across the name. */
.verdict {
  grid-column: 2; grid-row: 1 / span 2;
  justify-self: end; align-self: center;
  font-size: 12.5px; font-weight: 700;
  padding: 3px 8px; border-radius: var(--r-sm); white-space: nowrap;
}
.verdict.buy { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-line); }
.verdict.ok  { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

/* ── facts strip ──────────────────────────────────────────────────────── */
/* Product facts, every one checkable in the repo. No customer counts. */

.facts-strip {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px;
  background: var(--line); border: 1px solid var(--line);
  border-radius: var(--r-lg); overflow: hidden; margin: 8px 0 0;
}
@media (min-width: 760px) { .facts-strip { grid-template-columns: repeat(4, 1fr); } }
.facts-strip div { background: var(--bg); padding: 16px 14px; }
.facts-strip dt {
  font-size: 22px; font-weight: 750; letter-spacing: -0.02em;
  font-family: var(--font-num); color: var(--text);
}
.facts-strip dd { margin: 3px 0 0; font-size: 13px; color: var(--muted); line-height: 1.4; }

/* ── bands ────────────────────────────────────────────────────────────── */

.band { padding: 48px 0; border-top: 1px solid var(--line); margin-top: 8px; }
.band h2 { margin: 0 0 12px; font-size: var(--fs-h2); letter-spacing: -0.02em; font-weight: 750; line-height: 1.15; }
.band-lede { margin: 0 0 26px; max-width: 44rem; color: var(--text-2); font-size: 16px; line-height: 1.6; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.steps li { display: grid; grid-template-columns: auto 1fr; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.steps li:last-child { border-bottom: 0; }
.step-n {
  width: 26px; height: 26px; display: grid; place-items: center;
  border: 1px solid var(--accent-line); background: var(--accent-soft);
  color: var(--accent); border-radius: var(--r-sm);
  font-size: 13px; font-weight: 700; font-family: var(--font-num);
}
.steps h3 { margin: 0 0 5px; font-size: var(--fs-h3); font-weight: 650; }
.steps p { margin: 0; color: var(--text-2); font-size: 15px; line-height: 1.6; }

/* Audience cards: one bordered surface split by hairlines, never four
   separate floating bubbles. */
.who-grid {
  display: grid; gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden;
}
@media (min-width: 720px) { .who-grid { grid-template-columns: repeat(2, 1fr); } }
.who-card { background: var(--surface); padding: 18px 18px 20px; }
.who-card h3 { margin: 0 0 6px; font-size: 15.5px; font-weight: 700; }
.who-card p { margin: 0; color: var(--text-2); font-size: 14.5px; line-height: 1.55; }
.who-terms { display: block; margin-top: 8px; font-size: 12.5px; color: var(--muted); font-family: var(--font-num); }

/* Feature list: an icon, a claim, a sentence. */
.facts { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; margin: 0; }
@media (min-width: 720px) { .facts { grid-template-columns: repeat(2, 1fr); } }
.facts > div { background: var(--surface); padding: 18px; display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; }
.facts svg { width: 19px; height: 19px; color: var(--accent); margin-top: 1px; grid-row: 1 / span 2; }
.facts dt { grid-column: 2; font-weight: 650; font-size: 15px; margin-bottom: 4px; }
.facts dd { grid-column: 2; margin: 0; color: var(--text-2); font-size: 14.5px; line-height: 1.55; }

.closing .btn { text-decoration: none; }

/* ── footer ───────────────────────────────────────────────────────────── */

.site-foot {
  border-top: 1px solid var(--line); margin-top: 0; padding: 26px 0 40px;
  color: var(--muted); font-size: 14px;
  display: flex; flex-wrap: wrap; gap: 14px 20px; align-items: center;
}
.site-foot a { color: var(--text-2); text-decoration: none; }
.site-foot a:hover { color: var(--accent); text-decoration: underline; }
.foot-spacer { flex: 1; }

/* Three-way theme control, sharing the closet.theme key the app already uses. */
.theme-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: var(--surface); }
.theme-toggle button {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font: inherit; font-size: 12.5px; color: var(--text-2);
  padding: 5px 11px; border-right: 1px solid var(--line);
}
.theme-toggle button:last-child { border-right: 0; }
.theme-toggle button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }

/* ═══════════════════════════════ navy chrome ═════════════════════════════ */
/*
 * The whole app hangs under a dark navy bar, the way the original build did.
 * Tan stays the reading ground; navy carries the furniture around it, so the
 * blue is structural rather than a colour sprinkled on a few buttons.
 *
 * Navy needs a lighter blue for anything that has to read as clickable on top
 * of it. The page accent is too close to the bar itself to show up.
 */
:root { --accent-bright: #3b82d6; }
:root[data-theme="dark"] { --accent-bright: #6fb2f8; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --accent-bright: #6fb2f8; }
}

/* ── the app bar ──────────────────────────────────────────────────────── */

.topbar {
  background: var(--header);
  border-bottom: 1px solid var(--header-line);
  backdrop-filter: none;
  color: var(--header-ink);
}
.topbar .site-select {
  color: var(--header-ink);
  /* The chevron is a data URI, so its colour is baked in. Light stroke to
     match the bar rather than the page. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239bb0c9' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}
.topbar .site-select option { color: var(--text); background: var(--surface); }
.topbar .icon-btn, .topbar button { color: var(--header-ink); }
.topbar .icon-btn:hover { background: var(--header-line); }

/* ── the tab bar ──────────────────────────────────────────────────────── */

.tabbar {
  background: var(--header);
  border-top: 1px solid var(--header-line);
  backdrop-filter: none;
}
.tab { color: var(--header-muted); }
.tab.is-active { color: #ffffff; }
/* A rail across the top of the live cell. Colour alone is a weak signal at
   11px, and this is the control people hit with a thumb in a store room. */
.tab.is-active::before {
  content: ""; position: absolute; top: 0; left: 18%; right: 18%;
  height: 2px; background: var(--accent-bright);
}

/* ── the header search (desktop only) ─────────────────────────────────── */

/* Hidden on a phone: the Closet tab has its own search where the thumb is.
   On a laptop it is the control people reach for first, so it gets the
   middle of the bar. */
.topsearch {
  display: none; align-items: center; gap: 8px;
  flex: 1 1 auto; max-width: 520px; min-width: 0;
  padding: 0 10px; height: 36px;
  background: var(--header-2);
  border: 1px solid var(--header-line); border-radius: var(--r-md);
}
.topsearch:focus-within { border-color: var(--accent-bright); }
.topsearch-icon { width: 17px; height: 17px; flex: none; color: var(--header-muted); }
.topsearch input {
  flex: 1; min-width: 0; height: 100%;
  font: inherit; font-size: 14.5px; color: var(--header-ink);
  background: none; border: 0;
}
.topsearch input::placeholder { color: var(--header-muted); }
.topsearch input:focus { outline: none; }
.topsearch input::-webkit-search-cancel-button { filter: invert(1); }

/* ── desktop: the tab bar becomes a sidebar ───────────────────────────── */

/*
 * Only the owner app has a .tabbar, and it is the one page with a bare
 * <body>, so scoping on the body classes keeps the staff, crew and marketing
 * pages on their own layouts.
 *
 * Grid areas rather than flex ordering: the nav is last in the DOM (right for
 * a phone, where it reads after the content) but needs to be the left column
 * on a desktop, and named areas move it there without touching the markup.
 * The body fills the window and only #main scrolls, so the sidebar and the
 * bar simply stay where they are without any sticky arithmetic.
 */
@media (min-width: 900px) {
  body:not(.staff):not(.crew):not(.marketing) {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas: "topbar topbar" "offline offline" "nav main";
    height: 100dvh; overflow: hidden;
    padding-bottom: 0;
  }
  .topbar { grid-area: topbar; position: static; }
  .topsearch { display: flex; }
  .topbar .site-select { flex: 0 1 auto; max-width: 340px; margin-right: auto; }
  #main { grid-area: main; overflow-y: auto; }

  .tabbar {
    grid-area: nav;
    position: static;
    display: flex; flex-direction: column; gap: 2px;
    padding: 12px 10px;
    border-top: 0; border-right: 1px solid var(--header-line);
    backdrop-filter: none;
  }
  .tab {
    height: auto; padding: 11px 13px;
    grid-auto-flow: column; grid-auto-columns: auto 1fr;
    justify-items: start; align-items: center; gap: 12px;
    font-size: 14.5px; border-radius: var(--r-md);
  }
  .tab.is-active { background: var(--header-2); }
  /* The rail moves from the top edge to the left edge. */
  .tab.is-active::before { top: 22%; bottom: 22%; left: 0; right: auto; width: 3px; height: auto; }
  .tab .badge { position: static; margin-left: auto; }

  .view { max-width: 1000px; padding: 24px 28px 40px; }

  /* The scanner is 4:3, so a 1000px column makes it most of a laptop screen
     for a viewfinder nobody uses at a desk. Cap it. */
  .scanner, .scan-status, .scan-actions, .recent { max-width: 560px; margin-inline: auto; }

  /* Nothing sits at the bottom of the window any more. */
  .toast { bottom: 24px; }
  .putaway-bar { bottom: 8px; }
}

/* ── marketing header and footer ──────────────────────────────────────── */

/* The bar runs the full width of the window while its contents stay on the
   same 1040px column as .page, so the brand lines up with the headline under
   it. A constrained bar would leave tan slivers at both edges. */
body.marketing .site-head,
body.marketing .site-foot {
  max-width: none; margin-inline: 0; width: 100%;
  padding-inline: max(20px, calc((100% - 1040px) / 2 + 20px));
}

body.marketing .site-head {
  background: var(--header);
  border-bottom: 1px solid var(--header-line);
  backdrop-filter: none;
  color: var(--header-ink);
}
body.marketing .site-head .brand { color: var(--header-ink); }
body.marketing .site-nav a { color: var(--header-muted); }
body.marketing .site-nav a:hover { color: #ffffff; }
body.marketing .site-head .btn-primary {
  background: var(--accent-bright); border-color: var(--accent-bright); color: #ffffff;
}
body.marketing .site-head .btn-primary:hover { background: #5497e0; border-color: #5497e0; }

body.marketing .site-foot {
  background: var(--header);
  border-top: 1px solid var(--header-line);
  color: var(--header-muted);
}
body.marketing .site-foot a { color: var(--header-ink); }
body.marketing .site-foot a:hover { color: #ffffff; }
body.marketing .site-foot .theme-toggle {
  background: transparent; border-color: var(--header-line);
}
body.marketing .site-foot .theme-toggle button {
  color: var(--header-muted); border-right-color: var(--header-line);
}
body.marketing .site-foot .theme-toggle button[aria-pressed="true"] {
  background: var(--accent-bright); color: #ffffff;
}

/* ── navy accents inside the page ─────────────────────────────────────── */

/* The preview panel is a window onto the app, so it wears the app bar. */
.preview-head {
  background: var(--header); color: var(--header-ink);
  border-bottom-color: var(--header-line);
}
.preview-head span { color: var(--header-muted); }

/* The closing call to action is a solid navy block, which gives the foot of
   the page the same weight as its head. */
.band.closing {
  background: var(--header); color: var(--header-ink);
  border: 1px solid var(--header-line); border-radius: var(--r-lg);
  padding: 36px 28px; margin-top: 48px; margin-bottom: 8px;
}
.band.closing h2 { color: #ffffff; }
.band.closing .band-lede { color: var(--header-muted); }
.band.closing .eyebrow { color: var(--brand-warm); }
.band.closing .eyebrow::after { background: var(--header-line); }
.band.closing .btn-primary {
  background: var(--accent-bright); border-color: var(--accent-bright); color: #ffffff;
}
.band.closing .btn-primary:hover { background: #5497e0; border-color: #5497e0; }

/* account deletion */
.link-btn.link-danger { color: var(--danger); }
.delete-list { margin: 0; padding-left: 20px; display: grid; gap: 5px; font-size: 14px; line-height: 1.4; }
#delete-dialog .hint { margin: 0; }
#delete-dialog .sheet-actions { justify-content: flex-end; }

/* offline bar */

/* Sits directly under the top bar and says, once, that the counts on screen
   are the last ones this device saw. Square on purpose: it is a strip of the
   page, not a card. */
.offline-bar {
  width: 100%;
  background: var(--warn-bg);
  color: var(--warn-text);
  border-bottom: 1px solid var(--warn-line);
  font-size: 13.5px;
  padding: 8px 14px;
  border-radius: 0;
}
.offline-bar[hidden] { display: none; }

@media (min-width: 900px) {
  .offline-bar { grid-area: offline; grid-column: 1 / -1; }
}

/* two-factor setup */
.twofa-key { display: grid; gap: 4px; margin: 10px 0; }
.twofa-key code { font-family: var(--font-num); font-size: 16px; letter-spacing: 1px; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); word-break: break-all; }
.twofa-codes { list-style: none; margin: 10px 0; padding: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); }
.twofa-codes li { font-family: var(--font-num); font-size: 14.5px; }
