*,*::before,*::after{box-sizing:border-box}body{margin:0}[hidden]{display:none!important}
/* Atelier : bandeau fin + espace de travail en trois colonnes (plans · planche · mesures) ;
   le bordereau se lit comme une pièce écrite. Motif : strates de pisé. */
/* Esprit « book » : blanc, filets fins, capitales très espacées, police géométrique ;
   bandeau fin + espace de travail en trois colonnes (plans · planche · mesures). */
:root {
  --bg: #F7F6F4;
  --surface: #FFFFFF;
  --surface-2: #F0EEEA;
  --line: #E3E0DA;
  --line-strong: #C9C4BC;
  --ink: #2A2526;
  --muted: #776C6B;
  --accent: #0E5A53;
  --accent-ink: #FFFFFF;
  --accent-soft: #E1EEEC;
  --plan-paper: #FFFFFF;
  --plan-ink: #2F2A2A;
  --plan-faint: #B5AFA8;
  --ok: #2E7A4C;
  --warn: #A86A12;
  --bad: #B03636;
  --ai: #6B4FB0;
  --ai-soft: #EEE9F7;
  --shadow: 0 1px 2px rgba(42, 37, 38, .05), 0 10px 30px rgba(42, 37, 38, .08);
  --f-display: 'Jost', 'Century Gothic', Futura, 'Avenir Next', 'Segoe UI', sans-serif;
  --f-body: 'Jost', 'Century Gothic', Futura, 'Avenir Next', 'Segoe UI', sans-serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r: 3px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141312; --surface: #1C1A19; --surface-2: #262322; --line: #36322F; --line-strong: #4B4642;
    --ink: #EDE9E4; --muted: #A69C98; --accent: #6FC0B4; --accent-ink: #0A1F1C; --accent-soft: #16302D;
    --plan-paper: #121110; --plan-ink: #D6D0CA; --plan-faint: #5F5954;
    --ok: #6CC08E; --warn: #E0A548; --bad: #E77474; --ai: #B49BEA; --ai-soft: #2D2640;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141312; --surface: #1C1A19; --surface-2: #262322; --line: #36322F; --line-strong: #4B4642;
  --ink: #EDE9E4; --muted: #A69C98; --accent: #6FC0B4; --accent-ink: #0A1F1C; --accent-soft: #16302D;
  --plan-paper: #121110; --plan-ink: #D6D0CA; --plan-faint: #5F5954;
  --ok: #6CC08E; --warn: #E0A548; --bad: #E77474; --ai: #B49BEA; --ai-soft: #2D2640;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
/* Ambiances (accent) : terre de Legzira (défaut, Terra ocre), pin, chaux */
:root[data-amb="legzira"] { --accent: #A3462B; --accent-soft: #F5E4DD; --accent-ink: #FFFFFF; }
:root[data-amb="chaux"] { --accent: #4A4644; --accent-soft: #ECEBE8; --accent-ink: #FFFFFF; }
@media (prefers-color-scheme: dark) {
  :root[data-amb="legzira"]:not([data-theme="light"]) { --accent: #E08A6A; --accent-soft: #3A2019; --accent-ink: #1E0C06; }
  :root[data-amb="chaux"]:not([data-theme="light"]) { --accent: #CFCAC4; --accent-soft: #2E2B29; --accent-ink: #151312; }
}
:root[data-amb="legzira"][data-theme="dark"] { --accent: #E08A6A; --accent-soft: #3A2019; --accent-ink: #1E0C06; }
:root[data-amb="chaux"][data-theme="dark"] { --accent: #CFCAC4; --accent-soft: #2E2B29; --accent-ink: #151312; }

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--ink); font: 400 14.5px/1.45 var(--f-body); -webkit-font-smoothing: antialiased; }
#app { height: 100%; display: flex; flex-direction: column; min-height: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--f-display); margin: 0; text-wrap: balance; font-weight: 500; }
.page h2 { font-weight: 500; letter-spacing: .2em; text-transform: uppercase; font-size: 13px !important; }
.page .doc-head h2 { letter-spacing: .06em; font-size: 16px !important; font-weight: 600; }
.num, .mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.eyebrow { font: 500 10.5px/1.25 var(--f-body); letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Boutons et champs */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--r); border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { height: 26px; padding: 0 8px; font-size: 12.5px; }
.btn.danger { color: var(--bad); }
.btn.ai { border-color: var(--ai); color: var(--ai); }
.btn.ai.primary { background: var(--ai); color: var(--surface); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.field { display: grid; gap: 4px; min-width: 0; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 500; }
.input, select.input, textarea.input { height: 32px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); padding: 0 9px; min-width: 0; width: 100%; }
textarea.input { height: auto; padding: 8px 9px; resize: vertical; }
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 10px; font-size: 11.5px; font-weight: 500; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.ai { background: var(--ai-soft); color: var(--ai); }
.chip.ok { color: var(--ok); }
.chip.warn { color: var(--warn); }
.chip.bad { color: var(--bad); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.dot { width: 9px; height: 9px; border-radius: 2px; flex: none; }

/* Bandeau */
.topbar { display: flex; align-items: center; gap: 16px; padding: 0 16px; min-height: 52px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; white-space: nowrap; color: var(--ink); }
.org-logo { display: grid; justify-items: center; line-height: 1; }
.org-logo b { font: 700 16px/1 var(--f-display); letter-spacing: .34em; margin-right: -.34em; }
.org-logo small { font: 300 7.5px/1 var(--f-display); letter-spacing: .16em; margin-top: 2px; }
.brand-rule { width: 1px; height: 26px; background: var(--ink); opacity: .7; }
.app-name { font: 400 12.5px var(--f-display); letter-spacing: .34em; text-transform: uppercase; }
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1 1 auto; min-width: 0; scrollbar-width: none; }
.nav button { border: 0; background: none; height: 52px; padding: 0 12px; cursor: pointer; color: var(--muted); font: 500 11.5px var(--f-display); letter-spacing: .16em; text-transform: uppercase; border-bottom: 1.5px solid transparent; white-space: nowrap; }
.nav button:hover { color: var(--ink); }
.nav button[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.nav button:disabled { opacity: .4; cursor: default; }
.userchip { display: flex; align-items: center; gap: 8px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font: 600 11.5px var(--f-body); flex: none; }
.proto-tag { font: 600 10px var(--f-body); letter-spacing: .08em; text-transform: uppercase; color: var(--warn); border: 1px solid currentColor; border-radius: 3px; padding: 1px 5px; }

/* Pages de contenu */
.page { flex: 1 1 auto; overflow: auto; padding-block: 28px 48px; padding-inline: max(16px, calc((100% - 1180px) / 2)); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; font-weight: 400; letter-spacing: .26em; text-transform: uppercase; }
.page-head p { margin: 6px 0 0; color: var(--muted); max-width: 68ch; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 18px; min-width: 0; }
.proj-card { display: grid; gap: 12px; cursor: pointer; transition: border-color .15s; }
.proj-card:hover { border-color: var(--ink); }
.proj-card h3 { font-size: 15px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }
.proj-card .chaux { height: 64px; margin: -18px -18px 0; border-radius: 8px 8px 0 0; background: var(--surface-2) center / cover no-repeat; }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.kv div { display: grid; gap: 2px; }
.kv b { font: 500 15px var(--f-mono); font-variant-numeric: tabular-nums; }
.kv span { font-size: 11.5px; color: var(--muted); }
.book-head { display: flex; align-items: flex-start; gap: 10px; }
.book-head .bnum { writing-mode: vertical-rl; transform: rotate(180deg); font: 700 15px/1 var(--f-display); letter-spacing: .02em; }
.book-head b { display: block; font: 600 14.5px/1.2 var(--f-display); text-transform: uppercase; letter-spacing: .03em; }
.book-head span.sub { display: block; font: 300 13.5px/1.3 var(--f-display); text-transform: uppercase; letter-spacing: .03em; color: var(--ink); }

/* Connexion */
.login { flex: 1; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); min-height: 100%; }
.login-art { position: relative; overflow: hidden; background: #2a2526 center / cover no-repeat; min-height: 240px; }
.login-art .cap { position: absolute; left: 32px; bottom: 28px; color: #2A2526; font: 500 11px var(--f-display); letter-spacing: .34em; text-transform: uppercase; background: rgba(255, 255, 255, .72); padding: 7px 12px; }
.wiz-steps { display: flex; gap: 4px; flex-wrap: wrap; }
.wiz-steps span { font: 500 10.5px var(--f-display); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); padding: 6px 8px; border-bottom: 1.5px solid var(--line); }
.wiz-steps span[aria-current="step"] { color: var(--ink); border-bottom-color: var(--accent); }
.modal.wide { width: min(760px, 100%); }
#asst.modal.wide { width: min(1080px, 100%); }
.pdf-thumb { display: grid; gap: 4px; align-content: start; aspect-ratio: 210/297; max-height: 150px; width: auto; padding: 10px 9px; background: #fff; border: 1px solid var(--line); border-radius: 3px; position: relative; overflow: hidden; }
.pdf-thumb i { display: block; height: 4px; border-radius: 1px; background: #e4e0da; }
.pdf-thumb i.h { height: 11px; background: transparent; border-bottom: 2px solid var(--accent); margin-bottom: 4px; }
.pdf-thumb i.t { height: 9px; background: color-mix(in srgb, var(--accent) 10%, #fff); margin-bottom: 3px; }
.pdf-thumb i.l { background: color-mix(in srgb, var(--accent) 22%, #fff); }
.pdf-bandeau i.h { height: 20px; margin: -10px -9px 4px; background: var(--accent); border: 0; border-radius: 0; }
.pdf-bandeau i.t { background: var(--accent); opacity: .85; }
.pdf-bandeau i.l { background: #fff; border-left: 2px solid var(--accent); }
.pdf-editorial { padding: 14px 13px; }
.pdf-editorial i.h { height: 7px; border-bottom: 0; background: transparent; }
.pdf-editorial i.t { height: 6px; width: 70%; background: #3a3436; margin-bottom: 8px; }
.pdf-editorial i.r { height: 1px; background: #d6d1ca; margin: 3px 0; }
.pdf-editorial i.l { height: 3px; width: 40%; background: var(--accent); }
.roles-t th.role-col { min-width: 150px; vertical-align: top; text-transform: none; letter-spacing: 0; }
.roles-t .role-name { font-weight: 600; font-size: 13.5px; color: var(--ink); }
.roles-t .role-name-in { font-weight: 600; width: 100%; min-width: 130px; }
.roles-t .role-meta { font-size: 11.5px; color: var(--muted); font-weight: 400; margin-top: 3px; }
.roles-t .role-acts { display: flex; gap: 2px; margin-top: 4px; flex-wrap: wrap; }
.roles-t td.role-cell { text-align: center; }
.roles-t td.role-cell input { width: 16px; height: 16px; }
.foldable > .fold-head { cursor: pointer; user-select: none; }
.foldable.folded > :not(.fold-head) { display: none !important; }
.foldable.folded { padding-block: 12px; gap: 0 !important; }
.foldable.folded > .fold-head > :not(h2):not(button):not(.btn) { display: none; }
.fold-btn { display: inline-grid; place-items: center; width: 22px; height: 22px; margin: 0 8px 0 -2px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--muted); font: 600 15px/1 var(--f-body, inherit); vertical-align: middle; cursor: pointer; transition: transform .15s ease; transform: rotate(90deg); }
.foldable.folded .fold-btn { transform: rotate(0deg); }
.fold-btn:hover { color: var(--accent); border-color: var(--accent); }
section.foldable { border-bottom: 1px solid var(--line); padding-bottom: 22px; }
section.foldable.folded { margin-bottom: 0 !important; padding-block: 12px !important; }
.fold-all { display: flex; gap: 6px; justify-content: flex-end; margin: -6px 0 12px; }
@media (prefers-reduced-motion: reduce) { .fold-btn { transition: none; } }
.pick-list { display: grid; gap: 10px; max-height: 46vh; overflow: auto; padding-right: 4px; }
.pick-lot { display: grid; gap: 3px; }
.baie-box { display: grid; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.baie-box .panel-title { margin: 0; }
.baie-row { display: flex; gap: 6px; align-items: center; min-width: 0; }
.baie-row select { flex: 1; min-width: 0; }
.baie-warn { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12.5px; color: var(--warn, #8a5a00); }
.fix-panel { position: absolute; right: 12px; top: 12px; z-index: 6; width: min(360px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow: auto; background: var(--surface); border: 1px solid var(--ai); border-radius: 8px; box-shadow: var(--shadow); padding: 12px 14px; display: grid; gap: 8px; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.choice-card { display: grid; gap: 6px; text-align: left; padding: 14px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; font: inherit; font-size: 13px; line-height: 1.45; }
.choice-card b { font-size: 15px; font-weight: 600; }
.choice-card span { color: var(--muted); }
.choice-card:hover { border-color: var(--accent); }
.choice-card.primary { border-color: var(--ai); background: var(--ai-soft); }
.asst-top { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 760px) { .asst-top { grid-template-columns: minmax(0, 1fr); } }
.asst-prev canvas { display: block; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.asst-dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; margin: 0; font-size: 13px; }
.asst-dl dt { color: var(--muted); }
.asst-dl dd { margin: 0; }
.asst-q { display: grid; gap: 12px; }
.asst-q details summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.swatch { display: inline-block; width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--line-strong, #999); flex: none; }
.login-cover { display: flex; align-items: center; gap: 28px; }
.login-cover .word { font: 500 27px/1.2 var(--f-display); letter-spacing: .42em; text-transform: uppercase; }
.login-cover .vrule { width: 1px; align-self: stretch; min-height: 90px; background: var(--ink); }
.login-cover .org-logo b { font-size: 26px; }
.login-cover .org-logo small { font-size: 11px; margin-top: 4px; }
.login-form { display: flex; flex-direction: column; justify-content: center; padding: 40px clamp(16px, 5vw, 64px); gap: 22px; background: var(--surface); }
.login-form form { display: grid; gap: 14px; max-width: 380px; width: 100%; }
.demo-accounts { display: grid; gap: 6px; max-width: 380px; }
.demo-accounts button { display: flex; justify-content: space-between; gap: 8px; align-items: center; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 8px 10px; cursor: pointer; }
.demo-accounts button:hover { border-color: var(--ink); }
.form-error { color: var(--bad); font-size: 13px; min-height: 18px; }

/* Espace de métré */
.ws { flex: 1 1 auto; display: grid; grid-template-columns: 250px minmax(0, 1fr) 340px; min-height: 0; }
.ws-left, .ws-right { background: var(--surface); overflow: auto; min-width: 0; }
.ws-left { border-right: 1px solid var(--line); }
.ws-right { border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.panel { padding: 14px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.plan-item { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: center; padding: 7px 8px; border-radius: var(--r); cursor: pointer; border: 1px solid transparent; min-width: 0; }
.plan-item:hover { background: var(--surface-2); }
.plan-item[aria-current="true"] { background: var(--accent-soft); border-color: var(--accent); }
.plan-item .fmt { font: 600 10px var(--f-mono); padding: 2px 4px; border-radius: 3px; background: var(--surface-2); color: var(--muted); }
.plan-item[aria-current="true"] .fmt { background: var(--surface); }
.plan-item div { min-width: 0; }
.plan-item b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-item small { color: var(--muted); font-size: 11.5px; }
.layer-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.layer-row label { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.drop-hint { border: 1px dashed var(--line-strong); border-radius: var(--r); padding: 10px; font-size: 12px; color: var(--muted); text-align: center; }

.ws-center { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--plan-paper); }
.toolbar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tool { width: 34px; height: 32px; border-radius: var(--r); border: 1px solid transparent; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--ink); position: relative; }
.tool:hover { background: var(--surface-2); }
.tool[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.tool svg { width: 18px; height: 18px; }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.ouv-pick { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1 1 260px; }
.ouv-pick select { flex: 1 1 auto; min-width: 0; }
.deduct-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.canvas-wrap { position: relative; flex: 1 1 auto; min-height: 260px; overflow: hidden; touch-action: none; }
.canvas-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.canvas-msg { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--muted); pointer-events: none; }
.canvas-msg > div { max-width: 46ch; display: grid; gap: 8px; pointer-events: auto; }
.statusbar { display: flex; gap: 14px; align-items: center; padding: 5px 12px; font-size: 12px; color: var(--muted); background: var(--surface); border-top: 1px solid var(--line); flex-wrap: nowrap; height: 30px; flex: 0 0 30px; overflow: hidden; white-space: nowrap; }
/* hauteur fixe : un message plus long ne doit jamais changer la taille du plan (le dessin et la souris se décaleraient) */
.statusbar > * { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.statusbar .warn { color: var(--warn); font-weight: 500; }
.zoom-ctl { position: absolute; right: 12px; bottom: 12px; display: grid; gap: 4px; }
.zoom-ctl button { width: 32px; height: 32px; border-radius: var(--r); border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font: 500 16px var(--f-mono); box-shadow: var(--shadow); }
.popover { position: absolute; z-index: 5; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow); padding: 12px; display: grid; gap: 10px; width: min(300px, calc(100% - 24px)); left: 12px; top: 12px; }

.tabs { display: flex; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.tabs button { flex: 1; border: 0; background: none; height: 42px; cursor: pointer; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.m-group { display: grid; gap: 2px; }
.m-group-head { display: flex; align-items: flex-start; gap: 8px; padding: 6px 2px; font-weight: 500; font-size: 13px; }
.m-group-head .dot { margin-top: 5px; }
.m-group-head span:nth-child(2) { flex: 1; min-width: 0; }
.m-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 6px 8px 6px 19px; border-radius: var(--r); cursor: pointer; font-size: 12.5px; border: 1px solid transparent; }
.m-row:hover { background: var(--surface-2); }
.m-row[aria-current="true"] { border-color: var(--accent); background: var(--accent-soft); }
.m-row .q { font-family: var(--f-mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.m-row .meta { grid-column: 1 / -1; display: flex; gap: 4px; flex-wrap: wrap; }
.m-row.pending { border-style: dashed; border-color: var(--ai); }
.m-row.neg .q { color: var(--bad); }
.editor { background: var(--surface-2); border-radius: 8px; padding: 12px; display: grid; gap: 10px; }
.editor .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.formula-line { font: 12px var(--f-mono); color: var(--muted); overflow-wrap: anywhere; }
.banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 8px; background: var(--ai-soft); color: var(--ink); font-size: 13px; }
.banner.warn { background: color-mix(in srgb, var(--warn) 14%, var(--surface)); }
.ai-out { font-size: 13px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.check { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: start; font-size: 12.5px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.check:last-child { border-bottom: 0; }
.sev { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; }
.sev.erreur { background: var(--bad); } .sev.attention { background: var(--warn); } .sev.info { background: var(--muted); }
.cand { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; font-size: 12.5px; align-items: center; }

/* Tableaux (bordereau, bibliothèque, équipe) */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font: 500 10.5px var(--f-body); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line-strong); background: var(--surface); position: sticky; top: 0; white-space: nowrap; }
table.t td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t td.n, table.t th.n { text-align: right; font-family: var(--f-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t tr.lot td { background: var(--surface-2); font-family: var(--f-display); font-weight: 600; font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase; }
table.t tr.sub td { font-weight: 600; }
table.t tr.detail td { color: var(--muted); font-size: 12.5px; padding-top: 4px; padding-bottom: 4px; }
table.t tr.total td { font-weight: 700; border-bottom: 0; }
table.t tr.grand td { font-size: 15px; border-top: 2px solid var(--ink); }
table.t input.input { height: 28px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 0 12px; height: 32px; cursor: pointer; font-weight: 500; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.doc-head { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: end; padding: 18px; border: 1px solid var(--line); border-bottom: 0; border-radius: 8px 8px 0 0; background: var(--surface); }
.doc-head + .table-wrap { border-radius: 0 0 8px 8px; }
.doc-head h2 { font-size: 17px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.totals-note { margin-top: 10px; font-size: 12.5px; color: var(--muted); }

.amb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.amb { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 12px; cursor: pointer; display: grid; gap: 10px; text-align: left; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; flex: none; }
.proj-team { display: flex; gap: 4px; align-items: center; min-height: 26px; border-top: 1px solid var(--line); padding-top: 10px; }
.member-pick { display: grid; gap: 8px; max-height: 320px; overflow: auto; padding: 2px; }
.member-list { display: flex; gap: 8px 16px; flex-wrap: wrap; }
.member { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; }
.ai-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; align-items: start; }
.ai-card { display: grid; gap: 10px; align-content: start; }
.ai-h { font: 600 12px var(--f-display); letter-spacing: .14em; text-transform: uppercase; }
.ai-chk { display: flex; gap: 8px; align-items: center; font-size: 13px; cursor: pointer; }
.ai-meter { position: relative; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: visible; }
.ai-meter i { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--accent); }
.ai-meter.warn i { background: var(--warn); }
.ai-meter.bad i { background: var(--bad); }
.ai-meter s { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--ink); opacity: .45; }
.mat-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.mat-grid .amb { padding: 8px; gap: 6px; }
.amb[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.amb .sw { display: flex; gap: 4px; height: 36px; }
.amb .sw i { flex: 1; border-radius: 3px; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.perm-grid ul { margin: 8px 0 0; padding-left: 18px; font-size: 13px; }
.host-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.host-grid ul { margin: 8px 0 0; padding-left: 18px; font-size: 13px; line-height: 1.6; }

.toast-zone { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(440px, calc(100% - 32px)); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); font-size: 13px; }
.toast.bad { background: var(--bad); color: #fff; }
.modal-back { position: fixed; inset: 0; background: rgba(10, 10, 8, .45); display: grid; place-items: center; padding: 16px; z-index: 40; }
.modal { background: var(--surface); border-radius: 10px; box-shadow: var(--shadow); width: min(520px, 100%); max-height: 90vh; overflow: auto; padding: 20px; display: grid; gap: 14px; }
.modal h2 { font-size: 19px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.mobile-tabs { display: none; }
@media (max-width: 1600px) { .userchip .who { display: none !important; } }
@media (max-width: 1500px) { .topbar .pchip, .topbar .proto-tag { display: none; } .nav button { padding: 0 9px; letter-spacing: .12em; } }
@media (max-width: 1100px) {
  .ws { grid-template-columns: 220px minmax(0, 1fr) 300px; }
}
@media (max-width: 900px) {
  .ws { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .mobile-tabs { display: flex; border-bottom: 1px solid var(--line); background: var(--surface); }
  .mobile-tabs button { flex: 1; height: 40px; border: 0; background: none; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; }
  .mobile-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
  .ws > .ws-left, .ws > .ws-center, .ws > .ws-right { display: none; border: 0; }
  .ws[data-mob="plans"] > .ws-left, .ws[data-mob="plan"] > .ws-center, .ws[data-mob="mesures"] > .ws-right { display: flex; flex-direction: column; }
  .ws-center { min-height: 62vh; }
  .login { grid-template-columns: minmax(0, 1fr); }
  .login-art { min-height: 220px; }
  .login-art .cap { left: 16px; bottom: 16px; }
  .topbar { gap: 8px 12px; padding-block: 6px; }
  .nav { order: 3; flex-basis: 100%; }
  .nav button { height: 40px; }
  .doc-head { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
/* Vue 3D du relevé */
.v3d-back { position: fixed; inset: 0; z-index: 50; background: rgba(10, 10, 8, .55); display: grid; place-items: center; padding: 16px; }
.v3d { background: var(--surface); border-radius: 10px; box-shadow: var(--shadow); width: min(1280px, 100%); height: min(860px, 100%); display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; }
.v3d-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.v3d-head h2 { font-size: 17px; margin: 0; flex: 1 1 auto; }
.v3d canvas { width: 100%; height: 100%; display: block; cursor: grab; background: var(--bg); touch-action: none; }
.v3d-foot { display: flex; gap: 8px 16px; flex-wrap: wrap; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); align-items: center; }
.v3d-foot .sw { display: inline-block; width: 12px; height: 12px; border-radius: 2px; vertical-align: -2px; margin-right: 4px; }
/* Menu contextuel de la planche (clic droit) */
.ctx-menu { position: fixed; z-index: 60; min-width: 230px; max-width: 300px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow); padding: 5px; font-size: 13px; }
.ctx-menu .ctx-title { padding: 6px 10px 4px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.ctx-menu button { display: flex; width: 100%; justify-content: space-between; gap: 12px; align-items: center; border: 0; background: none; padding: 7px 10px; border-radius: 5px; cursor: pointer; color: var(--ink); font: inherit; text-align: left; }
.ctx-menu button:hover, .ctx-menu button:focus { background: var(--surface-2); outline: none; }
.ctx-menu button:disabled { opacity: .45; cursor: default; background: none; }
.ctx-menu button.danger { color: var(--bad); }
.ctx-menu button kbd { font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); }
.ctx-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }

/* Double authentification : QR code, clé, codes à 6 chiffres, codes de secours */
.mfa-qr { display: grid; justify-items: center; }
.mfa-qr svg { width: 200px; height: 200px; image-rendering: pixelated; border: 1px solid var(--line); border-radius: 4px; }
.mfa-key { font-size: 12.5px; text-align: center; }
.mfa-key code { font: 500 13px/1.4 var(--f-mono); letter-spacing: .06em; user-select: all; }
.mfa-link { font-size: 12.5px; text-align: center; color: var(--accent); }
.mfa-code { font: 500 20px/1 var(--f-mono); letter-spacing: .35em; text-align: center; }
.mfa-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 18px; padding: 12px 14px; background: var(--accent-soft); border-radius: 4px; font: 500 13.5px/1.5 var(--f-mono); letter-spacing: .04em; user-select: all; }
