/* FamilyCount — thème maison : tons chauds, faible saturation, mobile-first */

:root {
    --bg: #faf6f1;
    --surface: #ffffff;
    --surface-alt: #f3ece4;
    --primary: #b5674a;
    --primary-dark: #9a5138;
    --primary-soft: #f0ddd2;
    --text: #3d342e;
    --text-muted: #8d7f74;
    --positive: #5e7f5a;
    --negative: #b05a4f;
    --warn: #c99a4b;
    --danger: #b05a4f;
    --border: #e7ddd3;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(61, 52, 46, 0.08), 0 4px 12px rgba(61, 52, 46, 0.06);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
}

h1 {
    font-size: 1.4rem;
    margin: 0;
}

h2 {
    font-size: 1.05rem;
    margin: 1.4rem 0 0.6rem;
    color: var(--text-muted);
    font-weight: 600;
}

.muted { color: var(--text-muted); }
.error { color: var(--danger); }
.positive { color: var(--positive); font-weight: 600; }
.negative { color: var(--negative); font-weight: 600; }

.splash {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    color: var(--text-muted);
}

/* --- Structure --- */
.shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand {
    font-weight: 700;
    color: var(--primary-dark);
    flex: 1;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

/* Logo topbar : petit, aligné avec le texte « FamilyCount ».
   Contraintes dures (height + max-width) pour éviter que l'image
   prenne sa taille naturelle (1024px) si le CSS charge mal. */
.brand-logo {
    height: 1.875rem; /* 30px */
    width: auto;
    max-width: 2.5rem;
    border-radius: 0.4rem;
    display: inline-block;
    vertical-align: middle;
}

/* Logo écran d'accueil « Qui es-tu ? » : joli mais PAS géant.
   Le fichier source fait 1024px : largeur plafonnée quelle que
   soit la taille d'écran (mobile inclus). */
.gate-logo {
    width: 7.5rem; /* 120px */
    max-width: 38vw;
    height: auto;
    border-radius: 24px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    display: block;
    margin: 0 auto;
    /* Fond crème derrière le logo : contraste assuré en thème sombre. */
    background: #faf2ea;
}

.gate-brand {
    margin: 0;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary-dark);
}

.user-chip {
    background: var(--primary-soft);
    color: var(--primary-dark);
    border-radius: 999px;
    padding: 0.2rem 0.7rem;
    font-size: 0.8rem;
}

.menu-btn {
    border: none;
    background: none;
    font-size: 1.3rem;
    color: var(--primary-dark);
    cursor: pointer;
}

.sidenav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    height: 100vh;
    height: 100dvh;
    background: var(--surface);
    box-shadow: var(--shadow);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 40;
    padding-top: 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
}

.sidenav.open {
    transform: translateX(0);
}

.scrim {
    position: fixed;
    inset: 0;
    background: rgba(61, 52, 46, 0.35);
    z-index: 30;
    touch-action: none;
    overscroll-behavior: none;
}

/* Verrou de défilement : un panneau/feuille est ouvert (le scrim existe). */
body:has(.scrim) {
    overflow: hidden;
}

.nav-list {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0 0.8rem;
}

.nav-header {
    display: flex;
    flex-direction: column;
    padding: 0.4rem 0.8rem 1rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.6rem;
    color: var(--primary-dark);
}

.nav-list a, .nav-list .logout {
    display: block;
    padding: 0.65rem 0.8rem;
    border-radius: 10px;
    color: var(--text);
    text-decoration: none;
    border: none;
    background: none;
    font-size: 1rem;
    text-align: left;
    cursor: pointer;
}

.nav-list a.active, .nav-list a:hover, .nav-list .logout:hover {
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.content {
    flex: 1;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem 1rem 5.5rem; /* espace pour la barre du bas */
}

/* --- Barre de navigation basse (mobile) --- */
.bottomnav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 25;
    display: flex;
    justify-content: space-around;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 0.35rem 0 calc(0.35rem + env(safe-area-inset-bottom));
}

.bottomnav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.68rem;
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.2rem 0.4rem;
}

.bottomnav a.active {
    color: var(--primary-dark);
    font-weight: 600;
}

