/* ============================================================================
   RH IBB — charte reprise de Cassini (couleurs / formes), sans le logo.
   Tokens = source de vérité : ne pas coder de couleur en dur ailleurs.
   ============================================================================ */
:root {
  --color-brand-primary: #4a6fa5;
  --color-brand-primary-hover: #3d5d8f;
  --color-brand-primary-soft: #eaf0f8;
  --color-brand-accent: #ffd750;
  --color-brand-accent-hover: #f0c63a;
  --color-brand-accent-soft: #fff9ea;

  /* Statuts du circuit EAD */
  --st-preparation: #94a3b8;
  --st-entretien: #60a5fa;
  --st-a-signer: #fbbf24;
  --st-signee: #16a34a;
  --st-close: #475569;
  --color-negative: #dc2626;
  --color-negative-soft: #fde8e8;
  --color-positive: #16a34a;
  --color-positive-soft: #e8f5e9;

  /* Propriétaire d'un champ EAD */
  /* Trois teintes franchement distinctes (l'ancien bleu canard du collaborateur
     se confondait avec le bleu du « commun ») : orange / violet / vert. */
  --qui-collab: #ea580c;
  --qui-manager: #7c3aed;
  --qui-commun: #059669;

  /* « Voir en tant que » : teinte propre, absente du reste de l'interface. */
  --vue-fond: #be185d;

  --text-primary: #0f172a;
  --text-secondary: rgba(15, 23, 42, 0.7);
  --text-muted: rgba(15, 23, 42, 0.55);
  --text-on-brand: #fff;

  --border-subtle: rgba(0, 0, 0, 0.06);
  --border-default: rgba(0, 0, 0, 0.12);
  --border-strong: rgba(0, 0, 0, 0.2);

  --bg-app: #f5f6fa;
  --bg-surface: #fff;
  --bg-elevated: #fafafa;
  --bg-overlay: rgba(15, 23, 42, 0.45);

  --space-xs: 4px; --space-sm: 8px; --space-md: 12px; --space-lg: 16px;
  --space-xl: 20px; --space-2xl: 24px; --space-3xl: 32px;
  --radius-sm: 4px; --radius-md: 6px; --radius-lg: 8px; --radius-xl: 12px; --radius-pill: 14px; --radius-circle: 50%;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 2px 8px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 4px 14px rgba(15, 23, 42, 0.12);
  --transition-fast: 0.12s ease;

  --page-a4: 210mm;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-app); color: var(--text-primary); min-height: 100vh;
  -webkit-font-smoothing: antialiased; font-size: 15px;
}
a { color: var(--color-brand-primary); }
code { background: rgba(0, 0, 0, 0.06); padding: 0.1rem 0.35rem; border-radius: var(--radius-sm); font-size: 0.85em; }
.muted { color: var(--text-muted); }
.small { font-size: 0.8rem; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }

