/* ==========================================================================
   CertixPro — feuille de style
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f6;
  --border: #e0e5eb;
  --border-strong: #c7cfd9;
  --border-field: #7d8797;
  --focus: #1d4f91;
  --text: #16202c;
  --text-2: #4a5566;
  --text-3: #5f6b7d;

  --primary: #1d4f91;
  --primary-hover: #173f75;
  --primary-soft: #eaf1fb;
  --primary-ring: rgba(29, 79, 145, 0.25);
  --on-primary: #ffffff;
  --accent: #f0a024;
  --gestion: #c62d22; /* grue rouge : page de gestion de l'équipe (même rouge en thème sombre, comme le logo bleu) */

  --success: #17794a;
  --success-soft: #e5f4ec;
  --warning: #8f5800;
  --warning-soft: #fff4da;
  --warning-line: #f1d08a;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --danger-line: #f3b9b3;
  --info: #24589f;
  --info-soft: #e9f0fa;
  /* Filets des rappels (lignes fines « À faire » et points de vigilance) : jaune clair et gris clair, pour se détacher
     franchement du rouge bloquant. Un peu plus clairs que --warning et --text-2, qu'ils remplacent sur ces filets. */
  --filet-warning: #e0a800;
  --filet-info: #a8b2c0;
  --violet: #5b3fa3;
  --violet-soft: #f0ecfa;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 6px 16px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.18);

  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --topbar-h: 59px;
}

/* Thème sombre : data-theme est posé par index.html avant l'affichage (choix du bouton soleil / lune, sinon le système). */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e131a;
  --surface: #161d26;
  --surface-2: #1b232e;
  --surface-3: #222c38;
  --border: #2a3542;
  --border-strong: #3a4757;
  --border-field: #6b7689;
  --focus: #9dc0f5;
  --text: #e7ebf0;
  --text-2: #a2adbb;
  --text-3: #8b96a6;

  --primary: #78a8ec;
  --primary-hover: #94bbf2;
  --primary-soft: rgba(120, 168, 236, 0.14);
  --primary-ring: rgba(120, 168, 236, 0.35);
  --on-primary: #0b1420;

  --success: #5fcf96;
  --success-soft: rgba(95, 207, 150, 0.14);
  --warning: #f2bd5c;
  --warning-soft: rgba(242, 189, 92, 0.13);
  --warning-line: rgba(242, 189, 92, 0.35);
  --danger: #f58b80;
  --danger-soft: rgba(245, 139, 128, 0.14);
  --danger-line: rgba(245, 139, 128, 0.4);
  --info: #86b2f0;
  --info-soft: rgba(134, 178, 240, 0.14);
  --filet-warning: #f2bd5c;
  --filet-info: #a2adbb;
  --violet: #b7a2f0;
  --violet-soft: rgba(183, 162, 240, 0.15);

  --shadow: 0 1px 0 rgba(255, 255, 255, 0.02);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.55);
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: 0.95rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
/* Cases cochées en bleu de l'appli, même quand le système peint ses cases d'une autre couleur (orange sur certains postes). */
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }
kbd {
  font-family: var(--mono);
  font-size: 0.75em;
  padding: 1px 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-2);
}
sub { font-size: 0.7em; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
#app:focus { outline: none; }

.icon {
  width: 1.1em;
  height: 1.1em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.muted { color: var(--text-2); }
.small { font-size: 0.85rem; }
.pre-line { white-space: pre-line; }
.text-danger { color: var(--danger); }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Barre supérieure ---------- */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: #1d4f91;
  flex: none;
}
.brand-mark svg {
  width: 24px; height: 24px;
  fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.brand-mark .brand-hook { fill: var(--accent); stroke: none; }
/* Page de gestion de l'équipe (#/equipe) : même logo, en rouge (le back-office l'a en noir, l'appli en bleu). */
body[data-page="equipe"] .brand-mark { background: var(--gestion); }
.compte-menu .menu-item .picto-grue { color: var(--gestion); }
.compte-menu .menu-item:hover .picto-grue { color: var(--gestion); }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 1rem; }
.brand-text small { color: var(--text-2); font-size: 0.78rem; }
/* Stockage en ligne : témoin d'enregistrement, bandeau de conflit, compte connecté. */
.sync-etat {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 0.8rem; color: var(--text-2);
  white-space: nowrap;
}
.sync-etat::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
}
.sync-etat[data-etat="envoi"]::before { background: var(--accent); }
.sync-etat[data-etat="erreur"] { color: var(--danger); }
.sync-etat[data-etat="erreur"]::before { background: var(--danger); }
.sync-bandeau {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px 16px;
  padding: 10px 16px;
  background: var(--danger-soft); color: var(--danger);
  border-bottom: 1px solid var(--danger-line);
  font-weight: 600; font-size: 0.9rem; text-align: center;
}
.sync-bandeau[data-type="info"] { background: var(--info-soft); color: var(--info); border-bottom-color: var(--border); }
.sync-etat[data-etat="lecture"]::before { background: var(--info); }
/* Tout va bien : rien à dire. Le témoin ne s'affiche que pour « Enregistrement… », une erreur ou la lecture seule. */
.sync-etat[data-etat="ok"] { display: none; }
.compte { display: flex; align-items: center; gap: 10px; min-width: 0; margin-left: auto; }
.compte-bouton {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  padding: 4px 8px; border-radius: var(--radius-sm); cursor: pointer;
}
.compte-bouton:hover { background: var(--surface-3); }
.compte-bouton:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.compte-chevron { color: var(--text-2); font-size: 0.8rem; }
.compte-menu { min-width: 280px; padding: 8px; gap: 2px; }
.compte-pastille {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 0.86rem;
}
.compte-bouton .compte-pastille { width: 28px; height: 28px; font-size: 0.8rem; }
.compte-titre { margin: 8px 10px 4px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); }
.compte-item { display: flex; flex-direction: column; line-height: 1.25; text-align: left; min-width: 0; }
.compte-item strong, .compte-item small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compte-item small { color: var(--text-2); font-size: 0.78rem; }
.compte-entete { display: flex; align-items: center; gap: 10px; padding: 8px 10px 12px; margin: 0 0 6px; border-bottom: 1px solid var(--border); }
.compte-entete .compte-pastille { width: 38px; height: 38px; font-size: 1rem; }
.compte-menu .menu-item { gap: 10px; padding: 9px 10px; }
.compte-picto { flex: none; color: var(--text-2); }
.compte-menu .menu-item:hover .compte-picto { color: var(--text); }
.compte-trait { border: 0; border-top: 1px solid var(--border); margin: 6px 4px; }
.compte-libelle { flex: 1; }
.interrupteur {
  position: relative; flex: none; width: 34px; height: 20px; border-radius: 999px;
  background: var(--border-strong); transition: background 0.15s;
}
.interrupteur::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); transition: transform 0.15s;
}
[role="switch"][aria-checked="true"] .interrupteur { background: var(--primary); }
[role="switch"][aria-checked="true"] .interrupteur::after { transform: translateX(14px); }
.picto-soleil { display: none; }
:root[data-theme="dark"] .compte-menu .picto-soleil { display: block; }
:root[data-theme="dark"] .compte-menu .picto-lune { display: none; }
.compte-menu .menu-item.is-danger { font-weight: 600; }
.compte-menu .menu-item.is-danger .compte-picto { color: currentColor; }
.compte-menu .menu-item.is-danger:hover { background: var(--danger-soft); color: var(--danger); }
@media (prefers-reduced-motion: reduce) { .interrupteur, .interrupteur::after { transition: none; } }
.compte-offre { margin-left: auto; margin-right: 6px; font-size: 0.72rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.compte-offre + .compte { margin-left: 0; }
.compte-offre-solo { background: var(--primary-soft); color: var(--primary); }
.compte-offre-pro { background: var(--primary); color: var(--on-primary); }
.compte-nom { display: flex; flex-direction: column; line-height: 1.2; text-align: right; min-width: 0; }
.compte-nom strong { font-size: 0.86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compte-nom small { font-size: 0.76rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 520px) { .sync-etat { font-size: 0; gap: 0; } .compte-nom { display: none; } }
@media print { .sync-etat, .sync-bandeau, .compte { display: none; } }

/* Écrans de connexion, d'inscription et de création de l'organisation. */
.auth { max-width: 420px; margin: 48px auto; padding: 28px 28px 24px; }
.auth h1 { font-size: 1.4rem; margin: 0 0 4px; }
.auth > p.muted { margin: 0 0 20px; }
.auth form { display: flex; flex-direction: column; gap: 14px; }
.auth label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.9rem; }
.auth .aide { font-weight: 400; font-size: 0.8rem; color: var(--text-2); }
.auth .btn { width: 100%; justify-content: center; }
.auth-comptes { display: flex; flex-direction: column; gap: 6px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.auth-comptes p { margin: 0 0 2px; }
.auth .auth-compte { flex-direction: column; align-items: flex-start; gap: 0; text-align: left; }
.auth-compte small { font-size: 0.78rem; }
.auth-message { padding: 10px 12px; border-radius: 8px; font-size: 0.88rem; background: var(--surface-3); }
.auth-message[data-type="erreur"] { background: var(--danger-soft); color: var(--danger); }
.auth-message[data-type="ok"] { background: var(--success-soft); }
.auth-message[data-type="info"] { background: var(--primary-soft); color: var(--text); }
.auth-sep { display: flex; align-items: center; gap: 10px; margin: 18px 0; color: var(--text-3); font-size: 0.8rem; }
.auth-sep::before, .auth-sep::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.auth-fournisseurs { display: flex; flex-direction: column; gap: 8px; }
.auth-liens { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 18px; font-size: 0.86rem; }
.auth .auth-code { font-size: 1.4rem; letter-spacing: 0.35em; text-align: center; font-variant-numeric: tabular-nums; }

.btn.is-danger { color: var(--danger); }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 24px 72px;
}

/* ---------- Boutons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn:disabled:hover { background: var(--surface-3); border-color: var(--border); color: var(--text-3); cursor: not-allowed; }
.btn-ghost:disabled, .btn-ghost:disabled:hover { background: none; border-color: transparent; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 0.86rem; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 1rem; }
.btn-icon { width: 34px; padding: 0; }

.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-3); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.92); }
.btn-danger-text { color: var(--danger); }
.btn-danger-text:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn-row.center { justify-content: center; }

/* Interrupteur (ex. option « Révision des prix » du suivi) */

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--primary);
  cursor: pointer;
  font-size: inherit;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.link-discret { color: var(--text-3); align-self: flex-start; font-size: 0.88rem; text-decoration: underline; text-underline-offset: 2px; }
.link-btn.link-discret:hover { color: var(--text); }

.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  flex: none;
}
.icon-btn:hover { background: var(--danger-soft); color: var(--danger); }

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--text-2);
}
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-violet { background: var(--violet-soft); color: var(--violet); }
.badge-neutral { background: var(--surface-3); color: var(--text-2); }

/* ---------- En-têtes de page ---------- */

.eyebrow {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-2);
}

/* ---------- Cartes & panneaux ---------- */

.card, .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.panel { padding: 18px 20px 20px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
}
.chantier-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 20px;
  color: inherit;
}
/* Carte qui s'ouvre (un chantier archivé n'est pas un lien). */
.card-link { transition: border-color 0.12s, transform 0.12s, box-shadow 0.12s; }
.card-link:hover { text-decoration: none; border-color: var(--border-strong); transform: translateY(-1px); }
.card-wrap { position: relative; display: flex; flex-direction: column; }
.card-wrap[hidden] { display: none; }
.search-bar { margin-bottom: 16px; }
.search-bar .input { max-width: 420px; }
.card-wrap > .chantier-card { flex: 1; }
.card-wrap .card-top { padding-right: 34px; }
.card-wrap > .card-menu { position: absolute; top: 12px; right: 12px; z-index: 2; }
.card-menu > summary { width: 32px; height: 32px; }
.card-menu > summary:hover { background: var(--surface-3); color: var(--text); }
.card-menu .menu-pop { min-width: 170px; }
.card-wrap.is-archived .chantier-card { opacity: 0.75; }
/* Glisser-déposer des cartes chantier pour changer leur ordre. */
.grid-cards > .card-wrap:not(.is-archived) { touch-action: pan-y; }
.card-wrap.is-dragging { z-index: 20; cursor: grabbing; }
.card-wrap.is-dragging .card-link { box-shadow: var(--shadow-lg); border-color: var(--primary); transform: rotate(-1deg); transition: none; }
.grid-cards.is-sorting .card-wrap:not(.is-dragging) .card-link { border-style: dashed; }
.grid-cards.is-sorting { user-select: none; }
.grid-cards + .archives, .archives + .archives, .empty-state + .archives { margin-top: 16px; }
/* Chantiers archivés : carte repliable (chevron qui pivote à l'ouverture). */
.archives > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  cursor: pointer;
}
.archives > summary::-webkit-details-marker { display: none; }
/* Menu ⋯ de l'accueil : la liste s'ouvre par-dessus le bouton, son premier choix (« Nouveau chantier ») sous le pointeur. */
.accueil-menu { margin-left: auto; }
/* Liste « Chantiers en cours » repliée : pas de menu ⋯. */
.en-cours:not([open]) .accueil-menu { display: none; }
.accueil-menu > summary:hover, .accueil-menu[open] > summary { background: var(--surface-3); color: var(--text); }
.accueil-menu .menu-pop { top: -6px; right: -10px; min-width: 200px; }
/* « Nouveau chantier » : même allure que le bouton principal (texte blanc sur fond bleu). */
a.menu-item.menu-item-nouveau { margin-bottom: 4px; background: var(--primary); color: var(--on-primary); font-weight: 600; }
a.menu-item.menu-item-nouveau:hover { background: var(--primary-hover); }
.archives-title { display: inline-flex; align-items: center; gap: 6px; font-size: 1.1rem; font-weight: 650; }
/* Accueil en blocs (compte invité dans une équipe) : titres un cran au-dessus. */
.archives-title.bloc-titre { font-size: 1.25rem; }
.archives-title .icon { width: 18px; height: 18px; color: var(--text-3); transition: transform 0.15s; }
.archives[open] .archives-title .icon { transform: rotate(90deg); }
.archives[open] > summary { margin-bottom: 16px; }
.dialog .radio { color: var(--text); font-weight: 500; }
.card-top { display: flex; align-items: flex-start; gap: 12px; }
.card-top > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.card-top h2 { overflow-wrap: anywhere; }
.card-icon {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  flex: none;
}
.card-icon .icon { width: 22px; height: 22px; }

