/* Dépenses du foyer — même base que le site des factures.
   Téléphone d'abord, une colonne, gros éléments tactiles ; clair et sombre selon le téléphone */
:root {
  --fond: #f5f6f8; --carte: #ffffff; --texte: #1d2330; --discret: #5d6675; --bord: #d9dde4;
  --accent: #1a7f5a; --accent-texte: #ffffff; --alerte-fond: #fff4e5; --alerte: #8a4b00;
  --info-fond: #e6f4ee; --erreur: #b3261e; --rayon: 12px;
}
@media (prefers-color-scheme: dark) {
  :root { --fond: #12151b; --carte: #1c212a; --texte: #e8ebf0; --discret: #9aa3b2; --bord: #2f3642;
          --accent: #4cc38a; --accent-texte: #0b2118; --alerte-fond: #3a2a12; --alerte: #ffc27a; --info-fond: #15302a; --erreur: #ff8a80; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--fond); color: var(--texte); }
a { color: var(--accent); }
main { max-width: 760px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.5rem; margin: 8px 0 16px; overflow-wrap: anywhere; }
h2 { font-size: 1.15rem; margin: 20px 0 10px; }

.barre { position: sticky; top: 0; z-index: 5; background: var(--carte); border-bottom: 1px solid var(--bord);
         box-shadow: 0 1px 6px rgba(0, 0, 0, .06); }
.barre-haut, .onglets { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.barre-haut { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; padding-bottom: 6px; }
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.2rem; text-decoration: none; color: var(--texte); }
.logo svg { color: var(--accent); }
.barre .ajouter { min-height: 40px; padding: 6px 16px; border-radius: 999px; gap: 6px; transition: transform .15s, box-shadow .15s; }
/* Onglets : défilent horizontalement sur petit écran au lieu de passer à la ligne */
.onglets { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
           -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); }
.barre-actions { display: flex; align-items: center; gap: 10px; }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%;
          background: var(--info-fond); color: var(--accent); font-weight: 700; text-decoration: none; border: 2px solid transparent; }
.avatar.actif, .avatar:hover { border-color: var(--accent); }
.onglets::-webkit-scrollbar { display: none; }
.onglets a { flex: 0 0 auto; padding: 10px 10px 9px; color: var(--discret); text-decoration: none; font-weight: 600; font-size: .95rem;
             border-bottom: 3px solid transparent; white-space: nowrap; }
.onglets a:hover { color: var(--texte); }
.onglets a.actif { color: var(--accent); border-bottom-color: var(--accent); }
footer { text-align: center; color: var(--discret); font-size: .9rem; padding: 24px 16px 40px; }

.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 16px; margin-bottom: 16px; }
.connexion { max-width: 420px; margin: 10vh auto 0; }

label { display: block; margin: 0 0 12px; font-weight: 600; font-size: .95rem; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 12px; font: inherit; font-weight: 400;
  color: var(--texte); background: var(--fond); border: 1px solid var(--bord); border-radius: 10px; min-height: 48px; }
input[type=file] { padding: 10px; }
textarea { min-height: 80px; }
.bouton { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 10px 18px;
  border-radius: 10px; border: 1px solid var(--bord); background: var(--carte); color: var(--texte); font: inherit;
  font-weight: 600; text-decoration: none; cursor: pointer; }
