/* =========================================================================
   AutoBâti — feuille de style
   Variables (thème clair / sombre) · mise en page responsive · impression
   ========================================================================= */

:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #f0eee8;
  --text: #1d1f22;
  --text-2: #5d6168;
  --border: #e1ded6;
  --accent: #c2531b;          /* terre cuite */
  --accent-strong: #a3430f;
  --accent-soft: #fbe9df;
  --ok: #2f7d4f;
  --danger: #b42318;
  --poste-1: #8c6a3f;
  --poste-2: #c2531b;
  --poste-3: #2f6f9f;
  --poste-4: #6b5bb5;
  --poste-5: #3f8f6b;
  --poste-6: #2a8a8a;
  --poste-7: #8a5a2b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 20, 20, .04), 0 4px 16px rgba(20, 20, 20, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141517;
    --surface: #1d1f22;
    --surface-2: #26282c;
    --text: #ececea;
    --text-2: #a3a6ad;
    --border: #33363b;
    --accent: #e57a45;
    --accent-strong: #f08f5d;
    --accent-soft: #3a261c;
    --ok: #5cc28a;
    --danger: #f2766b;
    --poste-1: #c49a63;
    --poste-2: #e57a45;
    --poste-3: #5fa3d6;
    --poste-4: #9c8ce0;
    --poste-5: #62c095;
    --poste-6: #4fc0c0;
    --poste-7: #d6a06a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #141517;
    --surface: #1d1f22;
    --surface-2: #26282c;
    --text: #ececea;
    --text-2: #a3a6ad;
    --border: #33363b;
    --accent: #e57a45;
    --accent-strong: #f08f5d;
    --accent-soft: #3a261c;
    --ok: #5cc28a;
    --danger: #f2766b;
    --poste-1: #c49a63;
    --poste-2: #e57a45;
    --poste-3: #5fa3d6;
    --poste-4: #9c8ce0;
    --poste-5: #62c095;
    --poste-6: #4fc0c0;
    --poste-7: #d6a06a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
}
h2 { font-size: 1.1rem; margin: 0 0 1rem; display: flex; align-items: center; gap: .5rem; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); margin: 1.5rem 0 .6rem; }
h3 small { text-transform: none; letter-spacing: 0; font-weight: 400; }
a { color: var(--accent-strong); }
button, input, select { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; }
.skip-link:focus { left: 1rem; top: 1rem; z-index: 100; background: var(--surface); padding: .5rem 1rem; border-radius: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- En-tête ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  padding: .7rem max(16px, calc((100vw - 1280px) / 2 + 16px));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .45rem; font-weight: 700; font-size: 1.1rem; color: var(--accent); }
.brand-logo { width: 26px; height: 26px; }
.brand-name { color: var(--text); }
.project-name { flex: 1; min-width: 0; }
.project-name input {
  width: 100%; max-width: 420px; border: 1px solid transparent; background: transparent;
  padding: .35rem .6rem; border-radius: 8px; font-weight: 600;
}
.project-name input:hover, .project-name input:focus { border-color: var(--border); background: var(--surface); }

.save-indicator {
  display: inline-flex; align-items: center; gap: .45rem;
  font-size: .78rem; color: var(--text-2); white-space: nowrap;
}
.save-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); opacity: .55; transition: opacity .3s, transform .3s; }
.save-indicator.is-fresh .save-dot { opacity: 1; animation: pulse 1.2s ease-out; }
.save-indicator.is-error { color: var(--danger); white-space: normal; }
.save-indicator.is-error .save-dot { background: var(--danger); opacity: 1; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); } 100% { box-shadow: 0 0 0 8px transparent; } }

/* ---------- Mise en page ---------- */
.layout { max-width: 1280px; margin: 0 auto; padding: 1.25rem 16px 4rem; display: grid; gap: 1.25rem; }
.colonnes { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.pile { display: grid; gap: 1.25rem; }
.carte { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.titre-section { margin: .5rem 0 1rem; }
.tag { font-size: .7rem; font-weight: 600; padding: .15rem .5rem; border-radius: 99px; background: var(--accent-soft); color: var(--accent-strong); }

/* ---------- Tableau de bord ---------- */
.dashboard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.kpi { display: flex; flex-direction: column; gap: .15rem; padding: .25rem 0; }
.kpi + .kpi { border-left: 1px solid var(--border); padding-left: 1rem; }
.kpi-label { font-size: .8rem; color: var(--text-2); }
.kpi-value { font-size: clamp(1.4rem, 3.2vw, 2rem); font-weight: 700; letter-spacing: -.02em; }
.kpi-main .kpi-value { color: var(--accent); }
.kpi-sub { font-size: .78rem; color: var(--text-2); }
.repartition-bloc { margin-top: 1.1rem; }
.repartition { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--surface-2); gap: 2px; }
.repart-seg { display: block; height: 100%; transition: width .35s ease; }
.legende { list-style: none; padding: 0; margin: .8rem 0 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .5rem 1rem; }
.legende li { display: grid; grid-template-columns: auto 1fr; column-gap: .4rem; font-size: .8rem; }
.legende .leg-label { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legende strong { grid-column: 2; font-size: .95rem; }
.legende .leg-pct { grid-column: 2; color: var(--text-2); font-size: .75rem; }
.puce { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-top: .3rem; flex: none; }

/* ---------- Formulaires ---------- */
.field { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--text-2); margin-bottom: .8rem; }
.field input, .field select, .input-suffix {
  width: 100%; min-height: 40px; padding: .45rem .65rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font-size: .95rem;
}
.input-suffix { display: flex; align-items: center; padding: 0; overflow: hidden; }
.input-suffix input { border: 0; min-height: 38px; flex: 1; min-width: 0; }
.input-suffix em { font-style: normal; padding: 0 .65rem; color: var(--text-2); background: var(--surface-2); align-self: stretch; display: flex; align-items: center; }
.field input:focus, .field select:focus, .input-suffix:focus-within { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.input-suffix input:focus { box-shadow: none; outline: none; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.dims { grid-column: 1 / -1; }
.grid-3.dims { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.dims .field { margin-bottom: .8rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 .75rem; }

fieldset { border: 0; padding: 0; margin: 0 0 .8rem; min-width: 0; }
legend { font-size: .85rem; color: var(--text-2); margin-bottom: .3rem; padding: 0; }
.segmented { display: flex; flex-wrap: wrap; }
.segmented legend { width: 100%; }
.segmented label { flex: 1; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: block; text-align: center; padding: .55rem .75rem; min-height: 40px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); font-weight: 500; font-size: .9rem;
}
.segmented label:first-of-type span { border-radius: 8px 0 0 8px; }
.segmented label:last-of-type span { border-radius: 0 8px 8px 0; border-left: 0; }
.segmented input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.switch { display: flex; align-items: center; gap: .65rem; cursor: pointer; margin-bottom: .9rem; font-size: .9rem; }
.switch input { position: absolute; opacity: 0; }
.switch-ui { width: 38px; height: 22px; border-radius: 99px; background: var(--border); position: relative; flex: none; transition: background .2s; }
.switch-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + .switch-ui { background: var(--accent); }
.switch input:checked + .switch-ui::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--accent); outline-offset: 2px; }

.checkbox { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--text-2); margin-bottom: .8rem; align-self: end; min-height: 40px; }
.checkbox input, .c-toggle input { width: 18px; height: 18px; accent-color: var(--accent); }