/* ============ EN-TÊTE ============ */
.app-header {
  background: var(--color-brand-primary); color: var(--text-on-brand);
  padding: 0.6rem 1.2rem; display: flex; align-items: center; gap: 1rem;
  border-bottom: 4px solid var(--color-brand-accent); box-shadow: var(--shadow-md);
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; color: inherit; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px;
  background: var(--color-brand-accent); color: var(--color-brand-primary); font-weight: 800;
  border-radius: var(--radius-lg); font-size: 0.95rem;
}
.brand-mark.large { width: 58px; height: 58px; font-size: 1.4rem; margin-bottom: 0.75rem; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title { font-weight: 700; font-size: 1.05rem; }
.brand-sub { font-size: 0.72rem; opacity: 0.8; }
.header-nav { display: flex; gap: 0.35rem; margin-left: 1rem; flex-wrap: wrap; }
.header-nav a {
  color: rgba(255, 255, 255, 0.88); background: rgba(255, 255, 255, 0.1);
  padding: 0.45rem 0.85rem; border-radius: var(--radius-md); text-decoration: none; font-size: 0.86rem;
}
.header-nav a:hover { background: rgba(255, 255, 255, 0.2); color: #fff; }
.header-nav a.active { background: var(--color-brand-accent); color: var(--color-brand-primary); font-weight: 700; }
.user-box { display: flex; align-items: center; gap: 0.7rem; margin-left: auto; }
.user-meta { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.user-name { font-size: 0.85rem; }
.user-role { font-size: 0.66rem; opacity: 0.75; text-transform: uppercase; letter-spacing: 0.04em; }
.btn-logout { color: #fff; background: rgba(255, 255, 255, 0.14); padding: 0.4rem 0.8rem; border-radius: var(--radius-md); text-decoration: none; font-size: 0.8rem; }
.btn-logout:hover { background: rgba(255, 255, 255, 0.28); }

/* Bandeau « accès libre » (dev) — ne pas retirer : il rappelle que l'auth est coupée. */
.bandeau-dev {
  background: var(--color-brand-accent-soft); border-bottom: 1px solid var(--color-brand-accent);
  padding: 0.4rem 1.2rem; font-size: 0.8rem; display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap;
}
.bandeau-dev form { display: flex; gap: 0.4rem; align-items: center; }
.bandeau-dev input { padding: 0.25rem 0.5rem; border: 1px solid var(--border-default); border-radius: var(--radius-sm); font: inherit; width: 240px; }
.bandeau-dev button { padding: 0.25rem 0.6rem; border: 1px solid var(--border-default); border-radius: var(--radius-sm); background: #fff; cursor: pointer; font: inherit; }

/* « Voir en tant que » — ne pas retirer : il rappelle qu'on n'est pas soi-même. */
.bandeau-vue {
  background: var(--vue-fond); color: var(--text-on-brand);
  padding: 0.5rem 1.2rem; font-size: 0.85rem; display: flex; gap: 0.8rem; align-items: center; justify-content: space-between; flex-wrap: wrap;
}
.bandeau-vue .btn { background: var(--bg-surface); color: var(--vue-fond); border: none; font-weight: 600; }
.vue-resultats { list-style: none; margin-top: 0.6rem; }
.vue-resultats li { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; padding: 0.45rem 0; border-top: 1px solid var(--border-subtle); }
.vue-resultats li:first-child { border-top: none; }
.familles-export { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0.5rem 1rem; margin: 0.6rem 0 1rem; }
.familles-export .sensible { color: var(--color-negative); }

/* ============ LAYOUT ============ */
main { max-width: 1200px; margin: 0 auto; padding: 1.25rem; }
main.etroit { max-width: 900px; }
.page-titre { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-titre h1 { font-size: 1.35rem; }
.page-titre .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.card {
  background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-xl);
  padding: 1.3rem; margin-bottom: 1rem; box-shadow: var(--shadow-sm);
}
.card h2 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.card h3 { font-size: 0.98rem; margin: 0.8rem 0 0.4rem; }
.grille-cartes { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.carte-lien {
  display: block; text-decoration: none; color: inherit; background: var(--bg-surface);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-xl); padding: 1.2rem;
  box-shadow: var(--shadow-sm); border-top: 4px solid var(--color-brand-primary); transition: box-shadow var(--transition-fast);
}
.carte-lien:hover { box-shadow: var(--shadow-lg); }
.carte-lien h3 { font-size: 1.05rem; margin-bottom: 0.3rem; color: var(--color-brand-primary); }
.carte-lien p { font-size: 0.88rem; color: var(--text-secondary); }
.carte-lien.accent { border-top-color: var(--color-brand-accent); }

.deux-colonnes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; align-items: start; }

/* ============ BOUTONS ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  padding: 0.6rem 1.05rem; border-radius: var(--radius-lg); font-size: 0.88rem; font-weight: 600;
  cursor: pointer; border: 1px solid transparent; text-decoration: none; font-family: inherit;
  transition: background var(--transition-fast), opacity var(--transition-fast); white-space: nowrap;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primaire { background: var(--color-brand-primary); color: #fff; }
.btn-primaire:hover:not(:disabled) { background: var(--color-brand-primary-hover); }
.btn-accent { background: var(--color-brand-accent); color: var(--color-brand-primary); }
.btn-accent:hover:not(:disabled) { background: var(--color-brand-accent-hover); }
.btn-secondaire { background: var(--bg-surface); color: var(--text-secondary); border-color: var(--border-default); }
.btn-secondaire:hover:not(:disabled) { background: var(--bg-elevated); }
.btn-danger { background: var(--color-negative-soft); color: var(--color-negative); border-color: #f5b5b5; }
.btn-danger:hover:not(:disabled) { background: #fbd5d5; }
.btn-succes { background: var(--color-positive); color: #fff; }
.btn-petit { padding: 0.35rem 0.7rem; font-size: 0.8rem; }

/* ============ FORMULAIRES ============ */
.champ { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.8rem; }
.champ > label, .champ > .libelle { font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); }
.champ .aide { font-size: 0.76rem; color: var(--text-muted); }
.champ.requis > label::after { content: ' *'; color: var(--color-negative); }
input[type=text], input[type=email], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 0.55rem 0.75rem; border: 2px solid var(--border-default); border-radius: var(--radius-md);
  font-size: 0.92rem; font-family: inherit; color: var(--text-primary); background: var(--bg-surface); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--color-brand-primary); }
input:disabled, select:disabled, textarea:disabled, textarea[readonly] { background: var(--bg-elevated); color: var(--text-secondary); }
textarea { resize: vertical; min-height: 5.5rem; line-height: 1.45; }
.grille-champs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 0.9rem; }
.grille-champs .large { grid-column: 1 / -1; }
.case { display: flex; align-items: center; gap: 0.45rem; font-size: 0.88rem; cursor: pointer; }
.case input { width: 17px; height: 17px; accent-color: var(--color-brand-primary); }
fieldset { border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 0.9rem 1rem 0.3rem; margin-bottom: 1rem; }
legend { font-weight: 700; font-size: 0.85rem; color: var(--color-brand-primary); padding: 0 0.4rem; }