.bouton.principal { background: var(--accent); color: var(--accent-texte); border-color: var(--accent); }
.barre .bouton { min-height: 40px; padding: 6px 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.lien-danger { background: none; border: 0; color: var(--erreur); font: inherit; text-decoration: underline; cursor: pointer; padding: 8px 0; }
.danger { margin-top: 24px; text-align: center; }

.recherche { margin-bottom: 12px; }
.recherche input[type=search] { font-size: 1.05rem; }
details { margin: 12px 0; }
summary { cursor: pointer; font-weight: 600; padding: 8px 0; }
.filtres { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 640px) { .filtres { grid-template-columns: 1fr 1fr; } }

.resume { margin: 8px 0 12px; }
.exports { display: block; margin-top: 4px; font-size: .95rem; }
.vide { color: var(--discret); text-align: center; padding: 16px 0; }

.factures { list-style: none; margin: 0; padding: 0; }
.factures li a { display: block; padding: 14px 16px; margin-bottom: 8px; background: var(--carte); border: 1px solid var(--bord);
  border-radius: var(--rayon); text-decoration: none; color: var(--texte); }
.ligne1 { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; }
.fournisseur { overflow-wrap: anywhere; }
.montant { white-space: nowrap; font-variant-numeric: tabular-nums; }
.ligne2 { display: block; color: var(--discret); font-size: .92rem; margin-top: 2px; }

.gros { font-size: 1.8rem; font-weight: 700; margin: 0 0 12px; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 12px; }
dt { color: var(--discret); }
dd { margin: 0; overflow-wrap: anywhere; }
.notes { white-space: pre-wrap; }
.document { display: block; width: 100%; border: 1px solid var(--bord); border-radius: var(--rayon); background: #fff; }
.document + .document { margin-top: 8px; }

.info, .alerte, .erreur { padding: 12px 14px; border-radius: 10px; }
.info { background: var(--info-fond); }
.alerte { background: var(--alerte-fond); color: var(--alerte); }
.erreur { color: var(--erreur); border: 1px solid var(--erreur); }
.aide { color: var(--discret); font-size: .92rem; }

table { width: 100%; border-collapse: collapse; background: var(--carte); border-radius: var(--rayon); overflow: hidden; }
td { padding: 10px 12px; border-bottom: 1px solid var(--bord); }
td.n { color: var(--discret); text-align: right; width: 3em; }
td.montant { text-align: right; }
.annees { display: flex; flex-wrap: wrap; gap: 8px; }

.valeurs { list-style: none; margin: 0 0 12px; padding: 0; }
.valeurs li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--bord); }
.valeurs form { margin: 0; }
.ajout { display: flex; gap: 8px; }
.ajout input { margin: 0; }
small { color: var(--discret); }

.a-verifier { color: var(--alerte); }
form.alerte { display: block; }
form.alerte .bouton { margin: 8px 0 0; }

/* L'attribut hidden doit toujours masquer, même les champs stylés en display:block */
[hidden] { display: none !important; }

/* Bulles de montants trouvés dans le document */
.bulles { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 14px; }
.bulle { min-height: 40px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--bord); background: var(--carte);
  color: var(--texte); font: inherit; font-size: .95rem; font-weight: 600; cursor: pointer; font-variant-numeric: tabular-nums; }
.bulle small { font-weight: 400; color: var(--discret); margin-left: 4px; }
.bulle.choisie { background: var(--accent); border-color: var(--accent); color: var(--accent-texte); }
.bulle.choisie small { color: var(--accent-texte); }

/* Zone de dépôt de document (ajout d'une facture) */
.depot { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 160px; margin: 8px 0 20px; padding: 20px 16px; text-align: center; font-weight: 400; cursor: pointer;
  border: 2px dashed var(--bord); border-radius: var(--rayon); background: var(--fond); transition: border-color .15s, background .15s; }
.depot input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.depot:hover, .depot.survol { border-color: var(--accent); background: var(--info-fond); }
.depot.rempli { border-style: solid; border-color: var(--accent); }
.depot-icone { color: var(--accent); }
.depot-texte { color: var(--discret); }
.depot-texte strong { color: var(--texte); }
.depot-fichier { font-weight: 600; color: var(--accent); overflow-wrap: anywhere; }
.depot:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Fiche : flèche de retour, panneaux des factures proches à faire défiler horizontalement */
.fiche-haut { display: flex; align-items: center; gap: 12px; margin: 4px 0 12px; }
.rond { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: 0 0 44px;
          border-radius: 50%; border: 1px solid var(--bord); background: var(--carte); color: var(--texte); }
.rond:hover { border-color: var(--accent); color: var(--accent); }
.compteur { margin: 0; color: var(--discret); }
.panneaux { display: flex; flex-direction: column; }
.comparaison { position: relative; }
.echanger { position: absolute; z-index: 3; transform: translate(-50%, -50%); display: inline-flex; align-items: center; justify-content: center;
            width: 52px; height: 52px; border-radius: 50%; border: 0; cursor: pointer; background: var(--accent); color: var(--accent-texte);
            box-shadow: 0 2px 10px rgba(0, 0, 0, .25); transition: top .2s, left .3s; }
