/* Kwita — style. Mobile first, jasny i ciemny motyw z systemu. */

:root {
  --bg: #f3f6f5;
  --card: #ffffff;
  --card-2: #f7faf9;
  --text: #10201d;
  --muted: #5d6f6a;
  --line: #e1e8e5;
  --brand: #0f766e;
  --brand-2: #14b8a6;
  --brand-ink: #ffffff;
  --brand-soft: #e3f3ef;
  --pos: #15803d;
  --pos-soft: #e7f6ec;
  --neg: #c2410c;
  --neg-soft: #fdf0e7;
  --danger: #dc2626;
  --warn: #b45309;
  --shadow: 0 1px 2px rgba(16, 32, 29, .05), 0 6px 20px rgba(16, 32, 29, .06);
  --shadow-lg: 0 10px 40px rgba(16, 32, 29, .18);
  --r: 18px;
  --r-sm: 12px;
  --tabbar: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1614;
    --card: #14211e;
    --card-2: #182824;
    --text: #e6efec;
    --muted: #93a8a2;
    --line: #243632;
    --brand: #2dd4bf;
    --brand-2: #14b8a6;
    --brand-ink: #03201c;
    --brand-soft: #123631;
    --pos: #4ade80;
    --pos-soft: #12301f;
    --neg: #fb923c;
    --neg-soft: #36210f;
    --danger: #f87171;
    --warn: #fbbf24;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 100%/1.45 system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
body.noscroll { position: fixed; left: 0; right: 0; overflow: hidden; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75em; }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
small { font-size: .8em; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }

#app { max-width: 620px; margin: 0 auto; min-height: 100dvh; }
.page { padding: 12px 16px calc(28px + var(--safe-b)); }
.page.with-tabs { padding-bottom: calc(var(--tabbar) + 24px + var(--safe-b)); }
.page.center { display: grid; place-items: center; min-height: 60dvh; }

.boot { display: grid; place-items: center; gap: 8px; min-height: 80dvh; align-content: center; color: var(--muted); font-weight: 600; }
.boot img { border-radius: 18px; box-shadow: var(--shadow); }
.noscript { padding: 24px; text-align: center; }
#storage-warn { position: sticky; top: 0; z-index: 60; background: var(--danger); color: #fff; font-size: .85rem; font-weight: 600; padding: calc(8px + var(--safe-t)) 16px 8px; text-align: center; }

/* ---------- nagłówki */


.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 6px;
  padding: calc(8px + var(--safe-t)) 8px 8px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.top-title { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.top-title h1 { font-size: 1.05rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px; flex: none;
  border: 0; border-radius: 12px; background: transparent; color: var(--text);
}
.icon-btn:active { background: var(--line); }
.icon-btn[disabled] { opacity: .3; pointer-events: none; }
.icon-btn.small { width: 40px; height: 40px; }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn-spacer { width: 42px; flex: none; }

.sync-pill {
  display: inline-flex; align-items: center; gap: 5px; min-height: 28px;
  border: 0; background: transparent; padding: 4px 10px; margin: -4px 0; border-radius: 99px;
  font-size: .74rem; font-weight: 600; color: var(--muted);
}
.sync-pill svg { width: 13px; height: 13px; stroke-width: 2.5; }
.sync-pill.ok { color: var(--pos); }
.sync-pill.busy svg { animation: spin 1s linear infinite; }
.sync-pill.off { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.sync-pill.err { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
@keyframes spin { to { transform: rotate(360deg); } }

.section-title { font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 4px 10px; }

/* ---------- karty i przyciski */

.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; margin: 0 0 14px; }
.card > h2 { margin-bottom: 12px; }
.card p:last-child { margin-bottom: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--card); color: var(--text); font-weight: 600;
  transition: transform .08s ease, background .15s ease;
  text-align: center;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.big { min-height: 54px; font-size: 1.05rem; border-radius: 16px; }
.btn.small { min-height: 40px; padding: 0 14px; font-size: .88rem; border-radius: 11px; }
.btn.full { width: 100%; justify-content: flex-start; margin-bottom: 8px; }
.form > .btn.big { width: 100%; }
.btn.grow { flex: 1; }
.link-btn.inline { padding: 4px 2px; margin: 0; font-size: inherit; }
.link-btn { border: 0; background: none; color: var(--brand); font-weight: 600; padding: 10px 4px; margin: -6px 0; font-size: .88rem; text-align: left; }

.row { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.stack { display: grid; gap: 10px; margin: 16px 0; }
.stack.narrow { max-width: 320px; margin: 0 auto; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; flex: none; max-width: 100%; min-width: 0;
  min-height: 44px; padding: 0 14px; border-radius: 99px;
  border: 1.5px solid var(--line); background: var(--card); font-weight: 600; font-size: .93rem;
}
.chip.on { border-color: var(--brand); background: var(--brand-soft); color: var(--text); }
.chip.fam.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, var(--card)); }
.chip-label, .fam-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips-label { align-self: center; flex: none; font-size: .8rem; font-weight: 700; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--brand)); flex: none; }
.fam-tag { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; white-space: nowrap; min-width: 0; max-width: 100%; }

