/* =====================================================================
   Invoice Reader — Vise Pay design system.
   Tokens + shell + components ported from visepay/frontend/public/assets/
   vise.css so this app reads as a sibling module of Vise Pay. Light + dark
   via BOTH prefers-color-scheme AND :root[data-theme] overrides.
   ===================================================================== */

/* ---------------------------------------------------------------------
   Tokens — light (verbatim from vise.css)
--------------------------------------------------------------------- */
:root {
  color-scheme: light dark;
  --bg: #eef0fb; --surface: #ffffff; --ink: #191d3a; --soft: #6a6f97; --line: #e2e4f3;
  --indigo: #5b4bec; --violet: #8a5cff; --cyan: #10c4d8;
  --field: #f6f7fc; --good: #157a5b; --good-bg: #e4f5ee; --warn: #a15a1a; --warn-bg: #fdf0e6;
  --danger: #c0392b; --danger-bg: #fdecea;
  --grad: linear-gradient(135deg, var(--indigo), var(--violet));
  --shadow: 0 18px 50px #0b1b3a1f;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  --ctrl-h: 2.375rem;   /* 38px consistent control height */
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%236a6f97' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f1a; --surface: #151827; --ink: #eceefb; --soft: #9aa0c4; --line: #262a40;
    --field: #1c2036; --good: #57d0a0; --good-bg: #12291f; --warn: #f0b071; --warn-bg: #2b2013;
    --danger: #ff8a80; --danger-bg: #2a1a1e;
    --shadow: 0 18px 50px #00000055;
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%239aa0c4' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  }
}
:root[data-theme="light"] {
  --bg:#eef0fb; --surface:#fff; --ink:#191d3a; --soft:#6a6f97; --line:#e2e4f3; --field:#f6f7fc;
  --good:#157a5b; --good-bg:#e4f5ee; --warn:#a15a1a; --warn-bg:#fdf0e6; --danger:#c0392b; --danger-bg:#fdecea;
  --shadow: 0 18px 50px #0b1b3a1f;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%236a6f97' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] {
  --bg:#0d0f1a; --surface:#151827; --ink:#eceefb; --soft:#9aa0c4; --line:#262a40; --field:#1c2036;
  --good:#57d0a0; --good-bg:#12291f; --warn:#f0b071; --warn-bg:#2b2013; --danger:#ff8a80; --danger-bg:#2a1a1e;
  --shadow: 0 18px 50px #00000055;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%239aa0c4' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
}

/* ---------------------------------------------------------------------
   Base
--------------------------------------------------------------------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  background-image: radial-gradient(70rem 45rem at 85% -12%, color-mix(in srgb, var(--violet) 12%, transparent), transparent),
                    radial-gradient(55rem 40rem at -12% 108%, color-mix(in srgb, var(--cyan) 9%, transparent), transparent);
}
.mono, .num, code { font-family: var(--mono); font-variant-numeric: tabular-nums; }
a { color: var(--indigo); text-underline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--indigo) 22%, transparent); color: var(--ink); }

h1, h2, h3, h4 { text-wrap: balance; margin: 0; }
h1 { font-size: 1.4rem; font-weight: 800; letter-spacing: -.025em; }
h2 { font-size: 1.05rem; font-weight: 800; letter-spacing: -.02em; }
h3 { font-size: .95rem; font-weight: 800; letter-spacing: -.01em; }

.eyebrow {
  display: block; font-size: .68rem; font-weight: 800; letter-spacing: .12em;
  text-transform: uppercase; color: var(--soft);
}
.hint { color: var(--soft); font-size: .82rem; }

/* ---------------------------------------------------------------------
   App shell — 208px sticky sidebar + main
--------------------------------------------------------------------- */
.app-shell { display: grid; grid-template-columns: 208px 1fr; min-height: 100vh; }
.side {
  border-right: 1px solid var(--line); background: var(--field); padding: .95rem .8rem;
  display: flex; flex-direction: column; gap: .2rem; position: sticky; top: 0; height: 100vh;
}
.side .brand { display: flex; align-items: center; gap: .5rem; padding: .2rem .45rem .55rem; text-decoration: none; color: var(--ink); }
.side .brand .mk {
  width: 1.75rem; height: 1.75rem; border-radius: 8px; background: var(--grad); color: #fff;
  display: grid; place-items: center; flex-shrink: 0;
}
.side .brand .mk svg { display: block; }
.side .brand .bw { min-width: 0; line-height: 1.1; }
.side .brand b { display: block; font-size: .95rem; font-weight: 800; letter-spacing: -.02em; }
.co-eyebrow {
  display: block; font-size: .58rem; font-weight: 800; letter-spacing: .12em;
  text-transform: uppercase; color: var(--soft); margin: .5rem .1rem .28rem;
}
.side .brand .co-eyebrow { margin: .15rem 0 0; }

