/* Polices auto-hébergées (assets/fonts) — fichiers variables couvrant toute la plage de graisses utilisée. */
@font-face {
  font-family: 'Unbounded';
  font-style: normal;
  font-weight: 500 900;
  font-display: swap;
  src: url('../fonts/unbounded-variable.woff2') format('woff2');
}
@font-face {
  font-family: 'Hanken Grotesk';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/hanken-grotesk-variable.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/jetbrains-mono-variable.woff2') format('woff2');
}

:root {
  --bg: #131210;
  --bg-glow: #1a1814;
  --surface: #1b1916;
  --surface-2: #232019;
  --surface-hover: #29251e;
  --border: rgba(243, 239, 230, 0.09);
  --border-strong: rgba(243, 239, 230, 0.18);

  --text: #f4efe4;
  --text-soft: #a9a299;
  --text-faint: #726c62;

  /* fill = always bright, for solid-color surfaces (buttons, badges, swatches) */
  --lime-fill: #c8f04c;
  --coral-fill: #ff7657;
  --gold-fill: #eab84e;
  --ice-fill: #74d6ce;
  --violet-fill: #b593f2;
  --rose-fill: #f28fc0;
  --sky-fill: #6fa8f5;
  --jade-fill: #4ec98a;
  --cocoa-fill: #c99368;
  --slate-fill: #93a5c4;

  /* default tokens = theme-aware, for text/icons/borders drawn on the page background */
  --lime: var(--lime-fill);
  --lime-dim: rgba(200, 240, 76, 0.14);
  --coral: var(--coral-fill);
  --coral-dim: rgba(255, 118, 87, 0.14);
  --gold: var(--gold-fill);
  --gold-dim: rgba(234, 184, 78, 0.14);
  --ice: var(--ice-fill);
  --ice-dim: rgba(116, 214, 206, 0.14);
  --violet: var(--violet-fill);
  --violet-dim: rgba(181, 147, 242, 0.14);
  --rose: var(--rose-fill);
  --rose-dim: rgba(242, 143, 192, 0.14);
  --sky: var(--sky-fill);
  --sky-dim: rgba(111, 168, 245, 0.14);
  --jade: var(--jade-fill);
  --jade-dim: rgba(78, 201, 138, 0.14);
  --cocoa: var(--cocoa-fill);
  --cocoa-dim: rgba(201, 147, 104, 0.14);
  --slate: var(--slate-fill);
  --slate-dim: rgba(147, 165, 196, 0.14);

  --danger: #ff5d4a;

  /* brand accent — overridable per-user (defaults to lime) */
  --accent: var(--lime);
  --accent-fill: var(--lime-fill);
  --accent-dim: var(--lime-dim);
  --accent-ink: #17150f;

  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 9px;

  --shadow-card: 0 1px 0 rgba(243, 239, 230, 0.04) inset, 0 16px 32px -18px rgba(0, 0, 0, 0.6);
  --shadow-pop: 0 20px 60px -20px rgba(0, 0, 0, 0.7);

  /* semantic z-index scale */
  --z-nav: 20;
  --z-fab: 25;
  --z-modal-backdrop: 50;
  --z-modal: 51;
  --z-toast: 60;

  --font-display: 'Unbounded', sans-serif;
  --font-body: 'Hanken Grotesk', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

[data-theme="light"] {
  --bg: #f5f1e6;
  --bg-glow: #ede6d4;
  --surface: #fffdf8;
  --surface-2: #f0ebdc;
  --surface-hover: #e8e1cd;
  --border: rgba(28, 26, 18, 0.1);
  --border-strong: rgba(28, 26, 18, 0.22);

  --text: #201d16;
  --text-soft: #5f5a4c;
  --text-faint: #948c7a;

  /* mêmes teintes, assombries pour rester lisibles en texte sur fond clair */
  --lime: #5f7d16;
  --coral: #c0431f;
  --gold: #916b0d;
  --ice: #157b70;
  --violet: #6b3fc0;
  --rose: #b8447f;
  --sky: #2f5fa8;
  --jade: #1f8058;
  --cocoa: #7a5530;
  --slate: #45566f;

  --danger: #c0341f;

  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 16px 32px -18px rgba(28, 26, 18, 0.16);
  --shadow-pop: 0 20px 60px -20px rgba(28, 26, 18, 0.28);
}

/* ---- thème "Auto" : aucun data-theme n'est posé sur <html> dans ce cas,
   on suit alors la préférence système. Le sombre reste la valeur par
   défaut de :root, donc seul le cas clair a besoin d'être dupliqué ici. ---- */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #f5f1e6;
    --bg-glow: #ede6d4;
    --surface: #fffdf8;
    --surface-2: #f0ebdc;
    --surface-hover: #e8e1cd;
    --border: rgba(28, 26, 18, 0.1);
    --border-strong: rgba(28, 26, 18, 0.22);

    --text: #201d16;
    --text-soft: #5f5a4c;
    --text-faint: #948c7a;

    --lime: #5f7d16;
    --coral: #c0431f;
    --gold: #916b0d;
    --ice: #157b70;
    --violet: #6b3fc0;
    --rose: #b8447f;
    --sky: #2f5fa8;
    --jade: #1f8058;
    --cocoa: #7a5530;
    --slate: #45566f;

    --danger: #c0341f;

    --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 16px 32px -18px rgba(28, 26, 18, 0.16);
    --shadow-pop: 0 20px 60px -20px rgba(28, 26, 18, 0.28);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.045'/%3E%3C/svg%3E");
}

h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }

button, input, select { font-family: inherit; }
a { color: inherit; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.icon { width: 1em; height: 1em; display: inline-block; vertical-align: -0.15em; flex-shrink: 0; }
.icon.spinner { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .icon.spinner { animation-duration: 1.6s; } }

::selection { background: var(--accent-dim); color: var(--accent); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; }

/* ============================================================
   BRAND MARK
   ============================================================ */
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  flex-shrink: 0;
}
.brand-mark svg { display: block; }
.wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

/* ============================================================
   AUTH SCREEN
   ============================================================ */
.auth-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 18px 48px;
}

.auth-wrap::before,
.auth-wrap::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.16;
  z-index: -1;
}
.auth-wrap::before {
  width: 380px; height: 380px;
  background: var(--lime);
  top: -140px; left: -120px;
}
.auth-wrap::after {
  width: 420px; height: 420px;
  background: var(--gold);
  bottom: -160px; right: -140px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  border: 1px solid var(--border);
  padding: 40px 28px 32px;
  animation: rise 0.6s cubic-bezier(.19,1,.22,1) both;
}

.auth-mark { margin: 0 auto 22px; width: 56px; height: 56px; }

.auth-title {
  text-align: center;
  font-size: 27px;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.auth-sub {
  text-align: center;
  color: var(--text-soft);
  font-size: 14.5px;
  margin-bottom: 26px;
  line-height: 1.5;
}

.auth-tabs {
  display: flex;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 24px;
  position: relative;
  border: 1px solid var(--border);
}
.auth-tabs button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px 0;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: color 0.25s ease;
}
.auth-tabs button.active { color: var(--lime-ink); }
.auth-tabs .tab-glider {
  position: absolute;
  top: 4px; left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  background: var(--lime);
  border-radius: 999px;
  transition: transform 0.35s cubic-bezier(.65,0,.35,1);
}
.auth-tabs button.active + .tab-glider { transform: translateX(100%); }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 7px;
}
.field input {
  width: 100%;
  border: none;
  border-bottom: 1.5px solid var(--border-strong);
  background: transparent;
  padding: 9px 2px;
  font-size: 16px;
  color: var(--text);
  transition: border-color 0.2s ease;
}
.field input:focus { outline: none; border-bottom-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 14.5px;
  border-radius: 999px;
  padding: 13px 22px;
  white-space: nowrap;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, opacity .2s ease;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:active { transform: none; }
.btn-primary {
  width: 100%;
  background: var(--accent-fill);
  color: var(--accent-ink);
  box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.5);
  margin-top: 6px;
}
.btn-primary:hover { opacity: 0.9; }
.btn-ghost { background: transparent; color: var(--text); border: 1.5px solid var(--border-strong); }
.btn-ghost:hover { border-color: var(--text-soft); }
.btn-danger-ghost { background: transparent; color: var(--coral); border: 1.5px solid var(--coral-dim); }
.btn-danger { background: var(--coral-fill); color: #2a0f0a; }
.btn-danger:hover { opacity: 0.9; }

/* ---- profile / preferences ---- */
hr.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.hint-text { color: var(--text-soft); font-size: 13.5px; line-height: 1.5; margin: 0 0 14px; }
.invite-link-row { display: flex; gap: 8px; margin-top: 14px; align-items: center; }
.invite-link-row input {
  flex: 1; min-width: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  font-family: var(--font-mono);
  background: var(--surface-2);
  color: var(--text);
}
.invite-link-row input:focus { outline: none; border-color: var(--accent); }
.invite-link-row .btn-add { width: 40px; height: 40px; flex-shrink: 0; }
.profile-msg { font-size: 12.5px; margin-top: 10px; min-height: 15px; }
.profile-msg.success { color: var(--accent); }
.profile-msg.error { color: var(--coral); }

.pref-block { margin-bottom: 24px; }
.pref-block:last-child { margin-bottom: 0; }

.currency-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.currency-pill {
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 9px 18px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.currency-pill.active { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }

.theme-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.theme-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.theme-pill .icon { width: 15px; height: 15px; }
.theme-pill.active { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }

.accent-picker { display: flex; gap: 14px; flex-wrap: wrap; }
.accent-swatch {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  cursor: pointer;
  background: var(--sw);
  position: relative;
  transition: transform 0.15s ease;
}
.accent-swatch:hover { transform: scale(1.08); }
.accent-swatch.active::after {
  content: '';
  position: absolute;
  inset: -6px;
  border: 1.5px solid var(--sw);
  border-radius: 50%;
}

.join-preview {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.join-preview-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-faint); font-weight: 600; margin-bottom: 8px;
}
.join-preview-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.join-preview-list li { font-size: 13.5px; color: var(--text); }
.join-preview-list li::before { content: '— '; color: var(--accent); }

.auth-error {
  background: var(--coral-dim);
  color: var(--coral);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 16px;
  display: none;
}
.auth-error.show { display: block; animation: shake 0.4s ease; }

/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell { position: relative; z-index: 1; min-height: 100vh; padding-bottom: 92px; }

.verify-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--gold-dim);
  color: var(--gold);
  font-size: 13px;
  font-weight: 600;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
.verify-banner button {
  border: 1.5px solid var(--gold);
  background: transparent;
  color: var(--gold);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.verify-banner button:hover { background: var(--gold-dim); }
.verify-banner[hidden] { display: none; }
.install-banner { background: var(--accent-dim); color: var(--accent); }
.install-banner .icon { width: 14px; height: 14px; vertical-align: -2px; margin: 0 1px; }
.install-banner button { border-color: var(--accent); color: var(--accent); }
.install-banner button:hover { background: var(--accent-dim); }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 20px 10px;
}
.app-greeting .eyebrow {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  font-weight: 600;
  font-family: var(--font-mono);
}
.app-greeting h1 { font-size: 22px; }
.app-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--accent-fill);
  color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  cursor: pointer;
  border: none;
}