/* --- Éléments communs --- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.month-picker {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.15rem 0.4rem;
    text-transform: capitalize;
}

.month-picker button {
    border: none;
    background: none;
    font-size: 1.1rem;
    color: var(--primary-dark);
    cursor: pointer;
    padding: 0.2rem 0.5rem;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.7rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.9rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.card.hero {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    grid-column: 1 / -1;
}

.card.hero .card-label { color: rgba(255, 255, 255, 0.8); }

.card-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.big {
    font-size: 1.35rem;
    font-weight: 700;
}

.list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.list-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.7rem 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

.list-item small {
    display: block;
}

.tx-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-align: right;
}

.tx-right small { display: block; }

.icon-btn {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem;
    border-radius: 8px;
}

.icon-btn:hover { background: var(--surface-alt); }

/* --- Formulaires --- */
label {
    font-size: 0.82rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 0.2rem;
}

input, select, textarea {
    width: 100%;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-size: 1rem;
}

input:focus, select:focus {
    outline: 2px solid var(--primary-soft);
    border-color: var(--primary);
}

button {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 10px;
    padding: 0.55rem 1rem;
    font-size: 0.95rem;
    cursor: pointer;
}

button.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
    width: 100%;
}

button.primary:hover { background: var(--primary-dark); }
button:disabled { opacity: 0.6; cursor: default; }

.add-btn { margin-bottom: 0.8rem; }

.quick-add {
    margin-bottom: 1rem;
    gap: 0.6rem;
}

.form-row { margin-bottom: 0.6rem; }

.filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
}

/* --- Budgets --- */
.budget-row {
    margin-bottom: 0.7rem;
}

.budget-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.budget-card { margin-bottom: 0.7rem; }

.progress {
    height: 10px;
    background: var(--surface-alt);
    border-radius: 999px;
    overflow: hidden;
}

.progress .bar {
    height: 100%;
    background: var(--positive);
    border-radius: 999px;
    transition: width 0.3s ease;
}

.progress .bar.warn { background: var(--warn); }
.progress .bar.danger { background: var(--danger); }

/* --- Calendrier --- */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.cal-dayname {
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 0.25rem 0;
}

.cal-cell {
    min-height: 64px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 3px 5px;
    font-size: 0.72rem;
    overflow: hidden;
}

.cal-cell.empty {
    background: transparent;
    border: none;
}

.cal-cell.today {
    border-color: var(--primary);
    box-shadow: inset 0 0 0 1px var(--primary);
}

.cal-day {
    font-weight: 700;
    color: var(--text-muted);
}

.cal-entry {
    border-radius: 6px;
    padding: 1px 4px;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cal-entry.in { background: #e3eadf; color: var(--positive); }
.cal-entry.out { background: var(--primary-soft); color: var(--primary-dark); }

/* --- Login --- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.6rem;
    width: 100%;
    max-width: 380px;
}

.login-card h1 {
    color: var(--primary-dark);
}

.login-card form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* --- Blazor error UI --- */
#blazor-error-ui {
    background: var(--primary-soft);
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* --- Desktop --- */
@media (min-width: 768px) {
    .menu-btn { display: none; }

    .sidenav {
        position: sticky;
        top: 52px;
        transform: none;
        box-shadow: none;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        height: fit-content;
        margin: 0 0 0 1rem;
        align-self: flex-start;
    }

    .shell {
        display: grid;
        grid-template-columns: 260px 1fr;
        grid-template-rows: auto 1fr;
    }

    .topbar { grid-column: 1 / -1; }

    .content { padding-bottom: 2rem; }

    .bottomnav { display: none; }

    button.primary { width: auto; }

    .cal-cell { min-height: 90px; }
}

/* Bandeau mode démo */
.demo-banner {
    background: #f3e2c7;
    color: #6b5233;
    font-size: 0.78rem;
    text-align: center;
    padding: 0.25rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

@media (min-width: 768px) {
    .demo-banner { grid-column: 1 / -1; }
}

/* --- MVP v2 : Mon mois --- */
.user-chip {
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    font-size: 1.3rem;
}

.avatar.sm {
    width: 24px;
    height: 24px;
    font-size: 0.7rem;
}

.profile-gate {
    min-height: 70vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 1rem;
}

.gate-title { color: var(--primary-dark); }

.gate-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
}

.gate-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.4rem;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.gate-card.active { border-color: var(--primary); }

/* v11 : écran « Qui es-tu ? » */
.gate-avatar {
    width: 72px; height: 72px; font-size: 2rem;
    display: flex; align-items: center; justify-content: center;
}
.gate-name { font-weight: 600; }
.gate-card .muted { font-size: 0.8rem; }

/* Animation d'erreur du code PIN */
.pin-dots.shake { animation: pfos-shake 0.4s; }
@keyframes pfos-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-6px); }
    80% { transform: translateX(6px); }
}