.nav { display: flex; flex-direction: column; gap: .12rem; }
.nav-item {
  display: flex; align-items: center; gap: .55rem; padding: .45rem .55rem; border-radius: 9px;
  color: var(--soft); text-decoration: none; cursor: pointer;
}
.nav-item:hover { background: color-mix(in srgb, var(--indigo) 7%, transparent); color: var(--ink); }
.nav-item.on { background: color-mix(in srgb, var(--indigo) 12%, transparent); color: var(--indigo); }
.nav-item .ic { width: 1rem; text-align: center; opacity: .85; font-size: .9rem; flex-shrink: 0; display: grid; place-items: center; }
.nav-item .ic svg { display: block; }
.nav-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.nav-label { font-size: .85rem; font-weight: 700; }
.nav-sub { font-size: .68rem; font-weight: 500; color: var(--soft); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.nav-item.on .nav-sub { color: color-mix(in srgb, var(--indigo) 65%, var(--soft)); }
.nav-item .nav-pill { margin-left: auto; flex-shrink: 0; }

.side .foot {
  margin-top: auto; padding: .6rem .6rem 0; border-top: 1px solid var(--line);
  font-size: .74rem; color: var(--soft); display: flex; flex-direction: column; gap: .3rem;
}
.side .foot .foot-label { font-size: .58rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--soft); margin-bottom: .1rem; }
.side .foot a { color: var(--soft); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: .4rem; }
.side .foot a:hover { color: var(--indigo); }
.side .foot a svg { flex-shrink: 0; }

.main { min-width: 0; background: var(--surface); }

/* ---------------------------------------------------------------------
   Page header + container
--------------------------------------------------------------------- */
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; padding: 1.5rem 1.75rem 0;
}
.page-header p.hint { margin: .35rem 0 0; font-size: .9rem; }
.page-header .eyebrow { margin-bottom: .3rem; }

.container { padding: 1.25rem 1.75rem 2.5rem; min-width: 0; }
.container.narrow { max-width: 780px; }
.container.flush { padding: 0; max-width: none; }

/* ---------------------------------------------------------------------
   Buttons — Vise .btn
--------------------------------------------------------------------- */
button { font-family: inherit; }
.btn {
  display: inline-flex; align-items: center; gap: .4rem; border: none; border-radius: 9px;
  padding: .5rem .95rem; font-size: .83rem; font-weight: 700; cursor: pointer; font-family: inherit;
  color: var(--ink); background: var(--field); text-decoration: none;
  transition: filter .12s ease, background .12s ease, border-color .12s ease;
}
.btn.primary { background: var(--grad); color: #fff; box-shadow: 0 6px 18px color-mix(in srgb, var(--indigo) 35%, transparent); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: var(--field); color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: color-mix(in srgb, var(--indigo) 6%, var(--field)); }
.btn.danger { background: var(--danger-bg); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); }
.btn.danger:hover { filter: brightness(.97); }
.btn.sm { padding: .32rem .6rem; font-size: .76rem; }
.btn.big { font-size: .95rem; padding: .65rem 1.4rem; }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; filter: none; pointer-events: none; }

/* icon-only buttons (remove line, remove file) */
.remove-row, .fq-remove {
  border: 0; background: transparent; color: var(--soft); cursor: pointer;
  font-size: 1.1rem; line-height: 1; padding: .15rem .4rem; border-radius: 6px; font-family: inherit;
}
.remove-row:hover, .fq-remove:hover { color: var(--danger); background: var(--danger-bg); }