.app-main {
  padding: 6px 20px 20px;
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
}

.view { display: none; }
.view.active { display: grid; gap: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 22px;
  opacity: 1;
  min-width: 0;
  transform: translateY(0);
  transition: opacity 0.5s cubic-bezier(.19,1,.22,1), transform 0.5s cubic-bezier(.19,1,.22,1);
}
/* first-paint reveal only — never replayed when switching tabs afterward */
body.pre-reveal .view.active .card { opacity: 0; transform: translateY(16px); }
.card:nth-of-type(1) { transition-delay: 0.02s; }
.card:nth-of-type(2) { transition-delay: 0.08s; }
.card:nth-of-type(3) { transition-delay: 0.14s; }
.card:nth-of-type(4) { transition-delay: 0.2s; }

/* ---- squelette de chargement : le hero + les 4 stats restent visibles
   immédiatement (pas d'écran vide le temps du premier appel réseau), avec
   un scintillement à la place des chiffres tant qu'ils ne sont pas connus ---- */
body.pre-reveal #heroCard,
body.pre-reveal #summaryCard {
  opacity: 1;
  transform: none;
}
body.pre-reveal #heroAmount,
body.pre-reveal .stat-box .value {
  color: transparent;
  border-radius: 6px;
  background: linear-gradient(100deg, var(--surface-2) 25%, var(--surface-hover) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.3s ease-in-out infinite;
}
@keyframes skeletonShimmer { 0% { background-position: 180% 0; } 100% { background-position: -20% 0; } }
@media (prefers-reduced-motion: reduce) {
  body.pre-reveal #heroAmount, body.pre-reveal .stat-box .value { animation: none; opacity: 0.6; }
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  row-gap: 4px;
  margin-bottom: 16px;
}
.card-head h2 { font-size: 16px; white-space: nowrap; }
.card-head h2 .icon { margin-right: 9px; color: var(--text-faint); width: 0.95em; height: 0.95em; }
.card-head .hint { font-size: 12px; color: var(--text-faint); font-family: var(--font-mono); white-space: nowrap; margin-left: auto; padding-left: 10px; }

/* ---- carte repliable (Historique) : évite d'imposer le scroll d'une section
   "regarder en arrière" à chaque visite alors qu'elle est consultée bien
   moins souvent que le reste de Résumé ---- */
button.card-head-toggle {
  width: 100%; background: none; border: none; font: inherit; cursor: pointer;
  padding: 0; text-align: left; color: inherit;
}
.card-head-toggle .hint { display: inline-flex; align-items: center; gap: 4px; }
.card-head-toggle .chevron { width: 13px; height: 13px; transition: transform 0.2s ease; }
.card-head-toggle[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.card-head-toggle:hover .hint { color: var(--text-soft); }

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent-fill);
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  margin-right: 8px;
  vertical-align: middle;
  position: relative;
  top: -1px;
}

/* ---- welcome empty-state ---- */
.welcome-card {
  text-align: center;
  padding: 40px 26px 34px;
}
.welcome-icon {
  width: 56px; height: 56px;
  border-radius: 16px;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
}
.welcome-icon .icon { width: 26px; height: 26px; }
.welcome-card h2 { font-size: 21px; margin-bottom: 10px; }
.welcome-card p {
  color: var(--text-soft);
  font-size: 14.5px;
  line-height: 1.6;
  max-width: 340px;
  margin: 0 auto 24px;
}
.welcome-card .btn-primary { width: auto; padding: 14px 26px; }
.welcome-card .btn-primary .icon { width: 16px; height: 16px; }

/* ---- profil : en-tête d'identité ---- */
.profile-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 22px;
}
.profile-hero-avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--accent-fill);
  color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  flex-shrink: 0;
}
.profile-hero-info { min-width: 0; }
.profile-hero-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.profile-hero-email {
  font-size: 12.5px;
  color: var(--text-soft);
  margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---- sub-section divider inside merged budget cards ---- */
.subsection-divider {
  border-top: 1px solid var(--border);
  margin: 20px 0 16px;
  padding-top: 4px;
}
.subsection-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  font-weight: 600;
  margin-bottom: 12px;
}

/* ---- hero / disponible ---- */
.hero-card {
  background: linear-gradient(155deg, var(--surface-2) 0%, var(--bg) 100%);
  position: relative;
  overflow: hidden;
  border-color: var(--border-strong);
}
.hero-card::after {
  content: '';
  position: absolute;
  top: -60%; right: -20%;
  width: 260px; height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(200,240,76,0.16), transparent 70%);
}
.hero-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-soft);
  font-weight: 600;
  font-family: var(--font-mono);
  position: relative; z-index: 1;
}
.hero-amount {
  font-family: var(--font-display);
  font-size: clamp(30px, 5.5vw, 40px);
  font-weight: 700;
  line-height: 1.05;
  margin: 8px 0 4px;
  position: relative; z-index: 1;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.hero-amount.negative { color: var(--coral); }
.hero-sub { color: var(--text-soft); font-size: 13.5px; position: relative; z-index: 1; }
.hero-trend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  position: relative; z-index: 1;
  animation: rise 0.5s cubic-bezier(.19,1,.22,1) both;
}
.hero-trend .icon { width: 13px; height: 13px; }
.hero-trend[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .hero-trend { animation-duration: 0.01s; } }

