/* ===========================================================================
   Pilotage STTL — feuille de style
   ---------------------------------------------------------------------------
   Reprise de la maquette présentée aux associés (maquette_dashboard_STTL.html)
   avec les mêmes couleurs, la même grille et les mêmes composants. Aucune
   bibliothèque : les barres et le donut sont en CSS et SVG natifs.
   =========================================================================== */

:root {
  --rouge:        #C8202E;
  --rouge-clair:  #E84855;
  --bleu:         #1E5FAA;
  --violet:       #7B4FA0;
  --vert:         #2C8C5C;
  --orange:       #C77800;
  --ardoise:      #2A3F5A;
  --encre:        #1A2330;
  --gris:         #6B7686;
  --gris-clair:   #A8AFB9;
  --bordure:      #E5E8EC;
  --bordure-2:    #D8DDE3;
  --fond:         #F5F6F8;
  --fond-2:       #F0F2F5;
  --fond-3:       #FAFBFC;
  --blanc:        #FFFFFF;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", system-ui, sans-serif;
  background: var(--fond);
  color: var(--encre);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
.num { font-variant-numeric: tabular-nums; }
a { color: inherit; }

/* --- Bandeau d'avertissement ------------------------------------------- */
.bandeau {
  background: #FFF4E5;
  border-bottom: 1px solid #F4D8A8;
  color: #8B5A00;
  padding: 8px 24px;
  font-size: 12px;
  text-align: center;
  letter-spacing: 0.3px;
}
.bandeau strong { font-weight: 600; }
.bandeau details { display: inline; }
.bandeau summary { cursor: pointer; display: inline; text-decoration: underline dotted; }
.bandeau ul { display: inline; list-style: none; }
.bandeau li { display: inline; }
.bandeau li + li::before { content: " · "; }

/* --- En-tête ------------------------------------------------------------ */
header {
  background: var(--blanc);
  border-bottom: 1px solid var(--bordure);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.marque { display: flex; align-items: center; gap: 14px; text-decoration: none; }
.navigation { display: flex; gap: 4px; }
.navigation a {
  text-decoration: none; font-size: 13px; font-weight: 500; color: var(--gris);
  padding: 6px 12px; border-radius: 6px;
}
.navigation a:hover  { background: var(--fond-2); color: var(--encre); }
.navigation a.active { background: var(--fond-2); color: var(--encre); font-weight: 600; }
.logo {
  width: 42px; height: 42px;
  background: var(--rouge);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
  border-radius: 6px;
  letter-spacing: -0.5px;
}
.marque h1 { font-size: 16px; font-weight: 600; }
.marque p  { font-size: 12px; color: var(--gris); margin-top: 2px; }

.controles { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.groupe { display: flex; flex-direction: column; gap: 4px; }
.groupe label {
  font-size: 11px; color: var(--gris);
  text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600;
}
select {
  background: white;
  border: 1px solid var(--bordure-2);
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--encre);
  cursor: pointer;
  font-family: inherit;
  min-width: 180px;
}
select:hover { border-color: var(--gris-clair); }
select:focus { outline: 2px solid #C8202E33; border-color: var(--rouge); }

.synchro {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 99px;
  color: var(--vert); background: #EAFBF1; border: 1px solid #BCEACF;
}
.synchro.alerte { color: var(--orange); background: #FFF4E5; border-color: #F4D8A8; }
.synchro.echec  { color: var(--rouge);  background: #FDECEE; border-color: #F5C2C7; }
.pastille { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.synchro:not(.alerte):not(.echec) .pastille { animation: pulsation 2s ease-in-out infinite; }
@keyframes pulsation {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.85); }
}

.utilisateur { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--gris); }
.utilisateur form { display: inline; }
.utilisateur button {
  background: none; border: 1px solid var(--bordure-2); border-radius: 6px;
  padding: 5px 10px; font-size: 12px; color: var(--encre); cursor: pointer; font-family: inherit;
}
.utilisateur button:hover { border-color: var(--gris-clair); }

/* --- Corps -------------------------------------------------------------- */
main { padding: 24px 32px 48px; max-width: 1480px; margin: 0 auto; }

.titre-periode { margin-bottom: 16px; color: var(--gris); font-size: 13px; }
.titre-periode strong { color: var(--encre); font-weight: 600; }

/* --- Cartes KPI --------------------------------------------------------- */
.kpi-ligne {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.kpi {
  display: block;
  background: white;
  border: 1px solid var(--bordure);
  border-radius: 10px;
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
}
a.kpi:hover { border-color: var(--bordure-2); box-shadow: 0 2px 8px rgba(26, 35, 48, 0.06); }
.kpi::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent, var(--rouge));
}
.kpi-libelle { font-size: 12px; color: var(--gris); font-weight: 500; margin-bottom: 8px; }
.kpi-valeur  { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; line-height: 1.1; }
.kpi-valeur .unite { font-size: 16px; font-weight: 500; color: var(--gris); margin-left: 2px; }
.kpi-detail  { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--gris); flex-wrap: wrap; }

.tendance-hausse { color: var(--vert);   font-weight: 600; }
.tendance-baisse { color: var(--rouge);  font-weight: 600; }
.tendance-neutre { color: var(--gris);   font-weight: 600; }

/* --- Grilles et cartes -------------------------------------------------- */
.grille        { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
.grille-basse  { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; margin-bottom: 16px; }
.grille-pleine { margin-bottom: 16px; }

.carte {
  background: white;
  border: 1px solid var(--bordure);
  border-radius: 10px;
  padding: 22px 24px;
}
.carte-entete { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; gap: 12px; }
.carte-titre  { font-size: 14px; font-weight: 600; }
.carte-sous   { font-size: 12px; color: var(--gris); margin-top: 2px; }
.carte-vide   { color: var(--gris); font-size: 13px; padding: 12px 0; }

/* --- Barres horizontales (CA par agence) -------------------------------- */
.barres { display: flex; flex-direction: column; gap: 10px; }
.barre {
  display: grid;
  grid-template-columns: 150px 1fr 120px;
  gap: 14px;
  align-items: center;
  font-size: 13px;
  text-decoration: none;
  color: inherit;
  border-radius: 4px;
}
.barre:hover .barre-remplissage { filter: brightness(1.08); }
.barre.active .barre-remplissage { background: var(--rouge); }
.barre-libelle { font-weight: 500; }
.barre-libelle small { color: var(--gris); font-weight: 400; font-size: 11px; margin-left: 4px; }
.barre-piste { height: 24px; background: var(--fond); border-radius: 4px; overflow: hidden; }
.barre-remplissage {
  height: 100%;
  background: var(--ardoise);
  border-radius: 4px;
  transition: width 0.5s ease, filter 0.2s ease;
  min-width: 2px;
}
.barre-valeur { font-weight: 600; text-align: right; }
.barre-valeur small { display: block; font-size: 11px; font-weight: 500; }

/* --- Donut -------------------------------------------------------------- */
.donut { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.donut svg { width: 180px; height: 180px; }
.legende { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.legende-item { display: grid; grid-template-columns: 12px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.legende-point { width: 10px; height: 10px; border-radius: 2px; }
.legende-valeur { color: var(--gris); font-weight: 500; white-space: nowrap; }

/* --- Colonnes mensuelles (N vs N-1) ------------------------------------- */
.mensuel {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 10px;
  align-items: end;
  height: 180px;
  padding-top: 8px;
}
.mois { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.mois-colonnes { display: flex; align-items: flex-end; gap: 3px; width: 100%; height: 100%; justify-content: center; }
.colonne { width: 45%; max-width: 22px; border-radius: 3px 3px 0 0; min-height: 2px; }
.colonne.n1 { background: var(--bordure-2); }
.colonne.n  { background: var(--rouge); }
.mois-libelle { font-size: 11px; color: var(--gris); }
.mensuel-legende { display: flex; gap: 18px; font-size: 12px; color: var(--gris); margin-top: 12px; }
.mensuel-legende span::before {
  content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px;
}
.mensuel-legende .n::before  { background: var(--rouge); }
.mensuel-legende .n1::before { background: var(--bordure-2); }

/* --- Tableaux ----------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--gris); font-weight: 600; padding: 8px 8px 12px; border-bottom: 1px solid var(--bordure);
}
thead th.droite, tbody td.droite { text-align: right; }
tbody td { padding: 12px 8px; border-bottom: 1px solid var(--fond-2); font-size: 13px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--fond-3); }
.principal { font-weight: 500; }
.secondaire { font-size: 11px; color: var(--gris); margin-top: 2px; }

tr.lien { cursor: pointer; }
tbody td a { text-decoration: none; }
tbody td a:hover { text-decoration: underline; }
.defilement { overflow-x: auto; }
.attention { color: var(--orange); }

/* --- Drill-down : recherche de pièces ----------------------------------- */
.recherche { margin-bottom: 16px; }
.onglets { display: flex; gap: 4px; border-bottom: 1px solid var(--bordure); margin-bottom: 16px; }
.onglet {
  padding: 8px 14px; font-size: 13px; font-weight: 500; color: var(--gris); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.onglet input { position: absolute; opacity: 0; width: 0; height: 0; }
.onglet:hover  { color: var(--encre); }
.onglet.active { color: var(--rouge); border-bottom-color: var(--rouge); font-weight: 600; }
.criteres { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.criteres .champ { margin-bottom: 0; min-width: 120px; }
.criteres .champ.large { flex: 1 1 200px; }
.criteres .champ select, .criteres .champ input {
  border: 1px solid var(--bordure-2); border-radius: 6px; padding: 7px 10px;
  font-size: 13px; font-family: inherit; color: var(--encre); background: white;
}
.criteres .champ.case { flex-direction: column; gap: 2px; }
.criteres .champ.case label { text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--encre); font-weight: 500; }
.criteres .champ.case small { font-size: 11px; color: var(--gris); }
.criteres .actions { flex-direction: row; align-items: center; gap: 12px; }
.criteres .actions .bouton { width: auto; padding: 8px 16px; }
.criteres .actions a { font-size: 12px; color: var(--gris); }
.recherche .erreur { margin: 12px 0 0; }
.pagination { display: flex; gap: 12px; font-size: 13px; white-space: nowrap; }
.pagination a { text-decoration: none; color: var(--bleu); font-weight: 500; }
table.pieces td, table.lignes td { padding: 9px 8px; }
tr.commentaire td { color: var(--gris); font-style: italic; padding-top: 5px; padding-bottom: 5px; }

/* --- Drill-down : fiche d'une pièce -------------------------------------- */
.fil { font-size: 13px; color: var(--gris); margin-bottom: 12px; }
.fil a { color: var(--bleu); text-decoration: none; }
.fiche { margin-bottom: 16px; }
.fiche-total { text-align: right; }
.etiquette {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px;
  background: var(--fond-2); color: var(--gris); vertical-align: middle; margin-left: 6px;
}
.etiquette.en-cours { background: #FFF4E5; color: var(--orange); }
.proprietes { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; font-size: 13px; }
.proprietes dt { color: var(--gris); font-weight: 500; }
.discret { font-size: 12px; color: var(--bleu); margin-left: 10px; }

/* --- Liste de fraîcheur ------------------------------------------------- */
.etats { display: flex; flex-direction: column; gap: 10px; }
.etat {
  display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: center;
  padding: 10px 12px; background: var(--fond-3); border-radius: 8px;
  border-left: 3px solid var(--etat-couleur, var(--gris));
}
.etat-icone {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--etat-fond, var(--fond-2)); color: var(--etat-couleur, var(--gris));
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.etat.ok      { --etat-couleur: var(--vert);   --etat-fond: #EAFBF1; }
.etat.retard  { --etat-couleur: var(--orange); --etat-fond: #FFF4E5; }
.etat.echec   { --etat-couleur: var(--rouge);  --etat-fond: #FDECEE; }
.etat-titre { font-weight: 600; font-size: 13px; }
.etat-desc  { font-size: 12px; color: var(--gris); margin-top: 2px; }
.etat-quand { font-size: 12px; color: var(--gris); white-space: nowrap; }

/* --- Connexion ---------------------------------------------------------- */
.connexion { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.connexion .carte { width: 100%; max-width: 380px; padding: 32px; }
.connexion .marque { margin-bottom: 24px; }
.champ { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.champ label { font-size: 12px; color: var(--gris); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.champ input {
  border: 1px solid var(--bordure-2); border-radius: 6px; padding: 9px 12px;
  font-size: 14px; font-family: inherit; color: var(--encre);
}
.champ input:focus { outline: 2px solid #C8202E33; border-color: var(--rouge); }
.bouton {
  width: 100%; background: var(--rouge); color: white; border: none; border-radius: 6px;
  padding: 11px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.bouton:hover { background: #B01C29; }
.erreur { background: #FDECEE; color: var(--rouge); border: 1px solid #F5C2C7; border-radius: 6px; padding: 10px 12px; font-size: 13px; margin-bottom: 16px; }

/* --- Adaptation --------------------------------------------------------- */
@media (max-width: 1100px) {
  .kpi-ligne { grid-template-columns: repeat(2, 1fr); }
  .grille, .grille-basse { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .kpi-ligne { grid-template-columns: 1fr; }
  main { padding: 16px; }
  header { padding: 14px 16px; }
  .barre { grid-template-columns: 110px 1fr 90px; }
  .mensuel { gap: 4px; }
  .mois-libelle { font-size: 9px; }
}
