/* Notre Budget / Mon Budget — v2 (refonte « finance moderne »)
   Bleu de confiance + vert des entrées, Inter à chiffres tabulaires, en-tête en dégradé,
   navigation en verre dépoli, cibles tactiles ≥ 40 px. L'ancienne version est gardée dans
   « Notre Budget - ancienne version (v1) ». */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f2f5fb;
  --bg2: #e8edf7;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #5b6780;
  --line: #e3e8f2;
  --brand: #1e40af;
  --brand2: #3b82f6;
  --brand-soft: #e6eeff;
  --hero: linear-gradient(135deg, #1e3a8a 0%, #1e40af 45%, #2563eb 100%);
  --night: #0f172a;
  --side: #0b1224;
  --side-ink: #aab6d3;
  --accent: #f59e0b;
  --accent-ink: #8a5300;
  --in: #059669;
  --in-soft: #dcf7ec;
  --out: #dc2626;
  --out-soft: #fde8e8;
  --blue: #2563eb;
  --blue-soft: #e6eeff;
  --radius: 20px;
  --r-sm: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px -8px rgba(15, 23, 42, .10);
  --shadow-lg: 0 24px 60px -12px rgba(15, 23, 42, .35);
  --glass: rgba(255, 255, 255, .78);
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
/* Sombre : automatique (selon le téléphone) sauf si « clair » est forcé, ou forcé avec le bouton 🌓. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120;
    --bg2: #111a2e;
    --card: #151f35;
    --ink: #eef2fb;
    --muted: #97a3bf;
    --line: #243150;
    --brand-soft: #1a2b57;
    --hero: linear-gradient(135deg, #172554 0%, #1e3a8a 50%, #1d4ed8 100%);
    --night: #1c2742;
    --side: #070c18;
    --accent-ink: #fbbf24;
    --in: #34d399;
    --in-soft: #0d2e24;
    --out: #f87171;
    --out-soft: #3a1418;
    --blue: #60a5fa;
    --blue-soft: #16264d;
    --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px -12px rgba(0, 0, 0, .6);
    --glass: rgba(21, 31, 53, .78);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1120;
  --bg2: #111a2e;
  --card: #151f35;
  --ink: #eef2fb;
  --muted: #97a3bf;
  --line: #243150;
  --brand-soft: #1a2b57;
  --hero: linear-gradient(135deg, #172554 0%, #1e3a8a 50%, #1d4ed8 100%);
  --night: #1c2742;
  --side: #070c18;
  --accent-ink: #fbbf24;
  --in: #34d399;
  --in-soft: #0d2e24;
  --out: #f87171;
  --out-soft: #3a1418;
  --blue: #60a5fa;
  --blue-soft: #16264d;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px -12px rgba(0, 0, 0, .6);
  --glass: rgba(21, 31, 53, .78);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-feature-settings: "cv11", "ss01";
  background: var(--bg);
  color: var(--ink);
  display: flex;
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--brand2); outline-offset: 2px; }
/* Montants : chiffres de même largeur pour qu'ils s'alignent. */
.val, .acc-bal, .amt, .a, b, strong, td.n, .dt-row b, .chip b, .budget-h b { font-variant-numeric: tabular-nums; }

/* ---------- Barre latérale (ordinateur) ---------- */
.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--side); color: var(--side-ink);
  display: flex; flex-direction: column;
  padding: 24px 14px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 19px; letter-spacing: -.02em; color: #fff; padding: 0 8px 28px; }