/* ---------------------------------------------------------------------
   Pills
--------------------------------------------------------------------- */
.pill {
  display: inline-block; border-radius: 99px; padding: .14rem .6rem; font-size: .7rem;
  font-weight: 700; letter-spacing: .02em; white-space: nowrap;
}
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.danger { background: var(--danger-bg); color: var(--danger); }
.pill.neutral { background: var(--field); color: var(--soft); border: 1px solid var(--line); }

/* neutral method chip (extraction method) */
.method-chip {
  display: inline-flex; align-items: center; gap: .35rem; font-family: var(--mono);
  font-size: .72rem; color: var(--soft); background: var(--field);
  border: 1px solid var(--line); border-radius: 99px; padding: .12rem .55rem;
}

/* ---------------------------------------------------------------------
   KPI stat strip
--------------------------------------------------------------------- */
.stat-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; margin-bottom: 1.25rem; }
.stat-tile { background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: .75rem .9rem; min-width: 0; }
.stat-label { font-size: .72rem; color: var(--soft); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.stat-value {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; margin-top: .15rem; color: var(--ink);
}
.stat-value.warn { color: var(--warn); }
.stat-value.small { font-size: 1.02rem; padding-top: .2rem; }

/* ---------------------------------------------------------------------
   Cards / fieldsets / panels
--------------------------------------------------------------------- */
.card, fieldset.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 1.25rem 1.4rem; margin: 0 0 1.25rem; min-width: 0;
}
fieldset.card { border-color: var(--line); }
fieldset.card legend {
  font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em;
  color: var(--soft); padding: 0 .4rem;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .9rem 1.25rem; }
@media (max-width: 860px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------------
   Forms
--------------------------------------------------------------------- */
label {
  display: flex; flex-direction: column; min-width: 0; gap: .3rem;
  font-size: .78rem; font-weight: 600; color: var(--ink); letter-spacing: 0;
}
label .opt { font-weight: 400; color: var(--soft); }

input, select, textarea {
  width: 100%; min-width: 0; box-sizing: border-box; padding: .5rem .6rem; font-size: .9rem; color: var(--ink);
  background: var(--field); border: 1px solid var(--line); border-radius: 9px; outline: none; font-family: inherit;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input:not([type=checkbox]):not([type=radio]):not([type=file]), select { min-height: var(--ctrl-h); }
textarea { resize: vertical; min-height: var(--ctrl-h); }
input:not([type=checkbox]):not([type=radio]):hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--indigo) 32%, var(--line)); }
input:focus, select:focus, textarea:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px color-mix(in srgb, var(--indigo) 20%, transparent); background: var(--surface); }
input:disabled, select:disabled, textarea:disabled { opacity: .55; cursor: not-allowed; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--soft) 65%, transparent); }
input.mono, textarea.mono { font-family: var(--mono); }
/* numeric / code header fields read as data */
input[name*="amount"], input[name*="total"], input[name*="_no"], input[name*="tax_id"],
input[name*="rate"], input[name*="code"], input[name*="date"], input[type="number"] {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}
/* custom chevron — no OS arrow */
select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image: var(--chevron); background-repeat: no-repeat; background-position: right .65rem center;
  background-size: 1rem; padding-right: 2rem; cursor: pointer;
}
select::-ms-expand { display: none; }

/* empty-field flag (JS toggled) */
input.is-empty { border-left: 3px solid var(--warn); }

/* ---------------------------------------------------------------------
   Tables
--------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: 12px; }
table.data { width: 100%; border-collapse: collapse; font-size: .84rem; }
table.data th, table.data td {
  border-bottom: 1px solid var(--line); padding: .55rem .7rem; text-align: left; vertical-align: middle;
}
table.data thead th {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--soft);
  font-weight: 700; background: var(--field); white-space: nowrap;
}
table.data tbody tr:hover { background: color-mix(in srgb, var(--indigo) 5%, transparent); }
table.data td.num, table.data th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.data td.mono, table.data a.mono { font-family: var(--mono); }

table.data input {
  width: 100%; border: 1px solid transparent; background: transparent; color: var(--ink);
  font-size: .8rem; padding: .3rem .4rem; border-radius: 7px; min-height: 2rem; font-family: inherit;
}
table.data input:hover { border-color: var(--line); background: var(--field); }
table.data input:focus { outline: none; border-color: var(--indigo); background: var(--surface); box-shadow: 0 0 0 3px color-mix(in srgb, var(--indigo) 16%, transparent); }

/* Register table (list) */
.register-table a { text-decoration: none; }
.register-table .arrow { color: var(--indigo); font-weight: 700; }
tr.draft-row td:first-child { box-shadow: inset 3px 0 0 var(--warn); }

