:root {
  --bg: #f6f4ef; --card: #fff; --ink: #1f2a27; --muted: #6b7570; --line: #e4e0d6;
  --brand: #2f5d50; --brand-ink: #fff; --accent: #c8873a; --bad: #b3412f; --good: #2f7d4f;
  --r: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #141917; --card: #1d2421; --ink: #e9ece9; --muted: #96a19b; --line: #2d3632; --brand: #5fa48f; --brand-ink: #0d1412; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) calc(76px + env(safe-area-inset-bottom)) env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
}
main { max-width: 640px; margin: 0 auto; padding: 16px; }
h1 { font-size: 26px; margin: 8px 0 16px; letter-spacing: -0.02em; }
h2 { font-size: 17px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 14px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; font-weight: 600; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 17px; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; -webkit-appearance: none; appearance: none;
}
input[type=checkbox] { width: auto; -webkit-appearance: checkbox; appearance: auto; }
textarea { min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.row { display: flex; gap: 10px; align-items: flex-end; }
.row > * { flex: 1; min-width: 0; }
button, .btn {
  font: inherit; font-weight: 600; border: 0; border-radius: 12px; padding: 13px 16px; cursor: pointer;
  background: var(--brand); color: var(--brand-ink); width: 100%; margin-top: 14px; text-align: center; text-decoration: none; display: inline-block;
}
button.secondary { background: transparent; color: var(--brand); border: 1px solid var(--line); }
button.danger { background: transparent; color: var(--bad); border: 1px solid var(--line); }
button.inline { width: auto; margin: 0; padding: 8px 12px; font-size: 14px; }
button:disabled { opacity: .5; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.chip { flex: 1; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 999px; padding: 10px 12px; margin: 0; font-weight: 600; width: auto; }
.chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
table { width: 100%; border-collapse: collapse; }
td { padding: 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
td.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 10px; }
tr.total td { font-weight: 700; border-bottom: 0; }
tr.sub td { color: var(--muted); font-size: 14px; }
.net { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.badge.calculated, .badge.pending { background: #f3e2c9; color: #7a4d14; }
.badge.paid { background: #d4ecdc; color: #1d5a35; }
.badge.void, .badge.dismissed { background: #eee; color: #777; }
.list-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.list-item:last-child { border-bottom: 0; }
.err { color: var(--bad); margin-top: 10px; font-weight: 600; }
.ok { color: var(--good); margin-top: 10px; font-weight: 600; }
.warn { background: #fbecd2; color: #6d4510; padding: 10px 12px; border-radius: 10px; margin-top: 10px; font-size: 14px; }
.item-row { display: grid; grid-template-columns: 1fr 110px 40px; gap: 8px; margin-top: 8px; align-items: center; }
.item-row .x { margin: 0; padding: 10px 0; background: transparent; color: var(--muted); border: 1px solid var(--line); }
.tag { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.tag.reimbursement { color: var(--good); }
.tag.deduction { color: var(--bad); }
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 10;
}
nav.tabs a { flex: 1; text-align: center; padding: 10px 0 8px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600; }
nav.tabs a span { display: block; font-size: 20px; line-height: 1.2; }
nav.tabs a.on { color: var(--brand); }
.days { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.days label { margin-top: 2px; }
.center { text-align: center; }
.hidden { display: none !important; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
code { font-size: 12px; word-break: break-all; }
.pills { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; margin: 0 -2px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.pills::-webkit-scrollbar { display: none; }
.pill { flex: 0 0 auto; width: auto; margin: 0; padding: 10px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-weight: 600; line-height: 1.15; }
.pill small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.pill.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.pill.on small { color: var(--brand-ink); opacity: .85; }
.pills.wrap { flex-wrap: wrap; overflow: visible; }
