/* Layout: one narrow column (phone first), sticky header with two tabs; review drafts look like receipt strips. */
:root {
  --bg: #f3f5f2;
  --surface: #ffffff;
  --paper: #fbfbf7;
  --ink: #17211d;
  --ink-2: #4b5852;
  --muted: #7a8680;
  --line: #dce2dd;
  --accent: #0d6e56;
  --accent-ink: #ffffff;
  --accent-soft: #e1efe9;
  --bar: #2a78d6;
  --warn: #9a5b00;
  --warn-soft: #fbefd9;
  --danger: #b3261e;
  --font-display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111513; --surface: #191e1b; --paper: #1d2320; --ink: #e7ece8; --ink-2: #b4bfb9; --muted: #85918b;
    --line: #2c3430; --accent: #3dbb92; --accent-ink: #08130f; --accent-soft: #1d3a30; --bar: #3987e5;
    --warn: #f0b356; --warn-soft: #3a2c14; --danger: #f2827b; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111513; --surface: #191e1b; --paper: #1d2320; --ink: #e7ece8; --ink-2: #b4bfb9; --muted: #85918b;
  --line: #2c3430; --accent: #3dbb92; --accent-ink: #08130f; --accent-soft: #1d3a30; --bar: #3987e5;
  --warn: #f0b356; --warn-soft: #3a2c14; --danger: #f2827b; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.5; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
.wrap { max-width: 760px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
header.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); }
header.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 12px; flex-wrap: wrap; }
.brand { font-family: var(--font-display); font-weight: 700; font-size: 1.35rem; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.brand svg { color: var(--accent); }
nav.tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
nav.tabs a { text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: .9rem; padding: 6px 14px; border-radius: 999px; }
nav.tabs a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
nav.tabs a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, label.drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
main .wrap { padding-block: 20px 48px; display: flex; flex-direction: column; gap: 20px; }
h1, h2, h3 { font-family: var(--font-display); margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.eyebrow { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.mono, .amt { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.notice { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 12px 14px; font-size: .9rem; color: var(--ink-2); }
.notice.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }

.inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .inputs { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card h2 { display: flex; align-items: center; gap: 8px; }
.card h2 svg { color: var(--accent); flex: none; }
label.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border: 1.5px dashed var(--line); border-radius: var(--r); padding: 22px 12px; text-align: center; cursor: pointer; color: var(--ink-2); background: var(--paper); min-height: 128px; }
label.drop:hover { border-color: var(--accent); }
label.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
label.drop strong { color: var(--ink); }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.thumbs img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
textarea { width: 100%; min-height: 128px; resize: vertical; font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 8px 14px; font-weight: 600; font-size: .9rem; }
button:hover { border-color: var(--ink-2); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(1.07); }
button.ghost { border-color: transparent; background: transparent; color: var(--ink-2); padding: 6px 8px; }
button.ghost:hover { color: var(--ink); background: var(--accent-soft); }
button.danger { color: var(--danger); }
button:disabled { opacity: .55; cursor: default; filter: none; }
.status { font-size: .88rem; color: var(--ink-2); display: flex; align-items: center; gap: 8px; min-height: 1.4em; }
.status.err { color: var(--danger); }
.spin { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2.4s; } }

/* Review: receipt strips */
#review { display: flex; flex-direction: column; gap: 16px; }
.strip { background: var(--paper); border: 1px solid var(--line); border-radius: 4px; padding: 16px 14px 14px; position: relative; display: flex; flex-direction: column; gap: 10px; font-family: var(--font-mono); font-size: .85rem; min-width: 0; }
.strip::before, .strip::after { content: ""; position: absolute; left: 0; right: 0; height: 8px; background: radial-gradient(circle at 6px 0, var(--bg) 4px, transparent 4.5px) 0 0 / 12px 8px repeat-x; }
.strip::before { top: -1px; }
.strip::after { bottom: -1px; transform: scaleY(-1); }
.strip .head { display: grid; grid-template-columns: 150px 1fr auto; gap: 8px; align-items: center; }
@media (max-width: 480px) { .strip .head { grid-template-columns: 1fr auto; } .strip .head .merchant { grid-column: 1 / -1; grid-row: 2; } }
.strip input, .strip select { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-width: 0; width: 100%; }
.strip .items { display: flex; flex-direction: column; gap: 6px; border-top: 1px dashed var(--line); border-bottom: 1px dashed var(--line); padding-block: 10px; }
.strip .item { display: grid; grid-template-columns: 1fr 130px 96px 30px; gap: 6px; align-items: center; }
@media (max-width: 560px) { .strip .item { grid-template-columns: 1fr 96px 30px; } .strip .item .name { grid-column: 1 / -1; } }
.strip .item input.a { text-align: right; }
.strip .x { padding: 4px; width: 30px; height: 30px; display: grid; place-items: center; }
.strip .foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.strip .total { font-weight: 600; font-size: 1rem; }
.strip .flag { color: var(--warn); font-family: var(--font-body); font-size: .82rem; }
.review-bar { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* Summary */
.monthbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.monthbar h1 { font-size: 1.6rem; text-transform: capitalize; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 640px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; min-width: 0; }
.kpi .v { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 1.2rem; font-weight: 600; margin-top: 2px; overflow-wrap: anywhere; }
.kpi.main .v { color: var(--accent); font-size: 1.35rem; }
.kpi .d { font-size: .8rem; color: var(--muted); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.cats { display: flex; flex-direction: column; gap: 4px; }
.cat { display: grid; grid-template-columns: 96px 1fr 110px; gap: 10px; align-items: center; padding: 5px 6px; border-radius: 6px; border: 0; background: transparent; text-align: left; font-weight: 500; width: 100%; }
.cat:hover { background: var(--accent-soft); border-color: transparent; }
.cat[aria-pressed="true"] { background: var(--accent-soft); }
.cat .track { height: 12px; position: relative; }
.cat .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--bar); border-radius: 0 4px 4px 0; min-width: 2px; }
.cat .val { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: .85rem; }
.cat .val span { color: var(--muted); font-size: .75rem; margin-left: 4px; }
@media (max-width: 420px) { .cat { grid-template-columns: 84px 1fr 92px; gap: 8px; } .cat .val span { display: none; } }
.chartbox { position: relative; overflow-x: auto; }
.chartbox svg { display: block; width: 100%; min-width: 360px; height: auto; }
.chartbox text { fill: var(--muted); font-family: var(--font-mono); font-size: 13px; }
.chartbox .grid { stroke: var(--line); stroke-width: 1; }
.chartbox .col { fill: var(--bar); }
.chartbox .hit { fill: transparent; cursor: pointer; }
.chartbox .hit:hover + .col, .chartbox g.on .col { fill: var(--accent); }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); font-size: .8rem; padding: 6px 9px; border-radius: 6px; white-space: nowrap; transform: translate(-50%, -100%); font-family: var(--font-body); }
.tip b { font-family: var(--font-mono); }
.ai-out { font-size: .95rem; color: var(--ink); white-space: pre-wrap; line-height: 1.6; }
.list { display: flex; flex-direction: column; }
.entry { border-top: 1px solid var(--line); }
.entry:first-child { border-top: 0; }
.entry > button.sum { width: 100%; display: grid; grid-template-columns: 54px 1fr auto; gap: 10px; align-items: center; text-align: left; border: 0; background: transparent; border-radius: 0; padding: 10px 2px; font-weight: 400; }
.entry > button.sum:hover { background: transparent; }
.entry .day { font-family: var(--font-mono); font-size: .8rem; color: var(--muted); line-height: 1.2; }
.entry .day b { display: block; font-size: 1.05rem; color: var(--ink); }
.entry .who { min-width: 0; }
.entry .who .m { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.chip { font-size: .72rem; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--ink-2); font-weight: 500; }
.src { font-size: .72rem; color: var(--muted); }
.entry .tot { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 600; }
.detail { padding: 0 2px 12px 66px; display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 480px) { .detail { padding-left: 2px; } }
.detail table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.detail td { padding: 3px 0; border-bottom: 1px dotted var(--line); vertical-align: top; }
.detail td.c { color: var(--muted); padding-inline: 8px; white-space: nowrap; }
.detail td.a { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { text-align: center; padding: 28px 12px; color: var(--ink-2); display: flex; flex-direction: column; gap: 10px; align-items: center; }
.empty h2 { color: var(--ink); }
.filterline { display: flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--ink-2); }
.rec-list { display: flex; flex-direction: column; }
.rec { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 2px; border-top: 1px solid var(--line); align-items: center; }
.rec:first-child { border-top: 0; }
.rec .n { font-weight: 600; }
.rec .meta { font-size: .8rem; color: var(--muted); }
.rec .amt { font-weight: 600; }
.rec .acts { grid-column: 1 / -1; display: flex; gap: 2px; flex-wrap: wrap; align-items: center; margin-left: -8px; }
.rec.skipped .n, .rec.skipped .amt { text-decoration: line-through; color: var(--muted); }
.recform { display: grid; grid-template-columns: 1fr 140px 110px 80px; gap: 8px; align-items: end; background: var(--paper); border: 1px dashed var(--line); border-radius: var(--r); padding: 12px; }
@media (max-width: 600px) { .recform { grid-template-columns: 1fr 1fr; } .recform .full { grid-column: 1 / -1; } }
.recform label { display: flex; flex-direction: column; gap: 3px; font-size: .75rem; color: var(--muted); font-weight: 600; min-width: 0; }
.recform input, .recform select { font: inherit; font-size: .9rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 7px 8px; width: 100%; min-width: 0; }
.recform .btns { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip.fixed { background: var(--warn-soft); color: var(--warn); }
.catchips { display: flex; flex-wrap: wrap; gap: 6px; }
.catchip { display: inline-flex; align-items: center; gap: 2px; padding: 3px 4px 3px 11px; border: 1px solid var(--line); border-radius: 999px; font-size: .85rem; background: var(--paper); font-weight: 500; }
.catchip.def { padding-right: 11px; color: var(--ink-2); background: transparent; }
.catchip.own { border-color: var(--accent); }
.catchip button { padding: 0 7px; border: 0; background: transparent; color: var(--muted); font-size: 1rem; line-height: 1.2; font-weight: 400; }
.catchip button:hover { color: var(--danger); background: transparent; }
.catform { display: grid; grid-template-columns: 180px 1fr auto; gap: 8px; align-items: end; }
@media (max-width: 600px) { .catform { grid-template-columns: 1fr; } }
.catform label { display: flex; flex-direction: column; gap: 3px; font-size: .75rem; color: var(--muted); font-weight: 600; min-width: 0; }
.catform input { font: inherit; font-size: .9rem; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 7px 8px; width: 100%; min-width: 0; }
.strip .item.nc { grid-template-columns: 1fr 220px 96px 30px; }
@media (max-width: 560px) { .strip .item.nc { grid-template-columns: 1fr 96px 30px; } }
.strip .newcat { display: flex; gap: 4px; min-width: 0; }
.strip .newcat input { flex: 1; border-color: var(--accent); }
.strip .newcat button.x:not(.ghost) { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* Logowanie / rejestracja */
body { margin: 0; }
.userbox { display: flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--ink-2); }
.auth { max-width: 420px; margin: 32px auto 0; width: 100%; }
.auth h1 { font-size: 1.5rem; }
.authform { display: flex; flex-direction: column; gap: 12px; }
.authform label { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--muted); font-weight: 600; }
.authform input { font: inherit; font-size: 1rem; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%; }
.authform button.primary { padding: 10px 14px; font-size: 1rem; }
.authlinks { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.authlinks button { padding-inline: 0; }
.notice.ok { background: var(--accent-soft); border-color: transparent; color: var(--ink); }

/* Nagrywanie */
#recBtn[aria-pressed="true"] { background: var(--danger); border-color: var(--danger); color: #fff; }
#recBtn .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: middle; }

/* Podgląd hasła */
.pwwrap { position: relative; }
.pwwrap input { padding-right: 48px; }
.pwtoggle { position: absolute; right: 4px; bottom: 4px; width: 40px; height: 38px; display: grid; place-items: center; padding: 0; color: var(--muted); }
.pwtoggle[aria-pressed="true"] { color: var(--accent); }

/* Wspólny budżet */
.joinpanel { border-color: var(--accent); }
.choice { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.choice label { display: flex; gap: 8px; align-items: center; font-size: .92rem; }
.invitebox { display: flex; flex-direction: column; gap: 8px; background: var(--paper); border: 1px dashed var(--line); border-radius: var(--r); padding: 12px; }
.invitebox input { font: inherit; font-size: .85rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 8px; width: 100%; }
.hhname { grid-template-columns: 1fr auto; }
nav.tabs a { padding-inline: 12px; }
@media (max-width: 420px) { nav.tabs a { padding-inline: 9px; font-size: .85rem; } }

/* Menu konta (awatar) */
.userbox { position: relative; }
.menubtn { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); }
.menubtn[aria-expanded="true"] { border-color: var(--accent); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: .9rem; flex: none; }
.uname { max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
@media (max-width: 520px) { .uname { display: none; } }
.usermenu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; min-width: 230px; max-width: calc(100vw - 32px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 10px 30px rgb(0 0 0 / .14); padding: 6px; display: flex; flex-direction: column; }
.usermenu[hidden] { display: none; }
.usermenu .who { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; }
.usermenu .who b { color: var(--ink); font-size: .95rem; }
.usermenu a, .usermenu button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; text-decoration: none; color: var(--ink); background: transparent; border: 0; border-radius: 8px; padding: 10px; font-weight: 600; font-size: .92rem; }
.usermenu a svg, .usermenu button svg { color: var(--ink-2); flex: none; }
.usermenu a:hover, .usermenu button:hover, .usermenu a:focus-visible, .usermenu button:focus-visible { background: var(--accent-soft); }
.usermenu a[aria-current="page"] { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Strony: Udostępnij budżet, Konto */
.pageview { display: flex; flex-direction: column; gap: 16px; }
.pageview[hidden] { display: none; }
.pagehead { display: flex; flex-direction: column; gap: 6px; }
.pagehead h1 { font-size: 1.4rem; }
.acctform { display: flex; flex-direction: column; gap: 12px; }
.acctform label { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--muted); font-weight: 600; }
.acctform input { font: inherit; font-size: 1rem; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%; }
.dangerzone { border-color: var(--danger); }
.dangerzone h2 { color: var(--danger); }
.dangerzone button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
/* Telefon: logo i awatar w pierwszym wierszu, zakładki pod spodem na całą szerokość */
@media (max-width: 640px) {
  header.top .wrap { row-gap: 10px; }
  .userbox { margin-left: auto; }
  nav.tabs { order: 3; flex-basis: 100%; }
  nav.tabs a { flex: 1; text-align: center; }
}
