/* Sentorigo staff portal: design system and app shell.
   Source: eva's dashboard mockup (F:\work\artifacts\sentorigo-portal-dashboard-mockup.html) and the
   Sentorigo Brand Book v1.4. CSP-clean: no inline styles anywhere; this file and its siblings are the only CSS.

   Page-root classes (set server-side on <html>, so there is no flash):
     text-a | text-a1 | text-a2            text size A / A+ / A++  (1 / 1.18 / 1.36)
     theme-system | theme-light | theme-dark
     motion-system | motion-reduce | motion-full
   Everything is sized in rem, so the text-size class scales the whole interface. The wordmark keeps its size.
   Layout switches are container queries on .app / .auth measured in em, so a larger text size moves to the
   phone layout earlier instead of squeezing.  phone < 40em <= tablet < 64em <= desktop                     */

/* ------------------------------------------------------------------ fonts (self-hosted, SIL OFL, see fonts/OFL.txt) */
@font-face {
  font-family: "Archivo";
  src: url("../fonts/archivo-latin-var.woff2") format("woff2");
  font-weight: 400 750;
  font-stretch: 80% 125%;
  font-style: normal;
  font-display: swap;
}

/* ------------------------------------------------------------------ tokens */
:root {
  --paper: #F5F3EF; --paper-2: #ECE8E1; --panel: #FBFAF7;
  --ink: #1A1A1A; --ink-2: #55504A; --line: #BDB6AB; --grid: #E6E1D8;
  --amber: #E2871F; --amber-ink: #A85F0E;
  --risk: #A3392A; --risk-bg: #F8EAE6; --risk-line: #E0B4AA;        /* overdue, errors */
  --ok: #3E6B47; --ok-bg: #ECF2EC; --ok-line: #B7CDBB;              /* paid, done */
  --focus: #A85F0E;
  --scrim: rgba(26, 26, 26, .45);
  --qr-bg: #FFFFFF;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --rad: 3px;
  --rule: 1.5px;
  --tap: 2.75rem;                 /* 44 px at A; grows with the text size */
  --top-h: 3.5rem;
  --nav-h: 4.375rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not(.theme-light) {
    --paper: #141414; --paper-2: #24221F; --panel: #1C1B19;
    --ink: #F5F3EF; --ink-2: #BDB6AB; --line: #3A3733; --grid: #2A2824;
    --risk: #E58A75; --risk-bg: #33201B; --risk-line: #6A3A2F;
    --ok: #93C29E; --ok-bg: #1C2A20; --ok-line: #36513C;
    --focus: #E2871F; --scrim: rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root.theme-dark {
  --paper: #141414; --paper-2: #24221F; --panel: #1C1B19;
  --ink: #F5F3EF; --ink-2: #BDB6AB; --line: #3A3733; --grid: #2A2824;
  --risk: #E58A75; --risk-bg: #33201B; --risk-line: #6A3A2F;
  --ok: #93C29E; --ok-bg: #1C2A20; --ok-line: #36513C;
  --focus: #E2871F; --scrim: rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* text size: the whole interface is rem-based */
html { font-size: 100%; }
html.text-a1 { font-size: 118%; }
html.text-a2 { font-size: 136%; }

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: rgba(226, 135, 31, .18); }
body {
  background: var(--paper); color: var(--ink);
  font-family: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: .9375rem; line-height: 1.5; -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
::selection { background: var(--amber); color: #1A1A1A; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
h1 { font-weight: 750; font-size: 1.5rem; letter-spacing: -.01em; }                  /* brand book: H1 750 */
h2 { font-stretch: 118%; font-weight: 720; font-size: 1.0625rem; }                    /* H2 720 at 118% */
h3 { font-stretch: 110%; font-weight: 680; font-size: .9375rem; }                     /* H3 680 at 110% */
p { margin: 0 0 .75rem; }
p:last-child { margin-bottom: 0; }
small, .muted { color: var(--ink-2); font-size: .8125rem; }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, "Roboto Mono", monospace; font-size: .92em; }
.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;
}
.skip-link { position: absolute; left: 1rem; top: -4rem; z-index: 20; }
.skip-link:focus { top: .5rem; }

/* type roles */
.lbl { font-stretch: 80%; text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; color: var(--ink-2); font-weight: 600; }
.num { font-stretch: 108%; font-weight: 680; font-variant-numeric: tabular-nums; white-space: nowrap; }
.wm { font-weight: 650; font-stretch: 125%; letter-spacing: .08em; font-size: 16px; text-transform: uppercase; line-height: 1; white-space: nowrap; }
.nb { white-space: nowrap; }

/* ------------------------------------------------------------------ icons (inline SVG, see templates/_icons.html) */
.ico { width: 1.25rem; height: 1.25rem; flex: 0 0 auto; }
.ico-lg { width: 1.5rem; height: 1.5rem; }
.mark { width: 24px; height: 26px; min-height: 26px; flex: 0 0 auto; }          /* header shield: 24 x 26, never smaller */

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: var(--tap); padding: 0 1rem; border-radius: var(--rad);
  border: var(--rule) solid var(--ink); background: var(--ink); color: var(--paper);
  font-weight: 600; font-size: .875rem; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: transform .12s var(--ease), background-color .15s, filter .15s;
}
.btn:hover { filter: brightness(.86); text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { filter: none; background: var(--paper-2); }
.btn.big { min-height: 3.25rem; padding: 0 1.25rem; font-size: 1rem; }
.btn.block { display: flex; width: 100%; }
.btn.danger { background: var(--risk); border-color: var(--risk); color: #FFFFFF; }
@media (prefers-color-scheme: dark) { :root:not(.theme-light) .btn.danger { color: #141414; } }
:root.theme-dark .btn.danger { color: #141414; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; filter: none; transform: none; }
.btn .ico { width: 1.125rem; height: 1.125rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: .625rem; align-items: center; }
.btn.busy { opacity: .6; cursor: progress; }
.copy-key { margin: 0 0 1rem; }
.codes-actions { margin: 0 0 1.25rem; }
.codes-actions .copy-key { margin: 0; }
.switch-keys { display: inline-flex; align-items: center; font-size: .8125rem; margin: 0; }
.linkbtn { background: none; border: 0; padding: 0; min-height: var(--tap); color: inherit; text-decoration: underline; text-underline-offset: .18em; cursor: pointer; font-weight: 600; }

/* ------------------------------------------------------------------ chips and tags */
.chip {
  display: inline-flex; align-items: center; gap: .375rem; min-height: 1.5rem; padding: 0 .5rem;
  border-radius: var(--rad); font-size: .8125rem; font-weight: 600; white-space: nowrap;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-2);
}
.chip.risk { color: var(--risk); border-color: var(--risk-line); background: var(--risk-bg); }
.chip.ok { color: var(--ok); border-color: var(--ok-line); background: var(--ok-bg); }
.chip.you::before { content: ""; width: .375rem; height: .375rem; border-radius: 50%; background: var(--amber); }
.tag {
  font-stretch: 80%; text-transform: uppercase; letter-spacing: .07em; font-size: .6875rem; font-weight: 700;
  color: var(--ink-2); border: 1px solid var(--line); border-radius: 2px; padding: .0625rem .375rem; white-space: nowrap;
}
.risk-t { color: var(--risk); }
.ok-t { color: var(--ok); }

/* ------------------------------------------------------------------ notices */
.notice {
  display: flex; gap: .625rem; align-items: flex-start; margin: 0 0 1rem; padding: .75rem .875rem;
  border: var(--rule) solid var(--line); border-radius: var(--rad); background: var(--panel); font-size: .875rem;
}
.notice .ico { margin-top: .0625rem; }
.notice.risk { border-color: var(--risk-line); background: var(--risk-bg); color: var(--ink); }
.notice.risk .ico { color: var(--risk); }
.notice.ok { border-color: var(--ok-line); background: var(--ok-bg); }
.notice.ok .ico { color: var(--ok); }
.strip-notice {
  margin: 0; padding: .5rem 1.25rem; border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  background: var(--paper-2); font-size: .8125rem;
}

/* ------------------------------------------------------------------ panels */
.panel {
  background: var(--panel); border: var(--rule) solid var(--ink); border-radius: var(--rad);
  padding: 1.125rem 1.25rem;
}
.panel.quiet { border-color: var(--line); }
.panel + .panel { margin-top: 1rem; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin: 0 0 .75rem; }
.blueprint {
  background-color: var(--panel);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 20px 20px;
}
.empty { padding: 1.25rem 0 .25rem; color: var(--ink-2); }
.empty p { max-width: 46ch; }

/* key/value list (account, details pages) */
.kv { display: grid; grid-template-columns: minmax(7.5rem, auto) minmax(0, 1fr); gap: 0 1rem; margin: 0; }
.kv dt, .kv dd { margin: 0; padding: .625rem 0; border-top: 1px solid var(--grid); }
.kv dt:first-of-type, .kv dd:first-of-type { border-top: 0; }
.kv dt { color: var(--ink-2); font-size: .875rem; }
.kv dd { min-width: 0; overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ forms */
.field { display: grid; gap: .375rem; margin: 0 0 1rem; }
.field label, .field .label { font-weight: 600; font-size: .875rem; }
.field .hint { color: var(--ink-2); font-size: .8125rem; margin: 0; }
.field .error { color: var(--risk); font-size: .8125rem; font-weight: 600; margin: 0; }
.input, .field input[type="text"], .field input[type="email"], .field input[type="number"], .field input[type="date"],
.field input[type="search"], .field input[type="tel"], .field select, .field textarea {
  width: 100%; min-height: var(--tap); padding: .5rem .75rem; font-size: 1rem;
  background: var(--panel); color: var(--ink); border: var(--rule) solid var(--ink-2); border-radius: var(--rad);   /* 3:1 or better at rest */
}
.field textarea { min-height: 6rem; resize: vertical; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--ink); }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible { border-color: var(--ink); }
.field.invalid input, .field.invalid select, .field.invalid textarea, .input[aria-invalid="true"] { border-color: var(--risk); }
/* one-time and setup codes: big, spaced, tabular */
.input.code {
  min-height: 3.5rem; font-size: 1.5rem; font-weight: 650; font-stretch: 108%; letter-spacing: .18em;
  font-variant-numeric: tabular-nums; text-align: center;
}

/* segmented choice (preferences): every option is a real submit button */
.prefs { margin: 0; }
.prefs fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.prefs fieldset + fieldset { margin-top: .875rem; }
.prefs legend { padding: 0; margin: 0 0 .375rem; }
.seg { display: flex; border: var(--rule) solid var(--ink); border-radius: var(--rad); overflow: hidden; }
.seg button {
  flex: 1 1 0; min-width: 0; min-height: var(--tap); padding: 0 .5rem; border: 0; background: var(--panel); color: var(--ink);
  font-weight: 600; font-size: .875rem; cursor: pointer; white-space: nowrap;
  transition: background-color .15s;
}
.seg button + button { border-left: var(--rule) solid var(--ink); }
.seg button:hover { background: var(--paper-2); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.seg button:focus-visible { outline-offset: -4px; }
.seg.sizes button:nth-child(1) { font-size: .8125rem; }
.seg.sizes button:nth-child(2) { font-size: 1rem; }
.seg.sizes button:nth-child(3) { font-size: 1.1875rem; }

/* ------------------------------------------------------------------ menus and sheets (details/summary: work with no JS) */
.pop { position: relative; }
.pop > summary { list-style: none; cursor: pointer; }
.pop > summary::-webkit-details-marker { display: none; }
.pop-panel {
  position: absolute; right: 0; top: calc(100% + .375rem); z-index: 9; width: 18rem; max-width: calc(100vw - 2rem);
  background: var(--panel); border: var(--rule) solid var(--ink); border-radius: var(--rad); padding: .375rem;
}
.pop[open] > .pop-panel { animation: pop .14s var(--ease); }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(-4px); } to { opacity: 1; transform: none; } }
.pop-head { padding: .5rem .625rem .625rem; border-bottom: 1px solid var(--grid); margin-bottom: .25rem; min-width: 0; }
.pop-head b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-head small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-body { padding: .5rem .625rem .625rem; }
.mi {
  display: flex; align-items: center; gap: .625rem; width: 100%; min-height: var(--tap); padding: 0 .625rem;
  border: 0; border-radius: var(--rad); background: none; color: var(--ink); font-weight: 600; font-size: .875rem;
  text-align: left; text-decoration: none; cursor: pointer;
}
.mi:hover { background: var(--paper-2); text-decoration: none; }
.mi:active, .tbtn:active, .seg button:active { background: var(--paper-2); transform: scale(.98); }
.tbtn { transition: border-color .15s, background-color .15s, transform .12s var(--ease); }
.mi { transition: background-color .12s; }
.seg button[aria-pressed="true"]:active { background: var(--ink); filter: brightness(1.25); }
.mi-form { margin: 0; }
.mi-sep { height: 1px; background: var(--grid); margin: .25rem 0; }

/* ------------------------------------------------------------------ app shell */
.app { container: app / inline-size; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 6; display: flex; align-items: center; gap: .875rem;
  min-height: var(--top-h); padding: 0 1.25rem; background: var(--paper); border-bottom: var(--rule) solid var(--ink);
}
.top > * { min-width: 0; }
.lockup { display: flex; align-items: center; gap: 9px; text-decoration: none; flex: 0 0 auto; min-height: var(--tap); min-width: var(--tap); }
.lockup:hover { text-decoration: none; }
.plabel {
  font-stretch: 80%; text-transform: uppercase; letter-spacing: .09em; font-size: .75rem; color: var(--ink-2); font-weight: 600;
  padding-left: .75rem; border-left: var(--rule) solid var(--line); white-space: nowrap;
}
.top .sp { flex: 1 1 auto; }
.tbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: var(--tap); min-width: var(--tap);
  padding: 0 .625rem; border: var(--rule) solid var(--line); border-radius: var(--rad); background: var(--panel);
  color: var(--ink); font-weight: 600; font-size: .8125rem; white-space: nowrap;
}
.tbtn:hover, .pop[open] > .tbtn { border-color: var(--ink); }
.tbtn .ico { width: 1.25rem; height: 1.25rem; }
.who { padding: 0 .625rem 0 .3125rem; }
.av {
  width: 1.75rem; height: 1.75rem; border-radius: 50%; background: var(--ink); color: var(--paper);
  display: grid; place-items: center; font-size: .6875rem; font-weight: 700; font-stretch: 100%; flex: 0 0 auto;
}
.who .nm { overflow: hidden; text-overflow: ellipsis; max-width: 12rem; }
.who .role { font-stretch: 80%; text-transform: uppercase; letter-spacing: .06em; font-size: .6875rem; color: var(--ink-2); }

/* section navigation: tablet and desktop */
.sections {
  display: flex; gap: .125rem; padding: 0 .5rem; border-bottom: 1px solid var(--line); background: var(--paper);
  overflow-x: auto; scrollbar-width: none; position: relative;
}
.sections::-webkit-scrollbar { display: none; }
.sections a {
  position: relative; display: inline-flex; align-items: center; gap: .5rem; min-height: var(--tap); padding: 0 .75rem;
  color: var(--ink-2); font-weight: 600; font-size: .875rem; text-decoration: none; white-space: nowrap; flex: 0 0 auto;
}
.sections a:hover { color: var(--ink); }
.sections a:active { background: var(--paper-2); }
/* with shell.js the underline is one bar that slides to the current tab; without it, the tab draws its own */
.sections .bar { display: none; }
.sections.has-bar .bar { display: block; position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: var(--ink); pointer-events: none; }
.sections.has-bar a[aria-current="page"]::after { display: none; }
.sections a[aria-current="page"] { color: var(--ink); }
.sections a[aria-current="page"]::after {
  content: ""; position: absolute; left: .75rem; right: .75rem; bottom: -1px; height: 3px; background: var(--ink);
}

/* the admin area's own tab row, inside the page: wraps instead of scrolling so 320 px never scrolls sideways */
.sections.subtabs { flex-wrap: wrap; overflow-x: visible; padding: 0; margin: -.25rem 0 1rem; }
.sections.subtabs a { padding: 0 .625rem; }
.sections.subtabs a[aria-current="page"]::after { left: .625rem; right: .625rem; }
.sheet-panel .mi.sub { padding-left: 2.75rem; }

.main { flex: 1 0 auto; width: 100%; max-width: 80rem; margin: 0; padding: 1.25rem 1.25rem 2.5rem; }   /* left edge lines up with the lockup */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin: 0 0 1rem; }
.page-head small { display: block; margin-top: .1875rem; }

/* systems strip (home) */
.systems { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 12rem), 1fr)); gap: .5rem; }
.tile {
  display: flex; align-items: center; gap: .625rem; min-height: 3.5rem; padding: .5625rem .625rem;
  border: var(--rule) solid var(--line); border-radius: var(--rad); background: var(--panel); color: inherit; text-decoration: none;
  transition: transform .16s var(--ease), border-color .16s, box-shadow .16s;
}
a.tile:hover { transform: translateY(-2px); border-color: var(--ink); box-shadow: 0 2px 0 var(--ink); text-decoration: none; }
a.tile:active { transform: scale(.985); }
.tile .box { width: 1.875rem; height: 1.875rem; border: var(--rule) solid var(--ink); border-radius: var(--rad); display: grid; place-items: center; flex: 0 0 auto; background: var(--paper); }
.tile .box .ico { width: 1.125rem; height: 1.125rem; }
.tile .tname { font-weight: 680; font-stretch: 110%; font-size: .875rem; line-height: 1.2; }
.tile small { display: block; }
.tile > span:last-child { min-width: 0; }
.tile.soon { border-style: dashed; background: transparent; color: var(--ink-2); }
.tile.soon .box { border-style: dashed; border-color: var(--ink-2); background: transparent; }

