/* MGI Chantier — feuille de style (mobile d'abord, trois colonnes sur grand écran) */
:root {
  --fond: #EEF2F1;
  --surface: #FFFFFF;
  --surface-2: #F5F8F7;
  --encre: #142120;
  --gris: #5C6B6A;
  --gris-clair: #8C9998;
  --ligne: #DAE2E1;
  --accent: #0E6169;
  --accent-fort: #0A4D53;
  --accent-doux: #DDEEEF;
  --sur-accent: #FFFFFF;
  --bulle-moi: #0E6169;
  --bulle-moi-texte: #FFFFFF;
  --bulle: #FFFFFF;
  --signal: #B8660F;
  --signal-doux: #FBEBD8;
  --danger: #B23A3A;
  --danger-doux: #F8E1E1;
  --ok: #2F7D4F;
  --ok-doux: #DDF1E4;
  --rapport-a: #3C5FD6;
  --rapport-b: #D6456B;
  --ombre: 0 1px 2px rgba(20, 33, 32, .06), 0 4px 14px rgba(20, 33, 32, .06);
  --rayon: 14px;
  --police: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --barre-bas: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #0D1514; --surface: #15201F; --surface-2: #1B2827; --encre: #E4ECEB; --gris: #9AAAA9;
    --gris-clair: #6F7F7E; --ligne: #263534; --accent: #4FB3BC; --accent-fort: #7FCBD2; --accent-doux: #143536;
    --sur-accent: #0D1514; --bulle-moi: #1F5F65; --bulle-moi-texte: #F1FAFA; --bulle: #1B2827; --signal: #E2A35B;
    --signal-doux: #33240F; --danger: #E57373; --danger-doux: #3A1818; --ok: #6CC490; --ok-doux: #15301F;
    --ombre: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fond: #0D1514; --surface: #15201F; --surface-2: #1B2827; --encre: #E4ECEB; --gris: #9AAAA9;
  --gris-clair: #6F7F7E; --ligne: #263534; --accent: #4FB3BC; --accent-fort: #7FCBD2; --accent-doux: #143536;
  --sur-accent: #0D1514; --bulle-moi: #1F5F65; --bulle-moi-texte: #F1FAFA; --bulle: #1B2827; --signal: #E2A35B;
  --signal-doux: #33240F; --danger: #E57373; --danger-doux: #3A1818; --ok: #6CC490; --ok-doux: #15301F;
  --ombre: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--encre); font-family: var(--police); font-size: 15px;
  line-height: 1.45; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ------------------------------------------------------------------ démarrage / connexion */
.demarrage { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 12px; color: var(--gris); }
.logo-rond {
  width: 64px; height: 64px; border-radius: 18px; background: var(--accent); color: var(--sur-accent);
  display: grid; place-items: center; font-weight: 800; letter-spacing: .04em; font-size: 19px;
}
.connexion { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.carte-connexion {
  width: 100%; max-width: 400px; background: var(--surface); border-radius: 20px; padding: 28px 22px;
  box-shadow: var(--ombre); display: grid; gap: 14px;
}
.carte-connexion h1 { margin: 6px 0 0; font-size: 23px; letter-spacing: -.01em; }
.carte-connexion p { margin: 0; color: var(--gris); }
.champ { display: grid; gap: 5px; }
.champ > span { font-size: 13px; color: var(--gris); font-weight: 600; }
.saisie, select.saisie, textarea.saisie {
  width: 100%; border: 1px solid var(--ligne); background: var(--surface-2); border-radius: 11px;
  padding: 11px 12px; min-height: 44px; outline: none;
}
textarea.saisie { min-height: 90px; resize: vertical; }
.saisie:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-doux); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  padding: 0 16px; border-radius: 11px; border: 1px solid transparent; background: var(--accent);
  color: var(--sur-accent); font-weight: 650; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--accent-fort); }
