/* Style inspiré des feuilles d'heures hebdomadaires : Roboto, bleu des libellés,
   blocs gris clair, filets fins, violet pour la nuit, rouge pour les continues. */
:root {
  --fond: #f7f8fa; --carte: #fff; --bloc: #f2f2f2; --texte: #1a1a1a; --doux: #5f6670; --bord: #d9d9d9; --filet: #bfbfbf;
  --bleu: #4472c4; --bleu-fonce: #2f5597; --bleu-txt: #fff;
  --violet: #7030a0; --rouge: #c00000; --jaune: #ffe699;
  --ok: #1e7b4f; --ok-fond: #e3f4ea; --warn: #8a5a00; --warn-fond: #fff3d6;
  --ko: #b3261e; --ko-fond: #fde7e5; --info: #2f5597; --info-fond: #e8eef8; --gris-fond: #f2f2f2;
  --rayon: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #121519; --carte: #1b1f25; --bloc: #232830; --texte: #e8eaee; --doux: #a1a9b5; --bord: #323944; --filet: #4a5260;
    --bleu: #7ea3e6; --bleu-fonce: #9db9ee; --bleu-txt: #0d1420;
    --violet: #c49bf0; --rouge: #ff8a80; --jaune: #5c4a12;
    --ok: #6fd3a0; --ok-fond: #143325; --warn: #f2c063; --warn-fond: #3a2c0c;
    --ko: #ff8a80; --ko-fond: #3d1714; --info: #9db9ee; --info-fond: #1a2a44; --gris-fond: #232830;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--fond); color: var(--texte);
  font: 15px/1.45 Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}
.chargement { text-align: center; margin-top: 30vh; color: var(--doux); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; color: var(--bleu); font-weight: 700; }
h1 { font-size: 1.4rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
a { color: var(--bleu-fonce); }
.doux { color: var(--doux); }
.petit { font-size: .85em; }
.fort { font-weight: 700; }

/* ---- Structure ---- */
.entete {
  position: sticky; top: 0; z-index: 10;
  background: var(--carte); color: var(--texte); border-bottom: 2px solid var(--texte);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 0;
}
.entete .ligne { display: flex; align-items: center; gap: 12px; max-width: 1280px; margin: 0 auto; }
.entete .titre { font-weight: 700; flex: 1; color: var(--bleu); font-size: 1.15rem; }
.entete .qui { font-size: .85em; text-align: right; color: var(--texte); text-decoration: none; }
.onglets { display: flex; gap: 2px; overflow-x: auto; max-width: 1280px; margin: 6px auto 0; scrollbar-width: none; }
.onglets button {
  background: none; border: 0; color: var(--doux); padding: 10px 12px; font: inherit; min-height: 0; border-radius: 0;
  border-bottom: 3px solid transparent; white-space: nowrap; cursor: pointer;
}
.onglets button.actif { color: var(--bleu); border-bottom-color: var(--bleu); font-weight: 700; }
main { max-width: 1280px; margin: 0 auto; padding: 16px 16px calc(env(safe-area-inset-bottom) + 40px); }
.bandeau-demo { background: var(--warn-fond); color: var(--warn); padding: 8px 16px; font-size: .85em; text-align: center; }

/* ---- Cartes et formulaires ---- */
.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 14px; margin-bottom: 12px; }
.grille { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.pile > * + * { margin-top: 10px; }
.rangee { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rangee.fin { justify-content: flex-end; }
.espace { flex: 1; }
label { display: block; font-size: .85em; color: var(--bleu); font-weight: 500; }
label > input, label > select, label > textarea { margin-top: 3px; font-weight: 400; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--texte); background: var(--carte);
  border: 1px solid var(--filet); border-radius: 4px; padding: 8px 10px; min-height: 40px;
}
input[type="checkbox"] { width: auto; min-height: 0; accent-color: var(--bleu); }
textarea { min-height: 64px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--bleu); outline-offset: 1px; }
input:disabled, select:disabled, textarea:disabled { background: var(--bloc); color: var(--doux); }
.case { display: flex; gap: 8px; align-items: center; font-size: .95em; color: var(--texte); font-weight: 400; }

