/* ==========================================================================
   Feuille de style — thème clair par défaut, variante sombre via [data-theme]
   ========================================================================== */

:root {
  /* Fait peindre par le navigateur ses propres éléments — menus déroulants
     natifs, barres de défilement — dans le bon thème. */
  color-scheme: light;

  --fond: #f6f7f9;
  --fond-panneau: #ffffff;
  --fond-doux: #f1f3f6;
  --fond-survol: #eef1f6;
  --bordure: #e2e6ec;
  --bordure-forte: #cbd2dc;
  --texte: #12161c;
  --texte-doux: #5a6472;
  --texte-tres-doux: #8b95a3;
  --accent: #2f5fd8;
  --accent-fonce: #2449ab;
  --accent-doux: #e8eefc;
  /* Couleur du texte posé sur --accent. Le bleu du thème sombre est clair :
     du blanc dessus ne donnerait que 2,9:1, sous le seuil AA de 4,5:1. */
  --sur-accent: #ffffff;
  --succes: #17794a;
  --succes-doux: #e2f4ea;
  --alerte: #9a3412;
  --alerte-doux: #fdeee6;
  --erreur: #b42318;
  --erreur-doux: #fdecea;
  --erreur-survol: #8f1d13;
  --sur-erreur: #ffffff;
  --ombre: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px -12px rgba(16, 24, 40, .18);
  --ombre-forte: 0 12px 40px -12px rgba(16, 24, 40, .28);
  --rayon: 12px;
  --rayon-petit: 8px;
  --entete-hauteur: 60px;
}

[data-theme="sombre"] {
  color-scheme: dark;

  --fond: #0e1116;
  --fond-panneau: #161a21;
  --fond-doux: #1b2029;
  --fond-survol: #222833;
  --bordure: #262c37;
  --bordure-forte: #39414f;
  --texte: #e8ecf2;
  --texte-doux: #9aa5b4;
  --texte-tres-doux: #6c7787;
  --accent: #6b93ff;
  --accent-fonce: #4f7bf5;
  --accent-doux: #1c2740;
  --sur-accent: #0e1116;  /* 6,5:1 sur --accent, 4,9:1 sur --accent-fonce */
  --succes: #4ade80;
  --succes-doux: #12261c;
  --alerte: #fbbf24;
  --alerte-doux: #2b2011;
  --erreur: #f87171;
  --erreur-doux: #2b1616;
  --erreur-survol: #fca5a5;
  --sur-erreur: #0e1116;  /* 6,8:1 sur --erreur */
  --ombre: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .6);
  --ombre-forte: 0 12px 40px -12px rgba(0, 0, 0, .7);
}

* { box-sizing: border-box; }

/* Garde-fou : sans cette règle, la moindre déclaration `display` dans une
   classe l'emporte sur le style navigateur de [hidden] et l'élément reste
   visible. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }

.enveloppe { max-width: 1080px; margin: 0 auto; padding: 32px 24px 80px; }
.enveloppe--large { max-width: 100%; padding: 24px 24px 80px; }

/* ---------------------------------------------------------------- En-tête */

.entete {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--entete-hauteur);
  background: color-mix(in srgb, var(--fond-panneau) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--bordure);
}

.entete__interieur {
  height: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.marque { display: flex; align-items: center; gap: 10px; color: var(--texte); text-decoration: none; }
.marque:hover { text-decoration: none; }

.marque__logo {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--accent);
  color: var(--sur-accent);
}
.marque__logo svg { width: 17px; height: 17px; }

.marque__texte { display: flex; flex-direction: column; line-height: 1.15; }
.marque__texte strong { font-size: 14px; font-weight: 650; }
.marque__texte small { font-size: 11px; color: var(--texte-tres-doux); }

.nav { display: flex; gap: 4px; }
.nav__lien {
  padding: 7px 12px;
  border-radius: var(--rayon-petit);
  color: var(--texte-doux);
  font-weight: 500;
  font-size: 13px;
}
.nav__lien:hover { background: var(--fond-survol); color: var(--texte); text-decoration: none; }
.nav__lien.est-actif { background: var(--accent-doux); color: var(--accent); }

.entete__actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.bouton-theme {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-petit);
  background: var(--fond-panneau);
  color: var(--texte-doux);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.bouton-theme:hover { background: var(--fond-survol); color: var(--texte); }
