:root {
  --bg: #3d404a; --bg2: #4b4e5a; --bg3: #555866; --line: #5d606d;
  --text: #f3f3f5; --muted: #b6b8c3; --dim: #8d909c;
  --accent: #45cfc4; --accent-d: #34a99f;
  --red: #ff7b72; --red-bg: #6a3c40; --green: #7fdc95; --green-bg: #36584a;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { overscroll-behavior-y: contain; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg2); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 12px; width: 100%; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; }
.splash { display: grid; place-items: center; height: 100vh; color: var(--muted); }

/* ---------- Układ ---------- */
.wrap { max-width: 760px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(86px + var(--safe-b)); }
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: calc(10px + var(--safe-t)) 14px 8px; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.top h1 { font-size: 24px; margin: 0; font-weight: 700; text-align: center; flex: 1; letter-spacing: .2px; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; color: var(--text); flex: none; }
.icon-btn:active { background: var(--bg2); }
.sync { width: 42px; height: 42px; display: grid; place-items: center; flex: none; }
.sync i { width: 10px; height: 10px; border-radius: 50%; background: var(--dim); display: block; }
.sync.ok i { background: var(--green); } .sync.pending i { background: #f5c451; } .sync.err i { background: var(--red); }
.tbb { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 6px; font-size: 17px; }
.pill { display: inline-block; padding: 5px 14px; border-radius: 999px; background: var(--bg2); color: var(--dim); font-weight: 600; white-space: nowrap; }
.pill.pos { background: var(--green-bg); color: var(--green); } .pill.neg { background: var(--red-bg); color: var(--red); }
.pill.zero { color: var(--dim); }
.content { padding: 0 12px; }

/* ---------- Budżet ---------- */
.cols { display: grid; grid-template-columns: 1fr 112px 112px; gap: 8px; padding: 12px 14px 4px; color: var(--muted); font-size: 13px; letter-spacing: .6px; }
.cols .r { text-align: right; } .cols .sum { color: var(--text); font-size: 15px; letter-spacing: 0; margin-top: 4px; }
.group { margin-top: 14px; }
.group-h { display: grid; grid-template-columns: 1fr 112px 112px; gap: 8px; align-items: center; background: var(--bg2);
  padding: 10px 14px; font-weight: 700; font-size: 17px; border-radius: 4px; }
.group-h span { text-align: right; font-weight: 500; font-size: 15px; }
.cat { display: grid; grid-template-columns: 1fr 112px 112px; gap: 8px; align-items: center; padding: 6px 2px 6px 6px; min-height: 52px; }
.cat-name { display: flex; align-items: center; gap: 10px; min-width: 0; text-align: left; }
.cat-name b { font-weight: 500; font-size: 17px; overflow-wrap: break-word; hyphens: auto; line-height: 1.15; min-width: 0; }
.ico { width: 34px; height: 34px; border-radius: 8px; display: inline-grid; vertical-align: middle; place-items: center; font-size: 18px; flex: none; color: #222; font-weight: 800; }
.alloc { background: var(--bg3); border-radius: 4px; text-align: right; padding: 12px 10px; font-weight: 600; font-size: 17px; white-space: nowrap; }
.alloc:active { filter: brightness(1.15); }
.avail { text-align: right; } .avail .pill { font-size: 16px; padding: 8px 12px; }
.spent-only { text-align: right; color: var(--muted); font-weight: 600; }
.banner { background: var(--bg2); border-left: 4px solid var(--accent); border-radius: 8px; padding: 12px 14px; margin: 12px 2px; color: var(--muted); font-size: 14px; }
.banner b { color: var(--text); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 2px; }

/* ---------- Przyciski ---------- */
.btn { background: var(--bg2); border-radius: 10px; padding: 11px 16px; font-weight: 600; }
.btn:active { filter: brightness(1.15); }
.btn.primary { background: var(--accent); color: #10302d; }
.btn.danger { background: var(--red-bg); color: var(--red); }
.btn.block { width: 100%; display: block; text-align: center; margin-top: 10px; }
.btn.small { padding: 7px 12px; font-size: 14px; }
.link { color: var(--accent); font-weight: 600; }

/* ---------- Nawigacja dolna ---------- */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--bg); border-top: 1px solid #353841;
  display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px 0 calc(6px + var(--safe-b)); max-width: 760px; margin: 0 auto; }
.nav button { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 12.5px; padding: 4px 0; position: relative; }
.nav button .ni { font-size: 22px; line-height: 1; }
.nav button.on { color: var(--text); }
.nav button.on::after { content: ''; position: absolute; bottom: -6px; left: 18%; right: 18%; height: 3px; background: var(--accent); border-radius: 2px; }
.fab { width: 62px; height: 62px; border-radius: 50%; background: var(--accent); color: #10302d !important; font-size: 34px !important;
  margin: -24px auto 0; display: grid !important; place-items: center; box-shadow: 0 4px 14px rgba(0,0,0,.35); }

/* ---------- Transakcje ---------- */
.search { display: flex; gap: 8px; align-items: center; margin: 4px 0 8px; }
.search input { border-radius: 999px; padding-left: 16px; background: #363943; border-color: transparent; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 6px; align-items: center; color: var(--muted); font-size: 14px; }
.chip { background: var(--bg2); border-radius: 999px; padding: 6px 10px 6px 12px; display: inline-flex; gap: 8px; align-items: center; color: var(--text); font-size: 14px; }
.chip button { color: var(--muted); font-size: 16px; }
.day { font-weight: 700; font-size: 17px; margin: 18px 4px 6px; }
.tx { display: grid; grid-template-columns: 46px 1fr auto; gap: 12px; align-items: center; padding: 8px 4px; width: 100%; text-align: left; border-radius: 10px; }
.tx:active { background: var(--bg2); }
.tx .ico { width: 44px; height: 44px; border-radius: 50%; font-size: 20px; }
.tx-main { min-width: 0; } .tx-main b { display: block; font-weight: 500; font-size: 16.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-main small { color: var(--muted); font-size: 13.5px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-amt { text-align: right; font-weight: 600; font-size: 16.5px; white-space: nowrap; }
.tx-amt small { display: block; color: var(--muted); font-weight: 400; font-size: 13px; }
.tx-amt.inc { color: var(--green); } .tx-amt.tr { color: var(--muted); }
.footer-sum { position: fixed; left: 0; right: 0; bottom: calc(68px + var(--safe-b)); background: #464955; padding: 10px 16px; display: flex; justify-content: flex-end;
  gap: 8px; font-size: 17px; max-width: 760px; margin: 0 auto; z-index: 9; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

/* ---------- Konta / listy ---------- */
.card { background: var(--bg2); border-radius: var(--radius); padding: 14px 16px; margin: 10px 0; }
.card h3 { margin: 0 0 8px; font-size: 15px; color: var(--muted); font-weight: 600; letter-spacing: .3px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); width: 100%; text-align: left; }
.row:first-of-type { border-top: 0; }
.row .sub { display: block; color: var(--muted); font-size: 13px; }
.big { font-size: 26px; font-weight: 700; }
.muted { color: var(--muted); } .dim { color: var(--dim); }
.neg-t { color: var(--red); } .pos-t { color: var(--green); }
.menu-row { display: flex; align-items: center; gap: 12px; padding: 14px 4px; border-top: 1px solid var(--line); width: 100%; text-align: left; font-size: 16.5px; }
.menu-row:first-of-type { border-top: 0; }
.menu-row .mi { width: 28px; text-align: center; font-size: 20px; }
.menu-row .chev { margin-left: auto; color: var(--dim); }

/* ---------- Edytor kategorii ---------- */
.ed-group { background: var(--bg2); border-radius: var(--radius); margin: 12px 0; overflow: hidden; }
.ed-gh { display: flex; align-items: center; gap: 8px; padding: 12px 12px; font-weight: 700; background: #535664; }
.ed-gh .t { flex: 1; } .ed-gh small { font-weight: 400; color: var(--muted); }
.ed-cat { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--line); }
.ed-cat .t { flex: 1; min-width: 0; text-align: left; } .ed-cat .t small { color: var(--muted); display: block; font-size: 12.5px; }
.mv { width: 32px; height: 32px; border-radius: 8px; background: var(--bg3); display: grid; place-items: center; font-size: 14px; flex: none; }

/* ---------- Arkusz (modal) ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--bg); width: 100%; max-width: 620px; max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0;
  padding: 10px 18px calc(22px + var(--safe-b)); animation: up .2s ease-out; }
.sheet .grab { width: 44px; height: 5px; background: var(--line); border-radius: 3px; margin: 2px auto 10px; }
.sheet h2 { margin: 4px 0 6px; font-size: 20px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--bg2); border-radius: 12px; padding: 4px; gap: 4px; margin: 8px 0; }
.seg button { padding: 9px 4px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--bg3); color: var(--text); }
.amount-in { font-size: 34px; font-weight: 700; text-align: center; padding: 10px; background: transparent; border: 0; border-bottom: 2px solid var(--line); border-radius: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; margin: 14px 0 4px; color: var(--text); font-size: 15px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.colors { display: flex; flex-wrap: wrap; gap: 8px; }
.colors button { width: 34px; height: 34px; border-radius: 8px; border: 2px solid transparent; }
.colors button.on { border-color: #fff; }
.err { color: var(--red); font-size: 14px; margin-top: 10px; min-height: 1em; }
.note { color: var(--muted); font-size: 13.5px; margin: 10px 0; }
.auth { max-width: 420px; margin: 0 auto; padding: calc(40px + var(--safe-t)) 22px 40px; }
.auth h1 { font-size: 28px; margin: 0 0 4px; } .logo { font-size: 46px; margin-bottom: 8px; }
#toast { position: fixed; left: 50%; bottom: calc(150px + var(--safe-b)); transform: translateX(-50%); background: #23252c; color: #fff; padding: 10px 16px;
  border-radius: 10px; font-size: 14.5px; z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 420px) {
  .cols, .group-h, .cat { grid-template-columns: 1fr 96px 100px; }
  .cat-name b { font-size: 15.5px; } .alloc { font-size: 15.5px; padding: 11px 8px; } .avail .pill { font-size: 14.5px; padding: 7px 9px; }
  .group-h { font-size: 15.5px; } .ico { width: 30px; height: 30px; font-size: 16px; }
}
@media (min-width: 900px) { body { background: #33363f; } .wrap { background: var(--bg); } }
