:root {
  --bg: #eef3f9;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --text: #0f172a;
  --muted: #64748b;
  --line: #d7e2ee;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --success-bg: #ecfdf5;
  --success-text: #166534;
  --error-bg: #fef2f2;
  --error-text: #991b1b;
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --shadow: 0 18px 44px rgba(15, 23, 42, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #f7fbff 0%, var(--bg) 100%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; height: auto; }
.app-shell { min-height: 100vh; }
.page-wrap,
.topbar,
.app-nav {
  width: min(1120px, calc(100% - 24px));
  margin: 0 auto;
}
.page-wrap { padding: 16px 0 calc(104px + env(safe-area-inset-bottom, 0px)); }
.topbar {
  padding: 16px 0 8px;
  display: grid;
  gap: 12px;
}
.topbar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.topbar-brand-group {
  min-width: 0;
}
.topbar-brand {
  font-size: 1.08rem;
  font-weight: 800;
  line-height: 1.2;
}
.topbar-subtitle {
  color: var(--muted);
  font-size: .88rem;
  margin-top: 6px;
  line-height: 1.4;
}
.has-bottom-nav .topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding-top: max(12px, env(safe-area-inset-top, 0px));
  background: linear-gradient(180deg, rgba(247,251,255,.98) 0%, rgba(247,251,255,.92) 70%, rgba(247,251,255,0) 100%);
  backdrop-filter: blur(12px);
}
.topbar-actions {
  display: grid;
  gap: 10px;
}
.topbar-logout {
  width: auto;
  min-width: 104px;
}
.card {
  background: var(--surface);
  border: 1px solid rgba(215, 226, 238, .95);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}
.panel { padding: 18px; }
.grid { display: grid; gap: 14px; }
.grid-2,
.grid-3 { grid-template-columns: minmax(0, 1fr); }
.metric {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
  min-width: 0;
}
.metric-label {
  color: var(--muted);
  font-size: .82rem;
  margin-bottom: 8px;
  line-height: 1.4;
}
.metric-value {
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.15;
  word-break: break-word;
}
.metric-value.small { font-size: 1.22rem; }
.form-stack { display: grid; gap: 14px; }
.field { display: grid; gap: 8px; min-width: 0; }
.field label { font-size: .92rem; font-weight: 700; }
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  outline: none;
}
.field textarea {
  min-height: 116px;
  resize: vertical;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(37, 99, 235, .55);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.field small { color: var(--muted); }
.actions {
  display: grid;
  gap: 10px;
}
.actions > * {
  width: 100%;
}
.actions form { margin: 0; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  width: 100%;
  padding: 0 18px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-weight: 700;
  cursor: pointer;
  white-space: normal;
  text-align: center;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-strong); }
