/* Outil de pointage — mobile d'abord */
:root {
  --fond: #f3f1ec;
  --carte: #ffffff;
  --encre: #1f2a30;
  --doux: #6b7479;
  --trait: #dedad2;
  --accent: #1f2a30;
  --vert: #2e9e5b;
  --rouge: #d64541;
  --ambre: #b7791f;
  --rayon: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--encre);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 560px; margin: 0 auto; padding: 16px 16px 80px; }
.page-large main { max-width: 1100px; }
h1 { font-size: 1.5rem; margin: 8px 0 16px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

/* Barre du haut */
.barre {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: var(--accent); color: #fff;
}
.barre-titre { font-weight: 700; text-decoration: none; }
.barre-user { font-size: .9rem; opacity: .85; }

/* Connexion */
.page-login main { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login { width: 100%; max-width: 300px; text-align: center; }
.login h1 { margin-bottom: 4px; }
.login-aide { color: var(--doux); margin: 0 0 20px; }
.login-champ { position: absolute; opacity: 0; pointer-events: none; }
.login-points { display: flex; gap: 16px; justify-content: center; margin-bottom: 20px; }
.login-points span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--encre); }
.login-points span.plein { background: var(--encre); }
.login-erreur { color: var(--rouge); font-weight: 600; }
.pave { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pave button {
  height: 64px; border-radius: var(--rayon); border: 1px solid var(--trait);
  background: var(--carte); font-size: 1.5rem; font-weight: 600; cursor: pointer;
}
.pave button:active { background: var(--trait); }
.pave-del { font-size: 1.2rem !important; }

/* Accueil */
.tuiles { display: grid; gap: 12px; }
.tuile {
  display: block; padding: 18px; border-radius: var(--rayon); background: var(--carte);
  border: 1px solid var(--trait); text-decoration: none;
}
.tuile strong { display: block; font-size: 1.1rem; }
.tuile span { color: var(--doux); font-size: .9rem; }
.tuile-off { opacity: .5; }

/* Navigation par jour */
.jour-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.jour-fleche {
  flex: 0 0 48px; height: 48px; display: grid; place-items: center; text-decoration: none;
  font-size: 1.8rem; border-radius: 50%; background: var(--carte); border: 1px solid var(--trait);
}
.jour-titre { flex: 1; text-align: center; }
.jour-titre strong { display: block; font-size: 1.05rem; }
.jour-retour { font-size: .85rem; color: var(--doux); }

.bandeau {
  padding: 12px 14px; border-radius: var(--rayon); background: var(--carte);
  border: 1px solid var(--trait); text-align: center;
}
.bandeau-fige { background: #fff6e5; border-color: #f0d9a8; color: #7a5410; }
.bandeau-ok { background: #e9f6ee; border-color: #bfe3cc; color: #1c6b3d; }
.compteur { color: var(--doux); text-align: center; margin: 4px 0 12px; font-size: .95rem; }

/* Lignes du chef */
.liste { display: grid; gap: 10px; }
.ligne {
  background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon);
  padding: 12px 14px; transition: opacity .2s, border-color .3s;
}
.ligne.rouge { border-color: var(--rouge); }
.ligne.absent { background: #ebe8e1; }
.ligne.absent .ligne-nom { color: var(--doux); text-decoration: line-through; }
.ligne.envoi { opacity: .6; }
.ligne.ok { border-color: var(--vert); }
.ligne-haut { display: flex; align-items: center; gap: 12px; }
.ligne-nom {
  flex: 1; text-align: left; background: none; border: 0; padding: 6px 0;
  font-size: 1.1rem; font-weight: 600; cursor: pointer;
}
.gommette {
  flex: 0 0 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--vert); box-shadow: inset 0 -3px 0 rgba(0,0,0,.15);
}
.ligne.rouge .gommette { background: var(--rouge); }
.gommette[hidden] { display: none; }
.ligne-bas { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.etat { font-size: .85rem; color: var(--doux); }
.ligne.absent .etat { color: var(--ambre); font-weight: 600; }
.horaire {
  background: none; border: 1px dashed var(--trait); border-radius: 8px;
  padding: 4px 10px; font-size: .9rem; color: var(--doux); cursor: pointer;
}
.horaire[hidden] { display: none; }
.horaire-edit { display: flex; gap: 12px; margin-top: 10px; }
.horaire-edit[hidden] { display: none; }
.horaire-edit label { flex: 1; font-size: .85rem; color: var(--doux); }
.horaire-edit input { display: block; width: 100%; margin-top: 2px; padding: 8px; border: 1px solid var(--trait); border-radius: 8px; }
.commentaire {
  display: block; width: 100%; margin-top: 10px; padding: 10px;
  border: 1px solid var(--rouge); border-radius: 10px; resize: vertical; background: #fff8f7;
}
.commentaire[hidden] { display: none; }
.ligne button:disabled, .ligne textarea:disabled, .ligne input:disabled { cursor: default; opacity: .85; }

/* Pages bureau */
.entete { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-block; padding: 10px 16px; border-radius: 10px; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; text-decoration: none; font-weight: 600;
}
.btn-sec { background: var(--trait); color: var(--encre); }
.carte { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 16px; margin-bottom: 16px; }
.grille-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.grille-form label { font-size: .9rem; color: var(--doux); }
.grille-form input, .grille-form select {
  display: block; width: 100%; margin-top: 4px; padding: 9px; border: 1px solid var(--trait); border-radius: 8px; background: #fff;
}
.aide { color: var(--doux); font-size: .85rem; }
.erreur { color: var(--rouge); font-weight: 600; margin: 0 0 8px; }
.actions { display: flex; gap: 8px; margin-top: 12px; }
.filtre { color: var(--doux); font-size: .9rem; }
.tableau { width: 100%; border-collapse: collapse; background: var(--carte); border-radius: var(--rayon); overflow: hidden; }
.tableau th, .tableau td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--trait); }
.tableau th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--doux); }
.tableau tr.sorti td { color: var(--doux); }
.tableau .vide { text-align: center; color: var(--doux); }
@media (max-width: 640px) {
  .tableau thead { display: none; }
  .tableau tr { display: block; border-bottom: 1px solid var(--trait); padding: 8px 0; }
  .tableau td { display: block; border: 0; padding: 2px 12px; }
}

