/* ==========================================================================
   Qualistaff — feuille de styles (clair et sombre, mobile compris)
   ========================================================================== */
:root {
  --fond: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef2f5;
  --bord: #d7dee5;
  --texte: #16232e;
  --texte-doux: #5b6b7a;
  --accent: #0f766e;
  --accent-doux: #e3f1ef;
  --accent-2: #1d4ed8;
  --bon: #15803d;
  --mauvais: #b42318;
  --attention: #b45309;
  --rayon: 10px;
  --ombre: 0 1px 2px rgba(16, 35, 46, .06), 0 6px 18px rgba(16, 35, 46, .06);
}
html[data-theme="sombre"] {
  --fond: #10171d; --surface: #172029; --surface-2: #1e2933; --bord: #2c3a46;
  --texte: #e7eef4; --texte-doux: #9fb0be; --accent: #2dd4bf; --accent-doux: #14343a;
  --accent-2: #93b4ff; --bon: #4ade80; --mauvais: #fca5a5; --attention: #fbbf24;
  --ombre: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
/* L'attribut hidden doit toujours l'emporter sur les display: flex des blocs :
   sans cette règle, l'écran de connexion et la fenêtre modale recouvraient
   l'application et intercéptaient les clics. */
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--fond); color: var(--texte);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
a { color: var(--accent-2); }
.discret { color: var(--texte-doux); font-size: .82rem; }
.erreur { color: var(--mauvais); font-size: .9rem; margin: .4rem 0 0; }
.aide { color: var(--texte-doux); font-size: .82rem; margin-top: .8rem; }

/* ------------------------------------------------------------ connexion */
#ecran-connexion {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.2rem;
  background: linear-gradient(160deg, var(--accent-doux), var(--fond) 60%);
}
.carte-connexion {
  background: var(--surface); border: 1px solid var(--bord); border-radius: 14px;
  padding: 1.6rem; width: 100%; max-width: 380px; box-shadow: var(--ombre);
}
.carte-connexion h1 { display: flex; align-items: center; gap: .6rem; font-size: 1.35rem; }
.carte-connexion .sous-titre { margin: .1rem 0 1.2rem; color: var(--texte-doux); font-size: .88rem; }
.carte-connexion label { display: block; font-size: .85rem; margin: .7rem 0 .25rem; color: var(--texte-doux); }
.carte-connexion input {
  width: 100%; padding: .6rem .7rem; border: 1px solid var(--bord); border-radius: 8px;
  background: var(--surface); color: var(--texte); font-size: 1rem;
}
.logo {
  display: inline-flex; width: 34px; height: 34px; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; border-radius: 9px; font-weight: 700;
}

