/* Lecteur UART PS5 : thème sombre Foxchip. Aucune ressource externe. */

:root {
    color-scheme: dark;
    --etat-veille: #60a5fa;
    --etat-allume: #f97316;
    --a-relever: #94a3b8;
    --panne: #ff0000;
    --point: #ffd200;
    --carte-mesure: #0b1222;
    --carte-mesure-bord: #334155;
    --fond0: #050714;
    --fond1: #0a0f24;
    --fond2: #0f1530;
    --surface: #151b36;
    --surface2: #1e2442;
    --surface3: #282f50;
    --bordure: #1e2542;
    --bordure-forte: #323b60;
    --texte: #f1f5fc;
    --attenue: #97a3c4;
    --accent: #7c5cff;
    --accent-survol: #8e72ff;
    --accent-appui: #684ae8;
    --accent-clair: #b794ff;
    --accent-doux: #282360;
    --cyan: #22d3ee;
    --ok: #10b981;
    --attention: #f59e0b;
    --critique: #f87171;
    --critique-fort: #ef4444;
    --attention-fond: #342816;
    --ok-fond: #0d2c2e;
    --critique-fond: #381622;
    --cible: 40px;
    --police: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: var(--fond1);
    color: var(--texte);
    font: 14px/1.4 var(--police);
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.ico {
    width: 18px;
    height: 18px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ---------------------------------------------------------------- en-tête */

.entete {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: 48px;
    padding: 0 16px;
    background: var(--fond0);
    border-bottom: 1px solid var(--bordure);
}

.marque { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { width: 32px; height: 32px; flex: none; }
.lien-logo { display: inline-flex; flex: none; border-radius: 8px; transition: transform .15s ease, filter .15s ease; }
.lien-logo:hover { filter: brightness(1.2); transform: scale(1.06); }
.lien-logo:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.logo-fond { fill: #0b223a; }
.logo-cyan { fill: #4fd1ff; }
.logo-blanc { fill: #fff; }
/* En-tête identique sur toutes les pages du site : 48 px, logo 32 px à 16 px du bord, titre 18 px. */
.entete h1 { margin: 0; font: 600 18px/1.2 var(--police); white-space: nowrap; }
.outils { display: flex; gap: 8px; }

/* ---------------------------------------------------------------- boutons et champs */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--cible);
    padding: 0 14px;
    border: 1px solid var(--bordure-forte);
    border-radius: 8px;
    background: var(--surface2);
    color: var(--texte);
    font: inherit;
    font-weight: 500;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.btn:hover:not(:disabled) { background: var(--surface3); }
.btn:active:not(:disabled) { background: var(--bordure-forte); }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible, input:focus-visible, select:focus-visible, tr:focus-visible, .journal:focus-visible {
    outline: 2px solid var(--accent-clair);
    outline-offset: 2px;
}
.btn.primaire { background: var(--accent-appui); border-color: var(--accent); }
.btn.primaire:hover:not(:disabled) { background: var(--accent); }
.btn.danger { border-color: var(--critique-fort); color: var(--critique); }
.btn.danger:hover:not(:disabled) { background: var(--critique-fond); }
.btn.discret { background: transparent; border-color: transparent; color: var(--attenue); }
.btn.discret:hover:not(:disabled) { background: var(--surface2); color: var(--texte); }
.btn.lien { background: transparent; border-color: transparent; color: var(--cyan); }
.btn.lien:hover:not(:disabled) { background: var(--surface); text-decoration: underline; }
.btn.bascule[aria-pressed="true"] { background: var(--accent-doux); border-color: var(--accent); color: var(--accent-clair); }
.zones { display: inline-flex; gap: 4px; }
.btn.btn-zone { width: 44px; padding: 0; }
.btn.rond { width: 40px; min-height: 40px; padding: 0; border-radius: 50%; background: rgba(15, 21, 48, .88); }

input[type="text"], select {
    min-height: var(--cible);
    padding: 0 10px;
    border: 1px solid var(--bordure-forte);
    border-radius: 8px;
    background: var(--surface);
    color: var(--texte);
    font: inherit;
}
input[type="text"] { width: 190px; }
select { max-width: 100%; }
input:disabled { opacity: .5; }

.etiq { color: var(--attenue); }
.champ { display: inline-flex; align-items: center; gap: 8px; }
.champ.ligne { display: flex; flex: 1; min-width: 160px; }
.champ.ligne input { flex: 1; width: auto; min-width: 0; }

/* ---------------------------------------------------------------- disposition */

#app {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px 8px;
}

.onglets { display: none; }

.panneau-lecture { display: flex; flex-direction: column; gap: 8px; flex: none; }
.rang { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.rang #nom-module { font-weight: 600; }
.etat { color: var(--attenue); }
.etat.ok { color: var(--ok); font-weight: 600; }
.aide-carte { color: var(--attenue); }

.message {
    flex: none;
    margin: 0;
    padding: 8px 12px;
    min-height: 40px;
    border-left: 3px solid var(--bordure-forte);
    border-radius: 6px;
    background: var(--fond2);
    font-size: 15px;
    overflow-wrap: anywhere;
}
.message:empty { visibility: hidden; }
.message.ok { border-left-color: var(--ok); color: #6ee7b7; }
.message.err { border-left-color: var(--critique-fort); color: var(--critique); background: var(--critique-fond); }
.message.attention { border-left-color: var(--attention); color: var(--attention); background: var(--attention-fond); }

.principal {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(340px, 1fr);
    gap: 12px;
}

.panneau-carte, .panneau-erreurs { display: flex; flex-direction: column; gap: 8px; min-width: 0; min-height: 0; }

.barre-carte { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.faces { display: inline-flex; gap: 4px; }
.legende-carte { color: var(--attenue); flex: 1 1 100%; min-width: 0; white-space: normal; overflow-wrap: anywhere; }
.legende-carte:empty { display: none; }
.case { display: inline-flex; align-items: center; gap: 6px; color: var(--attenue); min-height: var(--cible); }
.case input { width: 18px; height: 18px; }

.vue {
    position: relative;
    flex: 1;
    min-height: 120px;
    border: 1px solid var(--bordure);
    border-radius: 10px;
    background: var(--fond0);
    overflow: hidden;
}
.vue canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.vue canvas.saisie { cursor: grabbing; }

/* Légende sous la photo : mêmes signes que le dessin. */
.legende-couleurs {
    flex: none;
    display: flex;
    flex-wrap: wrap;
    gap: 2px 14px;
    margin: 0;
    padding: 0 2px;
    list-style: none;
    color: var(--attenue);
    font-size: 13px;
    line-height: 1.5;
}
.legende-couleurs li { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 16px; height: 14px; flex: none; box-sizing: border-box; border-radius: 3px; }
.sw-zone { border: 2px solid var(--panne); border-radius: 0; }
.sw-point { width: 12px; height: 12px; margin: 0 2px; border: 1.5px solid #000; border-radius: 50%; background: var(--point); }
.sw-veille, .sw-allume { background: var(--carte-mesure); border: 1px solid var(--carte-mesure-bord); border-left-width: 4px; }
.sw-veille { border-left-color: var(--etat-veille); }
.sw-allume { border-left-color: var(--etat-allume); }
.sw-relever { border: 1.5px dashed var(--a-relever); }
.sw-premier { width: 22px; background: var(--carte-mesure); border: 1.5px solid var(--panne); border-radius: 4px; }
.zooms { position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 6px; }

/* ---------------------------------------------------------------- liste et détail */

.liste-cadre {
    flex: 0 1 auto;
    max-height: 46%;
    min-height: 92px;
    overflow: auto;
    border: 1px solid var(--bordure);
    border-radius: 10px;
    background: var(--fond2);
}
.liste { width: 100%; border-collapse: collapse; }
.liste th {
    position: sticky;
    top: 0;
    padding: 8px 10px;
    background: var(--surface);
    color: var(--attenue);
    font-weight: 500;
    text-align: left;
    border-bottom: 1px solid var(--bordure-forte);
}
.liste td { padding: 0 10px; height: var(--cible); border-bottom: 1px solid var(--bordure); }
.liste tbody tr { cursor: pointer; }
.liste tbody tr:hover { background: var(--surface); }
.liste tbody tr[aria-selected="true"] { background: var(--accent-doux); box-shadow: inset 3px 0 0 var(--accent); }
.liste tr.absent td { color: var(--attenue); }
.liste tr.alteree td { background: var(--attention-fond); }
.liste .num { width: 44px; }
.liste .code { width: 100px; font-family: Consolas, "Cascadia Mono", monospace; }
.liste .temp { width: 92px; white-space: nowrap; }
.aide { color: var(--attenue); margin: 0; }
.aide.vide { padding: 14px; }

.detail-cadre {
    flex: 1;
    min-height: 110px;
    overflow: auto;
    padding: 12px 14px;
    border: 1px solid var(--bordure);
    border-radius: 10px;
    background: var(--fond2);
}
.detail h3 { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
.detail p { margin: 0 0 8px; overflow-wrap: anywhere; }
.detail .titre-liste { margin-bottom: 4px; font-weight: 600; }
.detail .premier { padding: 4px 8px; border-left: 3px solid var(--panne); border-radius: 4px; background: var(--fond0); }
.a-mesurer { margin: 0 0 8px; }
.mesure {
    margin: 0 0 6px;
    padding: 5px 8px 5px 10px;
    border: 1px solid var(--carte-mesure-bord);
    border-left: 4px solid var(--a-relever);
    border-radius: 6px;
    background: var(--carte-mesure);
}
.mesure.etat-veille { border-left-color: var(--etat-veille); }
.mesure.etat-allume { border-left-color: var(--etat-allume); }
.mesure.a-relever { border-style: dashed; border-color: var(--a-relever); }
.mesure-titre { font-weight: 600; overflow-wrap: anywhere; }
.mesure-titre strong { font-weight: 700; }
.mesure-ligne { color: #e2e8f0; }
.mesure-vide { color: var(--a-relever); }
.mesure-origine { margin-top: 2px; color: var(--a-relever); font-size: 12px; }
.detail .mesures { margin: 0 0 8px; padding-left: 20px; }
.detail .attention { color: var(--attention); }
.detail .brut { color: var(--attenue); font-family: Consolas, "Cascadia Mono", monospace; font-size: 12px; }
.liens { flex: none; display: flex; flex-wrap: wrap; gap: 8px; }
.liens .btn.lien { padding-left: 0; white-space: normal; text-align: left; }

/* ---------------------------------------------------------------- terminal et pied */

.terminal { display: none; flex: none; height: 190px; flex-direction: column; gap: 8px; }
#app[data-terminal="1"] .terminal { display: flex; }
.journal {
    flex: 1;
    min-height: 0;
    margin: 0;
    padding: 8px 10px;
    overflow: auto;
    border: 1px solid var(--bordure);
    border-radius: 10px;
    background: var(--fond0);
    font: 12px/1.45 Consolas, "Cascadia Mono", monospace;
    white-space: pre;
}
.commande { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }

.barre-etat {
    flex: none;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 2px 16px;
    min-height: 36px;
    background: var(--fond0);
    border-top: 1px solid var(--bordure);
    color: var(--attenue);
    font-size: 13px;
}
.barre-etat .etat-base { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barre-etat .etat-base.alerte, .etat-serveur { color: var(--attention); }
.barre-etat .btn { min-height: 40px; }

.presse-papiers { position: fixed; left: -9999px; top: 0; }

/* ---------------------------------------------------------------- dialogues */

.voile {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background: rgba(5, 7, 20, .8);
}
.dialogue {
    width: 100%;
    max-width: 540px;
    max-height: 100%;
    overflow: auto;
    padding: 16px 20px;
    border: 1px solid var(--bordure-forte);
    border-radius: 12px;
    background: var(--fond1);
    box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
}
.dialogue.large { max-width: 720px; }
.choix-cartes { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-bottom: 12px; }
.choix-carte { justify-content: flex-start; min-height: 44px; }
.dialogue h2 { margin: 0 0 10px; font-size: 18px; font-weight: 600; }
.dialogue p { margin: 0 0 10px; }
.dialogue .sous-titre { color: var(--accent-clair); font-weight: 600; margin-bottom: 4px; }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.dialogue .champ.ligne { margin-bottom: 10px; }

.depannage { margin: 0 0 8px; padding: 0 12px; border: 1px solid var(--bordure); border-radius: 8px; background: var(--fond2); }
.depannage summary { display: flex; align-items: center; min-height: var(--cible); color: var(--accent-clair); font-weight: 600; cursor: pointer; }
.depannage[open] { padding-bottom: 8px; }
.depannage .aide { margin: 0 0 8px; }
.depannage .pas { margin: 0 0 8px; padding-left: 20px; }
.depannage .pas li { margin-bottom: 4px; }
.depannage .tensions-cadre { background: var(--fond1); }
.source-depannage { margin-top: 4px; }
.tensions-cadre { overflow-x: auto; margin: 0 0 8px; border: 1px solid var(--bordure); border-radius: 8px; background: var(--fond2); }
.tensions { width: 100%; border-collapse: collapse; font-size: 14px; }
.tensions th { padding: 6px 10px; color: var(--attenue); font-weight: 500; text-align: left; border-bottom: 1px solid var(--bordure-forte); white-space: nowrap; }
.tensions td { padding: 6px 10px; border-bottom: 1px solid var(--bordure); vertical-align: top; }
.tensions tbody tr:last-child td { border-bottom: 0; }
.tensions td:first-child { white-space: nowrap; }
.tensions td.v { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--accent-clair); }
.tensions td.code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

.plan { position: relative; height: clamp(170px, 34vh, 320px); margin: 8px 0; border-radius: 8px; overflow: hidden; }
.plan canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.legende { margin: 0 0 4px; }
.role { display: inline-block; width: 48px; font-weight: 600; }
.role-tx { color: var(--accent-clair); }
.role-rx { color: var(--cyan); }
.role-gnd { color: var(--texte); }

.faits { margin: 10px 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; }
.faits dt { color: var(--attenue); }
.faits dd { margin: 0; overflow-wrap: anywhere; }
.alerte-3v3 { padding: 8px 12px; border-left: 3px solid var(--attention); border-radius: 6px; background: var(--attention-fond); color: var(--attention); }

.schema { display: block; width: 100%; max-width: 460px; margin: 4px auto 8px; }
.schema text { font-family: var(--police); }
.sch-boite { fill: var(--fond2); stroke: var(--bordure-forte); }
.sch-titre { fill: var(--attenue); font-size: 13px; font-weight: 600; }
.sch-pin { fill: var(--texte); font-size: 14px; font-weight: 600; }
.sch-note { fill: var(--attenue); font-size: 12px; }
.sch-tx { --c: var(--accent-clair); }
.sch-rx { --c: var(--cyan); }
.sch-gnd { --c: var(--texte); }
.sch-libre { --c: #606c8e; }

.photo-bloc { margin: 4px 0 8px; }
.photo-cadre { position: relative; width: 100%; margin: 0 auto; border-radius: 8px; overflow: hidden; background: var(--fond2); }
.photo-img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.photo-calque { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.photo-calque text { font-family: var(--police); fill: var(--texte); }
.ph-nom { font-weight: 700; }
.ph-etiq { fill: rgba(5, 7, 20, .88); stroke: var(--c); stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
.ph-anneau { fill: none; stroke: var(--c); stroke-width: 3px; vector-effect: non-scaling-stroke; }
.ph-trait { stroke: var(--c); stroke-width: 2px; vector-effect: non-scaling-stroke; }
.photo-legende { margin: 6px 0 0; color: var(--attenue); text-align: center; }
.sch-fil { stroke: var(--c); stroke-width: 3; stroke-linecap: round; }
.sch-fil.sch-libre { stroke-dasharray: 5 5; }
.sch-pastille { fill: var(--c); }

/* ---------------------------------------------------------------- petits écrans (4,5 pouces tactile, 800 x 480) */

@media (pointer: coarse) {
    :root { --cible: 44px; }
}

@media (max-height: 800px) {
    .terminal { height: 120px; }
}

@media (max-width: 900px) {
    :root { --cible: 44px; }
    body { font-size: 15px; }
    #app { gap: 6px; padding: 8px 12px 6px; }

    .onglets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; flex: none; }
    .onglets button {
        display: inline-flex; align-items: center; justify-content: center; gap: 8px;
        min-height: 44px; border: 1px solid var(--bordure-forte); border-radius: 8px;
        background: var(--surface); color: var(--attenue); font: inherit; font-weight: 500; cursor: pointer;
    }
    .onglets button[aria-selected="true"] { background: var(--accent-doux); border-color: var(--accent); color: var(--texte); }
    .onglets button:focus-visible { outline: 2px solid var(--accent-clair); outline-offset: 2px; }

    .panneau-lecture, .principal, .panneau-carte, .panneau-erreurs, .terminal { display: none; }
    #app[data-onglet="lecture"] .panneau-lecture { display: flex; flex: 1; min-height: 0; overflow: auto; }
    #app[data-onglet="carte"] .principal, #app[data-onglet="erreurs"] .principal { display: flex; flex: 1; min-height: 0; }
    #app[data-onglet="carte"] .panneau-carte, #app[data-onglet="erreurs"] .panneau-erreurs { display: flex; flex: 1; min-width: 0; }
    #app[data-onglet="terminal"] .terminal, #app[data-terminal="1"][data-onglet="terminal"] .terminal { display: flex; flex: 1; height: auto; min-height: 0; }
    #app[data-terminal="1"]:not([data-onglet="terminal"]) .terminal { display: none; }

    .message { max-height: 4.6em; min-height: 0; overflow: auto; padding: 6px 10px; font-size: 14px; }
    .liste-cadre { max-height: 38%; }
    #app:not([data-onglet="lecture"]) .message { max-height: 2.9em; padding: 3px 10px; }
    .legende-carte { display: none; }
    .barre-etat { min-height: 28px; padding: 0 12px; }
    #b-terminal { display: none; }
    .barre-carte .btn { padding: 0 10px; }
    .dialogue { padding: 12px 14px; }
    .plan { height: clamp(150px, 32vh, 260px); }
}

@media (max-width: 900px) {
    .legende-couleurs { gap: 0 10px; font-size: 12px; line-height: 1.4; }
}

@media (max-width: 560px) {
    .barre-carte .lib { display: none; }
    .barre-carte #b-entiere .lib, .barre-carte #b-souder .lib { display: inline; }
    input[type="text"] { width: 150px; }
}

@media (prefers-reduced-motion: reduce) {
    * { scroll-behavior: auto !important; }
}

/* ---------------------------------------------------------------- rapport : aperçu A4 et impression */

.apercu {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    flex-direction: column;
    background: var(--fond0);
}
.apercu-barre {
    flex: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 16px;
    background: var(--fond1);
    border-bottom: 1px solid var(--bordure);
}
.apercu-etat { flex: 1 1 240px; align-self: center; margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.apercu-etat:empty { display: none; }
.apercu-etat.ok { color: var(--ok); }
.apercu-etat.err { color: var(--critique); }
.feuilles { flex: 1; min-height: 0; overflow: auto; padding: 16px; }
.feuille {
    box-sizing: border-box;
    width: 210mm;
    max-width: 100%;
    min-height: 297mm;
    margin: 0 auto;
    padding: 12mm;
    background: #fff;
    color: #14182b;
    font: 10.5pt/1.4 var(--police);
    box-shadow: 0 6px 30px rgba(0, 0, 0, .55);
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}
.feuille h2, .feuille h3 { margin: 0; color: #14182b; }
.r-entete { display: flex; align-items: center; gap: 14px; padding-bottom: 10px; border-bottom: 2px solid #14182b; }
.logo-rapport { width: 16mm; height: 16mm; flex: none; }
.r-atelier { margin: 0; font-size: 11pt; font-weight: 600; color: #4a3fb0; }
.feuille h2 { font-size: 16pt; font-weight: 600; }
.r-infos { display: grid; grid-template-columns: max-content 1fr; gap: 3px 16px; margin: 12px 0; }
.r-infos dt { color: #555d7a; }
.r-infos dd { margin: 0; font-weight: 600; }
.r-resume { margin: 0 0 12px; padding: 8px 10px; background: #eef0fb; border-left: 3px solid #4a3fb0; }
.r-vide { font-size: 12pt; font-weight: 600; }
.r-attention { color: #9a1c1c; font-weight: 600; }
.r-tab { width: 100%; border-collapse: collapse; margin-bottom: 12px; font-size: 9.5pt; }
.r-tab thead { display: table-header-group; }
.r-tab th { white-space: nowrap; text-align: left; padding: 4px 6px; background: #e6e9f5; border: 1px solid #aab0c8; }
.r-tab td { padding: 4px 6px; border: 1px solid #aab0c8; vertical-align: top; }
.r-tab tr { break-inside: avoid; page-break-inside: avoid; }
.r-tab .num { width: 9mm; text-align: center; font-weight: 600; }
.r-tab .code { font-family: Consolas, "Cascadia Mono", monospace; white-space: nowrap; }
.r-nb { white-space: nowrap; }
.r-petit { font-size: 8.5pt; color: #3b4260; }
.r-tab .r-mesures { min-width: 46mm; }
.r-relever { margin: 0 0 10px; font-weight: 600; }
.r-mesures .mesure { margin: 0 0 4px; padding: 2px 5px 2px 7px; border: 1px solid #aab0c8; border-left: 3px solid #7b869f; border-radius: 0; background: #fff; }
.r-mesures .mesure.etat-veille { border-left-color: #1d6fd6; }
.r-mesures .mesure.etat-allume { border-left-color: #d9600a; }
.r-mesures .mesure.a-relever { border-style: dashed; }
.r-mesures .mesure-titre { color: #14182b; }
.r-mesures .mesure-ligne { color: #14182b; }
.r-mesures .mesure-vide, .r-mesures .mesure-origine { color: #555d7a; font-size: 8pt; }
.r-fig { margin: 0 0 12px; break-inside: avoid; page-break-inside: avoid; }
.r-fig img { display: block; width: auto; height: auto; max-width: 100%; max-height: 100mm; margin: 0 auto; border: 1px solid #aab0c8; }
.r-fig figcaption { margin-top: 3px; font-size: 8.5pt; color: #3b4260; }
.r-sonde-ligne { margin: 0 0 3px; }
.r-titre-bloc { margin: 12px 0 4px; font-size: 11pt; font-weight: 600; break-after: avoid; }
.r-brut { margin: 0; padding: 6px 8px; background: #f3f4f9; border: 1px solid #d0d4e4; font: 7.5pt/1.35 Consolas, "Cascadia Mono", monospace; white-space: pre-wrap; overflow-wrap: anywhere; break-inside: avoid; }
.r-obs { display: block; width: 100%; min-height: 28mm; padding: 6px 8px; border: 1px solid #aab0c8; border-radius: 0; background: #fff; color: #14182b; font: inherit; resize: vertical; }
.r-signature { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 16px; break-inside: avoid; }
.r-signature p { margin: 0; padding-bottom: 14mm; border-bottom: 1px solid #14182b; }

@media screen and (max-width: 900px) {
    .apercu-barre .btn { min-height: 44px; }
    .feuilles { padding: 8px; }
    .feuille { padding: 6mm; min-height: 0; font-size: 9.5pt; }
    .r-infos { grid-template-columns: 1fr; gap: 0; }
    .r-infos dd { margin-bottom: 4px; }
}

@page {
    size: A4 portrait;
    margin: 12mm;
    @bottom-right { content: "Page " counter(page) " / " counter(pages); font: 8pt "Segoe UI", sans-serif; color: #555d7a; }
}

@media print {
    :root { color-scheme: light; }
    html, body { height: auto; overflow: visible; background: #fff; }
    body > *:not(.apercu) { display: none !important; }
    .apercu { position: static; display: block; background: #fff; }
    .apercu-barre { display: none; }
    .feuilles { overflow: visible; padding: 0; }
    .feuille { width: auto; max-width: none; min-height: 0; margin: 0; padding: 0; box-shadow: none; }
    .r-obs { resize: none; }
}

/* ---------------------------------------------------------------- sonde de température (fenêtre facultative) */

.pastille { margin-left: 2px; padding: 1px 8px; border-radius: 999px; background: var(--accent-doux); color: var(--accent-clair); font-weight: 600; font-variant-numeric: tabular-nums; }
.dlg-sonde { max-width: 780px; }
.sonde-commandes { margin: 6px 0 4px; }
.sonde-etat { min-height: 1.4em; margin: 0 0 6px; }
.sonde-etat.erreur { color: var(--critique); }
.sonde-voies { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
.voie { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 8px 10px; border: 1px solid var(--bordure); border-left: 4px solid var(--c); border-radius: 8px; background: var(--fond2); }
.voie-1 { --c: #fb923c; }
.voie-2 { --c: #60a5fa; }
.voie-3 { --c: #34d399; }
.voie-tete { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.voie-pastille { width: 10px; height: 10px; flex: none; border-radius: 50%; background: var(--c); }
.voie-composant { width: 100%; min-width: 0; }
.voie-temp { font-size: 26px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.voie-temp.voie-vide { color: var(--attenue); }
.voie-max { min-height: 1.4em; color: var(--attenue); font-variant-numeric: tabular-nums; }
.voie-defaut { color: var(--critique); font-size: 13px; }
.voie-defaut:empty { display: none; }
.sonde-courbe { position: relative; height: clamp(120px, 24vh, 200px); margin-bottom: 8px; border: 1px solid var(--bordure); border-radius: 8px; overflow: hidden; background: var(--fond2); }
.sonde-courbe canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.sonde-aide { padding: 0 12px 4px; border: 1px solid var(--bordure); border-radius: 8px; background: var(--fond2); }
.sonde-aide summary { display: flex; align-items: center; gap: 8px; min-height: var(--cible); color: var(--cyan); font-weight: 600; cursor: pointer; }
.sonde-aide .pas { margin: 0 0 10px; padding-left: 20px; }
.sonde-aide .pas li { margin-bottom: 4px; }
.sonde-tab { width: 100%; margin: 0 0 8px; border-collapse: collapse; }
.sonde-tab th, .sonde-tab td { padding: 4px 10px; border: 1px solid var(--bordure-forte); text-align: left; }
.sonde-tab th { background: var(--surface); color: var(--attenue); font-weight: 600; }
.aide-ligne { color: var(--attenue); }

@media (max-width: 900px) {
    .voie-temp { font-size: 22px; }
    .sonde-courbe { height: clamp(100px, 22vh, 160px); }
}
@media (max-width: 560px) {
    .sonde-voies { grid-template-columns: 1fr; }
}

/* Bouton Retour du bandeau : le même sur toutes les pages, juste après le titre. */
.retour-menu { display: inline-flex; align-items: center; gap: 6px; flex: none; height: 32px; padding: 0 12px; margin: 0 auto 0 0; border: 1px solid rgba(148, 163, 184, .35); border-radius: 8px; color: inherit; font-size: 14px; font-weight: 600; line-height: 1; text-decoration: none; white-space: nowrap; }
.retour-menu:hover, .retour-menu:focus-visible { background: rgba(148, 163, 184, .14); }
.retour-menu svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media print { .retour-menu { display: none; } }
.retour-menu.lien-cartes { margin: 0; }
@media print { .lien-cartes { display: none; } }