.badge { font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); }
.hint { display: block; color: var(--muted); font-size: .84rem; margin: 6px 2px 0; }
.form-error { color: var(--danger); font-weight: 600; font-size: .9rem; margin: 8px 0 0; min-height: 0; }
.form-error:empty { display: none; }
.form-error.soft { color: var(--muted); font-weight: 500; }
.inline-error { color: var(--danger); font-weight: 600; font-size: .88rem; margin: 6px 4px 10px; }
.invalid { box-shadow: 0 0 0 2px var(--danger) !important; border-radius: var(--r-sm); }
.amount-box.invalid { border-radius: var(--r); }
.rate-input.bad { border-color: var(--danger); }
.warn { color: var(--warn); font-weight: 600; }
.footnote { text-align: center; color: var(--muted); font-size: .8rem; margin: 20px 12px 0; }

/* ---------- formularze */

.field { display: block; margin: 0 0 16px; }
.label { display: block; font-size: .82rem; font-weight: 700; color: var(--muted); margin: 0 2px 7px; text-transform: uppercase; letter-spacing: .04em; }
.label small { text-transform: none; letter-spacing: 0; font-weight: 500; }
.input {
  width: 100%; min-height: 48px; padding: 11px 14px;
  border: 1.5px solid var(--line); border-radius: var(--r-sm);
  background: var(--card-2); font-size: 16px;
  -webkit-appearance: none; appearance: none;
}
.input:focus { outline: none; border-color: var(--brand); background: var(--card); }
select.input { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
select.input:disabled { opacity: .6; }
textarea.input { resize: vertical; min-height: 70px; line-height: 1.4; }

.fam-editor { display: grid; gap: 10px; }
.fam-row { display: flex; align-items: center; gap: 8px; }
.fam-row .input { flex: 1; min-width: 0; }
.color-dot { width: 32px; height: 32px; flex: none; border-radius: 50%; border: 3px solid var(--card); background: var(--c); box-shadow: 0 0 0 1.5px var(--line); margin: 0 4px; }
/* Na telefonie: nazwa rodziny na całą szerokość, liczba osób pod nią. */
@media (max-width: 480px) {
  .fam-row { flex-wrap: wrap; row-gap: 6px; }
  .fam-row .color-dot { order: 0; }
  .fam-row .input { order: 1; flex: 1 1 0; }
  .fam-row .icon-btn { order: 2; }
  .fam-row::after { content: ''; order: 3; flex-basis: 100%; height: 0; }
  .fam-row .stepper { order: 4; margin-left: 44px; }
}
.stepper { display: flex; align-items: center; border: 1.5px solid var(--line); border-radius: var(--r-sm); background: var(--card-2); flex: none; }
.stepper button { width: 42px; height: 44px; border: 0; background: none; font-size: 1.25rem; font-weight: 600; color: var(--brand); }
.stepper button[disabled] { color: var(--line); }
.stepper span { min-width: 48px; text-align: center; font-size: .85rem; color: var(--muted); white-space: nowrap; }
.stepper b { color: var(--text); font-size: 1rem; }

.choice { display: grid; gap: 8px; }
.choice-item { text-align: left; padding: 12px 14px; border-radius: var(--r-sm); border: 1.5px solid var(--line); background: var(--card-2); display: grid; gap: 2px; }
.choice-item b { font-size: .98rem; }
.choice-item span { font-size: .85rem; color: var(--muted); }
.choice-item.on { border-color: var(--brand); background: var(--brand-soft); }

.seg { display: flex; background: var(--card-2); border: 1.5px solid var(--line); border-radius: 13px; padding: 3px; gap: 3px; margin-bottom: 12px; }
.seg button { flex: 1; min-height: 42px; border: 0; background: transparent; border-radius: 10px; font-weight: 600; font-size: .92rem; color: var(--muted); }
.seg button.on { background: var(--brand-soft); color: var(--brand); box-shadow: inset 0 0 0 1.5px var(--brand); }
.seg.small { margin: 0; }
.seg.small button { min-height: 40px; padding: 0 14px; }

.link-box { background: var(--card-2); border: 1.5px dashed var(--line); border-radius: var(--r-sm); padding: 10px 12px; margin: 10px 0; overflow-wrap: anywhere; }
.link-box code { font: 500 .82rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); }

