/* =========================================================
   MoneyPilot — design mobile-first
   ========================================================= */

:root {
  --bg: #f2f4ef;
  --bg-deep: #e9ede4;
  --surface: #ffffff;
  --surface-soft: #f7f8f4;
  --surface-sunk: #eef1ea;
  --ink: #12211b;
  --ink-soft: #43554c;
  --muted: #79877f;
  --line: #e4e8e0;
  --line-strong: #d5dbd1;
  --accent: #0e9f6e;
  --accent-dark: #0b3b2e;
  --accent-deep: #082b21;
  --accent-soft: #e2f5ec;
  --blue: #3b6fd4;
  --blue-soft: #e8eefb;
  --purple: #a25bd6;
  --purple-soft: #f2e9fb;
  --danger: #c9483c;
  --danger-soft: #fbeae7;
  --warn: #b97b08;
  --warn-soft: #fcf3de;
  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(18, 33, 27, 0.04), 0 14px 34px -26px rgba(18, 33, 27, 0.35);
  --shadow-lift: 0 18px 44px -20px rgba(11, 59, 46, 0.45);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --max: 480px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background:
    radial-gradient(1100px 620px at 50% -12%, #e6efe7 0%, transparent 60%),
    linear-gradient(180deg, #eff3ec 0%, var(--bg) 38%, #eef1ea 100%);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

body.sheet-open { overflow: hidden; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
svg { display: block; }
[hidden], .hidden { display: none !important; }

.phone {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
}

/* ---------------- Topbar ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: calc(12px + env(safe-area-inset-top)) 18px 10px;
  background: rgba(240, 243, 237, 0.82);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 38px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(145deg, #11614a, #0b3b2e);
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 5px 14px -6px rgba(11, 59, 46, 0.7);
  flex: none;
}

.brand-mark svg { width: 18px; height: 18px; }

.brand-name {
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -0.025em;
}

.brand-sub {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: -2px;
}

.topbar-title {
  flex: 1;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--accent-dark);
  font-weight: 750;
  font-size: 14px;
  box-shadow: var(--shadow);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  transition: transform 0.15s ease, background 0.15s ease;
}

.icon-btn:active { transform: scale(0.94); background: var(--surface); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.accent { background: var(--accent-dark); color: #fff; border-color: var(--accent-dark); }

/* ---------------- Layout ---------------- */

.view {
  padding: 6px 18px 128px;
  outline: none;
}

.view > * + * { margin-top: 16px; }

.page-head { padding: 4px 2px 0; }
.page-head h1 {
  font-size: 27px;
  line-height: 1.15;
  letter-spacing: -0.035em;
  font-weight: 760;
}
.page-head p { color: var(--muted); font-size: 13.5px; margin-top: 4px; }

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.section-head h2 {
  font-size: 16.5px;
  font-weight: 720;
  letter-spacing: -0.02em;
}
.section-head .link {
  font-size: 12.5px;
  font-weight: 650;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-height: 32px;
  padding: 0 2px;
}
.section-head .link svg { width: 14px; height: 14px; }
.section-head .count { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---------------- Cards ---------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.card.flush { padding: 6px 0; }

/* ---------------- Hero ---------------- */

.hero {
  position: relative;
  overflow: hidden;
  border-radius: 26px;
  padding: 20px 20px 17px;
  color: #f1fff9;
  background:
    radial-gradient(120% 130% at 100% -20%, rgba(76, 220, 160, 0.42) 0%, rgba(76, 220, 160, 0) 52%),
    linear-gradient(135deg, #0b3b2e 0%, #10553f 60%, #0e6a4c 100%);
  box-shadow: 0 22px 48px -28px rgba(11, 59, 46, 0.75);
}

.hero::after {
  content: "";
  position: absolute;
  right: -46px;
  bottom: -70px;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  pointer-events: none;
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.hero-label {
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-weight: 650;
  color: rgba(235, 255, 247, 0.7);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.14);
  color: #f2fff9;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: #5ee0a8; box-shadow: 0 0 0 3px rgba(94, 224, 168, 0.18); }
.badge.warn .dot { background: #ffcb5c; box-shadow: 0 0 0 3px rgba(255, 203, 92, 0.18); }
.badge.risk .dot { background: #ff8b7e; box-shadow: 0 0 0 3px rgba(255, 139, 126, 0.2); }
.badge.neutral .dot { background: #c7d6ce; box-shadow: none; }

.hero-value {
  font-size: clamp(34px, 10.5vw, 42px);
  font-weight: 760;
  letter-spacing: -0.045em;
  line-height: 1.05;
  margin-top: 14px;
  font-variant-numeric: tabular-nums;
}

.hero-meta {
  font-size: 12.5px;
  color: rgba(223, 247, 237, 0.72);
  margin-top: 7px;
}

.hero-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid rgba(255, 255, 255, 0.13);
}

.hero-link {
  color: #b8f5d9;
  font-size: 12.5px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 30px;
  padding: 0 2px;
}
.hero-link svg { width: 14px; height: 14px; }
.hero-foot .sub { font-size: 11.5px; color: rgba(223, 247, 237, 0.62); }

/* ---------------- Month strip ---------------- */

.month-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 6px;
  box-shadow: var(--shadow);
}
.month-strip > div {
  padding: 0 10px;
  min-width: 0;
}
.month-strip > div + div { border-left: 1px solid var(--line); }
.month-strip span {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.month-strip strong {
  display: block;
  font-size: 16px;
  font-weight: 720;
  letter-spacing: -0.025em;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.month-strip small {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.amount-in { color: var(--accent-dark); }
.amount-out { color: var(--ink); }
.pos { color: var(--accent); }
.neg { color: var(--danger); }
.muted { color: var(--muted); }

/* ---------------- Quick add ---------------- */

.quick-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 18px 6px;
  margin: 0 -18px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.quick-row::-webkit-scrollbar { display: none; }

.quick {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 13px 8px 8px;
  box-shadow: var(--shadow);
  transition: transform 0.14s ease;
}
.quick:active { transform: scale(0.96); }
.quick .q-ic {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-sunk);
  color: var(--ink-soft);
  flex: none;
}
.quick .q-ic svg { width: 15px; height: 15px; }
.quick .q-txt { text-align: left; line-height: 1.15; }
.quick .q-txt b { display: block; font-size: 12.5px; font-weight: 650; }
.quick .q-txt span { display: block; font-size: 10.5px; color: var(--muted); margin-top: 1px; }

/* ---------------- Rows / lists ---------------- */

.list { display: flex; flex-direction: column; }
.row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 0;
  min-height: 56px;
  border-top: 1px solid var(--line);
  text-align: left;
  width: 100%;
}
.list > .row:first-child { border-top: 0; }
.card-pad { padding: 8px 18px; }

.row-ic {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: var(--surface-sunk);
  color: var(--ink-soft);
  flex: none;
}
.row-ic svg { width: 19px; height: 19px; }
.row-ic.f01 { background: var(--blue-soft); color: var(--blue); }
.row-ic.f02 { background: var(--purple-soft); color: var(--purple); }
.row-ic.f03 { background: var(--accent-soft); color: var(--accent); }

.row-main { flex: 1; min-width: 0; }
.row-title {
  font-size: 14px;
  font-weight: 620;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-side { text-align: right; flex: none; display: flex; align-items: center; gap: 8px; }
.row-amount {
  font-size: 14.5px;
  font-weight: 680;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.row-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 650;
  border-radius: 999px;
  padding: 2px 7px;
  background: var(--warn-soft);
  color: var(--warn);
  margin-top: 2px;
}
.row-tag.done { background: var(--accent-soft); color: var(--accent); }

.date-chip {
  width: 43px;
  flex: none;
  text-align: center;
  border-radius: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  padding: 5px 2px;
}
.date-chip b { display: block; font-size: 15px; font-weight: 720; line-height: 1.1; }
.date-chip span { display: block; font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.date-chip.late { background: var(--warn-soft); border-color: #f3e4bd; }
.date-chip.late span, .date-chip.late b { color: var(--warn); }

.pay-btn {
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 11.5px;
  font-weight: 700;
  padding: 8px 11px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  border: 1px solid #cdeee0;
}
.pay-btn:active { transform: scale(0.96); }
.pay-btn svg { width: 13px; height: 13px; }

.ghost-btn {
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 650;
  color: var(--ink-soft);
  background: var(--surface);
}
.ghost-btn:active { transform: scale(0.97); }
.ghost-btn svg { width: 15px; height: 15px; }

/* ---------------- Section / grids ---------------- */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.mini-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px;
  box-shadow: var(--shadow);
}
.mini-card span { font-size: 11px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 5px; }
.mini-card span svg { width: 13px; height: 13px; }
.mini-card strong { display: block; margin-top: 5px; font-size: 16px; font-weight: 720; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.mini-card small { display: block; color: var(--muted); font-size: 10.5px; margin-top: 2px; }

/* ---------------- Donut ---------------- */

.family-wrap {
  display: flex;
  align-items: center;
  gap: 18px;
}
.donut {
  --p1: 33;
  --p2: 66;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: conic-gradient(
    var(--blue) 0 calc(var(--p1) * 1%),
    var(--purple) calc(var(--p1) * 1%) calc(var(--p2) * 1%),
    var(--accent) calc(var(--p2) * 1%) 100%
  );
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
}
.donut::after {
  content: "";
  position: absolute;
  inset: 15px;
  border-radius: 50%;
  background: var(--surface);
}
.donut-center {
  position: relative;
  z-index: 1;
  text-align: center;
  line-height: 1.15;
}
.donut-center b { display: block; font-size: 15px; font-weight: 740; letter-spacing: -0.03em; }
.donut-center span { display: block; font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.donut.empty { background: var(--surface-sunk); }

.legend { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 9px; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.legend .swatch { width: 8px; height: 8px; border-radius: 3px; flex: none; }
.legend .l-name { flex: 1; min-width: 0; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend b { font-weight: 680; font-variant-numeric: tabular-nums; }

/* ---------------- Goals ---------------- */

.goal-row { padding: 12px 0; border-top: 1px solid var(--line); }
.goal-row:first-child { border-top: 0; padding-top: 2px; }
.goal-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.goal-top b { font-size: 13.5px; font-weight: 650; }
.goal-top span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar {
  height: 7px;
  border-radius: 99px;
  background: var(--surface-sunk);
  margin-top: 8px;
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0e9f6e, #3fc98f);
  transition: width 0.4s ease;
}
.bar.violet > i { background: linear-gradient(90deg, #8b46c4, #b77ce6); }

/* ---------------- Chart ---------------- */

.chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.chart-head h2 { font-size: 16.5px; font-weight: 720; letter-spacing: -0.02em; }
.chart-head p { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.seg {
  display: inline-flex;
  background: var(--surface-sunk);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.seg button {
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 11px;
  font-weight: 650;
  color: var(--muted);
}
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(18, 33, 27, 0.12); }

.chart { width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font); }

.chart-legend {
  display: flex;
  gap: 14px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
}
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend i { width: 8px; height: 8px; border-radius: 3px; display: inline-block; }

.plan-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.plan-summary .lbl { font-size: 11.5px; color: var(--muted); }
.plan-summary .val { font-size: 18px; font-weight: 740; letter-spacing: -0.03em; }

.month-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
  width: 100%;
  text-align: left;
}
.month-row:first-child { border-top: 0; }
.month-row .m-name { flex: 1; font-size: 13.5px; font-weight: 600; text-transform: capitalize; }
.month-row .m-net { font-size: 12.5px; font-variant-numeric: tabular-nums; font-weight: 600; width: 88px; text-align: right; }
.month-row .m-bal { font-size: 12.5px; font-variant-numeric: tabular-nums; font-weight: 680; width: 86px; text-align: right; }
.month-row .m-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.m-dot.ok { background: var(--accent); }
.m-dot.warn { background: #e3a71c; }
.m-dot.risk { background: var(--danger); }
.m-dot.neutral { background: var(--line-strong); }

/* ---------------- Buttons ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 50px;
  border-radius: 15px;
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  transition: transform 0.14s ease, filter 0.14s ease;
}
.btn:active { transform: scale(0.985); }
.btn.primary { background: linear-gradient(145deg, #118356, #0b6044); color: #fff; box-shadow: 0 14px 26px -16px rgba(14, 116, 82, 0.75); }
.btn.primary:hover { filter: brightness(1.04); }
.btn.secondary { background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink); }
.btn.ghost { color: var(--ink-soft); min-height: 44px; background: transparent; }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.sm { min-height: 42px; font-size: 13.5px; border-radius: 13px; width: auto; padding: 0 16px; }
.btn svg { width: 18px; height: 18px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

.text-action {
  color: var(--accent);
  font-weight: 650;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.text-action svg { width: 15px; height: 15px; }
.text-action.danger { color: var(--danger); }

/* ---------------- Filter chips ---------------- */

.chips { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; padding: 1px 0; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 13px;
}
.chip.active { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }

/* ---------------- Month navigation ---------------- */

.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 7px;
  box-shadow: var(--shadow);
}
.month-nav button {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  background: var(--surface-soft);
}
.month-nav button:active { background: var(--surface-sunk); }
.month-nav button svg { width: 17px; height: 17px; }
.month-nav .m-label { text-align: center; line-height: 1.15; }
.month-nav .m-label strong { display: block; font-size: 15px; font-weight: 720; text-transform: capitalize; letter-spacing: -0.02em; }
.month-nav .m-label span { display: block; font-size: 10.5px; color: var(--muted); margin-top: 1px; }

/* ---------------- Empty states ---------------- */

.empty {
  text-align: center;
  padding: 26px 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
}
.empty .e-ic {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  margin: 0 auto 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-soft);
}
.empty .e-ic svg { width: 20px; height: 20px; }
.empty b { display: block; color: var(--ink); font-size: 14px; margin-bottom: 3px; }
.empty p { font-size: 12.5px; max-width: 250px; margin: 0 auto; }
.empty .btn { margin-top: 14px; width: auto; padding: 0 18px; min-height: 44px; display: inline-flex; }

/* ---------------- Banner ---------------- */

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  border-radius: 14px;
  background: #fff8e8;
  border: 1px solid #f5e5bb;
  font-size: 12px;
  color: #7d5b09;
}
.banner svg { width: 16px; height: 16px; flex: none; }
.banner b { font-weight: 700; }
.banner button { margin-left: auto; color: #7d5b09; font-weight: 700; text-decoration: underline; font-size: 11.5px; white-space: nowrap; }

/* ---------------- Tabbar ---------------- */

.tabbar {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, var(--max));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border-top: 1px solid rgba(213, 219, 209, 0.8);
}
.tabbar[hidden] { display: none; }
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 5px 2px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.01em;
}
.tab svg { width: 21px; height: 21px; }
.tab.active { color: var(--accent-dark); }
.tab.active svg { color: var(--accent); }

/* ---------------- FAB ---------------- */

.fab {
  position: fixed;
  z-index: 45;
  right: max(18px, calc((100vw - var(--max)) / 2 + 18px));
  bottom: calc(78px + env(safe-area-inset-bottom));
  width: 58px;
  height: 58px;
  border-radius: 19px;
  background: linear-gradient(150deg, #12a06e, #0a6b4b);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 16px 30px -12px rgba(10, 107, 75, 0.7), 0 2px 6px rgba(10, 107, 75, 0.2);
  transition: transform 0.16s ease, opacity 0.2s ease;
}
.fab:active { transform: scale(0.92); }
.fab[hidden] { display: none; }
.fab-plus { position: relative; width: 22px; height: 22px; }
.fab-plus::before, .fab-plus::after {
  content: "";
  position: absolute;
  background: #fff;
  border-radius: 3px;
}
.fab-plus::before { left: 9.5px; top: 0; width: 3px; height: 22px; }
.fab-plus::after { top: 9.5px; left: 0; height: 3px; width: 22px; }

/* ---------------- Sheet ---------------- */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(8, 24, 18, 0.45);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
body.sheet-open .scrim { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 104%);
  width: min(100%, var(--max));
  max-height: 94dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border-radius: 26px 26px 0 0;
  padding: 8px 18px calc(22px + env(safe-area-inset-bottom));
  box-shadow: 0 -24px 60px -20px rgba(8, 24, 18, 0.4);
  transition: transform 0.32s cubic-bezier(0.22, 0.9, 0.25, 1), visibility 0s linear 0.34s;
  visibility: hidden;
  pointer-events: none;
}
body.sheet-open .sheet {
  transform: translate(-50%, 0);
  visibility: visible;
  pointer-events: auto;
  transition: transform 0.32s cubic-bezier(0.22, 0.9, 0.25, 1), visibility 0s linear 0s;
}

.sheet-grab {
  width: 40px;
  height: 4px;
  border-radius: 99px;
  background: var(--line-strong);
  margin: 2px auto 12px;
}
.sheet-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.sheet-head h2 { font-size: 20px; font-weight: 740; letter-spacing: -0.03em; flex: 1; }
.sheet-head .sub { font-size: 12px; color: var(--muted); margin-top: 2px; font-weight: 400; letter-spacing: 0; }
.sheet-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface-soft);
  display: grid;
  place-items: center;
  color: var(--ink-soft);
}
.sheet-close svg { width: 17px; height: 17px; }

.sheet-note {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 12px;
  padding: 11px 13px;
  background: var(--surface-soft);
  border-radius: 12px;
}

/* ---------------- Forms ---------------- */

.form { display: flex; flex-direction: column; gap: 15px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field-label {
  font-size: 11.5px;
  font-weight: 680;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
}
.field input[type="text"],
.field input[type="number"],
.field input[type="date"],
.field input[type="month"],
.field select,
.field textarea {
  width: 100%;
  min-height: 48px;
  border-radius: 13px;
  border: 1px solid var(--line-strong);
  background: var(--surface-soft);
  padding: 11px 13px;
  font-size: 15px;
  font-weight: 550;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2379877f' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(14, 159, 110, 0.13);
}
.field input::placeholder { color: #a3aea7; font-weight: 450; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.amount-field {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-soft);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 6px 16px;
}
.amount-field:focus-within {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(14, 159, 110, 0.13);
}
.amount-field .currency { font-size: 22px; font-weight: 600; color: var(--muted); }
.amount-field input {
  flex: 1;
  border: 0;
  background: transparent;
  outline: none;
  min-width: 0;
  padding: 8px 0;
  font-size: 38px;
  font-weight: 740;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.amount-field input::placeholder { color: #c3ccc6; }

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--surface-sunk);
  border-radius: 14px;
  padding: 4px;
}
.segmented label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
  cursor: pointer;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 5px rgba(18, 33, 27, 0.14);
}
.segmented label svg { width: 15px; height: 15px; }

.cat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}
.cat-option {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 66px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  padding: 8px 4px;
  text-align: center;
  cursor: pointer;
  color: var(--ink-soft);
  transition: border-color 0.12s ease, background 0.12s ease;
}
.cat-option input { position: absolute; opacity: 0; pointer-events: none; }
.cat-option svg { width: 19px; height: 19px; }
.cat-option span { font-size: 10.5px; font-weight: 600; line-height: 1.15; }
.cat-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.family-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 8px 0 6px;
}
.family-head:first-child { margin-top: 0; }
.family-head i { width: 6px; height: 6px; border-radius: 2px; display: inline-block; }

.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 11px 13px;
  cursor: pointer;
}
.switch .sw-txt b { display: block; font-size: 13px; font-weight: 650; }
.switch .sw-txt span { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.track {
  width: 44px;
  height: 27px;
  border-radius: 99px;
  background: var(--line-strong);
  position: relative;
  flex: none;
  transition: background 0.2s ease;
}
.track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(18, 33, 27, 0.25);
  transition: transform 0.2s ease;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(17px); }

.form-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 3px; }

/* ---------------- Onboarding ---------------- */

body.onboarding { background: #f6f7f2; }
body.onboarding .topbar,
body.onboarding .tabbar,
body.onboarding .fab { display: none; }

.onboard {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(22px + env(safe-area-inset-top)) 22px calc(22px + env(safe-area-inset-bottom));
  max-width: var(--max);
  margin: 0 auto;
  position: relative;
}

.ob-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ob-step { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: 0.05em; }
.ob-dots { display: flex; gap: 5px; }
.ob-dots i { width: 22px; height: 4px; border-radius: 99px; background: var(--line-strong); transition: background 0.2s ease; }
.ob-dots i.on { background: var(--accent); }

.ob-body { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 26px 0; }
.ob-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}
.ob-kicker svg { width: 14px; height: 14px; }
.ob-body h1 {
  font-size: clamp(27px, 7.8vw, 33px);
  line-height: 1.1;
  letter-spacing: -0.04em;
  font-weight: 760;
}
.ob-body h1 em { font-style: normal; color: var(--accent); }
.ob-lead { font-size: 14px; color: var(--ink-soft); margin-top: 10px; line-height: 1.55; max-width: 340px; }
.ob-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.ob-foot { display: flex; flex-direction: column; gap: 7px; }

.ob-features { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.ob-feature { display: flex; align-items: center; gap: 11px; font-size: 13.5px; color: var(--ink-soft); }
.ob-feature .f-ic {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--accent);
  flex: none;
}
.ob-feature .f-ic svg { width: 17px; height: 17px; }

.preset-list { display: flex; flex-direction: column; gap: 7px; }
.preset {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 9px 11px;
  background: var(--surface);
}
.preset label { display: flex; align-items: center; gap: 9px; flex: 1; font-size: 13px; font-weight: 600; cursor: pointer; min-width: 0; }
.preset input[type="checkbox"] {
  width: 19px;
  height: 19px;
  accent-color: var(--accent);
  flex: none;
}
.preset input[type="text"] {
  width: 88px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  padding: 6px 9px;
  text-align: right;
  font-weight: 650;
  font-size: 13px;
  outline: none;
}
.preset .unit { font-size: 11px; color: var(--muted); }

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  transform: translate(-50%, 14px);
  background: #12211b;
  color: #f2f7f4;
  border-radius: 13px;
  padding: 11px 15px;
  font-size: 12.5px;
  font-weight: 550;
  box-shadow: 0 16px 34px -12px rgba(8, 24, 18, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  max-width: calc(100vw - 36px);
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { color: #7ff0bd; font-weight: 700; font-size: 12px; text-decoration: underline; white-space: nowrap; }

/* ---------------- Misc ---------------- */

.divider { height: 1px; background: var(--line); margin: 4px 0; }
.row-link { display: flex; align-items: center; gap: 11px; padding: 12px 0; border-top: 1px solid var(--line); width: 100%; text-align: left; }
.row-link:first-child { border-top: 0; }
.row-link .chev { color: #b3bdb6; }
.row-link .chev svg { width: 16px; height: 16px; }
.set-label { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 700; color: var(--muted); padding: 18px 4px 8px; }
.set-value { font-size: 12px; color: var(--muted); margin-top: 1px; }
.accent-ic { background: var(--accent-soft); color: var(--accent-dark); }
.warn-ic { background: var(--warn-soft); color: var(--warn); }
.danger-ic { background: var(--danger-soft); color: var(--danger); }
.blue-ic { background: var(--blue-soft); color: var(--blue); }
.violet-ic { background: var(--purple-soft); color: var(--purple); }

.inline-note {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.5;
  padding: 0 2px;
}
.inline-note b { color: var(--ink-soft); }

.sim-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 4px; }
.sim-box {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 10px;
  text-align: center;
}
.sim-box span { display: block; font-size: 9.5px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; }
.sim-box b { display: block; margin-top: 4px; font-size: 13px; font-weight: 740; letter-spacing: -0.02em; }
.sim-box small { display: block; font-size: 9.5px; color: var(--muted); margin-top: 1px; }

.sim-verdict {
  border-radius: 13px;
  padding: 12px 14px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12.5px;
  line-height: 1.45;
}
.sim-verdict.risk { background: var(--danger-soft); color: #8c2c21; }
.sim-verdict.warn { background: var(--warn-soft); color: #7d5b09; }
.sim-verdict b { font-weight: 740; }

/* ---------------- Compléments d'écrans ---------------- */

.view.onboarding-view { padding: 0; }

.ops-days { display: flex; flex-direction: column; gap: 14px; }
.day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 0 4px 7px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: capitalize;
}
.day-head span:last-child { font-variant-numeric: tabular-nums; font-weight: 650; }

.summary-card {
  background: linear-gradient(135deg, #ffffff 0%, #f6f9f4 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 17px;
  box-shadow: var(--shadow);
}
.summary-card > span {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 650;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.summary-card > span svg { width: 14px; height: 14px; }
.summary-card strong {
  display: block;
  margin-top: 6px;
  font-size: 25px;
  font-weight: 760;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}
.summary-card small { display: block; margin-top: 3px; font-size: 11.5px; color: var(--muted); }

.mission-card { padding: 15px 16px; }
.mission-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.mission-name { font-size: 14.5px; font-weight: 680; letter-spacing: -0.015em; }
.mission-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.mission-mid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.mission-mid > div { min-width: 0; }
.mission-mid span { display: block; font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 650; }
.mission-mid b { display: block; font-size: 12.5px; font-weight: 680; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mission-bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: 11px; }
.mission-bottom span { display: block; font-size: 10px; color: var(--muted); font-weight: 600; }
.mission-bottom b { display: block; font-size: 17px; font-weight: 740; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.mission-bottom small { display: block; font-size: 10.5px; color: var(--muted); margin-top: 1px; }
.mission-actions { display: flex; align-items: center; gap: 7px; }
.mission-actions .ghost-btn { padding: 8px 9px; }
.mission-actions .ghost-btn svg { width: 14px; height: 14px; }

.tiny-done {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent);
  padding: 6px 9px;
  background: var(--accent-soft);
  border-radius: 999px;
}
.tiny-done svg { width: 13px; height: 13px; }

.goal-card { padding: 15px 16px; }
.goal-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.goal-foot > span { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.goal-actions { display: flex; align-items: center; gap: 7px; }
.goal-actions .ghost-btn { padding: 7px 10px; display: inline-flex; align-items: center; gap: 4px; }
.goal-actions .ghost-btn svg { width: 13px; height: 13px; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  padding: 4px 8px;
  white-space: nowrap;
  background: var(--surface-sunk);
  color: var(--ink-soft);
}
.tag.ok { background: var(--accent-soft); color: var(--accent-dark); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.risk { background: var(--danger-soft); color: var(--danger); }
.tag.neutral { background: var(--blue-soft); color: var(--blue); }

.event-hero { display: flex; align-items: center; gap: 12px; }
.event-hero > div:nth-child(2) { flex: 1; min-width: 0; }
.event-name { font-size: 15px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.event-amount { font-size: 18px; font-weight: 760; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; white-space: nowrap; }

.hint { font-size: 10.5px; color: var(--muted); line-height: 1.4; }

.ob-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.ob-line:first-child { border-top: 0; padding-top: 0; }
.ob-line:last-child { padding-bottom: 0; }
.ob-line span { color: var(--muted); }
.ob-line b { font-weight: 680; text-align: right; }

.row-link .row-main > span { display: block; }
.row-link .row-main .row-title { font-size: 14px; font-weight: 620; }
.row-link .row-main .row-sub { font-size: 11.5px; font-weight: 400; }

.chip { display: inline-flex; align-items: center; gap: 4px; }
.chip svg { width: 13px; height: 13px; }

.sim-cta {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #f4f1fc 0%, #ffffff 70%);
  border-color: #e8e0f5;
}
.sim-cta-ic {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: var(--purple-soft);
  color: var(--purple);
  flex: none;
}
.sim-cta-ic svg { width: 20px; height: 20px; }
.sim-cta-txt { flex: 1; min-width: 0; }
.sim-cta-txt b { display: block; font-size: 14px; font-weight: 700; }
.sim-cta-txt span { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.sim-cta .btn.sm { width: auto; flex: none; }

.sim-results { margin-top: 4px; }

/* ---------------- Responsive ---------------- */

@media (min-width: 560px) {
  .view { padding-left: 0; padding-right: 0; }
  .quick-row { padding-left: 0; padding-right: 0; margin: 0; }
  body { padding: 26px 0 46px; }
  .phone {
    border-radius: 34px;
    overflow: clip;
    background: rgba(255, 255, 255, 0.34);
    border: 1px solid rgba(213, 219, 209, 0.7);
    box-shadow: 0 40px 80px -50px rgba(11, 59, 46, 0.55);
    min-height: calc(100dvh - 72px);
  }
  .topbar { border-radius: 34px 34px 0 0; }
  .tabbar { width: var(--max); bottom: 26px; border-radius: 0 0 34px 34px; }
  .fab { bottom: 104px; }
  .sheet { bottom: 26px; border-radius: 26px; }
  .toast { bottom: 118px; }
  .onboard { min-height: calc(100dvh - 72px); }
  body.onboarding .phone { min-height: 100dvh; }
}

@media (max-width: 359px) {
  .view { padding-left: 14px; padding-right: 14px; }
  .topbar { padding-left: 14px; padding-right: 14px; }
  .quick-row { padding-left: 14px; padding-right: 14px; margin-left: -14px; margin-right: -14px; }
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
  .month-strip strong { font-size: 14px; }
  .hero-value { font-size: 32px; }
  .family-wrap { gap: 12px; }
  .donut { width: 96px; height: 96px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
  html { scroll-behavior: auto; }
}
