/* ERP de Groupe FYR : feuille de style de l'application du bureau.
   Aucun style en ligne dans la page : la CSP n'autorise que ce fichier (style-src 'self').
   Reprend les couleurs et les composants de PunchMaster (apps/punchmaster/public/style.css). */
:root {
  --fond: #f4f5f7;
  --surface: #ffffff;
  --texte: #16202c;
  --texte-doux: #5b6675;
  --bordure: #d9dee5;
  --marque: #fab800;
  --marque-texte: #16181d;
  --barre: #16181d;
  --barre-texte: #ffffff;
  --accent: #16181d;
  --vert: #18864b;
  --rouge: #c0392b;
  --orange: #a85a00;
  --bleu: #1d5fa8;
  --jaune-fond: #fff6db;
  --rayon: 12px;
  --ombre: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --largeur-menu: 236px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0f141a;
    --surface: #18202a;
    --texte: #e8edf3;
    --texte-doux: #9aa6b4;
    --bordure: #2a3542;
    --barre: #000000;
    --accent: #e8edf3;
    --vert: #2fae6a;
    --rouge: #e5604f;
    --orange: #f0a040;
    --bleu: #6aa8f0;
    --jaune-fond: #3a3018;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100vh; min-height: 100dvh; }
a { color: var(--bleu); }

.cache { display: none !important; }

/* ---------------------------------------------------------------------------
   Barre du haut, coquille et menu latéral
   --------------------------------------------------------------------------- */
header.barre {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--barre); color: var(--barre-texte);
  border-bottom: 4px solid var(--marque);
}
header.barre h1 { margin: 0; font-size: 18px; font-weight: 800; min-width: 0; flex: 1 1 auto; }
header.barre h1 span { color: var(--marque); }
header.barre h1 small { display: block; font-size: 12px; font-weight: 600; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
header.barre .qui { font-size: 14px; opacity: .9; max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
header.barre button, header.barre select {
  background: transparent; color: inherit; border: 1px solid currentColor; border-radius: 8px;
  padding: 6px 10px; font-size: 14px; width: auto;
}
header.barre select option { color: var(--texte); background: var(--surface); }
header.barre select { max-width: 42vw; text-overflow: ellipsis; }
.barre-droite { display: flex; gap: 8px; align-items: center; flex: 0 1 auto; min-width: 0; }
.bouton-menu { font-size: 20px !important; line-height: 1; }

.coquille { display: flex; align-items: stretch; min-height: calc(100vh - 60px); }
nav.menu {
  flex: 0 0 var(--largeur-menu); padding: 12px 8px; background: var(--surface);
  border-right: 1px solid var(--bordure); overflow-y: auto;
}
.menu-volet { margin-bottom: 10px; }
.menu-volet h2 {
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
  margin: 8px 8px 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--texte-doux);
}
.menu-volet.indisponible h2 { opacity: .55; }
.menu-volet ul { list-style: none; margin: 0; padding: 0; }
.menu-volet a {
  display: block; padding: 8px 10px; border-radius: 8px; color: var(--texte); text-decoration: none; font-weight: 500;
}
.menu-volet a:hover { background: var(--fond); }
.menu-volet a.actif { background: color-mix(in srgb, var(--marque) 22%, transparent); font-weight: 700; }
.menu-volet .note { padding: 4px 10px; font-size: 13px; color: var(--texte-doux); }

main { flex: 1 1 auto; min-width: 0; margin: 0 auto; padding: 16px; max-width: 1280px; }

@media (max-width: 860px) {
  nav.menu {
    position: fixed; z-index: 4; top: 60px; bottom: 0; left: 0; width: min(80vw, 300px);
    box-shadow: 4px 0 18px rgba(0, 0, 0, .2); transform: translateX(-105%); visibility: hidden;
    transition: transform .15s ease, visibility 0s linear .15s;
  }
  nav.menu.ouvert { transform: none; visibility: visible; transition: transform .15s ease; }
  .masquer-mobile { display: none; }
}
@media (min-width: 861px) { .bouton-menu { display: none !important; } }

/* ---------------------------------------------------------------------------
   Cartes, formulaires, boutons
   --------------------------------------------------------------------------- */
.carte {
  background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--rayon);
  box-shadow: var(--ombre); padding: 16px; margin-bottom: 16px;
}
.carte.etroite { max-width: 440px; margin: 24px auto; }

h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 16px 0 8px; }
label { display: block; font-weight: 600; font-size: 13px; margin: 10px 0 4px; color: var(--texte-doux); }
label.case { display: flex; gap: 8px; align-items: center; color: var(--texte); }
label.case input { width: auto; }

