/* CONCRACK — interface d'inspection. Palette et typographie conservées de la
   maquette validée ; composants reconstruits sans surcouches successives. */
/* Polices Geist embarquées (SIL OFL 1.1, assets/fonts/OFL.txt) : fonctionne hors ligne. */
@font-face { font-family: Geist; src: url("/apps/web/assets/fonts/geist-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("/apps/web/assets/fonts/geist-mono-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
:root {
  --ink: #0e0f12;
  --ink-2: #3d4250;
  --navy: #1a2845;
  --navy-2: #22345a;
  --paper: #f7f7f5;
  --card: #fff;
  --line: #e4e4df;
  --line-2: #efefeb;
  --muted: #6e6f75;
  --teal: #2f5bd3;
  --teal-2: #4a72e0;
  --teal-soft: #e0f6ef;
  --accent: #5b7ff0;
  --amber: #e0a033;
  --amber-ink: #8c5f18;
  --amber-soft: #fff4df;
  --blue: #3478ca;
  --blue-soft: #e7f0ff;
  --red: #b7584b;
  --red-soft: #fbeceb;
  --crack: #ffb547;
  --spalling: #55c4ec;
  --corrosion: #d56a3a;
  --rebar: #f34f74;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px #1a28450d, 0 6px 20px #1a28450d;
  --shadow-lg: 0 24px 80px #0913214d;
  --font: Geist, "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: "Geist Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 14px/1.45 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
:focus-visible { outline: 2px solid var(--teal-2); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- barre supérieure ---------- */
.topbar { position: sticky; top: 0; z-index: 30; height: 56px; background: var(--navy); color: #fff; display: flex; align-items: center; gap: 18px; padding: 0 20px; }
.logo { font-size: 18px; font-weight: 900; letter-spacing: -.05em; }
.logo i { color: var(--accent); font-style: normal; }
.topnav { display: flex; gap: 4px; }
.topnav button { border: 0; background: transparent; color: #a8b7bf; font-size: 12px; font-weight: 700; padding: 8px 10px; border-radius: 6px; }
.topnav button[aria-current="page"] { color: #fff; background: #ffffff14; }
.topbar .spacer { flex: 1; }
.chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 99px; padding: 5px 10px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.engine { background: #ffffff12; color: #9fe0cf; }
.chip.engine.classical { color: #f5c46b; }
.chip.engine.loading { color: #a8b7bf; }
.chip.sync { background: #ffffff12; color: #a8b7bf; }
.chip.sync.online { color: #9fe0cf; }
.icon-btn { border: 0; background: #ffffff14; color: #fff; width: 34px; height: 34px; border-radius: 8px; font-weight: 900; }

/* ---------- structure ---------- */
.shell { max-width: 1560px; margin: 0 auto; padding: 18px 20px 40px; }
.crumb { font-size: 11px; color: var(--muted); margin-bottom: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.crumb b { color: var(--ink-2); font-weight: 700; }
.pagehead { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.pagehead h1 { font-size: 26px; letter-spacing: -.04em; margin: 0 0 3px; line-height: 1.15; overflow-wrap: anywhere; }
.pagehead p { margin: 0; color: var(--muted); font-size: 13px; }
.pagehead .titles { min-width: 0; flex: 1 1 320px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.layout { display: grid; grid-template-columns: minmax(0, 1.62fr) minmax(330px, .8fr); gap: 14px; align-items: start; }
.stack { display: grid; gap: 14px; align-content: start; min-width: 0; }

/* ---------- composants ---------- */
.btn { min-height: 40px; border: 1px solid var(--line); background: #fff; border-radius: var(--radius-sm); padding: 8px 13px; color: var(--ink); font-weight: 800; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; text-decoration: none; }
.btn:hover:not(:disabled) { border-color: #b9cbca; background: #f8fbfa; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--navy-2); }
.btn.teal { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.teal:hover:not(:disabled) { background: var(--teal-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.small { min-height: 30px; padding: 5px 9px; font-size: 11px; }
.btn.danger { color: var(--red); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card > header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card > header h2 { font-size: 13px; margin: 0; }
.card > header .sub { color: var(--muted); font-size: 11px; }
.card > header .end { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.card .pad { padding: 14px 16px; }
.eyebrow { font-size: 10px; color: var(--muted); font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.pill { display: inline-block; background: var(--amber-soft); color: var(--amber-ink); border-radius: 99px; padding: 4px 9px; font-size: 10px; font-weight: 900; white-space: nowrap; }
.pill.teal { background: var(--teal-soft); color: var(--teal); }
.pill.blue { background: var(--blue-soft); color: #215b9d; }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.gray { background: #eef2f1; color: var(--muted); }
.note { color: var(--muted); font-size: 12px; margin: 6px 0 10px; }
.callout { background: #f3f6f6; border-radius: var(--radius-sm); padding: 10px 12px; color: var(--ink-2); font-size: 11.5px; line-height: 1.5; }
.callout.warn { background: var(--amber-soft); color: var(--amber-ink); }
.callout strong { color: var(--ink); }
.segmented { display: inline-flex; gap: 2px; background: #edf2f1; border-radius: 8px; padding: 3px; }
.segmented button { border: 0; background: transparent; border-radius: 6px; padding: 6px 9px; color: var(--muted); font-size: 11px; font-weight: 800; }
.segmented button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 4px #1232; }
.bar { height: 5px; background: #e6ecee; border-radius: 9px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--blue); border-radius: inherit; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
table.data { width: 100%; border-collapse: collapse; font-size: 12px; }
table.data th { text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 800; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.selected td { background: #fff9ec; }
table.data tr[data-defect] { cursor: pointer; }
table.data tr[data-defect]:hover td { background: #f7faf9; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; margin-right: 6px; }

/* ---------- visionneuse ---------- */
.viewer-card { overflow: hidden; }
.viewer-toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.viewer-toolbar .grow { flex: 1; }
.viewer { position: relative; height: clamp(360px, 52vw, 640px); background: #1f2d33; overflow: hidden; touch-action: none; user-select: none; }
.viewer canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.viewer.grab { cursor: grab; }
.viewer.grabbing { cursor: grabbing; }
.viewer.picking { cursor: crosshair; }
.viewer .flag { position: absolute; top: 12px; left: 12px; background: #0d1926e8; color: #fff; border-radius: 6px; padding: 6px 10px; font-size: 10px; font-weight: 800; letter-spacing: .03em; pointer-events: none; max-width: calc(100% - 24px); }
.viewer .scalebar { position: absolute; bottom: 12px; left: 12px; background: #0d1926e8; color: #fff; border-radius: 6px; padding: 7px 10px; font-size: 10px; pointer-events: none; }
.viewer .scalebar i { display: block; height: 0; border-top: 3px solid #fff; margin-bottom: 4px; }
.viewer .map-legend { position: absolute; left: 12px; bottom: 56px; background: #0d1926e8; color: #fff; border-radius: 7px; padding: 8px 10px; font-size: 10px; font-weight: 700; pointer-events: none; max-width: min(320px, calc(100% - 24px)); }
.viewer .map-legend b { display: block; font-size: 10px; letter-spacing: .04em; text-transform: uppercase; color: #c8d7df; margin-bottom: 6px; }
.viewer .map-legend .swatches { display: flex; flex-wrap: wrap; gap: 6px 10px; }
.viewer .map-legend .swatches span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.viewer .map-legend .swatches i { width: 16px; height: 4px; border-radius: 2px; display: inline-block; }
.viewer .map-legend .ramp { height: 8px; border-radius: 4px; width: 200px; max-width: 100%; }
.viewer .map-legend .ticks { display: flex; justify-content: space-between; color: #c8d7df; margin-top: 3px; }
.viewer .zoom { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 4px; background: #0d1926d9; border-radius: 8px; padding: 4px; }
.viewer .zoom button { border: 0; background: transparent; color: #fff; min-width: 30px; height: 30px; border-radius: 6px; font-weight: 900; }
.viewer .zoom button:hover { background: #ffffff1f; }
.viewer .zoom output { color: #c8d7df; font-size: 11px; font-weight: 800; align-self: center; min-width: 42px; text-align: center; }
.viewer .scene-alert { position: absolute; top: 12px; right: 12px; max-width: 260px; padding: 8px 10px; border-radius: 7px; background: #fff8eb; color: var(--amber-ink); border: 1px solid #edc979; font-size: 11px; font-weight: 800; line-height: 1.3; }
.viewer .progress { position: absolute; inset: 0; display: grid; place-items: center; background: #0d1926a6; color: #fff; }
.viewer .progress .box { background: #0d1926f2; border-radius: 12px; padding: 16px 18px; width: min(320px, calc(100% - 40px)); }
.viewer .progress .bar { background: #ffffff26; margin-top: 10px; }
.viewer .progress .bar i { background: #67c6ac; transition: width .2s; }
.viewer .empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: #c8d7df; padding: 24px; }
.viewer .empty .inner { max-width: 420px; display: grid; gap: 12px; justify-items: center; }
.viewer .empty h2 { color: #fff; margin: 0; font-size: 18px; }
.viewer .empty p { margin: 0; font-size: 13px; }
.viewer.dragover { outline: 3px dashed #67c6ac; outline-offset: -10px; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; padding: 8px 12px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); align-items: center; }
.legend label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 700; color: var(--ink-2); }
.legend input { accent-color: var(--teal); }
.legend .hint { margin-left: auto; }

/* ---------- indicateurs ---------- */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); }
.metric { padding: 12px 14px; border-right: 1px solid var(--line); min-width: 0; }
.metric:last-child { border-right: 0; }
.metric small { display: block; color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; }
.metric strong { display: block; font-size: 17px; margin-top: 3px; font-variant-numeric: tabular-nums; }
.metric span { display: block; font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.metric span.warn { color: var(--red); }
.metric span.good { color: var(--teal); }
.gate { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 14px; border-top: 1px solid var(--line); background: #f5faf8; flex-wrap: wrap; }
.gate strong { display: block; font-size: 12px; }
.gate span { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }

/* ---------- diagnostic ---------- */
.observation { background: var(--surface-2, rgba(0,0,0,.03)); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; color: var(--ink); }
.observation .evidence { margin: 0 0 6px; padding-left: 18px; font-size: 11.5px; color: var(--muted); }
.observation .signs { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.hypothesis { display: block; width: 100%; text-align: left; border: 0; border-top: 1px solid var(--line); background: transparent; padding: 11px 0; }
.hypothesis:hover .label { color: var(--teal); }
.hypothesis header { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; font-weight: 800; }
.hypothesis .conf { color: #215b9d; background: var(--blue-soft); border-radius: 5px; padding: 3px 6px; font-size: 10px; white-space: nowrap; }
.hypothesis p { color: var(--muted); font-size: 11.5px; margin: 5px 0 7px; }
.links { display: grid; gap: 6px; margin-top: 10px; }
.links button { border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 9px 10px; text-align: left; color: var(--ink-2); font-size: 11.5px; font-weight: 700; }
.links button:hover { border-color: #a9d2c9; color: var(--teal); }
.findings { display: grid; gap: 8px; }
.finding-row { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.finding-row .grow { flex: 1; min-width: 0; }
.finding-row small { color: var(--muted); display: block; }

/* ---------- graphiques ---------- */
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-tooltip { min-height: 16px; font-size: 11px; color: var(--ink-2); font-weight: 700; margin-top: 4px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); border-block: 1px solid var(--line); margin-top: 6px; }
.stats div { padding: 9px 10px 8px 0; border-right: 1px solid var(--line); }
.stats div + div { padding-left: 10px; }
.stats div:last-child { border-right: 0; }
.stats small { display: block; color: var(--muted); font-size: 9.5px; font-weight: 800; text-transform: uppercase; }
.stats strong { display: block; margin-top: 3px; font-size: 13px; font-variant-numeric: tabular-nums; }

/* ---------- méta ---------- */
.meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
.meta .card { padding: 12px 14px; }
.meta small { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; font-weight: 800; }
.meta b { font-size: 12px; display: block; margin-top: 3px; overflow-wrap: anywhere; }
.meta .card-button { font: inherit; color: inherit; text-align: left; cursor: pointer; }
.meta .card-button:hover, .meta .card-button:focus-visible { border-color: var(--teal); }
.meta .card-button small.note { text-transform: none; font-weight: 500; margin-top: 2px; }

/* ---------- boîtes de dialogue ---------- */
dialog.modal { border: 0; padding: 0; border-radius: 14px; box-shadow: var(--shadow-lg); width: min(560px, calc(100% - 24px)); max-height: calc(100dvh - 24px); color: var(--ink); background: #fff; overflow: hidden; }
dialog.modal.wide { width: min(900px, calc(100% - 24px)); }
dialog.modal.xwide { width: min(1180px, calc(100% - 24px)); }
dialog.modal::backdrop { background: #091321b8; }
dialog.modal[open] { display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 16px; line-height: 1.25; }
.modal-head .close { border: 0; background: #eef2f1; border-radius: 7px; width: 34px; height: 34px; font-size: 18px; flex: none; }
.modal-body { padding: 16px 18px; overflow: auto; flex: 1; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; background: #fff; }
.modal-foot .left { margin-right: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.dropzone { position: relative; display: grid; place-items: center; gap: 6px; text-align: center; border: 2px dashed #b9cbca; border-radius: 10px; padding: 26px 16px; color: var(--muted); min-height: 130px; }
.dropzone b { color: var(--ink); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone.dragover { border-color: var(--teal); background: var(--teal-soft); }
.field { display: grid; gap: 5px; font-size: 12px; font-weight: 800; color: var(--ink-2); }
.field input, .field select, .field textarea { border: 1px solid var(--line); border-radius: 7px; padding: 9px 10px; font-weight: 500; background: #fff; width: 100%; }
.field textarea { min-height: 80px; resize: vertical; }
.field small { font-weight: 500; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; font-size: 12px; }
.checks label { display: flex; gap: 7px; align-items: flex-start; }
fieldset { border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px 12px; margin: 0 0 12px; }
legend { font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 4px; }
.stage { position: relative; background: #0b1724; border-radius: 10px; overflow: hidden; }
.stage video, .stage canvas { display: block; width: 100%; max-height: 62vh; object-fit: contain; }
.stage canvas.overlay { position: absolute; inset: 0; height: 100%; pointer-events: none; }
.stage img.ghost { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; mix-blend-mode: normal; }
.stage img.ghost[hidden] { display: none; }
.stage .badge { position: absolute; top: 10px; left: 10px; background: #10263ae6; color: #91d8ee; padding: 6px 9px; border-radius: 6px; font-size: 10px; font-weight: 800; }
.live-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.live-grid div { background: #f3f6f6; border-radius: 8px; padding: 8px 10px; }
.live-grid small { display: block; font-size: 9.5px; color: var(--muted); font-weight: 800; text-transform: uppercase; }
.live-grid strong { font-size: 13px; }
.live-results { display: grid; grid-template-columns: 1.4fr 1.2fr 0.8fr 1.2fr; gap: 8px; margin-top: 8px; }
.live-card { background: #f3f6f6; border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.live-card small { font-size: 9.5px; color: var(--muted); font-weight: 800; text-transform: uppercase; }
.live-card strong { font-size: 13px; }
.live-bars { display: grid; gap: 3px; }
.live-bar { display: grid; grid-template-columns: 74px 1fr 38px; align-items: center; gap: 6px; font-size: 11px; }
.live-bar i { display: block; height: 7px; border-radius: 4px; background: #e87828; min-width: 2px; }
.live-bar b { font-size: 11px; text-align: right; }
.live-heat { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; width: 84px; aspect-ratio: 1; }
.live-heat span { border-radius: 3px; border: 1px solid rgba(20, 35, 49, .08); }
.report-doc { font-size: 12.5px; line-height: 1.5; }
.report-doc h3 { font-size: 13px; margin: 18px 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.report-doc img { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); }
.report-doc ul { margin: 6px 0; padding-left: 18px; }
.toast { position: fixed; left: 50%; bottom: 18px; visibility: hidden; transform: translate(-50%, calc(100% + 40px)); background: var(--navy); color: #fff; border-radius: 9px; padding: 11px 14px; transition: transform .2s ease; z-index: 100; font-size: 12.5px; max-width: min(520px, calc(100% - 24px)); box-shadow: var(--shadow-lg); }
.toast.show { visibility: visible; transform: translate(-50%, 0); }
.viewer .wheel-hint { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: #0d1926d9; color: #fff; padding: 10px 14px; border-radius: 9px; font-size: 12px; font-weight: 700; pointer-events: none; opacity: 0; transition: opacity .2s; }
.viewer .wheel-hint.show { opacity: 1; }
.toast.error { background: #6d241b; }
.tools-menu { position: relative; }
.tools-menu > div { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; min-width: 250px; z-index: 25; display: grid; }
.tools-menu > div button { border: 0; background: transparent; text-align: left; padding: 9px 10px; border-radius: 7px; font-size: 12px; font-weight: 700; color: var(--ink); }
.tools-menu > div button small { display: block; color: var(--muted); font-weight: 500; font-size: 11px; }
.tools-menu > div button:hover { background: #f3f6f6; }
.steps { counter-reset: step; display: grid; gap: 10px; }
.steps li { list-style: none; display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; }
.steps li::before { counter-increment: step; content: counter(step); width: 26px; height: 26px; border-radius: 50%; background: var(--teal-soft); color: var(--teal); display: grid; place-items: center; font-weight: 900; font-size: 12px; }
.steps { padding: 0; margin: 0; }
.twin-stage { position: relative; height: min(58vh, 520px); background: #0b1724; border-radius: 10px; overflow: hidden; touch-action: none; }
.twin-stage canvas { width: 100%; height: 100%; display: block; }
.twin-stage .badge { position: absolute; top: 10px; left: 10px; background: #10263ae6; color: #91d8ee; padding: 6px 9px; border-radius: 6px; font-size: 10px; font-weight: 800; pointer-events: none; }
.twin-stage .hint { position: absolute; bottom: 10px; left: 10px; color: #c8d7df; font-size: 11px; pointer-events: none; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .side-stack { grid-template-columns: 1fr 1fr; }
  .meta { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .topbar { padding: 0 12px; gap: 10px; }
  .topnav, .chip.sync { display: none; }
  .shell { padding: 12px 10px 90px; }
  .pagehead h1 { font-size: 21px; }
  .actions { width: 100%; }
  .actions .btn { flex: 1 1 auto; }
  .side-stack { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .viewer { height: 62vh; min-height: 320px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats div:nth-child(2) { border-right: 0; }
  .stats div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .stats div:nth-child(3) { padding-left: 0; }
  .grid-2, .grid-3, .checks { grid-template-columns: 1fr; }
  .live-grid { grid-template-columns: 1fr 1fr; }
  .live-results { grid-template-columns: 1fr 1fr; }
  .meta { grid-template-columns: 1fr 1fr; }
  .legend .hint { display: none; }
  /* Barres d'onglets : défilement horizontal au doigt plutôt que débordement. */
  .segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .segmented::-webkit-scrollbar { display: none; }
  .segmented button { flex: 0 0 auto; }
  /* Détections : l'essentiel sur petit écran (confiance et statut restent dans la fiche du tracé). */
  #detectionsTable th:nth-child(4), #detectionsTable td:nth-child(4), #detectionsTable th:nth-child(5), #detectionsTable td:nth-child(5) { display: none; }
  #detectionsTable table { font-size: 12px; }
  #detectionsTable th, #detectionsTable td { white-space: normal; padding-left: 6px; padding-right: 6px; }
  #detectionsTable td:last-child { white-space: nowrap; }
  .modal-body table.data { display: block; max-width: 100%; overflow-x: auto; }
  .finding-row { flex-wrap: wrap; }
  .pill { white-space: normal; max-width: 100%; }
  dialog.modal { width: 100vw; min-width: 0; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
}

/* ---------- impression du rapport ---------- */
@media print {
  body { background: #fff; }
  body > *:not(dialog[data-print="true"]) { display: none !important; }
  dialog[data-print="true"] { position: static; display: block; width: auto; max-height: none; box-shadow: none; border: 0; overflow: visible; }
  dialog[data-print="true"] .modal-head, dialog[data-print="true"] .modal-foot, dialog[data-print="true"] .no-print { display: none !important; }
  dialog[data-print="true"] .modal-body { overflow: visible; padding: 0; }
  .report-doc h3 { break-after: avoid; }
  .report-doc img { break-inside: avoid; }
}

/* Jumeau 3D */
.twin-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.twin-bar .grow { flex: 1; }
.twin-model-tools { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.twin-model-tools [aria-pressed="true"] { background: var(--teal); color: #fff; border-color: var(--teal); }
.twin-unit { font-size: 11px; font-weight: 800; color: var(--muted); display: inline-flex; gap: 4px; align-items: center; }
.twin-layout { display: grid; grid-template-columns: 1fr; gap: 10px; }
.twin-layout:has(.twin-side:not([hidden])) { grid-template-columns: minmax(0, 1fr) 320px; }
.twin-side { font-size: 12px; overflow: auto; max-height: min(58vh, 520px); }
.twin-photo canvas { width: 100%; display: block; border-radius: 8px; cursor: crosshair; margin-bottom: 8px; }
.twin-h { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 12px 0 4px; }
.twin-list { margin: 0; padding-left: 16px; }
.twin-list li { margin: 3px 0; }
@media (max-width: 760px) { .twin-layout:has(.twin-side:not([hidden])) { grid-template-columns: 1fr; } }
.twin-stage.light { background: #ffffff; border: 1px solid var(--line); }
.twin-stage.light .hint { color: #5b6b72; }
.twin-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11px; color: var(--muted); margin: 0 0 6px; }
.twin-legend span { display: inline-flex; align-items: center; gap: 5px; }
.twin-legend i { width: 14px; height: 4px; border-radius: 2px; display: inline-block; }
#twinSplit[aria-pressed="true"], #twinOrbit[aria-pressed="true"] { background: var(--teal); color: #fff; border-color: var(--teal); }

/* ---------- refonte 2026-09 : charte XAMLAB (A) + tableau de bord (C) ---------- */
body { font-feature-settings: "ss01"; letter-spacing: -.005em; }
.topbar { background: var(--navy); }
.btn { font-weight: 600; font-size: 12.5px; border-radius: 12px; }
.btn.teal { background: var(--teal); border-color: var(--teal); }
.card > header h2 { font-size: 14px; font-weight: 700; letter-spacing: -.01em; }
.metric strong, .stats strong, .num { font-family: var(--mono); font-weight: 600; }
.metric strong { font-size: 19px; }
.pagehead h1 { font-weight: 700; }
.eyebrow, .metric small, .stats small, table.data th, .meta small { font-family: var(--mono); font-weight: 500; letter-spacing: .06em; }
.segmented { border-radius: 12px; background: #efefeb; }
.segmented button { border-radius: 9px; font-weight: 600; }
.hypothesis header { font-weight: 700; }
.links button { border-radius: 12px; font-weight: 600; }
.fab, .tabbar { display: none; }

/* Mobile et tablette portrait : une section à la fois, onglets en bas. */
@media (max-width: 900px) {
  body { background: var(--paper); }
  .topbar { height: calc(52px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); border: 0; }
  .topnav, .chip.sync { display: none; }
  .shell { padding: 0 12px calc(96px + env(safe-area-inset-bottom)); }
  .crumb { display: none; }
  .pagehead { background: var(--navy); color: #fff; margin: 0 -12px 14px; padding: 6px 18px 22px; border-radius: 0 0 26px 26px; }
  .pagehead h1 { font-size: 23px; color: #fff; }
  .pagehead p { color: #b8c2d6; }
  .pagehead .actions { display: none; }
  .layout, .side-stack { grid-template-columns: 1fr; }
  .card { border-radius: 20px; border-color: transparent; box-shadow: 0 6px 18px #1a28451a; }
  .card > header { border-bottom-color: var(--line-2); padding: 14px 16px; }
  .viewer-card { overflow: hidden; }
  .viewer { height: min(58vh, 520px); min-height: 300px; }
  .viewer-toolbar { gap: 6px; }
  .metrics { grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px; border: 0; background: var(--paper); }
  .metric, .metric:nth-child(-n+2) { background: #fff; border: 0; border-radius: 14px; padding: 11px 12px; }
  .gate { border-radius: 0 0 20px 20px; }
  .gate > div:last-child { width: 100%; }
  .gate .btn { flex: 1 1 100%; min-height: 46px; }
  .meta { grid-template-columns: 1fr 1fr; }
  .meta .card { border-radius: 16px; }

  /* sections par onglet */
  .viewer-card, #detectionsCard, #distributionCard, #diagnosticCard, #findingsCard, #evolutionCard, #engineCard, .meta { display: none; }
  body[data-tab="inspect"] .viewer-card, body[data-tab="inspect"] #detectionsCard { display: block; }
  body[data-tab="diagnosis"] #diagnosticCard, body[data-tab="diagnosis"] #findingsCard { display: block; }
  body[data-tab="follow"] #evolutionCard, body[data-tab="follow"] #distributionCard { display: block; }
  body[data-tab="more"] #engineCard { display: block; }
  body[data-tab="more"] .meta { display: grid; }
  body[data-tab="more"] .pagehead .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; width: 100%; }
  body[data-tab="more"] .pagehead .actions .btn { background: #ffffff14; border-color: #ffffff26; color: #fff; min-height: 46px; }
  body[data-tab="more"] .pagehead .actions .tools-menu > .btn { width: 100%; }
  body[data-tab="more"] .tools-menu > div { left: 0; right: auto; color: var(--ink); max-width: calc(100vw - 36px); }

  .fab { display: grid; place-items: center; position: fixed; right: 18px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 40; width: 58px; height: 58px; border: 0; border-radius: 18px; background: var(--teal); color: #fff; font-size: 30px; font-weight: 400; line-height: 1; box-shadow: 0 10px 24px #2f5bd366; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: #fffffff2; backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .tabbar button { flex: 1; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; font-weight: 600; color: var(--muted); padding: 4px 0; min-height: 50px; }
  .tabbar i { font-style: normal; font-size: 17px; width: 42px; height: 26px; display: grid; place-items: center; border-radius: 99px; }
  .tabbar button[aria-current="page"] { color: var(--navy); }
  .tabbar button[aria-current="page"] i { background: var(--teal-soft); color: var(--teal); }
  .toast { bottom: calc(92px + env(safe-area-inset-bottom)); }
}
@media (min-width: 721px) and (max-width: 900px) {
  .shell { padding-left: 24px; padding-right: 24px; }
  .pagehead { margin: 0 -24px 16px; padding: 10px 28px 24px; }
  .viewer { height: min(62vh, 640px); }
  .metrics { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 900px) {
  .viewer .zoom { top: 12px; bottom: auto; }
  .viewer .scene-alert { top: 58px; }
  .viewer-toolbar #reanalyzeButton { margin-left: auto; }
}
@media (max-width: 900px) {
  .viewer .flag { max-width: calc(100% - 200px); line-height: 1.35; }
  .metric strong { font-size: 17px; }
}
@media (max-width: 900px) { body:not([data-tab="inspect"]) .fab { display: none; } }
@media (max-width: 900px) {
  .layout { display: flex; flex-direction: column; gap: 14px; }
  .layout > .stack { display: contents; }
  #evolutionCard { order: -1; }
}
.live-scale { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-top: 10px; padding: 10px 12px; background: var(--teal-soft); border-radius: 12px; }
.live-scale select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: #fff; }
.fc-tip { position: absolute; z-index: 5; pointer-events: none; background: #1a2845f2; color: #fff; border-radius: 10px; padding: 8px 10px; font-size: 11.5px; min-width: 200px; box-shadow: 0 8px 22px #1a284540; }
.fc-tip strong { display: block; font-size: 12px; margin-bottom: 4px; }
.fc-tip div { display: flex; justify-content: space-between; gap: 12px; }
.fc-tip span { color: #b8c2d6; }
.fc-tip b { font-family: var(--mono); font-weight: 600; }

/* Graphes modernes : légende en pastilles, barres en dégradé, bulle de lecture, cartes d'indicateurs. */
.dist-chart { position: relative; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 11.5px; color: var(--ink-2); margin: 0 0 6px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; background: var(--paper); border-radius: 99px; padding: 4px 10px; }
.chart-legend .sw { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.chart-legend .sw.bar { background: linear-gradient(#5b7ff0, #2f5bd3); }
.chart-legend .sw.cum { background: #1a2845; height: 3px; border-radius: 2px; }
.dist-bar { cursor: pointer; outline: none; }
.dist-bar .dbar { transition: opacity .15s, filter .15s; }
.dist-bar:hover .dbar, .dist-bar:focus .dbar { filter: brightness(1.08) drop-shadow(0 4px 8px #2f5bd355); }
.dist-bar.dim .dbar { opacity: .35; }
.cum-dot { transition: r .15s; pointer-events: none; }
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.kpi-row div { background: var(--paper); border-radius: 14px; padding: 10px 12px; min-width: 0; }
.kpi-row div.accent { background: var(--navy); color: #fff; }
.kpi-row div.accent small { color: #b8c2d6; }
.kpi-row small { display: block; font-family: var(--mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.kpi-row strong { display: block; margin-top: 3px; font-family: var(--mono); font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
#forecastChart { border-radius: 16px; overflow: visible; }
#forecastChart svg { border-radius: 14px; box-shadow: inset 0 0 0 1px var(--line-2); }
@media (max-width: 720px) { .kpi-row { grid-template-columns: 1fr 1fr; } }

/* ---------- refonte 2026-09 (suite) : diagnostic, détections, indicateurs, fenêtres, rapport ---------- */
.card > header { padding: 14px 18px; }
.card .pad { padding: 16px 18px; }
.btn { transition: background .15s, border-color .15s, transform .1s, box-shadow .15s; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, #22345a, #1a2845); box-shadow: 0 4px 12px #1a284533; }
.btn.teal { background: linear-gradient(135deg, #4a72e0, #2f5bd3); box-shadow: 0 4px 12px #2f5bd333; }
.pill { border-radius: 99px; padding: 4px 10px; font-weight: 700; letter-spacing: .01em; }
.pill.teal { background: #dff7ef; color: #00745d; }
.pill.red { background: #ffe8e8; color: #c0343a; }
.pill.gray { background: #f0f0ec; color: var(--muted); }
.callout { border-radius: 12px; background: #f4f5f1; border-left: 3px solid #c9cbc4; }
.callout.warn { background: #fff6e5; border-left-color: #e69500; color: #7a4f00; }
.segmented button[aria-pressed="true"] { box-shadow: 0 1px 6px #1a28451f; color: var(--navy); }

/* Indicateurs chiffrés : cartes */
.metrics { gap: 10px; padding: 12px; background: var(--paper); border-top: 1px solid var(--line-2); }
.metric, .metric:last-child { background: #fff; border: 0; border-radius: 14px; box-shadow: 0 1px 3px #1a28450f; padding: 12px 14px; }
.metric small { color: var(--muted); }
.metric strong { color: var(--navy); }
.gate { background: linear-gradient(135deg, #eafaf4, #f4f5f1); }

/* Diagnostic : constat mis en avant, origines en cartes classées */
.observation { background: linear-gradient(135deg, #f1f4fa, #fff); border: 1px solid #e3e8f2; border-left: 4px solid var(--navy); border-radius: 14px; padding: 12px 14px; }
.observation .signs .pill { background: #fff3dc; color: #7a4f00; }
.observation .signs .pill.teal { background: #dff7ef; color: #00745d; }
.hypothesis { position: relative; border: 1px solid var(--line-2); border-radius: 14px; background: #fff; padding: 12px 34px 12px 14px; margin-top: 8px; transition: box-shadow .15s, transform .15s, border-color .15s; }
.hypothesis:hover { border-color: #b8e8d9; box-shadow: 0 6px 18px #1a284514; transform: translateY(-1px); }
.hypothesis:hover .label { color: var(--navy); }
.hypothesis .label { display: inline-flex; gap: 8px; align-items: baseline; }
.hypothesis .rank { flex: none; font-style: normal; width: 22px; height: 22px; border-radius: 50%; background: var(--navy); color: #fff; display: inline-grid; place-items: center; font-size: 11px; font-family: var(--mono); transform: translateY(-1px); }
.hypothesis:nth-of-type(n+3) .rank { background: #8b8c93; }
.hypothesis .conf { font-family: var(--mono); font-weight: 600; border-radius: 99px; padding: 3px 9px; background: #f0f0ec; color: var(--ink-2); }
.hypothesis .conf[data-level="fort"] { background: #ffe8e8; color: #c0343a; }
.hypothesis .conf[data-level="modéré"] { background: #fff3dc; color: #8a5a00; }
.hypothesis .conf[data-level="faible"] { background: #e8eefb; color: #2f4d8a; }
.hypothesis .bar { height: 6px; background: #eef0ea; }
.hypothesis .bar > i { background: linear-gradient(90deg, #5b7ff0, #2f5bd3); }
.hypothesis .go { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 22px; color: #b5b7ae; transition: color .15s, right .15s; }
.hypothesis:hover .go { color: var(--teal); right: 9px; }
.links button { display: flex; justify-content: space-between; align-items: center; border-radius: 12px; padding: 11px 14px; background: #fff; border-color: var(--line-2); transition: border-color .15s, background .15s; }
.links button::after { content: "›"; font-size: 18px; color: #b5b7ae; }
.links button:hover { background: #f3fbf8; border-color: #b8e8d9; color: var(--navy); }
.links button:hover::after { color: var(--teal); }
.finding-row { background: var(--paper); border-radius: 12px; padding: 9px 12px; }

/* Tableaux : en-têtes discrets, lignes survolées, révision en boutons ronds colorés */
table.data th { font-family: var(--mono); font-weight: 500; font-size: 10px; background: #fafaf8; border-bottom: 1px solid var(--line-2); }
table.data td { border-bottom-color: #f1f1ee; }
table.data tr[data-defect] td { transition: background .12s; }
table.data tr[data-defect]:hover td { background: #f3fbf8; }
table.data tr.selected td { background: #e9f8f2; }
table.data tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--teal); }
.btn.rv { width: 32px; height: 32px; min-height: 32px; padding: 0; border-radius: 50%; font-size: 13px; border-color: transparent; }
.btn.rv.ok { background: #dff7ef; color: #00745d; }
.btn.rv.edit { background: #fff3dc; color: #8a5a00; }
.btn.rv.ko { background: #ffe8e8; color: #c0343a; }
.btn.rv.ok:hover:not(:disabled) { background: #2f5bd3; color: #fff; }
.btn.rv.edit:hover:not(:disabled) { background: #e69500; color: #fff; }
.btn.rv.ko:hover:not(:disabled) { background: #c0343a; color: #fff; }
.swatch { border-radius: 50%; }

/* Fenêtres : en-tête net, coins arrondis */
dialog.modal { border-radius: 22px; }
dialog.modal::backdrop { background: #1a2845b3; backdrop-filter: blur(3px); }
.modal-head { padding: 16px 20px; }
.modal-head h2 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.modal-head .close { border-radius: 50%; background: #f0f0ec; }
.modal-head .close:hover { background: #e4e4df; }
.modal-foot { background: #fafaf8; }
.field input, .field select, .field textarea { border-radius: 10px; transition: border-color .15s, box-shadow .15s; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px #2f5bd326; }

/* Rapport */
.report-doc { font-size: 13px; line-height: 1.6; }
.report-doc h3 { font-size: 14px; border: 0; padding: 0 0 0 10px; margin: 22px 0 8px; border-left: 3px solid var(--teal); color: var(--navy); }
.report-doc table.data { border: 1px solid var(--line-2); border-radius: 12px; overflow: hidden; border-collapse: separate; border-spacing: 0; }
.report-doc img { border-radius: 12px; }
.meta .card { border-radius: 14px; }
.tools-menu > div { border-radius: 14px; padding: 6px; }
.tools-menu > div button { border-radius: 10px; }
.tools-menu > div button:hover { background: #f3fbf8; }
.toast { border-radius: 14px; background: var(--navy); }
.hypothesis header .label { flex: 1; min-width: 0; }
.hypothesis header .label > :not(.rank) { min-width: 0; }
.hypothesis .label { display: block; }
.hypothesis .rank { margin-right: 8px; vertical-align: 1px; }
.hypothesis header { align-items: flex-start; }
.techdetails > summary { list-style: none; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 18px; cursor: pointer; }
.techdetails > summary::-webkit-details-marker { display: none; }
.techdetails > summary h2 { font-size: 14px; margin: 0; }
.techdetails > summary .sub { color: var(--muted); font-size: 11px; }
.techdetails > summary .pill { margin-left: auto; }
.techdetails > summary::after { content: "▾"; color: var(--muted); transition: transform .15s; }
.techdetails[open] > summary::after { transform: rotate(180deg); }
.techdetails[open] > summary { border-bottom: 1px solid var(--line-2); }

/* Sobriété : pas de liserés colorés latéraux, encadrés à bordure fine uniforme. */
.observation { border: 1px solid #e3e8f2; border-left: 1px solid #e3e8f2; background: #f7f9fc; }
.callout, .callout.warn { border-left: 0; border: 1px solid transparent; }
.callout { border-color: #ebebe6; }
.callout.warn { border-color: #f5dfb0; }
.report-doc h3 { border-left: 0; padding: 0 0 6px; border-bottom: 1px solid var(--line-2); }
table.data tr.selected td:first-child { box-shadow: none; }

/* Barre du haut explicite */
.chip.engine, .chip.sync { border: 0; cursor: pointer; font-family: inherit; }
.chip.engine:hover, .chip.sync:hover { background: #ffffff22; }
.lang-btn { border: 1px solid #ffffff2e; background: transparent; border-radius: 99px; padding: 3px; display: inline-flex; gap: 2px; font-size: 11px; font-weight: 700; }
.lang-btn b, .lang-btn span { padding: 4px 8px; border-radius: 99px; color: #b8c2d6; }
.lang-btn b { background: #fff; color: var(--navy); }
.help-btn { border: 0; background: var(--teal); color: #fff; border-radius: 99px; padding: 6px 14px 6px 6px; display: inline-flex; align-items: center; gap: 7px; font-weight: 700; font-size: 12.5px; }
.help-btn span { width: 22px; height: 22px; border-radius: 50%; background: #ffffff33; display: grid; place-items: center; }
.help-btn:hover { background: var(--teal-2); }
@media (max-width: 720px) { .help-btn { padding: 6px; } .help-btn { font-size: 0; } .help-btn span { font-size: 13px; } .chip.engine { display: none; } }

/* Manuel */
.modal-body.manual { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 0; padding: 0; overflow: hidden; }
.manual-nav { display: flex; flex-direction: column; gap: 4px; padding: 14px; border-right: 1px solid var(--line-2); background: #fafaf8; overflow: auto; }
.manual-search { border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; margin-bottom: 6px; }
.manual-search:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px #2f5bd326; }
.manual-tour { margin-bottom: 8px; }
.manual-link { border: 0; background: transparent; text-align: left; padding: 8px 10px; border-radius: 10px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); display: flex; gap: 10px; align-items: center; }
.manual-link i, .manual-section h3 i { font-style: normal; width: 24px; height: 24px; border-radius: 8px; background: #efefeb; display: inline-grid; place-items: center; font-size: 12px; flex: none; color: var(--navy); }
.manual-link:hover { background: #f0f0ec; }
.manual-link.active { background: var(--navy); color: #fff; }
.manual-link.active i { background: #ffffff22; color: #fff; }
.manual-content { overflow: auto; padding: 8px 26px 30px; max-height: calc(100dvh - 180px); scroll-behavior: smooth; }
.manual-section { padding: 16px 0 18px; border-bottom: 1px solid var(--line-2); font-size: 13.5px; line-height: 1.6; }
.manual-section h3 { display: flex; gap: 10px; align-items: center; font-size: 17px; margin: 0 0 10px; color: var(--navy); }
.manual-section h3 i { width: 30px; height: 30px; font-size: 14px; background: var(--teal-soft); color: var(--teal); }
.manual-section ul, .manual-section ol:not(.steps) { padding-left: 20px; }
.manual-section li { margin: 4px 0; }
.manual-section details { border: 1px solid var(--line-2); border-radius: 12px; padding: 10px 14px; margin: 8px 0; }
.manual-section summary { cursor: pointer; }
.manual-kv { grid-template-columns: 170px 1fr; gap: 8px 16px; font-size: 13px; }
.manual-kv dd { font-weight: 400; }
.manual-show { margin-top: 10px; }
@media (max-width: 720px) {
  .modal-body.manual { grid-template-columns: 1fr; overflow: auto; }
  .manual-nav { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line-2); }
  .manual-search { flex-basis: 100%; }
  .manual-link { flex: 0 0 auto; padding: 6px 9px; }
  .manual-content { max-height: none; overflow: visible; padding: 4px 16px 20px; }
  .manual-kv { grid-template-columns: 1fr; }
}
/* Me montrer / visite guidée */
.manual-spot { animation: manualSpot 2.6s ease; position: relative; z-index: 45; }
@keyframes manualSpot { 0%, 100% { box-shadow: 0 0 0 0 #5b7ff000; } 15%, 70% { box-shadow: 0 0 0 4px #5b7ff0, 0 0 0 12px #5b7ff040; } }
.tour-target { position: relative; z-index: 45; box-shadow: 0 0 0 4px #5b7ff0, 0 0 0 9999px #1a284599 !important; border-radius: 12px; transition: box-shadow .2s; }
.tour-pop { position: fixed; z-index: 60; width: min(340px, calc(100vw - 16px)); background: #fff; border-radius: 16px; padding: 14px 16px; box-shadow: 0 18px 50px #0913214d; font-size: 13.5px; }
.tour-pop p { margin: 4px 0 12px; line-height: 1.5; }
.tour-count { font-family: var(--mono); font-size: 11px; color: var(--teal); font-weight: 600; }
.tour-actions { display: flex; gap: 6px; align-items: center; }
.tour-actions span { flex: 1; }
.twin-info { background: var(--paper); border-radius: 12px; padding: 10px 12px; font-size: 12px; line-height: 1.5; margin-bottom: 8px; }
.twin-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 6px 0; }
.twin-kpis div { background: var(--paper); border-radius: 10px; padding: 7px 9px; }
.twin-kpis small { display: block; font-family: var(--mono); font-size: 9.5px; text-transform: uppercase; color: var(--muted); }
.twin-kpis b { font-family: var(--mono); font-size: 14px; }
.twin-cloud-tools { display: inline-flex; gap: 8px; align-items: center; }

/* Gestionnaire de projets */
.modal-body.pm { display: grid; grid-template-columns: 290px minmax(0, 1fr); padding: 0; overflow: hidden; min-height: min(72dvh, 760px); }
.pm-side { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-right: 1px solid var(--line-2); background: #fafaf8; overflow: auto; max-height: calc(100dvh - 170px); }
.pm-search { border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; }
.pm-list { display: grid; gap: 4px; margin-top: 4px; }
.pm-item { position: relative; border: 0; background: transparent; text-align: left; padding: 10px 40px 10px 12px; border-radius: 12px; display: grid; gap: 2px; }
.pm-item b { font-size: 13px; }
.pm-item small { color: var(--muted); font-size: 11px; }
.pm-item:hover { background: #f0f0ec; }
.pm-item.active { background: var(--navy); color: #fff; }
.pm-item.active small { color: #b8c2d6; }
.pm-count { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-family: var(--mono); font-size: 11px; background: #e4e4df; color: var(--ink-2); border-radius: 99px; padding: 2px 8px; }
.pm-item.active .pm-count { background: #ffffff26; color: #fff; }
.pm-loose { margin-top: 12px; border-top: 1px solid var(--line-2); padding-top: 10px; display: grid; gap: 6px; }
.pm-loose-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; }
.pm-loose-row small { display: block; color: var(--muted); }
.pm-main { overflow: auto; padding: 18px 22px 24px; max-height: calc(100dvh - 170px); }
.pm-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.pm-head h3 { margin: 2px 0 2px; font-size: 20px; color: var(--navy); }
.pm-desc { margin: 6px 0 0; font-size: 13px; color: var(--ink-2); max-width: 640px; }
.pm-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; max-width: 460px; justify-content: flex-end; }
.pm-kpis { grid-template-columns: repeat(5, 1fr); margin: 14px 0; }
.pm-import { display: grid; grid-template-columns: 1.4fr 1fr 1fr auto; gap: 10px; align-items: end; background: #f3fbf8; border: 1px solid #d6f0e6; border-radius: 14px; padding: 12px 14px; }
.pm-import small { display: block; }
.pm-progress { margin-top: 8px; font-size: 12px; }
.pm-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.photo-strip { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); }
.photo-strip[hidden] { display: none; }
.strip-list { display: flex; gap: 6px; overflow-x: auto; flex: 1; min-width: 0; padding: 2px; scrollbar-width: thin; }
.strip-item { flex: 0 0 auto; width: 64px; height: 48px; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: var(--line); cursor: pointer; }
.strip-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.strip-item.active { border-color: var(--teal); }
.strip-item:hover:not(.active) { border-color: var(--line-2); opacity: .85; }
.strip-count { font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.vk-head { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 10px; align-items: end; margin-bottom: 10px; }
.vk-head small { display: block; }
.vk .callout .pill { margin-top: 4px; white-space: normal; }
.vk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.vk-card { display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--line); border-radius: 10px; padding: 6px; cursor: pointer; background: var(--card, #fff); }
.vk-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; background: #e6ecee; }
.vk-card.off { opacity: .45; }
.vk-meta { font-size: 12px; }
.vk-meta small { display: block; color: var(--muted); }
.vk-meta small span { white-space: nowrap; }
.vk-rejected { font-size: 12px; margin-bottom: 8px; }
@media (max-width: 720px) { .vk-head { grid-template-columns: 1fr; } }
.pm-progress .bar { margin-top: 4px; }
.pm-table { margin-top: 14px; overflow-x: auto; }
.pm-group td { background: #fafaf8; }
.pm-thumb canvas { width: 56px; height: auto; border-radius: 6px; display: block; background: #eee; }
.pm-row-actions { white-space: nowrap; text-align: right; }
.pm-row-actions .btn { margin-left: 4px; }
.pm-empty { padding: 40px 10px; max-width: 520px; }
.crumb-project { border: 0; background: var(--teal-soft); color: var(--teal); font-weight: 700; border-radius: 99px; padding: 2px 10px; font-size: 11px; cursor: pointer; }
@media (max-width: 900px) {
  .modal-body.pm { grid-template-columns: 1fr; overflow: auto; }
  .pm-side, .pm-main { max-height: none; overflow: visible; }
  .pm-import, .pm-kpis { grid-template-columns: 1fr 1fr; }
}

/* ================= Charte B « Acier & Rouille » (identité) ================= */
:root {
  --ink: #1d2833; --ink-2: #3f4d5a; --navy: #243240; --navy-2: #2e3f50; --paper: #f4f1ec; --card: #fff;
  --line: #e2ddd4; --line-2: #ece8e1; --muted: #6b7178; --steel: #5b6b7a;
  --rust: #b5532e; --oxide: #d9822b; --accent: #d9822b;
  --crack: #d9822b; --red: #b5532e; --red-soft: #f7e6de;
}
.logo i, .couv-marque i { color: var(--oxide); }
.btn.primary { background: linear-gradient(135deg, #2e3f50, #243240); }
.hypothesis .rank { background: var(--navy); }
.kpi-row div.accent { background: var(--navy); }
.pill.red, .hypothesis .conf[data-level="fort"] { background: #f7e6de; color: var(--rust); }
.hypothesis .conf[data-level="modéré"] { background: #fbeedd; color: #9a5a1a; }
.chip.engine { color: #e8b48a; }

/* ================= Charte C « Sombre terrain » (thème sombre) ================= */
:root[data-theme="dark"] {
  --ink: #cdd9e5; --ink-2: #adbac7; --navy: #1c2128; --navy-2: #232b36; --paper: #22272e; --card: #2d333b;
  --line: #444c56; --line-2: #3a414a; --muted: #909dab; --teal: #5b7ff0; --teal-2: #a3bbff; --teal-soft: #253257;
  --accent: #5b7ff0; --crack: #5b7ff0; --amber-soft: #4a3c16; --amber-ink: #ffc53d; --red: #ff5a5f; --red-soft: #4a2224; --blue-soft: #243447;
  color-scheme: dark;
}
:root[data-theme="dark"] body { background: var(--paper); color: var(--ink); }
:root[data-theme="dark"] .logo i { color: var(--teal); }
:root[data-theme="dark"] .card, :root[data-theme="dark"] .metric, :root[data-theme="dark"] .metric:last-child, :root[data-theme="dark"] .hypothesis,
:root[data-theme="dark"] .links button, :root[data-theme="dark"] .kpi-row div, :root[data-theme="dark"] .meta .card, :root[data-theme="dark"] .tools-menu > div,
:root[data-theme="dark"] dialog.modal, :root[data-theme="dark"] .modal-foot, :root[data-theme="dark"] .pm-item.active .pm-count, :root[data-theme="dark"] .twin-info,
:root[data-theme="dark"] .twin-kpis div, :root[data-theme="dark"] .fc-tip, :root[data-theme="dark"] .tour-pop, :root[data-theme="dark"] .manual-nav, :root[data-theme="dark"] .pm-side { background: var(--card); color: var(--ink); }
:root[data-theme="dark"] .metrics, :root[data-theme="dark"] .finding-row, :root[data-theme="dark"] .callout, :root[data-theme="dark"] .observation,
:root[data-theme="dark"] .chart-legend span, :root[data-theme="dark"] table.data th, :root[data-theme="dark"] .segmented, :root[data-theme="dark"] .pm-import, :root[data-theme="dark"] .gate { background: #232b36; color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] .btn, :root[data-theme="dark"] .field input, :root[data-theme="dark"] .field select, :root[data-theme="dark"] .field textarea,
:root[data-theme="dark"] .manual-search, :root[data-theme="dark"] .pm-search, :root[data-theme="dark"] .modal-head .close { background: #2b3440; color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] .btn.teal { background: var(--teal); color: #22272e; }
:root[data-theme="dark"] .btn.primary { background: #444c56; color: #fff; }
:root[data-theme="dark"] .segmented button[aria-pressed="true"], :root[data-theme="dark"] .tabbar { background: #2b3440; color: var(--ink); }
:root[data-theme="dark"] .tabbar { border-color: var(--line); }
:root[data-theme="dark"] .pagehead { background: #232b36; }
:root[data-theme="dark"] .callout.warn { background: #3f3417; color: #ffd98a; border-color: #6b5520; }
:root[data-theme="dark"] table.data tr[data-defect]:hover td, :root[data-theme="dark"] table.data tr.selected td { background: #1f4038; }
:root[data-theme="dark"] .observation { border-color: var(--line); }
:root[data-theme="dark"] .hypothesis .conf { background: #3a424c; color: var(--ink); }
:root[data-theme="dark"] .fig-svg, :root[data-theme="dark"] .dist-chart svg, :root[data-theme="dark"] #forecastChart svg, :root[data-theme="dark"] .forecast-mini svg { background: #f4f1ec; border-radius: 12px; }
:root[data-theme="dark"] .pm-item:hover, :root[data-theme="dark"] .manual-link:hover { background: #2b3440; }
.theme-btn { border: 1px solid #ffffff2e; background: transparent; color: #fff; border-radius: 99px; width: 32px; height: 32px; font-size: 15px; line-height: 1; }

/* Thème sombre : « bleu nuit » sert de couleur de texte (titres, chiffres) → clair ; les fonds
   qui l'utilisaient reçoivent une teinte sombre explicite. */
:root[data-theme="dark"] { --navy: #dfe6ee; --navy-2: #c9d2dc; }
:root[data-theme="dark"] .topbar, :root[data-theme="dark"] .toast { background: #1c2128; color: #cdd9e5; }
:root[data-theme="dark"] .btn.primary { background: #444c56; border-color: #545d68; color: #fff; }
:root[data-theme="dark"] .pagehead, :root[data-theme="dark"] .kpi-row div.accent, :root[data-theme="dark"] .pm-item.active,
:root[data-theme="dark"] .manual-link.active { background: #3a424c; color: #fff; }
:root[data-theme="dark"] .hypothesis .rank { background: #545d68; color: #fff; }
:root[data-theme="dark"] .lang-btn b { background: #cdd9e5; color: #22272e; }
:root[data-theme="dark"] .manual-link i, :root[data-theme="dark"] .manual-section h3 i { background: #3a424c; color: var(--teal); }
:root[data-theme="dark"] .observation { background: #232b36; border-left-color: var(--line); }
:root[data-theme="dark"] .metric span.warn { color: #ff8a8e; }
:root[data-theme="dark"] .note, :root[data-theme="dark"] .sub, :root[data-theme="dark"] small { color: var(--muted); }
:root[data-theme="dark"] .pill { background: #4a3c16; color: #ffd98a; }
:root[data-theme="dark"] .pill.teal { background: #253257; color: #7ff5d9; }
:root[data-theme="dark"] .pill.red { background: #4a2224; color: #ff9da0; }
:root[data-theme="dark"] .pill.gray { background: #3a424c; color: #adbac7; }
:root[data-theme="dark"] .pill.blue { background: #243447; color: #9cc3ff; }
:root[data-theme="dark"] .chip.sync, :root[data-theme="dark"] .chip.engine { background: #ffffff14; }
:root[data-theme="dark"] a { color: #7ff5d9; }
:root[data-theme="dark"] .legend label { color: var(--ink-2); }
:root[data-theme="dark"] .hypothesis .conf[data-level="fort"] { background: #4a2224; color: #ff9da0; }
:root[data-theme="dark"] .hypothesis .conf[data-level="modéré"] { background: #4a3c16; color: #ffd98a; }
:root[data-theme="dark"] .hypothesis .conf[data-level="faible"] { background: #243447; color: #9cc3ff; }
:root[data-theme="dark"] .btn.rv.ok { background: #253257; color: #7ff5d9; }
:root[data-theme="dark"] .btn.rv.edit { background: #4a3c16; color: #ffd98a; }
:root[data-theme="dark"] .btn.rv.ko { background: #4a2224; color: #ff9da0; }
:root[data-theme="dark"] .help-btn { color: #22272e; }
:root[data-theme="dark"] .help-btn span { background: #22272e26; }
:root[data-theme="dark"] .pm-group td, :root[data-theme="dark"] table.data th { background: #232b36; color: var(--ink); }
:root[data-theme="dark"] .pm-item.active small { color: #c9d2dc; }
:root[data-theme="dark"] .pm-count { background: #3a424c; color: var(--ink); }
/* Contraste AA (≥ 4,5) en thème clair : gris secondaire et vert d'action légèrement foncés. */
:root:not([data-theme="dark"]) { --muted: #5b6678; --teal: #0284c7; --teal-2: #0369a1; }
:root:not([data-theme="dark"]) .report-doc h4 { color: #2f5bd3 !important; }
:root:not([data-theme="dark"]) .pill.red { background: #f7e6de; color: #8f3a1d; }
:root[data-theme="dark"] .tabbar button { color: #adbac7; }
.plausibility { margin: 0; padding: 12px 16px; font-size: 12.5px; border-top: 1px solid var(--line); }
.plausibility.warn { background: #fbeedd; color: #7a4a12; }
.plausibility.alert { background: #f7e0da; color: #8f2d17; }
.plausibility strong { display: block; margin-bottom: 4px; }
.plausibility ul { margin: 0 0 6px; padding-left: 18px; }
:root[data-theme="dark"] .plausibility.warn { background: #4a3c16; color: #ffd98a; }
:root[data-theme="dark"] .plausibility.alert { background: #4a2224; color: #ffb3b5; }
.chip.account { border: 0; background: #ffffff14; color: #e8b48a; cursor: pointer; font-family: inherit; }

/* ---------- onglets de colonnes (ordinateur / tablette) ---------- */
.desk-tabs { display: flex; gap: 4px; padding: 4px; background: var(--paper, #eef1f4); border: 1px solid var(--line, #dde3ea); border-radius: 12px; overflow-x: auto; }
.desk-tabs button { flex: 1 0 auto; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; padding: 8px 12px; border-radius: 9px; cursor: pointer; white-space: nowrap; }
.desk-tabs button:hover { color: var(--ink, inherit); }
.desk-tabs button[aria-selected="true"] { background: var(--card, #fff); color: var(--ink, inherit); box-shadow: 0 1px 3px #0000001f; }
.desk-tabs button:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }
@media (min-width: 721px) { .desk-tabbed.desk-hidden { display: none !important; } }
@media (min-width: 721px) and (max-width: 1080px) { .side-stack { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .desk-tabs { display: none; } }

/* ---------- lecture progressive et cartes raffinées ---------- */
details.more { margin-top: 8px; }
details.more > summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); padding: 3px 0; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: '›'; display: inline-block; transition: transform .15s; font-size: 14px; line-height: 1; }
details.more[open] > summary::before { transform: rotate(90deg); }
details.more > summary:hover { color: var(--ink); }
.flag { display: inline-block; margin: 8px 0 2px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--line-2); color: var(--ink-2); cursor: help; }
#diagnosticNote { font-size: 11.5px; opacity: .8; }
.hypothesis p { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; font-size: 12px; margin: 2px 0 6px; }
.hypothesis:hover p, .hypothesis:focus-visible p { -webkit-line-clamp: 3; }
@media (min-width: 721px) {
  .card { border-radius: 16px; border-color: var(--line-2); box-shadow: 0 1px 2px #1a1d2308, 0 8px 24px -12px #1a1d2324; }
  .card > header { border-bottom: 0; padding-bottom: 6px; }
  .card > header h2 { font-size: 15px; letter-spacing: -.01em; }
  .metric strong { letter-spacing: -.02em; }
  .desk-tabs { border-radius: 14px; }
}
:root[data-theme="dark"] .card { box-shadow: 0 1px 0 #ffffff08 inset, 0 10px 28px -14px #00000080; }
@media (min-width: 721px) {
  #diagnosticCard .links { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  #diagnosticCard .links button { margin: 0; min-height: 44px; font-size: 12px; line-height: 1.25; text-align: left; }
}

/* ================= Identité CONCRACK : graphite · cuivre · cobalt (distincte de XAMLAB) ================= */
:root {
  --navy: #2a2f38; --navy-2: #353b46; --ink: #20242b;
  --teal: #2f5bd3; --teal-2: #2449b0; --teal-soft: #e7edfc;
  --oxide: #c46a2e; --rust: #a5521f; --accent: #c46a2e; --crack: #d27838;
}
.logo { display: inline-flex; align-items: center; gap: 8px; letter-spacing: .02em; }
.logo img { border-radius: 7px; display: block; box-shadow: 0 0 0 1px #ffffff30; }
.btn.primary { background: linear-gradient(135deg, #353b46, #2a2f38); }
:root[data-theme="dark"] {
  --teal: #7b9cff; --teal-2: #a3bbff; --teal-soft: #253257;
  --accent: #e39a62; --crack: #e8a26a; --oxide: #e39a62;
}
:root[data-theme="dark"] .logo i { color: var(--oxide); }
:root[data-theme="dark"] table.data tr[data-defect]:hover td, :root[data-theme="dark"] table.data tr.selected td { background: #26304a; }
.tools-advanced { border-top: 1px solid var(--line-2); margin-top: 4px; padding-top: 4px; }
.tools-advanced > summary { cursor: pointer; list-style: none; padding: 8px 12px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.tools-advanced > summary::-webkit-details-marker { display: none; }
.tools-advanced > summary::after { content: ' ›'; }
.tools-advanced[open] > summary::after { content: ' ⌄'; }
@media (min-width: 721px) { .tools-menu .mobile-only { display: none; } }
@media (min-width: 721px) { .meta { display: none !important; } }

/* ================= Palette « Ardoise & Ciel » (fond moderne, bleu uni) ================= */
:root {
  --paper: #f3f5f8; --card: #ffffff; --line: #e2e8f0; --line-2: #edf1f6;
  --ink: #0f172a; --ink-2: #334155; --muted: #5b6678; --steel: #64748b;
  --navy: #111827; --navy-2: #1f2937;
  --teal: #0284c7; --teal-2: #0369a1; --teal-soft: #e0f2fe;
}
body { background: var(--paper); }
.viewer { background: #0f1720; }
.btn.teal, .fab, .help-btn { background: var(--teal) !important; background-image: none !important; color: #fff !important; border: 0 !important; box-shadow: 0 1px 2px #0f172a1f, 0 4px 14px -4px #0284c766 !important; }
.btn.teal:hover, .fab:hover, .help-btn:hover { background: var(--teal-2) !important; }
.tabbar [aria-current="page"] i { background: var(--teal-soft) !important; color: var(--teal-2) !important; }
.btn.primary { background: #111827; }
.hypothesis .bar > i { background: var(--teal); }
.card { border-color: var(--line); }
:root[data-theme="dark"] {
  --paper: #161b22; --card: #1f2630; --line: #313a47; --line-2: #28303b; --ink: #e2e8f0; --ink-2: #b4c0cf; --muted: #8b97a8;
  --navy: #0f141a; --navy-2: #1a2029; --teal: #38bdf8; --teal-2: #7dd3fc; --teal-soft: #0c3a52;
}
:root[data-theme="dark"] .btn.teal, :root[data-theme="dark"] .fab, :root[data-theme="dark"] .help-btn { color: #062a3d !important; }
:root[data-theme="dark"] .viewer { background: #0b1016; }
.gate { background: #f0f7fd !important; border-color: #d6e9f8 !important; }
:root[data-theme="dark"] .gate { background: #1a2633 !important; border-color: var(--line) !important; }
/* un seul style d'action principale */
.btn.primary, .btn.teal, .fab, .help-btn { background: var(--teal) !important; background-image: none !important; color: #fff !important; border: 0 !important; box-shadow: 0 1px 2px #0f172a1f, 0 4px 14px -4px #0284c766 !important; }
.btn.primary:hover, .btn.teal:hover { background: var(--teal-2) !important; }
:root[data-theme="dark"] .btn.primary, :root[data-theme="dark"] .btn.teal { color: #062a3d !important; }
.gate { background-image: none !important; }

/* ================= Écran d'accueil / connexion XAMLAB ================= */
dialog.welcome { border: 0; padding: 0; margin: auto; width: min(440px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow-x: hidden; overflow-y: auto; border-radius: 20px; box-sizing: border-box; background: var(--card); color: var(--ink); box-shadow: 0 30px 90px -20px #0f172a73; }
dialog.welcome::backdrop { background: #0f1720d9; backdrop-filter: blur(6px); }
.welcome-card { padding: 32px 28px 24px; display: flex; flex-direction: column; gap: 14px; }
.welcome-brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 22px; letter-spacing: .02em; }
.welcome-brand img { border-radius: 10px; }
.welcome-brand i { font-style: normal; color: var(--oxide, #c46a2e); }
.welcome-card h1 { margin: 6px 0 0; font-size: 20px; line-height: 1.25; }
.welcome-sub { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.welcome-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.welcome-actions .btn { min-height: 46px; font-size: 14px; }
.welcome-note { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.welcome-note.small { font-size: 11.5px; }
.welcome-sep { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.welcome-sep::before, .welcome-sep::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.welcome-guest { min-height: 44px; font-size: 14px; border: 1px solid var(--line) !important; color: var(--ink) !important; }
.welcome-guest:hover { background: var(--line-2) !important; }
@media (max-width: 420px) { .welcome-actions { grid-template-columns: 1fr; } .welcome-card { padding: 26px 20px 20px; } }
.chip.account.signed-out { background: transparent; box-shadow: inset 0 0 0 1px #ffffff40; color: #fff; }
.chip.account.signed-out:hover { background: #ffffff14; }

/* ================= Mode sombre : corrections après « Ardoise & Ciel » (audit de contraste 29/09) ================= */
.live-grid div, .live-card, .callout { background: var(--line-2); }
.tools-menu > div button:hover { background: var(--line-2); }
:root[data-theme="dark"] { --muted: #aab4c3; }
:root[data-theme="dark"] .metric strong, :root[data-theme="dark"] .manual-section h3 { color: var(--ink); }
/* Graphiques dessinés pour fond clair : panneau clair de la palette (et non plus le beige de l'ancienne charte). */
:root[data-theme="dark"] .fig-svg, :root[data-theme="dark"] .dist-chart svg, :root[data-theme="dark"] #forecastChart svg, :root[data-theme="dark"] .forecast-mini svg { background: #eef2f7; }
:root[data-theme="dark"] .live-scale select { background: var(--card); color: var(--ink); border-color: var(--line); }
@media (pointer: coarse) { .modal-foot .btn { min-height: 44px; } }
/* Téléphone : la barre du haut n'a pas la place pour la pastille compte (menu Outils → Compte XAMLAB). */
@media (max-width: 720px) { .chip.account { display: none !important; } }
#diagnosticNote { opacity: 1; color: var(--muted); }
/* Bleu d'action : #0284c7 → #0279bc (même teinte) pour un texte blanc à 4,7:1 (AA). */
:root:not([data-theme="dark"]) { --teal: #0279bc; }
:root:not([data-theme="dark"]) .manual-link i, :root:not([data-theme="dark"]) .manual-section h3 i { color: var(--teal-2); }
/* Aperçu du rapport : toujours une feuille blanche (comme le PDF), y compris en thème sombre. */
:root[data-theme="dark"] .report-doc {
  --ink: #0f172a; --ink-2: #334155; --muted: #5b6678; --navy: #111827; --line: #e2e8f0; --line-2: #edf1f6; --card: #fff; --paper: #f3f5f8;
  --teal: #0279bc; --teal-2: #0369a1; --teal-soft: #e0f2fe; --amber-soft: #fff4df; --amber-ink: #7a4f00; --red-soft: #fbeceb; --red: #b42318;
  background: #fff; color: var(--ink); border-radius: 12px; padding: 18px 20px;
}
:root[data-theme="dark"] .report-doc table.data th { background: var(--line-2); color: var(--ink); }
.chart-legend .sw.bar { background: #38a3dc; }
.chart-legend .sw.cum { background: #0f172a; }
/* Téléphone : les cartes (éléments de grille) peuvent rétrécir sous la largeur de leur contenu ; les modes défilent. */
.layout > *, .stack > *, .side-stack > *, .viewer-card, .viewer-toolbar { min-width: 0; }
@media (max-width: 720px) { .layout .card { width: 100%; max-width: 100%; box-sizing: border-box; } .viewer-toolbar .segmented { max-width: 100%; } }

/* ================= Marque : bleu des boutons (plus de cuivre), 29/09 ================= */
.logo i, .welcome-brand i, .couv-marque i, :root[data-theme="dark"] .logo i { color: var(--teal) !important; }
.chip.engine, .chip.account { color: #bae6fd; }
/* Barre du haut sur écrans moyens : Aide réduite à son icône, puis pastille moteur masquée. */
@media (max-width: 1240px) { .help-btn { font-size: 0 !important; padding: 6px 9px; } .help-btn span { font-size: 13px; margin: 0; } }
@media (max-width: 1060px) { .chip.engine { display: none; } }

/* ================= Mode « Évolution » (chemins prévus sur la photo) ================= */
.evolution-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 12px; background: var(--teal-soft); border-bottom: 1px solid var(--line); font-size: 12.5px; }
.evolution-bar .evo-text { flex: 1 1 320px; min-width: 0; line-height: 1.45; }
.evolution-bar .segmented { flex: 0 0 auto; }
:root[data-theme="dark"] .evolution-bar { background: #0c2a3b; }

/* ================= Bandeau d'outil (calibration, fissure manquante…) : lisible et entier ================= */
.mode-panel { border-top: 0 !important; border-bottom: 1px solid var(--line) !important; background: var(--teal-soft) !important; scroll-margin-top: 72px; align-items: flex-end; }
.mode-panel > div:first-child { flex: 1 1 280px !important; min-width: 0; }
.mode-panel .field { flex: 0 1 auto; min-width: 90px; }
.mode-panel > div:last-child { margin-left: auto; flex: 0 0 auto; }
.mode-panel a { color: var(--teal-2); }
:root[data-theme="dark"] .mode-panel { background: #0c2a3b !important; }
@media (max-width: 720px) { .mode-panel .field { flex: 1 1 30%; width: auto !important; } .mode-panel > div:last-child { width: 100%; display: flex; } .mode-panel > div:last-child .btn { flex: 1; } }
.gate.calibrated { background: var(--line-2) !important; }
.logo { font-size: 19px; } /* grand texte gras : bleu des boutons conforme AA sur la barre sombre */
.dist-metric { margin: 0 0 10px; }
.welcome-steps { margin: 0; padding-left: 20px; color: var(--ink-2); font-size: 13px; line-height: 1.55; }
.welcome-note a { color: var(--teal-2); }
/* Menu ouvert vers le haut (pied de fenêtre : « Autres formats »). */
.tools-menu.up > div { top: auto; bottom: calc(100% + 6px); right: 0; min-width: 230px; }
/* Jumeau 3D : commandes de vue superposées (zoom, recentrage, plein écran, image). */
.twin-stage .view-controls { position: absolute; top: 10px; right: 10px; display: grid; gap: 4px; z-index: 2; }
.twin-stage .view-controls button { width: 34px; height: 34px; border-radius: 9px; border: 1px solid #d6dde5; background: #ffffffeb; color: #0f172a; font-size: 17px; font-weight: 800; line-height: 1; cursor: pointer; display: grid; place-items: center; box-shadow: 0 1px 3px #0f172a1f; }
.twin-stage .view-controls button:hover { background: #fff; color: #0279bc; }
.twin-stage .view-controls button[aria-pressed="true"] { background: #0279bc; color: #fff; border-color: #0279bc; }
.twin-stage .view-controls button:focus-visible, .twin-stage:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.twin-stage:fullscreen { height: 100vh; width: 100vw; border-radius: 0; border: 0; }
.twin-stage:not(.light) .view-controls button { background: #10263ae6; color: #dbeafe; border-color: #2a4a63; }
@media (pointer: coarse) { .twin-stage .view-controls button { width: 44px; height: 44px; } }

/* Alerte de vraisemblance intégrée au panneau d'échelle (un seul bloc « échelle »). */
.gate .plausibility { margin: 0 0 8px; padding: 8px 10px; border: 0; border-radius: 8px; font-size: 12px; }
.gate .plausibility strong { display: inline; font-size: 12px; }
.gate .plausibility span, .gate .plausibility li { color: inherit; }
.gate .plausibility .more { margin-top: 4px; }

/* Logo cliquable : retour à l'accueil. */
a.logo { text-decoration: none; color: inherit; cursor: pointer; border-radius: 8px; }
a.logo:hover span { opacity: .85; }
a.logo:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }
.align-state { display: block; flex-basis: 100%; font-size: 12px; padding: 6px 10px; border-radius: 8px; background: var(--soft, #eef3f6); }
.align-state[data-state="ok"] { background: #dcf3e6; color: #13663a; }
.align-state[data-state="adjust"] { background: #fff1d6; color: #7a4b00; }
:root[data-theme="dark"] .align-state[data-state="ok"] { background: #12382a; color: #9ee6bd; }
:root[data-theme="dark"] .align-state[data-state="adjust"] { background: #3a2a0c; color: #f5cf88; }
.linklike { font: inherit; color: var(--teal); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.linklike:hover, .linklike:focus-visible { color: var(--ink, inherit); }
/* Légende adaptée au matériau : pas de corrosion ni d'armatures en maçonnerie. */
.only-masonry { display: none; }
body[data-material="maconnerie"] .only-masonry { display: inline; }
body[data-material="maconnerie"] .only-concrete { display: none; }
/* Gestionnaire de projets : case « Dans le rapport » */
.pm-in-report { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); margin-right: 6px; white-space: nowrap; }
/* Sélecteur de matériau (béton / maçonnerie) dans la barre de légende */
.legend .material-switch { margin-left: auto; }
.legend .material-switch button { font-size: 12px; padding: 4px 10px; }

.report-choice { display: grid; gap: 12px; }
.report-choice > .btn, .report-multi { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; height: auto; }
.report-choice small { color: var(--muted); font-weight: 400; }
.report-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; width: 100%; margin: 8px 0; }
.report-pick { display: flex; align-items: center; gap: 8px; font-size: 12px; cursor: pointer; }
.report-pick img { width: 56px; height: 42px; object-fit: cover; border-radius: 6px; background: var(--line); }
.report-pick span { display: flex; flex-direction: column; min-width: 0; }
.report-pick small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.strip-cell { position: relative; flex: 0 0 auto; display: inline-flex; }
.strip-cell.excluded .strip-item { opacity: .4; filter: grayscale(1); }
.strip-include { position: absolute; top: -4px; right: -4px; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--card); padding: 0; font-size: 11px; line-height: 1; font-weight: 900; cursor: pointer; background: var(--teal); color: #fff; }
.strip-include[aria-pressed="false"] { background: var(--muted); }
.strip-count { display: flex; flex-direction: column; align-items: flex-end; }
.strip-count small { font-size: 10px; }
.strip-list { padding-top: 6px; }

/* Rapport de projet : page de garde, planche de repérage, fiches */
.pr-cover { border-radius: 14px; overflow: hidden; border: 1px solid var(--line); margin-bottom: 14px; }
.pr-cover-band { background: #1a2845; color: #fff; padding: 18px 20px 16px; border-bottom: 4px solid #0279bc; }
.pr-brand { font-weight: 900; letter-spacing: .02em; } .pr-brand b { color: #38a8e8; }
.pr-kicker { display: block; color: #7cc4f0; font-size: 12px; margin-top: 14px; }
.pr-cover-band h2 { margin: 4px 0; font-size: 24px; color: #fff; }
.pr-cover-band p { margin: 0; color: #c7d2e0; font-size: 12.5px; }
.pr-figures { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 12px 14px 0; }
.pr-figures div { background: #f3f6fa; border-left: 3px solid #0279bc; padding: 8px 10px; border-radius: 6px; }
.pr-figures strong { display: block; font-size: 18px; color: #1a2845; } .pr-figures small { color: var(--muted); }
.pr-priority { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; font-size: 12px; color: var(--muted); }
.pr-priority > b { color: #fff; border-radius: 99px; padding: 3px 10px; font-size: 11px; }
.pr-bar { display: flex; flex: 1 1 100%; height: 9px; border-radius: 5px; overflow: hidden; }
.pr-cover .callout { margin: 0 14px 14px; }
.pr-toc { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; margin-bottom: 10px; }
.pr-sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.pr-thumb { display: block; font-size: 11.5px; color: var(--ink); text-decoration: none; }
.pr-thumb b { color: #0279bc; }
.pr-img { display: block; aspect-ratio: 4 / 3; border-radius: 6px; overflow: hidden; background: var(--line); border-bottom: 4px solid; margin-bottom: 4px; }
.pr-img img { width: 100%; height: 100%; object-fit: cover; }
.pr-annex { margin-top: 18px; }
.pr-annex-head { display: flex; align-items: center; gap: 14px; background: #eef3fa; border-left: 5px solid; border-radius: 8px; padding: 10px 14px; margin-bottom: 8px; }
.pr-annex-head .pr-ref { font-size: 22px; font-weight: 900; color: #0279bc; }
.pr-annex-head span:nth-child(2) { display: flex; flex-direction: column; flex: 1; } .pr-annex-head small { color: var(--muted); }
:root[data-theme="dark"] .pr-figures div, :root[data-theme="dark"] .pr-annex-head { background: #232b36; }
:root[data-theme="dark"] .pr-figures strong { color: var(--ink); }
@media (max-width: 720px) { .pr-figures { grid-template-columns: 1fr 1fr; } }
.strip-add { display: grid; place-items: center; font-size: 24px; font-weight: 300; color: var(--teal); background: transparent; border: 2px dashed var(--line-2, #cfd6dd); }
.strip-add:hover { border-color: var(--teal); background: var(--teal-soft); }

/* Lecture analysée d'une vidéo */
.va-stage { position: relative; background: #0b1220; border-radius: 10px; overflow: hidden; }
.va-video { display: block; width: 100%; max-height: 62vh; background: #0b1220; }
.va-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.va-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0 4px; font-size: 12px; }
.va-toggle { display: inline-flex; gap: 6px; align-items: center; font-weight: 700; }
.va-status { color: var(--muted); }

/* Mode éprouvette (recherche) */
.sp { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(240px, 1fr); gap: 14px; }
.sp-canvas { width: 100%; border-radius: 10px; background: #0b1220; display: block; }
.sp-side .kv { margin-top: 8px; }
.sp-side .pill { margin: 2px 2px 0 0; }
@media (max-width: 760px) { .sp { grid-template-columns: 1fr; } }
.report-bulk { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 6px; }

/* Planches visuelles */
.vs-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.vs-canvas { width: 100%; height: auto; display: block; border-radius: 10px; }
