/* ============================================================
   Portail RH — SPE Connect
   Même vocabulaire de composants que Temps Terrain (card, btn,
   puce, tabs, modale, toast) : les deux applications doivent se
   reconnaître au premier coup d'œil. Les jetons de marque
   viennent de brand.css.

   Une différence assumée : Temps Terrain est une application de
   terrain, pensée pour le pouce sur un téléphone. Celle-ci est un
   back-office où l'on lit des tableaux — la colonne centrale est
   donc large, et les tableaux sont denses.
   ============================================================ */

* { box-sizing: border-box; }

/* `hidden` est un attribut du HTML, pas une suggestion. La feuille de style du
   navigateur lui applique `display: none`, mais **toute** règle d'auteur qui
   fixe un display l'emporte : `.btn { display: inline-flex }` suffit à rendre
   visible un élément masqué. Conséquence constatée : l'onglet Paramètres
   s'affichait pour les collaborateurs, et un bouton d'action réservé aux RH
   aussi. Les boutons restaient sans effet — l'API refuse — mais une interface
   qui propose ce qu'elle n'autorise pas est une interface qui ment. */
[hidden] { display: none !important; }

html, body { max-width: 100%; overflow-x: clip; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--surface-green);
  color: var(--graphite);
  min-height: 100dvh;
  font-size: 15px;
  line-height: 1.5;
}

input, select, textarea, button { max-width: 100%; }

/* ── Barre supérieure ─────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 60;
  background: var(--forest);
  padding: 12px 20px;
  display: flex; align-items: center; gap: 14px;
  border-bottom: 3px solid var(--volt);
}
.topbar img { height: 26px; }
.topbar .spacer { flex: 1; }
.topbar .who { text-align: right; line-height: 1.25; }
.topbar .who strong { color: var(--white); font-size: 14px; display: block; }
.topbar .who span { color: var(--sage); font-size: 11.5px; font-family: var(--font-mono); }

/* ── Onglets ──────────────────────────────────────────────── */
.tabs {
  position: sticky; top: 55px; z-index: 50;
  display: flex; background: var(--white); border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; padding: 13px 18px; border: none; background: none;
  font-family: var(--font-body); font-size: 13.5px; font-weight: 600; color: var(--stone);
  cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap;
  display: flex; align-items: center; gap: 7px;
}
.tab:hover { color: var(--forest); }
.tab[aria-selected="true"] { color: var(--forest); border-bottom-color: var(--volt); }
.tab .compteur {
  background: var(--danger); color: var(--white); border-radius: 20px;
  padding: 1px 7px; font-size: 10.5px; font-family: var(--font-mono); font-weight: 600;
}
.tab[aria-selected="true"] .compteur { background: var(--forest); }

/* ── Contenu ──────────────────────────────────────────────── */
main { padding: 20px; max-width: 1420px; margin: 0 auto; }
.vue { display: none; }
.vue.active { display: block; }

.entete-vue {
  display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 16px;
}
.entete-vue h1 { font-size: 24px; margin: 0; }
.entete-vue .muted { margin-top: 2px; }
.entete-vue .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Cartes ───────────────────────────────────────────────── */
.card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.card.serre { padding: 0; overflow: hidden; }
.card-titre {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--stone); margin-bottom: 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.card.serre .card-titre { padding: 14px 16px 10px; margin-bottom: 0; }

.grille2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grille3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grille4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }

/* ── Indicateurs ──────────────────────────────────────────── */
.kpi { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 17px; }
.kpi .k {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--stone);
}
.kpi .v { font-family: var(--font-display); font-size: 30px; font-weight: 700; color: var(--forest); line-height: 1.1; margin-top: 5px; }
.kpi .d { font-size: 12.5px; color: var(--stone); margin-top: 3px; }
.kpi.danger .v { color: var(--danger); }
.kpi.warn .v { color: var(--warn); }
.kpi.ok .v { color: var(--ok); }
.kpi.volt { background: var(--forest); border-color: var(--forest); }
.kpi.volt .k { color: var(--sage); }
.kpi.volt .v { color: var(--volt); }
.kpi.volt .d { color: var(--sage); }