.bouton-theme svg { width: 16px; height: 16px; }
.icone-lune { display: none; }
[data-theme="sombre"] .icone-soleil { display: none; }
[data-theme="sombre"] .icone-lune { display: block; }

/* ------------------------------------------------------------ Menu compte */

.menu-compte { position: relative; }

.pastille {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--sur-accent);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

.menu-compte__panneau {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  padding: 6px;
  background: var(--fond-panneau);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  box-shadow: var(--ombre-forte);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
/* `display: flex` ci-dessus l'emporte sur le style navigateur de [hidden] :
   il faut donc masquer le panneau explicitement. */
.menu-compte__panneau[hidden] { display: none; }

.menu-compte__identite {
  padding: 10px 12px;
  border-bottom: 1px solid var(--bordure);
  margin-bottom: 4px;
  display: flex; flex-direction: column;
}
.menu-compte__identite strong { font-size: 13px; }
.menu-compte__identite span { font-size: 12px; color: var(--texte-tres-doux); }
.menu-compte__panneau a,
.menu-compte__panneau button {
  display: block; width: 100%; text-align: left;
  padding: 8px 12px;
  border: none; background: none;
  border-radius: var(--rayon-petit);
  color: var(--texte); font: inherit; font-size: 13px;
  cursor: pointer;
}
.menu-compte__panneau a:hover,
.menu-compte__panneau button:hover { background: var(--fond-survol); text-decoration: none; }
.menu-compte__panneau form { margin: 0; }

/* ------------------------------------------------------------- Composants */

.bouton {
  --spinner: var(--sur-accent);
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: var(--rayon-petit);
  background: var(--accent);
  color: var(--sur-accent);
  font: inherit; font-size: 13px; font-weight: 550;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.bouton:hover { background: var(--accent-fonce); text-decoration: none; color: var(--sur-accent); }
.bouton:disabled:not(.est-en-cours) { opacity: .5; cursor: not-allowed; }
.bouton svg { width: 15px; height: 15px; }

.bouton--discret {
  --spinner: var(--texte);
  background: var(--fond-panneau);
  color: var(--texte);
  border-color: var(--bordure);
}
.bouton--discret:hover { background: var(--fond-survol); color: var(--texte); }

.bouton--danger { --spinner: var(--erreur); background: transparent; color: var(--erreur); border-color: var(--bordure); }
.bouton--danger:hover { background: var(--erreur-doux); color: var(--erreur); }

/* Action irréversible : le bouton porte la couleur de l'avertissement. */
.bouton--destructif { --spinner: var(--sur-erreur); background: var(--erreur); color: var(--sur-erreur); }
.bouton--destructif:hover { background: var(--erreur-survol); color: var(--sur-erreur); }

.panneau {
  background: var(--fond-panneau);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
}

.etiquette {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  flex-shrink: 0;
}
.etiquette--ouverte { background: var(--succes-doux); color: var(--succes); }
.etiquette--brouillon { background: var(--fond-doux); color: var(--texte-doux); }
.etiquette--cloturee { background: var(--alerte-doux); color: var(--alerte); }

.messages { max-width: 1080px; margin: 16px auto -8px; padding: 0 24px; }
.message {
  padding: 10px 14px;
  border-radius: var(--rayon-petit);
  border: 1px solid var(--bordure);
  background: var(--fond-panneau);
  margin-bottom: 8px;
  font-size: 13px;
}
.message--success { background: var(--succes-doux); border-color: transparent; color: var(--succes); }
.message--error { background: var(--erreur-doux); border-color: transparent; color: var(--erreur); }

/* ------------------------------------------------------------ Formulaires */

.champ { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.champ > label { font-size: 12.5px; font-weight: 550; color: var(--texte-doux); }

.champ input[type="text"], .champ input[type="email"], .champ input[type="password"],
.champ input[type="number"], .champ select, .champ textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--bordure-forte);
  border-radius: var(--rayon-petit);
  background: var(--fond-panneau);
  color: var(--texte);
  font: inherit; font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s;
}
.champ input:focus, .champ select:focus, .champ textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-doux);
}
.champ .aide { font-size: 12px; color: var(--texte-tres-doux); }
.champ .erreur { font-size: 12px; color: var(--erreur); }
.champ ul { margin: 0; padding-left: 16px; }

