/* KPI Web Gate — charte du portail Molding France : bleu profond, frise tricolore, jour / nuit */
:root {
  --bleu: #0b2a63;
  --bleu-clair: #1d4fa8;
  --rouge: #e1000f;
  --fond: #f4f6fa;
  --carte: #ffffff;
  --texte: #14213d;
  --texte-doux: #5b6785;
  --bord: #d9dfeb;
  --filet: #e6eaf2;
  --piste: #e9edf5;
  --grille: #eef1f7;
  --barre-prod: #0b2a63;
  --barre-mp: #7f9ed8;
  --barre-st: #d27a1f;
  --barre-liv: #2a8c82;
  --ok: #1d4fa8;
  --tendu: #b45309;
  --tendu-texte: #8a4b00;
  --sur: #e1000f;
  --sur-texte: #c4000d;
  --capacite: #14213d;
  --police: "Air France Text", "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}
:root[data-theme="dark"] {
  --bleu: #8fb2ff;
  --bleu-clair: #5d8df0;
  --fond: #0c1424;
  --carte: #131d33;
  --texte: #e8edf8;
  --texte-doux: #9aa7c4;
  --bord: #25314f;
  --filet: #22304d;
  --piste: #1d2a45;
  --grille: #1a2640;
  --barre-prod: #8fb2ff;
  --barre-mp: #5a7ec4;
  --barre-st: #e8a04a;
  --barre-liv: #47b8aa;
  --ok: #5d8df0;
  --tendu: #e0932f;
  --tendu-texte: #f0b25e;
  --sur: #ff4d58;
  --sur-texte: #ff7a82;
  --capacite: #e8edf8;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--fond); color: var(--texte);
  font-family: var(--police); line-height: 1.45;
  min-height: 100vh; display: flex; flex-direction: column;
}
main { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 24px 16px 48px; }
h1 { font-size: 1.6rem; margin: 4px 0 18px; color: var(--bleu); }
h2 { font-size: 1.1rem; margin: 0; color: var(--bleu); }

.frise-tricolore { display: flex; height: 5px; }
.frise-tricolore span { flex: 1; }
.frise-tricolore span:nth-child(1) { background: #0055a4; }
.frise-tricolore span:nth-child(2) { background: #ffffff; }
.frise-tricolore span:nth-child(3) { background: var(--rouge); }
:root[data-theme="dark"] .frise-tricolore span:nth-child(1) { background: #3b7be0; }

.entete {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--carte); border-bottom: 1px solid var(--bord);
}
.marque { display: inline-flex; align-items: baseline; gap: 12px; text-decoration: none; min-height: 44px; align-items: center; }
.marque-nom { font-weight: 800; letter-spacing: .08em; color: var(--bleu); font-size: 1.05rem; }
.marque-sous { color: var(--texte-doux); font-size: .9rem; }
.entete-droite { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.fraicheur { color: var(--texte-doux); font-size: .9rem; }
.alerte-douce { color: var(--tendu-texte); font-weight: 600; }
.inline { display: inline; margin: 0; }
.bouton-rond {
  background: none; border: 1px solid var(--bord); color: var(--texte);
  width: 44px; height: 44px; border-radius: 50%; font-size: 1.1rem; cursor: pointer;
}
.lien { background: none; border: 0; color: var(--bleu-clair); cursor: pointer; font: inherit; min-height: 44px; padding: 0 4px; }
.lien:hover { text-decoration: underline; }
.pied { text-align: center; color: var(--texte-doux); font-size: .8rem; padding: 18px; }

.carte {
  background: var(--carte); border: 1px solid var(--bord); border-radius: 14px;
  padding: 20px 22px; margin-bottom: 18px; box-shadow: 0 1px 2px rgba(11,42,99,.05);
}
.carte-login { max-width: 400px; margin: 48px auto; }
.carte-login h1 { font-size: 1.25rem; text-align: center; margin: 0 0 4px; }
.sous-titre { text-align: center; color: var(--texte-doux); margin: 0 0 8px; }
label { display: block; margin: 14px 0 6px; font-size: .9rem; color: var(--texte-doux); }
input[type=text], input[type=password] {
  width: 100%; padding: 11px 12px; font: inherit; color: var(--texte); min-height: 44px;
  background: var(--fond); border: 1px solid var(--bord); border-radius: 8px;
}
input:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--bleu-clair); outline-offset: 2px;
}
.principal {
  width: 100%; margin-top: 22px; padding: 12px; font: inherit; font-weight: 600; min-height: 44px;
  color: #fff; background: #0b2a63; border: 0; border-radius: 8px; cursor: pointer;
}
:root[data-theme="dark"] .principal { background: var(--bleu-clair); }
.alerte { padding: 10px 12px; border-radius: 8px; font-size: .9rem; background: #fdecee; color: #8f0009; }
:root[data-theme="dark"] .alerte { background: #3a1a22; color: #ffb3b8; }

/* ---- indicateurs ---- */
.kpis { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr) minmax(0, 1.2fr); gap: 18px; margin-bottom: 18px; }
.kpis .carte { margin: 0; }
.kpi { display: flex; flex-direction: column; gap: 10px; }
.kpi-titre { font-size: .85rem; font-weight: 600; color: var(--texte-doux); text-transform: uppercase; letter-spacing: .06em; }
.kpi-grand { font-size: 2.6rem; font-weight: 700; color: var(--bleu); line-height: 1.05; font-variant-numeric: tabular-nums; }
.unite { font-size: .45em; font-weight: 600; color: var(--texte-doux); }
.kpi-detail { margin: 0; display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--texte-doux); border-top: 1px solid var(--filet); padding-top: 10px; }
.kpi-detail div { display: flex; justify-content: space-between; gap: 8px; }
.kpi-detail dt { margin: 0; }
.kpi-detail dd { margin: 0; font-weight: 700; color: var(--texte); font-variant-numeric: tabular-nums; }
.kpi-trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.kpi-trio.deux { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi-trio > div { display: flex; flex-direction: column; gap: 2px; }
.kpi-trio > div + div { border-left: 1px solid var(--filet); padding-left: 12px; }
.kpi-lib { font-size: .9rem; color: var(--texte-doux); }
.kpi-val { font-size: 2rem; font-weight: 700; color: var(--bleu); line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-note { margin: auto 0 0; font-size: .8rem; color: var(--texte-doux); border-top: 1px solid var(--filet); padding-top: 10px; }

/* ---- en-tête de carte et segments ---- */
.carte-tete { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.sous { margin: 2px 0 0; font-size: .9rem; color: var(--texte-doux); }
.segments { display: flex; gap: 4px; background: var(--fond); border: 1px solid var(--bord); border-radius: 10px; padding: 4px; flex-wrap: wrap; }
.segments button {
  min-height: 40px; padding: 0 14px; border: 0; border-radius: 7px; font: inherit; font-size: .9rem;
  cursor: pointer; background: transparent; color: var(--texte);
}
.segments button:hover { background: var(--piste); }
.segments button[aria-pressed="true"] { background: #0b2a63; color: #fff; font-weight: 700; }
:root[data-theme="dark"] .segments button[aria-pressed="true"] { background: var(--bleu-clair); }

/* ---- pouls ---- */
.resume { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.resume div { background: var(--fond); border-radius: 10px; padding: 10px 14px; display: flex; flex-direction: column; }
.resume span { font-size: .8rem; color: var(--texte-doux); }
.resume strong { font-size: 1.35rem; color: var(--bleu); font-variant-numeric: tabular-nums; }
.graphe { margin-bottom: 14px; }
.graphe-tete { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: .9rem; font-weight: 600; margin-bottom: 6px; }
.echelle { font-size: .75rem; font-weight: 400; color: var(--texte-doux); }
.pastille { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.pastille.prod { background: var(--barre-prod); }
.pastille.mp { background: var(--barre-mp); }
.pastille.st { background: var(--barre-st); }
.pastille.stc, .barre i.stc {
  background: repeating-linear-gradient(135deg, var(--barre-st) 0 3px, transparent 3px 6px);
  box-shadow: inset 0 0 0 1px var(--barre-st);
}
.resume small { font-size: .75rem; color: var(--texte-doux); }
.resume .fort { background: var(--piste); }
.legende.serree { margin: 0 0 6px; gap: 12px; }
.pastille.liv { background: var(--barre-liv); }
.pastille.ok { background: var(--ok); }
.pastille.tendu { background: var(--tendu); }
.pastille.sur { background: var(--sur); }
.trait { display: inline-block; width: 2px; height: 12px; background: var(--capacite); margin-right: 6px; vertical-align: -1px; }
.barres {
  display: flex; align-items: flex-end; gap: var(--ecart, 4px);
  border-bottom: 1px solid var(--bord); position: relative;
}
.barres.haute { height: 190px; background: repeating-linear-gradient(to top, transparent 0 46.5px, var(--grille) 46.5px 47.5px); }
.barres.basse { height: 120px; background: repeating-linear-gradient(to top, transparent 0 39px, var(--grille) 39px 40px); }
/* place au-dessus de la barre la plus haute pour son montant (horizontal, ou vertical si les barres sont étroites) */
.barres.haute, .barres.basse { margin-top: 18px; }
.barres.etroit { margin-top: 30px; }
.barre {
  flex: 1 1 0; min-width: 0; height: 100%; padding: 0; border: 0; background: transparent; cursor: pointer;
  display: flex; align-items: flex-end; -webkit-tap-highlight-color: transparent;
}
.barre i { display: block; width: 100%; border-radius: 3px 3px 0 0; }
.barres.basse .barre { flex-direction: column; justify-content: flex-end; align-items: stretch; }
.barre > * { flex-shrink: 0; }                 /* la barre garde sa hauteur, le montant déborde au-dessus */
.barre .val {
  display: block; font-size: .7rem; line-height: 1; font-weight: 600; color: var(--texte);
  text-align: center; white-space: nowrap; margin-bottom: 3px; font-variant-numeric: tabular-nums;
}
.barres.etroit .val { writing-mode: vertical-rl; transform: rotate(180deg); align-self: center; font-size: .66rem; }
.barre.partiel .val { color: var(--texte-doux); }
.barres.haute .barre { flex-direction: column; justify-content: flex-end; align-items: stretch; }
.barres.haute .barre i { border-radius: 0; }
.barres.haute .barre i:first-child { border-radius: 3px 3px 0 0; }
.barres.haute .barre i + i { box-shadow: 0 -1px 0 var(--carte); }
.barre i.prod { background: var(--barre-prod); }
.barre i.mp { background: var(--barre-mp); }
.barre i.st { background: var(--barre-st); }
.barres.basse .barre i { background: var(--barre-liv); }
.barre.partiel i { opacity: .45; }
.barre.choisie { outline: 2px solid var(--rouge); outline-offset: 1px; border-radius: 3px; }
.etiquettes { display: flex; gap: var(--ecart, 4px); margin-top: 4px; }
.etiquettes span { flex: 1 1 0; min-width: 0; font-size: .7rem; color: var(--texte-doux); text-align: center; white-space: nowrap; overflow: visible; }
.detail { margin: 6px 0 0; font-size: .9rem; min-height: 1.4em; }
.note { margin: 4px 0 0; font-size: .8rem; color: var(--texte-doux); }

/* ---- charge ---- */
.legende { display: flex; gap: 16px; flex-wrap: wrap; font-size: .8rem; color: var(--texte-doux); margin-bottom: 6px; }
.groupe { border: 1px solid var(--filet); border-radius: 10px; margin-bottom: 6px; overflow: hidden; }
.groupe summary { list-style: none; cursor: pointer; background: var(--fond); }
.groupe summary::-webkit-details-marker { display: none; }
.barres.tronque { border-bottom: 2px dashed var(--texte-doux); }
.heures small { display: block; font-size: .72rem; }
.ligne-charge { display: grid; grid-template-columns: 200px minmax(0, 1fr) 170px 92px; gap: 14px; align-items: center; padding: 8px 14px; min-height: 44px; }
.groupe .nom { font-weight: 700; color: var(--bleu); display: flex; align-items: center; gap: 8px; }
.chevron { width: 14px; height: 14px; transition: transform .15s; flex: none; }
.groupe[open] .chevron { transform: rotate(90deg); }
.machine { min-height: 36px; padding-top: 4px; padding-bottom: 4px; border-top: 1px solid var(--filet); }
.machine .nom { padding-left: 22px; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.piste { position: relative; height: 12px; background: var(--piste); border-radius: 6px; }
.machine .piste { height: 9px; }
.piste .plein { position: absolute; left: 0; top: 0; bottom: 0; border-radius: inherit; }
.piste .capa { position: absolute; left: 66.667%; top: -4px; bottom: -4px; width: 2px; background: var(--capacite); }
.heures { font-size: .8rem; color: var(--texte-doux); text-align: right; font-variant-numeric: tabular-nums; }
.pct { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.pct small { display: block; font-size: .7rem; font-weight: 600; }
.etat-ok { color: var(--texte); }
.etat-tendu { color: var(--tendu-texte); }
.etat-sur { color: var(--sur-texte); }
.vide { color: var(--texte-doux); font-size: .9rem; padding: 12px 0; }

@media (max-width: 900px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .ligne-charge { grid-template-columns: 112px minmax(0, 1fr) 62px; gap: 10px; padding: 8px 10px; }
  .ligne-charge .heures { display: none; }
  .machine .nom { padding-left: 4px; }
  .resume { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .resume div { flex-direction: row; flex-wrap: wrap; justify-content: space-between; align-items: baseline; column-gap: 8px; }
  .resume small { flex-basis: 100%; }
  .resume strong { font-size: 1.1rem; }
  .carte { padding: 16px 14px; }
  .kpi-val { font-size: 1.6rem; }
  .segments { width: 100%; }
  .segments button { flex: 1 1 auto; padding: 0 8px; }
}

/* ---- points d'attention ---- */
.titre-ligne { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.titre-ligne h1 { margin: 4px 0 0; }
.puce-attention {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 999px;
  font-size: .9rem; font-weight: 600; text-decoration: none;
  color: var(--tendu-texte); background: #fdf1e1; border: 1px solid #f0d3a8;
}
:root[data-theme="dark"] .puce-attention { background: #33240f; border-color: #6b4a1c; }
.puce-attention:hover { text-decoration: underline; }
.anomalies { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.anomalies li { border: 1px solid var(--filet); border-radius: 10px; padding: 10px 14px; }
.anomalie-tete { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.anomalie-type { font-weight: 700; color: var(--tendu-texte); }
.anomalie-depuis { font-size: .8rem; color: var(--texte-doux); }
.anomalie-affaire { font-weight: 600; margin-top: 2px; }
.anomalie-detail { font-size: .9rem; color: var(--texte-doux); }
.resolues { margin-top: 12px; }
.resolues summary { cursor: pointer; color: var(--bleu-clair); min-height: 44px; display: flex; align-items: center; }
.resolues .anomalie-type { color: var(--texte-doux); }

/* ---- commentaires sur les anomalies ---- */
.commentaire { margin: 8px 0 0; padding: 8px 12px; border-radius: 8px; background: var(--fond); font-size: .9rem; white-space: pre-line; }
.commentaire cite { display: block; margin-top: 4px; font-size: .75rem; font-style: normal; color: var(--texte-doux); }
.commenter { margin-top: 4px; }
.commenter summary { cursor: pointer; color: var(--bleu-clair); font-size: .85rem; min-height: 44px; display: inline-flex; align-items: center; }
.commenter form { display: flex; flex-direction: column; gap: 6px; }
.commenter label { margin: 0; }
.commenter textarea {
  width: 100%; padding: 8px 10px; font: inherit; color: var(--texte); background: var(--fond);
  border: 1px solid var(--bord); border-radius: 8px; resize: vertical;
}
.case { display: flex; align-items: flex-start; gap: 8px; font-size: .85rem; color: var(--texte); min-height: 44px; }
.case input { margin-top: 3px; width: 18px; height: 18px; flex: none; }
.secondaire {
  align-self: flex-start; min-height: 44px; padding: 0 18px; font: inherit; font-weight: 600; cursor: pointer;
  color: #fff; background: #0b2a63; border: 0; border-radius: 8px;
}
:root[data-theme="dark"] .secondaire { background: var(--bleu-clair); }
.anomalies li.expliquee .anomalie-type { color: var(--texte-doux); }