button, .bouton {
  font: inherit; border-radius: 4px; padding: 8px 14px; min-height: 38px; cursor: pointer;
  border: 1px solid var(--filet); background: var(--carte); color: var(--texte);
}
button:hover:not(:disabled) { border-color: var(--bleu); }
button.primaire { background: var(--bleu); border-color: var(--bleu); color: var(--bleu-txt); font-weight: 600; }
button.primaire:hover:not(:disabled) { background: var(--bleu-fonce); }
button.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
button.ko { color: var(--ko); border-color: var(--ko); }
button.lien { background: none; border: 0; padding: 4px; min-height: 0; color: var(--bleu-fonce); text-decoration: underline; }
button.mini { padding: 3px 9px; min-height: 30px; font-size: .85em; }
button:disabled { opacity: .45; cursor: default; }

.segment { display: inline-flex; border: 1px solid var(--filet); border-radius: 4px; overflow: hidden; flex-wrap: wrap; }
.segment button { border: 0; border-radius: 0; min-height: 34px; background: var(--carte); color: var(--doux); }
.segment button + button { border-left: 1px solid var(--filet); }
.segment button.actif { background: var(--bleu); color: var(--bleu-txt); font-weight: 600; }

.erreur { background: var(--ko-fond); color: var(--ko); padding: 10px; border-radius: 4px; }
.succes { background: var(--ok-fond); color: var(--ok); padding: 10px; border-radius: 4px; }
.note { background: var(--info-fond); color: var(--info); padding: 10px; border-radius: 4px; font-size: .9em; }

/* ---- Pastilles ---- */
.statut { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .78em; font-weight: 600; white-space: nowrap; }
.statut.brouillon { background: var(--gris-fond); color: var(--doux); }
.statut.soumis { background: var(--warn-fond); color: var(--warn); }
.statut.valide_chef { background: var(--info-fond); color: var(--info); }
.statut.valide { background: #dfeee6; color: var(--ok); }
.statut.valide_ap { background: var(--ok); color: #fff; }
.statut.refuse { background: var(--ko-fond); color: var(--ko); }
.ecart-pos { color: var(--ko); font-weight: 600; }
.ecart-neg { color: var(--warn); font-weight: 600; }
.indic { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.badge { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: .76em; font-weight: 600; white-space: nowrap; }
.badge.nuit { color: var(--violet); background: color-mix(in srgb, var(--violet) 12%, transparent); }
.badge.alerte { color: var(--rouge); background: color-mix(in srgb, var(--rouge) 12%, transparent); }
.badge.attention { color: var(--warn); background: var(--warn-fond); }

/* ---- Tableaux ---- */
.defile { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--bord); border-radius: var(--rayon); background: var(--carte); }
table { border-collapse: collapse; width: 100%; font-size: .9em; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--bord); text-align: left; white-space: nowrap; }
th { background: var(--carte); color: var(--bleu); font-weight: 700; position: sticky; top: 0; border-bottom: 2px solid var(--texte); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.cliquable { cursor: pointer; }
tr.cliquable:hover td { background: var(--bloc); }
tr.sous-total td { background: var(--bloc); font-weight: 700; color: var(--bleu); }
td.corrige { background: var(--jaune); font-weight: 600; }
tfoot td { font-weight: 700; background: var(--bloc); }

/* ---- Semaine du salarié ---- */
.jour { display: flex; gap: 12px; align-items: flex-start; }
.jour .date { width: 64px; flex: none; text-align: center; }
.jour .date b { display: block; font-size: 1.4em; line-height: 1; }
.jour .date span { font-size: .8em; color: var(--bleu); text-transform: uppercase; font-weight: 600; }
.jour.aujourdhui { border-color: var(--bleu); box-shadow: 0 0 0 1px var(--bleu); }
.jour .contenu { flex: 1; min-width: 0; }
.saisie-ligne { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; padding: 6px 0; border-top: 1px dashed var(--bord); }
.saisie-ligne:first-child { border-top: 0; }
.total { font-size: 1.1em; font-weight: 700; }

/* ---- Fenêtre modale ---- */
.voile { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modale {
  background: var(--carte); width: 100%; max-width: 720px; max-height: 92vh; overflow: auto;
  border-radius: 12px 12px 0 0; padding: 18px 16px calc(env(safe-area-inset-bottom) + 18px);
}
@media (min-width: 760px) { .voile { align-items: center; } .modale { border-radius: 8px; } }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 18px);
  background: var(--texte); color: var(--fond); padding: 10px 16px; border-radius: 99px; z-index: 60; max-width: 90vw;
}

/* ---- Connexion ---- */
.connexion { max-width: 380px; margin: 8vh auto; padding: 0 16px; }
.connexion .logo { width: 64px; height: 64px; display: block; margin: 0 auto 12px; }
.connexion h1 { text-align: center; }
.comptes-demo button { width: 100%; text-align: left; margin-top: 6px; }

.filtres { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); margin-bottom: 12px; }
.chiffres { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); margin-bottom: 12px; }
.chiffres .carte { margin: 0; background: var(--bloc); border-color: transparent; }
.chiffres .carte span { color: var(--bleu); font-weight: 600; }
.chiffres b { display: block; font-size: 1.4em; }

