/* Escarcelle — feuille de style unique, sans framework.
   Grand public : textes lisibles (16 px), contrastes francs, couleurs douces. */

:root {
  --fond: #f4f3f9;
  --carte: #ffffff;
  --bord: #e3e0ee;
  --texte: #1b2130;
  --texte-2: #4f5668;      /* contraste AA sur blanc */
  --texte-3: #6b7285;
  --accent: #5b3fc4;
  --accent-clair: #efeafd;
  --vert: #1d7a46;
  --rouge: #b42318;
  --ambre: #b26b00;
  --bleu: #2f6fae;
  --rayon: 14px;
  --ombre: 0 1px 2px rgba(27, 33, 48, .04), 0 2px 10px rgba(27, 33, 48, .04);

  /* Couleurs de comptes : fond pastel + point */
  --sarcelle-f: #e2efee; --sarcelle-p: #1f6f78;
  --indigo-f:   #e7e8f7; --indigo-p:   #4850b5;
  --sable-f:    #f4ebe2; --sable-p:    #94632a;
  --rose-f:     #f6e6ee; --rose-p:     #b0457a;
  --vert-f:     #e4f2e6; --vert-p:     #2f7d3e;
  --ambre-f:    #fcf0da; --ambre-p:    #b97a10;

  font-family: "Inter", "Segoe UI", system-ui, -apple-system, "Noto Sans", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--texte);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--fond); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
button, input, select { font: inherit; color: inherit; }

.pos { color: var(--vert); }
.neg { color: var(--rouge); }
.montant { font-variant-numeric: tabular-nums; white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.centre { text-align: center; }
.nowrap { white-space: nowrap; }
.tronque { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail { font-size: 13.5px; color: var(--texte-2); }
.discret { color: var(--texte-3); }
.afficher-etroit { display: none; }
.vide { color: var(--texte-2); margin: 4px 0; }
.puce { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }

/* ------------------------------------------------------------------ en-tête */
.entete {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 18px;
  padding: 10px 22px; background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--bord); backdrop-filter: blur(6px);
}
.marque { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--texte); font-weight: 700; font-size: 20px; flex: none; }
.marque-centree { justify-content: center; margin-bottom: 18px; font-size: 24px; }

