:root {
  --bleu: #085292;
  --bleu-2: #0B6BB8;
  --bleu-3: #06467E;
  --fond: #f4f7fb;
  --surface: #ffffff;
  --texte: #1b2430;
  --texte-2: #4a5666;
  --bord: #d5dde8;
  --vert: #1e7a3c;
  --vert-fond: #e6f4ea;
  --orange: #a35200;
  --orange-fond: #fff1df;
  --rouge: #b3261e;
  --rouge-fond: #fde8e7;
  --bleu-jauge: #0B6BB8;
  --ombre: 0 1px 3px rgba(8, 82, 146, .08), 0 4px 14px rgba(8, 82, 146, .06);
  --rayon: 10px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--texte);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
.conteneur { max-width: 1440px; margin: 0 auto; padding: 0 16px; }
.saut { position: absolute; left: -9999px; }
.saut:focus { left: 16px; top: 8px; background: #fff; padding: 8px; z-index: 50; }
.visuellement-cache { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.entete { background: linear-gradient(135deg, var(--bleu-3), var(--bleu) 55%, var(--bleu-2)); color: #fff; padding: 28px 0 24px; }
.entete h1 { margin: 4px 0 10px; font-size: clamp(1.4rem, 3.4vw, 2.1rem); line-height: 1.2; }
.surtitre { margin: 0; opacity: .9; font-size: .9rem; }
.aide-principale { margin: 0; max-width: 980px; }

h2 { color: var(--bleu-3); font-size: 1.2rem; margin: 0 0 12px; }
h3 { color: var(--bleu-3); font-size: 1.02rem; margin: 18px 0 8px; }
.petit { font-size: .88rem; color: var(--texte-2); }
.exemple { display: inline-block; font-size: .72rem; font-weight: 600; color: var(--bleu-3); background: #e4eef8; border-radius: 4px; padding: 0 6px; }
kbd { border: 1px solid var(--bord); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; font-size: .82em; background: #fff; }

.alerte { margin: 16px 0; padding: 10px 14px; border-left: 4px solid var(--orange); background: var(--orange-fond); border-radius: 6px; }
.carte-section { background: var(--surface); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 18px; margin: 16px 0; }

.grille-champs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; align-items: end; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; font-weight: 600; color: var(--texte); }
label.case { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
input, select { font: inherit; padding: 8px 10px; border: 1px solid #9aa7b8; border-radius: 6px; background: #fff; color: var(--texte); min-height: 40px; width: 100%; }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--bleu); }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible, .carte:focus-visible { outline: 3px solid #f2a900; outline-offset: 2px; }
fieldset { border: 1px solid var(--bord); border-radius: 8px; margin: 14px 0 0; padding: 10px 12px; }
legend { font-weight: 700; color: var(--bleu-3); padding: 0 4px; }
.grille-cases { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px 14px; align-items: center; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn { font: inherit; font-weight: 600; border: 0; border-radius: 8px; padding: 9px 16px; min-height: 40px; cursor: pointer; background: var(--bleu); color: #fff; text-decoration: none; display: inline-flex; align-items: center; }
.btn:hover { background: var(--bleu-3); }
.btn-secondaire { background: #fff; color: var(--bleu); border: 1px solid var(--bleu); }
.btn-secondaire:hover { background: #e9f1fa; }
.btn-danger { background: #fff; color: var(--rouge); border: 1px solid var(--rouge); }
.btn-clair { background: #fff; color: var(--bleu-3); }
.btn-clair:hover { background: #e9f1fa; }
.mini { font: inherit; font-size: .8rem; min-width: 30px; min-height: 30px; padding: 2px 6px; border: 1px solid var(--bord); background: #fff; color: var(--bleu-3); border-radius: 6px; cursor: pointer; }
.mini:hover { background: #e9f1fa; }
.mini:disabled { opacity: .35; cursor: default; }

.liste-equipes { display: grid; gap: 8px; margin-bottom: 12px; }
.ligne-equipe, .ligne-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.ligne-equipe label { flex: 1 1 180px; }
.ligne-equipe label.effectif, .ligne-form label:nth-child(2) { flex: 0 0 110px; }
.ligne-form label:first-child { flex: 1 1 220px; }

.legende { list-style: none; padding: 0; margin: 8px 0 12px; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .88rem; }
.pastille { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.pastille.vert { background: var(--vert); } .pastille.orange { background: #e07b00; } .pastille.rouge { background: var(--rouge); }
.vide { padding: 18px; text-align: center; color: var(--texte-2); border: 2px dashed var(--bord); border-radius: 8px; }

/* ---- Mur ---- */
.mur-defilement { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.mur-grille { display: grid; grid-template-columns: 170px repeat(6, minmax(190px, 1fr)); gap: 6px; min-width: 1330px; }
.col-entete, .ligne-entete, .cellule, .coin, .total-cell { border-radius: 8px; padding: 8px; }
.coin { background: transparent; font-size: .8rem; color: var(--texte-2); }
.col-entete { background: var(--bleu); color: #fff; font-size: .82rem; }
.col-entete strong { font-size: 1rem; display: block; }
.col-entete .ferie { display: block; background: rgba(255,255,255,.18); border-radius: 4px; padding: 1px 5px; margin-top: 3px; font-size: .74rem; }
.ligne-entete { background: #e4eef8; color: var(--bleu-3); font-weight: 700; font-size: .9rem; }
.ligne-entete span { display: block; font-weight: 500; font-size: .78rem; color: var(--texte-2); }
.cellule { background: #f7f9fc; border: 2px dashed transparent; min-height: 110px; display: flex; flex-direction: column; gap: 6px; transition: background .12s; }
.cellule.survol { background: #e4eef8; border-color: var(--bleu-2); }
.charge { font-size: .74rem; color: var(--texte-2); display: flex; justify-content: space-between; gap: 4px; }
.charge.surcharge { color: var(--rouge); font-weight: 700; }
.barre-charge { height: 4px; background: #dfe6ef; border-radius: 2px; overflow: hidden; }
.barre-charge i { display: block; height: 100%; background: var(--bleu-2); border-radius: 2px; }
.barre-charge.surcharge i { background: var(--rouge); }
.total-cell { background: #eef2f7; font-size: .8rem; }

.carte { background: #fff; border: 1px solid var(--bord); border-left: 6px solid var(--vert); border-radius: 8px; padding: 6px 8px; font-size: .82rem; box-shadow: 0 1px 2px rgba(0,0,0,.05); cursor: grab; user-select: none; -webkit-user-select: none; position: relative; }
.carte.orange { border-left-color: #e07b00; background: #fffaf3; }
.carte.rouge { border-left-color: var(--rouge); background: #fff6f5; }
.carte.en-glisse { opacity: .35; }
.carte .haut { display: flex; gap: 6px; align-items: flex-start; }
.poignee { touch-action: none; cursor: grab; border: 0; background: #eef2f7; color: var(--texte-2); border-radius: 4px; min-width: 26px; min-height: 30px; font-size: 1rem; line-height: 1; padding: 0; }
.carte .titre { font-weight: 700; color: var(--texte); line-height: 1.25; }
.carte .tache { color: var(--texte); }
.carte .meta { color: var(--texte-2); font-size: .76rem; }
.carte .etat { margin-top: 3px; font-size: .76rem; font-weight: 600; }
.carte.vert .etat { color: var(--vert); } .carte.orange .etat { color: var(--orange); } .carte.rouge .etat { color: var(--rouge); }
.carte .stop { display: inline-block; background: var(--rouge); color: #fff; border-radius: 4px; padding: 0 5px; margin-top: 2px; font-size: .72rem; font-weight: 700; }
.carte .badge { display: inline-block; font-size: .7rem; font-weight: 700; border-radius: 4px; padding: 0 5px; margin: 2px 3px 0 0; }
.badge.tenu { background: var(--vert-fond); color: var(--vert); }
.badge.non_tenu { background: var(--rouge-fond); color: var(--rouge); }
.badge.ex { background: #e4eef8; color: var(--bleu-3); }
.carte .boutons { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 5px; }
.fantome { position: fixed; z-index: 1000; pointer-events: none; width: 190px; opacity: .92; box-shadow: 0 8px 24px rgba(0,0,0,.25); transform: rotate(2deg); }

.hors-periode { margin-top: 14px; padding: 12px; border: 1px solid var(--bord); border-radius: 8px; background: #fafbfd; }
.hors-periode .cartes { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }

/* Vue liste (mobile) */
.vue-liste { display: none; }
.onglets { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 6px; }
.onglets button { flex: 0 0 auto; font: inherit; font-size: .82rem; border: 1px solid var(--bleu); background: #fff; color: var(--bleu); border-radius: 6px; padding: 6px 8px; min-height: 40px; }
.onglets button[aria-selected=true] { background: var(--bleu); color: #fff; }
.bloc-equipe { margin: 10px 0; padding: 10px; background: #f7f9fc; border-radius: 8px; }
.bloc-equipe h3 { margin: 0 0 4px; }
.bloc-equipe .cartes { display: grid; gap: 6px; margin-top: 6px; }
.feries-semaine { font-size: .82rem; color: var(--texte-2); margin: 6px 0; }

@media (max-width: 760px) {
  .mur-defilement { display: none; }
  .vue-liste { display: block; }
  .carte { cursor: default; }
  .carte-section { padding: 14px 12px; }
}

/* ---- Jauge ---- */
.jauge-chiffres { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin: 14px 0; }
.tuile { background: #f7f9fc; border-radius: 8px; padding: 10px; }
.tuile .v { font-size: 1.35rem; font-weight: 700; color: var(--bleu-3); display: block; }
.tuile .l { font-size: .8rem; color: var(--texte-2); }
.verdict { padding: 10px 12px; border-radius: 8px; font-weight: 600; margin: 8px 0; }
.verdict.rouge { background: var(--rouge-fond); color: var(--rouge); }
.verdict.orange { background: var(--orange-fond); color: var(--orange); }
.verdict.vert { background: var(--vert-fond); color: var(--vert); }
.verdict.bleu { background: #e4eef8; color: var(--bleu-3); }
.verdict.inconnu { background: #eef2f7; color: var(--texte-2); }
.jauge-svg { width: 100%; max-width: 760px; height: auto; display: block; }

/* ---- PPC ---- */
.tableau-defilement { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .86rem; min-width: 640px; }
th, td { border-bottom: 1px solid var(--bord); padding: 6px 8px; text-align: left; vertical-align: top; }
th { color: var(--bleu-3); background: #f2f6fb; }
td.num { font-variant-numeric: tabular-nums; }
.pareto-svg { width: 100%; max-width: 760px; height: auto; display: block; }

/* ---- Passerelle & pied ---- */
.passerelle { background: linear-gradient(135deg, var(--bleu-3), var(--bleu)); color: #fff; border-radius: var(--rayon); padding: 20px; margin: 24px 0; }
.passerelle h2 { color: #fff; }
.passerelle code { background: rgba(255,255,255,.16); padding: 0 4px; border-radius: 4px; color: #fff; }
.pied { background: #e9eef5; color: var(--texte-2); font-size: .85rem; padding: 18px 0; margin-top: 24px; }

dialog { border: 0; border-radius: 12px; padding: 18px; width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); color: var(--texte); }
dialog::backdrop { background: rgba(6, 70, 126, .45); }
dialog h2 { margin-top: 0; }

/* ---- Impression A3 paysage ---- */
@media print {
  @page { size: A3 landscape; margin: 10mm; }
  body { background: #fff; font-size: 10pt; }
  .entete { background: none; color: #000; padding: 0 0 6px; }
  .entete .surtitre, .alerte, .saut, .actions, #form-equipe, #liste-equipes, .carte-section:not(.mur-section), .passerelle, .carte .boutons, .poignee, .vue-liste, .hors-periode, dialog, .mur-section > .petit { display: none !important; }
  .carte-section.mur-section { box-shadow: none; padding: 0; margin: 0; }
  .mur-defilement { display: block !important; overflow: visible; }
  .mur-grille { min-width: 0; grid-template-columns: 130px repeat(6, 1fr); gap: 3px; }
  .col-entete { background: #fff !important; color: #000; border: 1px solid #000; }
  .col-entete .ferie { background: none; border: 1px solid #555; }
  .cellule { min-height: 0; background: #fff; border: 1px solid #999; }
  .carte { break-inside: avoid; box-shadow: none; font-size: 8pt; padding: 3px 5px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pied { background: none; font-size: 8pt; padding: 4px 0; margin: 0; }
}
