/* zz-theme.css v3 — shared theme for every Tax Portal page (login, upload, staff, ingest).
   Reference it as  <link rel="stylesheet" href="zz-theme.css?v=3">  and bump ?v= on change.
   Brand: maroon #991b1b, warm stone neutrals, self-hosted Inter + system CJK fonts.
   House rules: no inline <script>; icons are inline SVG (stroke, 20px) or the CSS masks
   below, never emoji; everything keyboard-focusable shows the same maroon focus ring.

   CLASS INDEX (markup pattern in brackets / after ">")
   ---------------------------------------------------------------------------------------
   Layout      body.wide ............ staff pages: header + .page widen to 1180px
               .app-header > .app-header__inner > .brand + .app-header__actions
               .brand > img.brand__logo + .brand__text > .brand__name + .brand__page
                                      (under 440px, with 3+ header action items, only the
                                      logo shows; the name stays for screen readers)
               .lang-toggle ......... [div role=group > button[data-set-lang=en|zh][aria-pressed]]
                                      (js/i18n.js wires these buttons automatically)
               .page ................ <main> column, 640px (client) / 1180px (body.wide)
               .page--auth .......... 440px column for the login card
               .page-intro .......... greeting / page title block (> h1 + p)
               .page-head ........... staff title row: > .page-head__text (h1 + .page-head__meta)
                                      + .page-head__actions
               .app-footer .......... small muted footer
               .stack / .stack-sm / .stack-lg   vertical rhythm (16 / 8 / 24px between children)
               .cluster (--between, --end)      horizontal wrapping row, 8px gap
               hr.divider
   Card        .card (--flush) ....... white panel, 14px radius; .card__footer
               .section-head ........ > .section-head__icon? + .section-head__text
                                      (> .section-head__title + .section-head__sub)
                                      + .section-head__aside?
   Forms       .fields (--2, --3) .... grid of fields (always 1 column on phones); .field--span-2
               .field > label (or .field__label) + control + .field__hint + .field__error
                        .field__optional (inside the label), .field__success (e.g. bank name)
                        .field.is-invalid or [aria-invalid=true] paints the control red
               inputs / selects / textareas are styled bare (or use .input / .select)
               input.input--code .... big spaced one-time-code input
               .input-group > input + button.input-group__btn   (e.g. SSN show/hide eye)
               .choices > label.choice > input[type=radio|checkbox] + text   (option tiles)
               .switch .............. [label.switch > input.switch__input[type=checkbox][role=switch]
                                       + .switch__text(> .switch__label + .switch__hint)
                                       + span.switch__track]
               .toggle-card > .switch + .toggle-card__body[hidden]   (switch that reveals fields)
               .summary > .summary__text + .summary__action   (collapsed "Your details" row)
               dl.kv ................ key/value list: dt + dd pairs
               details.disclosure > summary + .disclosure__body
   Buttons     .btn + .btn-primary | .btn-secondary | .btn-ghost ; sizes .btn-sm .btn-lg ;
               .btn-block ; .btn-icon (44px square; needs aria-label; + .btn-icon--danger) ;
               .btn-link (text button, 44px tall) ; add .is-loading to any .btn for a spinner
               .label-collapse on a label span: hidden visually under 600px, still read aloud
               .tile-grid > .tile-btn(--primary) (> svg + span + .tile-btn__sub)  big pickers
   Files       .dropzone(.is-dragover) > svg + .dropzone__title + .dropzone__sub
               ul.file-list > li.file-row(.is-rejected) > .file-row__thumb(--pdf|--image)
                  + .file-row__main(> .file-row__name + .file-row__meta) + .btn-icon
   Feedback    .alert + --info|--success|--warning|--danger (icon drawn by CSS; --plain: none)
                  > .alert__body > .alert__title + p + .alert__actions
               .inline-msg + --busy|--success|--danger|--muted   one-line live status
               .chips > .chip (+ --brand|--success|--warning|--danger|--info|--neutral)
               .status + --processing|--ready|--received|--attention|--failed|--imported|
                         --neutral    (pill: dot + text, so never colour alone)
               .progress(--indeterminate|--success|--warning|--danger) > .progress__bar
               .progress-label (two spans, spread apart)
               .spinner (--sm|--lg|--light)
               .hero-icon (--success|--danger|--brand|--info, --sm)   big round icon
               .empty > .empty__icon + .empty__title + .empty__text (+ .btn)
               ol.steps > li.step(.is-current|.is-done|.is-error) > .step__num + .step__body
                  (> .step__title + .step__text + optional .alert/.btn/.cluster)
   Overlays    dialog.dialog(.dialog--wide) > .dialog__header(> h2.dialog__title + .btn-icon)
                  + .dialog__body + .dialog__footer?     (bottom sheet on phones)
               .action-bar > .action-bar__inner > .btn + .action-bar__reason? + .action-bar__note
                  sticky bottom bar; make it the last child of .page
   Data        .stats > button.stat(--today|--processing|--ready|--attention)[aria-pressed]
                  > .stat__label + .stat__value
               .toolbar > .search(> input[type=search]) + .toolbar__meta + buttons
               .table-wrap > table.table(.table--stack) ; td[data-label] labels stacked cards
                  (< 700px; the label floats left, any cell content sits right);
                  td.cell-primary = card title when stacked; td.cell-actions (hidden when
                  empty); .cell-sub (muted 2nd line); .num; tr.is-highlighted
   Utilities   .visually-hidden .muted .text-sm .text-xs .strong .mono .nowrap .truncate
               .center .mt-0 .mt-8 .mt-16 .mt-24 .mb-0 .show-touch .show-pointer ; [hidden]
               (wrap masked values like •••-••-2222 in .nowrap so they never split)
   Tokens      colours --c-*, radii --radius-*, spacing --s-4 … --s-48, --shadow-card,
               --shadow-overlay, --focus-ring (text fields), --focus-ring-strong (everything
               else that takes keyboard focus), --control-h (48px), --tap (44px), --page-max
   Page: login .auth-card .auth-card__head .auth-links .trust-note
   ------------------------------------------------------------------------------------- */

/* ---------------------------------------------------------------------------- font */
/* Latin subset only; Chinese falls through to the system CJK fonts in --font. */
@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-var.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

