/* Contrôle d'accès tourniquets — feuille de style.
   Volontairement sobre : texte noir sur blanc, une couleur d'accent,
   de la couleur seulement quand elle signale quelque chose. */

:root {
  --fond: #f4f4f2;
  --surface: #ffffff;
  --texte: #1c1c1c;
  --discret: #666666;
  --bord: #d6d6d2;
  --accent: #1f4e8c;
  --ok: #1d6b30;
  --alerte: #8a4b00;
  --alerte-fond: #fdf3e1;
  --danger: #a8231a;
  --danger-fond: #fbeceb;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--texte);
  background: var(--fond);
}
a { color: var(--accent); }
h1 { font-size: 1.4rem; font-weight: 600; margin: .2rem 0 1rem; }
h2 { font-size: 1.1rem; font-weight: 600; margin: 0 0 .5rem; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .95em; }
.discret { color: var(--discret); font-size: .9rem; }
[hidden] { display: none !important; }

main { max-width: 1100px; margin: 0 auto; padding: 1rem; }
main.etroit { max-width: 600px; }
.pied { text-align: center; color: var(--discret); font-size: .8rem; padding: 2rem 1rem 1rem; }

/* --- En-tête ---------------------------------------------------------- */
.entete {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: .5rem 1.5rem; padding: .6rem 1rem;
  background: var(--surface); border-bottom: 1px solid var(--bord);
}
.marque { font-weight: 600; color: var(--texte); text-decoration: none; }
.entete-droite { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem 1.2rem; }
.entete-droite form { margin: 0; }
.entete-droite .compte { color: var(--discret); text-decoration: none; }
.choix-chantier select { min-width: 12rem; font-weight: 600; }
.chantier-unique { font-weight: 600; }
@media (max-width: 640px) {
  .entete-droite { width: 100%; }
  .choix-chantier { order: -1; width: 100%; }
  .choix-chantier label { width: 100%; }
  .choix-chantier select { flex: 1; min-width: 0; }
}

/* --- Onglets ---------------------------------------------------------- */
.onglets {
  display: flex; gap: .2rem; padding: 0 1rem; overflow-x: auto;
  background: var(--surface); border-bottom: 1px solid var(--bord);
}
.onglets a {
  flex: none; padding: .65rem .8rem; white-space: nowrap;
  color: var(--discret); text-decoration: none; border-bottom: 3px solid transparent;
}
.onglets a:hover { color: var(--texte); }
.onglets a.actif { color: var(--texte); font-weight: 600; border-bottom-color: var(--accent); }
.onglets a:not(.admin) + a.admin { margin-left: auto; }

.bandeau {
  padding: .6rem 1rem; text-align: center;
  background: var(--alerte-fond); color: var(--alerte);
  border-bottom: 1px solid #ecd3a8;
}
.bandeau a { color: var(--alerte); font-weight: 600; }

