:root {
  --bg: #f4f6f8; --card: #fff; --ink: #1c2530; --muted: #667788; --line: #dde3ea;
  --brand: #1f4e79; --brand-ink: #fff; --ok: #1f7a4d; --warn: #b7791f; --bad: #b3261e; --okbg: #e3f3ea; --warnbg: #fdf1d8; --badbg: #fbe4e2;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11161c; --card: #1a222b; --ink: #e8edf2; --muted: #93a1b0; --line: #2b3641; --brand: #5b9bd5; --brand-ink: #0b1620; --okbg: #12301f; --warnbg: #3a2e12; --badbg: #3d1b18; --ok: #6fd09a; --warn: #f0c070; --bad: #ff9a92; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: 'Assistant', 'Segoe UI', Arial, sans-serif; font-size: 17px; line-height: 1.45; padding-bottom: 76px; }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 18px; margin: 18px 0 8px; }
main { max-width: 760px; margin: 0 auto; padding: 14px 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.grid { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.stat .n { font-size: 24px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 14px; }
.neg { color: var(--bad); } .pos { color: var(--ok); }
button, .btn { font: inherit; border: 0; border-radius: 12px; padding: 12px 16px; min-height: 48px; background: var(--brand); color: var(--brand-ink); font-weight: 700; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button.sec, .btn.sec { background: transparent; color: var(--brand); border: 1.5px solid var(--brand); }
button.danger { background: var(--bad); color: #fff; }
button.small { min-height: 38px; padding: 6px 12px; font-size: 15px; }
button:disabled { opacity: .5; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; }
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea { font: inherit; width: 100%; padding: 11px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); min-height: 46px; }
input[type=checkbox] { width: 24px; height: 24px; min-height: 0; }
textarea { min-height: 110px; }
.unsure { border-color: var(--warn); background: var(--warnbg); }
nav { position: fixed; bottom: 0; inset-inline: 0; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
nav a { flex: 1; text-align: center; padding: 8px 2px 10px; color: var(--muted); text-decoration: none; font-size: 13px; }
nav a b { display: block; font-size: 22px; line-height: 1.2; }
nav a.on { color: var(--brand); font-weight: 700; }
.pill { flex: none; align-self: center; white-space: nowrap; display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; }
.pill.paid { background: var(--okbg); color: var(--ok); } .pill.partial { background: var(--warnbg); color: var(--warn); }
.pill.missing { background: var(--badbg); color: var(--bad); } .pill.future, .pill.none { background: var(--line); color: var(--muted); }
.item { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .sub { color: var(--muted); font-size: 14px; }
.cancelled { opacity: .5; text-decoration: line-through; }
.bar { height: 10px; background: var(--line); border-radius: 6px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--ok); }
.bar.over > i { background: var(--bad); }
.alert { padding: 10px 12px; border-radius: 10px; margin: 10px 0; background: var(--warnbg); color: var(--warn); font-weight: 600; }
.alert.bad { background: var(--badbg); color: var(--bad); }
.months { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 6px; margin: 8px 0; }
.months div { text-align: center; font-size: 12px; padding: 6px 2px; border-radius: 8px; }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 120px; margin-top: 8px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: 11px; color: var(--muted); }
.chart .pair { display: flex; align-items: flex-end; gap: 2px; width: 100%; height: 100%; }
.chart .pair i { flex: 1; border-radius: 4px 4px 0 0; min-height: 2px; }
.chart .in { background: var(--ok); } .chart .out { background: var(--bad); }
#toast { position: fixed; bottom: 90px; inset-inline: 16px; margin: 0 auto; max-width: 420px; background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 12px; opacity: 0; pointer-events: none; transition: opacity .2s; text-align: center; z-index: 10; }
#toast.show { opacity: 1; }
.busy { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 24px; }
.busybox { background: var(--card); color: var(--ink); border-radius: 18px; padding: 24px; text-align: center; max-width: 320px; width: 100%; display: grid; gap: 12px; justify-items: center; }
.spin { width: 48px; height: 48px; border: 5px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 3s; } }
.login { min-height: 80vh; display: grid; place-content: center; text-align: center; gap: 16px; padding: 24px; }
.num { direction: ltr; unicode-bidi: plaintext; display: inline-block; }
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 8; }
.sheet > div { background: var(--bg); width: 100%; max-width: 760px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 16px; }