/* -------------------------------------------------------------------------- tokens */
:root {
  color-scheme: light;

  /* brand */
  --c-primary: #991b1b;
  --c-primary-hover: #7f1d1d;
  --c-primary-active: #6d1717;
  --c-primary-soft: #fbf1f1;
  --c-primary-tint: #efd3d3;

  /* warm stone neutrals */
  --c-bg: #f7f6f4;
  --c-surface: #ffffff;
  --c-surface-2: #faf9f7;
  --c-surface-3: #f1efec;
  --c-border: #e6e2de;          /* hairlines, card edges */
  --c-border-strong: #8f8883;   /* form controls: 3.5:1 on white */
  --c-border-hover: #6b645e;
  --c-text: #1c1917;
  --c-text-2: #44403c;
  --c-muted: #6b645e;           /* 5.4:1 on --c-bg */
  --c-placeholder: #78716c;     /* 4.8:1 on white (placeholder text must stay readable) */

  /* semantic */
  --c-success: #15803d; --c-success-bg: #f0fdf4; --c-success-border: #bbf7d0; --c-success-text: #166534;
  --c-warning: #d97706; --c-warning-bg: #fffbeb; --c-warning-border: #fde68a; --c-warning-text: #92400e;
  --c-danger:  #dc2626; --c-danger-bg:  #fef2f2; --c-danger-border:  #fecaca; --c-danger-text:  #991b1b;
  --c-info:    #2563eb; --c-info-bg:    #eff6ff; --c-info-border:    #bfdbfe; --c-info-text:    #1e40af;
  --c-slate:   #64748b; --c-slate-bg:   #f1f5f9; --c-slate-border:   #cbd5e1; --c-slate-text:   #334155;

  /* shape + depth */
  --radius-sm: 6px;
  --radius-control: 10px;
  --radius-card: 14px;
  --radius-pill: 999px;
  --shadow-card: 0 1px 2px rgb(28 25 23 / 0.04), 0 4px 14px -4px rgb(28 25 23 / 0.08);
  --shadow-overlay: 0 24px 48px -12px rgb(28 25 23 / 0.35);
  --focus-ring: 0 0 0 3px rgb(153 27 27 / 0.35);     /* text fields: + maroon border on focus */
  /* Buttons, links, switches, tiles: a white gap + solid maroon ring (8:1 on white; the soft
     ring alone is 1.9:1, under the 3:1 WCAG 1.4.11 asks of a focus indicator). */
  --focus-ring-strong: 0 0 0 2px var(--c-surface), 0 0 0 4px var(--c-primary);

  /* spacing (8px grid; 4 and 12 for tight spots) */
  --s-4: 4px; --s-8: 8px; --s-12: 12px; --s-16: 16px; --s-24: 24px;
  --s-32: 32px; --s-40: 40px; --s-48: 48px;

  /* sizes */
  --control-h: 48px;
  --control-h-sm: 40px;
  --tap: 44px;
  --page-max: 640px;

  /* type */
  --font: "Inter Variable", "Inter", system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans SC", sans-serif;
  --font-zh: "Inter Variable", "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* motion */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur: 150ms;

  /* icons for CSS masks (decorative; painted in currentColor) */
  --icon-info: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-4M12 8h.01'/%3E%3C/svg%3E");
  --icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m8.5 12 2.5 2.5 4.5-5'/%3E%3C/svg%3E");
  --icon-warning: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z'/%3E%3Cpath d='M12 9v4M12 17h.01'/%3E%3C/svg%3E");
  --icon-error: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 8v4M12 16h.01'/%3E%3C/svg%3E");
  --icon-lock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='11' width='16' height='10' rx='2'/%3E%3Cpath d='M8 11V7a4 4 0 0 1 8 0v4'/%3E%3C/svg%3E");
  --icon-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  --icon-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
}
body.wide { --page-max: 1180px; }

/* ---------------------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: clip;             /* no sideways page scroll; `clip` keeps position:sticky working */
}
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  font-feature-settings: "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
html:lang(zh) body { font-family: var(--font-zh); line-height: 1.6; }
[hidden] { display: none !important; }
img, svg, video, canvas { display: inline-block; vertical-align: middle; max-width: 100%; }
svg { flex: none; }
h1, h2, h3, h4 { margin: 0; color: var(--c-text); font-weight: 600; letter-spacing: -0.011em; line-height: 1.3; }
h1, h2, h3, .section-head__title, .empty__title, .dialog__title { text-wrap: balance; }
p, .field__hint, .field__error, .alert__body { text-wrap: pretty; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p { margin: 0; }
ul, ol { margin: 0; }
a { color: var(--c-primary); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--c-primary-hover); }
strong, b { font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--c-primary-tint); color: var(--c-text); }
code, kbd { font-family: inherit; font-variant-numeric: tabular-nums; }

/* Keyboard focus: one maroon ring everywhere. The transparent outline keeps a visible
   ring in Windows high-contrast mode, which drops box-shadows. */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: var(--focus-ring-strong);
}
a:focus-visible { border-radius: 4px; }

/* ----------------------------------------------------------------------- utilities */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.muted { color: var(--c-muted); }
.text-sm { font-size: 14px; }
.text-xs { font-size: 13px; }
.strong { font-weight: 600; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.center { text-align: center; }
.mt-0 { margin-top: 0 !important; }
.mt-8 { margin-top: var(--s-8) !important; }
.mt-16 { margin-top: var(--s-16) !important; }
.mt-24 { margin-top: var(--s-24) !important; }
.mb-0 { margin-bottom: 0 !important; }
.stack > * + * { margin-top: var(--s-16); }
.stack-sm > * + * { margin-top: var(--s-8); }
.stack-lg > * + * { margin-top: var(--s-24); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-8); }
.cluster--between { justify-content: space-between; }
.cluster--end { justify-content: flex-end; }
.divider { border: 0; border-top: 1px solid var(--c-border); margin: var(--s-24) 0; }
/* Touch-only / mouse-only helpers ("Take a photo" vs drag & drop). */
@media (hover: hover) and (pointer: fine) { .show-touch { display: none !important; } }
@media not all and (hover: hover) and (pointer: fine) { .show-pointer { display: none !important; } }

/* ---------------------------------------------------------------------- app header */
.app-header {
  flex: none;
  background: var(--c-surface);
  border-top: 4px solid var(--c-primary);
  border-bottom: 1px solid var(--c-border);
}
.app-header__inner {
  max-width: calc(var(--page-max) + 2 * var(--s-16));
  min-height: 68px;
  margin: 0 auto;
  padding: var(--s-12) var(--s-16);
  display: flex;
  align-items: center;
  gap: var(--s-12);
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--s-12);
  min-width: 0;
  flex: 1 1 auto;
  color: inherit;
  text-decoration: none;
}
.brand__logo {
  width: 44px; height: 44px;
  flex: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px var(--c-border);
}
.brand__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.brand__name, .brand__page { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand__name { font-size: 16px; font-weight: 650; color: var(--c-text); letter-spacing: -0.01em; }
.brand__page { margin-top: 1px; font-size: 14px; color: var(--c-muted); }
.app-header__actions { display: flex; align-items: center; gap: var(--s-8); flex: none; }

/* EN | 中文 segmented toggle */
.lang-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  flex: none;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-pill);
  background: var(--c-surface-3);
}
.lang-toggle button {
  min-width: 44px;
  height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--c-text-2);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur), color var(--dur), box-shadow var(--dur);
}
.lang-toggle button:hover { color: var(--c-text); }
/* Touch: the 38px segments get an invisible 46px-tall hit area (the pill's full height). */
.lang-toggle button { position: relative; }
.lang-toggle button::after { content: ""; position: absolute; inset: -4px 0; }
/* Mouse: a 40px pill, the same height as the header's small buttons beside it. */
@media (hover: hover) and (pointer: fine) {
  .lang-toggle button { height: 32px; }
}
.lang-toggle button[aria-pressed="true"] {
  background: var(--c-surface);
  color: var(--c-primary);
  box-shadow: 0 1px 2px rgb(28 25 23 / 0.12), 0 0 0 1px var(--c-border);
}
.lang-toggle button:focus-visible { box-shadow: var(--focus-ring-strong); }

