/* =========================================================================
   fiche.css — la FICHE CHANTIER.

   Reprise de la feuille de la fiche « marché signé » de tahauku-app
   (front/html/admin/index.html, bloc <style> lignes 14 à 800) : mêmes
   briques, mêmes noms de classes (.card .kv .grid2 .badge .jauge
   .dossier-tabs .num .dt .mono), même densité. Deux différences voulues :

     — l'accent n'est plus l'orange HIKUE mais la BRIQUE TAHAUKU #94301c,
       prise sur les jetons déjà posés par base.css (--accent-texte /
       --accent-fond), donc les deux thèmes suivent sans règle en double ;
     — TOUT est confiné sous « .fiche ». La feuille d'origine habille les
       balises nues (table, th, td, input, button) ; ici cela écraserait la
       GED, les tableaux éditables et le wiki, déjà livrés et recettés. Le
       conteneur de la fiche, et toute fenêtre qu'elle ouvre, portent donc
       la classe « fiche » — rien d'autre dans l'application ne la porte.

   Aucune ressource externe : la police reste celle du poste.
   ========================================================================= */

/* ---- jetons ------------------------------------------------------------
   Alias sur les variables de base.css : changer de thème ne change que
   base.css, et cette feuille suit. Les jetons vraiment nouveaux (fonds des
   états, information) sont posés ici, pour les deux thèmes. */
:root {
  --accent: var(--accent-texte);        /* filets, titres, texte accentué   */
  --accent-plein: var(--accent-fond);   /* aplats portant du texte clair    */
  --on-accent: var(--accent-fond-texte);
  --accent-soft: var(--accent-voile);
  --accent-ink: var(--accent-texte);
  --ink: var(--encre);
  --muted: var(--encre-faible);
  --line: var(--filet);
  --warn: var(--alerte);
  --danger: var(--echec);

  --ok-bg: #e4f1ea;
  --warn-bg: #fdf3e2;
  --danger-bg: #fbe9e7;
  --info: #1a4f8a;
  --info-bg: #e8eff8;
  --zebra: rgba(0, 0, 0, .022);
}

:root[data-theme="sombre"] {
  --ok-bg: #14291f;
  --warn-bg: #2b2410;
  --danger-bg: #2c1614;
  --info: #7ab6f0;
  --info-bg: #12222f;
  --zebra: rgba(255, 255, 255, .018);
}

/* ---- ossature ---------------------------------------------------------- */

.fiche { min-width: 0; }

.fiche .fiche-tete {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 8px;
}
.fiche .fiche-tete h1 { margin: 0; font-size: 1.1rem; min-width: 0; overflow-wrap: anywhere; }
.fiche .spacer { flex: 1 1 auto; }

/* Barre d'onglets du dossier. Dans tahauku-app elle est en `nowrap` avec un
   défilement horizontal MUET : à 390 px, « Pièces » et « Échanges » sont hors
   écran et rien ne le dit. Ici elle se REPLIE — deux lignes valent mieux
   qu'un onglet invisible — et, si un onglet plus large que la barre forçait
   quand même un défilement, la classe `defile` allume deux flèches. */
.fiche .dossier-tabs-enveloppe { position: relative; display: flex; align-items: stretch; gap: 4px; }
.fiche .dossier-tabs {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: 0 0 12px; padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  flex: 1 1 auto; min-width: 0;
}
.fiche .dossier-tabs-enveloppe .tabs-fleche { display: none; }
.fiche .dossier-tabs-enveloppe.defile .dossier-tabs { flex-wrap: nowrap; overflow-x: auto; }
.fiche .dossier-tabs-enveloppe.defile .tabs-fleche {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; align-self: flex-start;
  border: 1px solid var(--filet-fort); background: var(--surface);
  color: var(--accent); font-weight: 700; cursor: pointer; border-radius: var(--rayon);
}
.fiche .dossier-tabs-enveloppe.defile .tabs-fleche[disabled] { opacity: .35; cursor: default; }

.fiche .tab {
  min-height: 44px; padding: 0 12px;
  font: inherit; font-weight: 600; font-size: .92rem;
  color: var(--accent); background: var(--surface);
  border: 1px solid var(--filet-fort); border-radius: var(--rayon);
  cursor: pointer; white-space: nowrap;
}
.fiche .tab:hover { background: var(--accent-soft); }
.fiche .tab.active {
  background: var(--accent-plein); border-color: var(--accent-plein);
  color: var(--on-accent); font-weight: 700;
}
.fiche .sousonglets { margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }

/* ---- cartes et paires clé / valeur ------------------------------------- */

.fiche .card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--rayon); padding: 14px; margin-bottom: 12px;
}
.fiche .card > h3 { margin: 0 0 10px; font-size: .98rem; color: var(--accent-ink); }
.fiche .card-tete { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.fiche .card-tete > b { font-size: .98rem; }

.fiche .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fiche .grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 760px) {
  .fiche .grid2, .fiche .grid3 { grid-template-columns: 1fr; }
}

