:root {
  --encre: #16242c;
  --nuit: #123242;
  --bleu: #1b627f;
  --bleu-pale: #e6f0f4;
  --doux: #5b6a73;
  --fond: #ffffff;
  --creux: #f4f6f7;
  --trait: #e2e7ea;
  --trait-fort: #bcc8ce;
  --bord: #ccd4d9;
  --clair: #c3d3db;
  --repere: #e9b866;
  --ambre: #9a5b00;
  --ambre-pale: #fbf0dc;
  --rouge: #a83229;
  --vert: #166534;
  --rayon: 6px;
}

* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 "IBM Plex Sans", "Segoe UI", system-ui, sans-serif; color: var(--encre);
  background: var(--fond); font-variant-numeric: tabular-nums; }
a { color: var(--bleu); text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; }
a.nom { color: var(--encre); }
h1 { margin: 0; font-size: 21px; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 600; margin: 24px 0 8px; }
:focus-visible { outline: 2px solid var(--bleu); outline-offset: 2px; }

/* Structure */
.app { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
.menu { background: var(--nuit); color: var(--fond); padding: 22px 0; display: flex; flex-direction: column; }
.marque { padding: 0 22px 26px; font-size: 16px; font-weight: 600; }
.menu > a { display: flex; justify-content: space-between; align-items: center; padding: 10px 22px;
  color: var(--clair); font-weight: 400; border-left: 3px solid transparent; }
.menu > a:hover { color: var(--fond); text-decoration: none; }
.menu > a.actif { color: var(--fond); background: rgba(255, 255, 255, .08); border-left-color: var(--repere); }
.nombre { background: rgba(255, 255, 255, .14); border-radius: 4px; padding: 0 7px; font-size: 12px; color: var(--fond); }
.compte { margin-top: auto; padding: 16px 22px 0; border-top: 1px solid rgba(255, 255, 255, .14); color: var(--clair); font-size: 13px; }
.compte button.lien, .compte a { color: var(--fond); }
.compte a { display: block; }
main { min-width: 0; }
.tete { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 16px 32px; min-height: 74px;
  border-bottom: 1px solid var(--trait); }
.droite { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.corps { padding: 20px 32px 40px; }
.etroit { max-width: 964px; }
.formulaire { max-width: 520px; }

.acces { max-width: 400px; margin: 0 auto; padding: 48px 16px; }
.carte { border: 1px solid var(--trait); border-radius: var(--rayon); padding: 24px; }
.carte h1 { margin-bottom: 16px; }

/* Saisie et boutons */
label { display: block; margin-bottom: 12px; }
input, select, button, .bouton { font: inherit; border-radius: var(--rayon); border: 1px solid var(--bord);
  background: var(--fond); color: var(--encre); padding: 7px 12px; }
.formulaire input:not([type="radio"]):not([type="checkbox"]), .formulaire select, .acces input { display: block; width: 100%; }
.formulaire input[type="radio"], .formulaire input[type="checkbox"] { margin-right: 6px; }
.formulaire ul.errorlist, .formulaire .errorlist { color: var(--rouge); padding-left: 0; list-style: none; }
.formulaire div > label { margin-bottom: 4px; }
button, .bouton { cursor: pointer; font-weight: 500; display: inline-block; }
button:hover, .bouton:hover { border-color: var(--bleu); text-decoration: none; }
.principal { background: var(--bleu); border-color: var(--bleu); color: var(--fond); }
.destructif { border-color: var(--rouge); color: var(--rouge); }
button.lien { border: 0; background: none; padding: 0; color: var(--bleu); }
button.lien:hover { text-decoration: underline; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ligne { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.ligne label { margin-bottom: 0; }
.section { margin-top: 24px; padding-top: 4px; border-top: 1px solid var(--trait); }
details { margin-top: 10px; }
summary { cursor: pointer; color: var(--bleu); font-weight: 500; }
details form { margin-top: 8px; }
details.discret { margin-top: 2px; font-size: 13px; }

/* Textes d'état */
.doux { color: var(--doux); font-weight: 400; }
.entree { color: var(--vert); font-weight: 600; }
.sortie { color: var(--rouge); font-weight: 600; }
/* Orange : une heure manquante ne se confond pas avec une sortie. */
.trou { color: var(--ambre); background: var(--ambre-pale); font-weight: 600; padding: 0 4px; border-radius: 3px; }
.ambre { color: var(--ambre); font-weight: 500; }
.etat::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px;
  background: var(--bleu); }
.etat.attente::before { background: var(--ambre); }
.etat.neutre::before { background: var(--trait-fort); }
.message { padding: 10px 14px; margin: 16px 32px 0; border: 1px solid var(--trait); border-radius: var(--rayon); }
.corps .message, .acces .message { margin: 0 0 12px; }
.message.error { border-color: var(--rouge); color: var(--rouge); }
.message.success { border-color: var(--vert); color: var(--vert); }
.constat { margin: 16px 0; padding: 11px 14px; background: var(--ambre-pale); border-radius: var(--rayon); }
.grand-code { font-size: 28px; font-weight: 600; letter-spacing: .15em; }
.qr { display: block; margin: 0 auto 12px; max-width: 100%; }

/* Tableaux */
.defile { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--doux); padding: 8px 14px 8px 0; border-bottom: 1px solid var(--trait-fort); }
td { padding: 9px 14px 9px 0; border-bottom: 1px solid var(--trait); vertical-align: top; }
tbody tr:hover td { background: var(--creux); }
tr.groupe td, tbody tr.groupe:hover td { font-weight: 600; padding-top: 20px; border-bottom-color: var(--trait-fort); background: none; }
td.fin { text-align: right; padding-right: 0; }
td.fin > * { display: inline-block; vertical-align: top; margin: 0 0 0 18px; }

/* Anomalies */
.partage { display: grid; grid-template-columns: 360px minmax(0, 1fr); min-height: calc(100vh - 74px); }
.liste { border-right: 1px solid var(--trait); }
.item { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 13px 24px;
  border-bottom: 1px solid var(--trait); color: var(--encre); font-weight: 400; }
.item:hover { background: var(--creux); text-decoration: none; }
.item b { font-weight: 500; }
.item.choisi { background: var(--bleu-pale); box-shadow: inset 3px 0 0 var(--bleu); }
.fiche { padding: 24px 32px; }
.fiche h2 { margin: 0 0 2px; font-size: 18px; }
.fiche h2 a { color: var(--encre); }
.photos { display: flex; gap: 16px; margin: 18px 0; flex-wrap: wrap; }
.photos figure { margin: 0; }
.photos img { width: 200px; height: 220px; object-fit: cover; border-radius: var(--rayon); background: var(--creux); }
figcaption { color: var(--doux); font-size: 13px; margin-top: 6px; }

/* Le mois en grille : nom et CIN restent visibles au défilement */
.grille-mois { overflow: auto; margin: 16px 24px 32px; max-height: calc(100vh - 130px); border: 1px solid var(--trait); }
.grille-mois table { border-collapse: separate; border-spacing: 0; width: max-content; font-size: 12.5px; }
.grille-mois th, .grille-mois td { border-right: 1px solid var(--trait); border-bottom: 1px solid var(--trait);
  padding: 5px 7px; text-align: center; min-width: 54px; background: var(--fond); vertical-align: middle; }
.grille-mois th { position: sticky; top: 0; background: var(--creux); z-index: 2; }
.grille-mois td div + div { border-top: 1px solid var(--trait); }
.grille-mois .g1, .grille-mois .g2 { position: sticky; z-index: 1; text-align: left; }
.grille-mois .g1 { left: 0; width: 180px; min-width: 180px; max-width: 180px; overflow-wrap: anywhere; }
.grille-mois .g2 { left: 180px; min-width: 96px; color: var(--doux); border-right-color: var(--trait-fort); }
.grille-mois th.g1, .grille-mois th.g2 { z-index: 3; }

/* Riads */
.riad { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 24px; padding: 20px 0; border-bottom: 1px solid var(--trait); }
.riad h2 { margin: 0 0 6px; }

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); align-content: start; }
  .menu { flex-direction: row; align-items: center; overflow-x: auto; padding: 0; white-space: nowrap; }
  .marque { display: none; }
  .menu > a { gap: 6px; padding: 12px 14px; border-left: 0; border-bottom: 3px solid transparent; }
  .menu > a.actif { border-bottom-color: var(--repere); }
  .compte { margin: 0 0 0 auto; padding: 0 14px; border-top: 0; font-size: 0; }
  .compte button.lien, .compte a { font-size: 13px; margin-left: 12px; }
  .compte { display: flex; align-items: center; }
  .tete, .corps, .fiche { padding-left: 16px; padding-right: 16px; }
  .droite { margin-left: 0; }
  .message { margin-left: 16px; margin-right: 16px; }
  .partage, .riad { grid-template-columns: minmax(0, 1fr); }
  .liste { border-right: 0; max-height: 40vh; overflow-y: auto; border-bottom: 2px solid var(--trait-fort); }
  .grille-mois { margin: 12px 8px 24px; }
  .grille-mois .g2 { position: static; }
  .grille-mois .g1 { width: 120px; min-width: 120px; max-width: 120px; }
}
