/* ==========================================================================
   Composants — cartes, indicateurs, jauges, graphiques, tableaux, formulaires,
   fenêtres, messages. Tout est piloté par les jetons de style.css.
   ========================================================================== */

/* ==========================  Cartes  ==================================== */
.carte {
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--r-3);
  box-shadow: var(--ombre-1);
  overflow: hidden;
}
.carte-tete {
  display: flex;
  align-items: center;
  gap: var(--e-3);
  padding: var(--e-4) var(--e-5);
  border-bottom: 1px solid var(--trait);
}
.carte-tete-plat {
  border-bottom: none;
  padding-bottom: 0;
}
.carte-corps {
  padding: var(--e-5);
}
.carte-corps-serre {
  padding: var(--e-4);
}
.carte-pied {
  padding: var(--e-3) var(--e-5);
  border-top: 1px solid var(--trait);
  background: var(--fond-2);
}
.carte-laiton {
  border-color: var(--trait-laiton);
}
.carte-sans-bord {
  border-color: transparent;
}

/* ==========================  Grilles  =================================== */
.grille {
  display: grid;
  gap: var(--e-5);
}
/* Deux piles indépendantes. Sans elles, chaque rangée de la grille prend la
   hauteur de sa carte la plus haute et la carte courte laisse un trou béant
   au-dessus d'elle — le défaut le plus visible du tableau de bord. */
.grille-2-1 > .pile,
.grille-1-2 > .pile {
  display: flex;
  flex-direction: column;
  gap: var(--e-6);
  min-width: 0;
}
.grille-kpi {
  /* 150 px minimum : deux colonnes tiennent sur un téléphone de 390 px, ce qui
     divise par deux la hauteur de la rangée d'indicateurs. */
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--e-4);
}
@media (max-width: 420px) {
  .grille-kpi .kpi-valeur {
    font-size: var(--t-titre);
  }
}
.grille-2 {
  grid-template-columns: minmax(0, 1fr);
  /* Les cartes gardent leur hauteur naturelle : sans ça, une carte courte se
     remplit de vide pour s'aligner sur sa voisine. */
  align-items: start;
}
.grille-2-1 {
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}
.grille-1-2 {
  align-items: start;
}
@media (min-width: 760px) {
  .grille-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (min-width: 1040px) {
  .grille-2-1 {
    grid-template-columns: minmax(0, 1.62fr) minmax(0, 1fr);
  }
  .grille-1-2 {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.62fr);
  }
}
.colle {
  gap: var(--e-3);
}
.colle-lache {
  gap: var(--e-6);
}

/* ==========================  Indicateurs  ============================== */
.kpi {
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--r-3);
  padding: var(--e-4) var(--e-5);
  display: flex;
  flex-direction: column;
  gap: var(--e-2);
  position: relative;
  overflow: hidden;
}
/* Filet coloré en haut : le code couleur du flux, sans envahir la carte. */
.kpi::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--teinte, transparent);
}
.kpi-tete {
  display: flex;
  align-items: center;
  gap: var(--e-2);
}
.kpi-valeur {
  font-family: var(--f-titre);
  font-size: var(--t-surtitre);
  line-height: 1.05;
  letter-spacing: -0.02em;
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.kpi-valeur .unite {
  font-family: var(--f-texte);
  font-size: var(--t-moyen);
  font-weight: 400;
  color: var(--encre-3);
  letter-spacing: 0;
}
.kpi-note {
  font-size: var(--t-petit);
  color: var(--encre-3);
  display: flex;
  align-items: center;
  gap: var(--e-1);
}
.kpi-flux {
  --teinte: var(--epargne);
}
.kpi-entree {
  --teinte: var(--entree);
}
.kpi-sortie {
  --teinte: var(--sortie);
}
.kpi-laiton {
  --teinte: var(--accent);
}

/* Écart par rapport à la période précédente */
.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: var(--r-plein);
  font-size: var(--t-micro);
  font-weight: 600;
}
.delta-haut {
  background: var(--entree-voile);
  color: var(--entree);
}
.delta-bas {
  background: var(--sortie-voile);
  color: var(--sortie);
}
.delta-plat {
  background: var(--surface-3);
  color: var(--encre-3);
}

/* ==========================  Grand chiffre (héros)  ==================== */
.heros {
  display: flex;
  flex-direction: column;
  gap: var(--e-4);
}
.heros-chiffre {
  font-family: var(--f-titre);
  font-size: var(--t-heros);
  line-height: 0.98;
  letter-spacing: -0.025em;
  display: flex;
  align-items: baseline;
  gap: var(--e-2);
  flex-wrap: wrap;
}
.heros-chiffre .unite {
  font-family: var(--f-texte);
  font-size: var(--t-moyen);
  color: var(--encre-3);
  letter-spacing: 0;
}
.heros-lecture {
  font-size: var(--t-corps);
  color: var(--encre-2);
  max-width: 46ch;
}