.ribbon { margin-top: 20px; position: relative; z-index: 1; }
.ribbon-track {
  display: flex;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(243,239,230,0.08);
}
.ribbon-seg { height: 100%; transition: width 0.6s cubic-bezier(.65,0,.35,1); min-width: 2px; }
.ribbon-legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 12px; font-size: 12px; }
.ribbon-legend span { display: inline-flex; align-items: center; gap: 6px; color: var(--text-soft); }
.ribbon-legend .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---- stat row ---- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px 16px; }
.stat-box .label { font-size: 11.5px; color: var(--text-soft); font-weight: 600; }
.stat-box .value { font-family: var(--font-mono); font-size: 19px; font-weight: 600; margin-top: 4px; color: var(--text); }
.stat-box.coral .value { color: var(--coral); }
.stat-box.gold .value { color: var(--gold); }
.stat-sub { font-size: 11px; color: var(--text-faint); margin-top: 3px; }

/* ---- case "Épargne commune" : seule valeur du tableau de bord qui n'est pas
   calculée — un vrai solde de compte, à tenir à jour soi-même ---- */
.stat-input-row { display: flex; align-items: baseline; gap: 4px; margin-top: 4px; }
.stat-input {
  border: none; border-bottom: 1px solid var(--border-strong); background: transparent;
  color: var(--gold); font-family: var(--font-mono); font-size: 19px; font-weight: 600;
  width: 100%; min-width: 0; padding: 1px 0;
}
.stat-input:focus { outline: none; border-bottom-color: var(--gold); }
.stat-input::placeholder { color: var(--text-faint); }
.stat-input-suffix { font-family: var(--font-mono); font-size: 19px; font-weight: 600; color: var(--gold); flex-shrink: 0; }

/* ---- répartition partagé / par personne, en tête du hero : réponse visuelle
   immédiate à "qui a dépensé quoi", avant même le détail par catégorie ---- */
.hero-split { margin-top: 18px; position: relative; z-index: 1; }
.hero-split-track {
  display: flex;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(243,239,230,0.08);
}
.hero-split-track i { height: 100%; transition: width 0.6s cubic-bezier(.65,0,.35,1); min-width: 2px; border-right: 2px solid var(--surface); }
.hero-split-track i:last-child { border-right: none; }
.hero-split-legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 12px; font-size: 12px; }
.hero-split-legend span { display: inline-flex; align-items: center; gap: 6px; color: var(--text-soft); }
.hero-split-legend b { color: var(--text); font-weight: 700; }
.hero-split-legend .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.hero-ribbon-divider { margin-top: 20px; }

/* ---- rows: incomes / expenses / allocations ---- */
.row-list { display: flex; flex-direction: column; }
.row-item { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px dashed var(--border); }
.row-item:last-child { border-bottom: none; }

/* ---- glisser une dépense pour révéler la suppression ---- */
.row-item-swipe { position: relative; overflow: hidden; }
.row-item-swipe:last-child .row-item { border-bottom: none; }
.row-swipe-action {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 72px;
  border: none;
  background: var(--coral-fill);
  color: #2a0f0a;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.row-swipe-action .icon { width: 18px; height: 18px; }
.row-item-swipe .row-item {
  position: relative;
  background: var(--surface);
  touch-action: pan-y;
  transition: transform 0.25s cubic-bezier(.19,1,.22,1);
}
.row-item-swipe .row-item.dragging { transition: none; }
.row-item-swipe .row-item.swiped-open { transform: translateX(-72px); }
@media (prefers-reduced-motion: reduce) {
  .row-item-swipe .row-item { transition-duration: 0.01s; }
}
.row-icon {
  width: 38px; height: 38px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.row-icon .icon { width: 18px; height: 18px; }
.row-body { flex: 1; min-width: 0; }
.row-title { font-weight: 600; font-size: 14.5px; }
.row-title-input {
  border: none; background: transparent; font-weight: 600; font-size: 14.5px;
  width: 100%; padding: 2px 0; font-family: var(--font-body); color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row-title-input:focus { outline: none; border-bottom: 1px solid var(--border-strong); }
.row-meta { font-size: 12px; color: var(--text-faint); }
.row-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 7px; }
.row-badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600; color: var(--text-soft);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 3px 9px; border-radius: 999px; line-height: 1.3;
  white-space: nowrap;
}
.row-badge-btn {
  cursor: pointer; font-family: inherit; color: var(--text-faint);
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}
.row-badge-btn:hover { color: var(--accent); border-color: var(--accent-dim); }
.row-badge-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }
.row-avatar-mini {
  width: 18px; height: 18px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 9.5px;
  flex-shrink: 0;
}
.row-item.skipped { opacity: 0.55; }
.row-item.skipped .row-title-input { text-decoration: line-through; }
.row-amount {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 14.5px;
  border: none;
  background: transparent;
  text-align: right;
  width: 78px;
  color: var(--text);
  padding: 4px 2px;
  border-bottom: 1px solid transparent;
  flex-shrink: 0;
}
.row-amount:focus { outline: none; border-bottom: 1px solid var(--border-strong); }
.row-del {
  border: none; background: transparent; color: var(--text-faint); cursor: pointer;
  width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  transition: background 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
}
.row-del .icon { width: 14px; height: 14px; }
.row-del:hover { background: var(--coral-dim); color: var(--coral); }
.row-edit {
  border: none; background: transparent; color: var(--text-faint); cursor: pointer;
  width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  transition: background 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
}
.row-edit .icon { width: 14px; height: 14px; }
.row-edit:hover { background: var(--accent-dim); color: var(--accent); }

