/* =====================================================================
   EllioGMAO — feuille de style unique (GMAO_01.md § 1.5)
   Thème sombre industriel : fond #111827, accent cyan, orange sécurité.
   Couleurs de statut des OT IMPOSÉES par le plan (§ 1.5).
   ===================================================================== */

:root {
    --fond:          #111827;
    --fond-2:        #1f2937;
    --fond-3:        #273449;
    --bordure:       #374151;
    --texte:         #e5e7eb;
    --texte-2:       #9ca3af;
    --accent:        #22d3ee;
    --accent-fonce:  #0e7490;
    --orange:        #f97316;
    --rouge:         #ef4444;
    --vert:          #4ade80;
    --vert-fonce:    #16a34a;
    --violet:        #a78bfa;
    --bleu:          #60a5fa;
    --rayon:         10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--fond);
    color: var(--texte);
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }

/* --- Bandeau démo permanent ------------------------------------------ */
.bandeau-demo {
    background: linear-gradient(90deg, var(--accent-fonce), #155e75);
    color: #ecfeff;
    text-align: center;
    padding: .35rem .75rem;
    font-size: .85rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

/* --- Structure application ------------------------------------------- */
.app { display: flex; min-height: calc(100vh - 30px); }

.sidebar {
    width: 230px;
    flex-shrink: 0;
    background: var(--fond-2);
    border-right: 1px solid var(--bordure);
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
}

.logo {
    font-size: 1.4rem;
    font-weight: 700;
    padding: 0 1.25rem .75rem;
    color: var(--texte);
}
.logo span { color: var(--accent); }
.logo-grand { font-size: 2.2rem; padding: 0; }

.sidebar nav { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 0 .5rem; }
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem .75rem;
    border-radius: 8px;
    color: var(--texte-2);
}
.sidebar nav a:hover { background: var(--fond-3); color: var(--texte); text-decoration: none; }
.sidebar nav a.actif { background: var(--accent-fonce); color: #ecfeff; }
.sidebar nav .ico { width: 1.4em; text-align: center; }

.sidebar-user {
    padding: .9rem 1.25rem 0;
    border-top: 1px solid var(--bordure);
    font-size: .85rem;
}
.user-nom { font-weight: 600; }
.user-role { color: var(--texte-2); margin-bottom: .5rem; }

.contenu { flex: 1; padding: 1.25rem 1.75rem 3rem; min-width: 0; }
.titre-page { font-size: 1.5rem; margin: 0 0 1.25rem; }

/* --- Cartes ------------------------------------------------------------ */
.carte {
    background: var(--fond-2);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    padding: 1.1rem 1.3rem;
    margin-bottom: 1.25rem;
}
.grille-cartes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}
.grille-cartes .carte { margin-bottom: 0; }
.texte-secondaire { color: var(--texte-2); font-size: .9rem; }

/* --- Boutons ------------------------------------------------------------ */
.btn {
    display: inline-block;
    background: var(--fond-3);
    color: var(--texte);
    border: 1px solid var(--bordure);
    border-radius: 8px;
    padding: .45rem 1rem;
    font: inherit;
    cursor: pointer;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn-accent { background: var(--accent-fonce); border-color: var(--accent-fonce); color: #ecfeff; }
.btn-accent:hover { background: #0891b2; }
.btn-danger { background: #7f1d1d; border-color: #991b1b; }
.btn-petit { padding: .2rem .6rem; font-size: .82rem; }

/* --- Badges statut OT (couleurs imposées, GMAO_01.md § 1.5) ------------- */
.badge {
    display: inline-block;
    padding: .1rem .55rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-statut-ouvert        { background: #4b5563; color: #f9fafb; }
.badge-statut-affecte       { background: #1d4ed8; color: #eff6ff; }
.badge-statut-en_cours      { background: var(--orange); color: #1c1917; }
.badge-statut-attente_piece { background: var(--violet); color: #1e1b4b; }
.badge-statut-termine       { background: var(--vert); color: #052e16; }
.badge-statut-cloture       { background: var(--vert-fonce); color: #f0fdf4; }
.badge-statut-annule        { background: transparent; color: var(--texte-2); text-decoration: line-through; border: 1px solid var(--bordure); }

.badge-role-admin       { background: #7f1d1d; color: #fee2e2; }
.badge-role-responsable { background: var(--accent-fonce); color: #ecfeff; }
.badge-role-technicien  { background: #92400e; color: #fef3c7; }
.badge-role-operateur   { background: #374151; color: #e5e7eb; }

/* Pastilles d'état machine (arbre équipements) */
.pastille { display: inline-block; width: .7em; height: .7em; border-radius: 50%; margin-right: .4em; }
.pastille-marche      { background: var(--vert); }
.pastille-arret       { background: var(--texte-2); }
.pastille-panne       { background: var(--rouge); animation: clignote 1s infinite; }
.pastille-maintenance { background: var(--orange); }
@keyframes clignote { 50% { opacity: .25; } }

/* --- Tableaux ------------------------------------------------------------ */
.tableau-scroll { overflow-x: auto; }
.tableau { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tableau th, .tableau td { padding: .5rem .7rem; text-align: left; border-bottom: 1px solid var(--bordure); }
.tableau th { color: var(--texte-2); font-weight: 600; white-space: nowrap; }
.tableau tbody tr:hover { background: var(--fond-3); }
.actions-cellule { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }

/* --- Formulaires ---------------------------------------------------------- */
label { display: block; font-size: .88rem; color: var(--texte-2); }
input, select, textarea {
    width: 100%;
    margin-top: .25rem;
    background: var(--fond);
    color: var(--texte);
    border: 1px solid var(--bordure);
    border-radius: 8px;
    padding: .45rem .6rem;
    font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-fonce); border-color: var(--accent-fonce); }
.form-grille {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: .9rem;
    align-items: end;
}
.inline { display: inline-block; }
.inline input { width: auto; }
details.inline summary { list-style: none; cursor: pointer; }

/* --- Alertes & toasts ------------------------------------------------------ */
.alerte { padding: .6rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.alerte-succes { background: #14532d; color: #dcfce7; }
.alerte-erreur { background: #7f1d1d; color: #fee2e2; }

#toasts { position: fixed; bottom: 1rem; right: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 200; }
.toast {
    background: var(--fond-3);
    border: 1px solid var(--bordure);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    padding: .6rem 1rem;
    max-width: 340px;
    animation: toast-in .2s ease-out;
}
.toast-erreur { border-left-color: var(--rouge); }
.toast-succes { border-left-color: var(--vert); }
@keyframes toast-in { from { transform: translateX(20px); opacity: 0; } }

/* --- Page de connexion ------------------------------------------------------ */
.page-login { min-height: 100vh; }
.login-conteneur { max-width: 1000px; margin: 0 auto; padding: 3rem 1.5rem; }
.login-entete { text-align: center; margin-bottom: 2rem; }
.login-sous-titre { color: var(--texte-2); max-width: 620px; margin: .75rem auto 0; }
.login-cartes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
}
.login-carte {
    background: var(--fond-2);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    padding: 1.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    transition: border-color .15s;
}
.login-carte:hover { border-color: var(--accent); }
.login-carte-icone { font-size: 2.2rem; }
.login-carte h2 { margin: 0; }
.login-carte p { color: var(--texte-2); font-size: .9rem; flex: 1; }
/* Héros vendeur (GMAO_02.md phase 15) */
.login-accroche { font-size: 1.35rem; margin: .9rem 0 0; color: var(--texte); }
.login-accroche strong { color: var(--accent); }
.login-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin: 1.8rem 0;
}
.login-stat {
    background: var(--fond-2);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    padding: .9rem 1.1rem;
    text-align: center;
}
.login-stat-valeur { display: block; font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.login-stat-libelle { color: var(--texte-2); font-size: .85rem; }
.login-apercu { margin: 0 auto 2.2rem; max-width: 920px; text-align: center; }
.login-apercu img {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--accent-fonce);
    border-radius: var(--rayon);
    box-shadow: 0 18px 40px rgba(0, 0, 0, .5);
    transform: perspective(1200px) rotateX(2.5deg);
}
.login-apercu figcaption { margin-top: .6rem; font-size: .82rem; }
.login-choix { text-align: center; font-size: 1.05rem; margin: 0 0 1rem; color: var(--texte); }
.login-ia {
    max-width: 640px;
    margin: 1.8rem auto 0;
    text-align: center;
    color: var(--texte-2);
    background: var(--fond-2);
    border: 1px solid var(--accent-fonce);
    border-radius: var(--rayon);
    padding: .75rem 1.1rem;
    font-size: .9rem;
}
.login-ia strong { color: var(--accent); }

.login-admin { margin-top: 2rem; text-align: center; color: var(--texte-2); }
.login-admin summary { cursor: pointer; }
.login-form-admin { max-width: 320px; margin: 1rem auto 0; display: flex; flex-direction: column; gap: .75rem; text-align: left; }
.login-pied { margin-top: 2.5rem; text-align: center; font-size: .85rem; }

/* --- Kanban (préparé pour la phase 3) ---------------------------------------- */
.kanban { display: flex; gap: 1rem; overflow-x: auto; align-items: flex-start; }
.kanban-col {
    background: var(--fond-2);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    min-width: 240px;
    flex: 1;
    padding: .6rem;
}
.kanban-col h3 { margin: .2rem .3rem .6rem; font-size: .85rem; color: var(--texte-2); text-transform: uppercase; }
.kanban-carte {
    background: var(--fond-3);
    border: 1px solid var(--bordure);
    border-radius: 8px;
    padding: .6rem .7rem;
    margin-bottom: .5rem;
    cursor: grab;
    font-size: .88rem;
}
.kanban-carte.survol { outline: 2px dashed var(--accent); }

/* --- Badges urgence / priorité / type / DI (phase 3) ---------------------------- */
.badge-urgence-basse    { background: var(--fond-3); color: var(--texte-2); }
.badge-urgence-normale  { background: #1e40af; color: #dbeafe; }
.badge-urgence-haute    { background: var(--orange); color: #1c1917; }
.badge-urgence-critique { background: var(--rouge); color: #fff; }

.badge-prio-P1 { background: var(--rouge); color: #fff; }
.badge-prio-P2 { background: var(--orange); color: #1c1917; }
.badge-prio-P3 { background: #1e40af; color: #dbeafe; }
.badge-prio-P4 { background: var(--fond-3); color: var(--texte-2); }

.badge-type-curatif      { background: #7c2d12; color: #ffedd5; }
.badge-type-preventif    { background: #14532d; color: #dcfce7; }
.badge-type-amelioration { background: #312e81; color: #e0e7ff; }

.badge-di-nouvelle { background: #1e40af; color: #dbeafe; }
.badge-di-validee  { background: var(--vert-fonce); color: #f0fdf4; }
.badge-di-rejetee  { background: var(--fond-3); color: var(--texte-2); text-decoration: line-through; }

/* --- Barre d'outils des pages liste --------------------------------------------- */
.barre-outils { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.barre-outils select, .barre-outils input[type=search] { width: auto; margin-top: 0; }
.filtres { display: flex; gap: .5rem; }
.label-case { display: inline-flex; align-items: center; gap: .4rem; color: var(--texte); }
.label-case input { width: auto; margin-top: 0; }
.ligne-form { display: flex; gap: .5rem; margin-top: .6rem; }
.ligne-form input { margin-top: 0; }
.ligne-cliquable { cursor: pointer; }
.texte-multiligne { white-space: pre-line; }

/* --- Tuiles KPI du tableau de bord ----------------------------------------------- */
.tuiles-kpi {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.tuile {
    background: var(--fond-2);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    padding: .9rem 1.1rem;
    display: flex;
    flex-direction: column;
    color: var(--texte);
}
a.tuile:hover { border-color: var(--accent); text-decoration: none; }
.tuile-valeur { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.tuile-libelle { color: var(--texte-2); font-size: .85rem; }
.tuile-alerte { border-color: var(--rouge); }
.tuile-alerte .tuile-valeur { color: var(--rouge); }

.colonnes-dash { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 900px) { .colonnes-dash { grid-template-columns: 1fr; } }

.fil-activite { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; font-size: .88rem; }
.fil-activite li { padding: .3rem 0; border-bottom: 1px solid var(--bordure); }
.fil-activite li.nouveau { animation: fil-in .5s ease-out; }
.fil-date { color: var(--texte-2); font-family: ui-monospace, monospace; font-size: .8rem; }
@keyframes fil-in { from { background: var(--accent-fonce); } }

/* --- Kanban : compléments (phase 3) ----------------------------------------------- */
.kanban-col.depot { outline: 2px dashed var(--accent); }
.kb-ligne1 { display: flex; gap: .4rem; align-items: center; margin-bottom: .25rem; }
.kb-numero { font-family: ui-monospace, monospace; font-size: .78rem; color: var(--texte-2); }
.kb-titre { margin-bottom: .25rem; }
.kb-meta { color: var(--texte-2); font-size: .78rem; }

/* --- Assistant IA (phase 10) ------------------------------------------------------------ */
.assistant-bouton {
    position: fixed;
    bottom: 1.2rem;
    right: 1.2rem;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 1px solid var(--accent-fonce);
    background: var(--accent-fonce);
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 150;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .4);
}
.assistant-bouton:hover { background: #0891b2; }

.assistant-volet {
    position: fixed;
    bottom: 5.5rem;
    right: 1.2rem;
    width: min(400px, calc(100vw - 2rem));
    height: min(540px, calc(100vh - 8rem));
    background: var(--fond-2);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    display: flex;
    flex-direction: column;
    z-index: 150;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
}
/* Le sélecteur de classe l'emporte sur [hidden]{display:none} du navigateur :
   il faut rétablir explicitement le masquage quand l'attribut hidden est posé. */
.assistant-volet[hidden] { display: none; }
.assistant-entete {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--bordure);
}
.assistant-note { color: var(--texte-2); font-size: .72rem; flex: 1; }
.assistant-fermer { background: none; border: none; color: var(--texte-2); cursor: pointer; font-size: 1rem; }
.assistant-messages { flex: 1; overflow-y: auto; padding: .8rem; display: flex; flex-direction: column; gap: .5rem; }
.assistant-bulle {
    max-width: 88%;
    padding: .5rem .8rem;
    border-radius: 12px;
    font-size: .88rem;
    white-space: normal;
}
.assistant-user { align-self: flex-end; background: var(--accent-fonce); color: #ecfeff; border-bottom-right-radius: 4px; }
.assistant-assistant { align-self: flex-start; background: var(--fond-3); border-bottom-left-radius: 4px; }
.assistant-attente { color: var(--texte-2); font-style: italic; animation: clignote 1.4s infinite; }
.assistant-outils { align-self: flex-start; color: var(--texte-2); font-size: .72rem; }
.assistant-suggestions { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 .8rem .5rem; }
.assistant-suggestion {
    background: var(--fond-3);
    border: 1px solid var(--bordure);
    border-radius: 999px;
    color: var(--texte-2);
    font-size: .76rem;
    padding: .25rem .7rem;
    cursor: pointer;
}
.assistant-suggestion:hover { border-color: var(--accent); color: var(--texte); }
.assistant-saisie { display: flex; gap: .5rem; padding: .7rem; border-top: 1px solid var(--bordure); align-items: flex-end; }
.assistant-champ { flex: 1; margin-top: 0; resize: none; font-size: .88rem; }

/* --- Usine en direct (phase 8) --------------------------------------------------------- */
.usine-direct {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: .6rem;
}
.usine-unite {
    background: var(--fond-3);
    border: 1px solid var(--bordure);
    border-radius: 8px;
    padding: .5rem .7rem;
    font-size: .85rem;
}
.usine-unite.usine-panne { border-color: var(--rouge); }
.usine-detail { color: var(--texte-2); font-size: .78rem; margin-top: .15rem; }

/* --- Planning des techniciens (phase 6) ----------------------------------------------- */
.planning-conteneur { display: flex; gap: 1.25rem; align-items: flex-start; }
.planning-non-planifies { width: 260px; flex-shrink: 0; max-height: calc(100vh - 180px); overflow-y: auto; }
.planning-grille-carte { flex: 1; min-width: 0; }
.planning-grille th.planning-tech { white-space: nowrap; font-weight: 600; }
.planning-grille th.planning-jour { text-align: center; min-width: 110px; }
.planning-cellule { vertical-align: top; min-height: 3rem; padding: .3rem; }
.planning-cellule.surcharge { background: rgba(239, 68, 68, .08); }
.planning-cellule.depot, .planning-zone.depot { outline: 2px dashed var(--accent); }
.planning-zone { min-height: 3rem; display: flex; flex-direction: column; gap: .3rem; }
.planning-chip {
    background: var(--fond-3);
    border: 1px solid var(--bordure);
    border-left: 4px solid var(--bleu);
    border-radius: 6px;
    padding: .18rem .45rem;
    font-size: .76rem;
    cursor: grab;
    margin-bottom: .25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 190px;
}
.planning-chip.prio-P1 { border-left-color: var(--rouge); }
.planning-chip.prio-P2 { border-left-color: var(--orange); }
.planning-chip.prio-P4 { border-left-color: var(--texte-2); }
.chip-numero { font-family: ui-monospace, monospace; color: var(--texte-2); }
.planning-charge { font-size: .74rem; color: var(--texte-2); margin-top: .15rem; }
@media (max-width: 900px) {
    .planning-conteneur { flex-direction: column; }
    .planning-non-planifies { width: 100%; max-height: 30vh; }
}

/* --- Stock & achats (phase 5) -------------------------------------------------------- */
.texte-alerte { color: var(--rouge); font-weight: 700; }
.badge-mvt-entree     { background: #14532d; color: #dcfce7; }
.badge-mvt-sortie     { background: #7c2d12; color: #ffedd5; }
.badge-mvt-retour     { background: #1e40af; color: #dbeafe; }
.badge-mvt-inventaire { background: var(--fond-3); color: var(--texte-2); }
.badge-cmd-brouillon       { background: var(--fond-3); color: var(--texte-2); }
.badge-cmd-envoyee         { background: #1e40af; color: #dbeafe; }
.badge-cmd-recue_partielle { background: var(--violet); color: #1e1b4b; }
.badge-cmd-recue           { background: var(--vert-fonce); color: #f0fdf4; }
.badge-cmd-annulee         { background: transparent; color: var(--texte-2); text-decoration: line-through; border: 1px solid var(--bordure); }

/* --- Préventif : jauges d'échéance et calendrier (phase 4) -------------------------- */
.jauge {
    display: inline-block;
    padding: .12rem .6rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
}
.jauge-echue   { background: var(--rouge); color: #fff; }
.jauge-preavis { background: var(--orange); color: #1c1917; }
.jauge-ok      { background: #14532d; color: #dcfce7; }
.jauge-inactif { background: var(--fond-3); color: var(--texte-2); }
.ligne-inactive { opacity: .5; }

.calendrier-preventif {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 1rem;
}
.cal-semaine h3 { font-size: .82rem; color: var(--texte-2); margin: 0 0 .3rem; text-transform: uppercase; }
.cal-semaine ul { list-style: none; margin: 0; padding: 0; font-size: .85rem; }
.cal-semaine li { padding: .2rem 0; border-bottom: 1px solid var(--bordure); }
.cal-date { color: var(--accent); font-family: ui-monospace, monospace; font-size: .78rem; margin-right: .4rem; }

/* --- Chronologie (historique OT) --------------------------------------------------- */
.chronologie { list-style: none; margin: 0; padding: 0; }
.chronologie li { padding: .4rem 0 .4rem 1rem; border-left: 2px solid var(--bordure); margin-left: .3rem; }
.chrono-date { color: var(--texte-2); font-size: .8rem; margin-right: .5rem; }
.liste-taches { list-style: none; margin: 0; padding: 0; }
.liste-taches li { padding: .2rem 0; }

/* --- Écran Équipements : arbre + fiche (phase 2) ------------------------------- */
.page-equip { display: flex; gap: 1.25rem; align-items: flex-start; }
.arbre-panneau { width: 380px; flex-shrink: 0; max-height: calc(100vh - 160px); overflow: auto; }
.fiche-panneau { flex: 1; min-width: 0; }

.arbre-outils { display: flex; gap: .5rem; margin-bottom: .75rem; flex-wrap: wrap; }
.arbre-outils input[type=search] { flex: 1; margin-top: 0; min-width: 140px; }

.arbre-liste { list-style: none; margin: 0; padding-left: 1rem; }
#arbre > .arbre-liste { padding-left: 0; }
.arbre-noeud {
    display: flex;
    align-items: center;
    gap: .35rem;
    padding: .15rem .3rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: .88rem;
    white-space: nowrap;
}
.arbre-noeud:hover { background: var(--fond-3); }
.arbre-noeud.selection { background: var(--accent-fonce); color: #ecfeff; }
.arbre-pli { width: 1em; text-align: center; color: var(--texte-2); user-select: none; }
.arbre-pli.vide { visibility: hidden; }
.arbre-code { color: var(--texte-2); font-family: ui-monospace, monospace; font-size: .8rem; }
.arbre-noeud.selection .arbre-code { color: #cffafe; }
.arbre-libelle { overflow: hidden; text-overflow: ellipsis; }
.arbre-crit {
    background: #7f1d1d; color: #fee2e2;
    font-size: .68rem; font-weight: 700;
    border-radius: 4px; padding: 0 .3rem;
}

.fiche-ariane { font-size: .82rem; color: var(--texte-2); margin-bottom: .4rem; }
.fiche-entete { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .5rem; }
.fiche-entete h2 { margin: 0; }
.fiche-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.fiche-section { margin-top: 1.1rem; }
.fiche-section h3 { font-size: .85rem; text-transform: uppercase; color: var(--texte-2); margin: 0 0 .4rem; }
.tableau-infos th { width: 160px; color: var(--texte-2); font-weight: 500; }
.nombre { font-variant-numeric: tabular-nums; text-align: right; }

.badge-statut-eq-marche      { background: #14532d; color: #dcfce7; }
.badge-statut-eq-arret       { background: #374151; color: #e5e7eb; }
.badge-statut-eq-panne       { background: var(--rouge); color: #fff; }
.badge-statut-eq-maintenance { background: var(--orange); color: #1c1917; }
.badge-crit-A { background: #7f1d1d; color: #fee2e2; }
.badge-crit-B { background: #78350f; color: #fef3c7; }
.badge-crit-C { background: var(--fond-3); color: var(--texte-2); }

dialog {
    background: var(--fond-2);
    color: var(--texte);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    padding: 1.25rem;
    max-width: 640px;
    width: 90vw;
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }

/* --- Responsive (< 768 px : la démo se montre sur téléphone) ------------------ */
@media (max-width: 768px) {
    .page-equip { flex-direction: column; }
    .arbre-panneau { width: 100%; max-height: 40vh; }
    .app { flex-direction: column; }
    .sidebar {
        width: 100%;
        flex-direction: row;
        align-items: center;
        overflow-x: auto;
        padding: .4rem .5rem;
        gap: .5rem;
    }
    .logo { padding: 0 .5rem; font-size: 1.1rem; }
    .sidebar nav { flex-direction: row; }
    .sidebar nav a { padding: .35rem .5rem; white-space: nowrap; }
    .sidebar-user { border-top: none; padding: 0 .5rem; white-space: nowrap; }
    .user-role { display: none; }
    .contenu { padding: 1rem; }
}

/* --- Synoptique « Usine en direct » (GMAO_02.md phase 14) ------------------------ */
.carte-hero {
    border-color: var(--accent-fonce);
    box-shadow: 0 8px 28px rgba(0, 0, 0, .35);
    background: linear-gradient(180deg, var(--fond-2), #1a2438);
}
.hero-entete { display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap; margin-bottom: .4rem; }
.hero-entete h2 { margin: 0; }
.hero-entete .texte-secondaire { font-size: .82rem; }

.synoptique { width: 100%; }
.synoptique-svg { width: 100%; height: auto; display: block; }
.syn-boite { fill: var(--fond-3); stroke: var(--bordure); stroke-width: 1; transition: stroke .15s; }
.syn-noeud { cursor: pointer; outline: none; }
.syn-noeud:hover .syn-boite, .syn-noeud:focus-visible .syn-boite { stroke: var(--accent); stroke-width: 1.5; }
.syn-noeud text { pointer-events: none; }
.syn-code { fill: var(--texte); font-size: 15px; font-weight: 700; }
.syn-libelle { fill: var(--texte-2); font-size: 12px; }
.syn-etat { fill: var(--accent); font-size: 12px; }
.syn-etat-droite { text-anchor: end; }
.syn-etat-panne { fill: var(--rouge); font-weight: 700; }
.syn-prod { fill: var(--texte); font-size: 13px; font-variant-numeric: tabular-nums; }
.syn-etiquette { fill: var(--texte-2); font-size: 11px; text-anchor: middle; letter-spacing: .04em; }
.syn-fleche { fill: var(--bordure); }
.syn-liaison { fill: none; stroke: var(--bordure); stroke-width: 2; stroke-dasharray: 7 7; }
.syn-flux { stroke: var(--accent-fonce); animation: syn-defile .9s linear infinite; }
@keyframes syn-defile { to { stroke-dashoffset: -14; } }
.syn-en-panne .syn-boite { stroke: var(--rouge); stroke-width: 2; }
.syn-en-panne { animation: syn-pulse 1.6s ease-in-out infinite; }
@keyframes syn-pulse {
    0%, 100% { filter: drop-shadow(0 0 4px rgba(239, 68, 68, .55)); }
    50%      { filter: drop-shadow(0 0 14px rgba(239, 68, 68, .95)); }
}
.syn-sous-panne .syn-boite { stroke: var(--rouge); stroke-dasharray: 4 3; }
.syn-sous-panne-txt { fill: var(--rouge) !important; font-weight: 600; }
.syn-pastille-marche      { fill: var(--vert); }
.syn-pastille-arret       { fill: var(--texte-2); }
.syn-pastille-panne       { fill: var(--rouge); }
.syn-pastille-maintenance { fill: var(--orange); }

/* En dessous de 768 px : liste compacte à la place du schéma */
.usine-direct-mobile { display: none; }
@media (max-width: 768px) {
    .synoptique { display: none; }
    .usine-direct-mobile { display: grid; }
}

/* Fil d'activité : séparateurs d'heure discrets */
.fil-separateur {
    color: var(--texte-2);
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: .55rem 0 .1rem !important;
    border-bottom: none !important;
}

/* --- Visite guidée & démo interactive (GMAO_02.md phase 16) ---------------------- */
.hero-action { margin-left: auto; }
.lien-visite {
    display: inline-block;
    color: var(--texte-2);
    font-size: .82rem;
    margin-bottom: .5rem;
}
.lien-visite:hover { color: var(--accent); text-decoration: none; }

.visite-fond { position: fixed; inset: 0; z-index: 400; }
.visite-trou {
    position: fixed;
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(3, 7, 15, .72);
    transition: all .25s ease;
    pointer-events: none;
}
.visite-bulle {
    position: fixed;
    width: min(360px, calc(100vw - 24px));
    background: var(--fond-2);
    border: 1px solid var(--accent-fonce);
    border-radius: var(--rayon);
    box-shadow: 0 10px 34px rgba(0, 0, 0, .6);
    padding: .9rem 1.1rem;
    z-index: 401;
}
.visite-etape { color: var(--accent); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.visite-bulle h3 { margin: .25rem 0 .35rem; font-size: 1.02rem; }
.visite-bulle p { margin: 0 0 .8rem; color: var(--texte-2); font-size: .88rem; }
.visite-boutons { display: flex; justify-content: space-between; gap: .6rem; }

/* --- Icônes SVG & finitions (GMAO_02.md phase 12) ------------------------------- */
.ico-svg { display: inline-block; vertical-align: -.18em; flex-shrink: 0; }
.ico-rouge { color: var(--rouge); }
.ico-vert  { color: var(--vert); }
.sidebar nav .ico { display: inline-flex; align-items: center; justify-content: center; }
.logo .logo-mark { vertical-align: -.32em; margin-right: .15rem; }
.bandeau-demo .ico-svg { vertical-align: -.22em; }
.login-carte-icone { color: var(--accent); line-height: 1; }
.assistant-bouton { color: #ecfeff; display: flex; align-items: center; justify-content: center; }
.tuile-valeur .ico-svg { vertical-align: -.12em; color: var(--accent); }

/* Scrollbars sombres (les barres claires du navigateur juraient sur le thème) */
* { scrollbar-width: thin; scrollbar-color: var(--bordure) var(--fond); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--fond); }
::-webkit-scrollbar-thumb { background: var(--bordure); border-radius: 5px; border: 2px solid var(--fond); }
::-webkit-scrollbar-thumb:hover { background: var(--fond-3); }

/* Focus clavier homogène */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Accessibilité : figer toutes les animations si l'utilisateur le demande */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* --- Impression (rapports, phase 7) -------------------------------------------- */
@media print {
    .sidebar, .bandeau-demo, .btn, #toasts { display: none !important; }
    body { background: #fff; color: #000; }
    .carte { border-color: #999; break-inside: avoid; }
}