/* ==========================  Jauges  =================================== */
.jauge {
  --valeur: 0;
  --teinte: var(--accent);
  position: relative;
  height: 8px;
  border-radius: var(--r-plein);
  background: var(--surface-3);
  overflow: hidden;
}
.jauge-pleine {
  height: 10px;
}
.jauge-fine {
  height: 5px;
}
.jauge-remplie {
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--valeur) * 100%);
  border-radius: var(--r-plein);
  background: var(--teinte);
  transition: width 420ms var(--courbe);
}
.jauge-repere {
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--repere, 0) * 100%);
  border-right: 1px dashed var(--trait-fort);
}
.jauge-legende {
  display: flex;
  justify-content: space-between;
  font-size: var(--t-petit);
  color: var(--encre-3);
  margin-top: var(--e-2);
}
/* Segments empilés : la répartition d'un mois sur une seule ligne. */
.jauge-segments {
  display: flex;
  height: 10px;
  border-radius: var(--r-plein);
  overflow: hidden;
  background: var(--surface-3);
}
.jauge-segment {
  width: calc(var(--valeur) * 100%);
  background: var(--teinte);
  transition: width 420ms var(--courbe);
}

/* ==========================  Boutons  ================================== */
.bouton {
  --fond-b: var(--surface-3);
  --encre-b: var(--encre);
  --bord-b: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--e-2);
  padding: 0 var(--e-4);
  height: 38px;
  border-radius: var(--r-2);
  border: 1px solid var(--bord-b);
  background: var(--fond-b);
  color: var(--encre-b);
  font-size: var(--t-petit);
  font-weight: 600;
  letter-spacing: 0.005em;
  white-space: nowrap;
  transition: filter var(--duree) var(--courbe),
    background var(--duree) var(--courbe), border-color var(--duree) var(--courbe);
}
.bouton:hover {
  filter: brightness(1.14);
}
.bouton:active {
  transform: translateY(0.5px);
}
.bouton[disabled] {
  opacity: 0.45;
  pointer-events: none;
}
.bouton svg {
  flex: none;
}

.bouton-laiton {
  --fond-b: var(--accent);
  --encre-b: var(--encre-sur-accent);
  font-weight: 700;
}
.bouton-contour {
  --fond-b: transparent;
  --bord-b: var(--trait-fort);
  --encre-b: var(--encre);
}
.bouton-contour:hover {
  --fond-b: var(--survol);
  filter: none;
}
.bouton-fantome {
  --fond-b: transparent;
  --encre-b: var(--encre-2);
}
.bouton-fantome:hover {
  --fond-b: var(--survol);
  --encre-b: var(--encre);
  filter: none;
}
.bouton-danger {
  --fond-b: transparent;
  --bord-b: color-mix(in oklab, var(--sortie) 45%, transparent);
  --encre-b: var(--sortie);
}
.bouton-danger:hover {
  --fond-b: var(--sortie-voile);
  filter: none;
}
.bouton-large {
  width: 100%;
}
.bouton-grand {
  height: 46px;
  font-size: var(--t-corps);
  padding: 0 var(--e-5);
}
.bouton-petit {
  height: 30px;
  font-size: var(--t-micro);
  padding: 0 var(--e-3);
  font-weight: 600;
  letter-spacing: 0.03em;
}
.bouton-rond {
  width: 38px;
  padding: 0;
  border-radius: var(--r-plein);
}
.bouton-icone {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--r-2);
  --fond-b: transparent;
  --encre-b: var(--encre-3);
  --bord-b: transparent;
}
.bouton-icone:hover {
  --fond-b: var(--survol);
  --encre-b: var(--encre);
  filter: none;
}

