/* Invoice reader. The page sits on a grey desk like a sheet of paper; carbon-copy violet marks
   where a value was read, and the review status is a rubber stamp. Everything else stays quiet. */

:root {
  color-scheme: light;
  --desk: #e7eaee;
  --paper: #ffffff;
  --raised: #f5f6f8;
  --ink: #1b2230;
  --ink-2: #3a4454;
  --muted: #5d6777;
  --line: #d3d8df;
  --line-soft: #e5e8ec;
  --carbon: #34368f;
  --carbon-wash: rgba(52, 54, 143, 0.12);
  --carbon-trace: rgba(52, 54, 143, 0.28);
  --stamp-red: #b3361f;
  --ok: #1f6e47;
  --ok-wash: #e4f2ea;
  --warn: #8f5405;
  --warn-wash: #fbf0dc;
  --bad: #b42318;
  --bad-wash: #fbe8e5;
  --focus: #34368f;
  --shadow-sheet: 0 1px 1px rgba(27, 34, 48, 0.08), 0 8px 24px -8px rgba(27, 34, 48, 0.22);
  --font: "Commissioner", "Fira Sans", "Noto Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --code: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --desk: #14171c;
    --paper: #1c2027;
    --raised: #232832;
    --ink: #e8ebf0;
    --ink-2: #c6ccd6;
    --muted: #9aa3b1;
    --line: #333a46;
    --line-soft: #2a303a;
    --carbon: #a5a8f2;
    --carbon-wash: rgba(165, 168, 242, 0.14);
    --carbon-trace: rgba(110, 114, 230, 0.45);
    --stamp-red: #f08a72;
    --ok: #6cc897;
    --ok-wash: #18311f;
    --warn: #e7ab52;
    --warn-wash: #33270f;
    --bad: #f28b7e;
    --bad-wash: #3a1d19;
    --focus: #a5a8f2;
    --shadow-sheet: 0 1px 1px rgba(0, 0, 0, 0.4), 0 10px 28px -10px rgba(0, 0, 0, 0.7);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  font-feature-settings: "kern";
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--carbon); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.num, .amount, table td.num { font-variant-numeric: tabular-nums; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Top bar ---------- */

.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 12px 24px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: baseline; gap: 12px; margin-right: auto; min-width: 0; }
.brand-name { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
.brand-role { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.services { position: relative; }
.services-button {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: var(--paper);
  border-radius: 999px; padding: 5px 12px; cursor: pointer; font-size: 14px;
}
.services-button:hover { border-color: var(--muted); }
.light { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.light.ok { background: var(--ok); }
.light.warn { background: var(--warn); }
.light.bad { background: var(--bad); }
.popover {
  position: absolute; right: 0; top: calc(100% + 8px); width: 340px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-sheet); padding: 8px; z-index: 30;
}
.service-row { display: grid; grid-template-columns: 9px 1fr auto; gap: 4px 10px; align-items: baseline; padding: 8px; }
.service-row .light { align-self: center; }
.service-name { font-weight: 600; }
.service-state { color: var(--muted); font-size: 13px; text-align: right; }
.service-detail { grid-column: 2 / 4; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.popover-foot { border-top: 1px solid var(--line-soft); margin-top: 4px; padding: 8px 8px 2px; }

.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.lang-switch button {
  border: 0; background: transparent; padding: 5px 12px; cursor: pointer; font-size: 14px; color: var(--muted);
}
.lang-switch button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

/* ---------- Auth gate ---------- */

.auth-gate {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100vh - 57px); padding: 24px;
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--paper);
  border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-sheet); padding: 28px 28px 32px;
}
.auth-card h1 { font-size: 20px; font-weight: 700; margin: 0 0 8px; letter-spacing: -0.01em; }

/* ---------- Layout ---------- */

.layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); min-height: calc(100vh - 57px); }
.rail {
  background: var(--paper); border-right: 1px solid var(--line);
  padding: 20px 20px 32px; display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 57px; height: calc(100vh - 57px); overflow-y: auto;
}
.workspace { padding: 24px 28px 48px; min-width: 0; }

.rail h2, .panel-title {
  font-size: 15px; font-weight: 650; margin: 0 0 10px; letter-spacing: -0.005em;
}

/* ---------- Intake ---------- */

