/* Service technique — couleurs reprises de la feuille papier (bleu marine, gris des cases fermées) */
:root {
  --fond: #f1f3f8; --carte: #ffffff; --ligne: #c9d0e3; --ligne-fine: #e2e6f0;
  --texte: #1a2140; --doux: #5b6482;
  --bleu: #24347f; --bleu-clair: #e6eaf6; --entete: #4b4f5c;
  --ferme: #c3c3c3; --ferme-fond: #dcdcdc;
  --fait: #2e7d4a; --fait-fond: #dff1e5;
  --pasfait: #b3362c; --pasfait-fond: #f8dedb;
  --prevu: #8a92ad;
  --r: 8px;
  --police: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fond); color: var(--texte); font: 15px/1.45 var(--police);
  padding-bottom: env(safe-area-inset-bottom, 0px); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--bleu); outline-offset: 2px; }
[hidden] { display: none !important; }
.cadre { max-width: 1280px; margin: 0 auto;
  padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px)); }

/* En-tête */
.haut { background: var(--bleu); color: #fff; position: sticky; top: 0; z-index: 5; padding-top: env(safe-area-inset-top, 0px); }
.haut-ligne { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-block: 10px; flex-wrap: wrap; }
.titre { display: flex; flex-direction: column; line-height: 1.1; }
.titre b { font-size: 1.15rem; letter-spacing: .01em; }
.titre span { font-size: .8rem; opacity: .8; }
.qui { display: flex; align-items: center; gap: 12px; font-size: .9rem; }
.lien { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; padding: 4px; }
.onglets { background: #1b2866; }
.onglets .cadre { display: flex; gap: 2px; overflow-x: auto; }
.onglets button { background: none; border: 0; color: #c9d0ee; padding: 10px 12px; cursor: pointer; white-space: nowrap; font-weight: 600;
  border-bottom: 3px solid transparent; }
.onglets button[aria-current="page"] { color: #fff; border-bottom-color: #ffd34d; }
.nb { background: var(--pasfait); color: #fff; border-radius: 10px; padding: 0 7px; font-size: .75rem; margin-left: 3px; }

main { padding-block: 16px 60px; }
h1 { font-size: 1.4rem; margin: 0 0 12px; }
h2 { font-size: 1.1rem; margin: 0 0 10px; color: var(--bleu); }
.carte { background: var(--carte); border: 1px solid var(--ligne); border-radius: var(--r); padding: 16px; margin-bottom: 14px; }
.etroit { max-width: 460px; margin-inline: auto; }
label { display: grid; gap: 4px; font-size: .85rem; color: var(--doux); margin-bottom: 10px; }
input, select, textarea { width: 100%; min-width: 0; border: 1px solid var(--ligne); border-radius: 6px; padding: 9px 10px; background: #fff; color: var(--texte); font-size: 1rem; }
textarea { resize: vertical; }
.aide { color: var(--doux); font-size: .88rem; margin: 6px 0; }
.erreur { color: var(--pasfait); font-weight: 600; }
.message { background: var(--bleu-clair); border-radius: 6px; padding: 10px 12px; }
.bouton { border: 1px solid var(--ligne); background: #fff; border-radius: 6px; padding: 9px 14px; cursor: pointer; font-weight: 600; }
.bouton:hover { border-color: var(--bleu); }
.bouton.plein { background: var(--bleu); border-color: var(--bleu); color: #fff; }
.bouton.danger { background: var(--pasfait); border-color: var(--pasfait); color: #fff; }
.bouton.petit { padding: 5px 10px; font-size: .85rem; }
.bouton:disabled { opacity: .5; cursor: not-allowed; }
.rond { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--ligne); background: #fff; cursor: pointer; font-size: 1.2rem; }

/* Barre de semaine */
.semaine-tete { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.navsem { display: flex; align-items: center; gap: 8px; }
.sem { display: flex; flex-direction: column; text-align: center; min-width: 170px; }
.sem b { font-size: 1.15rem; color: var(--bleu); }
.sem span { font-size: .82rem; color: var(--doux); }
.legende { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: .85rem; color: var(--doux); }
.legende span { display: inline-flex; align-items: center; gap: 5px; }
.pastille { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 2px solid var(--prevu); }
.pastille.fait { background: var(--fait); border-color: var(--fait); }
.pastille.pas_fait { background: var(--pasfait); border-color: var(--pasfait); }
.horaires { background: var(--bleu-clair); border-radius: var(--r); padding: 8px 12px; margin-bottom: 10px; font-size: .85rem; }
.horaires summary { cursor: pointer; font-weight: 600; color: var(--bleu); }
.horaires p { margin: 6px 0 2px; }

/* La feuille (ordinateur) */
.defile { overflow-x: auto; background: var(--carte); border: 1px solid var(--bleu); border-radius: var(--r); }
table.feuille { border-collapse: collapse; width: 100%; min-width: 980px; table-layout: fixed; }
.feuille th { background: var(--entete); color: #fff; font-size: .82rem; padding: 8px 6px; font-weight: 700; }
.feuille th.petit { font-size: .66rem; line-height: 1.2; }
.feuille td { border: 1px solid var(--ligne); vertical-align: top; padding: 4px; background: #fff; }
.feuille td.jour { background: #fff; color: var(--bleu); font-weight: 700; text-align: center; width: 44px; padding: 0; }
.feuille td.jour span { writing-mode: vertical-rl; transform: rotate(180deg); display: inline-block; padding: 6px 0; }
.feuille td.demi { width: 30px; font-size: .68rem; color: var(--doux); text-align: center; vertical-align: middle; padding: 0; }
.feuille tr.matin td.case { border-bottom: 1px dotted var(--ligne); }
.feuille tr.apres td { border-bottom: 2px solid var(--bleu); }
.feuille td.ferme, .carte-jour .ferme { background: var(--ferme-fond); }
.feuille td.aujourdhui { box-shadow: inset 3px 0 0 #ffd34d; }
.case { min-height: 58px; }
.vide-ferme { font-size: .72rem; color: #777; padding: 4px; }

/* Une tâche */
.tache { display: flex; align-items: flex-start; gap: 4px; border-radius: 5px; padding: 3px 3px 3px 6px; margin-bottom: 3px; background: var(--fond); }
.tache.fait { background: var(--fait-fond); }
.tache.pas_fait { background: var(--pasfait-fond); }
.tache.abandonne { opacity: .55; }
.tache.abandonne .t-texte { text-decoration: line-through; }
.tache .corps { flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 2px 0; cursor: default; font-size: .88rem; line-height: 1.3; }
.tache .corps.cliquable { cursor: pointer; }
.tache .corps.cliquable:hover .t-texte { text-decoration: underline; }
.t-texte { display: block; overflow-wrap: anywhere; }
.t-info { display: block; font-size: .74rem; color: var(--doux); overflow-wrap: anywhere; }
.t-info.rem { color: var(--texte); font-style: italic; }
.t-info.rep { color: var(--bleu); font-weight: 600; }
.coche { flex: none; width: 30px; height: 30px; border-radius: 6px; border: 2px solid var(--prevu); background: #fff; cursor: pointer;
  font-weight: 800; font-size: 1rem; line-height: 1; display: grid; place-items: center; }
.coche.fait { background: var(--fait); border-color: var(--fait); color: #fff; }
.coche.pas_fait { background: var(--pasfait); border-color: var(--pasfait); color: #fff; }
.coche:disabled { cursor: default; opacity: .85; }
.ajout { border: 1px dashed var(--ligne); background: none; color: var(--doux); border-radius: 5px; width: 100%; padding: 4px; cursor: pointer; font-size: .8rem; }
.ajout:hover { border-color: var(--bleu); color: var(--bleu); }
.pieton input { font-size: .85rem; padding: 6px; }
.pieton .lu { font-weight: 600; padding: 4px; }

/* La feuille (téléphone) : un jour = une carte */
.carte-jour { background: var(--carte); border: 1px solid var(--ligne); border-radius: var(--r); margin-bottom: 12px; overflow: hidden; }
.carte-jour > h3 { margin: 0; background: var(--bleu); color: #fff; padding: 8px 12px; font-size: 1rem; text-transform: capitalize; }
.carte-jour .bloc { padding: 8px 12px; border-top: 1px solid var(--ligne-fine); }
.carte-jour .bloc > h4 { margin: 0 0 6px; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--doux); }
.carte-jour .agent { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px; padding: 4px 0; border-top: 1px dotted var(--ligne-fine); }
.carte-jour .agent:first-of-type { border-top: 0; }
.carte-jour .agent > b { font-size: .82rem; padding-top: 6px; }
.carte-jour .ferme { border-radius: 5px; }

/* Congés et absences */
.feuille td.conge, .carte-jour .agent.conge > div { background: repeating-linear-gradient(135deg, #f3eedd 0 8px, #ebe3c8 8px 16px); }
.conge-etiquette { display: block; width: 100%; text-align: left; border: 0; border-radius: 4px; background: #8a6d1d; color: #fff;
  font-size: .78rem; font-weight: 700; padding: 3px 6px; margin-bottom: 3px; }
button.conge-etiquette { cursor: pointer; }
.lieu-form { grid-template-columns: minmax(0, 1fr) auto; margin: 8px 0 12px; }

/* Semaine type des agents */
.horaire-th { display: block; font-weight: 400; font-size: .72rem; opacity: .85; margin-top: 2px; }
.horaires-edit summary { cursor: pointer; color: var(--bleu); }
.horaires-edit[open] summary { margin-bottom: 8px; }
table.horaires-agent { border-collapse: collapse; font-size: .85rem; margin-bottom: 6px; }
.horaires-agent th { text-align: left; font-weight: 600; padding: 3px 6px; color: var(--doux); text-transform: capitalize; }
.horaires-agent thead th { text-align: center; text-transform: none; }
.horaires-agent td { padding: 2px 3px; }
.horaires-agent input { width: 100px; padding: 4px; font-size: .85rem; }
.horaires-agent .total { font-variant-numeric: tabular-nums; color: var(--doux); padding-left: 8px; white-space: nowrap; }

/* La journée */
table.feuille.journee { min-width: 560px; }
.feuille.journee th { font-size: .95rem; }
.feuille.journee .case { min-height: 120px; height: 120px; }
.feuille td.demi.grand { width: auto; font-size: .85rem; font-weight: 700; color: var(--bleu); }
.jour-bas { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 14px; margin-top: 14px; }
.jour-bas .carte { margin: 0; }
.sem input[type=date] { margin-top: 4px; padding: 4px 6px; font-size: .85rem; text-align: center; }
.vers-jour { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; padding: 0; writing-mode: vertical-rl; transform: rotate(180deg); }
.vers-jour:hover { text-decoration: underline; }
.feuille td.jour span, .feuille td.jour .vers-jour { padding: 6px 0; }
.nouveau-lieu { display: flex; gap: 8px; align-items: center; margin: -4px 0 10px; font-size: .85rem; color: var(--doux); flex-wrap: wrap; }
.lieux .suppr { border: 0; background: none; color: var(--pasfait); cursor: pointer; font-size: .8rem; }
@media (max-width: 760px) { .jour-bas { grid-template-columns: 1fr; } }

.obs { margin-top: 14px; }
.obs label { color: var(--texte); }

/* Bilan et reports */
.bilan { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.bilan .col h3 { margin: 0 0 6px; font-size: .95rem; }
.bilan .col h3 .n { font-weight: 800; font-size: 1.3rem; margin-right: 4px; }
.bilan .fait h3 { color: var(--fait); } .bilan .pas h3 { color: var(--pasfait); } .bilan .prev h3 { color: var(--doux); }
.bilan ul { margin: 0; padding-left: 18px; font-size: .88rem; }
.bilan li { margin-bottom: 3px; }
.report { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 2fr); gap: 10px 16px; padding: 12px 0; border-top: 1px solid var(--ligne-fine); }
.report:first-child { border-top: 0; }
.report .quoi b { display: block; }
.report .quoi small { color: var(--doux); display: block; }
.report .vers { display: grid; grid-template-columns: 150px 130px minmax(0, 1fr) auto auto; gap: 6px; align-items: end; }
.report .vers label { margin: 0; }
.vide { color: var(--doux); padding: 10px 0; }

/* Comptes */
.ligne-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 10px; align-items: end; }
.ligne-form label { margin: 0; }
.tableau-defile { overflow-x: auto; }
table.liste { border-collapse: collapse; width: 100%; min-width: 640px; font-size: .9rem; }
.liste th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--doux); padding: 6px; border-bottom: 1px solid var(--ligne); }
.liste td { padding: 6px; border-bottom: 1px solid var(--ligne-fine); vertical-align: middle; }
.liste td select, .liste td input { padding: 5px 6px; font-size: .88rem; }
.liste tr.inactif td { color: var(--doux); }
.absences { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: .78rem; }
.absences label { display: inline-flex; flex-direction: row; gap: 3px; align-items: center; margin: 0; color: var(--texte); }
.absences input { width: auto; }
.plans { margin: 0; padding-left: 20px; line-height: 2; }
.plans a { color: var(--bleu); font-weight: 600; }
.lieux { columns: 3 220px; font-size: .88rem; }
.lieux div { break-inside: avoid; padding: 2px 0; }
.lieux small { color: var(--doux); }

.titre-carte { display: flex; justify-content: space-between; align-items: start; gap: 10px; flex-wrap: wrap; }

/* Zone photographiée pour le PDF (hors écran) */
.zone-pdf { position: absolute; left: -12000px; top: 0; width: 820px; background: #fff; color: #000; padding: 18px; font-size: 13px; }
.zone-pdf.paysage { width: 1500px; }
.zone-pdf h1 { text-align: center; color: var(--bleu); font-size: 20px; margin: 0 0 6px; }
.zone-pdf .entete { display: flex; justify-content: space-between; color: var(--bleu); font-weight: 700; margin-bottom: 6px; }
.zone-pdf .consignes { border: 1px solid var(--bleu); background: var(--bleu-clair); padding: 6px 8px; font-size: 11px; margin-bottom: 8px; }
.zone-pdf table.feuille { min-width: 0; }
.zone-pdf .cadre-obs { border: 1px solid var(--bleu); margin-top: 8px; padding: 6px 8px; min-height: 60px; white-space: pre-wrap; }
.zone-pdf .pied { color: #666; font-size: 11px; margin-top: 8px; }
.zone-pdf .bilan { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.zone-pdf .report-pdf { border-top: 1px solid #ddd; padding: 5px 0; }

/* Fenêtre */
.fond { position: fixed; inset: 0; background: rgba(15, 20, 45, .55); z-index: 20; display: flex; align-items: center; justify-content: center; padding: 14px; }
.fenetre { background: #fff; border-radius: 10px; width: min(560px, 100%); max-height: 92vh; overflow: auto; padding: 18px; }
.fenetre h3 { margin: 0 0 4px; color: var(--bleu); }
.fenetre .ou { color: var(--doux); font-size: .88rem; margin: 0 0 12px; }
.deux { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.boutons { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.boutons > div { display: flex; gap: 8px; }
.etats { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.etats button { flex: 1; border: 2px solid var(--ligne); background: #fff; border-radius: 6px; padding: 8px; cursor: pointer; font-weight: 600; }
.etats button[aria-pressed="true"].fait { border-color: var(--fait); background: var(--fait-fond); color: var(--fait); }
.etats button[aria-pressed="true"].pas_fait { border-color: var(--pasfait); background: var(--pasfait-fond); color: var(--pasfait); }
.etats button[aria-pressed="true"].prevu { border-color: var(--bleu); background: var(--bleu-clair); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  background: var(--texte); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 30; font-size: .92rem; max-width: 90vw; }

@media (max-width: 760px) {
  .bilan { grid-template-columns: 1fr; }
  .report { grid-template-columns: 1fr; }
  .report .vers { grid-template-columns: 1fr 1fr; }
  .ligne-form { grid-template-columns: 1fr; }
  .deux { grid-template-columns: 1fr; }
  .sem { min-width: 0; }
}

/* Impression : la feuille comme sur papier, A4 paysage */
@media print {
  @page { size: A4 landscape; margin: 8mm; }
  body { background: #fff; font-size: 10px; }
  .haut, .onglets, .semaine-tete .legende, .horaires summary, #semEtat, .ajout, .coche:not(.fait):not(.pas_fait), #semPrec, #semSuiv, #semAuj { display: none !important; }
  .horaires { display: block; background: none; padding: 0; } .horaires[open] p, .horaires p { display: block; }
  main { padding: 0; } .cadre { max-width: none; padding: 0; }
  .defile { overflow: visible; border: 1px solid #000; }
  table.feuille { min-width: 0; }
  .feuille th { background: #4b4f5c !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .feuille td.ferme { background: #ccc !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .tache { background: none !important; padding: 0; }
  .coche { width: 16px; height: 16px; font-size: 9px; }
  .obs textarea { border: 0; resize: none; }
}