/* ==========================  Formulaires  ============================== */
.champ {
  display: flex;
  flex-direction: column;
  gap: var(--e-2);
  min-width: 0;
}
.champ > label,
.champ-label {
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--encre-3);
}
.champ-aide {
  font-size: var(--t-petit);
  color: var(--encre-3);
  letter-spacing: 0;
  text-transform: none;
  font-weight: 400;
}
.saisie {
  height: 40px;
  padding: 0 var(--e-3);
  border-radius: var(--r-2);
  border: 1px solid var(--trait-fort);
  background: var(--fond-2);
  color: var(--encre);
  font-size: var(--t-corps);
  width: 100%;
  transition: border-color var(--duree) var(--courbe),
    box-shadow var(--duree) var(--courbe);
}
select.saisie {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--encre-3) 50%),
    linear-gradient(135deg, var(--encre-3) 50%, transparent 50%);
  background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: var(--e-7);
}
textarea.saisie {
  height: auto;
  min-height: 88px;
  padding: var(--e-3);
  line-height: 1.5;
  resize: vertical;
}
.saisie::placeholder {
  color: var(--encre-3);
}
.saisie:hover {
  border-color: var(--trait-laiton);
}
.saisie:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-voile);
}
.saisie-montant {
  font-family: var(--f-titre);
  font-size: var(--t-moyen);
  letter-spacing: -0.01em;
}
.saisie-erreur {
  border-color: var(--sortie);
}
/* Un champ de montant : le symbole € reste collé au chiffre */
.montant-champ {
  position: relative;
  display: flex;
  align-items: center;
}
.montant-champ .saisie {
  padding-right: var(--e-8);
  text-align: right;
}
.montant-champ .symbole {
  position: absolute;
  right: var(--e-3);
  color: var(--encre-3);
  pointer-events: none;
  font-size: var(--t-corps);
}

/* Cases et interrupteurs */
.bascule {
  display: flex;
  align-items: center;
  gap: var(--e-3);
  cursor: pointer;
}
.bascule input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.bascule-piste {
  width: 38px;
  height: 22px;
  border-radius: var(--r-plein);
  background: var(--surface-4);
  position: relative;
  flex: none;
  transition: background var(--duree) var(--courbe);
}
.bascule-piste::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: var(--r-plein);
  background: var(--encre);
  transition: transform var(--duree) var(--courbe);
}
.bascule input:checked + .bascule-piste {
  background: var(--accent);
}
.bascule input:checked + .bascule-piste::after {
  transform: translateX(16px);
  background: var(--encre-sur-accent);
}
.bascule input:focus-visible + .bascule-piste {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Sélecteur de période (contrôle segmenté) */
.segments {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--r-2);
  background: var(--fond-2);
  border: 1px solid var(--trait);
}
.segment {
  padding: 5px var(--e-3);
  border-radius: var(--r-1);
  font-size: var(--t-petit);
  font-weight: 500;
  color: var(--encre-3);
  transition: background var(--duree) var(--courbe), color var(--duree) var(--courbe);
}
.segment:hover {
  color: var(--encre);
}
.segment[aria-pressed='true'] {
  background: var(--surface-3);
  color: var(--encre);
}

/* Sélecteur de mois. Les deux écritures du mois (longue / brève) sont déclarées
   dans style.css : les regles de base et leur variante mobile doivent vivre dans
   la MEME feuille, sinon l'ordre de chargement des fichiers fait gagner la regle
   de base et le mois disparait entierement sur telephone. */
.mois-nav {
  display: flex;
  align-items: center;
  gap: var(--e-1);
  padding: 3px;
  border-radius: var(--r-2);
  background: var(--fond-2);
  border: 1px solid var(--trait);
}
.mois-nav .mois-courant {
  min-width: 132px;
  text-align: center;
  font-size: var(--t-petit);
  font-weight: 600;
  text-transform: capitalize;
}

/* ==========================  Tableaux  ================================= */
.tableau-enveloppe {
  border-radius: var(--r-2);
  border: 1px solid var(--trait);
  overflow: auto;
  max-height: 68vh;
}
.tableau {
  font-size: var(--t-petit);
}
.tableau thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--fond-2);
  border-bottom: 1px solid var(--trait-fort);
  padding: var(--e-3) var(--e-4);
  text-align: left;
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--encre-3);
  white-space: nowrap;
}
.tableau tbody td {
  padding: 10px var(--e-4);
  border-bottom: 1px solid var(--trait);
  vertical-align: middle;
}
.tableau tbody tr:last-child td {
  border-bottom: none;
}
.tableau tbody tr:hover {
  background: var(--survol);
}
.tableau .col-montant {
  text-align: right;
  font-variant-numeric: tabular-nums lining-nums;
  white-space: nowrap;
  font-weight: 500;
}
.tableau .col-jour {
  width: 1%;
  white-space: nowrap;
  color: var(--encre-3);
  font-variant-numeric: tabular-nums;
}
.tableau .col-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}
.tableau-ligne-jour {
  font-weight: 600;
  color: var(--encre-2);
}
.tableau-jour td {
  background: var(--fond-2);
  border-bottom: 1px solid var(--trait-fort) !important;
  padding: 5px var(--e-4) !important;
  font-size: var(--t-micro) !important;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--encre-3);
  font-weight: 600;
}
.tableau-jour .total-jour {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Pastille de catégorie */
.pastille {
  display: inline-flex;
  align-items: center;
  gap: var(--e-2);
  min-width: 0;
}
.pastille-point {
  width: 8px;
  height: 8px;
  border-radius: var(--r-plein);
  background: var(--teinte, var(--encre-3));
  flex: none;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--teinte, var(--encre-3)) 18%, transparent);
}
.pastille-sans {
  color: var(--encre-3);
  font-style: italic;
}