.month-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
}

.month-nav h1 { text-transform: capitalize; font-size: 1.15rem; }

.btn {
    border: none;
    border-radius: 10px;
    padding: 0.5rem 0.9rem;
    font-size: 0.95rem;
    cursor: pointer;
}

.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:disabled { opacity: 0.5; }
.btn.ghost { background: none; color: var(--primary-dark); }
.btn.danger { background: var(--danger); color: #fff; margin-top: 0.6rem; }

.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0.5rem 0; }

.chip {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 999px;
    padding: 0.45rem 0.85rem;
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--text);
}

.chip.selected { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip.static { cursor: default; background: var(--surface-alt); font-size: 0.8rem; }

.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.9rem;
    margin-bottom: 0.5rem;
}

.main-card .row {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0;
}

.rest {
    margin-top: 0.6rem;
    border-radius: 12px;
    padding: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.rest strong { font-size: 1.7rem; }
.rest.ok { background: #e7efe3; color: var(--positive); }
.rest.warn { background: #f5ecd8; color: var(--warn); }
.rest.danger { background: #f3e0dd; color: var(--negative); }

.projection { margin: 0.4rem 0 0; font-size: 0.9rem; }

.bar-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.3rem 0;
}

.bar-label { width: 90px; font-size: 0.85rem; flex-shrink: 0; }

.bar-track {
    flex: 1;
    height: 14px;
    background: var(--surface-alt);
    border-radius: 999px;
    overflow: hidden;
}

.bar-fill { height: 100%; background: var(--primary); border-radius: 999px; }
.bar-fill.over { background: var(--negative); }

.bar-value { font-size: 0.8rem; color: var(--text-muted); min-width: 90px; text-align: right; }

.list-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--border);
}

.list-row:last-child { border-bottom: none; }
.list-row.total { border-top: 2px solid var(--border); margin-top: 0.3rem; padding-top: 0.6rem; }
.list-row .grow { flex: 1; display: flex; flex-direction: column; }

.group-title {
    margin: 0.7rem 0 0.2rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cat-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.fab {
    position: fixed;
    right: 1.2rem;
    bottom: 5.2rem;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: #fff;
    font-size: 1.8rem;
    box-shadow: var(--shadow);
    z-index: 26;
    cursor: pointer;
}

.sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    background: var(--surface);
    border-radius: 18px 18px 0 0;
    box-shadow: var(--shadow);
    padding: 1.2rem 1.2rem calc(1.2rem + env(safe-area-inset-bottom));
    max-height: 88vh;
    max-height: 88dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
}

.sheet label { display: flex; flex-direction: column; gap: 0.25rem; margin: 0.55rem 0; font-size: 0.9rem; }
.sheet label.check { flex-direction: row; align-items: center; gap: 0.5rem; }

/* --- v8.2 : rangées de chips horizontales DANS les feuilles ---
   Une seule ligne, défilement horizontal au doigt (pan-x), sans barre visible,
   avec un léger fondu sur le bord droit quand le contenu déborde. */
.sheet .chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    overscroll-behavior-x: contain;
    padding-bottom: 0.35rem;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, #000 0%, #000 calc(100% - 1.6rem), transparent 100%);
    mask-image: linear-gradient(to right, #000 0%, #000 calc(100% - 1.6rem), transparent 100%);
}
.sheet .chips::-webkit-scrollbar { display: none; }
.sheet .chips .chip { flex-shrink: 0; touch-action: pan-x pan-y; }

/* Le pavé numérique et les contrôles ne doivent pas piéger le geste vertical
   de la feuille : manipulation autorise le défilement du parent. */
.keypad, .key { touch-action: manipulation; }
.sheet input, .sheet select, .sheet textarea { touch-action: manipulation; }

.sheet input, .sheet select, .card input {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.6rem;
    font-size: 1rem;
    background: var(--bg);
    color: var(--text);
}

.form-row { display: flex; gap: 0.6rem; align-items: flex-end; flex-wrap: wrap; }
.form-row label { flex: 1; min-width: 120px; }
.form-row input { flex: 1; min-width: 0; }

.sheet-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 0.9rem; }

