/* =========================================================
   DOMOWY BUDŻET — Design System
   Jeden akcent (granat), grafitowy tekst, jasne tło.
   Odwaga skupiona w jednym miejscu: granatowy hero „Do wydania".
   ========================================================= */

/* ---------- Tokeny: motyw jasny ---------- */
:root {
  --bg:        #f0f3f7;
  --surface:   #ffffff;
  --surface-2: #f7f9fb;
  --surface-3: #eef2f6;

  --ink:   #171b23;   /* grafit — tekst główny */
  --ink-2: #5b6472;   /* tekst drugorzędny */
  --ink-3: #8b94a3;   /* wyciszony */

  --border:   #e6eaef;
  --border-2: #d7dde5;

  --accent:      #24365c;   /* głęboki granat — marka / akcje */
  --accent-2:    #33507f;   /* jaśniejszy granat */
  --accent-soft: #e9eef7;   /* tło akcentu */
  --accent-ink:  #ffffff;

  --pos:      #12885a;      /* pozytywne (zielony) */
  --pos-soft: #e2f4ec;
  --warn:     #c77a11;      /* ostrzeżenie (bursztyn) */
  --warn-soft:#fbf0dc;
  --neg:      #cf3d3d;      /* problem (czerwony) */
  --neg-soft: #fbe6e6;

  --shadow-sm: 0 1px 2px rgba(23,27,35,.05), 0 1px 3px rgba(23,27,35,.04);
  --shadow-md: 0 2px 6px rgba(23,27,35,.06), 0 8px 24px rgba(23,27,35,.06);
  --shadow-lg: 0 12px 40px rgba(23,27,35,.16);

  --r:    12px;   /* border radius bazowy (10–14px) */
  --r-sm: 9px;
  --r-lg: 16px;

  --sidebar-w: 250px;
  --maxw: 1440px;

  --hero-grad: linear-gradient(135deg, #24365c 0%, #2d456f 55%, #1c2c4d 100%);
}

/* ---------- Tokeny: motyw ciemny ---------- */
[data-theme="dark"] {
  --bg:        #0f1319;
  --surface:   #171c25;
  --surface-2: #1d2431;
  --surface-3: #232b3a;

  --ink:   #eef1f6;
  --ink-2: #a7b0c0;
  --ink-3: #71798a;

  --border:   #262e3c;
  --border-2: #313b4c;

  --accent:      #6f8fd6;
  --accent-2:    #85a1e0;
  --accent-soft: #1e2942;
  --accent-ink:  #0f1319;

  --pos:      #38c98a;  --pos-soft:#123024;
  --warn:     #e0a94a;  --warn-soft:#33290f;
  --neg:      #ec6a6a;  --neg-soft:#331616;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 2px 8px rgba(0,0,0,.35), 0 8px 28px rgba(0,0,0,.3);
  --shadow-lg: 0 16px 48px rgba(0,0,0,.55);

  --hero-grad: linear-gradient(135deg, #223458 0%, #2b4570 55%, #16233d 100%);
}

/* ---------- Reset / bazowe ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

/* [hidden] musi mieć pierwszeństwo nad display:grid/flex komponentów */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
  min-height: 100vh;
}

/* cyfry o stałej szerokości — kluczowe dla czytelności liczb */
.num, .hero__amount, .kpi__num, .networth__amount, .stat__num,
.tx__amt, .pay__amt, .budget-cell, .goal__cur, .modal .num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input  { font: inherit; }
h1,h2,h3 { font-weight: 700; letter-spacing: -0.01em; color: var(--ink); }
::selection { background: var(--accent-soft); }

/* Ikony SVG (wstrzykiwane przez JS do elementów [data-ico]) */
[data-ico] svg { width: 1em; height: 1em; display: block; }
.nav__item [data-ico] svg { width: 20px; height: 20px; }

/* =========================================================
   SIDEBAR
   ========================================================= */
.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 22px 14px 14px;
  z-index: 40;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; }
.brand__logo { width: 34px; height: 34px; flex: 0 0 auto; object-fit: contain; }
.brand__word { font-size: 21px; font-weight: 800; letter-spacing: -.01em; color: var(--ink); }
.brand__o { color: var(--brand-green, #17b877); }
/* pozostawione dla zgodności ze starym markupem (nieużywane) */
.brand__mark { width: 38px; height: 38px; border-radius: 10px; background: var(--hero-grad); color: #fff; display: grid; place-items: center; font-weight: 800; }
.brand__name { display: flex; flex-direction: column; line-height: 1.05; }
.brand__name strong { font-size: 14px; font-weight: 800; letter-spacing: .02em; }
.brand__name span   { font-size: 14px; font-weight: 800; letter-spacing: .02em; color: var(--accent); }
[data-theme="dark"] .brand__name span { color: var(--accent-2); }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav__group {
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3);
  padding: 16px 12px 6px;
}
.nav__group:first-child { padding-top: 4px; }

.nav__item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r-sm);
  font-size: 14.5px; font-weight: 500; color: var(--ink-2);
  transition: background .15s, color .15s;
  text-align: left;
}
.nav__item [data-ico] { color: var(--ink-3); transition: color .15s; display: inline-flex; }
.nav__item:hover { background: var(--surface-3); color: var(--ink); }
.nav__item:hover [data-ico] { color: var(--ink-2); }
.nav__item.is-active {
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
[data-theme="dark"] .nav__item.is-active { color: var(--accent-2); }
.nav__item.is-active [data-ico] { color: var(--accent); }
[data-theme="dark"] .nav__item.is-active [data-ico] { color: var(--accent-2); }

.sidebar__foot { padding-top: 12px; border-top: 1px solid var(--border); }
.userchip {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 8px 10px; border-radius: var(--r-sm); transition: background .15s;
}
.userchip:hover { background: var(--surface-3); }
.userchip__text { display: flex; flex-direction: column; line-height: 1.2; text-align: left; }
.userchip__text strong { font-size: 13.5px; }
.userchip__text span   { font-size: 12px; color: var(--ink-3); }

.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  background: var(--hero-grad); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.avatar--btn { border: none; }
.avatar--lg { width: 52px; height: 52px; font-size: 20px; }

/* =========================================================
   OBSZAR GŁÓWNY + TOPBAR
   ========================================================= */
.app { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 18px 32px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar__title h1 { font-size: 22px; font-weight: 800; }
.topbar__title p  { font-size: 13px; color: var(--ink-3); margin-top: 1px; }

.topbar__actions { display: flex; align-items: center; gap: 10px; }

.search { position: relative; }
.search input {
  width: 240px; padding: 10px 12px 10px 38px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; color: var(--ink); font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s, width .2s;
}
.search input::placeholder { color: var(--ink-3); }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); width: 300px; }
.search__ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-size: 16px; pointer-events: none; }