/* Étiquettes */
.etiquette {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--r-plein);
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--surface-3);
  color: var(--encre-2);
  white-space: nowrap;
}
.etiquette-entree {
  background: var(--entree-voile);
  color: var(--entree);
}
.etiquette-sortie {
  background: var(--sortie-voile);
  color: var(--sortie);
}
.etiquette-epargne {
  background: var(--epargne-voile);
  color: var(--epargne);
}
.etiquette-laiton {
  background: var(--accent-voile);
  color: var(--accent);
}
.etiquette-attention {
  background: var(--attention-voile);
  color: var(--attention);
}

/* ==========================  Graphiques  =============================== */
.graphique {
  width: 100%;
  overflow: visible;
}
.graphique .grille-fond {
  stroke: var(--trait);
  stroke-width: 1;
}
.graphique .axe-texte {
  fill: var(--encre-3);
  font-size: 10px;
  font-family: var(--f-texte);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.graphique .barre {
  fill: var(--teinte, var(--surface-4));
  transition: filter var(--duree) var(--courbe);
} /* Pas de rx/ry : les barres carrees tiennent mieux la densite. */
.graphique .barre:hover {
  filter: brightness(1.25);
}
.graphique .barre-selection {
  fill: var(--accent);
}
.graphique .aire {
  fill: url(#degrade-aire);
}
.graphique .courbe {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.75;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.graphique .point {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 2;
}
.graphique .point-actif {
  fill: var(--accent);
}
.graphique .aucune {
  fill: var(--encre-3);
  font-size: 12px;
  font-family: var(--f-texte);
}

.legende {
  display: flex;
  flex-wrap: wrap;
  gap: var(--e-4);
  font-size: var(--t-petit);
  color: var(--encre-2);
}
.legende-item {
  display: flex;
  align-items: center;
  gap: var(--e-2);
}
.legende-puce {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--teinte, var(--encre-3));
  flex: none;
}
/* Les listes de repartition : nom, barre, part. Aligne comme un releve. */
.repartition {
  display: flex;
  flex-direction: column;
  gap: var(--e-3);
}
.repartition-ligne {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--e-3);
  align-items: center;
}
.repartition-nom {
  display: flex;
  align-items: center;
  gap: var(--e-2);
  min-width: 0;
  font-size: var(--t-petit);
}
.repartition-nom .nom {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.repartition-montant {
  font-size: var(--t-petit);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.repartition-barre {
  grid-column: 1 / -1;
}

/* Anneau (répartition du patrimoine) */
.anneau {
  display: flex;
  align-items: center;
  gap: var(--e-5);
  flex-wrap: wrap;
}
.anneau svg {
  flex: none;
}
.anneau-centre {
  font-family: var(--f-titre);
  font-size: 1.1rem;
  fill: var(--encre);
}
.anneau-centre-sous {
  font-size: 9px;
  fill: var(--encre-3);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ==========================  Enveloppes  =============================== */
.enveloppe {
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--r-3);
  padding: var(--e-4);
  display: flex;
  flex-direction: column;
  gap: var(--e-3);
  transition: border-color var(--duree) var(--courbe);
}
.enveloppe:hover {
  border-color: var(--trait-fort);
}
.enveloppe-depassee {
  border-color: color-mix(in oklab, var(--sortie) 42%, transparent);
  background: linear-gradient(
    to bottom,
    var(--sortie-voile),
    transparent 62%
  );
}
.enveloppe-proche {
  border-color: color-mix(in oklab, var(--attention) 40%, transparent);
}
.enveloppe-tete {
  display: flex;
  align-items: center;
  gap: var(--e-3);
}
.enveloppe-nom {
  font-weight: 600;
  font-size: var(--t-corps);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.enveloppe-chiffres {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--e-3);
}
.enveloppe-depense {
  font-family: var(--f-titre);
  font-size: var(--t-grand);
  letter-spacing: -0.015em;
}
.enveloppe-depense .sur {
  font-family: var(--f-texte);
  font-size: var(--t-petit);
  color: var(--encre-3);
  letter-spacing: 0;
}

/* ==========================  Objectifs  ================================ */
.objectif {
  display: flex;
  flex-direction: column;
  gap: var(--e-3);
  padding: var(--e-4);
  border: 1px solid var(--trait);
  border-radius: var(--r-3);
  background: var(--surface);
  position: relative;
  overflow: hidden;
}
.objectif-atteint {
  border-color: var(--trait-laiton);
  background: linear-gradient(
    to bottom right,
    var(--accent-voile),
    transparent 55%
  );
}
.objectif-sceau {
  width: 38px;
  height: 38px;
  border-radius: var(--r-2);
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--teinte, var(--accent));
  flex: none;
}
.objectif-montants {
  display: flex;
  align-items: baseline;
  gap: var(--e-2);
}
.objectif-cumul {
  font-family: var(--f-titre);
  font-size: var(--t-grand);
  letter-spacing: -0.015em;
}

/* ==========================  Conseils & signaux  ======================= */
.conseil {
  display: flex;
  gap: var(--e-3);
  padding: var(--e-4);
  border-radius: var(--r-3);
  border: 1px solid var(--trait);
  background: var(--surface);
  position: relative;
}
.conseil::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  border-radius: var(--r-3) 0 0 var(--r-3);
  background: var(--teinte, var(--encre-3));
}
.conseil-ulysse {
  --teinte: var(--accent);
}
.conseil-info {
  --teinte: var(--epargne);
}
.conseil-positif {
  --teinte: var(--entree);
}
.conseil-attention {
  --teinte: var(--attention);
}
.conseil-urgent {
  --teinte: var(--sortie);
}
.conseil-epingle {
  border-color: var(--trait-laiton);
}
.conseil-sceau {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: var(--r-2);
  display: grid;
  place-items: center;
  background: color-mix(in oklab, var(--teinte, var(--encre-3)) 16%, transparent);
  color: var(--teinte, var(--encre-3));
  font-family: var(--f-titre);
  font-size: 0.95rem;
}
.conseil-titre {
  font-weight: 600;
  font-size: var(--t-corps);
  line-height: 1.35;
}
.conseil-corps {
  font-size: var(--t-petit);
  color: var(--encre-2);
  margin-top: var(--e-2);
  line-height: 1.6;
}
.conseil-corps p + p {
  margin-top: var(--e-3);
}
.conseil-corps ul {
  margin-top: var(--e-2);
  display: flex;
  flex-direction: column;
  gap: var(--e-1);
}
.conseil-corps li {
  padding-left: var(--e-4);
  position: relative;
}
.conseil-corps li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--encre-3);
}
.conseil-corps strong {
  color: var(--encre);
  font-weight: 600;
}
.conseil-action {
  margin-top: var(--e-3);
  font-size: var(--t-petit);
  display: flex;
  align-items: center;
  gap: var(--e-2);
  color: var(--accent);
  font-weight: 600;
}
.conseil-meta {
  display: flex;
  align-items: center;
  gap: var(--e-3);
  margin-top: var(--e-3);
  font-size: var(--t-micro);
  color: var(--encre-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}
.conseil-liste {
  display: flex;
  flex-direction: column;
  gap: var(--e-3);
}

/* ==========================  Listes d'opérations  ====================== */
.mouvement {
  display: flex;
  align-items: center;
  gap: var(--e-3);
  padding: 10px var(--e-4);
  border-bottom: 1px solid var(--trait);
  transition: background var(--duree) var(--courbe);
}
.mouvement:last-child {
  border-bottom: none;
}
.mouvement:hover {
  background: var(--survol);
}
.mouvement-jour {
  width: 34px;
  flex: none;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--encre-3);
  font-size: var(--t-petit);
}
.mouvement-jour .j {
  display: block;
  font-family: var(--f-titre);
  font-size: var(--t-moyen);
  color: var(--encre-2);
  line-height: 1;
}
.mouvement-corps {
  flex: 1;
  min-width: 0;
}
.mouvement-libelle {
  font-size: var(--t-corps);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mouvement-detail {
  font-size: var(--t-micro);
  color: var(--encre-3);
  display: flex;
  align-items: center;
  gap: var(--e-2);
  margin-top: 2px;
}
.mouvement-montant {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-size: var(--t-corps);
}

/* ==========================  États vides  ============================== */
.vide {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--e-3);
  padding: var(--e-8) var(--e-5);
  color: var(--encre-3);
}
.vide-sceau {
  width: 46px;
  height: 46px;
  border-radius: var(--r-plein);
  border: 1px dashed var(--trait-fort);
  display: grid;
  place-items: center;
  color: var(--encre-3);
}
.vide-titre {
  font-family: var(--f-titre);
  font-size: var(--t-grand);
  color: var(--encre);
}
.vide-texte {
  font-size: var(--t-petit);
  max-width: 42ch;
  line-height: 1.6;
}