/* ------------------------------------------------------------------------- layout */
.page {
  width: 100%;
  max-width: calc(var(--page-max) + 2 * var(--s-16));
  margin: 0 auto;
  padding: var(--s-24) var(--s-16) var(--s-48);
  flex: 1 0 auto;
}
.page--auth { max-width: calc(440px + 2 * var(--s-16)); }
.page-intro { margin-bottom: var(--s-24); }
.page-intro h1, .page-intro__title { font-size: 22px; }
.page-intro p, .page-intro__text { margin-top: var(--s-4); color: var(--c-muted); font-size: 16px; }
.page-intro strong { color: var(--c-text); }
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-12) var(--s-16);
  margin-bottom: var(--s-24);
}
.page-head__text { min-width: 0; }
.page-head__meta { margin-top: var(--s-4); color: var(--c-muted); font-size: 14px; }
.page-head__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-8); }
.app-footer {
  flex: none;
  padding: var(--s-24) var(--s-16) calc(var(--s-24) + env(safe-area-inset-bottom, 0px));
  color: var(--c-muted);
  font-size: 13px;
  text-align: center;
}

/* -------------------------------------------------------------------------- cards */
.card {
  padding: var(--s-24);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-card);
  background: var(--c-surface);
  box-shadow: var(--shadow-card);
}
.card--flush { padding: 0; overflow: hidden; }
.card + .card { margin-top: var(--s-16); }
.card__footer {
  margin-top: var(--s-24);
  padding-top: var(--s-16);
  border-top: 1px solid var(--c-border);
}
.section-head { display: flex; align-items: flex-start; gap: var(--s-12); margin-bottom: var(--s-16); }
.section-head__icon {
  width: 40px; height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--radius-control);
  background: var(--c-primary-soft);
  color: var(--c-primary);
}
.section-head__icon svg { width: 20px; height: 20px; }
.section-head__text { flex: 1 1 auto; min-width: 0; }
.section-head__title { margin: 0; font-size: 18px; font-weight: 600; line-height: 1.3; }
.section-head__sub { margin: var(--s-4) 0 0; color: var(--c-muted); font-size: 15px; }
.section-head__aside { flex: none; align-self: center; }

/* -------------------------------------------------------------------------- forms */
.fields { display: grid; gap: var(--s-16); grid-template-columns: minmax(0, 1fr); }
.fields + .fields { margin-top: var(--s-16); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field__label {
  font-size: 14px;
  font-weight: 600;
  color: var(--c-text-2);
  line-height: 1.35;
}
.field__optional { font-weight: 400; color: var(--c-muted); }
.field__hint { margin: 0; font-size: 14px; color: var(--c-muted); line-height: 1.45; }
.field__error, .field__success {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
}
.field__error { color: var(--c-danger-text); }
.field__success { color: var(--c-success-text); }
.field__error:empty, .field__success:empty { display: none; }
.field__error::before, .field__success::before {
  content: "";
  width: 16px; height: 16px;
  margin-top: 2px;
  flex: none;
  background: currentColor;
  -webkit-mask: var(--icon-error) center / contain no-repeat;
  mask: var(--icon-error) center / contain no-repeat;
}
.field__success::before { -webkit-mask-image: var(--icon-check); mask-image: var(--icon-check); }

.input,
.select,
input[type="text"], input[type="email"], input[type="tel"], input[type="number"],
input[type="search"], input[type="password"], input[type="date"], input[type="url"],
select, textarea {
  display: block;
  width: 100%;
  min-height: var(--control-h);
  padding: 0 14px;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-control);
  background-color: var(--c-surface);
  color: var(--c-text);
  font-size: 16px;               /* 16px: iOS does not zoom the page on focus */
  line-height: 1.3;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--dur), box-shadow var(--dur), background-color var(--dur);
}
textarea { min-height: 96px; padding: 12px 14px; line-height: 1.5; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--c-placeholder); opacity: 1; }
input:hover:not(:disabled):not(:focus), select:hover:not(:disabled):not(:focus),
textarea:hover:not(:disabled):not(:focus) { border-color: var(--c-border-hover); }
input:focus, select:focus, textarea:focus {
  outline: 2px solid transparent;
  border-color: var(--c-primary);
  box-shadow: var(--focus-ring);
}
input:disabled, select:disabled, textarea:disabled {
  border-color: #c9c3bd;
  background-color: var(--c-surface-3);
  color: var(--c-muted);
  cursor: not-allowed;
}
input[readonly] { background-color: var(--c-surface-2); }
input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
select {
  padding-right: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236b645e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 20px;
  cursor: pointer;
}
.field.is-invalid input, .field.is-invalid select, .field.is-invalid textarea,
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] {
  border-color: var(--c-danger);
}
.field.is-invalid input:focus, .field.is-invalid select:focus, .field.is-invalid textarea:focus,
input[aria-invalid="true"]:focus, select[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px rgb(220 38 38 / 0.3);
}
input[type="checkbox"], input[type="radio"] {
  width: 20px; height: 20px;
  margin: 0;
  flex: none;
  accent-color: var(--c-primary);
}

/* one-time code */
input.input--code {
  min-height: 64px;
  padding: 0 8px;
  font-size: 28px;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.45em;
  text-indent: 0.45em;           /* balances the trailing letter-spacing */
  font-variant-numeric: tabular-nums;
}
input.input--code::placeholder { color: #cfc8c2; }

/* input + trailing icon button (show/hide) */
.input-group { position: relative; display: block; }
.input-group > input { padding-right: 52px; }
.input-group__btn {
  position: absolute;
  top: 2px; right: 2px;
  width: var(--tap); height: var(--tap);
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--c-muted);
}
.input-group__btn:hover { background: var(--c-surface-3); color: var(--c-text); }
.input-group__btn svg { width: 20px; height: 20px; }

/* radio / checkbox tiles */
.choices { display: flex; flex-wrap: wrap; gap: var(--s-8); }
.choice {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 140px;
  min-height: var(--control-h);
  padding: 0 14px;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-control);
  background: var(--c-surface);
  color: var(--c-text-2);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--dur), background-color var(--dur), box-shadow var(--dur);
}
.choice:hover { border-color: var(--c-border-hover); }
.choice:has(input:checked) {
  border-color: var(--c-primary);
  background: var(--c-primary-soft);
  color: var(--c-primary-hover);
  box-shadow: inset 0 0 0 1px var(--c-primary);
}
.choice:has(input:focus-visible) { box-shadow: var(--focus-ring-strong); }
.choice input:focus-visible { box-shadow: none; }