/* Line-items editor column widths */
#line-items-table { table-layout: fixed; min-width: 1230px; }
#line-items-table td input { font-family: var(--mono); }
#line-items-table td:nth-child(6) input, #line-items-table td:nth-child(14) input { font-family: inherit; }
#line-items-table th:nth-child(1), #line-items-table td:nth-child(1) { width: 74px; }
#line-items-table th:nth-child(2), #line-items-table td:nth-child(2) { width: 64px; }
#line-items-table th:nth-child(3), #line-items-table td:nth-child(3) { width: 104px; }
#line-items-table th:nth-child(4), #line-items-table td:nth-child(4) { width: 52px; }
#line-items-table th:nth-child(5), #line-items-table td:nth-child(5) { width: 130px; }
#line-items-table th:nth-child(6), #line-items-table td:nth-child(6) { width: 200px; }
#line-items-table th:nth-child(7), #line-items-table td:nth-child(7) { width: 64px; }
#line-items-table th:nth-child(8), #line-items-table td:nth-child(8),
#line-items-table th:nth-child(9), #line-items-table td:nth-child(9) { width: 68px; }
#line-items-table th:nth-child(10), #line-items-table td:nth-child(10),
#line-items-table th:nth-child(11), #line-items-table td:nth-child(11),
#line-items-table th:nth-child(12), #line-items-table td:nth-child(12),
#line-items-table th:nth-child(13), #line-items-table td:nth-child(13) { width: 92px; }
#line-items-table th:nth-child(14), #line-items-table td:nth-child(14) { width: 140px; }
#line-items-table th:nth-child(15), #line-items-table td:nth-child(15) { width: 36px; }

