/* SwiftValidate — landing page and product demo.
   Design system: ledger precision. Paper-white surfaces, ink-navy type, hairline rules instead of
   cards, small radii, tabular figures, blue reserved for actions and selection, restrained status
   colours that always pair a glyph with a word. Standalone: doesn't load /assets/styles.css. */

@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter-latin-wght.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---------------- Tokens ---------------- */
:root {
  /* colour */
  --ink: #0d1626;          /* primary text, navigation */
  --ink-2: #2b3648;        /* body text */
  --ink-3: #566174;        /* supporting text */
  --ink-4: #7b8597;        /* placeholders, disabled */
  --paper: #ffffff;
  --canvas: #f5f6f8;       /* app background, alternate bands */
  --sunk: #eef0f3;         /* table heads, wells */
  --rule: #e2e5ea;         /* hairlines */
  --rule-2: #cdd2da;       /* control borders */
  --navy: #0b1a33;         /* brand navy */
  --blue: #2457d6;         /* actions, selection */
  --blue-ink: #1b45b0;
  --blue-wash: #eef3fd;
  --blue-line: #c9d7f6;
  --ok: #0c6b43;   --ok-wash: #ecf6f0;   --ok-line: #bfe0cd;
  --bad: #a3271b;  --bad-wash: #fbefed;  --bad-line: #efc9c3;
  --warn: #8f5308; --warn-wash: #fbf4e6; --warn-line: #ead7b0;
  --nc: #5b6474;   --nc-wash: #f1f2f5;   --nc-line: #d9dde3;
  /* type */
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --t-hero: clamp(2.5rem, 4.6vw, 3.9rem);
  --t-h2: clamp(1.75rem, 2.8vw, 2.4rem);
  --t-lede: 1.1875rem;
  --t-body: 1.0625rem;
  --t-ui: .9375rem;
  --t-sm: .875rem;
  --t-xs: .8125rem;       /* smallest text used anywhere */
  /* space */
  --s1: .25rem; --s2: .5rem; --s3: .75rem; --s4: 1rem; --s5: 1.5rem; --s6: 2rem; --s7: 3rem;
  /* shape */
  --r1: 4px;   /* controls */
  --r2: 6px;   /* panels */
  --r3: 10px;  /* the application window */
  --lift: 0 1px 2px rgb(13 22 38 / .05), 0 18px 48px -24px rgb(13 22 38 / .28);
  --focus: 0 0 0 3px rgb(36 87 214 / .28);
  --page: 1200px;
}

