/* Light only. One neutral scale, one accent, one grid. */
:root {
  color-scheme: light;
  --bg: #f4f4f1; --surface: #ffffff; --ink: #1b1b1b; --ink-2: #4a4a48; --muted: #7d7d79;
  --rule: #d9d9d4; --rule-2: #e8e8e4;
  --accent: #e2601f; --ok: #2f8a4f; --warn: #c98a00; --err: #c4321f; --info: #9a9a95; --focus: #e2601f;
  --gap: 32px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 "Helvetica Neue", Helvetica, Inter, -apple-system, "Segoe UI", Arial, sans-serif;
  font-feature-settings: "tnum" 1; -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent); }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px 48px; }

/* Grid: 7 / 5, used by intro, input and results so edges line up. */
.grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: var(--gap); align-items: start; }

/* Header */
.top { display: flex; justify-content: space-between; align-items: baseline; padding: 20px 0; border-bottom: 1px solid var(--ink); }
.mark { font-weight: 700; font-size: 15px; letter-spacing: -0.1px; }
.mark::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 10px; vertical-align: 1px; }
.mark-sub { font-weight: 400; color: var(--muted); margin-left: 4px; }
.top-right { display: flex; align-items: baseline; gap: 20px; }
.byline { font-size: 13px; color: var(--muted); text-decoration: none; }
.lang { display: inline-flex; border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; }
.lang button { min-height: 28px; padding: 3px 10px; border: 0; border-radius: 0; font-size: 12px; font-weight: 600; letter-spacing: .5px; color: var(--muted); background: transparent; }
.lang button + button { border-left: 1px solid var(--rule); }
.lang button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* Intro */
.intro { padding: 56px 0 48px; }
.has-results .intro { display: none; }
.has-results .top { border-bottom-color: transparent; padding-bottom: 8px; }
/* Once invoices are loaded, the drop zone becomes one row: adding more is secondary. */
.has-results .drop { min-height: 0; flex-direction: row; align-items: center; justify-content: flex-start; gap: 14px; padding: 14px 18px; }
.has-results .drop::before { width: 28px; height: 28px; margin: 0; font-size: 18px; flex: none; }
.has-results .drop-title { font-size: 15px; }
.has-results .drop-sub { margin: 0; }
h1 { font-size: 40px; line-height: 1.08; letter-spacing: -1px; font-weight: 600; margin: 0; }
.intro-side { padding-top: 6px; color: var(--ink-2); }
.intro-side p { margin: 0 0 14px; }
.local { margin: 0; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.led { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(47, 138, 79, .15); flex: none; }

/* Steps */
.step { padding: 0 0 48px; }
.sec {
  display: flex; align-items: baseline; gap: 14px; margin: 0 0 20px; padding-top: 12px; border-top: 1px solid var(--ink);
  font-size: 13px; font-weight: 600; letter-spacing: .2px;
}
.num { font-size: 11px; font-weight: 600; letter-spacing: 1px; color: var(--accent); text-transform: uppercase; }
.label { font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); }