/* --------------------------------------------------------------- entête */
.entete {
  display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; justify-content: space-between;
  padding: .6rem 1rem; background: var(--surface); border-bottom: 1px solid var(--bord);
  position: sticky; top: 0; z-index: 20;
}
.entete-titre { display: flex; align-items: center; gap: .6rem; }
.entete-titre strong { font-size: 1.05rem; display: block; }
.sous-titre-entete { color: var(--texte-doux); font-size: .8rem; }
.entete-actions { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
select, input[type=text], input[type=password], input[type=date], input[type=number], textarea {
  padding: .42rem .5rem; border: 1px solid var(--bord); border-radius: 8px;
  background: var(--surface); color: var(--texte); font-size: .92rem; font-family: inherit;
}
.badge-compte { color: var(--texte-doux); font-size: .84rem; }
.bouton {
  border: 1px solid var(--bord); background: var(--surface); color: var(--texte);
  padding: .45rem .8rem; border-radius: 8px; cursor: pointer; font-size: .9rem;
}
.bouton:hover { border-color: var(--accent); }
.bouton.principal { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.bouton.principal:hover { filter: brightness(1.08); }
.bouton.discret-bouton { color: var(--texte-doux); }
.bouton.mini { padding: .2rem .5rem; font-size: .8rem; }

/* ------------------------------------------------- intercalaires de classeur
   Les onglets se présentent comme les intercalaires d'un classeur : des
   languettes arrondies, posées SOUS le bandeau supérieur ; celle qui est
   ouverte est surélevée et se confond avec le contenu. */
:root { --onglet-fond: #dde5ec; --onglet-fond-survol: #e9eff4; }
html[data-theme="sombre"] { --onglet-fond: #1f2b36; --onglet-fond-survol: #26333f; }
.onglets {
  display: flex; align-items: flex-end; gap: .25rem; overflow-x: auto;
  padding: .5rem 1rem 0; background: var(--fond); border-bottom: 1px solid var(--bord);
}
.onglets button {
  position: relative; margin-bottom: -1px;
  border: 1px solid var(--bord); border-bottom: 0; border-radius: 9px 9px 0 0;
  background: var(--onglet-fond); color: var(--texte-doux);
  padding: .5rem .95rem; cursor: pointer; font-size: .9rem; white-space: nowrap;
  transition: transform .12s ease, background .12s ease, color .12s ease;
}
.onglets button:hover { background: var(--onglet-fond-survol); }
.onglets button.actif {
  background: var(--surface); color: var(--accent); font-weight: 600;
  transform: translateY(-4px); z-index: 2;
  box-shadow: 0 -3px 8px rgba(16, 35, 46, .10);
}
.onglets button.actif::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: var(--surface);
}
.onglets button[hidden] { display: none; }

/* ------------------------------------------------- bandeau de périmètre */
.bandeau-perimetre {
  flex-basis: 100%; display: flex; flex-wrap: wrap; gap: .7rem 1.5rem; align-items: center;
  padding-top: .55rem; margin-top: .15rem; border-top: 1px solid var(--bord);
}
.bandeau-groupe { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.services-bandeau, .unites-bandeau {
  display: flex; gap: .35rem; flex-wrap: wrap; align-items: center;
}
.badge-service {
  border: 1px solid var(--bord); border-radius: 999px; padding: .18rem .62rem;
  font-size: .82rem; background: var(--surface-2); color: var(--texte-doux);
}
.badge-service.cliquable { cursor: pointer; }
.badge-service.cliquable:hover { border-color: var(--accent); }
.badge-service.actif {
  border-color: var(--accent); background: var(--accent-doux); color: var(--accent); font-weight: 600;
}
.unite-case {
  display: inline-flex; align-items: center; gap: .3rem; font-size: .84rem;
  background: var(--surface-2); border: 1px solid var(--bord); border-radius: 999px;
  padding: .15rem .55rem; cursor: pointer;
}
.unite-case input { margin: 0; }

main { padding: 1rem; max-width: 1500px; margin: 0 auto; }
.pied {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .8rem 1rem 2rem; color: var(--texte-doux); font-size: .78rem;
  max-width: 1500px; margin: 0 auto;
}

/* --------------------------------------------------------------- blocs */
.bloc {
  background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon);
  padding: 1rem; margin-bottom: 1rem; box-shadow: var(--ombre);
}
.bloc > header { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; flex-wrap: wrap; }
.bloc-sous-titre { color: var(--texte-doux); font-size: .85rem; margin: -.2rem 0 .8rem; }
.grille { display: grid; gap: 1rem; }
.grille-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grille-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grille-4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.rangee { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.espace-haut { margin-top: .8rem; }
.separateur { border: 0; border-top: 1px solid var(--bord); margin: 1rem 0; }

/* ---------------------------------------------------------- indicateurs */
.carte-kpi { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: .8rem; }
.carte-kpi h3 { font-size: .88rem; color: var(--texte-doux); font-weight: 500; min-height: 2.4em; }
.carte-kpi .valeur { font-size: 1.7rem; font-weight: 700; }
.carte-kpi .valeur small { font-size: .8rem; font-weight: 400; color: var(--texte-doux); }
.carte-kpi .etincelle { height: 46px; }
.evolution { font-size: .84rem; font-weight: 600; }
.ev-bon { color: var(--bon); }
.ev-mauvais { color: var(--mauvais); }
.ev-neutre { color: var(--texte-doux); }
.etat-degradation { border-left: 4px solid var(--mauvais); }
.etat-amelioration { border-left: 4px solid var(--bon); }
.etat-variation { border-left: 4px solid var(--attention); }

table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: .42rem .5rem; border-bottom: 1px solid var(--bord); vertical-align: top; }
th { color: var(--texte-doux); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .02em; }
tbody tr:hover { background: var(--surface-2); }
td.nombre { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr.cliquable { cursor: pointer; }

.liste-indicateurs { max-height: 70vh; overflow: auto; }
.liste-indicateurs .section-titre { font-size: .78rem; text-transform: uppercase; color: var(--texte-doux);
  letter-spacing: .04em; margin: .8rem 0 .3rem; }
.entree-indicateur {
  display: flex; justify-content: space-between; gap: .6rem; padding: .35rem .45rem;
  border-radius: 7px; cursor: pointer; font-size: .9rem;
}
.entree-indicateur:hover { background: var(--surface-2); }
.entree-indicateur.actif { background: var(--accent-doux); color: var(--accent); font-weight: 600; }
.entree-indicateur .type { color: var(--texte-doux); font-size: .78rem; }

/* ---- fiche de saisie : thématiques du classeur, champs alignés ---------- */
/* Chaque thématique (section A … F du classeur) forme un bloc teinté de sa
   couleur ; dans le bloc, une même grille place le libellé, la case de saisie
   (largeur fixe, donc alignée de ligne en ligne) et le commentaire. */
#champs-saisie { display: flex; flex-direction: column; gap: 1rem; max-width: 1240px; }
/* En-tête de la fiche : les unités de soins côte à côte (9 L | ORTHO G 13 B),
   chacune au-dessus de sa colonne de saisie — la disposition du classeur. */
.entete-unites { display: grid; grid-template-columns: var(--colonnes-saisie); gap: .45rem .6rem; align-items: end; padding: .2rem .8rem .1rem; }
.entete-unites .coin { color: var(--texte-doux); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; }
.entete-unites .nom-unite {
  grid-column: span 2; text-align: center; font-weight: 700; font-size: .88rem;
  padding-bottom: .15rem; border-bottom: 2px solid var(--accent);
}
.theme {
  --teinte: var(--accent-doux);
  background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon);
  overflow: hidden; box-shadow: var(--ombre);
}
.theme-titre {
  display: flex; align-items: center; gap: .5rem; margin: 0; padding: .5rem .8rem;
  font-size: .92rem; background: var(--teinte); color: #1c2530;
  border-bottom: 1px solid rgba(0, 0, 0, .12);
}
.theme-titre .code-theme { font-weight: 700; }
.theme-groupe {
  margin: .45rem .8rem 0; padding: .2rem .55rem; font-size: .86rem; font-weight: 600;
  border-left: 6px solid var(--accent); background: var(--surface-2);
  border-radius: 0 6px 6px 0; color: var(--texte);
}
.champ-saisie {
  display: grid; grid-template-columns: var(--colonnes-saisie, minmax(230px, 1.05fr) 118px minmax(170px, 1fr));
  gap: .45rem .6rem; align-items: center; padding: .32rem .8rem;
}
.champ-saisie + .champ-saisie { border-top: 1px dashed var(--bord); }
/* Les colonnes de la fiche multi-unités sont posées par la vue (style en
   ligne) ; sur petit écran, la fiche défile horizontalement plutôt que de
   tasser les deux unités. */
@media (max-width: 760px) {
  #champs-saisie { overflow-x: auto; }
  #champs-saisie .theme, #champs-saisie .entete-unites { min-width: 620px; }
}
.champ-saisie label { font-size: .9rem; }
.champ-saisie .nom-ind { display: block; }
.champ-saisie .aide-ind { color: var(--texte-doux); font-size: .76rem; display: block; }
.champ-saisie input, .champ-saisie textarea { width: 100%; min-width: 0; }
.champ-saisie .saisie-valeur { text-align: right; font-variant-numeric: tabular-nums; }
.champ-saisie .saisie-commentaire { font-size: .85rem; }
.nb-commentaires { margin-top: .25rem; }
.manquant { color: var(--texte-doux); font-style: italic; }
.groupe-repartition tr.total td { font-weight: 700; }

.pastille { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .4rem; }
.evolution-barre { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.evolution-barre > span { display: block; height: 100%; background: var(--accent); }

.frise { border-left: 2px solid var(--bord); margin-left: .5rem; padding-left: .8rem; }
.frise .item { margin-bottom: .8rem; }
.frise .item time { color: var(--texte-doux); font-size: .8rem; display: block; }
.frise .item .qui { font-weight: 600; font-size: .85rem; }
.frise .item .quoi { font-size: .9rem; }
.frise .item .commentaire { color: var(--texte-doux); font-size: .85rem; font-style: italic; }

#notifications { position: fixed; right: 1rem; bottom: 1rem; z-index: 60; display: flex; flex-direction: column; gap: .5rem; }
.notification {
  background: var(--texte); color: var(--fond); padding: .6rem .9rem; border-radius: 8px;
  font-size: .88rem; box-shadow: var(--ombre); max-width: 380px;
}
.notification.erreur { background: var(--mauvais); color: #fff; }
.notification.succes { background: var(--accent); color: #fff; }

#modale { position: fixed; inset: 0; background: rgba(8, 20, 28, .55); display: flex;
  align-items: center; justify-content: center; z-index: 70; padding: 1rem; }
.modale-boite { background: var(--surface); border-radius: 12px; padding: 1.2rem; max-width: 860px;
  width: 100%; max-height: 88vh; overflow: auto; position: relative; box-shadow: var(--ombre); }
.modale-boite .fermer { position: absolute; top: .5rem; right: .6rem; border: 0; background: transparent;
  font-size: 1.4rem; cursor: pointer; color: var(--texte-doux); }

.canvas-boite { position: relative; height: 340px; }
.canvas-boite.petit { height: 240px; }
.canvas-boite.grand { height: 420px; }

@media (max-width: 720px) {
  .entete { gap: .4rem; }
  .entete-actions { width: 100%; }
  .canvas-boite { height: 300px; }
  main { padding: .6rem; }
  .onglets { padding: .3rem .5rem 0; }
}

/* ==========================================================================
   Portail d'entrée, portail des services, administration élargie
   (évolution du 03/11/2026)
   ========================================================================== */
.voile-portail { display: none; }
.carte-portail { max-width: 640px; }
.service-carte {
  border: 1px solid var(--bord); border-radius: 10px; padding: .9rem 1rem;
  margin-bottom: .8rem; background: var(--surface);
}
.service-carte.courant { border-color: var(--accent); }
.service-carte h3 { margin: 0 0 .2rem; font-size: 1.02rem; }
.code-service { display: flex; gap: .5rem; align-items: center; margin-top: .5rem; flex-wrap: wrap; }
.champ-code {
  width: 6.5rem; letter-spacing: .35rem; text-align: center; font-size: 1.15rem;
  padding: .5rem .3rem; border: 1px solid var(--bord); border-radius: 8px;
  background: var(--surface); color: var(--texte);
}
.encart {
  border: 1px solid var(--bord); border-left: 4px solid var(--accent); border-radius: 8px;
  padding: .8rem 1rem; margin-top: 1rem; background: var(--surface);
}
.encart h3 { margin: 0 0 .3rem; font-size: 1rem; }
.encart.succes { border-left-color: #15803d; }
.message { font-size: .9rem; margin: .6rem 0; }
.message.erreur, .aide.erreur { color: var(--mauvais); }
details.secours { margin-top: 1.2rem; border-top: 1px solid var(--bord); padding-top: .7rem; }
details.secours summary { cursor: pointer; font-size: .85rem; color: var(--texte-doux); }
.formulaire-admin {
  border: 1px solid var(--bord); border-radius: 10px; padding: .8rem;
  margin: .6rem 0; background: var(--surface);
}
.champ-admin {
  display: flex; flex-direction: column; gap: .2rem; font-size: .8rem;
  color: var(--texte-doux); min-width: 9rem;
}
.champ-admin input, .champ-admin select {
  padding: .35rem .5rem; border: 1px solid var(--bord); border-radius: 6px;
  background: var(--surface); color: var(--texte); font-size: .9rem;
}
.mini-champ { width: 4.5rem; }
/* Pastille de choix de couleur des thématiques (administration). */
.champ-couleur {
  width: 3.2rem; height: 1.9rem; padding: 0; border: 1px solid var(--bord);
  border-radius: 6px; background: var(--surface); cursor: pointer;
}
.bouton.danger { color: var(--mauvais); border-color: var(--mauvais); }

/* ---------------------------------------- sous-menus d'administration (2026) */
.menu-admin {
  display: flex; flex-wrap: wrap; gap: .3rem; margin: 0 0 .9rem;
  border-bottom: 1px solid var(--bord);
}
.menu-admin button {
  border: 1px solid var(--bord); border-bottom: 0; border-radius: 8px 8px 0 0;
  background: var(--surface-2); color: var(--texte-doux); padding: .45rem .85rem;
  cursor: pointer; font-size: .88rem;
}
.menu-admin button:hover { background: var(--onglet-fond-survol); }
.menu-admin button.actif {
  background: var(--surface); color: var(--accent); font-weight: 600; border-color: var(--bord);
}
.panneau-admin { display: flex; flex-direction: column; gap: .9rem; }
.pastille-couleur {
  display: inline-block; width: .8rem; height: .8rem; border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, .18); vertical-align: middle; margin-right: .35rem;
}
.legende-couleurs {
  display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin: .3rem 0 .7rem;
  font-size: .8rem; color: var(--texte-doux);
}
.legende-couleurs .item { display: inline-flex; align-items: center; gap: .3rem; }
.entree-indicateur.teinte { border-left: 4px solid transparent; }
.entete-thematique {
  display: flex; align-items: center; gap: .4rem; font-size: .8rem; font-weight: 600;
  color: var(--texte); padding: .5rem .2rem .15rem; text-transform: none;
}
