/*
 * app.css - the whole design system. One file, no build step.
 *
 * Palette and status colours from KoopApp (themselves from the co-op's public
 * site), so this reads as the same organisation; ratios in comments were
 * measured there. System fonts: a staff tool on office laptops does not need a
 * webfont download.
 *
 *   1. Tokens   2. Base   3. Shells   4. Navigation   5. Cards, lists, tables
 *   6. Forms, buttons, alerts   7. Motion
 */

/* ── 1. Tokens ──────────────────────────────────────────────────────────── */

:root {
  color-scheme: light;

  --navy:        #0F4C75;
  --navy-deep:   #052E47;
  --gold:        #FBBF24;   /* on navy only */

  --ground:      #F8F6F3;
  --surface:     #ffffff;
  --border:      rgba(15, 76, 117, 0.12);
  --border-mid:  rgba(15, 76, 117, 0.24);

  --fg:          #1a1a1a;
  --fg-mid:      #3d3d3d;
  --fg-muted:    #595959;   /* 7.0:1 on the ground */
  --fg-subtle:   #6E6E6E;   /* 4.5:1+ on every surface here */

  /* Status: fixed meanings, never brand, never alone (always icon + word). */
  --good:  #1A6B39;  --good-bg: #ECF5EF;
  --bad:   #8B1A0F;  --bad-bg:  #FBEEEC;
  --warn:  #8A4B06;  --warn-bg: #FDF4E8;   /* darker than KoopApp's for 4.5:1 on its own bg */
  --info:  #0F4C75;  --info-bg: #EAF2F8;

  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  --t-xs: 0.8125rem; --t-sm: 0.9375rem; --t-md: 1rem; --t-lg: 1.125rem; --t-xl: 1.375rem; --t-2xl: 1.75rem;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;

  --r: 12px;  --r-sm: 8px;   /* two radii: inner = outer - gap */
  --lift: 0 10px 30px rgba(5, 46, 71, 0.16);
  --tap: 48px;
  --rail-w: 15rem;
}

/* ── 2. Base ────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--ground); color: var(--fg); font-family: var(--font);
  font-size: var(--t-md); line-height: 1.55; min-height: 100dvh;
}
h1, h2, h3, h4 { line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; color: var(--navy-deep); }
.h1 { font-size: var(--t-2xl); }
.h2 { font-size: var(--t-xl); }
.h3 { font-size: var(--t-lg); }
.h4 { font-size: var(--t-md); margin-top: var(--s4); }
p { max-width: 70ch; }
.muted { color: var(--fg-muted); font-size: var(--t-sm); }
.empty { color: var(--fg-subtle); font-size: var(--t-sm); }
.num { font-variant-numeric: tabular-nums; }
a { color: var(--navy); text-underline-offset: 2px; }
a:hover { color: var(--navy-deep); }
:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; border-radius: 4px; }
.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skiplink { position: absolute; left: var(--s2); top: -100px; z-index: 50; background: var(--surface);
  padding: var(--s2) var(--s4); border-radius: var(--r-sm); box-shadow: var(--lift); }
.skiplink:focus { top: var(--s2); }
.ic { flex: none; vertical-align: middle; }
.bullets { padding-left: 1.2em; display: grid; gap: var(--s2); margin: var(--s4) 0; }

/* ── 3. Shells ──────────────────────────────────────────────────────────── */

/* Signed in. Phone: top bar, content, bottom tab bar. */
.frame { min-height: 100dvh; }
.col { display: flex; flex-direction: column; min-height: 100dvh; }
.main { flex: 1; width: 100%; max-width: 72rem; margin: 0 auto; padding: var(--s4) var(--s4) calc(var(--s7) + 64px);
  display: flex; flex-direction: column; gap: var(--s4); }
.main:focus { outline: none; }

.narrow { max-width: 36rem; }