.search__panel {
  position: absolute; top: calc(100% + 8px); right: 0; width: 380px; max-width: 88vw;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-lg);
  padding: 8px; z-index: 50; max-height: 60vh; overflow-y: auto;
}
.search__panel .sr-empty { padding: 22px 14px; text-align: center; color: var(--ink-3); font-size: 13.5px; }
.search__hint { padding: 8px 12px 10px; font-size: 12px; color: var(--ink-3); border-bottom: 1px solid var(--border); margin-bottom: 6px; }

.iconbtn {
  width: 40px; height: 40px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-size: 18px; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--border);
  transition: background .15s, color .15s, border-color .15s;
}
.iconbtn:hover { background: var(--surface-3); color: var(--ink); }
.iconbtn--dot { position: relative; }
.iconbtn--dot::after { content:""; position:absolute; top:9px; right:9px; width:7px; height:7px; border-radius:50%; background: var(--neg); border: 2px solid var(--surface); }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
  transition: transform .1s, background .15s, box-shadow .15s; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: var(--accent-2); }
.btn--ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--border-2); }
.btn--ghost:hover { background: var(--surface-3); }
.btn--add [data-ico] { font-size: 16px; display: inline-flex; }
.btn--block { width: 100%; justify-content: center; }
.btn--danger { background: var(--neg); color: #fff; }
.btn--lg { padding: 13px 20px; font-size: 15px; }

/* =========================================================
   CONTENT / VIEWS
   ========================================================= */
.content { padding: 26px 32px 60px; max-width: var(--maxw); width: 100%; margin: 0 auto; }
.view { display: none; animation: viewin .25s ease; }
.view.is-active { display: block; }
@keyframes viewin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.view__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.view__title { font-size: 24px; font-weight: 800; }
.view__sub { font-size: 13.5px; color: var(--ink-3); margin-top: 2px; }
.view__tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* =========================================================
   HERO — DO WYDANIA (element dominujący)
   ========================================================= */
.hero {
  position: relative; overflow: hidden;
  background: var(--hero-grad); color: #fff;
  border-radius: var(--r-lg); padding: 34px 36px;
  margin-bottom: 20px; box-shadow: var(--shadow-md);
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.hero__head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.hero__label {
  font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: rgba(255,255,255,.72);
}
.hero__how {
  font-size: 12px; font-weight: 600; color: #fff;
  padding: 5px 11px; border-radius: 20px;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.2);
  transition: background .15s;
}
.hero__how:hover { background: rgba(255,255,255,.24); }
.hero__amount { font-size: clamp(48px, 6vw, 76px); font-weight: 800; line-height: 1; letter-spacing: -0.03em; margin: 6px 0 10px; }
.hero__desc { font-size: 15px; color: rgba(255,255,255,.82); max-width: 46ch; }
.hero__delta {
  display: inline-flex; align-items: center; gap: 7px; margin-top: 16px;
  font-size: 13.5px; font-weight: 600;
  background: rgba(93, 214, 154, .18); color: #b9f2d3;
  padding: 6px 12px; border-radius: 20px;
}
.hero__delta [data-ico] { display: inline-flex; font-size: 15px; }

/* pierścień postępu „ile z miesięcznych środków zostało" */
.hero__ring {
  width: 150px; height: 150px; flex: none; border-radius: 50%;
  display: grid; place-items: center; position: relative;
  background: conic-gradient(#8fb0ea var(--ring, 33%), rgba(255,255,255,.16) 0);
}
.hero__ring::before { content:""; position:absolute; inset: 14px; border-radius:50%; background: linear-gradient(135deg,#2a4069,#1e3055); }
.hero__ring-label { position: relative; text-align: center; z-index: 1; }
.hero__ring-label b { font-size: 26px; font-weight: 800; display: block; }
.hero__ring-label span { font-size: 11px; color: rgba(255,255,255,.7); }
.hero__ring[hidden] { display: none; }

/* V28 — Hero wielowalutowy: wartość źródłowa + równowartość w walucie prezentacji */
.hero__fx { margin: 2px 0 12px; }
.hero__fx[hidden] { display: none; }
.hero__fx-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.hero__fx-row { display: grid; grid-template-columns: 44px minmax(96px, auto) auto; justify-content: start; column-gap: 14px; align-items: baseline; font-size: 15px; }
.hero__fx-cur { font-size: 12px; font-weight: 700; letter-spacing: .08em; color: rgba(255,255,255,.72); }
.hero__fx-amt { font-weight: 700; }
.hero__fx-eq { color: rgba(255,255,255,.72); white-space: nowrap; }
.hero__fx-note { font-size: 12.5px; color: rgba(255,255,255,.65); margin-top: 8px; }

/* =========================================================
   KPI (4 wskaźniki)
   ========================================================= */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 16px 18px; text-align: left; transition: transform .12s, box-shadow .15s, border-color .15s;
  display: flex; flex-direction: column; gap: 8px;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-2); }
.kpi__top { display: flex; align-items: center; justify-content: space-between; }
.kpi__label { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }
.kpi__ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; font-size: 16px; }
.kpi__num { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.kpi__foot { font-size: 12px; color: var(--ink-3); }
.kpi--in  .kpi__ico { background: var(--pos-soft);  color: var(--pos); }
.kpi--out .kpi__ico { background: var(--neg-soft);  color: var(--neg); }
.kpi--plan .kpi__ico{ background: var(--warn-soft); color: var(--warn); }
.kpi--save .kpi__ico{ background: var(--accent-soft); color: var(--accent); }
[data-theme="dark"] .kpi--save .kpi__ico { color: var(--accent-2); }

/* =========================================================
   GRID + CARDS
   ========================================================= */
.grid { display: grid; grid-template-columns: 1.55fr 1fr; gap: 20px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 20px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 20px; box-shadow: var(--shadow-sm);
}
.card--flush { padding: 6px; }
.card--wide { grid-column: 1 / -1; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card__head h2 { font-size: 16px; font-weight: 700; }
.card--flush .card__head { padding: 14px 14px 10px; margin: 0; }

.link { font-size: 13px; font-weight: 600; color: var(--accent); transition: opacity .15s; }
[data-theme="dark"] .link { color: var(--accent-2); }
.link:hover { opacity: .7; }
.chip { font-size: 11.5px; font-weight: 600; color: var(--ink-2); background: var(--surface-3); padding: 4px 10px; border-radius: 20px; }
.chip--warn { background: var(--warn-soft); color: var(--warn); }

/* =========================================================
   BUDŻET — listy i paski postępu
   ========================================================= */
.budget-list { display: flex; flex-direction: column; gap: 4px; }
.budget-row {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 12px;
  padding: 11px 10px; border-radius: 10px; align-items: center;
  transition: background .12s; text-align: left; width: 100%;
}
.budget-row:hover { background: var(--surface-2); }
.budget-row__name { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; }
.budget-row__emoji { font-size: 17px; }
.budget-row__vals { font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.budget-row__vals b { color: var(--ink); font-weight: 700; }
.budget-row__bar { grid-column: 1 / -1; }

.bar { display: block; width: 100%; height: 8px; border-radius: 6px; background: var(--surface-3); overflow: hidden; position: relative; }
.bar__fill { display: block; height: 100%; border-radius: 6px; width: 0; transition: width .8s cubic-bezier(.22,1,.36,1); }
.bar__fill.is-ok    { background: var(--accent); }
[data-theme="dark"] .bar__fill.is-ok { background: var(--accent-2); }
.bar__fill.is-warn  { background: var(--warn); }
.bar__fill.is-over  { background: var(--neg); }
.pct { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Widok Budżet — tabela */
.budget-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.budget-summary .stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 16px 18px; }
.table-head { font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); padding: 14px 16px 8px; border-bottom: 1px solid var(--border); }
.table-head--budget { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1.4fr; gap: 12px; }
.budget-table { display: flex; flex-direction: column; }
.budget-trow {
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1.4fr; gap: 12px; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--border); transition: background .12s; text-align: left; width: 100%;
}
.budget-trow:last-child { border-bottom: none; }
.budget-trow:hover { background: var(--surface-2); }
.budget-cell { font-size: 14px; font-variant-numeric: tabular-nums; }
.budget-cell--name { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.budget-cell--rem b { font-weight: 700; }
.budget-usage { display: flex; align-items: center; gap: 10px; }
.budget-usage .bar { flex: 1; }

/* =========================================================
   TRANSAKCJE
   ========================================================= */
.tx-list { display: flex; flex-direction: column; }
.tx {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center;
  padding: 12px 10px; border-radius: 10px; transition: background .12s; text-align: left; width: 100%;
}
.tx:hover { background: var(--surface-2); }
.tx-list--full .tx { border-radius: 0; padding: 14px 14px; border-bottom: 1px solid var(--border); }
.tx-list--full .tx:last-child { border-bottom: none; }
.tx__ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; background: var(--surface-3); }
.tx__mid { min-width: 0; }
.tx__name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx__meta { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.tx__meta .sep { opacity: .5; }
.tx__right { text-align: right; }
.tx__amt { font-weight: 700; font-size: 14.5px; }
.tx__amt.is-pos { color: var(--pos); }
.tx__date { font-size: 11.5px; color: var(--ink-3); }

.segmented { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented button { padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); transition: background .15s, color .15s; }
.segmented button.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* =========================================================
   PŁATNOŚCI
   ========================================================= */
.pay-list { display: flex; flex-direction: column; }
.pay {
  display: grid; grid-template-columns: 46px 1fr auto; gap: 12px; align-items: center;
  padding: 12px 10px; border-radius: 10px; transition: background .12s; text-align: left; width: 100%;
}
.pay:hover { background: var(--surface-2); }
.pay-list--full .pay { border-radius: 0; padding: 15px 16px; border-bottom: 1px solid var(--border); }
.pay-list--full .pay:last-child { border-bottom: none; }
.pay__date {
  width: 46px; height: 46px; border-radius: 10px; flex: none; text-align: center;
  background: var(--surface-3); display: flex; flex-direction: column; justify-content: center;
}
.pay__date b { font-size: 16px; font-weight: 800; line-height: 1; }
.pay__date span { font-size: 10px; color: var(--ink-3); text-transform: uppercase; }
.pay__name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.pay__sub { font-size: 12px; color: var(--ink-3); }
.pay__amt { font-weight: 700; font-size: 14.5px; }
.pay__due { font-size: 11px; color: var(--ink-3); text-align: right; }

.pay-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.pay-summary .stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 16px 18px; }

/* =========================================================
   CELE
   ========================================================= */
.goal-list { display: flex; flex-direction: column; gap: 12px; }
.goal {
  padding: 12px; border-radius: 12px; background: var(--surface-2);
  border: 1px solid var(--border); transition: transform .12s, box-shadow .15s; text-align: left; width: 100%;
}
.goal:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.goal__top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.goal__emoji { width: 36px; height: 36px; border-radius: 9px; background: var(--surface); border: 1px solid var(--border); display: grid; place-items: center; font-size: 18px; }
.goal__name { font-weight: 600; font-size: 14px; }
.goal__cur { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.goal__pct { margin-left: auto; font-size: 15px; font-weight: 800; color: var(--accent); }
[data-theme="dark"] .goal__pct { color: var(--accent-2); }
.goal .bar__fill { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* Widok Cele — duże karty */
.goal-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.goalcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 22px; box-shadow: var(--shadow-sm); transition: transform .12s, box-shadow .15s; text-align: left;
}
.goalcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.goalcard__head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.goalcard__emoji { width: 46px; height: 46px; border-radius: 12px; background: var(--accent-soft); display: grid; place-items: center; font-size: 24px; }
.goalcard__name { font-size: 16px; font-weight: 700; }
.goalcard__term { font-size: 12.5px; color: var(--ink-3); }
.goalcard__nums { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.goalcard__cur { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.goalcard__tgt { font-size: 14px; color: var(--ink-3); }
.goalcard .bar { height: 10px; margin: 12px 0; }
.goalcard__meta { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.goalcard__meta .m span { font-size: 11.5px; color: var(--ink-3); display: block; }
.goalcard__meta .m b { font-size: 14px; font-weight: 700; }

/* =========================================================
   KONTA / MAJĄTEK
   ========================================================= */
.networth {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow-sm);
  display: grid; grid-template-columns: 260px 1fr; gap: 24px; align-items: center;
}
.networth__label { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.networth__amount { font-size: 44px; font-weight: 800; letter-spacing: -0.03em; margin: 6px 0 8px; }
.networth__delta { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--pos); }
.networth__delta [data-ico] { display: inline-flex; }

.accounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.account {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 18px; box-shadow: var(--shadow-sm); transition: transform .12s, box-shadow .15s;
}
.account:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.account__top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.account__ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; background: var(--accent-soft); color: var(--accent); }
[data-theme="dark"] .account__ico { color: var(--accent-2); }
.account__name { font-weight: 600; font-size: 14px; }
.account__type { font-size: 12px; color: var(--ink-3); }
.account__bal { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.account__bal.is-neg { color: var(--neg); }

.wealth-split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }
.wealth-list { display: flex; flex-direction: column; }
.wealth-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 4px; border-bottom: 1px solid var(--border); }
.wealth-row:last-child { border-bottom: none; }
.wealth-row__name { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; }
.wealth-row__val { font-weight: 700; font-variant-numeric: tabular-nums; }
.wealth-row__val.is-neg { color: var(--neg); }

/* =========================================================
   PROGNOZA / RAPORTY / STATY
   ========================================================= */
.forecast-panels, .reports-grid { }
.forecast-panels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 18px 20px; }
.stat__label { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.stat__num { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; margin: 4px 0; }
.stat__num--warn { color: var(--warn); }
.stat__meta { font-size: 12.5px; color: var(--ink-3); }

.reports-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.rank { display: flex; flex-direction: column; gap: 10px; }
.rank__row { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; }
.rank__name { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 500; }
.rank__val { font-weight: 700; font-variant-numeric: tabular-nums; }
.rank__bar { grid-column: 1 / -1; }

.changes { display: flex; flex-direction: column; gap: 12px; }
.change { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border-radius: 10px; background: var(--surface-2); }
.change__name { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; }
.change__val { font-weight: 700; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 8px; }
.change__pill { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 20px; }
.change__pill.up   { background: var(--neg-soft); color: var(--neg); }
.change__pill.down { background: var(--pos-soft); color: var(--pos); }

/* Wykresy */
.chart-box { position: relative; width: 100%; }
.chart-box--sm { height: 190px; }
.chart-box--md { height: 260px; }
.chart-box--lg { height: 340px; }
.chart-box--nw { height: 150px; }
.legend { display: flex; gap: 16px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.legend__item { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot--warn { background: var(--warn); }
.chart-note { font-size: 12.5px; color: var(--ink-3); margin-top: 12px; display: flex; align-items: center; gap: 8px; }

/* =========================================================
   USTAWIENIA
   ========================================================= */
.settings { display: flex; flex-direction: column; gap: 16px; max-width: 620px; }
.settings__row { display: flex; align-items: center; gap: 16px; }
.settings__toggle { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.settings__toggle:last-child { border-bottom: none; }
.muted { color: var(--ink-3); font-size: 13px; }
.switch { width: 46px; height: 27px; border-radius: 20px; background: var(--border-2); position: relative; transition: background .2s; flex: none; }
.switch span { position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: var(--shadow-sm); }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"] span { transform: translateX(19px); }

/* =========================================================
   MODAL / OVERLAY
   ========================================================= */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 19, 25, .55); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 20px;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); width: 100%; max-width: 480px; max-height: 88vh;
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  animation: pop .22s cubic-bezier(.22,1,.36,1);
}
.modal--wide { max-width: 560px; }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 14px; border-bottom: 1px solid var(--border); }
.modal__head h3 { font-size: 18px; font-weight: 700; }
.modal__body { padding: 20px 22px; overflow-y: auto; }
.modal__foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }
.modal__foot:empty { display: none; }

/* Formularze w modalu */
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 7px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px; border-radius: 10px;
  border: 1px solid var(--border-2); background: var(--surface-2); color: var(--ink); font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
.field textarea { resize: vertical; min-height: 66px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.typeseg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: var(--surface-3); padding: 4px; border-radius: 11px; }
.typeseg button { padding: 10px; border-radius: 8px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); transition: all .15s; }
.typeseg button.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.typeseg button[data-t="expense"].is-active { color: var(--neg); }
.typeseg button[data-t="income"].is-active  { color: var(--pos); }