/* =====================================================================
   Feuille d'heures hebdomadaire
   ===================================================================== */
.feuille { background: #fff; color: #000; max-width: 1060px; margin: 0 auto 24px; padding: 28px 32px; border: 1px solid var(--bord); font-size: 14px; }
.feuille-titre { text-align: center; font-size: 1.15em; line-height: 1.35; margin-bottom: 10px; }
.feuille-entete { background: #f2f2f2; padding: 8px 10px 6px; margin-bottom: 18px; }
.feuille-entete h2 { color: #4472c4; font-size: 1.6em; margin: 0 0 8px; }
.feuille-entete dl { display: grid; grid-template-columns: 150px 1fr 150px 1fr; gap: 6px 10px; margin: 0; }
.feuille-entete dt { color: #4472c4; font-weight: 700; }
.feuille-entete dd { margin: 0; }
.feuille-table { width: 100%; border-collapse: collapse; font-size: .95em; }
.feuille-table th { position: static; background: #fff; color: #000; font-weight: 700; text-align: center; white-space: normal; line-height: 1.15;
  border-top: 2px solid #000; border-bottom: 2px solid #000; padding: 6px 4px; }
.feuille-table th.bleu { color: #4472c4; }
.feuille-table th.petit-th { font-size: .9em; }
.feuille-table td { text-align: center; border-bottom: 1px solid #bfbfbf; padding: 8px 4px; white-space: nowrap; }
.feuille-table td.jour { text-align: center; font-size: 1.05em; }
.feuille-table td.bleu { color: #4472c4; font-size: .92em; }
.feuille-table .violet { color: #7030a0; }
.feuille-table .rouge { color: #c00000; }
.feuille-table td.fort { font-size: 1.08em; }
.feuille-table td.surligne { background: #ffe699; }
.feuille-table .sep { border-left: 1px solid #bfbfbf; }
.feuille-table td:first-child { border-right: 1px solid #bfbfbf; }
.feuille-table tr.total td { color: #000; }
.feuille-table tr.total td.bleu { color: #4472c4; font-weight: 700; }
.feuille-table tr.total td.violet { color: #7030a0; }
.feuille-payees { display: flex; justify-content: flex-end; align-items: stretch; margin-right: calc(33.3% - 2px); }
.feuille-payees span { color: #4472c4; font-weight: 700; font-size: .9em; padding: 6px 6px 0; }
.feuille-payees b { border: 1px solid #bfbfbf; border-top: 0; min-width: 130px; text-align: center; padding: 6px 4px; font-size: 1.05em; }
.feuille-pied { text-align: center; margin-top: 56px; font-size: .95em; line-height: 1.4; }
.feuilles { overflow-x: auto; }
@media (max-width: 760px) {
  .feuille { padding: 14px; font-size: 12px; }
  .feuille-entete dl { grid-template-columns: 110px 1fr; }
}

/* ---- Impression : seulement les feuilles, une par page A4 paysage ---- */
@page { size: A4 landscape; margin: 10mm; }
@media print {
  body { background: #fff; }
  .entete, .bandeau-demo, .pas-imprime, .toast { display: none !important; }
  main { padding: 0; max-width: none; }
  .feuille { border: 0; margin: 0; padding: 0 4mm; max-width: none; page-break-after: always; break-after: page; }
  .feuille:last-child { page-break-after: auto; break-after: auto; }
  .feuille-entete, .feuille-table td.surligne { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
