:root {
  --sage: #5E8466; --sage-strong: #46684F; --sage-tint: #E6EEE7; --sidebar: #2D3E33;
  --canvas: #F5F6F2; --card: #FFFFFF; --line: rgba(0,0,0,.07);
  --ink: #1E2621; --ink2: #5D6962; --ink3: #8E9993;
  --danger: #B5483B; --waiting: #D2731E; --done: #2F8A47; --partly: #2C8A8A;
}
@media (prefers-color-scheme: dark) {
  :root { --sage: #8DB596; --sage-strong: #A8CBB0; --sage-tint: #2A3A2F; --sidebar: #1C2620;
    --canvas: #171B18; --card: #222824; --line: rgba(255,255,255,.08);
    --ink: #E9EEEA; --ink2: #A3AFA7; --ink3: #737F78;
    --danger: #E58B7F; --waiting: #F0A35E; --done: #74C98A; --partly: #6CC4C4; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--canvas); color: var(--ink);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; }
body { padding: env(safe-area-inset-top) 0 calc(72px + env(safe-area-inset-bottom)); }
header { background: var(--sidebar); color: #fff; padding: 18px 18px 16px; }
header h1 { margin: 0; font-size: 26px; font-weight: 650; display: flex; align-items: center; gap: 10px; }
header h1 img { width: 30px; height: 30px; border-radius: 7px; }
header p { margin: 4px 0 0; color: rgba(255,255,255,.6); font-size: 13px; }
main { padding: 14px 14px 20px; max-width: 640px; margin: 0 auto; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile, .card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.tile { padding: 12px 13px; }
.tile .t { font-size: 12px; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .v { font-size: 21px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tile .d { font-size: 11px; color: var(--ink3); margin-top: 1px; }
h2 { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink3); margin: 22px 4px 7px; font-weight: 650; }
.card .row { display: flex; align-items: center; gap: 10px; padding: 11px 13px; border-top: 1px solid var(--line); }
.card .row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .a { font-weight: 600; font-family: ui-monospace, "SF Mono", monospace; font-size: 14px; }
.row .b { font-size: 12.5px; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .amt { text-align: right; font-variant-numeric: tabular-nums; font-size: 15px; white-space: nowrap; }
.row .st { font-size: 11px; font-weight: 650; }
.overdue { color: var(--danger); } .sent { color: var(--waiting); } .paid { color: var(--done); } .partly { color: var(--partly); } .muted { color: var(--ink3); }
.empty { padding: 14px; color: var(--ink2); font-size: 14px; }
button, .btn { font: inherit; border: 0; border-radius: 12px; padding: 13px 16px; background: var(--sage); color: #fff; font-weight: 600; width: 100%; }
button.secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
button:disabled { opacity: .5; }
.big { padding: 18px; font-size: 18px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
form, .form { display: grid; gap: 10px; }
label { font-size: 13px; color: var(--ink2); display: grid; gap: 5px; }
input, select, textarea { font: inherit; font-size: 16px; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); width: 100%; }
.preview { width: 100%; max-height: 260px; object-fit: contain; border-radius: 12px; background: var(--card); border: 1px solid var(--line); }
.note { font-size: 13px; color: var(--ink2); margin: 10px 4px; }
.err { color: var(--danger); font-size: 14px; margin: 10px 4px; }
nav#tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
nav#tabs button { background: none; color: var(--ink3); font-size: 11px; padding: 6px 0; border-radius: 8px; display: grid; justify-items: center; gap: 2px; position: relative; }
nav#tabs button .i { font-size: 20px; line-height: 1; }
nav#tabs button.on { color: var(--sage-strong); }
nav#tabs b { position: absolute; top: 2px; right: calc(50% - 22px); background: var(--waiting); color: #fff; font-size: 10px; border-radius: 9px; padding: 1px 5px; }
.seg { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 10px; }
.seg button { width: auto; padding: 8px 12px; font-size: 13px; background: var(--card); color: var(--ink2); border: 1px solid var(--line); border-radius: 18px; white-space: nowrap; }
.seg button.on { background: var(--sage); color: #fff; border-color: var(--sage); }
.sheet { position: fixed; inset: 0; background: var(--canvas); z-index: 10; overflow-y: auto; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.sheet .bar { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; }
.sheet .bar button { width: auto; padding: 8px 12px; }
.sheet iframe { width: 100%; height: calc(100vh - 120px); border: 0; background: #fff; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--sage); border-radius: 50%; animation: s 0.8s linear infinite; vertical-align: -2px; }
@keyframes s { to { transform: rotate(360deg); } }
nav#tabs[hidden], [hidden] { display: none !important; }
