/* MyOrga : feuille de style unique. Clair par défaut, sombre si le système l'est. */
:root {
  --fond: #f4f5f8; --surface: #ffffff; --bord: #e2e5eb; --bord-fort: #cdd2db;
  --texte: #1b2230; --discret: #677080; --accent: #2f55d4; --accent-doux: #e8edfc;
  --vert: #1c9a57; --vert-doux: #e2f5ea; --ambre: #c27803; --ambre-doux: #fdf0d5;
  --bleu: #2f6fed; --bleu-doux: #e3ecff; --rouge: #cf3a3a; --rouge-doux: #fde7e7;
  --gris: #a0a8b4; --gris-doux: #eef0f4; --ombre: 0 1px 2px rgba(20, 30, 50, .06), 0 8px 24px rgba(20, 30, 50, .06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #11141a; --surface: #191e27; --bord: #272e3a; --bord-fort: #364050;
    --texte: #e5e8ee; --discret: #909aab; --accent: #86a2ff; --accent-doux: #212b47;
    --vert: #3fcb82; --vert-doux: #143224; --ambre: #eeb04c; --ambre-doux: #38290f;
    --bleu: #72a2ff; --bleu-doux: #1a2948; --rouge: #ff7070; --rouge-doux: #3b1a1a;
    --gris: #5d6675; --gris-doux: #222935; --ombre: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--texte);
  font: 14.5px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0; }
p { margin: 0 0 8px; }
code { background: var(--gris-doux); padding: 2px 6px; border-radius: 5px; font-size: 13px; }
.discret { color: var(--discret); }
.rouge { color: var(--rouge); }
.fort { font-weight: 600; }
.droite { text-align: right; }
.etiquette {
  display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 99px;
  background: var(--gris-doux); color: var(--discret); vertical-align: middle; letter-spacing: 0;
}

/* ---------- Structure ---------- */
.appli { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.menu {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
  padding: 18px 12px; background: var(--surface); border-right: 1px solid var(--bord);
}
.marque { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--texte); padding: 2px 8px 16px; }
.marque:hover { text-decoration: none; }
.menu nav { display: flex; flex-direction: column; gap: 1px; }
.menu nav a, .menu-bas a, .menu-bas .lien {
  display: block; padding: 7px 10px; border-radius: 8px; color: var(--texte); font-size: 14px;
}
.menu nav a:hover, .menu-bas a:hover, .menu-bas .lien:hover { background: var(--gris-doux); text-decoration: none; }
.menu nav a.actif { background: var(--accent-doux); color: var(--accent); font-weight: 600; }
.menu nav a.sous { font-size: 13.5px; padding: 5px 10px; color: var(--discret); }
.menu nav a.sous.actif { color: var(--accent); }
.menu nav a.discret { font-style: italic; }
.menu-titre { margin: 18px 10px 6px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--discret); }
.menu-bas { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--bord); }
.menu-bas a, .menu-bas .lien { color: var(--discret); font-size: 13.5px; }
.lien { background: none; border: 0; font: inherit; cursor: pointer; width: 100%; text-align: left; }
.contenu { padding: 26px 32px 60px; min-width: 0; }