.fiche .kv {
  display: flex; gap: 8px; align-items: baseline;
  margin: 3px 0; padding: 3px 0;
  border-bottom: 1px dotted var(--line); font-size: .92rem;
}
.fiche .kv:last-child { border-bottom: 0; }
.fiche .kv > b { flex: 0 0 42%; max-width: 42%; color: var(--muted); font-weight: 600; }
.fiche .kv > span { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
/* Une mesure qu'aucune source ne porte : dite absente, jamais remplacée par
   un zéro, et visiblement plus pâle que ce qui est renseigné. */
.fiche .absente { color: var(--muted); font-style: italic; }

.fiche .sub { color: var(--muted); font-size: .85rem; margin: 4px 0 0; }
.fiche .empty {
  padding: 14px; text-align: center; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--rayon);
}

/* ---- messages posés dans le flux --------------------------------------- */

.fiche .notice {
  padding: 9px 12px; margin-bottom: 10px; font-size: .88rem;
  border: 1px solid var(--line); border-left: 4px solid var(--accent);
  background: var(--surface-2); border-radius: var(--rayon);
}
.fiche .notice.att { border-left-color: var(--warn); background: var(--warn-bg); }
.fiche .notice.bloc { border-left-color: var(--danger); background: var(--danger-bg); }

/* ---- pastilles d'état --------------------------------------------------- */

.fiche .badge {
  display: inline-block; padding: 1px 8px; border-radius: 20px;
  font-size: .74rem; font-weight: 700; white-space: nowrap;
  background: var(--surface-3); color: var(--muted);
  border: 1px solid var(--line);
}
.fiche .badge.valide { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.fiche .badge.transmis { background: var(--info-bg); color: var(--info); border-color: var(--info); }
.fiche .badge.att { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.fiche .badge.non { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }

/* ---- jauge -------------------------------------------------------------- */

.fiche .jauge-ligne { display: flex; align-items: center; gap: 8px; }
.fiche .jauge {
  flex: 1 1 auto; height: 10px; background: var(--surface-3);
  border: 1px solid var(--line); border-radius: 5px; overflow: hidden;
}
.fiche .jauge > .jbar { display: block; height: 100%; background: var(--accent-plein); }
.fiche .jauge > .jbar.pleine { background: var(--ok); }
.fiche .jauge-val { font-family: var(--mono); font-size: .82rem; min-width: 62px; text-align: right; }

/* ---- vignettes de jalons ------------------------------------------------ */

.fiche .jalons { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.fiche .jalon {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--line); border-radius: var(--rayon); padding: 8px 10px;
}
.fiche .jalon.passe { border-left-color: var(--warn); }
.fiche .jalon .jl { display: block; font-size: .78rem; color: var(--muted); }
.fiche .jalon .jv { display: block; font-size: 1rem; font-weight: 700; margin-top: 2px; }
.fiche .jalon .jn { display: block; font-size: .74rem; color: var(--muted); font-style: italic; margin-top: 2px; }

/* ---- lignes « ce qui attend une décision » ------------------------------ */

.fiche .mkactions { display: flex; flex-direction: column; gap: 6px; }
.fiche .mkact {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 8px 11px; font-size: .88rem;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--line); border-radius: var(--rayon);
}
.fiche .mkact.att { border-left-color: var(--warn); background: var(--warn-bg); color: var(--warn); }
.fiche .mkact.bloc { border-left-color: var(--danger); background: var(--danger-bg); color: var(--danger); }
.fiche .mkact.ok { border-left-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.fiche .mkact > span { flex: 1 1 200px; min-width: 0; }

/* ---- tableaux (confinés : les tableaux éditables gardent les leurs) ----- */

.fiche .table-defile { overflow-x: auto; max-width: 100%; }
.fiche .table-defile:focus-visible { outline: 2px solid var(--accent); }
.fiche table {
  width: 100%; border-collapse: collapse;
  background: var(--surface); border: 1px solid var(--line);
}
.fiche th, .fiche td {
  text-align: left; padding: 8px 10px;
  border-bottom: 1px solid var(--line); font-size: .88rem; vertical-align: top;
}
.fiche th { background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; }
.fiche tbody tr:nth-child(even) td { background: var(--zebra); }
.fiche tr:last-child td { border-bottom: 0; }
.fiche td.num, .fiche th.num {
  text-align: right; white-space: nowrap;
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}
.fiche th.dt, .fiche td.dt { white-space: nowrap; }
.fiche .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
/* Une ligne ouvrable se prend au clic ET au clavier. Le fond du survol n'est
   qu'un renfort : l'état de la ligne est porté par son contenu, jamais par
   le seul survol. */
.fiche tbody tr.ouvrable { cursor: pointer; }
.fiche tbody tr.ouvrable:hover td,
.fiche tbody tr.ouvrable:focus-within td { background: var(--surface-3); }
.fiche tr.incomplete td { background: var(--warn-bg); }

/* ---- champ de date à la française -------------------------------------- */
/* JJ/MM/AAAA, toujours. Le champ natif <input type="date"> affiche le format
   du NAVIGATEUR : sur le poste de test il rend « mm/dd/yyyy », défaut relevé
   sur la fiche d'origine. On saisit donc en texte, et rien ne passe par
   Date() : à UTC−10 une conversion reculerait la date d'un jour. */
.fiche .datefr { display: inline-flex; flex-direction: column; gap: 2px; min-width: 118px; }
.fiche .datefr > input {
  width: 118px; min-height: 44px; padding: 4px 8px;
  font: inherit; font-family: var(--mono); font-size: .88rem;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--filet-fort); border-radius: var(--rayon);
}
.fiche .datefr > input[aria-invalid="true"] { border-color: var(--danger); border-width: 2px; }
.fiche .datefr > .datefr-msg { font-size: .74rem; color: var(--muted); min-height: 14px; }
.fiche .datefr > .datefr-msg[data-etat="echec"] { color: var(--danger); }
.fiche .datefr > .datefr-msg[data-etat="ok"] { color: var(--ok); }

/* ---- vignettes de pièces ------------------------------------------------ */

.fiche .journee { border: 1px solid var(--line); border-radius: var(--rayon); margin-bottom: 8px; background: var(--surface); }
.fiche .journee > summary {
  cursor: pointer; padding: 10px 12px; min-height: 44px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--surface-2); font-weight: 700; font-size: .9rem;
}
.fiche .journee > summary::marker { color: var(--accent); }
.fiche .journee > div { padding: 10px 12px; }
.fiche .vignettes { display: flex; flex-wrap: wrap; gap: 8px; }
.fiche .vignette {
  display: block; width: 140px; border: 1px solid var(--line);
  border-radius: var(--rayon); overflow: hidden; background: var(--surface-2);
  color: inherit; text-decoration: none;
}
.fiche .vignette:hover, .fiche .vignette:focus-visible { border-color: var(--accent); }
.fiche .vignette > img { display: block; width: 140px; height: 105px; object-fit: cover; }
.fiche .vignette > .vsansimg {
  display: flex; align-items: center; justify-content: center;
  width: 140px; height: 105px; font-family: var(--mono); font-size: .8rem; color: var(--muted);
}
.fiche .vignette > .vlegende {
  display: block; padding: 4px 6px; font-size: .74rem; line-height: 1.25;
  border-top: 1px solid var(--line);
}
.fiche .vignette > .vlegende .vnom { display: block; overflow-wrap: anywhere; }
/* Une pastille de publication est plus large que la vignette : elle se plie
   plutôt que d'être rognée. « publiée — pas encore vue » tronqué à
   « publiée » dirait exactement le contraire de ce qu'il faut lire. */
