:root {
  --bg: #f4f6f8; --card: #ffffff; --ink: #14324a; --muted: #5d6b78; --line: #e3e8ee;
  --brand: #14324a; --accent: #1f7a8c;
  --ok: #1b7a46; --ok-bg: #e6f4ec; --tight: #8a5a00; --tight-bg: #fff4dc;
  --bad: #b3261e; --bad-bg: #fdebea; --info-bg: #e8f1fb;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1a24; --card: #15242f; --ink: #e8eef3; --muted: #9fb0bf; --line: #24394a;
    --brand: #0b1620; --accent: #5cc2d6;
    --ok: #6fd39b; --ok-bg: #12301f; --tight: #f2c46b; --tight-bg: #33270d;
    --bad: #ff8a80; --bad-bg: #3a1513; --info-bg: #13283a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
a { color: var(--accent); }
h1 { font-size: 1.45rem; margin: 18px 0 12px; }
h1.hi { font-size: 1.25rem; font-weight: 600; }
h2 { font-size: 1.02rem; margin: 0 0 10px; }
small { display: block; font-size: .8rem; }
.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px; }
.top { display: flex; justify-content: space-between; align-items: center; background: var(--brand);
  color: #fff; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; }
.top .brand { font-weight: 700; letter-spacing: .2px; }
.top form { margin: 0; }
button.link { background: none; border: 0; color: #cfe3ee; font: inherit; font-size: .9rem; cursor: pointer; padding: 6px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin: 12px 0; }
.card.dim, .dim { opacity: .7; }
.stack > * + * { margin-top: 10px; }
.muted { color: var(--muted); }
.sm { font-size: .9rem; }
.foot { color: var(--muted); font-size: .82rem; text-align: center; margin: 18px 0; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .lbl { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.kpi .num { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; margin: 2px 0; }
.kpi .sub { font-size: .82rem; color: var(--muted); }
.kpi.ok { background: var(--ok-bg); border-color: transparent; } .kpi.ok .num { color: var(--ok); }
.kpi.tight { background: var(--tight-bg); border-color: transparent; } .kpi.tight .num { color: var(--tight); }
.kpi.bad { background: var(--bad-bg); border-color: transparent; } .kpi.bad .num { color: var(--bad); }

.alert { display: block; border-radius: var(--radius); padding: 12px 14px; margin: 12px 0; text-decoration: none; color: var(--ink); }
.alert.bad { background: var(--bad-bg); border-left: 5px solid var(--bad); }
.alert.tight { background: var(--tight-bg); border-left: 5px solid var(--tight); }
.alert .go { display: block; margin-top: 4px; color: var(--accent); font-weight: 600; }
.bad-text { color: var(--bad); }
.ok-card { background: var(--ok-bg); border-color: transparent; }

.flash { border-radius: 10px; padding: 10px 12px; margin: 12px 0; background: var(--info-bg); font-size: .92rem; }
.flash.error { background: var(--bad-bg); color: var(--bad); }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.block { display: block; text-decoration: none; color: var(--ink); }

.row { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; padding: 7px 0; border-top: 1px solid var(--line); }
.card h2 + .row, .row:first-child { border-top: 0; }
.row > span:first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.row.sm { font-size: .9rem; padding: 4px 0; border-top: 0; }
.row.total { font-weight: 700; border-top: 2px solid var(--line); margin-top: 6px; }
.link-row { text-decoration: none; color: var(--ink); }
.amt { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.amt.in { color: var(--ok); }
.day { padding: 6px 0; border-top: 1px solid var(--line); }
.day:first-of-type { border-top: 0; }
.dhead { display: flex; justify-content: space-between; font-weight: 600; font-size: .95rem; }
.bal { font-variant-numeric: tabular-nums; }
.bal.neg { color: var(--bad); }
.tag { font-style: normal; font-size: .72rem; background: var(--line); border-radius: 999px; padding: 2px 8px; margin-right: 6px; display: inline-block; }
.tag.good { background: var(--ok-bg); color: var(--ok); }
.tag.warn { background: var(--tight-bg); color: var(--tight); }

label { display: block; font-size: .9rem; font-weight: 600; }
label input, label select, .balrow input, textarea, details input, select {
  display: block; width: 100%; margin-top: 4px; font: inherit; font-weight: 400; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px; }
textarea { line-height: 1.5; }
label.inline { display: flex; gap: 8px; align-items: center; font-weight: 400; }
label.inline input { width: auto; min-height: 0; margin: 0; }
.balrow { display: grid; grid-template-columns: 1fr 120px; gap: 10px; align-items: center; font-weight: 600; font-size: .92rem; }
.balrow input { margin: 0; text-align: right; }
.balrow input.found { border-color: var(--accent); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.file input { padding: 18px 12px; border-style: dashed; }

.btn { display: inline-block; text-align: center; font: inherit; font-weight: 600; border-radius: 12px;
  padding: 11px 16px; min-height: 44px; border: 1px solid transparent; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--accent); color: #fff; width: 100%; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.sm { padding: 8px 12px; min-height: 40px; font-size: .88rem; }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); width: 100%; margin-bottom: 20px; }
.btn[disabled] { opacity: .6; }
.btn.sticky { position: sticky; bottom: calc(84px + env(safe-area-inset-bottom)); box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.btnrow { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.btnrow form { margin: 0; }
.btnrow .btn.primary { width: auto; }

.check { margin: 0; }
.tick { display: flex; align-items: center; gap: 12px; width: 100%; background: none; border: 0; border-top: 1px solid var(--line);
  padding: 10px 0; font: inherit; color: var(--ink); text-align: left; cursor: pointer; }
.tick .what { flex: 1; }
.tick .box { width: 24px; height: 24px; border: 2px solid var(--muted); border-radius: 7px; flex: none; }
.tick.on .box { background: var(--ok); border-color: var(--ok); }
.tick.on .box::after { content: "✓"; color: #fff; display: block; text-align: center; line-height: 20px; font-weight: 700; }
.tick.on .what { text-decoration: line-through; color: var(--muted); }

.fix { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-top: 10px; }
.fix.best { border: 2px solid var(--ok); }
.fix p { margin: 6px 0; }
.fix .result { font-size: .92rem; }
.pb { border-top: 1px solid var(--line); padding-top: 8px; }

.login { max-width: 380px; margin: 12vh auto 0; text-align: center; }
.login .card { text-align: left; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabs a { text-align: center; text-decoration: none; color: var(--muted); font-size: .72rem; padding: 8px 0 9px; min-height: 56px; }
.tabs a .ic { display: block; font-size: 1.2rem; line-height: 1.4; }
.tabs a.on { color: var(--accent); font-weight: 700; }
details { margin-top: -4px; }