/* ── Boutons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border: none; border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: filter .15s, transform .05s;
  background: var(--surface-warm); color: var(--forest); text-decoration: none;
}
.btn:hover { filter: brightness(.97); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primaire { background: var(--volt); color: var(--forest); font-weight: 700; }
.btn-primaire:hover { background: var(--volt-deep); filter: none; }
.btn-sombre { background: var(--forest); color: var(--white); }
.btn-contour { background: transparent; border: 1.5px solid var(--border-strong); color: var(--forest); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-ok { background: var(--ok-bg); color: var(--ok); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-bloc { width: 100%; }

/* ── Pastilles ────────────────────────────────────────────── */
.puce {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
  border-radius: 20px; font-family: var(--font-mono); font-size: 10px;
  font-weight: 500; letter-spacing: .5px; text-transform: uppercase; white-space: nowrap;
}
.puce-ok { background: var(--ok-bg); color: var(--ok); }
.puce-warn { background: var(--warn-bg); color: var(--warn); }
.puce-danger { background: var(--danger-bg); color: var(--danger); }
.puce-neutre { background: var(--surface-warm); color: var(--stone); }
.puce-volt { background: var(--volt); color: var(--forest); }
.puce-forest { background: var(--ok-bg); color: var(--forest); }
.point { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: 0 0 9px; }

/* ── Tableaux ─────────────────────────────────────────────── */
.tableau-conteneur { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .8px; text-transform: uppercase;
  color: var(--stone); text-align: left; padding: 10px 12px; border-bottom: 1.5px solid var(--border);
  white-space: nowrap; font-weight: 500; background: var(--white);
  position: sticky; top: 0; z-index: 2;
}
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: var(--surface-green); }
tr.cliquable { cursor: pointer; }
.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.pile { display: flex; flex-direction: column; gap: 2px; }
.pile .p { font-weight: 600; }
.pile .s { font-size: 11.5px; color: var(--stone); }

/* ── Formulaires ──────────────────────────────────────────── */
.champ { margin-bottom: 13px; }
.champ label {
  display: block; font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .8px;
  text-transform: uppercase; color: var(--stone); margin-bottom: 5px;
}
.champ .aide { font-size: 11.5px; color: var(--stone); margin-top: 4px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; font-family: var(--font-body); font-size: 14px;
  color: var(--graphite); background: var(--white);
  border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--moss); box-shadow: 0 0 0 3px rgba(45, 95, 88, .13);
}
input[type="checkbox"] { width: auto; accent-color: var(--moss); }
input[type="color"] { padding: 3px; height: 40px; }
textarea { resize: vertical; min-height: 68px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 15px 2px; margin: 0 0 14px; }
legend {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--stone); padding: 0 6px;
}
.case { display: flex; align-items: center; gap: 9px; font-size: 14px; margin-bottom: 11px; cursor: pointer; }
.case input { flex: 0 0 auto; }

.filtres {
  display: flex; gap: 11px; align-items: flex-end; flex-wrap: wrap;
  padding: 13px 16px; background: var(--surface-warm); border-bottom: 1px solid var(--border);
}
.filtres .champ { margin-bottom: 0; min-width: 145px; }
.filtres .champ.large { flex: 1; min-width: 230px; }