input, select, textarea {
  width: 100%; font: inherit; font-size: 15px; padding: 9px 10px;
  border: 1px solid var(--bordure); border-radius: 8px; background: var(--surface); color: var(--texte);
}
input[type="checkbox"], input[type="radio"] { width: auto; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--marque) 60%, transparent); outline-offset: 1px;
}
button { font: inherit; cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }

.bouton {
  display: inline-block; padding: 9px 14px; border: 0; border-radius: 9px;
  font-size: 15px; font-weight: 700; background: var(--marque); color: var(--marque-texte);
  text-decoration: none; text-align: center;
}
.bouton.large { display: block; width: 100%; }
.bouton.secondaire { background: transparent; color: var(--accent); border: 2px solid var(--accent); }
.bouton.petit { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.bouton.danger { background: var(--rouge); color: #fff; }
.lien { background: none; border: 0; padding: 6px 0; color: var(--texte-doux); text-decoration: underline; font-size: 14px; }

.message { padding: 10px 12px; border-radius: 9px; margin: 0 0 12px; font-weight: 600; }
.message ul { margin: 0; padding-left: 18px; }
.message.erreur { background: color-mix(in srgb, var(--rouge) 14%, transparent); color: var(--rouge); }
.message.info { background: color-mix(in srgb, var(--vert) 14%, transparent); color: var(--vert); }
.message.avertissement { background: var(--jaune-fond); color: var(--orange); }

.ligne { display: flex; gap: 8px; align-items: center; }
.ligne > * { flex: 1; }
.ligne > .fixe { flex: 0 0 auto; }
.ligne.envelopper { flex-wrap: wrap; }
.pousse { flex: 1 1 auto; }
.espace-haut { margin-top: 12px; }
.doux { color: var(--texte-doux); font-size: 14px; }
.sans-marge { margin: 0; }
.entete-vue { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-bottom: 12px; }
.entete-vue h2 { margin: 0; flex: 1 1 auto; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }

.etiquette {
  display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px;
  background: var(--fond); border: 1px solid var(--bordure); color: var(--texte-doux); white-space: nowrap;
}
.etiquette.alerte { background: var(--jaune-fond); color: var(--orange); border-color: var(--orange); }
.etiquette.ok { color: var(--vert); border-color: var(--vert); }
.etiquette.erreur { color: var(--rouge); border-color: var(--rouge); }
.etiquette.info { color: var(--bleu); border-color: var(--bleu); }

/* Onglets (files de travail, vues des BC) */
nav.onglets { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--bordure); margin-bottom: 12px; }
nav.onglets a {
  padding: 8px 12px; font-weight: 600; color: var(--texte-doux); text-decoration: none; white-space: nowrap;
  border-bottom: 3px solid transparent;
}
nav.onglets a.actif { color: var(--texte); border-bottom-color: var(--marque); }
nav.onglets .compte { margin-left: 4px; font-size: 12px; opacity: .8; }

/* Filtres d'une liste */
.filtres { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0 12px; align-items: end; margin-bottom: 8px; }
.filtres .case { margin-top: 30px; }

/* Tableaux */
.tableau { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--bordure); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--texte-doux); white-space: nowrap; }
td.nombre, th.nombre { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.actions-ligne, td.date { white-space: nowrap; }
tr.total td { font-weight: 700; background: var(--fond); }
tr.alerte td { background: var(--jaune-fond); }
tr.inactif td { color: var(--texte-doux); }
.vide { padding: 8px 0; }

/* Fiche (facture, BC, relevé) */
.grille-fiche { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 0 16px; }
dl.fiche { display: grid; grid-template-columns: minmax(130px, 40%) 1fr; gap: 4px 12px; margin: 0; font-size: 14px; }
dl.fiche dt { color: var(--texte-doux); }
dl.fiche dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.avertissement-bc {
  border-left: 4px solid var(--orange); background: var(--jaune-fond); color: var(--orange);
  padding: 8px 12px; border-radius: 6px; margin: 8px 0; font-weight: 600;
}
.historique { list-style: none; margin: 0; padding: 0; border-left: 3px solid var(--bordure); }
.historique li { position: relative; padding: 4px 0 8px 14px; font-size: 14px; }
.historique li::before {
  content: ""; position: absolute; left: -7px; top: 9px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--marque);
}
.historique .quand { color: var(--texte-doux); font-variant-numeric: tabular-nums; margin-right: 6px; }
.commentaire { border-bottom: 1px dashed var(--bordure); padding: 8px 0; }
.commentaire p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Tableau de bord */
.tuiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tuile {
  display: block; padding: 14px; border-radius: var(--rayon); background: var(--surface); border: 1px solid var(--bordure);
  box-shadow: var(--ombre); color: var(--texte); text-decoration: none;
}
.tuile .valeur { display: block; font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tuile .titre { display: block; color: var(--texte-doux); font-weight: 600; font-size: 13px; }
.tuile.alerte { border-color: var(--orange); background: var(--jaune-fond); }

/* Fenêtres */
dialog {
  border: 1px solid var(--bordure); border-radius: var(--rayon); background: var(--surface); color: var(--texte);
  max-width: 640px; width: calc(100% - 32px); padding: 20px; max-height: 92vh; overflow-y: auto;
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog .deux-colonnes { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
dialog ul { padding-left: 20px; }
@media (max-width: 560px) { dialog .deux-colonnes { grid-template-columns: 1fr; } }

.qr { display: block; margin: 12px auto; background: #fff; padding: 8px; border-radius: 8px; }
code.secret { font-size: 15px; font-weight: 700; letter-spacing: 1px; word-break: break-all; }
ol.etapes { padding-left: 20px; }
.message-modele { white-space: pre-wrap; background: var(--fond); border: 1px solid var(--bordure); border-radius: 8px; padding: 10px; font-size: 14px; }

@media (max-width: 640px) {
  main { padding: 10px; }
  th, td { padding: 6px 4px; }
  dl.fiche { grid-template-columns: 1fr; gap: 0; }
  dl.fiche dd { margin-bottom: 6px; }
}

/* ---------------------------------------------------------------------------
   Projets : liste, fiche, saisie
   --------------------------------------------------------------------------- */
th a.tri { color: inherit; text-decoration: none; }
th a.tri.asc, th a.tri.desc { color: var(--texte); }
.tuiles.compactes { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); margin: 10px 0 0; }
.tuiles.compactes .tuile { padding: 10px; box-shadow: none; }
.tuiles.compactes .valeur { font-size: 22px; }
.requis-ouverture { font-weight: 500; color: var(--orange); }
.carte.manquants { border-left: 4px solid var(--orange); background: var(--jaune-fond); }
.carte.manquants.discret { background: var(--surface); }
.carte.manquants ul { margin: 6px 0; }
.champ { min-width: 0; }
.carte .deux-colonnes { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.actions select { width: auto; max-width: 100%; }
.lien-bouton { background: none; border: 0; padding: 0 4px; color: var(--bleu); font-size: 15px; cursor: pointer; }

/* ---------------------------------------------------------------------------
   Facturation des clients : lignes par catégorie, éléments facturables, facture à imprimer
   (facturation/*.js). La facture garde un fond blanc à l'écran (aperçu du papier) et s'imprime
   seule, en portrait (page nommée « facture » ; le plan de charge garde son paysage).
   --------------------------------------------------------------------------- */
tr.groupe td, tr.groupe th { background: var(--fond); font-weight: 700; }
tr.detail td:first-child { padding-left: 22px; }
tr.sous-total td { font-weight: 600; }
.etiquette.long { white-space: normal; }
.impression-barre { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-bottom: 12px; }
.impression-barre p { margin: 0; }
.facture-imprimable {
  position: relative; max-width: 8.5in; margin: 0 auto 16px; padding: 0.55in 0.6in;
  background: #fff; color: #16202c; border: 1px solid var(--bordure); border-radius: 4px; box-shadow: var(--ombre);
  font-size: 13px; line-height: 1.4; color-scheme: light;
}
.facture-imprimable h2 { margin: 0 0 8px; font-size: 22px; text-transform: uppercase; letter-spacing: 1px; text-align: right; }
.facture-imprimable h3 { margin: 0 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: #5b6675; }
.fi-entete { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 12px; border-bottom: 3px solid var(--marque); }
.fi-nom { display: block; font-size: 17px; }
.fi-numeros { margin-top: 6px; font-size: 12px; color: #3b4552; }
.fi-numeros span { display: inline-block; margin-right: 14px; white-space: nowrap; }
.fi-repere { display: grid; grid-template-columns: auto auto; gap: 2px 12px; margin: 0; justify-content: end; }
.fi-repere dt { color: #5b6675; text-align: right; }
.fi-repere dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fi-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0; }
.facture-imprimable table { font-size: 12px; color: inherit; }
.facture-imprimable th, .facture-imprimable td { border-bottom-color: #d9dee5; padding: 5px 6px; }
.fi-lignes thead th { color: #5b6675; }
.fi-lignes tr.fi-groupe th { text-transform: none; letter-spacing: 0; font-size: 12px; color: #16202c; background: #f4f5f7; }
.fi-lignes tr.fi-sous-total td { font-weight: 600; border-bottom: 2px solid #d9dee5; }
table.fi-totaux { width: auto; min-width: 55%; margin: 12px 0 0 auto; }
.fi-totaux th { text-align: left; text-transform: none; letter-spacing: 0; font-size: 12px; color: #16202c; white-space: normal; font-weight: 500; }
.fi-totaux tr.fi-total th, .fi-totaux tr.fi-total td { font-weight: 700; }
.fi-totaux tr.fi-retenue th, .fi-totaux tr.fi-retenue td { color: #a85a00; }
.fi-totaux tr.fi-exigible th, .fi-totaux tr.fi-exigible td { font-weight: 800; font-size: 14px; border-top: 2px solid #16202c; }
.fi-pied { margin-top: 18px; font-size: 12px; color: #3b4552; }
.fi-pied p { margin: 4px 0; }
.fi-filigrane {
  margin: 0 0 10px; padding: 6px 10px; border: 2px solid #c0392b; border-radius: 6px; color: #c0392b;
  font-weight: 800; letter-spacing: 1px; text-align: center;
}
@media (max-width: 640px) {
  .facture-imprimable { padding: 14px; }
  .fi-entete, .fi-parties { display: block; }
  .facture-imprimable h2, .fi-repere { text-align: left; justify-content: start; }
  .fi-repere dt { text-align: left; }
  .facture-imprimable .fi-lignes { display: block; overflow-x: auto; }
}
@page facture { size: letter portrait; margin: 12mm; }
@media print {
  .facture-imprimable { page: facture; max-width: none; margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; font-size: 11pt; }
  .impression-barre { display: none !important; }
  .fi-lignes tr, .fi-totaux { break-inside: avoid; }
  .fi-entete, .fi-filigrane, .fi-lignes tr.fi-groupe th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------------------------------------------------------------------------
   Plan de charge : grille projets × semaines, couleurs d'écart (lib/projets.js : classeEcart)
   --------------------------------------------------------------------------- */
:root {
  --ecart-equilibre: #d8f0e1; --ecart-manque: #ffe3b8; --ecart-manque-fort: #f8c9c3; --ecart-surplus: #d5e6f9;
  --ecart-non-prevu: #e9ddf7;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ecart-equilibre: #1d4a31; --ecart-manque: #5a3d10; --ecart-manque-fort: #5e2620; --ecart-surplus: #1c3a5e;
    --ecart-non-prevu: #3b2c55;
  }
}
.legende-plan { display: flex; flex-wrap: wrap; gap: 4px 16px; list-style: none; padding: 0; margin: 0 0 10px; font-size: 13px; }
.pastille { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--bordure); vertical-align: -2px; }
table.plan { font-size: 13px; }
table.plan th.col-projet { position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 220px; max-width: 320px;
  text-transform: none; letter-spacing: 0; font-size: 13px; white-space: normal; color: var(--texte); }
table.plan tbody th.col-projet { font-weight: 400; }
table.plan tbody th.col-projet > a { font-weight: 700; }
table.plan thead th.semaine { text-align: center; min-width: 76px; }
table.plan thead th.semaine span { display: block; }
table.plan thead th.semaine .du { font-weight: 500; text-transform: none; }
table.plan th.courante, table.plan td.courante { box-shadow: inset 0 0 0 2px var(--marque); }
table.plan td.case { text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; vertical-align: middle; padding: 0; }
table.plan td.case > :not(button), table.plan tfoot td.case { padding: 7px 4px; }
table.plan .case-bouton { width: 100%; min-height: 34px; padding: 7px 4px; background: transparent; border: 0; color: inherit;
  font: inherit; cursor: pointer; }
table.plan .case-bouton:hover { outline: 2px dashed var(--bordure); outline-offset: -3px; }
table.plan .affecte { font-weight: 700; }
table.plan ul.phases { list-style: none; margin: 4px 0 0; padding: 0; font-weight: 400; }
table.plan ul.phases li { font-size: 12px; }
.ecart-equilibre { background: var(--ecart-equilibre); }
.ecart-manque { background: var(--ecart-manque); }
.ecart-manque-fort { background: var(--ecart-manque-fort); }
.ecart-surplus { background: var(--ecart-surplus); }
.ecart-non-prevu { background: var(--ecart-non-prevu); }
table.plan tfoot th, table.plan tfoot td { font-weight: 700; background: var(--fond); }
table.plan tfoot td.charge-pleine { color: var(--orange); }
table.plan tfoot td.charge-surcharge { color: var(--rouge); background: color-mix(in srgb, var(--rouge) 14%, var(--fond)); }

@media print {
  @page { size: landscape; margin: 10mm; }
  html, body { background: #fff; color: #000; }
  header.barre, nav.menu, #message, dialog, .actions, nav.onglets, .filtres, .imprimer-non, .lien-bouton { display: none !important; }
  main { padding: 0; max-width: none; }
  .carte { box-shadow: none; border: 0; padding: 0; }
  .tableau { overflow: visible; }
  table.plan { font-size: 10px; }
  table.plan th.col-projet { position: static; min-width: 0; }
  table.plan thead th.semaine { min-width: 0; }
  table.plan, .legende-plan, .pastille { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  table.plan tr { break-inside: avoid; }
}
