/* =====================================================================
   ATEC – feuille de style de l'application (arabe RTL, tablette d'abord)
   Propriétés logiques (inline-start = droite en arabe) partout.
   ===================================================================== */

@font-face {
  font-family: "Cairo";
  font-style: normal;
  font-display: swap;
  font-weight: 200 1000;
  src: url(/polices/cairo-arabic-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FEFC;
}
@font-face {
  font-family: "Cairo";
  font-style: normal;
  font-display: swap;
  font-weight: 200 1000;
  src: url(/polices/cairo-latin-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Jetons ----------
   Couleurs du logo ATEC : bleu des lettres (#1f5f94) et verts de la silhouette (#2a9156, #7cb551). */
:root {
  --marque-900: #0f2d47;
  --marque-800: #143c5f;
  --marque-700: #194c78;
  --marque-600: #1f5f94;
  --marque-500: #2f72ad;
  --marque-200: #bcd5ec;
  --marque-100: #e1edf8;
  --marque-50: #f2f7fc;
  --vert-800: #17603a;
  --vert-700: #1b6f42;
  --vert-600: #1e8049;
  --vert-500: #2a9156;
  --vert-400: #7cb551;
  --vert-100: #e3f3e8;
  /* Séries des graphiques (validées : bande de clarté, daltonisme, contraste ≥ 3:1) */
  --serie-ecoute: #2f72ad;
  --serie-ec: #2a9156;
  --serie-visite: #237d8b;
  --serie-vide: #b9c3cd;

  --fond: #f4f7fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f6;
  --bord: #e1e7ee;
  --bord-fort: #c8d2dd;
  --texte: #14212e;
  --texte-2: #4f5d6b;
  --texte-3: #66727f;
  --sur-marque: #ffffff;

  --succes: #1b6f42;
  --succes-fond: #e3f3e8;
  --attention: #a86a12;
  --attention-fond: #fdf1dc;
  --danger: #c23b3b;
  --danger-fond: #fbe7e7;
  --info: #2c67a8;
  --info-fond: #e4eef9;

  --accent: var(--marque-600);
  --accent-fond: var(--marque-100);
  --puce-active: var(--marque-700);

  --r-s: 10px;
  --r: 14px;
  --r-l: 20px;
  --ombre-1: 0 1px 2px rgb(15 35 55 / 6%), 0 2px 10px rgb(15 35 55 / 5%);
  --ombre-2: 0 4px 12px rgb(15 35 55 / 8%), 0 16px 40px rgb(15 35 55 / 10%);
  --anneau: 0 0 0 3px rgb(47 114 173 / 35%);

  --entete: 64px;
  --rail: 92px;
  --onglets: 68px;
  --contenu-max: 1240px;

  --police: "Cairo", "Noto Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #0f1720;
    --surface: #16212c;
    --surface-2: #1a2733;
    --surface-3: #213140;
    --bord: #2a3a4a;
    --bord-fort: #3c5064;
    --texte: #e9f0f6;
    --texte-2: #b2c0cd;
    --texte-3: #8a99a8;
    --accent: #7fb2e5;
    --accent-fond: #17324d;
    --puce-active: #2f72ad;
  --serie-ecoute: #4a8bcb; --serie-ec: #3fa36b; --serie-visite: #3a98a8; --serie-vide: #3e4e5e;
    --serie-ecoute: #4a8bcb; --serie-ec: #3fa36b; --serie-visite: #3a98a8; --serie-vide: #3e4e5e;
    --succes: #6cc893; --succes-fond: #173326;
    --attention: #e7b04f; --attention-fond: #372a12;
    --danger: #f07a7a; --danger-fond: #3b1c1e;
    --info: #79aee8; --info-fond: #172a40;
    --ombre-1: 0 1px 2px rgb(0 0 0 / 40%);
    --ombre-2: 0 8px 30px rgb(0 0 0 / 50%);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fond: #0f1720;
  --surface: #16212c;
  --surface-2: #1a2733;
  --surface-3: #213140;
  --bord: #2a3a4a;
  --bord-fort: #3c5064;
  --texte: #e9f0f6;
  --texte-2: #b2c0cd;
  --texte-3: #8a99a8;
  --accent: #7fb2e5;
  --accent-fond: #17324d;
  --puce-active: #2f72ad;
  --succes: #6cc893; --succes-fond: #173326;
  --attention: #e7b04f; --attention-fond: #372a12;
  --danger: #f07a7a; --danger-fond: #3b1c1e;
  --info: #79aee8; --info-fond: #172a40;
  --ombre-1: 0 1px 2px rgb(0 0 0 / 40%);
  --ombre-2: 0 8px 30px rgb(0 0 0 / 50%);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font-family: var(--police);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 750; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--anneau); border-radius: var(--r-s); }
.icone { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icone.petite { width: 18px; height: 18px; }
.icone.grande { width: 28px; height: 28px; }
.discret { color: var(--texte-2); }
.tres-discret { color: var(--texte-3); font-size: .9rem; }
.chiffres { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.visuellement-cache { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Démarrage ---------- */
.demarrage { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 16px; color: var(--texte-2); }
.demarrage img { animation: pulsation 1.4s ease-in-out infinite; border-radius: 16px; height: auto; }
.ecran-acces .logo-acces { width: 220px; height: auto; border-radius: 12px; }
@keyframes pulsation { 50% { transform: scale(.92); opacity: .7; } }

/* ---------- Coquille : en-tête, rail, onglets ---------- */
.app.coquille {
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  grid-template-rows: var(--entete) 1fr;
  grid-template-areas: "rail entete" "rail contenu";
  min-height: 100vh;
}
.entete {
  grid-area: entete;
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--fond) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-block-end: 1px solid var(--bord);
}
.entete .logo-entete { display: none; height: 34px; width: auto; padding: 3px 6px; background: #fff; border-radius: 8px; }
@media (max-width: 899px) { .entete .logo-entete { display: block; } }
.entete .titre-page { font-size: 1.15rem; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entete .espace { flex: 1; }
.recherche-rapide {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--bord); border-radius: 999px;
  padding: 0 14px; height: 44px; width: min(320px, 38vw);
  box-shadow: var(--ombre-1);
}
.recherche-rapide input { border: 0; background: none; outline: none; width: 100%; height: 100%; }
.recherche-rapide .icone { color: var(--texte-3); }
.profil {
  display: flex; align-items: center; gap: 10px;
  background: none; border: 0; padding: 4px; cursor: pointer; border-radius: 999px;
}
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800;
  background: linear-gradient(135deg, var(--marque-500), var(--marque-800)); color: #fff;
}
.profil .qui { text-align: start; line-height: 1.25; }
.profil .qui small { display: block; color: var(--texte-3); font-size: .8rem; }

.rail {
  grid-area: rail;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 10px;
  background: var(--marque-800);
  background: linear-gradient(180deg, var(--marque-700), var(--marque-900));
  color: #e3edf7;
}
.rail .logo { display: block; width: 76px; height: auto; margin-block-end: 18px; padding: 7px 6px; background: #fff; border-radius: 14px; box-shadow: 0 2px 8px rgb(0 0 0 / 18%); }
.rail a {
  width: 72px; padding: 10px 4px 8px; border-radius: 16px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: inherit; text-decoration: none; font-size: .78rem; font-weight: 600; text-align: center;
  transition: background .15s;
}
.rail a:hover { background: rgb(255 255 255 / 8%); }
.rail a[aria-current="page"] { background: rgb(255 255 255 / 16%); color: #fff; }
.rail a .icone { width: 24px; height: 24px; }
.rail .bas { margin-block-start: auto; }

.onglets { display: none; }

.contenu { grid-area: contenu; min-width: 0; }
.page { max-width: var(--contenu-max); margin: 0 auto; padding: 28px 28px 120px; }
.page.etroite { max-width: 980px; }

@media (max-width: 899px) {
  .app.coquille { grid-template-columns: 1fr; grid-template-areas: "entete" "contenu"; }
  .rail { display: none; }
  .onglets {
    display: grid; grid-template-columns: repeat(var(--nb, 4), 1fr);
    position: fixed; inset-inline: 0; bottom: 0; z-index: 30;
    height: calc(var(--onglets) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-block-start: 1px solid var(--bord);
  }
  .onglets a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--texte-3); text-decoration: none; font-size: .75rem; font-weight: 650;
  }
  .onglets a[aria-current="page"] { color: var(--accent); }
  .onglets a.nouveau .icone { background: var(--vert-600); color: #fff; border-radius: 12px; padding: 6px; width: 36px; height: 36px; }
  .entete { padding: 0 16px; }
  .recherche-rapide { display: none; }
  .profil .qui { display: none; }
  .page { padding: 20px 16px calc(var(--onglets) + 120px); }
}

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px;
  border-radius: 12px; border: 1px solid transparent;
  font-weight: 700; font-size: 1rem; cursor: pointer; text-decoration: none;
  transition: transform .06s, background .15s, box-shadow .15s, border-color .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.principal { background: var(--marque-600); color: var(--sur-marque); box-shadow: 0 2px 0 var(--marque-800); }
.btn.principal:hover { background: var(--marque-700); }
.btn.secondaire { background: var(--surface); color: var(--texte); border-color: var(--bord-fort); }
.btn.secondaire:hover { border-color: var(--accent); color: var(--accent); }
.btn.fantome { background: transparent; color: var(--accent); }
.btn.fantome:hover { background: var(--accent-fond); }
.btn.danger { background: var(--danger-fond); color: var(--danger); }
.btn.petit { min-height: 40px; padding: 0 14px; font-size: .92rem; border-radius: 10px; }
.btn.icone-seule { padding: 0; width: 48px; }
.btn.large { width: 100%; }

/* ---------- Cartes ---------- */
.carte {
  background: var(--surface); border: 1px solid var(--bord); border-radius: var(--r-l);
  box-shadow: var(--ombre-1); padding: 24px;
}
.carte + .carte { margin-block-start: 16px; }
.carte .entete-carte { display: flex; align-items: center; gap: 12px; margin-block-end: 18px; }
.carte .entete-carte .espace { flex: 1; }
.pastille-icone {
  width: 44px; height: 44px; border-radius: 14px; flex: none;
  display: grid; place-items: center; background: var(--accent-fond); color: var(--accent);
}

/* ---------- Accueil ---------- */
.salutation { margin-block-end: 22px; display: flex; align-items: center; gap: 20px; }
.salutation .textes { flex: 1; }
.salutation .logo-salutation { height: 84px; width: auto; border-radius: 12px; }
@media (max-width: 899px) { .salutation .logo-salutation { display: none; } }
.salutation h1 { font-size: 1.75rem; }
.salutation p { color: var(--texte-2); margin-block-start: 4px; }
.actions-rapides { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-block-end: 24px; }
.action-rapide {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 14px;
  min-height: 150px; padding: 22px; border-radius: var(--r-l);
  color: #fff; text-decoration: none; border: 0; cursor: pointer; text-align: start;
  background: linear-gradient(140deg, var(--marque-500), var(--marque-800));
  box-shadow: var(--ombre-2);
  transition: transform .15s, box-shadow .15s;
}
.action-rapide:hover { transform: translateY(-2px); }
.action-rapide.ec { background: linear-gradient(140deg, var(--vert-600), var(--vert-800)); }
.action-rapide.visite { background: linear-gradient(140deg, #237d8b, #19535f); }
.action-rapide .icone { width: 34px; height: 34px; background: rgb(255 255 255 / 18%); border-radius: 12px; padding: 6px; }
.action-rapide strong { font-size: 1.2rem; }
.action-rapide span { opacity: .85; font-size: .92rem; }
.action-rapide::after {
  content: ""; position: absolute; inset-inline-start: -30px; bottom: -40px;
  width: 140px; height: 140px; border-radius: 50%; background: rgb(255 255 255 / 9%);
}
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-block-end: 24px; }
.kpi { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--r-l); padding: 18px 20px; box-shadow: var(--ombre-1); }
.kpi .valeur { font-size: 2rem; font-weight: 800; line-height: 1.1; }
.kpi .libelle { color: var(--texte-2); font-size: .92rem; display: flex; align-items: center; gap: 8px; }
.kpi .point { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.kpi.attention .point { background: var(--attention); }
.kpi.succes .point { background: var(--succes); }
.kpi.info .point { background: var(--info); }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 899px) { .actions-rapides { grid-template-columns: 1fr; } .action-rapide { min-height: 0; flex-direction: row; align-items: center; } .action-rapide span { display: none; } }

/* ---------- Nouveau dossier : choix du type ---------- */
.choix-type { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.choix-type .action-rapide { min-height: 240px; flex-direction: column; align-items: flex-start; padding: 28px; gap: 10px; }
.choix-type .action-rapide .icone { width: 52px; height: 52px; padding: 10px; border-radius: 14px; margin-block-end: 6px; }
.choix-type .action-rapide strong { font-size: 1.55rem; }
.choix-type .action-rapide .nom-form { opacity: .8; font-size: .95rem; }
.choix-type .action-rapide span { display: block; line-height: 1.8; }
.choix-type .badge-brouillon { font-style: normal; font-weight: 700; font-size: .85rem; background: rgb(255 255 255 / 22%); padding: 3px 12px; border-radius: 999px; }
.lien-visite { margin-block-start: 22px; }
.changer-type { display: inline-flex; align-items: center; gap: 4px; font-size: .88rem; font-weight: 700; color: var(--accent); text-decoration: none; }
.etapes .changer-type { margin-block-start: 6px; }
.type-mobile { display: none; }
@media (max-width: 1099px) { .type-mobile { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-block: 14px 4px; } }
@media (max-width: 699px) { .choix-type { grid-template-columns: 1fr; } .choix-type .action-rapide { min-height: 0; padding: 22px; } }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 12px; border-radius: 999px; font-size: .85rem; font-weight: 700; white-space: nowrap;
  background: var(--surface-3); color: var(--texte-2);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.EN_COURS { background: var(--info-fond); color: var(--info); }
.badge.EN_ATTENTE { background: var(--attention-fond); color: var(--attention); }
.badge.CLOTURE { background: var(--succes-fond); color: var(--succes); }
.badge.type::before { display: none; }
.badge.type.ECOUTE { background: var(--marque-100); color: var(--marque-700); }
.badge.type.ETATCIVIL { background: var(--vert-100); color: var(--vert-800); }
:root[data-theme="dark"] .badge.type.ETATCIVIL { background: #173326; color: #8fd1a6; }
:root[data-theme="dark"] .badge.type.ECOUTE { background: #17324d; color: #9cc4ee; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge.type.ETATCIVIL { background: #173326; color: #8fd1a6; } :root:not([data-theme="light"]) .badge.type.ECOUTE { background: #17324d; color: #9cc4ee; } }

/* ---------- Liste des dossiers ---------- */
.barre-filtres { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-block-end: 18px; }
.champ-recherche {
  flex: 1 1 260px; display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--bord-fort); border-radius: 14px;
  padding: 0 16px; min-height: 52px;
}
.champ-recherche input { border: 0; outline: none; background: none; width: 100%; height: 50px; font-size: 1.05rem; }
.champ-recherche:focus-within { border-color: var(--accent); box-shadow: var(--anneau); }
.groupe-filtres { display: flex; flex-wrap: wrap; gap: 8px; }
.lignes { display: flex; flex-direction: column; gap: 10px; }
.ligne-dossier {
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 16px;
  background: var(--surface); border: 1px solid var(--bord); border-radius: var(--r);
  padding: 14px 18px; text-decoration: none; color: inherit; box-shadow: var(--ombre-1);
  transition: border-color .15s, transform .1s;
}
.ligne-dossier:hover { border-color: var(--marque-200); transform: translateY(-1px); }
.ligne-dossier .numero { font-size: 1.15rem; font-weight: 800; }
.ligne-dossier .meta { color: var(--texte-2); font-size: .9rem; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.ligne-dossier .meta span { display: inline-flex; align-items: center; gap: 6px; }
.ligne-dossier .chevron { color: var(--texte-3); }
@media (max-width: 640px) {
  .ligne-dossier { grid-template-columns: auto 1fr auto; }
  .ligne-dossier .chevron { display: none; }
}
.vide {
  text-align: center; padding: 48px 20px; color: var(--texte-2);
  border: 2px dashed var(--bord); border-radius: var(--r-l); background: var(--surface-2);
}
.vide .icone { width: 40px; height: 40px; color: var(--texte-3); margin-block-end: 8px; }

/* ---------- Puces (choix) ---------- */
.puces { display: flex; flex-wrap: wrap; gap: 10px; }
.puce {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 46px; padding: 6px 16px;
  border-radius: 999px; border: 1.5px solid var(--bord-fort);
  background: var(--surface); color: var(--texte);
  font-weight: 600; font-size: .98rem; cursor: pointer; text-align: start; line-height: 1.35;
  transition: background .12s, border-color .12s, color .12s;
  user-select: none;
}
.puce:hover { border-color: var(--accent); }
.puce[aria-pressed="true"], .puce[aria-checked="true"] {
  background: var(--puce-active); border-color: var(--puce-active); color: #fff;
}
.puce .coche { display: none; }
.puce[aria-pressed="true"] .coche, .puce[aria-checked="true"] .coche { display: inline; }
.puce.filtre { min-height: 40px; padding: 4px 14px; font-size: .92rem; }
.sous-groupe { margin-block: 14px 8px; color: var(--texte-2); font-weight: 700; font-size: .92rem; display: flex; align-items: center; gap: 10px; }
.sous-groupe::after { content: ""; flex: 1; height: 1px; background: var(--bord); }

/* Interrupteur segmenté (oui / non, options) */
.segments {
  display: inline-flex; padding: 4px; gap: 4px;
  background: var(--surface-3); border-radius: 14px; border: 1px solid var(--bord);
}
.segments button {
  min-height: 44px; min-width: 76px; padding: 0 16px;
  border: 0; border-radius: 11px; background: transparent; cursor: pointer; font-weight: 700; color: var(--texte-2);
}
.segments button[aria-checked="true"] { background: var(--surface); color: var(--accent); box-shadow: var(--ombre-1); }
.segments button[aria-checked="true"].oui { color: var(--succes); }
.segments button[aria-checked="true"].non { color: var(--danger); }

/* Compteur ( − n + ) */
.compteur { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-3); border-radius: 14px; padding: 4px; border: 1px solid var(--bord); }
.compteur button { width: 44px; height: 44px; border-radius: 11px; border: 0; background: var(--surface); font-size: 1.4rem; font-weight: 700; cursor: pointer; box-shadow: var(--ombre-1); }
.compteur input { width: 64px; height: 44px; text-align: center; border: 0; background: none; font-size: 1.15rem; font-weight: 800; -moz-appearance: textfield; }
.compteur input::-webkit-outer-spin-button, .compteur input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Champs texte et date */
.saisie {
  width: 100%; min-height: 50px; padding: 0 16px;
  border-radius: 12px; border: 1.5px solid var(--bord-fort); background: var(--surface);
  font-size: 1.02rem;
}
.saisie:focus { outline: none; border-color: var(--accent); box-shadow: var(--anneau); }
.saisie.chiffres { text-align: start; }
textarea.saisie { padding: 12px 16px; min-height: 96px; resize: vertical; }

/* ---------- Formulaire ---------- */
.editeur { display: grid; grid-template-columns: 280px 1fr; gap: 24px; align-items: start; }
.etapes {
  position: sticky; top: calc(var(--entete) + 16px);
  background: var(--surface); border: 1px solid var(--bord); border-radius: var(--r-l);
  padding: 14px; box-shadow: var(--ombre-1);
}
.liste-etapes { display: block; }
.etapes .titre-form { padding: 6px 10px 12px; border-block-end: 1px solid var(--bord); margin-block-end: 8px; }
.etapes .titre-form small { display: block; color: var(--texte-3); }
.etape {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 10px; border-radius: 12px; border: 0; background: none; cursor: pointer; text-align: start;
  color: var(--texte-2); font-weight: 650;
}
.etape:hover { background: var(--surface-3); }
.etape[aria-current="step"] { background: var(--accent-fond); color: var(--accent); }
.etape .num {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-size: .85rem; font-weight: 800;
  border: 2px solid var(--bord-fort); color: var(--texte-3); background: var(--surface);
}
.etape.rempli .num { background: var(--succes); border-color: var(--succes); color: #fff; }
.etape.erreur .num { background: var(--danger); border-color: var(--danger); color: #fff; }
.etape[aria-current="step"] .num { border-color: var(--accent); color: var(--accent); }
.etape .compte { margin-inline-start: auto; font-size: .8rem; color: var(--texte-3); font-weight: 600; }
.progression { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; margin: 10px; }
.progression > i { display: block; height: 100%; background: linear-gradient(90deg, var(--vert-400), var(--vert-500) 35%, var(--marque-600)); border-radius: 6px; transition: width .3s; }

.section-form .entete-section { display: flex; align-items: center; gap: 14px; margin-block-end: 22px; }
.section-form .entete-section p { color: var(--texte-2); font-size: .92rem; }
.grille-champs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 24px; }
.champ { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.champ.plein { grid-column: 1 / -1; }
.champ[hidden] { display: none; }
.champ .tete { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.champ label.etiquette, .champ .etiquette { font-weight: 750; font-size: 1.02rem; }
.marque-requis { color: var(--danger); font-weight: 800; }
.marque-important { font-size: .75rem; font-weight: 700; color: var(--attention); background: var(--attention-fond); padding: 1px 8px; border-radius: 999px; }
.champ .effacer { margin-inline-start: auto; border: 0; background: none; color: var(--texte-3); cursor: pointer; font-size: .85rem; padding: 4px 8px; border-radius: 8px; }
.champ .effacer:hover { color: var(--danger); background: var(--danger-fond); }
.champ .aide { color: var(--texte-3); font-size: .88rem; display: flex; align-items: center; gap: 6px; }
.champ .message-erreur { color: var(--danger); font-size: .9rem; font-weight: 650; display: flex; align-items: center; gap: 6px; }
.champ.invalide .saisie { border-color: var(--danger); }
.champ .etat-numero { font-size: .9rem; font-weight: 650; display: flex; align-items: center; gap: 6px; }
.champ .etat-numero.libre { color: var(--succes); }
.champ .etat-numero.pris { color: var(--danger); }
.precision { margin-block-start: 6px; }
@media (max-width: 1099px) {
  .editeur { grid-template-columns: 1fr; }
  .etapes {
    position: sticky; top: var(--entete); z-index: 10;
    display: flex; gap: 6px; overflow-x: auto; padding: 8px; border-radius: 0 0 var(--r) var(--r);
    margin: -20px -16px 0; border-inline: 0; border-block-start: 0;
    scrollbar-width: none;
  }
  .etapes::-webkit-scrollbar { display: none; }
  .etapes .titre-form, .etapes .progression { display: none; }
  .liste-etapes { display: flex; gap: 6px; }
  .etape { width: auto; flex: none; padding: 8px 12px; white-space: nowrap; }
  .etape .compte { display: none; }
}
@media (max-width: 720px) { .grille-champs { grid-template-columns: 1fr; } }

/* Listes répétées (auteurs, enfants) */
.element-liste { border: 1.5px dashed var(--bord-fort); border-radius: var(--r); padding: 18px; background: var(--surface-2); }
.element-liste + .element-liste { margin-block-start: 14px; }
.element-liste .tete-element { display: flex; align-items: center; gap: 10px; margin-block-end: 16px; }
.element-liste .tete-element h4 { flex: 1; }

/* Barre d'actions collante */
.barre-actions {
  position: sticky; bottom: 16px; z-index: 15;
  margin-block-start: 22px;
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--bord); box-shadow: var(--ombre-2);
}
.barre-actions .espace { flex: 1; }
.barre-actions .etat { color: var(--texte-3); font-size: .9rem; }
@media (max-width: 899px) { .barre-actions { bottom: calc(var(--onglets) + 12px); } }

/* Revue avant enregistrement */
.revue-section { border-block-end: 1px solid var(--bord); padding-block: 14px; }
.revue-section:last-child { border-block-end: 0; }
.revue-section h3 { display: flex; align-items: center; gap: 10px; margin-block-end: 10px; }
.paires { display: grid; grid-template-columns: minmax(160px, 32%) 1fr; gap: 8px 18px; }
.paires dt { color: var(--texte-2); font-size: .95rem; }
.paires dd { margin: 0; font-weight: 650; display: flex; flex-wrap: wrap; gap: 6px; }
.valeur-puce { background: var(--accent-fond); color: var(--accent); border-radius: 999px; padding: 1px 12px; font-size: .92rem; font-weight: 700; }
@media (max-width: 640px) { .paires { grid-template-columns: 1fr; } .paires dd { margin-block-end: 8px; } }
.alerte {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-radius: var(--r); margin-block-end: 16px;
  background: var(--info-fond); color: var(--info);
}
.alerte.attention { background: var(--attention-fond); color: var(--attention); }
.alerte.danger { background: var(--danger-fond); color: var(--danger); }
.alerte.succes { background: var(--succes-fond); color: var(--succes); }
.alerte .corps { color: var(--texte); }
.alerte ul { margin: 6px 0 0; padding-inline-start: 18px; }
.alerte button.lien { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font-weight: 700; text-decoration: underline; }

/* ---------- Dossier ---------- */
.entete-dossier { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.entete-dossier .numero-grand { font-size: 1.9rem; font-weight: 850; }
.entete-dossier .espace { flex: 1; }
.meta-dossier { display: flex; flex-wrap: wrap; gap: 6px 22px; color: var(--texte-2); margin-block-start: 8px; font-size: .95rem; }
.meta-dossier span { display: inline-flex; align-items: center; gap: 6px; }
.disposition-dossier { display: grid; grid-template-columns: 1fr 360px; gap: 20px; align-items: start; margin-block-start: 20px; }
@media (max-width: 1099px) { .disposition-dossier { grid-template-columns: 1fr; } }
.chronologie { list-style: none; margin: 0; padding: 0; position: relative; }
.chronologie li { position: relative; padding-inline-start: 30px; padding-block-end: 18px; }
.chronologie li::before { content: ""; position: absolute; inset-inline-start: 7px; top: 8px; bottom: -8px; width: 2px; background: var(--bord); }
.chronologie li:last-child::before { display: none; }
.chronologie li::after { content: ""; position: absolute; inset-inline-start: 1px; top: 6px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--marque-500); }
.chronologie .date { font-weight: 800; }
.chronologie .par { color: var(--texte-3); font-size: .88rem; }
.chronologie .services { display: flex; flex-wrap: wrap; gap: 6px; margin-block-start: 8px; }
.chronologie .note { margin-block-start: 6px; color: var(--texte-2); font-size: .95rem; background: var(--surface-2); border-radius: 10px; padding: 8px 12px; }

/* ---------- Dialogue ---------- */
dialog {
  border: 0; border-radius: var(--r-l); padding: 0; max-width: min(720px, calc(100vw - 32px)); width: 100%;
  background: var(--surface); color: var(--texte); box-shadow: var(--ombre-2);
}
dialog::backdrop { background: rgb(10 22 34 / 45%); backdrop-filter: blur(3px); }
dialog .corps-dialogue { padding: 24px; max-height: 70vh; overflow: auto; }
dialog .pied-dialogue { display: flex; gap: 12px; justify-content: flex-end; padding: 16px 24px; border-block-start: 1px solid var(--bord); background: var(--surface-2); }
dialog h2 { margin-block-end: 6px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 100; inset-inline: 0; bottom: 24px; display: grid; justify-items: center; gap: 10px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: 14px; box-shadow: var(--ombre-2);
  background: var(--texte); color: var(--fond); font-weight: 650;
  animation: monter .25s ease-out;
}
.toast.succes .icone { color: #6ee7a8; }
.toast.erreur { background: var(--danger); color: #fff; }
@keyframes monter { from { transform: translateY(16px); opacity: 0; } }
@media (max-width: 899px) { .toasts { bottom: calc(var(--onglets) + 20px); } }

/* ---------- Squelettes ---------- */
.squelette { border-radius: var(--r); background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: chatoiement 1.2s linear infinite; }
@keyframes chatoiement { to { background-position: -200% 0; } }

/* ---------- Écrans d'accès ---------- */
.ecran-acces { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 80% -10%, var(--marque-100), transparent), var(--fond); }
.ecran-acces .carte { max-width: 520px; text-align: center; padding: 40px 32px; }
.ecran-acces img { margin-block-end: 18px; }
.ecran-acces h1 { margin-block-end: 10px; }
.ecran-acces p { color: var(--texte-2); margin-block-end: 24px; }

.bandeau-demo {
  flex: none; background: var(--vert-400); color: #12301b; font-weight: 800; font-size: .8rem;
  padding: 2px 12px; border-radius: 999px;
}

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.sprite { display: none; }

/* ---------- Statistiques ---------- */
.filtres-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 22px; margin-block-end: 18px; }
.filtres-stats label, .filtres-stats .filtre-type > span { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--texte-2); }
.filtres-stats .filtre-type { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filtres-stats select.saisie { width: auto; min-width: 140px; }
.contenu-stats { transition: opacity .2s; }
.contenu-stats.charge { opacity: .55; pointer-events: none; }
.kpi .sous { color: var(--texte-3); font-size: .85rem; margin-block-start: 2px; }
.grille-graph { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.carte-graph.large { grid-column: 1 / -1; }
.carte-graph .entete-carte { align-items: flex-start; }
.carte-graph .titres p { margin: 2px 0 0; }
.carte-graph .bascule-tableau { flex: none; }
.corps-graph { margin-block-start: 6px; }
.note-stats { display: flex; align-items: center; gap: 6px; margin-block-start: 18px; }
@media (max-width: 999px) { .grille-graph { grid-template-columns: 1fr; } }

.graph-vide { color: var(--texte-3); padding: 18px 4px; margin: 0; }
.barres { display: flex; flex-direction: column; gap: 2px; }
.barre-ligne {
  display: grid; grid-template-columns: minmax(96px, 38%) minmax(0, 1fr) 3.4em; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 10px; cursor: default; outline-offset: 2px;
}
.barre-ligne:hover, .barre-ligne:focus-visible { background: var(--surface-2); }
.barre-ligne .lib { font-size: .92rem; line-height: 1.35; color: var(--texte); }
.barre-ligne .val { font-weight: 800; color: var(--texte); font-variant-numeric: tabular-nums; }
.piste { display: block; height: 18px; }
.barre { display: block; height: 100%; border-start-end-radius: 4px; border-end-end-radius: 4px; transition: filter .15s; }
.barre-ligne:hover .barre, .barre-ligne:focus-visible .barre { filter: brightness(1.1); }
.barre.ecoute, .segment.ecoute, .cle.ecoute { background: var(--serie-ecoute); }
.barre.ec, .segment.ec, .cle.ec { background: var(--serie-ec); }
.barre.visite, .segment.visite, .cle.visite { background: var(--serie-visite); }
.barre.manquant { background: var(--serie-vide); }

.graph-colonnes { container-type: inline-size; }
.graph-colonnes .legende { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-block-end: 10px; font-size: .88rem; color: var(--texte-2); }
.legende span { display: inline-flex; align-items: center; gap: 6px; }
.cle { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex: none; }
.colonnes-zone { position: relative; height: 230px; }
.grille { position: absolute; inset: 0 0 28px 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.graduation { position: relative; height: 0; border-block-start: 1px solid var(--bord); }
.graduation span { position: absolute; inset-inline-start: 0; top: -10px; font-size: .74rem; color: var(--texte-3); background: var(--surface); padding-inline-end: 4px; line-height: 1.2; }
.colonnes { position: absolute; inset: 0; margin-inline-start: 34px; display: flex; gap: 2px; }
.colonne { flex: 1; min-width: 0; display: flex; flex-direction: column; border-radius: 8px; outline-offset: 1px; cursor: default; }
.colonne:hover, .colonne:focus-visible { background: rgb(127 140 155 / 9%); }
.colonne-corps { position: relative; flex: 1; }
.pile { position: absolute; inset-block: 0; inset-inline: 0; margin-inline: auto; width: min(20px, 70%); display: flex; flex-direction: column-reverse; gap: 2px; }
.segment { display: block; width: 100%; flex: none; }
.pile .segment:last-child { border-start-start-radius: 4px; border-start-end-radius: 4px; }
.cap { position: absolute; inset-inline: 0; text-align: center; margin-block-end: 3px; font-size: .78rem; font-weight: 800; color: var(--texte); }
.colonne .mois { height: 28px; padding-block-start: 6px; text-align: center; font-size: .74rem; color: var(--texte-3); white-space: nowrap; overflow: hidden; }
.mois .court { display: none; }
@container (max-width: 620px) { .mois .long { display: none; } .mois .court { display: inline; } }

.infobulle {
  position: fixed; z-index: 100; pointer-events: none; max-width: 280px;
  display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; border-radius: 10px;
  background: var(--texte); color: var(--surface); box-shadow: var(--ombre-2); font-size: .88rem; line-height: 1.45;
}
.infobulle[hidden] { display: none; }
.infobulle strong { font-size: 1.05rem; }
.infobulle small { opacity: .8; }
.infobulle .ligne-bulle { display: flex; align-items: center; gap: 8px; }
.infobulle .ligne-bulle b { margin-inline-start: auto; }
.infobulle .cle { width: 14px; height: 3px; border-radius: 2px; }

.tableau-graph { overflow-x: auto; }
.tableau-graph table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tableau-graph th, .tableau-graph td { padding: 7px 8px; border-block-end: 1px solid var(--bord); text-align: start; }
.tableau-graph thead th { color: var(--texte-2); font-weight: 700; font-size: .85rem; }
.tableau-graph td { font-variant-numeric: tabular-nums; }

/* ---------- Remarques (texte libre) ---------- */
.texte-libre { margin: 0; white-space: pre-wrap; line-height: 1.8; color: var(--texte); background: var(--surface-2); border-radius: 12px; padding: 12px 14px; border-inline-start: 3px solid var(--accent); }
dd .texte-libre { width: 100%; }
.colonne-dossier { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.carte-remarques .entete-carte { margin-block-end: 10px; }
.aide-remarques { display: flex; align-items: center; gap: 6px; margin: 10px 0 0; font-size: .82rem; }

/* ---------- اسألي البيانات (questions libres) ---------- */
.carte-question { padding: 18px 20px; }
.formulaire-question .zone-question { min-height: 64px; font-size: 1.05rem; }
.pied-question { display: flex; align-items: center; gap: 10px; margin-block-start: 10px; }
.pied-question .espace { flex: 1; }
.aide-question { display: flex; align-items: center; gap: 6px; margin: 10px 0 0; font-size: .85rem; }
.exemples { margin-block-start: 14px; display: flex; flex-direction: column; gap: 8px; }
.exemples .puce { font-weight: 600; }
.fil-questions { display: flex; flex-direction: column; gap: 22px; margin-block-start: 22px; }
.echange { display: flex; flex-direction: column; gap: 10px; }
.echange .carte + .carte, .echange .carte { margin: 0; }
.bulle-question { display: flex; align-items: flex-start; gap: 10px; }
.bulle-question p { margin: 0; background: var(--accent-fond); color: var(--texte); border-radius: 16px; border-start-start-radius: 4px; padding: 10px 14px; font-weight: 650; max-width: 760px; }
.avatar-q { width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--surface-3); color: var(--texte-2); }
.pastille-icone.ia { background: var(--vert-100); color: var(--vert-700); }
.reponse-chiffre { padding: 6px 2px 4px; }
.reponse-chiffre .valeur { font-size: 2.6rem; font-weight: 850; line-height: 1.1; color: var(--texte); }
.reponse-chiffre .libelle { color: var(--texte-2); font-size: .95rem; }
.lien-dossier { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 700; text-decoration: none; }
.lien-dossier:hover { text-decoration: underline; }
.note-reponse { display: flex; align-items: center; gap: 6px; margin: 12px 0 0; font-size: .85rem; color: var(--texte-2); }
.note-reponse.attention { color: var(--attention); }
.meta-reponse { margin: 10px 0 0; font-size: .8rem; }
.sql-utilise { margin-block-start: 10px; border-block-start: 1px solid var(--bord); padding-block-start: 8px; }
.sql-utilise summary { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; color: var(--texte-2); font-size: .88rem; font-weight: 650; min-height: 40px; }
.sql-utilise pre { margin: 6px 0 0; padding: 12px 14px; background: var(--surface-2); border-radius: 12px; overflow-x: auto; font-size: .82rem; line-height: 1.6; white-space: pre-wrap; word-break: break-word; text-align: left; }
.reponse-precision .titres p { margin: 4px 0 0; font-weight: 650; }
.ligne-precision { display: flex; gap: 10px; }
.ligne-precision .saisie { flex: 1; }
.reponse-attente { display: flex; align-items: center; gap: 14px; color: var(--texte-2); }
.reponse-attente p { margin: 0; }
.points { display: inline-flex; gap: 5px; }
.points span { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); opacity: .3; animation: point-attente 1.2s infinite ease-in-out; }
.points span:nth-child(2) { animation-delay: .2s; }
.points span:nth-child(3) { animation-delay: .4s; }
@keyframes point-attente { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .points span { animation: none; opacity: .7; } }
@media (max-width: 640px) { .ligne-precision { flex-direction: column; } .reponse-chiffre .valeur { font-size: 2.1rem; } }
:root[data-theme="dark"] .pastille-icone.ia { background: #173326; color: #8fd1a6; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pastille-icone.ia { background: #173326; color: #8fd1a6; } }
@media (max-width: 640px) { .fil-questions .entete-carte .pastille-icone { display: none; } }
