:root {
  --fond: #ffffff;
  --surface: #f7f7f8;
  --surface-2: #ececec;
  --trait: #e5e5e5;
  --texte: #0d0d0d;
  --texte-2: #5d5d5d;
  --texte-3: #8f8f8f;
  --action: #0d0d0d;
  --sur-action: #ffffff;
  --rouge: #d4382c;
  --orange: #c77700;
  --vert: #10a37f;
  --rayon: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #212121;
    --surface: #2a2a2a;
    --surface-2: #383838;
    --trait: #3a3a3a;
    --texte: #ececec;
    --texte-2: #b4b4b4;
    --texte-3: #8a8a8a;
    --action: #ececec;
    --sur-action: #0d0d0d;
    --rouge: #f0715f;
    --orange: #f0a64a;
    --vert: #3ecf9e;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--fond); color: var(--texte); }
body {
  font: 15px/1.5 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
h2 { font-size: 17px; font-weight: 600; margin: 0 0 12px; letter-spacing: -0.01em; }
.petit { font-size: 13px; color: var(--texte-2); }
.discret { color: var(--texte-3); }
[hidden] { display: none !important; }

/* Mise en page */
.entete {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 4px;
  padding: 10px 20px; background: color-mix(in srgb, var(--fond) 88%, transparent);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--trait);
}
.marque { font-weight: 600; letter-spacing: -0.01em; margin-right: 16px; text-decoration: none; }
.nav a {
  text-decoration: none; color: var(--texte-2); padding: 6px 12px; border-radius: 999px; font-size: 14px;
}
.nav a:hover { color: var(--texte); background: var(--surface); }
.nav a.actif { color: var(--texte); background: var(--surface-2); }
.nav .pastille { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--rouge); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 600; }
.entete .droite { margin-left: auto; }
main { max-width: 980px; margin: 0 auto; padding: 36px 20px 80px; }
.titre { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.titre .outils { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* Boutons et champs */
.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--trait);
  background: var(--fond); cursor: pointer; font-size: 14px; font-weight: 500; white-space: nowrap; text-decoration: none;
}
.bouton:hover { background: var(--surface); }
.bouton.plein { background: var(--action); color: var(--sur-action); border-color: var(--action); }
.bouton.plein:hover { opacity: .86; }
.bouton.fantome { border-color: transparent; background: transparent; color: var(--texte-2); }
.bouton.fantome:hover { background: var(--surface); color: var(--texte); }
.bouton.danger { color: var(--rouge); }
.bouton.mini { height: 30px; padding: 0 12px; font-size: 13px; }
.bouton:disabled { opacity: .45; cursor: default; }
.champ {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--trait);
  background: var(--fond); outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea.champ { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.champ:focus { border-color: var(--texte-3); box-shadow: 0 0 0 3px color-mix(in srgb, var(--texte) 8%, transparent); }
.champ.rempli { border-color: var(--vert); }
.recherche { width: 240px; border-radius: 999px; background: var(--surface); border-color: transparent; }
label.l { display: block; font-size: 13px; color: var(--texte-2); margin-bottom: 4px; }
.grille { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 16px; }
.grille .large { grid-column: 1 / -1; }
@media (max-width: 640px) { .grille { grid-template-columns: 1fr; } .recherche { width: 100%; } }

.carte { background: var(--fond); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 20px; }
.carte + .carte { margin-top: 16px; }
.encart { background: var(--surface); border-radius: var(--rayon); padding: 16px; }

/* Liste */
.filtres { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.filtre { border: 0; background: transparent; padding: 5px 12px; border-radius: 999px; color: var(--texte-2); cursor: pointer; font-size: 14px; }
.filtre.actif { background: var(--surface-2); color: var(--texte); }
.liste { border-top: 1px solid var(--trait); }
.ligne {
  display: grid; grid-template-columns: minmax(180px, 1.1fr) minmax(300px, 2fr) minmax(150px, .9fr);
  gap: 16px; align-items: center; padding: 16px 8px; border-bottom: 1px solid var(--trait);
  text-decoration: none; border-radius: 0; transition: background .1s;
}
.ligne:hover { background: var(--surface); }
.ligne .nom { font-weight: 500; }
.ligne .sous { font-size: 13px; color: var(--texte-3); }
@media (max-width: 760px) { .ligne { grid-template-columns: 1fr; gap: 8px; } }
.vide { text-align: center; padding: 64px 0; color: var(--texte-3); }

/* Frise en bulles */
.frise { display: flex; align-items: flex-start; }
.frise .pas { flex: 1; display: flex; flex-direction: column; align-items: center; position: relative; min-width: 0; }
.frise .pas::before {
  content: ""; position: absolute; top: 6px; right: 50%; width: 100%; height: 2px; background: var(--trait);
}
.frise .pas:first-child::before { display: none; }
.frise .pas.fait::before, .frise .pas.courant::before { background: var(--texte); }
.bulle {
  position: relative; z-index: 1; width: 14px; height: 14px; border-radius: 50%;
  background: var(--fond); border: 2px solid var(--trait);
}
.pas.fait .bulle { background: var(--texte); border-color: var(--texte); }
.pas.courant .bulle { border-color: var(--texte); box-shadow: 0 0 0 4px color-mix(in srgb, var(--texte) 10%, transparent); }
.pas.retard .bulle { border-color: var(--rouge); box-shadow: 0 0 0 4px color-mix(in srgb, var(--rouge) 16%, transparent); }
.frise .lib { font-size: 11px; color: var(--texte-3); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pas.fait .lib, .pas.courant .lib { color: var(--texte-2); }
.pas.retard .lib { color: var(--rouge); }

/* Grande frise (fiche) */
.frise.grande .bulle { width: 26px; height: 26px; display: grid; place-items: center; font-size: 12px; cursor: pointer; transition: transform .1s; }
.frise.grande .bulle:hover { transform: scale(1.1); }
.frise.grande .pas::before { top: 12px; }
.frise.grande .pas.fait .bulle { color: var(--sur-action); }
.frise.grande .lib { font-size: 12px; margin-top: 8px; }
.frise.grande .date { font-size: 11px; color: var(--texte-3); height: 16px; }
.frise.grande .pas.selection .lib { color: var(--texte); font-weight: 600; }
@media (max-width: 640px) { .frise.grande .lib { font-size: 10px; } .frise.grande .date { font-size: 9px; } }

/* Échéances */
.puce { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 3px 10px; border-radius: 999px; background: var(--surface); color: var(--texte-2); white-space: nowrap; }
.puce::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--texte-3); }
.puce.retard { color: var(--rouge); background: color-mix(in srgb, var(--rouge) 10%, transparent); }
.puce.retard::before { background: var(--rouge); }
.puce.aujourdhui, .puce.bientot { color: var(--orange); background: color-mix(in srgb, var(--orange) 11%, transparent); }
.puce.aujourdhui::before, .puce.bientot::before { background: var(--orange); }
.puce.statut::before { display: none; }
.groupe { margin-bottom: 32px; }
.groupe h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--texte-3); font-weight: 600; }
.tache { display: flex; align-items: center; gap: 12px; padding: 12px 8px; border-bottom: 1px solid var(--trait); text-decoration: none; }
.tache:hover { background: var(--surface); }
.tache .q { width: 64px; font-size: 13px; color: var(--texte-3); flex-shrink: 0; }
.tache .quoi { flex: 1; min-width: 0; }