.grille-champs { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

/* ------------------------------------------- Page connexion / inscription */

.page-auth {
  min-height: calc(100vh - var(--entete-hauteur));
  display: grid; place-items: center;
  padding: 40px 24px 80px;
}
.carte-auth { width: 100%; max-width: 420px; padding: 32px; }
.carte-auth__entete { margin-bottom: 24px; }
.carte-auth__entete p { margin: 6px 0 0; color: var(--texte-doux); font-size: 13.5px; }
.carte-auth .bouton { width: 100%; justify-content: center; padding: 10px; }
.carte-auth__pied { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--bordure); font-size: 13px; color: var(--texte-doux); text-align: center; }

/* ------------------------------------------------------ Liste campagnes */

.titre-page { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.titre-page p { margin: 6px 0 0; color: var(--texte-doux); }

.cartes { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }

.carte { padding: 20px; display: flex; flex-direction: column; gap: 14px; transition: border-color .15s, transform .15s; }
.carte:hover { border-color: var(--bordure-forte); transform: translateY(-1px); }
.carte__entete { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.carte__actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* Icône seule, réutilisable partout où une action discrète est nécessaire
   (bouton-supprimer suit le même principe mais reste local à la grille). */
.bouton-icone {
  width: 26px; height: 26px;
  display: grid; place-items: center; flex: none;
  border-radius: 6px;
  color: var(--texte-tres-doux);
  transition: background-color .12s, color .12s;
}
.bouton-icone:hover { background-color: var(--accent-doux); color: var(--accent); text-decoration: none; }
.bouton-icone svg { width: 14px; height: 14px; }
.carte__titre { font-size: 15px; font-weight: 600; color: var(--texte); }
.carte__titre:hover { color: var(--accent); text-decoration: none; }
.carte__exercice { font-size: 12px; color: var(--texte-tres-doux); }
.carte__description { font-size: 13px; color: var(--texte-doux); margin: 0; }
.carte__stats { display: flex; gap: 24px; padding-top: 14px; border-top: 1px solid var(--bordure); }
.carte__stat { display: flex; flex-direction: column; }
.carte__stat b { font-size: 16px; font-weight: 650; font-variant-numeric: tabular-nums; }
.carte__stat span { font-size: 11.5px; color: var(--texte-tres-doux); text-transform: uppercase; letter-spacing: .04em; }

.vide {
  padding: 56px 24px;
  text-align: center;
  color: var(--texte-doux);
}
.vide h2 { margin-bottom: 6px; }

/* ------------------------------------------------------- Grille de saisie */

.barre-outils {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.barre-outils__titre { display: flex; flex-direction: column; gap: 4px; margin-right: auto; }
.barre-outils__meta { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--texte-tres-doux); }

.recherche { position: relative; }
.recherche input {
  width: 240px;
  padding: 8px 11px 8px 32px;
  border: 1px solid var(--bordure-forte);
  border-radius: var(--rayon-petit);
  background: var(--fond-panneau);
  color: var(--texte);
  font: inherit; font-size: 13px;
}
.recherche input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-doux); }
.recherche svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--texte-tres-doux); pointer-events: none;
}

.indicateur-sauvegarde {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--texte-tres-doux);
  min-width: 130px;
}
.indicateur-sauvegarde::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: var(--texte-tres-doux);
}
.indicateur-sauvegarde[data-etat="enregistrement"]::before { background: var(--accent); animation: pulse 1s infinite; }
.indicateur-sauvegarde[data-etat="enregistre"]::before { background: var(--succes); }
.indicateur-sauvegarde[data-etat="erreur"]::before { background: var(--erreur); }
@keyframes pulse { 50% { opacity: .3; } }

.cadre-grille {
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  background: var(--fond-panneau);
  box-shadow: var(--ombre);
  overflow: auto;
  max-height: calc(100vh - var(--entete-hauteur) - 190px);
}

table.grille {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

table.grille thead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--fond-doux);
  border-bottom: 1px solid var(--bordure-forte);
  border-right: 1px solid var(--bordure);
  padding: 10px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--texte-doux);
  white-space: nowrap;
}
table.grille thead th:last-child { border-right: none; }

