:root {
  --mint: #20c997;
  --mint-deep: #12b886;
  --mint-dark: #0ca678;
  --mint-soft: #e6fcf5;
  --coral: #ff6b6b;
  --coral-soft: #ffe3e3;
  --peach: #ffa94d;
  --sky: #4dabf7;
  --lavender: #845ef7;
  --pink: #f06595;
  --yellow: #fcc419;
  --bg: #f4f6fb;
  --bg-2: #eef1f8;
  --surface: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e8edf5;
  --accent: #12b886;
  --accent-2: #20c997;
  --accent-soft: #e6fcf5;
  --gold: #fcc419;
  --gold-soft: #fff3bf;
  --danger: #ff6b6b;
  --danger-soft: #ffe3e3;
  --warn: #ffa94d;
  --ok: #12b886;
  --on-accent: #ffffff;
  --hero: linear-gradient(165deg, #36d399 0%, #12b886 52%, #0ca678 100%);
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 18px 40px rgba(18, 184, 134, 0.16);
  --radius: 22px;
  --tabbar-h: 72px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "Nunito", "DM Sans", system-ui, sans-serif;
  --modal-md: 480px;
  --modal-md-h: 560px;
}

[data-theme="dark"] {
  --bg: #0f1720;
  --bg-2: #17202b;
  --surface: #1b2733;
  --ink: #f1f5f9;
  --muted: #94a3b8;
  --line: #2a3848;
  --accent: #2dd4a8;
  --accent-2: #5eead4;
  --accent-soft: #14352d;
  --gold: #fbbf24;
  --gold-soft: #3f3518;
  --danger: #fb7185;
  --danger-soft: #3f1d27;
  --warn: #fbbf24;
  --ok: #2dd4a8;
  --on-accent: #06281f;
  --hero: linear-gradient(165deg, #12956f 0%, #0d7a5c 100%);
  --mint-soft: #14352d;
  --coral-soft: #3f1d27;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
[hidden] { display: none !important; }

.app {
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 18px);
}

body.guest .app,
body.guest .tabbar,
body.guest .fab {
  display: none !important;
}
body.authed .auth-gate { display: none; }

.auth-gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px calc(24px + var(--safe-b));
  background: var(--hero);
}
.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 22px 22px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.auth-card .brand-mark {
  width: 48px;
  height: 48px;
  margin: 0 auto 10px;
  filter: none;
}
.auth-card h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--ink);
}
.auth-lead {
  color: var(--muted);
  font-weight: 700;
  margin: 6px 0 18px;
}
.auth-error.ok {
  background: var(--accent-soft);
  color: var(--mint-dark);
}
.auth-card .form-grid { text-align: left; }
.auth-switch {
  margin-top: 14px;
  border: 0;
  background: transparent;
  color: var(--mint-dark);
  font-weight: 800;
  font-size: 0.9rem;
}
.auth-switch:hover { text-decoration: underline; }
#auth-forgot { display: block; }

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 18px 44px;
  background: var(--hero);
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.12));
}
.brand h1 {
  margin: 0;
  font-size: 1.32rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: #fff;
}
.brand p {
  margin: 4px 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.month-switch {
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(255, 255, 255, 0.18);
  border: 0;
  border-radius: 999px;
  padding: 3px;
  flex-shrink: 0;
  backdrop-filter: blur(8px);
}
.month-switch button {
  border: 0;
  background: transparent;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  color: #fff;
  transition: background 0.15s ease;
}
.month-switch button:hover { background: rgba(255, 255, 255, 0.18); }
.month-switch span {
  font-size: 0.8rem;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
  padding: 0 4px;
  color: #fff;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.top-actions button {
  position: relative;
  border: 0;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border-radius: 12px;
  padding: 6px 8px;
  min-width: 44px;
  min-height: 44px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1;
}
.top-actions button svg {
  width: 18px;
  height: 18px;
}
.top-actions button.on {
  background: rgba(255, 255, 255, 0.32);
}
.top-actions button.admin-only { display: none; }
body.admin .top-actions button.admin-only { display: grid; }
body.has-pending .top-actions [data-view="users"] {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85);
}
body.has-pending .top-actions [data-view="users"]::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: #fcc419;
  position: absolute;
  top: 6px;
  right: 6px;
}