/* ============ BARRE D'OUTILS / TABLE ============ */
.outils { display: flex; gap: 0.6rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.outils input[type=search] { flex: 1; min-width: 200px; width: auto; }
.outils select { width: auto; }
.table-wrap { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); overflow-x: auto; box-shadow: var(--shadow-sm); }
.table { width: 100%; border-collapse: collapse; }
.table th {
  background: var(--bg-elevated); padding: 0.65rem 0.8rem; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.03em; color: var(--text-muted); text-align: left; border-bottom: 1px solid var(--border-default); white-space: nowrap;
}
.table td { padding: 0.6rem 0.8rem; font-size: 0.87rem; border-bottom: 1px solid var(--border-subtle); vertical-align: top; }
.table tbody tr.cliquable { cursor: pointer; }
.table tbody tr.cliquable:hover { background: var(--color-brand-accent-soft); }
.table tr.inactif td { color: var(--text-muted); }
.vide-etat { text-align: center; padding: 2.2rem; color: var(--text-muted); }

.badge {
  display: inline-block; padding: 0.2rem 0.6rem; border-radius: var(--radius-pill);
  font-size: 0.72rem; font-weight: 700; white-space: nowrap; color: #fff; background: var(--st-preparation);
}
.badge.preparation { background: var(--st-preparation); }
.badge.entretien { background: var(--st-entretien); }
.badge.a_signer { background: var(--st-a-signer); color: #6b4e00; }
.badge.signee { background: var(--st-signee); }
.badge.close { background: var(--st-close); }
.badge.brouillon { background: var(--st-preparation); }
.badge.finalise { background: var(--st-signee); }
.badge.neutre { background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border-default); }
.badge.ad { background: var(--color-brand-primary-soft); color: var(--color-brand-primary); }
.badge.rh { background: var(--color-brand-accent); color: var(--color-brand-primary); }