.chip-lime { background: var(--lime-dim); color: var(--lime); }
.chip-coral { background: var(--coral-dim); color: var(--coral); }
.chip-gold { background: var(--gold-dim); color: var(--gold); }
.chip-ice { background: var(--ice-dim); color: var(--ice); }
.chip-violet { background: var(--violet-dim); color: var(--violet); }
.chip-rose { background: var(--rose-dim); color: var(--rose); }
.chip-sky { background: var(--sky-dim); color: var(--sky); }
.chip-jade { background: var(--jade-dim); color: var(--jade); }
.chip-cocoa { background: var(--cocoa-dim); color: var(--cocoa); }
.chip-slate { background: var(--slate-dim); color: var(--slate); }

.bar-mini { height: 4px; border-radius: 2px; background: var(--border); margin-top: 6px; overflow: hidden; }
.bar-mini > i { display: block; height: 100%; border-radius: 2px; transition: width 0.4s cubic-bezier(.19,1,.22,1); }
.budget-row { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; margin-top: 6px; font-size: 11.5px; color: var(--text-faint); }
.budget-row.over { color: var(--coral); }
.budget-personal-note { flex-basis: 100%; white-space: nowrap; color: var(--sky); font-weight: 600; }

/* ---- tendance d'une catégorie vs le dernier mois connu : repère une dérive
   sans avoir à comparer les mois soi-même ---- */
.row-title-line { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.trend-badge { font-size: 11px; font-weight: 700; white-space: nowrap; font-family: var(--font-mono); }
.trend-badge.up { color: var(--coral); }
.trend-badge.down { color: var(--jade); }
.trend-badge.flat { color: var(--text-faint); }
.budget-input {
  border: none; border-bottom: 1px solid var(--border-strong); background: transparent;
  color: inherit; font-size: 11.5px; width: 46px; padding: 1px 0; text-align: right;
}
.budget-input:focus { outline: none; border-bottom-color: var(--accent); }
.budget-input::placeholder { color: var(--text-faint); }

/* ---- add-new inline form ---- */
.add-form { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.add-form[hidden] { display: none; }
.add-form input, .add-form select {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  background: var(--surface-2);
  color: var(--text);
}
.add-form input::placeholder { color: var(--text-faint); }
.add-form input:focus, .add-form select:focus { outline: none; border-color: var(--accent); }
.add-form .fld-label { flex: 1 1 140px; min-width: 0; }
.add-form .fld-amount { width: 100px; font-family: var(--font-mono); }
.add-form .fld-select { flex: 1 1 130px; }
.add-form .fld-date { width: 150px; font-family: var(--font-mono); color-scheme: dark; }
[data-theme="light"] .add-form .fld-date { color-scheme: light; }
@media (prefers-color-scheme: light) { :root:not([data-theme]) .add-form .fld-date { color-scheme: light; } }
.add-form .fld-date[hidden] { display: none; }
.btn-add {
  border: none;
  background: var(--accent-fill);
  color: var(--accent-ink);
  width: 40px; height: 40px;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.2s ease, transform 0.15s ease;
  display: flex; align-items: center; justify-content: center;
}
.btn-add .icon { width: 18px; height: 18px; }
.btn-add:hover { opacity: 0.88; }
.btn-add:active { transform: scale(0.9); }

.category-preview {
  width: 40px; height: 40px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.category-preview .icon { width: 18px; height: 18px; }

.category-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ---- grilles de sélection icône/couleur dans la modale d'édition de catégorie ---- */
.icon-grid, .color-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.icon-swatch {
  width: 38px; height: 38px;
  border-radius: 11px;
  border: 2px solid transparent;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.icon-swatch .icon { width: 17px; height: 17px; }
.icon-swatch.active { border-color: var(--text); transform: scale(1.06); }
.color-swatch {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.color-swatch.active { border-color: var(--text); transform: scale(1.12); }
.category-picker-scroll { margin: 0; }
/* ---- mobile : évite qu'une longue liste de catégories/banques grandisse
   indéfiniment en hauteur — on la fait défiler horizontalement sur une
   seule ligne, comme le reste du choix se fait déjà par pastilles ---- */
@media (max-width: 719px) {
  .category-picker-scroll {
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    margin: 0 -22px;
    padding: 0 22px;
    mask-image: linear-gradient(to right, black calc(100% - 28px), transparent 100%);
  }
  .category-picker-scroll .category-picker { flex-wrap: nowrap; }
  .category-picker-scroll .category-pill { flex-shrink: 0; }
}

/* ---- mobile : iOS Safari zoome automatiquement la page au focus d'un champ
   dont la taille de police est < 16px — on aligne tous les champs éditables
   sur 16px sous 720px, et on élargit ceux qui étaient calibrés pour un texte
   plus petit pour éviter que les chiffres ne se coupent ---- */
@media (max-width: 719px) {
  .add-form input, .add-form select,
  .invite-link-row input,
  .row-title-input,
  .row-amount,
  .budget-input,
  .split-percent-input,
  .goal-target {
    font-size: 16px;
  }
  .row-amount { width: 88px; }
  .row-line-bottom .row-amount { width: 84px; }
  .budget-input { width: 62px; }
  .split-percent-input { width: 44px; }
  .goal-target { width: 76px; }
  .add-form .fld-amount { width: 108px; }
  .add-form .fld-date { width: 162px; }
}

.category-pill {
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 7px 8px 7px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; gap: 7px;
  transition: all 0.2s ease;
}
.category-pill .icon { width: 14px; height: 14px; }
.category-pill.active { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }
.category-pill .pill-x {
  display: flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; color: inherit; opacity: 0.6;
}
.category-pill .pill-x .icon { width: 11px; height: 11px; }
.category-pill .pill-x:hover { opacity: 1; background: rgba(0,0,0,0.15); }

.ghost-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 2px;
  margin-top: 10px;
  cursor: pointer;
  transition: color 0.2s ease;
}
.ghost-toggle .icon { width: 13px; height: 13px; transition: transform 0.2s ease; }
.ghost-toggle:hover { color: var(--accent); }
.ghost-toggle.open .icon { transform: rotate(45deg); }

/* ---- feuille d'ajout rapide : pastilles catégorie/banque cliquables,
   ouvrent une mini-liste de sélection juste en dessous ---- */
.target-chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 12px; }
.target-chip {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease;
}
.target-chip:hover { border-color: var(--text-soft); }
.target-chip.open { border-color: var(--accent); }
.target-chip .icon:first-child { width: 14px; height: 14px; }
.target-chip .chevron { width: 11px; height: 11px; color: var(--text-faint); transition: transform 0.2s ease; }
.target-chip.open .chevron { transform: rotate(180deg); }
.mini-picker {
  margin: -2px 0 14px;
  padding: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  animation: popIn 0.2s cubic-bezier(.19,1,.22,1) both;
}
.mini-picker[hidden] { display: none; }

.method-toggle { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; gap: 2px; }
.method-toggle button {
  border: none; background: transparent; padding: 6px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 700; color: var(--text-soft); cursor: pointer; font-family: var(--font-mono);
}
.method-toggle button.active { background: var(--accent-fill); color: var(--accent-ink); }

.toggle-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }

/* ---- membres du foyer ---- */
.member-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--surface-2);
}
.member-block:last-of-type { margin-bottom: 16px; }
.member-header { display: flex; align-items: center; gap: 10px; }
.member-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.member-name-label {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  font-size: 14.5px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.member-you-tag { font-weight: 500; color: var(--text-faint); font-size: 12.5px; }
.member-share-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-soft);
  white-space: nowrap;
}
.split-mode-toggle { margin-bottom: 14px; }
.revoke-link {
  border: none; background: none; padding: 6px 4px; margin: 0;
  font-size: 12px; font-weight: 600; color: var(--text-faint);
  cursor: pointer; font-family: inherit; flex-shrink: 0;
}
.revoke-link:hover { color: var(--coral); }
.split-percent-field {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-soft);
  white-space: nowrap;
  flex-shrink: 0;
}
.split-percent-input {
  border: none;
  border-bottom: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12.5px;
  width: 34px;
  padding: 2px 0;
  text-align: right;
}
.split-percent-input:focus { outline: none; border-bottom-color: var(--accent); }
.member-incomes { margin: 10px 0 0; padding-left: 44px; }
.member-incomes .row-item { padding: 8px 0; }
.member-incomes .empty-state { text-align: left; padding: 6px 0 2px; font-size: 12.5px; }
.member-incomes .empty-state .glyph { display: none; }
.member-add-income { padding-left: 44px; margin-top: 8px; }
.member-invite-hint { margin: 14px 0 0; }
.member-invite-link { color: var(--accent); font-weight: 600; text-decoration: none; }
.member-invite-link:hover { text-decoration: underline; }