.view {
  width: min(980px, calc(100% - 28px));
  margin: -28px auto 0;
  position: relative;
  z-index: 21;
  padding: 0 0 24px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.hero-card {
  padding: 1.15rem 1.25rem 1.3rem;
}
.kpi .label {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 800;
}
.kpi .value {
  margin-top: 6px;
  font-size: 1.18rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.kpi.ok .value { color: var(--ok); }
.kpi.warn .value { color: var(--warn); }
.kpi.bad .value { color: var(--danger); }

.account-grid {
  display: grid;
  gap: 10px;
}
.account-tile {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
  border: 1px solid var(--line);
  border-left: 5px solid var(--acc, var(--mint));
  border-radius: 16px;
  padding: 12px 12px 12px 14px;
  background: color-mix(in srgb, var(--acc, var(--mint)) 8%, var(--surface));
}
.account-main {
  display: grid;
  justify-items: start;
  gap: 2px;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  color: inherit;
  width: 100%;
}
.account-kind {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.account-tile .bal {
  margin-top: 4px;
  font-size: 1.28rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.account-tile.neg .bal { color: var(--danger); }
.account-tile.on {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--acc, var(--mint)) 55%, transparent);
  border-color: color-mix(in srgb, var(--acc, var(--mint)) 40%, var(--line));
}
.account-filters {
  display: grid;
  gap: 10px;
  margin: 0 0 14px;
}
.account-filters .seg { width: 100%; }
.account-kind-filter { grid-column: 1 / -1; }
.account-move-sum {
  margin: 0 0 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.account-move-sum b.in { color: var(--ok); }
.row .run {
  margin-top: 2px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-align: right;
}
@media (min-width: 560px) {
  .account-grid { grid-template-columns: repeat(3, 1fr); }
  .account-filters { grid-template-columns: 1fr 1fr; }
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.section-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.section-head p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}
.income-head { align-items: flex-start; }
.section-head .income-total {
  margin: 8px 0 0;
  font-size: clamp(1.7rem, 6vw, 2.15rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
  color: var(--ink);
}
.section-head .income-total small {
  margin-left: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0;
}

.progress {
  height: 12px;
  background: var(--bg-2);
  border-radius: 99px;
  overflow: hidden;
}
.progress > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--mint), var(--mint-deep));
  border-radius: inherit;
  width: 0;
  transition: width 0.4s ease;
}
.progress.coral > i { background: linear-gradient(90deg, #ffa8a8, var(--coral)); }
.progress.peach > i { background: linear-gradient(90deg, #ffd8a8, var(--peach)); }
.progress.stacked {
  display: flex;
  overflow: hidden;
}
.seg-fill {
  display: flex;
  height: 100%;
  min-width: 0;
  overflow: hidden;
  border-radius: inherit;
}
.seg-fill i {
  display: block;
  height: 100%;
  flex: 0 0 auto;
  min-width: 3px;
}
.seg-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin: 2px 0 4px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
}
.seg-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.seg-legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.75rem;
  font-weight: 800;
  background: var(--accent-soft);
  color: var(--mint-dark);
  flex-shrink: 0;
  white-space: nowrap;
}
.badge.bad { background: var(--danger-soft); color: var(--danger); }
.badge.gold { background: var(--gold-soft); color: #b78105; }

.chart-box { height: 200px; }
.chart-box.tall { height: 240px; }
.chart-box.projection { height: 280px; }
.proj-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--muted);
}
.proj-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.proj-legend i {
  width: 16px;
  height: 4px;
  border-radius: 99px;
  display: inline-block;
}
.proj-legend i.in { background: #20c997; }
.proj-legend i.out { background: #ff6b6b; }
.proj-legend i.dash {
  background: repeating-linear-gradient(90deg, #868e96 0 4px, transparent 4px 7px);
}
.donut-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 210px;
}
.donut-center {
  position: absolute;
  text-align: center;
  pointer-events: none;
}
.donut-center strong {
  display: block;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
}
.donut-center small {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.cat-list { display: grid; gap: 2px; margin-top: 8px; }
.cat-row {
  display: grid;
  grid-template-columns: 14px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 2px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}
.cat-row:last-child { border-bottom: 0; }
.cat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.cat-row .pct {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  min-width: 42px;
  text-align: right;
}
.cat-row .amt { font-weight: 800; font-size: 0.92rem; }

.cat-ico {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.08);
}
.cat-ico svg { display: block; }

.compare { display: grid; gap: 8px; }
.compare-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 800;
  font-size: 0.88rem;
}
.compare-line span { color: var(--muted); font-weight: 700; font-size: 0.78rem; }

.gastos-filter { margin: 0 0 14px; }
.gastos-tools {
  display: grid;
  gap: 10px;
  margin: 0 0 14px;
}
@media (min-width: 640px) {
  .gastos-tools { grid-template-columns: 1.2fr 1fr; }
}
.gastos-tools .gastos-filter { margin: 0; }

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--muted);
}
.check-row input { width: 16px; height: 16px; accent-color: var(--accent); }

.tmpl-block { margin: 0 0 14px; }
.tmpl-label {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.tmpl-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.tmpl-chip {
  display: inline-flex;
  align-items: center;
  background: var(--bg-2);
  border-radius: 999px;
  overflow: hidden;
}
.tmpl-chip button {
  border: 0;
  background: transparent;
  padding: 6px 10px;
  font-weight: 800;
  font-size: 0.78rem;
  color: var(--ink);
}
.tmpl-chip .tmpl-x {
  padding: 6px 8px 6px 0;
  color: var(--muted);
}

.remind-card .row:last-child { border-bottom: 0; }
.year-nav {
  display: flex;
  gap: 6px;
}
.year-nav button {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  font-size: 1.1rem;
  font-weight: 800;
}
.year-card .spend-kpis { margin-top: 8px; }
.year-bars { margin: 14px 0 8px; }
.year-heat {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 8px;
  margin-top: 12px;
}
@media (min-width: 720px) {
  .year-heat { grid-template-columns: repeat(6, 1fr); }
}
.heat-label {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 4px;
  padding: 0;
  text-transform: capitalize;
}
.heat-label.on { color: var(--accent); }
.heat-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.heat-pad { display: block; aspect-ratio: 1; }
.heat-cell {
  aspect-ratio: 1;
  border: 0;
  border-radius: 2px;
  padding: 0;
  background: var(--line);
}
.heat-cell.lv1 { background: color-mix(in srgb, var(--coral) 28%, var(--line)); }
.heat-cell.lv2 { background: color-mix(in srgb, var(--coral) 48%, var(--line)); }
.heat-cell.lv3 { background: color-mix(in srgb, var(--coral) 72%, var(--line)); }
.heat-cell.lv4 { background: var(--coral); }
.heat-cell.on-month { outline: 1px solid var(--accent); }
.limit-meter {
  margin: 0 0 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.limit-meter .hint { margin: 8px 0 0; }
.limit-meter .seg-legend { margin-bottom: 0; }
.limit-meter .progress { margin-top: 8px; }

.list { display: grid; gap: 2px; }
.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
}
.row.with-ico { grid-template-columns: 42px 1fr auto; }
.cat-detail-item {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0;
  min-width: 0;
  color: inherit;
}
.cat-detail-list { margin-top: 8px; }
.row:last-child { border-bottom: 0; padding-bottom: 2px; }
.row .name { font-weight: 800; }
.row .sub { color: var(--muted); font-size: 0.78rem; margin-top: 2px; font-weight: 600; }
.row .amt {
  font-size: 0.95rem;
  font-weight: 800;
  text-align: right;
}
.row .amt.out { color: var(--ink); }
.row .amt.in { color: var(--ok); }
.row .actions {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
}
.icon-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 36px;
  height: 36px;
  border-radius: 12px;
  transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: var(--bg-2); color: var(--ink); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

.people {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.person-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  box-shadow: none;
}
.person-card h3 {
  margin: 0 0 8px;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.total-line {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-weight: 800;
}

.seg {
  display: flex;
  background: var(--bg-2);
  padding: 4px;
  border-radius: 14px;
  gap: 4px;
}
.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  border-radius: 11px;
  padding: 8px 10px;
  font-weight: 800;
  font-size: 0.82rem;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}
.seg button.on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}
.seg.chart-seg {
  width: fit-content;
  max-width: 100%;
  align-self: start;
  margin-bottom: 2px;
}
.seg.chart-seg button {
  flex: 0 1 auto;
  min-width: 7.2rem;
  padding: 8px 16px;
}
.sav-card {
  display: grid;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
}
.sav-card:last-child { border-bottom: 0; }
.sav-card-main {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  color: inherit;
  cursor: pointer;
}
.sav-card-actions { justify-content: flex-end; }
.sav-flag {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  vertical-align: middle;
}
.sav-flag.early { background: var(--gold-soft); color: #946200; }
.sav-flag.done { background: var(--mint-soft); color: var(--mint-dark); }
.sav-flag.late { background: var(--coral-soft); color: var(--danger); }
.sav-flag.ahead { background: var(--mint-soft); color: var(--mint-dark); }
.sav-flag.behind { background: var(--coral-soft); color: var(--danger); }
[data-theme="dark"] .sav-flag.early { color: var(--gold); }
.sav-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.sav-pct {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  flex: 0 0 auto;
}
.sav-detail-pct {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1;
  margin: 4px 0 12px;
}

.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 14px;
  padding: 11px 14px;
  font-weight: 800;
  min-height: 44px;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { background: var(--bg-2); }
.btn.primary {
  background: var(--mint);
  border-color: var(--mint);
  color: var(--on-accent);
  box-shadow: 0 8px 18px rgba(18, 184, 134, 0.28);
}
.btn.primary:hover { background: var(--mint-deep); }
.btn.danger {
  background: var(--danger);
  color: #fff;
}
.btn.danger:hover { filter: brightness(0.95); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }

.field { display: grid; gap: 6px; }
.field label {
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 14px;
  padding: 12px;
  min-height: 46px;
  outline: none;
  font-weight: 700;
  font-size: 16px;
}
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--mint);
  box-shadow: 0 0 0 4px rgba(32, 201, 151, 0.18);
}
.form-grid { display: grid; gap: 12px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }

.cal-card { padding: 16px 14px 10px; }
.cal-head {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  margin-bottom: 12px;
}
.cal-head strong {
  text-align: center;
  font-size: 1.02rem;
  font-weight: 800;
  text-transform: lowercase;
}
.cal-head button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--bg-2);
  color: var(--ink);
  font-size: 1.15rem;
  display: grid;
  place-items: center;
}
.cal-week,
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.cal-week {
  margin-bottom: 8px;
}
.cal-week span {
  text-align: center;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 2px 0;
}
.cal-day {
  border: 2px solid transparent;
  background: var(--bg-2);
  border-radius: 14px;
  min-height: 52px;
  padding: 6px 2px 5px;
  display: grid;
  justify-items: center;
  gap: 2px;
  color: var(--ink);
}
.cal-day .n {
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
}
.cal-day .v {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--muted);
  line-height: 1;
}
.cal-day.spent .v { color: #e8590c; }
.cal-day.today { border-color: var(--mint); }
.cal-day.out { opacity: 0.38; }
.month-sum-block {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.cal-card > .month-sum {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.hero-card .progress.stacked { margin-top: 12px; }
.chart-box.month-bars { height: 220px; }
.month-sum { padding: 10px 2px 2px; }
.spend-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 4px 0 8px;
}
.spend-kpis article {
  background: var(--bg);
  border-radius: 14px;
  padding: 10px 12px;
  min-width: 0;
}
.spend-kpis .lbl {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--muted);
}
.spend-kpis b {
  display: block;
  margin-top: 4px;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dot.plan {
  background: repeating-linear-gradient(90deg, #20c997 0 3px, transparent 3px 5px);
  border-radius: 1px;
  height: 3px;
  width: 12px;
  flex: 0 0 12px;
}
.month-sum-label {
  margin: 4px 0 0;
  color: var(--muted);
  font-weight: 700;
}
.month-sum-total {
  margin: 0 0 12px;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}
.month-sum-total.out { color: var(--ink); }
.month-sum-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-weight: 700;
}
.month-sum-row .lbl { color: var(--muted); flex: 1; }
.month-sum-row b { font-weight: 800; }
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 8px;
}
.dot.in { background: var(--mint); }
.dot.out { background: var(--coral); }

.limits-row {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 12px 2px 8px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.limits-row::-webkit-scrollbar { display: none; }
.limit-col {
  border: 0;
  background: transparent;
  color: inherit;
  width: 48px;
  flex: 0 0 48px;
  max-width: 48px;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 0;
  min-width: 0;
}
.limit-col:hover .limit-jar,
.limit-col:focus-visible .limit-jar {
  transform: translateY(-3px);
}
.limit-jar {
  position: relative;
  width: 34px;
  padding-top: 4px;
  transition: transform 0.2s ease;
}
.limit-rim {
  position: absolute;
  z-index: 4;
  top: 0;
  left: -3px;
  right: -3px;
  height: 8px;
  border-radius: 3px;
  background: linear-gradient(180deg, #fff 0%, #e8eef6 55%, #d5deea 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -1px 0 rgba(15, 23, 42, 0.08);
  pointer-events: none;
}
.limit-pill {
  position: relative;
  width: 100%;
  height: 176px;
  margin-top: -3px;
  border-radius: 2px 2px 18px 18px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.42), transparent 28%, transparent 72%, rgba(255, 255, 255, 0.16)),
    color-mix(in srgb, var(--bg-2) 55%, #fff);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 0 0 12px;
  gap: 6px;
  box-shadow:
    inset 0 0 0 1px rgba(148, 163, 184, 0.35),
    inset -5px 0 8px rgba(255, 255, 255, 0.28),
    0 8px 16px rgba(15, 23, 42, 0.07);
}
.limit-pill::before {
  content: "";
  position: absolute;
  z-index: 2;
  left: 5px;
  top: 16px;
  width: 5px;
  height: 46%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.04));
  pointer-events: none;
}
.limit-pill::after {
  content: "";
  position: absolute;
  z-index: 2;
  right: 5px;
  top: 22px;
  bottom: 36px;
  width: 3px;
  background: repeating-linear-gradient(
    to bottom,
    rgba(15, 23, 42, 0.14) 0 1.5px,
    transparent 1.5px 13px
  );
  pointer-events: none;
}
.limit-pill .fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--level, 0%);
  background: color-mix(in srgb, var(--water) 78%, #fff);
  pointer-events: none;
  overflow: visible;
  animation: water-rise 1.05s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: var(--delay, 0s);
}
.limit-pill .fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.32), transparent 40%, transparent 68%, rgba(255, 255, 255, 0.1));
  pointer-events: none;
}
.limit-col.dry .fill { display: none; }
.limit-pill .wave {
  position: absolute;
  left: 0;
  width: 200%;
  height: 11px;
  top: -8px;
  fill: color-mix(in srgb, var(--water) 78%, #fff);
  animation: water-wave 2.8s linear infinite;
}
.limit-pill .wave.back {
  top: -6px;
  opacity: 0.38;
  animation-duration: 4.4s;
  animation-direction: reverse;
}
@keyframes water-rise {
  from { height: 0; }
  to { height: var(--level, 0%); }
}
@keyframes water-wave {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
.limit-pill .pct {
  position: relative;
  z-index: 1;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.limit-ico {
  position: relative;
  z-index: 1;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.16);
}
.limit-ico svg { display: block; width: 12px; height: 12px; }
.limit-col.over .pct { color: var(--danger); }
.limit-col.over .wave { animation-duration: 1.5s; }
.spill {
  position: absolute;
  z-index: 6;
  inset: -2px -6px 0 -2px;
  pointer-events: none;
  color: color-mix(in srgb, var(--water) 88%, #fff);
}
.spill .meniscus {
  position: absolute;
  left: 5px;
  right: 9px;
  top: 2px;
  height: 8px;
  background: currentColor;
  border-radius: 50%;
}
.spill .pour {
  position: absolute;
  top: -1px;
  right: 0;
  width: 13px;
  height: 16px;
  background: currentColor;
  border-radius: 45% 60% 55% 70%;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
  animation: spill-pour 1.6s ease-in-out infinite;
}
.spill .run {
  position: absolute;
  top: 10px;
  right: 3px;
  width: 4px;
  height: 36px;
  background: linear-gradient(180deg, currentColor 0%, currentColor 45%, transparent);
  border-radius: 99px;
  opacity: 0.8;
}
.spill .drip {
  position: absolute;
  top: 12px;
  right: 1px;
  width: 8px;
  height: 11px;
  background: currentColor;
  border-radius: 45% 45% 60% 60%;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.14);
  opacity: 0;
  animation: spill-drip 2.6s cubic-bezier(0.32, 0, 0.68, 1) infinite;
}
.spill .d2 { animation-delay: 0.65s; width: 7px; height: 10px; right: 2px; }
.spill .d3 { animation-delay: 1.3s; width: 6px; height: 9px; right: 1px; }
.spill .d4 { animation-delay: 1.95s; width: 7px; height: 10px; right: 3px; }
@keyframes spill-pour {
  0%, 100% { transform: scale(1) translateY(0); }
  50% { transform: scale(1.08, 1.12) translateY(1px); }
}
@keyframes spill-drip {
  0%, 8% {
    transform: translateY(0) scaleY(0.4) scaleX(0.75);
    opacity: 0;
  }
  16% {
    transform: translateY(6px) scaleY(1.15) scaleX(0.9);
    opacity: 1;
  }
  100% {
    transform: translateY(152px) scale(0.72);
    opacity: 0;
  }
}
.limit-col strong {
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.limit-col small {
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  margin-top: -4px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
[data-theme="dark"] .limit-pill {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08), transparent 30%),
    color-mix(in srgb, var(--bg-2) 82%, #fff 8%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
[data-theme="dark"] .limit-rim {
  background: linear-gradient(180deg, #3a4454, #2a3340);
}
@media (prefers-reduced-motion: reduce) {
  .limit-pill .fill { animation: none; }
  .limit-pill .wave,
  .spill .pour,
  .spill .drip { animation: none; }
  .spill .pour { transform: none; }
  .spill .drip { opacity: 0.85; transform: translateY(20px); }
}

.icon-picker,
.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.icon-picker {
  max-height: 220px;
  overflow-y: auto;
  padding: 2px;
}
.icon-picker button {
  width: 40px;
  height: 40px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  display: grid;
  place-items: center;
  padding: 0;
}
.icon-picker button.on {
  border-color: var(--mint);
  background: var(--accent-soft);
  color: var(--mint-dark);
}
.color-picker button {
  width: 32px;
  height: 32px;
  border: 3px solid transparent;
  border-radius: 50%;
  padding: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}
.color-picker button.on {
  border-color: var(--ink);
}

.empty {
  text-align: center;
  padding: 28px 12px;
  color: var(--muted);
  font-weight: 600;
}
.empty h3 { margin: 0 0 6px; color: var(--ink); font-size: 1rem; font-weight: 800; }

.role-pill {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 99px;
  background: var(--bg-2);
  color: var(--muted);
  vertical-align: middle;
}
.role-pill.admin {
  background: var(--accent-soft);
  color: var(--mint-dark);
}
.role-pill.pending {
  background: var(--gold-soft);
  color: #b78105;
}
.invite-card {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-2);
}
.invite-card .lead {
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.invite-card .hint { margin: 0; }
.user-row-end {
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-row-end .btn {
  padding: 6px 10px;
  min-height: 36px;
  font-size: 0.78rem;
}

.admin-only { display: none; }
body.view-config .fab,
body.view-users .fab { display: none; }
body.view-config .month-switch,
body.view-users .month-switch { visibility: hidden; }

.status-card { display: grid; gap: 8px; }
.status-card .big {
  font-size: 1.28rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + var(--safe-b));
  box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.04);
}
.tabbar button {
  border: 0;
  background: transparent;
  color: var(--muted);
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 6px 2px;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  transition: color 0.15s ease;
}
.tabbar button svg { width: 20px; height: 20px; }
.tabbar button.on { color: var(--mint-dark); }

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px);
  z-index: 35;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: var(--mint);
  color: var(--on-accent);
  box-shadow: var(--shadow-lg);
  display: grid;
  place-items: center;
  transition: transform 0.15s ease;
}
.fab:hover { transform: translateY(-2px) scale(1.03); }

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(15, 23, 42, 0.42);
  display: grid;
  align-items: end;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.sheet-backdrop.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.confirm-backdrop {
  z-index: 70;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.confirm-backdrop .sheet {
  border-radius: 22px;
  transform: none;
  max-width: 420px;
  width: 100%;
  padding: 18px 18px calc(18px + var(--safe-b));
}
.sheet {
  background: var(--surface);
  border-radius: 26px 26px 0 0;
  padding: 10px 18px calc(18px + var(--safe-b));
  width: 100%;
  max-width: 100%;
  max-height: min(92dvh, 760px);
  overflow: auto;
  transform: translateY(18px);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}
.sheet-backdrop.open .sheet { transform: translateY(0); }
.sheet-handle {
  width: 42px;
  height: 4px;
  background: var(--line);
  border-radius: 99px;
  margin: 4px auto 12px;
}
.sheet h3 {
  margin: 0 0 14px;
  font-size: 1.35rem;
  font-weight: 800;
}
.sheet > .btn-row,
.sheet .form-grid > .btn-row {
  position: sticky;
  bottom: 0;
  z-index: 1;
  background: var(--surface);
  padding-top: 12px;
  box-shadow: 0 -12px 16px var(--surface);
}
.amount-input {
  font-size: 1.7rem !important;
  font-weight: 800 !important;
  letter-spacing: -0.04em;
}
.amount-input[readonly] {
  background: var(--bg, #f4f6fb);
  pointer-events: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 80px);
  transform: translateX(-50%) translateY(8px);
  z-index: 80;
  background: var(--ink);
  color: var(--surface);
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.85rem;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  max-width: calc(100% - 32px);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.desktop-nav { display: none; }

@media (min-width: 920px) {
  .app {
    display: grid;
    grid-template-columns: 240px 1fr;
    grid-template-rows: auto 1fr;
    padding-bottom: 0;
    min-height: 100dvh;
  }
  .desktop-nav { grid-row: 1 / span 2; }
  .topbar, .view { grid-column: 2; }
  .view { width: min(980px, calc(100% - 48px)); }
  .tabbar { display: none; }
  .fab { bottom: 28px; right: 32px; }
  .desktop-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: sticky;
    top: 0;
    height: 100dvh;
    padding: 28px 18px;
    background: #0ca678;
    color: #fff;
  }
  .desktop-nav .nav-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0 0 18px;
    color: #fff;
  }
  .desktop-nav button {
    border: 0;
    background: transparent;
    text-align: left;
    padding: 11px 12px;
    border-radius: 14px;
    color: rgba(255, 255, 255, 0.78);
    font-weight: 800;
    transition: background 0.15s ease, color 0.15s ease;
  }
  .desktop-nav button.on {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
  }
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .sheet-backdrop {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
  }
  .sheet {
    width: 100%;
    max-width: var(--modal-md);
    max-height: min(var(--modal-md-h), 70dvh);
    border-radius: 20px;
    padding: 20px 22px 18px;
    transform: scale(0.98);
    box-shadow: 0 24px 56px rgba(15, 23, 42, 0.22);
  }
  .sheet-backdrop.open .sheet { transform: none; }
  .sheet-handle { display: none; }
  .sheet h3 { margin: 0 0 12px; font-size: 1.22rem; }
  .confirm-backdrop .sheet {
    width: 100%;
    max-width: 400px;
    max-height: none;
    padding: 20px 22px 18px;
  }
}

@media (max-width: 760px) {
  .view {
    width: calc(100% - 16px);
    gap: 10px;
  }
  .card { padding: 1rem 0.8rem; }
  .hero-card { padding: 0.9rem 0.75rem 1rem; }
  .topbar {
    gap: 8px;
    padding-left: 12px;
    padding-right: 12px;
  }
  .brand h1 { font-size: 1.12rem; }
  .brand p { font-size: 0.72rem; }
  .month-switch span { font-size: 0.72rem; }
  .month-switch button { width: 30px; height: 30px; }
  .top-actions span { display: none; }
  .top-actions button { min-width: 40px; padding: 8px; }

  .limits-row { gap: 8px; padding: 10px 2px 6px; }
  .limit-col {
    flex: 0 0 38px;
    min-width: 38px;
    max-width: 38px;
    width: 38px;
    gap: 5px;
  }
  .limit-jar { width: 26px; }
  .limit-pill {
    height: 148px;
    padding: 0 0 10px;
    gap: 5px;
    border-radius: 4px 4px 14px 14px;
  }
  .limit-pill .pct { font-size: 0.56rem; }
  .limit-ico { width: 18px; height: 18px; box-shadow: 0 3px 8px rgba(15, 23, 42, 0.16); }
  .limit-ico svg { width: 10px; height: 10px; }
  .limit-col strong { font-size: 0.64rem; }
  .limit-col small { font-size: 0.48rem; margin-top: -2px; }

  .cal-card { padding: 12px 8px 8px; }
  .cal-week, .cal-grid { gap: 3px; }
  .cal-day {
    min-height: 42px;
    border-radius: 10px;
    padding: 4px 1px 3px;
  }
  .cal-day .n { font-size: 0.64rem; }
  .cal-day .v { font-size: 0.56rem; }
  .cal-week span { font-size: 0.58rem; }

  .people { gap: 8px; }
  .person-card { padding: 10px; }
  .amount-input { font-size: 1.35rem !important; }
  .month-sum-total { font-size: 1.5rem; }
  .chart-box.projection { height: 210px; }
  .chart-box.month-bars { height: 180px; }
  .spend-kpis { gap: 6px; }
  .spend-kpis article { padding: 8px 8px; }
  .spend-kpis b { font-size: 0.82rem; }
  .section-head { margin-bottom: 8px; gap: 8px; }
  .kpi .value { font-size: 1.02rem; }
  .kpi-grid { gap: 8px; }
  .status-card .big { font-size: 1.12rem; }
}

@media (max-width: 380px) {
  .form-grid.two { grid-template-columns: 1fr; }
}
