:root {
  --fond: #f5f2ea; --carte: #fff; --ligne: #e4ded0; --texte: #1f2a24; --pale: #6d7a72;
  --vert: #2f6b4f; --vert-pale: #e3efe8; --jaune: #fff4d6; --jaune-fonce: #8a6200; --rouge: #b3261e;
  --haut: env(safe-area-inset-top); --bas: env(safe-area-inset-bottom);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--fond); color: var(--texte); font: 16px/1.4 -apple-system, system-ui, "Segoe UI", sans-serif; }
body { min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
.chargement { text-align: center; color: var(--pale); padding-top: 40vh; }
h1 { font-size: 1.6rem; margin: 0; }
h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--pale); margin: 22px 4px 8px; font-weight: 700; display: flex; justify-content: space-between; }
.aide { color: var(--pale); font-size: .85rem; margin: 8px 4px; }
.vide { color: var(--pale); text-align: center; padding: 26px 16px; }
.msg { color: var(--rouge); margin: 10px 4px; }

/* connexion */
.login { max-width: 380px; margin: 0 auto; padding: calc(70px + var(--haut)) 16px 40px; text-align: center; }
.logo { width: 92px; height: 92px; border-radius: 22px; margin: 0 auto 14px; display: block; box-shadow: 0 6px 20px #2f6b4f33; }
.sous { color: var(--pale); margin: 4px 0 26px; }
.login .carte { text-align: left; }

/* structure */
.haut { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--haut)) 16px 10px; background: #f5f2eaee; backdrop-filter: blur(10px); border-bottom: 1px solid var(--ligne); }
.haut h1 { flex: 1; font-size: 1.25rem; }
.haut select { border: 1px solid var(--ligne); background: var(--carte); border-radius: 10px; padding: 6px 8px; font-weight: 600; }
.page { max-width: 600px; margin: 0 auto; padding: 12px 16px calc(96px + var(--bas)); }
.onglets { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; background: #ffffffee; backdrop-filter: blur(14px); border-top: 1px solid var(--ligne); padding-bottom: var(--bas); }
.onglets button { flex: 1; position: relative; background: none; border: 0; padding: 8px 0 7px; font-size: .7rem; color: var(--pale); display: flex; flex-direction: column; align-items: center; gap: 1px; }
.onglets .ico { font-size: 1.25rem; line-height: 1.3; }
.onglets .actif { color: var(--vert); font-weight: 700; }
.pastille { position: absolute; top: 3px; left: calc(50% + 8px); background: var(--rouge); color: #fff; border-radius: 9px; font-size: .65rem; padding: 1px 6px; font-style: normal; }

/* cartes et formulaires */
.carte { background: var(--carte); border: 1px solid var(--ligne); border-radius: 14px; padding: 14px; margin-bottom: 10px; }
label { display: block; font-size: .8rem; color: var(--pale); margin: 10px 0 4px; font-weight: 600; }
input, select, textarea { width: 100%; border: 1px solid var(--ligne); border-radius: 10px; padding: 10px 11px; background: #fff; font-size: 16px; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--vert); border-color: transparent; }
.case { display: flex; align-items: flex-start; gap: 10px; font-size: .92rem; color: var(--texte); font-weight: 400; margin: 12px 0 0; }
.case input { width: 22px; height: 22px; flex: none; margin: 0; accent-color: var(--vert); }
.deux { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn, .primaire, .secondaire, .danger { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 12px; padding: 12px 14px; font-weight: 600; border: 1px solid var(--ligne); background: #fff; cursor: pointer; text-decoration: none; color: var(--texte); }
.primaire { background: var(--vert); color: #fff; border-color: var(--vert); width: 100%; margin-top: 14px; }
.secondaire { width: 100%; margin-top: 8px; }
.danger { color: var(--rouge); width: 100%; margin-top: 8px; }
.lien { background: none; border: 0; color: var(--vert); font-weight: 600; padding: 6px; cursor: pointer; }
.gros { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }
.gros .btn { padding: 16px 10px; font-size: 1rem; }
.gros .btn.vert { background: var(--vert); color: #fff; border-color: var(--vert); }
.gros input[type=file] { display: none; }
.bandeau { background: var(--vert-pale); border-radius: 12px; padding: 10px 12px; margin: 10px 0; font-size: .9rem; display: flex; align-items: center; gap: 10px; }
.bandeau.jaune { background: var(--jaune); color: var(--jaune-fonce); }
.bandeau .lien { margin-left: auto; white-space: nowrap; }
.roue { width: 16px; height: 16px; border: 2px solid var(--vert); border-right-color: transparent; border-radius: 50%; animation: tourne .8s linear infinite; flex: none; }
@keyframes tourne { to { transform: rotate(360deg); } }

/* factures à vérifier */
.verif { display: grid; grid-template-columns: 74px 1fr; gap: 12px; }
.vignette { width: 74px; height: 96px; border-radius: 8px; border: 1px solid var(--ligne); object-fit: cover; background: #f0ede4; display: grid; place-items: center; font-size: .75rem; color: var(--pale); text-decoration: none; }
.verif .titre { font-weight: 700; display: flex; justify-content: space-between; gap: 8px; }
.verif .meta { color: var(--pale); font-size: .85rem; }
.doute { background: var(--jaune); color: var(--jaune-fonce); border-radius: 8px; padding: 6px 8px; font-size: .82rem; margin-top: 6px; }
.actions { display: flex; gap: 8px; margin-top: 10px; }
.actions .btn { flex: 1; padding: 9px 8px; font-size: .9rem; }
.actions .btn.vert { background: var(--vert); color: #fff; border-color: var(--vert); }

/* liste des dépenses confirmées */
.mois { background: var(--carte); border: 1px solid var(--ligne); border-radius: 14px; overflow: hidden; margin-bottom: 10px; }
.mois-titre { display: flex; justify-content: space-between; padding: 10px 14px; background: #faf8f3; font-weight: 700; border-bottom: 1px solid var(--ligne); }
.ligne { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 14px; border-bottom: 1px solid #f0ece2; cursor: pointer; }
.ligne:last-child { border-bottom: 0; }
.ligne .m { font-weight: 600; }
.ligne .s { color: var(--pale); font-size: .8rem; grid-column: 1; }
.ligne .montant { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.ligne.exclue { opacity: .5; }
.etiquette { display: inline-block; font-size: .7rem; border-radius: 6px; padding: 1px 6px; background: #f0ede4; color: var(--pale); margin-left: 4px; }

/* loyers */
.grille { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grille label { margin: 0 0 3px; }
.grille input { padding: 8px; text-align: right; font-variant-numeric: tabular-nums; }

/* sommaire */
.tableau { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tableau td { padding: 7px 2px; border-bottom: 1px solid #f0ece2; }
.tableau td:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tableau tr.total td { font-weight: 700; border-top: 2px solid var(--ligne); border-bottom: 0; }
.tableau tr.zero td { color: #b5bcb7; }

/* feuille d'édition (bas de l'écran) */
.voile { position: fixed; inset: 0; background: #0006; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.feuille { background: var(--fond); width: 100%; max-width: 600px; max-height: 92dvh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 16px 16px calc(20px + var(--bas)); }
.feuille .entete { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.feuille .entete h3 { margin: 0; font-size: 1.1rem; }
.apercu { display: block; width: 100%; max-height: 280px; object-fit: contain; border-radius: 10px; border: 1px solid var(--ligne); background: #fff; }
.dossiers button { display: block; width: 100%; text-align: left; background: #fff; border: 1px solid var(--ligne); border-radius: 10px; padding: 10px 12px; margin-top: 6px; }

#toast { position: fixed; left: 50%; bottom: calc(86px + var(--bas)); transform: translateX(-50%); background: #1f2a24; color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 40; max-width: 90vw; text-align: center; font-size: .92rem; }