.dropzone {
  display: block; border: 1.5px dashed var(--line); border-radius: 10px;
  padding: 18px 16px; text-align: center; cursor: pointer; background: var(--raised);
  transition: border-color 0.15s, background-color 0.15s;
}
.dropzone:hover, .dropzone.active { border-color: var(--carbon); background: var(--carbon-wash); }
.dropzone strong { display: block; font-weight: 600; }
.dropzone .link { color: var(--carbon); text-decoration: underline; text-underline-offset: 2px; }
.dropzone small { display: block; color: var(--muted); margin-top: 4px; font-size: 13px; }
.dropzone input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.picked { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 14px; margin-top: 10px; }
.picked ul { margin: 6px 0 0; padding: 0; list-style: none; font-size: 13px; color: var(--muted); }
.picked li { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.field-group { display: grid; gap: 6px; margin-top: 16px; }
.field-group label, .field-label { font-size: 14px; font-weight: 550; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
select, input[type="text"], input[type="search"], input[type="number"], input[type="password"] {
  width: 100%; border: 1px solid var(--line); border-radius: 6px;
  background: var(--paper); padding: 7px 9px; min-height: 36px;
}
select:disabled { opacity: 0.55; }
.stepper { display: inline-grid; grid-template-columns: 36px 52px 36px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; width: max-content; }
.stepper button { border: 0; background: var(--raised); cursor: pointer; font-size: 18px; line-height: 1; }
.stepper button:hover { background: var(--line-soft); }
.stepper input { border: 0; border-radius: 0; text-align: center; min-height: 34px; padding: 4px; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }

.toggle { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; align-items: start; margin-top: 16px; cursor: pointer; }
.toggle input { appearance: none; width: 36px; height: 20px; border-radius: 999px; background: var(--line); position: relative; margin: 2px 0 0; cursor: pointer; transition: background 0.15s; }
.toggle input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--paper); transition: transform 0.15s; }
.toggle input:checked { background: var(--ink); }
.toggle input:checked::after { transform: translateX(16px); }
.toggle .hint { grid-column: 2; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  border-radius: 6px; padding: 7px 14px; min-height: 36px; cursor: pointer; text-decoration: none;
  font-weight: 550; font-size: 14px; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.primary:hover:not(:disabled) { background: var(--ink-2); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--muted); padding-inline: 8px; }