.btn-light { background: #fff; border-color: var(--line); }
.btn-block { width: 100%; }
.alert {
  margin-bottom: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid transparent;
  transition: opacity .25s ease;
}
.alert-success { background: var(--success-bg); color: var(--success-text); border-color: #bbf7d0; }
.alert-error { background: var(--error-bg); color: var(--error-text); border-color: #fecaca; }
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  width: 100%;
  padding: 8px 14px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
  overflow-wrap: anywhere;
}
.section-title {
  margin: 0 0 8px;
  font-size: 1.15rem;
  line-height: 1.25;
}
.section-lead {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  background: #f8fbff;
}
tr:last-child td { border-bottom: 0; }
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px 12px;
}
.auth-card {
  width: min(520px, 100%);
  padding: 22px;
}
.app-nav {
  display: none;
  gap: 10px;
  padding: 0 0 12px;
}
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, rgba(238,243,249,0) 0%, rgba(238,243,249,.9) 24%, rgba(238,243,249,.98) 100%);
  backdrop-filter: blur(14px);
}
.bottom-nav-link {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 4px;
  min-height: 62px;
  padding: 8px 6px;
  border: 1px solid rgba(215, 226, 238, .96);
  border-radius: 18px;
  background: rgba(255,255,255,.92);
  color: var(--muted);
  box-shadow: 0 12px 30px rgba(15, 23, 42, .08);
}
.bottom-nav-link.is-active {
  color: var(--primary-strong);
  border-color: rgba(37, 99, 235, .24);
  background: linear-gradient(180deg, #ffffff 0%, #eff6ff 100%);
}
.bottom-nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 1.05rem;
  line-height: 1;
}
.bottom-nav-label {
  font-size: .72rem;
  font-weight: 800;
  line-height: 1.1;
}
.app-nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.75);
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}
.app-nav-link.is-active {
  background: #fff;
  color: var(--text);
  border-color: rgba(37, 99, 235, .24);
  box-shadow: 0 10px 24px rgba(15, 23, 42, .05);
}
.compact-grid { gap: 12px; }

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: .82rem;
  font-weight: 700;
}
.status-planned { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.status-paid, .status-closed { background: #ecfdf5; color: #166534; border-color: #bbf7d0; }
.status-partial { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.status-skipped { background: #f8fafc; color: #475569; border-color: #cbd5e1; }
.status-overdue { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.status-active { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.dashboard-head {
  display: grid;
  gap: 16px;
}
.wrap-actions { gap: 10px; }
@media (max-width: 760px) {
  .topbar {
    gap: 10px;
  }
  .topbar-head {
    align-items: center;
  }
  .topbar-brand-group {
    flex: 1 1 auto;
  }
  .topbar-brand {
    font-size: 1rem;
  }
  .topbar-subtitle {
    font-size: .8rem;
    margin-top: 4px;
  }
  .topbar-logout {
    min-height: 42px;
    padding-inline: 14px;
  }
  .chip {
    justify-content: flex-start;
  }
  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }
  .table-wrap table,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap td {
    display: block;
    width: 100%;
  }
  .table-wrap thead { display: none; }
  .table-wrap tbody { display: grid; gap: 12px; }
  .table-wrap tr {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 10px 26px rgba(15, 23, 42, .05);
  }
  .table-wrap td {
    display: grid;
    grid-template-columns: minmax(108px, 42%) minmax(0, 1fr);
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
  }
  .table-wrap td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: .72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
  }
  .table-wrap td[colspan] {
    grid-template-columns: 1fr;
  }
  .table-wrap td[colspan]::before {
    display: none;
  }
}
@media (min-width: 760px) {
  .page-wrap,
  .topbar,
  .app-nav { width: min(1120px, calc(100% - 40px)); }
  .page-wrap { padding: 20px 0 44px; }
  .panel { padding: 22px; }
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
  }
  .actions > * {
    width: auto;
  }
  .btn {
    width: auto;
    white-space: nowrap;
  }
  .topbar-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
  }
  .chip { width: auto; justify-content: center; }
  .inline-month-form { width: auto; }
  .has-bottom-nav .topbar {
    position: static;
    background: transparent;
    backdrop-filter: none;
  }
}
@media (min-width: 900px) {
  .bottom-nav { display: none; }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .topbar {
    padding: 24px 0 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
  }
  .topbar-head {
    display: block;
    flex: 1 1 auto;
  }
  .app-nav {
    display: flex;
    flex-wrap: wrap;
  }
  .topbar-brand { font-size: 1.2rem; }
  .topbar-subtitle { font-size: .95rem; }
  .metric-value { font-size: 1.8rem; }
}


.chip-soft {
  background: rgba(255,255,255,.78);
  border-color: rgba(37, 99, 235, .16);
  color: var(--text);
}
.page-kicker,
.section-kicker {
  margin-bottom: 8px;
  color: var(--primary-strong);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.mobile-page-hero {
  background:
    radial-gradient(circle at top right, rgba(96,165,250,.14), transparent 38%),
    linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}
.hero-main-row {
  display: grid;
  gap: 14px;
}
.hero-balance-card {
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(37,99,235,.12);
  background: rgba(255,255,255,.8);
}
.hero-balance-value {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.2;
}
.hero-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.pill-stat {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.9);
  border: 1px solid rgba(215,226,238,.95);
  color: var(--text);
  font-size: .84rem;
  font-weight: 700;
}
.month-controls-grid {
  display: grid;
  gap: 12px;
}
.month-switcher {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.month-switcher .btn,
.month-inline-form .btn,
.month-inline-form input {
  width: 100%;
}
.form-card-shell {
  overflow: hidden;
}
.form-section {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fbfdff;
}
.form-section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.mobile-form-actions {
  position: sticky;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  z-index: 24;
  padding: 12px;
  border-radius: 20px;
  background: rgba(247,251,255,.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(215,226,238,.96);
  box-shadow: 0 14px 28px rgba(15,23,42,.08);
}
.mobile-quick-fab {
  position: fixed;
  right: 14px;
  bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  z-index: 42;
}
.mobile-quick-fab__button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  box-shadow: 0 18px 34px rgba(37,99,235,.28);
}
.mobile-quick-fab__button span {
  font-size: 1.15rem;
  line-height: 1;
}
.mobile-quick-fab__sheet {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding: 12px;
  min-width: min(86vw, 260px);
  border-radius: 20px;
  background: rgba(255,255,255,.97);
  border: 1px solid rgba(215,226,238,.95);
  box-shadow: 0 18px 44px rgba(15,23,42,.12);
}
.mobile-quick-fab__link {
  display: flex;
  align-items: center;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 14px;
  background: #f8fbff;
  border: 1px solid var(--line);
  font-weight: 700;
}
.desktop-only-actions {
  display: none;
}
@media (max-width: 760px) {
  .page-wrap {
    padding-top: 10px;
  }
  .panel {
    padding: 16px;
  }
  .topbar-brand {
    font-size: .98rem;
  }
  .topbar-subtitle {
    display: none;
  }
  .topbar-head {
    align-items: flex-start;
  }
  .topbar-actions .chip {
    min-height: 34px;
    padding-inline: 12px;
    font-size: .82rem;
  }
  .section-title {
    font-size: 1.06rem;
  }
  .metric {
    padding: 14px;
  }
  .metric-value {
    font-size: 1.34rem;
  }
  .hero-main-row {
    grid-template-columns: 1fr;
  }
  .month-switcher {
    gap: 8px;
  }
  .inline-month-form.month-inline-form {
    grid-template-columns: 1fr;
  }
  .inline-month-form.month-inline-form input {
    min-height: 48px;
  }
  .table-wrap td {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .table-wrap td::before {
    margin-bottom: 2px;
  }
  .table-wrap td[data-label="Akcja"] .btn,
  .table-wrap td[data-label="Akcja"] form,
  .table-wrap td[data-label="Akcja"] form .btn {
    width: 100%;
  }
  .mobile-form-actions {
    grid-template-columns: 1fr 1fr;
  }
}
@media (min-width: 760px) {
  .hero-main-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }
  .month-controls-grid {
    grid-template-columns: auto auto 1fr;
    align-items: center;
  }
  .desktop-only-actions {
    display: flex;
    justify-content: flex-end;
  }
  .mobile-form-actions {
    position: static;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
    backdrop-filter: none;
  }
}
@media (min-width: 900px) {
  .mobile-quick-fab {
    display: none;
  }
}


/* Stage 6: desktop polish */
@media (min-width: 1100px) {
  .page-wrap,
  .topbar,
  .app-nav { width: min(1360px, calc(100% - 56px)); }

  .page-wrap {
    padding-top: 18px;
    padding-bottom: 56px;
  }

  .topbar {
    padding: 28px 0 12px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
  }

  .topbar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
  }

  .topbar-brand {
    font-size: 1.35rem;
    letter-spacing: -.02em;
  }

  .topbar-subtitle {
    display: block;
    max-width: 780px;
    font-size: .95rem;
  }

  .topbar-actions {
    justify-content: flex-end;
  }

  .topbar-logout {
    min-width: 132px;
  }

  .app-nav {
    display: flex;
    gap: 12px;
    padding: 0 0 18px;
  }

  .app-nav-link {
    min-height: 46px;
    padding: 0 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,.84);
    box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
  }

  .app-nav-link:hover {
    border-color: rgba(37, 99, 235, .22);
    color: var(--primary-strong);
  }

  .card {
    border-radius: 22px;
  }

  .panel {
    padding: 24px;
  }

  .grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .table-wrap {
    overflow: hidden;
  }

  th, td {
    padding: 15px 16px;
  }

  .bottom-nav {
    display: none !important;
  }

  .has-bottom-nav .topbar {
    position: static;
    background: transparent;
    backdrop-filter: none;
  }
}

@media (min-width: 1320px) {
  .page-wrap,
  .topbar,
  .app-nav { width: min(1440px, calc(100% - 72px)); }
}

/* Stage 7: visual polish for desktop + mobile */
:root {
  --bg: #ecf2f8;
  --surface: rgba(255,255,255,.94);
  --surface-soft: #f6f9fc;
  --line: #dbe5ef;
  --line-strong: #c8d5e3;
  --text: #0f172a;
  --muted: #5f6f85;
  --primary: #2458d3;
  --primary-strong: #183ea1;
  --shadow-soft: 0 14px 36px rgba(15,23,42,.06);
  --shadow-card: 0 22px 54px rgba(15,23,42,.08);
}
html {
  scroll-behavior: smooth;
}
body {
  background:
    radial-gradient(circle at top left, rgba(96,165,250,.16), transparent 26%),
    radial-gradient(circle at top right, rgba(191,219,254,.24), transparent 24%),
    linear-gradient(180deg, #f8fbff 0%, #eef3f8 52%, #e9eff6 100%);
}
.app-shell {
  position: relative;
  padding-bottom: 8px;
}
.app-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 12%, rgba(255,255,255,.54), transparent 18%),
    radial-gradient(circle at 82% 6%, rgba(255,255,255,.4), transparent 16%);
}
.page-wrap,
.topbar,
.app-nav {
  width: min(1440px, calc(100% - 28px));
}
.page-wrap {
  position: relative;
  z-index: 1;
  padding: 16px 0 calc(112px + env(safe-area-inset-bottom, 0px));
}
.card {
  background: var(--surface);
  border: 1px solid rgba(219,229,239,.95);
  box-shadow: var(--shadow-card);
}
.panel {
  padding: 18px;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 34;
  padding: max(12px, env(safe-area-inset-top, 0px)) 0 10px;
  backdrop-filter: blur(14px);
}
.topbar::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 0 0 24px 24px;
  background: linear-gradient(180deg, rgba(248,251,255,.96) 0%, rgba(248,251,255,.82) 78%, rgba(248,251,255,0) 100%);
  z-index: -1;
}
.topbar-head {
  padding: 14px 16px;
  border: 1px solid rgba(219,229,239,.94);
  border-radius: 24px;
  background: rgba(255,255,255,.8);
  box-shadow: var(--shadow-soft);
}
.topbar-brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 16px;
  background: linear-gradient(180deg, #2458d3 0%, #163c9f 100%);
  color: #fff;
  font-weight: 900;
  letter-spacing: -.03em;
  box-shadow: 0 16px 32px rgba(36,88,211,.26);
}
.topbar-brand {
  font-size: 1.08rem;
  letter-spacing: -.02em;
}
.topbar-subtitle {
  max-width: 66ch;
  color: var(--muted);
}
.topbar-userbox {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.topbar-user-chip {
  min-height: 42px;
  font-weight: 700;
  background: rgba(247,250,252,.96);
}
.app-nav {
  position: sticky;
  top: 90px;
  z-index: 30;
  display: none;
  gap: 10px;
  padding: 2px 0 14px;
}
.app-nav-link {
  gap: 10px;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 16px;
  background: rgba(255,255,255,.84);
  border-color: rgba(219,229,239,.96);
  box-shadow: 0 10px 24px rgba(15,23,42,.04);
  transition: transform .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
.app-nav-link:hover {
  transform: translateY(-1px);
  border-color: rgba(36,88,211,.24);
  color: var(--primary-strong);
}
.app-nav-link.is-active {
  background: linear-gradient(180deg, #ffffff 0%, #edf3ff 100%);
  color: var(--primary-strong);
  border-color: rgba(36,88,211,.22);
  box-shadow: 0 14px 28px rgba(36,88,211,.12);
}
.app-nav-link__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 1rem;
  opacity: .9;
}
.app-nav-link__label {
  line-height: 1;
}
.bottom-nav {
  left: 50%;
  right: auto;
  bottom: max(10px, env(safe-area-inset-bottom, 0px));
  width: min(560px, calc(100% - 20px));
  transform: translateX(-50%);
  gap: 6px;
  padding: 10px;
  border: 1px solid rgba(219,229,239,.92);
  border-radius: 26px;
  background: rgba(255,255,255,.88);
  box-shadow: 0 24px 60px rgba(15,23,42,.16);
  backdrop-filter: blur(18px);
}
.bottom-nav-link {
  min-height: 58px;
  border: 0;
  border-radius: 18px;
  background: transparent;
  box-shadow: none;
}
.bottom-nav-link.is-active {
  background: linear-gradient(180deg, #edf3ff 0%, #ffffff 100%);
  box-shadow: inset 0 0 0 1px rgba(36,88,211,.14);
}
.bottom-nav-icon {
  width: 22px;
  height: 22px;
  font-size: 1rem;
}
.bottom-nav-label {
  font-size: .69rem;
}
.btn {
  min-height: 48px;
  border-radius: 15px;
  transition: transform .14s ease, box-shadow .14s ease, background .14s ease;
}
.btn:hover {
  transform: translateY(-1px);
}
.btn-primary {
  background: linear-gradient(180deg, #2458d3 0%, #183ea1 100%);
  box-shadow: 0 12px 26px rgba(36,88,211,.22);
}
.btn-light {
  background: rgba(255,255,255,.96);
  border-color: var(--line-strong);
}
.field input,
.field select,
.field textarea {
  border-color: var(--line-strong);
  background: rgba(255,255,255,.98);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45);
}
.field input::placeholder,
.field textarea::placeholder {
  color: #97a6ba;
}
.metric,
.quick-link-card,
.budget-card,
.category-item,
.bar-row,
.workflow-card,
.quick-edit-kv,
.form-section {
  background: linear-gradient(180deg, rgba(255,255,255,.98) 0%, #f9fbfe 100%);
  border-color: rgba(219,229,239,.96);
  box-shadow: 0 14px 32px rgba(15,23,42,.05);
}
.metric {
  position: relative;
  overflow: hidden;
}
.metric::after {
  content: "";
  position: absolute;
  inset: auto 14px 0;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(36,88,211,.88), rgba(96,165,250,.54));
}
.alert {
  box-shadow: 0 14px 28px rgba(15,23,42,.06);
}
.chip-soft,
.pill-stat,
.filter-chip,
.status-badge,
.chip {
  box-shadow: 0 6px 16px rgba(15,23,42,.04);
}
.page-kicker,
.section-kicker {
  color: var(--primary-strong);
}
.mobile-page-hero {
  background:
    radial-gradient(circle at top right, rgba(96,165,250,.2), transparent 34%),
    radial-gradient(circle at left top, rgba(255,255,255,.55), transparent 26%),
    linear-gradient(180deg, rgba(255,255,255,.98) 0%, rgba(246,250,255,.98) 100%);
}
.mobile-form-actions {
  bottom: calc(94px + env(safe-area-inset-bottom, 0px));
  border-radius: 22px;
  background: rgba(255,255,255,.9);
  border-color: rgba(219,229,239,.96);
  box-shadow: 0 20px 40px rgba(15,23,42,.12);
}
.mobile-quick-fab {
  right: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  transform: translateX(50%);
}
.mobile-quick-fab__button {
  min-height: 56px;
  padding: 0 20px;
  border-radius: 20px;
}
.mobile-quick-fab__sheet {
  border-radius: 22px;
}
.table-wrap tr:hover td {
  background: rgba(248,251,255,.66);
}
@media (max-width: 759px) {
  .page-wrap,
  .topbar,
  .app-nav {
    width: min(720px, calc(100% - 18px));
  }
  .page-wrap {
    padding-top: 12px;
  }
  .topbar {
    top: 0;
    padding-top: max(8px, env(safe-area-inset-top, 0px));
  }
  .topbar-head {
    padding: 12px 12px 10px;
    border-radius: 22px;
  }
  .brand-mark {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
    border-radius: 14px;
    font-size: .94rem;
  }
  .topbar-brand {
    font-size: 1rem;
  }
  .topbar-userbox {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }
  .topbar-user-chip {
    flex: 1 1 auto;
    min-width: 0;
    justify-content: flex-start;
  }
  .topbar-logout {
    min-width: 110px;
  }
  .section-title {
    font-size: 1.14rem;
    letter-spacing: -.02em;
  }
  .section-lead {
    font-size: .94rem;
  }
  .card {
    border-radius: 22px;
  }
  .panel {
    padding: 16px;
  }
  .metric {
    padding: 15px;
  }
  .metric-label {
    font-size: .78rem;
  }
  .metric-value {
    font-size: 1.42rem;
  }
  .chip,
  .pill-stat,
  .filter-chip,
  .status-badge {
    box-shadow: none;
  }
  .hero-chip-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .pill-stat {
    min-height: 44px;
    padding: 0 10px;
    justify-content: center;
    text-align: center;
    font-size: .8rem;
    line-height: 1.2;
  }
  .month-switcher {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .mobile-form-actions {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .mobile-quick-fab {
    right: 14px;
    bottom: calc(100px + env(safe-area-inset-bottom, 0px));
    transform: none;
  }
  .mobile-quick-fab__button {
    min-height: 54px;
    min-width: 54px;
    padding: 0 18px;
  }
  .table-wrap tr:hover td {
    background: transparent;
  }
  .table-wrap tr {
    background: linear-gradient(180deg, rgba(255,255,255,.98) 0%, #f9fbfe 100%);
  }
}
@media (min-width: 760px) {
  .page-wrap,
  .topbar,
  .app-nav {
    width: min(1440px, calc(100% - 44px));
  }
  .page-wrap {
    padding: 20px 0 52px;
  }
  .topbar {
    padding: 22px 0 12px;
  }
  .topbar-head {
    align-items: center;
    gap: 16px;
  }
  .app-nav {
    display: flex;
  }
  .grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (min-width: 1100px) {
  .page-wrap,
  .topbar,
  .app-nav {
    width: min(1480px, calc(100% - 72px));
  }
  .topbar-head {
    padding: 18px 20px;
  }
  .topbar-brand {
    font-size: 1.22rem;
  }
  .topbar-subtitle {
    display: block;
    font-size: .92rem;
  }
  .app-nav {
    top: 114px;
    padding-bottom: 18px;
  }
  .app-nav-link {
    min-height: 50px;
    padding: 0 18px;
  }
  .panel {
    padding: 24px;
  }
  .grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .section-title {
    font-size: 1.28rem;
  }
  .table-wrap {
    border-radius: 20px;
    overflow: hidden;
  }
  .table-wrap table {
    table-layout: fixed;
  }
  .table-wrap th {
    padding-top: 16px;
    padding-bottom: 16px;
  }
  .table-wrap td {
    padding-top: 16px;
    padding-bottom: 16px;
  }
}

/* Stage 8: targeted desktop + mobile rebalance */
@media (min-width: 900px) {
  .grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .page-wrap,
  .topbar,
  .app-nav {
    width: min(1500px, calc(100% - 56px));
  }
}
@media (min-width: 1320px) {
  .page-wrap,
  .topbar,
  .app-nav {
    width: min(1560px, calc(100% - 72px));
  }
}
.topbar-brand {
  letter-spacing: -.025em;
}
.topbar-subtitle {
  max-width: 72ch;
}
.app-nav {
  padding-bottom: 18px;
}
.app-nav-link {
  min-width: 132px;
}
.page-wrap > .card:first-child,
.page-wrap > .dashboard-head:first-child {
  margin-top: 2px;
}
@media (max-width: 759px) {
  .bottom-nav {
    width: min(560px, calc(100% - 16px));
    padding: 8px;
    border-radius: 24px;
  }
  .bottom-nav-link {
    min-height: 54px;
    border-radius: 16px;
  }
  .bottom-nav-label {
    font-size: .67rem;
  }
  .page-wrap {
    padding-bottom: calc(108px + env(safe-area-inset-bottom, 0px));
  }
}

/* Stage 12 - uproszczenie UX */
.page-wrap {
  padding-top: 12px;
}
.topbar-simple {
  padding-bottom: 10px;
}
.topbar-simple .topbar-subtitle {
  max-width: 520px;
  font-size: .84rem;
}
.topbar-userbox {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.ux-hero {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}
.ux-hero__title {
  font-size: 1.55rem;
  margin-bottom: 6px;
}
.ux-hero__actions {
  display: grid;
  gap: 10px;
}
.ux-summary-grid {
  margin-bottom: 16px;
}
.ux-summary-card {
  background: #fff;
}
.ux-section {
  border-radius: 22px;
}
.ux-section-head {
  margin-bottom: 14px;
}
.ux-main-grid {
  align-items: start;
}
.ux-main-grid-simple {
  align-items: start;
}
.ux-quick-grid {
  margin-bottom: 16px;
}
.ux-quick-card {
  min-height: 112px;
  border-radius: 20px;
  padding: 18px;
  background: #fff;
}
.ux-task-grid {
  gap: 12px;
}
.ux-task-card {
  background: #fbfdff;
}
.ux-task-meta {
  display: grid;
  gap: 6px;
  margin: 12px 0;
  color: var(--muted);
}
.ux-action-row {
  align-items: stretch;
}
.ux-side-grid {
  display: grid;
  gap: 14px;
}
.ux-note-list {
  display: grid;
  gap: 10px;
}
.ux-note-item {
  padding: 12px 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.ux-category-columns {
  gap: 18px;
}
.ux-category-item,
.ux-liability-item {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}
.ux-system-grid {
  margin-top: 16px;
}
.ux-checkbox-row {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  font-weight: 600;
}
.ux-auth-card {
  width: min(460px, 100%);
}
.filter-chip span {
  min-width: 24px;
}
.bottom-nav {
  box-shadow: 0 -8px 24px rgba(15,23,42,.08);
}
.bottom-nav-link {
  padding: 8px 4px;
  border-radius: 16px;
}
.bottom-nav-link.is-active {
  background: #fff;
  border: 1px solid var(--line);
}
@media (min-width: 768px) {
  .page-wrap,
  .topbar,
  .app-nav {
    width: min(1240px, calc(100% - 40px));
  }
  .page-wrap {
    padding-bottom: 36px;
  }
  .ux-hero {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }
  .ux-hero__actions {
    justify-items: end;
  }
  .ux-main-grid {
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, .75fr);
    gap: 18px;
  }
  .ux-main-grid-simple {
    grid-template-columns: minmax(360px, .9fr) minmax(0, 1.1fr);
    gap: 18px;
  }
  .ux-task-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .actions.action-tight,
  .ux-action-row {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    justify-content: start;
  }
  .actions.action-tight > *,
  .ux-action-row > * {
    width: auto;
  }
}


/* Mobile overflow hotfix */
.app-shell,
.page-wrap,
.card,
.panel,
.ux-main-grid,
.ux-main-grid-simple,
.ux-section,
.ux-hero,
.ux-summary-grid,
.ux-quick-grid,
.ux-side-grid {
  min-width: 0;
}

@media (max-width: 899px) {
  html, body {
    max-width: 100%;
    overflow-x: hidden;
  }

  .page-wrap,
  .topbar,
  .app-nav {
    width: min(100%, calc(100% - 20px));
  }

  .ux-main-grid,
  .ux-main-grid-simple {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .ux-task-grid,
  .ux-category-columns {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .ux-hero,
  .ux-section,
  .ux-summary-card,
  .ux-quick-card,
  .ux-category-item,
  .ux-liability-item {
    width: 100%;
    min-width: 0;
  }
}


/* Visual stage 1: shell, topbar and navigation rework */
:root {
  --shell-max: 1180px;
  --shell-gutter: 24px;
  --shell-surface: rgba(255, 255, 255, 0.94);
  --shell-border: rgba(203, 213, 225, 0.92);
  --shell-shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
  --shell-shadow-soft: 0 10px 28px rgba(15, 23, 42, 0.05);
}

body.has-bottom-nav {
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.07), transparent 26%),
    linear-gradient(180deg, #f8fbff 0%, #eef3f9 100%);
}

.page-wrap,
.topbar,
.app-nav {
  width: min(var(--shell-max), calc(100% - (var(--shell-gutter) * 2)));
}

.app-shell {
  padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
}

.shell-header {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: max(14px, env(safe-area-inset-top, 0px)) 0 12px;
  background: linear-gradient(180deg, rgba(248, 251, 255, 0.98) 0%, rgba(248, 251, 255, 0.94) 82%, rgba(248, 251, 255, 0) 100%);
  backdrop-filter: blur(10px);
}

.has-bottom-nav .topbar,
.topbar,
.topbar-simple {
  position: relative;
  top: auto;
  padding: 0;
  background: transparent;
  backdrop-filter: none;
}

.topbar::before {
  display: none;
}

.topbar-head {
  align-items: center;
  gap: 20px;
  padding: 18px 22px;
  border: 1px solid var(--shell-border);
  border-radius: 24px;
  background: var(--shell-surface);
  box-shadow: var(--shell-shadow);
}

.topbar-brand-row,
.topbar-brand-link {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.topbar-brand-link {
  text-decoration: none;
}

.brand-mark {
  width: 50px;
  height: 50px;
  border-radius: 16px;
  background: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 100%);
  color: #fff;
  font-size: 1.22rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.topbar-brand-group {
  display: grid;
  gap: 4px;
}

.topbar-brand {
  font-size: 1.14rem;
  font-weight: 800;
  line-height: 1.18;
  letter-spacing: -0.01em;
}

.topbar-subtitle {
  margin: 0;
  color: #64748b;
  font-size: 0.89rem;
  line-height: 1.42;
}

.topbar-userbox {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
}

.topbar-user-meta {
  display: grid;
  gap: 6px;
  min-width: 0;
  justify-items: end;
}

.topbar-user-label {
  color: #64748b;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.topbar-user-chip {
  width: auto;
  max-width: min(360px, 40vw);
  min-height: 42px;
  padding-inline: 14px;
  justify-content: flex-start;
  border-color: rgba(203, 213, 225, 0.9);
  background: #f8fafc;
  color: #0f172a;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.topbar-logout {
  width: auto;
  min-width: 112px;
  min-height: 42px;
  border-color: rgba(203, 213, 225, 0.95);
  background: #fff;
  box-shadow: var(--shell-shadow-soft);
}

.app-nav {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--shell-border);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shell-shadow-soft);
}

.app-nav-link {
  display: grid;
  gap: 4px;
  align-content: center;
  min-height: 64px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: transparent;
  color: #475569;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.app-nav-link:hover {
  background: rgba(248, 250, 252, 0.95);
  border-color: rgba(203, 213, 225, 0.95);
  color: #0f172a;
  transform: translateY(-1px);
}

.app-nav-link.is-active {
  background: linear-gradient(180deg, rgba(239, 246, 255, 0.98) 0%, rgba(226, 239, 255, 0.98) 100%);
  border-color: rgba(147, 197, 253, 0.95);
  color: #0f172a;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.98);
}

.app-nav-link__eyebrow {
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.app-nav-link.is-active .app-nav-link__eyebrow {
  color: #1d4ed8;
}

.app-nav-link__label {
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.2;
}

.page-wrap {
  padding: 20px 0 calc(102px + env(safe-area-inset-bottom, 0px));
}

.page-wrap > .alert:first-child,
.page-wrap > .card:first-child,
.page-wrap > .dashboard-head:first-child,
.page-wrap > section:first-child {
  margin-top: 0;
}

.bottom-nav {
  left: max(12px, env(safe-area-inset-left, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  bottom: max(12px, env(safe-area-inset-bottom, 0px));
  padding: 8px;
  border: 1px solid rgba(203, 213, 225, 0.98);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.16);
  gap: 6px;
}

.bottom-nav-link {
  min-height: 52px;
  border-radius: 16px;
  color: #64748b;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.bottom-nav-link.is-active {
  background: linear-gradient(180deg, rgba(239, 246, 255, 0.98) 0%, rgba(226, 239, 255, 0.98) 100%);
  color: #1d4ed8;
}

.bottom-nav-label {
  font-size: 0.73rem;
  font-weight: 800;
}

@media (max-width: 1099px) {
  :root {
    --shell-max: 1080px;
    --shell-gutter: 20px;
  }

  .topbar-head {
    padding: 16px 18px;
  }

  .topbar-user-chip {
    max-width: min(290px, 38vw);
  }
}

@media (max-width: 899px) {
  :root {
    --shell-gutter: 12px;
  }

  .shell-header {
    padding: max(10px, env(safe-area-inset-top, 0px)) 0 8px;
  }

  .page-wrap,
  .topbar,
  .app-nav {
    width: min(100%, calc(100% - (var(--shell-gutter) * 2)));
  }

  .topbar-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    padding: 14px;
    border-radius: 20px;
  }

  .topbar-brand-link {
    align-items: flex-start;
  }

  .brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    font-size: 1.08rem;
  }

  .topbar-brand {
    font-size: 1.02rem;
  }

  .topbar-subtitle {
    font-size: 0.83rem;
  }

  .topbar-userbox {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 10px;
  }

  .topbar-user-meta {
    justify-items: start;
  }

  .topbar-user-chip {
    max-width: 100%;
    width: 100%;
    min-height: 40px;
    justify-content: flex-start;
    text-align: left;
  }

  .topbar-logout {
    min-width: 104px;
    padding-inline: 14px;
  }

  .app-nav {
    display: none;
  }

  .page-wrap {
    padding: 16px 0 calc(108px + env(safe-area-inset-bottom, 0px));
  }
}

@media (min-width: 900px) {
  .bottom-nav {
    display: none;
  }

  .page-wrap {
    padding-bottom: 42px;
  }
}