/* ---- répartition du foyer (résumé) ---- */
.repartition-row {
  padding: 14px 0;
  border-bottom: 1px dashed var(--border);
}
.repartition-row:last-child { border-bottom: none; }
.repartition-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.repartition-top .member-avatar { width: 30px; height: 30px; font-size: 12px; }
.repartition-name { font-weight: 600; font-size: 14.5px; flex: 1; min-width: 0; }
.repartition-income { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-faint); }
.repartition-bar { height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; margin-bottom: 8px; }
.repartition-bar > i { display: block; height: 100%; border-radius: 4px; transition: width 0.6s cubic-bezier(.19,1,.22,1); }
.repartition-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--text-soft); }
.repartition-meta .share-amount { flex-basis: 100%; font-family: var(--font-mono); font-weight: 700; color: var(--text); }
.share-breakdown { margin-top: 4px; font-size: 11.5px; color: var(--text-faint); }

/* ---- "Dépenses personnelles" : un mini top-catégories par membre, plutôt
   qu'un mélange générique — symétrique au "Top dépenses" partagé ---- */
.personal-top-member { margin-bottom: 22px; }
.personal-top-member:last-child { margin-bottom: 0; }
.personal-top-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.personal-top-head .member-avatar { width: 28px; height: 28px; font-size: 11.5px; }
.personal-top-name { font-weight: 700; font-size: 14px; flex: 1; min-width: 0; }
.personal-top-total { font-size: 14px; font-weight: 700; color: var(--text); }
.personal-top-member .row-item { padding: 9px 0; }
.personal-top-member .row-item:last-child { border-bottom: none; }

.empty-state { text-align: center; padding: 26px 10px; color: var(--text-faint); font-size: 13.5px; }
.empty-state .glyph { display: flex; justify-content: center; margin-bottom: 10px; }
.empty-state .glyph .icon { width: 30px; height: 30px; opacity: 0.7; }

