/* Suivi du potentiel commercial HM · LGM — téléphone d'abord. */

:root {
  --encre: #15202b;
  --encre-douce: #5b6b7c;
  --fond: #eef1f4;
  --carte: #ffffff;
  --trait: #d4dae1;
  --trait-saisie: #7d8a98;
  --marine: #123a5a;
  --accent: #0f6fb3;
  --vert: #0f7a4d;
  --vert-fond: #e4f4ec;
  --rouge: #b02121;
  --rouge-fond: #fbeaea;
  --ambre: #8a5a00;
  --ambre-fond: #fdf2db;
  --rayon: 8px;
  --ombre: 0 1px 2px rgba(21, 32, 43, .08), 0 1px 6px rgba(21, 32, 43, .05);
}

* { box-sizing: border-box; }
/* .champ pose display:flex, ce qui écrase la règle du navigateur sur
   [hidden] : sans ce !important, un bloc masqué par app.js reste affiché. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--encre);
  background: var(--fond);
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }
h1 { font-size: 1.3rem; margin: 0 0 .2rem; }
h2 { font-size: 1.05rem; margin: 1.4rem 0 .5rem; }
/* Un titre de section posé à même la page (et non dans une carte) doit se
   retrouver en faisant défiler : les écrans de réunion sont longs. */
main > h2 { font-size: 1.12rem; border-bottom: 1px solid var(--trait); padding-bottom: .2rem; }
h3 { font-size: .95rem; margin: 1rem 0 .4rem; }
p { margin: .4rem 0; }