.grid { display: grid; gap: var(--s4); align-items: start; }
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.row { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.head-row { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; justify-content: space-between; }

@media (min-width: 60rem) {
  /* The rail column is navy all the way down, however long the page. */
  .frame { display: grid; grid-template-columns: var(--rail-w) 1fr;
    background: linear-gradient(to right, var(--navy-deep) var(--rail-w), var(--ground) var(--rail-w)); }
  .main { padding: var(--s6) var(--s6) var(--s7); gap: var(--s5); }
  .grid--2 { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
}

/* Sign in and the other one-decision pages: KoopApp's layout. Phone: the navy
   band, the white sheet rising over its foot. Laptop: all navy, one card. */
.page-auth { background: var(--navy-deep); }
.auth { min-height: 100dvh; display: flex; flex-direction: column;
  background:
    repeating-linear-gradient(45deg,  rgba(251, 191, 36, 0.045) 0 1px, transparent 1px 16px),
    repeating-linear-gradient(-45deg, rgba(251, 191, 36, 0.045) 0 1px, transparent 1px 16px),
    var(--navy-deep); }
.auth__top { color: #fff; display: flex; flex-direction: column; align-items: center; gap: var(--s2); text-align: center;
  padding: calc(var(--s6) + env(safe-area-inset-top)) var(--s4) calc(var(--s7) + var(--s3)); }
.auth__brand { display: flex; flex-direction: column; align-items: center; gap: var(--s3); color: #fff; text-decoration: none; }
.auth__brand .brand__mark { width: 72px; height: 72px; border-radius: 18px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); }
.auth__name { font-size: var(--t-2xl); font-weight: 750; letter-spacing: -0.01em; }
.auth__org { font-size: var(--t-sm); color: rgba(255, 255, 255, 0.8); }
.auth__sheet { flex: 1; margin-top: calc(var(--s6) * -1); background: var(--surface); color: var(--fg);
  border-radius: var(--r) var(--r) 0 0; padding: var(--s5) var(--s4) calc(var(--s6) + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: var(--s4); }
.auth__sheet:focus { outline: none; }
.auth__help { margin-top: auto; padding-top: var(--s4); font-size: var(--t-sm); color: var(--fg-muted); text-align: center; }
@media (min-width: 40rem) {
  .auth { align-items: center; justify-content: center; padding: var(--s5) var(--s4); }
  .auth__top { padding: 0 0 var(--s5); }
  .auth__sheet { flex: none; width: min(28rem, 100%); margin: 0; border-radius: var(--r); padding: var(--s5);
    box-shadow: var(--lift); }   /* the one card that floats on the navy */
  .auth__help { margin-top: 0; }
}
/* A short phone with its keyboard up: the welcome gives way so the form stays above the keys. */
@media (max-width: 40rem) and (max-height: 34rem) {
  .auth__org { display: none; }
  .auth__top { padding-top: calc(var(--s3) + env(safe-area-inset-top)); padding-bottom: calc(var(--s6) + var(--s2)); }
  .auth__brand { flex-direction: row; }
  .auth__brand .brand__mark { width: 40px; height: 40px; border-radius: 10px; }
  .auth__name { font-size: var(--t-xl); }
}

/* ── 4. Navigation ──────────────────────────────────────────────────────── */

.brand { display: inline-flex; align-items: center; gap: var(--s2); font-weight: 700; color: inherit;
  text-decoration: none; min-height: var(--tap); }
.brand__mark svg { width: 100%; height: 100%; display: block; }
/* The signature writes itself (1.4s), rests, fades, and writes again. */
.brand__mark--live .brand__ink { stroke-dasharray: 40; stroke-dashoffset: 40; animation: ink 4.8s ease-in-out 0.3s infinite; }
@keyframes ink {
  0% { stroke-dashoffset: 40; opacity: 1; }
  30% { stroke-dashoffset: 0; opacity: 1; }
  80% { stroke-dashoffset: 0; opacity: 1; }
  92% { stroke-dashoffset: 0; opacity: 0; }
  100% { stroke-dashoffset: 40; opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .brand__mark--live .brand__ink { animation: none; stroke-dashoffset: 0; } }
.brand__mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-sm);
  background: var(--gold); color: var(--navy-deep); }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  gap: var(--s3); padding: 0 var(--s4); background: var(--navy-deep); color: #fff; }
.topbar .btn--quiet { color: #fff; }
.rail { display: none; }

.tabbar { position: fixed; inset: auto 0 0 0; z-index: 10; display: flex; background: var(--surface);
  border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
.tabbar .nav__link { flex: 1; flex-direction: column; gap: 2px; font-size: var(--t-xs); min-height: 60px;
  justify-content: center; }

.nav__link { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); color: var(--fg-muted);
  text-decoration: none; border-radius: var(--r-sm); font-weight: 550; }
.nav__link:hover { color: var(--navy-deep); background: var(--info-bg); }
.nav__link.is-on { color: var(--navy-deep); }
.tabbar .nav__link.is-on .nav__icon { background: var(--info-bg); }
.nav__icon { position: relative; display: inline-grid; place-items: center; width: 44px; height: 28px; border-radius: 14px; }
.nav__count { position: absolute; top: -6px; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--gold); color: var(--navy-deep); font-size: 11px; font-weight: 800; line-height: 18px; text-align: center; }
.rail .nav__count { right: -10px; }

@media (min-width: 60rem) {
  .topbar, .tabbar { display: none; }
  .rail { display: flex; flex-direction: column; gap: var(--s5); position: sticky; top: 0; height: 100dvh;
    padding: var(--s5) var(--s4); background: var(--navy-deep); color: #fff; }
  .rail__nav { display: flex; flex-direction: column; gap: var(--s1); }
  .rail .nav__link { color: rgba(255, 255, 255, 0.82); min-height: var(--tap); }
  .rail .nav__link:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
  .rail .nav__link.is-on { background: rgba(255, 255, 255, 0.14); color: #fff; }
  .rail .nav__icon { width: 24px; }
  .rail__foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--s2); }
  .rail__who { font-size: var(--t-sm); color: rgba(255, 255, 255, 0.82); }
  .rail .btn--quiet { color: #fff; padding-left: var(--s3); }
}

.backlink { display: inline-flex; align-items: center; gap: var(--s1); min-height: var(--tap); font-weight: 550; }

/* ── 5. Cards, lists, tables ────────────────────────────────────────────── */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.card--pad { padding: var(--s5); display: flex; flex-direction: column; gap: var(--s3); }
.card--pad > .btn { align-self: flex-start; }   /* a button is as wide as its words, except on phones */
.form-card { max-width: 40rem; }
.danger-zone { border-color: rgba(139, 26, 15, 0.25); }

.list { list-style: none; display: flex; flex-direction: column; }
.list__row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s3) 0; border-bottom: 1px solid var(--border); }
.list__row:last-child { border-bottom: 0; }
.list__row > span, .dl dd { min-width: 0; overflow-wrap: anywhere; }

.dl { display: grid; grid-template-columns: max-content 1fr; gap: var(--s2) var(--s4); align-items: baseline; }
.dl dt { color: var(--fg-muted); font-size: var(--t-sm); }
@media (max-width: 29.99rem) {
  .dl { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .dl dd { margin-bottom: var(--s3); }
}

.table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.table th { text-align: left; font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--fg-subtle); font-weight: 700; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); }
.table td { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
/* Phones: each row becomes a block, each cell labelled from data-label. */
@media (max-width: 47.99rem) {
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .table tr { display: block; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); }
  .table tr:last-child { border-bottom: 0; }
  .table td { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: var(--s2); padding: var(--s1) 0; border: 0; }
  .table td::before { content: attr(data-label); color: var(--fg-subtle); font-size: var(--t-xs); }
}