/* ---------- ekran startowy */

.home-top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
}
.home-logo { display: inline-flex; align-items: center; gap: 10px; font-size: 1.28rem; font-weight: 800; letter-spacing: -.03em; }
.home-logo img { border-radius: 10px; box-shadow: 0 1px 2px rgba(16, 32, 29, .12); }
.home-acc {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  background: var(--brand); color: var(--brand-ink); font-weight: 800; font-size: .95rem;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}
.home-login {
  display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 14px;
  border-radius: 99px; border: 1px solid var(--line); background: var(--card);
  color: var(--text); font-weight: 600; font-size: .9rem;
}
.home-login svg { width: 17px; height: 17px; color: var(--brand); }

.page.home { padding-top: 6px; }
.home-intro { margin: 8px 2px 16px; }
.home-intro h1 { font-size: 1.9rem; font-weight: 800; letter-spacing: -.035em; }
.home-intro p { margin: 4px 0 0; color: var(--muted); font-size: .92rem; }

.home-actions { display: grid; grid-template-columns: 1.35fr 1fr; gap: 10px; margin: 0 0 18px; }
.home-actions .btn { min-height: 50px; border-radius: 14px; }

/* Pusty ekran */
.home-hero { text-align: center; padding: 18px 6px 4px; }
.home-hero h1 { font-size: 1.7rem; font-weight: 800; letter-spacing: -.035em; line-height: 1.15; margin: 6px 0 10px; }
.home-hero p { color: var(--muted); max-width: 26em; margin: 0 auto; font-size: 1rem; }
.home-hero .stack { max-width: 360px; margin: 22px auto 0; }
.home-hero.compact h1 { font-size: 1.45rem; }
.hero-art { width: 150px; height: 112px; margin: 0 auto 4px; display: block; overflow: visible; }
.hero-art .ha-paper { fill: var(--card); stroke: var(--line); stroke-width: 1.5; filter: drop-shadow(0 6px 14px rgba(16, 32, 29, .10)); }
.hero-art .ha-back { fill: var(--card-2); }
.hero-art .ha-line { stroke: var(--line); stroke-width: 5; stroke-linecap: round; }
.hero-art .ha-strong { stroke: var(--brand); opacity: .75; }
.hero-art .ha-badge { fill: var(--brand); stroke: none; }
.hero-art .ha-check { stroke: var(--brand-ink); stroke-width: 4; fill: none; }

.home-features { list-style: none; margin: 26px 0 8px; padding: 6px 16px; background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); }
.home-features li { display: flex; gap: 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.home-features li:first-child { border-top: 0; }
.home-features b { display: block; font-size: .95rem; }
.home-features li > span:last-child { color: var(--muted); font-size: .86rem; line-height: 1.35; }
.hf-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--brand-soft); color: var(--brand); }
.hf-icon svg { width: 19px; height: 19px; }