/* ---------------------------------------------------------- en-tête */
.entete { background: var(--marine); color: #fff; box-shadow: var(--ombre); }
.bandeau {
  display: flex; align-items: center; justify-content: space-between;
  gap: .6rem; padding: .55rem .8rem; max-width: 1400px; margin: 0 auto;
}
.marque { color: #fff; text-decoration: none; font-weight: 600; font-size: .98rem; }
.marque span { font-weight: 400; opacity: .72; }
.deconnexion { display: flex; align-items: center; gap: .5rem; margin: 0; }
.qui { display: flex; flex-direction: column; text-align: right; line-height: 1.1; font-size: .8rem; }
.qui em { font-style: normal; opacity: .65; font-size: .7rem; text-transform: uppercase; letter-spacing: .03em; }
.deconnexion button {
  background: rgba(255, 255, 255, .14); color: #fff; border: 1px solid rgba(255, 255, 255, .3);
  border-radius: var(--rayon); padding: .3rem .6rem; font-size: .8rem; cursor: pointer;
}
.deconnexion button:hover { background: rgba(255, 255, 255, .24); }

.onglets {
  display: flex; gap: .15rem; overflow-x: auto; padding: 0 .5rem;
  max-width: 1400px; margin: 0 auto; scrollbar-width: thin;
}
.onglets a {
  color: rgba(255, 255, 255, .82); text-decoration: none; white-space: nowrap;
  padding: .5rem .7rem; font-size: .88rem; border-bottom: 3px solid transparent;
}
.onglets a:hover { color: #fff; }
.onglets a.actif { color: #fff; font-weight: 600; border-bottom-color: #7fc2ef; }

/* ---------------------------------------------------------- page */
.page { max-width: 1400px; margin: 0 auto; padding: .9rem .8rem 2.5rem; }
.pied {
  max-width: 1400px; margin: 0 auto; padding: 0 .8rem 1.6rem;
  color: var(--encre-douce); font-size: .78rem;
}
/* D'où l'on vient, quand on a cliqué sur un total pour en voir le détail. */
.fil { margin: 0 0 .7rem; font-size: .9rem; }
.fil a { text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; }
.fil a:hover { text-decoration: underline; }

/* Un total cliquable : il mène au détail qui le compose. */
td.nombre a, .chiffre a { text-decoration: none; color: inherit; }
td.nombre a:hover, .chiffre a:hover { text-decoration: underline; color: var(--accent); }
a.chiffre { display: block; text-decoration: none; color: inherit; }
a.chiffre:hover { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
a.chiffre .valeur { color: var(--encre); }

.titre-page { display: flex; flex-wrap: wrap; align-items: baseline; gap: .6rem; margin-bottom: .6rem; }
.titre-page .sous { color: var(--encre-douce); font-size: .85rem; }

.carte {
  background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon);
  box-shadow: var(--ombre); padding: .8rem; margin-bottom: .9rem;
}
.carte > h2:first-child, .carte > h3:first-child { margin-top: 0; }

/* ---------------------------------------------------------- messages */
.message {
  border-radius: var(--rayon); padding: .6rem .75rem; margin: 0 0 .8rem;
  border: 1px solid transparent; font-size: .92rem;
}
.message.succes { background: var(--vert-fond); border-color: #b7e0cb; color: var(--vert); }
.message.refus {
  background: var(--rouge-fond); border-color: #f0c4c4; color: var(--rouge);
  position: sticky; top: 0; z-index: 3;
}
.carte.en-erreur { border-color: var(--rouge); border-width: 2px; }
.carte.en-erreur > h2 { color: var(--rouge); }
.champ.en-erreur > label { color: var(--rouge); }
.champ.en-erreur input, .champ.en-erreur select, .champ.en-erreur textarea {
  border-color: var(--rouge); border-width: 2px; background: var(--rouge-fond);
}
.message.avis { background: var(--ambre-fond); border-color: #ebd49c; color: var(--ambre); }
.message.info { background: #e8f1f8; border-color: #c2dcef; color: #14537e; }
.message strong { display: block; }

/* ---------------------------------------------------------- tableaux */
.cadre-table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; background: var(--carte); }
caption { text-align: left; color: var(--encre-douce); font-size: .82rem; padding: .3rem 0; }
th, td { padding: .45rem .5rem; text-align: left; border-bottom: 1px solid var(--trait); vertical-align: top; }
thead th {
  background: #e6ebf0; font-size: .74rem; text-transform: uppercase;
  letter-spacing: .03em; color: var(--encre-douce); white-space: nowrap;
}
tbody tr:hover { background: #f7f9fb; }
.nombre { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td, tr.total td { font-weight: 600; background: #eef2f6; border-top: 2px solid var(--trait); }
tr.sous-total td { font-weight: 600; background: #f3f6f9; }
td.vide, .vide { color: var(--encre-douce); }

/* Fiche d'une affaire : intitulé à gauche, valeur à droite, à toute largeur.
   Ce tableau n'a pas d'en-tête : sans cette règle, les valeurs sont nues. */
table.fiche-champs td {
  display: flex; gap: .8rem; justify-content: space-between; align-items: baseline;
}
/* Au-delà, l'intitulé et sa valeur se retrouvent à près d'un mètre d'écran
   l'un de l'autre sur un grand moniteur. */
table.fiche-champs { max-width: 34rem; }
table.fiche-champs td::before {
  content: attr(data-libelle); flex: 0 0 16rem;
  color: var(--encre-douce); font-size: .78rem;
  text-transform: uppercase; letter-spacing: .02em;
}
/* Téléphone : chaque ligne devient une fiche, l'intitulé passe devant la valeur. */
@media (max-width: 760px) {
  table.adaptable, table.adaptable tbody, table.adaptable tr, table.adaptable td { display: block; width: 100%; }
  table.adaptable thead { display: none; }
  table.adaptable tr {
    border: 1px solid var(--trait); border-radius: var(--rayon);
    margin-bottom: .55rem; padding: .25rem .1rem; background: var(--carte);
  }
  /* Intitulé calé à gauche, valeur à droite, et retour à la ligne propre
     quand la cellule porte un badge ou un <br>. */
  table.adaptable td {
    border: 0; padding: .2rem .55rem; display: flex; flex-wrap: wrap;
    justify-content: flex-end; column-gap: .6rem; row-gap: .15rem; text-align: right;
  }
  table.adaptable td::before {
    content: attr(data-libelle); color: var(--encre-douce); font-size: .78rem;
    text-transform: uppercase; letter-spacing: .02em;
    flex: 0 0 auto; margin-right: auto; text-align: left;
  }
  table.adaptable td br { flex: 1 0 100%; height: 0; }
  /* La référence est la cible du doigt : 44 px de haut, toute la largeur. */
  table.adaptable td.titre-ligne {
    font-weight: 600; border-bottom: 1px solid var(--trait);
    padding: 0; margin-bottom: .2rem; justify-content: flex-start; text-align: left;
  }
  table.adaptable td.titre-ligne::before { content: ""; display: none; }
  table.adaptable td.titre-ligne a {
    flex: 1 1 auto; display: flex; align-items: center; min-height: 44px;
    padding: .55rem; font-size: 1rem; font-weight: 600; text-decoration: none;
  }
  table.adaptable td a { display: inline-flex; align-items: center; min-height: 44px; padding: .4rem .25rem; }
  /* Colonnes de second rang : la fiche de l'affaire les porte toutes. */
  table.adaptable td.secondaire { display: none; }
  table.adaptable .nombre { text-align: right; }
  table.adaptable tfoot td, table.adaptable tr.total td, table.adaptable tr.sous-total td { background: #eef2f6; }
  /* Pas de défilement imbriqué dans une page qui défile déjà. */
  .resultats { max-height: none; overflow-y: visible; }
  .sur-tel { display: inline; }   /* visible sur téléphone seulement */
  /* Une case de remplissage deviendrait une bande vide dans la carte. */
  table.adaptable td:empty { display: none; }
  /* Sinon le « aucune ligne » part à droite, comme une valeur. */
  table.adaptable td[colspan] { justify-content: center; text-align: center; }
}

/* ---------------------------------------------------------- étiquettes */
.badge {
  display: inline-block; padding: .1rem .45rem; border-radius: 999px;
  font-size: .72rem; font-weight: 600; white-space: nowrap; border: 1px solid;
}
.badge.potentiel { background: #e8f1f8; border-color: #c2dcef; color: #14537e; }
.badge.livre { background: var(--ambre-fond); border-color: #ebd49c; color: var(--ambre); }
.badge.realise { background: var(--vert-fond); border-color: #b7e0cb; color: var(--vert); }
.badge.perdu { background: #eceff2; border-color: var(--trait); color: var(--encre-douce); }
.badge.alerte { background: var(--rouge-fond); border-color: #f0c4c4; color: var(--rouge); }
.badge.societe { background: #f1eef8; border-color: #d8cdeb; color: #4b357e; }
.puce-alerte { color: var(--rouge); font-weight: 700; }

/* ---------------------------------------------------------- formulaires */
.grille { display: grid; gap: .7rem; }
@media (min-width: 760px) { .grille.deux { grid-template-columns: 1fr 1fr; } }
.champ { display: flex; flex-direction: column; gap: .22rem; }
.champ > label { font-size: .82rem; font-weight: 600; color: var(--encre-douce); }
.champ .aide { font-size: .76rem; color: var(--encre-douce); }
.champ.large { grid-column: 1 / -1; }
/* Hauteur imposée : sans elle, un champ date fait 43px quand un menu
   déroulant en fait 41, et leurs bas ne coïncident pas sur une même ligne.
   2,75rem = 44px, la cible tactile annoncée. textarea garde la sienne. */
input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="search"], select { height: 2.75rem; }
input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="search"], select, textarea {
  font: inherit; font-size: 16px; padding: .5rem .55rem;
  /* 3,5:1 sur blanc : le contour reste visible en plein soleil, sur un chantier. */
  border: 1px solid var(--trait-saisie);
  border-radius: var(--rayon); background: #fff; color: var(--encre); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
textarea { min-height: 4.5rem; resize: vertical; }
.obligatoire { color: var(--rouge); }
/* Ce qu'un prix tapé en milliers représente en MAD. */
.echo { color: var(--accent); white-space: nowrap; }

/* Premier bouton de soumission du formulaire, hors écran : la touche Entrée
   enregistre, au lieu de déclencher la recherche de client. */
.defaut-invisible {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); border: 0;
}

.boutons { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .9rem; }
button, .bouton {
  min-height: 2.75rem;
  font: inherit; font-size: .92rem; padding: .55rem .9rem; border-radius: var(--rayon);
  border: 1px solid var(--trait-saisie); background: #fff; color: var(--encre);
  cursor: pointer; text-decoration: none; display: inline-block; text-align: center;
}
button:hover, .bouton:hover { background: #f2f5f8; }
button.principal, .bouton.principal { background: var(--marine); border-color: var(--marine); color: #fff; font-weight: 600; }
button.principal:hover, .bouton.principal:hover { background: #0d2c45; }
button.discret { background: transparent; border-color: transparent; color: var(--accent); padding: .35rem .4rem; }
button.discret:hover { background: #e8f1f8; }

#bloc-motif-report {
  background: var(--ambre-fond); border: 1px solid #ebd49c;
  border-radius: var(--rayon); padding: .6rem .7rem;
}

/* ---------------------------------------------------------- filtres */
.filtres { display: grid; gap: .5rem; margin-bottom: .9rem; }
/* Les cases d'un filtre n'ont pas toutes une ligne d'aide : les aligner par
   le bas (align-items: end) mettait leurs champs à trois hauteurs différentes
   sur une même ligne. On les aligne par le haut, l'aide descend d'elle-même,
   et le bouton se pose à la hauteur des champs. */
@media (min-width: 760px) {
  .filtres { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .filtres .champ .aide { margin-top: auto; }
  /* Deux boutons ne tiennent pas dans une colonne de 150 px : la case en
     prend deux, sans quoi « Afficher » et « Réinitialiser » s'empilent. */
  .filtres .actions { align-self: start; margin-top: calc(.76rem * 1.45 + .22rem);
                      grid-column: span 2; }
}
/* Sur téléphone les onglets passent à la ligne : rien ne reste hors écran,
   et ils font 44px de haut comme les autres cibles tactiles. */
@media (max-width: 760px) {
  .onglets { flex-wrap: wrap; overflow-x: visible; padding: 0 .5rem .25rem; }
  /* 44px exactement sous le doigt, sans dépendre de l'interligne. */
  .onglets a { min-height: 44px; display: inline-flex; align-items: center;
               padding: 0 .6rem; }
}
.filtres .champ > label { font-size: .76rem; }
.filtres .actions { display: flex; flex-wrap: wrap; gap: .4rem; }

/* Quelle photo chaque date utilise réellement */
.reperes {
  display: flex; flex-wrap: wrap; gap: .25rem 1.2rem;
  margin: -.4rem 0 .9rem; font-size: .82rem; color: var(--encre-douce);
}
.reperes b { font-weight: 600; color: var(--encre); margin-right: .25rem; }

/* ---------------------------------------------------------- recherche client */
.recherche-client { border: 1px solid var(--trait); border-radius: var(--rayon); padding: .55rem; background: #fafbfc; }
.ligne-recherche { display: flex; gap: .4rem; }
.ligne-recherche input { flex: 1; }
.resultats { list-style: none; margin: .5rem 0 0; padding: 0; max-height: 15rem; overflow-y: auto; }
.resultats li { border-top: 1px solid var(--trait); }
.resultats button { width: 100%; text-align: left; border: 0; background: transparent; padding: .6rem .5rem; border-radius: 0; min-height: 44px; }
.resultats button:hover { background: #e8f1f8; }
.origine { color: var(--encre-douce); font-size: .76rem; margin-left: .4rem; }
.client-choisi { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
.client-choisi strong { font-size: 1rem; }

/* ---------------------------------------------------------- chiffres clés */
.chiffres { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: .9rem; }
.chiffre { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); padding: .6rem .7rem; box-shadow: var(--ombre); }
.chiffre .intitule { font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; color: var(--encre-douce); }
.chiffre .valeur { font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.chiffre .detail { font-size: .76rem; color: var(--encre-douce); }

/* ---------------------------------------------------------- journal */
.entree-journal { border-left: 3px solid var(--trait); padding: .2rem 0 .5rem .7rem; margin-bottom: .6rem; }
.entree-journal .quand { font-size: .8rem; color: var(--encre-douce); }
.entree-journal .qui { display: inline; font-weight: 600; font-size: .9rem; }
.modifs { list-style: none; margin: .3rem 0 0; padding: 0; font-size: .86rem; }
.modifs li { padding: .12rem 0; }
.modifs .avant { color: var(--encre-douce); text-decoration: line-through; }
.modifs .apres { font-weight: 600; }

/* ---------------------------------------------------------- graphique */
.graphe { width: 100%; height: auto; background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); }
.graphe .grille-h { stroke: #e3e8ed; stroke-width: 1; }
.graphe .graduation { fill: var(--encre-douce); font-size: 10px; }
.graphe .etiquette-x { fill: var(--encre-douce); font-size: 10px; }
.graphe polyline { fill: none; stroke-width: 2; }
/* Le pondéré en tireté : les six courbes restent distinctes sans la couleur. */
.graphe .serie-groupe-pondere, .graphe .serie-hm-pondere, .graphe .serie-lgm-pondere,
.legende .serie-groupe-pondere, .legende .serie-hm-pondere, .legende .serie-lgm-pondere {
  stroke-dasharray: 6 4;
}
.graphe circle { stroke: #fff; stroke-width: 1; }
.serie-groupe-brut { stroke: #123a5a; fill: #123a5a; }
.serie-groupe-pondere { stroke: #0f6fb3; fill: #0f6fb3; }
.serie-hm-brut { stroke: #0f7a4d; fill: #0f7a4d; }
.serie-hm-pondere { stroke: #58b08a; fill: #58b08a; }
.serie-lgm-brut { stroke: #8a5a00; fill: #8a5a00; }
.serie-lgm-pondere { stroke: #d09a3c; fill: #d09a3c; }
.legende { display: flex; flex-wrap: wrap; gap: .8rem; margin: .5rem 0 0; font-size: .82rem; }
.legende span { display: flex; align-items: center; gap: .3rem; }
.legende i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }

/* Sur téléphone le SVG est réduit d'environ 0,42 : 10 px de viewBox ne font
   que 4 px à l'écran. 24 px de viewBox en rendent 10. */
@media (max-width: 760px) {
  .graphe .graduation, .graphe .etiquette-x { font-size: 24px; }
}

/* ---------------------------------------------------------- connexion */
.ecran-connexion { max-width: 23rem; margin: 2.5rem auto; padding: 0 1rem; }
.ecran-connexion .carte { padding: 1.2rem; }
.ecran-connexion h1 { font-size: 1.15rem; }
.ecran-connexion .sous { color: var(--encre-douce); font-size: .85rem; margin-bottom: 1rem; }
.ecran-connexion button { width: 100%; }

.pied .version { opacity: .6; }
/* « Date dépassée » et « Sans date » sont dans un second <tbody> : un trait
   dit qu'on change de nature de ligne. */
tbody + tbody tr:first-child > td { border-top: 2px solid var(--trait); }

.vide-liste { text-align: center; color: var(--encre-douce); padding: 1.6rem .5rem; }

/* Hors téléphone, ce qui n'est destiné qu'au petit écran disparaît. Cette
   règle doit rester AVANT le bloc média, sinon elle l'annule. */
@media (min-width: 761px) { .sur-tel { display: none; } }

/* ------------------------------------------------------------------ */
/* Administration des listes (écran réservé au SI et à la Direction)   */
/* ------------------------------------------------------------------ */
/* Sous-navigation d'un écran : même mécanique que la barre principale,
   en plus discret, et elle passe à la ligne sur un téléphone. */
.onglets.sous-onglets { margin: .2rem 0 1rem; font-size: .9rem; }
.onglets.sous-onglets a { padding: .45rem .7rem; }

.liste-plate { list-style: none; margin: .4rem 0 0; padding: 0; }
.liste-plate li {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
  padding: .45rem 0; border-top: 1px solid var(--trait);
}
.liste-plate li:first-child { border-top: 0; }

/* Une valeur retirée des listes reste lisible : elle est encore portée par
   des affaires, on ne la grise pas au point de ne plus la lire. */
tr.ligne-inactive > td { color: var(--encre-douce); }
tr.ligne-inactive .titre-ligne { text-decoration: line-through; }

/* Les boutons d'une ligne de tableau : côte à côte, et sur deux lignes
   quand la colonne devient étroite. */
.actions-ligne { white-space: nowrap; }
.actions-ligne form { display: inline-block; margin: 0 .25rem .25rem 0; }
@media (max-width: 760px) { .actions-ligne { white-space: normal; } }

/* Case à cocher et son intitulé sur la même ligne, cible tactile comprise. */
label.case {
  display: flex; align-items: center; gap: .5rem;
  font-size: .95rem; font-weight: 400; min-height: 44px;
}
label.case input[type="checkbox"] { width: 20px; height: 20px; }

/* .bouton.discret existe déjà plus haut pour les <button> ; on ne fait que
   l'étendre aux liens et garantir la cible tactile. */
.bouton.discret { background: transparent; border-color: transparent; color: var(--accent); }
.actions-ligne button.discret { min-height: 2.25rem; }

/* L'intitulé d'une entrée de la liste « À valider ». */
.etiquette {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--encre-douce); min-width: 9rem;
}

/* Les sous-onglets sont posés sur le fond clair de la page, pas sur le
   bandeau marine : sans cette règle ils héritent du blanc et deviennent
   illisibles. */
.onglets.sous-onglets a { color: var(--accent); }
.onglets.sous-onglets a.actif { color: var(--encre); border-bottom-color: var(--accent); }

/* Un bloc de boutons qui occupe toute la largeur d'une grille, sans que les
   boutons eux-mêmes s'étirent. */
.boutons.pleine-largeur { grid-column: 1 / -1; }
/* L'intitulé d'un champ qui n'est pas un <label> : une case à cocher porte
   déjà le sien, deux <label> pour un même contrôle se marchent dessus. */
.intitule-champ { font-size: .82rem; font-weight: 600; color: var(--encre-douce); }