.btn.quiet:hover { color: var(--ink); background: var(--raised); }
.btn.small { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.btn.block { width: 100%; min-height: 42px; font-size: 15px; margin-top: 20px; }
kbd { font: 12px var(--font); opacity: 0.7; }

.notice { font-size: 13px; color: var(--ink-2); background: var(--warn-wash); border-radius: 8px; padding: 10px 12px; margin: 0; }

.joblist, .history { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.joblist li, .history li > button {
  display: grid; grid-template-columns: 1fr auto; gap: 0 10px; width: 100%; text-align: left;
  border: 0; background: transparent; border-radius: 6px; padding: 8px 10px; cursor: pointer;
}
.joblist li { cursor: default; }
.joblist li.clickable { cursor: pointer; }
.history li > button:hover, .joblist li.clickable:hover { background: var(--raised); }
.history li > button[aria-current="true"], .joblist li[aria-current="true"] { background: var(--carbon-wash); }
.entry-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-meta { grid-column: 1; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-side { grid-row: 1 / 3; grid-column: 2; align-self: center; font-size: 13px; color: var(--muted); text-align: right; }
.entry-side.amount { color: var(--ink); font-weight: 600; }
.state-failed { color: var(--bad); }
.state-done { color: var(--ok); }
.history-head { display: flex; justify-content: space-between; align-items: baseline; }
.history li { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 4px; align-items: center; }
.history li > input { width: 16px; height: 16px; margin: 0 0 0 2px; accent-color: var(--ink); cursor: pointer; }
.batch { border-top: 1px solid var(--line-soft); padding-top: 18px; }
.batch h2 { margin-bottom: 4px; }
.batch .hint { margin-bottom: 10px; }
.batch-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.is-disabled { opacity: 0.45; pointer-events: none; }

/* ---------- Empty, running, failed ---------- */

.blank { max-width: 620px; margin: 8vh auto 0; }
.blank h2 { font-size: 30px; line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 12px; font-weight: 700; }
.blank p { color: var(--ink-2); margin: 0 0 20px; font-size: 16px; line-height: 1.6; }
.blank ol { margin: 0; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 12px; }
.blank ol li { counter-increment: step; display: grid; grid-template-columns: 28px 1fr; gap: 10px; color: var(--ink-2); }
.blank ol li::before {
  content: counter(step); width: 26px; height: 26px; border-radius: 50%;
  border: 1.5px solid var(--carbon); color: var(--carbon); display: grid; place-items: center;
  font-size: 13px; font-weight: 650;
}
.running .clock { font-size: 44px; font-weight: 300; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; margin: 8px 0 18px; }
.running ol li::before { border-color: var(--line); color: var(--muted); }
.failed h2 { color: var(--bad); }
.failed .message { background: var(--paper); border-left: 3px solid var(--bad); padding: 12px 14px; border-radius: 0 6px 6px 0; }

/* ---------- Result summary ---------- */

.summary {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 32px;
  align-items: end; position: relative; padding: 4px 0 22px;
  border-bottom: 1px solid var(--line); margin-bottom: 22px;
}
.summary-doc { color: var(--ink-2); font-size: 15px; margin: 0 0 6px; }
.summary-doc strong { color: var(--ink); font-weight: 650; }
.supplier-name { font-size: clamp(24px, 2.6vw, 34px); line-height: 1.1; letter-spacing: -0.02em; margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.summary-sub { color: var(--muted); font-size: 14px; margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.summary-figure { text-align: right; }
.summary-figure .label { display: block; color: var(--muted); font-size: 14px; }
.summary-figure .amount { display: block; font-size: clamp(28px, 3vw, 40px); font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; }
.summary-figure .payable { color: var(--muted); font-size: 14px; }
.summary-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 2px 9px; border-radius: 999px; background: var(--carbon-wash); color: var(--carbon); font-weight: 550; }

.stamp {
  position: absolute; right: 0; top: -6px; transform: rotate(-4deg);
  border: 3px double currentColor; border-radius: 6px; padding: 3px 12px;
  font-weight: 800; font-size: 17px; letter-spacing: 0.06em; line-height: 1.3;
  color: var(--stamp-red); opacity: 0.85; pointer-events: none;
  mix-blend-mode: multiply;
}
.stamp.ready, .stamp.posted, .stamp.checked { color: var(--carbon); }
.stamp.enter { animation: stamp 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.2) both; }
@keyframes stamp {
  from { opacity: 0; transform: rotate(-4deg) scale(1.35); }
  to { opacity: 0.85; transform: rotate(-4deg) scale(1); }
}
@media (prefers-color-scheme: dark) { .stamp { mix-blend-mode: normal; } }
.summary.has-stamp .summary-figure { padding-top: 40px; }

.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: ""; width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg) translateY(-2px); margin-left: 2px; }
.menu-list {
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 15; min-width: 300px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-sheet); padding: 6px; display: grid;
}
.menu-list a, .menu-list button {
  display: block; text-align: left; border: 0; background: transparent; color: var(--ink);
  text-decoration: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 14px;
}
.menu-list a:hover, .menu-list button:hover { background: var(--raised); }
.menu-list small { display: block; color: var(--muted); font-size: 12.5px; }
.menu-list hr { border: 0; border-top: 1px solid var(--line-soft); margin: 4px 6px; }
.menu-list .disabled { opacity: 0.45; pointer-events: none; }

/* ---------- Split: page and reading ---------- */