.brand-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; background: var(--hero); box-shadow: 0 6px 16px -4px rgba(37, 99, 235, .6); }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav button {
  position: relative; display: flex; align-items: center; gap: 12px;
  background: none; border: 0; border-radius: 12px; min-height: 44px;
  padding: 10px 12px; color: var(--side-ink); text-align: left;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.nav button span { font-size: 18px; width: 24px; text-align: center; }
.nav button b { font-weight: 600; }
.nav button:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav button.active { background: rgba(59, 130, 246, .18); color: #fff; }
.nav button.active::before { content: ''; position: absolute; left: -14px; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--brand2); }
.side-foot { margin-top: auto; font-size: 12px; padding: 10px; line-height: 1.4; opacity: .8; }
.side-foot b { color: #fff; }

/* ---------- En-tête : solde total en dégradé ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 16px 28px;
  background: var(--hero); color: #fff;
  box-shadow: 0 10px 30px -18px rgba(30, 64, 175, .9);
}
.total small { display: block; color: rgba(255, 255, 255, .72); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.total strong { font-size: 28px; font-weight: 800; letter-spacing: -.03em; white-space: nowrap; }
#totalNow.neg { color: #fecaca !important; }
.chips { display: flex; gap: 8px; overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: none; padding: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .18); border-radius: 999px;
  padding: 4px 12px 4px 4px; font-size: 13px; white-space: nowrap; color: #fff;
  backdrop-filter: blur(6px);
}
.chip b { font-weight: 700; }
.chip.neg b { color: #fecaca; }
.btn-add {
  flex-shrink: 0; border: 0; border-radius: 14px; min-height: 44px; padding: 10px 18px;
  background: #fff; color: var(--brand); font-weight: 800; font-size: 15px;
  box-shadow: 0 8px 20px -8px rgba(0, 0, 0, .45);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.btn-add:hover { transform: translateY(-1px); box-shadow: 0 12px 24px -8px rgba(0, 0, 0, .5); }
.btn-add:active { transform: scale(.97); }

.monthbar { display: flex; align-items: center; gap: 10px; padding: 22px 28px 6px; }
.monthbar h1 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -.02em; min-width: 210px; text-align: center; text-transform: capitalize; }
.mnav { width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); font-size: 22px; line-height: 1; box-shadow: var(--shadow); transition: transform .15s var(--ease); }
.mnav:active { transform: scale(.94); }
.today-btn { border: 1px solid var(--line); background: var(--card); border-radius: 999px; min-height: 40px; padding: 8px 16px; font-weight: 700; font-size: 13px; color: var(--brand); }
:root[data-theme="dark"] .today-btn { color: var(--blue); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .today-btn { color: var(--blue); } }
.monthbar.hidden { display: none; }

#page { padding: 16px 28px 60px; animation: fade .35s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Logos ---------- */
.logo {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  background: #fff center / contain no-repeat; border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 17px; overflow: hidden;
}
.logo.lg { width: 48px; height: 48px; border-radius: 14px; font-size: 26px; }
.logo.sm { width: 22px; height: 22px; border-radius: 6px; font-size: 13px; }
.chip .logo { border-radius: 50%; border-color: transparent; }
.logo.crop { background-size: auto 230%; background-position: 46% 50%; }

/* ---------- Cartes et grilles ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; border: 1px solid var(--line); }
.card h2 { margin: 0 0 14px; font-size: 16px; font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; row-gap: 6px; }
.card h2 .sub { margin-left: auto; font-weight: 500; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.card h2 .sub a { color: var(--blue); font-weight: 600; text-decoration: none; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); margin-bottom: 16px; }

.kpi { position: relative; overflow: hidden; }
.kpi .lbl { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; text-transform: uppercase; letter-spacing: .04em; padding-right: 16px; }
.kpi .val { font-size: 27px; font-weight: 800; letter-spacing: -.03em; margin-top: 8px; white-space: nowrap; }
.kpi .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi.in { box-shadow: inset 0 3px 0 var(--in), var(--shadow); }
.kpi.out { box-shadow: inset 0 3px 0 var(--out), var(--shadow); }
.kpi.in .val { color: var(--in); }
.kpi.out .val { color: var(--out); }
.kpi.end { background: var(--night); color: #fff; border-color: transparent; }
.kpi.end .lbl, .kpi.end .hint { color: rgba(255, 255, 255, .7); }
.kpi.fc { background: var(--hero); color: #fff; border-color: transparent; box-shadow: 0 14px 30px -14px rgba(37, 99, 235, .8); }
.kpi.fc .lbl, .kpi.fc .hint { color: rgba(255, 255, 255, .8); }
.kpi.fc::before { content: ''; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, .22), transparent 70%); pointer-events: none; }

.chart-wrap { position: relative; height: 230px; }
.chart-wrap.tall { height: 290px; }
.donut-row { display: grid; grid-template-columns: 200px 1fr; gap: 18px; align-items: center; }
.donut-row .chart-wrap { height: 200px; }
.legend { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; }
.legend-item { display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: center; font-size: 14px; padding: 4px 6px; border-radius: 10px; }
.legend-item .bar { grid-column: 2 / 4; height: 6px; border-radius: 3px; background: var(--bg2); overflow: hidden; margin-top: -4px; }
.legend-item .bar i { display: block; height: 100%; border-radius: 3px; }
.legend-item .amt { font-weight: 700; white-space: nowrap; }
.legend-item .pct { color: var(--muted); font-weight: 500; font-size: 12px; margin-left: 4px; }
.pay-h { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin: 4px 0 8px; }
.pay-h.out { color: var(--out); }
.pay-h.in { color: var(--in); margin-top: 16px; }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; font-size: 14px; }
.empty .e { font-size: 36px; display: block; margin-bottom: 8px; }

/* ---------- Opérations ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filters input, .filters select, .field input, .field select, .field textarea {
  border: 1px solid var(--line); background: var(--card); border-radius: var(--r-sm);
  min-height: 44px; padding: 10px 12px; min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}
.filters input:focus, .filters select:focus, .field input:focus, .field select:focus { outline: none; border-color: var(--brand2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand2) 22%, transparent); }
.filters input { flex: 1; min-width: 180px; }
.day { margin-bottom: 16px; }
.day-h { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-weight: 700; padding: 0 6px 8px; text-transform: uppercase; letter-spacing: .04em; }
.op {
  display: grid; grid-template-columns: 42px 1fr auto; gap: 12px; align-items: center;
  padding: 10px 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line);
  margin-bottom: 8px; cursor: pointer; transition: border-color .15s, transform .15s var(--ease), box-shadow .15s;
}
.op:hover { border-color: color-mix(in srgb, var(--brand2) 45%, var(--line)); box-shadow: var(--shadow); }
.op:active { transform: scale(.99); }
.op .ico { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; font-size: 20px; }
.op .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.op .s { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-top: 2px; overflow: hidden; white-space: nowrap; }
.op .a { font-weight: 800; white-space: nowrap; text-align: right; letter-spacing: -.01em; }
.op .a small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); }
.a.in { color: var(--in); }
.a.out { color: var(--out); }
.a.tr { color: var(--blue); }
.tag { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--blue-soft); color: var(--blue); }

/* ---------- Comptes ---------- */
.accounts { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.accounts > .card { transition: transform .2s var(--ease), box-shadow .2s; }
.accounts > .card:hover { transform: translateY(-2px); }
.acc-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.acc-head b { font-size: 17px; display: block; }
.acc-head small { color: var(--muted); }
.acc-bal { font-size: 28px; font-weight: 800; letter-spacing: -.03em; }
.acc-bal.neg { color: var(--out); }
.acc-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 6px; }
.acc-row b { color: var(--ink); }
.acc-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

/* ---------- Boutons et formulaires ---------- */
.btn {
  border: 1px solid var(--line); background: var(--card); border-radius: var(--r-sm);
  min-height: 40px; padding: 8px 14px; font-weight: 600; font-size: 14px;
  transition: border-color .15s, background .15s, transform .12s var(--ease);
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: 0 6px 16px -8px rgba(30, 64, 175, .8); }
.btn.primary:hover { background: #1d3a9e; }
.btn.danger { color: var(--out); }
.btn.ok { background: var(--in); color: #fff; border-color: var(--in); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 13px; }

dialog {
  border: 0; border-radius: 24px; padding: 0; width: min(560px, calc(100vw - 24px));
  background: var(--card); color: var(--ink); box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(8, 12, 28, .55); backdrop-filter: blur(4px); }
dialog[open] { animation: pop .28s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }
.dlg { padding: 24px; max-height: calc(100vh - 40px); overflow-y: auto; }
.dlg h3 { margin: 0 0 16px; font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--bg2); padding: 4px; border-radius: 14px; margin-bottom: 16px; }
.seg.two-seg { grid-template-columns: repeat(2, 1fr); }
.seg button { border: 0; background: none; border-radius: 11px; min-height: 40px; padding: 8px; font-weight: 700; color: var(--muted); transition: background .2s var(--ease), color .2s; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.seg button.on[data-v="depense"] { background: var(--out); color: #fff; }
.seg button.on[data-v="revenu"] { background: var(--in); color: #fff; }
.seg button.on[data-v="virement"] { background: var(--blue); color: #fff; }
.amount-in { display: flex; align-items: center; border-bottom: 2px solid var(--line); margin-bottom: 18px; transition: border-color .15s; }
.amount-in:focus-within { border-color: var(--brand2); }
.amount-in input { border: 0; background: none; font-size: 38px; font-weight: 800; letter-spacing: -.03em; width: 100%; padding: 4px 0; outline: none; font-variant-numeric: tabular-nums; }
.amount-in span { font-size: 26px; font-weight: 700; color: var(--muted); }
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field input, .field select { width: 100%; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.picks { display: flex; flex-wrap: wrap; gap: 6px; }
.pick {
  display: flex; align-items: center; gap: 7px; border: 1.5px solid var(--line); background: var(--card);
  border-radius: 999px; min-height: 38px; padding: 4px 12px 4px 4px; font-size: 13px; font-weight: 600;
  transition: border-color .15s, background .15s, transform .12s var(--ease);
}
.pick:active { transform: scale(.96); }
.pick.cat { padding: 6px 12px; }
.pick.on { border-color: var(--brand); background: var(--brand); color: #fff; }
.dlg-actions { display: flex; gap: 8px; margin-top: 22px; }
.dlg-actions .sp { flex: 1; }
.dlg-actions .btn { min-height: 46px; padding: 10px 18px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; min-height: 36px; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }

/* ---------- Prévisions et dépenses prévues ---------- */
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.t td { padding: 11px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td.n, table.t th.n { text-align: right; }
table.t tr.cur td { background: var(--brand-soft); font-weight: 700; }
table.t tr.cur td:first-child { border-radius: 10px 0 0 10px; }
table.t tr.cur td:last-child { border-radius: 0 10px 10px 0; }
.table-scroll { overflow-x: auto; }
.rec { display: grid; grid-template-columns: 42px 1fr auto auto; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.rec:last-child { border-bottom: 0; }
.rec .ico { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; font-size: 20px; }
.rec .t { font-weight: 600; }
.rec .s { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.rec .a { font-weight: 800; white-space: nowrap; }
.rec.done { opacity: .55; }
.budget { margin-bottom: 16px; }
.budget-h { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; gap: 8px; }
.budget-h b { white-space: nowrap; }
.pbar { height: 8px; border-radius: 6px; background: var(--bg2); overflow: hidden; }
.pbar i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--in), color-mix(in srgb, var(--in) 70%, #a7f3d0)); transition: width .6s var(--ease); }
.pbar i.warn { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.pbar i.over { background: linear-gradient(90deg, var(--out), #f87171); }

.set-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.set-row:last-child { border-bottom: 0; }
.set-row .grow { flex: 1; min-width: 180px; }
.set-row small { color: var(--muted); display: block; }
.cat-list { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-pill { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 4px 4px 4px 12px; font-size: 14px; }
.cat-pill button { border: 0; background: var(--bg2); border-radius: 50%; width: 30px; height: 30px; font-size: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 30px); opacity: 0;
  background: var(--night); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600;
  box-shadow: var(--shadow-lg);
  transition: opacity .25s var(--ease), transform .25s var(--ease); pointer-events: none; z-index: 100; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.foot { text-align: right; color: var(--muted); font-size: 12px; padding: 10px 28px 20px; }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  body { flex-direction: column; font-size: 14px; }
  /* Barre de navigation flottante en verre dépoli */
  .sidebar {
    position: fixed; top: auto; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
    height: auto; width: auto; flex-direction: row; padding: 6px; z-index: 50;
    background: var(--glass); color: var(--muted);
    backdrop-filter: blur(18px) saturate(1.6); -webkit-backdrop-filter: blur(18px) saturate(1.6);
    border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 16px 40px -12px rgba(15, 23, 42, .35);
  }
  .brand, .side-foot { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; gap: 2px; }
  .nav button { flex-direction: column; gap: 2px; padding: 6px 2px; min-height: 52px; font-size: 10.5px; flex: 1; align-items: center; justify-content: center; text-align: center; color: var(--muted); border-radius: 16px; }
  .nav button:hover { background: none; color: var(--ink); }
  .nav button b { font-weight: 600; line-height: 1.15; }
  .nav button.active { background: var(--brand); color: #fff; }
  .nav button.active::before { display: none; }
  .topbar { flex-wrap: wrap; padding: 14px 16px 12px; gap: 10px; border-radius: 0 0 24px 24px; }
  .total strong { font-size: 26px; }
  .chips { order: 3; flex-basis: 100%; }
  .btn-add { margin-left: auto; padding: 9px 16px; }
  .btn-add span { display: none; }
  .monthbar { padding: 16px 16px 4px; }
  .monthbar h1 { font-size: 20px; min-width: 0; flex: 1; }
  #page { padding: 12px 16px 110px; }
  .two { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi .val { font-size: 21px; }
  .kpi.fc { grid-column: 1 / -1; }
  .kpi.fc .val { font-size: 26px; }
  .card { padding: 16px; border-radius: 18px; }
  .donut-row { grid-template-columns: 1fr; }
  .donut-row .chart-wrap { height: 180px; }
  .row2 { grid-template-columns: 1fr; }
  .foot { padding-bottom: 100px; }
  /* Fenêtres en feuille qui monte du bas */
  dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 26px 26px 0 0; }
  dialog[open] { animation: sheet .32s var(--ease); }
  .dlg { padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); max-height: 88vh; }
  .dlg::before { content: ''; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: -8px auto 14px; }
  .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
}
@keyframes sheet { from { transform: translateY(40%); opacity: .4; } to { transform: none; opacity: 1; } }

/* ---------- Connexion / foyer ---------- */
#gate {
  position: fixed; inset: 0; z-index: 200; overflow-y: auto;
  background: radial-gradient(circle at 15% 0%, #2563eb 0, transparent 45%), radial-gradient(circle at 100% 100%, #0ea5e9 0, transparent 40%), #0b1224;
  display: grid; place-items: center; padding: 24px 16px;
}
#gate[hidden] { display: none; }
.gate-card {
  width: min(460px, 100%); background: var(--card); color: var(--ink);
  border-radius: 26px; padding: 28px 22px; box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
  animation: pop .3s var(--ease);
}
.gate-brand { font-size: 24px; font-weight: 800; letter-spacing: -.02em; text-align: center; margin-bottom: 18px; }
.gate-card h3 { margin: 0 0 6px; font-size: 20px; }
.gate-sub { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.gate-card .seg button.on { background: var(--brand); color: #fff; }
.gate-btn { width: 100%; min-height: 48px; padding: 12px; font-size: 15px; }
.gate-btn:disabled { opacity: .6; cursor: wait; }
.gate-box { border: 1px solid var(--line); border-radius: 18px; padding: 16px; margin-bottom: 12px; }
.gate-box > b { display: block; margin-bottom: 12px; font-size: 16px; }
.gate-msg { min-height: 1em; margin: 12px 0 0; color: var(--out); font-size: 14px; font-weight: 600; }
.gate-msg:empty { margin: 0; }
.gate-msg.ok { color: var(--in); }
.link { background: none; border: 0; color: var(--blue); font-weight: 600; padding: 10px 0 0; display: block; margin: 0 auto; min-height: 40px; }
code.invite { font: 800 18px/1 ui-monospace, Consolas, monospace; letter-spacing: .12em; background: var(--bg2); border: 1px dashed var(--muted); border-radius: 10px; padding: 9px 12px; }

/* ---------- Soldes négatifs, dépenses prévues, montants à venir ---------- */
.neg, .kpi .val.neg, table.t td.neg { color: var(--out) !important; }
.kpi.end .val.neg { color: #fca5a5 !important; }
.kpi.fc .val.neg { color: #fecaca !important; }
.kpi.fc .val.pos { color: #a7f3d0; }
.kpi .hint small { font-size: 11px; opacity: .85; }
.kpi .hint b.neg { color: var(--out) !important; }
.kpi.fc .hint b, .kpi.end .hint b { color: #fff; }
.note { color: var(--muted); font-size: 13px; margin-top: 10px; line-height: 1.5; }
.budget-s { font-size: 12px; color: var(--muted); margin-top: 5px; text-align: right; }
.vc-total { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; background: var(--bg2); border-radius: 14px; padding: 12px 14px; margin-bottom: 16px; font-size: 13px; color: var(--muted); }
.vc-total b { color: var(--ink); }
small.tocome { font-size: 12px; font-weight: 600; color: var(--muted); margin-right: 8px; white-space: nowrap; }
@media (max-width: 860px) {
  .rec { grid-template-columns: 42px 1fr auto; row-gap: 6px; }
  .rec > span:last-child { grid-column: 2 / -1; justify-content: flex-end; }
}
.tag-btn { border: 0; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 10px; font-size: 12px; }
.tag-btn span { opacity: .55; font-size: 13px; }
.tag-btn:hover { background: var(--out-soft); color: var(--out); }
.tag-btn:hover span { opacity: 1; }

/* ---------- Petits plus ---------- */
.theme-btn { flex-shrink: 0; width: 44px; height: 44px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .12); font-size: 18px; color: #fff; }
.due { flex-shrink: 0; border: 0; border-radius: 999px; min-height: 34px; padding: 7px 12px; background: #fff; color: var(--out); font-weight: 700; font-size: 13px; white-space: nowrap; animation: pulse 2s ease-in-out 3; }
.due[hidden] { display: none; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.nav-badge { position: absolute; top: 4px; right: 8px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--out); color: #fff; font: 700 11px/18px "Inter", system-ui, sans-serif; font-style: normal; text-align: center; box-shadow: 0 0 0 2px var(--side); }
.nav-badge[hidden] { display: none; }

/* Conseils du mois */
.mood { position: relative; display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow); overflow: hidden; }
.mood::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--blue); }
.mood-emoji { font-size: 38px; line-height: 1; animation: wobble 2.5s ease-in-out 1; }
.mood small { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.mood p { margin: 4px 0 0; font-size: 14.5px; font-weight: 500; line-height: 1.5; }
.mood-top { background: linear-gradient(120deg, var(--in-soft), var(--card) 65%); } .mood-top small { color: var(--in); } .mood-top::before { background: var(--in); }
.mood-calme { background: linear-gradient(120deg, var(--blue-soft), var(--card) 65%); } .mood-calme small { color: var(--blue); }
.mood-attention { background: linear-gradient(120deg, color-mix(in srgb, var(--accent) 22%, var(--card)), var(--card) 65%); } .mood-attention small { color: var(--accent-ink); } .mood-attention::before { background: var(--accent); }
.mood-alerte { background: linear-gradient(120deg, var(--out-soft), var(--card) 65%); } .mood-alerte small { color: var(--out); } .mood-alerte::before { background: var(--out); }
@keyframes wobble { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-12deg) scale(1.1); } 40% { transform: rotate(10deg); } 60% { transform: rotate(-5deg); } }
.mood-body { flex: 1; min-width: 0; }
.tip-next { flex: none; align-self: center; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: inherit; font-size: 22px; line-height: 1; cursor: pointer; box-shadow: var(--shadow); transition: transform .15s var(--ease); }
.tip-next:hover { transform: translateX(2px); }
.tip-next:active { transform: scale(.94); }
.tip-in { animation: tipIn .3s var(--ease); }
@keyframes tipIn { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }

/* Saisie express */
.quick { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 16px; padding: 2px; scrollbar-width: none; align-items: center; }
.quick::-webkit-scrollbar { display: none; }
.quick-t { font-size: 18px; flex-shrink: 0; }
.quick-chip { flex-shrink: 0; border: 1px solid var(--line); background: var(--card); border-radius: 999px; min-height: 40px; padding: 8px 14px; font-weight: 600; font-size: 14px; white-space: nowrap; box-shadow: var(--shadow); transition: transform .12s var(--ease), border-color .12s; }
.quick-chip:hover { border-color: var(--brand2); }
.quick-chip:active { transform: scale(.95); }
.quick-chip b { margin-left: 4px; color: var(--out); }
.quick-chip.add { border-style: dashed; color: var(--muted); box-shadow: none; background: transparent; }

.cmp { display: inline-block; font-size: 11px; font-weight: 700; margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: var(--bg2); color: var(--muted); white-space: nowrap; }
.cmp.good { color: var(--in); background: var(--in-soft); }
.cmp.bad { color: var(--out); background: var(--out-soft); }
.kpi .hint .cmp { margin-left: 0; }

.bilan { margin-bottom: 16px; border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.bilan-k { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 14px; margin-bottom: 10px; }
.bilan-k b { margin-left: 4px; }
.bilan-l { font-size: 14px; margin-top: 8px; display: grid; gap: 4px; }
.bilan-l small { color: var(--muted); font-weight: 700; text-transform: uppercase; font-size: 11px; letter-spacing: .05em; }
.bilan-l b { float: right; }

.goal { padding: 12px 0; border-bottom: 1px solid var(--line); }
.goal:last-child { border-bottom: 0; }
.goal-h { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.goal-e { font-size: 26px; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; background: var(--bg2); }
.goal-n { flex: 1; min-width: 0; }
.goal-n b { display: block; }
.goal-n small { color: var(--muted); font-size: 12px; }
.goal-a { display: flex; gap: 6px; }
.goal.done .goal-n b::after { content: ' ✅'; }

.couple-d { font-size: 12px; color: var(--muted); margin: -4px 0 4px 34px; }
.couple-m { margin: 12px 0 0; font-size: 14px; }

.toast.with-action { pointer-events: auto; display: flex; align-items: center; gap: 12px; }
.toast-undo { border: 0; background: #fff; color: var(--brand); font-weight: 800; border-radius: 10px; min-height: 34px; padding: 6px 12px; }
canvas.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 300; }

@media (max-width: 860px) {
  .theme-btn { width: 42px; height: 42px; }
  .due { order: 4; padding: 6px 10px; font-size: 12px; }
  .mood { padding: 14px 14px 14px 16px; gap: 12px; }
  .mood-emoji { font-size: 32px; }
  .mood p { font-size: 13.5px; }
  .nav-badge { top: 2px; right: 14%; box-shadow: 0 0 0 2px var(--card); }
}

/* Rappels */
.rappels { margin-bottom: 16px; border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.rappel { display: grid; grid-template-columns: 22px 1fr auto auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rappel:last-child { border-bottom: 0; padding-bottom: 0; }
.rappel-t b { display: block; }
.rappel-t small { color: var(--muted); font-size: 12px; }
.rappel.late .rappel-t small { color: var(--out); font-weight: 700; }
.rappel.now .rappel-t small { color: var(--accent-ink); font-weight: 700; }
.due.soon { background: #fff7e0; color: #8a5300; }
.rec.late { background: var(--out-soft); border-radius: 14px; padding: 10px; margin: 4px -10px; border-bottom-color: transparent; box-shadow: inset 4px 0 0 var(--out); }
.rec.late .t { color: var(--out); }
.late-tag { color: var(--out); font-weight: 800; font-size: 12px; white-space: nowrap; margin-left: 4px; }

/* Dépenses prévues */
.vc-add { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; padding-top: 12px; border-top: 1px dashed var(--line); }
.vc-add select { flex: 1 1 160px; min-width: 0; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 10px; }
.vc-add input { width: 110px; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 10px; }
.vc-del { border: 0; background: var(--bg2); color: var(--muted); border-radius: 50%; width: 36px; height: 36px; font-size: 13px; flex-shrink: 0; transition: background .15s, color .15s; }
.vc-del:hover { background: var(--out-soft); color: var(--out); }
.auto-tag { font-size: 11px; color: var(--blue); font-weight: 700; margin-left: 4px; }
#cEmoji { font-size: 24px; padding: 4px 12px; }
.vc-item { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; font-size: 13px; margin: 8px 0; padding: 8px 10px; border-radius: 14px; background: color-mix(in srgb, var(--bg2) 60%, transparent); }
.vc-item input { width: 84px; min-height: 36px; border: 1px solid var(--line); border-radius: 10px; padding: 4px 8px; background: var(--card); font-variant-numeric: tabular-nums; }
.vc-tag { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--blue-soft); color: var(--blue); white-space: nowrap; }
.vc-tag.once { background: color-mix(in srgb, var(--accent) 22%, var(--card)); color: var(--accent-ink); }
.vc-note { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.vc-item .vc-note { flex: 1 1 0; min-width: 90px; }
.vc-note-in { flex: 1 1 100%; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 10px; }
.vc-freq { flex: 1 1 100%; margin: 0; }
.vc-freq button.on { background: var(--brand); color: #fff; }
.vc-go { flex: 1 1 100%; padding: 10px; }
.vc-act { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.vc-item.done .vc-note { text-decoration: line-through; opacity: .6; }
.vc-toggle { display: block; margin: 10px auto 0; background: none; border: 0; color: var(--blue); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; padding: 10px; min-height: 40px; }
.freq-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.freq-choice button { display: grid; gap: 4px; justify-items: center; text-align: center; padding: 18px 10px; border-radius: 18px; border: 1.5px solid var(--line); background: var(--card); transition: border-color .15s, transform .12s var(--ease); }
.freq-choice button:hover { border-color: var(--brand2); }
.freq-choice button:active { transform: scale(.97); }
.freq-choice span { font-size: 30px; }
.freq-choice b { font-size: 16px; }
.freq-choice small { color: var(--muted); font-size: 12px; }

/* Formulaire incomplet */
.form-err { margin: 8px 0 12px; padding: 11px 14px; border-radius: 12px; background: var(--out-soft); color: var(--out); font-weight: 700; font-size: 14px; }
.form-err.shake { animation: shake .35s ease; }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }
.field-err > label { color: var(--out); font-weight: 800; }
.field-err input, .field-err select, .field-err .picks, .amount-in.field-err { outline: 2px solid var(--out); outline-offset: 3px; border-radius: 10px; }

/* Détails au clic */
[data-detail] { cursor: pointer; }
.kpi[data-detail] { transition: transform .2s var(--ease), box-shadow .2s var(--ease); }
.kpi[data-detail]:hover { transform: translateY(-2px); }
.kpi[data-detail]:active { transform: scale(.98); }
.kpi[data-detail]::after { content: '›'; position: absolute; top: 12px; right: 14px; font-size: 20px; font-weight: 700; line-height: 1; opacity: .45; }
.legend-item[data-detail]:hover { background: var(--bg2); }
.dt-month { margin: -8px 0 12px; color: var(--muted); font-size: 13px; text-transform: capitalize; }
.dt-h { margin: 18px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.dt-note { margin: 4px 0 8px; color: var(--muted); font-size: 13px; }
.dt-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.dt-row > span { min-width: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dt-row small { color: var(--muted); font-weight: 500; }
.dt-row b { white-space: nowrap; text-align: right; }
.dt-total { border-bottom: 0; margin-top: 8px; padding: 12px 14px; border-radius: 14px; background: var(--bg2); font-size: 15px; }
.dt-total b { font-size: 18px; letter-spacing: -.02em; }
.dt-ops .op { cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Épargne ---------- */
.epargne { margin-bottom: 16px; background: linear-gradient(135deg, var(--in-soft), var(--card) 70%); border-color: color-mix(in srgb, var(--in) 35%, var(--line)); }
.ep-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ep-head > div { flex: 1; min-width: 0; }
.ep-lbl { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--in); }
.ep-val { font-size: 28px; font-weight: 800; letter-spacing: -.03em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.ep-sub { font-size: 13px; color: var(--muted); }
.ep-sub b { color: var(--in); }
.ep-add { background: var(--in); color: #fff; border-color: var(--in); min-height: 44px; }
.ep-add:hover { border-color: var(--in); filter: brightness(1.05); }
.ep-rows { margin-top: 12px; display: grid; gap: 2px; }
.ep-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.ep-row b { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- Nom de l'appli dans l'en-tête (Mon Budget en violet, Notre Budget en bleu) ---------- */
.app-name { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 6px; padding: 3px 10px; border-radius: 999px; background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .22); color: #fff; font-size: 13px; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; }
.app-name span { font-weight: 500; opacity: .75; }
@media (min-width: 861px) { .app-name { display: none; } } /* sur ordinateur, le nom est déjà dans la barre latérale */
:root[data-app="perso"] { --hero: linear-gradient(135deg, #3b0764 0%, #5b21b6 50%, #7c3aed 100%); }
:root[data-app="perso"] .brand-ico { background: linear-gradient(135deg, #5b21b6, #a855f7); }