.amount-input { position: relative; }
.amount-input input { font-size: 30px; font-weight: 800; padding: 14px 46px 14px 16px; text-align: left; font-variant-numeric: tabular-nums; }
.amount-input .cur { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: 20px; font-weight: 700; color: var(--ink-3); }

.tags-in { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 4px; }
.tagpick { font-size: 12.5px; padding: 6px 12px; border-radius: 20px; border: 1px solid var(--border-2); background: var(--surface-2); color: var(--ink-2); transition: all .15s; }
.tagpick.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
[data-theme="dark"] .tagpick.is-active { color: var(--accent-2); }

/* „Jak to obliczamy" — rozliczenie */
.calc-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--border); }
.calc-row:last-of-type { border-bottom: none; }
.calc-row__label { font-size: 14px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.calc-row__op { color: var(--ink-3); font-weight: 700; width: 16px; display: inline-block; text-align: center; }
.calc-row__val { font-weight: 700; font-variant-numeric: tabular-nums; }
.calc-total { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; padding: 16px; border-radius: 12px; background: var(--accent-soft); }
.calc-total span { font-weight: 700; color: var(--accent); }
[data-theme="dark"] .calc-total span { color: var(--accent-2); }
.calc-total b { font-size: 26px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
[data-theme="dark"] .calc-total b { color: var(--accent-2); }

/* Szczegóły w modalu */
.detail-hero { text-align: center; padding: 8px 0 18px; }
.detail-hero__emoji { font-size: 40px; }
.detail-hero__amt { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; margin-top: 6px; }
.detail-hero__amt.is-pos { color: var(--pos); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 4px 0 16px; }
.detail-grid .d { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.detail-grid .d span { font-size: 11.5px; color: var(--ink-3); display: block; }
.detail-grid .d b { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.detail-section-title { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin: 18px 0 8px; }

.impact { display: flex; flex-direction: column; gap: 12px; }
.impact__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.impact__flow { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 10px; }
.impact__arrow { color: var(--ink-3); }
.impact__to { color: var(--warn); }

/* =========================================================
   TOAST
   ========================================================= */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--surface);
  padding: 13px 20px; border-radius: 12px; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600;
  z-index: 200; opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none;
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast [data-ico] { color: var(--pos); display: inline-flex; font-size: 18px; }

/* Pusty stan */
.empty { text-align: center; padding: 46px 20px; color: var(--ink-3); }
.empty__ico { font-size: 30px; opacity: .5; margin-bottom: 10px; }
.empty p { font-size: 14px; }

/* =========================================================
   DOLNA NAWIGACJA (mobile) — domyślnie ukryta
   ========================================================= */
.bottomnav { display: none; }

/* =========================================================
   RESPONSYWNOŚĆ
   ========================================================= */

/* Tablet 768–1439 */
@media (max-width: 1200px) {
  .grid { grid-template-columns: 1fr; }
  .reports-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .networth { grid-template-columns: 1fr; }
  .wealth-split { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
  :root { --sidebar-w: 76px; }
  .brand__name, .brand__word, .nav__group, .nav__label,
  .userchip__text { display: none; }
  .nav__item { justify-content: center; padding: 12px; }
  .brand { justify-content: center; padding: 4px 0 22px; }
  .userchip { justify-content: center; padding: 8px; }
  .content, .topbar { padding-left: 22px; padding-right: 22px; }
}

/* Mobile ≤767 */
@media (max-width: 767px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .app { margin-left: 0; padding-bottom: 78px; }

  .topbar { padding: 14px 16px; gap: 10px; }
  .topbar__title h1 { font-size: 18px; }
  .topbar__title p { display: none; }
  .search { display: none; }              /* wyszukiwarka → dostępna z „Więcej" */
  .btn--add { display: none; }   /* dodawanie przez centralny „+" w dolnej nawigacji */
  #bellBtn { display: none; }

  .content { padding: 16px 16px 40px; }

  .hero { flex-direction: column; align-items: flex-start; padding: 24px 22px; }
  .hero__ring { display: none; }
  .hero__amount { font-size: 52px; }

  .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi__num { font-size: 22px; }

  .view__head { flex-direction: column; align-items: stretch; }
  .view__tools { justify-content: space-between; }

  .budget-summary, .pay-summary, .forecast-panels { grid-template-columns: 1fr; }
  .goal-cards { grid-template-columns: 1fr; }

  /* Tabela budżetu → kompaktowa */
  .table-head--budget { grid-template-columns: 1.4fr 1fr 1.2fr; }
  .table-head--budget span:nth-child(3), .table-head--budget span:nth-child(5) { display: none; }
  .budget-trow { grid-template-columns: 1.4fr 1fr 1.2fr; }
  .budget-trow .budget-cell:nth-child(3), .budget-trow .budget-usage { display: none; }

  .modal { max-width: 100%; align-self: flex-end; border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 92vh; }
  .overlay { place-items: end center; padding: 0; }

  /* Dolna nawigacja */
  .bottomnav {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 20px rgba(23,27,35,.06);
  }
  .bottomnav__item { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--ink-3); font-size: 10.5px; font-weight: 600; padding: 4px; }
  .bottomnav__item [data-ico] svg { width: 22px; height: 22px; }
  .bottomnav__item.is-active { color: var(--accent); }
  [data-theme="dark"] .bottomnav__item.is-active { color: var(--accent-2); }
  .bottomnav__add {
    width: 54px; height: 54px; border-radius: 50%; margin: 0 auto; justify-self: center;
    background: var(--accent); color: #fff; display: grid; place-items: center;
    box-shadow: var(--shadow-md); transform: translateY(-14px);
  }
  .bottomnav__add [data-ico] svg { width: 26px; height: 26px; }
}

/* Dostępność: redukcja ruchu */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Widoczny focus klawiatury */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* =========================================================
   PODZIAŁ TRANSAKCJI + MINI KALKULATOR  (rozszerzenie)
   ========================================================= */

/* --- Pole kwoty z przyciskiem kalkulatora --- */
.amount-wrap { position: relative; }
.amount-input input { width: 100%; box-sizing: border-box; padding: 14px 88px 14px 16px; }   /* pola kwoty poza .field też pełnej szerokości */
.split-cat, .split-desc { width: 100%; box-sizing: border-box; }
.amount-input .calc-btn {
  position: absolute; right: 46px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9px; background: var(--surface-3); color: var(--ink-2);
  border: 1px solid var(--border-2); transition: background .15s, color .15s, border-color .15s;
}
.amount-input .calc-btn:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.amount-input .calc-btn [data-ico] { display: inline-flex; }
.amount-input .calc-btn [data-ico] svg { width: 18px; height: 18px; }

.amount-input--sm input { font-size: 15px; font-weight: 700; padding: 10px 62px 10px 12px; }
.amount-input--sm .cur { right: 10px; font-size: 13px; }
.amount-input--sm .calc-btn { right: 32px; width: 25px; height: 25px; border-radius: 7px; }
.amount-input--sm .calc-btn [data-ico] svg { width: 14px; height: 14px; }

/* --- Podpowiedź wyniku działania --- */
.expr-hint { min-height: 16px; margin-top: 5px; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-3); }
.expr-hint.is-ok { color: var(--pos); }
.expr-hint.is-bad { color: var(--neg); }
.field-tip { margin-top: 8px; font-size: 12px; color: var(--ink-3); line-height: 1.5; }
.field-tip code { background: var(--surface-3); border: 1px solid var(--border-2); border-radius: 5px; padding: 1px 6px; font-size: 11.5px; font-variant-numeric: tabular-nums; }

/* --- Przełącznik „Podziel transakcję" --- */
.split-toggle { display: flex; align-items: center; gap: 11px; cursor: pointer; user-select: none;
  margin: 2px 0 16px; padding: 12px 14px; border: 1px solid var(--border-2); border-radius: 11px; background: var(--surface-2);
  transition: background .15s, border-color .15s; }
.split-toggle:hover { border-color: var(--accent); background: var(--accent-soft); }
.split-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.split-toggle__box { flex: 0 0 auto; width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--border-2);
  background: var(--surface); display: inline-flex; align-items: center; justify-content: center; color: transparent; transition: all .15s; }
.split-toggle__box [data-ico] svg { width: 13px; height: 13px; }
.split-toggle input:checked + .split-toggle__box { background: var(--accent); border-color: var(--accent); color: #fff; }
.split-toggle__label { font-size: 13.5px; font-weight: 600; color: var(--ink); display: inline-flex; align-items: center; gap: 7px; }
.split-toggle__label [data-ico] svg { width: 16px; height: 16px; color: var(--ink-3); }

/* --- Lista pozycji podziału (desktop: kompaktowy wiersz) --- */
.split-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.split-cat, .split-desc, .amount-input--sm input {
  border: 1px solid var(--border-2); background: var(--surface-2); color: var(--ink);
  border-radius: 10px; transition: border-color .15s, box-shadow .15s;
}
.split-cat, .split-desc { font-size: 13.5px; padding: 0 11px; }
.split-cat:focus, .split-desc:focus, .amount-input--sm input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface);
}
.split-row { display: grid; grid-template-columns: 150px 1fr 1fr 34px; gap: 8px; align-items: start; }
.split-row__amt { min-width: 0; }
.split-row .split-cat, .split-row .split-desc { align-self: start; height: 40px; }
.split-row .split-del { align-self: start; height: 40px; width: 34px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border-2); color: var(--ink-3); transition: all .15s; }
.split-row .split-del:hover { background: var(--neg-soft); color: var(--neg); border-color: var(--neg); }
.split-row .split-del [data-ico] svg { width: 16px; height: 16px; }
.split-row .expr-hint { min-height: 0; }
.split-row .expr-hint:empty { margin-top: 0; }

