/* Charte inspirée du site OBO Bettermann (obo.fr) : orange OBO, anthracite, gris, boutons arrondis.
 * Logo : déposer le fichier officiel fourni par OBO dans web/logo.svg (ou web/logo.png) ; affiché s'il existe. */
:root {
  --obo-orange: #f39b00; --obo-orange-fonce: #d98a00; --obo-orange-clair: #fff3e0;
  --anthracite: #282a31; --gris: #939498; --gris-clair: #f5f5f5; --gris-bleu: #e4ebed; --ardoise: #7694a4;
  --bleu: #0045a5; --bord: #e5e7eb; --blanc: #ffffff;
  --ok: #2e7d32; --alerte: #f39b00; --bloquant: #c62828;
  --fond: var(--gris-clair); --panneau: var(--blanc); --texte: var(--anthracite); --discret: var(--gris);
  --accent: var(--obo-orange); --selection: var(--bleu);
  font-family: "Nimbus Sans", "Nimbus Sans L", Arial, "Helvetica Neue", sans-serif; font-size: 14px; color: var(--texte);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--fond); }
body { display: flex; flex-direction: column; }

/* en-tête */
header { display: flex; align-items: center; gap: 10px; padding: 10px 18px; background: var(--blanc);
  border-bottom: 3px solid var(--obo-orange); flex-wrap: wrap; }
.marque { display: flex; align-items: center; gap: 12px; margin-right: 10px; }
.marque img { height: 34px; max-width: 180px; object-fit: contain; display: block; }
.marque img + .titre { padding-left: 12px; border-left: 1px solid var(--bord); }
.marque .titre { display: flex; flex-direction: column; line-height: 1.1; }
.marque .titre b { font-size: 17px; letter-spacing: .2px; color: var(--anthracite); }
.marque .titre span { font-size: 11px; color: var(--gris); text-transform: uppercase; letter-spacing: 1.2px; }
.nom { font-weight: 700; min-width: 240px; }
.barre { display: flex; align-items: center; gap: 8px; padding: 8px 18px; background: var(--blanc);
  border-bottom: 1px solid var(--bord); flex-wrap: wrap; }
.sep { width: 1px; height: 24px; background: var(--bord); margin: 0 4px; }
.info { color: var(--gris); font-size: 12px; }
.aide { color: var(--ardoise); font-size: 12px; margin-left: auto; }

/* boutons : style « pilule » OBO */
button { font: inherit; padding: 6px 16px; border: 1px solid var(--bord); background: var(--blanc); color: var(--anthracite);
  border-radius: 9999px; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
button:hover:not(:disabled) { border-color: var(--obo-orange); color: var(--obo-orange-fonce); }
button:disabled { opacity: .4; cursor: default; }
button.actif { background: var(--anthracite); color: var(--blanc); border-color: var(--anthracite); }
button.actif:hover:not(:disabled) { color: var(--blanc); }
button.primaire { background: var(--obo-orange); color: var(--blanc); border-color: var(--obo-orange); font-weight: 700; }
button.primaire:hover:not(:disabled) { background: var(--obo-orange-fonce); border-color: var(--obo-orange-fonce); color: var(--blanc); }
input, select { font: inherit; padding: 5px 8px; border: 1px solid var(--bord); border-radius: 4px; background: var(--blanc); color: var(--texte); }
input:focus, select:focus { outline: 2px solid var(--obo-orange-clair); border-color: var(--obo-orange); }
input[type=checkbox] { accent-color: var(--obo-orange); }
label { display: inline-flex; align-items: center; gap: 6px; }
label.case { gap: 6px; }

main { flex: 1; display: flex; min-height: 0; }
#zone { flex: 1; position: relative; overflow: hidden; background: var(--gris-bleu); display: flex; flex-direction: column; }
#plan { width: 100%; flex: 1; min-height: 0; display: block; cursor: default; user-select: none; }
#plan.mode-trace, #plan.mode-calage { cursor: crosshair; }

/* panneau latéral */
aside { width: 400px; background: var(--panneau); border-left: 1px solid var(--bord); display: flex; flex-direction: column; min-height: 0; }
.onglets { display: flex; border-bottom: 1px solid var(--bord); background: var(--blanc); }
.onglets button { flex: 1; border: none; border-radius: 0; background: none; padding: 12px 6px; color: var(--gris);
  border-bottom: 3px solid transparent; font-size: 13px; }
.onglets button:hover:not(:disabled) { color: var(--anthracite); }
.onglets button.actif { color: var(--anthracite); background: none; border-bottom-color: var(--obo-orange); font-weight: 700; }
.onglet { padding: 14px; overflow: auto; flex: 1; }
.onglet label { display: flex; flex-direction: column; align-items: stretch; gap: 3px; margin-bottom: 8px; font-size: 12px; color: var(--gris); }
.onglet label.case { flex-direction: row; align-items: center; color: var(--texte); font-size: 14px; }
.ligne { display: flex; gap: 8px; } .ligne > * { flex: 1; }
h3 { font-size: 12px; margin: 16px 0 6px; text-transform: uppercase; letter-spacing: 1px; color: var(--anthracite); }
.vide { color: var(--gris); }

table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { text-align: left; color: var(--gris); font-weight: 700; padding: 6px 3px; border-bottom: 2px solid var(--anthracite); }
td { padding: 4px 3px; border-bottom: 1px solid var(--bord); vertical-align: top; }
tbody tr:hover td { background: var(--gris-clair); }
.cables input, .cables select { width: 100%; padding: 2px 4px; font-size: 12px; }
.cables td:nth-child(2), .cables td:nth-child(3), .cables td:nth-child(4) { width: 52px; }
.cables td:nth-child(5) { width: 72px; } .cables td:last-child { width: 24px; }
.cables button { padding: 0 6px; border: none; color: var(--gris); border-radius: 4px; }
.nomenclature td:nth-child(n+3) { text-align: right; white-space: nowrap; }
.nomenclature td:first-child { color: var(--gris); white-space: nowrap; }

.resultat { margin-top: 14px; padding: 12px; border-radius: 6px; background: var(--gris-clair); border-left: 4px solid var(--obo-orange);
  font-size: 12px; line-height: 1.6; }
.resultat b { font-size: 13px; }
.jauge { height: 6px; background: var(--gris-bleu); border-radius: 3px; margin: 2px 0 6px; overflow: hidden; }
.jauge > div { height: 100%; background: var(--ok); }
.jauge.haute > div { background: var(--obo-orange); }

#listeAlertes { list-style: none; padding: 0; margin: 0; }
#listeAlertes li { padding: 8px 10px; border-left: 4px solid var(--alerte); background: var(--obo-orange-clair); margin-bottom: 6px;
  font-size: 12px; cursor: pointer; border-radius: 0 4px 4px 0; }
