:root {
  --bg: #17191d;
  --view: #1c1f24;
  --panel: #202328;
  --card: #262a30;
  --card-2: #2c3037;
  --line: #353a43;
  --line-2: #414754;
  --text: #e8eaee;
  --muted: #9aa1ad;
  --faint: #6f7682;
  --accent: #f0a63a;
  --accent-ink: #1d1a14;
  --blue: #4c9dff;
  --ok: #5cc27a;
  --warn: #e9b44c;
  --err: #ec6a5e;
  --h: 30px;          /* hauteur commune des contrôles */
  --r: 6px;
  --gap: 6px;
  --pad: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 13px/1.4 "Segoe UI", system-ui, -apple-system, sans-serif; }
button, select, input { font: inherit; color: inherit; }
.hidden { display: none !important; }
kbd { background: #3a3f48; border-radius: 3px; padding: 0 4px; font-size: 11px; }

/* ---------- barre du haut ---------- */
.topbar { height: 48px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--pad); background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }
.brand .logo { width: 20px; height: 20px; fill: var(--accent); }
.brand small { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 4px; }
.topbar-actions { display: flex; gap: 10px; }

/* ---------- boutons ---------- */
.btn { height: var(--h); padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--card-2); border: 1px solid var(--line-2); border-radius: var(--r); cursor: pointer;
  white-space: nowrap; transition: background .12s, border-color .12s; user-select: none; }