/* bottom navigation and sheets: phones only */
.bnav { display: none; }

/* ------------------------------------------------------------------ list rows (compact rows with a Manage link) */
.rows { border-top: var(--rule) solid var(--line); }
.row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .25rem 1rem;
  min-height: 3.25rem; padding: .5rem .5rem; border-bottom: 1px solid var(--grid);
}
.row:hover { background: var(--panel); }
.row b { font-weight: 650; }
.row small { display: block; }

/* account page */
.acct { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: 1rem; align-items: start; }
.acct .panel + .panel { margin-top: 0; }
.acct-note { margin: .75rem 0 0; }
.acct-signout { margin: 1rem 0 0; padding-top: 1rem; border-top: 1px solid var(--grid); }

/* ------------------------------------------------------------------ bare layout: sign-in, codes, errors */
.auth { container: auth / inline-size; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.auth .top { position: static; }
.auth-main { flex: 1 0 auto; width: 100%; max-width: 30rem; margin: 0 auto; padding: 2.5rem 1.25rem 3rem; }
.auth-main.wide { max-width: 36rem; }
.auth-card { background: var(--panel); border: var(--rule) solid var(--ink); border-radius: var(--rad); padding: 1.5rem 1.5rem 1.625rem; }
.auth-card h1 { margin: 0 0 .5rem; }
.auth-card .lede { color: var(--ink-2); margin: 0 0 1.25rem; }
.auth-card form { margin: 0; }
.auth-after { margin: 1rem .25rem 0; color: var(--ink-2); font-size: .8125rem; }
.auth-after a { display: inline-flex; align-items: center; min-height: var(--tap); font-weight: 600; color: var(--ink); }

/* step line: the brand's measured line from a reference point (origin = ring with the amber dot) */
.steps {
  list-style: none; margin: 0 0 1.25rem; padding: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  position: relative; counter-reset: step;
}
.steps::before {
  content: ""; position: absolute; left: .5rem; right: 12%; top: .5rem; border-top: var(--rule) dashed var(--ink-2);
  transform-origin: left; animation: draw .55s var(--ease) both;
}
@keyframes draw { from { transform: scaleX(0); } to { transform: none; } }
.steps li {
  position: relative; padding: 1.625rem .5rem 0 0; font-size: .8125rem; color: var(--ink-2); font-weight: 600; line-height: 1.25;
}
.steps li::before {
  content: ""; position: absolute; left: .1875rem; top: .1875rem; width: .6875rem; height: .6875rem;
  background: var(--paper); border: var(--rule) solid var(--ink-2); border-radius: 1px;
}
.steps li.done::before { background: var(--ink-2); }
.steps li.now { color: var(--ink); }
.steps li.now::before { background: var(--ink); border-color: var(--ink); }
.steps li:first-child::before {
  left: -1px; top: -1px; width: 1.0625rem; height: 1.0625rem; border-radius: 50%; background: var(--panel); border-color: var(--ink);
}
.steps li:first-child::after {
  content: ""; position: absolute; left: .25rem; top: .25rem; width: .4375rem; height: .4375rem; border-radius: 50%; background: var(--amber);
}
.steps .n { display: block; font-stretch: 80%; text-transform: uppercase; letter-spacing: .08em; font-size: .6875rem; }

/* QR and setup key */
.qr { display: grid; place-items: center; margin: 0 0 1rem; }
.qr svg { width: 13.75rem; height: auto; aspect-ratio: 1 / 1; max-width: 100%; padding: .25rem; background: var(--qr-bg); border: var(--rule) solid var(--ink); border-radius: var(--rad); }
.key {
  display: flex; flex-wrap: wrap; gap: .25rem .625rem; padding: .625rem .75rem; margin: .375rem 0 1rem;
  background: var(--paper); border: 1px dashed var(--ink-2); border-radius: var(--rad);
  font-weight: 650; letter-spacing: .06em; font-size: 1rem; word-break: break-all;
}
/* recovery codes */
.codes { list-style: none; margin: 0 0 1.25rem; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .375rem; }
.codes li {
  padding: .5rem .625rem; background: var(--paper); border: 1px solid var(--line); border-radius: var(--rad);
  text-align: center; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: .04em; white-space: nowrap;
}
/* error and refusal pages */
.ref { display: inline-flex; align-items: center; gap: .5rem; padding: .25rem .5rem; border: 1px solid var(--line); border-radius: var(--rad); background: var(--paper); font-size: .8125rem; color: var(--ink-2); }
.ref code { color: var(--ink); font-weight: 650; letter-spacing: .04em; }

/* ------------------------------------------------------------------ users and settings (task 1.11) */
.searchbar { display: flex; gap: .625rem; align-items: flex-end; margin: 0 0 1rem; }
.searchbar .field { flex: 1 1 auto; margin: 0; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: .375rem; margin-top: .375rem; }
.chip.wait { color: var(--ink-2); border-style: dashed; }
.row .btn { justify-self: end; }
.actions { display: grid; gap: .625rem; }
.code-show {
  display: block; padding: 1rem; border: var(--rule) solid var(--ink); border-radius: var(--rad); background: var(--paper-2);
  font-size: 1.5rem; font-weight: 650; letter-spacing: .12em; text-align: center; overflow-wrap: anywhere; user-select: all;
}
.field .choice { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.field .choice label { display: inline-flex; align-items: center; gap: .5rem; min-height: var(--tap); font-weight: 500; }
.field .choice input { width: 1.25rem; height: 1.25rem; }
.catrow { grid-template-columns: minmax(0, 1fr); padding: .75rem .5rem; gap: .5rem; }
.catform { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; }
.catform .error { flex: 0 0 100%; margin: 0; }
.catform input[type="text"] { flex: 1 1 auto; min-width: 0; min-height: var(--tap); padding: .5rem .75rem; font-size: 1rem; background: var(--panel); color: var(--ink); border: var(--rule) solid var(--ink-2); border-radius: var(--rad); }
.catform .field { flex: 1 1 auto; margin: 0; min-width: 0; }
.catactions { gap: .5rem; }
.catactions form { margin: 0; }
.addcat { margin-top: 1rem; }
.stepup { padding: .875rem; border: var(--rule) dashed var(--ink-2); border-radius: var(--rad); }

/* ------------------------------------------------------------------ tablet */
@container app (max-width: 64em) {
  .plabel { display: none; }
  .main { padding: 1.125rem 1.25rem 2.25rem; }
}

/* ------------------------------------------------------------------ phone */
@container app (max-width: 40em) {
  .top { min-height: 3.375rem; padding: 0 .875rem; gap: .5rem; }
  .tbtn .tx, .who .nm, .top .newpop { display: none; }
  .top .tbtn { border-color: transparent; background: none; }
  .top .pop[open] > .tbtn { border-color: var(--ink); }
  .who { padding: 0; }
  .who .av { width: 2rem; height: 2rem; }
  .sections:not(.subtabs) { display: none; }
  .main { padding: 1rem .875rem calc(var(--nav-h) + 1.5rem + env(safe-area-inset-bottom)); }
  h1 { font-size: 1.3125rem; }
  .panel { padding: .875rem .875rem 1rem; }
  .kv { grid-template-columns: minmax(0, 1fr); }
  .kv dt { padding-bottom: .125rem; }
  .kv dd { padding-top: 0; border-top: 0; }
  .systems { grid-template-columns: minmax(0, 1fr); }
  .row { grid-template-columns: minmax(0, 1fr); }

  .bnav {
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 7;
    min-height: var(--nav-h); padding: 0 .25rem env(safe-area-inset-bottom); background: var(--paper); border-top: var(--rule) solid var(--ink);
  }
  .bnav > a, .bnav > details > summary {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1875rem;
    min-height: 3.75rem; height: 100%; padding: .375rem 0; color: var(--ink-2); font-size: .75rem; font-weight: 600; font-stretch: 92%;
    text-decoration: none; white-space: nowrap; cursor: pointer; list-style: none;
    transition: transform .12s var(--ease);
  }
  .bnav > details > summary::-webkit-details-marker { display: none; }
  .bnav > a:active, .bnav > details > summary:active { transform: scale(.94); }
  .bnav .ico { width: 1.5rem; height: 1.5rem; }
  .bnav > a[aria-current="page"], .bnav > details[open] > summary { color: var(--ink); }
  .bnav > a[aria-current="page"]::before {
    content: ""; position: absolute; top: -1.5px; left: 22%; right: 22%; height: 3px; background: var(--ink);
  }
  .bnav .fab-box {
    width: 3.375rem; height: 3.375rem; margin-top: -1.5rem; border-radius: var(--rad); background: var(--ink); color: var(--paper);
    display: grid; place-items: center; border: 3px solid var(--paper); box-shadow: 0 0 0 1.5px var(--ink);
  }
  .bnav .fab { color: var(--ink); }
  .sheet-panel {
    position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 8;
    max-height: calc(100dvh - var(--nav-h) - 4rem); overflow-y: auto;
    background: var(--paper); border-top: var(--rule) solid var(--ink); border-radius: 10px 10px 0 0;
    padding: .625rem .875rem 1rem; box-shadow: 0 -1px 0 var(--ink), 0 -40vh 0 40vh var(--scrim);
  }
  .bnav details[open] .sheet-panel { animation: sheet .24s var(--ease); }
  .bnav details.closing .sheet-panel { animation: sheet-out .2s var(--ease) forwards; }     /* shell.js removes [open] when it ends */
  @keyframes sheet { from { transform: translateY(30%); opacity: 0; } to { transform: none; opacity: 1; } }
  @keyframes sheet-out { from { transform: none; opacity: 1; } to { transform: translateY(30%); opacity: 0; } }
  .sheet-panel .grab { width: 2.5rem; height: .25rem; border-radius: 2px; background: var(--line); margin: 0 auto .625rem; }
  .sheet-panel .mi { min-height: 3.5rem; font-size: 1rem; border-bottom: 1px solid var(--grid); border-radius: 0; padding: 0 .25rem; }
  .sheet-panel .mi .ico { width: 1.5rem; height: 1.5rem; }
  .pop-panel { position: fixed; left: .875rem; right: .875rem; top: calc(3.375rem + .5rem); width: auto; max-width: none; }
}
/* the shield alone, never a wrapped or shrunken wordmark: on 320 px phones, and at A+ / A++ on phones */
@container app (max-width: 340px) { .lockup .wm { display: none; } }
@container app (max-width: 40em) {
  :root.text-a1 .lockup .wm, :root.text-a2 .lockup .wm { display: none; }
}

/* bare layout on phones */
@container auth (max-width: 40em) {
  .auth .top { min-height: 3.375rem; padding: 0 .875rem; }
  .auth-main { padding: 1.25rem .875rem 2rem; }
  .auth-card { padding: 1.125rem 1rem 1.25rem; }
  .auth-card h1 { font-size: 1.3125rem; }
}
@container auth (max-width: 340px) { .lockup .wm { display: none; } }
@container auth (max-width: 40em) {
  :root.text-a1 .lockup .wm, :root.text-a2 .lockup .wm { display: none; }
}
@container auth (max-width: 22em) {
  .codes { grid-template-columns: minmax(0, 1fr); }
  .plabel { display: none; }
}

/* ------------------------------------------------------------------ reduced motion: device setting unless overridden, or the saved "reduce" */
@media (prefers-reduced-motion: reduce) {
  :root:not(.motion-full) *, :root:not(.motion-full) *::before, :root:not(.motion-full) *::after {
    animation: none !important; transition: none !important; scroll-behavior: auto !important;
  }
}
:root.motion-reduce *, :root.motion-reduce *::before, :root.motion-reduce *::after {
  animation: none !important; transition: none !important; scroll-behavior: auto !important;
}

/* ------------------------------------------------------------------ print */
@media print {
  .top, .sections, .bnav, .skip-link { display: none !important; }
  body { background: #FFFFFF; color: #000000; }
  .panel, .auth-card { border-color: #000000; }
}

/* ------------------------------------------------------------------ audit log page (/admin/audit) */
.auditfilter { display: grid; grid-template-columns: minmax(0, 1fr); gap: .5rem 1rem; margin: 0 0 1rem; }
.auditfilter .field { margin: 0; min-width: 0; }
.auditfilter .btn-row { margin-top: .25rem; }
.auditdates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.auditdates .field { margin: 0; min-width: 0; }
.auditdates input[type="date"] { min-width: 0; padding: .5rem .375rem; font-size: .9375rem; }
.auditrow { grid-template-columns: minmax(0, 1fr); padding: .625rem .5rem; }
.auditmain { min-width: 0; overflow-wrap: anywhere; }
.auditwho { margin-left: .25rem; }
.auditpart { margin-top: .125rem; }
.auditpager { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin: 1rem 0; }
@media (min-width: 48rem) {
  .auditfilter { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; }
  .auditdates { grid-column: span 2; }
}
.page-head small a { display: inline-flex; align-items: center; min-height: var(--tap); }

/* ================================================================== quotes, price list, customers (tasks 2.3, 2.4, 2.10)
   Internal-tool register: dense rows, one icon per item, status by colour + word, nothing decorative.
   The quote editor is one grid of lines per block (in every option / Option N); each block has ONE Save.
   Layout switches are container queries (em), so A+ / A++ fall back to the card layout sooner.            */

/* status filter tabs with counts (quote list, price list, customers) */
.filters { display: flex; flex-wrap: wrap; gap: .375rem; margin: -.25rem 0 1rem; }
.filter {
  display: inline-flex; align-items: center; gap: .375rem; min-height: var(--tap); padding: 0 .75rem;
  border: var(--rule) solid var(--line); border-radius: var(--rad); background: var(--panel);
  font-weight: 600; font-size: .8125rem; color: var(--ink-2); text-decoration: none; white-space: nowrap;
}
.filter:hover { border-color: var(--ink); color: var(--ink); text-decoration: none; }
.filter[aria-current="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.count { font-variant-numeric: tabular-nums; font-weight: 700; font-size: .75rem; opacity: .75; }
h2 .count { margin-left: .25rem; color: var(--ink-2); }

/* status chips used here (chip.ok / chip.risk / chip.wait come from the shell) */
.chip.sent::before { content: ""; width: .4375rem; height: .4375rem; border-radius: 50%; border: 1.5px solid currentColor; }
.chip.off { background: var(--paper-2); border-color: transparent; }
.chip .ico { width: .875rem; height: .875rem; }
.warn-t { color: var(--risk); }
.btn.ghost.warn-t { color: var(--risk); }
.btn.ghost.warn-t:hover { background: var(--risk-bg); }

/* one icon per row: a small square in ink, tinted by status */
.rbox {
  width: 2rem; height: 2rem; flex: 0 0 auto; display: grid; place-items: center;
  border: var(--rule) solid var(--ink); border-radius: var(--rad); background: var(--paper);
}
.rbox .ico { width: 1.125rem; height: 1.125rem; }
.rbox.st-ok { border-color: var(--ok); color: var(--ok); background: var(--ok-bg); }
.rbox.st-risk { border-color: var(--risk); color: var(--risk); background: var(--risk-bg); }
.rbox.st-wait { border-style: dashed; border-color: var(--ink-2); }
.rbox.st-off { border-color: var(--line); color: var(--ink-2); background: transparent; }

/* quote list rows */
.qrow { grid-template-columns: auto minmax(0, 1fr) auto auto; gap: .25rem .875rem; }
.qmain { min-width: 0; }
.qref { display: block; font-size: .8125rem; color: var(--ink-2); }
.qref .mono { color: var(--ink); font-weight: 650; }
.qtitle { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qrow .qside { display: grid; justify-items: end; gap: .25rem; }
.qrow .qside .num { font-size: 1rem; }
.from { font-weight: 500; font-size: .75rem; color: var(--ink-2); font-stretch: 100%; }
.crow, .xrow { grid-template-columns: auto minmax(0, 1fr) auto; gap: .25rem .875rem; }
.cmain, .xmain { min-width: 0; }
.cmain small, .xmain small { display: block; }
.row.off b { color: var(--ink-2); }
.row.off .rbox { border-color: var(--line); color: var(--ink-2); }

/* quote page head */
.qhead-main { min-width: 0; }
.page-head > div > small > a { display: inline-flex; align-items: center; gap: .375rem; min-height: var(--tap); font-weight: 600; }
.page-head > div > small > a .ico { width: 1rem; height: 1rem; }
.qhead-ref { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 0 0 .25rem; }
.qhead-ref .mono { font-weight: 650; font-size: 1rem; letter-spacing: .02em; }
.qhead h1 { margin-bottom: .375rem; }
.page-head .qwho { display: flex; flex-wrap: wrap; align-items: center; gap: .375rem; }
.qwho .ico { width: 1rem; height: 1rem; color: var(--ink-2); }
.qwho .sep { margin: 0 .25rem; }
.revtabs a { gap: .5rem; }
.revtabs b { font-weight: 700; }
.revst { font-weight: 500; font-size: .8125rem; color: var(--ink-2); }

/* quote page layout: lines left, status + totals right; one column on narrow screens (status first) */
.qlayout { display: grid; grid-template-columns: minmax(0, 1fr) 19.5rem; grid-template-rows: auto 1fr; grid-template-areas: "lines status" "lines side"; gap: 1rem 1.25rem; align-items: start; }
.qstatus { grid-area: status; }
.qlines { grid-area: lines; min-width: 0; container: qlines / inline-size; display: grid; gap: 1rem; }
.qlayout > .qside { grid-area: side; display: grid; gap: 1rem; min-width: 0; }
.qlayout > .qside .panel + .panel { margin-top: 0; }
.qstatus .lbl, .qlayout > .qside .lbl { margin: 0 0 .5rem; }
.kv.tight dt, .kv.tight dd { padding: .4375rem 0; }
.kv.tight dd small { display: block; }
.qactions { margin-top: .875rem; gap: .5rem; }
.qstatus .notice { margin: .75rem 0 0; }
.pre { white-space: pre-line; }
.small-note { margin: .625rem 0 0; font-size: .8125rem; }

/* confirm panels: a details.pop[data-menu] holding one form; a bottom sheet on phones */
.pop.act > summary { list-style: none; }
.pop.act > summary::-webkit-details-marker { display: none; }
.act-panel { width: 24rem; padding: 1rem 1rem 1.125rem; }
.act-panel h3 { margin: 0 0 .5rem; font-size: 1rem; }
.act-panel form > .muted { margin: 0 0 .875rem; font-size: .875rem; }
.act-panel .field:last-of-type { margin-bottom: 1rem; }
.addbar .pop:first-child .act-panel, .addbar .pop:nth-child(2) .act-panel { left: 0; right: auto; }
.picker .act-panel { width: 28rem; }
.trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 .625rem; }
.duo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 .625rem; }
.duo > .field, .trio > .field { min-width: 0; }

/* radio choices: option cards and a segmented "how" picker */
fieldset.field { border: 0; padding: 0; margin: 0 0 1rem; min-width: 0; }
fieldset.field legend { padding: 0; margin: 0 0 .375rem; }
.choice-cards { display: grid; gap: .375rem; }
.ccard {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .625rem;
  min-height: var(--tap); padding: .5rem .75rem; border: var(--rule) solid var(--line); border-radius: var(--rad);
  background: var(--panel); cursor: pointer; font-weight: 500;
}
.ccard:hover { border-color: var(--ink); }
.ccard:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.ccard input { width: 1.125rem; height: 1.125rem; margin: 0; accent-color: var(--ink); }
.ccard .muted { display: block; font-size: .8125rem; }
.seg.pick { flex-wrap: wrap; }
.seg.pick label { flex: 1 1 auto; position: relative; display: flex; }
.seg.pick label + label { border-left: var(--rule) solid var(--ink); }
.seg.pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg.pick span {
  flex: 1; display: grid; place-items: center; min-height: var(--tap); padding: 0 .625rem; background: var(--panel);
  font-weight: 600; font-size: .8125rem; white-space: nowrap; cursor: pointer;
}
.seg.pick input:checked + span { background: var(--ink); color: var(--paper); }
.seg.pick input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -4px; }

/* a block of lines: "Lines", "In every option", or one option */
.lgroup { background: var(--panel); border: var(--rule) solid var(--ink); border-radius: var(--rad); min-width: 0; }
.lgroup.common { border-style: dashed; border-color: var(--ink-2); }
.lgroup.chosen { border-color: var(--ok); box-shadow: inset 4px 0 0 var(--ok); }
.lgroup.unchosen { border-color: var(--line); }
.lgroup.unchosen .lg-body { opacity: .78; }
.lg-head { display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem; border-bottom: 1px solid var(--grid); flex-wrap: wrap; }
.lg-name { flex: 1 1 14rem; min-width: 0; display: grid; gap: .375rem; }
.lg-name small { display: block; }
.lg-sub { font-weight: 500; font-stretch: 100%; color: var(--ink-2); }
.lg-title { min-height: 2.5rem; font-size: .9375rem; }
.optbadge {
  width: 2rem; height: 2rem; flex: 0 0 auto; display: grid; place-items: center; border-radius: var(--rad);
  background: var(--ink); color: var(--paper); font-weight: 750; font-stretch: 110%; font-variant-numeric: tabular-nums;
}
.lgroup.chosen .optbadge { background: var(--ok); color: var(--panel); }
.lgroup.unchosen .optbadge { background: var(--paper-2); color: var(--ink-2); }
.lg-ctl { display: flex; gap: .375rem; align-items: center; }
.lg-body { margin: 0; padding: 0 1rem .875rem; }
.lg-empty { margin: 0; padding: .875rem 0 .25rem; font-size: .875rem; }
.lg-foot { display: grid; gap: .125rem; padding-top: .625rem; border-top: var(--rule) solid var(--ink); margin-top: .25rem; }
.lg-body > .lg-empty + .lg-foot { border-top-color: var(--grid); }
.sum { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; font-size: .875rem; color: var(--ink-2); }
.sum[hidden] { display: none; }                                       /* luke: the margin row hides when a line has no cost */
.sum .num { color: var(--ink); }
.sum.big { font-size: 1rem; color: var(--ink); font-weight: 650; padding-top: .125rem; }
.sum.big .num { font-size: 1.1875rem; }
.sum.margin { font-size: .8125rem; padding-top: .25rem; }
.sum.margin .num { color: var(--ink-2); font-weight: 600; }
.sum .tag { margin-left: .375rem; }
.savebar { display: flex; justify-content: flex-end; align-items: center; gap: .75rem; padding-top: .75rem; flex-wrap: wrap; }
.savestate { font-size: .8125rem; font-weight: 600; }
.savestate.ok { color: var(--ok); }
.savestate.risk { color: var(--risk); }

/* the lines grid (wide): # | description | qty | unit | price | [cost] | total | [actions] */
.lines { --cols: 1.5rem minmax(0, 1fr) 4.25rem 4.25rem 6.25rem 6.5rem; }
.lines.with-cost { --cols: 1.5rem minmax(0, 1fr) 4.25rem 4.25rem 6.25rem 5.75rem 6.5rem; }
.lines.editing { --cols: 1.5rem minmax(0, 1fr) 4.5rem 4.25rem 6.25rem 6.5rem 7.75rem; }
.lines.editing.with-cost { --cols: 1.5rem minmax(0, 1fr) 4.5rem 4.25rem 6.25rem 5.75rem 6.5rem 7.75rem; }
.ln {
  display: grid; grid-template-columns: var(--cols); gap: .375rem .5rem; align-items: start;
  padding: .5rem 0; border-bottom: 1px solid var(--grid);
}
.ln:last-child { border-bottom: 0; }
.ln.ro { align-items: baseline; padding: .625rem 0; }
.ln-head { padding: .625rem 0 .375rem; border-bottom: 1px solid var(--line); }
.ln-head > span { font-stretch: 80%; text-transform: uppercase; letter-spacing: .08em; font-size: .6875rem; color: var(--ink-2); font-weight: 600; }
.ln-head .ln-qty, .ln-head .ln-price, .ln-head .ln-cost, .ln-head .ln-total { text-align: right; }
.ln-n { padding-top: .625rem; font-size: .75rem; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ln.ro .ln-n, .ln-head .ln-n { padding-top: 0; }
.ln-desc { min-width: 0; white-space: pre-line; }
.ln-desc textarea { resize: vertical; min-height: var(--tap); line-height: 1.35; }
.ln-qty, .ln-price, .ln-cost { text-align: right; min-width: 0; }
.ln-unit { min-width: 0; overflow-wrap: anywhere; }
.ln-total { text-align: right; padding-top: .625rem; display: block; }
.ln.ro .ln-total { padding-top: 0; }
.ln-lbl { display: none; }
.ln .input { min-height: var(--tap); padding: .375rem .5rem; font-size: .9375rem; }
.num-in { text-align: right; font-variant-numeric: tabular-nums; }
.ln-act { display: flex; gap: .25rem; justify-content: flex-end; grid-column: -2; grid-row: 1; }
.ln-head .ln-total { padding-top: 0; }
.ln-opt { grid-column: 2 / -1; grid-row: 2; display: flex; align-items: center; gap: .5rem; }
.ln-opt::before { content: "Belongs to"; font-size: .75rem; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.ln-opt select.input { width: auto; min-width: 11rem; min-height: 2.25rem; padding: .25rem .5rem; font-size: .875rem; }
.ln-error { grid-column: 2 / -1; margin: 0; }
.ibtn {
  display: inline-grid; place-items: center; width: 2.375rem; height: var(--tap); padding: 0; flex: 0 0 auto;
  border: var(--rule) solid var(--line); border-radius: var(--rad); background: var(--panel); color: var(--ink); cursor: pointer;
  list-style: none; transition: border-color .15s, background-color .15s, transform .12s var(--ease);
}
.ibtn::-webkit-details-marker { display: none; }
.ibtn:hover { border-color: var(--ink); }
.ibtn:active { transform: scale(.94); }
.ibtn .ico { width: 1.125rem; height: 1.125rem; }
.ibtn.warn { color: var(--risk); }
.ibtn.warn:hover { border-color: var(--risk); background: var(--risk-bg); }
.ln.dirty { box-shadow: inset 3px 0 0 var(--amber); }                       /* luke: a changed, unsaved line */
.ln.dirty .ln-n { color: var(--amber-ink); }

/* add line / add from price list / add option */
.addbar { display: flex; flex-wrap: wrap; gap: .5rem; }
.picklist { max-height: 16rem; overflow-y: auto; border: var(--rule) solid var(--line); border-radius: var(--rad); margin: 0 0 1rem; }
.pickrow {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .625rem;
  min-height: var(--tap); padding: .375rem .625rem; border-bottom: 1px solid var(--grid); cursor: pointer; font-size: .875rem;
}
.pickrow:last-child { border-bottom: 0; }
.pickrow:hover { background: var(--paper-2); }
.pickrow:has(input:checked) { background: var(--paper-2); box-shadow: inset 3px 0 0 var(--ink); }
.pickrow input { margin: 0; width: 1.125rem; height: 1.125rem; accent-color: var(--ink); }
.pickrow[hidden] { display: none; }

/* "price if the customer chooses" */
.pricelist { list-style: none; margin: 0; padding: 0; }
.pricelist li { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; padding: .5rem 0; border-top: 1px solid var(--grid); }
.pricelist li:first-child { border-top: 0; }
.pricelist small { display: block; }
.pricelist .num { font-size: 1.0625rem; }
.pricelist li.chosen b, .pricelist li.chosen .num { color: var(--ok); }
.pricelist li.chosen b::after { content: " · chosen"; font-weight: 600; font-size: .8125rem; }

/* forms on their own page, and the shared two-column field grid */
.panel.narrow { max-width: 44rem; }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; align-items: start; }
.fgrid .field.wide { grid-column: 1 / -1; }
.fgrid .field { min-width: 0; }
.check { display: flex; align-items: center; gap: .625rem; min-height: var(--tap); margin: -.25rem 0 1rem; font-weight: 500; font-size: .9375rem; cursor: pointer; }
.check input { width: 1.25rem; height: 1.25rem; margin: 0; accent-color: var(--ink); flex: 0 0 auto; }

/* price list: one editable row per item, one Save */
.pl { --plcols: 2rem minmax(0, 1fr) 5rem 7rem auto; border-top: var(--rule) solid var(--line); container: pl / inline-size; margin: 0; }
.pl.with-cost { --plcols: 2rem minmax(0, 1fr) 5rem 7rem 7rem 4.5rem auto; }
.pl-row { display: grid; grid-template-columns: var(--plcols); gap: .375rem .625rem; align-items: center; padding: .5rem .25rem; border-bottom: 1px solid var(--grid); }
.pl-head { padding: .5rem .25rem .375rem; }
.pl-head > span { font-stretch: 80%; text-transform: uppercase; letter-spacing: .08em; font-size: .6875rem; color: var(--ink-2); font-weight: 600; }
.pl-p, .pl-c, .pl-m { text-align: right; }
.pl-head .pl-ico { width: 2rem; }
.pl-d, .pl-u { min-width: 0; }
.pl-row .input { min-height: var(--tap); padding: .375rem .5rem; font-size: .9375rem; }
.pl-a { display: flex; justify-content: flex-end; min-width: 6.5rem; }
.pl-row.off { color: var(--ink-2); }
.pl-row .ln-error { grid-column: 2 / -1; }
.pl-row.dirty { box-shadow: inset 3px 0 0 var(--amber); }
.pl .savebar { position: sticky; bottom: 0; background: var(--paper); padding: .75rem .25rem; border-top: 1px solid var(--line); }

/* customer page */
.cgrid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.cgrid .panel + .panel { margin-top: 0; }
.ccol { display: grid; gap: 1rem; min-width: 0; }
.cdetails .savebar { padding-top: .25rem; }
.xrow { align-items: start; }
.xrow > .rbox { margin-top: .125rem; }
.access { display: block; margin-top: .125rem; font-size: .8125rem; }
.rowedit { display: contents; }
.rowedit > summary { list-style: none; grid-column: 3; grid-row: 1; justify-self: end; }
.rowedit > summary::-webkit-details-marker { display: none; }
.rowedit[open] > summary { background: var(--paper-2); }
.rowform { grid-column: 1 / -1; padding: .75rem 0 .25rem; margin: 0; }
.rowform .notice { margin-bottom: .875rem; }
.addfold { margin-top: .75rem; }
.addfold > summary { list-style: none; }
.addfold > summary::-webkit-details-marker { display: none; }
.addfold[open] > summary { display: none; }
.addfold .rowform { padding-top: .75rem; border-top: 1px dashed var(--line); }
.old { margin-top: .625rem; font-size: .875rem; }
.old > summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; color: var(--ink-2); font-weight: 600; }

/* ---- narrower: one column (iPad portrait, or A+/A++ on a laptop) */
@container app (max-width: 60em) {
  .qlayout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; grid-template-areas: "status" "lines" "side"; }
  .qactions { grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); }
  .qactions > .pop:first-child { grid-column: 1 / -1; }
  .cgrid { grid-template-columns: minmax(0, 1fr); }
}

/* ---- lines as cards when the lines column is narrow (phone, iPad portrait at A++) */
@container qlines (max-width: 46em) {
  .ln-head { display: none; }
  .ln, .ln.ro {
    grid-template-columns: 1.25rem repeat(3, minmax(0, 1fr));
    grid-template-areas: "n desc desc desc" "n qty unit price" "n cost total total" "n opt opt opt" "n err err err" "n act act act";
    gap: .375rem .5rem; padding: .75rem 0; align-items: end;
  }
  .ln-n { grid-area: n; align-self: start; padding-top: .25rem; }
  .ln-desc { grid-area: desc; }
  .ln-qty { grid-area: qty; text-align: left; }
  .ln-unit { grid-area: unit; }
  .ln-price { grid-area: price; text-align: left; }
  .ln-cost { grid-area: cost; text-align: left; }
  .ln-total { grid-area: total; padding-top: 0; font-size: 1rem; align-self: center; }
  .ln-opt { grid-area: opt; }
  .ln-error { grid-area: err; }
  .ln-act { grid-area: act; }
  .ln-lbl { display: block; font-stretch: 80%; text-transform: uppercase; letter-spacing: .08em; font-size: .6875rem; color: var(--ink-2); font-weight: 600; margin-bottom: .1875rem; }
  .ln.ro .ln-desc { font-weight: 600; }
  .ln.ro { row-gap: .25rem; }
  .num-in { text-align: left; }
  .ln-opt select.input { flex: 1 1 auto; min-width: 0; }
  .lg-head { padding: .625rem .75rem; }
  .lg-body { padding: 0 .75rem .75rem; }
}
@container pl (max-width: 46em) {
  .pl-head { display: none; }
  .pl-row, .pl.with-cost .pl-row {
    grid-template-columns: 2rem repeat(3, minmax(0, 1fr));
    grid-template-areas: "ico d d d" ". u p c" ". m a a" ". err err err"; align-items: end; padding: .75rem .25rem;
  }
  .pl-ico { grid-area: ico; align-self: start; }
  .pl-d { grid-area: d; font-weight: 600; }
  .pl-u { grid-area: u; }
  .pl-p { grid-area: p; text-align: left; }
  .pl-c { grid-area: c; text-align: left; }
  .pl-m { grid-area: m; text-align: left; }
  .pl-a { grid-area: a; min-width: 0; }
  .pl-row .ln-error { grid-area: err; }
  .pl-row .ln-lbl { display: block; font-stretch: 80%; text-transform: uppercase; letter-spacing: .08em; font-size: .6875rem; color: var(--ink-2); font-weight: 600; margin-bottom: .1875rem; }
  .pl-row .num-in { text-align: left; }
}

/* ---- phone */
@container app (max-width: 40em) {
  .qrow { grid-template-columns: auto minmax(0, 1fr) auto; }
  .qrow { align-items: start; }
  .qrow > .rbox { grid-column: 1; grid-row: 1 / span 2; }
  .qmain { grid-column: 2; grid-row: 1 / span 2; }
  .qrow .qside { grid-column: 3; grid-row: 1; }
  .qrow > .btn { grid-column: 3; grid-row: 2; justify-self: end; align-self: end; }
  .pl .savebar { bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
  .qtitle { white-space: normal; }
  .fgrid, .duo { grid-template-columns: minmax(0, 1fr); }
  .qactions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .qactions > .btn, .qactions > .pop > summary { white-space: normal; text-align: center; line-height: 1.2; padding: .375rem .5rem; }
  .page-head > .pop.act, .page-head > .btn-row { width: 100%; }
  .page-head > .pop.act > summary, .page-head > .btn-row > .btn { flex: 1 1 auto; width: 100%; }
  .page-head > .btn-row > form { flex: 1 1 auto; }
  .page-head > .btn-row > form .btn { width: 100%; }
  .filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-right: -.875rem; padding-right: .875rem; }
  .filters::-webkit-scrollbar { display: none; }
  .addbar { display: grid; grid-template-columns: minmax(0, 1fr); }
  .addbar > .pop > summary { width: 100%; }
  /* confirm panels become bottom sheets above the bottom navigation, at thumb height */
  .act-panel, .picker .act-panel {
    position: fixed; left: 0; right: 0; top: auto; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); width: auto; max-width: none;
    max-height: calc(100dvh - var(--nav-h) - 4.5rem); overflow-y: auto; z-index: 8;
    border-width: var(--rule) 0 0; border-radius: 10px 10px 0 0; padding: 1rem .875rem 1.25rem;
    box-shadow: 0 -40vh 0 40vh var(--scrim);
  }
  .pop.act[open] > .act-panel { animation: sheet .24s var(--ease); }
  .picklist { max-height: 40dvh; }
}

.qr-preview { image-rendering: pixelated; background: #fff; border: 1px solid var(--line, #bdb6ab); padding: 4px; }

/* phones: nothing may be wider than the screen (a long word or a file input must not push the page sideways) */
.panel, .rows, .row, .field, .cgrid > *, .ccol > * { min-width: 0; }
.field input[type="file"] { max-width: 100%; min-width: 0; }
details.act > summary.btn { white-space: normal; max-width: 100%; overflow-wrap: anywhere; text-align: center; padding-top: .5rem; padding-bottom: .5rem; }
.legacy-text { white-space: pre-wrap; overflow-wrap: anywhere; }