/* --- Podsumowanie sumy pozycji --- */
.split-summary { margin-top: 12px; padding: 13px 15px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border-2); }
.split-sum-line { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--ink-2); padding: 2px 0; }
.split-sum-line b { font-size: 14px; color: var(--ink); font-variant-numeric: tabular-nums; }
.split-sum-status { margin-top: 9px; padding-top: 10px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.split-status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; }
.split-status [data-ico] svg { width: 16px; height: 16px; }
.split-status.is-ok { color: var(--pos); }
.split-status.is-warn { color: var(--warn); }
.split-status.is-bad { color: var(--neg); }
.btn--sm { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }

/* --- Zablokowany przycisk zapisu (suma niezgodna) --- */
.btn--primary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn--primary:disabled:hover { background: var(--accent); }

/* --- Wskaźnik podziału w historii --- */
.split-badge { display: inline-flex; align-items: center; gap: 4px; }
.split-badge [data-ico] svg { width: 13px; height: 13px; vertical-align: -2px; }
.split-badge--sm { font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 1px 8px; border-radius: 20px; margin-left: 4px; }
.split-badge--sm [data-ico] svg { width: 11px; height: 11px; }

/* --- Podział w szczegółach transakcji --- */
.split-detail { display: flex; flex-direction: column; }
.split-detail__row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.split-detail__row:last-child { border-bottom: 0; }
.split-detail__cat { font-size: 14px; font-weight: 600; color: var(--ink); }
.split-detail__amt { font-size: 14px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.split-detail__desc { grid-column: 1 / -1; font-size: 12.5px; color: var(--ink-3); }

/* --- Popover kalkulatora --- */
.calc-backdrop { position: fixed; inset: 0; z-index: 299; background: transparent; }
.calc-pop { position: fixed; z-index: 300; width: 260px; padding: 12px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--border-2); box-shadow: var(--shadow-lg); }
.calc-pop__display { padding: 10px 12px; margin-bottom: 10px; border-radius: 10px; background: var(--surface-3); text-align: right; min-height: 52px; }
.calc-pop__expr { display: block; font-size: 13px; color: var(--ink-3); word-break: break-all; font-variant-numeric: tabular-nums; }
.calc-pop__res { display: block; font-size: 20px; font-weight: 800; color: var(--ink); margin-top: 2px; font-variant-numeric: tabular-nums; }
.calc-pop__pad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.calc-key { height: 44px; border-radius: 10px; font-size: 16px; font-weight: 600; background: var(--surface-2);
  border: 1px solid var(--border-2); color: var(--ink); transition: background .12s, transform .05s; }
