:root {
  --fond: #f4f5f7; --panneau: #ffffff; --panneau-2: #fafbfc;
  --texte: #12181f; --doux: #5d6b7a; --ligne: #e0e4e9; --ligne-forte: #c3ccd6;
  --accent: #1f5fa8; --accent-texte: #ffffff;
  --weekend: #eef0f3; --danger: #b4232a; --ok: #1c7a4a; --alerte: #a86100;
  --serie: #1f5fa8; --serie-douce: #b9cde5;
  --ombre: 0 1px 2px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.06);
  --r: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0f1418; --panneau: #171d23; --panneau-2: #1c2329;
    --texte: #e6ebf0; --doux: #93a1b0; --ligne: #2a333c; --ligne-forte: #3d4954;
    --accent: #4a90d9; --accent-texte: #0b1116;
    --weekend: #131a20; --danger: #e06a70; --ok: #4cc38a; --alerte: #d99a3a;
    --serie: #4a90d9; --serie-douce: #26415d;
    --ombre: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--texte);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
a { color: var(--accent); }

/* ---------- ossature ---------- */
.entete {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 12px 20px; background: var(--panneau); border-bottom: 1px solid var(--ligne);
  position: sticky; top: 0; z-index: 30;
}
.marque { display: flex; align-items: baseline; gap: 10px; }
.marque strong { font-size: 17px; letter-spacing: -.02em; }
.marque span { color: var(--doux); font-size: 12.5px; text-transform: uppercase; letter-spacing: .09em; }
.onglets { display: flex; gap: 2px; margin-left: auto; flex-wrap: wrap; }
.onglets button {
  border: 0; background: transparent; color: var(--doux); cursor: pointer;
  padding: 7px 13px; border-radius: var(--r); font: inherit; font-size: 14px;
}
.onglets button:hover { background: var(--panneau-2); color: var(--texte); }
.onglets button[aria-current="page"] { background: var(--accent); color: var(--accent-texte); }
.qui { display: flex; align-items: center; gap: 10px; color: var(--doux); font-size: 13.5px; }

main { padding: 16px 20px 40px; max-width: 1800px; margin: 0 auto; }
.vue[hidden] { display: none; }
.carte { background: var(--panneau); border: 1px solid var(--ligne); border-radius: var(--r); box-shadow: var(--ombre); }
.carte + .carte { margin-top: 16px; }
.carte > header {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--ligne);
}
.carte > header h2 { font-size: 15px; }
.carte > footer { padding: 9px 16px; border-top: 1px solid var(--ligne); }
.carte .corps { padding: 16px; }
.legende { display: flex; gap: 18px; flex-wrap: wrap; }

/* ---------- contrôles ---------- */
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--panneau-2); border: 1px solid var(--ligne); border-radius: 6px;
  padding: 7px 9px; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type="color"] { height: 36px; padding: 3px; }
textarea { resize: vertical; min-height: 68px; }
label { display: block; font-size: 12.5px; color: var(--doux); margin-bottom: 4px; }
.champ { margin-bottom: 12px; }
.grille2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.bouton {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  background: var(--panneau-2); border: 1px solid var(--ligne); border-radius: 6px;
  padding: 7px 13px; cursor: pointer; white-space: nowrap; width: auto;
}
.bouton:hover { border-color: var(--accent); }
.bouton.primaire { background: var(--accent); border-color: var(--accent); color: var(--accent-texte); }
.bouton.danger { color: var(--danger); }
.bouton:disabled { opacity: .5; cursor: not-allowed; }
.pousse { margin-left: auto; }
.mini { color: var(--doux); font-size: 13px; }

/* ---------- planning : réserve + grille ---------- */
.zone-planning { display: flex; gap: 16px; align-items: flex-start; }
.reserve { width: 292px; flex: none; display: flex; flex-direction: column; position: sticky; top: 77px; }
.reserve .corps { padding: 10px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; max-height: calc(100svh - 210px); }
@media (max-width: 1150px) {
  .zone-planning { flex-wrap: wrap; }
  .reserve { width: 100%; position: static; }
  .reserve .corps { max-height: 300px; flex-direction: row; flex-wrap: wrap; }
  .reserve .fiche { width: 240px; }
}
.fiche {
  border: 1px solid var(--ligne); border-left: 4px solid var(--urgence, var(--accent));
  border-radius: 6px; padding: 8px 10px; background: var(--panneau-2); cursor: grab;
}
.fiche:hover { border-color: var(--accent); border-left-color: var(--urgence, var(--accent)); }
.fiche:active { cursor: grabbing; }
.fiche.glisse { opacity: .4; }
.fiche b { display: block; font-size: 13.5px; }
.fiche .meta { display: flex; gap: 6px 10px; flex-wrap: wrap; color: var(--doux); font-size: 12px; margin-top: 3px; }
.fiche .jauge { height: 4px; border-radius: 2px; background: var(--ligne); margin-top: 6px; overflow: hidden; }
.fiche .jauge i { display: block; height: 100%; background: var(--urgence, var(--accent)); }
.urgence-basse { --urgence: #7c8896; }
.urgence-normale { --urgence: var(--accent); }
.urgence-haute { --urgence: var(--alerte); }
.urgence-critique { --urgence: var(--danger); }
.pastille-urgence { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--urgence); margin-right: 4px; vertical-align: baseline; }

