:root {
  --bg: #f6f5f2; --card: #fff; --text: #1d1d1f; --muted: #5c5c63; --line: #dcdad4;
  --accent: #1f5f8b; --accent-text: #fff; --ok: #1e6b3a; --warn: #8a5a00; --bad: #a12a2a;
  --ok-bg: #e3f2e7; --warn-bg: #fdf0d5; --bad-bg: #fbe4e4; --focus: #1f5f8b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141416; --card: #1d1d20; --text: #ececee; --muted: #a6a6ae; --line: #34343a;
    --accent: #6cb4e6; --accent-text: #0b1a26; --ok: #8fd6a6; --warn: #f0c46a; --bad: #f29b9b;
    --ok-bg: #173323; --warn-bg: #3a2c0c; --bad-bg: #3d1717; --focus: #6cb4e6;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--card); padding: 8px; z-index: 9; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.top { background: var(--card); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; flex-wrap: wrap; }
.top .muted { margin-left: 8px; }
h1 { font-size: 1.6rem; margin: 24px 0 12px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 0 0 8px; }
.muted { color: var(--muted); font-size: .92em; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px; margin: 0 0 16px; }
.narrow { max-width: 380px; margin: 48px auto; }
.row-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.month-nav { display: flex; gap: 8px; align-items: center; margin: 0 0 12px; }

.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0 0 12px; }
.summary dt { color: var(--muted); font-size: .85rem; }
.summary dd { margin: 0; font-weight: 600; }
.summary .total { font-size: 1.3rem; }
.meter { height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--ok); }
.meter span.over { background: var(--bad); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: .85rem; font-weight: 600; }
.badge.open { background: var(--warn-bg); color: var(--warn); }
.badge.reported { background: var(--warn-bg); color: var(--warn); }
.badge.overdue, .badge.void { background: var(--bad-bg); color: var(--bad); }
.badge.partial { background: var(--warn-bg); color: var(--warn); }
.badge.paid { background: var(--ok-bg); color: var(--ok); }
.badge.over { background: var(--bad-bg); color: var(--bad); }

.changes { list-style: none; padding: 0; margin: 0; }
.changes li { padding: 8px 0; border-top: 1px solid var(--line); }
.changes li:first-child { border-top: 0; }
.changes time { display: inline-block; min-width: 4.5em; color: var(--muted); font-variant-numeric: tabular-nums; }

.pay-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 12px 0; }
.pay-opt { border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; }
.qr svg { display: block; width: 200px; height: 200px; border-radius: 4px; }

label { display: block; font-size: .9rem; margin-bottom: 4px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--muted); border-radius: 6px; padding: 6px 8px; min-height: 40px; max-width: 100%; }
input[type=checkbox] { min-height: 0; width: 22px; height: 22px; }
button, .btn { font: inherit; font-weight: 600; background: var(--accent); color: var(--accent-text); border: 0; border-radius: 6px; padding: 8px 14px; min-height: 40px; cursor: pointer; text-decoration: none; display: inline-block; }
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
button.small { min-height: 32px; padding: 4px 10px; font-size: .9rem; }
button.link { background: none; color: var(--accent); padding: 0 4px; min-height: 24px; font-weight: 500; text-decoration: underline; }
form.inline, .sent { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.sent { margin-top: 12px; }
.sent label { margin: 0 0 10px; }
.inline .grow { flex: 1 1 220px; }
.inline .grow input { width: 100%; }
.inline-btn { display: inline; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: end; }
.grid-form input { width: 100%; }
.narrow input { width: 100%; margin-bottom: 12px; }
.actions { margin-top: 12px; }
.error { color: var(--bad); font-weight: 600; }
code { overflow-wrap: anywhere; }

.table-scroll { overflow-x: auto; position: relative; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-top: 1px solid var(--line); vertical-align: top; }
thead th { border-top: 0; font-size: .85rem; color: var(--muted); }
.hidden-row td { opacity: .6; text-decoration: line-through; }
.hidden-row td:nth-child(n+4) { text-decoration: none; opacity: 1; }
.bank { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; }
.bank dt { color: var(--muted); font-size: .9rem; }
.bank dd { margin: 0; }
.check { display: flex; gap: 8px; align-items: center; }
.check label { margin: 0; }
.check input[type=checkbox] { width: 22px; margin-bottom: 0; }  /* .narrow input would stretch it */
.narrow .check { margin: 12px 0; }
fieldset { border: 0; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
textarea { width: 100%; margin-bottom: 12px; }
.nav { display: flex; gap: 16px; align-items: center; }
.notice { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 10px 14px; margin: 16px 0 0; font-weight: 600; }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.notice a { color: inherit; }
.codes { columns: 2; list-style: none; padding: 0; font-size: 1.1rem; }
.grid-form .wide { grid-column: 1 / -1; }
input.full { width: 100%; margin-bottom: 12px; }
details { margin-top: 6px; }
summary { cursor: pointer; color: var(--accent); }
.num { text-align: right; white-space: nowrap; }
.btn.secondary-btn { background: transparent; color: var(--accent); border: 1px solid var(--accent); margin-left: 8px; }
.logo-preview { max-height: 60px; max-width: 220px; background: #fff; padding: 4px; border-radius: 4px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
input[type=file] { width: 100%; min-width: 0; }
form.inline > div { min-width: 0; max-width: 100%; }
.notes { white-space: pre-wrap; line-height: 1.55; margin-bottom: 8px; }
#notes textarea { font: 0.95rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.extra-line { margin-bottom: 8px; }
.special { margin: 12px 0; align-items: center; }
.nav a[aria-current] { font-weight: 700; text-decoration: none; }
fieldset.block { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 0 0 12px; display: block; }
fieldset.block legend { font-weight: 600; padding: 0 6px; }
.block-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0 0; }
iframe.preview { width: 100%; height: 760px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
img.thumb { max-width: 160px; max-height: 120px; border-radius: 4px; display: block; }
.top .nav { flex-wrap: wrap; row-gap: 4px; }
