/* ==========================================================================
   Module Production : planning, pointages, approvisionnement
   Grille faite main : une colonne par jour ouvré, la couleur appartient aux affaires.
   ========================================================================== */

.pr-barre-outils { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pr-segment { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; }
.pr-segment a, .pr-segment button { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 8px; border: 0; background: none;
  font: 600 13px var(--ff-ui); color: var(--fg-2); cursor: pointer; white-space: nowrap; }
.pr-segment a:hover, .pr-segment button:hover { background: var(--surface-2); color: var(--fg); text-decoration: none; }
.pr-segment a.actif { background: var(--fg); color: var(--bg); }

/* ---------- Bandeau des conflits ---------- */
.pr-conflits { border-radius: var(--r); border: 1px solid color-mix(in srgb, var(--bad) 30%, var(--line)); background: var(--surface);
  box-shadow: var(--ombre); overflow: hidden; margin-bottom: 18px; }
.pr-conflits-tete { display: flex; align-items: center; gap: 12px; padding: 14px 18px; background: var(--bad-bg); color: var(--bad); }
.pr-conflits-tete h2 { font-size: 16px; color: inherit; }
.pr-conflits-tete .ti { font-size: 22px; }
.pr-conflits.ok { border-color: color-mix(in srgb, var(--good) 30%, var(--line)); }
.pr-conflits.ok .pr-conflits-tete { background: var(--good-bg); color: var(--good); }
.pr-conflits.vigilance { border-color: color-mix(in srgb, var(--warn) 30%, var(--line)); }
.pr-conflits.vigilance .pr-conflits-tete { background: var(--warn-bg); color: var(--warn); }
.pr-conflit { display: flex; align-items: flex-start; gap: 12px; padding: 11px 18px; border-top: 1px solid var(--line); color: inherit; }
.pr-conflit:hover { background: var(--surface-2); text-decoration: none; }
.pr-conflit .icone-rond { width: 32px; height: 32px; border-radius: 9px; }
.pr-conflit .principal { flex: 1; min-width: 0; }
.pr-conflit .titre { font-weight: 600; font-size: 14px; }
.pr-conflit .sous { font-size: 13px; color: var(--fg-3); }
.pr-conflit .aller { color: var(--fg-3); align-self: center; }
.pr-conflits details summary { padding: 10px 18px; border-top: 1px solid var(--line); cursor: pointer; font-size: 13px; font-weight: 600; color: var(--fg-2); list-style: none; }
.pr-conflits details summary::-webkit-details-marker { display: none; }
.pr-conflits details summary .ti { transition: transform var(--t); }
.pr-conflits details[open] summary .ti-chevron-down { transform: rotate(180deg); }

/* ---------- Grille ---------- */
.pr-carte { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--ombre); overflow: hidden; }
.pr-scroll { overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.pr-grille { --pr-label: 220px; --pr-col: 34px; min-width: calc(var(--pr-label) + var(--nb) * var(--pr-col)); }
.pr-rang { display: grid; grid-template-columns: var(--pr-label) repeat(var(--nb), minmax(var(--pr-col), 1fr)); align-items: stretch; position: relative; }
.pr-rang > .pr-case { grid-row: 1; border-left: 1px solid var(--line); min-height: 100%; }
.pr-rang > .pr-case.lun { border-left-color: var(--line-2); }
.pr-rang > .pr-case.aujourdhui { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.pr-rang > .pr-case.ferie { background: repeating-linear-gradient(135deg, transparent 0 5px, var(--surface-3) 5px 6px); }
.pr-label { grid-column: 1; grid-row: 1; position: sticky; left: 0; z-index: 3; background: var(--surface); padding: 8px 12px 8px 16px;
  border-right: 1px solid var(--line); min-width: 0; display: flex; align-items: center; gap: 8px; }

.pr-semaines { border-bottom: 1px solid var(--line); background: var(--surface-2); }
.pr-semaines .pr-label { background: var(--surface-2); font-size: 12px; color: var(--fg-3); font-weight: 600; }
.pr-semaine { grid-row: 1; padding: 7px 8px; font-size: 12px; font-weight: 600; color: var(--fg-2); border-left: 1px solid var(--line-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-semaine .num { color: var(--fg-3); font-weight: 500; margin-left: 4px; }
.pr-jours { border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 4; background: var(--surface); }
.pr-jour { grid-row: 1; text-align: center; padding: 5px 0 6px; border-left: 1px solid var(--line); line-height: 1.15; }
.pr-jour.lun { border-left-color: var(--line-2); }
.pr-jour .j { font-size: 10.5px; color: var(--fg-3); text-transform: uppercase; letter-spacing: .03em; }
.pr-jour .n { font-family: var(--ff-num); font-size: 13px; font-weight: 600; }
.pr-jour.aujourdhui .n { background: var(--accent); color: #fff; border-radius: 99px; display: inline-block; min-width: 22px; padding: 0 4px; }
:root[data-theme="dark"] .pr-jour.aujourdhui .n { color: #1b160f; }
.pr-jour.ferie .j, .pr-jour.ferie .n { color: var(--bad); }

.pr-affaire { border-top: 1px solid var(--line); background: var(--surface-2); }
.pr-affaire .pr-label { background: var(--surface-2); grid-column: 1 / -1; position: sticky; left: 0; border-right: 0; padding: 9px 16px; }
.pr-affaire .pastille-affaire { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.pr-affaire .nom { font-weight: 700; font-family: var(--ff-d); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-affaire .sous { font-size: 12.5px; color: var(--fg-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pr-ligne { border-top: 1px solid var(--line); min-height: 46px; }
.pr-ligne .pr-label { font-size: 13.5px; }
.pr-ligne .pr-label .principal { min-width: 0; flex: 1; }
.pr-ligne .pr-label .titre { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-ligne .pr-label .sous { font-size: 12px; color: var(--fg-3); white-space: nowrap; }
.pr-lieu { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--fg-2); }
.pr-lieu .ti { font-size: 15px; vertical-align: 0; }
.pr-lieu.atelier { background: var(--accent-doux); color: var(--accent-fg); }
.pr-lieu.chantier { background: var(--vente-doux); color: var(--vente); }

.pr-barre { grid-row: 1; z-index: 1; align-self: center; margin: 6px 2px; height: 32px; border-radius: 8px; position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 6px; padding: 0 8px; color: var(--fg); font-size: 12.5px; font-weight: 600;
  background: color-mix(in srgb, var(--c) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  border-left: 4px solid var(--c); transition: box-shadow var(--t), transform var(--t); white-space: nowrap; min-width: 0; }
.pr-barre:hover { box-shadow: var(--ombre-h); transform: translateY(-1px); text-decoration: none; z-index: 2; }
.pr-barre > * { position: relative; }
.pr-barre .pr-av { position: absolute; left: 0; top: 0; bottom: 0; background: color-mix(in srgb, var(--c) 28%, transparent); z-index: -1; }
.pr-barre .txt { overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.pr-barre .pct { font-family: var(--ff-num); font-size: 11.5px; color: var(--fg-2); flex: none; }
.pr-barre .ti { font-size: 15px; vertical-align: 0; flex: none; }
.pr-barre.coupe-g { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left-style: dashed; }
.pr-barre.coupe-d { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.pr-barre.terminee { opacity: .55; }
.pr-barre.conflit { box-shadow: 0 0 0 2px var(--bad); }
.pr-marques { display: flex; align-items: center; gap: 3px; flex: none; }
.pr-pt { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--line-2); }
.pr-pt.good { background: var(--good); } .pr-pt.warn { background: var(--warn); } .pr-pt.bad { background: var(--bad); }
.pr-meteo { color: var(--info); }
.pr-alerte { color: var(--bad); }
.pr-avatars { display: flex; flex: none; }
.pr-avatars .avatar { width: 20px; height: 20px; font-size: 9px; border: 1.5px solid var(--surface); margin-left: -5px; }
.pr-avatars .avatar:first-child { margin-left: 0; }

/* vue par personne */
.pr-personne { border-top: 1px solid var(--line); min-height: 52px; }
.pr-personne .pr-label .titre { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-personne .pr-label .sous { font-size: 12px; color: var(--fg-3); }
.pr-bloc { grid-row: 1; z-index: 1; align-self: center; margin: 6px 2px; min-height: 36px; border-radius: 8px; padding: 4px 8px; font-size: 12px;
  line-height: 1.25; overflow: hidden; color: var(--fg); background: color-mix(in srgb, var(--c, var(--fg-3)) 16%, var(--surface));
  border-left: 4px solid var(--c, var(--fg-3)); display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.pr-bloc:hover { text-decoration: none; box-shadow: var(--ombre-h); }
.pr-bloc b, .pr-bloc span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-bloc span { color: var(--fg-2); }
.pr-bloc.indispo { --c: var(--fg-3); background: repeating-linear-gradient(135deg, var(--surface-2) 0 6px, var(--surface-3) 6px 12px); }
.pr-bloc.conflit { --c: var(--bad); background: repeating-linear-gradient(135deg, var(--bad-bg) 0 6px, color-mix(in srgb, var(--bad) 18%, var(--surface)) 6px 12px); color: var(--bad); }
.pr-charge { font-family: var(--ff-num); font-size: 11.5px; padding: 1px 6px; border-radius: 99px; background: var(--surface-3); color: var(--fg-2); flex: none; }
.pr-charge.plein { background: var(--good-bg); color: var(--good); }
.pr-charge.vide { background: var(--warn-bg); color: var(--warn); }

.pr-legende { display: flex; flex-wrap: wrap; gap: 14px; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--fg-3); }
.pr-legende span { display: inline-flex; align-items: center; gap: 6px; }
.pr-legende .ti { font-size: 15px; }

.pr-cote { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }

/* ---------- Fiche phase ---------- */
.ph-entete { border-left: 5px solid var(--c); padding-left: 14px; }
.ph-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.ph-equipe { display: flex; flex-direction: column; }
.ph-membre { display: flex; align-items: center; gap: 10px; padding: 9px 20px; border-top: 1px solid var(--line); }
.ph-membre:first-child { border-top: 0; }
.ph-membre .principal { flex: 1; min-width: 0; }

/* ---------- Recalage avant / après ---------- */
.rc-colonnes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0; }
.rc-colonnes > div { padding: 16px 20px; }
.rc-colonnes > div + div { border-left: 1px solid var(--line); background: color-mix(in srgb, var(--accent) 4%, var(--surface)); }
.rc-frise { padding: 6px 20px 18px; }
.rc-ligne { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 10px; align-items: center; padding: 6px 0; }
.rc-piste { position: relative; height: 34px; background: repeating-linear-gradient(90deg, transparent 0 calc(100% / 8 - 1px), var(--line) calc(100% / 8 - 1px) calc(100% / 8)); border-radius: 6px; }
.rc-avant, .rc-apres { position: absolute; height: 13px; border-radius: 4px; }
.rc-avant { top: 3px; background: color-mix(in srgb, var(--fg-3) 30%, transparent); border: 1px dashed var(--fg-3); }
.rc-apres { bottom: 3px; background: var(--c); }
.rc-apres.inchange { opacity: .45; }
.rc-table td.avant { color: var(--fg-3); }
.rc-table tr.change td.apres { font-weight: 600; color: var(--accent-fg); }
.rc-fleche { color: var(--fg-3); }
.rc-validation { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; }

/* ---------- Pointages ---------- */
.pt-jour { margin-bottom: 14px; }
.pt-jour-tete { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 20px 10px; }
.pt-groupe { border-top: 1px solid var(--line); }
.pt-groupe-tete { display: flex; align-items: center; gap: 10px; padding: 10px 20px; background: var(--surface-2); font-size: 13.5px; }
.pt-groupe-tete .principal { flex: 1; min-width: 0; font-weight: 600; }
.pt-ligne { display: flex; align-items: center; gap: 12px; padding: 9px 20px; border-top: 1px solid var(--line); }
.pt-ligne .principal { flex: 1; min-width: 0; }
.pt-ligne .heures { font-family: var(--ff-num); font-weight: 600; font-size: 15px; min-width: 58px; text-align: right; }
.pt-puces { display: flex; gap: 6px; flex-wrap: wrap; }
.pt-ligne.valide { opacity: .55; }
.pt-synthese td .barre { min-width: 90px; }
.pt-ecart.bad { color: var(--bad); font-weight: 600; } .pt-ecart.good { color: var(--good); font-weight: 600; } .pt-ecart.warn { color: var(--warn); font-weight: 600; }
.pt-phase td:first-child { padding-left: 34px; color: var(--fg-2); }
.pt-affaire td { font-weight: 600; background: var(--surface-2); }

/* ---------- Logistique ---------- */
.lg-frise { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.lg-semaine { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; min-height: 140px; }
.lg-semaine.courante { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); background: color-mix(in srgb, var(--accent) 5%, var(--surface-2)); }
.lg-semaine h3 { font-size: 13px; color: var(--fg-2); padding: 2px 4px 10px; display: flex; justify-content: space-between; gap: 8px; }
.lg-phase { display: block; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: var(--r-s);
  padding: 9px 11px; margin-bottom: 8px; color: inherit; box-shadow: var(--ombre); transition: box-shadow var(--t), transform var(--t); }
.lg-phase:hover { box-shadow: var(--ombre-h); transform: translateY(-1px); text-decoration: none; }
.lg-phase .titre { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 7px; }
.lg-phase .sous { font-size: 12px; color: var(--fg-3); }
.lg-voyant { display: flex; align-items: center; gap: 7px; font-size: 12px; margin-top: 6px; color: var(--fg-2); }
.lg-feu { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--line-2); box-shadow: 0 0 0 3px var(--surface-3); }
.lg-feu.good { background: var(--good); box-shadow: 0 0 0 3px var(--good-bg); }
.lg-feu.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }
.lg-feu.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-bg); }
.lg-kanban { grid-auto-columns: minmax(220px, 1fr); }
.lg-carte .titre { font-weight: 600; font-size: 13.5px; }
.lg-carte .sous { font-size: 12px; color: var(--fg-3); }
.lg-carte .pied { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 7px; }

.cmd-etapes { display: flex; gap: 0; overflow-x: auto; padding: 4px 2px 2px; }
.cmd-etape { flex: 1; min-width: 92px; text-align: center; position: relative; font-size: 12px; color: var(--fg-3); padding-top: 26px; }
.cmd-etape::before { content: ""; position: absolute; top: 9px; left: 0; right: 0; height: 3px; background: var(--line); }
.cmd-etape:first-child::before { left: 50%; } .cmd-etape:last-child::before { right: 50%; }
.cmd-etape .rond { position: absolute; top: 2px; left: calc(50% - 9px); width: 18px; height: 18px; border-radius: 50%; background: var(--surface);
  border: 3px solid var(--line-2); z-index: 1; }
.cmd-etape.faite { color: var(--fg-2); } .cmd-etape.faite::before { background: var(--good); }
.cmd-etape.faite .rond { background: var(--good); border-color: var(--good); }
.cmd-etape.courante { color: var(--fg); font-weight: 700; }
.cmd-etape.courante .rond { border-color: var(--accent); background: var(--accent-doux); box-shadow: 0 0 0 4px var(--accent-doux); }
.cmd-etape.litige .rond { border-color: var(--bad); background: var(--bad); }

.rp-frise { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.rp-jalon { border: 1px solid var(--line); border-radius: var(--r-s); padding: 10px 12px; background: var(--surface-2); position: relative; }
.rp-jalon .label { font-size: 12px; color: var(--fg-3); }
.rp-jalon .date { font-family: var(--ff-num); font-weight: 600; font-size: 15px; }
.rp-jalon.cle { background: var(--accent-doux); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.rp-jalon.cle .date { color: var(--accent-fg); }
.rp-jalon.depasse { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.rp-jalon.depasse .date { color: var(--bad); }

.pr-lignes-cmd { width: 100%; border-collapse: collapse; }
.pr-lignes-cmd td { padding: 4px 4px; }
.pr-lignes-cmd input { min-height: 36px; padding: 6px 10px; font-size: 14px; }

.fr-ligne summary { list-style: none; cursor: pointer; }
.fr-ligne summary::-webkit-details-marker { display: none; }
.fr-ligne[open] summary { background: var(--surface-2); }
.fr-ligne .fr-form { padding: 6px 20px 16px; border-top: 1px dashed var(--line); }

.pr-erreurs { margin-bottom: 14px; }
.pr-erreurs ul { margin: 4px 0 0; padding-left: 18px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .pr-cote { grid-template-columns: minmax(0, 1fr); }
  .ph-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .pr-grille { --pr-label: 140px; --pr-col: 28px; }
  .pr-ligne .pr-label .sous, .pr-personne .pr-label .sous { display: none; }
  .pr-label { padding: 6px 8px 6px 10px; }
  .pr-barre .txt, .pr-barre .pct { display: none; }
  .pr-barre { justify-content: center; padding: 0 4px; }
  .pr-bloc span { display: none; }
  .rc-colonnes { grid-template-columns: minmax(0, 1fr); }
  .rc-colonnes > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .rc-ligne { grid-template-columns: 90px minmax(0, 1fr); }
  .rp-frise { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pt-ligne { flex-wrap: wrap; }
}