.planning { overflow-x: auto; }
.grille { min-width: 820px; }
.ligne-semaines, .ligne-jours, .rangee { display: grid; grid-template-columns: var(--colonnes); }
.ligne-semaines, .ligne-jours { position: sticky; background: var(--panneau); z-index: 10; }
.ligne-semaines { top: 57px; }
.ligne-jours { top: 80px; border-bottom: 1px solid var(--ligne); }
.semaine { grid-column: span 5; text-align: center; font-size: 11.5px; color: var(--doux); padding: 3px 4px; border-left: 2px solid var(--ligne-forte); }
.semaine.courante { color: var(--accent); font-weight: 600; }
.jour { padding: 5px 2px 6px; text-align: center; font-size: 11px; color: var(--doux); border-left: 1px solid var(--ligne); }
.jour.lundi, .colonne.lundi { border-left: 2px solid var(--ligne-forte); }
.jour.aujourdhui { color: var(--accent); font-weight: 700; }
.jour b { display: block; font-size: 13.5px; color: var(--texte); font-weight: 600; }
.jour.aujourdhui b { color: var(--accent); }
.coin { border-bottom: 1px solid var(--ligne); }

.rangee { border-bottom: 1px solid var(--ligne); }
.rangee:last-child { border-bottom: 0; }
.rangee-tete { padding: 10px 12px; display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; background: var(--panneau-2); }
.pastille { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.rangee-tete small { color: var(--doux); font-weight: 400; }
.piste { position: relative; display: grid; row-gap: 3px; column-gap: 0; padding: 4px 0; }
.colonne { grid-row: 1 / -1; border-left: 1px solid var(--ligne); cursor: copy; }
.colonne.aujourdhui { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.colonne:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.colonne.cible { background: color-mix(in srgb, var(--accent) 26%, transparent); box-shadow: inset 0 0 0 1px var(--accent); }
.barre {
  position: relative; z-index: 2; margin: 0 2px; padding: 3px 7px; border-radius: 5px;
  border: 0; font-family: inherit; font-size: 12.5px; line-height: 1.25; cursor: grab;
  overflow: hidden; color: #fff; border-left: 3px solid rgba(0,0,0,.3); text-align: left;
}
.barre:hover { filter: brightness(1.08); }
.barre.glisse { opacity: .4; }
.barre.verrou { cursor: not-allowed; box-shadow: inset 0 0 0 2px rgba(255,255,255,.55); }
.barre b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barre small { opacity: .88; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.barre.termine { opacity: .55; }
.barre.annule { opacity: .45; text-decoration: line-through; }
.puce-verrou { font-size: 11px; }
.vide { padding: 28px 16px; text-align: center; color: var(--doux); }

/* ---------- tableaux ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--ligne); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--doux); font-weight: 600; }
td.nombre, th.nombre { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--panneau-2); }
tfoot td { font-weight: 650; border-top: 2px solid var(--ligne-forte); }
.etiquette { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--ligne); white-space: nowrap; }
.etiquette.prevu { color: var(--accent); border-color: currentColor; }
.etiquette.en_cours { color: var(--ok); border-color: currentColor; }
.etiquette.termine { color: var(--doux); }
.etiquette.annule { color: var(--danger); border-color: currentColor; }

/* ---------- rapport ---------- */
.tuiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 12px; margin-bottom: 22px; }
.tuile { border: 1px solid var(--ligne); border-radius: 8px; padding: 12px 14px; background: var(--panneau-2); }
.tuile .lib { font-size: 11.5px; color: var(--doux); text-transform: uppercase; letter-spacing: .07em; }
.tuile .val { font-size: 25px; font-weight: 650; letter-spacing: -.025em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tuile .note { font-size: 12px; color: var(--doux); }
.figure { margin: 0 0 22px; }
.figure figcaption { font-size: 13.5px; font-weight: 600; margin-bottom: 2px; }
.figure .sous { font-size: 12.5px; color: var(--doux); margin-bottom: 10px; }
.figure svg { display: block; width: 100%; height: auto; overflow: visible; }
.axe { fill: var(--doux); font-size: 11px; }
.grille-h { stroke: var(--ligne); stroke-width: 1; }
.zero { stroke: var(--ligne-forte); stroke-width: 1; }
.marque-svg { fill: var(--serie); }
.repere { stroke: var(--doux); stroke-width: 1; stroke-dasharray: 3 3; }
.etiq-val { fill: var(--texte); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cle { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--doux); margin: 4px 0 10px; }
.cle i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; vertical-align: -2px; margin-right: 5px; }

/* ---------- modale & infobulle ---------- */
dialog {
  border: 1px solid var(--ligne); border-radius: 10px; padding: 0; background: var(--panneau);
  color: var(--texte); box-shadow: var(--ombre); width: min(560px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(8,12,16,.55); }
dialog header, dialog footer { padding: 13px 16px; }
dialog header { border-bottom: 1px solid var(--ligne); }
dialog .corps { padding: 16px; }
dialog footer { border-top: 1px solid var(--ligne); display: flex; gap: 8px; align-items: center; }
#infobulle {
  position: fixed; z-index: 100; pointer-events: none; background: var(--panneau);
  border: 1px solid var(--ligne-forte); border-radius: 6px; padding: 7px 10px;
  font-size: 12.5px; box-shadow: var(--ombre); max-width: 280px;
}
#infobulle[hidden] { display: none; }

/* ---------- connexion ---------- */
.accueil { min-height: 100svh; display: grid; place-items: center; padding: 24px; }
.accueil .carte { width: min(420px, 100%); }
.message { padding: 9px 12px; border-radius: 6px; font-size: 13.5px; margin-bottom: 12px; }
.message.err { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.message.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