/* ==========================  Fenêtres  ================================= */
.voile {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: var(--voile);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: var(--e-4);
  overflow-y: auto;
}
.voile-haut {
  align-items: start;
}
.fenetre {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--trait-fort);
  border-radius: var(--r-4);
  box-shadow: var(--ombre-3);
  animation: surgir 220ms var(--courbe) both;
  max-height: calc(100dvh - var(--e-8));
  display: flex;
  flex-direction: column;
}
.fenetre-large {
  max-width: 720px;
}
@keyframes surgir {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
}
.fenetre-tete {
  display: flex;
  align-items: center;
  gap: var(--e-3);
  padding: var(--e-5) var(--e-5) var(--e-4);
  border-bottom: 1px solid var(--trait);
}
.fenetre-titre {
  font-family: var(--f-titre);
  font-size: var(--t-grand);
  letter-spacing: -0.01em;
}
.fenetre-corps {
  padding: var(--e-5);
  display: flex;
  flex-direction: column;
  gap: var(--e-4);
  overflow-y: auto;
}
.fenetre-pied {
  display: flex;
  gap: var(--e-3);
  justify-content: flex-end;
  padding: var(--e-4) var(--e-5);
  border-top: 1px solid var(--trait);
  background: var(--fond-2);
}

/* ==========================  Messages  ================================= */
.messages {
  position: fixed;
  right: var(--e-5);
  bottom: var(--e-5);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: var(--e-2);
  max-width: min(380px, calc(100vw - var(--e-8)));
}
@media (max-width: 1000px) {
  .messages {
    left: var(--e-4);
    right: var(--e-4);
    bottom: calc(var(--e-8) + env(safe-area-inset-bottom));
    max-width: none;
  }
}
.message {
  display: flex;
  align-items: flex-start;
  gap: var(--e-3);
  padding: var(--e-4);
  border-radius: var(--r-3);
  background: var(--surface-2);
  border: 1px solid var(--trait-fort);
  box-shadow: var(--ombre-3);
  font-size: var(--t-petit);
  animation: surgir 200ms var(--courbe) both;
}
.message-ok {
  border-left: 3px solid var(--entree);
}
.message-erreur {
  border-left: 3px solid var(--sortie);
}
.message-attention {
  border-left: 3px solid var(--attention);
}
.message-texte {
  flex: 1;
  min-width: 0;
}