.calc-key:hover { background: var(--surface-3); }
.calc-key:active { transform: translateY(1px); }
.calc-key--fn { color: var(--ink-3); font-size: 14px; }
.calc-key--fn [data-ico] svg { width: 17px; height: 17px; }
.calc-key--eq { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 800; }
.calc-key--eq:hover { background: var(--accent-2); }

/* --- Mobile: pozycje jako karty, kalkulator jako dolny sheet --- */
@media (max-width: 767px) {
  .split-row { display: flex; flex-direction: column; gap: 8px; padding: 12px;
    border: 1px solid var(--border-2); border-radius: 12px; background: var(--surface-2); }
  .split-row .split-cat, .split-row .split-desc { height: 42px; }
  .split-row .split-del { align-self: flex-end; width: auto; height: 32px; padding: 0 14px; gap: 6px; font-size: 12.5px; font-weight: 600; }
  .split-row .split-del::after { content: "Usuń"; }
  .calc-pop { width: calc(100vw - 24px); max-width: 340px; }
  .calc-key { height: 48px; }
}

/* =========================================================
   POZYCJE + PODKATEGORIE + EDYCJA + AUDYT MOBILE (v3)
   ========================================================= */

/* Pola pozycji spójne z formularzem */
.it-cat, .it-sub, .it-desc, .amount-input--sm input {
  border: 1px solid var(--border-2); background: var(--surface-2); color: var(--ink);
  border-radius: 10px; transition: border-color .15s, box-shadow .15s;
}
.it-cat, .it-sub, .it-desc { font-size: 13.5px; padding: 0 10px; min-width: 0; }
.it-cat:focus, .it-sub:focus, .it-desc:focus, .amount-input--sm input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface);
}