.menu { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.menu a {
  text-decoration: none; color: var(--texte-2); font-weight: 600; font-size: 15px;
  padding: 8px 14px; border-radius: 10px; white-space: nowrap;
}
.menu a:hover { background: var(--accent-clair); color: var(--accent); }
.menu a.actif { background: var(--accent); color: #fff; }

.entete-droite { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.bouton-rond {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--bord); color: var(--texte-2); background: #fff;
}
.bouton-rond:hover, .bouton-rond.actif { color: var(--accent); border-color: var(--accent); }
.utilisateur { position: relative; }
.utilisateur summary {
  list-style: none; cursor: pointer; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 700;
}
.utilisateur summary::-webkit-details-marker { display: none; }
.utilisateur-menu {
  position: absolute; right: 0; top: 48px; min-width: 220px; background: #fff;
  border: 1px solid var(--bord); border-radius: 12px; box-shadow: var(--ombre); padding: 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.utilisateur-menu small { color: var(--texte-2); margin-bottom: 8px; }
.utilisateur-menu button { border: 1px solid var(--bord); background: #fff; border-radius: 8px; padding: 7px; cursor: pointer; }
.utilisateur-menu button:hover { border-color: var(--rouge); color: var(--rouge); }

.menu-bascule, .menu-bouton { display: none; }

.bandeau { padding: 10px 22px; text-align: center; font-weight: 500; }
.bandeau a { font-weight: 700; }
.bandeau-essai { background: #fff6e0; color: #6b4600; }
.bandeau-lecture { background: #fde8e6; color: #7a1a12; }

/* ------------------------------------------------------------------ mise en page */
.contenu { flex: 1; width: 100%; max-width: 1500px; margin: 0 auto; padding: 20px 22px 32px; }
.titre-page { font-size: 26px; margin: 4px 0 18px; }
.pied { text-align: center; color: var(--texte-3); font-size: 13px; padding: 18px; }

.carte {
  background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon);
  box-shadow: var(--ombre); padding: 16px 18px; margin-bottom: 16px; min-width: 0;
}
.carte > h2 {
  font-size: 17px; padding-bottom: 10px; margin-bottom: 12px; border-bottom: 1px solid var(--bord);
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
}
.carte h3 { font-size: 15px; margin: 16px 0 8px; color: var(--texte-2); }
.lien-carte { font-size: 14px; font-weight: 600; color: var(--texte-2); text-decoration: none; white-space: nowrap; }
.lien-carte:hover { color: var(--accent); }

.rangee-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.rangee-2 > .carte { margin-bottom: 16px; }
.rangee-2.aligne-haut { align-items: start; }
.rangee-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.ligne-entre { display: flex; justify-content: space-between; gap: 10px; }

.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 500; word-break: break-word; }
.flash-info { background: #e8f0fb; color: #173f6b; }
.flash-succes { background: #e3f4e8; color: #134d2c; }
.flash-erreur { background: #fde8e6; color: #7a1a12; }

/* ------------------------------------------------------------------ tableau de bord */
.tdb { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 16px; align-items: start; }

.gros-montant { font-size: 34px; font-weight: 700; margin: 2px 0 6px; }
.gros-montant .montant:not(.neg) { color: var(--vert); }

.grille-comptes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grille-comptes-large { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin-bottom: 18px; }
.carte-compte {
  display: block; text-decoration: none; color: inherit; border-radius: 12px; padding: 16px 18px;
  background: var(--f); border: 1px solid transparent; transition: border-color .15s;
}
a.carte-compte:hover { border-color: var(--p); }
.compte-nom { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.point { width: 10px; height: 10px; border-radius: 50%; background: var(--p); flex: none; display: inline-block; }
.compte-solde { font-size: 26px; font-weight: 700; margin: 6px 0 4px; }
.carte-compte .detail strong { color: var(--texte); }

.c-sarcelle { --f: var(--sarcelle-f); --p: var(--sarcelle-p); }
.c-indigo   { --f: var(--indigo-f);   --p: var(--indigo-p); }
.c-sable    { --f: var(--sable-f);    --p: var(--sable-p); }
.c-rose     { --f: var(--rose-f);     --p: var(--rose-p); }
.c-vert     { --f: var(--vert-f);     --p: var(--vert-p); }
.c-ambre    { --f: var(--ambre-f);    --p: var(--ambre-p); }

.tuile { border: 1px solid var(--bord); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; background: var(--f, #faf9fd); }
.tuile small { color: var(--texte-2); font-size: 13.5px; }
.tuile strong { font-size: 20px; }
.variation { font-size: 12.5px; font-weight: 600; }
.variation.bon { color: var(--vert); }
.variation.mauvais { color: var(--rouge); }
.rangee-comptes { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }

.jauge { height: 8px; background: #ecebf2; border-radius: 4px; overflow: hidden; margin: 5px 0 3px; }
.jauge.fine { height: 5px; }
.jauge > div { height: 100%; border-radius: 4px; }
.jauge .rouge { background: var(--rouge); }
.jauge .ambre { background: #e09a1a; }
.jauge .bleu { background: var(--sarcelle-p); }
.jauge .point-couleur { background: var(--p, var(--accent)); }

.alertes, .top-categories, .echeances, .liste-simple, .liste-modules { list-style: none; margin: 0; padding: 0; }
.alertes li { margin-bottom: 10px; }
.alerte-tete { display: flex; align-items: center; font-weight: 600; }
.alerte-tete .badge { margin-left: auto; }
.top-categories li { margin-bottom: 10px; }

.badge { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 20px; background: #eeedf3; color: var(--texte-2); white-space: nowrap; }
.badge-rouge { background: #fde8e6; color: var(--rouge); }
.badge-ambre { background: #fff1d6; color: #8a5300; }
.badge-vert { background: #e3f4e8; color: var(--vert); }

.echeances li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid #efedf5; }
.echeances li:last-child { border-bottom: none; }
.pastille-date { width: 48px; flex: none; text-align: center; background: var(--accent-clair); color: var(--accent); border-radius: 10px; padding: 4px 0; line-height: 1.1; }
.pastille-date b { display: block; font-size: 18px; }
.pastille-date span { font-size: 12px; text-transform: uppercase; }
.en-retard .pastille-date { background: #fde8e6; color: var(--rouge); }
.echeance-infos { flex: 1; min-width: 0; }
.echeance-tiers { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tableau { width: 100%; border-collapse: collapse; }
.tableau th { text-align: left; font-size: 13px; font-weight: 600; color: var(--texte-2); padding: 6px 8px; border-bottom: 1px solid var(--bord); }
.tableau th.num { text-align: right; }
.tableau td { padding: 7px 8px; border-bottom: 1px solid #f0eef5; vertical-align: middle; }
.tableau tbody tr:nth-child(odd) td { background: #faf9fd; }
.tableau-fixe { table-layout: fixed; }
.tableau-fixe td { overflow: hidden; }
.tableau-fixe .col-date { width: 106px; }
.tableau-fixe .col-cat { width: 27%; }
.tableau-fixe .col-mt { width: 102px; }
.tableau-fixe .col-etat { width: 46px; }
.tableau tr.en-attente td { color: var(--texte-2); }

.pastille-etat {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  font-size: 11px; font-weight: 700; border: 1.5px dashed #a9afbf; color: transparent; cursor: help;
}
.pastille-etat.etat-P { border: 1.5px solid var(--ambre); color: var(--ambre); }
.pastille-etat.etat-R { border: 1.5px solid var(--vert); background: var(--vert); color: #fff; }

/* ------------------------------------------------------------------ formulaires */
.formulaire { display: flex; flex-direction: column; gap: 14px; }
.formulaire label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 14.5px; }
.formulaire label small { font-weight: 400; color: var(--texte-2); }
.formulaire input:not([type=radio]):not([type=color]), .formulaire select {
  padding: 10px 12px; border: 1px solid #cfcadf; border-radius: 9px; background: #fff; font-weight: 400; min-width: 0;
}
.formulaire input[type=color] { width: 60px; height: 40px; border: 1px solid #cfcadf; border-radius: 8px; padding: 2px; }
.formulaire input:focus, .formulaire select:focus { outline: 3px solid var(--accent-clair); border-color: var(--accent); }
.formulaire-grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: end; }
.formulaire-ligne { flex-direction: row; align-items: end; flex-wrap: wrap; }
.formulaire-ligne label { flex: 1; min-width: 240px; }
.choix-couleur { border: none; padding: 0; margin: 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.choix-couleur legend { font-weight: 600; font-size: 14.5px; margin-bottom: 5px; }
.pastille-couleur { cursor: pointer; flex-direction: row !important; }
.pastille-couleur input { position: absolute; opacity: 0; }
.pastille-couleur .point { width: 30px; height: 30px; border: 3px solid var(--f); box-shadow: 0 0 0 1px var(--bord); }
.pastille-couleur input:checked + .point { box-shadow: 0 0 0 3px var(--texte); }
.actions { display: flex; justify-content: flex-end; }

.bouton { display: inline-block; text-decoration: none; text-align: center; border: 1px solid var(--bord); background: #fff; border-radius: 10px; padding: 10px 18px; font-weight: 600; cursor: pointer; }
.bouton-principal { background: var(--accent); border-color: var(--accent); color: #fff; }
.bouton-principal:hover { background: #4a2fae; }
.bouton-lien { border: none; background: none; color: var(--texte-2); cursor: pointer; padding: 2px 4px; font-size: 14px; text-decoration: underline; }
.bouton-lien.rouge:hover { color: var(--rouge); }

.liste-simple li { display: flex; align-items: center; gap: 12px; padding: 7px 0; border-bottom: 1px solid #f0eef5; }
.liste-simple li > span:first-child { flex: 1; }
.liste-modules li { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid #f0eef5; }
.gros-texte { font-size: 18px; margin: 0 0 6px; }

.onglets { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.onglets a { text-decoration: none; color: var(--texte-2); font-weight: 600; padding: 8px 14px; border-radius: 10px; background: #fff; border: 1px solid var(--bord); }
.onglets a.actif { background: var(--accent); border-color: var(--accent); color: #fff; }

.vide-grand { text-align: center; padding: 50px 20px; max-width: 640px; margin: 30px auto; }
.vide-grand h1 { margin-bottom: 10px; }
.vide-icone { font-size: 44px; }
.erreur-publique { text-align: center; }
.erreur-publique p { color: var(--texte-2); margin: 8px 0 20px; }

/* ------------------------------------------------------------------ pages publiques */
.page-publique { justify-content: center; align-items: center; padding: 20px; }
.carte-publique { background: #fff; border: 1px solid var(--bord); border-radius: 18px; box-shadow: var(--ombre); padding: 30px 32px; width: 100%; max-width: 440px; flex: none; }
.carte-publique h1 { font-size: 22px; margin-bottom: 8px; }
.intro { color: var(--texte-2); margin: 0 0 16px; }
.lien-bas { text-align: center; margin: 18px 0 0; color: var(--texte-2); }

/* ------------------------------------------------------------------ écrans étroits */
@media (max-width: 1180px) {
  /* Une seule colonne : les cartes se réordonnent (échéances juste après le solde) */
  .tdb { display: flex; flex-direction: column; align-items: stretch; gap: 0; }
  .tdb-gauche, .tdb-droite { display: contents; }
  .o-1 { order: 1; } .o-2 { order: 2; } .o-3 { order: 3; } .o-4 { order: 4; }
  .o-5 { order: 5; } .o-6 { order: 6; } .o-7 { order: 7; }
}
@media (max-width: 900px) {
  .entete { flex-wrap: wrap; padding: 10px 14px; }
  .menu-bouton { display: flex; flex-direction: column; gap: 5px; cursor: pointer; padding: 8px; order: 3; }
  .menu-bouton span { width: 22px; height: 2px; background: var(--texte); border-radius: 2px; }
  .entete-droite { order: 2; }
  .menu { display: none; order: 4; flex-basis: 100%; flex-direction: column; padding-top: 6px; }
  .menu-bascule:checked ~ .menu { display: flex; }
  .contenu { padding: 14px 12px 24px; }
  .rangee-2 { grid-template-columns: 1fr; gap: 0; }
  .masquer-etroit { display: none; }
  .afficher-etroit { display: block; }
  .tableau-fixe .col-date { width: 74px; }
  .tableau-fixe .col-mt { width: 96px; }
  .tableau-fixe .col-etat { width: 40px; }
}
@media (max-width: 560px) {
  .grille-comptes { grid-template-columns: 1fr; }
  .rangee-3 { grid-template-columns: 1fr; }
  .gros-montant { font-size: 28px; }
}