/* switch (a checkbox with role=switch inside a label) */
.switch {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-16);
  min-height: 64px;
  padding: var(--s-12) var(--s-16);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-control);
  background: var(--c-surface);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color var(--dur), background-color var(--dur);
}
.switch:hover { border-color: var(--c-border-strong); }
.switch__input {
  position: absolute;
  width: 1px; height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}
.switch__text { flex: 1 1 auto; min-width: 0; }
.switch__label { display: block; font-size: 16px; font-weight: 600; color: var(--c-text); }
.switch__hint { display: block; margin-top: 2px; font-size: 14px; color: var(--c-muted); }
.switch__track {
  position: relative;
  width: 50px; height: 30px;
  flex: none;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-pill);
  background: #e7e3df;
  transition: background-color var(--dur), border-color var(--dur), box-shadow var(--dur);
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(28 25 23 / 0.35);
  transition: transform var(--dur) var(--ease);
}
.switch__input:checked ~ .switch__track { border-color: var(--c-primary); background: var(--c-primary); }
.switch__input:checked ~ .switch__track::after { transform: translateX(20px); }
.switch__input:focus-visible ~ .switch__track { box-shadow: var(--focus-ring-strong); }
.switch__input:disabled ~ .switch__track { opacity: 0.5; }
.switch:has(.switch__input:checked) { border-color: var(--c-primary-tint); background: var(--c-primary-soft); }

.toggle-card {
  overflow: hidden;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-control);
  background: var(--c-surface);
}
.toggle-card + .toggle-card { margin-top: var(--s-12); }
.toggle-card > .switch { border: 0; border-radius: 0; }
.toggle-card:has(.switch__input:checked) { border-color: var(--c-primary-tint); }
.toggle-card__body {
  padding: var(--s-16);
  border-top: 1px solid var(--c-primary-tint);
  background: var(--c-surface);
}

/* collapsed summary row with an action ("Test Client · SSN •••-••-2222 · 2025   Edit") */
.summary {
  display: flex;
  align-items: center;
  gap: var(--s-12);
  padding: var(--s-12) var(--s-12) var(--s-12) var(--s-16);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-control);
  background: var(--c-surface-2);
}
.summary__text { flex: 1 1 auto; min-width: 0; font-size: 15px; color: var(--c-text-2); overflow-wrap: anywhere; }
.summary__text strong { color: var(--c-text); }
.summary__action { flex: none; }

/* key / value list */
.kv {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--s-8) var(--s-16);
  margin: 0;
  font-size: 15px;
}
.kv dt { color: var(--c-muted); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

/* <details class="disclosure"><summary>Details</summary><div class="disclosure__body">… */
.disclosure {
  border: 1px solid var(--c-border);
  border-radius: var(--radius-control);
  background: var(--c-surface);
}
.disclosure > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-8);
  min-height: var(--tap);
  padding: 10px var(--s-16);
  border-radius: var(--radius-control);
  color: var(--c-text-2);
  font-size: 15px;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::after {
  content: "";
  width: 20px; height: 20px;
  flex: none;
  background: currentColor;
  -webkit-mask: var(--icon-chevron) center / contain no-repeat;
  mask: var(--icon-chevron) center / contain no-repeat;
  transition: transform var(--dur) var(--ease);
}
.disclosure[open] > summary::after { transform: rotate(180deg); }
.disclosure__body { padding: 0 var(--s-16) var(--s-16); }

/* ------------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-8);
  min-height: var(--control-h);
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--c-text-2);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  transition: background-color var(--dur), border-color var(--dur), color var(--dur),
    box-shadow var(--dur), transform var(--dur);
}
.btn svg { width: 20px; height: 20px; }
.btn:active:not(:disabled):not(.is-loading) { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { cursor: not-allowed; }

.btn-primary {
  border-color: var(--c-primary);
  background: var(--c-primary);
  color: #fff;
  box-shadow: 0 1px 2px rgb(127 29 29 / 0.3);
}
.btn-primary:hover:not(:disabled) { border-color: var(--c-primary-hover); background: var(--c-primary-hover); color: #fff; }
.btn-primary:active:not(:disabled) { background: var(--c-primary-active); }
/* A disabled primary still reads as a (pale maroon) button: 7.6:1 text contrast. */
.btn-primary:disabled, .btn-primary[aria-disabled="true"] {
  border-color: #dcc3c3;
  background: #ecdcdc;
  color: #7a2323;
  box-shadow: none;
}

.btn-secondary {
  border-color: var(--c-border-strong);
  background: var(--c-surface);
  color: var(--c-text);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--c-border-hover); background: var(--c-surface-2); color: var(--c-text); }
.btn-secondary:active:not(:disabled) { background: var(--c-surface-3); }
.btn-secondary:disabled { border-color: #c9c3bd; background: var(--c-surface-2); color: var(--c-muted); }

.btn-ghost { background: transparent; color: var(--c-text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--c-surface-3); color: var(--c-text); }
.btn-ghost:disabled { color: var(--c-muted); }

.btn-sm { min-height: var(--control-h-sm); padding: 0 14px; gap: 6px; font-size: 14px; }
.btn-sm svg { width: 18px; height: 18px; }
.btn-lg { min-height: 56px; padding: 0 24px; border-radius: 12px; font-size: 17px; }
.btn-block { display: flex; width: 100%; }
/* Touch screens (phones, tablets): small buttons still get a 44px target. */
@media (pointer: coarse) { .btn-sm { min-height: var(--tap); } }

.btn-icon {
  display: inline-grid;
  place-items: center;
  width: var(--tap); height: var(--tap);
  min-height: var(--tap);
  flex: none;
  padding: 0;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--c-text-2);
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur), color var(--dur);
}
.btn-icon svg { width: 20px; height: 20px; }
.btn-icon:hover:not(:disabled) { background: var(--c-surface-3); color: var(--c-text); }
.btn-icon--danger:hover:not(:disabled) { background: var(--c-danger-bg); color: var(--c-danger-text); }
.btn-icon:disabled { color: var(--c-placeholder); cursor: not-allowed; }

.btn-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 0 4px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--c-primary);
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.btn-link svg { width: 18px; height: 18px; }
.btn-link:hover:not(:disabled) { color: var(--c-primary-hover); }
.btn-link:disabled { color: var(--c-muted); text-decoration: none; cursor: default; }