.btn svg { width: 19px; height: 19px; flex: 0 0 auto; }
.btn.secondaire { background: var(--surface-2); color: var(--encre); border-color: var(--ligne); }
.btn.secondaire:hover { background: var(--accent-doux); }
.btn.danger { background: var(--danger-doux); color: var(--danger); }
.btn.petit { min-height: 34px; padding: 0 11px; font-size: 13.5px; border-radius: 9px; }
.btn.plein { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.lien-btn { background: none; border: 0; color: var(--accent); padding: 6px 0; font-weight: 600; text-align: left; }
.erreur { color: var(--danger); font-size: 14px; }
.aide { font-size: 13px; color: var(--gris); }

/* ------------------------------------------------------------------ cadre général */
.cadre { display: grid; grid-template-columns: 1fr; height: 100dvh; }
.col-liste, .col-fil, .col-panneau { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.col-liste { background: var(--surface); }
.col-fil { background: var(--fond); }
.col-panneau { background: var(--surface); }
/* Mobile : une seule colonne visible */
.cadre[data-vue="liste"] .col-fil, .cadre[data-vue="liste"] .col-panneau { display: none; }
.cadre[data-vue="fil"] .col-liste, .cadre[data-vue="fil"] .col-panneau { display: none; }
.cadre[data-vue="panneau"] .col-liste, .cadre[data-vue="panneau"] .col-fil { display: none; }
@media (min-width: 760px) {
  .cadre { grid-template-columns: 340px 1fr; }
  .cadre[data-vue] .col-liste { display: flex; border-right: 1px solid var(--ligne); }
  .cadre[data-vue="liste"] .col-fil { display: flex; }
  .cadre[data-vue="panneau"] .col-fil { display: none; }
  .cadre[data-vue="panneau"] .col-panneau { display: flex; }
}
@media (min-width: 1180px) {
  .cadre { grid-template-columns: 340px 1fr 380px; }
  .cadre[data-vue] .col-fil, .cadre[data-vue] .col-panneau { display: flex; }
  .col-panneau { border-left: 1px solid var(--ligne); }
  .seulement-mobile-panneau { display: none !important; }
  /* panneau élargi : galerie, carte, rapports ; très large : maquette 3D et Gantt */
  .cadre:has(.col-panneau.large) { grid-template-columns: 320px 1fr 540px; }
  .cadre:has(.col-panneau.vaste) { grid-template-columns: 340px minmax(300px, .75fr) 1.6fr; }
}

.entete {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-height: 58px;
  padding-top: max(10px, env(safe-area-inset-top)); background: var(--surface); border-bottom: 1px solid var(--ligne);
  position: relative; z-index: 5;
}
.entete h1, .entete h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }
.entete .titre { flex: 1; min-width: 0; }
.entete .titre small { display: block; color: var(--gris); font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entete .titre-bouton { background: none; border: 0; padding: 0; text-align: left; display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.ico {
  width: 40px; height: 40px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 11px;
  background: none; border: 0; color: var(--encre); font-size: 19px;
}
.ico:hover { background: var(--surface-2); }
.ico svg { width: 22px; height: 22px; }
.ico.actif { color: var(--accent); background: var(--accent-doux); }
.defile { flex: 1; overflow-y: auto; min-height: 0; -webkit-overflow-scrolling: touch; }

/* barre du bas (mobile) */
.barre-bas {
  display: flex; border-top: 1px solid var(--ligne); background: var(--surface);
  padding-bottom: env(safe-area-inset-bottom);
}
.barre-bas button {
  flex: 1; display: grid; justify-items: center; gap: 2px; padding: 8px 0 7px; background: none; border: 0;
  color: var(--gris); font-size: 11.5px; font-weight: 600;
}
.barre-bas button svg { width: 23px; height: 23px; }
.barre-bas button[aria-current="page"] { color: var(--accent); }
@media (min-width: 760px) { .barre-bas { display: none; } .rail { display: flex !important; } }

/* ------------------------------------------------------------------ liste des conversations */
.recherche-liste { padding: 10px 12px 6px; display: grid; gap: 8px; }
.recherche-liste .saisie { min-height: 40px; padding: 8px 12px; border-radius: 10px; }
.puces { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.puce {
  border: 1px solid var(--ligne); background: var(--surface); border-radius: 999px; padding: 4px 11px;
  font-size: 13px; color: var(--gris); white-space: nowrap; font-weight: 600;
}
.puce[aria-pressed="true"] { background: var(--accent); color: var(--sur-accent); border-color: var(--accent); }
.conv {
  display: flex; gap: 11px; padding: 11px 12px; border: 0; background: none; width: 100%; text-align: left;
  border-bottom: 1px solid var(--ligne); align-items: flex-start;
}
.conv:hover { background: var(--surface-2); }
.conv[aria-current="true"] { background: var(--accent-doux); }
.avatar-conv {
  width: 46px; height: 46px; border-radius: 13px; background: var(--surface-2); display: grid; place-items: center;
  font-size: 23px; flex: 0 0 auto; border: 1px solid var(--ligne);
}
.conv-corps { flex: 1; min-width: 0; display: grid; gap: 2px; }
.conv-ligne1 { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.conv-date, .pastille { flex: 0 0 auto; }
.conv-nom { flex: 1; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-date { font-size: 12px; color: var(--gris); }
.conv-date.nouveau { color: var(--accent); font-weight: 700; }
.conv-apercu { min-width: 0; font-size: 13.5px; color: var(--gris); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-meta { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--gris-clair); min-width: 0; }
.conv-meta .adr { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.etiq { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; padding: 1px 6px; border-radius: 5px; background: var(--surface-2); color: var(--gris); border: 1px solid var(--ligne); }
.pastille { min-width: 21px; height: 21px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: var(--sur-accent); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.bouton-flottant {
  position: absolute; right: 16px; bottom: calc(var(--barre-bas) + 14px + env(safe-area-inset-bottom));
  border-radius: 999px; box-shadow: 0 6px 20px rgba(14, 97, 105, .35); z-index: 10;
}
@media (min-width: 760px) { .bouton-flottant { bottom: 18px; } }
.col-liste { position: relative; }
.vide { padding: 40px 20px; text-align: center; color: var(--gris); }
.vide b { display: block; color: var(--encre); font-size: 16px; margin-bottom: 4px; }

/* ------------------------------------------------------------------ fil de discussion */
.fil { padding: 12px 10px 18px; display: flex; flex-direction: column; gap: 3px; }
.jour { align-self: center; margin: 14px 0 8px; font-size: 12px; font-weight: 700; color: var(--gris); background: var(--surface); border: 1px solid var(--ligne); padding: 3px 11px; border-radius: 99px; }
.msg { display: flex; flex-direction: column; max-width: min(78%, 520px); align-self: flex-start; position: relative; }
.msg.moi { align-self: flex-end; align-items: flex-end; }
.msg .auteur { font-size: 12.5px; font-weight: 700; margin: 8px 0 2px 10px; }
.bulle {
  background: var(--bulle); border-radius: 16px; padding: 7px 11px 6px; box-shadow: var(--ombre);
  white-space: pre-wrap; overflow-wrap: anywhere; position: relative; max-width: 100%;
}
.msg.moi .bulle { background: var(--bulle-moi); color: var(--bulle-moi-texte); }
.msg.moi .bulle a { color: inherit; }
.heure { font-size: 11px; color: var(--gris-clair); margin-left: 8px; float: right; margin-top: 5px; white-space: nowrap; }
.msg.moi .heure { color: rgba(255,255,255,.75); }
.bulle.media { padding: 4px; background: var(--bulle); }
.msg.moi .bulle.media { background: var(--bulle-moi); }
.bulle.media .legende { padding: 4px 7px 2px; white-space: pre-wrap; }
.photo-fil { width: 100%; border-radius: 12px; overflow: hidden; position: relative; background: var(--surface-2); cursor: zoom-in; border: 0; padding: 0; display: block; }
.photo-fil img { width: 100%; max-height: 360px; object-fit: cover; min-height: 120px; }
.grille-photos { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; width: min(320px, 70vw); }
.grille-photos .photo-fil img { height: 150px; min-height: 0; }
.grille-photos .plus { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.45); color: #fff; font-size: 26px; font-weight: 700; }
.lieu { font-size: 11.5px; color: var(--gris); padding: 3px 7px 1px; display: flex; gap: 4px; align-items: center; }
.msg.moi .lieu { color: rgba(255,255,255,.8); }
.carte-fichier { display: flex; gap: 10px; align-items: center; padding: 8px 6px; min-width: 220px; text-decoration: none; color: inherit; }
.carte-fichier .ext { width: 40px; height: 46px; border-radius: 8px; background: var(--danger-doux); color: var(--danger); font-size: 11px; font-weight: 800; display: grid; place-items: center; flex: 0 0 auto; text-transform: uppercase; }
.carte-fichier .ext.doc { background: #DCE7FA; color: #2A56B5; }
.carte-fichier .ext.xls { background: var(--ok-doux); color: var(--ok); }
.carte-fichier .nom { font-weight: 600; font-size: 14px; word-break: break-word; }
.carte-fichier small { color: var(--gris); display: block; }
.msg.moi .carte-fichier small { color: rgba(255,255,255,.8); }
.audio-fil { display: grid; gap: 5px; padding: 6px 6px 2px; min-width: 240px; }
.audio-fil audio { width: 100%; height: 38px; }
.transcription { font-size: 13px; font-style: italic; opacity: .85; white-space: pre-wrap; }
.video-fil video { width: 100%; max-height: 360px; border-radius: 12px; background: #000; display: block; }
.carte-rapport {
  align-self: center; width: min(92%, 440px); margin: 8px 0; border-radius: 16px; padding: 10px 14px; color: #fff;
  background: linear-gradient(100deg, var(--rapport-a), var(--rapport-b)); text-align: center; border: 0; box-shadow: var(--ombre);
}
.carte-rapport b { font-weight: 700; }
.carte-rapport .ouvrir { display: block; margin-top: 4px; font-weight: 700; font-size: 13px; opacity: .95; }
.carte-rapport .heure { color: rgba(255,255,255,.8); }
.systeme { align-self: center; font-size: 12.5px; color: var(--gris); padding: 4px 10px; text-align: center; max-width: 90%; }
.citation { border-left: 3px solid var(--accent); background: var(--surface-2); color: var(--encre); border-radius: 8px; padding: 4px 8px; margin: 2px 0 5px; font-size: 13px; }
.msg.moi .citation { background: rgba(255,255,255,.16); color: inherit; border-color: rgba(255,255,255,.7); }
.citation b { display: block; font-size: 12px; }
.reactions { display: flex; gap: 4px; margin-top: -6px; margin-left: 10px; position: relative; z-index: 1; }
.msg.moi .reactions { margin-right: 10px; }
.reaction { background: var(--surface); border: 1px solid var(--ligne); border-radius: 99px; font-size: 12.5px; padding: 0 7px; line-height: 20px; }
.msg.attente .bulle { opacity: .7; }
.msg.attente .heure::before { content: "⏱ "; }
.msg.echec .bulle { outline: 2px solid var(--danger); }
.lus { align-self: flex-end; font-size: 11.5px; color: var(--gris); margin: 2px 4px 0; }
.charger-plus { align-self: center; margin: 6px 0 10px; }
.msg-actions { position: absolute; top: 4px; right: -4px; transform: translateX(100%); display: none; gap: 2px; }
.msg.moi .msg-actions { right: auto; left: -4px; transform: translateX(-100%); }
@media (hover: hover) { .msg:hover .msg-actions { display: flex; } }
.msg-actions button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--ligne); background: var(--surface); font-size: 14px; display: grid; place-items: center; color: var(--gris); }

/* zone de saisie */
.saisie-msg {
  display: flex; align-items: flex-end; gap: 6px; padding: 8px 8px; background: var(--surface);
  border-top: 1px solid var(--ligne); padding-bottom: max(8px, env(safe-area-inset-bottom));
}
.saisie-msg textarea {
  flex: 1; resize: none; border: 1px solid var(--ligne); background: var(--surface-2); border-radius: 20px;
  padding: 10px 14px; max-height: 140px; min-height: 42px; outline: none; line-height: 1.35;
}
.saisie-msg textarea:focus { border-color: var(--accent); }
.rond { width: 42px; height: 42px; border-radius: 999px; border: 0; display: grid; place-items: center; background: var(--surface-2); color: var(--encre); flex: 0 0 auto; }
.rond svg { width: 21px; height: 21px; }
.rond.envoyer { background: var(--accent); color: var(--sur-accent); }
.rond.enreg { background: var(--danger); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(178,58,58,.2); } }
.reponse-en-cours { display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: var(--surface-2); border-top: 1px solid var(--ligne); font-size: 13px; }
.reponse-en-cours div { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-pj { position: absolute; bottom: 64px; left: 8px; background: var(--surface); border: 1px solid var(--ligne); border-radius: 14px; box-shadow: var(--ombre); padding: 6px; display: grid; z-index: 20; min-width: 230px; }
.menu-pj button { display: flex; gap: 12px; align-items: center; border: 0; background: none; padding: 11px 12px; border-radius: 9px; text-align: left; font-weight: 600; }
.menu-pj button:hover { background: var(--surface-2); }
.menu-pj .e { font-size: 20px; width: 26px; text-align: center; }
.col-fil { position: relative; }
.bandeau { padding: 7px 12px; font-size: 13px; text-align: center; background: var(--signal-doux); color: var(--signal); font-weight: 600; }
.bandeau.ok { background: var(--ok-doux); color: var(--ok); }

/* ------------------------------------------------------------------ panneau dossier / infos */
.onglets { display: flex; gap: 4px; padding: 8px 12px; border-bottom: 1px solid var(--ligne); }
.onglet { flex: 1; border: 0; background: var(--surface-2); border-radius: 10px; padding: 8px; font-weight: 650; color: var(--gris); }
.onglet[aria-selected="true"] { background: var(--accent-doux); color: var(--accent); }
.bloc { padding: 14px 14px 6px; border-bottom: 8px solid var(--fond); }
.bloc h3 { margin: 0 0 10px; font-size: 15px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bloc h3 button { font-size: 13.5px; }
.vignettes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-bottom: 8px; }
.vignettes button { aspect-ratio: 1; padding: 0; border: 0; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.vignettes img { width: 100%; height: 100%; object-fit: cover; }
.ligne-lien { display: flex; align-items: center; gap: 11px; width: 100%; padding: 11px 4px; border: 0; background: none; text-align: left; border-bottom: 1px solid var(--ligne); color: var(--encre); text-decoration: none; }
.ligne-lien:last-child { border-bottom: 0; }
.ligne-lien:hover { background: var(--surface-2); }
.ligne-lien .lib { flex: 1; min-width: 0; font-weight: 550; }
.ligne-lien .lib small { display: block; color: var(--gris); font-weight: 450; font-size: 12.5px; }
.ligne-lien .nb { color: var(--gris); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.ligne-lien .e { width: 26px; text-align: center; font-size: 18px; }
.chevron { color: var(--gris-clair); }
.membre { display: flex; gap: 10px; align-items: center; padding: 8px 0; }
.membre .lib { flex: 1; min-width: 0; }
.membre .lib small { display: block; color: var(--gris); font-size: 12.5px; }
.initiales { width: 36px; height: 36px; border-radius: 999px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13.5px; flex: 0 0 auto; }

/* galerie + visionneuse */
.galerie { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 3px; padding: 3px; }
.galerie button { aspect-ratio: 1; border: 0; padding: 0; background: var(--surface-2); position: relative; overflow: hidden; }
.galerie img { width: 100%; height: 100%; object-fit: cover; }
.galerie .video-badge { position: absolute; right: 5px; bottom: 5px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 6px; }
.titre-mois { padding: 12px 10px 6px; font-size: 13px; font-weight: 700; color: var(--gris); text-transform: capitalize; }
.visionneuse { position: fixed; inset: 0; background: #000; z-index: 100; display: flex; flex-direction: column; color: #fff; }
.visionneuse .haut, .visionneuse .bas { display: flex; align-items: center; gap: 8px; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); background: rgba(0,0,0,.6); }
.visionneuse .bas { padding-bottom: max(10px, env(safe-area-inset-bottom)); display: block; font-size: 13.5px; }
.visionneuse .ico { color: #fff; }
.visionneuse .ico:hover { background: rgba(255,255,255,.12); }
.visionneuse .scene { flex: 1; min-height: 0; display: grid; place-items: center; position: relative; touch-action: pan-y; }
.visionneuse .scene img, .visionneuse .scene video { max-width: 100%; max-height: 100%; object-fit: contain; }
.visionneuse .nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 99px; border: 0; background: rgba(255,255,255,.14); color: #fff; font-size: 24px; }
.visionneuse .nav.g { left: 10px; } .visionneuse .nav.d { right: 10px; }

/* carte */
.carte-zone { flex: 1; min-height: 300px; }
.leaflet-container { font-family: var(--police); background: var(--surface-2); }
.marqueur-emoji { background: var(--surface); border: 2px solid var(--accent); border-radius: 12px; display: grid !important; place-items: center; font-size: 19px; box-shadow: var(--ombre); }
.marqueur-photo { border: 2px solid #fff; border-radius: 9px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,.35); background: #ccc; }
.marqueur-photo img { width: 100%; height: 100%; object-fit: cover; }
.popup-conv b { display: block; font-size: 14px; }
.popup-conv small { color: #5C6B6A; }

/* rapports */
.liste-rapports .rapport-ligne { display: flex; gap: 10px; align-items: center; width: 100%; padding: 11px 12px; border: 0; border-bottom: 1px solid var(--ligne); background: var(--surface); text-align: left; }
.rapport-ligne:hover { background: var(--surface-2); }
.rapport-ligne .mini { width: 46px; height: 46px; border-radius: 9px; object-fit: cover; background: var(--surface-2); flex: 0 0 auto; display: grid; place-items: center; font-size: 20px; overflow: hidden; }
.rapport-ligne .lib { flex: 1; min-width: 0; }
.rapport-ligne .lib b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rapport-ligne .lib small { color: var(--gris); }
.statut { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--signal-doux); color: var(--signal); white-space: nowrap; }
.statut.clos { background: var(--ok-doux); color: var(--ok); }
.formulaire { padding: 14px; display: grid; gap: 16px; max-width: 760px; width: 100%; margin: 0 auto; }
.valeur-rapport { display: grid; gap: 3px; padding: 10px 0; border-bottom: 1px solid var(--ligne); }
.valeur-rapport .lib { font-size: 12.5px; color: var(--gris); font-weight: 650; }
.valeur-rapport .val { white-space: pre-wrap; }
.photos-champ { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 5px; }
.photos-champ .ph { aspect-ratio: 1; border-radius: 9px; overflow: hidden; border: 0; padding: 0; background: var(--surface-2); }
.photos-champ .ph img { width: 100%; height: 100%; object-fit: cover; }
.photos-champ .ajouter { aspect-ratio: 1; border-radius: 9px; border: 2px dashed var(--ligne); background: none; color: var(--gris); font-size: 26px; }
.cases { display: flex; flex-wrap: wrap; gap: 6px; }
.cases label { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border: 1px solid var(--ligne); border-radius: 10px; background: var(--surface-2); font-size: 14px; }
.cases input { accent-color: var(--accent); width: 17px; height: 17px; }
.signature-zone { border: 1px dashed var(--ligne); border-radius: 12px; background: #fff; touch-action: none; width: 100%; height: 170px; }
.signature-img { max-height: 120px; background: #fff; border-radius: 8px; border: 1px solid var(--ligne); }
.groupe-ligne { border: 1px solid var(--ligne); border-radius: 12px; padding: 10px; display: grid; gap: 8px; background: var(--surface-2); }
.groupe-ligne header { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 700; color: var(--gris); }
.barre-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 14px; border-top: 1px solid var(--ligne); background: var(--surface); padding-bottom: max(10px, env(safe-area-inset-bottom)); }

/* équipe */
.carte-blanche { background: var(--surface); border-radius: var(--rayon); padding: 14px; box-shadow: var(--ombre); display: grid; gap: 12px; }
.page { padding: 14px; display: grid; gap: 14px; align-content: start; max-width: 820px; width: 100%; margin: 0 auto; }
.role { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); color: var(--gris); border: 1px solid var(--ligne); }
.role.admin { background: var(--accent-doux); color: var(--accent); border-color: transparent; }
.role.externe { background: var(--signal-doux); color: var(--signal); border-color: transparent; }
.lien-invit { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; word-break: break-all; background: var(--surface-2); padding: 9px; border-radius: 9px; border: 1px solid var(--ligne); }
.grille-2 { display: grid; gap: 12px; }
@media (min-width: 600px) { .grille-2 { grid-template-columns: 1fr 1fr; } }

/* modale */
.voile { position: fixed; inset: 0; background: rgba(10, 18, 18, .45); z-index: 80; display: grid; align-items: end; justify-items: center; }
@media (min-width: 640px) { .voile { align-items: center; } }
.modale {
  background: var(--surface); width: 100%; max-width: 520px; max-height: 92dvh; overflow: auto; border-radius: 20px 20px 0 0;
  padding: 18px 16px; padding-bottom: max(18px, env(safe-area-inset-bottom)); display: grid; gap: 14px; box-shadow: var(--ombre);
}
@media (min-width: 640px) { .modale { border-radius: 20px; } }
.modale h2 { margin: 0; font-size: 18px; }
.modale .actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.suggestions { border: 1px solid var(--ligne); border-radius: 10px; overflow: hidden; }
.suggestions button { display: block; width: 100%; text-align: left; border: 0; background: var(--surface); padding: 9px 11px; border-bottom: 1px solid var(--ligne); font-size: 14px; }
.suggestions button:hover { background: var(--surface-2); }
.choix-liste { max-height: 260px; overflow: auto; border: 1px solid var(--ligne); border-radius: 10px; }
.choix-liste label { display: flex; gap: 10px; align-items: center; padding: 9px 11px; border-bottom: 1px solid var(--ligne); }
.choix-liste input { accent-color: var(--accent); width: 18px; height: 18px; }

#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 200; display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { background: var(--encre); color: var(--fond); padding: 10px 14px; border-radius: 12px; font-size: 14px; box-shadow: var(--ombre); animation: monte .2s ease-out; }
.toast.erreur { background: var(--danger); color: #fff; }
@keyframes monte { from { transform: translateY(8px); opacity: 0; } }
.chargement { padding: 30px; text-align: center; color: var(--gris); }
.resultat { padding: 10px 14px; border-bottom: 1px solid var(--ligne); background: var(--surface); width: 100%; text-align: left; border-left: 0; border-right: 0; border-top: 0; display: grid; gap: 2px; }
.resultat small { color: var(--gris); }
.resultat mark { background: var(--signal-doux); color: inherit; border-radius: 3px; }
.rail { display: none; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------------------------------------------------------------- 1.2 : maquette BIM, Gantt, commandes */
.lien-sans { border: 0; background: none; padding: 0; text-align: left; color: inherit; font: inherit; cursor: pointer; }
.saisie.petit { min-height: 34px; padding: 0 8px; font-size: 13.5px; width: auto; border-radius: 9px; }
.btn.actif { background: var(--accent); color: var(--sur-accent); border-color: var(--accent); }
.outils-3d { display: flex; gap: 6px; padding: 8px 12px; overflow-x: auto; border-bottom: 1px solid var(--ligne); background: var(--surface); flex: none; align-items: center; scrollbar-width: none; }
.outils-3d > * { flex: none; }
.reglage-3d { display: flex; gap: 10px; align-items: center; padding: 6px 14px; background: var(--surface); border-bottom: 1px solid var(--ligne); font-size: 13.5px; flex: none; }
.reglage-3d input[type=range] { flex: 1; accent-color: var(--accent); }
.vue-3d { position: relative; flex: 1; min-height: 260px; overflow: hidden; background: var(--surface-2); display: flex; touch-action: none; }
.canvas-3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
.legende-3d { position: absolute; left: 10px; top: 10px; z-index: 2; display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; border-radius: 10px; background: color-mix(in srgb, var(--surface) 88%, transparent); box-shadow: var(--ombre); font-size: 12px; max-width: 60%; pointer-events: none; }
.legende-3d span { display: flex; align-items: center; gap: 6px; }
.legende-3d i { width: 12px; height: 12px; border-radius: 3px; flex: none; border: 1px solid rgba(0,0,0,.12); }
.legende-3d small { color: var(--gris); }
.fiche-3d { position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 3; padding: 10px 12px; border-radius: 14px; background: var(--surface); box-shadow: 0 6px 24px rgba(0,0,0,.18); max-height: 55%; overflow: auto; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
@media (min-width: 760px) { .fiche-3d { left: auto; width: 360px; } }
.fiche-titre { display: flex; align-items: center; gap: 8px; justify-content: space-between; margin-bottom: 4px; }
.fiche-titre b { font-size: 15px; }
.infos-3d { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 4px 0 10px; font-size: 13.5px; }
.infos-3d dt { color: var(--gris); }
.infos-3d dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }
.filtres-3d { display: grid; gap: 10px; max-height: 60vh; overflow: auto; }
.filtres-3d summary { font-weight: 650; cursor: pointer; padding: 4px 0; }
.cases-filtre { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 10px; font-size: 13.5px; padding: 4px 0; }
.cases-filtre label { display: flex; gap: 6px; align-items: center; }
.actions-filtre { display: flex; gap: 12px; font-size: 13px; }
.statut.liv-demandee { background: #E2EAFB; color: #2F59B8; }
.statut.liv-commandee { background: #EEE5FA; color: #6E3FB5; }
.statut.liv-livree { background: var(--ok-doux); color: var(--ok); }
.statut.liv-annulee { background: var(--surface-2); color: var(--gris); }

/* Gantt */
.gantt-zone { display: flex; flex-direction: column; flex: 1; min-height: 0; --g-lib: 210px; --g-weekend: rgba(20, 33, 32, .045); --g-h: 34px; }
@media (max-width: 600px) { .gantt-zone { --g-lib: 132px; } }
.g-defile { flex: 1; min-height: 0; overflow: auto; position: relative; overscroll-behavior: contain; }
.g-contenu { position: relative; min-height: 100%; }
.g-ligne, .g-entete { display: flex; min-height: var(--g-h); border-bottom: 1px solid var(--ligne); }
.g-entete { position: sticky; top: 0; z-index: 4; background: var(--surface); min-height: 44px; }
.g-lib { position: sticky; left: 0; z-index: 2; width: var(--g-lib); flex: none; background: var(--surface); border-right: 1px solid var(--ligne); padding: 4px 8px; display: flex; flex-direction: column; justify-content: center; min-width: 0; text-align: left; border-top: 0; border-left: 0; border-bottom: 0; font: inherit; color: inherit; }
button.g-lib { cursor: pointer; }
.g-lib span { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-lib small { font-size: 11px; color: var(--gris); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-entete .g-lib { z-index: 5; font-size: 12px; color: var(--gris); }
.g-groupe .g-lib { font-weight: 700; font-size: 12.5px; color: var(--accent); background: var(--surface-2); }
.g-groupe { min-height: 28px; background: var(--surface-2); }
.g-temps { position: relative; flex: none; }
.g-rang-mois, .g-rang-sem { position: relative; height: 22px; }
.g-mois { position: absolute; top: 3px; font-size: 12px; font-weight: 650; white-space: nowrap; padding-left: 4px; border-left: 1px solid var(--ligne); text-transform: capitalize; }
.g-sem { position: absolute; top: 3px; font-size: 10.5px; color: var(--gris); white-space: nowrap; overflow: hidden; padding-left: 3px; border-left: 1px solid var(--ligne); }
.g-barre { position: absolute; top: 6px; height: calc(var(--g-h) - 13px); border-radius: 6px; border: 0; padding: 0; overflow: hidden; cursor: pointer; text-align: left; background: #B9C3C2; color: #142120; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.g-barre.avenir { background: #C9D3D2; }
.g-barre.encours { background: #F6C48F; }
.g-barre.fait { background: #9FD3B2; }
.g-barre.retard { background: #F2A7A7; box-shadow: inset 0 0 0 2px #D64545; }
.g-barre.bloque { background: repeating-linear-gradient(45deg, #E9B0B0, #E9B0B0 6px, #F5D5D5 6px, #F5D5D5 12px); }
.g-av { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(14, 97, 105, .38); }
.g-txt { position: relative; font-size: 11.5px; font-weight: 600; padding: 0 6px; white-space: nowrap; line-height: calc(var(--g-h) - 13px); }
.g-jalon { position: absolute; top: 10px; width: 14px; height: 14px; transform: rotate(45deg); border-radius: 2px; border: 0; padding: 0; background: #8C9998; cursor: pointer; }
.g-jalon.liv-demandee { background: #3C6FD6; }
.g-jalon.liv-commandee { background: #8E5BD0; }
.g-jalon.liv-livree { background: #2F9E5B; }
.g-jalon.liv-retard { background: #D64545; }
.g-jalon.liv-prevue { background: #E2A35B; }
.g-commande { position: absolute; top: 16px; height: 2px; background: repeating-linear-gradient(90deg, #8C9998, #8C9998 4px, transparent 4px, transparent 7px); }
.g-aujourdhui { position: absolute; top: 0; bottom: 0; width: 2px; background: #D64545; z-index: 1; pointer-events: none; }
.legende-gantt { display: flex; gap: 12px; flex-wrap: wrap; padding: 8px 14px; border-top: 1px solid var(--ligne); font-size: 12px; color: var(--gris); flex: none; }
.legende-gantt span { display: flex; align-items: center; gap: 5px; }
.legende-gantt .g-barre { position: static; display: inline-block; width: 22px; height: 11px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .gantt-zone { --g-weekend: rgba(255,255,255,.04); }
  :root:not([data-theme="light"]) .g-barre { color: #0d1514; }
}
:root[data-theme="dark"] .gantt-zone { --g-weekend: rgba(255,255,255,.04); }
