:root {
  --bleu: #002458;
  --bleu-clair: #e8eef7;
  --rouge: #c8102e;
  --vert: #1e7a46;
  --orange: #b35c00;
  --gris: #5b6472;
  --bord: #d5dbe5;
  --fond: #f5f7fa;
  --blanc: #ffffff;
  --rayon: 8px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--fond); color: #1b2330;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
a { color: var(--bleu); }
header.top {
  background: var(--bleu); color: #fff; padding: 12px 16px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
header.top .titre { font-weight: 700; letter-spacing: .2px; }
header.top nav { display: flex; gap: 14px; flex-wrap: wrap; margin-left: auto; align-items: center; }
header.top nav a { color: #fff; text-decoration: none; opacity: .9; }
header.top nav a:hover { opacity: 1; text-decoration: underline; }
header.top form { margin: 0; }
header.top button.lien { background: none; border: 0; color: #fff; cursor: pointer; font: inherit; opacity: .9; padding: 0; }
main { max-width: 980px; margin: 24px auto; padding: 0 16px; }
main.large { max-width: 1280px; }
h1 { font-size: 1.5rem; color: var(--bleu); margin: 0 0 8px; }
h2 { font-size: 1.15rem; color: var(--bleu); margin: 28px 0 10px; border-bottom: 2px solid var(--bleu-clair); padding-bottom: 4px; }
.sous-titre { color: var(--gris); margin-top: 0; }
.carte { background: var(--blanc); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 20px; margin-bottom: 18px; }
.etapes { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 20px; flex-wrap: wrap; font-size: .85rem; }
.etapes li { padding: 4px 10px; border-radius: 999px; background: #e3e7ee; color: var(--gris); }
.etapes li.fait { background: #d7efe1; color: var(--vert); }
.etapes li.actif { background: var(--bleu); color: #fff; }

label { display: block; font-weight: 600; margin: 12px 0 4px; font-size: .95rem; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; margin: 4px 16px 4px 0; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=date],
input[type=time], input[type=search], select, textarea {
  width: 100%; padding: 9px 10px; border: 1px solid #b9c2d0; border-radius: 6px; font: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #7aa2e3; border-color: #7aa2e3; }
.grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 18px; }
.aide { color: var(--gris); font-size: .85rem; margin: 2px 0 0; }
.cache { display: none; }

button, .btn {
  display: inline-block; background: var(--bleu); color: #fff; border: 0; border-radius: 6px;
  padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
button.secondaire, .btn.secondaire { background: #fff; color: var(--bleu); border: 1px solid var(--bleu); }
button.danger { background: var(--rouge); }
button.petit, .btn.petit { padding: 5px 10px; font-size: .85rem; font-weight: 500; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 18px; }

.msg { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.msg.info { background: #e6f0ff; border: 1px solid #b7cff5; }
.msg.erreur { background: #fdeaea; border: 1px solid #f0b4b4; color: #7c1010; }
.msg ul { margin: 4px 0 0; padding-left: 20px; }

table.donnees { width: 100%; border-collapse: collapse; background: #fff; font-size: .92rem; }
table.donnees th, table.donnees td { border-bottom: 1px solid var(--bord); padding: 7px 8px; text-align: left; vertical-align: top; }
table.donnees th { background: var(--bleu-clair); color: var(--bleu); font-weight: 600; position: sticky; top: 0; }
table.donnees tr:hover td { background: #fafcff; }
.defile { overflow-x: auto; }

table.horaires { border-collapse: collapse; width: 100%; }
table.horaires th, table.horaires td { border: 1px solid var(--bord); padding: 6px; text-align: center; }
table.horaires th { background: var(--bleu-clair); color: var(--bleu); }
table.horaires input { width: 100%; min-width: 58px; padding: 6px 4px; }
table.horaires .duo { display: flex; gap: 4px; align-items: center; }
#total-horaires { font-weight: 700; }
#total-horaires.ko { color: var(--rouge); }
#total-horaires.ok { color: var(--vert); }

.recap dt { font-weight: 600; color: var(--gris); font-size: .85rem; margin-top: 8px; }
.recap dd { margin: 0; }
.recap { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 24px; }

.sigpad { border: 2px dashed #9aa7bb; border-radius: 6px; background: #fff; touch-action: none; width: 100%; max-width: 520px; height: 180px; display: block; cursor: crosshair; }
.sigbloc { margin: 10px 0 18px; }
.sigbloc .outils { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.apercu-sig { max-height: 80px; border: 1px solid var(--bord); background: #fff; padding: 4px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.b-importee { background: #eceff3; color: #3d4654; }
.b-famille, .b-signature_famille { background: #fff1d6; color: var(--orange); }
.b-entreprise { background: #fde7d0; color: #9a4400; }
.b-controle { background: #e6e0fa; color: #4b2aa8; }
.b-direction { background: #dbe8ff; color: #123f99; }
.b-terminee { background: #d7efe1; color: var(--vert); }
.b-papier, .b-annulee { background: #eee; color: #666; }

.compteurs { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.compteurs a { text-decoration: none; background: #fff; border: 1px solid var(--bord); border-radius: var(--rayon); padding: 8px 14px; color: inherit; min-width: 120px; }
.compteurs a.actif { border-color: var(--bleu); box-shadow: 0 0 0 1px var(--bleu); }
.compteurs .n { font-size: 1.4rem; font-weight: 700; color: var(--bleu); display: block; }
.compteurs .l { font-size: .8rem; color: var(--gris); }
.filtres { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.filtres > * { width: auto; }
.retard { color: var(--rouge); font-weight: 600; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; word-break: break-all; }
pre.mail { white-space: pre-wrap; background: #fafafa; border: 1px solid var(--bord); padding: 10px; font-size: .85rem; }
footer { text-align: center; color: var(--gris); font-size: .8rem; margin: 30px 0; }

@media (max-width: 640px) {
  main { margin-top: 12px; }
  .carte { padding: 14px; }
  table.horaires, table.horaires tbody, table.horaires tr, table.horaires td, table.horaires th { display: block; width: 100%; }
  table.horaires thead { display: none; }
  table.horaires td[data-jour]::before { content: attr(data-jour); display: block; font-weight: 600; color: var(--bleu); text-align: left; }
}
.etroit { max-width: 420px; margin: auto; }
.marge-haut { margin-top: 14px; }
.carte > h2:first-child, .carte > form > h2:first-child { margin-top: 0; }