/* Nagłówek listy pozycji */
.items-head { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin: 6px 0 8px; }
.item-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }

/* Wiersz pozycji — desktop: kompaktowa karta z opisem w drugiej linii */
.item-row {
  display: grid; gap: 8px; align-items: start;
  grid-template-columns: 132px 1fr 1fr 36px;
  grid-template-areas: "amt cat sub del" "desc desc desc desc";
  padding: 10px; border: 1px solid var(--border-2); border-radius: 12px; background: var(--surface-2);
}
.item-row__amt { grid-area: amt; min-width: 0; }
.item-row .it-cat { grid-area: cat; height: 40px; }
.item-row .it-sub { grid-area: sub; height: 40px; }
.item-row .it-desc { grid-area: desc; height: 38px; }
.item-row .item-del {
  grid-area: del; height: 40px; width: 36px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9px; background: var(--surface); border: 1px solid var(--border-2); color: var(--ink-3); transition: all .15s;
}
.item-row .item-del:hover { background: var(--neg-soft); color: var(--neg); border-color: var(--neg); }
.item-row .item-del [data-ico] svg { width: 16px; height: 16px; }
.item-row .expr-hint { min-height: 0; }
.item-row .expr-hint:empty { margin-top: 0; }

/* Powrót „← Transakcje" w szczegółach */
.detail-back {
  display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px;
  font-size: 13.5px; font-weight: 600; color: var(--accent); padding: 6px 4px; border-radius: 8px;
}
.detail-back:hover { text-decoration: underline; }
.detail-back [data-ico] svg { width: 17px; height: 17px; }
.detail-sub { color: var(--ink-3); font-weight: 500; }

/* Zabezpieczenie przed poziomym przewijaniem (bez maskowania — realne min-width:0) */
.tx__meta { min-width: 0; overflow: hidden; }
.tx__meta > * { flex-shrink: 0; }
.detail-grid .d b { overflow-wrap: anywhere; }

/* =========================================================
   MOBILE 375 / 390 / 430 — realne dopasowanie układu
   ========================================================= */