table.grille td {
  border-bottom: 1px solid var(--bordure);
  border-right: 1px solid var(--bordure);
  padding: 0;
  vertical-align: middle;
}
table.grille td:last-child { border-right: none; }
table.grille tbody tr:hover td { background: var(--fond-survol); }
table.grille tbody tr.est-masquee { display: none; }

.col-num { width: 44px; text-align: center; color: var(--texte-tres-doux); font-size: 11.5px; }
.col-num--corps {
  padding: 0 6px !important;
  text-align: center;
  color: var(--texte-tres-doux);
  background: var(--fond-doux);
  position: sticky; left: 0; z-index: 2;
}
table.grille tbody tr:hover .col-num--corps { background: var(--fond-survol); }

/* Cellules éditables : l'input remplit toute la cellule, sans bordure propre. */
.cellule {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 2px solid transparent;
  border-radius: 0;
  background-color: transparent;
  color: var(--texte);
  font: inherit;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  appearance: none;
}
/* `background-color` et non le raccourci `background` : ce dernier
   réinitialiserait `background-image`, qui porte le chevron des listes. */
.cellule:hover:not(:disabled) { background-color: color-mix(in srgb, var(--accent) 4%, transparent); }
.cellule:focus {
  outline: none;
  border-color: var(--accent);
  background-color: var(--fond-panneau);
  box-shadow: inset 0 0 0 1px var(--accent);
  position: relative; z-index: 1;
}
.cellule:disabled { color: var(--texte-doux); cursor: default; }
.cellule--nombre { text-align: right; }
.cellule--select {
  padding-right: 22px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b95a3' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 13px;
}
.cellule--vide { color: var(--texte-tres-doux); }

/* Le menu déroulant natif hérite du fond de son <select>. Celui des cellules
   étant transparent, il faut colorer les options : sinon, en thème sombre,
   Chromium peint un menu blanc sous un texte clair — donc illisible. */
.cellule--select option,
.champ select option {
  background-color: var(--fond-panneau);
  color: var(--texte);
}

.cellule-calculee {
  display: block;
  padding: 0 10px;
  height: 38px;
  line-height: 38px;
  text-align: right;
  font-weight: 600;
  color: var(--texte);
  background: color-mix(in srgb, var(--accent) 3%, transparent);
}

.cellule.est-invalide { box-shadow: inset 0 0 0 2px var(--erreur); }

/* Cellule Matériel : liste déroulante, ou champ libre quand l'entrée choisie
   est marquée « saisie libre » (« à décrire »). Les deux ne coexistent jamais. */
.cellule-materiel { position: relative; }

.saisie-libre { display: flex; align-items: center; }
.saisie-libre .cellule { flex: 1; min-width: 0; }

.bouton-retour-liste {
  flex: none;
  width: 26px; height: 26px;
  margin-right: 4px;
  display: grid; place-items: center;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--texte-tres-doux);
  cursor: pointer;
  transition: background-color .12s, color .12s;
}
.bouton-retour-liste:hover { background-color: var(--accent-doux); color: var(--accent); }
.bouton-retour-liste svg { width: 14px; height: 14px; }

.bouton-supprimer {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  margin: 0 auto;
  border: none; background: none;
  border-radius: 6px;
  color: var(--texte-tres-doux);
  cursor: pointer;
  transition: background-color .12s, color .12s;
}
.bouton-supprimer:hover { background-color: var(--erreur-doux); color: var(--erreur); }
.bouton-supprimer:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.bouton-supprimer svg { width: 14px; height: 14px; }

table.grille tfoot td {
  position: sticky; bottom: 0; z-index: 3;
  background: var(--fond-doux);
  border-top: 1px solid var(--bordure-forte);
  padding: 12px 10px;
  font-weight: 650;
}
.total-libelle { text-align: right; color: var(--texte-doux); font-weight: 550; text-transform: uppercase; font-size: 11.5px; letter-spacing: .04em; }
.total-montant { text-align: right; font-size: 15px; white-space: nowrap; }

.pied-grille {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-top: 14px; flex-wrap: wrap;
}
.pied-grille__info { font-size: 12.5px; color: var(--texte-tres-doux); }

/* --------------------------------------------------------------- Historique */

