:root {
  --fond: #f4f6f9; --panneau: #ffffff; --bord: #d9dee5; --texte: #1d2530; --doux: #66717f;
  --accent: #c2410c; --accent-clair: #fff1e8; --alerte: #b42318;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px; color: var(--texte);
}
* { box-sizing: border-box; }
body { margin: 0; height: 100vh; display: flex; flex-direction: column; background: var(--fond); }
header { display: flex; align-items: center; gap: 16px; padding: 8px 16px; background: #1d2530; color: #fff; }
.logo { font-weight: 800; font-size: 20px; letter-spacing: .5px; color: #fb923c; }
.nom-projet { background: transparent; border: 1px solid transparent; color: #fff; font-size: 15px; padding: 4px 6px; border-radius: 4px; min-width: 200px; }
.nom-projet:hover, .nom-projet:focus { border-color: #4b5563; outline: none; }
.actions { margin-left: auto; display: flex; gap: 8px; }
button { font: inherit; padding: 6px 12px; border-radius: 5px; border: 1px solid var(--bord); background: #fff; color: var(--texte); cursor: pointer; }
header button { background: #2d3746; border-color: #4b5563; color: #fff; }
button.primaire { background: var(--accent); border-color: var(--accent); color: #fff; }
button:hover { filter: brightness(1.08); }
button.petit { padding: 2px 8px; font-size: 12px; }

main { flex: 1; display: grid; grid-template-columns: 210px 1fr 320px; min-height: 0; }
aside { background: var(--panneau); overflow-y: auto; padding: 12px; }
.gauche { border-right: 1px solid var(--bord); }
.droite { border-left: 1px solid var(--bord); }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--doux); margin: 4px 0 8px; }
h3 { font-size: 13px; margin: 14px 0 6px; }

.bibliotheque { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 18px; }
.famille { border: 1px solid var(--bord); border-radius: 6px; padding: 8px 4px; text-align: center; font-size: 12px; background: #fff; cursor: pointer; }
.famille svg { width: 40px; height: 32px; display: block; margin: 0 auto 4px; }
.famille:hover { border-color: var(--accent); background: var(--accent-clair); }
.famille[disabled] { opacity: .45; cursor: not-allowed; background: #fafafa; }
.reperes { list-style: none; margin: 0; padding: 0; }
.reperes li { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 5px; cursor: pointer; }
.reperes li.actif { background: var(--accent-clair); outline: 1px solid var(--accent); }
.reperes .rep { font-weight: 700; min-width: 28px; }
.reperes .suppr { margin-left: auto; border: none; background: none; color: var(--doux); padding: 0 4px; }

.centre { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.onglets { display: flex; align-items: flex-end; gap: 2px; padding: 8px 8px 0; border-bottom: 1px solid var(--bord); overflow-x: auto; flex: none; }
.onglet { display: flex; align-items: center; gap: 6px; padding: 7px 8px 7px 12px; border: 1px solid var(--bord); border-bottom: none; border-radius: 6px 6px 0 0; background: #e9edf2; color: var(--doux); cursor: pointer; white-space: nowrap; margin-bottom: -1px; }
.onglet:hover { background: #f3f5f8; }
.onglet.actif { background: var(--fond); color: var(--texte); border-color: var(--bord); border-top: 2px solid var(--accent); padding-top: 6px; }
.onglet .rep { font-weight: 700; color: var(--texte); }
.onglet .fermer { border: none; background: none; padding: 0 4px; color: var(--doux); line-height: 1; }
.onglet .fermer:hover { color: var(--alerte); }
.onglet-plus { position: relative; }
.onglet-plus > button { border: 1px dashed var(--bord); border-bottom: none; border-radius: 6px 6px 0 0; background: transparent; padding: 6px 12px; color: var(--doux); margin-bottom: -1px; }
.menu { position: fixed; z-index: 10; background: #fff; border: 1px solid var(--bord); border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.12); padding: 4px; min-width: 180px; }
.menu button { display: block; width: 100%; text-align: left; border: none; padding: 6px 10px; }
.menu button:hover:not([disabled]) { background: var(--accent-clair); }
.menu button[disabled] { color: #a0a8b3; cursor: not-allowed; }
.onglets .vide { padding: 8px; }
.vues { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 8px; min-width: 0; min-height: 0; }
.vue { background: var(--panneau); border: 1px solid var(--bord); border-radius: 6px; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.vue-titre { font-size: 12px; color: var(--doux); padding: 6px 10px; border-bottom: 1px solid var(--bord); }
.vue-corps { flex: 1; position: relative; min-height: 0; overflow: hidden; }
.vue-corps canvas { position: absolute; inset: 0; }
.vue2d { background: #fff; display: flex; }
.vue2d svg { width: 100%; height: 100%; }
.vue2d .contour { fill: #eef2f6; stroke: #1d2530; stroke-width: var(--trait); vector-effect: non-scaling-stroke; stroke-width: 1.6px; }
.vue2d .trou { fill: #fff; stroke: #1d2530; stroke-width: 1.3px; vector-effect: non-scaling-stroke; }
.vue2d .axe { stroke: #c2410c; stroke-width: .8px; vector-effect: non-scaling-stroke; stroke-dasharray: 6 2 1 2; fill: none; }
.vue2d .ligne-cote { stroke: #2563eb; stroke-width: .8px; vector-effect: non-scaling-stroke; fill: none; }
.vue2d .cote { fill: #2563eb; font-family: system-ui, sans-serif; }
.vue2d .titre { fill: var(--doux); font-family: system-ui, sans-serif; }

.champ { display: grid; grid-template-columns: 1fr 150px; align-items: center; gap: 8px; margin: 5px 0; }
.champ label { color: var(--doux); }
.champ input, .champ select, .table input, .table select { font: inherit; padding: 4px 6px; border: 1px solid var(--bord); border-radius: 4px; width: 100%; background: #fff; }
.champ input:focus, .champ select:focus { outline: 2px solid #fdba74; border-color: var(--accent); }
.champ.case { grid-template-columns: 1fr auto; }
.champ.case input { width: auto; }
.bloc { border: 1px solid var(--bord); border-radius: 6px; padding: 6px 10px; margin: 8px 0; background: #fbfcfd; }
.bloc-tete { display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.table { width: 100%; border-collapse: collapse; font-size: 12px; }
.table th { color: var(--doux); font-weight: 500; text-align: left; }
.table td { padding: 2px; }
.vide { color: var(--doux); }
#alertes .alerte { color: var(--alerte); background: #fef3f2; border: 1px solid #fecdca; padding: 6px 8px; border-radius: 5px; margin: 6px 0; font-size: 13px; }
#infos table { width: 100%; margin-top: 12px; border-top: 1px solid var(--bord); padding-top: 6px; }
#infos td { padding: 2px 0; } #infos td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.note { color: var(--doux); font-size: 12px; margin: 6px 0; line-height: 1.4; }
.vue2d .note-plan { fill: var(--texte); font-family: system-ui, sans-serif; }
.vue2d.empile { flex-direction: column; }
.vue2d.empile .plan-section { flex: 2; min-height: 0; display: flex; border-bottom: 1px solid var(--bord); }
.vue2d.empile .plan-barre { flex: 3; min-height: 0; display: flex; }
.vue2d .cache { stroke: #1d2530; stroke-width: .8px; vector-effect: non-scaling-stroke; stroke-dasharray: 5 3; fill: none; }
.vue2d .arete { stroke: #1d2530; stroke-width: 1.2px; vector-effect: non-scaling-stroke; fill: none; }
.vue2d .fond-barre { fill: #eef2f6; stroke: none; }
.vue2d .nom-vue { fill: var(--doux); font-family: system-ui, sans-serif; }
.vue2d .usinage { fill: #fff; stroke: #1d2530; stroke-width: 1.1px; vector-effect: non-scaling-stroke; }
.vue2d .usinage.cache { fill: none; stroke-dasharray: 5 3; stroke-width: .8px; }
.vue2d .masque { fill: #fff; stroke: none; }
.boutons { display: flex; gap: 6px; flex-wrap: wrap; }
.onglet-nomenclature { margin-left: auto; }
.nomenclature { flex: 1; overflow: auto; padding: 12px 16px; }
.nomenclature[hidden], .vues[hidden] { display: none; }
.nomen-tete { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.nomen-tete h2 { font-size: 15px; text-transform: none; letter-spacing: 0; color: var(--texte); margin: 0; }
table.nomen { width: 100%; border-collapse: collapse; background: var(--panneau); border: 1px solid var(--bord); font-variant-numeric: tabular-nums; }
.nomen th { text-align: left; font-weight: 600; font-size: 12px; color: var(--doux); padding: 8px; border-bottom: 2px solid var(--bord); background: #f8fafc; }
.nomen td { padding: 7px 8px; border-bottom: 1px solid var(--bord); }
.nomen tbody tr { cursor: pointer; }
.nomen tbody tr:hover { background: var(--accent-clair); }
.nomen .num { text-align: right; }
.nomen .rep { font-weight: 700; white-space: nowrap; }
.nomen tfoot td { font-weight: 700; border-top: 2px solid var(--bord); }
.pastille { display: inline-block; margin-left: 6px; width: 16px; height: 16px; border-radius: 50%; background: var(--alerte); color: #fff; font-size: 11px; text-align: center; line-height: 16px; }
.onglet-special { margin-left: auto; }
.onglet-special + .onglet-nomenclature { margin-left: 0; }
.vues.ensemble { grid-template-columns: 3fr 2fr; }
.liste-ensemble { width: 100%; border-collapse: collapse; font-size: 13px; }
.liste-ensemble td { padding: 5px 4px; border-bottom: 1px solid var(--bord); vertical-align: top; }
.liste-ensemble tr { cursor: pointer; } .liste-ensemble tr:hover { background: var(--accent-clair); }
.liste-ensemble .note { margin: 0; }
.puce { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid #0003; }
.note.lie { color: #1d4ed8; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 5px; padding: 6px 8px; }
.schema-cadre { flex: 1; overflow: auto; padding: 8px; display: flex; flex-direction: column; }
.schema-aide { font-size: 12px; color: var(--doux); margin: 0 0 8px; }
svg.schema { width: 100%; height: auto; max-height: 100%; font-family: system-ui, sans-serif; }
.schema .noeud { cursor: pointer; }
.schema .noeud-cadre { fill: #fff; stroke: #94a3b8; stroke-width: 1.2; }
.schema .noeud:hover .noeud-cadre { stroke: var(--accent); }
.schema .noeud.arme .noeud-cadre { stroke: var(--accent); stroke-width: 2.5; fill: var(--accent-clair); }
.schema .noeud.libre .noeud-cadre { stroke-dasharray: 5 3; }
.schema .noeud-rep { font-weight: 700; font-size: 14px; fill: #1d2530; }
.schema .noeud-nom { font-size: 13px; fill: #1d2530; }
.schema .noeud-info { font-size: 11px; fill: #66717f; }
.schema .lien { cursor: pointer; }
.schema .lien-trait { fill: none; stroke: #475569; stroke-width: 1.6; }
.schema .lien-zone { fill: none; stroke: transparent; stroke-width: 14; }
.schema .lien.actif .lien-trait, .schema .lien:hover .lien-trait { stroke: var(--accent); stroke-width: 2.4; }
.schema .lien-etiquette { fill: #f1f5f9; stroke: #cbd5e1; }
.schema .lien-etiquette.a-preciser { fill: #fff7ed; stroke: #fdba74; }
.schema .lien-texte { font-size: 11px; fill: #334155; }
.bandeau { position: absolute; left: 8px; right: 8px; top: 8px; z-index: 2; background: rgba(29,37,48,.86); color: #fff; font-size: 13px; padding: 7px 10px; border-radius: 6px; pointer-events: none; white-space: pre-wrap; }
.croquis svg { width: 100%; height: 90px; display: block; margin: 4px 0; }
.croquis path { fill: #dbe3ec; stroke: #1d2530; stroke-width: 1.2px; vector-effect: non-scaling-stroke; }
.croquis text { fill: #1d2530; font-family: system-ui, sans-serif; }
.vue2d .numero-morceau { fill: #c2410c; font-family: system-ui, sans-serif; font-weight: 700; }
.vue2d .joint { stroke: #dc2626; stroke-width: 1.2px; vector-effect: non-scaling-stroke; stroke-dasharray: 10 3 2 3; fill: none; }
.vue2d .pli { stroke: #2563eb; stroke-width: 1px; vector-effect: non-scaling-stroke; stroke-dasharray: 12 3 2 3; fill: none; }
.vue2d .pli-fin { stroke: #93b4f5; stroke-dasharray: 6 3; }
.etat-enregistrement { font-size: 12px; color: #9aa7b4; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #1d2530; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 30; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 80vw; }
.toast.erreur { background: var(--alerte); }
.fond-dialogue { position: fixed; inset: 0; background: rgba(15,23,32,.45); z-index: 20; display: flex; align-items: center; justify-content: center; }
.dialogue { background: #fff; border-radius: 10px; padding: 18px; width: min(520px, 92vw); max-height: 80vh; overflow: auto; }
.dialogue h2 { font-size: 16px; text-transform: none; letter-spacing: 0; color: var(--texte); margin: 0 0 12px; }
.liste-projets { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.liste-projets .projet { display: flex; justify-content: space-between; gap: 12px; text-align: left; padding: 10px 12px; }
.liste-projets .projet span { color: var(--doux); font-size: 12px; }
.nomenclature .nomen + .nomen-tete { margin-top: 22px; }
.propositions { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 12px; }
.proposition { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 2px; padding: 8px 10px; border-radius: 6px; }
.proposition strong { font-weight: 600; }
.proposition span { font-size: 12px; color: var(--doux); }
.proposition.forte { border-color: #86efac; background: #f0fdf4; }
.proposition:hover { border-color: var(--accent); background: var(--accent-clair); }
.vue2d.empile .plan-section.gabarits { flex-direction: column; }
.vue2d.empile .plan-section.gabarits svg { height: 50%; }

/* ---------- arbre de montage ---------- */
.arbre-defile { overflow: auto; padding: 4px 0 12px; }
.arbre { position: relative; }
.arbre-traits { position: absolute; left: 0; top: 0; pointer-events: none; }
.arbre-traits .trait { stroke: #1d2530; stroke-width: 1.6; fill: none; }
.arbre-traits .trait.non-soude { stroke-dasharray: 6 4; }
.arbre-traits .trait.a-poser { stroke: #ea580c; stroke-dasharray: 2 3; stroke-width: 2; }
.arbre-tete, .arbre-ligne { display: grid; grid-template-columns: 22px 48px 1fr 40px 70px; align-items: center; gap: 6px; }
.arbre-tete { font-size: 12px; font-weight: 600; color: #475569; padding: 0 6px; margin-top: 8px; }
.arbre-ligne { position: absolute; left: 0; padding: 0 6px; background: #fff; border: 1px solid #d5dce4; border-radius: 6px; cursor: pointer; font-size: 13px; }
.arbre-ligne:hover { border-color: #2563eb; }
.arbre-ligne.choisi { outline: 2px solid #f97316; }
.arbre-rep { font-weight: 600; }
.arbre-des { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; line-height: 1.25; }
.arbre-nb { text-align: center; }
.arbre-vig img, .arbre-vig svg { width: 66px; height: 50px; object-fit: contain; display: block; }
.arbre-ligne .rang, .arbre-noeud .rang { position: absolute; right: -8px; top: -8px; background: #2563eb; color: #fff; border-radius: 9px; font-size: 11px; padding: 0 6px; }
.arbre-noeud { position: absolute; background: #fff; border: 1px solid #d5dce4; border-radius: 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; padding: 3px; box-sizing: border-box; }
.arbre-noeud:hover { border-color: #2563eb; }
.arbre-noeud.choisi { outline: 2px solid #f97316; }
.arbre-noeud.incomplet { border-color: #ea580c; }
.arbre-noeud-img { flex: 1; display: flex; align-items: center; justify-content: center; width: 100%; min-height: 0; }
.arbre-noeud-img img { max-width: 100%; max-height: 64px; }
.arbre-noeud-nom { font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.case-vide { display: inline-block; width: 13px; }
.legende { margin-top: 6px; }

/* ---------- assistant IA ---------- */
header .assistant { background: #4c1d95; border-color: #6d28d9; color: #fff; }
.dialogue textarea, #params textarea { width: 100%; box-sizing: border-box; font: inherit; padding: 6px; border: 1px solid #cbd5e1; border-radius: 6px; margin: 6px 0; }
.champ.question label { white-space: normal; }
.description-ia { margin: 4px 0 8px; padding: 6px 10px; border-left: 3px solid #6d28d9; background: #f5f3ff; white-space: pre-wrap; font-size: 13px; user-select: text; }
.description-ia.precision { border-left-color: #a78bfa; }
.champ.question { display: block; }
.champ.question label { display: block; margin-bottom: 3px; color: var(--texte); }
.champ.question input { width: 100%; box-sizing: border-box; }
.note.lie:empty { display: none; }
.exemplaires { display: block; font-size: 10px; font-weight: 400; color: #64748b; white-space: nowrap; }
.arbre-exemplaire { position: absolute; left: 24px; display: flex; gap: 10px; align-items: center; padding: 0 8px; font-size: 12px;
  background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: 5px; cursor: pointer; color: #334155; box-sizing: border-box; }
.arbre-exemplaire:hover { border-color: #2563eb; }
.arbre-exemplaire .arbre-rep { min-width: 42px; }
.arbre-exemplaire.manquant { border-color: #ea580c; color: #c2410c; background: #fff7ed; }
.arbre-info { display: block; font-size: 11px; color: #64748b; margin-top: 2px; }
.arbre-vig { cursor: zoom-in; }
.croquis { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.croquis-vignette { position: relative; }
.croquis-vignette img { width: 110px; height: 80px; object-fit: cover; border: 1px solid #cbd5e1; border-radius: 6px; display: block; }
.croquis-vignette button { position: absolute; top: 2px; right: 2px; padding: 0 6px; }
.champ-croquis { margin: 4px 0 8px; }
.manques { margin: 6px 0 10px; }
.alerte.manque { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* galerie des placements proposés */
.galerie { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin: 6px 0; }
.carte-prop { display: flex; flex-direction: column; align-items: stretch; gap: 3px; padding: 6px; text-align: left; background: #fff; border: 1px solid #d5dce4; border-radius: 8px; cursor: pointer; font: inherit; }
.carte-prop:hover { border-color: #f97316; box-shadow: 0 0 0 2px #fed7aa; }
.carte-prop.forte { border-color: #86efac; }
.carte-prop img, .carte-prop .carte-vide { width: 100%; height: 80px; object-fit: contain; background: #f1f5f9; border-radius: 5px; display: flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 12px; }
.carte-prop strong { font-size: 12px; line-height: 1.2; }
.carte-prop span { font-size: 11px; color: #64748b; line-height: 1.2; }
/* cotes sur la 3D d'ensemble */
.cote3d { position: absolute; transform: translate(-50%, -50%); z-index: 3; font: 600 12px/1.2 inherit; padding: 1px 5px; border-radius: 4px;
  background: rgba(255,255,255,.92); border: 1px solid #94a3b8; color: #334155; pointer-events: none; white-space: nowrap; }
.cote3d.modifiable { pointer-events: auto; border-color: #2563eb; color: #1d4ed8; width: auto; text-align: center; cursor: text; }
.cote3d.modifiable:focus { outline: 2px solid #f97316; background: #fff; }
.liste-reportes { width: 100%; font-size: 12px; border-collapse: collapse; }
.liste-reportes td { padding: 2px 4px; border-bottom: 1px solid #e2e8f0; }
.mode-cotes { position: absolute; right: 8px; bottom: 8px; z-index: 4; display: flex; gap: 4px; align-items: center; background: rgba(255,255,255,.9); padding: 4px 6px; border-radius: 6px; font-size: 12px; }
.mode-cotes .actif { background: #2563eb; color: #fff; border-color: #2563eb; }
.arbre-compact { overflow: auto; max-height: calc(100% - 40px); }
.contexte-perdu { position: absolute; inset: 40% 10% auto; z-index: 5; background: #fff7ed; border: 1px solid #ea580c; color: #9a3412; padding: 10px; border-radius: 8px; text-align: center; }
.vue-corps .recadrer { position: absolute; left: 8px; bottom: 8px; z-index: 4; }
.diag3d { position: absolute; left: 8px; top: 56px; z-index: 6; margin: 0; padding: 6px 8px; font: 11px/1.35 monospace; background: rgba(15,23,42,.85); color: #e2e8f0; border-radius: 6px; max-width: 95%; white-space: pre-wrap; pointer-events: none; }
header button.icone { font-size: 18px; padding: 2px 10px; }
header button.icone:disabled { opacity: .35; cursor: default; }
/* vue Squelette */
.sq-cadre { overflow: auto; height: 100%; padding: 8px 10px; box-sizing: border-box; }
.sq-table { border-collapse: collapse; font-size: 12px; margin-bottom: 10px; }
.sq-table th { text-align: left; color: #475569; font-weight: 600; padding: 2px 4px; }
.sq-table td { padding: 2px 4px; border-bottom: 1px solid #e2e8f0; }
.sq-table tr.choisi td { background: #eff6ff; }
.sq-table tr:hover td { background: #f8fafc; cursor: pointer; }
.sq-champ { width: 64px; font: inherit; padding: 2px 4px; }
.sq-table select { font: inherit; }