.entete { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.entete p { margin: 4px 0 0; }
.fil { font-size: 13px; color: var(--discret); margin: 0 0 2px !important; }
.recherche input, .filtres input[type=search], .filtres select, .formulaire input, .formulaire select, .formulaire textarea,
.outils input, .outils select, .connexion input {
  font: inherit; color: var(--texte); background: var(--surface); border: 1px solid var(--bord-fort);
  border-radius: 8px; padding: 7px 10px; min-width: 0;
}
.recherche input { width: 260px; max-width: 100%; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

.bouton {
  display: inline-flex; align-items: center; justify-content: center; font: inherit; font-weight: 600; cursor: pointer;
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--bord-fort); background: var(--surface); color: var(--texte);
}
.bouton:hover { background: var(--gris-doux); text-decoration: none; }
.bouton.principal { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .bouton.principal { color: #10131a; } }
.bouton.principal:hover { filter: brightness(1.08); background: var(--accent); }
.bouton.petit { padding: 5px 11px; font-size: 13px; }
.boutons { display: flex; gap: 8px; flex-wrap: wrap; }

.messages { margin-bottom: 14px; }
.message { padding: 9px 14px; border-radius: 9px; background: var(--vert-doux); color: var(--vert); font-weight: 600; margin: 0 0 6px; }
.message.error { background: var(--rouge-doux); color: var(--rouge); }

.carte { background: var(--surface); border: 1px solid var(--bord); border-radius: 12px; padding: 18px 20px; margin-bottom: 16px; }
.carte.sans-marge { padding: 0; overflow: hidden; }
.carte-titre { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; font-size: 13.5px; }
.colonnes { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.pile { min-width: 0; }

/* ---------- Chiffres clés ---------- */
.chiffres { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.chiffres.trois { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 2.2fr); }
.chiffre {
  display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--bord);
  border-radius: 12px; padding: 14px 18px; color: var(--texte);
}
a.chiffre:hover { border-color: var(--bord-fort); text-decoration: none; }
.chiffre .nombre { font-size: 30px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.chiffre .legende { font-size: 13px; color: var(--discret); }
.chiffre.alerte { border-color: var(--rouge); background: var(--rouge-doux); }
.chiffre.alerte .nombre { color: var(--rouge); }
.chiffre.vigilance .nombre { color: var(--ambre); }
.prochaines { list-style: none; margin: 4px 0 0; padding: 0; font-size: 13.5px; }
.prochaines b { font-variant-numeric: tabular-nums; margin-right: 6px; }

/* ---------- Jauges ---------- */
.jauge { display: inline-block; width: 110px; height: 7px; border-radius: 99px; background: var(--gris-doux); overflow: hidden; vertical-align: middle; }
.jauge > span { display: block; height: 100%; background: var(--vert); border-radius: 99px; }
.jauge.grande { width: 180px; height: 9px; }
.bilan { display: flex; align-items: center; gap: 12px; font-size: 13.5px; }

/* ---------- Listes du tableau de bord ---------- */
.liste-suivis, .liste-dossiers { list-style: none; margin: 0; padding: 0; }
.liste-suivis a, .liste-dossiers a {
  display: flex; align-items: center; gap: 12px; padding: 7px 8px; margin: 0 -8px; border-radius: 8px; color: var(--texte);
}
.liste-suivis a:hover, .liste-dossiers a:hover { background: var(--gris-doux); text-decoration: none; }
.liste-suivis .nom, .liste-dossiers .nom { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.liste-dossiers .nom { flex: 0 0 auto; }
.liste-dossiers .reste { margin-left: auto; }
.liste-suivis .reste, .liste-dossiers .reste { font-size: 13px; color: var(--discret); white-space: nowrap; min-width: 92px; text-align: right; }

/* ---------- Échéances ---------- */
.echeance { display: flex; gap: 14px; padding: 12px 0; border-top: 1px solid var(--bord); }
.carte-titre + .echeance { border-top: 0; padding-top: 2px; }
.echeance-date {
  flex: 0 0 58px; height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 10px; background: var(--gris-doux); line-height: 1.1;
}
.echeance-date .jour { font-size: 20px; font-weight: 700; }
.echeance-date .mois { font-size: 11px; color: var(--discret); text-transform: lowercase; }
.echeance.retard .echeance-date { background: var(--rouge-doux); color: var(--rouge); }
.echeance.retard .echeance-date .mois { color: var(--rouge); }
.echeance.proche .echeance-date { background: var(--ambre-doux); color: var(--ambre); }
.echeance.proche .echeance-date .mois { color: var(--ambre); }
.echeance-corps { min-width: 0; flex: 1; }
.echeance-titre { font-weight: 600; margin-bottom: 4px; }
.delai { font-weight: 400; font-size: 12.5px; color: var(--discret); margin-left: 6px; white-space: nowrap; }
.echeance.retard .delai { color: var(--rouge); font-weight: 600; }
.note-bas { font-size: 13px; max-width: 720px; }

/* ---------- Tables simples ---------- */
.defilement { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--discret); padding: 10px 14px; border-bottom: 1px solid var(--bord); white-space: nowrap; }
.table th.droite { text-align: right; }
.table td { padding: 9px 14px; border-bottom: 1px solid var(--bord); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--gris-doux) 55%, transparent); }
.table .inactif td { color: var(--discret); }
.table .separateur td { background: var(--fond); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--discret); }
.table td.droite { white-space: nowrap; font-variant-numeric: tabular-nums; }
.col-avancement { min-width: 190px; }

.filtres { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filtres .compte { margin-left: 4px; font-size: 13px; }
.coche { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; }
.legende-etats { margin-left: auto; display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--discret); }
.legende-etats > span { display: inline-flex; align-items: center; gap: 5px; }

/* ---------- Pastilles d'état ---------- */
.pastille {
  flex: 0 0 auto; width: 17px; height: 17px; border-radius: 5px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; line-height: 1; border: 1.5px solid var(--gris); color: transparent;
}
.s-a_faire .pastille { background: transparent; }
.s-en_cours .pastille { border-color: var(--bleu); background: linear-gradient(90deg, var(--bleu) 50%, var(--bleu-doux) 50%); }
.s-attente .pastille { border-color: var(--ambre); background: var(--ambre); color: #fff; }
.s-attente .pastille::before { content: "II"; font-size: 9.5px; letter-spacing: 1px; margin-left: 1px; }
.s-fait .pastille { border-color: var(--vert); background: var(--vert); color: #fff; }
.s-fait .pastille::before { content: "✓"; }
.s-nc .pastille { border-color: transparent; background: transparent; color: var(--bord-fort); }
.editeur .s-nc .pastille, .legende-etats .s-nc .pastille, .mode-fiche.s-nc .pastille { background: var(--gris-doux); color: var(--gris); }
.s-nc .pastille::before { content: "–"; }
.s-vide .pastille { border: 1.5px dotted var(--bord-fort); }
@media (prefers-color-scheme: dark) { .s-attente .pastille, .s-fait .pastille { color: #10131a; } }
.case.retard .pastille { border-color: var(--rouge); box-shadow: 0 0 0 2px var(--rouge-doux), 0 0 0 3px var(--rouge); }

.case {
  font: inherit; color: var(--texte); cursor: pointer; border: 0; background: transparent; display: inline-flex;
  align-items: center; gap: 6px; border-radius: 7px; max-width: 100%;
}
.case-texte { font-size: 12px; color: var(--discret); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case.mode-grille { width: 100%; min-width: 32px; min-height: 30px; justify-content: center; padding: 2px 5px; border-radius: 0; }
.case.mode-grille:hover, .case.ouverte { background: var(--accent-doux); }
.case.mode-grille .case-texte { max-width: 120px; }
.case.mode-grille.s-texte .case-texte { color: var(--texte); }
.case.mode-fiche, .case.mode-echeance {
  padding: 5px 10px 5px 7px; border: 1px solid var(--bord); background: var(--surface); font-size: 13.5px;
}
.case.mode-fiche:hover, .case.mode-echeance:hover { border-color: var(--accent); }
.case.mode-fiche.s-nc { color: var(--discret); background: transparent; border-style: dashed; }
.case.mode-fiche.s-fait .case-nom { color: var(--discret); }
.case.mode-fiche.retard, .case.mode-echeance.retard { border-color: var(--rouge); }
.case.mode-fiche.s-texte .case-texte, .case.mode-fiche.s-vide .case-nom { color: var(--discret); }
.case.mode-fiche.s-texte .case-texte { color: var(--texte); font-size: 13px; }
.case.mode-fiche .case-texte { max-width: 260px; }
.cases-fiche { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Grille d'un suivi ---------- */
.grille-zone { max-height: calc(100vh - 215px); overflow: auto; }
.grille { border-collapse: separate; border-spacing: 0; font-size: 13.5px; min-width: 100%; }
.grille th, .grille td { border-bottom: 1px solid var(--bord); background: var(--surface); padding: 0; }
.grille thead th { position: sticky; top: 0; z-index: 3; font-size: 12px; font-weight: 600; color: var(--discret); padding: 8px 8px; white-space: nowrap; text-align: center; vertical-align: bottom; }
.grille thead tr.groupes th { color: var(--texte); font-weight: 700; padding: 7px 8px 5px; border-bottom: 0; height: 30px; }
.grille thead tr.groupes + tr.etapes th { top: 30px; }
.grille thead th small { display: block; font-weight: 400; color: var(--accent); font-size: 11px; }
.grille.dense thead tr.etapes th:not(.fixe):not(.col-commentaire) { padding: 6px 2px 8px; height: 108px; }
.grille.dense thead tr.etapes th:not(.fixe):not(.col-commentaire) span { writing-mode: vertical-rl; transform: rotate(180deg); }
.grille .fixe { position: sticky; left: 0; z-index: 2; text-align: left; padding: 0 10px 0 14px; white-space: nowrap; border-right: 1px solid var(--bord-fort); font-weight: 600; min-width: 150px; }
.grille thead .fixe { z-index: 4; text-align: left; }
.grille tbody .fixe { display: table-cell; }
.grille tbody .fixe a { color: var(--texte); }
.grille td { text-align: center; }
.grille .debut { border-left: 1px solid var(--bord-fort); }
.grille tbody tr:hover > * { background: color-mix(in srgb, var(--gris-doux) 60%, var(--surface)); }
.grille tfoot th, .grille tfoot td { position: sticky; bottom: 0; z-index: 2; padding: 7px 4px; font-size: 12px; font-weight: 700; border-top: 1px solid var(--bord-fort); border-bottom: 0; font-variant-numeric: tabular-nums; }
.grille tfoot .fixe { z-index: 3; color: var(--discret); padding-left: 14px; }
.grille td.vide { padding: 18px; text-align: left; }
.compteur {
  float: right; margin-left: 10px; min-width: 20px; padding: 0 6px; border-radius: 99px; text-align: center;
  font-size: 11.5px; font-weight: 700; background: var(--ambre-doux); color: var(--ambre); line-height: 19px; margin-top: 1px;
}
.compteur.zero { display: none; }
.col-commentaire { text-align: left !important; min-width: 220px; border-left: 1px solid var(--bord-fort); }
td.col-commentaire { padding: 0 4px !important; }
.commentaire {
  width: 100%; font: inherit; font-size: 13px; color: var(--texte); background: transparent; border: 1px solid transparent;
  border-radius: 6px; padding: 4px 8px;
}
.commentaire:hover { border-color: var(--bord); }
.commentaire:focus { border-color: var(--accent); background: var(--surface); outline: 0; }
.commentaire.enregistre { border-color: var(--vert); }
.suivi-dossier .commentaire { margin-top: 10px; border-color: var(--bord); }

/* ---------- Fiche dossier ---------- */
.identite dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px 20px; margin: 0; }
.identite dt { font-size: 12px; color: var(--discret); }
.identite dd { margin: 0; font-weight: 600; }
.note { margin: 14px 0 0; padding: 10px 14px; border-radius: 9px; background: var(--ambre-doux); font-size: 13.5px; }
.avancement { display: inline-flex; align-items: center; gap: 10px; }
.groupe-etapes { display: flex; gap: 10px; align-items: baseline; padding: 4px 0; }
.groupe-nom { flex: 0 0 104px; font-size: 12px; font-weight: 600; color: var(--discret); text-align: right; }
.repli > summary { cursor: pointer; font-weight: 600; }
.repli[open] > summary { margin-bottom: 12px; }
.repli-periodes { margin: -8px 0 16px; }
.repli-periodes.seul { margin-top: 0; }
.repli-periodes > summary { cursor: pointer; color: var(--discret); font-size: 13.5px; padding: 2px 4px; }
.repli-periodes[open] > summary { margin-bottom: 10px; }
.repli-periodes .carte { border-style: dashed; }

/* ---------- Périodes d'une obligation ---------- */
.periodes { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; font-size: 13.5px; }
.periodes a {
  padding: 3px 12px; border-radius: 99px; border: 1px solid var(--bord-fort); background: var(--surface);
  color: var(--texte); font-weight: 600; font-variant-numeric: tabular-nums;
}
.periodes a:hover { border-color: var(--accent); text-decoration: none; }
.periodes a.actif { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .periodes a.actif { color: #10131a; } }
.periodes a.passee { color: var(--discret); font-weight: 400; }
.periodes-cellule a { margin-right: 10px; font-variant-numeric: tabular-nums; }

/* ---------- Outils d'un suivi et formulaires ---------- */
.outils { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; margin-top: 16px; align-items: start; }
.outils .carte { margin: 0; padding: 12px 16px; }
.outils label, .formulaire label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--discret); }
.outils .dates { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px 12px; margin: 10px 0 12px; }
.outils .en-ligne { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.outils .en-ligne p { flex: 1 0 100%; font-size: 13px; }
.outils .archiver { align-self: center; }
.formulaire .champs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 18px; margin-bottom: 18px; }
.formulaire .champ.large { grid-column: 1 / -1; }
.formulaire .champ.coche { flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; }
.formulaire .champ.coche input { order: -1; width: 17px; height: 17px; }
.formulaire input, .formulaire select, .formulaire textarea { color: var(--texte); width: 100%; }
.formulaire .champ.coche input { width: 17px; }

/* ---------- Éditeur de case ---------- */
.editeur {
  position: absolute; z-index: 50; width: 244px; padding: 12px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--bord-fort); box-shadow: var(--ombre);
}
.editeur[hidden] { display: none; }
.editeur-titre { font-weight: 700; font-size: 13.5px; margin: 0 0 2px; }
.editeur-echeance { font-size: 12.5px; color: var(--discret); margin: 0 0 8px; }
.editeur-echeance:empty { display: none; }
.editeur-etats { display: flex; flex-direction: column; gap: 2px; margin: 8px 0; }
.editeur-etats button {
  display: flex; align-items: center; gap: 9px; font: inherit; color: var(--texte); background: transparent; border: 0;
  padding: 6px 8px; border-radius: 7px; cursor: pointer; text-align: left;
}
.editeur-etats button:hover { background: var(--gris-doux); }
.editeur-etats button.choisi { background: var(--accent-doux); font-weight: 600; }
.editeur.texte-seul .editeur-etats { display: none; }
.editeur-texte { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--discret); }
.editeur-texte input { font: inherit; color: var(--texte); background: var(--surface); border: 1px solid var(--bord-fort); border-radius: 7px; padding: 6px 9px; }
.editeur-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; }

/* ---------- Connexion ---------- */
.connexion { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.connexion-carte { width: 340px; max-width: 100%; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--ombre); }
.connexion-carte .marque { padding: 0; }
.connexion label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--discret); }

/* ---------- Petits écrans ---------- */
@media (max-width: 980px) {
  .colonnes { grid-template-columns: minmax(0, 1fr); }
  .chiffres, .chiffres.trois { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chiffres.trois .large { grid-column: 1 / -1; }
}
@media (max-width: 780px) {
  .appli { grid-template-columns: minmax(0, 1fr); }
  .menu { position: static; height: auto; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--bord); }
  .marque { padding-bottom: 8px; }
  .menu nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
  .menu nav a { white-space: nowrap; }
  .menu-titre { display: none; }
  .menu-bas { display: flex; gap: 4px; margin-top: 6px; padding-top: 6px; }
  .menu-bas .lien { width: auto; }
  .contenu { padding: 18px 16px 48px; }
  .grille-zone { max-height: none; }
  .grille .fixe { min-width: 112px; padding-left: 10px; }
  .groupe-etapes { flex-direction: column; gap: 4px; }
  .groupe-nom { flex: none; text-align: left; }
  .legende-etats { margin-left: 0; }
}