.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--border);
}
.mini-stats dt { font-size: 0.75rem; color: var(--text-3); }
.mini-stats dd { margin: 0; font-weight: 600; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.card-foot { display: flex; flex-wrap: wrap; gap: 6px; }

.empty-state {
  position: relative;
  padding: 48px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.empty-state p { max-width: 460px; }
.empty-state .btn-row { margin-top: 8px; }
.empty-state > .accueil-menu { position: absolute; top: 12px; right: 12px; }
.empty-icon {
  width: 64px; height: 64px;
  display: grid; place-items: center;
  border-radius: 18px;
  background: var(--primary-soft);
  color: var(--primary);
}
.empty-icon .icon { width: 32px; height: 32px; }
.empty-inline {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 18px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.empty-inline .btn { margin-top: 6px; }
.empty-note {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--success);
  font-size: 0.9rem;
}

/* ---------- Carte d'en-tête de page ---------- */
/* Flèche de retour, titre, pastilles, actions ; bande de chiffres clés en bas (voir DESIGN.md). */

.panel.page-card { padding: 0; margin-bottom: 16px; }
.page-card-top { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 16px; padding: 16px 20px; }
.page-card-main { display: flex; flex-direction: column; gap: 4px; flex: 1 1 320px; min-width: 0; }
.page-card-titre { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; min-width: 0; }
.page-card-main h1 { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 1.5rem; overflow-wrap: anywhere; }
.page-card-main h1 .badge { font-size: 0.74rem; }
.page-card-actions { margin-left: auto; align-self: center; }
.stats.page-stats { grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); border: 0; border-top: 1px solid var(--border); border-radius: 0 0 var(--radius-lg) var(--radius-lg); background: transparent; }
.stat-value small { font-size: 0.85rem; color: var(--text-3); font-weight: 600; }
.stat-value .badge { font-size: 0.8rem; padding: 3px 10px; }
a.menu-item { color: var(--text); text-decoration: none; }

/* Flèche de retour : ronde, comme le bouton de thème. */
.back-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  flex: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  transition: background-color 0.12s, color 0.12s, border-color 0.12s;
}
.back-btn:hover { text-decoration: none; background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.back-btn .icon { width: 19px; height: 19px; transition: transform 0.12s; }
.back-btn:hover .icon { transform: translateX(-2px); }
.back-row { margin-bottom: 16px; }

/* ---------- Mise en page chantier / lot ---------- */

.panel-lots { margin-bottom: 16px; }

.fiche-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.panel-alerts { margin-bottom: 16px; }
.panel-repli > summary { display: flex; align-items: center; gap: 8px; list-style: none; cursor: pointer; }
.panel-repli > summary::-webkit-details-marker { display: none; }
.panel-repli > summary .icon { width: 16px; height: 16px; color: var(--text-2); transition: transform 0.15s; }
.panel-repli[open] > summary .icon { transform: rotate(90deg); }
.panel-repli[open] > summary { margin-bottom: 12px; }

/* ---------- Tableau des lots ---------- */

.table-wrap { overflow-x: auto; margin: 0 -20px -20px; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table .lot-actions { width: 44px; padding-left: 0; text-align: right; }
.table tbody tr.is-selected, .table tbody tr.is-selected:hover { background: var(--primary-soft); }
.table td:first-child { position: relative; }
.table th:first-child, .table td:first-child { transition: padding-left 0.12s; }
.table.en-selection th:first-child, .table.en-selection td:first-child { padding-left: 50px; }
.lot-coche { display: none; position: absolute; left: 20px; top: 50%; width: 18px; height: 18px; margin-top: -9px; place-items: center; border: 2px solid var(--text-3); border-radius: 4px; background: var(--surface); color: var(--surface); }
.lot-coche .icon { width: 13px; height: 13px; stroke-width: 3.5; visibility: hidden; }
.en-selection .lot-coche { display: grid; }
.is-selected .lot-coche { border-color: var(--primary); background: var(--primary); }
.is-selected .lot-coche .icon { visibility: visible; }
.menu-item[hidden] { display: none; }
.panel-lots.a-tableau { padding-top: 0; }
.panel-lots.a-tableau .table th { border-top: 0; }
.panel-lots.a-tableau .table th:first-child { border-top-left-radius: var(--radius-lg); }
.panel-lots.a-tableau .table th:last-child { border-top-right-radius: var(--radius-lg); }
.th-nouveau > div { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.th-nouveau .btn { text-transform: none; letter-spacing: 0; white-space: nowrap; }
.lots-supprimes { margin-top: 16px; }
#impression-lots { display: none; }
.impression-lot + .impression-lot { break-before: page; }
.impression-lot h1 { font-size: 1.4rem; margin: 0; }
.impression-lot .fiche-grid { margin-top: 12px; }
.lot-menu { display: inline-block; }
.lot-menu > summary { width: 32px; height: 32px; }
.lot-menu > summary:hover { background: var(--surface-3); color: var(--text); }
.lot-menu .menu-pop { position: fixed; top: 0; left: 0; right: auto; min-width: 190px; }
.menu-sep { height: 1px; margin: 4px 6px; border: 0; background: var(--border); }
.table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 10px 12px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.table tbody tr { cursor: pointer; transition: background-color 0.1s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tfoot td { font-weight: 650; border-bottom: 0; background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-title { font-weight: 650; color: var(--text); }
.row-sub { display: block; font-size: 0.8rem; color: var(--text-2); font-weight: 400; }
.dot {
  width: 24px; height: 24px;
  display: inline-grid; place-items: center;
  border-radius: 50%;
}
.dot-ok { background: var(--success-soft); color: var(--success); }
.dot .icon { width: 14px; height: 14px; }

/* ---------- Points de vigilance ---------- */

.alerts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.88rem;
}
#bandeau-stockage { padding-top: 12px; padding-bottom: 0; }
#bandeau-stockage .btn-row { margin-top: 8px; }
.alert-icon { color: var(--info); padding-top: 1px; }
.alert-body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.alert-scope { display: block; font-size: 0.75rem; font-weight: 650; color: var(--text-2); }
.alert-source { display: block; font-size: 0.75rem; color: var(--text-2); margin-top: 2px; }
.alert-ignorer { border: 0; background: none; padding: 1px 0 0; font-size: 0.8rem; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.alert-ignorer:hover { color: var(--text); text-decoration: underline; }
.afaire-liste { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.afaire-ligne { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 12px; padding: 6px 10px; border-left: 3px solid var(--border-strong); font-size: 0.86rem; cursor: pointer; }
.afaire-ligne:hover { background: var(--surface-2); }
.afaire-ligne .alert-scope { grid-column: 1 / -1; }
.afaire-ligne .alert-scope a { color: inherit; text-decoration: none; }
.afaire-ligne .alert-scope a:hover { text-decoration: underline; }
.afaire-ligne.is-danger { border-left-color: var(--danger); }
.afaire-ligne.is-warning { border-left-color: var(--filet-warning); }
.afaire-ligne.is-info { border-left-color: var(--filet-info); }
/* Rappels partout (points de vigilance du chantier et du lot, Fin de chantier, mois, écarts de la synthèse) : même ligne fine
   que « À faire », un filet de couleur à gauche, sans fond ni pictogramme. Les trois filets reprennent les trois couleurs des
   pastilles de comptage (rouge, jaune, gris), le jaune et le gris en plus clair pour que les trois bandes se distinguent. */
.alerts { gap: 4px; }
.alerts > .alert { align-items: baseline; gap: 2px 12px; padding: 6px 10px; border: 0; border-left: 3px solid var(--border-strong);
  border-radius: 0; background: none; font-size: 0.86rem; }
.alerts > .alert .alert-icon { display: none; }
.alerts > .alert .alert-body p { margin: 0; color: var(--text); font-weight: 400; }
.alerts > .alert-danger { border-left-color: var(--danger); }
.alerts > .alert-warning { border-left-color: var(--filet-warning); }
.alerts > .alert-info { border-left-color: var(--filet-info); }
.alerts-ignores { margin-top: 8px; font-size: 0.84rem; color: var(--text-2); }
.alerts-ignores summary { cursor: pointer; }
.alerts-ignores ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; }
.alerts-ignores li { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.alert-link { font-weight: 600; font-size: 0.84rem; white-space: nowrap; padding-top: 1px; }
.alert-danger { background: var(--danger-soft); border-color: var(--danger-line); }
.alert-danger .alert-icon, .alert-danger .alert-body p { color: var(--danger); }
.alert-danger .alert-body p { font-weight: 600; }
.alert-warning { background: var(--warning-soft); border-color: var(--warning-line); }
.alert-warning .alert-icon { color: var(--warning); }

/* ---------- Fiches (réponses) ---------- */

.fiche { margin: 0; display: flex; flex-direction: column; }
.fiche-row {
  display: grid;
  grid-template-columns: minmax(120px, 40%) minmax(0, 1fr) 32px;
  gap: 4px 12px;
  align-items: start;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.fiche-row:last-child { border-bottom: 0; }
.fiche-row dt { color: var(--text-2); font-size: 0.86rem; padding-top: 1px; }
.fiche-row dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; min-width: 0; }
/* Infos calculées (ex. « RG indicative ») : collées à leur ligne, le trait de séparation passe sous le groupe. */
.fiche-row:has(+ .fiche-row-computed) { border-bottom: 0; padding-bottom: 4px; }
.fiche-row-computed { padding-top: 0; }
.fiche-row-computed dt { font-size: 0.8rem; color: var(--text-3); padding-left: 10px; }
.fiche-row-computed dd { font-size: 0.88rem; font-weight: 400; }
.fiche-note, .preview-note { display: block; margin-top: 4px; color: var(--text-2); font-size: 0.82rem; font-weight: 400; }
.preview-note { margin-top: 6px; }
.duree { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.duree .input-short { max-width: 140px; }
.duree select.input { width: auto; min-width: 140px; }
.fiche-edit {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  color: var(--text-3);
  margin-top: -4px;
}
.fiche-edit:hover { background: var(--primary-soft); color: var(--primary); }
/* Crayons visibles seulement sur la ligne survolée (toujours visibles sur écran tactile et au clavier). */
@media (hover: hover) {
  .fiche-edit { opacity: 0; }
  .fiche-row:hover .fiche-edit, .fiche-edit:focus-visible { opacity: 1; }
}
.fiche-edit .icon { width: 15px; height: 15px; }
.fiche-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
  margin: 20px 0 4px;
}
.fiche-title:first-child { margin-top: 0; }

.plain-list { margin: 0; padding-left: 18px; }
.plain-list li + li { margin-top: 2px; }

/* ---------- Questionnaire ---------- */

.wizard {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
.wizard-main { max-width: 760px; width: 100%; }

.steps {
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  padding: 4px 4px 4px 0;
}
.steps-title { font-weight: 650; font-size: 0.92rem; margin-bottom: 8px; overflow-wrap: anywhere; }
.steps ol { list-style: none; margin: 0; padding: 0; }
.steps-section {
  font-size: 0.72rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  margin: 14px 0 4px;
}
.steps-sep { height: 1px; background: var(--border); margin: 10px 0; }
.step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 0.87rem;
  line-height: 1.3;
}
.step:hover { background: var(--surface-3); text-decoration: none; color: var(--text); }
.step-dot {
  width: 18px; height: 18px;
  display: grid; place-items: center;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--surface);
}
.step-dot .icon { width: 11px; height: 11px; stroke-width: 3; }
.step.is-answered .step-dot { border-color: var(--success); background: var(--success); color: #fff; }
.step.is-skipped .step-dot { border-color: var(--warning); border-style: dashed; }
.step.is-current { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.step.is-current .step-dot { border-color: var(--primary); }
.step.is-current.is-answered .step-dot { background: var(--primary); }
.step-recap .step-dot { border: 0; background: none; color: inherit; }
.step-recap .step-dot .icon { width: 16px; height: 16px; stroke-width: 2; }

.wizard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.progress {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
  margin-bottom: 18px;
}
.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.25s ease;
}

.question-card { padding: 30px 32px 24px; }
.question-title { font-size: 1.55rem; font-weight: 700; margin-bottom: 8px; }
.question-help { color: var(--text-2); margin-bottom: 4px; max-width: 640px; }
.answer { margin-top: 22px; }
.preview:not(:empty) {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--text);
  font-size: 0.92rem;
}
.field-error {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 500;
  font-size: 0.9rem;
}
.wizard-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.spacer { flex: 1; }
.wizard-foot {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  font-size: 0.82rem;
  color: var(--text-3);
}
.recap { margin-top: 18px; }

/* ---------- Champs ---------- */

.input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-field);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input::placeholder { color: var(--text-3); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.45; }
select.input { padding-right: 8px; cursor: pointer; }
.input-lg { height: 52px; font-size: 1.08rem; padding: 0 16px; }
textarea.input-lg { padding: 12px 16px; }
.input-lg-wrap .input { height: 52px; font-size: 1.08rem; padding: 0 16px; }
.input-short { max-width: 200px; }
.input-date { max-width: 260px; }
.input-coef { width: 96px; text-align: right; font-variant-numeric: tabular-nums; }

.input-affix { position: relative; display: flex; align-items: center; }
.input-affix .input { padding-right: 58px; font-variant-numeric: tabular-nums; }
.input-affix .affix {
  position: absolute;
  right: 12px;
  color: var(--text-3);
  font-size: 0.88rem;
  font-weight: 500;
  pointer-events: none;
}
.input-lg-wrap .input-affix { max-width: 340px; }
.input-lg-wrap .input-affix.input-short { max-width: 160px; }
.input-lg-wrap .input-affix.input-short .input { padding-right: 40px; }


/* Choix (cases à cocher / boutons radio présentés en cartes) */
.choices { display: grid; gap: 10px; }
.choices-inline { grid-template-columns: repeat(2, minmax(0, 220px)); }
.choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.12s, background-color 0.12s;
}
.choice:hover { border-color: var(--primary); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice-mark {
  width: 20px; height: 20px;
  flex: none;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  display: grid; place-items: center;
  transition: border-color 0.12s;
}
.choice input[type="checkbox"] ~ .choice-mark { border-radius: 6px; }
.choice-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.choice-label { font-weight: 600; }
.choice-hint { font-size: 0.84rem; color: var(--text-2); }
.choice-key { flex: none; opacity: 0.8; }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.choice input:checked ~ .choice-mark { border-color: var(--primary); }
.choice input[type="radio"]:checked ~ .choice-mark::after {
  content: "";
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--primary);
}
.choice input[type="checkbox"]:checked ~ .choice-mark { background: var(--primary); }
.choice input[type="checkbox"]:checked ~ .choice-mark::after {
  content: "";
  width: 5px; height: 10px;
  margin-top: -2px;
  border: solid var(--on-primary);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.choice:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--primary-ring); }

/* Lignes répétables (options, index) */
.rows { display: flex; flex-direction: column; gap: 8px; }
.row-item { display: grid; gap: 8px; align-items: center; }
.option-row { grid-template-columns: minmax(0, 1fr) 190px 36px; }
.rows-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.rows-total { font-size: 0.9rem; color: var(--text-2); }

/* Tableau du questionnaire (lignes à colonnes, type « tableau ») */
.tableau-tete {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-3);
  margin-bottom: 6px;
}
.tableau-libelle { font-size: 0.9rem; color: var(--text-2); line-height: 1.3; }

/* Formule de révision */
.formule-fixe {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin-bottom: 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.formule-fixe label { font-weight: 600; }
.terme-head, .terme-row { grid-template-columns: 150px minmax(0, 1fr) 96px 36px; }
.terme-head {
  display: grid;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-3);
  margin-bottom: 6px;
}
.terme-head span:nth-child(3) { text-align: right; }
.terme-libelle { font-size: 0.84rem; color: var(--text-2); line-height: 1.3; }
.formule-preview:not(:empty) {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
}
.formule-math {
  font-family: "Cambria Math", "STIX Two Math", Georgia, serif;
  font-size: 1.08rem;
  line-height: 1.7;
  overflow-wrap: anywhere;
}
.fiche .formule-math { font-size: 1rem; margin-bottom: 4px; }
.ratio { white-space: nowrap; }
.sum { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 0.88rem; }
.sum-ok { color: var(--success); }
.sum-ko { color: var(--danger); }

/* ---------- Suivi de chantier ---------- */

.container.is-wide { max-width: 1480px; }
/* Page large : la barre du haut suit le contenu (logo au bord gauche, menu du compte au bord droit). */
body:has(#app.is-wide) .topbar-inner { max-width: 1480px; }

.meter {
  display: block;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.meter > span { display: block; height: 100%; border-radius: inherit; background: var(--primary); }
.meter.is-over > span { background: var(--danger); }

/* Pastilles d'informations (carte d'en-tête de page). */
.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--text);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}
.chip-k { color: var(--text-3); }

.suivi {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

/* Liste des mois */
.mois-nav {
  position: sticky;
  z-index: 8;
  top: calc(var(--topbar-h) + 16px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mois-nav.panel { padding: 12px; }
.mois-nav-title { font-size: 1.1rem; font-weight: 650; color: var(--text); padding: 2px 6px; }
.mois-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: calc(100vh - var(--topbar-h) - 140px);
  overflow-y: auto;
}
.mois-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s;
}
.mois-item:hover { background: var(--surface-3); }
.mois-item.is-active { background: var(--primary-soft); }
.mois-item.is-active .mois-pct, .mois-item.is-active .mois-sub > span:first-child { color: var(--primary); }
.mois-line { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.mois-name { font-weight: 650; }
.mois-item.is-active .mois-name { color: var(--primary); }
.mois-pct { font-size: 0.8rem; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }
.mois-sub { font-size: 0.78rem; color: var(--text-2); }
.mois-state { display: inline-flex; align-items: center; gap: 3px; font-size: 0.74rem; color: var(--text-3); white-space: nowrap; }
.mois-state .icon { width: 12px; height: 12px; }
.mois-add { width: 100%; }
.mois-state.is-valide { color: var(--success); }
.mois-state.is-nonvalide { color: var(--warning); }
.mois-state.is-erreur { color: var(--danger); font-weight: 600; }
.mois-state.is-dgd { color: var(--violet); font-weight: 600; }

/* Contenu du mois : carte du mois (titre, actions, alertes, chiffres), puis les tableaux, chacun dans sa carte. */
.mois-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.panel.mois-card { padding: 0; }
.mois-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 20px;
  padding: 16px 20px;
}
.mois-card-title { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.mois-card-title h2 { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 1.1rem; }
.mois-card-title h2 .badge { font-size: 0.72rem; }
.mois-fleche { width: 28px; height: 28px; padding: 0; justify-content: center; }
/* Sur grand écran, la liste des mois reste à côté : les flèches ne servent que sur écran étroit. */
@media (min-width: 1081px) { .mois-fleche { display: none; } }
.mois-card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-left: auto; }
.icon-btn-sm { width: 32px; padding: 0; justify-content: center; }
.icon-btn-sm svg { width: 18px; height: 18px; }
.mois-card .mois-alerts { display: flex; flex-direction: column; gap: 6px; padding: 0 20px 16px; }
.alerts-more > summary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  padding: 2px 0;
}
.alerts-more > summary::-webkit-details-marker { display: none; }
.alerts-more > summary .icon { width: 14px; height: 14px; transition: transform 0.15s; }
.alerts-more[open] > summary .icon { transform: rotate(90deg); }
.alerts-more > summary:hover { color: var(--text); }
.alerts-more > .alerts { margin-top: 6px; }
.mois-card > .stats { border: 0; border-top: 1px solid var(--border); border-radius: 0 0 var(--radius-lg) var(--radius-lg); background: transparent; }

.stats {
  display: grid;
  grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.stat { display: flex; flex-direction: column; gap: 3px; padding: 12px 16px; min-width: 0; }
.stat + .stat { border-left: 1px solid var(--border); }
.stat-label { font-size: 0.76rem; color: var(--text-2); }
.stat-value { font-size: 1.12rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-sub { font-size: 0.78rem; color: var(--text-3); }
.stat .meter { margin: 3px 0 1px; }

.section-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.section-head h2 { font-size: 1.1rem; }

/* Onglets (bande de boutons, celui ouvert souligné) : page Équipe, tableau de synthèse. */
.onglets { display: flex; gap: 4px; overflow-x: auto; overflow-y: hidden; border-bottom: 1px solid var(--border); scrollbar-width: thin; }
.onglet {
  padding: 10px 16px; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent; background: none;
  color: var(--text-2); font: inherit; font-size: 0.92rem; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.onglet:hover { color: var(--text); }
/* Onglet grisé (compte Solo : fonction de l'offre Pro) */
.onglet:disabled { color: var(--text-3); opacity: 0.55; cursor: not-allowed; }
.onglet:disabled:hover { color: var(--text-3); }
.onglet[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }

/* Menu « Plus… » */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  min-width: 240px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  text-align: left;
  font-size: 0.88rem;
  cursor: pointer;
}
.menu-item:hover { background: var(--surface-3); }
.menu-item:disabled { color: var(--text-3); cursor: not-allowed; }
.menu-item:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.menu-item.is-danger { color: var(--danger); }
/* Précision à côté du libellé d'une entrée du menu « ⋯ » (« Dupliquer (brouillon) ») : petite et discrète. */
.menu-item-note { color: var(--text-2); font-size: 0.85em; }
/* Catégorie du menu « ⋯ » : sa liste s'ouvre au survol, à gauche du menu (le menu est au bord droit du tableau). */
.menu-sous { position: relative; }
.menu-sous-titre { width: 100%; }
.menu-sous-pop { display: none; top: -6px; right: 100%; min-width: 0; width: max-content; max-width: 440px; }
/* Ouverte au survol, ou au clavier (pas après un clic à la souris : elle se fermerait mal en passant sur une autre). */
.menu-sous:hover > .menu-sous-pop, .menu-sous:has(:focus-visible) > .menu-sous-pop { display: flex; }
.menu-sous:hover > .menu-sous-titre, .menu-sous:has(:focus-visible) > .menu-sous-titre { background: var(--surface-3); }
.menu-sous-pop .menu-item { padding: 4px 8px; font-size: 0.78rem; }
.menu-sous-ligne { gap: 8px; }
.menu-sous-ligne strong { min-width: 44px; font-weight: 600; }
.menu-sous-texte { flex: 1; }
.menu-sous-signe {
  display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%;
  background: var(--surface-3); color: var(--text-2); font-weight: 700; line-height: 1;
}
.menu-sous-ligne.is-retire { color: var(--text-3); }
.menu-sous-ligne.is-retire .menu-sous-signe { background: var(--primary-soft, var(--surface-3)); color: var(--primary); }

/* Tableau de révision des prix (reprise du tableau papier) */
.rev-panel { padding-bottom: 14px; }
/* Infos du tableau : grille serrée libellé (petit, gris) au-dessus de la valeur. */
.rev-formule {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 1rem;
}
.rev-scroll { overflow-x: auto; }
.rev {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}
.rev th {
  padding: 6px 5px;
  background: #2b3036;
  color: #fff;
  font-weight: 650;
  font-size: 0.76rem;
  line-height: 1.25;
  text-align: center;
  border: 1px solid #4a5059;
}
.rev td { padding: 3px 6px; border: 1px solid var(--border-strong); white-space: nowrap; height: 34px; }
.rev td.n { text-align: right; }
.rev td.c { text-align: center; }
.rev tbody tr.is-current td { background: var(--primary-soft); }
.rev tfoot td { font-weight: 700; border: 0; border-top: 1px solid var(--border-strong); }
.rev tfoot td:not(:first-child) { border: 1px solid var(--border-strong); }
.rev-empty td { text-align: center; color: var(--text-3); height: 44px; }
.rev tr.rev-m0 td { background: var(--surface-2); }
.rev-m0-note { font-size: 0.78rem; white-space: normal; }
.text-warning { color: var(--warning); font-weight: 500; }
.rev-note { display: block; font-size: 0.72rem; color: var(--text-3); font-weight: 400; white-space: normal; max-width: 140px; margin-left: auto; }
.rev-in {
  height: 28px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  font: inherit;
  color: inherit;
}
.rev-in { width: 62px; padding: 0 5px; text-align: right; }
.rev-in:hover { border-color: var(--border-strong); }
.rev-in:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); background: var(--surface); }
.rev-in.is-missing { border-color: var(--warning-line); background: var(--warning-soft); }
.rev-in::placeholder { color: var(--warning); font-size: 0.78rem; }
.rev-in.is-insee { color: var(--primary); }
/* Index pas encore publié : dernier index connu, affiché normalement (rien n'est écrit dans la case). */
.rev-in.is-prov::placeholder { color: var(--text); opacity: 1; font-size: inherit; }
.rev-in.is-bad { border-color: var(--warning); background: var(--warning-soft); box-shadow: 0 0 0 1px var(--warning); }
.rev-prov { display: block; font-size: 0.7rem; color: var(--warning); font-weight: 500; white-space: nowrap; }
.rev-dgd { display: inline-block; margin-left: 4px; padding: 0 5px; border-radius: 4px; background: var(--violet-soft); color: var(--violet); font-size: 0.68rem; font-weight: 700; vertical-align: 1px; }
.rev-tabs { display: flex; align-items: center; gap: 10px; margin: -4px 0 12px; }
.rev-arrow { width: 34px; padding: 0; justify-content: center; }
.rev-arrow .icon { width: 18px; height: 18px; }
.rev-tab-label { font-size: 0.9rem; color: var(--text-2); }
.rev-tab-label strong { color: var(--text); font-variant-numeric: tabular-nums; }
.rev-all { margin: 10px 0 0; font-size: 0.86rem; color: var(--text-2); }
.rev-all strong { color: var(--text); font-variant-numeric: tabular-nums; }
.rev-insee { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.rev-insee-res { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 0.86rem; color: var(--text-2); }
.rev-insee-res li { display: flex; align-items: flex-start; gap: 6px; }
.rev-insee-res .icon { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.rev-insee-res .is-ok { color: var(--text); }
.rev-insee-res .is-ok .icon { color: var(--success); }
.mois-alerts .alerts { gap: 6px; }

.tool-field { display: inline-flex; align-items: center; gap: 8px; font-size: 0.86rem; color: var(--text-2); }
.tool-field .input { height: 32px; width: auto; padding: 0 8px; }

/* ---------- Tableur ---------- */

.sheet {
  --cell-line: var(--border);
  --cell-box: var(--text-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: clip;
  background: var(--surface);
}
/* Menu « ⋯ » ouvert : rien n'est coupé (ses listes au survol dépassent souvent du bas d'un tableau court). */
.sheet:has(.sheet-bar .menu[open]) { overflow: visible; }
.sheet-bar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.sheet-addr {
  min-width: 64px;
  padding: 0 8px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 0.82rem;
  white-space: nowrap;
}
.sheet-fx { font-style: italic; font-weight: 700; color: var(--text-3); font-family: Georgia, serif; }
.sheet-formula {
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 0.86rem;
}
.sheet-formula:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.sheet-formula[readonly] { color: var(--text-2); background: var(--surface-3); }
.sheet-formula.is-calc { font-family: var(--font); }
.sheet.is-editing { border-color: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }
.sheet.is-editing .sheet-bar { background: var(--warning-soft); }

.sheet-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.tool-group { display: inline-flex; gap: 4px; }
.tool {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  min-width: 30px;
  padding: 0 8px;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  font-size: 0.82rem;
  cursor: pointer;
}
.tool:hover { background: var(--surface-3); }
.tool.is-on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.tool-red { color: var(--danger); font-weight: 700; }
.tool-danger { color: var(--danger); }
.tool-check { display: inline-flex; align-items: center; gap: 6px; font-size: 0.84rem; color: var(--text-2); cursor: pointer; }
.input-name { width: 130px !important; text-transform: uppercase; font-family: var(--mono); font-size: 0.82rem; }

.sheet-scroll { overflow-x: auto; outline: none; }
.sheet-scroll:focus-visible { box-shadow: inset 0 0 0 2px var(--primary-ring); }
.sheet-paper { position: relative; padding: 0; min-width: max-content; }
/* Images posées sur la feuille : logo, signature, cachet, photo (déplaçables et redimensionnables). */
/* « multiply » : le fond blanc d'une signature ou d'un cachet scanné laisse voir la grille et le texte dessous. */
.sheet-img { position: absolute; z-index: 3; border-radius: 3px; outline: none; mix-blend-mode: multiply; }
.sheet-img img { display: block; height: 100%; width: auto; max-width: none; pointer-events: none; user-select: none; }
.sheet-img.is-movable { cursor: move; touch-action: none; }
.sheet-img.is-fixe { pointer-events: none; }
.sheet-img.is-movable:hover, .sheet-img:focus-visible, .sheet-img.is-dragging { box-shadow: 0 0 0 1px var(--primary); }
.sheet-img.is-dragging { opacity: 0.85; z-index: 6; }
.sheet-img-del {
  position: absolute;
  top: -9px;
  right: -9px;
  width: 20px;
  height: 20px;
  display: none;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  cursor: pointer;
}
.sheet-img-del .icon { width: 12px; height: 12px; }
.sheet-img-resize {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 11px;
  height: 11px;
  display: none;
  border: 2px solid var(--surface);
  border-radius: 2px;
  background: var(--primary);
  cursor: nwse-resize;
}
.sheet-img.is-movable:hover .sheet-img-del, .sheet-img:focus .sheet-img-del { display: grid; }
.sheet-img.is-movable:hover .sheet-img-resize, .sheet-img:focus .sheet-img-resize, .sheet-img.is-dragging .sheet-img-resize { display: block; }
:root[data-theme="dark"] .sheet-img { mix-blend-mode: normal; }

/* Cases « RG » devant les lignes de travaux et la révision (colonne A) : assiette de la retenue de garantie. */
.grid td.has-check { padding: 0; text-align: center; }
.cell-check { width: 15px; height: 15px; margin: 0; vertical-align: middle; cursor: pointer; accent-color: var(--primary); }
.grid td > .cell-tip { display: inline-flex; align-items: center; justify-content: center; overflow: visible; pointer-events: auto; position: relative; z-index: auto; line-height: 25px; }
.cell-check-none { font-size: 0.8rem; color: var(--text-3); cursor: help; }
.cell-check-head { font-size: 0.75rem; font-weight: 700; color: var(--text-2); cursor: help; border-bottom: 1px dotted var(--text-3); line-height: 1.2 !important; outline: none; }
/* Bulle d'explication au survol (ou au focus clavier). */
.cell-tip::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 30;
  width: 320px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #1f2933;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.4;
  text-align: left;
  white-space: normal;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s 0.15s;
}
.cell-tip:hover::after, .cell-tip:focus-visible::after, .cell-tip:focus-within::after { opacity: 1; visibility: visible; }
.grid {
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
}
.grid th {
  height: 24px;
  background: var(--surface-3);
  color: var(--text-3);
  font-weight: 600;
  font-size: 0.74rem;
  border: 1px solid var(--cell-line);
  user-select: none;
}
.grid tbody th { position: sticky; left: 0; z-index: 4; cursor: pointer; }
/* Rôles (mode modification) : signalés discrètement, sans couleur nouvelle. */
.grid thead th.has-role { color: var(--text-2); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.grid th .role-tag { font-weight: 500; color: var(--text-3); }
.grid tbody th.has-role { box-shadow: inset -2px 0 0 var(--text-3); }
.grid td.has-role::before { content: ''; position: absolute; top: 2px; right: 2px; width: 5px; height: 5px; border-radius: 50%; background: var(--text-3); z-index: 2; }
.import-rapport { margin: 0 0 10px; font-size: 0.86rem; }
/* Modèle du lot modifié depuis : proposition discrète au-dessus du bordereau du dernier mois. */
.maj-modele { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; font-size: 0.9rem; color: var(--text-2); }
.maj-modele > svg { width: 16px; height: 16px; color: var(--text-3); flex: none; }
.import-rapport summary { cursor: pointer; }
.import-rapport ul { margin: 6px 0 0; padding-left: 18px; max-height: 180px; overflow: auto; }
.import-rapport .tool-field { margin-left: 8px; }
.grid td {
  height: 26px;
  padding: 0 6px;
  border: 1px solid var(--cell-line);
  white-space: nowrap;
  overflow: visible;
  cursor: cell;
  position: relative;
}
/* Le texte peut déborder sur les cases vides voisines sans bloquer le clic sur celles-ci. */
.grid td > span { display: block; line-height: 25px; overflow: hidden; text-overflow: ellipsis; position: relative; z-index: 1; pointer-events: none; }
.grid td.al-r { text-align: right; }
.grid td.al-c { text-align: center; }
.grid td.b { font-weight: 700; }
.grid td.i { font-style: italic; }
/* Mise en forme reprise d'un fichier Excel (souligné, retour à la ligne, fond, couleur, cadre côté par côté). */
.grid td.u > span { text-decoration: underline; }
.grid td.wrap > span { white-space: pre-line; line-height: 1.25; overflow: hidden; }
/* Alignement vertical d'Excel (ligne plus haute, fusion sur plusieurs lignes) : en haut ou en bas de la case. */
.grid td.va-t { vertical-align: top; }
.grid td.va-b { vertical-align: bottom; }
.grid td.has-bg { background: var(--bg); color: #16202c; }
/* Feuille aux lignes plus basses (sheet.ligne, ex. tableau de synthèse copié d'un fichier Excel) : texte plus petit. */
.sheet.is-serre .grid { font-size: 0.74rem; }
.sheet.is-serre .grid td { height: var(--ligne); padding: 0 4px; }
.sheet.is-serre .grid td > span { line-height: calc(var(--ligne) - 1px); }
.sheet.is-serre .grid tbody th { height: var(--ligne); font-size: 0.68rem; }
/* Tableau de synthèse : police du fichier Excel d'origine (Aptos / Calibri, sinon leurs équivalents). */
.synthese .grid { font-family: Aptos, Calibri, Carlito, "Liberation Sans", Arial, sans-serif; }
/* Tableau de synthèse un peu agrandi (lignes et colonnes × 1,15, voir js/synthese.js) : texte à la même échelle. */
.synthese .sheet.is-serre .grid { font-size: 0.84rem; }
.synthese .sheet.is-serre .grid tbody th { font-size: 0.74rem; }
/* Date du tableau dans le titre : un bouton discret en pastille (choisir le jour). */
.synthese-date {
  display: inline-flex; align-items: center; gap: 6px; margin-left: 2px; padding: 2px 10px 2px 8px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2);
  font: inherit; color: inherit; cursor: pointer; vertical-align: baseline;
}
.synthese-date:hover { background: var(--surface-3); border-color: var(--border-strong); }
.synthese-date .icon { width: 16px; height: 16px; color: var(--text-3); }
.is-expanded .synthese-date { font-size: 1rem; }
/* Cases venues des lots modifiées à la main : messages au-dessus du tableau (cases en rouge dans la grille). */
.synthese-alertes { margin: 0 0 10px; }
/* Page du tableau de synthèse : toute la largeur de l'écran, marges réduites, liste des mois plus étroite. */
.container.is-pleine { max-width: none; padding-left: 12px; padding-right: 12px; }
body:has(#app.is-pleine) .topbar-inner { max-width: none; }
@media (min-width: 1081px) { .suivi.synthese { grid-template-columns: 170px minmax(0, 1fr); gap: 12px; } }
.synthese .panel.bordereau:not(.is-expanded) { padding: 12px 12px 14px; }
.synthese .bordereau > .section-head { padding-right: 90px; min-height: 34px; }
/* En-tête de la page (comme les autres pages) : retour, « Tableau de synthèse » et le chantier, Informations et Exporter. */
/* En-tête plus bas que celui des autres pages (le tableau garde la hauteur de l'écran) : titre et chantier sur une ligne. */
.synthese-haut .page-card { margin-bottom: 10px; }
.synthese-haut .page-card-top { padding: 11px 16px; gap: 8px 14px; }
.synthese-haut .page-card-main { flex-direction: row; align-items: baseline; gap: 12px; }
.synthese-haut .page-card-main h1 { font-size: 1.2rem; }
.synthese-haut .back-btn { width: 34px; height: 34px; }
.synthese-haut .back-btn .icon { width: 17px; height: 17px; }
/* Onglets du classeur seuls sur leur ligne (« Récap opération », « État 2 »). */
.synthese-bande { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.synthese-bande .onglets { flex: 1; min-width: 0; }
/* Au-dessus du tableau : « Synthèse du » et sa date à gauche, « Modifier les informations » au bout, en gris. */
.synthese-tete { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 6px 14px; }
.synthese-tete h2 { font-size: 1rem; }
.synthese-tete [data-informations] { color: var(--text-2); }
/* « Pour ajouter une ligne ou autre → » : repère en gris clair, collé au bouton qu'il montre. */
/* Tableau agrandi : onglets à gauche du titre, sans trait dessous (l'en-tête en a déjà un). */
.is-expanded .synthese-onglets { flex: none; border-bottom: 0; }
.is-expanded .synthese-onglets .onglet { padding: 8px 12px; }
.synthese .bordereau:not(.is-expanded) > .expand-tools { top: 12px; right: 12px; }
/* Menu « ⋯ » du mois : au-dessus de la barre de formule du tableau (z-index 6), qui est juste dessous. */
.synthese .bordereau > .expand-tools { z-index: 9; }
.grid td.has-fg { color: var(--fg); }
.grid td.bd {
  box-shadow: inset 0 var(--bt, 0) 0 var(--text), inset calc(-1 * var(--br, 0px)) 0 0 var(--text),
    inset 0 calc(-1 * var(--bb, 0px)) 0 var(--text), inset var(--bl, 0px) 0 0 var(--text);
}
.grid td.red { color: var(--danger); }
/* Mots ajoutés au libellé à l'affichage : « provisoire entreprise » (rouge), « finale DGD ». */
.grid .cell-suffix { font-style: inherit; }
.grid .cell-suffix.is-red { color: var(--danger); }
/* Case vide à remplir (ex. « budget max » d'un sous-traitant) : texte d'attente grisé, non imprimé. */
.grid .cell-attente { color: var(--text-3); font-weight: 400; font-size: 0.92em; }
.grid td.box { box-shadow: inset 0 0 0 1px var(--cell-box); }
.grid td.is-err { color: var(--danger); font-weight: 600; }
.grid td.has-action > span { padding-right: 22px; }
.cell-action {
  position: absolute;
  top: 4px;
  right: 8px;
  z-index: 3;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.cell-action:hover { filter: brightness(1.1); }
/* Bouton discret (« − » / « + » de la légende du Suivi exe) : gris. */
.cell-action.is-discret { background: var(--border-strong); color: var(--text-2); }
.cell-action.is-discret:hover { filter: brightness(0.92); }
/* « + » posé sur un libellé (modèle importé) : juste après le texte, qui n'est jamais recouvert. */
.grid td.has-action-inline > span { display: flex; align-items: center; overflow: visible; }
.grid td.has-action-inline.al-c > span { justify-content: center; }
.grid td.has-action-inline.al-r > span { justify-content: flex-end; }
.grid td.has-action-inline .cell-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.cell-action.is-inline { position: relative; top: auto; right: auto; flex: none; margin-left: 6px; pointer-events: auto; }
/* Boutons de ligne en colonne A : « + » ajouter un sous-traitant, « × » retirer une ligne vide. */
.grid td.has-row-btn { padding: 0; text-align: center; }
.row-btn {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
  cursor: pointer;
}
.row-btn[data-action="st-del"] { background: transparent; color: var(--text-3); font-size: 16px; }
.row-btn[data-action="st-del"]:hover { background: var(--danger-soft); color: var(--danger); }
.row-btn[data-action="st-add"]:hover { filter: brightness(1.1); }
/* Valeur impossible (rouge) ou douteuse (orange) : la case à corriger, signalée aussi en haut du mois. */
.grid td.mark-danger { background: var(--danger-soft); color: var(--danger); font-weight: 700; box-shadow: inset 0 0 0 2px var(--danger); }
.grid td.mark-warning { background: var(--warning-soft); box-shadow: inset 0 0 0 2px var(--warning-line); }
/* Valeur tapée à la place d'un calcul : le nombre s'affiche en rouge (et le triangle bleu indique la formule d'origine). */
.grid td.is-override { color: var(--danger); }
/* Mois validé : plus de rouge, le coin bleu reste (la valeur tapée reste repérable). */
.grid td.is-override.is-valide { color: inherit; }
.grid td.is-override::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  border: 4px solid transparent;
  border-top-color: var(--primary);
  border-left-color: var(--primary);
}
.sheet.is-editing .grid td.is-formula::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  border: 4px solid transparent;
  border-top-color: var(--warning);
  border-right-color: var(--warning);
}
.grid td.is-sel { outline: 2px solid var(--primary); outline-offset: -2px; z-index: 2; }
.sheet-hint { padding: 8px 12px; font-size: 0.85rem; color: var(--text-2); border-top: 1px solid var(--border); margin: 0; }
/* Touches du clavier dans la consigne sous les tableaux de la synthèse (js/synthese-view-tableur.js, CONSIGNE : Tab, Ctrl
   + Entrée) : dessinées comme des touches, un peu plus grandes, pour qu'on les repère sur son clavier ; la place de Tab n'est
   dite qu'au survol. */
.sheet-hint kbd {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border: 1px solid var(--border-strong);
  border-bottom-width: 2px; border-radius: 5px; background: var(--surface); color: var(--text); font: inherit;
  font-size: 0.95em; font-weight: 650; white-space: nowrap;
}
.sheet-hint kbd .icon { width: 0.95em; height: 0.95em; }
/* « Ctrl + Entrée » cliquable (valide toutes les suggestions) : à peine marqué, les touches foncent un peu au survol. */
.sheet-hint-touches { padding: 0; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; border-radius: 6px; }
.sheet-hint-touches:hover kbd { border-color: var(--primary); color: var(--primary); }
.sheet-hint-touches:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Formulaires des boîtes de dialogue */
.dialog.dialog-wide { max-width: 720px; }
.dialog-body { display: flex; flex-direction: column; gap: 12px; }
.dialog .dialog-body p { color: var(--text-2); }
.form-field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.9rem; border: 0; padding: 0; margin: 0; }
.form-field legend { margin-bottom: 6px; }
.radio { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 0.9rem; flex-wrap: wrap; }
.radio .input { height: 34px; width: auto; }
/* Fenêtre « Équipe du chantier » (js/partage.js) : un tableau à trois colonnes (personne, rôle, fin de l'accès), en-tête collant,
   noms et adresses rabotés au besoin. Même langage que les tableaux de l'appli, en plus dense (champs de 32 px). */
.partage-liste {
  max-height: min(56vh, 440px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.partage-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 0.92rem; }
.partage-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 9px 14px;
  text-align: left;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-3);
  white-space: nowrap;
  background: var(--surface-2);
  box-shadow: inset 0 -1px 0 var(--border);
}
.partage-table th + th, .partage-table td + td { border-left: 1px solid var(--border); }
.partage-table th:nth-child(2), .partage-table td:nth-child(2) { width: 172px; }
.partage-table th:nth-child(3), .partage-table td:nth-child(3) { width: 190px; }
.partage-facultatif { text-transform: none; letter-spacing: 0; font-weight: 400; }
.partage-ligne td { padding: 7px 14px; border-top: 1px solid var(--border); vertical-align: middle; }
.partage-table tbody tr:first-child td { border-top: 0; }
.partage-ligne:not(.is-direction):hover td { background: var(--surface-2); }
.partage-nom { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.partage-nom strong, .partage-nom small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.partage-nom strong { font-weight: 600; }
.partage-nom small { font-size: 0.78rem; }
.partage-direction { font-weight: 600; }
.partage-sans { color: var(--text-3); font-size: 0.95rem; line-height: 1; }
.partage-ligne .input { height: 32px; padding: 0 8px; font-size: 0.9rem; }
.partage-role .input, .partage-fin .input { width: 100%; }
.partage-fin .input:disabled { opacity: 0.45; background: var(--surface-2); cursor: not-allowed; }
/* Écran étroit : une fiche par personne, chaque champ sous son libellé. */
@media (max-width: 640px) {
  .partage-liste { max-height: min(60vh, 480px); }
  .partage-table, .partage-table tbody, .partage-table tr, .partage-table td { display: block; width: auto; }
  .partage-table thead { display: none; }
  .partage-table tbody tr { padding: 10px 12px; border-top: 1px solid var(--border); }
  .partage-table tbody tr:first-child { border-top: 0; }
  .partage-table td { padding: 0; border: 0; }
  .partage-table th:nth-child(2), .partage-table td:nth-child(2),
  .partage-table th:nth-child(3), .partage-table td:nth-child(3) { width: auto; }
  .partage-table td + td { border-left: 0; margin-top: 8px; }
  .partage-nom { padding-bottom: 8px; }
  .partage-ligne:not(.is-direction):hover td { background: none; }
  .partage-table td.partage-role, .partage-table td.partage-fin { display: flex; align-items: center; gap: 10px; }
  .partage-table td.partage-role::before, .partage-table td.partage-fin::before {
    content: "Rôle";
    flex: none;
    width: 92px;
    font-size: 0.76rem;
    color: var(--text-3);
  }
  .partage-table td.partage-fin::before { content: "Fin de l'accès"; }
  .partage-table td.partage-role .input, .partage-table td.partage-fin .input { width: auto; flex: 1; min-width: 0; }
}
code { font-family: var(--mono); font-size: 0.85em; padding: 1px 4px; border-radius: 4px; background: var(--surface-3); }

/* ---------- Boîte de dialogue & notifications ---------- */

.dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 440px;
  width: calc(100% - 32px);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgba(10, 16, 24, 0.45); }
.dialog h2 { font-size: 1.15rem; margin-bottom: 8px; }
.dialog p { color: var(--text-2); }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 22px; }
/* Deux réponses possibles (ex. garder la révision provisoire entreprise / passer en révision finale DGD). */
.dialog-actions.is-choice { flex-direction: column; align-items: stretch; }
.dialog-actions.is-choice .btn { white-space: normal; text-align: center; }

.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 50;
  pointer-events: none;
  width: calc(100% - 32px);
}
.toast {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: #16202c;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s ease;
  transition: opacity 0.3s, transform 0.3s;
  max-width: 520px;
}
.toast-danger { background: #b42318; }
.toast.is-leaving { opacity: 0; transform: translateY(6px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
/* Bulle posée sous une case (SC.ui.bulle) : « Remplacer le calcul ». */
.bulle {
  position: absolute;
  z-index: 60;
  max-width: 320px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.86rem;
}
.bulle p { margin: 0 0 8px; }
.bulle-boutons { display: flex; justify-content: flex-end; gap: 6px; }

/* ---------- Adaptation écrans ---------- */

@media (max-width: 1080px) {
  .suivi { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .mois-add { width: auto; align-self: flex-start; }
  .mois-nav { position: static; gap: 8px; }
  .mois-list { flex-direction: row; overflow-x: auto; max-height: none; padding-bottom: 4px; }
  .mois-list li { flex: none; }
  .mois-item { width: auto; min-width: 136px; border-color: var(--border); }
  .fiche-grid { grid-template-columns: minmax(0, 1fr); }
  .wizard { grid-template-columns: minmax(0, 1fr); }
  .steps { display: none; }
  .wizard-main { margin: 0 auto; }
}

@media (max-width: 860px) {
  .stats, .stats.page-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(odd) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--border); }

  /* Tableau des lots → cartes empilées */
  .table-wrap { margin: 0; overflow: visible; }
  .table thead, .table tfoot tr td:empty { display: none; }
  .panel-lots.a-tableau { padding-top: 12px; }
  .panel-lots .table thead { display: block; }
  .panel-lots .table thead th:not(.th-nouveau), .th-nouveau span { display: none; }
  .panel-lots .table thead tr { margin-bottom: 10px; }
  .panel-lots .table .th-nouveau { display: block; padding: 0; background: none; border: 0; }
  .th-nouveau > div { justify-content: flex-end; }
  .table .lot-actions { width: 100%; padding-left: 14px; justify-content: flex-end; }
  .table, .table tbody, .table tfoot, .table tr, .table td { display: block; width: 100%; }
  .table tbody tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    padding: 6px 0;
  }
  .table td, .table th:first-child, .table td:first-child, .table td:last-child {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 6px 14px;
    border: 0;
    text-align: right;
  }
  .table td::before {
    content: attr(data-label);
    font-size: 0.78rem;
    color: var(--text-3);
    text-align: left;
    flex: none;
  }
  .table td:first-child { display: block; text-align: left; padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
  .table td:first-child::before { display: none; }
  .table .num { flex-wrap: wrap; white-space: normal; }
  .table .num .row-sub { flex-basis: 100%; text-align: right; }
  .table tfoot tr { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
  .table tfoot td:first-child { border-bottom: 0; margin-bottom: 0; padding-top: 10px; }
  .table tfoot td.num { justify-content: flex-end; }
  .table tfoot td.num::before { content: none; }
}

@media (max-width: 640px) {
  .alert { flex-wrap: wrap; }
  .alert-body { flex-basis: calc(100% - 30px); }
  .alert-link { margin-left: 28px; }
  .alerts > .alert .alert-body { flex-basis: 100%; }
  .alerts > .alert .alert-link { margin-left: 0; }
}

@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .topbar-inner, .container { padding-left: 16px; padding-right: 16px; }
  .container { padding-top: 16px; }
  h1 { font-size: 1.45rem; }
  .grid-cards { grid-template-columns: minmax(0, 1fr); }
  .panel { padding: 16px; }
  .question-card { padding: 22px 18px 18px; }
  .question-title { font-size: 1.3rem; }
  .choices-inline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .choice-key { display: none; }
  .wizard-actions .btn-primary { flex: 1 1 auto; }
  .wizard-foot span:last-child { display: none; }
  .option-row { grid-template-columns: minmax(0, 1fr) 36px; }
  .option-row .input-affix { grid-column: 1; }
  .option-row .icon-btn { grid-row: 1 / span 2; grid-column: 2; }
  .terme-head { display: none; }
  .terme-row { grid-template-columns: minmax(0, 1fr) 96px 36px; }
  .terme-libelle { grid-column: 1 / -1; grid-row: 2; margin-top: -4px; }
  .fiche-row { grid-template-columns: minmax(0, 1fr) 32px; }
  .fiche-row dt { grid-column: 1; }
  .fiche-row dd { grid-column: 1; }
  .fiche-row .fiche-edit { grid-column: 2; grid-row: 1 / span 2; }
  .fiche-row-computed dt { padding-left: 0; }
  .mini-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- Impression ---------- */

@media print {
  :root { color-scheme: light; }
  body { background: #fff; font-size: 12px; }
  .topbar, .no-print, .toasts, .steps, .sheet-bar, .sheet-tools, .sheet-hint { display: none !important; }
  body:has(#impression-lots) > :not(#impression-lots) { display: none !important; }
  #impression-lots { display: block; }
  .sheet-scroll { overflow: visible; }
  .grid th { display: none; }
  .grid td.is-sel { outline: none; }
  .rev-in { border: 0 !important; background: none !important; appearance: none; }
  .sheet-img { box-shadow: none !important; }
  .sheet-img-del, .sheet-img-resize, .cell-check, .cell-check-none, .cell-check-head, .row-btn, .cell-action, .cell-attente { display: none !important; }
  .grid td.mark-danger, .grid td.mark-warning { background: none !important; box-shadow: none !important; color: inherit !important; }
  .suivi { display: block; }
  .rev th { background: #ddd; color: #000; }
  .sheet-paper { min-width: 0; }
  .container { padding: 0; max-width: none; }
  .card, .panel { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .fiche-grid { grid-template-columns: 1fr; }
  .table tbody tr { cursor: default; }
  a { color: inherit; }
}

/* ---------- Détail des montants & avenants ---------- */

.montant-detail { display: inline-block; position: relative; }
.montant-detail > summary { list-style: none; }
.montant-detail > summary::-webkit-details-marker { display: none; }
.montant-sum {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  border-bottom: 1px dashed var(--border-strong);
  font-variant-numeric: tabular-nums;
}
.montant-sum:hover { color: var(--primary); border-bottom-color: var(--primary); }
.montant-sum .chev { width: 0.85em; height: 0.85em; color: var(--text-3); transition: transform 0.15s; }
.montant-detail[open] .chev { transform: rotate(180deg); }
/* Fixe (placé par ui.js) : le tableau des lots défile, il couperait un menu absolu. */
.detail-pop { position: fixed; top: 0; left: 0; right: auto; min-width: 300px; max-width: min(460px, calc(100vw - 32px)); padding: 10px 12px; font-size: 0.86rem; font-weight: 400; letter-spacing: 0; }
.detail-table { width: 100%; border-collapse: collapse; }
.detail-table td { padding: 5px 4px; border-bottom: 1px solid var(--border); text-align: left; white-space: normal; color: var(--text); }
.detail-table td.n { text-align: right; white-space: nowrap; padding-left: 16px; font-variant-numeric: tabular-nums; }
.detail-table tfoot td { font-weight: 700; border-bottom: 0; border-top: 2px solid var(--border-strong); }
.stat-value .montant-detail { font: inherit; }

.dialog-full {
  max-width: none;
  width: calc(100vw - 48px);
  height: calc(100vh - 48px);
  max-height: none;
}
.dialog-full form { height: 100%; display: flex; flex-direction: column; }
.dialog-full .dialog-body { flex: 1; min-height: 0; }
.av-scroll { overflow: auto; flex: 1; min-height: 120px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.av-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.av-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 10px;
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.av-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.av-table .n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.av-table .input { height: 36px; }
.av-table td:nth-child(2) { width: 36%; }
.av-type { min-width: 170px; }
.av-table [data-f="moisId"] { min-width: 170px; }
.av-table [data-f="description"] { min-width: 180px; }
.av-type-hint { display: block; margin-top: 3px; font-size: 0.74rem; color: var(--text-3); }
.av-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.av-add-menu .menu-pop { left: 0; right: auto; top: auto; bottom: calc(100% + 4px); }
.av-bis-hint { color: var(--primary); font-weight: 600; }
.av-table tr.av-bis td:first-child { padding-left: 26px; }
.av-table tr.is-dim { opacity: 0.45; }
.av-pick {
  padding: 4px 10px;
  border: 2px solid var(--primary);
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary);
  font: inherit;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  animation: av-pick 1.2s ease-in-out 4 alternate;
}
.av-pick:hover, .av-pick:focus-visible { background: var(--primary); color: var(--on-primary); outline: none; }
@keyframes av-pick { to { box-shadow: 0 0 0 4px var(--primary-ring); } }
@media (prefers-reduced-motion: reduce) { .av-pick { animation: none; } }

/* Fenêtre « Exporter » : un bouton par format. */
.av-montant { text-align: right; max-width: 150px; }
.av-rg { white-space: nowrap; }
.av-rg-input { display: inline-flex; align-items: center; gap: 4px; }
.av-rg-input .input { width: 4.5em; text-align: right; }
.av-empty { text-align: center; padding: 24px !important; }
.nowrap { white-space: nowrap; }
.av-resume { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px 28px; font-size: 0.9rem; }
.av-resume > div { display: flex; flex-direction: column; align-items: flex-end; }
.av-resume span { font-size: 0.78rem; color: var(--text-2); }
.av-resume strong { font-variant-numeric: tabular-nums; }
.av-total strong { font-size: 1.15rem; color: var(--primary); }

@media (max-width: 640px) {
  .dialog-full { width: calc(100vw - 16px); height: calc(100vh - 16px); padding: 16px; }
  .av-table { min-width: 720px; }
}

.cell-count {
  position: absolute;
  top: -7px;
  right: -9px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1.5px solid var(--surface);
  background: var(--warning);
  color: #1b1300;
  font-size: 9.5px;
  font-weight: 800;
  line-height: 1;
}

/* ---------- Proposition d'actualisation des mois suivants ---------- */

.mois-nav-head { display: flex; align-items: center; gap: 8px; padding-right: 4px; }
.report-dot {
  width: 10px;
  height: 10px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 0 var(--warning-line);
  animation: report-pulse 1.8s ease-out 4;
  cursor: pointer;
  transition: opacity 0.25s;
}
.report-dot.is-ghost { animation: none; opacity: 0.25; }
.mois-nav-head:hover .report-dot.is-ghost { opacity: 0.8; }
@keyframes report-pulse {
  0% { box-shadow: 0 0 0 0 var(--warning-line); }
  70%, 100% { box-shadow: 0 0 0 7px transparent; }
}
.report {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--warning-line);
  border-radius: var(--radius-sm);
  background: var(--warning-soft);
  font-size: 0.84rem;
  transition: opacity 0.3s;
}
.report-title { display: flex; align-items: center; gap: 8px; font-weight: 650; color: var(--warning); padding-right: 22px; }
.report-pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); flex: none; animation: report-pulse 1.8s ease-out 4; }
.report-hide {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text-2);
  cursor: pointer;
}
.report-hide:hover { background: var(--surface-3); color: var(--text); }
.report-hide .icon { width: 14px; height: 14px; }
.report-go { padding: 0 10px; white-space: nowrap; }
/* Alerte masquée : presque invisible, elle revient un peu quand la souris s'en approche. */
.report.is-hidden {
  opacity: 0.12;
  padding: 4px 10px;
  border-style: dashed;
  background: transparent;
  outline: 14px solid transparent;
}
.report.is-hidden:hover, .report.is-hidden:focus-within, .mois-nav-head:hover + .report.is-hidden { opacity: 0.75; }
.report-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--warning);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.report-ghost .icon { width: 14px; height: 14px; }
.report-list { margin: 0; padding-left: 16px; display: flex; flex-direction: column; gap: 6px; }
.report-list ul { margin: 2px 0 0; padding-left: 14px; color: var(--text-2); }
.report-voir { align-self: center; font-size: 0.84rem; font-weight: 650; text-decoration: underline; color: var(--text); }

/* ---------- Avancement réel (dernier mois du suivi) ---------- */

.av-cell { min-width: 140px; }
.av-bar { display: flex; flex-direction: column; gap: 4px; min-width: 120px; color: inherit; }
a.av-bar:hover { text-decoration: none; }
a.av-bar:hover strong { color: var(--primary); }
.av-bar-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 0.84rem; font-variant-numeric: tabular-nums; }
.av-bar-top .muted { font-size: 0.75rem; }
.kpi-meter { margin-top: 8px; }
@media (max-width: 860px) {
  .av-cell .av-bar { width: 150px; }
}

/* Tableau agrandi (bouton en haut à droite des tableaux du suivi) */
.rev-panel, .bordereau { position: relative; }
.expand-tools { position: absolute; top: 12px; right: 12px; z-index: 5; display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; }
.expand-btn { width: 34px; padding: 0; justify-content: center; }
.expand-btn svg { width: 18px; height: 18px; }
.export-menu .menu-pop { min-width: 450px; padding: 6px; gap: 2px; }
.exe-menu .menu-pop { min-width: 340px; }
.legende-menu .menu-pop { min-width: 420px; }
.mois-card-actions .menu-item { white-space: nowrap; }
/* Le bouton « Exporter » : la flèche annonce un menu déroulant, elle se retourne à l'ouverture. */
.export-menu > summary .icon:last-child { width: 1em; height: 1em; margin-left: 2px; opacity: 0.7; transition: transform 0.15s; }
.export-menu[open] > summary .icon:last-child { transform: rotate(180deg); }
.export-menu[open] > summary.btn-secondary { background: var(--surface-3); }
.menu-ligne { display: flex; align-items: center; gap: 7px; padding: 8px 9px; border-radius: 8px; font-size: 0.86rem; }
.menu-ligne:hover { background: var(--surface-2); }
.menu-ligne-titre { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; font-weight: 500; white-space: nowrap; }
.menu-ligne-titre .icon { width: 18px; height: 18px; color: var(--text-3); }
.menu-format {
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  font: inherit; font-size: 0.8rem; font-weight: 600; color: var(--text); cursor: pointer;
}
.menu-format .icon, .menu-item.fmt-xlsx .icon, .menu-item.fmt-csv .icon, .menu-item.fmt-pdf .icon { width: 15px; height: 15px; }
.menu-format:hover { background: var(--surface-3); border-color: var(--border-strong); }
.fmt-xlsx .icon { color: var(--success); }
.fmt-csv .icon { color: var(--primary); }
.fmt-pdf .icon { color: var(--danger); }
.btn-primary .icon:last-child { opacity: 0.8; }
.export-menu > summary.btn-primary .icon:last-child { margin-left: 2px; }
.menu-imprimer { margin-top: 4px; padding: 10px 9px; border-top: 1px solid var(--border); border-radius: 0 0 6px 6px; font-size: 0.86rem; }
.menu-imprimer .icon { width: 18px; height: 18px; color: var(--text-3); margin-right: 4px; }
.menu-head { padding: 6px 10px 4px; font-size: 0.74rem; font-weight: 600; color: var(--text-3); }
.rev-panel > .section-head, .bordereau > .section-head { padding-right: 48px; }
.is-expanded {
  --expand-head: 56px;
  position: fixed;
  inset: 12px;
  z-index: 40;
  overflow: auto;
  margin: 0;
  padding: 0 20px 20px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 0 0 100vmax rgba(10, 16, 24, 0.55), 0 20px 60px rgba(0, 0, 0, 0.35);
}
/* En-tête collé en haut du tableau agrandi ; la barre de formule du bordereau se colle juste dessous. */
.is-expanded > .expand-tools {
  position: sticky;
  top: 0;
  right: auto;
  z-index: 8;
  flex-wrap: nowrap;
  height: var(--expand-head);
  margin: 0 -20px 12px;
  padding: 0 12px 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.expand-title { margin-right: auto; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.is-expanded > .section-head { padding-right: 0; }
.is-expanded > .section-head h2 { display: none; }
.is-expanded .sheet-bar { top: var(--expand-head); }
body:has(.is-expanded) { overflow: hidden; }
@media (max-width: 640px) {
  .is-expanded { inset: 0; border-radius: 0; padding: 0 12px 14px; }
  .is-expanded > .expand-tools { position: static; flex-wrap: wrap; height: auto; padding: 10px 12px; margin: 0 -12px 12px; }
  .is-expanded .sheet-bar { top: 0; }
}

/* ---------- Animation d'accueil (js/intro.js) ---------- */
/* Couche plein écran au-dessus de la page : curseurs, cadres en pointillés, poignées. */

.intro-layer { position: fixed; inset: 0; z-index: 1000; pointer-events: none; overflow: hidden; }
.intro-frame {
  position: absolute;
  box-sizing: border-box;
  border: 1.5px dashed var(--ic);
  border-radius: var(--ir);
  opacity: 0;
}
.intro-handle {
  position: absolute;
  width: 8px; height: 8px;
  box-sizing: border-box;
  background: #fff;
  border: 1.5px solid var(--ic);
  border-radius: 2px;
}
.intro-handle.nw { left: -5.5px; top: -5.5px; }
.intro-handle.ne { right: -5.5px; top: -5.5px; }
.intro-handle.se { right: -5.5px; bottom: -5.5px; }
.intro-handle.sw { left: -5.5px; bottom: -5.5px; }
.intro-size, .intro-name {
  background: var(--ic);
  color: #fff;
  font: 600 11px/1 var(--font);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.intro-size { position: absolute; right: 0; top: calc(100% + 10px); padding: 4px 7px; border-radius: 6px; }
.intro-cursor { position: absolute; left: 0; top: 0; opacity: 0; will-change: transform; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.28)); }
.intro-cursor svg { display: block; margin: -1.5px 0 0 -2px; }
.intro-name { position: absolute; left: 14px; top: 17px; padding: 4px 8px; border-radius: 999px; }
.intro-cursor.is-flip .intro-name { left: auto; right: 6px; }
@media print { .intro-layer { display: none; } }

/* Mouvement réduit : pas d'animation ni de transition pour qui le demande (système). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* Environnement hors production (js/environnement.js) : rappel permanent, sans gêner la lecture. */
.env-badge {
  position: fixed; left: 12px; bottom: 12px; z-index: 1000; pointer-events: none;
  padding: 4px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em;
  background: var(--warning-soft); color: var(--warning); border: 1px solid var(--warning-line);
}
.env-badge.env-local { background: var(--info-soft); color: var(--info); border-color: var(--border-strong); }
@media print { .env-badge { display: none; } }

/* Écran de connexion sans mail : explication sous le formulaire. */
.auth-aide { margin: 16px 0 0; text-align: center; max-width: 42ch; margin-inline: auto; }

/* Factures jointes à un mois (trombone du mois, fenêtre « Joindre une facture »). */
.pj-btn { position: relative; }
.pj-btn.has-pj { color: var(--primary); }
.pj-count {
  position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--primary); color: var(--on-primary); font-size: 0.68rem; font-weight: 700; line-height: 16px; text-align: center;
}
.pj-zone {
  display: grid; place-items: center; min-height: 120px; border: 2px dashed var(--border-strong); border-radius: 12px;
  color: var(--text-3); cursor: pointer; transition: border-color 0.12s, background-color 0.12s, color 0.12s;
}
.pj-zone .icon { width: 32px; height: 32px; }
.pj-zone:hover, .pj-zone.is-over { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.pj-zone:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--primary-ring); }
.pj-liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.pj-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.pj-item > .icon { width: 20px; height: 20px; flex: none; color: var(--text-3); }
.pj-nom { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
/* Export Chorus Pro : contenu choisi avec la roue dentée. */
.menu-reglage { padding: 7px 9px; }
.menu-chorus-choix { display: flex; flex-direction: column; gap: 6px; margin: 0 10px 8px 42px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.menu-chorus-choix[hidden] { display: none; }
.menu-chorus-case { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; cursor: pointer; white-space: nowrap; }
.menu-chorus-case input { accent-color: var(--primary); width: 16px; height: 16px; margin: 0; }
.menu-chorus-case.is-off { opacity: 0.55; cursor: default; }

/* ——— Mes modèles (js/modeles.js) ——— */
.modeles-liste { list-style: none; margin: 0; padding: 0; }
.modeles-item { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--border); }
.modeles-item:last-child { border-bottom: 0; }
.modeles-item > svg { width: 18px; height: 18px; color: var(--text-3); flex: none; }
.modeles-menu .menu-pop { min-width: 190px; }
.modeles-nom { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modeles-item .badge-partage { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Mentions (« Modèle de base », « Partagé avec l'équipe »…) centrées dans une même colonne, dates alignées à droite. */
.modeles-badges { flex: none; width: 13rem; display: flex; justify-content: center; }
.modeles-date { flex: none; min-width: 5.6em; text-align: right; }
.modele-etapes { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; font-size: 0.8rem; color: var(--text-3); }
.modele-etapes .is-on { color: var(--primary); font-weight: 600; }
.modele-etapes .is-done { color: var(--text-2); }
.modele-etape-lien { padding: 0; border: 0; background: none; font: inherit; color: var(--text-2); cursor: pointer; }
.modele-etape-lien:hover, .modele-etape-lien:focus-visible { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
.modele-parcours h2 { margin: 0 0 12px; }
.modele-nav { justify-content: space-between; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.modele-choix-liste { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.modele-choix { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--border-strong); border-radius: var(--radius); cursor: pointer; }
.modele-choix input { position: absolute; opacity: 0; pointer-events: none; }
.modele-choix > svg { width: 22px; height: 22px; color: var(--text-3); flex: none; }
.modele-choix span { display: flex; flex-direction: column; gap: 2px; }
.modele-choix.is-on { border-color: var(--primary); background: var(--primary-soft); }
.modele-choix.is-on > svg { color: var(--primary); }
.modele-choix:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.modele-depot { min-height: 110px; gap: 10px; }
.modele-onglet { margin-top: 12px; }
/* Questionnaire du modèle : question au-dessus, tableau du client en lecture dessous, une couleur de surlignage. */
.mq .question-card { padding: 20px 24px 14px; }
.mq .question-title { font-size: 1.3rem; margin-bottom: 0; }
.mq .wizard-actions { margin-top: 16px; padding-top: 14px; }
/* Petite ligne sous la question, hauteur fixe (rien ne saute) : aide de « Je montre » ou doublon, puis mention de
   l'IA. */
.mq-sous { display: flex; align-items: baseline; gap: 12px; height: 1.2rem; margin: 2px 0 0; font-size: 0.82rem; color: var(--text-3); overflow: hidden; white-space: nowrap; }
.mq-sous > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.mq-sous > span:first-child:empty { display: none; }
/* Barre de la question : Précédent et Passer en liens discrets, un seul bouton plein. */
.mq-actions { gap: 6px; margin-top: 10px !important; padding-top: 12px !important; }
.mq-actions .spacer { min-width: 12px; }
.mq-nav { display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 6px; border: 0; border-radius: 6px; background: none; font: inherit; font-size: 0.86rem; color: var(--text-3); cursor: pointer; }
.mq-nav:hover { color: var(--text); }
.mq-nav .icon { width: 14px; height: 14px; }
.mq-nav + .mq-nav { margin-left: 4px; }
.mq-actions .btn-ghost { color: var(--text-2); font-weight: 500; }
.mq-actions .btn-ghost.is-actif { background: var(--surface-3); color: var(--text); }
.mq-absent .icon { width: 14px; height: 14px; }
.mq-absent.btn-ghost .icon { color: var(--text-3); }
/* Avis « absent » de l'IA : petite flèche noire vers « Mon tableau n'en a pas ». */
.mq-avis-ia { display: inline-flex; align-items: center; gap: 3px; margin-right: 2px; font-size: 0.78rem; font-weight: 600; color: var(--text); white-space: nowrap; }
.mq-avis-ia .icon { width: 14px; height: 14px; }
.mq-effet { margin: 8px 0 0; font-size: 0.82rem; color: var(--text-3); text-align: right; }
/* Proposition venue de Mistral : mention discrète, grise, sans couleur. */
.mq-ia { font-size: 0.78rem; color: var(--text-3); white-space: nowrap; flex: none; }
.mq-ia .icon { width: 12px; height: 12px; vertical-align: -1px; margin-right: 2px; }
/* Valeur déjà prise par une autre réponse : même mention, le nom de l'autre question mène à elle. */
.mq-doublon { color: var(--text-2); }
/* L'IA analyse le tableau avant la première question : petit cercle qui tourne, une ligne, un lien discret. */
.mq-chargement { padding: 28px 0 12px; text-align: center; }
.mq-chargement p { margin: 0; }
.mq-chargement-titre { font-size: 1.05rem; color: var(--text); }
.mq-chargement-aide { margin-top: 6px !important; font-size: 0.82rem; color: var(--text-3); }
.mq-chargement-sans { margin-top: 18px; font-size: 0.82rem; color: var(--text-3); }
.mq-roue { display: inline-block; width: 13px; height: 13px; margin-right: 9px; vertical-align: -1px; border: 2px solid var(--text-3); border-right-color: transparent; border-radius: 50%; animation: mq-roue 0.9s linear infinite; }
@keyframes mq-roue { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .mq-roue { animation: none; border-right-color: var(--text-3); opacity: 0.6; } }
.mq-lien { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.mq-lien:hover { color: var(--primary); }
.btn-secondary.is-actif { background: var(--surface-3); border-color: var(--text-2); }
.mq-tableau { margin-top: 14px; }
.mq-tableau .sheet-scroll { max-height: 58vh; overflow: auto; }
.sheet.is-nu .sheet-bar, .sheet.is-nu .sheet-hint { display: none; }
.sheet.is-nu .grid td.is-sel { outline: none; }
.sheet.is-nu .grid td { cursor: default; }
/* « Je montre » : ce qu'un clic sélectionne (Case, Ligne, Colonne, menu) ; le survol éclaire ce qui serait pris. */
.mq-tableau.is-montre .grid td { cursor: pointer; }
.mq-tableau.is-montre.u-ligne .grid th[data-row], .mq-tableau.is-montre.u-col .grid th[data-col] { cursor: pointer; }
.mq-tableau.is-montre.u-case .grid td:hover::before,
.mq-tableau.is-montre.u-ligne .grid tr:hover td::before,
.mq-tableau.is-montre.u-col .grid td.is-survol::before { content: ''; position: absolute; inset: 0; background: var(--primary-ring); opacity: 0.4; pointer-events: none; z-index: 2; }
.mq-tableau.is-montre.u-ligne .grid tr:hover th[data-row]:not(.is-hl), .mq-tableau.is-montre.u-col .grid th.is-survol:not(.is-hl) { background: var(--surface-3); color: var(--text); }
.mq-montre-menu { flex: none; }
/* Largeur fixe (« Je montre · Colonne ») : le mode affiché ne déplace pas les autres boutons. */
.mq-actions .mq-montre { min-width: 11.5em; justify-content: center; gap: 4px; user-select: none; }
.mq-montre .icon { width: 14px; height: 14px; color: var(--text-3); }
.mq-montre-mode { color: var(--text-3); font-weight: 400; white-space: nowrap; }
.mq-montre-menu[open] > .mq-montre { background: var(--surface-3); color: var(--text); }
.mq-montre-pop { min-width: 100%; right: 0; }
.mq-montre-pop .menu-item .icon { width: 14px; height: 14px; visibility: hidden; color: var(--text-2); }
.mq-montre-pop .menu-item[aria-checked="true"] { font-weight: 600; }
.mq-montre-pop .menu-item[aria-checked="true"] .icon { visibility: visible; }
.mq-montre-pop .menu-item:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.mq-montre-pop .mq-montre-retour { margin-top: 4px; border-top: 1px solid var(--border); border-radius: 0 0 6px 6px; color: var(--text-2); white-space: nowrap; }
.mq-montre-pop .mq-montre-retour .icon { visibility: visible; color: var(--text-3); }
.mq-erreur { color: var(--danger); }
/* Surlignage net même sur une case colorée (fond jaune de saisie) : voile léger et cadre épais de l'accent,
   autour de la case, le long de la colonne ou de la ligne. */
.grid td.is-hl::before { content: ''; position: absolute; inset: 0; background: color-mix(in srgb, var(--primary) 18%, transparent); pointer-events: none; z-index: 2; }
.grid td.is-hl-col::before { box-shadow: inset 3px 0 0 var(--primary), inset -3px 0 0 var(--primary); }
.grid td.is-hl-row::before { box-shadow: inset 0 3px 0 var(--primary), inset 0 -3px 0 var(--primary); }
.grid td.is-hl-case::before { box-shadow: inset 0 0 0 3px var(--primary); }
.grid th.is-hl { background: var(--primary); color: #fff; }
.mq-recap-etape { margin: 12px 0 2px; font-size: 0.75rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.mq-recap-etape:first-child { margin-top: 0; }
.mq-a-faire { color: var(--text-3); font-style: italic; }
.mq-ligne { cursor: pointer; }
.mq-ligne:hover dd { color: var(--primary); }
/* « Modifier » un modèle : « Précédent » grisé sur la première question (rien avant). */
.mq-nav:disabled, .mq-nav:disabled:hover { color: var(--text-3); opacity: 0.45; cursor: default; }
/* Modèle en cours (liste des modèles) : le nom reprend le parcours. */
/* « Modèles archivés » sous la liste (comme « Chantiers archivés » à l'accueil) ; sans menu, la place du bouton est gardée. */
.modeles + .modeles-archives { margin-top: 16px; }
.modeles-archives .modeles-nom { color: var(--text-2); }
.modeles-menu-vide { flex: none; width: 32px; }
.modeles-reprendre { padding: 0; border: 0; background: none; font: inherit; font-weight: 600; color: inherit; text-align: left; cursor: pointer; }
.modeles-reprendre:hover { color: var(--primary); }

/* Page Modèles : colonne à gauche (Bordereaux, Tableaux de synthèse, Formulaires EXE sous lui, Valeurs par défaut) et
   réglages de la structure (js/modeles-reglages.js). */
.modeles-cadre { display: grid; grid-template-columns: 13rem minmax(0, 1fr); gap: 20px; align-items: start; }
.modeles-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: calc(var(--topbar-h) + 16px); }
.modeles-nav-lien { padding: 8px 12px; border-radius: var(--radius-sm); color: var(--text-2); text-decoration: none; font-weight: 500; }
.modeles-nav-lien:hover { background: var(--surface-3); color: var(--text); }
.modeles-nav-lien.is-on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
/* Sous-partie des tableaux de synthèse : en retrait sous eux, un filet qui la rattache. */
.modeles-nav-lien.is-sous { position: relative; padding-left: 24px; }
.modeles-nav-lien.is-sous::before { content: ""; position: absolute; left: 13px; top: 5px; bottom: 5px; width: 2px; border-radius: 1px; background: var(--border-strong); }
.modeles-contenu { min-width: 0; }
.reglages h3 { margin: 20px 0 8px; font-size: 0.95rem; }
.reglages-barre { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.reglages-aide, .reglages-lecture { margin: 8px 0 0; }
.reglages-lecture { margin: 0 0 12px; }
.reglages-couleurs { display: flex; flex-wrap: wrap; gap: 8px; }
.reglage-couleur { position: relative; display: inline-flex; }
.reglage-couleur input[type="color"] { width: 40px; height: 32px; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
.reglage-origine { position: absolute; right: -3px; bottom: -3px; width: 12px; height: 12px; border: 1px solid var(--border-strong); border-radius: 50%; }
.reglages-logo { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.reglages-logo-img { max-height: 48px; max-width: 160px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.reglages-largeurs { margin-top: 16px; }
.reglages-largeurs summary { cursor: pointer; font-weight: 600; }
.reglages-colonnes { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 10px; }
.reglages .input-court { width: 5.5em; }
.reglages-apercu { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: auto; max-height: 70vh; }
.reglages-champs { display: flex; flex-wrap: wrap; gap: 12px 24px; }
.reglages-delais { border-collapse: collapse; width: 100%; }
.reglages-delais td { padding: 6px 4px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.reglages-delais td:last-child { white-space: nowrap; text-align: right; width: 1%; }
.reglages-pieces { display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: 6px 16px; }
@media (max-width: 760px) {
  .modeles-cadre { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .modeles-nav { position: static; flex-direction: row; overflow-x: auto; }
  .modeles-nav-lien { white-space: nowrap; }
  .modeles-nav-lien.is-sous { padding-left: 12px; }
  .modeles-nav-lien.is-sous::before { content: none; }
}

/* ── Images jointes aux messages d'aide (js/pieces-jointes.js) : appli et back-office. */
.pj-joindre svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.pj-vignettes { display: flex; flex-wrap: wrap; gap: 6px; }
.pj-vignettes[hidden] { display: none; }
.pj-vignette { position: relative; width: 56px; height: 56px; flex: none; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.pj-vignette img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.pj-retirer {
  position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; padding: 0; display: grid; place-items: center;
  border: 2px solid var(--surface); border-radius: 50%; background: var(--text); color: var(--surface);
  font-size: 13px; line-height: 1; cursor: pointer;
}
.pj-retirer:hover { background: var(--danger); }
.pj-galerie { display: flex; flex-wrap: wrap; gap: 6px; white-space: normal; }
.pj-galerie:not(:first-child) { margin-top: 8px; }
.pj-mini { padding: 0; border: 0; border-radius: 8px; background: none; line-height: 0; cursor: zoom-in; overflow: hidden; }
.pj-mini img { display: block; max-width: 100%; max-height: 150px; border-radius: 8px; background: #fff; }
.pj-mini:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.pj-survol { outline: 2px dashed var(--primary); outline-offset: -4px; }
.pj-lightbox { padding: 0; border: 0; background: none; max-width: 96vw; max-height: 96vh; overflow: visible; pointer-events: auto; }
.pj-lightbox::backdrop { background: rgba(10, 16, 24, 0.8); }
.pj-lightbox img { display: block; max-width: 96vw; max-height: 94vh; border-radius: 8px; cursor: zoom-out; background: #fff; }

/* ——— Fin de chantier d'un lot (js/cloture-view.js) ——— */
.cloture-phase, .cloture-delais, .cloture-alertes { margin-bottom: 16px; }
.cloture-table tbody tr { cursor: default; }
.cloture-table tbody tr:hover { background: none; }
.cloture-table td { padding: 8px 12px; vertical-align: top; }
.cloture-table th:nth-child(2), .cloture-table td:nth-child(2) { width: 130px; }
.cloture-table th:nth-child(3), .cloture-table td:nth-child(3) { width: 190px; }
.cloture-table th:nth-child(4), .cloture-table td:nth-child(4) { width: 280px; }
.cloture-titre { display: block; font-weight: 600; }
.cloture-base { display: block; color: var(--text-2); font-size: 0.8rem; margin-top: 2px; }
.cloture-qui { color: var(--text-2); }
.cloture-saisie .input { width: auto; height: 32px; padding: 0 8px; font-size: 0.85rem; margin: 0 6px 4px 0; }
.cloture-saisie .input.is-office { color: #9a9a9a; font-style: italic; }
.cloture-fait { color: var(--success); }
.cloture-retard { color: var(--danger); font-weight: 600; }
.cloture-ligne.is-fait .cloture-titre { color: var(--text-2); }
.cloture-delais > summary { cursor: pointer; list-style: none; margin-bottom: 0; justify-content: flex-start; }
.cloture-delais > summary::-webkit-details-marker { display: none; }
.cloture-delais[open] > summary { margin-bottom: 14px; }
.cloture-delais-liste { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 8px 24px; }
.cloture-delai { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 0.88rem; }
.cloture-delai-valeur { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.cloture-delai .input { width: 70px; height: 32px; padding: 0 8px; }

/* Formulaire EXE (js/exe-formulaire-view.js) : listes de choix en haut, puis le formulaire. */
.exe-choix {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; width: fit-content; max-width: 100%; margin: 16px auto 20px;
  padding: 6px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow);
}
.exe-choix-liste {
  position: relative; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: 10px; color: var(--text-3);
  transition: background .12s;
}
.exe-choix-liste:hover, .exe-choix-liste:focus-within { background: var(--surface-2); color: var(--primary); }
.exe-choix-liste + .exe-choix-liste { border-left: 1px solid var(--border); border-radius: 0 10px 10px 0; }
.exe-choix-liste .icon { flex: none; width: 17px; height: 17px; }
.exe-choix-liste .icon:last-child { position: absolute; right: 10px; width: 14px; height: 14px; pointer-events: none; }
.exe-choix-liste select {
  appearance: none; min-width: 200px; max-width: 380px; padding: 10px 26px 10px 0; border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 0.95rem; font-weight: 500; text-overflow: ellipsis; cursor: pointer;
}
.exe-choix-liste select:focus { outline: 0; }
.exe-choix-liste:has(select:focus-visible) { outline: 2px solid var(--focus); outline-offset: 1px; }
.exe-choix-court select { min-width: 70px; }

/* Formulaire EXE : le modèle de la DAJ (Arial, bandeau et rubriques #66CCFF), champs posés sur la feuille. Feuille blanche,
   même en thème sombre. */
.daj {
  --daj-bleu: #66ccff;
  max-width: 820px; margin: 0 auto 32px; padding: 36px 48px 28px; background: #fff; color: #000;
  border: 1px solid var(--border); box-shadow: var(--shadow); font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 1.4;
}
.daj p { margin: 0; }
.daj-tete { text-align: center; }
.daj-logo { width: 104px; height: auto; display: block; margin: 0 auto 10px; }
.daj-ministere { font-size: 10px; font-weight: 700; }
.daj-ministere span { font-size: 11px; }
.daj-bandeau { position: relative; margin: 18px 0 10px; padding: 6px 70px; background: var(--daj-bleu); text-align: center; }
.daj-bandeau p { font-size: 13px; }
.daj-bandeau .daj-sur, .daj-bandeau h2 { font-weight: 700; }
.daj-bandeau h2 { margin: 0; font-size: 15px; }
.daj-bandeau > strong { position: absolute; top: 6px; right: 10px; font-size: 15px; }
.daj-intro { font-style: italic; font-size: 11px; text-align: justify; margin-bottom: 12px !important; }
.daj-rubrique { margin-bottom: 14px; }
.daj-rubrique > h3 { margin: 0 0 4px; padding: 1px 4px; background: var(--daj-bleu); font-size: 13px; font-weight: 700; }
.daj-consigne { font-style: italic; font-size: 11px; text-align: justify; margin-bottom: 6px !important; }
.daj-ligne { display: flex; align-items: baseline; gap: 6px; margin: 6px 0 !important; }
.daj-ligne > label { flex: none; max-width: 60%; }
.daj-bloc { margin: 6px 0; }
.daj-bloc > label { display: block; margin-bottom: 2px; }
.daj-saisie, .daj-zone {
  font: inherit; color: inherit; background: transparent; border: 0; border-bottom: 1px dotted #000; border-radius: 0; padding: 1px 2px;
}
.daj-saisie { flex: 1; min-width: 80px; }
.daj-nombre { flex: 0 1 160px; text-align: right; }
.daj-date { flex: 0 0 auto; width: 150px; }
.daj-zone { display: block; width: 100%; min-height: 40px; resize: none; overflow: hidden; border: 1px dotted #9a9a9a; }
.daj-saisie:hover:not(:disabled), .daj-zone:hover:not(:disabled) { background: #f0f9ff; }
.daj-saisie:focus, .daj-zone:focus { outline: 0; background: #e6f6ff; }
.daj-saisie::placeholder, .daj-zone::placeholder { color: #8a8a8a; font-style: italic; }
.daj-saisie.is-suggestion, .daj-zone.is-suggestion { color: #9a9a9a; font-style: italic; }
.daj-signe-par { margin-top: 4px !important; text-align: center; }
.daj-signe-par .daj-saisie { width: 100%; text-align: center; }
.exe-astuce { margin: 14px auto -6px; text-align: center; color: var(--text-3); font-size: 0.82rem; }
.exe-astuce[hidden] { display: none; }
.exe-astuce kbd {
  display: inline-block; padding: 1px 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px;
  background: var(--surface); color: var(--text-2); font: inherit; font-size: 0.76rem;
}
.daj-saisie:disabled, .daj-zone:disabled, .daj-carre:disabled { cursor: not-allowed; }
.daj-unite { flex: none; }
.daj-choix { margin: 8px 0; }
.daj-choix > p { margin-bottom: 4px !important; }
.daj-coche { display: flex; align-items: flex-start; gap: 10px; margin: 4px 0 4px 34px; cursor: pointer; }
.daj-choix[hidden], .daj-coche[hidden], .daj-ligne[hidden], .daj-bloc[hidden] { display: none; }
.daj-carre {
  appearance: none; flex: none; width: 12px; height: 12px; margin: 3px 0 0; border: 1px solid #000; border-radius: 0; background: #fff; cursor: pointer;
}
.daj-carre:checked {
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 2l8 8M10 2l-8 8' stroke='%23000' stroke-width='1.6'/%3E%3C/svg%3E") center/10px no-repeat;
}
.daj-carre:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.daj-liste { margin: 4px 0; padding-left: 20px; }
.daj-signature { margin: 10px 0 8px 45%; }
.daj-signature .daj-saisie { flex: none; width: 140px; }
.daj-signature .daj-date { width: 140px; }
.daj-signe { margin-top: 10px !important; text-align: center; }
.daj-signe em { font-size: 11px; }
.daj-pied { display: flex; justify-content: space-between; gap: 16px; margin-top: 22px; padding: 3px 6px; background: var(--daj-bleu); font-size: 11px; font-weight: 700; }
.daj-pied em { font-weight: 700; }
/* Feuilles au centre, un peu agrandies sur grand écran ; panneau de mise en forme à droite, qui suit le défilement. */
.daj-plan { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 820px) minmax(0, 1fr); gap: 20px; align-items: start; }
.daj-feuilles { grid-column: 2; min-width: 0; }
@media (min-width: 1280px) {
  .daj-plan { grid-template-columns: minmax(0, 1fr) minmax(0, 984px) minmax(272px, 1fr); }
  .daj-feuilles { zoom: 1.2; }
}
@media (max-width: 1100px) {
  .daj-plan { grid-template-columns: minmax(0, 1fr); }
  .daj-feuilles { grid-column: 1; }
}
.daj-libre { position: relative; display: flex; flex-direction: column; min-height: 1160px; margin-top: 24px; }
.daj-libre-texte { flex: 1; min-height: 200px; outline: 0; font-size: small; line-height: 1.5; overflow-wrap: anywhere; cursor: text; }
.daj-libre-texte[contenteditable]:empty::before { content: attr(data-vide); color: #9a9a9a; font-style: italic; pointer-events: none; }
.daj-libre-retirer {
  position: absolute; top: 10px; right: 10px; display: inline-grid; place-items: center; width: 26px; height: 26px; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: #8a8a8a; cursor: pointer; opacity: 0; transition: opacity .15s;
}
.daj-libre:hover .daj-libre-retirer, .daj-libre-retirer:focus-visible { opacity: 1; }
.daj-libre-retirer:hover { background: #f1f1f1; color: #c62828; }
.daj-libre-retirer .icon { width: 15px; height: 15px; }
.daj-ajouter { display: flex; justify-content: center; margin: 18px 0 40px; }
/* Panneau de mise en forme du texte des pages libres. */
.daj-outils {
  grid-column: 3; justify-self: start; position: sticky; top: calc(var(--topbar-h) + 16px); width: 272px; padding: 16px;
  display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  box-shadow: var(--shadow);
}
@media (max-width: 1100px) {
  .daj-outils { grid-column: 1; grid-row: 1; justify-self: stretch; width: auto; top: calc(var(--topbar-h) + 8px); z-index: 5; }
}
.daj-outils-groupe { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 10px; background: var(--surface-2); }
.daj-tailles { flex-direction: column; flex-wrap: nowrap; gap: 2px; }
.daj-tailles .daj-taille { text-align: left; padding: 6px 10px; color: var(--text); }
.daj-taille[data-taille="1"] { font-size: 0.72rem; }
.daj-taille[data-taille="2"] { font-size: 0.86rem; }
.daj-taille[data-taille="4"] { font-size: 1rem; }
.daj-taille[data-taille="5"] { font-size: 1.18rem; }
.daj-taille[data-taille="6"] { font-size: 1.4rem; font-weight: 600; }
.daj-taille, .daj-style {
  flex: 1 1 auto; padding: 8px 6px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--text-2);
  font-size: 0.82rem; line-height: 1.1; cursor: pointer; white-space: nowrap; transition: background .12s, color .12s;
}
.daj-style { font-size: 1rem; font-family: Georgia, 'Times New Roman', serif; }
.daj-taille:hover, .daj-style:hover { background: var(--surface); border-color: var(--border); color: var(--text); }
.daj-style[aria-pressed="true"] { background: var(--surface); border-color: var(--border); color: var(--primary); }
.daj-pastilles { gap: 8px; padding: 10px; background: transparent; border: 1px solid var(--border); }
.daj-pastille {
  position: relative; width: 26px; height: 26px; padding: 0; border: 2px solid var(--surface); border-radius: 50%; background: var(--c);
  box-shadow: 0 0 0 1px var(--border); cursor: pointer; transition: box-shadow .12s;
}
.daj-pastille:hover { box-shadow: 0 0 0 2px var(--text-3); }
.daj-pastille:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.daj-perso { overflow: hidden; background: conic-gradient(#f44336, #ffeb3b, #4caf50, #2196f3, #9c27b0, #f44336); }
.daj-perso input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.daj-aucun { background: linear-gradient(135deg, transparent 45%, #c62828 45%, #c62828 55%, transparent 55%), #fff; }
@media (max-width: 700px) { .daj { padding: 20px 16px; } .daj-signature { margin-left: 0; } .daj-ligne { flex-wrap: wrap; } }

/* Sélecteur d'espace de l'accueil (compte invité dans une équipe : à partir de deux espaces). */

/* Page « Fiches » du chantier : trois cartes (chantier, lots, synthèse) ; un clic sur une carte ou un lot ouvre la fiche. */
.fiches-choix { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; align-items: start; }
.fiche-choix { display: flex; flex-direction: column; gap: 8px; padding: 20px; color: var(--text); }
.fiche-choix h2 { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; margin: 0; }
.fiche-choix h2 .icon { width: 18px; height: 18px; color: var(--primary); }
.fiche-choix p { margin: 0; }
.fiche-choix-lots { list-style: none; margin: 4px 0 0; padding: 0; }
.fiche-choix-lots a { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; margin: 0 -10px; border-radius: 6px; color: var(--text); }
.fiche-choix-lots a > .icon { width: 16px; height: 16px; margin-top: 2px; color: var(--text-2); flex: none; }
.fiche-choix-lots a > span { display: flex; flex-direction: column; }
.fiche-choix-lots a:hover { background: var(--surface-3); text-decoration: none; }

/* Bloc de points replié (points de vigilance, « À faire ») : les nouveaux points depuis la dernière ouverture, sous le titre. */
.panel-repli > summary, .archives.afaire > summary { flex-wrap: wrap; }
.repli-nouveaux { flex-basis: 100%; margin: 6px 0 0; cursor: default; }
details[open] > summary > .repli-nouveaux { display: none; }

/* Page Modèles, « Formulaires EXE » : un onglet par formulaire (point : page préparée), le formulaire vierge, sa page dessous. */
.exe-pieces { flex-wrap: wrap; overflow: visible; margin: 12px 0 16px; }
.exe-pieces-point { display: inline-block; width: 6px; height: 6px; margin-left: 5px; border-radius: 50%; background: var(--primary); vertical-align: middle; }
.modeles-contenu .daj-plan { grid-template-columns: minmax(0, 820px) 272px; }
.modeles-contenu .daj-feuilles { grid-column: 1; zoom: 1; }
.modeles-contenu .daj-outils { grid-column: 2; }
@media (max-width: 1250px) {
  .modeles-contenu .daj-plan { grid-template-columns: minmax(0, 1fr); }
  .modeles-contenu .daj-outils { grid-column: 1; grid-row: 1; justify-self: stretch; width: auto; }
}
.daj-vierge { pointer-events: none; }
/* Rubrique ajoutée dans une page (« G - Titre ») : comme les rubriques du formulaire, toute la ligne sur fond bleu, en gras. */
.daj-libre-texte h3 { margin: 8px 0 4px; padding: 1px 4px; background: var(--daj-bleu); font-size: 13px; font-weight: 700; }
.daj-rubrique-ajout { align-self: stretch; justify-content: center; }

/* Mots de passe (SC.motDePasse, utils.js) : bouton « Afficher » dans le champ, règles cochées au fil de la frappe. */
.mdp-champ { position: relative; display: block; }
.mdp-champ .input { width: 100%; padding-right: 42px; }
.mdp-voir {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%); display: inline-flex; align-items: center;
  justify-content: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 6px; background: none;
  color: var(--text-3); cursor: pointer;
}
.mdp-voir:hover, .mdp-voir:focus-visible { color: var(--text); background: var(--surface-3); }
.mdp-voir[aria-pressed="false"] .mdp-barre { display: none; }
.mdp-regles { list-style: none; margin: -4px 0 4px; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: 0.8rem; color: var(--text-2); }
.mdp-regles li { position: relative; padding-left: 20px; }
.mdp-regles li::before { content: "○"; position: absolute; left: 2px; top: 0; color: var(--text-3); }
.mdp-regles li.is-ok { color: var(--success); }
.mdp-regles li.is-ok::before { content: "✓"; color: var(--success); font-weight: 700; }