.sous-bloc { margin-top: .5rem; border: 1px solid var(--border); border-radius: 8px; padding: .6rem .8rem; }
.sous-bloc summary { cursor: pointer; font-size: .85rem; font-weight: 600; }
.sous-bloc[open] summary { margin-bottom: .8rem; }

.toit-eval { border: 1px solid var(--border); border-radius: 8px; padding: .75rem .9rem; margin-bottom: .8rem; display: grid; gap: .6rem; font-size: .84rem; }
.toit-eval-tete { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; color: var(--text-2); }
.pill { font-size: .72rem; font-weight: 700; padding: .15rem .55rem; border-radius: 99px; }
.pill-compatible { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.pill-deconseille { background: color-mix(in srgb, #d08a00 18%, transparent); color: #a86f00; }
.pill-incompatible { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.toit-attributs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem 1rem; margin: 0; }
.toit-attributs dt { font-size: .72rem; color: var(--text-2); }
.toit-attributs dd { margin: 0; font-weight: 600; }
.toit-motifs, .toit-conseils { margin: 0; padding-left: 1.1rem; display: grid; gap: .25rem; }
.toit-motifs { color: var(--text); }
.toit-conseils { color: var(--text-2); }
.toit-eval .erreur { margin: 0; }
.eq-liste { display: grid; gap: .6rem; margin-bottom: .6rem; }
.eq-ligne { border: 1px solid var(--border); border-radius: 8px; padding: .6rem .8rem .1rem; background: var(--surface-2); }
.eq-tete { display: flex; justify-content: space-between; align-items: center; font-size: .82rem; margin-bottom: .4rem; }
.eq-grille { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 .75rem; }
.eq-grille .eq-gen { grid-column: 1 / -1; }
.eq-grille select { width: 100%; min-height: 40px; padding: .45rem .65rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: .92rem; }
.eq-info { font-style: normal; color: var(--text-2); font-size: .82rem; min-height: 40px; display: flex; align-items: center; }
.eq-ajouter { margin-bottom: 1rem; }
.ch-conseils summary { cursor: pointer; color: var(--text-2); font-size: .82rem; }
.ch-conseils[open] summary { margin-bottom: .4rem; }
.pertes { display: grid; gap: .4rem; }
.perte { display: grid; grid-template-columns: minmax(0, 1fr) minmax(120px, 1.2fr) 3.2rem; align-items: center; gap: .75rem; font-size: .88rem; }
.perte-label { display: flex; gap: .45rem; align-items: center; }
.perte-label .puce { margin-top: 0; }
.perte input[type=range] { width: 100%; accent-color: var(--accent); }
.perte output { text-align: right; font-weight: 600; }
.presets { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .8rem; font-size: .82rem; color: var(--text-2); }

.aide { font-size: .78rem; color: var(--text-2); margin: .8rem 0 0; }
.avertissement { margin-top: 1rem; }
.erreur { color: var(--danger); font-size: .85rem; margin: 0 0 .6rem; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 40px;
  padding: .5rem 1rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; font-weight: 600; font-size: .88rem;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost { min-height: 32px; padding: .25rem .65rem; font-weight: 500; }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost.is-armed { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-icon { width: 30px; height: 30px; border-radius: 6px; border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--text-2); font-size: 1rem; }
.btn-icon:hover { background: var(--surface-2); border-color: var(--border); }
.btn-danger:hover { color: var(--danger); }

/* ---------- Injecteur ---------- */
.injecteur { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1rem; }
.field-full { grid-column: 1 / -1; }

.hypotheses { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem 1rem; margin: 0; }
.hypotheses div { display: flex; flex-direction: column; }
.hypotheses dt { font-size: .75rem; color: var(--text-2); }
.hypotheses dd { margin: 0; font-weight: 600; font-size: .9rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.actions .aide { width: 100%; margin-top: .3rem; }

/* ---------- Postes ---------- */
.postes { display: grid; gap: .75rem; }
.poste { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--poste-couleur); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.poste summary { display: flex; align-items: center; gap: .9rem; padding: .9rem 1.1rem; cursor: pointer; list-style: none; }
.poste summary::-webkit-details-marker { display: none; }
.poste summary::after { content: "›"; font-size: 1.3rem; color: var(--text-2); transition: transform .2s; }
.poste[open] summary::after { transform: rotate(90deg); }
.poste-num { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--poste-couleur); color: #fff; font-weight: 700; flex: none; }
.poste-titre { flex: 1; font-weight: 650; display: flex; flex-direction: column; min-width: 0; }
.poste-titre small { font-weight: 400; color: var(--text-2); font-size: .78rem; }
.poste-totaux { display: flex; flex-direction: column; align-items: flex-end; font-size: .8rem; color: var(--text-2); }
.poste-totaux strong { font-size: 1.05rem; color: var(--text); }
.vide { padding: 0 1.1rem 1rem; color: var(--text-2); font-size: .88rem; }

.table-wrap { overflow-x: auto; border-top: 1px solid var(--border); }
table.lignes { width: 100%; border-collapse: collapse; font-size: .84rem; }
.lignes th { text-align: left; font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); padding: .55rem .6rem; background: var(--surface-2); white-space: nowrap; }
.lignes td { padding: .45rem .6rem; border-top: 1px solid var(--border); vertical-align: middle; }
.lignes .c-num { text-align: right; white-space: nowrap; }
.lignes .c-toggle { width: 36px; text-align: center; }
.lignes .c-action { width: 40px; text-align: center; }
.lignes .c-unite { white-space: nowrap; color: var(--text-2); }
.c-designation { min-width: 260px; }
.designation { display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .45rem; }
.designation small { width: 100%; color: var(--text-2); font-size: .74rem; }
.cell-input { width: 104px; text-align: right; padding: .3rem .45rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); font-size: .84rem; }
.cell-input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
tr.is-off td:not(.c-toggle) { opacity: .55; }   /* ligne non retenue (décochée) */
.badge { font-size: .68rem; font-weight: 600; padding: .05rem .4rem; border-radius: 99px; background: var(--surface-2); color: var(--text-2); }
.badge-web { background: color-mix(in srgb, var(--poste-3) 18%, transparent); color: var(--poste-3); }
.badge-devis { background: color-mix(in srgb, var(--poste-4) 18%, transparent); color: var(--poste-4); }
tr.is-devis td { background: color-mix(in srgb, var(--poste-4) 6%, transparent); }
.aide-top { margin: -.5rem 0 1rem; }
.aide-inline { font-size: .75rem; color: var(--text-2); }
.field select:disabled { opacity: .6; }
.liste-devis { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: .5rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.liste-devis li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: .75rem; font-size: .85rem; }
.liste-devis li.is-off { opacity: .5; }
.liste-devis small { display: block; color: var(--text-2); font-size: .75rem; }
.devis-montant { font-weight: 700; text-align: right; white-space: nowrap; }
.devis-montant small { display: inline; margin-left: .25rem; font-weight: 400; }
.badge-manuel { background: var(--accent-soft); color: var(--accent-strong); }
.badge-prix { background: color-mix(in srgb, var(--ok, #2f7d4f) 16%, transparent); color: var(--ok, #2f7d4f); }
.badge-estime { background: transparent; color: var(--text-2); border: 1px dashed currentColor; }
.prix-estime .cell-input { color: var(--text-2); font-style: italic; }
.prix-estimes { margin: .75rem 0 0; padding: .5rem .75rem; border-radius: 8px; background: var(--accent-soft); color: var(--accent-strong); font-size: .85rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translate(-50%, 150%); z-index: 50;
  background: var(--text); color: var(--bg); padding: .7rem 1.1rem; border-radius: 10px; font-size: .88rem;
  max-width: calc(100vw - 32px); transition: transform .25s ease; box-shadow: 0 6px 24px rgba(0,0,0,.2);
}
.toast.is-visible { transform: translate(-50%, 0); }
.toast.is-error { background: var(--danger); color: #fff; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .colonnes { grid-template-columns: minmax(0, 1fr); }
  .legende { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  body { font-size: 14px; }
  .topbar { flex-wrap: wrap; gap: .4rem .75rem; padding: .6rem 16px; }
  .project-name { order: 3; flex-basis: 100%; }
  .save-indicator { margin-left: auto; font-size: .72rem; }
  .save-indicator .save-text { max-width: 52vw; overflow: hidden; text-overflow: ellipsis; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi-main { grid-column: 1 / -1; order: -1; border-bottom: 1px solid var(--border); padding-bottom: .75rem; }
  .kpi + .kpi { border-left: 0; padding-left: 0; }
  .kpi:nth-child(2) { border-left: 1px solid var(--border); padding-left: 1rem; }
  .legende { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-3, .injecteur, .hypotheses, .toit-attributs { grid-template-columns: minmax(0, 1fr); }
  .perte { grid-template-columns: minmax(0, 1fr) 3rem; }
  .perte input[type=range] { grid-column: 1 / -1; grid-row: 2; }
  .poste summary { flex-wrap: wrap; }
  .poste-totaux { flex-basis: 100%; flex-direction: row; justify-content: space-between; padding-left: calc(28px + .9rem); }

  /* Tableau → cartes empilées */
  .table-wrap { overflow: visible; }
  .lignes thead { display: none; }
  .lignes, .lignes tbody, .lignes tr, .lignes td { display: block; width: 100%; }
  .lignes tr { position: relative; padding: .7rem 1rem .7rem 2.8rem; border-top: 1px solid var(--border); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .25rem .75rem; }
  .lignes td { border: 0; padding: 0; text-align: left !important; }
  .lignes td.c-toggle { position: absolute; left: .8rem; top: .75rem; width: auto; }
  .lignes td.c-designation { grid-column: 1 / -1; min-width: 0; margin-bottom: .3rem; font-weight: 500; }
  .lignes td.c-action { position: absolute; right: .5rem; top: .5rem; width: auto; }
  .lignes td[data-label] { display: flex; justify-content: space-between; align-items: center; gap: .5rem; font-size: .82rem; }
  .lignes td[data-label]::before { content: attr(data-label); color: var(--text-2); font-size: .74rem; }
  .cell-input { width: 76px; }
  .lignes td[data-label] { min-width: 0; }
  .poste summary::after { display: none; }
}

/* ---------- Impression / PDF ---------- */
@media print {
  :root { --bg: #fff; --surface: #fff; --shadow: none; }
  body { font-size: 10pt; }
  .topbar { position: static; backdrop-filter: none; }
  .save-indicator, .injecteur, .aide-top, .actions, .presets, .skip-link, .toast, #reset-pertes, .c-action, .c-toggle { display: none !important; }
  .colonnes { grid-template-columns: 1fr; }
  .pile:not(.pile-gauche) > .carte:first-child { display: none; }
  .poste { break-inside: auto; box-shadow: none; }
  .poste summary::after { display: none; }
  .cell-input { border: 0; width: auto; padding: 0; }
  tr.is-off { display: none; }
  .table-wrap { overflow: visible; }
}

/* Gros œuvre : arbre Étapes → Sous-catégories */
.go-etapes { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .55rem; }
.go-etape > strong { font-size: .86rem; }
.go-etape.is-inactive { color: var(--text-2); }
.go-etape.is-inactive > strong { font-weight: 500; }
.go-etape .go-motif { font-size: .78rem; margin-left: .4rem; }
.go-sc { list-style: none; margin: .25rem 0 0; padding: 0 0 0 .9rem; border-left: 2px solid var(--border); display: grid; gap: .2rem; }
.go-sc li { font-size: .8rem; display: flex; flex-wrap: wrap; gap: .15rem .5rem; align-items: baseline; }
.go-sc .go-meta { color: var(--text-2); font-size: .74rem; }
.go-badge { font-size: .68rem; padding: .05rem .4rem; border-radius: 999px; background: var(--surface-2, rgba(127,127,127,.12)); color: var(--text-2); white-space: nowrap; }
.go-badge.auto { background: color-mix(in srgb, var(--accent, #c2410c) 14%, transparent); color: var(--accent, #c2410c); }

/* Un élément masqué par l’attribut hidden le reste, même s’il porte une classe qui fixe display */
[hidden] { display: none !important; }

/* Détail groupé (gros œuvre) : lignes de titre d'étape et de sous-catégorie */
.lignes tr.grp .grp-ligne { display: flex; justify-content: space-between; align-items: baseline; gap: .4rem 1rem; flex-wrap: wrap; }
.lignes tr.grp-etape td { background: var(--surface-2); font-weight: 700; font-size: .84rem; padding-top: .6rem; padding-bottom: .6rem; border-top: 2px solid var(--border); }
.lignes tr.grp-sc td { font-weight: 600; font-size: .8rem; padding-left: 1.6rem; color: var(--text); }
.lignes tr.grp small { font-weight: 400; color: var(--text-2); margin-left: .5rem; font-size: .74rem; }
.lignes tr.grp .grp-total { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: .78rem; }
.lignes tr.grp-sc .grp-total { color: var(--text-2); font-weight: 500; }
@media (max-width: 640px) {
  .lignes tr.grp { display: block; padding: 0; }
  .lignes tr.grp td { display: block; padding: .55rem 1rem; }
  .lignes tr.grp-sc td { padding-left: 1.4rem; }
}

/* Cases de groupe et outils de poste */
.lignes tr.grp .grp-titre { display: inline-flex; align-items: baseline; gap: .5rem; cursor: pointer; flex-wrap: wrap; }
.lignes tr.grp .grp-titre input { align-self: center; width: 1.05rem; height: 1.05rem; accent-color: var(--accent); margin: 0; }
.poste-outils { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .6rem 1rem; border-top: 1px solid var(--border); }
.poste-outils .aide { margin: 0; }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; min-height: 0; }
@media print { .poste-outils, .lignes tr.grp input { display: none; } }

/* Menuiseries extérieures : cartes de saisie */
.mx-liste { display: grid; gap: .6rem; margin-top: .6rem; }
.mx-carte { border: 1px solid var(--border); border-radius: 10px; padding: .7rem .8rem; background: var(--surface); }
.mx-carte.is-erreur { border-color: color-mix(in srgb, var(--danger) 50%, var(--border)); }
.mx-tete { display: flex; align-items: center; gap: .6rem; justify-content: space-between; margin-bottom: .5rem; }
.mx-tete strong { font-size: .88rem; }
.mx-tete .mx-total { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; font-size: .86rem; white-space: nowrap; }
.mx-grille { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem .6rem; }
.mx-grille .mx-large { grid-column: span 2; }
.mx-grille .field span:first-child { font-size: .74rem; }
.mx-pied { margin: .45rem 0 0; font-size: .76rem; color: var(--text-2); }
.mx-pied.erreur { color: var(--danger); }
.mx-ajout { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem; margin: .7rem 0 .4rem; }
.mx-ajout .field { flex: 1 1 200px; margin: 0; }
.mx-vide { font-size: .82rem; color: var(--text-2); padding: .6rem 0; }
@media (max-width: 640px) {
  .mx-grille { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Blocs repliables du formulaire Projet */
details.bloc { border: 1px solid var(--border); border-radius: 10px; margin-top: .6rem; background: var(--surface); }
details.bloc > summary.bloc-tete { display: flex; align-items: baseline; gap: .4rem .8rem; flex-wrap: wrap; padding: .7rem .9rem; cursor: pointer; list-style: none; }
details.bloc > summary::-webkit-details-marker { display: none; }
details.bloc > summary.bloc-tete::after { content: "›"; margin-left: auto; font-size: 1.2rem; line-height: 1; color: var(--text-2); transition: transform .2s; align-self: center; }
details.bloc[open] > summary.bloc-tete::after { transform: rotate(90deg); }
details.bloc[open] > summary.bloc-tete { border-bottom: 1px solid var(--border); }
.bloc-titre { font-weight: 700; font-size: .78rem; letter-spacing: .05em; text-transform: uppercase; color: var(--text); }
.bloc-titre small { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--text-2); }
.bloc-resume { font-size: .8rem; color: var(--text-2); min-width: 0; flex: 1 1 12rem; }
.bloc-corps { padding: .2rem .9rem .9rem; }
.bloc-corps > .grid-2:first-child, .bloc-corps > .field:first-child { margin-top: .6rem; }
/* Étapes repliables dans le détail du Gros Œuvre */
.grp-bascule { order: 4; margin-left: .2rem; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 999px; font-size: .72rem; padding: .15rem .65rem; cursor: pointer; }
.grp-bascule:hover { color: var(--text); border-color: var(--text-2); }
.lignes tr.grp-etape .grp-ligne { align-items: center; }
.lignes tr.grp-etape .grp-total { order: 3; margin-left: auto; }
@media print { details.bloc { break-inside: avoid; } .grp-bascule { display: none; } }

/* ===== Cotes de la maison ===== */
.dims { margin-top: .25rem; align-items: end; }
.dims-aide { margin: .35rem 0 .9rem; }
.dims-aide.avertissement { color: var(--danger); }
@media (max-width: 720px) { .grid-3.dims { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 .5rem; } .dims .field > span:first-child { font-size: .8rem; } }

/* ===== Bloc béton rectifié (Technibloc) ===== */
.go-tb-bilan { margin: .75rem 0; padding: .75rem .9rem; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 10px; background: var(--surface); }
.go-tb-bilan .tb-titre { display: block; font-size: .9rem; margin-bottom: .4rem; }
.tb-liste { display: grid; gap: .3rem; margin: 0; }
.tb-liste > div { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: .5rem; font-size: .85rem; }
.tb-liste dt { color: var(--text-2); }
.tb-liste dd { margin: 0; }
@media (max-width: 720px) { .tb-liste > div { grid-template-columns: minmax(0, 1fr); gap: 0; } }

/* ===== Escalier (catégorie indépendante) ===== */
.esc-statut { margin: .4rem 0 .6rem; }
.esc-edition { border: 0; padding: 0; margin: 0; min-width: 0; }
.esc-edition:disabled { opacity: .6; }
.esc-options { display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; margin-top: .55rem; font-size: .84rem; }
.esc-options .check { display: inline-flex; align-items: center; gap: .4rem; }
.esc-options input:disabled + span { opacity: .5; }

/* ===== Suivi de chantier ===== */
.sc-section .aide-top { margin: -.4rem 0 .8rem; }
.sc-avancement { display: grid; gap: .7rem; margin-bottom: .75rem; }
.sc-tete { display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem 1rem; color: var(--text-2); font-size: .88rem; }
.sc-pct { font-size: 1.6rem; color: var(--accent); letter-spacing: -.02em; }
.sc-prochain { margin-left: auto; color: var(--text); font-weight: 600; }
.sc-barre, .sc-mini-barre { display: block; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.sc-barre > span, .sc-mini-barre > span { display: block; height: 100%; background: var(--ok); transition: width .3s; }
.sc-mini-barre { width: 90px; height: 5px; margin-top: .3rem; }
.sc-mini-barre > span { background: var(--poste-couleur); }
.sc-jalons { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.sc-jalons li { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; padding: .25rem .65rem .25rem .3rem; border: 1px solid var(--border); border-radius: 99px; color: var(--text-2); }
.sc-jalons li small { font-size: .7rem; }
.sc-jalon-puce { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--border); display: grid; place-items: center; font-size: .7rem; font-weight: 700; }
.sc-jalons li.is-atteint { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); background: color-mix(in srgb, var(--ok) 8%, transparent); }
.sc-jalons li.is-atteint .sc-jalon-puce { background: var(--ok); border-color: var(--ok); color: #fff; }
.sc-postes { border-top: 1px solid var(--border); }
.sc-poste { border-top: 1px solid var(--border); }
.sc-poste:first-child { border-top: 0; }
.sc-poste > summary { display: flex; align-items: center; gap: .7rem; padding: .6rem 1.1rem; cursor: pointer; list-style: none; }
.sc-poste > summary::-webkit-details-marker { display: none; }
.sc-puce { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--border); flex: none; }
.sc-poste.is-enCours .sc-puce { border-color: #d08a00; background: color-mix(in srgb, #d08a00 35%, transparent); }
.sc-poste.is-valide .sc-puce { border-color: var(--ok); background: var(--ok); }
.sc-poste.is-nonConcerne { opacity: .55; }
.sc-nom { flex: 1; min-width: 0; font-size: .88rem; font-weight: 600; display: flex; flex-direction: column; }
.sc-nom small { font-weight: 400; color: var(--text-2); font-size: .74rem; }
.sc-statut { font-size: .72rem; font-weight: 600; padding: .12rem .55rem; border-radius: 99px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.sc-statut.is-enCours { background: color-mix(in srgb, #d08a00 16%, transparent); color: #a86f00; }
.sc-statut.is-valide { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.sc-corps { padding: 0 1.1rem .9rem 2.6rem; font-size: .84rem; display: grid; gap: .5rem; }
.sc-def { margin: 0; color: var(--text); }
.sc-taches { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
.sc-taches label { display: inline-flex; gap: .5rem; align-items: center; cursor: pointer; }
.sc-taches input { width: 17px; height: 17px; accent-color: var(--ok); }
.sc-taches input:checked + span { color: var(--text-2); text-decoration: line-through; }
.sc-mat { margin: 0; color: var(--text-2); }
.sc-mat strong { color: var(--text); font-weight: 600; }
.sc-actions { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.sc-actions .btn.is-actif { background: var(--accent); border-color: var(--accent); color: #fff; }
.sc-actions small { color: var(--text-2); font-size: .74rem; }
@media (max-width: 640px) {
  .sc-prochain { margin-left: 0; flex-basis: 100%; }
  .sc-corps { padding-left: 1.1rem; }
  .sc-phase .poste-totaux { align-items: center; }
}
.sc-planning { display: flex; flex-wrap: wrap; align-items: end; gap: .5rem 1rem; padding-top: .7rem; border-top: 1px solid var(--border); }
.sc-planning .aide, .sc-plan-bilan { margin: 0 0 .35rem; flex: 1 1 240px; }
.sc-date { margin: 0; max-width: 190px; }
.sc-plan-bilan { font-weight: 600; font-size: .88rem; }
.sc-retard, .sc-badge-retard { color: var(--danger, #c0392b); }
.sc-avance { color: var(--ok); }
.sc-badge-retard { font-size: .7rem; font-weight: 700; padding: .1rem .45rem; border-radius: 99px; background: color-mix(in srgb, var(--danger, #c0392b) 12%, transparent); white-space: nowrap; }
.sc-frise { --lbl: 112px; display: grid; gap: .3rem; position: relative; font-size: .74rem; }
.sc-frise-ligne { display: grid; grid-template-columns: var(--lbl) 1fr; align-items: center; gap: .5rem; }
.sc-lane-nom { display: flex; gap: .35rem; align-items: center; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-piste { position: relative; height: 18px; border-radius: 4px; background: var(--surface-2); }
.sc-frise-tete .sc-piste { background: none; height: 20px; border-bottom: 1px solid var(--border); border-radius: 0; }
.sc-frise-jalons .sc-piste { background: none; height: 14px; }
.sc-frise-jalons .sc-lane-nom { font-size: .68rem; }
.sc-grad { position: absolute; bottom: 1px; transform: translateX(-50%); color: var(--text-2); font-size: .66rem; white-space: nowrap; }
.sc-grad::before { content: ''; position: absolute; left: 50%; bottom: -2px; height: 4px; border-left: 1px solid var(--border); }
.sc-losange { position: absolute; top: 2px; width: 10px; height: 10px; margin-left: -5px; transform: rotate(45deg); background: var(--surface); border: 1.5px solid var(--accent); cursor: help; }
.sc-losange.is-atteint { background: var(--ok); border-color: var(--ok); }
.sc-seg-prevu, .sc-seg, .sc-seg-retard { position: absolute; top: 3px; bottom: 3px; border-radius: 3px; }
.sc-seg-prevu { top: 1px; bottom: 1px; border: 1.5px dashed color-mix(in srgb, var(--poste-couleur) 70%, transparent); }
.sc-seg { background: color-mix(in srgb, var(--poste-couleur) 35%, transparent); overflow: hidden; }
.sc-seg-fait { display: block; height: 100%; background: var(--poste-couleur); }
.sc-seg-retard { background: repeating-linear-gradient(45deg, var(--danger, #c0392b) 0 3px, transparent 3px 6px); opacity: .75; }
.sc-frise-auj { position: absolute; inset: 0; pointer-events: none; }
.sc-frise-auj .sc-piste { background: none; height: 100%; }
.sc-auj { position: absolute; top: 0; bottom: 0; border-left: 2px solid var(--accent); }
.sc-auj { font-size: 0; }
.sc-piste small { position: absolute; left: .4rem; top: 1px; color: var(--text-2); }
.sc-duree { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .8rem; }
.sc-duree label { display: inline-flex; align-items: center; gap: .4rem; }
.sc-duree input { width: 4.5rem; padding: .25rem .4rem; }
.sc-duree small { color: var(--text-2); font-size: .74rem; }
@media (max-width: 560px) {
  .sc-frise { --lbl: 26px; }
  .sc-lane-lib { display: none; }
  .sc-frise-jalons .sc-lane-nom { font-size: 0; }
  .sc-grad:nth-child(even) { display: none; }
}
.sc-badge-photo { font-size: .72rem; color: var(--text-2); white-space: nowrap; }
.sc-code { display: inline-block; font: .72rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; padding: .05rem .35rem; margin: .1rem .25rem .1rem 0; border-radius: 4px; background: var(--surface-2); color: var(--text-2); word-break: break-all; }
.sc-preuves { display: grid; gap: .4rem; }
.sc-preuves-liste { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .4rem; }
.sc-preuves-liste:empty { display: none; }
.sc-vignette { margin: 0; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.sc-vignette img { display: block; width: 100%; height: 80px; object-fit: cover; }
.sc-vignette figcaption { display: flex; justify-content: space-between; align-items: center; gap: .3rem; padding: .15rem .35rem; font-size: .68rem; color: var(--text-2); }
.sc-suppr-preuve { border: 0; background: none; color: var(--text-2); cursor: pointer; font-size: .72rem; min-width: 24px; min-height: 24px; padding: 0 .2rem; }
.sc-suppr-preuve.is-armed { color: var(--danger); font-weight: 700; }
.sc-photo { justify-self: start; cursor: pointer; }
.sc-photo:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.sv-etat { margin: 0; font-size: .78rem; color: var(--text-2); flex-basis: 100%; }
.sv-etat.is-alerte { color: var(--danger); font-weight: 600; }
dialog.avertissement { max-width: 640px; width: calc(100% - 32px); border: 1px solid var(--border); border-radius: 12px; padding: 1.2rem 1.3rem 1rem; background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog.avertissement::backdrop { background: rgba(15, 18, 22, .55); }
dialog.avertissement h2 { margin: 0 0 .7rem; font-size: 1.1rem; }
.avt-corps { max-height: min(55vh, 460px); overflow-y: auto; font-size: .86rem; line-height: 1.55; padding-right: .3rem; }
.avt-corps p { margin: 0 0 .7rem; }
.avt-corps:focus:not(:focus-visible) { outline: none; }
.avt-pied { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem; margin-top: .8rem; padding-top: .8rem; border-top: 1px solid var(--border); }
.avt-accord { display: inline-flex; gap: .5rem; align-items: center; font-size: .86rem; cursor: pointer; }
.avt-accord input { width: 18px; height: 18px; accent-color: var(--accent); }
.avt-version { display: block; margin-top: .5rem; color: var(--text-2); font-size: .7rem; }
.sc-justifs { display: grid; gap: .4rem; }
.sc-justif-liste { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
.sc-justif-liste li { display: flex; align-items: center; gap: .5rem; padding: .35rem .5rem; border: 1px solid var(--border); border-radius: 6px; }
.sc-justif-type { flex: none; font-size: .68rem; font-weight: 700; padding: .1rem .45rem; border-radius: 99px; background: var(--surface-2); color: var(--text-2); }
.sc-justif-type.is-devis { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.sc-justif-type.is-facture { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.sc-justif-nom { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sc-justif-nom a { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-justif-nom small { color: var(--text-2); font-size: .7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-justif-form { display: grid; grid-template-columns: 110px 1fr 2fr auto; gap: .35rem; align-items: center; }
.sc-justif-form select, .sc-justif-form input { min-width: 0; padding: .3rem .45rem; font-size: .82rem; }
.sc-justif-form input[aria-invalid="true"] { border-color: var(--danger); }
.sc-justif-erreur { grid-column: 1 / -1; margin: 0; font-size: .76rem; }
@media (max-width: 640px) { .sc-justif-form { grid-template-columns: 1fr 1fr; } .sc-justif-form input[name="url"], .sc-justif-boutons { grid-column: 1 / -1; } .sc-justif-boutons .btn { flex: 1; } }
.sc-justif-boutons { display: inline-flex; gap: .3rem; }
.bandeau { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .7rem;
  width: min(560px, calc(100% - 32px)); padding: .7rem .9rem; border-radius: 12px; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0,0,0,.18); font-size: .86rem; }
.bandeau > span { flex: 1 1 220px; }
.bandeau-alerte { top: max(12px, env(safe-area-inset-top)); bottom: auto; border-color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
dialog.partage .partage-form { display: grid; gap: .7rem; }
dialog.partage h2 { margin: 0; }
.partage-lien { margin: 0; display: grid; gap: .1rem; padding: .5rem .6rem; border-radius: 8px; background: var(--surface-2); }
.partage-lien small { color: var(--text-2); font-size: .74rem; word-break: break-all; }
dialog.partage select, dialog.partage input { width: 100%; }
dialog.partage .erreur { margin: 0; }
@media print { .bandeau, .sc-justif-form, .sc-photo, .sc-suppr-preuve, .sc-actions, .sc-taches input, .sc-duree input, .sc-date input { display: none; } }

/* Surfaces calculées depuis les cotes */
.dim-surfaces { margin: .5rem 0 0; padding: .6rem .75rem; border-radius: 8px; background: var(--surface-2); display: grid; gap: .4rem; }
.dim-surface { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .5rem; }
.dim-surface > span { font-size: .85rem; color: var(--text-2); }
.dim-surface > strong { font-size: 1rem; }
.dim-surface > small { flex-basis: 100%; color: var(--text-2); font-size: .75rem; }
.dim-surfaces .aide { margin: 0; }
.dim-surfaces .btn { justify-self: start; }

/* ===== Licence (js/licence.js) ===== */
.licence-champ { width: 100%; font: .82rem/1.4 ui-monospace, Consolas, monospace; padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); resize: vertical; word-break: break-all; }
.licence-motif { padding: .5rem .7rem; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 6px; }
dialog.licence .erreur { margin: .4rem 0 0; }
.licence-etat { margin: 0; font-size: .8rem; }
.liens-legaux { margin: .4rem 0 0; font-size: .8rem; color: var(--text-2); }
.liens-legaux a { color: inherit; }
.avt-cles { margin: 0 0 .9rem; padding: .7rem .9rem .7rem 1.8rem; background: var(--surface-2); border-radius: 8px; }
.avt-cles li { margin: .2rem 0; }
.avt-liens { font-size: .8rem; color: var(--text-2); }
/* Mode découverte : l'impression (y compris Ctrl+P) est réservée à la version complète */
@media print {
  body.mode-decouverte > * { display: none !important; }
  body.mode-decouverte::before { content: "Impression réservée à la version complète d’AutoBâti (achat unique, sans abonnement). Activez votre licence avec le bouton « Activer ma licence »."; display: block; padding: 2cm; font: 14pt/1.5 system-ui, sans-serif; }
}

/* =========================================================================
 * Dossier bancaire (js/dossierbanque.js) : invisible à l'écran, seul imprimé
 * quand <html> porte la classe .impression-banque
 * ========================================================================= */
.dossier-banque { display: none; }
@media print {
  html.impression-banque body > *:not(#dossier-banque) { display: none !important; }
  html.impression-banque body { background: #fff; color: #111; font-size: 9.5pt; }
  html.impression-banque #dossier-banque { display: block; }
}
@page { margin: 14mm 12mm; }
.db-document { font-family: inherit; color: #111; }
.db-page + .db-page { break-before: page; }
.db-synthese { break-inside: avoid; }
.db-entete { display: flex; justify-content: space-between; gap: 8mm; border-bottom: 2px solid #c2531b; padding-bottom: 4mm; margin-bottom: 5mm; }
.db-surtitre { margin: 0; font-size: 8.5pt; text-transform: uppercase; letter-spacing: .08em; color: #a3430f; font-weight: 700; }
.db-entete h1 { margin: 1.5mm 0 1mm; font-size: 18pt; line-height: 1.15; }
.db-date { margin: 0; color: #555; font-size: 9pt; }
.db-ident { display: grid; grid-template-columns: auto auto; gap: .6mm 4mm; margin: 0; font-size: 8.5pt; align-content: start; }
.db-ident dt { color: #555; }
.db-ident dd { margin: 0; font-weight: 600; text-align: right; }
.db-besoin { display: flex; flex-wrap: wrap; align-items: baseline; gap: 1mm 5mm; border: 2px solid #c2531b; background: #fbe9df; border-radius: 3mm; padding: 4mm 5mm; margin-bottom: 5mm; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.db-besoin span { font-weight: 700; font-size: 11pt; text-transform: uppercase; letter-spacing: .04em; color: #a3430f; }
.db-besoin strong { font-size: 24pt; line-height: 1; font-variant-numeric: tabular-nums; margin-left: auto; }
.db-besoin strong small { font-size: 11pt; font-weight: 600; }
.db-besoin em { flex-basis: 100%; text-align: right; font-style: normal; color: #444; font-size: 8.5pt; }
.db-table { width: 100%; border-collapse: collapse; font-size: 9pt; }
.db-table th, .db-table td { padding: 1.3mm 2mm; text-align: left; border-bottom: .3mm solid #ddd; vertical-align: baseline; }
.db-table thead th { font-size: 7.5pt; text-transform: uppercase; letter-spacing: .05em; color: #555; border-bottom: .5mm solid #999; }
.db-table .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.db-table small { display: block; color: #666; font-size: 7.5pt; font-weight: 400; }
.db-table tr.db-section th, .db-table tr.db-section td { background: #f1efec; font-weight: 700; border-top: .5mm solid #bbb; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.db-retrait { padding-left: 6mm !important; }
.db-table tfoot th, .db-table tfoot td { font-weight: 700; border-top: .6mm solid #111; border-bottom: 0; font-size: 10pt; }
.db-chiffres { display: grid; grid-template-columns: repeat(auto-fit, minmax(38mm, 1fr)); gap: 3mm; margin: 5mm 0; }
.db-chiffres p { margin: 0; border: .3mm solid #ccc; border-radius: 2mm; padding: 2mm 3mm; }
.db-chiffres span { display: block; font-size: 7.5pt; color: #555; }
.db-chiffres strong { font-size: 11pt; font-variant-numeric: tabular-nums; }
.db-notes { font-size: 7.5pt; color: #444; border-top: .3mm solid #ccc; padding-top: 2mm; }
.db-notes p { margin: 0 0 1mm; }
.db-alerte { color: #8a2c00; font-weight: 600; }
.db-vide { padding: 6mm; border: .3mm dashed #999; text-align: center; }
.db-annexe h2 { font-size: 13pt; margin: 0 0 4mm; border-bottom: 2px solid #c2531b; padding-bottom: 2mm; }
.db-poste { margin-bottom: 5mm; }
.db-poste h3 { display: flex; justify-content: space-between; font-size: 10.5pt; margin: 0 0 1.5mm; break-after: avoid; }
.db-detail { font-size: 8pt; }
.db-detail tr { break-inside: avoid; }
.db-detail thead { display: table-header-group; }

/* =========================================================================
   Mesurer sur mon plan (js/plan.js)
   ========================================================================= */
.plan-carte { padding: 0; }
.plan-tete { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; padding: 1rem 1.25rem; cursor: pointer; list-style: none; }
.plan-tete::-webkit-details-marker { display: none; }
.plan-tete::before { content: "▸"; color: var(--text-2); transition: transform .15s; }
.plan-carte[open] > .plan-tete::before { transform: rotate(90deg); }
.plan-titre { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.plan-corps { padding: 0 1.25rem 1.25rem; display: grid; gap: .75rem; }
.plan-import, .plan-outils, .plan-options, .plan-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.plan-import .field { margin: 0; flex-direction: row; align-items: center; }
.plan-chargement { font-size: .85rem; color: var(--text-2); }
.plan-outils .btn.is-actif { background: var(--accent); border-color: var(--accent); color: #fff; }
.plan-outils .btn:disabled { opacity: .45; cursor: not-allowed; }
.plan-etape { margin: 0; }
.plan-options:empty { display: none; }
.plan-champ { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--text-2); }
.plan-champ input, .plan-champ select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .3rem .5rem; min-width: 0; }
.plan-champ .input-suffix input { border: 0; padding: 0; width: 6rem; }
.plan-info { font-size: .85rem; color: var(--text-2); }
.plan-angle { margin: 0; }
.plan-zone { position: relative; height: min(70vh, 640px); min-height: 320px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface-2); touch-action: none; }
.plan-zone canvas { display: block; width: 100%; height: 100%; outline: none; }
.plan-zone canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.plan-vide { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: var(--text-2); font-size: .9rem; pointer-events: none; text-align: center; padding: 1rem; }
.plan-zoom { position: absolute; right: .5rem; bottom: .5rem; display: flex; gap: .3rem; }
.plan-zoom .btn { background: var(--surface); min-width: 2.2rem; }
.plan-resultats { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.plan-bloc { border: 1px solid var(--border); border-left: 4px solid var(--plan-c, var(--border)); border-radius: 10px; padding: .75rem .9rem; display: grid; gap: .4rem; align-content: start; min-width: 0; }
.plan-bloc h4 { margin: 0 0 .2rem; font-size: .9rem; }
.plan-bloc .aide { margin: 0; }
.plan-ligne { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 .75rem; font-size: .85rem; align-items: baseline; }
.plan-ligne small { grid-column: 1 / -1; color: var(--text-2); font-size: .75rem; }
.plan-liste { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
.plan-liste li { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .5rem; font-size: .85rem; }
.plan-liste li > input[type="text"] { flex: 1 1 8rem; min-width: 0; font: inherit; border: 1px solid var(--border); border-radius: 6px; padding: .2rem .4rem; background: var(--surface); color: var(--text); }
.plan-liste small { color: var(--text-2); }
.plan-cloisons select { flex: 1 1 9rem; min-width: 0; font: inherit; border: 1px solid var(--border); border-radius: 6px; padding: .15rem .3rem; background: var(--surface); color: var(--text); }
.plan-mesures { list-style: none; margin: 0 0 .5rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .25rem .75rem; }
.plan-mesures li { display: flex; align-items: center; gap: .4rem; font-size: .85rem; }
.plan-mesures small { color: var(--text-2); }
.plan-num { display: inline-grid; place-items: center; min-width: 1.4rem; height: 1.4rem; padding: 0 .25rem; border-radius: 999px; background: #d61f1f; color: #fff; font-size: .72rem; font-weight: 700; }
.plan-implantation h5 { margin: .4rem 0 .3rem; font-size: .85rem; }
.plan-lettre { display: inline-grid; place-items: center; min-width: 1.4rem; height: 1.3rem; padding: 0 .2rem; border: 1.5px solid #d61f1f; border-radius: 3px; color: #d61f1f; font-size: .72rem; font-weight: 700; background: #fff; }
.plan-pastille { width: .8rem; height: .8rem; border-radius: 3px; background: var(--plan-c); flex: none; }
.plan-type { flex: 1 1 8rem; }
.plan-mini { width: 6.2rem; padding: .1rem .4rem; }
.plan-mini input { width: 100%; border: 0; padding: 0; background: transparent; color: var(--text); font: inherit; }
.plan-retenues, .plan-tout { grid-column: 1 / -1; }
.plan-retenues .field { margin-bottom: 0; }
.plan-lien { margin-top: .4rem; }
@media print { .plan-carte { display: none; } }
.plan-champ .input-suffix { width: auto; min-height: 34px; }
.plan-champ .input-suffix input, .plan-mini input { min-height: 30px; }
.plan-mini { min-height: 32px; }
.plan-ouvertures li { display: grid; grid-template-columns: 5.6rem 5.6rem minmax(0, 1fr) auto; gap: .2rem .35rem; align-items: center; }
.plan-mini em { padding: 0 .35rem; }
.plan-mini input { -moz-appearance: textfield; }
.plan-mini input::-webkit-inner-spin-button, .plan-mini input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.plan-ouvertures .plan-mini { width: auto; }
.plan-ouvertures .plan-type { grid-column: 1 / -1; font-weight: 600; }
.plan-resultats.is-auto .plan-report, .plan-resultats.is-auto .plan-tout { display: none; }
.plan-auto { grid-column: 1 / -1; }
.plan-auto .checkbox { margin: 0; min-height: 0; color: var(--text); }
.plan-liens { display: flex; flex-wrap: wrap; gap: .4rem; margin: .4rem 0 .6rem; }
.plan-liens .btn, .plan-poste { border-style: dashed; }
.plan-retour { margin-left: auto; }
.plan-grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); gap: 0 .75rem; }

/* ===== Mode démo (sans licence) : seul le soubassement est chiffré ===== */
.demo-bandeau { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; margin: 0 0 1rem; padding: .9rem 1.1rem;
  background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius); color: var(--text); }
.demo-bandeau p { margin: 0; flex: 1 1 22rem; font-size: .92rem; line-height: 1.45; }
.demo-actions { display: inline-flex; flex-wrap: wrap; gap: .4rem; vertical-align: middle; }
.verrou-note { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem; margin: 0 0 .5rem; padding: .6rem .9rem;
  border: 1px dashed var(--accent); border-radius: var(--radius); background: var(--surface); font-size: .9rem; }
.is-verrou { opacity: .45; filter: grayscale(.6); user-select: none; }
tr.is-verrou { opacity: .6; filter: none; }
.verrou-cell { color: var(--text-2); }
.badge-verrou { background: transparent; color: var(--accent); border: 1px solid currentColor; }
.demo-poste { margin: .4rem 0 .6rem; padding: .5rem .8rem; border-radius: 8px; background: var(--surface-2); font-size: .88rem; }
@media (prefers-color-scheme: dark) { .demo-bandeau { background: var(--surface-2); } }