.fiche .vignette > .vlegende .badge {
  display: inline-block; margin-top: 3px; white-space: normal;
}

/* ---- espace de travail du lot (fenêtre 95 %) ---------------------------- */

.modale.modale-plein {
  width: 95vw; max-width: 95vw; height: 95vh; max-height: 95vh;
}
@media (max-width: 760px) {
  .modale.modale-plein { width: 100%; max-width: 100%; height: 92vh; max-height: 92vh; }
}
.fiche .espace-corps { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 12px; align-items: start; }
@media (max-width: 900px) {
  .fiche .espace-corps { grid-template-columns: 1fr; }
}
.fiche .espace-volet { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--rayon); padding: 12px; }

/* ---- tâches ------------------------------------------------------------- */

.fiche .tache { border: 1px solid var(--line); border-radius: var(--rayon); margin-bottom: 10px; background: var(--surface); }
.fiche .tache-tete {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.fiche .tache-tete > b { flex: 1 1 180px; min-width: 0; overflow-wrap: anywhere; }
.fiche .tache-corps { padding: 10px 12px; }
.fiche .actions-liste { list-style: none; margin: 0; padding: 0; }
.fiche .actions-liste > li {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 0; border-bottom: 1px dotted var(--line);
}
.fiche .actions-liste > li:last-child { border-bottom: 0; }
.fiche .actions-liste label {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px;
  min-height: 44px; cursor: pointer; font-size: .9rem;
}
.fiche .actions-liste label > span { overflow-wrap: anywhere; }
.fiche .actions-liste .faite > span { text-decoration: line-through; color: var(--muted); }
.fiche .actions-liste input[type="checkbox"] { width: 24px; height: 24px; flex: 0 0 auto; }
.fiche .action-poids { font-size: .76rem; color: var(--muted); white-space: nowrap; font-family: var(--mono); }

/* ---- barre d'actions ---------------------------------------------------- */

.fiche .row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.fiche .compteur { font-size: .85rem; color: var(--muted); }

/* Sur téléphone, un tableau large défile DANS son bloc : la page, elle, ne
   glisse jamais de côté. */
@media (max-width: 760px) {
  .fiche table { min-width: 100%; }
  .fiche .kv { flex-direction: column; gap: 0; }
  .fiche .kv > b { flex-basis: auto; max-width: none; }
}

/* Mention de défilement d'un tableau : elle n'a de sens que là où le
   débordement existe, c'est-à-dire sur écran étroit. */
.fiche .defile-note { display: none; }
@media (max-width: 760px) {
  .fiche .defile-note { display: block; margin-top: 4px; }
}