.history-legend { display: flex; gap: 16px; font-size: 12px; margin-bottom: 10px; }
.history-legend span { display: inline-flex; align-items: center; gap: 6px; color: var(--text-soft); }
.history-legend .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.history-bars {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 156px;
  overflow-x: auto;
}
.history-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 1 0 32px;
  height: 100%;
  min-width: 32px;
  background: none;
  border: none;
  padding: 4px 2px;
  border-radius: var(--radius-sm);
  font: inherit;
  cursor: pointer;
  transition: background 0.2s ease;
}
.history-col:hover { background: var(--surface-2); }
.history-col.open { background: var(--surface-2); }
.history-col.open .history-label { color: var(--accent); font-weight: 700; }
.history-half {
  width: 100%;
  max-width: 26px;
  height: 60px;
  display: flex;
}
.history-half.income { align-items: flex-end; }
.history-half.expense { align-items: flex-start; }
.history-bar-income {
  width: 100%;
  background: var(--jade-fill);
  border-radius: 4px 4px 0 0;
  transition: height 0.5s cubic-bezier(.19,1,.22,1);
}
.history-bar-expense {
  width: 100%;
  background: var(--coral-fill);
  border-radius: 0 0 4px 4px;
  transition: height 0.5s cubic-bezier(.19,1,.22,1);
}
.history-baseline { width: 100%; max-width: 26px; height: 1px; background: var(--border-strong); flex-shrink: 0; }

/* ---- évolution du solde d'épargne commune : chart secondaire à une seule
   série (pas de paire revenus/dépenses), plus compact ---- */
.savings-history-bars { display: flex; align-items: flex-end; gap: 10px; height: 86px; overflow-x: auto; }
.savings-history-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; flex: 1 0 32px; height: 100%; min-width: 32px; }
.savings-history-bar { width: 100%; max-width: 26px; background: var(--gold-fill); border-radius: 4px 4px 0 0; transition: height 0.5s cubic-bezier(.19,1,.22,1); }
.history-label {
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--text-faint);
  text-transform: capitalize;
  white-space: nowrap;
}

/* ---- détail d'un mois, déplié sous le graphique au clic sur une colonne ---- */
#monthDetail:empty { display: none; }
#monthDetail {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  animation: popIn 0.3s cubic-bezier(.19,1,.22,1) both;
}
@media (prefers-reduced-motion: reduce) { #monthDetail { animation-duration: 0.01s; } }
.month-detail-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.month-detail-head h3 { font-size: 15px; text-transform: capitalize; }

/* ---- stacked layout for allocation rows ---- */
.row-item--stacked { display: block; }
.row-line-top { display: flex; align-items: center; gap: 10px; }
.row-line-top .row-title-input { flex: 1; min-width: 0; }
.row-line-bottom { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding-left: 48px; }
.row-line-bottom .alloc-eq { font-size: 12px; color: var(--text-faint); font-family: var(--font-mono); }
.row-line-bottom .row-amount { margin-left: auto; width: 76px; }

.row-goal { margin-top: 10px; padding-left: 48px; }
.goal-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
  margin-bottom: 8px;
}
.goal-bar > i { display: block; height: 100%; border-radius: 3px; background: var(--accent-fill); transition: width 0.5s cubic-bezier(.19,1,.22,1); }
.goal-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.goal-progress { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; }
.goal-target {
  border: none;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-soft);
  width: 56px;
  padding: 2px;
  border-bottom: 1px solid transparent;
}
.goal-target:focus { outline: none; border-bottom-color: var(--border-strong); color: var(--text); }
.goal-add-btn {
  border: 1px solid var(--accent-dim);
  background: var(--accent-dim);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  margin-left: auto;
}
.goal-add-btn:hover { background: var(--accent-dim); opacity: 0.8; }

/* ============================================================
   BOTTOM NAV (mobile) / SIDEBAR (desktop)
   ============================================================ */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 20;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 24px -16px rgba(0,0,0,0.5);
}
.nav-btn {
  flex: 1;
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 0;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-faint);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color 0.2s ease;
}
.nav-btn .icon { width: 19px; height: 19px; transition: transform 0.25s cubic-bezier(.65,0,.35,1); }
.nav-btn.active { color: var(--accent); }
.nav-btn.active .icon { transform: translateY(-3px); }