.pill { display: inline-flex; align-items: center; padding: 2px var(--s2); border-radius: 999px; font-size: var(--t-xs);
  font-weight: 650; white-space: nowrap; border: 1px solid currentColor; }
.pill--good { color: var(--good); background: var(--good-bg); }
.pill--bad  { color: var(--bad);  background: var(--bad-bg); }
.pill--warn { color: var(--warn); background: var(--warn-bg); }
.pill--info { color: var(--info); background: var(--info-bg); }
.pill--brand { color: var(--navy-deep); background: #FEF3C7; }

/* ── 6. Forms, buttons, alerts ──────────────────────────────────────────── */

form { display: flex; flex-direction: column; gap: var(--s4); }
.logout { display: block; }
.fld { display: flex; flex-direction: column; gap: var(--s1); }
.fld__label, .fieldset legend { font-weight: 650; font-size: var(--t-sm); color: var(--fg); }
.fld__hint { color: var(--fg-muted); font-size: var(--t-sm); }
.fld__input { font: inherit; width: 100%; min-height: var(--tap); padding: var(--s2) var(--s3);
  border: 1px solid var(--border-mid); border-radius: var(--r-sm); background: var(--surface); color: var(--fg); }
textarea.fld__input { resize: vertical; }
.fld__input:hover { border-color: var(--navy); }
.fld__input:focus-visible { outline: 3px solid var(--navy); outline-offset: 0; border-color: var(--navy); }
.fld--bad .fld__input { border-color: var(--bad); border-width: 2px; }
.fld__err { display: flex; gap: var(--s1); align-items: flex-start; color: var(--bad); font-size: var(--t-sm); font-weight: 600; }
.fieldset { border: 0; display: flex; flex-direction: column; gap: var(--s3); }
.check { display: grid; grid-template-columns: auto 1fr; gap: 0 var(--s3); align-items: center; }
.check input { width: 22px; height: 22px; margin: 11px; accent-color: var(--navy); }
.check .fld__hint { grid-column: 2; }

.btn { font: inherit; font-weight: 650; display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s2); min-height: var(--tap); padding: var(--s2) var(--s5); border-radius: var(--r-sm);
  border: 1px solid transparent; cursor: pointer; text-decoration: none; position: relative; }
