/* Tot's : feuille de style unique. Mobile first, desktop à partir de 900px. */

:root {
    --pink: #ffd6e0;
    --pink-deep: #f7a8bd;
    --orange: #ffe0b5;
    --orange-deep: #f9c27a;
    --green: #cdefd9;
    --green-deep: #8fd6a9;
    --bg: #ffffff;
    --bg-soft: #fbf8f9;
    --card: #ffffff;
    --ink: #3a2e39;
    --ink-soft: #7d6f7c;
    --ink-faint: #b8adb6;
    --line: #f0e6ea;
    --danger: #e0607a;
    --radius: 20px;
    --radius-sm: 12px;
    --shadow: 0 6px 24px rgba(58, 46, 57, 0.08);
    --shadow-sm: 0 2px 8px rgba(58, 46, 57, 0.06);
    --font: ui-rounded, -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --nav-h: 64px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; overscroll-behavior-y: none; }
body {
    margin: 0;
    font-family: var(--font);
    color: var(--ink);
    background: var(--bg);
    font-size: 16px;
    line-height: 1.4;
    min-height: 100vh;
    padding-bottom: calc(var(--nav-h) + var(--safe-b));
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
[hidden] { display: none !important; }

/* ---------- Marque : trois pastilles ---------- */
.blob { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 3px; vertical-align: middle; }
.blob-pink { background: var(--pink-deep); }
.blob-orange { background: var(--orange-deep); }
.blob-green { background: var(--green-deep); }
.brand { display: flex; align-items: center; gap: 4px; font-weight: 800; font-size: 20px; }
.brand-name { margin-left: 6px; }

/* ---------- Barre du haut ---------- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    background: rgba(255,255,255,0.92);
    backdrop-filter: saturate(160%) blur(12px);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    border-bottom: 1px solid var(--line);
    padding-top: var(--safe-t);
}
.topbar-inner {
    max-width: 1100px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; gap: 16px;
}
.nav-desktop { display: none; gap: 4px; }
.nav-desktop a {
    padding: 8px 14px; border-radius: 999px; font-weight: 600; color: var(--ink-soft);
    transition: background .15s, color .15s;
}
.nav-desktop a:hover { background: var(--bg-soft); color: var(--ink); }
.nav-desktop a.active { background: var(--pink); color: var(--ink); }
.avatar {
    width: 40px; height: 40px; border-radius: 50%; border: none;
    background: var(--av, var(--pink)); font-size: 20px; display: grid; place-items: center;
    box-shadow: var(--shadow-sm);
}

/* ---------- Conteneur ---------- */
.app { max-width: 1100px; margin: 0 auto; padding: 16px 16px 40px; }
.view-title { font-size: 26px; margin: 8px 0 4px; }
.view-sub { color: var(--ink-soft); margin: 0 0 18px; }

/* ---------- Cartes résumé ---------- */
.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.card {
    background: var(--card); border-radius: var(--radius); padding: 16px 18px;
    box-shadow: var(--shadow-sm); border: 1px solid var(--line);
}
.card.tint-pink { background: var(--pink); border-color: transparent; }
.card.tint-orange { background: var(--orange); border-color: transparent; }
.card.tint-green { background: var(--green); border-color: transparent; }
.card-label { font-size: 13px; color: var(--ink-soft); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.tint-pink .card-label, .tint-orange .card-label, .tint-green .card-label { color: rgba(58,46,57,.65); }
.card-value { font-size: 28px; font-weight: 800; margin-top: 4px; letter-spacing: -0.02em; }
.card-hint { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.card.big { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card.big .card-value { font-size: 36px; }

/* ---------- Boutons ---------- */
.btn {
    border: none; border-radius: 999px; padding: 12px 20px; font-weight: 700;
    background: var(--bg-soft); color: var(--ink); transition: transform .08s, filter .15s;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--pink-deep); color: #fff; }
.btn-green { background: var(--green-deep); color: #1f4a30; }
.btn-orange { background: var(--orange-deep); color: #5a3a00; }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-danger { background: transparent; color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 14px; }

.fab {
    position: fixed; right: 18px; bottom: calc(var(--nav-h) + var(--safe-b) + 14px); z-index: 25;
    width: 60px; height: 60px; border-radius: 50%; border: none;
    background: var(--pink-deep); color: #fff; font-size: 34px; line-height: 1;
    box-shadow: 0 10px 24px rgba(247,168,189,.55);
    display: grid; place-items: center; transition: transform .1s;
}
.fab:active { transform: scale(.94); }

/* ---------- Navigation mobile ---------- */
.nav-mobile {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
    background: rgba(255,255,255,0.95); border-top: 1px solid var(--line);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    display: flex; justify-content: space-around; align-items: stretch;
}
.nav-mobile a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; font-size: 11px; font-weight: 600; color: var(--ink-faint);
}
.nav-mobile a .ico { font-size: 22px; transition: transform .15s; filter: grayscale(1) opacity(.6); }
.nav-mobile a.active { color: var(--ink); }
.nav-mobile a.active .ico { transform: translateY(-2px); filter: none; }

/* ---------- Puces / filtres ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip {
    flex: 0 0 auto; border: 2px solid var(--line); background: #fff; border-radius: 999px;
    padding: 8px 14px; font-weight: 600; font-size: 14px; white-space: nowrap; transition: all .15s;
}
.chip.active { border-color: var(--ink); background: var(--ink); color: #fff; }
.chip .em { margin-right: 4px; }
.chip.cat.active { color: var(--ink); background: var(--chip, var(--pink)); border-color: var(--chip, var(--pink)); }

.filters { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.filters .row { display: flex; gap: 8px; align-items: center; }
.search {
    flex: 1; min-width: 0; border: 2px solid var(--line); border-radius: 999px; padding: 10px 16px; background: #fff; outline: none;
}
.filters .row select.select { flex: 0 1 auto; max-width: 48%; }
.search:focus { border-color: var(--pink-deep); }
select.select {
    border: 2px solid var(--line); border-radius: 999px; padding: 9px 14px; background: #fff; outline: none;
    -webkit-appearance: none; appearance: none; font-weight: 600;
}

/* ---------- Liste de dépenses ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.group-title { font-size: 13px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .05em; margin: 14px 4px 2px; }
.exp {
    display: flex; align-items: center; gap: 12px;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 12px 14px; box-shadow: var(--shadow-sm); cursor: pointer; transition: transform .08s, box-shadow .15s;
    text-align: left; width: 100%;
}
.exp:active { transform: scale(.99); }
.exp .cat-ico {
    flex: 0 0 auto; width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center;
    font-size: 22px; background: var(--c, var(--bg-soft));
}
.exp .body { flex: 1; min-width: 0; }
.exp .lbl { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exp .meta { font-size: 13px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exp .amt { font-weight: 800; font-size: 17px; white-space: nowrap; }
.exp.is-paid .amt { color: var(--ink-soft); }
.exp .badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.badge.pending { background: var(--orange); color: #6a4300; }
.badge.paid { background: var(--green); color: #1f4a30; }
.exp .pic { font-size: 14px; margin-left: 4px; }
.exp .chk {
    flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--ink-faint);
    display: grid; place-items: center; font-size: 15px; color: #fff; transition: all .15s;
}
.exp.selected .chk { background: var(--green-deep); border-color: var(--green-deep); }
.exp.selected { border-color: var(--green-deep); background: #f4fbf6; }

.empty { text-align: center; padding: 40px 16px; color: var(--ink-soft); }
.empty .big { font-size: 48px; margin-bottom: 8px; }

/* ---------- Barre de paiement (parents) ---------- */
.paybar {
    position: sticky; bottom: calc(var(--nav-h) + var(--safe-b) + 8px); z-index: 15;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    background: var(--ink); color: #fff; border-radius: 999px; padding: 10px 10px 10px 20px;
    box-shadow: var(--shadow); margin-top: 14px;
}
.paybar .sum { font-weight: 800; font-size: 18px; }
.paybar .cnt { font-size: 13px; opacity: .7; margin-left: 6px; }
.selbar { display: flex; gap: 8px; align-items: center; margin: 4px 0 12px; flex-wrap: wrap; }

/* ---------- Paiements ---------- */
.pay {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
    box-shadow: var(--shadow-sm); cursor: pointer;
}
.pay .top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.pay .who { font-weight: 700; }
.pay .amt { font-weight: 800; font-size: 20px; color: #1f4a30; }
.pay .meta { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.pay .details { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.pay .details .row { display: flex; justify-content: space-between; font-size: 14px; gap: 10px; }
.pay .details .row span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Bilan ---------- */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.bar-row .lab { font-weight: 600; font-size: 14px; display: flex; gap: 6px; align-items: center; }
.bar-row .val { font-weight: 700; font-size: 14px; white-space: nowrap; }
.bar-row .track { grid-column: 1 / -1; height: 12px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 999px; background: var(--c, var(--pink-deep)); width: 0; transition: width .5s cubic-bezier(.2,.8,.2,1); }
.months { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; align-items: end; height: 160px; padding-top: 24px; }
.months .col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; position: relative; }
.months .stack { width: 100%; max-width: 28px; display: flex; flex-direction: column; justify-content: flex-end; border-radius: 8px 8px 4px 4px; overflow: hidden; height: 100%; }
.months .seg { width: 100%; }
.months .seg.paid { background: var(--green-deep); }
.months .seg.pend { background: var(--orange-deep); }
.months .m { font-size: 10px; color: var(--ink-soft); font-weight: 600; }
.months .v { position: absolute; top: -20px; font-size: 10px; font-weight: 700; color: var(--ink-soft); white-space: nowrap; }
.months .col.cur .m { color: var(--ink); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-soft); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: middle; }
.section { margin-bottom: 24px; }
.section h2 { font-size: 18px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }

/* ---------- Réglages ---------- */
.settings-user { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.settings-user .avatar { width: 56px; height: 56px; font-size: 28px; }
.settings-user .nm { font-size: 20px; font-weight: 800; }
.settings-user .rl { color: var(--ink-soft); font-size: 14px; }
.seg-ctl { display: inline-flex; background: var(--bg-soft); border-radius: 999px; padding: 4px; gap: 4px; }
.seg-ctl button { border: none; background: transparent; padding: 8px 16px; border-radius: 999px; font-weight: 700; color: var(--ink-soft); }
.seg-ctl button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }

/* ---------- Formulaires ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.field input, .field textarea, .field select {
    border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; background: #fff; outline: none;
    width: 100%; font-size: 16px;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--pink-deep); }
.field textarea { resize: vertical; min-height: 70px; }
.amount-field { display: flex; align-items: center; gap: 8px; }
.amount-field input { font-size: 34px; font-weight: 800; text-align: center; padding: 8px; border-radius: var(--radius); }
.amount-field .cur { font-size: 28px; font-weight: 800; color: var(--ink-faint); }
.form-error { color: var(--danger); font-weight: 600; margin: 0 0 12px; font-size: 14px; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.cat-btn {
    border: 2px solid transparent; background: var(--bg-soft); border-radius: 14px; padding: 10px 6px;
    display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; transition: all .12s;
}
.cat-btn .em { font-size: 24px; }
.cat-btn.active { background: var(--c, var(--pink)); border-color: var(--ink); transform: scale(1.03); }
.photo-zone { display: flex; align-items: center; gap: 12px; }
.photo-zone img { width: 72px; height: 72px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.photo-zone .btn { flex: 1; font-size: 14px; padding: 12px 10px; white-space: nowrap; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; align-items: center; }
.form-actions .btn-primary { flex: 1; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Bottom sheet / modale ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(58,46,57,.35); z-index: 40; animation: fade .18s; }
.sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
    background: #fff; border-radius: 24px 24px 0 0; padding: 12px 18px calc(18px + var(--safe-b));
    max-height: 92vh; overflow-y: auto; animation: up .22s cubic-bezier(.2,.8,.2,1);
    box-shadow: 0 -10px 40px rgba(58,46,57,.15);
}
.sheet::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { font-size: 20px; margin-bottom: 14px; }
.sheet .close-x { position: absolute; top: 12px; right: 14px; border: none; background: var(--bg-soft); width: 32px; height: 32px; border-radius: 50%; font-size: 18px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.detail-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.detail-head .cat-ico { width: 52px; height: 52px; border-radius: 16px; font-size: 26px; display: grid; place-items: center; background: var(--c, var(--bg-soft)); }
.detail-head .amt { font-size: 30px; font-weight: 800; }
.detail-rows { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; color: var(--ink-soft); font-size: 15px; }
.detail-rows b { color: var(--ink); }
.detail-photo img { width: 100%; border-radius: 14px; border: 1px solid var(--line); cursor: zoom-in; }

/* ---------- Toast, lightbox ---------- */
.toast {
    position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 84px); transform: translateX(-50%);
    background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 700; z-index: 60;
    box-shadow: var(--shadow); animation: up .2s; max-width: 90vw; text-align: center;
}
.toast.ok { background: var(--green-deep); color: #1f4a30; }
.toast.err { background: var(--danger); }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 70; display: grid; place-items: center; }
.lightbox img { max-width: 96vw; max-height: 92vh; border-radius: 8px; }
.lightbox-close { position: absolute; top: calc(12px + var(--safe-t)); right: 14px; border: none; background: rgba(255,255,255,.2); color: #fff; width: 40px; height: 40px; border-radius: 50%; font-size: 24px; }

/* ---------- Confettis ---------- */
.confetti { position: fixed; top: -10px; width: 8px; height: 12px; z-index: 80; pointer-events: none; animation: drop 1.4s ease-in forwards; border-radius: 2px; }
@keyframes drop { to { transform: translateY(105vh) rotate(720deg); opacity: .2; } }

/* ---------- Connexion ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; background: linear-gradient(160deg, #fff 0%, #fff6f8 50%, #f3fbf6 100%); }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 28px; padding: 32px 28px; box-shadow: var(--shadow); text-align: center; }
.login-logo { display: flex; align-items: center; justify-content: center; gap: 2px; }
.login-logo h1 { font-size: 40px; margin-left: 8px; }
.login-logo .blob { width: 18px; height: 18px; }
.login-tagline { color: var(--ink-soft); margin: 4px 0 24px; }
.login-card form { text-align: left; }
.login-lang { margin: 18px 0 0; font-size: 14px; }
.login-lang a { color: var(--ink-soft); text-decoration: underline; }

/* ---------- Desktop ---------- */
@media (min-width: 900px) {
    body { padding-bottom: 40px; background: var(--bg-soft); }
    .nav-desktop { display: flex; }
    .nav-mobile { display: none; }
    .app { padding: 28px 24px 60px; }
    .fab { bottom: 32px; right: 32px; }
    .paybar { bottom: 20px; }
    .toast { bottom: 40px; }
    .summary { grid-template-columns: repeat(3, 1fr); }
    .card.big { grid-column: auto; flex-direction: column; align-items: flex-start; }
    .card.big .card-value { font-size: 32px; }
    .sheet {
        left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%);
        width: 560px; max-height: 88vh; border-radius: 24px; padding: 22px 26px 26px;
        animation: pop .18s cubic-bezier(.2,.8,.2,1);
    }
    .sheet::before { display: none; }
    @keyframes pop { from { transform: translate(-50%, -48%) scale(.97); opacity: 0; } to { transform: translate(-50%, -50%); opacity: 1; } }
    .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
    .filters { flex-direction: row; align-items: center; justify-content: space-between; }
    .filters .chips { padding: 0; }
    .exp { padding: 14px 18px; }
    .exp:hover { box-shadow: var(--shadow); }
    .months { height: 220px; }
    .months .m { font-size: 12px; }
    .months .v { font-size: 11px; }
    .cat-grid { grid-template-columns: repeat(5, 1fr); }
}
