:root {
  --bg: #f6f7f5; --card: #ffffff; --ink: #1b1f1c; --muted: #5d6660; --line: #dfe3df;
  --brand: #14532d; --brand-ink: #ffffff; --ok: #166534; --ok-bg: #dcfce7; --warn: #92400e; --warn-bg: #fef3c7;
  --bad: #991b1b; --bad-bg: #fee2e2; --info-bg: #e0f2fe; --info: #075985; --focus: #2563eb;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1311; --card: #171c19; --ink: #e8ece9; --muted: #a2aca5; --line: #2a322d; --brand: #22c55e; --brand-ink: #062b14;
    --ok: #86efac; --ok-bg: #0f2e1b; --warn: #fcd34d; --warn-bg: #3a2a07; --bad: #fca5a5; --bad-bg: #3b1212; --info-bg: #0c2a3a; --info: #7dd3fc; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: 72px; }
.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 16px; background: var(--brand); color: var(--brand-ink); }
.brand { font-weight: 800; letter-spacing: .04em; }
.who { font-size: 14px; text-align: right; }
.who button { margin-left: 8px; background: transparent; color: inherit; border: 1px solid currentColor; border-radius: 8px; padding: 4px 8px; font-size: 13px; min-height: 0; }
main { max-width: 760px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin: 4px 0 12px; } h2 { font-size: 18px; margin: 20px 0 8px; }
.muted { color: var(--muted); } .center { text-align: center; } .small { font-size: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 10px 0; }
.big-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.big-buttons button { min-height: 76px; font-size: 17px; }
button, .btn { font: inherit; font-weight: 600; min-height: 48px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); cursor: pointer; }
button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
button.danger { color: var(--bad); border-color: var(--bad); }
button:disabled { opacity: .55; cursor: progress; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
label { display: block; font-weight: 600; margin: 12px 0 4px; }
input, select, textarea { font: inherit; width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); }
input[inputmode="decimal"] { font-size: 22px; font-weight: 700; }
.row { display: flex; gap: 10px; align-items: center; } .row > * { flex: 1; min-width: 0; }
.actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; } .actions > * { flex: 1; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 10px; padding: 12px 4px; border-bottom: 1px solid var(--line); align-items: center; }
.list li:last-child { border-bottom: 0; }
.list .amt { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tap { cursor: pointer; } .tap:active { background: var(--line); }
.chip { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); } .chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); } .chip.info { background: var(--info-bg); color: var(--info); }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.kpi .v { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; } .kpi .l { font-size: 13px; color: var(--muted); }
.kpi.tap:hover { border-color: var(--brand); }
details { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; margin: 10px 0; }
summary { font-weight: 700; cursor: pointer; min-height: 32px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); } td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line); z-index: 5;
  padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1 1 0; min-width: 0; padding: 4px 2px; border: 0; border-radius: 0; min-height: 60px; font-size: 13px; background: transparent; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs button.on { color: var(--brand); box-shadow: inset 0 3px 0 var(--brand); }
.busy { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 20; overflow: hidden; }
.busy .bar { height: 100%; width: 40%; background: var(--focus); animation: slide 1s infinite ease-in-out; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
.toast { position: fixed; left: 16px; right: 16px; bottom: 76px; max-width: 560px; margin: 0 auto; padding: 14px 16px; border-radius: 12px;
  background: var(--ink); color: var(--bg); font-weight: 600; z-index: 30; box-shadow: 0 6px 24px rgba(0,0,0,.25); pointer-events: none; }
.toast.bad { background: var(--bad); color: #fff; }
.msg { padding: 12px; border-radius: 10px; margin: 10px 0; } .msg.bad { background: var(--bad-bg); color: var(--bad); }
.msg.ok { background: var(--ok-bg); color: var(--ok); } .msg.warn { background: var(--warn-bg); color: var(--warn); } .msg.info { background: var(--info-bg); color: var(--info); }
.line-entry { display: grid; grid-template-columns: 96px 1fr 48px; gap: 8px; align-items: center; margin: 6px 0; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; border: 0; border-radius: 0; min-height: 44px; font-size: 14px; padding: 4px; }
.seg button.on { background: var(--brand); color: var(--brand-ink); }
.spinner { display: inline-block; width: 1em; height: 1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 380px) { .big-buttons, .kpis { grid-template-columns: 1fr; } }
.row button[data-d] { flex: 0 0 52px; padding: 0; }
@media (max-width: 380px) { .tabs button { font-size: 11px; letter-spacing: -.01em; } .top { padding: 8px 12px; } .brand { font-size: 15px; } }

/* wide tables scroll inside their card instead of widening the whole page on small phones */
.card, details { overflow-x: auto; }
main { overflow-wrap: anywhere; }
@media (max-width: 380px) { table { font-size: 13px; } th, td { padding: 6px 4px; } .kpi .v { font-size: 19px; } }
