:root {
  color-scheme: dark;
  --ink: #f1efe7;
  --muted: #b5b9ad;
  --ground: #141613;
  --surface: #20231e;
  --rule: #444c3e;
  --accent: #d1e598;
  --debit: #f4ab94;
  font: 1rem/1.5 system-ui, sans-serif;
  color: var(--ink);
  background: var(--ground);
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
.masthead {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: .4rem 1rem;
  padding: .9rem max(1rem, calc((100% - 53rem) / 2));
  border-bottom: 1px solid var(--rule);
}
.wordmark { font: 700 1.22rem Georgia, serif; }
.local { color: var(--accent); font-size: .82rem; }
main { width: min(calc(100% - 2rem), 53rem); margin: auto; padding: clamp(1.5rem, 5vw, 4rem) 0 2rem; }
.intro { margin-bottom: 2rem; }
h1, h2, h3, h4, p { margin: 0; }
h1 { font: 400 clamp(2.4rem, 6vw, 4.1rem)/1.05 Georgia, serif; letter-spacing: -.045em; }
h2 { font: 400 1.65rem/1.2 Georgia, serif; margin-bottom: .55rem; }
h3 { font-size: 1.08rem; }
h4 { font-size: .92rem; margin-top: 1.15rem; }
p { color: var(--muted); margin-top: .5rem; overflow-wrap: anywhere; }
.workspace, .summary, .import, .recent { padding: 1.2rem 0; border-top: 1px solid var(--rule); }
.workspace label, .input-label { display: block; margin: .6rem 0 .32rem; font-size: .86rem; font-weight: 600; }
.account-form-fields, .preview-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; }
.account-form-fields input { flex: 1 1 15rem; }
input, select, button {
  min-height: 44px;
  max-width: 100%;
  min-width: 0;
  padding: .55rem .72rem;
  border: 1px solid var(--rule);
  border-radius: .25rem;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
}
select { width: min(100%, 22rem); }
button { cursor: pointer; font-weight: 700; color: var(--ground); background: var(--accent); border-color: var(--accent); }
button.secondary { color: var(--ink); background: var(--ground); border-color: var(--rule); }
button:disabled { cursor: default; color: var(--muted); background: var(--surface); border-color: var(--rule); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input[type=file] { width: min(100%, 29rem); font-size: 1rem; }
.import-diagnostics { margin-top: .65rem; }
.import-diagnostics summary { width: fit-content; padding: .7rem 0; cursor: pointer; }
[role=status]:empty { display: none; }
[role=status][data-error] { color: var(--debit); }
.totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; margin: .85rem 0 .4rem; }
.totals > div { border-left: 1px solid var(--rule); padding-left: .7rem; }
dt { font-size: .82rem; color: var(--muted); }
dd { margin: 0; font-size: clamp(.95rem, 2.6vw, 1.5rem); font-weight: 600; overflow-wrap: anywhere; }
dd, .amount, time { font-variant-numeric: tabular-nums; }
.in { color: var(--accent); }
.out { color: var(--debit); }
#preview { background: var(--surface); margin-top: 1rem; padding: clamp(.8rem, 4vw, 1.35rem); border: 1px solid var(--rule); border-left: 3px solid var(--accent); }
.file-results { list-style: none; margin: .4rem 0 0; padding: 0; }
.file-results li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .15rem .75rem; padding: .6rem 0; border-top: 1px solid var(--rule); }
.file-name { overflow-wrap: anywhere; font-weight: 600; }
.file-result, .file-detail { font-size: .85rem; }
.file-result { color: var(--muted); text-align: end; }
.file-result.ready { color: var(--accent); }
.file-result.invalid { color: var(--debit); }
.file-detail { grid-column: 1 / -1; margin: 0; }
.rows { list-style: none; padding: 0; margin: .65rem 0 0; }
.rows li { display: grid; grid-template-columns: minmax(0, 1fr) fit-content(42%); gap: .65rem; border-top: 1px solid var(--rule); padding: .65rem 0; }
.rows li > div { min-width: 0; overflow-wrap: anywhere; }
.rows time { display: block; color: var(--muted); font-size: .8rem; }
.rows .amount { text-align: end; max-width: min(40vw, 10rem); overflow-wrap: anywhere; }
#match-review { margin-top: .9rem; border-block: 1px solid var(--rule); }
#match-review[open] { padding-bottom: .65rem; }
#match-review summary { min-height: 44px; padding: .65rem 0; color: var(--accent); font-weight: 600; cursor: pointer; }
#match-controls { margin: 0; padding: 0; border: 0; min-inline-size: 0; }
.match-pages { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: .5rem; }
#retry-matches { margin-top: .5rem; }
.match-source { color: var(--muted); font-size: .8rem; }
.match-rows li { row-gap: .25rem; }
.match-rows li > div:first-child { grid-row: 1 / span 2; }
.keep-match { display: flex; grid-column: 2; align-items: center; justify-self: end; gap: .45rem; min-height: 44px; padding: 0 .35rem; cursor: pointer; }
.keep-match input { width: 1.15rem; height: 1.15rem; min-height: 0; margin: 0; accent-color: var(--accent); }
.keep-match input:disabled { cursor: default; }
.preview-actions { justify-content: flex-end; margin-top: .85rem; }
#save-feedback { flex: 1 1 100%; margin: 0; text-align: end; }
#save-feedback:empty { display: none; }
#save-feedback[data-error] { color: var(--debit); }
.retention { font-size: .85rem; border-top: 1px solid var(--rule); padding-top: .65rem; }
@media (max-width: 25rem) {
  .totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .preview-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
  .preview-actions > button { padding-inline: .38rem; font-size: .9rem; }
  #save-feedback { grid-column: 1 / -1; text-align: start; }
}