/* Loading: add .is-loading (plus disabled) to any .btn; its first svg becomes a spinner. */
.btn.is-loading { cursor: progress; pointer-events: none; }
.btn.is-loading > svg:first-child { display: none; }
.btn.is-loading::before {
  content: "";
  width: 18px; height: 18px;
  flex: none;
  border: 2.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: zz-spin 0.7s linear infinite;
}
.btn-primary.is-loading, .btn-primary.is-loading:disabled {
  border-color: var(--c-primary);
  background: var(--c-primary);
  color: #fff;
}
.btn-sm.is-loading::before { width: 15px; height: 15px; border-width: 2px; }

/* Large picker tiles ("Take a photo" / "Choose files"): a <button>, or a <label> that
   wraps a visually-hidden file input (the ring then follows the input's focus). */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--s-12); }
.tile-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 116px;
  padding: var(--s-16);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-card);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur), border-color var(--dur), box-shadow var(--dur), transform var(--dur);
}
.tile-btn svg { width: 28px; height: 28px; margin-bottom: 2px; color: var(--c-primary); }
.tile-btn__sub { font-size: 14px; font-weight: 400; color: var(--c-muted); }
.tile-btn:hover:not(:disabled) { border-color: var(--c-primary); background: var(--c-primary-soft); }
.tile-btn:active:not(:disabled) { transform: translateY(1px); }
.tile-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.tile-btn:has(:focus-visible) { box-shadow: var(--focus-ring-strong); }
.tile-btn--primary { border-color: var(--c-primary); background: var(--c-primary); color: #fff; }
.tile-btn--primary svg { color: #fff; }
.tile-btn--primary .tile-btn__sub { color: rgb(255 255 255 / 0.85); }
.tile-btn--primary:hover:not(:disabled) { border-color: var(--c-primary-hover); background: var(--c-primary-hover); }

/* -------------------------------------------------------------------- dropzone + files */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: var(--s-24) var(--s-16);
  border: 2px dashed var(--c-border-strong);
  border-radius: var(--radius-card);
  background: var(--c-surface-2);
  color: var(--c-muted);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--dur), background-color var(--dur);
}
.dropzone svg { width: 28px; height: 28px; margin-bottom: 4px; color: var(--c-primary); }
.dropzone__title { font-size: 16px; font-weight: 600; color: var(--c-text); }
.dropzone__sub { font-size: 14px; }
.dropzone:hover, .dropzone.is-dragover { border-color: var(--c-primary); background: var(--c-primary-soft); }
.dropzone.is-dragover { border-style: solid; }

.file-list { display: flex; flex-direction: column; gap: var(--s-8); margin: var(--s-16) 0 0; padding: 0; list-style: none; }
.file-list:empty { display: none; }
.file-row {
  display: flex;
  align-items: center;
  gap: var(--s-12);
  min-height: 64px;
  padding: var(--s-8);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-control);
  background: var(--c-surface);
}
.file-row__thumb {
  width: 48px; height: 48px;
  flex: none;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: var(--c-surface-3);
  color: var(--c-text-2);
}
.file-row__thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-row__thumb svg { width: 22px; height: 22px; }
.file-row__thumb--pdf { background: var(--c-primary-soft); color: var(--c-primary); }
.file-row__thumb--image { background: var(--c-info-bg); color: var(--c-info-text); }
.file-row__main { flex: 1 1 auto; min-width: 0; }
.file-row__name {
  display: block;
  overflow: hidden;
  color: var(--c-text);
  font-size: 15px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-row__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px var(--s-8);
  margin-top: 2px;
  color: var(--c-muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.file-row.is-rejected { border-color: var(--c-danger-border); background: #fffafa; }
.file-row.is-rejected .file-row__thumb { background: var(--c-danger-bg); color: var(--c-danger-text); }
.file-row.is-rejected .file-row__name { color: var(--c-text-2); }

/* ------------------------------------------------------------------ alerts + messages */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--s-12);
  padding: 14px var(--s-16);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-control);
  background: var(--c-surface-2);
  color: var(--c-text-2);
  font-size: 15px;
  line-height: 1.5;
}
.alert::before {
  content: "";
  width: 20px; height: 20px;
  margin-top: 1px;
  flex: none;
  background: currentColor;
  -webkit-mask: var(--icon-info) center / contain no-repeat;
  mask: var(--icon-info) center / contain no-repeat;
}
.alert--plain::before { display: none; }
.alert__body { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.alert__body > * + * { margin-top: 4px; }
.alert__title { display: block; color: inherit; font-weight: 600; }
.alert__actions { display: flex; flex-wrap: wrap; gap: var(--s-8); margin-top: var(--s-12) !important; }
.alert--info    { border-color: var(--c-info-border);    background: var(--c-info-bg);    color: var(--c-info-text); }
.alert--success { border-color: var(--c-success-border); background: var(--c-success-bg); color: var(--c-success-text); }
.alert--warning { border-color: var(--c-warning-border); background: var(--c-warning-bg); color: var(--c-warning-text); }
.alert--danger  { border-color: var(--c-danger-border);  background: var(--c-danger-bg);  color: var(--c-danger-text); }
.alert--success::before { -webkit-mask-image: var(--icon-check); mask-image: var(--icon-check); }
.alert--warning::before { -webkit-mask-image: var(--icon-warning); mask-image: var(--icon-warning); }
.alert--danger::before  { -webkit-mask-image: var(--icon-error); mask-image: var(--icon-error); }
.alert + .alert { margin-top: var(--s-12); }

/* One-line status (give it role=status / aria-live). Keep the element in the DOM while
   empty so screen readers announce what is written into it later. */
.inline-msg {
  display: flex;
  align-items: flex-start;
  gap: var(--s-8);
  margin: 0;
  color: var(--c-text-2);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.45;
}
.inline-msg:not(:empty) { margin-top: var(--s-12); }
.inline-msg:not(:empty)::before {
  content: "";
  width: 18px; height: 18px;
  margin-top: 2px;
  flex: none;
  background: currentColor;
  -webkit-mask: var(--icon-info) center / contain no-repeat;
  mask: var(--icon-info) center / contain no-repeat;
}
.inline-msg--muted { color: var(--c-muted); }
.inline-msg--muted:not(:empty)::before { display: none; }
.inline-msg--success { color: var(--c-success-text); }
.inline-msg--success:not(:empty)::before { -webkit-mask-image: var(--icon-check); mask-image: var(--icon-check); }
.inline-msg--danger { color: var(--c-danger-text); }
.inline-msg--danger:not(:empty)::before { -webkit-mask-image: var(--icon-error); mask-image: var(--icon-error); }
.inline-msg--busy:not(:empty)::before {
  width: 16px; height: 16px;
  margin-top: 3px;
  border: 2px solid var(--c-primary-tint);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  background: transparent;
  -webkit-mask: none;
  mask: none;
  animation: zz-spin 0.7s linear infinite;
}

/* ------------------------------------------------------------------- chips + status */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 2px 10px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-pill);
  background: var(--c-surface-3);
  color: var(--c-text-2);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  white-space: nowrap;
}
.chip svg { width: 14px; height: 14px; }
.chip--brand   { border-color: var(--c-primary-tint);   background: var(--c-primary-soft); color: var(--c-primary-hover); }
.chip--success { border-color: var(--c-success-border); background: var(--c-success-bg);   color: var(--c-success-text); }
.chip--warning { border-color: var(--c-warning-border); background: var(--c-warning-bg);   color: var(--c-warning-text); }
.chip--danger  { border-color: var(--c-danger-border);  background: var(--c-danger-bg);    color: var(--c-danger-text); }
.chip--info    { border-color: var(--c-info-border);    background: var(--c-info-bg);      color: var(--c-info-text); }
.chip--neutral { border-color: var(--c-border);         background: var(--c-surface-3);    color: var(--c-muted); }