.amount-display {
    text-align: center;
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 0.6rem;
}

.amount-display small { font-size: 1rem; color: var(--text-muted); }

.keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.key {
    padding: 0.9rem;
    font-size: 1.4rem;
    border: none;
    border-radius: 12px;
    background: var(--surface-alt);
    color: var(--text);
    cursor: pointer;
}

.key:active { background: var(--primary-soft); }

.note-input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.6rem;
    font-size: 1rem;
    background: var(--bg);
    color: var(--text);
    margin-top: 0.5rem;
}

.totals-card { display: flex; flex-direction: column; gap: 0.3rem; }

.confirm { margin-top: 0.8rem; padding: 0.8rem; background: var(--surface-alt); border-radius: 10px; }
.confirm .btn { margin-right: 0.5rem; margin-top: 0.4rem; }

/* --- v3 : badges, calendrier, budgets, enveloppes --- */
.badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
    margin-left: 0.35rem;
    vertical-align: middle;
}

.badge.planned { background: #f5ecd8; color: var(--warn); }
.badge.over { background: #f3e0dd; color: var(--negative); }

.bar-fill.warn { background: var(--warn); }
.over-note { display: block; margin: -0.15rem 0 0.3rem 96px; }

.cal-cell { cursor: pointer; }
.cal-cell.selected { border-color: var(--primary-dark); box-shadow: inset 0 0 0 2px var(--primary-dark); }
.cal-entry.planned { background: #f5ecd8; color: var(--warn); }
.cal-entry.real { background: var(--surface-alt); color: var(--text-muted); }

.legend { font-size: 0.78rem; }

.day-detail { margin-top: 0.8rem; }

.point-bas { margin-top: 0.8rem; gap: 0.3rem; }

.bilan-row { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; padding: 0.3rem 0; flex-wrap: wrap; }

.more-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.68rem;
    color: var(--text-muted);
    border: none;
    background: none;
    padding: 0.2rem 0.4rem;
    cursor: pointer;
}

/* --- v4 : emoji picker, day picker, catégories, immobilier --- */
.emoji-picker { margin: 0.55rem 0; }
.emoji-current { display: flex; align-items: center; gap: 0.5rem; }
.emoji-big { font-size: 1.3rem; }
.emoji-panel {
    margin-top: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
    max-height: 260px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    padding: 0.4rem;
}
.emoji-section-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    margin: 0.5rem 0 0.25rem;
}
.emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
    gap: 4px;
}
.emoji-cell {
    border: none;
    background: none;
    font-size: 1.4rem;
    padding: 0.3rem;
    border-radius: 10px;
    cursor: pointer;
    text-align: center;
}
.emoji-cell:hover { background: var(--surface-alt); }
.emoji-cell.selected { background: var(--primary-soft); box-shadow: inset 0 0 0 2px var(--primary); }