.split { display: grid; grid-template-columns: minmax(260px, 36%) minmax(0, 1fr); gap: 24px; align-items: start; }
.split > * { min-width: 0; }
.viewer { position: sticky; top: 81px; }
.viewer-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; color: var(--muted); font-size: 14px; }
.viewer-bar .page-label { margin-right: auto; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 6px; border: 1px solid var(--line); background: var(--paper);
  cursor: pointer; display: grid; place-items: center; font-size: 16px; line-height: 1; color: var(--ink);
}
.icon-btn:disabled { opacity: 0.4; cursor: default; }
.sheet-wrap { max-height: calc(100vh - 140px); overflow: auto; border-radius: 2px; }
.sheet { position: relative; background: #fff; box-shadow: var(--shadow-sheet); width: calc(100% * var(--zoom, 1)); }
.sheet img { display: block; width: 100%; height: auto; }
.sheet .missing { padding: 60px 24px; color: #5d6777; text-align: center; font-size: 14px; aspect-ratio: 595 / 842; display: grid; place-items: center; }
.trace {
  position: absolute; border: 1px solid var(--carbon-trace); border-radius: 2px;
  background: transparent; transition: background-color 0.12s, border-color 0.12s, box-shadow 0.12s;
  cursor: pointer; padding: 0;
}
.trace:hover { border-color: #34368f; }
.trace.lit { background: rgba(52, 54, 143, 0.16); border: 2px solid #34368f; box-shadow: 0 0 0 3px rgba(52, 54, 143, 0.15); }

/* ---------- Tabs ---------- */

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tab {
  border: 0; background: transparent; padding: 9px 10px; cursor: pointer; color: var(--muted);
  font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
  display: inline-flex; gap: 6px; align-items: center;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.count { font-size: 12px; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--line-soft); color: var(--ink-2); text-align: center; font-weight: 600; }
.count.bad { background: var(--bad-wash); color: var(--bad); }
.count.warn { background: var(--warn-wash); color: var(--warn); }

.pane { min-width: 0; }
.section { margin-bottom: 28px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.section-head h3 { font-size: 16px; font-weight: 650; margin: 0; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 20px; }
.toolbar .status { color: var(--muted); font-size: 14px; }
.toolbar .status.ok { color: var(--ok); }
.toolbar .status.bad { color: var(--bad); }

.groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 8px 28px; margin-bottom: 28px; }
.group h3 { font-size: 16px; font-weight: 650; margin: 0 0 6px; }
.kv { margin: 0; }
.kv .row { display: grid; grid-template-columns: 8.5em minmax(0, 1fr); gap: 10px; padding: 5px 6px; margin: 0 -6px; border-radius: 4px; }
.kv .row[data-path]:hover, .kv .row.lit, tr.lit td { background: var(--carbon-wash); }
.kv dt { color: var(--muted); font-size: 14px; }
.kv dd { margin: 0; overflow-wrap: break-word; min-width: 0; display: flex; gap: 8px; align-items: baseline; justify-content: space-between; }
.kv dd .empty, td .empty { color: var(--muted); font-style: italic; font-size: 14px; }
.kv input, .kv select, td input { min-height: 30px; padding: 4px 7px; }
.mark { flex: none; font-size: 12px; font-weight: 600; padding: 0 6px; border-radius: 4px; line-height: 1.6; }
.mark.low { background: var(--bad-wash); color: var(--bad); }
.mark.mid { background: var(--warn-wash); color: var(--warn); }
.mark.human { background: var(--carbon-wash); color: var(--carbon); }
.invalid { border-color: var(--bad) !important; box-shadow: 0 0 0 2px var(--bad-wash); }
.field-error { color: var(--bad); font-size: 12.5px; display: block; }
#upload-paused { margin: 8px 0 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 550; color: var(--muted); font-size: 13px; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 7px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th.num, td.num { text-align: right; }
tfoot td { border-bottom: 0; font-weight: 650; }
tr[data-path] { cursor: default; }
tr[data-path]:hover td { background: var(--carbon-wash); }
td input { width: 100%; min-width: 64px; }
td.desc input { min-width: 180px; }
td.desc { min-width: 12em; }
td .mark { margin-left: 6px; }

.totals { display: grid; justify-content: end; margin-top: 12px; }
.totals .kv .row { grid-template-columns: 12em 9em; }
.totals dd { justify-content: flex-end; }
.totals .grand dt, .totals .grand dd { color: var(--ink); font-weight: 700; font-size: 16px; }
.totals .grand { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 8px; }

.note-block { border-left: 3px solid var(--warn); background: var(--paper); padding: 10px 14px; border-radius: 0 6px 6px 0; margin-top: 16px; font-size: 14px; }
.note-block.bad { border-left-color: var(--bad); }
.note-block p { margin: 0 0 6px; }
.note-block ul { margin: 0; padding-left: 18px; }

/* Checks */
.check-summary { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.checks { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line-soft); }
.check { display: grid; grid-template-columns: 26px 1fr; gap: 2px 12px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.check-icon { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; margin-top: 1px; }
.check.pass .check-icon { background: var(--ok-wash); color: var(--ok); }
.check.fail .check-icon { background: var(--bad-wash); color: var(--bad); }
.check.warn .check-icon { background: var(--warn-wash); color: var(--warn); }
.check.skip .check-icon { background: var(--line-soft); color: var(--muted); }
.check-title { font-weight: 600; }
.check-detail { grid-column: 2; color: var(--ink-2); font-size: 14px; }
.check-detail ul { margin: 2px 0 0; padding-left: 18px; }
.check.skip .check-title, .check.skip .check-detail { color: var(--muted); }

/* Sources */
.filters { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 12px; }
.filters input[type="search"] { max-width: 260px; }
.filters label { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; }
.conf { display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.bar { width: 48px; height: 5px; border-radius: 3px; background: var(--line-soft); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ok); }
.bar.mid i { background: var(--warn); }
.bar.low i { background: var(--bad); }

/* Posting */
.gate { border-radius: 8px; padding: 14px 16px; margin-bottom: 20px; }
.gate.ok { background: var(--ok-wash); }
.gate.bad { background: var(--bad-wash); }
.gate h3 { margin: 0 0 4px; font-size: 16px; }
.gate.ok h3 { color: var(--ok); }
.gate.bad h3 { color: var(--bad); }
.gate p { margin: 0; color: var(--ink-2); font-size: 14px; }
.gate ul { margin: 8px 0 0; padding-left: 18px; font-size: 14px; color: var(--ink-2); }
.ok-text { color: var(--ok); }
.bad-text { color: var(--bad); }
.postbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.postbar .hint { max-width: 46ch; }
.lead { color: var(--ink-2); margin: 0 0 16px; max-width: 70ch; }
.erp-status { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px;
  background: var(--warn-wash); border-radius: 8px; padding: 14px 16px; margin-bottom: 18px; }
.erp-status.ok { background: var(--ok-wash); }
.erp-status p { margin: 0; max-width: 62ch; font-size: 14px; color: var(--ink-2); }
.import-table th { white-space: nowrap; }
.import-table td { white-space: nowrap; vertical-align: middle; }
.import-table td.desc { white-space: normal; min-width: 14em; }
.import-table.flat td, .import-table.flat th { font-size: 13px; padding: 5px 7px; }
.kv.wide-labels .row { grid-template-columns: 13em minmax(0, 1fr); }
.import-table td.code { min-width: 15em; }
.import-table td.code input { min-width: 14em; }
.import-table td.code input.missing { border-color: var(--warn); background: var(--warn-wash); }
.import-table td.code small { display: block; }
.warn-text { color: var(--warn); }

/* Technical */
details.fold { border-top: 1px solid var(--line-soft); padding: 10px 0; }
details.fold > summary { cursor: pointer; font-weight: 600; }
details.fold[open] > summary { margin-bottom: 10px; }
pre {
  margin: 0; padding: 14px; background: var(--paper); border: 1px solid var(--line-soft); border-radius: 6px;
  font: 12.5px/1.55 var(--code); overflow: auto; max-height: 60vh; white-space: pre;
}
.links { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; margin-top: 12px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--paper); border-radius: 8px; padding: 10px 16px; font-size: 14px;
  box-shadow: var(--shadow-sheet); max-width: min(560px, calc(100vw - 32px));
}

/* ---------- Narrow screens ---------- */

@media (max-width: 1180px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .viewer { position: static; }
  .sheet-wrap { max-height: 70vh; }
}
@media (max-width: 860px) {
  .topbar { padding: 10px 16px; gap: 10px; flex-wrap: wrap; }
  .brand-role { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .workspace { padding: 20px 16px 40px; }
  .summary { grid-template-columns: 1fr; }
  .summary-figure { text-align: left; }
  .summary.has-stamp .summary-figure { padding-top: 0; }
  .stamp { position: static; grid-row: 1; justify-self: start; font-size: 14px; margin: 4px 0 6px 4px; }
  .popover { width: min(340px, calc(100vw - 32px)); }
  .kv .row { grid-template-columns: 8em minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Print: the summary, the reading and the checks ---------- */

@media print {
  /* Paper is always light, whatever the screen theme. */
  :root {
    --desk: #fff; --paper: #fff; --raised: #f5f6f8; --ink: #000; --ink-2: #222; --muted: #555;
    --line: #bbb; --line-soft: #ddd; --carbon: #34368f; --carbon-wash: transparent; --stamp-red: #b3361f;
    --ok: #1f6e47; --ok-wash: #e4f2ea; --warn: #8f5405; --warn-wash: #fbf0dc; --bad: #b42318; --bad-wash: #fbe8e5;
  }
  .lit, .lit td { background: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .topbar, .rail, .viewer, .tabs, .summary-actions, .toolbar, .filters, .toast, .no-print { display: none !important; }
  .layout, .split { display: block; }
  .workspace { padding: 0; }
  .pane { display: none !important; }
  .pane[data-print] { display: block !important; margin-bottom: 18pt; }
  .stamp { mix-blend-mode: normal; }
  a { color: inherit; text-decoration: none; }
  tr, .check { break-inside: avoid; }
}