.status {
  --dot: var(--c-placeholder);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 11px 3px 9px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-pill);
  background: var(--c-surface-3);
  color: var(--c-text-2);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.status::before {
  content: "";
  width: 8px; height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--dot);
}
.status--processing { --dot: var(--c-warning); border-color: var(--c-warning-border); background: var(--c-warning-bg); color: var(--c-warning-text); }
.status--processing::before { animation: zz-pulse 1.6s ease-in-out infinite; }
.status--ready, .status--received { --dot: var(--c-success); border-color: var(--c-success-border); background: var(--c-success-bg); color: var(--c-success-text); }
.status--attention, .status--failed { --dot: var(--c-danger); border-color: var(--c-danger-border); background: var(--c-danger-bg); color: var(--c-danger-text); }
.status--imported { --dot: var(--c-slate); border-color: var(--c-slate-border); background: var(--c-slate-bg); color: var(--c-slate-text); }
.status--neutral { --dot: var(--c-placeholder); }

/* ------------------------------------------------------------- progress + spinner */
.progress {
  position: relative;
  height: 8px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--c-surface-3);
  box-shadow: inset 0 0 0 1px rgb(28 25 23 / 0.05);
}
.progress__bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--c-primary);
  transition: width 0.3s var(--ease);
}
.progress--success .progress__bar { background: var(--c-success); }
.progress--warning .progress__bar { background: var(--c-warning); }
.progress--danger .progress__bar { background: var(--c-danger); }
.progress--indeterminate .progress__bar { width: 35% !important; animation: zz-indeterminate 1.3s ease-in-out infinite; }
.progress-label {
  display: flex;
  justify-content: space-between;
  gap: var(--s-12);
  margin-top: var(--s-8);
  color: var(--c-muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.progress-label strong { color: var(--c-text); }

.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  flex: none;
  border: 2.5px solid var(--c-primary-tint);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: zz-spin 0.7s linear infinite;
}
.spinner--sm { width: 16px; height: 16px; border-width: 2px; }
.spinner--lg { width: 32px; height: 32px; border-width: 3px; }
.spinner--light { border-color: rgb(255 255 255 / 0.35); border-top-color: #fff; }

/* -------------------------------------------------------------- hero icon, empty */
.hero-icon {
  width: 72px; height: 72px;
  margin: 0 auto var(--s-16);
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--c-surface-3);
  color: var(--c-text-2);
}
.hero-icon svg { width: 36px; height: 36px; }
.hero-icon--sm { width: 56px; height: 56px; }
.hero-icon--sm svg { width: 26px; height: 26px; }
.hero-icon--success { background: var(--c-success-bg); color: var(--c-success); box-shadow: 0 0 0 8px rgb(240 253 244 / 0.6); }
.hero-icon--danger { background: var(--c-danger-bg); color: var(--c-danger); }
.hero-icon--brand { background: var(--c-primary-soft); color: var(--c-primary); }
.hero-icon--info { background: var(--c-info-bg); color: var(--c-info); }

.empty { padding: var(--s-40) var(--s-16); color: var(--c-muted); text-align: center; }
.empty__icon {
  width: 56px; height: 56px;
  margin: 0 auto var(--s-12);
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--c-surface-3);
  color: var(--c-text-2);
}
.empty__icon svg { width: 26px; height: 26px; }
.empty__title { margin: 0; color: var(--c-text); font-size: 17px; font-weight: 600; }
.empty__text { max-width: 38ch; margin: var(--s-4) auto 0; font-size: 15px; }
.empty .btn { margin-top: var(--s-16); }

/* ----------------------------------------------------------------------- steps */
.steps { margin: 0; padding: 0; list-style: none; }
.step {
  display: flex;
  gap: var(--s-16);
  padding: var(--s-16) 0;
  border-bottom: 1px solid var(--c-border);
}
.step:first-child { padding-top: 0; }
.step:last-child { padding-bottom: 0; border-bottom: 0; }
.step__num {
  width: 32px; height: 32px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--c-border-strong);
  border-radius: 50%;
  background: var(--c-surface);
  color: var(--c-text-2);
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.step__num svg { width: 18px; height: 18px; }
.step.is-current .step__num { border-color: var(--c-primary); background: var(--c-primary); color: #fff; }
.step.is-done .step__num { border-color: var(--c-success); background: var(--c-success); color: #fff; }
.step.is-error .step__num { border-color: var(--c-danger); background: var(--c-danger-bg); color: var(--c-danger-text); }
.step__body { flex: 1 1 auto; min-width: 0; padding-top: 4px; }
.step__title { margin: 0; font-size: 16px; font-weight: 600; }
.step__text { margin-top: 2px; color: var(--c-muted); font-size: 15px; }
.step__body > .alert, .step__body > .btn, .step__body > .cluster, .step__body > .inline-msg:not(:empty) { margin-top: var(--s-12); }

/* ---------------------------------------------------------------------- dialog */
dialog.dialog {
  width: min(640px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100dvh - 48px);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 16px;
  background: var(--c-surface);
  color: var(--c-text);
  box-shadow: var(--shadow-overlay);
}
dialog.dialog[open] { display: flex; flex-direction: column; animation: zz-dialog-in 0.18s var(--ease); }
dialog.dialog::backdrop { background: rgb(28 25 23 / 0.5); }
dialog.dialog.dialog--wide { width: min(880px, calc(100vw - 32px)); }
.dialog__header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-12);
  padding: var(--s-12) var(--s-12) var(--s-12) var(--s-24);
  border-bottom: 1px solid var(--c-border);
}
.dialog__title { margin: 0; font-size: 18px; font-weight: 600; }
.dialog__body { flex: 1 1 auto; padding: var(--s-24); overflow-y: auto; overscroll-behavior: contain; }
.dialog__footer {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--s-8);
  padding: var(--s-16) var(--s-24) calc(var(--s-16) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--c-border);
}
html:has(dialog.dialog[open]) { overflow: hidden; }

