/* Gestion des comptes : style minimaliste et intuitif, mode sombre par défaut (réglable dans les Préférences), comme Actions. */

:root {
    color-scheme: light;
    --fond: #f6f7f6; --carte: #ffffff; --encre: #15181a; --doux: #687076; --ligne: #e3e6e4; --champ: #ffffff;
    --accent: #0f8a66; --accent-doux: #dcf2ea; --sur-accent: #ffffff;
    --positif: #12805c; --negatif: #c2412d; --attention: #a86a12;
    --alerte: #c2412d; --alerte-doux: #fbe9e6;
    --rayon: 14px;
    /* Graphiques (assets/graphiques.js lit ces variables au moment du dessin). */
    --graphe-1: #2f6fdb; --graphe-2: #e2772b; --graphe-3: #0f8a66; --graphe-4: #8a63d2; --graphe-5: #c9a31c; --graphe-6: #d1477a;
    --graphe-7: #138fa3; --graphe-8: #7a8a2c;
    --graphe-positif: #18a070; --graphe-negatif: #d4513c; --graphe-neutre: #9aa3a9; --graphe-voile: rgba(47, 111, 219, .14);
}
[data-theme="sombre"] {
    color-scheme: dark;
    --fond: #0e1113; --carte: #161a1d; --encre: #e9eef0; --doux: #8b959c; --ligne: #252b2f; --champ: #1b2024;
    --accent: #4fd1a5; --accent-doux: #12312a; --sur-accent: #0b1512;
    --positif: #4fd1a5; --negatif: #f07a63; --attention: #f0b44c;
    --alerte: #f07a63; --alerte-doux: #3a1f1a;
    --graphe-1: #6b9bff; --graphe-2: #f59a52; --graphe-3: #4fd1a5; --graphe-4: #a98bfa; --graphe-5: #ecc94b; --graphe-6: #f27aa6;
    --graphe-7: #4cc3d9; --graphe-8: #b4c55a;
    --graphe-positif: #4fd1a5; --graphe-negatif: #f07a63; --graphe-neutre: #5d676e; --graphe-voile: rgba(107, 155, 255, .16);
}