.echanger:hover { filter: brightness(1.1); }
.echanger:focus-visible { outline: 3px solid var(--texte); outline-offset: 2px; }
/* Plusieurs factures : grille d'une rangée de panneaux ; les encarts (1re ligne) ont la même hauteur
   et les documents (2e ligne) commencent à la même hauteur grâce à subgrid. Défilement par les flèches uniquement. */
.panneaux.plusieurs { display: grid; grid-auto-flow: column; grid-auto-columns: 86%; grid-template-rows: auto auto;
                      column-gap: 24px; overflow-x: hidden; }
@media (min-width: 900px) { .panneaux.plusieurs { grid-auto-columns: 70%; } }
.panneaux.plusieurs .panneau { display: grid; grid-row: span 2; grid-template-rows: subgrid; transition: opacity .25s, transform .25s; }
.panneaux.plusieurs .panneau > .carte { margin-bottom: 0; display: flex; flex-direction: column; }
.panneaux.plusieurs .panneau > .carte .actions { margin-top: auto; padding-top: 8px; }
.documents { padding-top: 12px; min-width: 0; }
.panneau.disparait { opacity: 0; transform: scale(.96); }
.etiquette { font-size: .9rem; font-weight: 400; color: var(--discret); }
.bandeau-verifier { margin-bottom: 12px; }
.bandeau-verifier .bouton { display: flex; margin-top: 8px; }
.bouton.danger-plein { color: var(--erreur); border-color: var(--erreur); background: transparent; }
.bouton.danger-plein:hover { background: var(--erreur); color: var(--accent-texte); }

