/* Accounts payable — a supplier invoice read on arrival.
 *
 * The whole demo rests on one interaction: tap a field the system extracted and
 * it lights up on the document. Highlights are anchored to the real elements
 * carrying the text (`data-f`), not to coordinates over a flat image — so they
 * stay correct when the page reflows, at any width, in either language.
 *
 * The document is drawn rather than scanned. A real scan would be another
 * asset with another provenance question, and this way the highlight targets
 * are actual DOM nodes.
 */

:root {
  --ink: #14181f;
  --muted: #5b6472;
  --line: #e3e7ed;
  --bg: #f4f6f8;
  --card: #ffffff;
  --paper: #fefefe;
  --accent: #1663c7;
  --accent-soft: #e9f1fc;
  --good: #147a52;
  --good-soft: #e6f5ee;
  --warn: #a35b06;
  --warn-soft: #fdf3e3;
  --risk: #b5301c;
  --risk-soft: #fdecea;
  --font-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { letter-spacing: -0.015em; line-height: 1.2; }

/* ------------------------------------------------------------------ top -- */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  padding-right: 108px;   /* clears the fixed language switch */
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brandline { display: flex; align-items: center; gap: 12px; }
.mark {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 9px; background: #0d2242; color: #fff;
  font-weight: 700; font-size: 17px;
}
.topbar h1 { margin: 0; font-size: 15px; font-weight: 650; }
.topbar :where(p) { margin: 1px 0 0; font-size: 12.5px; color: var(--muted); }
.disclaimer {
  font-size: 11.5px; color: var(--muted);
  padding: 5px 11px; border: 1px dashed var(--line); border-radius: 999px;
}

/* ---------------------------------------------------------------- stage -- */
.stage {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: 24px;
  align-items: start;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 24px 72px;
}

/* ------------------------------------------------------------- document -- */
.docwrap { position: sticky; top: 20px; }
.docbar {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 0 4px 9px;
}
.file { font: 600 12.5px/1 var(--mono); }
.docbar .meta { font-size: 11.8px; color: var(--muted); }

.paper {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 30px 32px 26px;
  box-shadow: 0 1px 2px rgba(20, 24, 31, 0.06), 0 12px 34px rgba(20, 24, 31, 0.09);
  font-size: 13px;
  /* A faint paper tint, so it reads as a document rather than another panel. */
  background-image: linear-gradient(180deg, rgba(0, 0, 0, 0.012), transparent 120px);
}

.ihead { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.supplier { margin: 0; font-size: 15.5px; font-weight: 680; letter-spacing: -0.01em; }
.addr { margin: 2px 0 0; font-size: 11.5px; color: var(--muted); }
.iright { text-align: right; flex: none; }
.itype {
  margin: 0; font: 700 10.5px/1 var(--mono);
  letter-spacing: 0.18em; color: var(--muted);
}
.inum { margin: 5px 0 0; font: 650 15px/1 var(--mono); }
.idate { margin: 5px 0 0; font-size: 11.5px; color: var(--muted); }

.ito { margin: 22px 0 0; }
.ito p { margin: 0; }
.ito .lab {
  font: 700 9.5px/1 var(--mono);
  letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 5px;
}

.lines { width: 100%; border-collapse: collapse; margin: 22px 0 0; font-size: 12.5px; }
.lines th {
  text-align: left;
  font: 700 9.5px/1 var(--mono);
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted);
  padding: 0 0 8px;
  border-bottom: 1px solid var(--ink);
}
/* The gutter matters: without it the right-aligned figures of adjacent
   columns touch at phone widths and read as one number ("$2,15$8.600,00"). */
.lines th.num, .lines td.num { text-align: right; padding-left: 14px; }
.lines td {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.lines td:first-child { padding-right: 14px; }

.totals { margin: 16px 0 0; margin-left: auto; width: min(260px, 100%); font-size: 12.5px; }
.totals div {
  display: flex; justify-content: space-between; gap: 20px;
  padding: 5px 0;
  font-variant-numeric: tabular-nums;
}
.totals .grand {
  border-top: 1px solid var(--ink);
  margin-top: 5px; padding-top: 8px;
  font-size: 14px; font-weight: 680;
}

.ifoot { margin: 24px 0 0; padding-top: 14px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--muted); }
.ifoot p { margin: 0 0 3px; }
/* The bank line is deliberately degraded — this is the field the reader is
   meant to notice the system refusing to trust. */
.smudge span[data-f] { filter: blur(0.35px); opacity: 0.72; letter-spacing: 0.01em; }

/* ----------------------------------------------------------- highlights -- */
[data-f] {
  border-radius: 3px;
  padding: 1px 3px;
  margin: 0 -3px;
  transition: background 0.16s ease, box-shadow 0.16s ease;
  cursor: pointer;
}
[data-f]:hover { background: rgba(22, 99, 199, 0.1); }
[data-f].lit {
  background: #fde68a;
  box-shadow: 0 0 0 2px #f0b429;
}
[data-f].lit.low { background: #fed7aa; box-shadow: 0 0 0 2px #ea8c1c; }
[data-f].lit.bad { background: #fecaca; box-shadow: 0 0 0 2px #dc4a35; }

/* ---------------------------------------------------------------- panel -- */
.panelwrap { display: grid; gap: 16px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 17px 18px 18px;
}
.cardhead { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.card h2 { margin: 0; font-size: 14.5px; font-weight: 640; }
.card .sub { margin: 6px 0 13px; font-size: 12.6px; color: var(--muted); }

.ai {
  font: 600 9.5px/1 var(--mono);
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft);
  padding: 4px 7px; border-radius: 5px;
}
.ai.warn { color: var(--warn); background: var(--warn-soft); }

/* extracted fields */
.fields { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.fields button {
  appearance: none; width: 100%; cursor: pointer;
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
  align-items: baseline;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card); color: inherit;
  padding: 10px 12px;
  text-align: left;
  transition: border-color 0.14s ease, background 0.14s ease;
}
.fields button:hover { border-color: var(--accent); background: #fbfcfe; }
.fields button[aria-pressed="true"] { border-color: #f0b429; background: #fffbeb; }
.fields button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fields .k { font-size: 11.5px; color: var(--muted); }
.fields .v { font-size: 13.2px; font-weight: 600; font-variant-numeric: tabular-nums; }
.fields .c {
  grid-column: 2; grid-row: 1 / span 2;
  align-self: center;
  font: 600 10.5px/1 var(--mono);
  padding: 4px 7px; border-radius: 5px;
  background: var(--good-soft); color: var(--good);
  white-space: nowrap;
}
.fields .c.mid  { background: var(--warn-soft); color: var(--warn); }
.fields .c.low  { background: var(--risk-soft); color: var(--risk); }
.fields button[data-low="true"] { border-left: 3px solid var(--risk); }

/* three-way match */
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.checks li {
  display: grid; grid-template-columns: 20px 1fr; gap: 10px;
  align-items: start;
  font-size: 12.8px;
}
.checks .ic {
  width: 19px; height: 19px; border-radius: 50%;
  display: grid; place-items: center;
  font: 700 11px/1 var(--font-body);
  color: #fff; margin-top: 1px;
}
.checks .ic.ok  { background: var(--good); }
.checks .ic.no  { background: var(--risk); }
.checks strong { display: block; font-weight: 600; font-size: 13px; }
.checks span.d { color: var(--muted); }

/* exception */
.card.exception { border-left: 3px solid var(--warn); }
.exline {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 13px;
  margin-bottom: 10px;
}
.exline.bad { border-color: rgba(181, 48, 28, 0.35); background: #fffbfa; }
.exline h3 { margin: 0 0 4px; font-size: 13px; font-weight: 620; }
.exline p { margin: 0; font-size: 12.4px; color: var(--muted); }
.exline .figs {
  display: flex; flex-wrap: wrap; gap: 6px 16px;
  margin-top: 9px; padding-top: 9px;
  border-top: 1px dashed var(--line);
  font-size: 12px; font-variant-numeric: tabular-nums;
}
.exline .figs b { font-weight: 650; }
.exline p.clause {
  margin-top: 9px; padding: 8px 10px;
  background: var(--bg); border-radius: 7px;
  font-size: 11.8px; color: var(--muted);
  border-left: 2px solid var(--line);
}

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.btn {
  appearance: none; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font: 600 12.5px/1 var(--font-body);
  padding: 10px 13px; border-radius: 8px;
}
.btn:hover:not(:disabled) { border-color: #c6cddb; }
.btn.primary { background: #0d2242; border-color: #0d2242; color: #fff; }
.btn.primary:hover:not(:disabled) { background: #16305c; }
.btn:disabled { opacity: 0.6; cursor: default; }
.done {
  margin: 10px 0 0; padding: 10px 12px;
  border-radius: 8px; background: var(--good-soft);
  color: #0d5b3e; font-size: 12.4px;
}

/* --------------------------------------------------------------- narrow -- */
@media (max-width: 1000px) {
  .stage { grid-template-columns: 1fr; }
  .docwrap { position: static; }
}
@media (max-width: 560px) {
  .topbar { padding: 13px 16px; padding-right: 100px; }
  .stage { padding: 18px 14px 92px; gap: 18px; }
  .paper { padding: 20px 18px; font-size: 12px; }
  .ihead { flex-direction: column; gap: 14px; }
  .iright { text-align: left; }
  .lines { font-size: 11.5px; }
  .totals { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  [data-f], .fields button { transition: none; }
}