/* --- Messages --------------------------------------------------------- */
.flash { padding: .6rem .8rem; border-radius: 4px; margin: 0 0 1rem; border: 1px solid; }
.flash-ok { background: #eef6ef; border-color: #bcd9c1; color: var(--ok); }
.flash-erreur { background: var(--danger-fond); border-color: #e9bcb8; color: var(--danger); }
.toast {
  position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); z-index: 100;
  max-width: calc(100% - 2rem); padding: .6rem 1rem; border-radius: 4px;
  background: #1c1c1c; color: #fff;
}
.toast-erreur { background: var(--danger); }
.maj { margin-top: 1rem; }
.maj.erreur { color: var(--danger); }

/* --- Blocs, boutons, formulaires ------------------------------------- */
.boite {
  background: var(--surface); border: 1px solid var(--bord); border-radius: 4px;
  padding: 1rem; margin-bottom: 1rem;
}
.titre-ligne { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 1rem; }

.bouton {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 42px; padding: .4rem 1rem;
  font: inherit; color: var(--texte); text-decoration: none; cursor: pointer;
  background: var(--surface); border: 1px solid #b9b9b4; border-radius: 4px;
}
.bouton:hover { background: #f0f0ed; }
.bouton:disabled { opacity: .5; cursor: default; }
.bouton.principal { background: var(--accent); border-color: var(--accent); color: #fff; }
.bouton.principal:hover { background: #193f73; }
.bouton.danger { color: var(--danger); border-color: #d9a29d; }
.bouton.petit { min-height: 34px; padding: .2rem .7rem; font-size: .9rem; }
.bouton.large { width: 100%; }
.lien { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }

label { display: block; margin-bottom: .9rem; }
label small, fieldset small { display: block; color: var(--discret); font-size: .85rem; margin-top: .15rem; }
label.case { display: flex; align-items: center; gap: .5rem; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  display: block; width: 100%; margin-top: .2rem; min-height: 42px; padding: .4rem .6rem;
  font: inherit; color: var(--texte); background: #fff;
  border: 1px solid #b9b9b4; border-radius: 4px;
}
input[type=checkbox], input[type=radio] { width: 1.1rem; height: 1.1rem; margin: 0; flex: none; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.sous-groupe { border: 1px solid var(--bord); border-radius: 4px; padding: .7rem .9rem; margin-bottom: 1rem; }
legend { padding: 0 .3rem; }
.en-ligne-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.en-ligne-form > input, .en-ligne-form > select { width: auto; flex: 1 1 140px; margin: 0; }
label.en-ligne { display: flex; align-items: center; gap: .5rem; margin: 0; }
label.en-ligne select { width: auto; margin: 0; }

.filtres {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0 .8rem; align-items: end; margin-bottom: 1rem;
}
.filtres label { margin-bottom: .6rem; font-size: .9rem; }
.filtres .bouton { margin-bottom: .6rem; }

pre.bloc, code.bloc {
  display: block; white-space: pre-wrap; word-break: break-all; padding: .7rem;
  background: var(--fond); border: 1px solid var(--bord); border-radius: 4px; font-size: .85rem;
}
.avertissement { color: var(--danger); }
.ok { color: var(--ok); }
.ko { color: var(--danger); }
.alerte { color: var(--alerte); }

/* --- Tableau de bord -------------------------------------------------- */
.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 1rem; }
.tq {
  background: var(--surface); border: 1px solid var(--bord); border-radius: 4px;
  padding: .9rem 1rem; display: flex; flex-direction: column; gap: .6rem;
}
.tq.hors-ligne { border-left: 4px solid var(--danger); }
.tq.mode-special { border-left: 4px solid #d08a1f; }
.tq-tete { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.tq-tete h2 { margin: 0; font-size: 1.1rem; }
.tq-tete h2 a { color: var(--texte); text-decoration: none; }
.tq-tete h2 a:hover { text-decoration: underline; }
.tq p { margin: 0; }
.tq-mode strong { font-weight: 600; }
.tq-mode.special { color: var(--alerte); }
.etat { font-size: .9rem; white-space: nowrap; }
.etat.en-ligne { color: var(--ok); }
.etat.hors-ligne { color: var(--danger); }
.attente { font-size: .9rem; color: var(--alerte); }

.modes { display: flex; border: 1px solid #b9b9b4; border-radius: 4px; overflow: hidden; }
.mode-btn {
  flex: 1; min-height: 42px; padding: .3rem .4rem; font: inherit; font-size: .9rem; line-height: 1.2;
  color: var(--texte); background: var(--surface); border: 0; border-left: 1px solid #b9b9b4; cursor: pointer;
}
.mode-btn:first-child { border-left: 0; }
.mode-btn:hover { background: #f0f0ed; }
.mode-btn[aria-pressed="true"] { color: #fff; font-weight: 600; }
.mode-btn.mode-normal[aria-pressed="true"] { background: var(--ok); }
.mode-btn.mode-tout_ouvert[aria-pressed="true"] { background: #b86e00; }
.mode-btn.mode-bloque[aria-pressed="true"] { background: var(--danger); }
.mode-btn.mode-normal[aria-pressed="true"] { cursor: default; }

.tq-actions { display: flex; gap: .5rem; }
.tq-actions form { flex: 1; margin: 0; }
.tq-actions .bouton { width: 100%; }
.tq-statut { font-size: .9rem; }
.statut-executee { color: var(--ok); }
.statut-en_attente, .statut-envoyee { color: var(--discret); }
.statut-expiree, .statut-refusee { color: var(--danger); }

table.mini { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.mini td { padding: .3rem .4rem .3rem 0; border-top: 1px solid #ecece8; vertical-align: top; }
table.mini td.h { color: var(--discret); white-space: nowrap; font-variant-numeric: tabular-nums; width: 1%; }
table.mini td.res { text-align: right; white-space: nowrap; }

/* --- Dialogue --------------------------------------------------------- */
dialog {
  width: min(460px, calc(100% - 2rem)); padding: 1.2rem;
  border: 1px solid var(--bord); border-radius: 4px; color: var(--texte); background: #fff;
}
dialog::backdrop { background: rgba(0, 0, 0, .4); }
.choix { display: flex; gap: .6rem; align-items: flex-start; padding: .5rem 0; margin: 0; border-bottom: 1px solid #ecece8; }
.choix input { margin-top: .25rem; }
.choix small { display: block; color: var(--discret); }
.boutons-dialogue { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }

/* --- Tableaux de données --------------------------------------------- */
.tableau-donnees { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--bord); }
.tableau-donnees th, .tableau-donnees td { padding: .5rem .6rem; text-align: left; border-bottom: 1px solid #e6e6e2; vertical-align: top; }
.tableau-donnees th { font-weight: 600; font-size: .9rem; background: #fafaf8; }
.tableau-donnees tr.inactif td { color: var(--discret); }
.tableau-donnees td.vide { text-align: center; color: var(--discret); padding: 1.5rem; }
@media (max-width: 760px) {
  .tableau-donnees, .tableau-donnees tbody, .tableau-donnees tr, .tableau-donnees td { display: block; width: 100%; }
  .tableau-donnees thead { display: none; }
  .tableau-donnees { border: 0; background: none; }
  .tableau-donnees tr { background: var(--surface); border: 1px solid var(--bord); border-radius: 4px; margin-bottom: .5rem; padding: .3rem 0; }
  .tableau-donnees td { border: 0; padding: .15rem .7rem; display: grid; grid-template-columns: 7rem 1fr; gap: .5rem; }
  .tableau-donnees td::before { content: attr(data-titre); color: var(--discret); font-size: .85rem; }
  .tableau-donnees td.vide { display: block; }
  .tableau-donnees td.vide::before { content: none; }
}

.pagination { display: flex; gap: 1rem; justify-content: center; align-items: center; margin: 1rem 0; }

.liste-refuses { list-style: none; margin: 0; padding: 0; }
.liste-refuses li { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem 1rem; padding: .5rem 0; border-top: 1px solid #ecece8; }
.liste-refuses li:first-child { border-top: 0; }
.liste-refuses form { margin-left: auto; }

.colonnes { display: grid; gap: 1rem; }
@media (min-width: 900px) { .colonnes { grid-template-columns: 1fr 1fr; align-items: start; } }
dl.sante { display: grid; grid-template-columns: minmax(9rem, auto) 1fr; gap: .3rem 1rem; margin: 0 0 .5rem; }
dl.sante dt { color: var(--discret); }
dl.sante dd { margin: 0; }
.zone-danger summary { cursor: pointer; color: var(--danger); }

.connexion { margin-top: 3rem; }
.duree { margin-top: .8rem; }