/* definition lists (detail) */
dl { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.5rem; margin: 0; }
dl dt { color: var(--soft); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
dl dd { margin: 0; }
dl dd.mono { font-family: var(--mono); }

/* ---------------------------------------------------------------------
   Callouts — Vise-tinted panels
--------------------------------------------------------------------- */
.callout {
  display: flex; gap: .7rem; align-items: flex-start;
  background: color-mix(in srgb, var(--indigo) 9%, var(--surface));
  color: var(--ink); border: 1px solid color-mix(in srgb, var(--indigo) 22%, var(--line));
  border-radius: 12px; padding: .8rem 1rem; font-size: .86rem; margin: 0 0 1.1rem;
}
.callout svg { flex-shrink: 0; margin-top: .15rem; color: var(--indigo); }
.callout a { color: inherit; text-decoration: underline; }
.callout strong { font-family: var(--mono); font-weight: 700; }
.callout.warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.callout.warn svg { color: var(--warn); }
.callout.danger { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.callout.danger svg { color: var(--danger); }

/* ---------------------------------------------------------------------
   Filters / pager / empty state
--------------------------------------------------------------------- */
.filters { display: flex; gap: .6rem; margin-bottom: 1.1rem; align-items: center; flex-wrap: wrap; }
.filters input[type="text"] {
  padding: .5rem .75rem .5rem 2.1rem; min-width: 230px; width: auto;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="none" stroke="%236a6f97" stroke-width="1.6"><circle cx="6" cy="6" r="5"/><line x1="9.6" y1="9.6" x2="13" y2="13"/></svg>');
  background-repeat: no-repeat; background-position: .7rem center;
}
.filters select { width: auto; }
.filters .spacer { flex: 1; }
.row-count { font-family: var(--mono); font-size: .78rem; color: var(--soft); margin: .25rem 0 0; }

.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.1rem; flex-wrap: wrap; }
.pager-info { font-family: var(--mono); font-size: .8rem; color: var(--soft); }

.empty-state { text-align: center; padding: 3.5rem 2rem; color: var(--soft); }
.empty-state svg { color: color-mix(in srgb, var(--soft) 70%, transparent); margin-bottom: 1rem; }
.empty-state p { margin: 0 0 1.1rem; }

/* ---------------------------------------------------------------------
   Review — verification desk split
--------------------------------------------------------------------- */
.verify-layout { display: grid; grid-template-columns: minmax(420px, 55%) 1fr; align-items: start; min-height: 100vh; }
.doc-pane {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  border-right: 1px solid var(--line); background: var(--field);
}
.doc-toolbar {
  display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem;
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.doc-toolbar .eyebrow { margin-right: auto; }
.doc-toolbar a { font-size: .74rem; font-weight: 700; text-decoration: none; }
/* .doc-pane is a <details open>; its summary is the mobile toggle, hidden on desktop */
.doc-pane > summary { display: none; }
.doc-pane > summary::-webkit-details-marker { display: none; }
/* Explicit height: <details> does not honor display:flex reliably, so the
   frame can't rely on flex:1 filling the pane. 42px ≈ toolbar height. */
.doc-frame { flex: 1; min-height: 0; height: calc(100vh - 42px); }
.doc-frame iframe, .doc-frame img { width: 100%; height: 100%; border: 0; display: block; }
.doc-frame img { object-fit: contain; padding: 1rem; }

.verify-form { min-width: 0; padding: 1.25rem 1.5rem 0; max-width: 820px; }
.verify-head { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: .35rem; }
.verify-head .vh-no { font-family: var(--mono); font-size: 1.5rem; font-weight: 800; line-height: 1; color: var(--ink); letter-spacing: -.02em; }
.queue-nav { margin-left: auto; display: flex; gap: .5rem; }
.queue-nav a, .queue-nav span {
  font-size: .76rem; font-weight: 700; padding: .32rem .6rem; border: 1px solid var(--line);
  border-radius: 9px; text-decoration: none; color: var(--ink); background: var(--field);
}
.queue-nav a:hover { background: color-mix(in srgb, var(--indigo) 6%, var(--field)); }
.queue-nav span.disabled { opacity: .4; }

/* checks strip — mini KPI cards */
.checks { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin: 1rem 0 1.25rem; }
.check {
  display: grid; grid-template-columns: 20px 1fr; align-items: center; gap: .1rem .55rem;
  padding: .6rem .75rem; background: var(--field); border: 1px solid var(--line); border-radius: 12px;
}
.check.ok { background: var(--good-bg); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.check.bad { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.check-icon { grid-row: 1 / span 2; width: 20px; text-align: center; font-size: 1rem; line-height: 1; color: color-mix(in srgb, var(--soft) 70%, transparent); }
.check.ok .check-icon { color: var(--good); }
.check.bad .check-icon { color: var(--warn); }
.check-label { font-size: .64rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--soft); }
.check-val { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: .8rem; color: var(--ink); min-height: 1.1em; }

.verify-footer {
  position: sticky; bottom: 0; display: flex; align-items: center; gap: .85rem;
  padding: .85rem 0; margin-top: 1.5rem;
  background: linear-gradient(to top, var(--surface) 65%, transparent);
}
.verify-footer .kbd-hint { margin-left: auto; font-family: var(--mono); font-size: .72rem; color: color-mix(in srgb, var(--soft) 80%, transparent); }

/* collapsible fieldsets (Seller, Signatures) */
details.card > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: .5rem;
  font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; color: var(--soft);
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "▸"; margin-left: auto; color: var(--soft); font-size: .7rem; }
details.card[open] > summary { margin-bottom: 1rem; }
details.card[open] > summary::after { content: "▾"; }

/* ---------------------------------------------------------------------
   Detail — the document sheet (elevated Vise card)
--------------------------------------------------------------------- */
.sheet-actions {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  max-width: 900px; margin: 1.5rem auto 1rem; padding: 0 1rem;
}
.sheet-actions .spacer { flex: 1; }

.sheet {
  position: relative; max-width: 900px; margin: 0 auto 3rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 2.5rem 2.75rem;
}
.sheet table.data th, .sheet table.data td.mono, .sheet table.data td.num { white-space: nowrap; }

.letterhead { display: flex; justify-content: space-between; gap: 2rem; border-bottom: 2px solid var(--ink); padding-bottom: 1rem; margin-bottom: 1.25rem; }
.lh-seller .lh-th { font-weight: 800; font-size: 1.02rem; letter-spacing: -.01em; }
.lh-seller .lh-en { font-size: .82rem; font-weight: 700; color: var(--soft); }
.lh-seller .lh-meta { font-size: .76rem; color: var(--soft); margin-top: .4rem; line-height: 1.55; }
.lh-seller .lh-meta .mono { color: var(--ink); }
.lh-doc { text-align: right; flex-shrink: 0; }
.lh-doc .lh-title { font-weight: 800; font-size: 1.05rem; letter-spacing: -.01em; }
.lh-doc .lh-line { font-size: .76rem; color: var(--soft); margin-top: .35rem; }
.lh-doc .lh-line b { color: var(--ink); font-family: var(--mono); font-weight: 700; }

/* THE STAMP — the app's signature mark */
.stamp {
  position: absolute; top: 1.6rem; right: 2.2rem; transform: rotate(-6deg);
  border: 2.5px solid currentColor; outline: 2.5px solid currentColor; outline-offset: 3px;
  border-radius: 6px; padding: .4rem .9rem .5rem; text-align: center; opacity: .85;
  mix-blend-mode: multiply; pointer-events: none; background: transparent;
}
.stamp .stamp-word { font-weight: 800; text-transform: uppercase; letter-spacing: .14em; font-size: 1.15rem; line-height: 1; }
.stamp .stamp-date { font-family: var(--mono); font-size: .62rem; letter-spacing: .06em; margin-top: .25rem; }
.stamp.confirmed { color: var(--good); }
.stamp.draft { color: var(--warn); }
/* multiply muddies ink on a dark sheet — disable it (dual-mechanism, property not token) */
@media (prefers-color-scheme: dark) { .stamp { mix-blend-mode: normal; } }
:root[data-theme="dark"] .stamp { mix-blend-mode: normal; }
:root[data-theme="light"] .stamp { mix-blend-mode: multiply; }
@media (prefers-reduced-motion: no-preference) { .stamp { animation: stamp-press 240ms ease-out; } }
@keyframes stamp-press {
  from { transform: rotate(-6deg) scale(1.08); opacity: 0; }
  to { transform: rotate(-6deg) scale(1); opacity: .85; }
}

.doc-section { margin: 1.5rem 0; }
.doc-section > h2 {
  font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; color: var(--soft);
  border-bottom: 1px solid var(--line); padding-bottom: .35rem; margin-bottom: .75rem;
}
.doc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem 2rem; }
.doc-grid .fld { display: grid; grid-template-columns: max-content 1fr; gap: 1rem; border-bottom: 1px dotted var(--line); padding: .25rem 0; }
.doc-grid .fld dt { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--soft); }
.doc-grid .fld dd { margin: 0; text-align: right; }
@media (max-width: 620px) { .doc-grid { grid-template-columns: 1fr; } }

