/* ── токени ─────────────────────────────────────────────── */
:root{
  --bg:#F1F3F2; --surface:#FFFFFF; --surface-2:#F6F8F7;
  --ink:#0B0F0E; --muted:#6B7A74; --line:#E4E9E6;
  --accent:#0F6B54; --accent-ink:#FFFFFF; --accent-soft:#E6F1EC;
  --warn:#9A6410; --warn-soft:#FCF2E0;
  --danger:#B02A1E; --danger-soft:#FCE9E6;
  --radius:20px; --radius-sm:14px;
  --shadow:0 1px 2px rgba(11,15,14,.04), 0 6px 20px -12px rgba(11,15,14,.18);
  --tab-h:62px;
  --sans:"Onest",system-ui,-apple-system,"Segoe UI",sans-serif;
  --mono:"IBM Plex Mono",ui-monospace,Menlo,monospace;
}
@media (prefers-color-scheme:dark){
  :root:not([data-theme="light"]){
    --bg:#000000; --surface:#141816; --surface-2:#1C211E;
    --ink:#F2F5F3; --muted:#8D9B94; --line:#262C29;
    --accent:#39C093; --accent-ink:#04120D; --accent-soft:#12271F;
    --warn:#D9A44F; --warn-soft:#2A2214;
    --danger:#E8786A; --danger-soft:#2C1815;
    --shadow:none;
  }
}
:root[data-theme="dark"]{
  --bg:#000000; --surface:#141816; --surface-2:#1C211E;
  --ink:#F2F5F3; --muted:#8D9B94; --line:#262C29;
  --accent:#39C093; --accent-ink:#04120D; --accent-soft:#12271F;
  --warn:#D9A44F; --warn-soft:#2A2214;
  --danger:#E8786A; --danger-soft:#2C1815;
  --shadow:none;
}

*{box-sizing:border-box; -webkit-tap-highlight-color:transparent}
html,body{height:100%}
body{
  margin:0; background:var(--bg); color:var(--ink);
  font-family:var(--sans); font-size:16px; line-height:1.45;
  -webkit-font-smoothing:antialiased;
  overscroll-behavior-y:none;
}
button,input,select{font:inherit; color:inherit}
.num{font-variant-numeric:tabular-nums}

/* ── каркас ─────────────────────────────────────────────── */
#app{min-height:100%; display:flex; flex-direction:column}
.screen{flex:1; padding:0 16px calc(var(--tab-h) + env(safe-area-inset-bottom,0px) + 24px)}
.screen.center{display:flex; flex-direction:column; justify-content:center; padding-bottom:24px; max-width:420px; margin:0 auto; width:100%}
.wrap{max-width:640px; margin:0 auto; width:100%}