/* Input */
.drop {
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
  min-height: 176px; padding: 28px; background: var(--surface); border: 1px solid var(--rule); border-radius: 4px;
  cursor: pointer; transition: border-color .15s;
}
.drop::before {
  content: "+"; display: grid; place-items: center; width: 36px; height: 36px; margin-bottom: 18px;
  border-radius: 50%; background: var(--accent); color: #fff; font-size: 22px; font-weight: 300; line-height: 1;
}
.drop:hover, .drop.over { border-color: var(--ink); }
.drop.over { background: #fbfbf9; }
.drop:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.drop-title { font-weight: 600; font-size: 17px; }
.drop-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

.input-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.drop { min-height: 200px; }
.switch { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); cursor: pointer; width: fit-content; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; flex: none; width: 30px; height: 18px; border-radius: 9px; background: var(--rule); transition: background .15s; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--ok); }
.switch input:checked + .switch-track::after { transform: translateX(12px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Buttons */
button {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--rule);
  border-radius: 4px; padding: 8px 16px; cursor: pointer; min-height: 40px;
}
button:hover { border-color: var(--ink); }
button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
button.primary:hover { background: #000; }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
button.ghost:hover { color: var(--ink); }

/* Status */
.status { min-height: 22px; margin: 16px 0 0; color: var(--ink-2); font-size: 13px; }
.status:empty { margin: 0; min-height: 0; }
.status .bar { display: inline-block; width: 160px; height: 2px; background: var(--rule); vertical-align: middle; margin-left: 12px; overflow: hidden; }
.status .bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.status.error { color: var(--err); }

/* Results */
.col-main, .col-aside { display: flex; flex-direction: column; gap: 28px; min-width: 0; }
.col-aside { position: sticky; top: 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.sheet { position: relative; border: 1px solid var(--rule); box-shadow: 0 1px 2px rgba(0, 0, 0, .04); background: #fff; }
#preview { width: 100%; height: auto; display: block; }
.marks { position: absolute; inset: 0; }
.hit {
  position: absolute; min-height: 0; padding: 0; margin: -2px; box-sizing: content-box; border: 1px solid rgba(226, 96, 31, .45);
  border-radius: 2px; background: rgba(226, 96, 31, .06); cursor: pointer; transition: background .12s, border-color .12s;
}
.hit:hover, .hit.active { border-color: var(--accent); background: rgba(226, 96, 31, .2); box-shadow: 0 0 0 2px rgba(226, 96, 31, .25); }
.legend { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.legend-box { width: 14px; height: 9px; border: 1px solid var(--accent); background: rgba(226, 96, 31, .1); border-radius: 2px; }
.pill { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }

.raw { border-top: 1px solid var(--rule); padding-top: 10px; }
.raw summary { cursor: pointer; list-style: none; }
.raw summary::-webkit-details-marker { display: none; }
.raw summary::after { content: "+"; float: right; font-size: 14px; color: var(--muted); }
.raw[open] summary::after { content: "–"; }
.raw pre {
  white-space: pre-wrap; word-break: break-word; font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--ink-2); background: var(--surface); border: 1px solid var(--rule-2); padding: 12px;
  margin: 10px 0 0; max-height: 360px; overflow: auto;
}

/* Summary: the answer first */
.summary { background: var(--surface); border: 1px solid var(--ink); border-radius: 4px; padding: 20px 22px 8px; }
.verdict-line { margin: 0 0 14px; font-size: 14px; font-weight: 600; }
.dot.verdict-line::before { width: 10px; height: 10px; }
.pay { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; padding-bottom: 16px; border-bottom: 1px solid var(--rule); }
.pay-amount { font-size: 36px; line-height: 1.1; font-weight: 600; letter-spacing: -0.8px; }
.pay-due { font-size: 15px; color: var(--ink-2); }
.pay-due b { color: var(--ink); font-weight: 600; }
.pay-when { color: var(--muted); }
.pay-amount.active, .pay-due b.active { color: var(--accent); }
.pay-rows { display: grid; grid-template-columns: 130px minmax(0, 1fr); margin: 0; font-size: 14px; }
.pay-rows dt, .pay-rows dd { padding: 10px 0; border-bottom: 1px solid var(--rule-2); }
.pay-rows dt:nth-last-child(2), .pay-rows dd:last-child { border-bottom: 0; }
.pay-rows dt { color: var(--muted); }
.pay-rows dt.active, .pay-rows dd.active .v { color: var(--accent); }
.pay-rows dd { margin: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; min-width: 0; }
.pay-rows .v { min-width: 0; overflow-wrap: anywhere; }
.pay-rows .mono { font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink-2); }
button.copy { flex: none; min-height: 28px; padding: 3px 10px; font-size: 12px; color: var(--ink-2); }
button.copy.done { color: var(--ok); border-color: var(--ok); }

/* Checks: problems shown, the rest folded */
.checks[hidden] + .passed { margin-top: 0; }
.passed { margin-top: 10px; }
.passed summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); padding: 4px 0; }
.passed summary::-webkit-details-marker { display: none; }
.passed summary::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.passed summary::after { content: "+"; color: var(--muted); margin-left: 4px; }
.passed[open] summary::after { content: "–"; }
.passed .checks { margin-top: 8px; }
button.link { min-height: 0; padding: 0; border: 0; background: none; font-size: 13px; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
button.link:hover { color: var(--ink); }

.checks { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--rule); border-radius: 4px; }
.checks li { display: grid; grid-template-columns: 16px 1fr; gap: 12px; padding: 11px 14px; font-size: 14px; border-top: 1px solid var(--rule-2); }
.checks li:first-child { border-top: 0; }
.checks li[data-key] { cursor: default; transition: background .12s; }
.checks li.active { background: #fbf6f2; }
.checks li b { font-weight: 600; }
.checks .ico { font-size: 0; padding-top: 7px; }
.checks .ico::before { content: ""; display: block; width: 8px; height: 8px; border-radius: 50%; background: var(--info); }
.checks .ok .ico::before { background: var(--ok); }
.checks .warn .ico::before { background: var(--warn); }
.checks .error .ico::before { background: var(--err); }
.checks .info .ico::before { background: transparent; border: 1.5px solid var(--info); }
.checks .error b { color: var(--err); }
.checks .msg { color: var(--ink-2); display: block; word-break: break-word; font-size: 13px; }

/* Fields */
.fields fieldset { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; margin: 0 0 22px; padding: 0; border: 0; min-width: 0; }
.fields legend { grid-column: 1 / -1; float: left; width: 100%; padding: 0 0 8px; margin-bottom: 2px; border-bottom: 1px solid var(--rule-2); font-size: 12px; font-weight: 600; color: var(--ink); }
#show-empty { margin-top: -6px; }
.fields label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); min-width: 0; }
.fields .why { min-height: 0; font-size: 11px; line-height: 1.3; color: var(--muted); }
.fields .why:empty { display: none; }
.fields .unsure .f-name::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 6px; border-radius: 50%; background: var(--warn); vertical-align: 1px; }
.fields .unsure .why { color: #8a5f00; }
.fields .unsure input { border-color: var(--warn); }
.fields .f.active .f-name { color: var(--accent); }
.fields .f.active input { border-color: var(--accent); }
.fields input {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--rule);
  border-radius: 4px; padding: 8px 10px; min-width: 0; width: 100%;
}
.fields input:hover { border-color: #b9b9b3; }
.fields input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.fields .wide { grid-column: 1 / -1; }

.batch { margin-bottom: 32px; }
.table-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: 4px; }
.batch-table, .vat-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.batch-table th, .vat-table th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .5px; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.batch-table td { padding: 9px 12px; border-top: 1px solid var(--rule-2); white-space: nowrap; }
.batch-table tbody tr:first-child td { border-top: 0; }
.batch-table tbody tr { cursor: pointer; }
.batch-table tbody tr:hover { background: #fafaf8; }
.batch-table tr.current { background: #f6f1ec; box-shadow: inset 2px 0 0 var(--accent); }
.batch-table .r, .vat-table .r { text-align: right; }
.row-btn { min-height: 0; padding: 0; border: 0; background: none; font-size: 13px; font-weight: 600; text-align: left; }
.row-btn:hover { color: var(--accent); }
.dot { display: inline-flex; align-items: center; gap: 7px; }
.dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--info); }
.dot.OK::before { background: var(--ok); }
.dot.CHECK::before { background: var(--warn); }
.dot.FLAGGED { color: var(--err); }
.dot.FLAGGED::before { background: var(--err); }
.tag-dup { margin-left: 8px; font-size: 10px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; color: var(--err); border: 1px solid currentColor; border-radius: 2px; padding: 0 4px; }
.vat-table { background: var(--surface); border: 1px solid var(--rule); }
.vat-table td { padding: 8px 12px; border-top: 1px solid var(--rule-2); }
.vat-table tr.sum td { font-weight: 600; border-top: 1px solid var(--ink); }
.vat-table tr.past td { color: var(--muted); }
.vat-table tr.next td { font-weight: 600; }
.vat-table tr.next td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
.tag-next { margin-left: 8px; font-size: 10px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; color: var(--accent); border: 1px solid currentColor; border-radius: 2px; padding: 0 4px; }
.kv { display: grid; grid-template-columns: 120px 1fr; margin: 0; font-size: 14px; border-top: 1px solid var(--rule); }
.kv dt, .kv dd { padding: 8px 0; border-bottom: 1px solid var(--rule-2); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions .ghost { margin-left: auto; }

/* Method */
.how { padding-top: 16px; }
.how-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); color: var(--ink-2); font-size: 14px; }
.how-list .num { display: block; margin-bottom: 6px; }
.how-list li { border-top: 1px solid var(--rule); padding-top: 10px; }
.note { color: var(--muted); font-size: 13px; margin: 28px 0 0; max-width: 640px; }

.foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 56px; padding-top: 14px; border-top: 1px solid var(--rule); color: var(--muted); font-size: 12px; }

@media (max-width: 900px) {
  .how-list { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  :root { --gap: 24px; }
  .wrap { padding: 0 16px 40px; }
  .grid { grid-template-columns: 1fr; }
  .col-aside { position: static; }
  .intro { padding: 40px 0 36px; }
  h1 { font-size: 30px; }
}
@media (max-width: 520px) {
  .fields fieldset, .how-list { grid-template-columns: 1fr; }
  .pay-rows { grid-template-columns: 1fr; }
  .pay-rows dt { padding-bottom: 0; border-bottom: 0; }
  .pay-amount { font-size: 30px; }
  .actions .ghost { margin-left: 0; }
  .top-right { gap: 12px; }
  .byline { display: none; }
}