/* ── Fenêtre modale ───────────────────────────────────────── */
.modale {
  position: fixed; inset: 0; z-index: 200; background: rgba(20, 18, 16, .62);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 20px; overflow-y: auto; backdrop-filter: blur(2px);
}
.modale[hidden] { display: none; }
.modale-boite {
  background: var(--surface-warm); border-radius: var(--radius); width: 100%;
  max-width: 620px; padding: 20px;
  animation: monte .22s cubic-bezier(.2, .8, .3, 1);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.modale-boite.large { max-width: 980px; }
.modale-titre { font-family: var(--font-display); font-size: 19px; color: var(--forest); margin-bottom: 3px; }
.modale-pied {
  border-top: 1px solid var(--border); margin-top: 14px; padding-top: 14px;
  display: flex; gap: 9px; justify-content: flex-end; flex-wrap: wrap;
}
@keyframes monte { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ── Messages ─────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(160%);
  background: var(--forest); color: var(--white); padding: 13px 20px;
  border-radius: var(--radius); font-size: 14px; font-weight: 500; z-index: 500;
  transition: transform .28s cubic-bezier(.2, .8, .3, 1); max-width: min(92vw, 480px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .28); border-left: 3px solid var(--volt);
}
.toast.visible { transform: translateX(-50%) translateY(0); }
.toast.erreur { border-left-color: var(--danger); }

.encart {
  padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13.5px;
  margin-bottom: 14px; border-left: 3px solid var(--moss); background: var(--ok-bg); color: var(--ok);
}
.encart.warn { background: var(--warn-bg); color: var(--warn); border-left-color: var(--warn); }
.encart.danger { background: var(--danger-bg); color: var(--danger); border-left-color: var(--danger); }
.encart a { color: inherit; font-weight: 600; }

/* ── Divers ───────────────────────────────────────────────── */
.muted { color: var(--stone); font-size: 13px; }
.mono { font-family: var(--font-mono); }
.rangee { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rangee.espace { justify-content: space-between; }
.sep { height: 1px; background: var(--border); margin: 13px 0; }
.vide { text-align: center; padding: 38px 20px; color: var(--stone); font-size: 14px; }
.vide strong { display: block; color: var(--graphite); margin-bottom: 4px; font-size: 15px; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--ok-bg); color: var(--forest);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-weight: 600; font-size: 12px; flex: 0 0 34px;
}
.avatar.grand { width: 54px; height: 54px; flex-basis: 54px; font-size: 18px; }

.jauge { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.jauge span { display: block; height: 100%; background: var(--moss); }

.liste { list-style: none; margin: 0; padding: 0; }
.liste li { padding: 9px 0; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: center; }
.liste li:last-child { border-bottom: none; }

.zone-depot {
  border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 26px;
  text-align: center; color: var(--stone); cursor: pointer; background: var(--white);
}
.zone-depot:hover, .zone-depot.survol { border-color: var(--moss); background: var(--ok-bg); color: var(--ok); }

.spinner {
  width: 16px; height: 16px; border: 2px solid var(--sage); border-top-color: transparent;
  border-radius: 50%; animation: tourne .7s linear infinite; display: inline-block;
}
@keyframes tourne { to { transform: rotate(360deg); } }

/* ── Matrice de couverture ────────────────────────────────── */
table.matrice td.cellule { text-align: center; padding: 4px 5px; }
.etat {
  display: inline-flex; align-items: center; justify-content: center; width: 100%;
  padding: 4px 6px; border-radius: var(--radius-sm); min-width: 64px;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500;
}
.etat.ok, .etat.permanente { background: var(--ok-bg); color: var(--ok); }
.etat.a_prevoir { background: var(--warn-bg); color: var(--warn); }
.etat.urgente { background: #F5E4D8; color: #8A4A12; }
.etat.expiree { background: var(--danger-bg); color: var(--danger); }
.etat.manquante { background: var(--surface-warm); color: var(--stone); }
.etat.sans_objet { background: transparent; color: var(--border-strong); }

/* ── Calendrier des absences ──────────────────────────────── */
table.calendrier { border-collapse: collapse; font-size: 11.5px; }
table.calendrier th, table.calendrier td { border: 1px solid var(--border); padding: 0; text-align: center; }
table.calendrier th.jour { width: 27px; padding: 4px 0; font-size: 9px; position: static; }
table.calendrier th.nom, table.calendrier td.nom {
  text-align: left; padding: 6px 10px; min-width: 195px;
  position: sticky; left: 0; background: var(--white); z-index: 3;
}
table.calendrier th.nom { z-index: 4; }
table.calendrier td.case-jour { height: 27px; }
table.calendrier td.we { background: var(--surface-warm); }
table.calendrier td.ferie { background: var(--warn-bg); }
.bande { display: block; width: 100%; height: 25px; }
.bande.attente {
  background-image: repeating-linear-gradient(45deg, transparent, transparent 3px,
    rgba(255, 255, 255, .6) 3px, rgba(255, 255, 255, .6) 6px);
}

/* ── Connexion ────────────────────────────────────────────── */
.connexion { min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr; }
.connexion .visuel {
  background: var(--forest); color: var(--white); padding: 56px;
  display: flex; flex-direction: column; justify-content: center; gap: 20px;
}
.connexion .visuel img { height: 34px; align-self: flex-start; }
.connexion .visuel h1 { font-size: 34px; color: var(--white); line-height: 1.15; margin: 0; }
.connexion .visuel p { color: var(--sage); font-size: 15.5px; line-height: 1.6; max-width: 440px; margin: 0; }
.connexion .visuel ul { color: var(--sage); line-height: 2; padding-left: 20px; margin: 0; font-size: 14.5px; }
.connexion .visuel li::marker { color: var(--volt); }
.connexion .boite { display: flex; align-items: center; justify-content: center; padding: 40px; }
.connexion form { width: 100%; max-width: 350px; }
.connexion form h2 { font-size: 22px; margin-bottom: 4px; }

/* ── Écrans étroits ───────────────────────────────────────── */
@media (max-width: 1100px) {
  .grille4 { grid-template-columns: 1fr 1fr; }
  .grille3 { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  main { padding: 14px; }
  .grille2, .grille3, .grille4 { grid-template-columns: 1fr; }
  .topbar { padding: 11px 14px; }
  .tabs { top: 53px; }
  .tab { padding: 12px 13px; font-size: 12.5px; }
  th, td { padding: 8px 7px; font-size: 12.5px; }
  .connexion { grid-template-columns: 1fr; }
  .connexion .visuel { display: none; }
  .entete-vue h1 { font-size: 20px; }
}

@media print {
  .topbar, .tabs, .entete-vue .actions, .btn { display: none !important; }
  main { padding: 0; max-width: none; }
  .card { border: none; padding: 0; }
}