.btn--block { width: 100%; }
.btn--sm { min-height: 44px; padding: var(--s1) var(--s3); font-size: var(--t-sm); }
.btn--primary { background: var(--navy); color: #fff; }
.btn--primary:hover { background: var(--navy-deep); color: #fff; }
.btn--secondary { background: var(--surface); color: var(--navy-deep); border-color: var(--border-mid); }
.btn--secondary:hover { border-color: var(--navy); color: var(--navy-deep); }
.btn--danger { background: var(--bad); color: #fff; }
.btn--danger:hover { background: #6E140B; color: #fff; }
.btn--quiet { background: transparent; color: var(--navy); }
.btn--danger-quiet { background: var(--surface); color: var(--bad); border-color: rgba(139, 26, 15, 0.45); }
.btn--danger-quiet:hover { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.btn--quiet:hover { background: var(--info-bg); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn__spin { display: none; width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin 0.8s linear infinite; }
.btn.is-busy .btn__spin { display: inline-block; }
@media (max-width: 47.99rem) {
  form .btn, .card .btn { width: 100%; }   /* full width within a form column on phones */
}

.alert { border-radius: var(--r-sm); padding: var(--s3) var(--s4); border: 1px solid; display: flex;
  flex-direction: column; gap: var(--s1); }
.alert:focus { outline: 3px solid var(--bad); }
.alert__title { display: flex; gap: var(--s2); align-items: flex-start; font-weight: 650; }
.alert__body, .alert__list { color: var(--fg-mid); font-size: var(--t-sm); }
.alert__list { padding-left: 1.75rem; }
.alert--bad  { background: var(--bad-bg);  border-color: rgba(139, 26, 15, 0.3); }
.alert--bad .alert__title { color: var(--bad); }
.alert--good { background: var(--good-bg); border-color: rgba(26, 107, 57, 0.3); }
.alert--good .alert__title { color: var(--good); }
.alert--info { background: var(--info-bg); border-color: rgba(15, 76, 117, 0.25); }
.alert--info .alert__title { color: var(--info); }
.alert--warn { background: var(--warn-bg); border-color: rgba(138, 75, 6, 0.3); }
.alert--warn .alert__title { color: var(--warn); }
[data-toast].is-floating { position: fixed; z-index: 40; left: 50%; top: var(--s4); transform: translateX(-50%);
  width: min(28rem, calc(100% - 2 * var(--s4))); box-shadow: var(--lift); }

.rules { list-style: none; display: grid; gap: var(--s1); font-size: var(--t-sm); color: var(--fg-muted); }
.rule { display: flex; gap: var(--s2); align-items: center; }
.rule__mark { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  border: 1.5px solid var(--border-mid); color: transparent; }
.rule__mark .ic { width: 14px; height: 14px; }
.rule.is-ok { color: var(--good); }
.rule.is-ok .rule__mark { border-color: var(--good); background: var(--good); color: #fff; }

.divider { display: flex; align-items: center; gap: var(--s3); color: var(--fg-subtle); font-size: var(--t-sm);
  margin: var(--s2) 0; max-width: none; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.passkey-login { display: flex; flex-direction: column; gap: var(--s2); }
.passkey-login__msg:empty, .offer__msg:empty { display: none; }
.passkey-login__msg, .offer__msg { font-size: var(--t-sm); color: var(--bad); font-weight: 600; }
.offer { display: flex; flex-direction: column; gap: var(--s2); }

/* The file picker: the real input, hidden but focusable, and its label as a drop area. */
.filepick__input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.filepick__zone { display: flex; align-items: center; gap: var(--s4); padding: var(--s5); cursor: pointer;
  border: 2px dashed var(--border-mid); border-radius: var(--r); background: var(--surface); min-height: 96px;
  transition: border-color 150ms ease, background-color 150ms ease; }
.filepick__zone:hover, .filepick__zone.is-over { border-color: var(--navy); background: var(--info-bg); }
.filepick__input:focus-visible + .filepick__zone { outline: 3px solid var(--navy); outline-offset: 2px; }
.filepick__icon { flex: none; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%;
  background: var(--info-bg); color: var(--navy); }
.filepick__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.filepick__title { font-weight: 700; color: var(--navy-deep); }
.filepick__hint { font-size: var(--t-sm); color: var(--fg-muted); }
.filepick__chosen { font-size: var(--t-sm); font-weight: 650; color: var(--good); overflow-wrap: anywhere; }
.filepick__chosen:empty { display: none; }
.filepick.has-file .filepick__zone { border-style: solid; border-color: var(--good); }
.filepick.has-file .filepick__icon { background: var(--good-bg); color: var(--good); }
.fld--bad .filepick__zone { border-color: var(--bad); }
.filepick--compact .filepick__zone { padding: var(--s3) var(--s4); min-height: 0; }
.filepick--compact .filepick__icon { width: 36px; height: 36px; }

/* ── Vouchers ───────────────────────────────────────────────────────────── */

.grid--fields { display: grid; gap: var(--s4); }
@media (min-width: 40rem) { .grid--fields { grid-template-columns: 1fr 1fr; } }
.fld__file { font: inherit; min-height: var(--tap); padding: var(--s2) 0; max-width: 100%; }
.scan-msg:empty { display: none; }
.scan-msg { font-size: var(--t-sm); color: var(--fg-mid); }
.upload { gap: var(--s4); }
#after-file { display: flex; flex-direction: column; gap: var(--s4); }
#after-file[hidden] { display: none; }
.actions { display: flex; gap: var(--s2); }

.chain { list-style: none; display: flex; flex-direction: column; gap: var(--s2); }
.step { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s2) var(--s3); align-items: start;
  padding: var(--s3); border: 1px solid var(--border); border-radius: var(--r-sm); }
.step__n { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--navy); color: #fff; font-weight: 700; font-size: var(--t-sm); }
.step__body { display: flex; flex-direction: column; gap: var(--s2); min-width: 0; }
.step__lines { list-style: none; font-size: var(--t-sm); color: var(--fg-mid); }
.step__warn { color: var(--warn); font-weight: 600; }
.step__tools { grid-column: 2; display: flex; gap: var(--s1); flex-wrap: wrap; }
.step--done .step__n { background: var(--good); }
.step--now { border-color: var(--navy); border-width: 2px; }
.step__state { font-size: var(--t-sm); }

/* ── The voucher list (the main page) ─────────────────────────────────────── */

/* Which vouchers: one switch of three, the current one filled. */
.scopes { display: flex; gap: var(--s1); padding: var(--s1); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); width: fit-content; max-width: 100%; overflow-x: auto; }
.scopes__item { display: inline-flex; align-items: center; gap: var(--s2); min-height: 40px; padding: 0 var(--s4);
  border-radius: var(--r-sm); color: var(--fg-muted); font-weight: 650; text-decoration: none; white-space: nowrap; }
.scopes__item:hover { color: var(--navy-deep); background: var(--info-bg); }
.scopes__item.is-on { background: var(--navy); color: #fff; }
.scopes__count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
  background: var(--gold); color: var(--navy-deep); font-size: var(--t-xs); font-weight: 800; }
@media (max-width: 47.99rem) { .scopes { width: 100%; } .scopes__item { flex: 1; justify-content: center; padding: 0 var(--s2); } }

.filters { display: grid; gap: var(--s3); grid-template-columns: 1fr 1fr; align-items: end; }
.filters__q { grid-column: 1 / -1; }
.filters__go { grid-column: 1 / -1; display: flex; gap: var(--s2); }
@media (min-width: 60rem) {
  .filters { grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) minmax(0, 1fr) auto; }
  .filters__q, .filters__go { grid-column: auto; }
}

.vcard__head { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); flex-wrap: wrap;
  padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); }
.vcard__sum { color: var(--fg-mid); }
.vcard__head .btn { flex: none; }
@media (max-width: 47.99rem) { .vcard__head .btn { width: auto; } }
.vcard__sum strong { color: var(--navy-deep); }
.vcard__dot { color: var(--fg-subtle); margin: 0 2px; }
.vcard__empty { padding: var(--s5); }

.vtable { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.vtable th { text-align: left; font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-subtle);
  font-weight: 700; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); }
.vtable td { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.vtable tbody tr { position: relative; }
.vtable tbody tr:hover { background: var(--ground); }
.vtable tbody tr:last-child td { border-bottom: 0; }
.vtable__amt { text-align: right; white-space: nowrap; }
.vtable__no a { font-weight: 700; color: var(--navy-deep); text-decoration: none; }
.vtable__no a::after { content: ""; position: absolute; inset: 0; }   /* the whole row is the link */
.vtable__no a:focus-visible { outline: none; }
.vtable tbody tr:focus-within { outline: 3px solid var(--navy); outline-offset: -3px; }
.vtable__date { white-space: nowrap; color: var(--fg-muted); }
/* Phones: each row is a card - number and amount on top, payee, then date and status. */
@media (max-width: 47.99rem) {
  .vtable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .vtable tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px var(--s3);
    padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); }
  .vtable td { padding: 0; border: 0; }
  .vtable__no { grid-column: 1; grid-row: 1; }
  .vtable__amt { grid-column: 2; grid-row: 1; font-weight: 700; color: var(--navy-deep); }
  .vtable__payee { grid-column: 1 / -1; grid-row: 2; color: var(--fg-mid); overflow-wrap: anywhere; }
  .vtable__date { grid-column: 1; grid-row: 3; font-size: var(--t-xs); align-self: center; }
  .vtable__status { grid-column: 2; grid-row: 3; text-align: right; }
}

.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  padding: var(--s3) var(--s4); border-top: 1px solid var(--border); }
.pager__nums { list-style: none; display: flex; gap: var(--s1); align-items: center; }
.pager__num, .pager__step { display: inline-flex; align-items: center; justify-content: center; gap: var(--s1);
  min-width: 44px; min-height: 44px; padding: 0 var(--s2); border-radius: var(--r-sm); font-weight: 650;
  text-decoration: none; color: var(--navy); }