@media (max-width: 767px) {
  /* Modal jako bottom-sheet: przewijalny środek, sticky nagłówek i stopka */
  .modal { max-height: 94vh; }
  .modal__head { position: sticky; top: 0; z-index: 2; background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .modal__body { padding: 16px; -webkit-overflow-scrolling: touch; }
  .modal__foot {
    position: sticky; bottom: 0; background: var(--surface);
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    flex-wrap: wrap;
  }
  .modal__foot .btn { flex: 1 1 auto; justify-content: center; }

  /* Pozycja transakcji → pełna karta pionowa (wygodna palcem) */
  .item-row {
    grid-template-columns: 1fr auto;
    grid-template-areas: "amt del" "cat cat" "sub sub" "desc desc";
    gap: 8px; padding: 12px;
  }
  .item-row .it-cat, .item-row .it-sub, .item-row .it-desc { height: 44px; }
  .item-row .item-del { height: 40px; }

  /* Pola/formularze: nic nie wychodzi poza ekran */
  .field-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .field input, .field select, .field textarea { max-width: 100%; }
  .amount-input input { font-size: 26px; }

  /* Podpowiedzi i podsumowanie */
  .split-summary { padding: 12px; }
  .split-sum-status { gap: 8px; }
  .split-status { font-size: 12.5px; }

  /* Szczegóły — siatka 2 kolumny mieści się na 375 */
  .detail-grid { grid-template-columns: 1fr 1fr; }

  /* Kalkulator: bottom sheet z bezpiecznym marginesem */
  .calc-pop { bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important; }

  /* Wykresy skalują się do kontenera */
  .chart-box { max-width: 100%; }
  canvas { max-width: 100% !important; }
}

/* Węższe telefony 375 px — dodatkowe dociśnięcie */
@media (max-width: 400px) {
  .typeseg button { font-size: 12.5px; padding: 9px 4px; }
  .item-row { grid-template-columns: 1fr auto; }
  .kpi__num { font-size: 20px; }
  .hero__amount { font-size: 46px; }
}

/* =========================================================
   TRANSFER + KONTEKSTOWA NAWIGACJA (v4)
   ========================================================= */
.tx__amt--transfer { color: var(--ink-2); }
.transfer-hint:empty { display: none; }
.transfer-hint { margin: -4px 0 6px; }

/* Przepływ „konto → konto" w szczegółach transferu */
.transfer-flow {
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
  margin: 4px 0 18px; padding: 16px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--border-2);
}
.transfer-flow__acc { font-size: 14.5px; font-weight: 700; color: var(--ink); text-align: center; }
.transfer-flow__arrow { color: var(--accent); display: inline-flex; }
.transfer-flow__arrow svg { width: 22px; height: 22px; }

@media (max-width: 767px) {
  .transfer-flow { flex-direction: column; gap: 8px; padding: 14px; }
  .transfer-flow__arrow { transform: rotate(90deg); }
}

/* =========================================================
   WIELOWALUTOWOŚĆ (v5): ustawienia, waluty kont, transfer FX
   ========================================================= */
/* Preferencje w Ustawieniach */
.settings__title { font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 4px; }
.settings__field { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-top: 1px solid var(--border); }
.settings__field:first-of-type { border-top: 0; }
.settings__field > div { min-width: 0; }
.settings__select {
  flex: 0 0 auto; min-width: 190px; max-width: 55%; height: 40px; padding: 0 12px;
  border: 1px solid var(--border-2); background: var(--surface-2); color: var(--ink);
  border-radius: 10px; font-size: 14px; font-weight: 600;
}
.settings__select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Przeliczenie salda konta na walutę raportu */
.account__balwrap { text-align: right; }
.wealth-row__valwrap { text-align: right; }
.acc-conv { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; margin-top: 2px; }
.wealth-row__cur, .account__type { font-variant-numeric: normal; }
.wealth-row__cur { font-size: 11px; color: var(--ink-3); font-weight: 600; }

/* Notka o walucie / kursach demonstracyjnych */
.fx-note { font-size: 12.5px; color: var(--ink-3); margin: 0 0 14px; padding: 8px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.transfer-flow .fx-note { margin: 10px 0 0; }

/* Kwoty kont w przepływie transferu */
.transfer-flow__acc { display: flex; flex-direction: column; gap: 2px; }
.transfer-flow__cur { font-size: 12.5px; font-weight: 600; color: var(--ink-3); font-variant-numeric: tabular-nums; }

@media (max-width: 767px) {
  .settings__field { flex-direction: column; align-items: stretch; gap: 8px; }
  .settings__select { min-width: 0; max-width: 100%; width: 100%; }
}

/* =========================================================
   TAGI (chipy + edytor) i PŁATNOŚCI v6
   ========================================================= */
/* Edytor tagów */
.tag-editor { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tagchip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px 4px 10px; border-radius: 20px;
  background: var(--accent-soft); color: var(--accent); font-size: 12.5px; font-weight: 600; }
.tagchip--ro { padding: 4px 10px; }
.tagchip__x { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%;
  background: transparent; color: var(--accent); font-size: 15px; line-height: 1; }
.tagchip__x:hover { background: var(--accent); color: #fff; }
.tag-add { flex: 1 1 90px; min-width: 90px; height: 34px; padding: 0 12px; border: 1px dashed var(--border-2);
  background: var(--surface-2); color: var(--ink); border-radius: 18px; font-size: 13px; }
.tag-add:focus { outline: none; border-style: solid; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tag-add--sm { height: 30px; font-size: 12.5px; flex-basis: 70px; }

/* Trzecia linia pozycji: tagi */
.item-row { grid-template-areas: "amt cat sub del" "desc desc desc desc" "tags tags tags tags"; }
.item-row__tags { grid-area: tags; }
@media (max-width: 767px) {
  .item-row { grid-template-areas: "amt del" "cat cat" "sub sub" "desc desc" "tags tags"; }
}

/* Tagi w szczegółach pozycji */
.split-detail__tags { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }

/* Segmentowany wybór 4 typów płatności */
.typeseg--4 { display: grid; grid-template-columns: repeat(4, 1fr); }
.typeseg--4 button { padding: 9px 4px; font-size: 13px; }

/* Częstotliwość */
.freq-row { display: flex; gap: 8px; width: 100%; min-width: 0; }
.freq-num { flex: 0 0 84px; width: 84px; min-width: 0; }
.freq-unit { flex: 1 1 0; min-width: 0; width: 0; }
@media (max-width: 400px) {
  .freq-num { flex-basis: 72px; width: 72px; }
}
.check-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; font-size: 14px; cursor: pointer; }
.check-row input { width: 18px; height: 18px; accent-color: var(--accent); }

/* Sekcje płatności */
.pay-section-title { font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); margin: 20px 4px 10px; }
.pay-section-title:first-of-type { margin-top: 4px; }
.pay--off { opacity: .5; }
.pay--off .pay__amt { text-decoration: line-through; }

/* Zobowiązania (kredyty) */
.obligations { display: flex; flex-direction: column; gap: 10px; }
.obligation { display: block; width: 100%; text-align: left; padding: 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border-2); }
.obligation:hover { border-color: var(--accent); }
.obligation__top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.obligation__name { font-weight: 700; font-size: 15px; color: var(--ink); }
.obligation__amt { font-size: 15px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.obligation__per { font-size: 12px; font-weight: 500; color: var(--ink-3); }
.obligation__meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 8px 0 10px; font-size: 12.5px; color: var(--ink-2); }
.obligation__rata { font-weight: 700; color: var(--accent); }
.obligation__bar { height: 6px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.obligation__fill { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

/* Licznik rat w szczegółach */
.loan-counter { text-align: center; margin: 4px 0 16px; padding: 16px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border-2); }
.loan-counter__main { font-size: 20px; color: var(--ink); }
.loan-counter__main b { font-size: 24px; color: var(--accent); }
.loan-counter__meta { font-size: 12.5px; color: var(--ink-3); margin: 4px 0 12px; }
.detail-grid--2 { grid-template-columns: 1fr 1fr; }

/* =========================================================
   PŁATNOŚĆ → ZAPŁACONE (v9)
   ========================================================= */
.modal__foot { flex-wrap: wrap; }               /* stopka szczegółów płatności ma do 4 przycisków */
.settle-q { font-size: 14px; color: var(--ink-2); margin-bottom: 14px; line-height: 1.5; }

/* =========================================================
   WARSTWA SaaS (v10): ekran wejściowy, menu użytkownika, plany
   ========================================================= */
body.auth-open { overflow: hidden; }
.auth { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: var(--bg); }
.auth[hidden] { display: none; }
.auth__card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: 28px 26px; }
.auth__brand { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; margin-bottom: 24px; }
.auth__logo-img { width: 240px; max-width: 82%; height: auto; background: #fff; padding: 14px 20px; border-radius: 16px; box-sizing: border-box; }
[data-theme="dark"] .auth__logo-img { box-shadow: var(--shadow-sm); }
.auth__title { font-size: 18px; font-weight: 800; letter-spacing: .02em; }
.auth__tagline { font-size: 12.5px; color: var(--ink-3); line-height: 1.5; max-width: 300px; }
.auth__form { display: flex; flex-direction: column; gap: 12px; }
.auth__field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.auth__field input { height: 44px; padding: 0 14px; border: 1px solid var(--border-2); background: var(--surface-2);
  color: var(--ink); border-radius: 11px; font-size: 14px; }
.auth__field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.auth__switch { font-size: 13px; color: var(--ink-3); text-align: center; margin-top: 2px; }
.auth__link { color: var(--accent); font-weight: 700; }
.auth__link:hover { text-decoration: underline; }
.auth__divider { display: flex; align-items: center; gap: 12px; margin: 18px 0 14px; color: var(--ink-3); font-size: 12px; }
.auth__divider::before, .auth__divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth__note { font-size: 11.5px; color: var(--ink-3); text-align: center; margin-top: 12px; line-height: 1.5; }

/* Menu użytkownika */
.usermenu__head { display: flex; align-items: center; gap: 12px; padding-bottom: 14px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
.usermenu__head strong { display: block; font-size: 15px; }
.usermenu__head .muted { font-size: 12.5px; }
.usermenu__badge { display: inline-block; margin-top: 5px; font-size: 11px; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); padding: 2px 9px; border-radius: 20px; }
.usermenu__item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 10px;
  border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--ink); }
