:root {
  --bg: #f6f5f1;
  --panel: #ffffff;
  --ink: #1d2126;
  --muted: #646b74;
  --line: #dfdcd3;
  --accent: #8a5a12;
  --accent-ink: #ffffff;
  --link: #1f4f82;
  --owed: #a3341f;
  --warn-bg: #fbf1d9;
  --warn-ink: #6b4a08;
  --note-bg: #e6eef7;
  --note-ink: #1f4f82;
  --ok: #24663b;
  --row: #faf9f6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --panel: #1d2024;
    --ink: #e8e6e1;
    --muted: #9aa1ab;
    --line: #30343a;
    --accent: #d9a548;
    --accent-ink: #1a1405;
    --link: #8fbdf0;
    --owed: #f08a72;
    --warn-bg: #3a2f14;
    --warn-ink: #f0d28a;
    --note-bg: #1c2f45;
    --note-ink: #a9cdf5;
    --ok: #7fcf98;
    --row: #212529;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.7rem; line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 0.6rem; font-weight: 600; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.owed { color: var(--owed); font-weight: 600; }

/* header */
.top {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 0.6rem 1.25rem; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--ink); letter-spacing: -0.01em; border-left: 4px solid var(--accent); padding-left: 0.6rem; }
.brand:hover { text-decoration: none; }
.quick { display: flex; gap: 0.4rem; flex: 1 1 18rem; max-width: 34rem; }
.quick input { flex: 1; min-width: 0; }
.top nav { display: flex; align-items: center; gap: 1rem; margin-left: auto; font-size: 0.9rem; }
.top nav form { margin: 0; }

main { max-width: 86rem; margin: 0 auto; padding: 1.25rem; }
footer { max-width: 86rem; margin: 0 auto; padding: 0.5rem 1.25rem 2rem; color: var(--muted); font-size: 0.8rem; }
section { margin: 0 0 1.5rem; }

/* controls */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 0.42rem 0.55rem; width: 100%;
}
input[type="checkbox"] { width: auto; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 6px;
  padding: 0.45rem 0.95rem; font-weight: 600; cursor: pointer; white-space: nowrap;
}
button:hover { filter: brightness(1.08); }
button.link { background: none; color: var(--link); padding: 0; font-weight: 400; }
label { display: block; font-size: 0.8rem; color: var(--muted); }
label input, label select { margin-top: 0.2rem; color: var(--ink); font-size: 0.93rem; }

.filters {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); gap: 0.7rem 0.8rem; align-items: end;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 0.9rem 1rem; margin-bottom: 1rem;
}
.filters .wide { grid-column: 1 / -1; }
.filters .check { display: flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; color: var(--ink); padding-bottom: 0.45rem; }
.filters .check input { margin: 0; }
.filters .actions { display: flex; align-items: center; gap: 0.9rem; }

.result-line { margin: 0 0 0.7rem; color: var(--muted); }
.result-line strong { color: var(--ink); }
.empty { background: var(--panel); border: 1px dashed var(--line); border-radius: 10px; padding: 1.5rem; color: var(--muted); }
.hint { font-size: 0.83rem; color: var(--muted); margin: 0.4rem 0 0.8rem; max-width: 60rem; }
.notice { background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; padding: 0.65rem 0.9rem; margin: 0 0 1rem; }
.notice a { color: inherit; text-decoration: underline; }

/* tables */
.scroll { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
table.list { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
table.list th {
  text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted);
  font-weight: 600; padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.list th.num { text-align: right; }
table.list td { padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tbody tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover { background: var(--row); }
table.list .summary { color: var(--muted); max-width: 24rem; }
table.list .flags { white-space: nowrap; text-align: right; }
table.list .desc { color: var(--muted); white-space: pre-wrap; }
table.list tfoot td { border-top: 1px solid var(--line); border-bottom: 0; color: var(--muted); text-align: right; }
table.list tfoot .grand td { color: var(--ink); font-weight: 700; font-size: 1rem; }
table.checks td:first-child { white-space: nowrap; }

.badge { display: inline-block; font-size: 0.7rem; font-weight: 600; border-radius: 999px; padding: 0.1rem 0.5rem; margin-left: 0.25rem; background: var(--warn-bg); color: var(--warn-ink); }
.badge.note { background: var(--note-bg); color: var(--note-ink); }

.pager { display: flex; justify-content: center; gap: 1.5rem; padding: 1rem 0; }
.tabs { display: flex; gap: 1.25rem; border-bottom: 1px solid var(--line); margin: 0 0 1rem; }
.tabs a { padding: 0.5rem 0; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }

/* detail pages */
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.eyebrow { margin: 0; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); font-weight: 700; }
.sub { margin: 0.25rem 0 0; color: var(--muted); }
.amounts { display: flex; gap: 2rem; }
.amounts div { text-align: right; }
.amounts span { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.amounts strong { font-size: 1.45rem; font-variant-numeric: tabular-nums; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); gap: 1rem; }
.cols dl { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 0.9rem 1rem; margin: 0; display: grid; grid-template-columns: 9rem 1fr; gap: 0.45rem 0.9rem; align-content: start; }
dt { color: var(--muted); font-size: 0.85rem; }
dd { margin: 0; overflow-wrap: anywhere; }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 0.12rem 0; }
.prose { white-space: pre-wrap; margin: 0; max-width: 62rem; overflow-wrap: anywhere; }

.notes .note { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 6px; padding: 0.6rem 0.85rem; margin-bottom: 0.6rem; max-width: 50rem; }
.notes .by { margin: 0.35rem 0 0; font-size: 0.8rem; color: var(--muted); }
.notes form { max-width: 50rem; margin-top: 1rem; }
.notes textarea { margin-top: 0.25rem; resize: vertical; }

.card { max-width: 24rem; margin: 3rem auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1.5rem; display: grid; gap: 0.9rem; }
.card h1 { font-size: 1.3rem; }
.card p { margin: 0; }
.error { color: var(--owed); font-weight: 600; }
.ok { color: var(--ok); font-weight: 600; }

@media (max-width: 640px) {
  main { padding: 0.9rem 1rem; }
  .top { padding: 0.6rem 1rem; }
  .top nav { margin-left: 0; }
  .amounts { gap: 1.25rem; }
  .cols dl { grid-template-columns: 1fr; gap: 0.1rem 0; }
  .cols dt { margin-top: 0.5rem; }
}

@media print {
  .top, footer, .noprint, .tabs, .pager { display: none; }
  body { background: #fff; color: #000; font-size: 11pt; }
  main { padding: 0; max-width: none; }
  .scroll, .cols dl { border-color: #999; }
  a { color: inherit; }
}