/* ---------------------------------------------------------------- sticky action bar */
.action-bar {
  position: sticky;
  bottom: 0;
  z-index: 30;
  margin: var(--s-24) calc(-1 * var(--s-16)) calc(-1 * var(--s-48));
  padding: var(--s-12) var(--s-16) calc(var(--s-12) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--c-border);
  background: rgb(255 255 255 / 0.96);
  box-shadow: 0 -8px 24px -12px rgb(28 25 23 / 0.25);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
}
.action-bar__inner { display: flex; flex-direction: column; gap: var(--s-8); max-width: var(--page-max); margin: 0 auto; }
.action-bar__inner > .btn { width: 100%; }
.action-bar__reason { color: var(--c-text-2); font-size: 14px; font-weight: 500; text-align: center; }
.action-bar__note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--c-muted);
  font-size: 13px;
  text-align: center;
}
.action-bar__note::before {
  content: "";
  width: 14px; height: 14px;
  flex: none;
  background: var(--c-success);
  -webkit-mask: var(--icon-lock) center / contain no-repeat;
  mask: var(--icon-lock) center / contain no-repeat;
}

/* ------------------------------------------------------------ stats, toolbar, table */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-12); margin-bottom: var(--s-16); }
.stat {
  --dot: var(--c-placeholder);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
  padding: 14px var(--s-16);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-card);
  background: var(--c-surface);
  box-shadow: var(--shadow-card);
  color: var(--c-text);
  font: inherit;
  text-align: left;
  transition: border-color var(--dur), background-color var(--dur), box-shadow var(--dur);
}
button.stat { cursor: pointer; }
button.stat:hover { border-color: var(--c-border-strong); }
.stat[aria-pressed="true"] { border-color: var(--c-primary); background: var(--c-primary-soft); box-shadow: inset 0 0 0 1px var(--c-primary); }
.stat__label { display: flex; align-items: flex-start; gap: var(--s-8); color: var(--c-muted); font-size: 14px; font-weight: 600; line-height: 1.4; }
.stat__label::before { content: ""; width: 8px; height: 8px; margin-top: 6px; flex: none; border-radius: 50%; background: var(--dot); }
.stat__value { font-size: 28px; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat--today { --dot: var(--c-primary); }
.stat--processing { --dot: var(--c-warning); }
.stat--ready { --dot: var(--c-success); }
.stat--attention { --dot: var(--c-danger); }
.stat--attention .stat__value { color: var(--c-danger-text); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-12); margin-bottom: var(--s-16); }
.toolbar__meta { color: var(--c-muted); font-size: 14px; white-space: nowrap; }
.search { position: relative; flex: 1 1 280px; min-width: 0; }
.search::before {
  content: "";
  position: absolute;
  top: 50%; left: 14px;
  width: 20px; height: 20px;
  margin-top: -10px;
  background: var(--c-muted);
  -webkit-mask: var(--icon-search) center / contain no-repeat;
  mask: var(--icon-search) center / contain no-repeat;
  pointer-events: none;
}
.search > input { padding-left: 44px; }

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-card);
  background: var(--c-surface);
  box-shadow: var(--shadow-card);
}
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th {
  padding: 10px var(--s-16);
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface-2);
  color: var(--c-muted);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
.table td {
  padding: 14px var(--s-16);
  border-bottom: 1px solid var(--c-border);
  vertical-align: top;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--c-surface-2); }
.table tr.is-highlighted td { background: var(--c-primary-soft); animation: zz-flash 1.8s var(--ease); }
.table tr.is-highlighted td:first-child { box-shadow: inset 3px 0 0 var(--c-primary); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .cell-sub { display: block; margin-top: 2px; color: var(--c-muted); font-size: 13px; }
.table .cell-actions { text-align: right; white-space: nowrap; }
.table .cell-actions .cluster { justify-content: flex-end; flex-wrap: nowrap; }
.table .chips { margin-top: 6px; }

/* ------------------------------------------------------------------ page: login */
.auth-card { padding: var(--s-32) var(--s-24); }
.auth-card__head { margin-bottom: var(--s-24); text-align: center; }
.auth-card__head h1 { font-size: 22px; }
.auth-card__head p { margin-top: var(--s-8); color: var(--c-muted); text-wrap: balance; }
.auth-card__head p strong { display: inline-block; max-width: 100%; color: var(--c-text); overflow-wrap: anywhere; }
.auth-card form > .btn { margin-top: var(--s-24); }
.auth-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 var(--s-16);
  margin-top: var(--s-16);
  padding-top: var(--s-8);
  border-top: 1px solid var(--c-border);
}
/* 10-21: centered text with the lock inline at its start (was a flex row of icon and left-aligned text):
   a wrapped line never shrinks its box to the longest line, so once the privacy link joined the text the
   block sat left of the card's center on a computer, most of all in Chinese. Centered lines stay centered. */
.trust-note {
  max-width: 44ch;
  margin: var(--s-24) auto 0;
  color: var(--c-muted);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  text-wrap: balance;
}
.trust-note::before {
  content: "";
  display: inline-block;
  width: 16px; height: 16px;
  margin-right: 6px;
  vertical-align: -3px;
  background: var(--c-success);
  -webkit-mask: var(--icon-lock) center / contain no-repeat;
  mask: var(--icon-lock) center / contain no-repeat;
}
/* 2026-10-21: "Continue with Google" under the code form, an "or" rule between them, and the privacy
   policy link at the end of the trust line under the card. */