#listeAlertes li.bloquant { border-color: var(--bloquant); background: #fdecec; }
#listeAlertes li.info { border-color: var(--ardoise); background: var(--gris-bleu); }
#listeAlertes .code { color: var(--gris); margin-right: 4px; font-weight: 700; }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--anthracite); color: var(--blanc);
  padding: 10px 18px; border-radius: 9999px; opacity: 0; transition: opacity .2s; pointer-events: none; border-left: 4px solid var(--obo-orange); }
#toast.visible { opacity: .96; }

/* feuilles (niveaux) */
.feuilles { display: flex; gap: 4px; padding: 6px 12px 0; background: var(--gris-bleu); border-bottom: 1px solid #c5d9de; overflow-x: auto; }
.feuilles button { border-radius: 6px 6px 0 0; border-bottom: none; background: #f4f7f8; padding: 6px 16px; white-space: nowrap; color: var(--gris); }
.feuilles button.actif { background: var(--blanc); color: var(--anthracite); border-color: #c5d9de; font-weight: 700;
  box-shadow: inset 0 3px 0 var(--obo-orange); }
.feuilles .fermer { margin-left: 10px; color: var(--gris); }
.feuilles .ajout { background: transparent; border-style: dashed; color: var(--ardoise); }

/* réseaux */
.pastille { display: inline-block; width: 22px; height: 5px; border-radius: 3px; background: var(--gris); }
.reseau { border: 1px solid var(--bord); border-radius: 6px; padding: 10px; margin-bottom: 10px; }
.reseau .tete { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.reseau .tete input[type=text] { flex: 1; font-weight: 700; }
.reseau .tete button { padding: 2px 9px; }
.reseau input[type=color] { width: 36px; height: 30px; padding: 1px; border-radius: 4px; }
.reseau .ligne label { margin-bottom: 0; }
.reseau .usage { font-size: 11px; color: var(--gris); margin-top: 6px; }

/* plan */
.troncon { fill: none; stroke-linecap: round; stroke-linejoin: round; cursor: pointer; }   /* couleur = attribut (réseau) */
.troncon-zone { fill: none; stroke: transparent; cursor: pointer; }
.sommet { fill: #fff; stroke: #5b6472; }
.etiquette { font-family: Arial, sans-serif; fill: var(--texte); paint-order: stroke; stroke: #fff; stroke-linejoin: round; }
.saisie { fill: none; stroke: var(--obo-orange); stroke-dasharray: 6 4; }
.calage { stroke: var(--bleu); stroke-dasharray: 4 3; fill: none; }
.accroche { fill: none; stroke: var(--bleu); }
.halo { fill: none; stroke: var(--selection); stroke-opacity: .28; stroke-linecap: round; stroke-linejoin: round; }
/* Les éléments redessinés à chaque mouvement ne doivent pas capter la souris (sinon le double-clic se perd) */
#calqueFond, #calqueSaisie, #calqueLegende, .troncon, .sommet, .etiquette, .halo { pointer-events: none; }
#plan:not(.mode-selection) .troncon-zone { pointer-events: none; }
.feuilles button.actif:hover:not(:disabled), .onglets button.actif:hover:not(:disabled) { color: var(--anthracite); }

/* import DXF / DWG */
dialog#dlgCao { border: none; border-radius: 8px; padding: 0; width: 460px; max-width: 94vw; border-top: 4px solid var(--obo-orange);
  box-shadow: 0 12px 40px rgba(40, 42, 49, .3); }
dialog#dlgCao::backdrop { background: rgba(40, 42, 49, .45); }
dialog#dlgCao form { padding: 18px 20px; display: flex; flex-direction: column; gap: 8px; }
dialog#dlgCao h2 { margin: 0; font-size: 17px; }
dialog#dlgCao label:not(.case) { flex-direction: column; align-items: stretch; font-size: 12px; color: var(--gris); }
dialog#dlgCao .info { margin: 0; }
.titreCalques { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.titreCalques button { padding: 2px 10px; font-size: 12px; }
.calques { max-height: 300px; overflow: auto; border: 1px solid var(--bord); border-radius: 4px; padding: 4px 8px; }
.calques label { display: flex; gap: 8px; padding: 3px 0; font-size: 13px; }
.calques label span { flex: 1; }
.calques small { color: var(--gris); }
dialog#dlgCao .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* sélecteur de langue (à droite de l'en-tête) */
header .langue { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; color: var(--gris); }
header .langue select { border-radius: 9999px; padding: 5px 12px; cursor: pointer; color: var(--anthracite); }
header .langue:hover { color: var(--obo-orange-fonce); }