.day-picker { margin: 0.55rem 0; }
.day-picker-row {
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    padding: 0.2rem 0 0.5rem;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, #000 0%, #000 calc(100% - 1.6rem), transparent 100%);
    mask-image: linear-gradient(to right, #000 0%, #000 calc(100% - 1.6rem), transparent 100%);
}
.day-picker-row::-webkit-scrollbar { display: none; }
.day-picker-row .chip { touch-action: pan-x pan-y; }
.day-chip { min-width: 44px; text-align: center; padding: 0.45rem 0; flex-shrink: 0; }

.cat-badge { font-size: 1.05rem; margin-right: 0.3rem; }

/* Jauge dépensé (plein) + prévu (pointillés) */
.bar-fill.planned-overlay {
    background: repeating-linear-gradient(45deg, var(--warn), var(--warn) 4px, transparent 4px, transparent 8px);
    background-color: #f0e2c0;
}
.progress .bar.planned {
    background: repeating-linear-gradient(45deg, var(--warn), var(--warn) 4px, #f5ecd8 4px, #f5ecd8 8px);
}

.badge.rental { background: #e3eadf; color: var(--positive); }

.rental-hero {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border-radius: var(--radius);
    padding: 0.9rem;
    box-shadow: var(--shadow);
    margin-bottom: 0.5rem;
}
.rental-hero .big { font-size: 1.6rem; }
.rental-hero small { color: rgba(255,255,255,0.8); }

.cashflow-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.cashflow-table td, .cashflow-table th {
    padding: 0.3rem 0.4rem;
    border-bottom: 1px solid var(--border);
    text-align: right;
}
.cashflow-table td:first-child, .cashflow-table th:first-child { text-align: left; text-transform: capitalize; }
.cashflow-table tr.total td { border-top: 2px solid var(--border); font-weight: 700; }

.day-actions { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.6rem; }

.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 26px;
    flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 999px;
    transition: background 0.2s;
    cursor: pointer;
}
.switch .slider::before {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: var(--shadow);
}
.switch input:checked + .slider { background: var(--positive); }
.switch input:checked + .slider::before { transform: translateX(20px); }

@media (min-width: 768px) {
    .emoji-grid { grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); }
}

/* ===================== v6 ===================== */

/* --- Mode sombre : déclinaison du thème chaud --- */
[data-theme="sombre"] {
    --bg: #1a1512;
    --surface: #262019;
    --surface-alt: #302821;
    --primary: #c9826e;
    --primary-dark: #dfa188;
    --primary-soft: #3d2d24;
    --text: #efe6dc;
    --text-muted: #b3a393;
    --positive: #9db98f;
    --negative: #d08a7e;
    --warn: #d9b36c;
    --danger: #d08a7e;
    --border: #42362c;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="sombre"] .rest.ok { background: #26331f; color: var(--positive); }
[data-theme="sombre"] .rest.warn { background: #38301c; color: var(--warn); }
[data-theme="sombre"] .rest.danger { background: #3a241f; color: var(--negative); }
[data-theme="sombre"] .badge.planned { background: #38301c; color: var(--warn); }
[data-theme="sombre"] .badge.over { background: #3a241f; color: var(--negative); }
[data-theme="sombre"] .badge.rental { background: #26331f; color: var(--positive); }
[data-theme="sombre"] .cal-entry.in { background: #26331f; color: var(--positive); }
[data-theme="sombre"] .cal-entry.planned { background: #38301c; color: var(--warn); }
[data-theme="sombre"] .bar-fill.planned-overlay { background-color: #38301c; }
[data-theme="sombre"] .scrim { background: rgba(0, 0, 0, 0.55); }
[data-theme="sombre"] .demo-banner { background: #38301c; color: #d9b36c; }
[data-theme="sombre"] .card.hero, [data-theme="sombre"] .rental-hero { background: linear-gradient(135deg, #4a3125, #332219); }
[data-theme="sombre"] .fab, [data-theme="sombre"] .btn.primary, [data-theme="sombre"] button.primary { color: #1a1512; }
[data-theme="sombre"] .chip.selected { color: #1a1512; }
[data-theme="sombre"] input[type="color"] { padding: 0.2rem; }

/* --- Transitions douces entre pages --- */
.page-fade { animation: pageFade 0.18s ease-out; }
@keyframes pageFade {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

/* --- v10 : transition de glissement au changement de mois (swipe) --- */
.swipe-exit-left { transition: opacity 0.2s ease-in, transform 0.2s ease-in; opacity: 0; transform: translateX(-48px); }
.swipe-exit-right { transition: opacity 0.2s ease-in, transform 0.2s ease-in; opacity: 0; transform: translateX(48px); }
.swipe-enter-left { animation: swipeEnterLeft 0.25s ease-out; }
.swipe-enter-right { animation: swipeEnterRight 0.25s ease-out; }
@keyframes swipeEnterLeft {
    from { opacity: 0; transform: translateX(-48px); }
    to { opacity: 1; transform: none; }
}
@keyframes swipeEnterRight {
    from { opacity: 0; transform: translateX(48px); }
    to { opacity: 1; transform: none; }
}

/* --- États vides --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.4rem;
    padding: 1.4rem 0.6rem;
    color: var(--text);
}
.empty-emoji { font-size: 2.4rem; }
.empty-state p { margin: 0; }

/* --- Badge compteur d'alertes (menu) --- */
.menu-btn { position: relative; }
.nav-badge {
    position: absolute;
    top: -4px;
    right: -8px;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    background: var(--negative);
    color: #fff;
    font-size: 0.66rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.theme-btn {
    border: none;
    background: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.2rem;
}

/* --- Alertes --- */
.alerts-list { display: flex; flex-direction: column; gap: 0.5rem; }
.alert-card {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--warn);
    border-radius: var(--radius);
    padding: 0.7rem 0.9rem;
    box-shadow: var(--shadow);
}
.alert-card.danger { border-left-color: var(--negative); }
.alert-card.info { border-left-color: var(--primary); }
.alert-card .grow { flex: 1; display: flex; flex-direction: column; gap: 0.1rem; }
.alert-card small { color: var(--text-muted); }
.alert-icon { font-size: 1.25rem; }
.btn-sm { width: auto; padding: 0.4rem 0.9rem; font-size: 0.85rem; }

/* --- Simulateur --- */
.sim-link { text-decoration: none; font-weight: 600; padding-left: 0; }
.verdict {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    border-radius: 12px;
    padding: 0.8rem;
    margin-bottom: 0.5rem;
}
.verdict strong { display: block; font-size: 1.1rem; }
.verdict-icon { font-size: 1.8rem; }
.verdict.oui { background: #e7efe3; color: var(--positive); }
.verdict.tendu { background: #f5ecd8; color: var(--warn); }
.verdict.ko { background: #f3e0dd; color: var(--negative); }
[data-theme="sombre"] .verdict.oui { background: #26331f; }
[data-theme="sombre"] .verdict.tendu { background: #38301c; }
[data-theme="sombre"] .verdict.ko { background: #3a241f; }

/* --- Statistiques : graphiques SVG --- */
.chart-card { padding: 0.7rem; }
.chart { width: 100%; height: auto; display: block; }
.bar-inc { fill: var(--positive); }
.bar-out { fill: var(--primary); }
.line-sav { stroke: var(--warn); stroke-width: 2; }
.dot-sav { fill: var(--warn); }
.axis-zero { stroke: var(--border); }
.chart-label { font-size: 8px; fill: var(--text-muted); text-transform: capitalize; }
.chart-value { font-size: 8px; fill: var(--text-muted); }

/* --- Scanner « À venir » --- */
.scanner-hero { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.badge.soon { background: var(--primary-soft); color: var(--primary-dark); font-size: 0.8rem; padding: 0.25rem 0.7rem; }

.scan-mockup-card { align-items: center; }
.scan-frame {
    position: relative;
    width: 210px;
    height: 290px;
    margin: 0.6rem auto;
    background: var(--surface-alt);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.scan-corner {
    position: absolute;
    width: 26px;
    height: 26px;
    border: 3px solid var(--primary);
    z-index: 2;
}
.scan-corner.tl { top: 8px; left: 8px; border-right: none; border-bottom: none; border-radius: 8px 0 0 0; }
.scan-corner.tr { top: 8px; right: 8px; border-left: none; border-bottom: none; border-radius: 0 8px 0 0; }
.scan-corner.bl { bottom: 8px; left: 8px; border-right: none; border-top: none; border-radius: 0 0 0 8px; }
.scan-corner.br { bottom: 8px; right: 8px; border-left: none; border-top: none; border-radius: 0 0 8px 0; }
.scan-line {
    position: absolute;
    left: 14px;
    right: 14px;
    height: 2px;
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary);
    animation: scanMove 2.2s ease-in-out infinite;
    z-index: 2;
}
@keyframes scanMove {
    0%, 100% { top: 12%; }
    50% { top: 86%; }
}
.ticket {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 150px;
    padding: 0.7rem 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: var(--shadow);
}
.ticket-head { font-size: 0.66rem; font-weight: 700; text-align: center; letter-spacing: 0.05em; }
.ticket-line { height: 6px; border-radius: 3px; background: var(--surface-alt); }
.ticket-line.w80 { width: 80%; } .ticket-line.w60 { width: 60%; }
.ticket-line.w70 { width: 70%; } .ticket-line.w50 { width: 50%; } .ticket-line.w40 { width: 40%; }
.ticket-total {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    font-weight: 700;
    border-top: 1px dashed var(--border);
    padding-top: 5px;
    color: var(--primary-dark);
}
.ticket-foot { font-size: 0.58rem; text-align: center; color: var(--text-muted); }

.steps { display: flex; flex-direction: column; gap: 0.7rem; margin: 0.8rem 0; }
.step { display: flex; align-items: center; gap: 0.8rem; }
.step-num { font-size: 1.5rem; }
.step small { display: block; }
.notify-box {
    margin-top: 0.6rem;
    background: var(--primary-soft);
    color: var(--primary-dark);
    border-radius: 12px;
    padding: 0.8rem;
    text-align: center;
}

/* --- FAB secondaire (scanner) --- */
.fab-scan {
    bottom: 9.6rem;
    width: 48px;
    height: 48px;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--border);
    right: 1.5rem;
}


/* --- v7 : Gabarits favorites --- */
.fav-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.3rem 0 0.7rem;
}
.fav-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}
.fav-scroll {
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    padding-bottom: 0.2rem;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    overscroll-behavior-x: contain;
    flex: 1;
    min-width: 0;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, #000 0%, #000 calc(100% - 1.6rem), transparent 100%);
    mask-image: linear-gradient(to right, #000 0%, #000 calc(100% - 1.6rem), transparent 100%);
}
.fav-scroll::-webkit-scrollbar { display: none; }
.fav-scroll .chip { flex-shrink: 0; touch-action: pan-x pan-y; }
.fav-chip { flex-shrink: 0; }
.fav-chip small { opacity: 0.75; font-weight: 400; }
.fav-manage { flex-shrink: 0; }

/* --- Toast de confirmation --- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 92px;
    transform: translateX(-50%);
    background: var(--positive);
    color: #fff;
    padding: 0.6rem 1.1rem;
    border-radius: 999px;
    font-weight: 600;
    box-shadow: var(--shadow);
    z-index: 60;
    animation: toastIn 0.18s ease-out;
}
@keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, 8px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}
[data-theme="sombre"] .toast { color: #1a1512; }

/* --- Tags --- */
.tag-chip {
    display: inline-block;
    background: var(--primary-soft);
    color: var(--primary-dark);
    border-radius: 999px;
    padding: 0.05rem 0.45rem;
    font-size: 0.72rem;
    margin-right: 0.25rem;
    font-weight: 600;
}
[data-theme="sombre"] .tag-chip { background: #3a2c22; color: #d9a488; }
.tags-inline { display: block; margin-top: 0.15rem; }

/* --- Recherche globale --- */
.search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 1rem;
    margin-top: 0.5rem;
}
.search-input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }

/* --- Ligne tappable (détail dépense) --- */
.list-row.tappable { cursor: pointer; }

/* --- Jauge objectif épargne --- */
.bar-fill.goal-ok { background: var(--positive); }

/* --- Notes « vs mois dernier » --- */
.vs-note { font-size: 0.78rem; }

/* --- Grille détail dépense --- */
.detail-grid .row { padding: 0.25rem 0; }

/* --- v8 : PIN, semaine, rappels --- */
.reminder-card {
    display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
    border: 1px dashed var(--primary); background: var(--surface-alt);
}
.pin-gate { min-height: 80vh; }
.pin-dots { display: flex; gap: 1rem; justify-content: center; margin: 1rem 0; }
.pin-dot {
    width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid var(--primary); background: transparent;
    transition: background 0.15s;
}
.pin-dot.filled { background: var(--primary); }
.pin-keypad { max-width: 280px; margin: 0 auto; }
.week-bars { display: flex; gap: 0.4rem; margin-top: 0.8rem; }
.week-day { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.25rem; }
.week-bar-track {
    height: 70px; width: 100%; max-width: 34px; display: flex; align-items: flex-end;
    background: var(--surface-alt); border-radius: 6px; overflow: hidden;
}
.week-bar { width: 100%; background: var(--primary); border-radius: 6px 6px 0 0; }
.progress .bar.bar-over { background: var(--danger); }
.bar-fill.over { background: var(--danger); }

/* --- v9 : compte commun --- */
.badge.common { background: #e3eadf; color: var(--positive); }
[data-theme="sombre"] .badge.common { background: #26331f; color: var(--positive); }
.pot-cta { width: 100%; margin: 0.4rem 0 0.8rem; }
.pot-alert { border-left: 4px solid var(--danger); }

/* --- v13 : onboarding de première utilisation --- */
.onboarding {
    position: fixed;
    inset: 0;
    z-index: 120;
    background: var(--bg);
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    justify-content: center;
}

.ob-card {
    width: 100%;
    max-width: 480px;
    margin: auto;
}

.ob-progress {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.ob-back, .ob-skipall { min-width: 4.5rem; }
.ob-step-label { font-size: 0.9rem; font-weight: 600; }

.ob-bar {
    height: 6px;
    border-radius: 3px;
    background: var(--surface-alt);
    margin: 0.6rem 0 1.2rem;
    overflow: hidden;
}

.ob-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.ob-body { padding-bottom: 2rem; }
.ob-center { text-align: center; padding-top: 2rem; }

.ob-emoji { font-size: 3.2rem; display: block; margin-bottom: 0.6rem; }

.ob-title {
    font-size: 1.35rem;
    margin-bottom: 0.8rem;
    color: var(--primary-dark);
}

.ob-cta { width: 100%; padding: 1rem; font-size: 1.1rem; margin-top: 0.8rem; }
.ob-actions { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.3rem; }
.ob-hint { font-size: 0.9rem; }
.ob-label { display: block; font-size: 0.9rem; margin: 0.7rem 0 0.3rem; color: var(--text-muted); font-weight: 600; }
.ob-check { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.6rem; font-size: 0.95rem; }

.ob-amount {
    display: block;
    width: 100%;
    text-align: center;
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--primary-dark);
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 0.8rem;
    margin: 0.6rem 0;
    cursor: pointer;
}

.ob-amount small { font-size: 1rem; color: var(--text-muted); }
.ob-amount.sm { font-size: 1.5rem; padding: 0.6rem; }
.ob-amount.xs {
    width: auto;
    display: inline-block;
    font-size: 1.1rem;
    padding: 0.45rem 0.9rem;
    margin: 0;
    min-width: 5.5rem;
}

.ob-income {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.9rem;
    margin-bottom: 0.8rem;
}

.ob-charges { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.8rem; }

.ob-charge {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.ob-charge.on { border-color: var(--primary); }

.ob-charge-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0.9rem 1rem;
    background: none;
    border: none;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    text-align: left;
}

.ob-checkdot {
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    border: 2px solid var(--border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.95rem;
}

.ob-charge.on .ob-checkdot { background: var(--primary); border-color: var(--primary); }

.ob-charge-detail { padding: 0 1rem 1rem; }

.ob-segments { display: flex; gap: 0.5rem; margin-top: 0.7rem; }

.ob-segment {
    flex: 1;
    padding: 0.9rem;
    font-size: 1rem;
    font-weight: 600;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-alt);
    color: var(--text);
    cursor: pointer;
}

.ob-segment.selected { background: var(--primary); border-color: var(--primary); color: #fff; }

.ob-budget-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--border);
}

.ob-budget-row .grow { flex: 1; font-weight: 600; }

.ob-two { display: flex; gap: 0.8rem; }
.ob-two > div { flex: 1; min-width: 0; }

.ob-input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.7rem;
    font-size: 1rem;
    background: var(--surface);
    color: var(--text);
}

.ob-recap {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    margin: 1rem 0;
    text-align: left;
}

.ob-recap-row {
    display: flex;
    justify-content: space-between;
    padding: 0.45rem 0;
}

.ob-recap-row.total {
    border-top: 2px solid var(--border);
    margin-top: 0.4rem;
    padding-top: 0.7rem;
    font-size: 1.15rem;
}

.ob-recap-row.total strong { color: var(--primary-dark); }

.ob-pad { max-width: 360px; }

@media (min-width: 600px) {
    .onboarding { padding: 2rem; }
}
.ob-check input[type="checkbox"] { width: auto; flex-shrink: 0; }