.pager__num:hover, .pager__step:hover { background: var(--info-bg); }
.pager__num.is-on { background: var(--navy); color: #fff; }
.pager__step.is-off { color: var(--fg-subtle); opacity: 0.5; }
.pager__gap { color: var(--fg-subtle); padding: 0 var(--s1); }
.flip { display: inline-flex; transform: scaleX(-1); }
@media (max-width: 29.99rem) { .pager__step span:not(.flip) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); } }

/* ── Settings: rows that each lead to their own page ──────────────────────── */

.eyebrow { font-size: var(--t-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--fg-subtle); margin: 0 0 var(--s2) var(--s1); }
.rowlist { list-style: none; overflow: hidden; }
.rowlist li + li { border-top: 1px solid var(--border); }
.rowlink { display: flex; align-items: center; gap: var(--s4); min-height: 64px; padding: var(--s3) var(--s4);
  color: var(--fg); text-decoration: none; }
.rowlink:hover { background: var(--ground); color: var(--navy-deep); }
.rowlink__icon { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-sm);
  background: var(--info-bg); color: var(--navy); }
.rowlink__text { flex: 1; min-width: 0; font-weight: 650; }
.rowlink__sub { display: block; font-weight: 400; font-size: var(--t-sm); color: var(--fg-muted); }
.rowlink__go { color: var(--fg-subtle); }