.doc-totals { margin-left: auto; width: 100%; max-width: 320px; margin-top: 1.25rem; }
.doc-totals dl { grid-template-columns: 1fr auto; gap: .35rem 1.5rem; }
.doc-totals dt { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--soft); }
.doc-totals dd { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.doc-totals .grand { border-top: 2px solid var(--ink); margin-top: .5rem; padding-top: .5rem; }
.doc-totals .grand dt, .doc-totals .grand dd { font-size: 1.15rem; font-weight: 800; color: var(--ink); }
.words-line { font-size: .78rem; color: var(--soft); font-style: italic; margin-top: .5rem; text-align: right; }

.sig-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-top: .75rem; }
.sig-box { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: .6rem .75rem .7rem; min-height: 66px; display: flex; flex-direction: column; justify-content: space-between; }
.sig-box .sig-label { font-size: .62rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--soft); }
.sig-box .sig-val { font-size: .9rem; margin-top: .6rem; }
.sig-grid .sig-box:nth-child(3n) { border-right: 0; }
.sig-grid .sig-box:nth-last-child(-n+3) { border-bottom: 0; }
@media (max-width: 620px) {
  .sig-grid { grid-template-columns: 1fr 1fr; }
  .sig-grid .sig-box { border-right: 1px solid var(--line); }
  .sig-grid .sig-box:nth-child(2n) { border-right: 0; }
  .sig-grid .sig-box:nth-child(3n) { border-right: 1px solid var(--line); }
}
.memo-line { margin-top: 1rem; font-size: .86rem; }
.memo-line .eyebrow { display: block; margin-bottom: .25rem; }

