/* =========================================================================
   Thème — VizoraMail
   ========================================================================= */
:root {
  --navy:        #1f3a5f;  /* bleu marine foncé  (Viz)  */
  --navy-clair:  #2c4f7c;
  --teal:        #2dd4bf;  /* vert/teal clair    (ora)  */
  --teal-fonce:  #14b8a6;
  --texte:       #1f2937;
  --texte-doux:  #6b7280;
  --fond:        #f4f6f8;
  --carte:       #ffffff;
  --bordure:     #e3e8ee;
  --sidebar-l:   212px;
  --topbar-h:    62px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: system-ui, "Segoe UI", Arial, sans-serif;
  margin: 0;
  background: var(--fond);
  color: var(--texte);
}

h1 { color: var(--navy); font-size: 26px; margin: 0 0 18px; }
h2 { color: var(--navy-clair); margin-top: 28px; }
a  { color: var(--teal-fonce); }

/* =========================================================================
   LOGO « VizoraMail »  — police stylée, sans gras ; le « V » grand,
   « izora » en blanc léger, « Mail » en teal.
   ========================================================================= */
.logo {
  font-family: "Josefin Sans", system-ui, "Segoe UI", sans-serif;
  font-weight: 400;
  letter-spacing: 1px;
  line-height: 1;
  display: inline-flex;
  align-items: baseline;
  color: #fff;
}
.logo .v {
  font-size: 40px;
  color: var(--teal);
  margin-right: 1px;
}
.logo .reste {
  font-size: 25px;
  font-weight: 300;
  color: #ffffff;
}
.logo .mail {
  font-size: 25px;
  font-weight: 400;
  color: var(--teal);
}

/* =========================================================================
   MENU LATÉRAL (sidebar)
   ========================================================================= */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-l);
  background: var(--navy);
  color: #cfe0f5;
  display: flex;
  flex-direction: column;
  z-index: 30;
}

/* En-tête du logo, même marine que le menu (bande continue avec la topbar) */
.sidebar-haut {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 20px;
  background: var(--navy);
  border-bottom: 1px solid rgba(255, 255, 255, .10);
}