/* ── The voucher page ─────────────────────────────────────────────────────── */

.vhead { display: flex; flex-direction: column; gap: var(--s1); }
.vhead__meta { color: var(--fg-muted); overflow-wrap: anywhere; }
.vlayout { display: grid; gap: var(--s4); align-items: start; }
.vside { display: flex; flex-direction: column; gap: var(--s4); min-width: 0; }
@media (min-width: 60rem) {
  /* The voucher is the work: it gets the room; the panel stays in reach while it scrolls. */
  .vlayout { grid-template-columns: minmax(0, 1fr) 22rem; gap: var(--s5); }
  .vside { position: sticky; top: var(--s5); max-height: calc(100dvh - 2 * var(--s5)); overflow-y: auto;
    overscroll-behavior: contain; padding-bottom: var(--s2); }
}
.vdoc { min-width: 0; display: flex; flex-direction: column; gap: var(--s2); }
.vtools { display: flex; justify-content: flex-end; }
/* Zoomed, the voucher is wider than its column and scrolls sideways inside it
   (never the page). Boxes are placed in percent, so they follow. */
.vscroll { overflow-x: auto; overscroll-behavior-x: contain; border-radius: var(--r-sm); }
.viewer.is-zoomed { width: 220%; }
@media (min-width: 60rem) { .viewer.is-zoomed { width: 160%; } }
.viewer { display: flex; flex-direction: column; gap: var(--s3); position: relative; }
.vpage { position: relative; width: 100%; background: #fff; border: 1px solid var(--border-mid);
  border-radius: var(--r-sm); overflow: hidden; container-type: inline-size; }