.auth-or {
  display: flex;
  align-items: center;
  gap: var(--s-12);
  margin: var(--s-24) 0 var(--s-16);
  color: var(--c-muted);
  font-size: 14px;
}
.auth-or::before, .auth-or::after { content: ""; flex: 1; border-top: 1px solid var(--c-border); }
.btn-google svg { width: 18px; height: 18px; }
/* 10-21 (item 3): "Keep me signed in on this device" - a checkbox with its label and a hint under it. */
.check-row { display: flex; align-items: flex-start; gap: 10px; margin-top: var(--s-16); cursor: pointer; }
.check-row input { margin-top: 2px; }
.check-row__text { display: flex; flex-direction: column; gap: 2px; color: var(--c-text-2); font-size: 15px; }
.check-row__hint { color: var(--c-muted); font-size: 13px; }
.trust-note a { color: inherit; text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }
/* The privacy policy page (privacy.html). */
.policy { max-width: 72ch; margin: 0 auto; padding: var(--s-32) var(--s-24); }
.policy h1 { font-size: 24px; }
.policy h2 { margin-top: var(--s-24); font-size: 18px; }
.policy p, .policy ul { margin-top: var(--s-8); }
.policy ul { padding-left: 1.25em; }
.policy li + li { margin-top: var(--s-8); }
.policy__date { color: var(--c-muted); font-size: 14px; }
/* 10-21 (items 4 and 2): the upload page's year card - where the return stands and which forms came in. */
.year-card { display: flex; flex-direction: column; gap: var(--s-8); }
.year-card__title { font-size: 18px; }
.year-card__status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 16px; color: var(--c-text); }
.year-card__dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--c-muted); }
.year-card__dot--received, .year-card__dot--in_preparation { background: #2563eb; }
.year-card__dot--need_documents { background: #d97706; }
.year-card__dot--ready_for_review { background: var(--c-primary); }
.year-card__dot--filed { background: var(--c-success); }
.year-card__when { color: var(--c-muted); font-size: 14px; }
.year-card__line { color: var(--c-text-2); font-size: 15px; }
.year-card__missing { color: var(--c-muted); }

/* Focus ring must win over the variants' own box-shadows (declared last on purpose). */
.btn:focus-visible, .btn-icon:focus-visible, .btn-link:focus-visible, .tile-btn:focus-visible,
.stat:focus-visible, .dropzone:focus-visible, .disclosure > summary:focus-visible,
.input-group__btn:focus-visible, .table-wrap:focus-visible {
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: var(--focus-ring-strong);
}

/* ------------------------------------------------------------------- keyframes */
@keyframes zz-spin { to { transform: rotate(360deg); } }
@keyframes zz-pulse { 50% { opacity: 0.35; } }
@keyframes zz-indeterminate { 0% { transform: translateX(-100%); } 100% { transform: translateX(290%); } }
@keyframes zz-dialog-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes zz-sheet-in { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: none; } }
@keyframes zz-flash { from { background-color: #fde8c8; } }

/* ------------------------------------------------------------------ responsive */
@media (min-width: 600px) {
  .fields--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fields--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .field--span-2 { grid-column: span 2; }
  .page { padding-top: var(--s-32); }
  .page--auth { padding-top: max(var(--s-40), 7vh); }
  .auth-card { padding: var(--s-40) var(--s-32) var(--s-32); }
}
@media (min-width: 700px) {
  .action-bar {
    bottom: var(--s-16);
    margin: var(--s-32) 0 0;
    padding: var(--s-16) var(--s-24);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-overlay);
  }
}
@media (max-width: 599.98px) {
  .card { padding: 20px var(--s-16); }
  .auth-card { padding: var(--s-24) var(--s-16); }
  .app-header__inner { min-height: 64px; padding: 10px var(--s-16); gap: var(--s-8); }
  .brand { gap: 10px; }
  .brand__logo { width: 40px; height: 40px; }
  .brand__name { font-size: 15px; }
  .brand__page { font-size: 13px; }
  .label-collapse {
    position: absolute !important;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
  .btn:has(> .label-collapse) { width: var(--tap); min-height: var(--tap); padding: 0; }
  .app-header__actions { gap: 4px; }
  .section-head__icon { width: 36px; height: 36px; }
  .page-intro h1, .page-intro__title { font-size: 21px; }
  /* Dialogs become bottom sheets on phones. */
  dialog.dialog, dialog.dialog.dialog--wide {
    width: 100vw;
    max-width: 100vw;
    max-height: 92dvh;
    margin: auto 0 0;
    border-radius: 16px 16px 0 0;
  }
  dialog.dialog[open] { animation-name: zz-sheet-in; }
  .dialog__header { padding-left: var(--s-16); }
  .dialog__body { padding: var(--s-16); }
  /* A sheet without a footer: keep the last item clear of the iPhone home indicator. */
  .dialog__body:last-child { padding-bottom: calc(var(--s-24) + env(safe-area-inset-bottom, 0px)); }
  .dialog__footer { padding-left: var(--s-16); padding-right: var(--s-16); }
  .dialog__footer .btn { flex: 1 1 auto; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .kv dd { margin-bottom: var(--s-8); }
  .step { gap: var(--s-12); }
}

/* Very narrow phones: with the language toggle plus two or more header buttons there is no
   room for the firm name, so the logo stands alone (the name stays for screen readers). */
@media (max-width: 439.98px) {
  .app-header:has(.app-header__actions > :nth-child(3)) .brand__text {
    position: absolute !important;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
}

@media (max-width: 699.98px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat__value { font-size: 24px; }
  .page-head { align-items: flex-start; }
  /* Stacked-card tables: <table class="table table--stack"> with td[data-label]. */
  .table-wrap:has(.table--stack), .table-wrap--stack {
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
  .table--stack thead {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
  }
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; width: 100%; }
  .table--stack tr {
    margin-bottom: var(--s-12);
    padding: var(--s-4) 0;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-card);
    background: var(--c-surface);
    box-shadow: var(--shadow-card);
  }
  .table--stack tbody tr:hover td { background: transparent; }
  .table--stack tr.is-highlighted { border-color: var(--c-primary); box-shadow: inset 0 0 0 1px var(--c-primary), var(--shadow-card); }
  .table--stack tr.is-highlighted td { background: transparent; }
  .table--stack tr.is-highlighted td:first-child { box-shadow: none; }
  /* Label floats left, the cell's content (any mix of text, chips, .cell-sub) sits right. */
  .table--stack td {
    display: flow-root;
    padding: var(--s-8) var(--s-16);
    border: 0;
    text-align: right;
    overflow-wrap: anywhere;
  }
  .table--stack td::before {
    content: attr(data-label);
    float: left;
    max-width: 45%;
    margin-right: var(--s-12);
    padding-top: 2px;
    color: var(--c-muted);
    font-size: 13px;
    font-weight: 600;
    text-align: left;
  }
  .table--stack td:not([data-label])::before, .table--stack td[data-label=""]::before { display: none; }
  .table--stack td.cell-primary {
    display: block;
    padding-top: var(--s-12);
    padding-bottom: var(--s-8);
    font-size: 16px;
    font-weight: 600;
    text-align: left;
  }
  .table--stack td.cell-primary::before { display: none; }
  .table--stack td.cell-primary .cell-sub { font-weight: 400; }
  .table--stack td.cell-actions:empty { display: none; }
  .table--stack td.cell-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: var(--s-8);
    margin-top: var(--s-4);
    padding-top: var(--s-12);
    padding-bottom: var(--s-12);
    border-top: 1px solid var(--c-border);
    text-align: left;
    white-space: normal;
  }
  .table--stack td.cell-actions::before { display: none; }
  .table--stack td.cell-actions .cluster { flex-wrap: wrap; justify-content: flex-start; }
  .table--stack .chips { justify-content: flex-end; }
  .table--stack td.cell-primary .chips { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  /* Spinners keep turning (slowly): they are the only sign that something is happening. */
  .spinner, .btn.is-loading::before, .inline-msg--busy:not(:empty)::before,
  .progress--indeterminate .progress__bar {
    animation-duration: 1.6s !important;
    animation-iteration-count: infinite !important;
  }
  .status--processing::before { animation: none !important; }
}

@media (forced-colors: active) {
  .btn, .btn-icon, .chip, .status, .card, .lang-toggle button[aria-pressed="true"], .stat[aria-pressed="true"] {
    border: 1px solid ButtonText;
  }
  .switch__input:checked ~ .switch__track, .progress__bar { background: Highlight; }
}