.btn:hover { background: #343943; border-color: #4b5262; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.icon { width: var(--h); padding: 0; font-size: 15px; }
.btn.block { width: 100%; }
.btn.lg { height: 38px; font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #f5b552; }
.btn.subtle { background: transparent; }
.btn.subtle:hover { background: var(--card-2); }
.btn.mode.active, .btn.on { background: #263a52; border-color: var(--blue); color: #fff; }
.btn-group { display: flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--r) 0 0 var(--r); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--r) var(--r) 0; }

.grid { display: grid; gap: var(--gap); }
.grid.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid .btn { width: 100%; min-width: 0; padding: 0 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot.pour { background: #ff8c3a; } .dot.vent { background: #47b5ff; }
.dot.rib { background: #6cd27a; } .dot.foot { background: #c77dff; }

/* ---------- mise en page ---------- */
main { position: relative; display: flex; height: calc(100% - 48px); }
#panel { width: 352px; flex: none; display: flex; flex-direction: column; background: var(--panel);
  border-right: 1px solid var(--line); }
.panel-scroll { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.panel-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); padding: 10px;
  border-top: 1px solid var(--line); background: var(--panel); }

/* ---------- cartes (sections) ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; flex: none; }
.card > header { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 10px; cursor: pointer;
  font-weight: 600; user-select: none; }
.card .num { width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 11px; font-weight: 700; flex: none; }
.chev { margin-left: auto; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform .15s; }
.card.open .chev { transform: rotate(45deg); }
.card-body { display: none; padding: 2px 10px 12px; flex-direction: column; gap: 8px; }
.card.open .card-body { display: flex; }
.hint-line { margin: 0; color: var(--muted); font-size: 12px; }
.callout { background: #2f2b22; border-left: 3px solid var(--accent); border-radius: 4px; padding: 8px 10px;
  color: #ddd2b9; font-size: 12px; }
.info { background: #1f2227; border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; font-size: 12px; }
.info .k { color: var(--muted); }
.info a { color: var(--blue); }

/* ---------- champs : grille commune libellé | valeur ---------- */
.fields { display: flex; flex-direction: column; gap: 6px; }
.field { display: grid; grid-template-columns: minmax(0, 1fr) 112px; align-items: center; gap: 10px; min-height: var(--h); }
.field > label { font-size: 12.5px; color: #d5d9e0; line-height: 1.25; }
.field > label small { display: block; color: var(--faint); font-size: 11px; }
.inp { display: flex; align-items: center; height: var(--h); background: #1b1e22;
  border: 1px solid var(--line-2); border-radius: var(--r); }
.inp:focus-within { border-color: var(--blue); }
.inp input { flex: 1; min-width: 0; height: 100%; background: transparent; border: 0; outline: 0; text-align: right; padding: 0 4px 0 8px; }
.inp .unit { color: var(--faint); font-size: 11px; padding-right: 8px; width: 34px; text-align: left; }
.field select { width: 100%; height: var(--h); background: #1b1e22; border: 1px solid var(--line-2);
  border-radius: var(--r); padding: 0 8px; }
.switch { justify-self: end; position: relative; width: 38px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #3a3f48; border-radius: 11px; cursor: pointer; transition: .15s; }
.switch span::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; border-radius: 50%;
  background: #cfd3da; transition: .15s; }
.switch input:checked + span { background: var(--blue); }
.switch input:checked + span::after { transform: translateX(16px); background: #fff; }

.drop { display: flex; flex-direction: column; align-items: center; gap: 2px; border: 1.5px dashed #4a5263;
  border-radius: 8px; padding: 16px 8px; cursor: pointer; color: var(--muted); text-align: center; }
.drop b { color: var(--text); font-weight: 600; }
.drop span { font-size: 12px; }
.drop:hover, .drop.over { border-color: var(--accent); background: #2b2a26; }

/* ---------- éléments placés ---------- */
.elems { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.elems:empty { display: none; }
.elem { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; background: #1f2227; border: 1px solid var(--line);
  border-radius: var(--r); padding: 7px 8px; cursor: pointer; }
.elem.sel { border-color: var(--blue); background: #1e2a38; }
.elem-head { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12px; }
.elem-head .pos { color: var(--faint); font-weight: 400; }
.elem-props { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.elem-props label { display: flex; flex-direction: column; gap: 2px; font-size: 10.5px; color: var(--muted); }
.elem-props input { height: 26px; width: 100%; background: #17191d; border: 1px solid var(--line-2); border-radius: 4px;
  text-align: right; padding: 0 5px; }
.elem .del { height: 22px; width: 22px; padding: 0; font-size: 11px; }

/* ---------- vue 3D ---------- */
#view { position: relative; flex: 1; min-width: 0; overflow: hidden; background: var(--view); }
#c3d { width: 100%; height: 100%; display: block; }
/* barres flottantes : zones flexibles qui laissent la place au panneau de résultats */
.vtop { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: space-between; align-items: flex-start; z-index: 2; pointer-events: none; }
.vtop > * { pointer-events: auto; }
.vbottom { position: absolute; left: 12px; right: 12px; bottom: 14px; display: flex; justify-content: center; z-index: 2; pointer-events: none; }
.vbottom > * { pointer-events: auto; }
body.drawer-open .vtop, body.drawer-open .vbottom { right: 392px; }
.vbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; }
.vbar.bottom { background: rgba(32, 35, 40, .94); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,.35); max-width: 100%; }
.seg { display: inline-flex; background: rgba(32, 35, 40, .94); border: 1px solid var(--line-2); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button { height: 26px; padding: 0 12px; border: 0; background: transparent; border-radius: 5px; cursor: pointer; color: var(--muted); }
.seg button:hover:not(:disabled) { color: var(--text); background: #30343c; }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg button:disabled { opacity: .35; cursor: default; }
.seg.compact button { padding: 0 9px; }
.sep { width: 1px; align-self: stretch; background: var(--line); }
.chips { display: flex; gap: 4px; }
.chip { cursor: pointer; }
.chip input { display: none; }
.chip span { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 13px; border: 1px solid var(--line-2);
  color: var(--faint); font-size: 12px; }
.chip input:checked + span { color: var(--text); background: #2f3540; border-color: #56607a; }
.ctl { display: flex; align-items: center; gap: 8px; }
.ctl .btn { height: 26px; }
.ctl-label { color: var(--muted); font-size: 12px; }
.ctl select { height: 26px; background: #1b1e22; border: 1px solid var(--line-2); border-radius: 5px; }
.ctl input[type=range] { width: 110px; accent-color: var(--accent); }
.banner { position: absolute; top: 56px; left: 50%; transform: translateX(-50%); background: #22344a; border: 1px solid var(--blue);
  padding: 7px 14px; border-radius: 8px; font-size: 12.5px; z-index: 2; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.empty-box { display: flex; flex-direction: column; gap: 4px; align-items: center; color: var(--muted);
  border: 1.5px dashed #3b414c; border-radius: 14px; padding: 28px 40px; }
.empty-box b { color: var(--text); font-size: 15px; }
.legend { position: absolute; left: 12px; bottom: 14px; display: flex; gap: 14px; background: rgba(32,35,40,.94);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12px; z-index: 2; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.legend .sw.ok { background: #8fa7c4; } .legend .sw.bad { background: #ec4b3e; }

/* ---------- panneau des résultats ---------- */
.drawer { position: absolute; top: 12px; right: 12px; bottom: 12px; width: 368px; display: flex; flex-direction: column;
  background: rgba(32, 35, 40, .97); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.4); z-index: 3; }
.drawer-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 10px 10px 8px; }
.drawer-head select { height: 28px; min-width: 0; background: #1b1e22; border: 1px solid var(--line-2); border-radius: 5px; padding: 0 6px; }
.drawer-head .btn.icon { width: 28px; height: 28px; font-size: 12px; }
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0 10px; border-bottom: 1px solid var(--line); }
.tabs button { height: 32px; background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--muted); cursor: pointer; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.drawer-body { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.progress { padding: 4px 12px 10px; }
.progress .bar { height: 6px; background: #15171a; border-radius: 3px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.progress span { display: block; color: var(--muted); font-size: 12px; margin-top: 6px; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.stat { background: #1f2227; border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; }
.stat b { display: block; font-size: 16px; }
.stat span { color: var(--muted); font-size: 11px; }
.msg { border-radius: var(--r); padding: 8px 10px; font-size: 12px; }
.msg.warn { background: #382f1d; border-left: 3px solid var(--warn); }
.msg.err { background: #3a201e; border-left: 3px solid var(--err); }
.msg.ok { background: #1f3326; border-left: 3px solid var(--ok); }
.msg.info { background: #1e2a38; border-left: 3px solid var(--blue); }

.plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.prow { display: grid; grid-template-columns: 24px 12px minmax(0, 1fr) auto; gap: 8px; align-items: center; background: #1f2227;
  border: 1px solid var(--line); border-radius: var(--r); padding: 6px 8px; }
.prow.off { opacity: .45; }
.prow .eye { width: 24px; height: 24px; padding: 0; border: 0; background: transparent; cursor: pointer; color: var(--muted); font-size: 14px; }
.prow .eye:hover { color: var(--text); }
.prow .sw { width: 12px; height: 12px; border-radius: 3px; cursor: pointer; }
.prow .name { font-size: 12.5px; }
.prow .name small { display: block; color: var(--faint); font-size: 11px; }
.prow a { color: var(--blue); text-decoration: none; font-size: 12px; font-weight: 600; }
.badge { font-size: 10.5px; padding: 1px 6px; border-radius: 4px; margin-left: 4px; white-space: nowrap; }
.badge.ok { background: #20382a; color: var(--ok); }
.badge.bad { background: #43231f; color: var(--err); }
.row-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.row-actions .btn { width: 100%; }
.dl { display: flex; align-items: center; justify-content: center; height: 38px; background: var(--accent); color: var(--accent-ink);
  font-weight: 700; border-radius: var(--r); text-decoration: none; flex: none; }
.dl:hover { background: #f5b552; }
.section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin: 4px 0 -2px; }
.steps { padding-left: 18px; margin: 0; color: #d5d9e0; display: flex; flex-direction: column; gap: 6px; }
.pcard { background: #1f2227; border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px;
  display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 4px 8px; align-items: center; }
.pcard .sw { width: 12px; height: 12px; border-radius: 3px; }
.pcard small { grid-column: 2 / -1; color: var(--muted); font-size: 11.5px; }
.foot-note { color: var(--faint); font-size: 11px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #2b313b; border: 1px solid var(--line-2);
  border-radius: 8px; padding: 9px 16px; box-shadow: 0 8px 24px rgba(0,0,0,.4); z-index: 10; }

/* ---- Connexion, compte, administration ---- */
.login-body { display: flex; align-items: center; justify-content: center; }
.login-page { width: 100%; padding: 16px; display: flex; justify-content: center; }
.login-card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 28px 26px; box-shadow: 0 10px 40px rgba(0, 0, 0, .35); }
.login-card h1 { margin: 0 0 4px; font-size: 20px; display: flex; align-items: center; gap: 10px; }
.login-card h1 .logo { width: 24px; height: 24px; fill: var(--accent); }
.login-card .subtitle { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.login-card form, .modal form { display: flex; flex-direction: column; gap: 8px; }
.login-card label, .modal label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.login-card input, .modal input, .modal select { background: var(--bg); border: 1px solid var(--line-2); color: var(--text);
  border-radius: 6px; padding: 8px 10px; font: inherit; }
.login-card button { margin-top: 8px; }
.error-msg { color: var(--err); font-size: 12px; min-height: 16px; }
.ok-msg { color: var(--ok); font-size: 12px; }

.account { position: relative; }
#btnAccount small { color: var(--muted); margin-left: 6px; font-size: 11px; }
.acc-menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel); border: 1px solid var(--line-2);
  border-radius: 8px; min-width: 210px; padding: 4px; z-index: 50; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); }
.acc-menu button { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text);
  padding: 8px 10px; border-radius: 6px; cursor: pointer; font: inherit; }
.acc-menu button:hover { background: var(--card-2); }
.pw-banner { background: #3a2a14; color: #ffd9a0; border-bottom: 1px solid #6b4a1c; padding: 6px 16px; font-size: 13px;
  display: flex; align-items: center; gap: 12px; }

.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-card { background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; width: 100%; max-width: 380px;
  max-height: 90vh; overflow: auto; padding: 0 18px 18px; }
.modal-card.wide { max-width: 720px; }
.modal-card > header { display: flex; justify-content: space-between; align-items: center; font-weight: 600;
  padding: 14px 0 10px; position: sticky; top: 0; background: var(--panel); }
.admin-tabs { grid-template-columns: repeat(2, 1fr); margin: 0 0 12px; }
.utable, .rtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.utable td, .utable th, .rtable td, .rtable th { padding: 6px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.rtable td.c, .rtable th.c { text-align: center; }
.rtable small { display: block; color: var(--muted); font-size: 11px; }
.rtable .grp td { color: var(--accent); font-weight: 600; padding-top: 12px; }
.utable .acts { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.new-user { display: grid; grid-template-columns: 1fr 1fr 130px auto; gap: 8px; align-items: end; margin-top: 12px; }
@media (max-width: 640px) { .new-user { grid-template-columns: 1fr; } }
.perm-locked { opacity: .45; pointer-events: none; }