/* ---------------------------------------------------------------------
   Upload — intake dropzone
--------------------------------------------------------------------- */
.dropzone {
  border: 1.5px dashed var(--line); border-radius: 14px; background: var(--field);
  padding: 3rem 2rem; text-align: center; cursor: pointer; display: block;
  transition: border-color .15s ease, background-color .15s ease;
}
.dropzone.drag-over { border-color: var(--indigo); background: color-mix(in srgb, var(--indigo) 8%, var(--field)); }
.dropzone-icon { color: color-mix(in srgb, var(--soft) 75%, transparent); margin-bottom: .75rem; }
.dropzone strong { display: block; font-size: .95rem; font-weight: 800; letter-spacing: -.01em; margin-bottom: .25rem; color: var(--ink); }
.dropzone .hint { color: var(--soft); font-size: .85rem; margin: .4rem 0 1.1rem; }
.dropzone input[type="file"] { display: none; }
.file-types { display: flex; gap: .4rem; justify-content: center; margin-top: 1rem; }
.file-types span { font-family: var(--mono); font-size: .7rem; color: var(--soft); border: 1px solid var(--line); border-radius: 99px; padding: .15rem .55rem; }

.file-queue { list-style: none; margin: 1.25rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.file-queue li {
  display: flex; align-items: center; gap: .75rem; padding: .55rem .75rem;
  border: 1px solid var(--line); border-radius: 9px; background: var(--field); font-size: .86rem;
}
.file-queue li.error { border-color: color-mix(in srgb, var(--danger) 40%, transparent); color: var(--danger); background: var(--danger-bg); }
.file-queue .fq-name { font-family: var(--mono); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-queue .fq-size { margin-left: auto; font-family: var(--mono); font-size: .78rem; color: var(--soft); }
.file-queue li.error .fq-size, .file-queue li.error .fq-remove { color: inherit; }

/* ---------------------------------------------------------------------
   Focus + reduced motion
--------------------------------------------------------------------- */
a:focus-visible, .btn:focus-visible, .nav-item:focus-visible, button:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--indigo); outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------------------------------------------------------------------
   Responsive
--------------------------------------------------------------------- */
@media (max-width: 1000px) {
  .verify-layout { grid-template-columns: 1fr; min-height: 0; }
  .doc-pane { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .doc-pane > summary {
    display: block; cursor: pointer; list-style: none; padding: .85rem 1.5rem;
    font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; color: var(--soft);
  }
  .doc-pane:not([open]) .doc-toolbar, .doc-pane:not([open]) .doc-frame { display: none; }
  .doc-pane .doc-frame { height: 68vh; }
  .verify-form { max-width: none; }
  .checks { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
}
/* sidebar collapses to a compact top bar */
@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .side {
    position: sticky; top: 0; z-index: 40; height: auto; flex-direction: row; flex-wrap: wrap;
    align-items: center; gap: .4rem 1rem; padding: .55rem 1rem;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .side .brand { padding: 0; }
  .side .brand .co-eyebrow { display: none; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: .3rem; margin-left: auto; }
  .nav-item { padding: .35rem .55rem; }
  .nav-sub { display: none; }
  .side .foot { margin: 0; border: 0; padding: 0; flex-direction: row; gap: .8rem; width: 100%; }
  .side .foot .foot-label { display: none; }
  .page-header, .container { padding-left: 1.1rem; padding-right: 1.1rem; }
  .verify-form { padding-left: 1.1rem; padding-right: 1.1rem; }
  .sheet { padding: 1.75rem 1.25rem; }
  .stamp { right: 1rem; top: 1rem; }
}
@media (max-width: 420px) {
  .stat-strip { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 1.15rem; }
}

/* ---------------------------------------------------------------------
   Print — detail sheet prints as a clean document
--------------------------------------------------------------------- */
@media print {
  .side, .sheet-actions { display: none !important; }
  .app-shell { display: block; }
  .main { background: #fff; }
  .container, .container.flush { padding: 0 !important; }
  body { background: #fff; }
  .sheet { border: 0; box-shadow: none; max-width: none; margin: 0; padding: 0; }
  .stamp { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