/* Message flottant */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--encre); color: #fff; padding: 10px 16px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100% - 32px);
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.erreur { background: var(--rouge); }

/* ===== Écran bureau ===== */
.page-bureau main { max-width: 1200px; padding-bottom: 120px; }
.sem-nav { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.sem-nav .btn { padding: 8px 12px; font-weight: 500; }
.sem-date { padding: 7px; border: 1px solid var(--trait); border-radius: 8px; background: #fff; }
.legende { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-left: 6px; }

.grille-scroll { overflow-x: auto; border-radius: var(--rayon); border: 1px solid var(--trait); background: var(--carte); }
.grille { width: 100%; border-collapse: collapse; min-width: 860px; }
.grille th, .grille td { border-bottom: 1px solid var(--trait); padding: 6px 8px; text-align: center; vertical-align: middle; }
.grille thead th { background: #faf9f6; font-size: .85rem; font-weight: 600; position: sticky; top: 0; }
.grille .col-check { width: 32px; }
.grille .col-nom { text-align: left; white-space: nowrap; }
.grille .col-nom a { text-decoration: none; font-weight: 500; }
.grille .col-nom a:hover { text-decoration: underline; }
.grille .col-total { white-space: nowrap; width: 90px; }
.grille .col-total small { display: block; font-size: .75rem; }
.grille .col-total .plus { color: var(--vert); }
.grille .col-total .moins { color: var(--rouge); }
.j-tete { display: flex; gap: 6px; justify-content: center; align-items: center; }
.j-ferie { font-size: .75rem; color: var(--ambre); font-weight: 600; }
.lien-ferie { background: none; border: 0; padding: 0; font-size: .7rem; color: var(--doux); text-decoration: underline; cursor: pointer; }
.grille th.off, .grille td.off { background: repeating-linear-gradient(45deg, #f4f2ed, #f4f2ed 6px, #ece9e2 6px, #ece9e2 12px); }
.grille td.hors { background: #f6f5f2; }
.grille td.manque { color: var(--ambre); font-weight: 700; }
.grille tr.g-ligne td { background: #f4f2ed; text-align: left; font-weight: 700; font-size: .9rem; }
.grille tr.sel td { background: #f1f6fb; }
.grille td.case { cursor: pointer; white-space: nowrap; font-size: .85rem; }
.grille td.case:hover { outline: 2px solid var(--encre); outline-offset: -2px; }
.grille td.cible { box-shadow: inset 0 0 0 2px #4a7fb5; }
.grille td.case-fige { color: var(--doux); }
.grille .h-modif { font-weight: 700; color: #4a7fb5; }
.grille .bulle { margin-left: 3px; font-size: .8rem; }
.pt { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.pt-v { background: var(--vert); }
.pt-r { background: var(--rouge); }
.abs { display: inline-block; padding: 1px 7px; border-radius: 6px; background: #f3e6d0; color: #7a5410; font-size: .8rem; }
.abs-q { background: #fde3e1; color: var(--rouge); }

/* Barre de saisie groupée */
.groupe {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 20;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center;
  background: var(--encre); color: #fff; padding: 10px 14px; border-radius: var(--rayon);
  box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: calc(100% - 32px);
}
.groupe[hidden] { display: none; }
.groupe select, .groupe input { padding: 7px; border-radius: 8px; border: 0; background: #fff; color: var(--encre); }
.groupe .btn { background: #fff; color: var(--encre); padding: 8px 14px; }
.groupe .btn-sec { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.4); }
.groupe .btn:disabled { opacity: .4; cursor: not-allowed; }
.g-champs { display: inline-flex; gap: 6px; }
.g-champs[hidden] { display: none; }
.groupe-compte { font-weight: 600; }

/* Fiche d'une case */
.fiche { border: 0; border-radius: var(--rayon); padding: 0; width: min(420px, calc(100% - 32px)); box-shadow: 0 12px 40px rgba(0,0,0,.3); }
.fiche::backdrop { background: rgba(20, 28, 32, .45); }
.fiche-entete { display: flex; justify-content: space-between; align-items: flex-start; padding: 14px 16px; border-bottom: 1px solid var(--trait); margin: 0; }
.fiche-entete span { color: var(--doux); }
.fiche-fermer { background: none; border: 0; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--doux); }
.fiche .bandeau { margin: 12px 16px 0; }
.fiche-corps { padding: 14px 16px; display: grid; gap: 12px; }
.fiche-corps label { display: grid; gap: 4px; font-size: .85rem; color: var(--doux); }
.fiche-corps label[hidden], .fiche-corps div[hidden] { display: none; }
.fiche-corps select, .fiche-corps input, .fiche-corps textarea { padding: 8px; border: 1px solid var(--trait); border-radius: 8px; background: #fff; color: var(--encre); }
.fiche-heures { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.fiche-heures label { flex: 1; }
.fiche-heures .aide { flex-basis: 100%; margin: 0; }
.fiche-bonus { display: flex; justify-content: space-between; align-items: center; }
.fiche-bonus .gommette { flex: 0 0 40px; height: 40px; }
.fiche-bonus .gommette.rouge { background: var(--rouge); }
.segment { display: flex; border: 1px solid var(--trait); border-radius: 10px; overflow: hidden; }
.segment button { flex: 1; padding: 10px; border: 0; background: #fff; cursor: pointer; font-weight: 600; }
.segment button.actif { background: var(--encre); color: #fff; }
.segment button:disabled { cursor: default; }

/* ===== Rapport et périodes figées ===== */
.rapport-filtre { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.rapport-filtre label { display: grid; gap: 4px; font-size: .85rem; color: var(--doux); }
.rapport-filtre input[type=date] { padding: 8px; border: 1px solid var(--trait); border-radius: 8px; background: #fff; }
.rapport-filtre .case-a-cocher { display: flex; gap: 6px; align-items: center; padding-bottom: 10px; color: var(--encre); }
.rapport-filtre .erreur { flex-basis: 100%; }
.rapport-verrous { margin-top: -4px; }
.rapport-h2 { margin-top: 28px; }
.lien { background: none; border: 0; padding: 0; color: var(--rouge); text-decoration: underline; cursor: pointer; }

.grille.rapport { min-width: 0; }
.grille.rapport th, .grille.rapport td { padding: 5px 3px; }
.grille.rapport .col-nom { padding-left: 10px; padding-right: 10px; position: sticky; left: 0; background: var(--carte); z-index: 1; }
.grille.rapport thead .col-nom { background: #faf9f6; z-index: 2; }
.grille.rapport .sem-tete { font-size: .75rem; color: var(--doux); border-left: 2px solid var(--trait); }
.grille.rapport .col-j { font-size: .75rem; font-weight: 600; min-width: 24px; line-height: 1.1; }
.grille.rapport .col-j span { display: block; font-weight: 400; color: var(--doux); }
.grille.rapport .sep { border-left: 2px solid var(--trait); }
.grille.rapport td { font-size: .8rem; }
.grille.rapport td.vert, .legende .vert { color: var(--vert); font-size: 1rem; }
.grille.rapport td.rouge, .rouge { color: var(--rouge); }
.grille.rapport td.rouge { font-size: 1rem; background: #fdecea; }
.grille.rapport td.pres, .legende .pres { color: var(--doux); font-weight: 700; }
.grille.rapport td.c-abs { background: #f3e6d0; color: #7a5410; font-weight: 700; border-radius: 0; padding: 5px 2px; }
.grille.rapport td.c-absq { background: #fde3e1; color: var(--rouge); }
.grille.rapport td.manque, .legende .manque, .manque { color: var(--ambre); font-weight: 700; }
.grille.rapport td.com { position: relative; }
.grille.rapport td.com::after { content: ''; position: absolute; top: 2px; right: 2px; border: 4px solid transparent; border-top-color: #4a7fb5; border-right-color: #4a7fb5; }
.grille.rapport .col-cpt { min-width: 38px; font-variant-numeric: tabular-nums; border-left: 1px solid var(--trait); }
.grille.rapport td.col-cpt.zero { color: #c9c4ba; }
.grille.rapport td.col-cpt.fort { font-weight: 700; }
.plus { color: var(--vert); }
.moins { color: var(--rouge); }
.tableau.detail td.h-modif { color: #4a7fb5; font-weight: 700; }
.tableau.detail tr.off td { color: var(--doux); background: #f6f5f2; }
.tableau.detail tr.sous-total td { background: #f4f2ed; font-weight: 600; font-size: .9rem; }
.tableau.detail tr.total td { background: var(--encre); color: #fff; font-weight: 700; }
.tableau.detail tr.total td.plus { color: #7fd4a0; }
.tableau.detail tr.total td.moins { color: #ff9c95; }

@media print {
  .barre, .rapport-filtre, .rapport-verrous, .toast, .entete .btn { display: none !important; }
  body { background: #fff; font-size: 11px; }
  main { max-width: none; padding: 0; }
  .grille-scroll { overflow: visible; border: 0; }
  .grille.rapport .col-nom { position: static; }
  @page { size: landscape; margin: 10mm; }
}
