:root {
  color-scheme: light;
  --bg: #f5f5f2;
  --surface: #ffffff;
  --ink: #18181b;
  --muted: #66666d;
  --line: #e4e4df;
  --accent: #f2c200;
  --accent-ink: #18181b;
  --paid: #17663f;
  --paid-bg: #e6f3ec;
  --late: #b42318;
  --late-bg: #fdeceb;
  --open: #4b4b52;
  --open-bg: #efefeb;
  --focus: #2457d6;
  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
h1, h2 { line-height: 1.2; margin: 0; }
h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 16px; font-weight: 650; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
p { margin: 0 0 8px; }
a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { flex: none; }
.link { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.link:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* layout */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh;
  background: linear-gradient(to right, var(--surface) 231px, var(--line) 231px, var(--line) 232px, transparent 232px); }
.nav { background: var(--surface); border-right: 1px solid var(--line); min-width: 0; padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; padding: 4px 8px; }
.nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav li a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 550; }
.nav li a:hover { background: var(--bg); color: var(--ink); }
.nav li a[aria-current="page"] { background: var(--bg); color: var(--ink); box-shadow: inset 3px 0 0 var(--accent); }
.logout { margin-top: auto; display: grid; gap: 6px; }
.who { font-size: 13px; color: var(--muted); padding: 0 10px; }
.main { padding: 28px 32px 48px; max-width: 1180px; width: 100%; display: grid; gap: 18px; align-content: start; }
.main > *, .two > * { min-width: 0; }  /* wide tables scroll inside their card instead of widening the page */
.page-head { display: grid; gap: 4px; }
.page-head p { max-width: 70ch; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; text-decoration: none; display: grid; gap: 4px; align-content: start; transition: border-color .15s, box-shadow .15s; }
.tile:hover { border-color: #cfcfc8; box-shadow: 0 2px 10px rgba(0,0,0,.05); }
.tile:active { transform: translateY(1px); }
.tile-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 550; }
.amount { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.tile-sub { font-size: 13px; color: var(--muted); }
.amount-other { font-size: 14px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.late { color: var(--late); }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s; white-space: nowrap; }
.btn:hover { background: var(--bg); border-color: #cfcfc8; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn[aria-busy="true"] { opacity: .7; cursor: progress; }
.btn[aria-busy="true"]::after { content: ""; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #e3b600; border-color: #e3b600; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); background: var(--bg); border-color: transparent; }
.btn-small { min-height: 32px; padding: 5px 10px; font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.count { display: inline-flex; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--late-bg); color: var(--late); font-size: 12px; font-weight: 700; align-items: center; justify-content: center; }

/* lists and tables */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list-main { display: flex; flex-wrap: wrap; align-items: center; column-gap: 8px; min-width: 0; }
.list-main .muted { white-space: nowrap; }
.list-side { display: grid; justify-items: end; font-size: 13px; text-align: right; white-space: nowrap; }
.amount-sm { font-weight: 650; font-variant-numeric: tabular-nums; font-size: 14px; }
.dir { color: var(--muted); display: inline-flex; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th.num { text-align: right; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.warn { color: var(--late); font-weight: 600; }
.note { display: block; font-size: 12px; color: var(--muted); }
.detail { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 650; }
.badge-paid { background: var(--paid-bg); color: var(--paid); }
.badge-late { background: var(--late-bg); color: var(--late); }
.badge-open { background: var(--open-bg); color: var(--open); }
.badge-hist { background: var(--line, #e7e7ea); color: var(--muted); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.pay-form { display: flex; gap: 6px; align-items: center; }
.pay-form input[type="date"] { min-height: 32px; padding: 4px 6px; font-size: 13px; width: 140px; }

/* forms */
label { font-size: 13px; font-weight: 600; color: var(--muted); }
input, select { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid #d6d6d0; border-radius: 8px; min-height: 38px; padding: 7px 10px; }
input:hover, select:hover { border-color: #bdbdb6; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field { display: grid; gap: 4px; }
.field.grow { flex: 1 1 220px; }
.field.grow input { width: 100%; }
.alert { background: var(--late-bg); color: var(--late); padding: 10px 12px; border-radius: 8px; font-weight: 600; }

/* review */
.review { list-style: none; margin: 0; padding: 0; }
.review > li { padding: 12px 0; border-top: 1px solid var(--line); }
.review > li:first-child { border-top: 0; }
.review-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.review-head .btn { margin-left: auto; }
.reasons { margin: 6px 0 0; padding-left: 18px; color: var(--late); font-size: 14px; }

/* status */
.status dl { margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.status dt { font-size: 13px; color: var(--muted); font-weight: 600; }
.status dd { margin: 2px 0 0; }
.empty { text-align: left; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 10px; padding: 28px; }
.login-card h1 { font-size: 22px; }
.login-card input { width: 100%; }
.login-card .btn { justify-content: center; margin-top: 6px; }

@media (max-width: 980px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .two { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); background: none; }
  .nav { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 16px; gap: 10px; }
  .nav ul { grid-auto-flow: column; justify-content: start; overflow-x: auto; min-width: 0; scrollbar-width: none; }
  .nav li a span { white-space: nowrap; }
  .logout { margin-top: 0; grid-auto-flow: column; justify-content: space-between; align-items: center; }
  .main { padding: 18px 16px 40px; }
  .tiles { grid-template-columns: 1fr; }
  .status dl { grid-template-columns: 1fr; }
  .table.invoices thead { display: none; }
  .table.invoices tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .table.invoices td { border: 0; padding: 0; }
  .table.invoices td[data-label="Partij"] { grid-column: 1; font-weight: 650; order: -2; }
  .table.invoices td[data-label="Bedrag"] { grid-column: 2; order: -1; }
  .table.invoices td:last-child { grid-column: 1 / -1; }
  .row-actions { justify-content: flex-start; margin-top: 6px; }
}