* { box-sizing: border-box; }
html { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fond); color: var(--encre); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body.avec-navigation { padding-bottom: calc(5rem + env(safe-area-inset-bottom)); }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
main { max-width: 640px; margin: 0 auto; padding: calc(1.25rem + env(safe-area-inset-top)) 1rem 2rem; }
h1 { font-size: 1.7rem; line-height: 1.15; margin: .25rem 0; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
.sous-titre { color: var(--doux); margin: 0 0 1.25rem; }
.details { color: var(--doux); font-size: .9rem; margin: .6rem 0 0; }
.centre { text-align: center; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.flash { margin: 0 0 1rem; padding: .7rem .9rem; border-radius: var(--rayon); background: var(--accent-doux); color: var(--accent); font-weight: 500; }
.flash-erreur { background: var(--alerte-doux); color: var(--alerte); }
.vide { margin: 1rem 0; padding: 1.5rem 1rem; text-align: center; color: var(--doux); border: 1px dashed var(--ligne); border-radius: var(--rayon); }
.negatif { color: var(--negatif); }
.positif { color: var(--positif); }
.hausse { color: var(--positif); }
.baisse { color: var(--negatif); }

.entete { display: flex; align-items: flex-start; gap: .75rem; }
.entete > div { flex: 1; min-width: 0; }
.entete .sous-titre { margin-bottom: 1rem; }

/* Barre de navigation : boutons d'émoji, en bas de l'écran (à portée de pouce). */
.navigation { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: center; gap: .25rem;
              padding: .5rem .75rem calc(.5rem + env(safe-area-inset-bottom)); background: var(--carte); border-top: 1px solid var(--ligne); }
.onglet { flex: 1; max-width: 5rem; display: flex; align-items: center; justify-content: center; height: 3rem; border-radius: 12px;
          font-size: 1.45rem; line-height: 1; text-decoration: none; filter: grayscale(.85); opacity: .7; transition: background .15s, opacity .15s, filter .15s; }
.onglet:hover, .onglet:focus-visible { opacity: 1; filter: none; }
.onglet[aria-current="page"] { background: var(--accent-doux); opacity: 1; filter: none; }

/* Cartes et boutons */
.panneau { margin: 0 0 1rem; padding: 1.1rem; background: var(--carte); border: 1px solid var(--ligne); border-radius: var(--rayon); }
.panneau h2 { margin: 0 0 .8rem; font-size: 1.1rem; }
.panneau h3 { font-size: 1rem; margin: 0; }
.bouton { display: inline-block; border: 0; border-radius: 999px; padding: .65rem 1.4rem; background: var(--accent); color: var(--sur-accent);
          font-weight: 700; text-decoration: none; text-align: center; }

/* Filtres (formulaire GET qui se renvoie à chaque choix). */
.filtres { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1rem; }
.filtres select { flex: 1 1 10rem; min-width: 0; padding: .55rem .7rem; border: 1px solid var(--ligne); border-radius: 12px; background: var(--champ); color: var(--encre); }
.filtres select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* 💰 Soldes : le total, puis un compte par ligne (toute la ligne mène à ses opérations). */
.total { margin: 0 0 1.1rem; padding: 1.1rem 1.2rem; border-radius: var(--rayon); background: var(--accent-doux); }
.total-libelle { display: block; color: var(--doux); font-size: .85rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.total-valeur { display: block; font-size: 2.2rem; line-height: 1.15; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.total-details { display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin: .4rem 0 0; padding: 0; list-style: none; color: var(--doux); font-size: .9rem; }
.total-details strong { color: var(--encre); font-variant-numeric: tabular-nums; }
.comptes { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .45rem; }
.compte { display: flex; align-items: center; gap: .75rem; padding: .7rem .85rem; background: var(--carte); border: 1px solid var(--ligne); border-radius: 12px;
          text-decoration: none; transition: border-color .15s; }
.compte:hover, .compte:focus-visible { border-color: var(--accent); }
.compte-emoji, .operation-emoji, .mensualite-emoji { flex: none; width: 2.3rem; height: 2.3rem; display: flex; align-items: center; justify-content: center;
                                                     border-radius: 10px; background: var(--fond); font-size: 1.25rem; line-height: 1; }
.compte-texte, .operation-texte, .mensualite-texte { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.compte-nom, .operation-libelle, .mensualite-nom { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compte-details, .operation-details, .mensualite-details { color: var(--doux); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compte-solde { flex: none; display: flex; flex-direction: column; align-items: flex-end; }
.compte-montant { font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.compte-montant.inconnu { color: var(--doux); }
.compte-date { color: var(--doux); font-size: .78rem; white-space: nowrap; }
.legende { list-style: none; margin: 0; padding: 0; }
.legende li { display: flex; justify-content: space-between; gap: .75rem; padding: .4rem 0; border-bottom: 1px solid var(--ligne); }
.legende li:last-child { border-bottom: 0; }
.legende .valeur { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Chiffres clés (Comptes, Mensualités, Statistiques). */
.chiffres { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; margin: 0 0 1rem; }
.chiffres-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.chiffre { display: flex; flex-direction: column; gap: .1rem; padding: .8rem .9rem; background: var(--carte); border: 1px solid var(--ligne); border-radius: 12px; min-width: 0; }
.chiffre-libelle { color: var(--doux); font-size: .8rem; font-weight: 600; }
.chiffre-valeur { font-size: 1.3rem; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.chiffre-valeur small { font-size: .75rem; color: var(--doux); font-weight: 500; }
.chiffre-detail { color: var(--doux); font-size: .78rem; overflow-wrap: anywhere; }
.chiffre.alerte { border-color: var(--negatif); }
.chiffre.alerte .chiffre-valeur { color: var(--negatif); }
@media (max-width: 480px) { .chiffres-3 { grid-template-columns: 1fr; } .chiffres-3 .chiffre { flex-direction: row; flex-wrap: wrap; align-items: baseline; justify-content: space-between; } }

/* 📒 Opérations, jour par jour. */
.jour { margin: 0 0 1rem; }
.jour-titre { display: flex; justify-content: space-between; gap: .5rem; margin: 0 0 .4rem; padding: 0 .2rem; color: var(--doux); font-size: .85rem; font-weight: 600; }
.jour-total { font-variant-numeric: tabular-nums; }
.operations, .mensualites, .top { list-style: none; margin: 0; padding: 0; background: var(--carte); border: 1px solid var(--ligne); border-radius: 12px; overflow: hidden; }
.operation, .mensualite, .top li { display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem; }
.operation + .operation, .mensualite + .mensualite, .top li + li { border-top: 1px solid var(--ligne); }
.operation.virement { opacity: .75; }
.operation-notes, .mensualite-notes { color: var(--doux); font-size: .78rem; white-space: pre-line; }
.operation-montant { flex: none; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* 🔁 Mensualités */
.mensualites { margin-bottom: 1rem; }
.mensualite-prochaine { color: var(--doux); font-size: .8rem; }
.mensualite-prochaine.bientot { color: var(--attention); font-weight: 600; }
.mensualite-montant { flex: none; display: flex; flex-direction: column; align-items: flex-end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mensualite-par-mois { color: var(--doux); font-size: .78rem; }
.mensualite.inactive { opacity: .6; }
.arretees > summary { width: fit-content; color: var(--doux); font-weight: 600; cursor: pointer; margin: .5rem 0 .6rem; }

/* 📊 Statistiques */
.stats-section { margin: 1.5rem 0 0; }
.stats-section > h2 { font-size: 1.15rem; margin: 0 0 .7rem; }
.graphique-carte .details { margin: .2rem 0 .8rem; }
.graphique { position: relative; width: 100%; }
.graphique-vide { margin: 0; padding: 1.2rem; text-align: center; color: var(--doux); border: 1px dashed var(--ligne); border-radius: 10px; }
.donnees { margin: .8rem 0 0; }
.donnees > summary { width: fit-content; color: var(--doux); font-size: .85rem; cursor: pointer; }
.donnees table, .tableau { width: 100%; margin: .5rem 0 0; border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums; }
.donnees th, .donnees td, .tableau th, .tableau td { padding: .35rem .3rem; text-align: right; border-bottom: 1px solid var(--ligne); }
.donnees th[scope="row"], .tableau th[scope="row"], .tableau thead th:first-child { text-align: left; font-weight: 500; }
.tableau thead th { color: var(--doux); font-weight: 600; }
.top { padding: 0; }

/* Préférences */
.choix-theme { border: 0; margin: 0 0 1rem; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.option-theme { display: flex; align-items: center; gap: .6rem; padding: .8rem .9rem; border: 1px solid var(--ligne); border-radius: 12px; background: var(--champ); font-weight: 600; cursor: pointer; }
.option-theme:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.option-theme input { accent-color: var(--accent); width: 1.1rem; height: 1.1rem; margin: 0; }
.application-android ol { margin: .9rem 0 0; padding-left: 1.2rem; color: var(--doux); font-size: .95rem; }
.application-android li + li { margin-top: .25rem; }
@media (max-width: 420px) { .choix-theme { grid-template-columns: 1fr; } .panneau .bouton { width: 100%; } }

/* Connexion */
.connexion { max-width: 360px; margin: 3rem auto; text-align: center; }
.connexion .logo { font-size: 3rem; margin: 0; line-height: 1; }
.connexion label { display: block; text-align: left; font-weight: 600; margin: 1.25rem 0 .35rem; }
.connexion input[type="password"] { width: 100%; font-size: 1.1rem; padding: .8rem .9rem; border: 1px solid var(--ligne); border-radius: 12px; background: var(--champ); color: var(--encre); }
.connexion input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.connexion .bouton { width: 100%; margin-top: 1.25rem; padding: .85rem; font-size: 1.05rem; }
.erreur { margin: 1rem 0 0; padding: .7rem .9rem; border-radius: 12px; background: var(--alerte-doux); color: var(--alerte); font-weight: 500; }

/* Fenêtre de confirmation (déconnexion) : centrée, ou en bas de l'écran sur téléphone. */
dialog.confirmation { width: min(92vw, 360px); padding: 1.3rem; border: 1px solid var(--ligne); border-radius: 18px; background: var(--carte); color: var(--encre); }
dialog.confirmation::backdrop { background: rgba(0, 0, 0, .55); }
.confirmation-titre { font-size: 1.2rem; margin: 0 0 .35rem; }
.confirmation p { margin: 0 0 1.2rem; color: var(--doux); }
.confirmation-boutons { display: flex; gap: .6rem; justify-content: flex-end; }
.confirmation-boutons > * { min-height: 2.75rem; padding: .6rem 1.1rem; border-radius: 12px; font-weight: 600;
                            display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.confirmation .annuler { background: var(--champ); border: 1px solid var(--ligne); }
.confirmation .confirmation-oui { background: var(--alerte); color: #fff; border: 1px solid var(--alerte); }
@media (max-width: 480px) {
    dialog.confirmation { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 18px 18px 0 0; padding-bottom: calc(1.3rem + env(safe-area-inset-bottom)); }
    .confirmation-boutons { flex-direction: column-reverse; }
    .confirmation-boutons > * { width: 100%; }
}