/* ==========================  Bandeau d'alerte  ========================= */
.bandeau {
  display: flex;
  align-items: flex-start;
  gap: var(--e-3);
  padding: var(--e-3) var(--e-4);
  border-radius: var(--r-2);
  background: var(--attention-voile);
  border: 1px solid color-mix(in oklab, var(--attention) 35%, transparent);
  font-size: var(--t-petit);
  color: var(--encre);
}
.bandeau-erreur {
  background: var(--sortie-voile);
  border-color: color-mix(in oklab, var(--sortie) 38%, transparent);
}

/* ==========================  Sécurité  ================================= */
.ligne-secu {
  display: flex;
  align-items: center;
  gap: var(--e-4);
  padding: var(--e-4) var(--e-5);
  border-bottom: 1px solid var(--trait);
}
.ligne-secu:last-child {
  border-bottom: none;
}
.ligne-secu-corps {
  flex: 1;
  min-width: 0;
}
.ligne-secu-titre {
  font-weight: 600;
  font-size: var(--t-corps);
  display: flex;
  align-items: center;
  gap: var(--e-2);
}
.ligne-secu-note {
  font-size: var(--t-petit);
  color: var(--encre-3);
  margin-top: 2px;
  line-height: 1.5;
}
.etat-point {
  width: 7px;
  height: 7px;
  border-radius: var(--r-plein);
  flex: none;
  background: var(--encre-3);
}
.etat-actif {
  background: var(--entree);
  box-shadow: 0 0 0 3px var(--entree-voile);
}
.etat-inactif {
  background: var(--encre-3);
}
.etat-alerte {
  background: var(--attention);
  box-shadow: 0 0 0 3px var(--attention-voile);
}