/* Fiche : parcours de la liste (précédente / suivante) */
.fiche-haut { justify-content: space-between; }
.parcours { display: flex; align-items: center; gap: 10px; }
.position { color: var(--discret); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rond.inactif { opacity: .3; }

/* Statut : vérifiée / à vérifier / doublon possible */
.statut { display: inline-block; align-self: flex-start; margin: 0 0 8px; padding: 2px 10px; border-radius: 999px; font-size: .85rem; font-weight: 600; }
.factures .statut { margin: 6px 0 0; }
.statut-ok { background: #e3f4e8; color: #1e6b34; }
.statut-verifier { background: var(--alerte-fond); color: var(--alerte); }
.statut-doublon { background: #fde7e9; color: #a1222f; }
@media (prefers-color-scheme: dark) {
  .statut-ok { background: #173523; color: #8fd9a8; }
  .statut-doublon { background: #3d1a1e; color: #ff9aa5; }
}
.coche { color: #1e8e3e; font-weight: 700; }
.nb-filtres { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px; margin-left: 4px;
              border-radius: 999px; background: var(--accent); color: var(--accent-texte); font-size: .8rem; }
.statut-acompte { background: #ece6fb; color: #5b3aa8; }
@media (prefers-color-scheme: dark) { .statut-acompte { background: #2a2140; color: #c9b6ff; } }
.pastilles { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.pastilles .statut { margin: 0; }
.factures .statut + .statut { margin-left: 6px; }
label.case { display: flex; align-items: center; gap: 10px; min-height: 48px; cursor: pointer; }
label.case input { width: 22px; height: 22px; min-height: 0; margin: 0; flex: 0 0 22px; }

/* « Importer » accepte un document glissé : il s'anime dès qu'un fichier est tiré au-dessus de la page */
body.glisse .ajouter { box-shadow: 0 0 0 4px var(--info-fond), 0 0 0 6px var(--accent); animation: appel 1s ease-in-out infinite; }
.ajouter.cible { transform: scale(1.1); animation: none !important; }
.ajouter.occupe, .depot.occupe { opacity: .7; pointer-events: none; cursor: progress; }
@keyframes appel { 50% { transform: scale(1.06); } }

/* Liste groupée par jour : petite date en en-tête, factures du jour dans un même bloc */
.jour { margin: 0 0 14px; }
.jour-titre { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 18px 4px 6px;
              font-size: .78rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--discret); }
.jour-total { font-variant-numeric: tabular-nums; text-transform: none; letter-spacing: 0; }
.factures.groupe { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); overflow: hidden; }
.factures.groupe li a { margin: 0; border: 0; border-radius: 0; border-top: 1px solid var(--bord); }
.factures.groupe li:first-child a { border-top: 0; }
.factures.groupe li a:hover { background: var(--fond); }

/* Page Importer : deux sous-onglets (une facture / import en masse), en contrôle segmenté */
.sous-onglets { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 0 0 18px;
                background: var(--fond); border: 1px solid var(--bord); border-radius: 14px; }
.sous-onglets a { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 8px 12px;
                  border-radius: 10px; color: var(--discret); font-weight: 600; text-decoration: none; white-space: nowrap;
                  transition: background .15s, color .15s, box-shadow .15s; }
.sous-onglets a:hover { color: var(--texte); background: var(--carte); }
.sous-onglets a.actif { background: var(--carte); color: var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 0 0 1px var(--bord); }
.sous-onglets a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.barre .ajouter.actif { box-shadow: 0 0 0 3px var(--info-fond); }

/* Synthèse : carte d'export */
.exports-carte h2 { margin-top: 0; }
.exports-carte .bouton { gap: 8px; }

/* Saisie d'une facture avec l'aperçu du document : côte à côte sur grand écran (aperçu fixe pendant le défilement),
   l'un sous l'autre sur téléphone */
main.large { max-width: 1240px; }
.saisie { display: grid; gap: 16px; }
.saisie > .carte { margin-bottom: 0; }
.apercu-doc .aide { margin: 0 0 8px; }
@media (min-width: 960px) {
  .saisie.avec-apercu { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); align-items: start; }
  .apercu-doc { position: sticky; top: 112px; max-height: calc(100vh - 128px); overflow-y: auto; padding-right: 4px; }
}

/* Résumé d'une ligne (liste : tronqué ; fiche : en entier) */
.resume-ligne { display: block; color: var(--texte); font-size: .92rem; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resume-fiche { margin: -6px 0 12px; color: var(--texte); }
.mots-cles { color: var(--discret); font-size: .92rem; }

/* ---------------------------------------------------------------- Dépenses : couleurs du budget */
:root { --vert: #1e8e3e; --orange: #c26a00; --rouge: #c5221f; --vert-fond: #e3f4e8; --courses-fond: #eceff3; --courses: #4a5568; }
@media (prefers-color-scheme: dark) {
  :root { --vert: #6fd08f; --orange: #ffb35c; --rouge: #ff8a80; --vert-fond: #173523; --courses-fond: #2a303b; --courses: #b8c0cc; }
}
.vert { color: var(--vert); } .orange { color: var(--orange); } .rouge { color: var(--rouge); } .discret { color: var(--discret); }
.centre { text-align: center; }
.vert-fond { background: var(--vert); } .rouge-fond { background: var(--rouge); }

/* En-tête du mois : flèches de part et d'autre */
.mois-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 12px; }
.mois-nav h1 { margin: 0; text-align: center; flex: 1; }

/* Jauge du budget annexe */
.jauge-titre { margin: 0; color: var(--discret); font-weight: 600; font-size: .9rem; text-transform: uppercase; letter-spacing: .04em; }
.jauge-chiffres { margin: 4px 0 12px; font-variant-numeric: tabular-nums; }
.jauge-chiffres strong { font-size: 2rem; }
.jauge-chiffres span { color: var(--discret); }
.barre-budget { position: relative; height: 16px; border-radius: 999px; background: var(--fond); border: 1px solid var(--bord); overflow: visible; }
.barre-budget .rempli { height: 100%; border-radius: 999px; background: var(--vert); transition: width .4s; }
.jauge-avance .rempli { background: var(--orange); }
.jauge-depasse .rempli { background: var(--rouge); }
.jauge-depasse .jauge-chiffres strong { color: var(--rouge); }
/* Repère du rythme attendu au jour J */
.barre-budget .repere { position: absolute; top: -5px; bottom: -5px; width: 3px; margin-left: -1.5px; border-radius: 2px; background: var(--texte); opacity: .55; }
.jauge-details { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 4px; }
.courses-ligne { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--bord); color: var(--discret); }
.courses-ligne strong { color: var(--texte); font-variant-numeric: tabular-nums; }

/* Saisie rapide */
.ajout-rapide summary { padding: 0; font-size: 1.05rem; }
.ajout-rapide[open] summary { margin-bottom: 12px; }
.deux { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 380px) { .deux { grid-template-columns: 1fr; } }

/* Choix grosses courses / annexe en contrôle segmenté */
.genre { border: 0; margin: 0 0 8px; padding: 0; min-width: 0; }
.genre legend { font-weight: 600; font-size: .95rem; margin-bottom: 4px; padding: 0; }
.segments { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--fond); border: 1px solid var(--bord); border-radius: 14px; }
.segments label { margin: 0; position: relative; }
.segments input { position: absolute; opacity: 0; pointer-events: none; }
.segments span { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 52px; padding: 6px 8px;
                 border-radius: 10px; text-align: center; cursor: pointer; color: var(--discret); line-height: 1.2; }
.segments small { font-weight: 400; font-size: .78rem; }
.segments input:checked + span { background: var(--carte); color: var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 0 0 1px var(--bord); }
.segments input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.genre .raison { min-height: 1.3em; margin: 6px 2px 0; }

/* Liste du mois : chaque dépense porte son type, modifiable d'un toucher */
.depense { position: relative; }
.depense > a { padding-right: 16px; }
.depense .bascule { position: absolute; right: 12px; bottom: 10px; margin: 0; }
.depense .ligne2 { padding-right: 150px; min-height: 1.4em; }
.depense > a { padding-bottom: 16px; }
.depense .bascule .statut { margin: 0; border: 0; cursor: pointer; font: inherit; font-size: .8rem; font-weight: 600; }
.statut-annexe { background: var(--info-fond); color: var(--accent); }
.statut-courses { background: var(--courses-fond); color: var(--courses); }
.statut .auto { font-weight: 400; opacity: .7; margin-left: 2px; }
.depense-courses .fournisseur, .depense-courses .montant { color: var(--discret); }
.depense.nouvelle > a { animation: surligne 2.5s ease-out; }
@keyframes surligne { from { background: var(--info-fond); } }

/* Synthèse */
.tableau { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tableau th, .tableau td { padding: 8px 4px; border-bottom: 1px solid var(--bord); text-align: left; vertical-align: top; }
.tableau th { color: var(--discret); font-size: .85rem; font-weight: 600; }
.tableau .nombre { text-align: right; white-space: nowrap; }
.mini-barre { height: 5px; margin-top: 4px; border-radius: 999px; background: var(--fond); overflow: hidden; max-width: 160px; }
.mini-barre div { height: 100%; }
.annees { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.annees .bulle { display: inline-flex; align-items: center; text-decoration: none; }

/* Ticket : appareil photo direct ou choix d'un fichier (photo / PDF) ; le champ fichier est caché dans son bouton */
.choix-ticket { display: grid; gap: 10px; width: 100%; max-width: 360px; }
.choix-ticket .bouton, .photo-rapide .bouton { position: relative; margin: 0; cursor: pointer; gap: 8px; }
.depot .choix-ticket input[type=file], .photo-rapide input[type=file] { position: absolute; inset: auto; width: 1px; height: 1px; min-height: 0; padding: 0; opacity: 0; pointer-events: none; }
.choix-ticket .bouton:focus-within, .photo-rapide .bouton:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.depot { cursor: default; }
.photo-rapide { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin: 0 0 16px; }
.photo-rapide .bouton.occupe { opacity: .7; pointer-events: none; }
@media (max-width: 380px) { .photo-rapide { grid-template-columns: 1fr; } }

/* Connexion avec Google (bouton blanc, logo en couleurs), mot de passe en secours */
.bouton.google { display: flex; width: 100%; gap: 10px; margin: 4px 0 8px; background: #fff; color: #1f1f1f; border-color: #747775; }
.bouton.google:hover { background: #f2f2f2; }
.connexion .mdp summary { color: var(--discret); font-weight: 600; text-align: center; }

/* Banque */
.operation { padding: 12px 16px; border-top: 1px solid var(--bord); }
.factures.groupe li:first-child .operation { border-top: 0; }
.operation .ligne2 { overflow-wrap: anywhere; }
.usage-compte select { min-height: 40px; padding: 6px 10px; margin: 0; width: auto; }
.valeurs li > span { min-width: 0; overflow-wrap: anywhere; }