.menu {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.lien {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #cfe0f5;
  text-decoration: none;
  font-size: 14px;
  line-height: 1;
  transition: background .15s, color .15s;
}
.lien svg { width: 18px; height: 18px; flex-shrink: 0; }
.lien:hover { background: rgba(255, 255, 255, .08); color: #fff; }

/* Séparateur dans le menu latéral : indique l'agence gérée par l'admin */
.menu-separateur {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--teal);
  padding: 10px 12px 3px;
  margin-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, .10);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Lien "Quitter" rouge discret dans le menu admin */
.lien-quitter { color: #f87171 !important; }
.lien-quitter:hover { background: rgba(248, 113, 113, .12) !important; color: #fca5a5 !important; }

/* Élément du menu actuellement sélectionné — reste mis en évidence */
.lien.actif {
  background: var(--teal);
  color: var(--navy);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(45, 212, 191, .35);
}

/* =========================================================================
   BARRE HORIZONTALE DU HAUT (topbar)
   ========================================================================= */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-l);
  right: 0;
  height: var(--topbar-h);
  background: var(--navy);
  box-shadow: 0 1px 6px rgba(0, 0, 0, .15);
  display: flex;
  align-items: center;
  padding: 0 22px;
  z-index: 20;
}

/* Bloc aligné à droite : agence + déconnexion */
.topbar-droite {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ident {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 320px;
  padding: 7px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .10);
  color: #fff;
  font-weight: 500;
  font-size: 14px;
}
.ident svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--teal); }
.ident span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Badge topbar indiquant l'agence gérée par l'admin */
.badge-agence-geree {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(45, 212, 191, .15);
  color: var(--teal);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid rgba(45, 212, 191, .30);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge-agence-geree svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .30);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, border-color .15s;
}
.btn-logout svg { width: 18px; height: 18px; }
.btn-logout:hover { background: #b91c1c; border-color: #b91c1c; }

.burger { display: none; cursor: pointer; color: #fff; margin-right: 14px; }

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 25;
}

/* =========================================================================
   ZONE DE CONTENU
   ========================================================================= */
.avec-menu main {
  margin-left: var(--sidebar-l);
  padding: calc(var(--topbar-h) + 24px) 28px 48px;
  max-width: 1280px;
}
.sans-menu main {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
}

/* =========================================================================
   ALERTES — flottantes en haut au milieu, comme le toast
   ========================================================================= */
.alertes-flottantes {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}
.alerte {
  padding: 11px 16px;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .15);
  font-size: 14px;
  transition: opacity .2s ease, transform .2s ease;
}
.alerte.ok     { background: #e3f6e8; color: #1d6b34; }
.alerte.erreur { background: #fde8e8; color: #a12121; }
.alerte.masquee { opacity: 0; transform: translateY(-8px); }

/* Confirmation flottante (changement d'état sans rechargement) */
#toast-etat {
  position: fixed;
  top: 24px;
  left: 50%;
  z-index: 300;
  padding: 11px 16px;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .15);
  font-size: 14px;
  opacity: 0;
  transform: translate(-50%, -8px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}
#toast-etat.ok     { background: #e3f6e8; color: #1d6b34; opacity: 1; transform: translate(-50%, 0); }
#toast-etat.erreur { background: #fde8e8; color: #a12121; opacity: 1; transform: translate(-50%, 0); }

/* =========================================================================
   TABLEAUX
   ========================================================================= */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--carte);
  margin-top: 12px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .07);
}
th, td {
  text-align: left;
  padding: 13px 16px;
  border-bottom: 1px solid var(--bordure);
  font-size: 14px;
  vertical-align: middle;
}
/* En-tête de tableau : couleur claire, moderne */
thead th {
  background: linear-gradient(180deg, #f3f7fc, #e9f0f8);
  color: var(--navy-clair);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 2px solid var(--bordure);
  white-space: nowrap;
}
/* Compat : tableaux sans thead (anciennes pages) */
th { background: #eef2f7; color: var(--navy-clair); font-size: 13px; }
tbody tr { transition: background .12s; }
tbody tr:nth-child(even) td { background: #fbfcfe; }
tbody tr:hover td { background: #f0f7f6; }
tr:last-child td { border-bottom: 0; }
td .actions-ligne { display: flex; gap: 4px; align-items: center; flex-wrap: nowrap; justify-content: flex-end; white-space: nowrap; }
td:last-child { white-space: nowrap; width: 1%; }
.cellule-vide { color: var(--texte-doux); text-align: center; padding: 26px 12px; }

/* Cellule de date : reste sur une seule ligne, jamais coupée */
.col-date { white-space: nowrap; }

/* Texte tronqué « … » : ne saute jamais de ligne ; au survol, le texte
   complet apparaît dans une infobulle (attribut title de la cellule). */
.tronque {
  display: inline-block;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
/* La colonne « Objet » dispose d'un peu plus d'espace que les autres */
.tronque-objet { max-width: 320px; }

/* =========================================================================
   BARRE D'OUTILS (filtre + bouton « + »)  — en haut de chaque liste
   ========================================================================= */
.entete-page {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 6px;
}
.entete-page h1 { margin: 0; }

.barre-outils {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 14px 0 4px;
  padding: 12px 14px;
  background: var(--carte);
  border: 1px solid var(--bordure);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .05);
}
.zone-filtre { display: flex; align-items: center; gap: 10px; flex: 1 1 260px; flex-wrap: wrap; }

/* Rangée « filtres + bouton » : le bouton Ajouter est hors du conteneur de
   filtres, séparé par un petit espace (gap) */
.barre-page {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin: 14px 0 4px;
}
.barre-page .barre-outils { flex: 1 1 260px; margin: 0; min-width: 0; }
.barre-page .btn-plus { margin-left: 0; flex-shrink: 0; padding-top: 12px; padding-bottom: 12px; }

/* Groupes de puces poussés à droite, sur la même ligne que la recherche :
   la rangée ne casse pas, ce sont les puces qui se replient à droite */
.barre-page .zone-filtre { flex-wrap: nowrap; }
.groupe-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-left: auto;
  flex: 0 1 auto;
}
/* La recherche s'étire et occupe tout l'espace libre à gauche des puces */
.barre-page .champ-filtre { flex: 1 1 200px; min-width: 150px; }

/* Puces compactes pour que recherche + état + date tiennent sur une ligne */
.barre-page .puce-etat { padding: 7px 11px; font-size: 12px; }
.barre-page .filtres-etat { gap: 5px; }

.champ-filtre {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 220px;
  min-width: 180px;
}
.champ-filtre svg {
  position: absolute;
  left: 11px;
  width: 17px; height: 17px;
  color: var(--texte-doux);
  pointer-events: none;
}
.champ-filtre input[type=text] {
  width: 100%;
  padding: 9px 12px 9px 36px;
  margin: 0;
  border: 1px solid #d5dde6;
  border-radius: 9px;
  font-size: 14px;
  background: #f8fafc;
}
.champ-filtre input:focus { background: #fff; }

.select-filtre {
  padding: 9px 12px;
  border: 1px solid #d5dde6;
  border-radius: 9px;
  font-size: 14px;
  background: #f8fafc;
  color: var(--texte);
  cursor: pointer;
}

/* Filtre d'état sous forme de puces colorées */
.filtres-etat { display: inline-flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.puce-etat {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid #d5dde6;
  border-radius: 999px;
  background: #fff;
  color: var(--texte-doux);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
}
.puce-etat::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--puce-couleur, #94a3b8);
}
.puce-tous::before { display: none; }
.puce-detecte { --puce-couleur: #1d4ed8; }
.puce-attente { --puce-couleur: #b45309; }
.puce-termine { --puce-couleur: #1d6b34; }

/* Survol : la puce prend sa couleur d'état (sinon le button:hover global
   applique un fond navy avec du texte sombre, illisible) */
.puce-etat:hover {
  border-color: transparent;
  background: var(--puce-couleur, var(--navy));
  color: #fff;
}
.puce-etat:hover::before { background: rgba(255, 255, 255, .9); }

/* Puce active : pastille pleine dans la couleur de l'état */
.puce-etat.actif {
  color: #fff;
  border-color: transparent;
  background: var(--puce-couleur, var(--navy));
  box-shadow: 0 2px 8px rgba(15, 23, 42, .18);
}
.puce-etat.actif::before { background: rgba(255, 255, 255, .9); }

/* Filtre par date : mêmes puces, couleur neutre ardoise */
.puce-date { --puce-couleur: #475569; }
.puce-date::before { display: none; }

/* Séparateur vertical entre les groupes de puces */
.sep-filtre { width: 1px; height: 22px; background: var(--bordure); }

/* Panneau « Avancé » : intervalle Du / Au sur sa propre ligne */
.filtre-date-perso {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px dashed #d5dde6;
}
.filtre-date-perso[hidden] { display: none; }
.filtre-date-perso label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--texte-doux);
}
.filtre-date-perso input[type=date] {
  padding: 7px 10px;
  margin: 0;
  border: 1px solid #d5dde6;
  border-radius: 8px;
  font-size: 13px;
  background: #f8fafc;
  color: var(--texte);
}
.btn-effacer-dates {
  background: none;
  border: 1px solid #d5dde6;
  color: var(--texte-doux);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}
.btn-effacer-dates:hover { background: #f1f5f9; border-color: #b6c2d0; color: var(--texte); }

/* Bouton « + Ajouter » (à droite) */
.btn-plus {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 10px 16px 10px 13px;
  background: var(--teal-fonce);
  color: #fff;
  border: 0;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(20, 184, 166, .35);
  transition: background .15s, transform .05s;
}
.btn-plus:hover { background: #0f9e8e; }
.btn-plus:active { transform: translateY(1px); }
.btn-plus svg { width: 18px; height: 18px; }

/* =========================================================================
   ÉTIQUETTES D'ÉTAT (badges)
   ========================================================================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.badge-detecte   { background: #e6f0fb; color: #1d4ed8; }
.badge-attente   { background: #fef3e2; color: #b45309; }
.badge-termine   { background: #e4f7ec; color: #1d6b34; }
.badge-neutre    { background: #eef1f5; color: #4b5563; }
.badge-actif     { background: #e4f7ec; color: #1d6b34; }
.badge-inactif   { background: #f3f4f6; color: #6b7280; }
.badge-suspendue { background: #fef3e2; color: #b45309; }
.badge-gmail     { background: #fce8e6; color: #c5221f; }
.badge-outlook   { background: #e3f0ff; color: #0f5db5; }

/* Menu déroulant pour changer l'état directement dans le tableau */
.form-etat { margin: 0; }
.select-etat {
  padding: 6px 28px 6px 10px;
  border: 1px solid #d5dde6;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  background: #f8fafc;
  color: var(--navy-clair);
  cursor: pointer;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
}
.select-etat:focus { background-color: #fff; outline: 2px solid var(--teal-fonce); }

/* Boutons d'action discrets dans les lignes */
.lien-action {
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  padding: 5px 10px;
  border-radius: 7px;
  border: 1px solid var(--bordure);
  color: var(--navy-clair);
  background: #fff;
  transition: background .12s, border-color .12s;
}
.lien-action:hover { background: #eef4f3; border-color: var(--teal); }
.lien-action.danger { color: #b91c1c; }
.lien-action.danger:hover { background: #fde8e8; border-color: #f0b4b4; }
.lien-action.succes { color: #1d6b34; }
.lien-action.succes:hover { background: #e4f7ec; border-color: #a7d8b8; }

/* Ligne d'une agence suspendue : légèrement estompée pour la distinguer d'un
   coup d'œil des agences actives. */
tr.ligne-suspendue > td { background: #fbfbfc; color: #9aa1ab; }
tr.ligne-suspendue > td:first-child { box-shadow: inset 3px 0 0 #d97706; }

/* Boutons d'action en icône seule (lignes de tableau) */
.btn-icone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--bordure);
  background: #fff;
  color: var(--navy-clair);
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.btn-icone svg { width: 17px; height: 17px; }
.btn-icone:hover { background: #eef4f3; border-color: var(--teal); color: var(--teal-fonce); }
.btn-icone.danger { color: #b91c1c; }
.btn-icone.danger:hover { background: #fde8e8; border-color: #f0b4b4; color: #b91c1c; }

/* =========================================================================
   FENÊTRE MODALE (popup d'ajout)
   ========================================================================= */
.modal-fond {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(2px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 60;
}
.modal-fond.ouverte { display: flex; }
body.modal-active { overflow: hidden; }

.modal {
  background: var(--carte);
  width: 100%;
  max-width: 520px;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
  animation: modal-apparition .18s ease;
  margin: auto 0;
}
@keyframes modal-apparition {
  from { opacity: 0; transform: translateY(-12px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.modal-tete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--bordure);
}
.modal-tete h2 { margin: 0; font-size: 18px; color: var(--navy); }
.modal-fermer {
  background: transparent;
  border: 0;
  color: var(--texte-doux);
  cursor: pointer;
  padding: 4px;
  border-radius: 7px;
  line-height: 0;
}
.modal-fermer:hover { background: #f1f3f6; color: var(--texte); }
.modal-fermer svg { width: 20px; height: 20px; }

.modal-corps { padding: 20px 22px 22px; }
/* À l'intérieur d'une modale, le formulaire prend toute la largeur */
.modal-corps .formulaire {
  box-shadow: none;
  padding: 0;
  max-width: 100%;
  background: transparent;
}
.modal-corps .formulaire button { width: 100%; margin-top: 6px; }
.modal-corps select {
  width: 100%; padding: 9px 10px; margin-top: 4px;
  border: 1px solid #c7d0da; border-radius: 6px; font-size: 14px; background: #fff;
}

/* Modal élargie (détail email) */
.modal-large {
  max-width: 860px;
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
}
.modal-large .modal-corps {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* Bouton œil (voir le message) */
.btn-voir {
  background: transparent;
  border: 1px solid var(--bordure);
  border-radius: 7px;
  color: var(--texte-doux);
  cursor: pointer;
  padding: 5px 7px;
  line-height: 0;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-voir:hover { background: #e8f4fd; color: var(--navy); border-color: var(--navy-clair); }
.btn-voir svg { width: 16px; height: 16px; }

/* Métadonnées de l'email */
.detail-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0;
  border: 1px solid var(--bordure);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 20px;
  font-size: 14px;
}
.detail-ligne {
  display: contents;
}
.detail-ligne:not(:last-child) .detail-label,
.detail-ligne:not(:last-child) .detail-valeur {
  border-bottom: 1px solid var(--bordure);
}
.detail-label {
  background: #f7f9fb;
  color: var(--texte-doux);
  font-weight: 600;
  padding: 10px 14px;
  white-space: nowrap;
}
.detail-valeur {
  background: var(--carte);
  padding: 10px 14px;
  word-break: break-word;
}
.detail-valeur ul.liste-pj { margin: 0; padding-left: 18px; }
.detail-valeur ul.liste-pj li { margin: 2px 0; }

/* Zone contenu du message */
.detail-contenu h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--navy-clair);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin: 0 0 10px;
}
.iframe-email {
  width: 100%;
  min-height: 60px;
  border: 1px solid var(--bordure);
  border-radius: 8px;
  background: #fff;
  display: block;
}
.corps-texte {
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.6;
  background: #f7f9fb;
  border: 1px solid var(--bordure);
  border-radius: 8px;
  padding: 14px;
  overflow-x: auto;
  margin: 0;
  display: inline-block;
  width: 100%;
  box-sizing: border-box;
}

/* =========================================================================
   FORMULAIRES & CARTES
   ========================================================================= */
.formulaire, .carte-connexion {
  background: var(--carte);
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
  max-width: 520px;
}
.formulaire label, .carte-connexion label {
  display: block; margin-bottom: 14px; font-size: 14px; color: #444;
}
input[type=text], input[type=email], input[type=password],
input[type=tel], input:not([type]) {
  width: 100%; padding: 9px 10px; margin-top: 4px;
  border: 1px solid #c7d0da; border-radius: 6px; font-size: 14px;
}
input:focus { outline: 2px solid var(--teal-fonce); outline-offset: 0; border-color: transparent; }

button {
  background: var(--navy);
  color: #fff; border: 0;
  padding: 10px 18px; border-radius: 7px;
  cursor: pointer; font-size: 15px;
  transition: background .15s;
}
button:hover { background: var(--navy-clair); }
.aide { color: var(--texte-doux); font-size: 13px; }

.carte-connexion { margin: 8vh auto 0; }

/* Lien de retour vers la page d'accueil publique, sous le formulaire */
.retour-accueil { margin: 16px 0 0; text-align: center; font-size: 13.5px; }
.retour-accueil a { color: var(--texte-doux); text-decoration: none; }
.retour-accueil a:hover { color: var(--teal-fonce); }

/* Cartes du tableau de bord */
.cartes { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 20px; }
.carte {
  background: var(--carte);
  padding: 20px;
  border-radius: 10px;
  flex: 1 1 200px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}
.carte .grand { font-size: 34px; font-weight: 700; color: var(--navy); }

/* En-tête de carte avec pastille d'icône */
.carte-tete { display: flex; align-items: center; gap: 12px; }
.carte-icone {
  width: 42px; height: 42px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e6f0fb;
  color: var(--navy);
  flex-shrink: 0;
}
.carte-icone svg { width: 22px; height: 22px; }
.carte-icone.teal { background: #d8f7f1; color: var(--teal-fonce); }
.carte-icone.ambre { background: #fef3e2; color: #b45309; }
.carte .libelle { color: var(--texte-doux); font-size: 14px; }
.carte .lien-carte {
  margin-top: auto;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
/* Répartition des états sous le compteur d'emails */
.repartition { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.repartition .badge { font-size: 11px; padding: 3px 9px; }

/* =========================================================================
   RESPONSIVE
   ========================================================================= */
@media (max-width: 860px) {
  /* La sidebar coulisse depuis la gauche, masquée par défaut */
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 2px 0 16px rgba(0, 0, 0, .25);
  }
  /* La topbar prend toute la largeur et affiche le bouton menu */
  .topbar { left: 0; }
  .burger { display: inline-flex; }

  .avec-menu main {
    margin-left: 0;
    padding: calc(var(--topbar-h) + 18px) 16px 40px;
    max-width: 100%;
  }

  /* Quand la case est cochée : on affiche le menu + le voile */
  #menu-toggle:checked ~ .sidebar  { transform: translateX(0); }
  #menu-toggle:checked ~ .overlay  { display: block; }

  /* Tableaux : défilement horizontal pour ne rien couper */
  table { display: block; overflow-x: auto; white-space: nowrap; }
  /* Sur mobile (pas de survol), on montre le texte complet via le défilement */
  .tronque, .tronque-objet { max-width: none; overflow: visible; }

  .formulaire, .carte-connexion { max-width: 100%; }

  /* Barre d'outils : le bouton « + » passe en pleine largeur */
  .btn-plus { margin-left: 0; width: 100%; justify-content: center; }
  .zone-filtre { flex: 1 1 100%; }
  /* Sur petit écran, la recherche et les puces s'empilent à nouveau */
  .barre-page .zone-filtre { flex-wrap: wrap; }
  .barre-page .champ-filtre { flex: 1 1 100%; }
  .groupe-chips { justify-content: flex-start; }
}

@media (max-width: 520px) {
  /* Sur très petit écran, on garde l'icône de déconnexion, on cache le texte */
  .btn-logout span { display: none; }
  .btn-logout { padding: 8px; }
  .ident { max-width: 170px; }
}

@media (max-width: 420px) {
  h1 { font-size: 22px; }
  .carte .grand { font-size: 28px; }
}

/* =========================================================================
   TABLEAU DE BORD ADMIN
   ========================================================================= */

.db-entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}
.db-sous-titre {
  color: var(--texte-doux);
  font-size: 14px;
  margin: 4px 0 0;
}

/* KPI */
.db-kpi {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-carte {
  background: var(--carte);
  border: 1px solid var(--bordure);
  border-radius: 12px;
  padding: 20px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .07);
  transition: box-shadow .2s, transform .2s;
}
.kpi-carte:hover { box-shadow: 0 6px 18px rgba(0, 0, 0, .10); transform: translateY(-1px); }
.kpi-icone {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.kpi-icone svg { width: 22px; height: 22px; }
.kpi-bleu   { background: #e6f0fb; color: var(--navy); }
.kpi-teal   { background: #d8f7f1; color: var(--teal-fonce); }
.kpi-violet { background: #ede9fe; color: #6d28d9; }
.kpi-ambre  { background: #fef3e2; color: #b45309; }
.kpi-info   { display: flex; flex-direction: column; min-width: 0; }
.kpi-valeur { font-size: 30px; font-weight: 700; color: var(--navy); line-height: 1; }
.kpi-label  { font-size: 13px; color: var(--texte-doux); margin-top: 5px; }
.kpi-detail { font-size: 12px; color: var(--texte-doux); margin-top: 2px; }
.kpi-aujourd-hui { color: #1d6b34 !important; font-weight: 600; }
.kpi-boites-ratio { font-weight: 600; }

/* Graphiques */
.db-graphiques {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.db-chart-carte {
  background: var(--carte);
  border: 1px solid var(--bordure);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .07);
}
.db-chart-titre {
  font-size: 12px;
  font-weight: 700;
  color: var(--navy-clair);
  margin: 0 0 14px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.db-legende {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}
.db-leg-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--texte-doux);
}
.db-leg-item span:not(.db-leg-dot) { flex: 1; }
.db-leg-item strong { color: var(--texte); font-size: 13px; }
.db-leg-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Rangée bas */
.db-bas {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 16px;
  align-items: start;
}
.db-section {
  background: var(--carte);
  border: 1px solid var(--bordure);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .07);
}
.db-section table { margin-top: 0; border-radius: 8px; }
.db-section-tete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.db-section-titre {
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
}
.db-voir-tout {
  font-size: 12px;
  font-weight: 600;
  color: var(--teal-fonce);
  text-decoration: none;
}
.db-voir-tout:hover { text-decoration: underline; }

/* Tableau à largeur contrainte : occupe 100 % de son conteneur et n'en
   déborde jamais — chaque cellule tronque son contenu avec « … ». */
.table-fixe {
  table-layout: fixed;
  width: 100%;
}
.table-fixe th,
.table-fixe td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.table-fixe .tronque { display: block; max-width: 100%; }

/* Liste emails récents */
.db-emails-recents {
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-height: 540px;
  overflow-y: auto;
}
.db-email-item {
  padding: 11px 13px;
  border: 1px solid var(--bordure);
  border-radius: 9px;
  background: #fafbfc;
  transition: background .12s;
}
.db-email-item:hover { background: #f0f7f6; border-color: var(--teal); }
.db-email-haut {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
  gap: 8px;
}
.db-email-agence {
  font-size: 10px;
  font-weight: 700;
  color: var(--navy-clair);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.db-email-objet {
  font-size: 13px;
  font-weight: 500;
  color: var(--texte);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 5px;
}
.db-email-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--texte-doux);
  gap: 8px;
}
.db-email-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 55%;
}
.db-email-meta span:last-child { flex-shrink: 0; max-width: none; }

/* =========================================================================
   BADGE COMPTEUR D'EMAILS PAR BOÎTE
   ========================================================================= */
.badge-nb-emails {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #f3f4f6;
  color: #9ca3af;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
  white-space: nowrap;
}
.badge-nb-emails svg { width: 13px; height: 13px; flex-shrink: 0; }
.badge-nb-emails:hover {
  background: #e6f0fb;
  color: var(--navy-clair);
  border-color: #bfcfe8;
}
.badge-nb-emails-actif {
  background: #e6f0fb;
  color: var(--navy);
  border-color: #bfcfe8;
}
.badge-nb-emails-actif:hover {
  background: #dbeafe;
  border-color: var(--navy-clair);
  box-shadow: 0 2px 8px rgba(31,58,95,.15);
}

/* =========================================================================
   LISTE D'EMAILS EN CARTES (dans le modal boîtes)
   ========================================================================= */
.emails-cartes {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.email-carte {
  display: flex;
  flex-shrink: 0;
  border: 1px solid var(--bordure);
  border-radius: 10px;
  background: var(--carte);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s, background .12s;
}
.email-carte:hover {
  box-shadow: 0 3px 14px rgba(0,0,0,.09);
  border-color: var(--teal);
  background: #f0fdfa;
}
.email-carte:hover .email-carte-voir-lien {
  color: var(--teal-fonce, #0f766e);
}

.email-carte-bord {
  width: 4px;
  flex-shrink: 0;
  background: #d1d5db;
}
.bord-detecte   { background: #1d4ed8; }
.bord-attente   { background: #b45309; }
.bord-termine   { background: #1d6b34; }

.email-carte-corps {
  flex: 1;
  padding: 11px 14px;
  min-width: 0;
}

.email-carte-haut {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 3px;
}
.email-carte-exp {
  font-size: 12px;
  font-weight: 700;
  color: var(--navy-clair);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.email-carte-date {
  font-size: 11px;
  color: var(--texte-doux);
  white-space: nowrap;
  flex-shrink: 0;
}

.email-carte-objet {
  font-size: 14px;
  font-weight: 600;
  color: var(--texte);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 6px;
}

.email-carte-bas {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}
.email-carte-client {
  font-size: 12px;
  color: var(--navy-clair);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
.email-carte-infos {
  font-size: 12px;
  color: var(--texte-doux);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.email-carte-actions { flex-shrink: 0; margin-left: auto; }

/* Chevron accordéon */
.email-carte-chevron {
  margin-left: auto;
  flex-shrink: 0;
  color: var(--texte-doux);
  line-height: 0;
  transition: color .15s;
}
.chevron-carte {
  width: 16px; height: 16px;
  transition: transform .2s ease;
  display: block;
}
/* Combinateurs enfants (>) : ne cibler QUE le chevron/détail de la carte
   ouverte elle-même, pas ceux des lignes imbriquées (emails/boîtes d'un
   passage déplié), qui gèrent leur propre état .ouverte. */
.email-carte.ouverte > .email-carte-corps > .email-carte-resume .chevron-carte {
  transform: rotate(180deg);
}
.email-carte.ouverte > .email-carte-corps > .email-carte-resume .email-carte-chevron {
  color: var(--teal-fonce, #0f766e);
}

/* Zone détail accordéon */
.email-carte-detail {
  display: none;
  border-top: 1px solid var(--bordure);
  margin-top: 10px;
  padding-top: 14px;
  cursor: default;
}
.email-carte.ouverte {
  border-color: var(--teal);
  box-shadow: 0 4px 18px rgba(0,0,0,.10);
  cursor: default;
}
.email-carte.ouverte > .email-carte-corps > .email-carte-resume {
  cursor: pointer;
}
.email-carte.ouverte > .email-carte-corps > .email-carte-detail {
  display: block;
}

/* Bouton retour dans le header de modal */
.btn-retour {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 1px solid var(--bordure);
  background: #f8fafc;
  color: var(--navy-clair);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .12s, border-color .12s;
}
.btn-retour svg { width: 16px; height: 16px; }
.btn-retour:hover { background: #eef4f3; border-color: var(--teal); color: var(--teal-fonce); }

/* =========================================================================
   INDICATEUR « NOUVEAU EMAIL » — point vert pulsant
   ========================================================================= */
.emails-col {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.point-nouveau {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.point-pulse-anneau {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #22c55e;
  opacity: 0.6;
  animation: pulse-anneau 1.6s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.point-pulse-centre {
  position: relative;
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #16a34a;
  flex-shrink: 0;
}

@keyframes pulse-anneau {
  0%   { transform: scale(1);   opacity: 0.6; }
  70%  { transform: scale(2.2); opacity: 0; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* Point dans la ligne des cartes email (entre expéditeur et date) */
.point-nouveau-carte {
  flex-shrink: 0;
}

/* Badge email avec nouveaux messages : légère surbrillance verte */
.badge-nb-emails-new {
  border-color: #86efac !important;
  background: #f0fdf4 !important;
  color: #15803d !important;
}
.badge-nb-emails-new:hover {
  background: #dcfce7 !important;
  border-color: #4ade80 !important;
  box-shadow: 0 2px 8px rgba(22, 163, 74, .20) !important;
}

/* Responsive dashboard admin */
@media (max-width: 1200px) {
  .db-kpi { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1000px) {
  .db-graphiques { grid-template-columns: 1fr 1fr; }
  .db-graphiques > .db-chart-carte:first-child { grid-column: 1 / -1; }
}
@media (max-width: 860px) {
  .db-bas { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .db-kpi { grid-template-columns: 1fr 1fr; }
  .db-graphiques { grid-template-columns: 1fr; }
  .db-kpi .kpi-valeur { font-size: 24px; }
}

/* =========================================================================
   HISTORIQUE DES TRAITEMENTS (admin) — passages > boîtes > emails (dépliables)
   ========================================================================= */
/* Compteur de sessions dans la barre d'outils */
.compteur-sessions {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--texte-doux);
  white-space: nowrap;
}

/* Repère rouge à gauche d'un traitement en erreur */
.bord-erreur { background: #c5221f; }

/* Passage (niveau 1) : type + cadence en titre */
.passage-carte > .email-carte-corps > .email-carte-resume .email-carte-exp {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.passage-cadence { font-size: 12px; color: var(--texte-doux); font-weight: 500; }
.passage-agences {
  color: var(--texte-doux);
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Carte de session/boîte : titre = agence, sous-titre = boîte */
.session-carte .email-carte-exp {
  font-size: 13.5px;
  color: var(--navy);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ico-agence { width: 14px; height: 14px; flex-shrink: 0; color: var(--navy-clair); }
.passage-carte .email-carte-objet,
.session-carte .email-carte-objet { display: flex; align-items: center; gap: 8px; white-space: normal; }

/* Bandeau de statistiques (replié), passe à la ligne si besoin */
.session-bas { flex-wrap: wrap; row-gap: 6px; }
.sstat {
  font-size: 12px;
  color: var(--texte-doux);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.sstat b { color: var(--navy); font-weight: 700; }
.sstat-det b { color: #1d6b34; }
.sstat-err b { color: #c5221f; }
.session-bas .sstat:not(:last-of-type)::after {
  content: "";
  width: 1px; height: 12px;
  background: var(--bordure);
  margin-left: 8px;
}
.session-bas .email-carte-chevron { margin-left: auto; }

/* Cartes imbriquées légèrement teintées pour matérialiser les niveaux */
.passage-carte.ouverte > .email-carte-corps > .email-carte-detail { background: #fbfdff; }
.session-carte.ouverte > .email-carte-corps > .email-carte-detail { background: #fcfdfd; }

/* Carte « Résumé & règles figées » repliée par défaut dans le détail d'une boîte :
   on déplie d'abord les emails, les détails restent accessibles d'un clic. */
.carte-infos { background: #f8fafc; }
.carte-infos > .email-carte-bord { background: #cbd5e1; }
.carte-infos-tete { width: 100%; }
.carte-infos .email-carte-infos { color: var(--navy-clair); font-size: 12.5px; flex: 1; }

/* Emails en lignes compactes : 1 email = 1 ligne, pour en voir le maximum
   à l'écran. Cliquable pour déplier sa règle figée juste en dessous. */
.emails-lignes { display: flex; flex-direction: column; gap: 4px; }
.email-ligne {
  border: 1px solid var(--bordure);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}
.email-ligne-tete {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  font-size: 12.5px;
  cursor: pointer;
}
.email-ligne:hover { border-color: var(--teal); }
.el-badge { font-size: 11px; padding: 2px 8px; flex-shrink: 0; min-width: 60px; text-align: center; }
.el-agence {
  font-weight: 600; color: var(--navy-clair);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 130px; flex-shrink: 0;
}
.el-boite {
  color: var(--teal-fonce);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 170px; flex-shrink: 0;
}
.el-exp {
  color: var(--navy);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 170px; flex-shrink: 0;
}
.el-objet {
  flex: 1; min-width: 60px; color: #475569;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.el-regle {
  color: #64748b;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 150px; flex-shrink: 0;
}
.el-date { color: #94a3b8; font-size: 11.5px; white-space: nowrap; flex-shrink: 0; }
.entete-emails { margin: 2px 0 10px; font-size: 13px; color: var(--navy); }
.email-ligne .email-carte-chevron { flex-shrink: 0; }
.email-ligne.ouverte .chevron-carte { transform: rotate(180deg); }
.email-ligne .email-carte-detail {
  display: none;
  margin: 0; padding: 0 10px 10px;
  border-top: 1px solid var(--bordure);
}
.email-ligne.ouverte { border-color: var(--teal); }
.email-ligne.ouverte .email-carte-detail { display: block; padding-top: 10px; }

/* Onglets du détail d'un passage : Emails analysés / Boîtes traitées */
.onglets-detail {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--bordure);
}
.onglet {
  appearance: none;
  border: none;
  background: none;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--texte-doux);
  padding: 6px 10px 8px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .12s, border-color .12s;
}
.onglet:hover { color: var(--navy); }
.onglet-actif { color: var(--teal-fonce); border-bottom-color: var(--teal); }

/* Pagination — liste des passages (bas de page) et pagers internes des onglets */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 18px 0 6px;
}
.page-lien {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--bordure);
  border-radius: 8px;
  background: #fff;
  color: var(--navy);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
a.page-lien:hover,
button.page-lien:hover:not(:disabled) { border-color: var(--teal); background: #f0fdfa; }
.page-actif { background: var(--teal); border-color: var(--teal); color: var(--navy); cursor: default; }
.page-inactif { opacity: .45; cursor: default; pointer-events: none; }
.page-ellipse { color: var(--texte-doux); padding: 0 2px; align-self: center; }
.page-info { font-size: 12.5px; color: var(--texte-doux); font-weight: 600; padding: 0 6px; }
.pagination-detail { margin: 12px 0 2px; }

/* Message d'erreur d'une boîte dans le détail déplié */
.texte-erreur { color: #c5221f; }

/* Carte mise en avant via ?passage=…&session=… (lien depuis un email) */
.passage-carte.ligne-cible,
.session-carte.ligne-cible {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(45, 212, 191, .35);
}

/* Titres de section dans le détail déplié */
.titre-section {
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  margin: 22px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--bordure);
}
.titre-section:first-child { margin-top: 4px; }

/* Sous-titre des deux groupes de règles (actives / désactivées) */
.bloc-regles { margin-top: 4px; }
.sous-titre-regles {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--texte-doux);
  margin: 12px 0 8px;
}
.sous-titre-regles:first-child { margin-top: 0; }

/* Carte de règle : réutilise .email-carte mais avec un repère teal au survol */
.regle-carte .email-carte-exp { font-size: 13.5px; color: var(--navy); }

/* Liste des sessions rattachées à un email (détail email) */
.liste-sessions { margin: 0; padding: 0; list-style: none; }
.liste-sessions li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
.liste-sessions li:not(:last-child) { border-bottom: 1px dashed var(--bordure); }
.lien-session {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  text-decoration: none;
  color: var(--navy-clair);
  font-weight: 600;
  transition: color .12s;
}
.lien-session:hover { color: var(--teal-fonce); text-decoration: underline; }
.lien-session-type { font-size: 13px; }
.lien-session-date {
  font-size: 12px;
  color: var(--texte-doux);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

/* =========================================================================
   NOTIFICATIONS INTERNES (cloche, page et échéances des boîtes)
   ========================================================================= */

/* Champs date et textarea des formulaires (mêmes réglages que les inputs) */
input[type=date], textarea {
  width: 100%; padding: 9px 10px; margin-top: 4px;
  border: 1px solid #c7d0da; border-radius: 6px; font-size: 14px;
  font-family: inherit; background: #fff; color: var(--texte);
}
textarea:focus, input[type=date]:focus {
  outline: 2px solid var(--teal-fonce); outline-offset: 0; border-color: transparent;
}

/* Cloche de la topbar avec badge de non-lues */
.cloche-notif {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: 8px;
  color: #fff;
  background: rgba(255, 255, 255, .10);
  transition: background .15s;
}
.cloche-notif svg { width: 19px; height: 19px; }
.cloche-notif:hover { background: rgba(255, 255, 255, .20); }
.cloche-badge {
  position: absolute;
  top: -5px; right: -6px;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  border: 2px solid var(--navy);
  box-sizing: content-box;
}

/* Badge de non-lues dans le menu latéral */
.menu-badge {
  margin-left: auto;
  min-width: 18px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
}

/* Page des notifications : liste de cartes */
.notifs-liste {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 860px;
}
.notif-carte {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--carte);
  border: 1px solid #e5e9f0;
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}
.notif-non-lue {
  border-left: 4px solid var(--teal-fonce);
  background: #f4fbfa;
}
.notif-icone {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #eef1f5;
  color: #4b5563;
}
.notif-icone svg { width: 19px; height: 19px; }
.notif-icone-email_detecte    { background: #e6f0fb; color: #1d4ed8; }
.notif-icone-paiement         { background: #fef3e2; color: #b45309; }
.notif-icone-echeance_dossier { background: #fde8e8; color: #b91c1c; }
.notif-icone-message          { background: #e4f7ec; color: #1d6b34; }

.notif-contenu { flex: 1; min-width: 0; }
.notif-titre {
  font-weight: 600;
  color: var(--navy);
  font-size: 14px;
  overflow-wrap: anywhere;
}
.notif-message {
  margin-top: 3px;
  font-size: 13px;
  color: var(--texte);
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.notif-meta {
  margin-top: 7px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.notif-meta .badge { font-size: 11px; padding: 2px 8px; }
.notif-type-email_detecte    { background: #e6f0fb; color: #1d4ed8; }
.notif-type-paiement         { background: #fef3e2; color: #b45309; }
.notif-type-echeance_dossier { background: #fde8e8; color: #b91c1c; }
.notif-type-message          { background: #e4f7ec; color: #1d6b34; }
.notif-date { font-size: 12px; color: var(--texte-doux); }
.notif-lien { font-size: 12px; font-weight: 600; }

.notif-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Colonne Échéances du tableau des boîtes */
.echeances-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}
.badge-echeance {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: #eef1f5;
  color: #4b5563;
  white-space: nowrap;
}
.echeance-depassee { background: #fde8e8; color: #b91c1c; }

/* Toast d'arrivée d'une notification (cliquable, mène à /notifications) */
#toast-notif {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%) translateY(-90px);
  background: var(--navy);
  color: #fff;
  padding: 11px 20px;
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .28);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  z-index: 400;
  opacity: 0;
  pointer-events: none;
  transition: transform .25s ease, opacity .25s ease;
  max-width: min(90vw, 480px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#toast-notif.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}
#toast-notif:hover { background: var(--navy-clair); color: #fff; }

/* =========================================================================
   NOTIFICATIONS — clignotement, pulsation et panneau déroulant de la cloche
   ========================================================================= */

/* Le toast CLIGNOTE pendant quelques secondes pour attirer l'attention */
@keyframes clignote-notif {
  0%, 100% { opacity: 1; }
  50%      { opacity: .35; }
}
#toast-notif.visible {
  animation: clignote-notif .9s ease-in-out .3s 5;
}

/* Le badge rouge de la cloche pulse tant qu'il reste des non-lues */
@keyframes pulse-badge {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.3); }
}
.cloche-badge { animation: pulse-badge 1.2s ease-in-out infinite; }

/* Zone de la cloche : point d'ancrage du panneau déroulant */
.zone-cloche { position: relative; }

.panneau-notifs {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 380px;
  max-width: 92vw;
  background: var(--carte);
  border: 1px solid #dde3ec;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .22);
  overflow: hidden;
  z-index: 60;
}
.panneau-notifs-tete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid #e5e9f0;
  font-weight: 600;
  color: var(--navy);
  font-size: 14px;
}
.panneau-notifs-tete a { font-size: 12px; font-weight: 600; }
.panneau-notifs-corps { max-height: min(65vh, 460px); overflow-y: auto; }
.panneau-notifs-vide {
  margin: 0;
  padding: 22px 14px;
  text-align: center;
  color: var(--texte-doux);
  font-size: 13px;
}

.panneau-notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f0f2f6;
}
.panneau-notif-item:last-child { border-bottom: 0; }
.panneau-notif-item:hover { background: #f4f7fb; }
.panneau-notif-item.non-lue { background: #f0faf8; }
.panneau-notif-item.non-lue:hover { background: #e6f6f2; }
.panneau-notif-item.non-lue .pn-titre::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--teal-fonce);
  margin-right: 6px;
  vertical-align: 1px;
}

.pn-icone {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #eef1f5;
  color: #4b5563;
}
.pn-icone svg { width: 15px; height: 15px; }
.pn-texte {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.pn-titre {
  font-size: 13px;
  font-weight: 600;
  color: var(--texte);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pn-message {
  font-size: 12px;
  color: var(--texte-doux);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pn-date { font-size: 11px; color: var(--texte-doux); }

/* Sur mobile, le panneau occupe la largeur de l'écran sous la topbar */
@media (max-width: 640px) {
  .panneau-notifs {
    position: fixed;
    top: calc(var(--topbar-h) + 6px);
    left: 8px;
    right: 8px;
    width: auto;
  }
}