/* Stats */
.stats { display: flex; gap: 0.7rem; margin-bottom: 1rem; flex-wrap: wrap; }
.stat {
  flex: 1; min-width: 120px; background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); padding: 0.8rem 1rem; text-align: center; box-shadow: var(--shadow-sm);
  border-top: 3px solid var(--border-default); cursor: pointer;
}
.stat.actif { outline: 2px solid var(--color-brand-primary); }
.stat b { display: block; font-size: 1.6rem; }
.stat span { font-size: 0.76rem; color: var(--text-muted); }
.stat.preparation { border-top-color: var(--st-preparation); }
.stat.entretien { border-top-color: var(--st-entretien); }
.stat.a_signer { border-top-color: var(--st-a-signer); }
.stat.signee { border-top-color: var(--st-signee); }
.stat.close { border-top-color: var(--st-close); }
.progression { height: 8px; background: var(--bg-elevated); border-radius: var(--radius-pill); overflow: hidden; border: 1px solid var(--border-subtle); }
.progression > div { height: 100%; background: var(--st-signee); }

.onglets { display: flex; gap: 0.3rem; margin-bottom: 1rem; border-bottom: 2px solid var(--border-subtle); flex-wrap: wrap; }
.onglets button {
  padding: 0.55rem 1rem; border: none; background: none; font: inherit; font-size: 0.9rem; font-weight: 600;
  color: var(--text-muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.onglets button.actif { color: var(--color-brand-primary); border-bottom-color: var(--color-brand-primary); }

/* ============ ALERTES / TOAST ============ */
.alerte { padding: 0.7rem 1rem; border-radius: var(--radius-lg); margin-bottom: 1rem; font-size: 0.88rem; line-height: 1.45; }
.alerte.info { background: var(--color-brand-primary-soft); border: 1px solid #c7d6ea; }
.alerte.attention { background: var(--color-brand-accent-soft); border: 1px solid var(--color-brand-accent); color: #6d4c00; }
.alerte.erreur { background: var(--color-negative-soft); border: 1px solid #f5b5b5; color: var(--color-negative); }
.alerte.succes { background: var(--color-positive-soft); border: 1px solid #a5d6a7; color: #2e7d32; }
#toasts { position: fixed; bottom: 1.2rem; right: 1.2rem; z-index: 2000; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
  background: var(--text-primary); color: #fff; padding: 0.7rem 1rem; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); font-size: 0.88rem; max-width: 420px;
}
.toast.erreur { background: var(--color-negative); }
.toast.succes { background: var(--color-positive); }

/* ============ SALAIRES MASQUÉS ============ */
.oeil {
  display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; padding: 0;
  border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--bg-surface);
  color: var(--text-muted); cursor: pointer; vertical-align: middle; margin-left: 0.3rem; flex-shrink: 0;
}
.oeil:hover { color: var(--color-brand-primary); border-color: var(--color-brand-primary); }
.oeil[aria-pressed="true"] { color: var(--color-brand-primary); background: var(--color-brand-primary-soft); }
.masque { letter-spacing: 0.15em; color: var(--text-muted); }
input.masque { cursor: not-allowed; }
/* Champ + œil sur une ligne */
.avec-oeil { display: flex; align-items: center; gap: 0.3rem; }
.avec-oeil > input, .avec-oeil > textarea { flex: 1; }
@media print { .oeil { display: none !important; } }

/* ============ MODALE ============ */
.modale { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modale-fond { position: absolute; inset: 0; background: var(--bg-overlay); }
.modale-contenu {
  position: relative; background: var(--bg-surface); border-radius: var(--radius-xl); width: 100%;
  max-width: 720px; max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modale-contenu.large { max-width: 1000px; }
.modale-tete {
  display: flex; justify-content: space-between; align-items: center; padding: 0.9rem 1.3rem;
  border-bottom: 1px solid var(--border-subtle); position: sticky; top: 0; background: var(--bg-surface); z-index: 2;
}
.modale-tete h3 { font-size: 1.05rem; }
.modale-fermer { background: none; border: none; font-size: 1.6rem; cursor: pointer; color: var(--text-muted); line-height: 1; }
.modale-corps { padding: 1.3rem; }
.modale-pied { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 0.9rem 1.3rem; border-top: 1px solid var(--border-subtle); flex-wrap: wrap; }
.modale-pied .gauche { margin-right: auto; }

/* ============ FICHE EAD ============ */
.fiche-entete { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.6rem 1.2rem; }
.fiche-entete dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }
.fiche-entete dd { font-weight: 600; font-size: 0.93rem; }
.circuit { display: flex; gap: 0.3rem; margin: 1rem 0 0.4rem; flex-wrap: wrap; }
.circuit li { list-style: none; flex: 1; min-width: 120px; font-size: 0.74rem; text-align: center; padding: 0.4rem; border-radius: var(--radius-md); background: var(--bg-elevated); color: var(--text-muted); border: 1px solid var(--border-subtle); }
.circuit li.fait { background: var(--color-positive-soft); color: #2e7d32; }
.circuit li.courant { background: var(--color-brand-primary); color: #fff; font-weight: 700; }
.legende-qui { display: flex; gap: 1rem; font-size: 0.78rem; flex-wrap: wrap; }
.puce-qui { display: inline-block; width: 10px; height: 10px; border-radius: var(--radius-circle); margin-right: 0.3rem; vertical-align: middle; }
.puce-qui.collab { background: var(--qui-collab); }
.puce-qui.manager { background: var(--qui-manager); }
.puce-qui.commun { background: var(--qui-commun); }

.section-ead { border-left: 4px solid var(--color-brand-accent); }
.section-ead > h2 { color: var(--color-brand-primary); }
.section-ead .intro { font-size: 0.86rem; color: var(--text-secondary); margin-bottom: 0.8rem; line-height: 1.45; }
.repetition { border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 0.8rem 1rem 0.2rem; margin-bottom: 0.8rem; background: var(--bg-elevated); }
.repetition > h3 { margin-top: 0; font-size: 0.9rem; color: var(--text-secondary); }
.champ-ead > label { display: flex; align-items: center; gap: 0.2rem; }
.champ-ead.collab textarea, .champ-ead.collab input { border-left: 4px solid var(--qui-collab); }
.champ-ead.manager textarea, .champ-ead.manager input { border-left: 4px solid var(--qui-manager); }
.champ-ead.commun textarea, .champ-ead.commun input { border-left: 4px solid var(--qui-commun); }
.info-ead { background: var(--color-brand-primary-soft); border-radius: var(--radius-md); padding: 0.6rem 0.8rem; margin: 0.6rem 0; font-size: 0.85rem; }
.info-ead strong { display: block; margin-bottom: 0.2rem; color: var(--color-brand-primary); }
.notes { display: flex; gap: 0.35rem; }
.notes label { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 2px solid var(--border-default); border-radius: var(--radius-md); cursor: pointer; font-weight: 700; }
.notes input { display: none; }
.notes input:checked + span { color: #fff; }
.notes label:has(input:checked) { background: var(--color-brand-primary); border-color: var(--color-brand-primary); color: #fff; }
.notes label:has(input:disabled) { cursor: default; opacity: 0.75; }
/* Champ d'un autre intervenant : visible, non modifiable. */
.champ-ead.lecture-seule textarea, .champ-ead.lecture-seule input[type=text], .champ-ead.lecture-seule input[type=date] {
  background: var(--bg-elevated); border-style: dashed; color: var(--text-secondary); cursor: not-allowed;
}
.tag-lecture {
  display: inline-block; margin-left: 0.4rem; padding: 0.05rem 0.45rem; border-radius: var(--radius-pill);
  font-size: 0.68rem; font-weight: 600; background: var(--bg-elevated); color: var(--text-muted);
  border: 1px solid var(--border-default);
}
.etat-sauvegarde { font-size: 0.8rem; color: var(--text-muted); }
.etat-sauvegarde.erreur { color: var(--color-negative); font-weight: 600; }
.barre-actions {
  position: sticky; bottom: 0; background: var(--bg-surface); border-top: 1px solid var(--border-default);
  padding: 0.8rem 1.2rem; display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap;
  box-shadow: 0 -2px 8px rgba(15, 23, 42, 0.06); z-index: 20; margin: 0 -1.25rem -1.25rem;
}
.barre-actions .droite { margin-left: auto; display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Pagination de la fiche : un onglet par feuille du classeur d'origine */
/* Jusqu'à 6 onglets : une seule ligne, défilement horizontal si l'écran est étroit
   (deux rangées d'onglets collants mangeraient la moitié de l'écran). */
.pages-ead { display: flex; gap: 0.4rem; margin-bottom: 1rem; flex-wrap: nowrap; overflow-x: auto; position: sticky; top: 64px; z-index: 15; background: var(--bg-app); padding: 0.4rem 0; scrollbar-width: thin; }
.pages-ead button {
  /* Numéro à gauche, titre puis compteur empilés : rien n'est rogné. */
  flex: 1 1 0; min-width: 125px; display: grid; grid-template-columns: auto 1fr; column-gap: 0.45rem; row-gap: 0.1rem;
  align-items: center; text-align: left;
  padding: 0.45rem 0.55rem; border: 2px solid var(--border-default); border-radius: var(--radius-lg);
  background: var(--bg-surface); cursor: pointer; font: inherit; color: var(--text-secondary);
}
.pages-ead button:hover { border-color: var(--color-brand-primary); }
.pages-ead button.actif { border-color: var(--color-brand-primary); background: var(--color-brand-primary-soft); color: var(--text-primary); }
.pages-ead .num {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: var(--radius-circle); display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-elevated); border: 1px solid var(--border-default); font-weight: 700; font-size: 0.82rem;
}
.pages-ead button.actif .num { background: var(--color-brand-primary); border-color: var(--color-brand-primary); color: #fff; }
.pages-ead .num { grid-row: 1 / span 2; }
.pages-ead .titre { font-weight: 600; font-size: 0.78rem; line-height: 1.2; }
.pages-ead .compte { grid-column: 2; font-size: 0.7rem; color: var(--text-muted); white-space: nowrap; }
.pages-ead button.complete .compte { color: var(--color-positive); font-weight: 700; }
.titre-page { font-size: 1.1rem; margin: 0 0 0.8rem; color: var(--color-brand-primary); }
.nav-pages { display: inline-flex; align-items: center; gap: 0.5rem; }

/* ============ ÉDITEUR DE MODÈLE ============ */
.modele-page { border: 2px dashed var(--border-default); border-radius: var(--radius-xl); padding: 0.8rem; margin-bottom: 1rem; }
.modele-page > .tete { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.7rem; }
.modele-page > .tete .num { font-weight: 800; color: var(--color-brand-primary); white-space: nowrap; }
.modele-page > .tete input { font-weight: 700; }
.modele-section { border: 1px solid var(--border-default); border-radius: var(--radius-lg); margin-bottom: 0.8rem; background: var(--bg-surface); }
.modele-section > .tete { display: flex; gap: 0.5rem; align-items: center; padding: 0.6rem 0.8rem; background: var(--bg-elevated); border-bottom: 1px solid var(--border-subtle); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.modele-section > .tete input { font-weight: 700; }
.modele-section > .corps { padding: 0.7rem 0.8rem; }
.modele-champ { display: grid; grid-template-columns: 1fr 120px 120px auto; gap: 0.4rem; align-items: center; margin-bottom: 0.4rem; }
.modele-champ input, .modele-champ select { padding: 0.4rem 0.55rem; font-size: 0.84rem; }
.icone-btn { border: 1px solid var(--border-default); background: var(--bg-surface); border-radius: var(--radius-sm); cursor: pointer; padding: 0.25rem 0.5rem; font-size: 0.85rem; }
.icone-btn:hover { background: var(--bg-elevated); }

/* ============ DOCUMENTS ============ */
.types-doc { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0.6rem; }
.type-doc {
  border: 2px solid var(--border-default); border-radius: var(--radius-lg); padding: 0.8rem; cursor: pointer; background: var(--bg-surface);
  text-align: left; font: inherit;
}
.type-doc:hover { border-color: var(--color-brand-primary); }
.type-doc.actif { border-color: var(--color-brand-primary); background: var(--color-brand-primary-soft); }
.type-doc b { display: block; color: var(--color-brand-primary); }
.type-doc span { font-size: 0.78rem; color: var(--text-muted); }
.editeur-doc { display: grid; grid-template-columns: minmax(360px, 440px) minmax(0, 1fr); gap: 1rem; align-items: start; }
.editeur-doc .apercu-col { position: sticky; top: 76px; }
.apercu-cadre { background: #e5e7eb; border-radius: var(--radius-lg); padding: 1rem; max-height: calc(100vh - 170px); overflow: auto; }
.manquants { font-size: 0.8rem; margin-bottom: 0.6rem; }

/* La page du document (écran, impression, partage, Word) */
.feuille {
  background: #fff; width: 100%; max-width: var(--page-a4); margin: 0 auto; padding: 18mm 18mm 20mm;
  box-shadow: var(--shadow-md); font-family: Georgia, 'Times New Roman', serif; font-size: 10.5pt; line-height: 1.5; color: #111;
}
.feuille h1 { font-size: 14pt; text-align: center; margin: 0 0 1.4em; letter-spacing: 0.03em; }
.feuille h2 { font-size: 11pt; margin: 1.2em 0 0.4em; }
.feuille h3 { font-size: 10.5pt; margin: 1em 0 0.3em; }
.feuille p { margin: 0 0 0.6em; text-align: justify; }
.feuille ul { margin: 0 0 0.6em 1.4em; }
.feuille .espace { height: 1em; }
.feuille .vide { background: #fde68a; border-radius: 2px; padding: 0 2px; }
.feuille .a-remplir { color: #555; }
.feuille .signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 2em; margin-top: 1.5em; page-break-inside: avoid; }
.feuille .signatures.seule { grid-template-columns: 1fr; max-width: 50%; margin-left: auto; }
.feuille .sig-titre { font-weight: 700; margin-bottom: 0.3em; }
.feuille .sig-ligne { font-size: 9.5pt; }
.feuille .sig-zone { height: 28mm; border: 1px dashed #bbb; margin-top: 0.5em; }
.feuille.fige .vide { background: none; }

/* ============ GABARITS ============ */
.editeur-gabarit textarea { font-family: Consolas, 'Courier New', monospace; font-size: 0.84rem; min-height: 60vh; line-height: 1.5; }
.aide-syntaxe { font-size: 0.8rem; line-height: 1.6; }
.aide-syntaxe code { font-size: 0.78rem; }
.liste-variables { max-height: 220px; overflow: auto; font-size: 0.78rem; columns: 2; }
.liste-variables code { cursor: pointer; }

/* ============ LOGIN / REFUS / PARTAGE ============ */
.page-centree {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem;
  background: linear-gradient(135deg, var(--color-brand-primary) 0%, var(--color-brand-primary-hover) 100%);
}
.carte-centree {
  background: var(--bg-surface); border-radius: var(--radius-xl); padding: 2.3rem 2rem; max-width: 440px; width: 100%;
  text-align: center; box-shadow: var(--shadow-lg); border-top: 5px solid var(--color-brand-accent);
}
.carte-centree h1 { font-size: 1.35rem; margin-bottom: 0.6rem; }
.carte-centree p { color: var(--text-secondary); font-size: 0.92rem; margin-bottom: 1.2rem; line-height: 1.5; }
.carte-centree .btn { width: 100%; padding: 0.8rem; font-size: 1rem; }
.code-saisie { font-size: 2rem !important; letter-spacing: 0.6em; text-align: center; font-weight: 700; padding: 0.6rem !important; margin-bottom: 1rem; }
.partage-barre { max-width: var(--page-a4); margin: 1rem auto; display: flex; gap: 0.6rem; justify-content: space-between; align-items: center; flex-wrap: wrap; padding: 0 0.5rem; }

/* ============ IMPRESSION ============ */
.impression-barre { max-width: var(--page-a4); margin: 1rem auto; display: flex; gap: 0.5rem; justify-content: flex-end; }
.fiche-imprimee { max-width: var(--page-a4); margin: 0 auto 2rem; background: #fff; padding: 14mm; box-shadow: var(--shadow-md); font-size: 10pt; }
.fiche-imprimee h1 { font-size: 13pt; text-align: center; margin-bottom: 0.8em; color: var(--color-brand-primary); }
.fiche-imprimee h2 { font-size: 11pt; background: var(--color-brand-primary); color: #fff; padding: 0.3em 0.6em; margin: 1.2em 0 0.5em; }
.fiche-imprimee h3 { font-size: 10pt; margin: 0.8em 0 0.3em; }
.fiche-imprimee .q { font-weight: 700; margin-top: 0.5em; font-size: 9.5pt; }
.fiche-imprimee .r { white-space: pre-wrap; border: 1px solid #ddd; padding: 0.35em 0.5em; min-height: 1.8em; margin-top: 0.15em; }
.fiche-imprimee table.entete { width: 100%; border-collapse: collapse; margin-bottom: 0.6em; }
.fiche-imprimee table.entete td { border: 1px solid #ddd; padding: 0.3em 0.5em; }
.fiche-imprimee .signatures-ead { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5em; margin-top: 1.5em; page-break-inside: avoid; }
.fiche-imprimee .signatures-ead > div { border: 1px solid #ccc; padding: 0.6em; min-height: 25mm; }
.fiche-imprimee .page-titre-impr { font-size: 12pt; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 3px solid var(--color-brand-accent); padding-bottom: 0.2em; margin: 0 0 0.6em; }
.fiche-imprimee .page-impr + .page-impr { break-before: page; page-break-before: always; margin-top: 2em; }

@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  .app-header, .impression-barre, .partage-barre, .bandeau-dev, .bandeau-vue, .no-print { display: none !important; }
  .feuille, .fiche-imprimee { box-shadow: none; margin: 0; max-width: none; }
  .fiche-imprimee { padding: 12mm 14mm; }
  .feuille .vide { background: none; }
  .fiche-imprimee h2 { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  main { padding: 0; max-width: none; }
}

@media (max-width: 900px) {
  .editeur-doc, .deux-colonnes { grid-template-columns: 1fr; }
  .editeur-doc .apercu-col { position: static; }
  .modele-champ { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .app-header { flex-wrap: wrap; gap: 0.5rem; padding: 0.6rem 0.9rem; }
  .header-nav { order: 3; width: 100%; margin-left: 0; }
  main { padding: 0.9rem; }
  .card { padding: 1rem; }
  .feuille { padding: 8mm; }
  .barre-actions { margin: 0 -0.9rem -0.9rem; }
}