/* Karty wyjazdów */
.trip-list { display: grid; gap: 12px; }
.trip-card {
  display: block; background: var(--card); border-radius: var(--r); box-shadow: var(--shadow);
  padding: 14px 14px 12px 16px; color: var(--text); border: 1px solid transparent;
  transition: transform .12s ease, box-shadow .12s ease;
}
.trip-card:active { transform: scale(.985); }
@media (hover: hover) { .trip-card:hover { box-shadow: var(--shadow), 0 0 0 1px color-mix(in srgb, var(--brand) 25%, transparent); } }
.tc-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tc-mono {
  width: 44px; height: 44px; border-radius: 13px; flex: none; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--h), color-mix(in srgb, var(--h) 70%, #000));
  color: #fff; font-weight: 800; font-size: 1rem; letter-spacing: .02em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18);
}
.tc-mono.small { width: 36px; height: 36px; border-radius: 11px; font-size: .85rem; }
.tc-title { flex: 1; min-width: 0; display: grid; gap: 2px; }
.tc-title h2 { font-size: 1.08rem; font-weight: 700; letter-spacing: -.015em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-title .muted { font-size: .84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-chev { color: var(--muted); opacity: .6; display: grid; }
.tc-chev svg { width: 18px; height: 18px; }
.tc-foot {
  display: flex; align-items: center; gap: 12px; margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--line);
}
.tc-fams { display: inline-flex; flex: none; padding-left: 6px; }
.tc-fams i {
  width: 26px; height: 26px; margin-left: -6px; border-radius: 50%; display: grid; place-items: center;
  background: var(--c, var(--muted)); color: #fff; font-style: normal; font-weight: 700; font-size: .72rem;
  box-shadow: 0 0 0 2px var(--card);
}
.tc-fams i.more { background: var(--card-2); color: var(--muted); }
.tc-total, .tc-status { display: grid; gap: 1px; line-height: 1.2; min-width: 0; }
.tc-total { flex: 1; }
.tc-total small, .tc-status small { font-size: .68rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.tc-total b, .tc-status b { font-variant-numeric: tabular-nums; white-space: nowrap; font-size: .98rem; }
.tc-status { text-align: right; justify-items: end; padding: 6px 10px; border-radius: 12px; }
.tc-status.pos { background: var(--pos-soft); }
.tc-status.pos b, .tc-status.pos small { color: var(--pos); }
.tc-status.neg { background: var(--neg-soft); }
.tc-status.neg b, .tc-status.neg small { color: var(--neg); }
.tc-status.open { background: var(--card-2); }
.tc-status.even { background: var(--pos-soft); color: var(--pos); font-weight: 700; font-size: .88rem; }
.tc-status.none { color: var(--muted); font-size: .86rem; }

/* Zakończone wyjazdy — zwarta lista */
.trip-list.past { gap: 0; background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.trip-card.past {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 0; box-shadow: none;
  border: 0; border-top: 1px solid var(--line);
}
.trip-card.past:first-child { border-top: 0; }
.past-body { flex: 1; min-width: 0; display: grid; gap: 1px; }
.past-body b { font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.past-body .muted { font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.past-side { display: grid; justify-items: end; gap: 1px; font-size: .88rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.past-side span { font-size: .74rem; }
.even-mini { color: var(--pos); font-weight: 700; }

/* Banery (konto, instalacja) */
.home-banner {
  position: relative; display: flex; align-items: stretch; margin: 14px 0 0;
  background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden;
}
.home-banner .hb-main, .home-banner.static {
  flex: 1; display: flex; align-items: center; gap: 12px; padding: 13px 14px; min-width: 0;
  border: 0; background: none; text-align: left; color: var(--text);
}
.home-banner.static { padding: 13px 14px; }
.hb-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--brand-soft); color: var(--brand); }
.hb-icon svg { width: 19px; height: 19px; }
.hb-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.hb-text b { font-size: .93rem; }
.hb-text span { font-size: .82rem; color: var(--muted); line-height: 1.35; }
.hb-text span svg { width: 14px; height: 14px; vertical-align: -2px; color: var(--brand); }
.hb-chev { color: var(--muted); opacity: .6; display: grid; }
.hb-chev svg { width: 18px; height: 18px; }
.hb-close { border: 0; background: none; color: var(--muted); width: 40px; flex: none; display: grid; place-items: center; }
.hb-close svg { width: 16px; height: 16px; }
.home-banner .hb-main:has(+ .hb-close) .hb-chev { display: none; }

.callout-actions { margin-top: 20px; }
.home-foot { text-align: center; color: var(--muted); font-size: .8rem; margin: 22px 12px 0; line-height: 1.5; }

.callout { border: 2px solid var(--brand); }
.callout .btn { width: 100%; margin-top: 8px; }
.install { display: flex; gap: 12px; align-items: center; }
.install > div:first-child { color: var(--brand); }
.install > div:nth-child(2) { flex: 1; }
.install h3 { margin-bottom: 3px; }
.install p { font-size: .86rem; color: var(--muted); margin: 0; }
.install p svg { width: 15px; height: 15px; vertical-align: -2px; color: var(--brand); }

/* ---------- lista wydatków */

.hero {
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 1px;
  background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 55%, var(--brand-2)));
  color: #fff; border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 14px;
}
@media (prefers-color-scheme: dark) { .hero { background: linear-gradient(135deg, #0f766e, #115e59); } }
.hero > * { padding: 14px 16px; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.hero .lbl { font-size: .76rem; font-weight: 700; opacity: .95; text-transform: uppercase; letter-spacing: .05em; overflow-wrap: anywhere; }
.hero strong { font-size: clamp(1.15rem, 6.2vw, 1.55rem); font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.hero .sub { font-size: .82rem; opacity: .95; }
.hero-side { background: rgba(0, 0, 0, .2); color: #fff; }
.hero-side strong { font-size: clamp(1rem, 5vw, 1.2rem); }
.hero-side strong.pos, .hero-side strong.neg { color: #fff; }
.hero-side .muted { color: rgba(255, 255, 255, .85); font-size: .88rem; }

.filters { display: grid; gap: 10px; margin: 0 0 6px; }
.search { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1.5px solid var(--line); border-radius: 13px; padding: 0 12px; color: var(--muted); }
.search:focus-within { border-color: var(--brand); }
.search input { flex: 1; border: 0; background: none; min-height: 44px; outline: none; font-size: 16px; color: var(--text); }
.filters .chip { min-height: 38px; font-size: .86rem; padding: 0 12px; }

.day h3 { display: flex; justify-content: space-between; font-size: .85rem; font-weight: 700; color: var(--muted); margin: 18px 6px 8px; font-variant-numeric: tabular-nums; }
.items { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 14px; border: 0; background: none; text-align: left;
  border-top: 1px solid var(--line);
}
.item:first-child { border-top: 0; }
.item:active { background: var(--card-2); }
.item.flash { animation: flash 1.6s ease; }
@keyframes flash { 0%, 30% { background: var(--brand-soft); } 100% { background: transparent; } }
.item-icon { width: 42px; height: 42px; border-radius: 13px; background: var(--card-2); display: grid; place-items: center; font-size: 1.3rem; flex: none; }
.item.transfer .item-icon { background: var(--pos-soft); }
.item.income .item-icon { background: var(--pos-soft); }
.item.income .item-amt strong { color: var(--pos); }
.item-meta .inc { color: var(--pos); font-weight: 700; }
.kind-hint { margin: -4px 2px 12px; }
.seg.kinds button { padding: 0 10px; }
.item-body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.item-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; min-width: 0; }
.item-title .fam-tag { flex: 0 1 auto; }
.item-title svg { width: 14px; height: 14px; color: var(--muted); }
.item-meta { font-size: .82rem; color: var(--muted); display: block; }
.item-meta .dot { width: 8px; height: 8px; vertical-align: 1px; margin-right: 5px; }
.item-meta .new { margin-left: 4px; }
.item-err { display: block; }
.item-meta .clip svg { width: 13px; height: 13px; vertical-align: -2px; }
.item-amt { text-align: right; display: grid; justify-items: end; gap: 1px; flex: none; }
.item-amt strong { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.item-amt small { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.item-amt .wait svg { width: 13px; height: 13px; color: var(--warn); }
.item-err { font-size: .8rem; font-weight: 600; color: var(--danger); white-space: normal; }
.new { font-size: .68rem; font-weight: 800; color: var(--brand-ink); background: var(--brand); padding: 1px 6px; border-radius: 99px; text-transform: uppercase; letter-spacing: .04em; }
.card-list { margin-bottom: 14px; }
.new-strip { font-size: .85rem; color: var(--muted); margin: 0 4px 10px; display: flex; gap: 8px; align-items: center; }

.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.empty-state { text-align: center; padding: 34px 16px; }
.empty-state h2 { margin-bottom: 8px; }
.empty-state p { color: var(--muted); max-width: 26em; margin: 0 auto 18px; }
.big-emoji { font-size: 2.8rem; margin-bottom: 8px; }
.fab-space { height: 70px; }

.fab {
  position: fixed; z-index: 30;
  right: max(16px, calc(50vw - 310px + 16px));
  bottom: calc(var(--tabbar) + 16px + var(--safe-b));
  width: 60px; height: 60px; border-radius: 20px; border: 0;
  background: var(--brand); color: var(--brand-ink);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--brand) 45%, transparent), var(--shadow);
  display: grid; place-items: center;
}
.fab svg { width: 28px; height: 28px; stroke-width: 2.5; }
.fab:active { transform: scale(.94); }

.tabbar {
  position: fixed; z-index: 25; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center;
  padding: 6px max(8px, calc(50vw - 310px)) calc(6px + var(--safe-b));
  background: color-mix(in srgb, var(--card) 90%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar a { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; font-size: .7rem; font-weight: 600; color: var(--muted); border-radius: 12px; }
.tabbar a svg { width: 23px; height: 23px; }
.tabbar a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabbar a.on { color: var(--brand); }
.tab-dot { position: absolute; top: 4px; left: calc(50% + 9px); width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.tabbar a.on svg { stroke-width: 2.4; }

/* ---------- rozliczenie */

.settle-card h2 { margin-bottom: 8px; }
.settle-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.settle-row:first-of-type { border-top: 0; }
.settle-who { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 1.02rem; }
.settle-who .fam-tag { flex: 0 1 auto; }
.settle-who .arrow { flex: none; }
.settle-who .arrow svg { width: 18px; height: 18px; color: var(--muted); }
.settle-amt { white-space: nowrap; font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
@media (max-width: 380px) {
  .settle-who { grid-column: 1 / -1; }
  .settle-amt { text-align: left; }
}
.settle-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.settle-row > .pay-chip, .settle-row > .pay-add { grid-column: 1 / -1; justify-self: start; }
.pay-add { display: inline-flex; max-width: 100%; min-width: 0; }
.pay-add span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-left: .3em; }
.pay-chip { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 12px; border-radius: 11px; border: 1.5px dashed var(--line); background: var(--card-2); font-size: .86rem; font-weight: 600; font-variant-numeric: tabular-nums; max-width: 100%; }
.pay-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pay-chip svg { width: 15px; height: 15px; color: var(--muted); }
.fam-pay { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: .88rem; font-weight: 600; }
.fam-pay span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.fam-pay svg { width: 16px; height: 16px; color: var(--muted); }
.fam-pay-add { margin-top: 8px; }
.even { font-size: 1.3rem; font-weight: 800; color: var(--pos); padding: 10px 0 4px; }

.fam-grid { display: grid; gap: 12px; margin-bottom: 14px; }
@media (min-width: 540px) { .fam-grid { grid-template-columns: 1fr 1fr; } }
.fam-card { margin: 0; border-top: 4px solid var(--c); }
.fam-card header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; min-width: 0; }
.fam-card header h3 { font-size: 1.08rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fam-card header .muted { font-size: .85rem; margin-right: auto; }
.fam-card dl { margin: 0; display: grid; gap: 6px; }
.fam-card dl div { display: flex; justify-content: space-between; gap: 10px; font-size: .93rem; }
.fam-card dd { white-space: nowrap; }
.fam-card dt { color: var(--muted); }
.fam-card dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; }
.balance { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding: 10px 12px; border-radius: 12px; font-weight: 700; }
.balance strong { font-size: 1.12rem; font-variant-numeric: tabular-nums; }
.balance.pos { background: var(--pos-soft); color: var(--pos); }
.balance.neg { background: var(--neg-soft); color: var(--neg); }
.balance.zero { background: var(--card-2); color: var(--muted); }

.explain summary { font-weight: 700; cursor: pointer; list-style: none; display: flex; justify-content: space-between; }
.explain summary::after { content: '＋'; color: var(--muted); }
.explain[open] summary::after { content: '－'; }
.explain summary::-webkit-details-marker { display: none; }
.explain p { font-size: .9rem; color: var(--muted); margin: 10px 0 0; }

/* ---------- statystyki */

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 13px 14px; display: grid; gap: 2px; }
.stat span { font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.stat strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat small { color: var(--muted); }

.bars { display: grid; gap: 12px; }
.bar-top { display: flex; justify-content: space-between; gap: 10px; font-size: .92rem; margin-bottom: 5px; min-width: 0; }
.bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.bar-label .wd { display: inline-block; min-width: 2.2em; color: var(--muted); }
.bar-val { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.bar-val small { color: var(--muted); font-weight: 500; margin-left: 4px; }
.bar { height: 8px; background: var(--card-2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }

.fam-costs { display: grid; gap: 10px; }
.fam-cost { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--c) 9%, var(--card)); }
.fam-cost > div:first-child { display: grid; gap: 1px; min-width: 0; }
.fam-cost .muted { font-size: .82rem; }
.fam-cost-nums { text-align: right; display: grid; }
.fam-cost-nums strong { font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.fam-cost-nums small { color: var(--muted); font-variant-numeric: tabular-nums; }

.sticky-save { position: sticky; z-index: 2; bottom: calc(var(--tabbar) + 10px + var(--safe-b)); background: var(--card); padding: 10px 0 2px; margin-top: 4px; box-shadow: 0 -10px 12px -8px color-mix(in srgb, var(--card) 90%, transparent); }

/* ---------- bottom sheet */

#sheet-root { position: fixed; left: 0; right: 0; top: 0; height: 100%; z-index: 50; pointer-events: none; }
#sheet-root.open { pointer-events: auto; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(8, 15, 13, .45); opacity: 0; transition: opacity .2s ease; }
#sheet-root.shown .sheet-backdrop { opacity: 1; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 620px;
  max-height: calc(100% - 24px - var(--safe-t));
  background: var(--bg); border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  /* Wjazd z bliska, nie spod ekranu: pole z fokusem od razu jest tam, gdzie będzie. */
  transform: translateY(28px); opacity: 0;
  transition: transform .22s cubic-bezier(.2, .8, .2, 1), opacity .16s ease;
}
#sheet-root.shown .sheet { transform: none; opacity: 1; }
.sheet:focus { outline: none; }
.sheet.full { height: calc(100% - 12px - var(--safe-t)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 10px 6px; flex: none; }
.sheet-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 6px 16px 16px; }
.sheet.compact .sheet-body { padding: 26px 20px calc(18px + var(--safe-b)); }
.center-body { text-align: center; }
.center-body h2 { font-size: 1.3rem; margin-bottom: 8px; }
.sheet-foot { flex: none; display: flex; gap: 8px; padding: 10px 16px calc(10px + var(--safe-b)); border-top: 1px solid var(--line); background: var(--bg); }
.sheet-foot .btn.ghost.danger { padding: 0 14px; }
.fam-btn { justify-content: flex-start; min-height: 56px; font-size: 1.08rem; border: 2px solid color-mix(in srgb, var(--c) 45%, var(--line)); }
.fam-btn .dot { width: 14px; height: 14px; }
.fam-btn small { margin-left: auto; color: var(--muted); font-weight: 500; }

.amount-box { display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 8px 10px 8px 16px; margin: 4px 0 6px; }
.amount-input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 2.2rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; padding: 6px 0; }
.amount-input::placeholder { color: color-mix(in srgb, var(--muted) 45%, transparent); }
.cur-select { position: relative; flex: none; }
.cur-select select { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; font-size: 16px; }
.cur-select.foreign span { background: color-mix(in srgb, var(--warn) 16%, var(--card)); color: var(--warn); box-shadow: inset 0 0 0 1.5px var(--warn); }
.cur-select span { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); font-weight: 800; letter-spacing: .02em; }
.cur-select span::after { content: '▾'; margin-left: 6px; font-size: .8em; }
.amount-sub { display: flex; align-items: flex-start; gap: 8px; }
.amount-hint { flex: 1; min-width: 0; min-height: 1.3em; font-size: .9rem; color: var(--muted); font-weight: 600; padding: 6px 6px 0; font-variant-numeric: tabular-nums; white-space: pre-wrap; }
.calc-keys { display: flex; gap: 6px; flex: none; }
.calc-key { width: 48px; height: 42px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--card); color: var(--brand); font-size: 1.25rem; font-weight: 700; line-height: 1; }
.calc-key:active { background: var(--brand-soft); }
.rate-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: .88rem; padding: 4px 6px 12px; color: var(--muted); }
.rate-line b { color: var(--text); }
.rate-line .small { flex-basis: 100%; font-size: .82rem; }
.rate-input { width: 110px; min-height: 38px; padding: 6px 10px; }

.cats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
@media (max-width: 360px) { .cats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.cat { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 2px 7px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); font-size: .74rem; font-weight: 600; line-height: 1.1; text-align: center; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.cat span { font-size: 1.3rem; line-height: 1; }
.cat.on { border-color: var(--brand); background: var(--brand-soft); color: var(--text); }

.split-chips .chip { min-height: 44px; }
.split-chips .chip small { color: var(--muted); font-weight: 500; }
.split-chips .chip b { flex: none; margin-left: 4px; padding-left: 9px; border-left: 1.5px solid var(--line); font-variant-numeric: tabular-nums; }
.split-chips .chip:not(.on) { opacity: .75; }
.split-chips .chip:not(.on) b { color: var(--muted); font-weight: 500; }
.custom-split { display: grid; gap: 8px; }
.custom-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.custom-row > span { flex: 1; min-width: 0; }
.custom-row .input { width: 120px; flex: none; text-align: right; font-variant-numeric: tabular-nums; }
.custom-row em { font-style: normal; color: var(--muted); width: 28px; flex: none; }
.custom-rest { font-size: .88rem; font-weight: 600; padding: 4px 2px; display: flex; align-items: center; gap: 6px; }
.custom-rest svg { width: 16px; height: 16px; }
.custom-rest.ok { color: var(--pos); }
.custom-rest.bad { color: var(--warn); }

.date-row { display: flex; gap: 8px; align-items: center; }
.date-row .input { flex: 1; min-width: 0; }
.date-row .chip { min-height: 48px; border-radius: var(--r-sm); }
@media (max-width: 360px) {
  .date-row { flex-wrap: wrap; }
  .date-row .input { flex-basis: 100%; }
  .date-row .chip { flex: 1; justify-content: center; }
}

.receipt { display: flex; align-items: center; gap: 12px; }
.receipt-thumb { width: 84px; height: 84px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card-2); padding: 0; overflow: hidden; position: relative; display: grid; place-items: center; }
.receipt-thumb img { width: 100%; height: 100%; object-fit: cover; display: none; }
.receipt-thumb.ready img { display: block; }
.receipt-thumb.ready .loading-txt { display: none; }
.loading-txt { font-size: .72rem; color: var(--muted); padding: 4px; }
.receipt-add { width: 100%; }
.meta-line { font-size: .8rem; color: var(--muted); text-align: center; margin: 4px 0 0; }

.viewer { position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, .92); display: grid; place-items: center; padding: calc(12px + var(--safe-t)) 12px calc(12px + var(--safe-b)); }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.viewer .icon-btn { position: absolute; top: calc(10px + var(--safe-t)); right: 10px; color: #fff; background: rgba(255, 255, 255, .15); }

/* ---------- toast i ładowanie */

#toast {
  position: fixed; z-index: 90; left: 50%; bottom: calc(var(--tabbar) + 90px + var(--safe-b));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px); width: max-content;
  background: #13201d; color: #fff; padding: 12px 16px; border-radius: 14px; box-shadow: var(--shadow-lg);
  font-weight: 600; font-size: .93rem; transition: opacity .2s ease, transform .2s ease;
}
@media (prefers-color-scheme: dark) { #toast { background: #e6efec; color: #10201d; } }
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { border: 0; background: none; color: var(--brand-2); font-weight: 800; padding: 4px 2px; text-transform: uppercase; font-size: .85rem; letter-spacing: .04em; }
@media (prefers-color-scheme: dark) { #toast button { color: #0f766e; } }

.loader { display: grid; place-items: center; gap: 14px; color: var(--muted); }
.loader span { width: 34px; height: 34px; border-radius: 50%; border: 3.5px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; }
.loader.small { padding: 18px 0; }
.loader.small span { width: 24px; height: 24px; border-width: 3px; }

/* Konto */
.link-btn.center { display: block; text-align: center; margin: 0 auto; }
.link-btn.center svg { width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; }
.link-btn[disabled] { color: var(--muted); font-weight: 500; }
.row.spread { justify-content: space-between; flex-wrap: wrap; }
.row.center-row { justify-content: center; }
.acc-nag .row { margin-top: 10px; }
.acc-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; min-width: 0; }
.acc-head > div { display: grid; min-width: 0; }
.acc-head b { overflow-wrap: anywhere; }
.acc-icon { width: 42px; height: 42px; border-radius: 13px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex: none; }
.code-input { font-size: 1.7rem; font-weight: 700; letter-spacing: .28em; text-align: center; font-variant-numeric: tabular-nums; }
.code-input::placeholder { letter-spacing: .28em; color: var(--line); }
.footnote a { display: inline-flex; align-items: center; gap: 5px; color: var(--brand); font-weight: 600; max-width: 100%; }
.footnote a span { overflow-wrap: anywhere; }
.footnote a svg { width: 15px; height: 15px; }

/* Lista wyjazdów: historia */
.year-title { font-size: .85rem; font-weight: 700; color: var(--muted); margin: 14px 6px 8px; font-variant-numeric: tabular-nums; }
.open-mini { color: var(--warn); font-weight: 700; }

/* Historia zmian */
.hist-intro { margin: 2px 4px 4px; }
.item.hist { align-items: flex-start; }
.item.hist.tappable { cursor: pointer; }
.item.hist.tappable:active { background: var(--card-2); }
.item.hist .item-icon { font-size: 1.1rem; }
.item.hist .item-title { white-space: normal; display: block; overflow-wrap: anywhere; }
.item.hist .item-meta .fam-tag { vertical-align: -3px; }
.hist-diff { list-style: none; margin: 4px 0 0; padding: 0; font-size: .84rem; display: grid; gap: 2px; }
.hist-diff li { overflow-wrap: anywhere; }
.hist-diff li::before { content: '· '; color: var(--muted); }
.item-amt .btn.small { min-height: 44px; margin-top: 6px; }
.strike { text-decoration: line-through; color: var(--muted); }
.warn-card { color: var(--warn); font-weight: 600; font-size: .9rem; }

@media (min-width: 700px) {
  .sheet { bottom: 24px; border-radius: 22px; max-height: calc(100% - 48px); }
  .sheet.full { height: min(860px, calc(100% - 48px)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.acc-icon.big { width: 56px; height: 56px; border-radius: 18px; margin: 4px auto 14px; }
.acc-icon.big svg { width: 26px; height: 26px; }
.break { overflow-wrap: anywhere; }