/* Secret TOTP : chasse fixe, groupé par 4, lisible à recopier */
.secret {
  font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: var(--t-corps);
  letter-spacing: 0.14em;
  background: var(--fond-2);
  border: 1px dashed var(--trait-laiton);
  border-radius: var(--r-2);
  padding: var(--e-3) var(--e-4);
  word-break: break-all;
  text-align: center;
  color: var(--accent);
}
.codes-secours {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--e-2);
}
.code-secours {
  font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: var(--t-petit);
  letter-spacing: 0.08em;
  padding: var(--e-2) var(--e-3);
  border-radius: var(--r-1);
  background: var(--fond-2);
  border: 1px solid var(--trait);
  text-align: center;
  color: var(--encre-2);
}

/* Écran de connexion : une seule colonne, centrée, sans distraction */
.connexion {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: var(--e-6);
}
.connexion-marque {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--e-3);
  text-align: center;
}
.connexion-sceau {
  width: 54px;
  height: 54px;
  border-radius: var(--r-3);
  border: 1px solid var(--trait-laiton);
  background: linear-gradient(
    150deg,
    color-mix(in oklab, var(--accent) 24%, transparent),
    transparent
  );
  display: grid;
  place-items: center;
  font-family: var(--f-titre);
  font-size: 1.6rem;
  color: var(--accent);
}
.connexion-form {
  display: flex;
  flex-direction: column;
  gap: var(--e-4);
}
.separateur {
  display: flex;
  align-items: center;
  gap: var(--e-3);
  color: var(--encre-3);
  font-size: var(--t-micro);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}
.separateur::before,
.separateur::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--trait);
}
.code-6 {
  font-family: var(--f-titre);
  font-size: var(--t-surtitre);
  letter-spacing: 0.42em;
  text-align: center;
  text-indent: 0.42em;
}

/* Affichage selon la largeur : un tableau dense sur ordinateur, une liste
   aérée sur téléphone. Les deux sont rendus, le CSS choisit. */
.seulement-etroit {
  display: block;
}
.seulement-large {
  display: none;
}
@media (min-width: 760px) {
  .seulement-etroit {
    display: none !important;
  }
  .seulement-large {
    display: block;
  }
}

/* ==========================  Blocs utilitaires  ======================== */
.encart {
  padding: var(--e-4);
  border-radius: var(--r-2);
  background: var(--fond-2);
  border: 1px solid var(--trait);
  font-size: var(--t-petit);
  color: var(--encre-2);
  line-height: 1.6;
}
.encart-laiton {
  border-color: var(--trait-laiton);
  background: var(--accent-voile);
  color: var(--encre);
}
.separateur-trait {
  height: 1px;
  background: var(--trait);
  border: none;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--e-2);
}
.chip {
  padding: 4px var(--e-3);
  border-radius: var(--r-plein);
  border: 1px solid var(--trait);
  background: var(--fond-2);
  font-size: var(--t-petit);
  color: var(--encre-2);
  transition: all var(--duree) var(--courbe);
}
.chip:hover {
  border-color: var(--trait-laiton);
  color: var(--encre);
}
.chip[aria-pressed='true'] {
  background: var(--accent-voile);
  border-color: var(--trait-laiton);
  color: var(--accent);
  font-weight: 600;
}

/* ========================  Panneau Ulysse (chat)  =========================
   Un bouton flottant, un panneau latéral. Il passe au-dessus des vues mais
   reste sous les fenêtres modales (z-index 80) et suit le thème courant. */

.chat-bouton {
  position: fixed;
  right: var(--e-5);
  bottom: var(--e-5);
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: var(--e-2);
  padding: 12px 18px 12px 12px;
  border: none;
  border-radius: var(--r-plein);
  background: var(--accent);
  color: var(--encre-sur-accent);
  font-family: var(--f-titre);
  font-size: var(--t-petit);
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow: var(--ombre-3);
  transition:
    transform var(--duree) var(--courbe),
    box-shadow var(--duree) var(--courbe);
}
.chat-bouton:hover {
  transform: translateY(-2px);
}
.chat-bouton[hidden] {
  display: none;
}
.chat-bouton .chat-sceau {
  background: rgba(255, 255, 255, 0.2);
  color: currentColor;
}

.chat-sceau {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: var(--r-plein);
  background: var(--accent-voile);
  color: var(--accent);
}

.chat-panneau {
  position: fixed;
  right: var(--e-5);
  bottom: calc(var(--e-5) + 62px);
  z-index: 60;
  width: min(430px, calc(100vw - 2 * var(--e-4)));
  height: min(620px, calc(100vh - 150px));
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: var(--r-4);
  box-shadow: var(--ombre-3);
  overflow: hidden;
}
.chat-panneau[hidden] {
  display: none;
}

