:root {
  --fond: #f2f4f8;
  --nuit: #121b2e;
  --surface: #ffffff;
  --texte: #1c2430;
  --discret: #64707f;
  --bordure: #dde3ea;
  --primaire: #2b4fd1;
  --primaire-clair: #e8edfc;
  --succes: #1e7a46;
  --succes-fond: #e5f4ea;
  --attention: #9a5b00;
  --attention-fond: #fdf1dc;
  --danger: #b3261e;
  --danger-fond: #fde8e6;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--fond); color: var(--texte); line-height: 1.45; }
a { color: var(--primaire); }
h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
.discret { color: var(--discret); font-size: .85em; }

.entete { background: var(--nuit); color: #fff; padding: .8rem 1rem 1rem; }
.entete a { color: #fff; text-decoration: none; }
.entete-haut { display: flex; align-items: center; justify-content: space-between; gap: 1rem; max-width: 1400px; margin: 0 auto .7rem; }
.onglets { display: flex; flex-wrap: wrap; gap: .4rem .5rem; max-width: 1400px; margin: 0 auto; }
.onglets a { padding: .45rem .9rem; border-radius: 10px; font-weight: 500; color: #e6e9f2; }
.onglets a:hover { background: rgba(255,255,255,.1); }
.onglets a.actif { background: #fff; color: var(--nuit); font-weight: 600; }
.badge-alerte { display: inline-block; min-width: 1.4em; padding: 0 .4em; margin-left: .3em; border-radius: 999px; background: var(--danger); color: #fff; font-size: .8em; text-align: center; }

.micro-flottant {
  position: fixed; right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); z-index: 50;
  display: inline-flex; align-items: center; gap: .55rem; padding: .85rem 1.3rem;
  background: var(--primaire); color: #fff; text-decoration: none; font-weight: 600; font-size: 1rem;
  border-radius: 999px; box-shadow: 0 6px 18px rgba(18, 27, 46, .28);
}
.micro-flottant:hover { filter: brightness(1.08); }
@media (max-width: 330px) { .micro-flottant span { display: none; } .micro-flottant { padding: .9rem; } }
.contenu { padding-bottom: 5.5rem !important; }
.entete-gauche { display: flex; align-items: center; gap: .6rem; }
.retour { display: none; background: rgba(255,255,255,.15); color: #fff; border: 0; border-radius: 6px; padding: .3rem .6rem; font: inherit; font-size: 1rem; cursor: pointer; }
.mode-appli .retour { display: inline-block; }
@media (max-width: 420px) { .retour span { display: none; } }
.logo { font-weight: 700; font-size: 1.35rem; letter-spacing: .01em; }
.deconnexion { margin: 0; }
.deconnexion button { background: none; border: 1px solid rgba(255,255,255,.5); color: #fff; border-radius: 6px; padding: .25rem .6rem; cursor: pointer; }

.contenu { max-width: 1400px; margin: 0 auto; padding: 1rem; }
.carte { background: var(--surface); border: 1px solid var(--bordure); border-radius: 10px; padding: 1rem; margin-bottom: 1rem; }
.carte-etroite { max-width: 560px; margin-inline: auto; }

.message { padding: .6rem .9rem; border-radius: 8px; margin: 0 0 .75rem; }
.message-success { background: var(--succes-fond); color: var(--succes); }
.message-warning { background: var(--attention-fond); color: var(--attention); }
.message-error { background: var(--danger-fond); color: var(--danger); }

.bouton { display: inline-block; background: var(--primaire); color: #fff; border: 0; border-radius: 8px; padding: .6rem 1rem; font: inherit; cursor: pointer; text-decoration: none; }
.bouton-secondaire { background: #fff; color: var(--texte); border: 1px solid var(--bordure); }
.bouton-danger { background: var(--danger); }

.barre-semaine { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: 1rem; }
.barre-semaine h1 { margin: 0; text-align: center; flex: 1 1 260px; }

.alertes { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.alertes li { padding: .4rem .7rem; border-radius: 6px; border-left: 4px solid; }
.alertes a { color: inherit; }
.alerte-bloquant { background: var(--danger-fond); color: var(--danger); }
.alerte-attention { background: var(--attention-fond); color: var(--attention); }

.grille-defilement { overflow-x: auto; margin-bottom: 1rem; border: 1px solid var(--bordure); border-radius: 10px; background: var(--surface); }
.grille { border-collapse: collapse; width: 100%; min-width: 980px; }
.grille th, .grille td { border-bottom: 1px solid var(--bordure); border-right: 1px solid var(--bordure); padding: .4rem; vertical-align: top; }
.grille thead th { background: #e9edf5; font-weight: 600; text-align: center; position: sticky; top: 0; }
.grille th.site { text-align: left; min-width: 150px; font-weight: 600; }
.grille td { width: 12%; }

.vacation { display: block; text-decoration: none; color: var(--texte); background: var(--primaire-clair); border-left: 4px solid var(--primaire); border-radius: 6px; padding: .3rem .45rem; margin-bottom: .3rem; font-size: .85rem; }
.vacation span { display: block; }
.vacation.statut-confirmee, .vacation.statut-realisee { border-left-color: var(--succes); background: var(--succes-fond); }
.vacation.statut-annulee { opacity: .5; text-decoration: line-through; }
.vacation.non-pourvu { border-left-color: var(--danger); background: var(--danger-fond); color: var(--danger); font-weight: 600; }
.vacation.en-alerte { outline: 2px solid var(--danger); }
.badge { display: inline-block; font-size: .72rem; background: rgba(0,0,0,.06); border-radius: 4px; padding: 0 .3rem; margin-top: .15rem; }
.vacation .badge { display: inline-block; }
#id_qualifications_requises { display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; }
#id_qualifications_requises label { display: flex; align-items: center; gap: .4rem; font-weight: 400; margin: 0; }
#id_qualifications_requises input { width: auto; }
.ajout { display: block; text-align: center; color: var(--discret); text-decoration: none; border: 1px dashed var(--bordure); border-radius: 6px; }
.ajout:hover { color: var(--primaire); border-color: var(--primaire); }

.tableau { border-collapse: collapse; }
.tableau th, .tableau td { text-align: left; padding: .3rem 1rem .3rem 0; border-bottom: 1px solid var(--bordure); }

.formulaire .champ, form label { display: block; margin-bottom: .8rem; }
.formulaire label { display: block; font-weight: 600; margin-bottom: .2rem; }
input, select, textarea { width: 100%; font: inherit; padding: .45rem .55rem; border: 1px solid var(--bordure); border-radius: 6px; background: #fff; }
.errorlist { color: var(--danger); margin: .2rem 0 0; padding-left: 1rem; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }

.barre-outils { margin-bottom: 1rem; }
.case { display: flex; align-items: center; gap: .5rem; font-weight: 400; margin: .8rem 0 .2rem; }
.case input { width: auto; }
.grille-defilement.sans-bordure { border: 0; margin: 0; }
.tableau-heures { width: 100%; min-width: 560px; }
.tableau-heures td, .tableau-heures th { white-space: nowrap; }
.tableau-heures tfoot th { border-top: 2px solid var(--texte); }

.assistant { max-width: 860px; margin: 0 auto; }
.conversation { max-height: 55vh; overflow-y: auto; display: flex; flex-direction: column; gap: .6rem; }
.bulle { padding: .6rem .8rem; border-radius: 10px; max-width: 85%; }
.bulle-vous { align-self: flex-end; background: var(--primaire); color: #fff; }
.bulle-assistant { align-self: flex-start; background: var(--primaire-clair); }
.propositions { border-left: 5px solid var(--attention); }
.proposition { border-bottom: 1px solid var(--bordure); padding: .5rem 0; }
.proposition:last-child { border-bottom: 0; }
.proposition p { margin: .2rem 0; }
.saisie textarea { margin-bottom: .5rem; }

.jour { margin-top: 1.25rem; text-transform: capitalize; }
.vacation-agent { border-left: 5px solid var(--primaire); }
.vacation-agent.statut-confirmee, .vacation-agent.statut-realisee { border-left-color: var(--succes); }
.vacation-agent p { margin: .2rem 0; }
.horaire { font-size: 1.2rem; font-weight: 700; }

/* Logo : étoile IA connectée dans un carré */
.logo-marque { display: inline-flex; align-items: center; gap: .45em; vertical-align: middle; }
.logo-symbole { flex: none; display: block; }
.logo-connexion { display: flex; justify-content: center; margin: 0 0 1rem; font-size: 1.8rem; font-weight: 700; color: var(--nuit); }
.micro-flottant .logo-marque { gap: .3em; }
.micro-flottant .logo-symbole rect { fill: #121b2e; }

/* Vacations en cours et terminées */
.vacation.en-cours { border-left-color: #f59e0b; background: #fff4dc; box-shadow: inset 0 0 0 1px #f59e0b; }
.vacation.terminee { border-left-color: #8a94a6; background: #eceff3; color: #5b6575; }
.vacation.terminee.non-pourvu { border-left-color: var(--danger); background: #f6e3e1; color: var(--danger); }
.vacation-agent.en-cours { border-left-color: #f59e0b; background: #fff8e8; }
.vacation-agent.terminee { border-left-color: #8a94a6; background: #f3f5f8; color: #5b6575; }
.legende { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; margin: -.4rem 0 1rem; font-size: .85rem; color: var(--discret); }
.legende span { display: inline-flex; align-items: center; gap: .35rem; }
.pastille { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border-left: 4px solid var(--primaire); background: var(--primaire-clair); }
.pastille.statut-confirmee { border-left-color: var(--succes); background: var(--succes-fond); }
.pastille.en-cours { border-left-color: #f59e0b; background: #fff4dc; }
.pastille.terminee { border-left-color: #8a94a6; background: #eceff3; }
.pastille.non-pourvu { border-left-color: var(--danger); background: var(--danger-fond); }
.pastille.statut-annulee { opacity: .5; }

/* Isoler un site ou une date par double-clic */
.astuce-grille { margin: 0 0 .5rem; }
.grille th.site, .grille th.entete-jour { cursor: zoom-in; user-select: none; }
.bouton.petit { padding: .2rem .6rem; font-size: .85rem; }

/* Signature des bons de remise */
.zone-signature { width: 100%; max-width: 600px; aspect-ratio: 600 / 220; background: #fff; border: 2px dashed var(--bordure); border-radius: 10px; touch-action: none; display: block; margin: .3rem 0 .8rem; }
.bon .tableau { width: 100%; margin-bottom: 1rem; }

/* Pointage (espace agent) */
.pointage { border-left: 5px solid var(--primaire); }
.pointage-vacation { margin: 0 0 .6rem; font-size: 1.05rem; }
.bouton-pointage { width: 100%; padding: 1rem; font-size: 1.2rem; font-weight: 700; background: var(--succes); border-radius: 12px; }
.bouton-pointage.fin { background: var(--danger); }
.bouton-pointage:disabled { opacity: .6; }
/* Pointages sur la grille de la direction */
.vacation .pointe { display: block; font-size: .75rem; color: var(--succes); }
.vacation .pointe.alerte { color: var(--danger); font-weight: 600; }
.signature-lue { display: block; max-width: 320px; width: 100%; border: 1px solid var(--bordure); border-radius: 8px; background: #fff; margin: .4rem 0 1rem; }

/* Page des identifiants : impression propre */
.identifiants .mdp { font-family: ui-monospace, Consolas, monospace; font-size: 1.3rem; letter-spacing: .08em; }
@media print {
  .entete, .micro-flottant, .pas-a-imprimer, .message-warning { display: none !important; }
  body { background: #fff; }
  .carte { border: 0; }
}

/* Espace agent : qualifications et recyclages */
.exigences { margin: .3rem 0; display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.badge-qualif { background: var(--primaire-clair); color: var(--primaire); font-weight: 600; }
.vacation-agent.formation { border-left-color: #7c3aed; }
.validite-expiree, .validite-absente { color: var(--danger); font-weight: 600; }
.validite-bientot { color: var(--attention); font-weight: 600; }

/* Facturation : clients non facturables */
.non-facturable td { background: #fdf3f2; }
.tarif-manquant { color: var(--danger); font-weight: 600; white-space: normal !important; }

/* Demandes des agents */
.demande { border-left: 5px solid var(--primaire); }
.demande.statut-acceptee { border-left-color: var(--succes); }
.demande.statut-refusee, .demande.statut-annulee { border-left-color: var(--discret); opacity: .85; }
.demande.statut-attente { border-left-color: var(--attention); }
.demande p { margin: .3rem 0; }
.reponse { background: var(--primaire-clair); padding: .5rem .7rem; border-radius: 8px; }
.badge-attente { background: var(--attention-fond); color: var(--attention); }
.badge-acceptee { background: var(--succes-fond); color: var(--succes); }
.badge-refusee, .badge-annulee { background: #eceff3; color: var(--discret); }
.deux-colonnes { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
[hidden] { display: none !important; }
@media (max-width: 480px) { .deux-colonnes { grid-template-columns: 1fr; } }
