:root {
  --ink: #17211e; --muted: #5d6965; --line: #dfe5e2; --paper: #f6f8f7; --card: #fff;
  --brand: #0f4c3a; --brand-2: #16674f; --brand-soft: #e3efe9;
  --gold: #d99a16; --ok: #1f7a4d; --ok-soft: #e2f3ea; --bad: #b4371b; --bad-soft: #fbe9e4; --warn: #a76a00; --warn-soft: #fbf0d9;
  --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); background: var(--paper); font-size: 15px; line-height: 1.45;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--brand-2); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--brand); color: #dfeee7; padding: 1.1rem .8rem; display: flex; flex-direction: column; gap: .2rem; }
.side .brand { font-weight: 700; font-size: 1.1rem; color: #fff; padding: .2rem .6rem 1rem; display: flex; gap: .5rem; align-items: center; }
.side .brand i { width: 22px; height: 22px; border-radius: 50%; background: var(--gold); display: inline-block; box-shadow: inset -6px -4px 0 rgba(0,0,0,.18); }
.side a { color: #dfeee7; text-decoration: none; padding: .5rem .7rem; border-radius: 6px; display: block; }
.side a:hover, .side a:focus-visible { background: rgba(255,255,255,.08); }
.side a.on { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
.side .group { font-size: .78rem; color: #9cc3b3; padding: .9rem .7rem .2rem; }
.side .foot { margin-top: auto; font-size: .85rem; padding: .6rem; color: #b8d4c8; }
.side .foot button { background: none; border: 1px solid rgba(255,255,255,.3); color: #fff; border-radius: 6px; padding: .3rem .7rem; cursor: pointer; margin-top: .4rem; }

main { padding: 1.4rem 1.8rem 3rem; max-width: 1320px; width: 100%; }
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); } .g32 { grid-template-columns: 3fr 2fr; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; }
.stat b { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat.lead { background: var(--brand); color: #fff; border-color: var(--brand); }
.stat.lead span { color: #b9dccd; }
.stat.alert b { color: var(--bad); }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; font-size: .82rem; color: var(--muted); border-bottom: 1px solid var(--line); padding: .45rem .5rem; }
td { border-bottom: 1px solid var(--line); padding: .5rem; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfb; }
.table-wrap { overflow-x: auto; }

.pill { display: inline-block; padding: .08rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.pill.paid, .pill.online, .pill.yes, .pill.active, .pill.sent, .pill.success { background: var(--ok-soft); color: var(--ok); }
.pill.unpaid, .pill.offline, .pill.no, .pill.failed, .pill.lost { background: var(--bad-soft); color: var(--bad); }
.pill.part_paid, .pill.pending, .pill.repair, .pill.wait, .pill.skipped { background: var(--warn-soft); color: var(--warn); }
.pill.waived, .pill.cancelled, .pill.retired { background: #eef0ef; color: var(--muted); }

form.inline { display: inline; }
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .25rem; }
input, select, textarea { font: inherit; padding: .5rem .6rem; border: 1px solid #c9d2ce; border-radius: 6px; width: 100%; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: 1px; border-color: var(--brand-2); }
input[type=checkbox] { width: auto; }
.field { margin-bottom: .8rem; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1; min-width: 140px; }
.row > .shrink { flex: 0 0 auto; min-width: 0; }
.btn { display: inline-block; font: inherit; font-weight: 600; background: var(--brand); color: #fff; border: 0; border-radius: 6px; padding: .5rem 1rem; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--brand-2); }
.btn:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.btn.ghost { background: #fff; color: var(--brand); border: 1px solid #c9d2ce; }
.btn.danger { background: var(--bad); }
.btn.small { padding: .3rem .65rem; font-size: .85rem; }
.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.flash.ok { background: var(--ok-soft); color: #14563a; }
.flash.error { background: var(--bad-soft); color: #7d2512; }
.errors { color: var(--bad); font-size: .88rem; margin: .2rem 0 .6rem; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; align-items: flex-end; }
.filters > * { width: auto; }
.seg { display: inline-flex; border: 1px solid #c9d2ce; border-radius: 6px; overflow: hidden; background: #fff; }
.seg a { padding: .4rem .75rem; text-decoration: none; color: var(--ink); font-size: .88rem; border-right: 1px solid #c9d2ce; }
.seg a:last-child { border-right: 0; }
.seg a.on { background: var(--brand); color: #fff; }

/* Bar chart: collections per day */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 190px; padding-top: .5rem; border-bottom: 1px solid var(--line); }
.bars .b { flex: 1; display: flex; flex-direction: column-reverse; min-width: 4px; position: relative; }
.bars .b span { display: block; }
.bars .b .cash { background: var(--brand-2); }
.bars .b .momo { background: var(--gold); }
.bars .b:hover::after { content: attr(data-tip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: .75rem; padding: .2rem .45rem; border-radius: 4px; white-space: nowrap; z-index: 2; }
.axis { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); margin-top: .3rem; }
.legend { font-size: .82rem; color: var(--muted); display: flex; gap: 1rem; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; }
.hbar { height: 8px; background: var(--brand-soft); border-radius: 4px; overflow: hidden; margin-top: .25rem; }
.hbar i { display: block; height: 100%; background: var(--brand-2); }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
dl.facts dt { color: var(--muted); font-size: .88rem; }
dl.facts dd { margin: 0; }
.photo { width: 96px; height: 96px; border-radius: 8px; object-fit: cover; background: var(--brand-soft); }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--brand-soft); padding: .1rem .4rem; border-radius: 4px; }
details summary { cursor: pointer; font-weight: 600; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; padding: .6rem; }
  .side .group, .side .foot { display: none; }
  .g2, .g3, .g32 { grid-template-columns: 1fr; }
  main { padding: 1rem; }
}
@media print { .side, .filters, .no-print { display: none !important; } .shell { display: block; } }