/* шапка */
.topbar{
  position:sticky; top:0; z-index:20; background:var(--bg);
  padding:calc(env(safe-area-inset-top,0px) + 14px) 16px 10px;
}
.topbar .inner{max-width:640px; margin:0 auto; display:flex; align-items:center; justify-content:space-between; gap:12px}
.picker{
  display:flex; align-items:center; gap:8px; background:none; border:0; padding:6px 0;
  font-size:19px; font-weight:700; letter-spacing:-.02em; cursor:pointer; min-width:0;
}
.picker span{overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.picker svg{flex:none; opacity:.45}
.iconbtn{
  width:38px; height:38px; flex:none; display:grid; place-items:center;
  background:var(--surface); border:0; border-radius:50%; cursor:pointer; box-shadow:var(--shadow);
}

/* ── картки ─────────────────────────────────────────────── */
.card{background:var(--surface); border-radius:var(--radius); padding:20px; box-shadow:var(--shadow); margin-bottom:12px}
.card.tight{padding:6px 20px}
.card h2{margin:0 0 4px; font-size:13px; font-weight:600; color:var(--muted); letter-spacing:.01em}

.hero{text-align:left}
.hero .big{font-size:40px; font-weight:800; letter-spacing:-.03em; line-height:1.05; margin:6px 0 2px}
.hero .big.neg{color:var(--danger)}
.hero .sub{font-size:14px; color:var(--muted)}

.pill{display:inline-flex; align-items:center; gap:6px; font-size:12.5px; font-weight:600;
  padding:5px 11px; border-radius:999px; background:var(--accent-soft); color:var(--accent)}
.pill.warn{background:var(--warn-soft); color:var(--warn)}
.pill.danger{background:var(--danger-soft); color:var(--danger)}

/* список рядків */
.row{display:flex; align-items:center; gap:14px; padding:14px 0; border-bottom:1px solid var(--line)}
.row:last-child{border-bottom:0}
.row .ic{width:40px; height:40px; flex:none; border-radius:12px; display:grid; place-items:center;
  background:var(--surface-2); font-size:17px}
.row .body{flex:1; min-width:0}
.row .t{font-size:15px; font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.row .s{font-size:13px; color:var(--muted); margin-top:1px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.row .v{font-size:15.5px; font-weight:700; white-space:nowrap; text-align:right}
.row .v small{display:block; font-size:12px; font-weight:500; color:var(--muted); margin-top:1px}
.row.off{opacity:.45}
.row.off .v{text-decoration:line-through}

/* прогрес ліміту */
.meter{height:8px; border-radius:99px; background:var(--surface-2); overflow:hidden; margin:12px 0 8px}
.meter i{display:block; height:100%; border-radius:99px; background:var(--accent); transition:width .3s}
.meter.warn i{background:var(--warn)} .meter.danger i{background:var(--danger)}
.meterfoot{display:flex; justify-content:space-between; font-size:12.5px; color:var(--muted)}

/* ── кнопки й поля ──────────────────────────────────────── */
.btn{
  display:block; width:100%; height:52px; border:0; border-radius:var(--radius-sm);
  background:var(--accent); color:var(--accent-ink); font-size:16px; font-weight:700;
  cursor:pointer; transition:opacity .15s;
}
.btn:active{opacity:.75}
.btn.ghost{background:var(--surface); color:var(--ink); box-shadow:var(--shadow)}
.btn.quiet{background:transparent; color:var(--accent); height:44px; font-weight:600}
.btn[disabled]{opacity:.5; cursor:default}

.field{margin-bottom:12px}
.field label{display:block; font-size:13px; font-weight:600; color:var(--muted); margin-bottom:6px}
.input{
  width:100%; height:52px; padding:0 16px; border:0; border-radius:var(--radius-sm);
  background:var(--surface); box-shadow:var(--shadow); font-size:16px;
}
.input:focus{outline:2px solid var(--accent); outline-offset:0}

/* ── нижня навігація ────────────────────────────────────── */
.tabs{
  position:fixed; left:0; right:0; bottom:0; z-index:30;
  display:grid; grid-template-columns:repeat(4,1fr);
  background:var(--surface); border-top:1px solid var(--line);
  padding-bottom:env(safe-area-inset-bottom,0px);
}
.tabs button{
  height:var(--tab-h); background:none; border:0; cursor:pointer;
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px;
  color:var(--muted); font-size:11px; font-weight:600;
}
.tabs button[aria-selected="true"]{color:var(--accent)}
.tabs svg{width:22px; height:22px}

/* ── шторка ─────────────────────────────────────────────── */
.sheet-bg{position:fixed; inset:0; background:rgba(0,0,0,.4); z-index:40; opacity:0; pointer-events:none; transition:opacity .2s}
.sheet-bg.open{opacity:1; pointer-events:auto}
.sheet{
  position:fixed; left:0; right:0; bottom:0; z-index:41;
  background:var(--surface); border-radius:24px 24px 0 0;
  padding:8px 16px calc(env(safe-area-inset-bottom,0px) + 16px);
  transform:translateY(100%); transition:transform .25s cubic-bezier(.32,.72,0,1);
  max-height:82vh; overflow:auto;
}
.sheet.open{transform:none}
.sheet .grab{width:38px; height:4px; border-radius:99px; background:var(--line); margin:6px auto 14px}
.sheet h3{margin:0 0 12px; font-size:17px; font-weight:700}

/* ── дрібне ─────────────────────────────────────────────── */
.empty{text-align:center; color:var(--muted); font-size:14.5px; padding:40px 20px}
.toast{
  position:fixed; left:50%; bottom:calc(var(--tab-h) + 24px); transform:translateX(-50%) translateY(12px);
  background:var(--ink); color:var(--bg); padding:12px 18px; border-radius:12px; font-size:14px;
  font-weight:600; z-index:60; opacity:0; pointer-events:none; transition:.2s; max-width:88vw; text-align:center;
}
.toast.show{opacity:1; transform:translateX(-50%)}
.mgrid{display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin-top:4px}
.mcell{background:var(--surface-2); border-radius:12px; padding:10px}
.mcell span{display:block; font-size:11px; color:var(--muted)}
.mcell b{display:block; font-size:13.5px; font-weight:700; margin-top:2px}
.hidden{display:none!important}
@media (prefers-reduced-motion:reduce){*{transition:none!important}}