.chat-entete {
  display: flex;
  align-items: center;
  gap: var(--e-3);
  padding: var(--e-4);
  border-bottom: 1px solid var(--trait);
  background: var(--surface-2);
}
.chat-titres {
  flex: 1;
  min-width: 0;
}
.chat-titre {
  font-family: var(--f-titre);
  font-size: var(--t-moyen);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.chat-sous-titre {
  font-size: var(--t-micro);
  color: var(--encre-3);
}
.chat-fermer {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border: none;
  border-radius: var(--r-plein);
  background: transparent;
  color: var(--encre-3);
  cursor: pointer;
}
.chat-fermer:hover {
  background: var(--survol);
  color: var(--encre);
}

.chat-liste {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--e-3);
  padding: var(--e-4);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.chat-accueil {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--e-2);
}
.chat-accueil-titre {
  font-family: var(--f-titre);
  font-size: var(--t-grand);
  font-weight: 600;
  letter-spacing: -0.025em;
  margin-top: var(--e-2);
}
.chat-accueil-texte {
  font-size: var(--t-petit);
  line-height: 1.55;
  color: var(--encre-2);
}
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--e-2);
  margin-top: var(--e-3);
}
.chat-suggestion {
  padding: 8px 13px;
  border: 1px solid var(--trait-fort);
  border-radius: var(--r-plein);
  background: var(--surface);
  color: var(--encre);
  font: inherit;
  font-size: var(--t-micro);
  cursor: pointer;
  transition: all var(--duree) var(--courbe);
}
.chat-suggestion:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chat-tour {
  display: flex;
  align-items: flex-start;
  gap: var(--e-2);
}
.chat-moi {
  justify-content: flex-end;
}
.chat-moi .chat-texte {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: var(--r-3) var(--r-3) 6px var(--r-3);
  background: var(--accent);
  color: var(--encre-sur-accent);
}
.chat-lui .chat-corps {
  display: flex;
  flex-direction: column;
  gap: var(--e-2);
  max-width: calc(100% - 38px);
  padding: 12px 14px;
  border: 1px solid var(--trait);
  border-radius: 6px var(--r-3) var(--r-3) var(--r-3);
  background: var(--surface-2);
}
.chat-texte {
  font-size: var(--t-petit);
  line-height: 1.55;
  white-space: pre-line;
}
.chat-source {
  font-size: var(--t-micro);
  color: var(--encre-3);
}
.chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--e-2);
  margin-top: var(--e-1);
}
.chat-puce {
  padding: 7px 12px;
  border: 1px solid var(--trait-laiton);
  border-radius: var(--r-plein);
  background: var(--epargne-voile);
  color: var(--encre);
  font: inherit;
  font-size: var(--t-micro);
  font-weight: 600;
  cursor: pointer;
}
.chat-puce:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Les trois points, pendant que le modèle rédige. */
.chat-points {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}
.chat-points span {
  width: 6px;
  height: 6px;
  border-radius: var(--r-plein);
  background: var(--encre-3);
  animation: chat-pulse 1.1s ease-in-out infinite;
}
.chat-points span:nth-child(2) {
  animation-delay: 0.15s;
}
.chat-points span:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes chat-pulse {
  0%,
  100% {
    opacity: 0.25;
  }
  50% {
    opacity: 1;
  }
}

.chat-saisie {
  display: flex;
  align-items: flex-end;
  gap: var(--e-2);
  padding: var(--e-3);
  border-top: 1px solid var(--trait);
  background: var(--surface);
}
.chat-zone {
  flex: 1;
  max-height: 120px;
  padding: 10px 12px;
  border: 1px solid var(--trait-fort);
  border-radius: var(--r-2);
  background: var(--surface-2);
  color: var(--encre);
  font-family: var(--f-texte);
  font-size: var(--t-petit);
  resize: none;
}
.chat-zone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.chat-envoyer {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border: none;
  border-radius: var(--r-plein);
  background: var(--accent);
  color: var(--encre-sur-accent);
  cursor: pointer;
}
.chat-envoyer:hover {
  background: var(--accent-fort);
}

@media (max-width: 560px) {
  .chat-panneau {
    right: var(--e-3);
    left: var(--e-3);
    width: auto;
    height: min(72vh, calc(100vh - 130px));
  }
  .chat-bouton {
    padding: 12px;
  }
  .chat-bouton span {
    display: none;
  }
}