@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes popIn { from { opacity: 0; transform: scale(0.9) translateY(6px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.row-item.entering { animation: popIn 0.35s cubic-bezier(.19,1,.22,1) both; }

/* ============================================================
   TOASTS
   ============================================================ */
.toast-stack {
  position: fixed;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
@media (min-width: 720px) { .toast-stack { bottom: 28px; } }
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-pop);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  animation: toastIn 0.35s cubic-bezier(.19,1,.22,1) both;
}
.toast.leaving { animation: toastOut 0.25s cubic-bezier(.65,0,.35,1) both; }
.toast .toast-glyph { width: 20px; height: 20px; flex-shrink: 0; display: flex; }
.toast.success .toast-glyph { color: var(--accent); }
.toast.error .toast-glyph { color: var(--coral); }
.toast.info .toast-glyph { color: var(--text-soft); }
.toast.warning .toast-glyph { color: var(--coral); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastOut { from { opacity: 1; transform: translateY(0) scale(1); } to { opacity: 0; transform: translateY(6px) scale(0.97); } }
@media (prefers-reduced-motion: reduce) {
  .toast, .toast.leaving { animation-duration: 0.01s; }
}

/* ============================================================
   MODAL (confirmation)
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal-backdrop);
  background: rgba(10, 9, 7, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  animation: modalBgIn 0.25s ease both;
}
[data-theme="light"] .modal-overlay { background: rgba(28, 26, 18, 0.35); }
@media (min-width: 720px) { .modal-overlay { align-items: center; } }
.modal-overlay[hidden] { display: none; }
.modal-card {
  position: relative;
  z-index: var(--z-modal);
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: 24px;
  animation: modalCardIn 0.3s cubic-bezier(.19,1,.22,1) both;
}
.modal-text { font-size: 14.5px; line-height: 1.6; color: var(--text); margin: 0 0 20px; white-space: pre-line; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-actions .btn { padding: 11px 20px; }
@keyframes modalBgIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalCardIn { from { opacity: 0; transform: translateY(16px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .modal-overlay, .modal-card { animation-duration: 0.01s; }
}

.quick-add-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.quick-add-head .modal-text { font-family: var(--font-display); font-weight: 700; font-size: 16px; }
.modal-close {
  border: none; background: var(--surface-2); color: var(--text-soft);
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.modal-close .icon { width: 14px; height: 14px; }
.modal-close:hover { background: var(--coral-dim); color: var(--coral); }

/* ============================================================
   IMPORT DE RELEVÉ — dépôt de fichier + relecture avant import
   ============================================================ */
.import-card { max-width: 480px; max-height: 82vh; overflow-y: auto; }
.import-drop {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 22px 16px;
  margin-bottom: 12px;
  color: var(--text-soft);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease, transform 0.2s cubic-bezier(.19,1,.22,1);
}
.import-drop:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.import-drop.has-file { border-style: solid; border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.import-drop.drag-over {
  border-style: solid;
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
  transform: scale(1.02);
}
.import-drop .icon { width: 18px; height: 18px; flex-shrink: 0; }
@media (prefers-reduced-motion: reduce) { .import-drop { transition-duration: 0.01s; } }

.import-cat-select {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 12.5px;
  background: var(--surface-2);
  color: var(--text);
  max-width: 170px;
  flex-shrink: 0;
}

/* ---- un groupe = une catégorie Boursobank, une seule décision (suggestion
   ou nouvelle catégorie) qui s'applique à toutes ses transactions ---- */
.import-group { padding: 14px 0; border-bottom: 1px solid var(--border); }
.import-group:last-child { border-bottom: none; padding-bottom: 0; }
.import-group:first-child { padding-top: 0; }
.import-group-head { display: flex; align-items: flex-start; gap: 10px; }
.import-group-head .row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.import-group-head .row-title { font-size: 13.5px; }
.import-group-head .row-meta { font-size: 11.5px; }
.import-group > .add-form { margin: 10px 0 0; }
.import-group > .add-form .category-preview { width: 34px; height: 34px; }
.import-group-items {
  margin-top: 10px;
  padding-left: 4px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.import-item { display: flex; align-items: flex-start; gap: 10px; }
.import-item input[type="checkbox"] {
  width: 17px; height: 17px;
  margin-top: 2px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.import-item .row-title { font-size: 13px; font-weight: 600; }
.import-item .row-meta { font-size: 11.5px; }
.import-item.is-duplicate .row-title { color: var(--text-faint); }
.duplicate-flag { color: var(--coral); font-weight: 600; }

/* ============================================================
   FAB — ajout rapide d'une dépense (mobile), visible depuis
   n'importe quel point de scroll de l'onglet Budget
   ============================================================ */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(92px + env(safe-area-inset-bottom) + 14px);
  z-index: var(--z-fab);
  width: 54px; height: 54px;
  border-radius: 50%;
  border: none;
  background: var(--accent-fill);
  color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-pop);
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.2s ease;
}
.fab .icon { width: 24px; height: 24px; }
.fab:active { transform: scale(0.92); }
/* ---- desktop : la barre du bas reste identique au mobile, donc le même
   décalage vertical fonctionne tel quel ; seul le décalage horizontal
   change pour suivre le bord du conteneur centré (1140px max) plutôt que
   le bord brut de la fenêtre, qui s'éloignerait du contenu sur un grand
   écran ---- */
@media (min-width: 720px) {
  .fab { right: max(24px, calc((100vw - 1140px) / 2 + 24px)); }
}

/* ============================================================
   TABLET / DESKTOP — la navigation reste la barre du bas partout,
   seule la mise en page du contenu s'adapte aux écrans larges.
   ============================================================ */
@media (min-width: 720px) {
  .view.active { grid-template-columns: repeat(2, 1fr); align-items: start; }
  .view.active .card.span-2,
  .view.active .card.span-3 { grid-column: span 2; }
  .app-header { padding: 28px 32px 6px; max-width: 1140px; margin: 0 auto; width: 100%; }
  .app-main { max-width: 1140px; padding: 6px 32px 40px; }
}

@media (min-width: 1024px) {
  .view.active { grid-template-columns: repeat(3, 1fr); }
  .view.active .card.span-2 { grid-column: span 2; }
  .view.active .card.span-3 { grid-column: span 3; }
}

@media (min-width: 720px) {
  .auth-wrap { padding: 40px; }
}

/* ---- desktop : évite que les listes/barres mobiles s'étirent sur toute la
   largeur d'une carte pleine largeur — garde un contenu lisible, chiffres
   toujours alignés à droite ---- */
@media (min-width: 720px) {
  .row-body { max-width: 420px; }
  .row-amount { margin-left: auto; }
  .repartition-row { max-width: 620px; }
  .add-form { max-width: 640px; }
  .history-bars { max-width: 640px; margin: 0 auto; gap: 22px; }

  /* ---- cartes pleine largeur : plutôt que de laisser une colonne unique
     capée flotter avec un grand vide à droite, on répartit le contenu
     sur plusieurs colonnes pour occuper l'espace disponible ---- */
  #membersList { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; align-items: start; }
  #membersList .member-block { margin-bottom: 0; }

  #topCategories { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px 36px; }
  #topCategories .empty-state { grid-column: 1 / -1; }

  #expenseList { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 36px; align-items: start; }
  #expenseList .empty-state { grid-column: 1 / -1; }
  #expenseList .row-item-swipe:last-child .row-item,
  #expenseList .row-item-swipe:nth-last-child(2) .row-item { border-bottom: none; }
}