/* ---------------- Base ---------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 4.5rem; }
body { margin: 0; font-family: var(--font); font-size: var(--t-body); line-height: 1.6; color: var(--ink-2); background: var(--paper); font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; color: var(--ink); font-weight: 650; letter-spacing: -.015em; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
a { color: var(--blue-ink); text-underline-offset: 3px; }
img, svg { max-width: 100%; }
code, .mono { font-family: var(--mono); font-size: .92em; letter-spacing: -.01em; }
.num, td.r, .r { font-variant-numeric: tabular-nums; }
.r { text-align: right; }
.muted { color: var(--ink-3); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 1rem; top: -4rem; z-index: 400; background: var(--ink); color: #fff; padding: .6rem .9rem; border-radius: var(--r1); }
.skip:focus { top: 1rem; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
h2[tabindex="-1"]:focus, h3[tabindex="-1"]:focus, h4[tabindex="-1"]:focus { outline: none; }
.ico { width: 1em; height: 1em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------- Buttons and controls ---------------- */
.button { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 2.5rem; padding: .5rem 1rem; border: 1px solid transparent; border-radius: var(--r1); font: inherit; font-size: var(--t-ui); font-weight: 600; line-height: 1.2; text-decoration: none; cursor: pointer; transition: background-color .15s, border-color .15s, color .15s; white-space: nowrap; }
.button .ico { width: 1rem; height: 1rem; }
.button-lg { min-height: 3rem; padding: .7rem 1.35rem; font-size: 1rem; }
.button-block { width: 100%; }
.button-primary { background: var(--blue); color: #fff; }
.button-primary:hover { background: var(--blue-ink); }
.button-secondary { background: var(--paper); color: var(--ink); border-color: var(--rule-2); }
.button-secondary:hover { border-color: var(--ink-4); background: var(--canvas); }
.button-danger { background: var(--paper); color: var(--bad); border-color: var(--bad-line); }
.button-danger:hover { background: var(--bad-wash); }
.button:disabled { cursor: not-allowed; opacity: .5; }
.tb { display: inline-flex; align-items: center; gap: .4rem; min-height: 2.25rem; padding: .35rem .7rem; border: 1px solid var(--rule-2); border-radius: var(--r1); background: var(--paper); color: var(--ink); font: inherit; font-size: var(--t-sm); font-weight: 550; cursor: pointer; white-space: nowrap; transition: background-color .15s, border-color .15s; }
.tb .ico { width: .95rem; height: .95rem; color: var(--ink-3); }
.tb:hover:not(:disabled) { background: var(--canvas); border-color: var(--ink-4); }
.tb.is-on { background: var(--blue-wash); border-color: var(--blue-line); color: var(--blue-ink); }
.tb.is-on .ico { color: var(--blue); }
.tb:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem; flex: none; border: 1px solid transparent; border-radius: var(--r1); background: none; color: var(--ink-3); cursor: pointer; }
.icon-btn:hover { background: var(--sunk); color: var(--ink); }
.icon-btn .ico { width: 1rem; height: 1rem; }
.link-btn { display: inline-flex; align-items: center; gap: .3rem; min-height: 2rem; padding: 0; border: 0; background: none; color: var(--blue-ink); font: inherit; font-size: var(--t-sm); font-weight: 550; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link-btn:disabled { opacity: .5; cursor: not-allowed; }
.tag { display: inline-flex; align-items: center; padding: 0 .4rem; border: 1px solid var(--rule); border-radius: 3px; font-size: .75rem; font-weight: 600; color: var(--ink-3); background: var(--paper); line-height: 1.5; white-space: nowrap; }
.tag-edit, .tag-you { color: var(--blue-ink); border-color: var(--blue-line); background: var(--blue-wash); margin-left: .4rem; }

/* Status: glyph + word, restrained colour */
.pill, .st { display: inline-flex; align-items: center; gap: .3rem; padding: .05rem .45rem; border: 1px solid; border-radius: 3px; font-size: var(--t-xs); font-weight: 600; line-height: 1.5; white-space: nowrap; }
.pill .ico { width: .8rem; height: .8rem; stroke-width: 2.6; }
.pill.tone-ok, .st-pass { color: var(--ok); background: var(--ok-wash); border-color: var(--ok-line); }
.pill.tone-bad, .st-exc { color: var(--bad); background: var(--bad-wash); border-color: var(--bad-line); }
.pill.tone-warn, .st-rev { color: var(--warn); background: var(--warn-wash); border-color: var(--warn-line); }
.pill.tone-np, .st-nc { color: var(--nc); background: var(--nc-wash); border-color: var(--nc-line); }
.badge-s { display: inline-flex; align-items: center; gap: .4rem; font-size: var(--t-xs); font-weight: 600; white-space: nowrap; color: var(--ink-2); }
.bdot { width: .5rem; height: .5rem; border-radius: 1px; background: currentColor; flex: none; }
.badge-s.tone-ok .bdot { background: var(--ok); }
.badge-s.tone-warn .bdot { background: #c27a12; }
.badge-s.tone-bad .bdot { background: var(--bad); }
.badge-s.tone-info .bdot { background: var(--blue); animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* ---------------- Navigation ---------------- */
.nav { position: sticky; top: 0; z-index: 100; background: rgb(255 255 255 / .94); backdrop-filter: saturate(180%) blur(8px); border-bottom: 1px solid var(--rule); padding-top: env(safe-area-inset-top, 0px); }
.nav-in { display: flex; align-items: center; gap: var(--s6); max-width: var(--page); margin-inline: auto; min-height: 3.75rem; padding-inline: max(1.25rem, env(safe-area-inset-left)) max(1.25rem, env(safe-area-inset-right)); }
.brand { display: inline-flex; align-items: center; gap: .55rem; color: var(--ink); font-weight: 700; font-size: 1.0625rem; letter-spacing: -.02em; text-decoration: none; min-height: 2.75rem; }
.brand-mark { width: 1.6rem; height: 1.6rem; flex: none; }
.lbl-short { display: none; }
.nav-links { display: flex; gap: var(--s1); margin-right: auto; }
.nav-links a { padding: .5rem .7rem; color: var(--ink-3); font-size: var(--t-ui); font-weight: 500; text-decoration: none; border-radius: var(--r1); }
.nav-links a:hover { color: var(--ink); background: var(--canvas); }
.nav-toggle { display: none; width: 2.75rem; height: 2.75rem; border: 1px solid var(--rule-2); border-radius: var(--r1); background: var(--paper); cursor: pointer; }
.nav-toggle svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
@media (max-width: 820px) {
  .nav-in { gap: var(--s3); }
  .nav-toggle { display: inline-grid; place-items: center; }
  .nav-cta { margin-left: auto; }
  .nav-links { display: none; position: absolute; left: 0; right: 0; top: 100%; flex-direction: column; gap: 0; padding: var(--s2) max(1.25rem, env(safe-area-inset-left)) var(--s4); background: var(--paper); border-bottom: 1px solid var(--rule); box-shadow: 0 12px 24px -16px rgb(13 22 38 / .3); }
  .nav-open .nav-links { display: flex; }
  .nav-links a { padding: .8rem .25rem; border-bottom: 1px solid var(--rule); border-radius: 0; font-size: 1rem; color: var(--ink); }
}
@media (max-width: 400px) {
  .nav-cta { padding-inline: .8rem; white-space: nowrap !important; }
  .lbl-long { display: none; }
  .lbl-short { display: inline; }
  .button { white-space: normal; }   /* long labels wrap rather than overflow on the narrowest phones */
}

/* ---------------- Hero ---------------- */
.hero { border-bottom: 1px solid var(--rule); }
.hero-in { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr); gap: clamp(2rem, 5vw, 4.5rem); align-items: center; max-width: var(--page); margin-inline: auto; padding: clamp(2.75rem, 6vw, 5rem) max(1.25rem, env(safe-area-inset-right)) clamp(2.75rem, 6vw, 4.5rem) max(1.25rem, env(safe-area-inset-left)); }
.hero h1 { font-size: var(--t-hero); line-height: 1.04; font-weight: 680; letter-spacing: -.038em; max-width: 13.5ch; }
.hero-lede { margin-top: var(--s5); max-width: 33rem; font-size: var(--t-lede); line-height: 1.55; color: var(--ink-2); }
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--s3); margin-top: var(--s6); }
.hero-facts { display: grid; grid-template-columns: repeat(3, auto); justify-content: start; gap: var(--s5); margin: var(--s7) 0 0; padding-top: var(--s5); border-top: 1px solid var(--rule); }
.hero-facts dt { font-size: var(--t-xs); color: var(--ink-3); }
.hero-facts dd { margin: .15rem 0 0; font-size: var(--t-sm); font-weight: 600; color: var(--ink); }
.hero-product { margin: 0; min-width: 0; }
.hp-card { border: 1px solid var(--rule-2); border-radius: var(--r3); background: var(--paper); box-shadow: var(--lift); overflow: hidden; font-size: var(--t-sm); }
.hp-bar { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .75rem; padding: .7rem 1rem; background: var(--canvas); border-bottom: 1px solid var(--rule); }
.hp-title { font-weight: 650; color: var(--ink); }
.hp-crumb { color: var(--ink-3); font-size: var(--t-xs); }
.hp-body { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.hp-doc { padding: 1rem; border-right: 1px solid var(--rule); min-width: 0; }
.hp-side { padding: 1rem; min-width: 0; background: #fcfcfd; }
.hp-label { font-size: var(--t-xs); font-weight: 600; color: var(--ink-3); margin-bottom: .4rem; }
.hp-lines { width: 100%; border-collapse: collapse; font-size: var(--t-xs); }
.hp-lines th { text-align: left; font-weight: 600; color: var(--ink-3); padding: .3rem .35rem; border-bottom: 1px solid var(--rule-2); }
.hp-lines th.r { text-align: right; }
.hp-lines td { padding: .45rem .35rem; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.hp-lines code { font-size: .78rem; }
.hp-lines tr.is-bad td { background: var(--bad-wash); }
.hp-lines tr.is-bad td:first-child { box-shadow: inset 2px 0 0 var(--bad); }
.hp-exc { margin-top: .85rem; padding: .75rem .85rem; border: 1px solid var(--bad-line); border-left: 3px solid var(--bad); border-radius: var(--r1); background: var(--paper); }
.hp-exc-title { font-weight: 650; color: var(--ink); }
.hp-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem 1rem; margin: .55rem 0 0; }
.hp-facts dt { font-size: .75rem; color: var(--ink-3); }
.hp-facts dd { margin: 0; font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; }
.hp-src { margin-top: .55rem; font-size: .75rem; color: var(--ink-3); }
.hp-checks { list-style: none; margin: 0; padding: 0; }
.hp-checks li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .4rem 0; border-bottom: 1px solid var(--rule); font-size: var(--t-xs); color: var(--ink-2); }
.hp-checks li:last-child { border-bottom: 0; }
.hp-caption { margin-top: .75rem; font-size: var(--t-sm); color: var(--ink-3); }

/* ---------------- Problem statement ---------------- */
.col { max-width: var(--page); margin-inline: auto; padding-inline: max(1.25rem, env(safe-area-inset-left)) max(1.25rem, env(safe-area-inset-right)); }
.problem { padding-block: clamp(3rem, 6vw, 4.5rem); }
.problem h2 { font-size: var(--t-h2); line-height: 1.12; max-width: 24ch; }
.problem-list { list-style: none; counter-reset: p; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: var(--s6) 0 0; padding: 0; border-top: 1px solid var(--ink); }
.problem-list li { counter-increment: p; padding: var(--s4) var(--s5) 0 0; display: grid; gap: .25rem; align-content: start; }
.problem-list li + li { padding-left: var(--s5); border-left: 1px solid var(--rule); }
.problem-list li::before { content: "0" counter(p); font-size: var(--t-xs); font-weight: 600; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.problem-list b { color: var(--ink); font-size: 1.0625rem; }
.problem-list span { color: var(--ink-3); }
.problem-close { margin-top: var(--s6); max-width: 40rem; font-size: var(--t-lede); color: var(--ink); }

/* ---------------- Demo section and application window ---------------- */
.demo { background: var(--canvas); border-block: 1px solid var(--rule); padding: clamp(2.5rem, 5vw, 4rem) max(1rem, env(safe-area-inset-left)) clamp(3rem, 6vw, 5rem); }
.demo-head { max-width: var(--page); margin: 0 auto var(--s5); padding-inline: max(.25rem, env(safe-area-inset-left)); display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: var(--s3) var(--s7); align-items: end; }
.demo-head h2 { font-size: var(--t-h2); line-height: 1.1; grid-row: span 2; }
.demo-lede { color: var(--ink-2); }
.demo-notice { display: flex; gap: .5rem; align-items: center; font-size: var(--t-sm); color: var(--ink-3); }
.demo-notice svg { width: 1rem; height: 1rem; flex: none; fill: none; stroke: var(--ink-3); stroke-width: 1.4; stroke-linecap: round; }
@media (max-width: 900px) { .demo-head { grid-template-columns: 1fr; } .demo-head h2 { grid-row: auto; } }

.app-frame { position: relative; max-width: 1440px; margin-inline: auto; background: var(--paper); border: 1px solid var(--rule-2); border-radius: var(--r3); box-shadow: var(--lift); overflow: hidden; container: app / inline-size; scroll-margin-top: 4.5rem; min-height: 38rem; }
.app-loading { display: flex; gap: .75rem; align-items: center; justify-content: center; min-height: 36rem; color: var(--ink-3); }
.spinner { width: 1.1rem; height: 1.1rem; border-radius: 50%; border: 2px solid var(--rule-2); border-top-color: var(--blue); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.demo-app.is-full { position: fixed; inset: 0; z-index: 300; max-width: none; border: 0; border-radius: 0; overflow: auto; overscroll-behavior: contain; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
body.demo-full { overflow: hidden; }

.app-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; min-height: 3rem; padding: .45rem .75rem; background: var(--canvas); border-bottom: 1px solid var(--rule); }
.app-mark { display: inline-flex; gap: 5px; }
.app-mark i { width: .6rem; height: .6rem; border-radius: 50%; background: var(--rule-2); }
.app-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-left: auto; }
.stepper { list-style: none; display: flex; align-items: center; margin: 0; padding: 0; }
.stepper li { display: flex; align-items: center; font-size: var(--t-sm); color: var(--ink-3); }
.stepper li + li::before { content: ""; width: 1.25rem; height: 1px; background: var(--rule-2); margin-inline: .6rem; }
.step-num { display: inline-grid; place-items: center; width: 1.35rem; height: 1.35rem; margin-right: .45rem; border: 1px solid var(--rule-2); border-radius: 50%; font-size: .75rem; font-weight: 650; background: var(--paper); }
.step-num .ico { width: .75rem; height: .75rem; stroke-width: 3; }
.stepper li.now { color: var(--ink); font-weight: 600; }
.stepper li.now .step-num { background: var(--ink); border-color: var(--ink); color: #fff; }
.stepper li.done .step-num { border-color: var(--ok); color: var(--ok); }
@container app (max-width: 640px) {
  .stepper li:not(.now) .step-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .stepper li + li::before { width: .6rem; margin-inline: .35rem; }
  .app-mark { display: none; }
  .app-actions { margin-left: 0; width: 100%; }
}
.app-body { min-width: 0; }
.stage.enter { animation: fade .25s ease-out; }
@keyframes fade { from { opacity: 0; } }

/* Shared pane chrome */
.pane-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; min-height: 3rem; padding: .6rem 1rem; border-bottom: 1px solid var(--rule); }
.pane-head h4, .col-head h4, .ov-block h4, .action-bar h4 { font-size: var(--t-ui); font-weight: 650; letter-spacing: -.005em; }
.pane-meta, .col-meta { font-size: var(--t-xs); color: var(--ink-3); }
.empty { padding: var(--s6) var(--s4); text-align: center; color: var(--ink-3); border: 1px dashed var(--rule-2); border-radius: var(--r2); font-size: var(--t-sm); }

/* ---------------- Step 1: document list + invoice ---------------- */
.stage-choose { display: grid; grid-template-columns: minmax(0, 23rem) minmax(0, 1fr); min-height: 38rem; }
.doclist { border-right: 1px solid var(--rule); background: var(--paper); min-width: 0; }
.doclist-cols { display: grid; grid-template-columns: 1fr auto; gap: .75rem; padding: .45rem 1rem; background: var(--sunk); border-bottom: 1px solid var(--rule); font-size: .75rem; font-weight: 600; color: var(--ink-3); }
.lib-list { list-style: none; margin: 0; padding: 0; }
.lib-list li { border-bottom: 1px solid var(--rule); }
.scn { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "doc amt" "text text"; gap: .3rem .75rem; align-items: baseline; width: 100%; padding: .75rem 1rem; border: 0; background: none; font: inherit; text-align: left; color: var(--ink-2); cursor: pointer; transition: background-color .12s; }
.scn:hover { background: var(--canvas); }
.scn.is-on { background: var(--blue-wash); box-shadow: inset 3px 0 0 var(--blue); }
.scn-doc { grid-area: doc; display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .6rem; min-width: 0; }
.scn-text { grid-area: text; display: grid; gap: .1rem; min-width: 0; }
.scn-num { font-family: var(--mono); font-size: var(--t-sm); font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.scn-prov { font-size: var(--t-xs); color: var(--ink-3); }
.scn-name { display: flex; flex-wrap: wrap; align-items: center; margin-top: .15rem; gap: .35rem; font-size: var(--t-sm); font-weight: 600; color: var(--ink); }
.scn-dot { width: .45rem; height: .45rem; border-radius: 1px; flex: none; }
.tone-ok.scn-dot { background: var(--ok); }
.tone-bad.scn-dot { background: var(--bad); }
.tone-warn.scn-dot { background: #c27a12; }
.scn-hint { font-size: var(--t-xs); color: var(--ink-3); }
.scn-amt { grid-area: amt; text-align: right; font-size: var(--t-sm); font-weight: 600; color: var(--ink); }
.doclist-note { padding: .85rem 1rem; font-size: var(--t-xs); color: var(--ink-3); }
.preview-pane { min-width: 0; display: flex; flex-direction: column; background: var(--canvas); }
.pane-toolbar { background: var(--paper); }
.pane-titles { display: grid; min-width: 0; }
.pane-title { font-family: var(--mono); font-size: var(--t-ui); }
.pane-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.edit-tip { margin: .85rem 1rem 0; padding: .6rem .8rem; border-left: 2px solid var(--blue); background: var(--paper); font-size: var(--t-sm); color: var(--ink-2); }
.preview-pane > .doc-scroll { margin: 1rem; }
.pane-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-top: auto; padding: .75rem 1rem; border-top: 1px solid var(--rule); background: var(--paper); font-size: var(--t-sm); color: var(--ink-3); }
@container app (max-width: 900px) {
  .stage-choose { grid-template-columns: 1fr; }
  .doclist { border-right: 0; border-bottom: 1px solid var(--rule); }
}
@container app (max-width: 520px) {
  .doclist-cols { display: none; }
  .pane-foot .button { width: 100%; }
  .preview-pane > .doc-scroll { margin: .6rem; }
}

/* ---------------- Invoice document ---------------- */
.doc-scroll { overflow-x: auto; container: doc / inline-size; }
.invdoc { position: relative; background: var(--paper); border: 1px solid var(--rule-2); border-radius: var(--r1); padding: clamp(1.1rem, 3vw, 2rem); font-size: var(--t-sm); color: var(--ink-2); line-height: 1.5; }
.doc-head { display: flex; justify-content: space-between; gap: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--ink); }
.doc-provider { font-size: 1.0625rem; font-weight: 650; color: var(--ink); }
.doc-small { font-size: var(--t-xs); color: var(--ink-3); }
.doc-title { text-align: right; }
.doc-kind { font-size: var(--t-sm); font-weight: 700; letter-spacing: .14em; color: var(--ink); }
.doc-meta { display: grid; grid-template-columns: auto auto; gap: .15rem .8rem; margin: .4rem 0 0; justify-content: end; font-size: var(--t-xs); }
.doc-meta dt { color: var(--ink-3); }
.doc-meta dd { margin: 0; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; padding: 1rem 0; }
.doc-label { font-size: .75rem; font-weight: 600; color: var(--ink-3); margin-bottom: .15rem; }
.doc-parties p:not(.doc-label):not(.doc-small) { color: var(--ink); font-weight: 550; }
.doc-missing { color: var(--warn); font-style: italic; font-weight: 600; }
.doc-table { width: 100%; border-collapse: collapse; font-size: var(--t-xs); }
.doc-table th { text-align: left; padding: .45rem .5rem; font-weight: 600; color: var(--ink-3); border-top: 1px solid var(--rule-2); border-bottom: 1px solid var(--rule-2); white-space: nowrap; }
.doc-table th.r { text-align: right; }
.doc-table td { padding: .6rem .5rem; border-bottom: 1px solid var(--rule); vertical-align: top; color: var(--ink-2); }
.doc-table td.r { text-align: right; white-space: nowrap; }
.doc-table .nowrap { white-space: nowrap; }
.doc-code { font-family: var(--mono); font-size: .8rem; font-weight: 600; color: var(--ink); }
.doc-desc { margin-top: .1rem; color: var(--ink-2); }
.doc-claim { display: inline-block; margin-left: .3rem; padding: 0 .3rem; border: 1px solid var(--blue-line); border-radius: 3px; color: var(--blue-ink); font-weight: 600; }
.doc-table tr.hl-exception td { background: var(--bad-wash); }
.doc-table tr.hl-missing td, .doc-table tr.hl-review td { background: var(--warn-wash); }
.doc-table tr.hl-exception td:first-child { box-shadow: inset 2px 0 0 var(--bad); }
.doc-table tr.hl-missing td:first-child, .doc-table tr.hl-review td:first-child { box-shadow: inset 2px 0 0 #c27a12; }
.doc-table tr.is-focus td { animation: linepulse 1.4s ease-out 1; }
.doc-table tr.is-focus td:first-child { box-shadow: inset 3px 0 0 var(--blue); }
.doc-table tr.is-focus { outline: 1px solid var(--blue); outline-offset: -1px; }
@keyframes linepulse { 0%, 30% { background: #dfe8fb; } }
.doc-foot { display: grid; grid-template-columns: 1fr auto; gap: 1.5rem; margin-top: 1rem; }
.doc-notes p + p { margin-top: .25rem; }
.doc-totals { display: grid; grid-template-columns: auto auto; gap: .25rem 1.75rem; margin: 0; align-content: start; font-variant-numeric: tabular-nums; font-size: var(--t-sm); }
.doc-totals dt { color: var(--ink-3); }
.doc-totals dd { margin: 0; text-align: right; font-weight: 600; color: var(--ink); }
.doc-totals .doc-grand { padding-top: .35rem; border-top: 1px solid var(--ink); font-size: 1rem; font-weight: 700; color: var(--ink); }
/* Editable fields look like a finance app's inputs */
input.doc-input, select.doc-input { font: inherit; font-size: var(--t-xs); color: var(--ink); background: var(--paper); border: 1px solid var(--rule-2); border-radius: 3px; padding: .3rem .4rem; min-height: 2rem; max-width: 100%; transition: border-color .12s, box-shadow .12s; }
input.doc-input:hover { border-color: var(--ink-4); }
input.doc-input:focus-visible { outline: none; border-color: var(--blue); box-shadow: var(--focus); }
input.doc-input.mono { font-family: var(--mono); font-size: .8rem; }
input.doc-input.r { text-align: right; font-variant-numeric: tabular-nums; }
.doc-editing .doc-table td { vertical-align: middle; }
.w-code { width: 12rem; }
.w-num { width: 8rem; }
.w-qty { width: 4.2rem; }
.w-money { width: 6rem; }
.doc-money { display: inline-flex; align-items: center; gap: .2rem; color: var(--ink-3); }
@container doc (max-width: 540px) {
  .doc-head { flex-direction: column; gap: .75rem; }
  .doc-title { text-align: left; }
  .doc-meta { justify-content: start; }
}
@container doc (max-width: 400px) {
  .doc-parties { grid-template-columns: 1fr; gap: .75rem; }
  .doc-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .doc-table, .doc-table tbody, .doc-table tr { display: block; }
  .doc-table tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .35rem .5rem; padding: .7rem .5rem; border-bottom: 1px solid var(--rule); }
  .doc-editing .doc-table tr { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .doc-editing .doc-table td[data-l="Total"] { grid-column: 1 / -1; }
  .doc-table td { display: block; padding: 0; border: 0; text-align: left !important; }
  .doc-table td:nth-child(1), .doc-table td:nth-child(2) { grid-column: 1 / -1; }
  .doc-table td[data-l]::before, .doc-table td:nth-child(2)::before { display: block; font-size: .75rem; font-weight: 600; color: var(--ink-3); }
  .doc-table td[data-l]::before { content: attr(data-l); }
  .doc-table td:nth-child(2)::before { content: "Support item"; }
  .doc-table tr.hl-exception { background: var(--bad-wash); box-shadow: inset 2px 0 0 var(--bad); }
  .doc-table tr.hl-missing, .doc-table tr.hl-review { background: var(--warn-wash); box-shadow: inset 2px 0 0 #c27a12; }
  .doc-table tr[class*="hl-"] td, .doc-table tr.is-focus td { background: none; box-shadow: none; animation: none; }
  .doc-foot { grid-template-columns: 1fr; }
  input.doc-input.r { text-align: left; }
  .w-code, .w-qty { width: 100%; }
  .w-money { width: calc(100% - .8rem); }
  .doc-money { display: flex; }
}

/* ---------------- Step 2: email client ---------------- */
.stage-email { display: grid; grid-template-columns: minmax(0, 20rem) minmax(0, 1fr); min-height: 34rem; background: var(--canvas); }
.files { border-right: 1px solid var(--rule); background: var(--paper); }
.files-body { padding: 1rem; display: grid; gap: .75rem; }
.files-help { font-size: var(--t-sm); color: var(--ink-3); }
.only-coarse { display: none; }
@media (pointer: coarse) { .only-fine { display: none; } .only-coarse { display: inline; } }
.file-row { display: flex; gap: .5rem; align-items: center; }
.file-row .file-tile { flex: 1; min-width: 0; }
.files-links { display: grid; justify-items: start; }
.file-tile { display: flex; align-items: center; gap: .65rem; padding: .55rem .65rem; border: 1px solid var(--rule-2); border-radius: var(--r1); background: var(--paper); }
.file-tile.draggable { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; transition: border-color .12s, box-shadow .12s; }
.file-tile.draggable:hover { border-color: var(--ink-4); }
.file-tile.is-attached { border-color: var(--ok-line); background: var(--ok-wash); }
.file-tile.is-source { opacity: .4; }
.file-ico { position: relative; display: grid; place-items: center; width: 2rem; height: 2.4rem; flex: none; }
.file-ico .ico { width: 2rem; height: 2.4rem; stroke-width: 1.2; color: var(--ink-4); }
.file-ico span { position: absolute; bottom: .3rem; font-size: .6rem; font-weight: 800; letter-spacing: .02em; background: var(--bad); color: #fff; padding: 0 .2rem; border-radius: 2px; }
.file-text { display: grid; min-width: 0; }
.file-name { font-family: var(--mono); font-size: var(--t-sm); font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-sub { font-size: var(--t-xs); color: var(--ink-3); }
.ghost { position: fixed; z-index: 500; pointer-events: none; margin: 0; border-color: var(--blue); box-shadow: 0 16px 32px -12px rgb(13 22 38 / .4); cursor: grabbing; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; }
@media (max-width: 720px) { .file-tile.draggable { touch-action: manipulation; } }
.mail { position: relative; margin: 1.25rem; min-width: 0; align-self: start; background: var(--paper); border: 1px solid var(--rule-2); border-radius: var(--r2); overflow: hidden; }
.mail-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .6rem 1rem; border-bottom: 1px solid var(--rule); font-size: var(--t-ui); font-weight: 650; color: var(--ink); }
.mail-bar-meta { font-size: var(--t-xs); font-weight: 500; color: var(--ink-3); }
.mail-fields { display: grid; grid-template-columns: 5.5rem 1fr; margin: 0; font-size: var(--t-sm); }
.mail-fields dt, .mail-fields dd { padding: .55rem 1rem; border-bottom: 1px solid var(--rule); margin: 0; }
.mail-fields dt { color: var(--ink-3); }
.mail-fields dd { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; min-width: 0; color: var(--ink); overflow-wrap: anywhere; }
.addr { font-weight: 600; }
.mail-body { padding: 1rem; display: grid; gap: .6rem; font-size: var(--t-ui); color: var(--ink-2); }
.drop { margin: .25rem 1rem 1rem; min-height: 4rem; display: grid; place-items: center; border: 1px dashed var(--rule-2); border-radius: var(--r1); background: var(--canvas); transition: border-color .12s, background-color .12s; }
.drop.is-ready { border-color: var(--blue-line); background: var(--blue-wash); }
.drop.is-over { border-style: solid; border-color: var(--blue); background: #e3ebfc; }
.drop.has-file { border-style: solid; border-color: var(--rule); background: var(--paper); place-items: stretch; padding: .4rem; }
.drop.is-error { border-color: var(--bad); background: var(--bad-wash); }
.drop:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.drop-empty { display: flex; gap: .5rem; align-items: center; padding: .75rem; font-size: var(--t-sm); color: var(--ink-3); }
.attach-chip { display: flex; align-items: center; gap: .35rem; }
.attach-chip.enter { animation: fade .25s ease-out; }
.attach-chip .file-tile { flex: 1; min-width: 0; border-color: var(--ok-line); background: var(--ok-wash); }
.field-err { margin: -.5rem 1rem .75rem; color: var(--bad); font-size: var(--t-sm); font-weight: 600; }
.mail-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; padding: .75rem 1rem; border-top: 1px solid var(--rule); background: var(--canvas); font-size: var(--t-xs); color: var(--ink-3); }
.mail-overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgb(255 255 255 / .86); animation: fade .15s ease-out; }
.send-card { display: grid; justify-items: center; gap: .3rem; min-width: 15rem; padding: 1.25rem 1.5rem; border: 1px solid var(--rule-2); border-radius: var(--r2); background: var(--paper); box-shadow: var(--lift); text-align: center; font-size: var(--t-sm); }
.send-bar { width: 11rem; height: 3px; background: var(--sunk); overflow: hidden; margin-bottom: .4rem; }
.send-bar i { display: block; height: 100%; width: 40%; background: var(--blue); animation: slide 1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
.big-tick { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border: 1px solid var(--ok-line); border-radius: 50%; color: var(--ok); background: var(--ok-wash); }
.big-tick .ico { width: 1.1rem; height: 1.1rem; stroke-width: 3; }
@container app (max-width: 820px) {
  .stage-email { grid-template-columns: 1fr; }
  .files { border-right: 0; border-bottom: 1px solid var(--rule); }
  .mail { margin: .75rem; }
  .mail-actions .button { width: 100%; }
}

/* ---------------- Step 3: SwiftValidate application ---------------- */
.portal { background: var(--paper); }
.p-body { display: grid; grid-template-columns: 13rem minmax(0, 1fr); min-height: 38rem; }
.p-nav { display: flex; flex-direction: column; gap: 1px; padding: .75rem .5rem; background: var(--navy); }
.p-org { display: grid; padding: .35rem .6rem .85rem; margin-bottom: .4rem; border-bottom: 1px solid rgb(255 255 255 / .1); }
.p-org-name { font-size: var(--t-sm); font-weight: 650; color: #fff; }
.p-org-sub { font-size: .75rem; color: #9fb0cc; }
.p-nav-btn { display: flex; align-items: center; gap: .6rem; min-height: 2.4rem; padding: .4rem .6rem; border: 0; border-radius: var(--r1); background: none; color: #c3cee0; font: inherit; font-size: var(--t-sm); font-weight: 500; text-align: left; cursor: pointer; white-space: nowrap; }
.p-nav-btn .ico { width: 1rem; height: 1rem; color: #8c9dba; }
.p-nav-btn:hover { background: rgb(255 255 255 / .06); color: #fff; }
.p-nav-btn.is-on { background: rgb(255 255 255 / .1); color: #fff; font-weight: 600; }
.p-nav-btn.is-on .ico { color: #a9c1f5; }
.p-nav-btn:focus-visible { outline-color: #a9c1f5; }
.count { margin-left: auto; min-width: 1.4rem; padding: 0 .35rem; border-radius: 3px; background: rgb(255 255 255 / .1); color: #dfe6f2; font-size: .75rem; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
.count-bad { background: #6d2a25; color: #fde2de; }
.p-main { min-width: 0; padding: 1.25rem 1.5rem 1.5rem; container: main / inline-size; }
.p-foot { padding: .55rem 1rem; border-top: 1px solid var(--rule); background: var(--canvas); font-size: var(--t-xs); color: var(--ink-3); }
.p-head { margin-bottom: 1.1rem; }
.crumb { font-size: var(--t-xs); color: var(--ink-3); margin-bottom: .15rem; }
.p-head h3, .res-head h3 { font-size: 1.375rem; letter-spacing: -.02em; }
.p-sub { margin-top: .15rem; font-size: var(--t-sm); color: var(--ink-3); }
@container app (max-width: 860px) {
  .p-body { grid-template-columns: 1fr; }
  .p-nav { flex-direction: row; overflow-x: auto; padding: .4rem; gap: .25rem; }
  .p-org { display: none; }
  .p-main { padding: 1rem; }
}

/* Overview: one metrics strip, not a card per number */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--rule); border-radius: var(--r2); overflow: hidden; }
.kpi { display: grid; gap: .3rem; align-content: start; padding: .85rem 1rem; border: 0; border-right: 1px solid var(--rule); background: var(--paper); font: inherit; text-align: left; cursor: pointer; }
.kpi:last-child { border-right: 0; }
.kpi:hover { background: var(--canvas); }
.kpi-label { font-size: var(--t-xs); color: var(--ink-3); }
.kpi-value { font-size: 1.5rem; font-weight: 650; letter-spacing: -.02em; color: var(--ink); }
.kpi.tone-bad .kpi-value { color: var(--bad); }
@container main (max-width: 720px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { border-bottom: 1px solid var(--rule); }
  .kpi:nth-child(2n) { border-right: 0; }
}
.ov-cols { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 1.5rem; margin-top: 1.5rem; }
@container main (max-width: 760px) { .ov-cols { grid-template-columns: 1fr; } }
.ov-block h4 { padding-bottom: .5rem; border-bottom: 1px solid var(--ink); }
.ov-block { min-width: 0; }
.mini-table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
@container main (max-width: 560px) {
  .mini-table td:nth-child(2) { display: none; }      /* provider: shown in the inbox */
  .mini-table .badge-s { white-space: normal; }
}
.mini-table td { padding: .5rem .25rem; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.mini-table .link-btn { font-family: var(--mono); }
.legend-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem 1.25rem; margin: 1.5rem 0 0; padding-top: 1rem; border-top: 1px solid var(--rule); }
.legend-row div { display: grid; gap: .35rem; justify-items: start; }
.legend-row dt, .legend-row dd { margin: 0; }
.legend-row dd { font-size: var(--t-xs); color: var(--ink-3); }
@container main (max-width: 720px) { .legend-row { grid-template-columns: 1fr 1fr; } }
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: grid; grid-template-columns: 8.5rem 1fr; gap: .05rem 1rem; padding: .55rem 0; border-bottom: 1px solid var(--rule); font-size: var(--t-sm); }
.act-time { grid-row: span 2; color: var(--ink-3); font-size: var(--t-xs); font-variant-numeric: tabular-nums; padding-top: .1rem; }
.act-event { font-weight: 600; color: var(--ink); }
.act-detail { color: var(--ink-3); }
.activity li > * { min-width: 0; overflow-wrap: anywhere; }
@container main (max-width: 520px) { .activity li { grid-template-columns: 1fr; } .act-time { grid-row: auto; } }

/* Inbox table */
.q-table-wrap { border: 1px solid var(--rule); border-radius: var(--r2); overflow-x: auto; }
.q-table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.q-table th { text-align: left; padding: .55rem .75rem; background: var(--sunk); border-bottom: 1px solid var(--rule-2); font-size: var(--t-xs); font-weight: 600; color: var(--ink-3); white-space: nowrap; }
.q-table th.r { text-align: right; }
.q-table td { padding: .6rem .75rem; border-bottom: 1px solid var(--rule); vertical-align: middle; color: var(--ink-2); }
.q-table tbody tr:last-child td { border-bottom: 0; }
.q-table tbody tr:hover td { background: #fafbfc; }
.q-table tr.is-open td { background: var(--blue-wash); }
.q-when { white-space: nowrap; color: var(--ink-3); }
.q-open { padding: 0; border: 0; background: none; font-family: var(--mono); font-size: var(--t-sm); font-weight: 600; color: var(--blue-ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; min-height: 2rem; }
.exc-n { font-weight: 600; color: var(--ink-3); }
.exc-n.has { color: var(--bad); }
@container main (max-width: 680px) {
  .q-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .q-table, .q-table tbody, .q-table tr, .q-table td { display: block; }
  .q-table tr { display: grid; grid-template-columns: 1fr auto; padding: .6rem .8rem; border-bottom: 1px solid var(--rule); }
  .q-table td { padding: .1rem 0; border: 0; text-align: left !important; }
  .q-table td[data-l="Invoice"] { grid-column: 1; }
  .q-table td[data-l="Participant"], .q-table td[data-l="Received"], .q-table td[data-l="Exceptions"] { display: none; }
  .q-table td[data-l="Amount"] { text-align: right !important; grid-row: 1; grid-column: 2; }
}

/* Exceptions list */
.exc-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--rule); border-radius: var(--r2); overflow: hidden; }
.exc-list li + li { border-top: 1px solid var(--rule); }
.exc-row { display: flex; align-items: center; gap: .9rem; width: 100%; padding: .75rem 1rem; border: 0; background: var(--paper); font: inherit; text-align: left; cursor: pointer; }
.exc-row:hover { background: var(--canvas); }
.exc-row > .ico { color: var(--ink-4); }
.exc-main { display: grid; flex: 1; min-width: 0; }
.exc-main b { color: var(--ink); font-size: var(--t-ui); font-weight: 600; }
.exc-main span { font-size: var(--t-xs); color: var(--ink-3); }

/* Verification results: invoice | checks | detail and decision */
.res-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: .5rem 1rem; }
.res-head-r { display: flex; align-items: center; gap: 1rem; }
.d-amt { font-size: 1.375rem; font-weight: 650; color: var(--ink); letter-spacing: -.02em; }
.pipe-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin: 1rem 0; padding: .6rem 0; border-block: 1px solid var(--rule); }
.pipe { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 0; flex: 1; margin: 0; padding: 0; }
.pipe li { display: flex; align-items: center; font-size: var(--t-sm); color: var(--ink-4); }
.pipe li + li::before { content: ""; width: 1.75rem; height: 1px; background: var(--rule-2); margin-inline: .6rem; }
.pipe li.done + li::before { background: var(--ok); }
.pipe-dot { display: inline-grid; place-items: center; width: 1.3rem; height: 1.3rem; margin-right: .45rem; border: 1px solid var(--rule-2); border-radius: 50%; font-size: .72rem; font-weight: 650; background: var(--paper); }
.pipe-dot .ico { width: .72rem; height: .72rem; stroke-width: 3; }
.pipe li.done { color: var(--ink-2); }
.pipe li.done .pipe-dot { border-color: var(--ok); color: var(--ok); }
.pipe li.now { color: var(--ink); font-weight: 600; }
.pipe li.now .pipe-dot { border-color: var(--blue); color: var(--blue); animation: ring 1.2s ease-in-out infinite; }
@keyframes ring { 50% { box-shadow: 0 0 0 4px rgb(36 87 214 / .12); } }
@container main (max-width: 640px) { .pipe li + li::before { width: .75rem; margin-inline: .35rem; } .pipe-label { font-size: var(--t-xs); } }

.pane-switch { display: none; margin-bottom: .75rem; border: 1px solid var(--rule-2); border-radius: var(--r1); overflow: hidden; }
.pane-switch button { flex: 1; min-height: 2.75rem; border: 0; background: var(--paper); color: var(--ink-3); font: inherit; font-size: var(--t-sm); font-weight: 600; cursor: pointer; }
.pane-switch button + button { border-left: 1px solid var(--rule-2); }
.pane-switch button.is-on { background: var(--ink); color: #fff; }

.res-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.6fr); gap: 1.25rem; align-items: start; }
.res-right { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .9fr); gap: 1.25rem; align-items: start; min-width: 0; }
.res-centre, .res-aside, .res-decision, .res-detail { display: grid; gap: 1rem; min-width: 0; align-content: start; }
.res-right > *, .res-detail > *, .res-decision > * { min-width: 0; max-width: 100%; }
/* Below three-column width the detail moves to the top of the right column, beside the invoice line it highlights. */
@container main (max-width: 1099px) {
  .res-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .res-right { display: flex; flex-direction: column; }
  .res-aside { display: contents; }
  .res-detail { order: -1; }
  .res-decision { order: 1; }
}
@container main (max-width: 820px) {
  .pane-switch { display: flex; }
  .res-grid { grid-template-columns: 1fr; }
  .res-grid.show-results .res-left, .res-grid.show-invoice .res-right { display: none; }
}
.col-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; min-height: 2.25rem; margin-bottom: .5rem; padding-bottom: .4rem; border-bottom: 1px solid var(--ink); }
.res-left { min-width: 0; }
.res-left .doc-scroll { position: relative; }
.res-left.is-scanning .doc-scroll::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--blue); box-shadow: 0 0 0 6px rgb(36 87 214 / .08); animation: scan 1.1s ease-in-out infinite alternate; pointer-events: none; }
@keyframes scan { from { transform: translateY(0); } to { transform: translateY(28rem); } }

.headline { display: grid; gap: .35rem; padding: .8rem 1rem; border: 1px solid; border-left-width: 3px; border-radius: var(--r1); }
.headline h4 { display: flex; align-items: center; gap: .5rem; font-size: 1.0625rem; }
.headline h4 .ico { width: 1.05rem; height: 1.05rem; stroke-width: 2.6; }
.headline p { font-size: var(--t-xs); color: var(--ink-3); }
.headline.tone-ok { border-color: var(--ok-line); border-left-color: var(--ok); background: var(--ok-wash); }
.headline.tone-ok h4 { color: var(--ok); }
.headline.tone-warn { border-color: var(--warn-line); border-left-color: #c27a12; background: var(--warn-wash); }
.headline.tone-warn h4 { color: var(--warn); }
.headline.tone-bad { border-color: var(--bad-line); border-left-color: var(--bad); background: var(--bad-wash); }
.headline.tone-bad h4 { color: var(--bad); }
.diff { display: grid; gap: .25rem; padding: .7rem .9rem; border: 1px solid var(--blue-line); border-radius: var(--r1); background: var(--paper); font-size: var(--t-sm); }
.diff.enter { animation: fade .3s ease-out; }
.diff p { display: flex; gap: .45rem; align-items: flex-start; }
.diff .ico { margin-top: .25rem; }
.diff-ok { color: var(--ok); font-weight: 600; }
.diff-bad { color: var(--bad); font-weight: 600; }
.diff-note { font-size: var(--t-xs); color: var(--ink-3); }

.check-list { list-style: none; margin: 0; padding: 0; }
.chk { display: grid; grid-template-columns: 1.25rem minmax(0, 1fr); gap: .65rem; padding: .6rem 0; border-bottom: 1px solid var(--rule); font-size: var(--t-sm); }
.chk-text { display: grid; gap: .2rem; min-width: 0; }
.chk-row { display: flex; flex-wrap: wrap; gap: .25rem .6rem; align-items: center; justify-content: space-between; }
.chk-row b { font-weight: 600; color: var(--ink); }
.chk-text > span:not(.chk-row) { font-size: var(--t-xs); color: var(--ink-3); }
.chk-ico { display: grid; place-items: center; width: 1.25rem; height: 1.25rem; margin-top: .1rem; border-radius: 50%; }
.chk-ico .ico { width: .8rem; height: .8rem; stroke-width: 2.8; }
.chk-ico i { width: .8rem; height: .8rem; border-radius: 50%; border: 1.5px solid var(--rule-2); }
.chk.waiting b { color: var(--ink-4); font-weight: 500; }
.running .chk-ico i { border-top-color: var(--blue); animation: spin .7s linear infinite; }
.chk.out-pass .chk-ico { color: var(--ok); background: var(--ok-wash); }
.chk.out-exception .chk-ico { color: #fff; background: var(--bad); }
.chk.out-review .chk-ico, .chk.out-missing .chk-ico { color: var(--warn); background: var(--warn-wash); }
.finds { list-style: none; margin: .3rem 0 0; padding: 0; display: grid; gap: .3rem; }
.find { display: flex; align-items: center; gap: .6rem; width: 100%; min-height: 2.5rem; padding: .4rem .65rem; border: 1px solid var(--rule-2); border-left-width: 3px; border-radius: var(--r1); background: var(--paper); font: inherit; font-size: var(--t-sm); font-weight: 600; color: var(--ink); text-align: left; cursor: pointer; transition: background-color .12s, border-color .12s; }
.find > span:first-child { flex: 1; }
.find.out-exception { border-left-color: var(--bad); }
.find.out-review, .find.out-missing { border-left-color: #c27a12; }
.find:hover { background: var(--canvas); }
.find.is-on { background: var(--blue-wash); border-color: var(--blue-line); border-left-color: var(--blue); }
.find .ico { color: var(--ink-4); transition: transform .15s; }
.find.is-on .ico { transform: rotate(90deg); color: var(--blue); }
.find-where { font-size: var(--t-xs); font-weight: 500; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.not-checked { margin-top: .5rem; font-size: var(--t-xs); color: var(--ink-3); }
.not-checked summary { display: flex; align-items: center; gap: .4rem; min-height: 2.5rem; cursor: pointer; color: var(--ink-2); }
.not-checked ul { margin: .25rem 0 0; padding-left: 1.1rem; display: grid; gap: .3rem; }

.detail-panel { display: grid; gap: .7rem; padding: 1rem; border: 1px solid var(--rule-2); border-top: 3px solid; border-radius: var(--r1); background: var(--paper); font-size: var(--t-sm); animation: fade .2s ease-out; }
.detail-panel.out-exception { border-top-color: var(--bad); }
.detail-panel.out-review, .detail-panel.out-missing { border-top-color: #c27a12; }
.detail-top { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; }
.detail-ref { flex: 1 1 8rem; min-width: 0; font-size: var(--t-xs); color: var(--ink-3); overflow-wrap: anywhere; }
.detail-top .icon-btn { margin-left: auto; }
.detail-panel h4 { font-size: 1.0625rem; line-height: 1.3; }
.detail-item { margin-top: -.35rem; font-size: var(--t-xs); color: var(--ink-3); }
.facts { display: grid; grid-template-columns: minmax(0, 1fr) auto; margin: 0; border-top: 1px solid var(--ink); font-variant-numeric: tabular-nums; }
.facts dt, .facts dd { padding: .45rem 0; border-bottom: 1px solid var(--rule); }
.facts dt { color: var(--ink-3); }
.facts dd { margin: 0; text-align: right; font-weight: 650; color: var(--ink); overflow-wrap: anywhere; }
.facts dt:last-of-type, .facts dd:last-of-type { border-bottom-color: var(--ink); }
.detail-why { color: var(--ink-2); }
.f-action { padding: .55rem .7rem; background: var(--canvas); border-radius: var(--r1); color: var(--ink-2); }
.f-action b { color: var(--ink); }
.f-source { font-size: var(--t-xs); color: var(--ink-3); }
.corr { display: grid; gap: .7rem; padding: .85rem; border: 1px solid var(--blue-line); border-radius: var(--r1); background: var(--blue-wash); }
.corr-note { font-size: var(--t-xs); font-weight: 600; color: var(--blue-ink); }
.corr-field { display: grid; gap: .3rem; }
.corr-field label { font-size: var(--t-xs); font-weight: 600; color: var(--ink); }
.corr-row { display: flex; flex-wrap: wrap; gap: .4rem; }
.corr-row input { flex: 1; min-width: 8rem; min-height: 2.5rem; padding: .4rem .6rem; border: 1px solid var(--rule-2); border-radius: var(--r1); background: var(--paper); font: inherit; font-size: 1rem; color: var(--ink); }
.corr-row input:focus-visible { outline: none; border-color: var(--blue); box-shadow: var(--focus); }
.corr-row input.mono { font-family: var(--mono); font-size: .95rem; }
.corr-actions { display: flex; flex-wrap: wrap; gap: .4rem; }

.action-bar { display: grid; gap: .55rem; padding: 1rem; border: 1px solid var(--rule); border-radius: var(--r1); background: var(--canvas); font-size: var(--t-xs); color: var(--ink-3); }
.action-bar .button { justify-self: start; max-width: 100%; white-space: normal; text-align: left; }
.done-note { display: flex; gap: .5rem; align-items: flex-start; color: var(--ok); }
.done-note .ico { margin-top: .15rem; }
.done-note.is-bad { color: var(--bad); }
.done-note span { color: var(--ink-2); }
.done-note b { color: inherit; }
.pilot-cta { display: grid; gap: .5rem; padding: 1.1rem; border-radius: var(--r1); background: var(--navy); color: #c3cee0; font-size: var(--t-sm); }
.pilot-cta h4 { color: #fff; font-size: 1.0625rem; }
.pilot-sum { color: #fff; font-weight: 600; }
.cta-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .3rem; }
.pilot-cta .button-secondary { background: transparent; color: #fff; border-color: rgb(255 255 255 / .3); }
.pilot-cta .button-secondary:hover { background: rgb(255 255 255 / .08); }
.pilot-cta :focus-visible { outline-color: #a9c1f5; }

/* Preview dialog */
.preview-dialog { width: min(58rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 0; border: 1px solid var(--rule-2); border-radius: var(--r2); box-shadow: var(--lift); }
.preview-dialog::backdrop { background: rgb(13 22 38 / .5); }
.preview-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .6rem 1rem; border-bottom: 1px solid var(--rule); background: var(--canvas); }
.preview-head h3 { font-family: var(--mono); font-size: var(--t-ui); }
.preview-head .btn-s { display: inline-flex; align-items: center; gap: .35rem; min-height: 2.25rem; padding: .35rem .7rem; border: 1px solid var(--rule-2); border-radius: var(--r1); background: var(--paper); font: inherit; font-size: var(--t-sm); font-weight: 550; cursor: pointer; }
.preview-head .btn-s .ico { width: .95rem; height: .95rem; }
.preview-dialog .doc-scroll { padding: 1rem; }

/* ---------------- Reference table ---------------- */
.checks-ref { padding-block: clamp(3rem, 6vw, 4.5rem); }
.split-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: var(--s3) var(--s7); align-items: end; margin-bottom: var(--s5); }
.split-head h2 { font-size: var(--t-h2); line-height: 1.1; }
.split-head p { color: var(--ink-2); line-height: 1.9; }
@media (max-width: 860px) { .split-head { grid-template-columns: 1fr; } }
.table-wrap { overflow-x: auto; }
.ref-table { width: 100%; border-collapse: collapse; font-size: var(--t-ui); }
.ref-table th, .ref-table td { padding: .7rem .75rem .7rem 0; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); }
.ref-table thead th { font-size: var(--t-xs); font-weight: 600; color: var(--ink-3); border-bottom: 1px solid var(--ink); }
.ref-table tbody th { width: 22%; font-weight: 650; color: var(--ink); }
.ref-table tbody tr:has(th) > * { border-top: 1px solid var(--ink-4); }
.ref-table tbody tr:first-child > * { border-top: 0; }
.ref-table td:last-child { width: 28%; color: var(--ink-3); font-size: var(--t-sm); }
@media (max-width: 720px) {
  .ref-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .ref-table, .ref-table tbody, .ref-table tr, .ref-table th, .ref-table td { display: block; width: auto !important; }
  .ref-table tbody th { padding-top: 1.25rem; border-bottom: 1px solid var(--ink); }
  .ref-table td { padding: .55rem 0 .1rem; border: 0; }
  .ref-table td:last-child { padding: 0 0 .55rem; border-bottom: 1px solid var(--rule); }
}
.outcomes { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s5); margin: var(--s6) 0 0; padding: 0; }
.outcomes li { padding-top: var(--s3); border-top: 2px solid var(--ink); color: var(--ink-2); }
.outcomes b { display: block; color: var(--ink); font-size: 1.0625rem; margin-bottom: .2rem; }
@media (max-width: 820px) { .outcomes { grid-template-columns: 1fr; gap: var(--s4); } }
.disclosure { margin-top: var(--s6); border-top: 1px solid var(--rule); font-size: var(--t-sm); color: var(--ink-2); }
.disclosure summary { display: flex; align-items: center; gap: .5rem; min-height: 3rem; cursor: pointer; font-weight: 600; color: var(--ink); list-style: none; }
.disclosure summary::-webkit-details-marker { display: none; }
.disclosure summary::after { content: "+"; margin-left: auto; font-size: 1.25rem; font-weight: 400; color: var(--ink-3); }
.disclosure[open] summary::after { content: "−"; }
.disclosure ul { margin: 0 0 var(--s4); padding-left: 1.1rem; display: grid; gap: .45rem; max-width: 52rem; }

/* ---------------- Pilot ---------------- */
.pilot { background: var(--canvas); border-top: 1px solid var(--rule); padding-block: clamp(3rem, 6vw, 4.5rem); }
.pilot-in { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 27rem); gap: clamp(2rem, 6vw, 5rem); align-items: start; max-width: var(--page); margin-inline: auto; padding-inline: max(1.25rem, env(safe-area-inset-left)) max(1.25rem, env(safe-area-inset-right)); }
.pilot-copy h2 { font-size: var(--t-h2); line-height: 1.1; }
.pilot-copy > p { margin-top: var(--s4); max-width: 34rem; color: var(--ink-2); }
.pilot-points { list-style: none; margin: var(--s5) 0 0; padding: 0; max-width: 30rem; border-top: 1px solid var(--rule-2); }
.pilot-points li { display: flex; gap: .7rem; padding: .6rem 0; border-bottom: 1px solid var(--rule-2); color: var(--ink); }
.pilot-points li::before { content: ""; width: .8rem; height: .45rem; margin-top: .5rem; flex: none; border-left: 2px solid var(--ok); border-bottom: 2px solid var(--ok); transform: rotate(-45deg); }
@media (max-width: 860px) { .pilot-in { grid-template-columns: 1fr; } }
.form { display: grid; gap: 1rem; padding: clamp(1.25rem, 3vw, 1.75rem); background: var(--paper); border: 1px solid var(--rule-2); border-radius: var(--r2); }
.form-steps { font-size: var(--t-xs); font-weight: 600; color: var(--ink-3); }
.form-step { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 1rem; }
.form-step[hidden] { display: none; }
.field { display: grid; gap: .35rem; }
.form label { font-size: var(--t-sm); font-weight: 600; color: var(--ink); }
.opt { font-weight: 400; color: var(--ink-3); }
.form input[type="text"], .form input[type="email"], .form select, .form textarea { width: 100%; min-height: 2.75rem; padding: .55rem .7rem; border: 1px solid var(--rule-2); border-radius: var(--r1); background: var(--paper); font: inherit; font-size: 1rem; color: var(--ink); transition: border-color .12s, box-shadow .12s; }
.form textarea { min-height: 5rem; resize: vertical; }
.form input:focus-visible, .form select:focus-visible, .form textarea:focus-visible { outline: none; border-color: var(--blue); box-shadow: var(--focus); }
[aria-invalid="true"] { border-color: var(--bad) !important; }
.form .consent { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; font-size: var(--t-sm); color: var(--ink-2); cursor: pointer; }
.consent input { width: 1.25rem; height: 1.25rem; margin-top: .15rem; flex: none; accent-color: var(--blue); }
.note { font-size: var(--t-xs); color: var(--ink-3); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.form-nav { display: flex; gap: .5rem; }
.form-nav .button { flex: 1; }
.status { min-height: 1.2em; font-size: var(--t-sm); font-weight: 600; }
.status.ok { color: var(--ok); }
.status.err { color: var(--bad); }
.form.done { justify-items: center; text-align: center; padding-block: 2.5rem; }
.form.done svg { width: 3rem; height: 3rem; }
.form.done h3 { font-size: 1.25rem; }
.form.done p { color: var(--ink-3); }

/* ---------------- Footer ---------------- */
.footer { border-top: 1px solid var(--rule); padding-block: var(--s6) calc(var(--s6) + env(safe-area-inset-bottom, 0px)); }
.footer-in { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s3) var(--s6); align-items: start; max-width: var(--page); margin-inline: auto; padding-inline: max(1.25rem, env(safe-area-inset-left)) max(1.25rem, env(safe-area-inset-right)); font-size: var(--t-xs); color: var(--ink-3); }
.brand-foot { font-size: var(--t-ui); min-height: 0; }
.brand-foot .brand-mark { width: 1.25rem; height: 1.25rem; }
.footer-in p { max-width: 44rem; }
.footer-links { overflow-wrap: anywhere; }
.footer a { color: var(--ink-2); }
@media (max-width: 820px) { .footer-in { grid-template-columns: 1fr; } }

/* ---------------- Responsive: hero and problem ---------------- */
@media (max-width: 980px) {
  .hero-in { grid-template-columns: 1fr; }
  .hero h1 { max-width: 16ch; }
}
@media (max-width: 720px) {
  .hero-facts { grid-template-columns: 1fr 1fr; }
  .hero-facts div:last-child { grid-column: 1 / -1; }
  .hero-actions .button { flex: 1 1 100%; }
  .problem-list { grid-template-columns: 1fr; }
  .problem-list li, .problem-list li + li { padding: var(--s4) 0; border-left: 0; border-bottom: 1px solid var(--rule); }
  .hp-body { grid-template-columns: 1fr; }
  .hp-doc { border-right: 0; border-bottom: 1px solid var(--rule); }
  .hp-lines td:nth-child(4), .hp-lines th:nth-child(4) { display: none; }
}
@media (max-width: 640px), (pointer: coarse) {
  /* 16px: stops iOS zooming the page when an input gets focus */
  input.doc-input, input.doc-input.mono, select.doc-input { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .res-left.is-scanning .doc-scroll::after { display: none; }
}

/* ---------------- Privacy notice ---------------- */
.legal-head { border-bottom: 1px solid var(--rule); background: var(--canvas); }
.legal-head .col { padding-block: clamp(2.5rem, 6vw, 4.5rem) clamp(2rem, 4vw, 3rem); }
.legal-kicker { font-size: var(--t-xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--blue-ink); }
.legal-head h1 { margin-top: var(--s3); font-size: var(--t-hero); line-height: 1.04; font-weight: 680; letter-spacing: -.038em; }
.legal-lede { margin-top: var(--s4); max-width: 40rem; font-size: var(--t-lede); line-height: 1.55; }
.legal-meta { display: flex; flex-wrap: wrap; gap: var(--s4) var(--s6); margin: var(--s6) 0 0; padding-top: var(--s4); border-top: 1px solid var(--rule-2); }
.legal-meta dt { font-size: var(--t-xs); color: var(--ink-3); }
.legal-meta dd { margin: .15rem 0 0; font-size: var(--t-sm); font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.legal-body { display: grid; grid-template-columns: 14rem minmax(0, 1fr); gap: var(--s7); align-items: start; padding-block: clamp(2rem, 5vw, 3.5rem) clamp(3rem, 6vw, 4.5rem); }
.legal-toc { position: sticky; top: 5rem; font-size: var(--t-sm); }
.legal-toc-h { padding-bottom: .4rem; border-bottom: 1px solid var(--ink); font-size: var(--t-xs); font-weight: 600; color: var(--ink-3); }
.legal-toc ol { list-style: none; counter-reset: t; margin: 0; padding: 0; }
.legal-toc li { counter-increment: t; border-bottom: 1px solid var(--rule); }
.legal-toc a { display: flex; gap: .6rem; padding: .55rem 0; color: var(--ink-2); text-decoration: none; }
.legal-toc a::before { content: "0" counter(t); color: var(--ink-4); font-variant-numeric: tabular-nums; }
.legal-toc a:hover { color: var(--blue-ink); }
.legal-text { max-width: 44rem; min-width: 0; }
.legal-text section { scroll-margin-top: 5rem; padding-bottom: var(--s6); }
.legal-text section + section { padding-top: var(--s6); border-top: 1px solid var(--rule); }
.legal-text h2 { font-size: 1.375rem; line-height: 1.25; }
.legal-text p, .legal-text ul { margin-top: var(--s3); }
.legal-text ul { padding-left: 1.1rem; display: grid; gap: .4rem; }
.legal-text a { overflow-wrap: anywhere; }
.legal-points { list-style: none; padding: 0 !important; gap: 0 !important; border-top: 1px solid var(--ink); }
.legal-points li { display: grid; gap: .15rem; padding: var(--s3) 0; border-bottom: 1px solid var(--rule); }
.legal-points b { color: var(--ink); }
.legal-points span { color: var(--ink-3); }
.legal-points li:last-child { border-bottom: 0; }
.legal-note { padding: .75rem .9rem; border: 1px solid var(--warn-line); border-left: 3px solid var(--warn); border-radius: var(--r1); background: var(--warn-wash); color: var(--ink); font-size: var(--t-ui); }
.legal-back { margin-top: var(--s4) !important; }
@media (max-width: 860px) {
  .legal-body { grid-template-columns: 1fr; gap: var(--s5); }
  .legal-toc { position: static; }
}

/* ---------------- Page not found ---------------- */
.nf { border-bottom: 1px solid var(--rule); background: var(--canvas); }
.nf .col { padding-block: clamp(3.5rem, 12vh, 7rem); }
.nf h1 { margin-top: var(--s3); max-width: 16ch; font-size: var(--t-hero); line-height: 1.04; font-weight: 680; letter-spacing: -.038em; }
.nf-lede { margin-top: var(--s4); max-width: 36rem; font-size: var(--t-lede); line-height: 1.55; }