.vpage canvas { display: block; width: 100%; height: 100%; }
.vpage--loading { aspect-ratio: 595 / 842;
  background: linear-gradient(100deg, #fff 30%, #eef2f6 50%, #fff 70%) 0 0 / 300% 100%; animation: shimmer 1.4s ease-in-out infinite; }
@keyframes shimmer { to { background-position: -100% 0; } }
.vpage__layer { position: absolute; inset: 0; }
.stamp, .sbox { position: absolute; display: flex; align-items: flex-end; justify-content: center; }
.stamp img, .sbox img { max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none; }
.stamp__date { position: absolute; font: calc(800cqw / var(--pw)) / 1 Helvetica, Arial, sans-serif; color: #000;
  white-space: nowrap; pointer-events: none; }
.stamp__date--mine { color: var(--navy); }
.sbox { outline: 2px dashed var(--navy); outline-offset: 1px; background: rgba(15, 76, 117, 0.07);
  cursor: grab; touch-action: none; border-radius: 2px; }
.sbox:hover { background: rgba(15, 76, 117, 0.12); }
.sbox:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; }
.sbox.is-dragging { cursor: grabbing; background: rgba(15, 76, 117, 0.16); }
.sbox__empty { align-self: center; font-size: clamp(9px, 1.6cqw, 13px); font-weight: 650; color: var(--navy); }
.sbox__label { position: absolute; left: 0; bottom: 100%; font-size: clamp(9px, 1.5cqw, 12px); font-weight: 700;
  background: var(--navy); color: #fff; padding: 1px 6px; border-radius: 4px 4px 0 0; white-space: nowrap; }
.sbox__grip { position: absolute; right: -7px; bottom: -7px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--navy); border: 2px solid #fff; cursor: nwse-resize; }
.sbox--missing { outline-color: var(--warn); background: rgba(138, 75, 6, 0.10); }
.sbox--missing .sbox__label { background: var(--warn); }
.viewer.is-preview::before { content: "Preview: not signed yet"; position: sticky; top: var(--s2); z-index: 2;
  align-self: center; background: var(--navy-deep); color: #fff; font-weight: 650; font-size: var(--t-sm);
  padding: var(--s1) var(--s4); border-radius: 999px; box-shadow: var(--lift); }
.viewer.is-preview .vpage { border-color: var(--navy); border-width: 2px; }
.viewer__err:empty { display: none; }

.signpanel { border-color: var(--navy); border-width: 2px; }
.signpanel__place, .signpanel__confirm { display: flex; flex-direction: column; gap: var(--s3); }
.signpanel__confirm[hidden], .signpanel__place[hidden] { display: none; }
.signpanel h2:focus { outline: none; }
.signpanel__msg:empty { display: none; }
.sigpick { gap: var(--s2); }
.sigpick__list { display: grid; grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); gap: var(--s2); }
.sigopt { position: relative; display: grid; place-items: center; height: 64px; padding: var(--s2);
  border: 1px solid var(--border-mid); border-radius: var(--r-sm); background: #fff; cursor: pointer; }
.sigopt img { max-width: 100%; max-height: 100%; object-fit: contain; }
.sigopt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.sigopt:has(input:checked) { border: 2px solid var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }
.sigopt:has(input:checked)::after { content: "✓"; position: absolute; top: 2px; right: 6px; font-weight: 800; color: var(--navy); }
.sigopt:has(input:focus-visible) { outline: 3px solid var(--navy); outline-offset: 2px; }
.returnbox, .reassign { border-top: 1px solid var(--border); padding-top: var(--s3); }
.returnbox summary, .reassign summary { cursor: pointer; font-weight: 650; color: var(--navy); min-height: 44px;
  display: flex; align-items: center; }
.returnbox[open] summary, .reassign[open] summary { margin-bottom: var(--s3); }
.link-quiet { display: inline-flex; align-items: center; gap: var(--s1); font-size: var(--t-sm); min-height: 44px; }

/* The signature pad. A dialog: the one place a shadow belongs. */
.pad { margin: auto; width: min(36rem, calc(100% - 2 * var(--s4))); border: 0; border-radius: var(--r);
  padding: var(--s5); box-shadow: var(--lift); display: none; }
.pad[open] { display: flex; flex-direction: column; gap: var(--s3); }
.pad::backdrop { background: rgba(5, 46, 71, 0.45); }
.pad__canvas { width: 100%; height: 180px; border: 1px solid var(--border-mid); border-radius: var(--r-sm);
  touch-action: none; cursor: crosshair; background:
  linear-gradient(to top, transparent 34px, var(--border-mid) 34px, var(--border-mid) 35px, transparent 35px) #fff; }
.pad__msg:empty { display: none; }
.pad__actions { display: flex; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; }
.pad__end { display: flex; gap: var(--s2); }

.sig-grid { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: var(--s4); }
.sig-card { display: flex; flex-direction: column; overflow: hidden; }
.sig-card__img { height: 120px; display: grid; place-items: center; padding: var(--s4); border-bottom: 1px solid var(--border); }
.sig-card__img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.sig-card__foot { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); padding: var(--s2) var(--s3); }
.sig-card__foot form { display: block; }
.add-msg:empty { display: none; }

/* ── 7. Motion ──────────────────────────────────────────────────────────── */

@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