.usermenu__item:hover { background: var(--surface-2); }
.usermenu__item [data-ico] svg { width: 18px; height: 18px; color: var(--ink-3); }
.usermenu__item--danger { color: var(--neg); }
.usermenu__item--danger [data-ico] svg { color: var(--neg); }
.avatar--sm { width: 30px; height: 30px; font-size: 12px; }

/* Członkowie gospodarstwa */
.members { display: flex; flex-direction: column; gap: 8px; }
.member-row { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border: 1px solid var(--border-2); border-radius: 11px; background: var(--surface-2); }
.member-row__name { font-weight: 600; font-size: 14px; flex: 1; }
.member-row__role { font-size: 12px; color: var(--ink-3); text-transform: capitalize; }

/* Plany */
.plans { display: flex; flex-direction: column; gap: 12px; }
.plan-card { border: 1px solid var(--border-2); border-radius: 14px; padding: 16px; background: var(--surface-2); }
.plan-card--active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.plan-card__head { display: flex; align-items: center; justify-content: space-between; }
.plan-card__head strong { font-size: 15px; }
.plan-card__badge { font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 2px 9px; border-radius: 20px; }
.plan-card__price { font-size: 13px; color: var(--ink-3); margin: 2px 0 8px; }
.plan-card__feats { list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 10px; }
.plan-card__feats li::before { content: "✓ "; color: var(--pos); font-weight: 700; }

/* Placeholder banków + „Wkrótce" */
.bank-empty { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 6px 0; }
.bank-empty__ico { flex: 0 0 auto; width: 42px; height: 42px; border-radius: 11px; background: var(--surface-3);
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink-3); }
.bank-empty__ico [data-ico] svg { width: 20px; height: 20px; }
.bank-empty > div { flex: 1; min-width: 160px; }
.bank-empty strong { font-size: 14px; }
.soon-badge { font-size: 10.5px; font-weight: 700; color: var(--ink-3); background: var(--surface-3); border: 1px solid var(--border-2);
  padding: 1px 7px; border-radius: 20px; margin-left: 6px; }

@media (max-width: 767px) {
  .auth__card { padding: 24px 20px; }
}

/* Telefony / ekrany dotykowe: pola formularzy min. 16 px — iOS Safari powiększa stronę przy wejściu w pole < 16 px
   (formularz „rozjeżdżał się” poza ekran). Pola kwot (.amount-input, 26–30 px) bez zmian; zoom gestem nadal dostępny. */
@media (max-width: 767px), (hover: none) and (pointer: coarse) {
  :is(input, select, textarea):not(.amount-input input):not([type=checkbox]):not([type=radio]) { font-size: 16px; }
}

/* Kafelki KPI na wąskich ekranach (~360 px): kolumny 1fr nie zwężały się poniżej treści etykiet → strona szersza
   niż ekran, przez co telefon poszerzał układ i formularze (modal) oraz dolna nawigacja wychodziły poza ekran. */
@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { min-width: 0; }
  .kpi__top { gap: 8px; }
  .kpi__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 400px) {
  .kpi__label { letter-spacing: .01em; font-size: 10px; }
  .kpi__ico { width: 26px; height: 26px; font-size: 14px; flex: none; }
}

/* Modal na wąskich ekranach: kolumna siatki nakładki nie może rosnąć ponad ekran (auto → minmax(0, 1fr));
   pola w wierszach mogą się zwężać. ≤ 360 px: wiersz z kwotą jeden pod drugim, węższy przełącznik typów. */
.overlay { grid-template-columns: minmax(0, 1fr); }
.modal { min-width: 0; }
.modal .field-row > * { min-width: 0; }
.modal select { min-width: 0; max-width: 100%; }
@media (max-width: 360px) {
  .modal .field-row:has(.amount-input) { grid-template-columns: minmax(0, 1fr); }
  .typeseg button, .seg button { font-size: 12px; padding-left: 4px; padding-right: 4px; }
}

/* Pole daty na telefonach: natywna kontrolka iOS Safari ma własną minimalną szerokość i wychodziła poza ekran. */
@media (max-width: 767px), (hover: none) and (pointer: coarse) {
  .modal input[type="date"] { -webkit-appearance: none; appearance: none; display: block; width: 100%; min-width: 0; max-width: 100%; }
  .modal input[type="date"]::-webkit-date-and-time-value { text-align: left; }
}
