:root {
  --bg: #f4f1e9;
  --surface: #fffdf8;
  --surface-2: #ece8dc;
  --ink: #17201e;
  --muted: #68726f;
  --brand: #173c36;
  --brand-2: #235c52;
  --accent: #d9a441;
  --danger: #a53c34;
  --success: #2f725f;
  --warning: #9a6616;
  --line: #ded9cc;
  --shadow: 0 10px 30px rgba(23,32,30,.08);
  --radius: 22px;
}
* { box-sizing: border-box; }
html { background: var(--brand); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { max-width: 680px; margin: 0 auto; min-height: 100vh; padding-bottom: 108px; }
.topbar {
  padding: calc(18px + env(safe-area-inset-top)) 20px 10px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--brand); color: white;
}
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 24px; margin-bottom: 0; letter-spacing: -.03em; }
h2 { font-size: 22px; margin-bottom: 0; letter-spacing: -.025em; }
h3 { font-size: 17px; margin-bottom: 8px; }
.eyebrow { margin: 0 0 4px; font-size: 10px; letter-spacing: .15em; font-weight: 800; opacity: .72; }
.icon-btn { border: 0; background: rgba(255,255,255,.12); color: inherit; width: 42px; height: 42px; border-radius: 14px; }
.month-switcher {
  background: var(--brand); color: white; display: grid; grid-template-columns: 54px 1fr 54px; align-items: center;
  padding: 8px 16px 26px; border-radius: 0 0 28px 28px;
}
.month-nav, .month-label { border: 0; background: transparent; color: inherit; }
.month-nav { font-size: 34px; height: 48px; }
.month-label { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.month-label span { font-weight: 800; font-size: 18px; }
.month-label small { opacity: .65; }
main { padding: 18px 16px 0; }
.view { display: none; }
.view.active { display: block; }
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.summary-card {
  min-height: 132px; border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: var(--shadow); border: 1px solid rgba(255,255,255,.65);
}
.summary-card span { font-size: 13px; font-weight: 700; color: var(--muted); }
.summary-card strong { display: block; font-size: 24px; letter-spacing: -.04em; }
.summary-card small { color: var(--muted); font-size: 12px; }
.income-card { background: #f6e9c8; }
.paid-card { background: #dfeee7; }
.pending-card { background: #f1dfda; }
.balance-card { background: var(--surface); }
.mini-action { border: 0; background: transparent; padding: 0; text-align: left; font-size: 12px; font-weight: 800; color: var(--brand-2); }
.global-card { margin-top: 12px; background: var(--brand); color: white; padding: 18px; border-radius: var(--radius); box-shadow: var(--shadow); }
.global-card > div { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.global-card span { font-size: 13px; opacity: .72; }
.global-card strong { font-size: 24px; }
.global-card p { margin: 8px 0 0; font-size: 12px; opacity: .66; line-height: 1.45; }
.section-block { margin-top: 28px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.sticky-heading { position: sticky; top: 0; z-index: 4; background: linear-gradient(var(--bg) 78%, transparent); padding: 6px 0 16px; }
.text-btn { border: 0; background: transparent; color: var(--brand-2); font-weight: 800; padding: 8px; }
.primary-btn, .secondary-btn, .danger-btn { border: 0; border-radius: 15px; min-height: 48px; padding: 0 18px; font-weight: 800; }
.primary-btn { background: var(--brand); color: white; }
.secondary-btn { background: var(--surface-2); color: var(--ink); }
.danger-btn { background: #f5dedb; color: var(--danger); margin-top: 10px; }
.compact { min-height: 42px; border-radius: 13px; }
.full { width: 100%; margin-top: 8px; }
.stack-list { display: flex; flex-direction: column; gap: 10px; }
.stack-list.spacious { gap: 12px; }
.empty-state { background: var(--surface); border: 1px dashed var(--line); border-radius: 18px; padding: 22px; text-align: center; color: var(--muted); }
.list-card { background: var(--surface); border: 1px solid var(--line); border-radius: 19px; padding: 14px; box-shadow: 0 5px 18px rgba(23,32,30,.04); }
.list-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.list-card-title { display: flex; align-items: flex-start; gap: 11px; min-width: 0; }
.provider-icon { width: 42px; height: 42px; border-radius: 14px; background: var(--surface-2); display: grid; place-items: center; flex: 0 0 auto; font-size: 18px; font-weight: 900; }
.list-card h3 { margin: 1px 0 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { color: var(--muted); font-size: 12px; line-height: 1.45; }
.amount { font-weight: 900; font-size: 17px; white-space: nowrap; }
.status-row { margin-top: 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.badge { display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.badge.paid { color: var(--success); background: #e2f0e9; }
.badge.pending { color: var(--warning); background: #f7ead1; }
.badge.overdue { color: var(--danger); background: #f5dedb; }
.inline-actions { display: flex; gap: 8px; }
.inline-actions button { border: 0; border-radius: 11px; min-height: 36px; padding: 0 12px; font-size: 12px; font-weight: 800; }
.mark-paid { background: var(--brand); color: white; }
.edit-btn { background: var(--surface-2); color: var(--ink); }
.segmented { display: grid; grid-template-columns: repeat(3,1fr); gap: 4px; background: #e5e1d6; padding: 4px; border-radius: 15px; margin-bottom: 14px; }
.segmented button { border: 0; background: transparent; min-height: 38px; border-radius: 11px; font-size: 12px; font-weight: 800; color: var(--muted); }
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.helper { color: var(--muted); font-size: 12px; line-height: 1.5; }
.block { display: block; margin-top: 10px; }
.info-card { background: var(--surface); border: 1px solid var(--line); padding: 17px; border-radius: 18px; margin-bottom: 14px; }
.info-card p { color: var(--muted); line-height: 1.55; margin-bottom: 14px; }
.warning-card { background: #fff4dd; border-color: #ecd39e; }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.action-tile { border: 1px solid var(--line); background: var(--surface); border-radius: 18px; padding: 16px; min-height: 132px; text-align: left; display: flex; flex-direction: column; justify-content: center; gap: 4px; color: var(--ink); }
.action-tile span { font-size: 23px; margin-bottom: 8px; }
.action-tile small { color: var(--muted); }
.bottom-nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: min(680px,100%); height: calc(74px + env(safe-area-inset-bottom)); padding: 8px 18px env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(5,1fr); background: rgba(255,253,248,.94); backdrop-filter: blur(18px); border-top: 1px solid var(--line); z-index: 20; }
.bottom-nav button { border: 0; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.bottom-nav button span { font-size: 22px; line-height: 1; }
.bottom-nav button small { font-size: 10px; font-weight: 800; }
.bottom-nav button.active { color: var(--brand); }
.fab-wrap { position: fixed; left: 50%; bottom: calc(82px + env(safe-area-inset-bottom)); width: min(680px,100%); transform: translateX(-50%); pointer-events: none; z-index: 21; display: flex; justify-content: flex-end; padding-right: 18px; }
.fab { width: 58px; height: 58px; border-radius: 20px; border: 0; background: var(--accent); color: #2c2415; font-size: 32px; box-shadow: 0 12px 24px rgba(82,62,25,.28); pointer-events: auto; }
.modal { width: min(600px, calc(100% - 20px)); border: 0; border-radius: 26px; padding: 0; background: var(--surface); color: var(--ink); max-height: calc(100vh - 24px); }
.modal::backdrop { background: rgba(9,22,19,.58); backdrop-filter: blur(3px); }
.modal form { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.modal .icon-btn { background: var(--surface-2); color: var(--ink); }
.modal label { font-size: 12px; font-weight: 800; color: var(--muted); display: flex; flex-direction: column; gap: 7px; }
.modal input, .modal select, .modal textarea { width: 100%; border: 1px solid var(--line); background: white; border-radius: 13px; padding: 13px 14px; color: var(--ink); outline: none; }
.modal input:focus, .modal select:focus, .modal textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(35,92,82,.1); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.money-input { position: relative; }
.money-input input { padding-right: 42px; }
.money-input span { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.optional { font-weight: 500; opacity: .7; }
.checkbox-line { flex-direction: row !important; align-items: center; gap: 9px !important; }
.checkbox-line input { width: 21px; height: 21px; margin: 0; }
.compact-modal { max-width: 440px; }
.hidden { display: none !important; }
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translate(-50%,20px); background: #152420; color: white; padding: 12px 16px; border-radius: 14px; font-size: 13px; font-weight: 700; opacity: 0; pointer-events: none; transition: .25s ease; z-index: 100; max-width: calc(100% - 36px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%,0); }

@media (min-width: 700px) {
  body { background: #d8d4c9; }
  .app-shell { background: var(--bg); box-shadow: 0 0 45px rgba(0,0,0,.16); }
}
@media (max-width: 430px) {
  .summary-card strong { font-size: 21px; }
  .two-col { grid-template-columns: 1fr; }
}
@media print {
  body { background: white; }
  .topbar, .month-nav, .bottom-nav, .fab-wrap, .view:not(.active), .text-btn, .primary-btn, .secondary-btn, .danger-btn, .inline-actions, .segmented { display: none !important; }
  .app-shell { max-width: none; padding-bottom: 0; }
  .month-switcher { color: black; background: white; border-radius: 0; padding-bottom: 10px; }
  main { padding: 0; }
  .summary-card, .global-card, .list-card, .month-close-card, .chart-card { box-shadow: none; break-inside: avoid; }
  .global-card { color: black; background: #eee; }
}

/* V3: cykle, zamykanie miesiąca, kalendarz i historia */
.heading-actions { display: flex; align-items: center; gap: 2px; }
.lock-banner {
  margin-bottom: 12px; border-radius: 18px; padding: 13px 14px; background: #fff2d9; border: 1px solid #e7ca8b;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.lock-banner > div { display: flex; flex-direction: column; gap: 3px; }
.lock-banner small { color: var(--muted); line-height: 1.35; }
.lock-notice { margin-bottom: 12px; padding: 12px 14px; border-radius: 15px; background: #fff2d9; border: 1px solid #e7ca8b; color: #6f5019; font-size: 12px; line-height: 1.45; }
.month-close-card {
  margin-top: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 17px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; box-shadow: 0 5px 18px rgba(23,32,30,.04);
}
.month-close-card h3 { margin-bottom: 5px; }
.month-close-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.month-close-card.closed { background: #e4efe9; border-color: #bfd7cb; }
.month-close-card .secondary-btn { flex: 0 0 auto; }
button:disabled { opacity: .48; cursor: default; }

.history-controls { background: var(--surface); border: 1px solid var(--line); border-radius: 19px; padding: 14px; margin-bottom: 12px; }
.history-controls label { font-size: 12px; font-weight: 800; color: var(--muted); display: flex; flex-direction: column; gap: 7px; }
.history-controls select { width: 100%; border: 1px solid var(--line); background: white; border-radius: 13px; padding: 13px 14px; color: var(--ink); }
.history-range { margin: 12px 0 0; }
.history-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.history-stats article { background: var(--surface); border: 1px solid var(--line); border-radius: 17px; padding: 14px; min-height: 87px; display: flex; flex-direction: column; justify-content: space-between; }
.history-stats span { color: var(--muted); font-size: 11px; font-weight: 700; }
.history-stats strong { font-size: 18px; }
.chart-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: 0 5px 18px rgba(23,32,30,.04); }
.chart-heading h3 { margin-bottom: 4px; }
.chart-heading p { margin: 0 0 14px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.chart-wrap { min-height: 270px; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
.chart-wrap svg { display: block; min-width: 100%; height: 270px; overflow: visible; }
.chart-grid-line { stroke: #ded9cc; stroke-width: 1; }
.chart-axis-label { fill: #68726f; font-size: 10px; font-family: inherit; }
.chart-value-label { fill: #17201e; font-size: 10px; font-weight: 800; font-family: inherit; }
.chart-bar { fill: #235c52; rx: 6; }
.chart-bar:hover { fill: #173c36; }
.chart-empty { height: 250px; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 24px; }
.history-list-block { margin-top: 22px; }
.history-payment-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }
.history-payment-row .amount { text-align: right; }
.frequency-badge { background: #e4e7f3; color: #46506e; }

@media (max-width: 430px) {
  .month-close-card { align-items: flex-start; flex-direction: column; }
  .month-close-card .secondary-btn { width: 100%; }
  .bottom-nav { padding-left: 8px; padding-right: 8px; }
  .bottom-nav button small { font-size: 9px; }
  .inline-actions { flex-wrap: wrap; justify-content: flex-end; }
}

/* =========================================================
   V4 — cieplejszy, bardziej „aplikacyjny” interfejs mobilny
   ========================================================= */
:root {
  --bg: #f3f5ef;
  --surface: #ffffff;
  --surface-2: #eef1eb;
  --ink: #15231f;
  --muted: #697873;
  --brand: #123f39;
  --brand-2: #1f675b;
  --brand-3: #2d8071;
  --accent: #f1bd5a;
  --accent-soft: #fff0c9;
  --danger: #b44f48;
  --success: #278167;
  --warning: #a66a13;
  --line: #e2e8e2;
  --shadow: 0 16px 36px rgba(21, 44, 38, .09);
  --shadow-soft: 0 8px 22px rgba(21, 44, 38, .06);
  --radius: 24px;
}

html { background: var(--brand); }
body {
  background:
    radial-gradient(circle at 6% 24%, rgba(240, 189, 90, .09), transparent 24%),
    linear-gradient(180deg, #edf2ec 0%, var(--bg) 42%, #f7f7f3 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}
button, .action-tile { -webkit-tap-highlight-color: transparent; }
button:active, .action-tile:active { transform: scale(.985); }
.icon {
  width: 1em;
  height: 1em;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.app-shell {
  max-width: 720px;
  background: transparent;
  padding-bottom: 118px;
}
.app-hero {
  position: relative;
  overflow: hidden;
  color: #fff;
  padding-bottom: 58px;
  border-radius: 0 0 38px 38px;
  background:
    radial-gradient(circle at 86% 0%, rgba(118, 207, 184, .30), transparent 31%),
    radial-gradient(circle at 3% 92%, rgba(240, 189, 90, .20), transparent 30%),
    linear-gradient(145deg, #0d332e 0%, #164c44 58%, #1e6358 100%);
  box-shadow: 0 18px 44px rgba(11, 53, 46, .22);
}
.app-hero::before,
.app-hero::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 50%;
  pointer-events: none;
}
.app-hero::before { width: 180px; height: 180px; right: -74px; top: 24px; }
.app-hero::after { width: 86px; height: 86px; left: -34px; bottom: 14px; }
.topbar {
  position: relative;
  z-index: 1;
  padding: calc(18px + env(safe-area-inset-top)) 20px 14px;
  background: transparent;
}
.brand-wrap { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  position: relative;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: #184f47;
  background: linear-gradient(145deg, #fffdf5, #e9f3ed);
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 16px;
  box-shadow: 0 9px 24px rgba(0,0,0,.16);
}
.brand-mark > .icon { width: 24px; height: 24px; }
.brand-check {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #173f38;
  background: var(--accent);
  border: 3px solid #164c44;
}
.brand-check .icon { width: 10px; height: 10px; stroke-width: 3; }
h1 { font-size: clamp(22px, 6vw, 26px); letter-spacing: -.045em; }
.topbar .eyebrow { color: rgba(255,255,255,.65); }
.topbar-settings {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.16);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
  backdrop-filter: blur(12px);
}
.topbar-settings .icon { width: 21px; height: 21px; }

.month-switcher {
  position: relative;
  z-index: 1;
  width: calc(100% - 32px);
  margin: 6px auto 0;
  padding: 5px;
  border-radius: 22px;
  grid-template-columns: 48px 1fr 48px;
  color: #fff;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
  backdrop-filter: blur(18px);
}
.month-nav {
  width: 42px;
  height: 42px;
  margin: auto;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.10);
  transition: background .2s ease, transform .2s ease;
}
.month-nav:hover { background: rgba(255,255,255,.17); }
.month-nav .icon { width: 22px; height: 22px; }
.month-label { min-height: 54px; justify-content: center; }
.month-label span { font-size: 18px; letter-spacing: -.02em; }
.month-label small { font-size: 11px; color: rgba(255,255,255,.64); opacity: 1; }

main {
  position: relative;
  z-index: 2;
  margin-top: -42px;
  padding: 0 16px 10px;
}
.view.active { animation: view-enter .26s ease both; }
@keyframes view-enter { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.balance-hero {
  position: relative;
  min-height: 172px;
  padding: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  overflow: hidden;
  color: #fff;
  border-radius: 28px;
  background:
    radial-gradient(circle at 92% 14%, rgba(241,189,90,.27), transparent 36%),
    linear-gradient(135deg, #173f38 0%, #286d60 100%);
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 18px 38px rgba(19, 65, 57, .22);
}
.balance-hero::after {
  content: "";
  position: absolute;
  width: 150px;
  height: 150px;
  right: -75px;
  bottom: -88px;
  border-radius: 50%;
  border: 24px solid rgba(255,255,255,.045);
}
.balance-hero.negative { background: radial-gradient(circle at 92% 14%, rgba(255,208,144,.25), transparent 36%), linear-gradient(135deg, #653c37, #a1574e); }
.balance-copy { position: relative; z-index: 1; min-width: 0; }
.balance-copy > span { display: block; margin-bottom: 7px; color: rgba(255,255,255,.68); font-size: 12px; font-weight: 750; }
.balance-copy strong { display: block; max-width: 210px; font-size: clamp(30px, 9vw, 42px); line-height: 1; letter-spacing: -.055em; overflow-wrap: anywhere; }
.balance-copy small { display: block; max-width: 220px; margin-top: 10px; color: rgba(255,255,255,.61); font-size: 11px; line-height: 1.4; }
.progress-ring {
  --progress: 0deg;
  position: relative;
  z-index: 1;
  width: 94px;
  height: 94px;
  flex: 0 0 auto;
  padding: 7px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--progress), rgba(255,255,255,.13) 0);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.10), 0 9px 26px rgba(0,0,0,.12);
  transition: background .45s ease;
}
.progress-ring-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(13,51,46,.92);
  border: 1px solid rgba(255,255,255,.09);
}
.progress-ring strong { font-size: 20px; letter-spacing: -.04em; }
.progress-ring span { margin-top: 1px; font-size: 9px; color: rgba(255,255,255,.62); }

.summary-grid { margin-top: 12px; gap: 10px; }
.summary-card {
  position: relative;
  min-height: 128px;
  padding: 15px;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,.8);
  box-shadow: var(--shadow-soft);
  transition: transform .2s ease, box-shadow .2s ease;
}
.summary-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.summary-card::after {
  content: "";
  position: absolute;
  width: 72px;
  height: 72px;
  right: -30px;
  bottom: -36px;
  border-radius: 50%;
  background: rgba(255,255,255,.34);
}
.summary-wide {
  grid-column: 1 / -1;
  min-height: 102px;
  flex-direction: row;
  align-items: center;
}
.summary-card-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.summary-card > div:last-child { position: relative; z-index: 1; }
.summary-card span:not(.summary-icon) { color: #60716b; font-size: 11px; font-weight: 760; }
.summary-card strong { margin-top: 4px; font-size: 22px; color: #1a2b26; }
.summary-card small { display: block; margin-top: 3px; color: #70817b; }
.summary-icon {
  position: relative;
  z-index: 1;
  width: 39px;
  height: 39px;
  flex: 0 0 auto;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 900;
  color: var(--brand);
  background: rgba(255,255,255,.65);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.65);
}
.summary-icon .icon { width: 19px; height: 19px; stroke-width: 2.2; }
.income-card { background: linear-gradient(135deg, #fff4d8, #fae6b7); }
.paid-card { background: linear-gradient(145deg, #e5f4ed, #d4ebe1); }
.pending-card { background: linear-gradient(145deg, #ffede6, #f7ddd6); }
.mini-action {
  position: relative;
  z-index: 2;
  min-height: 39px;
  padding: 0 13px;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 13px;
  color: #173f38;
  background: rgba(255,255,255,.68);
  box-shadow: 0 5px 14px rgba(93,72,28,.10);
}
.mini-action .icon { width: 15px; height: 15px; stroke-width: 2.4; }

.global-card {
  position: relative;
  margin-top: 12px;
  padding: 17px;
  display: flex;
  align-items: center;
  gap: 14px;
  overflow: hidden;
  color: var(--ink);
  background: rgba(255,255,255,.80);
  border: 1px solid rgba(255,255,255,.9);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
}
.global-card.negative { border-color: #efd2cf; background: #fff6f4; }
.global-icon {
  width: 47px;
  height: 47px;
  flex: 0 0 auto;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: var(--brand-2);
  background: #e5f2ec;
}
.global-icon .icon { width: 23px; height: 23px; }
.global-content { min-width: 0; flex: 1; }
.global-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.global-card span { color: var(--muted); font-size: 11px; font-weight: 760; opacity: 1; }
.global-chip { padding: 4px 7px; border-radius: 999px; color: var(--brand-2) !important; background: #e7f1ed; font-size: 8px !important; letter-spacing: .08em; }
.global-card strong { display: block; margin-top: 3px; color: var(--ink); font-size: 25px; letter-spacing: -.045em; }
.global-card p { margin: 3px 0 0; color: var(--muted); opacity: 1; font-size: 10px; }

.month-close-card {
  margin-top: 12px;
  padding: 16px;
  align-items: center;
  gap: 12px;
  border-radius: 22px;
  background: rgba(255,255,255,.82);
  border: 1px solid rgba(255,255,255,.9);
  box-shadow: var(--shadow-soft);
}
.month-close-icon {
  width: 43px;
  height: 43px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: #776124;
  background: var(--accent-soft);
}
.month-close-icon .icon { width: 20px; height: 20px; }
.month-close-copy { min-width: 0; flex: 1; }
.month-close-card .eyebrow { color: #8c7a45; }
.month-close-card h3 { margin-bottom: 3px; }
.month-close-card p { max-width: 390px; }
.month-close-card.closed { background: #e9f4ef; border-color: #cde3d9; }
.month-close-card.closed .month-close-icon { color: var(--success); background: #d3eadf; }

.section-block { margin-top: 30px; }
.section-heading { margin-bottom: 13px; }
.section-heading h2 { font-size: 21px; }
.section-heading .eyebrow { color: #7c8985; opacity: 1; }
.heading-actions { gap: 4px; }
.text-btn {
  min-height: 37px;
  padding: 0 10px;
  border-radius: 12px;
  font-size: 12px;
  transition: background .2s ease;
}
.text-btn:hover { background: #e8eeea; }
.primary-btn, .secondary-btn, .danger-btn {
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
}
.primary-btn { background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 8px 18px rgba(20,72,63,.18); }
.primary-btn:hover { box-shadow: 0 10px 22px rgba(20,72,63,.24); }
.secondary-btn { background: #edf1ed; }
.compact { min-height: 40px; }

.sticky-heading {
  top: 0;
  margin: 0 -16px 12px;
  padding: 12px 16px 14px;
  background: linear-gradient(180deg, rgba(243,245,239,.98) 75%, rgba(243,245,239,0));
  backdrop-filter: blur(8px);
}
.stack-list { gap: 11px; }
.list-card {
  position: relative;
  overflow: hidden;
  padding: 15px;
  border-radius: 21px;
  border: 1px solid rgba(224,232,225,.96);
  background: rgba(255,255,255,.90);
  box-shadow: var(--shadow-soft);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.list-card:hover { transform: translateY(-1px); border-color: #d3dfd7; box-shadow: var(--shadow); }
.list-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 0 5px 5px 0;
  background: #cad6d0;
}
.list-card.category-power::before { background: #e8b33f; }
.list-card.category-internet::before { background: #746bd1; }
.list-card.category-phone::before { background: #4384db; }
.list-card.category-gas::before { background: #e2774c; }
.list-card.category-medicine::before { background: #e36b83; }
.list-card.category-shopping::before { background: #46a77d; }
.list-card.category-insurance::before { background: #5576ad; }
.list-card.category-tax::before { background: #93755e; }
.list-card.category-repairs::before { background: #66716d; }
.list-card.category-income::before { background: var(--success); }
.provider-icon {
  width: 44px;
  height: 44px;
  border-radius: 15px;
  color: #44524d;
  background: #eef2ef;
  border: 1px solid #e2e9e4;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8);
}
.category-power .provider-icon { background: #fff2c9; color: #94620c; border-color: #f4dfa0; }
.category-internet .provider-icon { background: #efedff; color: #5f58ae; border-color: #dedafb; }
.category-phone .provider-icon { background: #e9f2ff; color: #326cb8; border-color: #d8e8fb; }
.category-gas .provider-icon { background: #fff0e8; color: #b75934; border-color: #f5ddd2; }
.category-medicine .provider-icon { background: #ffecef; color: #b9445c; border-color: #f6d9df; }
.category-shopping .provider-icon, .category-income .provider-icon { background: #e7f5ee; color: #2b7b60; border-color: #d5eadf; }
.list-card h3 { font-size: 16px; letter-spacing: -.02em; }
.amount { font-size: 18px; letter-spacing: -.025em; }
.meta { color: #74817d; }
.status-row { margin-top: 13px; }
.badge {
  position: relative;
  min-height: 27px;
  padding: 0 10px 0 22px;
  border: 1px solid transparent;
}
.badge::before {
  content: "";
  position: absolute;
  left: 9px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge.paid { background: #e8f4ee; border-color: #d5eadf; }
.badge.pending { background: #fff1d8; border-color: #f1dfba; }
.badge.overdue { background: #fde8e5; border-color: #efd5d1; }
.frequency-badge { padding-left: 10px; background: #eeeff9; border-color: #dfe1f3; }
.frequency-badge::before { display: none; }
.inline-actions { align-items: center; }
.inline-actions button {
  min-height: 35px;
  padding: 0 11px;
  border-radius: 12px;
  transition: background .16s ease, transform .16s ease;
}
.mark-paid { background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 5px 12px rgba(20,72,63,.15); }
.edit-btn { color: #53625d; background: #eef2ef; }
.edit-btn:hover { background: #e4eae6; }
.empty-state {
  min-height: 116px;
  display: grid;
  place-items: center;
  padding: 26px;
  color: #71807b;
  border: 1px dashed #cfd9d2;
  background: rgba(255,255,255,.65);
  box-shadow: inset 0 0 0 5px rgba(255,255,255,.28);
}

.segmented {
  padding: 5px;
  gap: 3px;
  border: 1px solid #dfe6e0;
  background: #e9eee9;
  border-radius: 17px;
}
.segmented button { min-height: 39px; border-radius: 12px; }
.segmented button.active { color: var(--brand); box-shadow: 0 5px 14px rgba(24,59,52,.08); }

.history-controls,
.history-stats article,
.chart-card,
.info-card {
  border-color: rgba(224,232,225,.96);
  background: rgba(255,255,255,.88);
  box-shadow: var(--shadow-soft);
}
.history-controls { border-radius: 22px; padding: 16px; }
.history-stats article { border-radius: 19px; min-height: 92px; }
.history-stats article:nth-child(1) { background: linear-gradient(145deg, #fff, #edf6f2); }
.history-stats article:nth-child(2) { background: linear-gradient(145deg, #fff, #fff6df); }
.history-stats article:nth-child(3) { background: linear-gradient(145deg, #fff, #ffede8); }
.history-stats article:nth-child(4) { background: linear-gradient(145deg, #fff, #eaf0ff); }
.history-stats strong { font-size: 19px; letter-spacing: -.03em; }
.chart-card { border-radius: 24px; padding: 17px; }
.chart-wrap { border-radius: 18px; background: linear-gradient(180deg, rgba(238,244,240,.68), rgba(255,255,255,.28)); }
.chart-grid-line { stroke: #dce5df; stroke-dasharray: 3 5; }
.chart-axis-label { fill: #71807b; }
.chart-value-label { fill: #183d36; }
.chart-bar { fill: url(#barGradient); filter: drop-shadow(0 4px 4px rgba(26,96,83,.12)); }

.warning-card {
  background: linear-gradient(145deg, #fff9e9, #fff1cf);
  border-color: #f0d9a4;
}
.action-grid { gap: 11px; }
.action-tile {
  position: relative;
  overflow: hidden;
  min-height: 128px;
  padding: 16px;
  border-radius: 21px;
  border-color: rgba(224,232,225,.96);
  background: rgba(255,255,255,.90);
  box-shadow: var(--shadow-soft);
  transition: transform .18s ease, box-shadow .18s ease;
}
.action-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.action-tile:last-of-type { grid-column: 1 / -1; min-height: 105px; }
.action-tile::after {
  content: "";
  position: absolute;
  width: 76px;
  height: 76px;
  right: -34px;
  bottom: -38px;
  border-radius: 50%;
  background: #eef4f0;
}
.tile-icon {
  width: 39px;
  height: 39px;
  margin-bottom: 8px !important;
  display: grid;
  place-items: center;
  color: var(--brand-2);
  border-radius: 13px;
  background: #e5f2ec;
}
.tile-icon .icon { width: 20px; height: 20px; }
.action-tile strong, .action-tile small { position: relative; z-index: 1; }

.bottom-nav {
  bottom: calc(10px + env(safe-area-inset-bottom));
  width: min(696px, calc(100% - 20px));
  height: 72px;
  padding: 7px 7px;
  border: 1px solid rgba(220,229,222,.86);
  border-radius: 24px;
  background: rgba(255,255,255,.90);
  box-shadow: 0 16px 38px rgba(22,48,41,.17);
  backdrop-filter: blur(22px) saturate(1.15);
}
.bottom-nav button {
  position: relative;
  border-radius: 17px;
  gap: 3px;
  transition: background .2s ease, color .2s ease;
}
.bottom-nav button.active { color: var(--brand); background: #eaf3ee; }
.nav-icon {
  width: 28px;
  height: 27px;
  display: grid;
  place-items: center;
  font-size: inherit !important;
}
.nav-icon .icon { width: 20px; height: 20px; stroke-width: 2; }
.bottom-nav button small { font-size: 9px; letter-spacing: .01em; }
.fab-wrap {
  bottom: calc(90px + env(safe-area-inset-bottom));
  width: min(720px,100%);
  padding-right: 20px;
}
.fab {
  width: 58px;
  height: 58px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  color: #234038;
  background: linear-gradient(145deg, #ffd77c, #ebb34d);
  border: 1px solid rgba(255,255,255,.56);
  box-shadow: 0 14px 28px rgba(91,68,24,.28), inset 0 1px 0 rgba(255,255,255,.55);
}
.fab .icon { width: 25px; height: 25px; stroke-width: 2.4; }

.modal {
  border-radius: 28px;
  background: #fbfcf9;
  box-shadow: 0 26px 70px rgba(8,30,25,.28);
}
.modal[open] { animation: modal-enter .22s ease both; }
@keyframes modal-enter { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }
.modal form { padding: 21px; gap: 15px; }
.modal .icon-btn { display: grid; place-items: center; border-radius: 13px; }
.modal input, .modal select, .modal textarea {
  min-height: 47px;
  border-color: #dce5de;
  background: #fff;
  box-shadow: inset 0 1px 2px rgba(24,54,47,.025);
}
.modal textarea { min-height: 76px; }
.modal input:focus, .modal select:focus, .modal textarea:focus {
  border-color: #54a08f;
  box-shadow: 0 0 0 4px rgba(45,128,113,.10);
}
.toast {
  bottom: calc(96px + env(safe-area-inset-bottom));
  min-width: 170px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 15px;
  background: rgba(17,50,44,.96);
  box-shadow: 0 14px 34px rgba(12,40,34,.24);
  backdrop-filter: blur(12px);
}

@media (min-width: 700px) {
  body { background: #dbe4de; }
  .app-shell { background: linear-gradient(180deg, #f2f5f0, #f7f7f3); box-shadow: 0 0 58px rgba(14,45,38,.18); }
}
@media (max-width: 430px) {
  .balance-hero { min-height: 162px; padding: 20px 18px; }
  .progress-ring { width: 86px; height: 86px; }
  .balance-copy strong { font-size: 34px; }
  .summary-card strong { font-size: 21px; }
  .summary-wide { min-height: 98px; }
  .month-close-card { align-items: stretch; flex-direction: row; flex-wrap: wrap; }
  .month-close-card .secondary-btn { width: 100%; }
  .month-close-copy { width: calc(100% - 58px); }
  .inline-actions { width: 100%; justify-content: flex-end; margin-top: 3px; }
  .status-row { flex-wrap: wrap; }
  .bottom-nav { width: calc(100% - 14px); bottom: calc(7px + env(safe-area-inset-bottom)); }
  .bottom-nav button small { font-size: 8.5px; }
}
@media (max-width: 355px) {
  .balance-hero { gap: 8px; }
  .progress-ring { width: 76px; height: 76px; }
  .progress-ring strong { font-size: 17px; }
  .balance-copy strong { font-size: 30px; }
  .balance-copy small { font-size: 10px; }
  .mini-action { padding: 0 10px; font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
@media print {
  .app-hero { color: #000; background: #fff; box-shadow: none; padding-bottom: 0; }
  main { margin-top: 0; }
  .balance-hero { color: #000; background: #eee; box-shadow: none; }
  .progress-ring { display: none; }
  .global-card { color: #000; background: #eee; }
  .bottom-nav { display: none !important; }
}
/* Correct the broad legacy selector from the earlier layout. */
.global-card > .global-content { display: block; align-items: initial; justify-content: initial; gap: 0; }
.global-card > .global-icon { display: grid; }
.global-card .global-title { display: flex; }