/* Fiche patiente */
.fiche { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
@media (max-width: 860px) { .fiche { grid-template-columns: 1fr; } }
.detail-etape { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--trait); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.coord { display: grid; gap: 10px; }
.coord .k { font-size: 12px; color: var(--texte-3); }
.coord a { text-decoration: none; }
.journal { list-style: none; margin: 0; padding: 0; }
.journal li { padding: 10px 0; border-bottom: 1px solid var(--trait); font-size: 14px; display: flex; gap: 10px; }
.journal li:last-child { border-bottom: 0; }
.journal .q { color: var(--texte-3); font-size: 12px; width: 78px; flex-shrink: 0; padding-top: 2px; }
.journal .x { margin-left: auto; opacity: 0; border: 0; background: none; cursor: pointer; color: var(--texte-3); }
.journal li:hover .x { opacity: 1; }
.rep { font-size: 13px; color: var(--texte-2); margin-top: 2px; white-space: pre-wrap; }

/* Coller */
.coller { width: 100%; display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: var(--rayon); border: 1px dashed var(--trait); background: transparent; cursor: pointer; text-align: left; }
.coller:hover { border-color: var(--texte-3); }

/* Fenêtre */
.voile { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 50; padding: 16px; animation: apparait .12s ease-out; }
.fenetre { background: var(--fond); border-radius: 20px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.fenetre .pied { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
@keyframes apparait { from { opacity: 0; } }
.choix { display: flex; gap: 6px; flex-wrap: wrap; }
.choix button { border: 1px solid var(--trait); background: var(--fond); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 14px; }
.choix button.on { background: var(--action); color: var(--sur-action); border-color: var(--action); }
.question { margin-bottom: 16px; }

/* Connexion */
.connexion { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.connexion form { width: min(340px, 100%); text-align: center; }
.connexion h1 { font-size: 24px; margin-bottom: 6px; }
.connexion .champ { text-align: center; letter-spacing: .3em; height: 48px; font-size: 18px; margin: 24px 0 12px; border-radius: 12px; }
.connexion .bouton { width: 100%; height: 44px; }
.erreur { color: var(--rouge); font-size: 13px; min-height: 20px; margin-top: 10px; }

/* Documents */
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.doc { display: block; text-decoration: none; padding: 18px; border-radius: var(--rayon); border: 1px solid var(--trait); }
.doc:hover { background: var(--surface); }
.doc .t { font-weight: 500; }
.lien { font-size: 13px; color: var(--texte-2); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--trait); }
.lien:hover { color: var(--texte); text-decoration-color: currentColor; }
.liens { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--action); color: var(--sur-action); padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 60; animation: apparait .15s; }

/* Éligibilité */
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--texte-3); font-weight: 600; margin: 22px 0 4px; }
.titre.serre { margin-bottom: 8px; }
.critere { display: flex; gap: 14px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--trait); font-size: 14px; }
.critere:last-of-type { border-bottom: 0; }
.critere .quoi { flex: 1; min-width: 0; }
.critere.bloquant .quoi > div:first-child { color: var(--rouge); font-weight: 500; }
.petitchoix { flex-shrink: 0; flex-wrap: nowrap; }
.petitchoix button { padding: 3px 11px; font-size: 13px; }
.ia { margin-top: 6px; font-size: 13px; color: var(--texte-2); background: var(--surface); border-radius: 10px; padding: 8px 10px; }
.ia-tag { font-weight: 600; }
.ia.inconnu .ia-tag { color: var(--texte-3); }
.retenir { border: 0; background: none; cursor: pointer; padding: 0; margin-left: 8px; }
.puce.ok { color: var(--vert); background: color-mix(in srgb, var(--vert) 12%, transparent); }
input[type=file] { font-size: 13px; color: var(--texte-2); }