.filtre-dates {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 14px 16px;
  background: var(--fond-panneau);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
}
.filtre-dates__champ { display: flex; flex-direction: column; gap: 5px; }
.filtre-dates__champ label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--texte-doux);
}
.filtre-dates input[type="date"] {
  padding: 8px 11px;
  border: 1px solid var(--bordure-forte);
  border-radius: var(--rayon-petit);
  background: var(--fond-panneau);
  color: var(--texte);
  font: inherit;
  font-size: 13.5px;
}
.filtre-dates input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-doux);
}

.journal { display: flex; flex-direction: column; }
.journal__entree {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 16px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--bordure);
  font-size: 13px;
}
.journal__entree:last-child { border-bottom: none; }
.journal__date { color: var(--texte-tres-doux); font-size: 12.5px; }
.journal__detail b { font-weight: 600; }
/* Rattachement de l'auteur, tel qu'il était au moment de la modification. */
.journal__rattachement {
  display: block;
  margin-top: 1px;
  color: var(--texte-tres-doux);
  font-size: 12px;
}
.journal__valeur {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--fond-doux);
  font-size: 12px;
}
.journal__valeur--avant { text-decoration: line-through; color: var(--texte-tres-doux); }
.journal__valeur--apres { background: var(--succes-doux); color: var(--succes); }

/* -------------------------------------------------------------- Chargement */

/* Le libellé est masqué sans être retiré : la largeur du bouton ne bouge pas,
   donc la mise en page ne saute pas au moment du clic. */
.est-en-cours {
  position: relative;
  pointer-events: none;
  color: transparent !important;
}
.est-en-cours > * { visibility: hidden; }

.est-en-cours::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 15px;
  height: 15px;
  margin: -8px 0 0 -8px;
  border: 2px solid color-mix(in srgb, var(--spinner, currentColor) 28%, transparent);
  border-top-color: var(--spinner, currentColor);
  border-radius: 50%;
  animation: rotation .6s linear infinite;
}

.bouton-supprimer.est-en-cours { --spinner: var(--erreur); }
.bouton-supprimer.est-en-cours::after { width: 13px; height: 13px; margin: -7px 0 0 -7px; }

@keyframes rotation { to { transform: rotate(360deg); } }

/* Sans animation : le disque pulse au lieu de tourner. */
@media (prefers-reduced-motion: reduce) {
  .est-en-cours::after {
    animation: pulse 1s ease-in-out infinite;
    border-top-color: var(--spinner, currentColor);
  }
}

/* ------------------------------------------------------------------ Modale */

.modale {
  width: min(430px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  background: var(--fond-panneau);
  color: var(--texte);
  box-shadow: var(--ombre-forte);
}
.modale[open] { animation: entree-modale .16s ease-out; }

.modale::backdrop {
  background: rgba(16, 24, 40, .45);
  backdrop-filter: blur(2px);
}
[data-theme="sombre"] .modale::backdrop { background: rgba(0, 0, 0, .62); }

.modale__titre { font-size: 17px; font-weight: 650; margin-bottom: 8px; }
.modale__texte { margin: 0 0 22px; color: var(--texte-doux); font-size: 13.5px; }
.modale__actions { display: flex; justify-content: flex-end; gap: 8px; }
/* Rappelle la ligne visée : on ne supprime pas « une ligne » en aveugle. */
.modale__resume {
  display: block;
  margin-bottom: 6px;
  color: var(--texte);
  font-size: 13.5px;
  overflow-wrap: anywhere;
}

@keyframes entree-modale {
  from { opacity: 0; transform: translateY(-6px) scale(.98); }
}

/* ------------------------------------------------------------------ Toasts */

.toasts {
  position: fixed; right: 20px; bottom: 20px; z-index: 90;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 11px 16px;
  border-radius: var(--rayon-petit);
  background: var(--fond-panneau);
  border: 1px solid var(--bordure);
  box-shadow: var(--ombre-forte);
  font-size: 13px;
  max-width: 340px;
  animation: entree-toast .2s ease-out;
}
.toast--erreur { border-color: var(--erreur); color: var(--erreur); }
.toast--succes { border-color: var(--succes); color: var(--succes); }
@keyframes entree-toast { from { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------------------- Responsive */

@media (max-width: 760px) {
  .nav { display: none; }
  .enveloppe { padding: 24px 16px 64px; }
  .grille-champs { grid-template-columns: 1fr; }
  .recherche input { width: 100%; }
  .barre-outils { flex-direction: column; align-items: stretch; }
  .barre-outils__titre { margin-right: 0; }
}
