:root {
  --asphalte: #23292e;
  --beton: #eceff1;
  --panneau: #ffffff;
  --trait: #d3d8dc;
  --texte: #1d2226;
  --gris: #5b6770;
  --signal: #f2b200;
  --orange: #d9730d;
  --vert: #2f7a4b;
  --rouge: #b3261e;
  --rayon: 6px;
  font-family: "Barlow", system-ui, sans-serif;
  font-size: 16px;
  color: var(--texte);
  background: var(--beton);
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: inherit; }
body { margin: 0; min-height: 100vh; }
h1, h2, h3 { font-family: "Barlow Semi Condensed", "Barlow", sans-serif; font-weight: 700; margin: 0; }
h1 { font-size: 1.75rem; line-height: 1.15; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; font-weight: 600; }
.chiffres, td.num, .num { font-variant-numeric: tabular-nums; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }

/* ---------- Barre du haut ---------- */
.barre {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 1.5rem;
  background: var(--asphalte); color: #fff;
  padding: .7rem 1.25rem;
}
.marque { display: flex; align-items: center; gap: .6rem; font-family: "Barlow Semi Condensed", sans-serif; font-weight: 700; font-size: 1.2rem; letter-spacing: .02em; }
.bande {
  width: 26px; height: 18px; border-radius: 2px;
  background: repeating-linear-gradient(135deg, var(--signal) 0 6px, var(--asphalte) 6px 12px);
}
nav { display: flex; gap: .25rem; flex: 1; }
nav a { color: #cfd6db; text-decoration: none; padding: .35rem .7rem; border-radius: var(--rayon); font-weight: 500; }
nav a:hover { color: #fff; }
nav a.actif { color: var(--asphalte); background: var(--signal); }
.lien-discret { background: none; border: 0; color: #cfd6db; cursor: pointer; padding: .3rem; }
.lien-discret:hover { color: #fff; }

main { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

/* ---------- Éléments communs ---------- */
.panneau { background: var(--panneau); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 1.1rem 1.25rem; }
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  border: 1px solid var(--asphalte); background: var(--panneau); color: var(--asphalte);
  padding: .5rem .9rem; border-radius: var(--rayon); cursor: pointer; font-weight: 600;
}
.btn:hover { background: #f4f6f7; }
.btn.principal { background: var(--asphalte); color: #fff; }
.btn.principal:hover { background: #343c43; }
.btn.valider { background: var(--vert); border-color: var(--vert); color: #fff; }
.btn.petit { padding: .25rem .55rem; font-size: .9rem; font-weight: 500; }
.btn.fantome { border-color: transparent; background: none; color: var(--gris); }
.btn.fantome:hover { color: var(--rouge); background: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
label { display: block; font-size: .9rem; color: var(--gris); margin-bottom: .25rem; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=time], input[type=date], select {
  border: 1px solid var(--trait); border-radius: 4px; background: #fff; padding: .4rem .5rem; min-height: 2.2rem;
}
input:disabled, select:disabled { background: #f3f5f6; color: var(--gris); }
.champ { margin-bottom: .9rem; }
.champ input, .champ select { width: 100%; }
.erreur { color: var(--rouge); font-size: .95rem; }
.vide { color: var(--gris); padding: 1rem 0; }

#toast {
  position: fixed; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--asphalte); color: #fff; padding: .7rem 1.1rem; border-radius: var(--rayon);
  box-shadow: 0 6px 20px rgba(0,0,0,.25); z-index: 20; max-width: 90vw;
}
#toast.ko { background: var(--rouge); }

/* ---------- Connexion ---------- */
.connexion { max-width: 380px; margin: 8vh auto 0; }
.connexion h1 { margin-bottom: 1.2rem; }
.connexion .btn { width: 100%; justify-content: center; padding: .7rem; }

/* ---------- Saisie des heures ---------- */
.entete-saisie { display: flex; flex-wrap: wrap; align-items: end; gap: 1rem 1.5rem; margin-bottom: 1.25rem; }
.entete-saisie select { min-width: 230px; }
.nav-semaine { display: flex; align-items: center; gap: .5rem; }
.nav-semaine .titre { min-width: 15rem; text-align: center; }
.nav-semaine .titre strong { display: block; font-family: "Barlow Semi Condensed", sans-serif; font-size: 1.3rem; }
.nav-semaine .titre span { color: var(--gris); font-size: .92rem; }
.statut { padding: .25rem .6rem; border-radius: 99px; font-size: .88rem; font-weight: 600; background: #fff3cc; color: #6b5200; }
.statut.ok { background: #dcefe3; color: var(--vert); }

.grille { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 1.25rem; align-items: start; }
.jours { display: flex; flex-direction: column; gap: .6rem; }
.jour { background: var(--panneau); border: 1px solid var(--trait); border-radius: var(--rayon); padding: .75rem 1rem; }
.jour.weekend { background: #f6f7f8; }
.jour-tete { display: flex; align-items: center; gap: .75rem; margin-bottom: .4rem; }
.jour-tete h3 { flex: 1; }
.jour-total { font-variant-numeric: tabular-nums; font-weight: 600; }
.tag { font-size: .8rem; padding: .1rem .45rem; border-radius: 4px; background: #e6e9ec; color: var(--gris); font-weight: 600; }
.tag.ferie { background: #fff3cc; color: #6b5200; }
.ligne { display: grid; grid-template-columns: 6.2rem 6.2rem minmax(0, 1fr) 3.6rem 2rem; gap: .5rem; align-items: center; margin-bottom: .35rem; }
.ligne.absence { grid-template-columns: minmax(0, 1fr) 6rem 2rem; }
.ligne .duree { text-align: right; font-variant-numeric: tabular-nums; color: var(--gris); }
.ligne select { min-width: 0; }
.actions-jour { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-top: .3rem; }
.panier { display: inline-flex; align-items: center; gap: .35rem; margin-left: auto; color: var(--gris); font-size: .95rem; }
.panier input { width: 1.1rem; height: 1.1rem; accent-color: var(--asphalte); }

.synthese { position: sticky; top: 4.2rem; }
.synthese h2 { margin-bottom: .8rem; }
.synthese dl { display: grid; grid-template-columns: 1fr auto; gap: .35rem 1rem; margin: 0 0 1rem; }
.synthese dt { color: var(--gris); }
.synthese dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.synthese dd.fort { font-size: 1.15rem; }
.synthese .separe { border-top: 1px solid var(--trait); padding-top: .35rem; }
.synthese .boutons { display: flex; flex-direction: column; gap: .5rem; margin-top: 1rem; }
.synthese .boutons .btn { justify-content: center; }
.note { font-size: .88rem; color: var(--gris); margin-top: .6rem; }

/* La jauge hebdomadaire : l'élément signature */
.jauge { margin: .3rem 0 1.4rem; }
.jauge-piste { position: relative; height: 26px; background: repeating-linear-gradient(90deg, #f1f3f4 0 calc(100% / 48 - 1px), #e2e6e9 calc(100% / 48 - 1px) calc(100% / 48)); border-radius: 3px; overflow: hidden; }
.jauge-seg { position: absolute; top: 0; bottom: 0; transition: width .25s ease, left .25s ease; }
.jauge-seg.hn { background: var(--asphalte); }
.jauge-seg.abs { background: repeating-linear-gradient(135deg, #8b979f 0 4px, #a9b3b9 4px 8px); }
.jauge-seg.hs25 { background: var(--signal); }
.jauge-seg.hs50 { background: var(--orange); }
.jauge-reperes { position: relative; height: 1.2rem; font-size: .78rem; color: var(--gris); font-variant-numeric: tabular-nums; }
.jauge-reperes span { position: absolute; transform: translateX(-50%); top: .15rem; }
.jauge-seuil { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--texte); }
.legende { display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: .82rem; color: var(--gris); }
.legende i { display: inline-block; width: .7rem; height: .7rem; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; }
@media (prefers-reduced-motion: reduce) { .jauge-seg { transition: none; } }

/* ---------- Listes (salariés, affaires) ---------- */
.entete-liste { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.tableau { width: 100%; border-collapse: collapse; background: var(--panneau); border: 1px solid var(--trait); border-radius: var(--rayon); overflow: hidden; }
.tableau th { text-align: left; font-weight: 600; color: var(--gris); font-size: .9rem; padding: .6rem .8rem; border-bottom: 1px solid var(--trait); background: #f6f7f8; }
.tableau td { padding: .55rem .8rem; border-bottom: 1px solid #edf0f2; }
.tableau tr:last-child td { border-bottom: 0; }
.tableau td.num, .tableau th.num { text-align: right; }
.tableau tr.inactif td { color: var(--gris); }
.defile { overflow-x: auto; }
.formulaire { margin-bottom: 1.25rem; }
.formulaire .colonnes { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 1rem; }
.formulaire .boutons { display: flex; gap: .5rem; }
.case { display: flex; align-items: center; gap: .5rem; margin-top: 1.7rem; }
.case label { margin: 0; color: var(--texte); }

@media (max-width: 900px) {
  .grille { grid-template-columns: 1fr; }
  .synthese { position: static; order: -1; }
}
@media (max-width: 560px) {
  .barre { flex-wrap: wrap; gap: .5rem 1rem; }
  nav { order: 3; flex-basis: 100%; }
  main { padding: 1rem .75rem 4rem; }
  .ligne { grid-template-columns: 1fr 1fr 2rem; }
  .ligne .affaire { grid-column: 1 / 3; grid-row: 2; }
  .ligne .duree { grid-column: 3; grid-row: 2; }
  .nav-semaine .titre { min-width: 0; }
}
