/* Espace salarié – feuille de style autonome (aucune bibliothèque externe).
   Pensé d'abord pour le téléphone : on saisit ses heures entre deux livraisons. */

:root {
  --ink: #1b2235;
  --ink-2: #566079;
  --paper: #edf0f6;
  --card: #ffffff;
  --stripe: #f6f8fc;
  --line: #d6dce9;
  --blue: #3d5a9c;
  --blue-soft: #e2e9f7;
  --orange: #eda63b;
  --on-orange: #1b2235;
  --green: #1c7f5a;
  --green-soft: #dcf2e8;
  --red: #b8362f;
  --red-soft: #fbe3e1;
  --amber-soft: #fdf0d6;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --ink: #e8ecf6; --ink-2: #a3adc6; --paper: #0f131e; --card: #171d2c; --stripe: #1b2233;
  --line: #2b3550; --blue: #93aae2; --blue-soft: #202c4a; --green: #5ac79b; --green-soft: #15332a;
  --red: #ff8f87; --red-soft: #3a1c1b; --amber-soft: #3a2f14;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.65rem; font-weight: 750; }
h2 { font-size: 1.1rem; font-weight: 700; }
p { margin: 0 0 .75rem; }
a { color: var(--blue); }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: .5rem; top: -4rem; background: var(--card); padding: .5rem 1rem; z-index: 200; }
.skip-link:focus { top: .5rem; }
.logo { display: block; height: auto; max-width: min(15rem, 62vw); }
.logo--dark { display: none; }
[data-theme="dark"] .logo--light { display: none; }
[data-theme="dark"] .logo--dark { display: block; }

/* ---------- Structure : menu burger (petit écran) / menu latéral (grand écran) ---------- */
.shell { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: .5rem;
  padding: .5rem .75rem; background: var(--card); border-bottom: 1px solid var(--line);
}
.topbar__brand { margin-right: auto; }
.topbar .logo { max-width: 11rem; }
.icon-btn svg { width: 1.5rem; height: 1.5rem; }
.icon-btn { display: inline-grid; place-items: center; }

.scrim { position: fixed; inset: 0; z-index: 90; background: rgba(15, 19, 30, .55); }
.scrim[hidden] { display: none; }
html.nav-open { overflow: hidden; }

.nav {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 100; width: min(19rem, 86vw);
  display: flex; flex-direction: column; gap: .15rem; padding: 1rem;
  background: var(--card); border-right: 1px solid var(--line); overflow-y: auto;
  visibility: hidden; transform: translateX(-100%); transition: transform .2s ease, visibility .2s;
}
.nav.is-open { visibility: visible; transform: none; }
.nav__top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: 1rem; }
.nav__brand { display: block; }
.nav__spacer { flex: 1; }
.nav__item {
  display: flex; align-items: center; gap: .75rem; width: 100%; padding: .7rem .75rem; text-align: left;
  font: inherit; color: var(--ink-2); text-decoration: none; background: none; border: 0; border-radius: 8px; cursor: pointer;
}
.nav__item svg { width: 1.3rem; height: 1.3rem; flex: none; }
.nav__item:hover { background: var(--blue-soft); color: var(--ink); }
.nav__item[aria-current="page"] { background: var(--blue-soft); color: var(--ink); font-weight: 700; box-shadow: inset 3px 0 0 var(--orange); }
.nav form { display: contents; }
.nav__close { display: inline-grid; }

/* Bouton de thème : la lune propose le thème sombre, le soleil le thème clair. */
.theme-toggle .ic-sun { display: none; }
[data-theme="dark"] .theme-toggle .ic-sun { display: inline-grid; }
[data-theme="dark"] .theme-toggle .ic-moon { display: none; }
.ic-sun, .ic-moon { display: inline-grid; }

.main { width: 100%; max-width: 76rem; margin: 0 auto; padding: 1.25rem 1rem 2.5rem; }

@media (min-width: 60rem) {
  .shell { display: grid; grid-template-columns: 16rem 1fr; }
  .topbar, .scrim, .nav__close { display: none; }
  .nav {
    position: sticky; height: 100vh; align-self: start; width: auto; padding: 1.5rem 1rem;
    visibility: visible; transform: none; transition: none;
  }
  .main { padding: 2rem 2.5rem 3rem; }
}
@media (prefers-reduced-motion: reduce) { .nav { transition: none; } }

.page-head { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; align-items: flex-end; justify-content: space-between; margin-bottom: 1.25rem; }
.page-head__actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---------- Boutons, champs, pastilles ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 2.75rem; padding: .5rem 1rem;
  font: inherit; font-weight: 650; text-decoration: none; cursor: pointer; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
}
.btn:hover { border-color: var(--ink-2); }
.btn--primary { background: var(--orange); border-color: var(--orange); color: var(--on-orange); }
.btn--primary:hover { filter: brightness(.95); border-color: var(--orange); }
.btn--blue { background: var(--blue); border-color: var(--blue); color: #fff; }
[data-theme="dark"] .btn--blue { color: #0f131e; }
.btn--block { width: 100%; }
.btn--danger { color: var(--red); }

.field {
  width: 100%; min-height: 2.75rem; padding: .45rem .65rem; font: inherit; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 6px;
}
.field:hover { border-color: var(--ink-2); }
textarea.field { min-height: 5rem; resize: vertical; }
.field.is-invalid { border-color: var(--red); }
.check { width: 1.25rem; height: 1.25rem; accent-color: var(--blue); flex: none; }
.form-row { margin-bottom: 1rem; }
.form-row label, .label { display: block; font-weight: 650; margin-bottom: .3rem; }
.hint { color: var(--ink-2); font-size: .875rem; margin-top: .25rem; }
.error { color: var(--red); font-size: .875rem; margin-top: .25rem; }
.grid-2 { display: grid; gap: 0 1rem; }
@media (min-width: 40rem) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.chip { display: inline-block; padding: .1rem .6rem; font-size: .8rem; font-weight: 650; border-radius: 999px; background: var(--blue-soft); color: var(--blue); }
.chip--ok { background: var(--green-soft); color: var(--green); }
.chip--stop { background: var(--red-soft); color: var(--red); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.card__body { padding: 1rem 1.25rem; }
.card__head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .85rem 1.25rem; border-bottom: 1px solid var(--line); }
.card__foot { padding: .85rem 1.25rem; border-top: 1px solid var(--line); text-align: right; }
.stack > * + * { margin-top: 1rem; }
.cols { display: grid; gap: 1rem; align-items: start; }
@media (min-width: 60rem) { .cols { grid-template-columns: 1fr 1fr; } }

/* ---------- Messages ---------- */
.notice { display: flex; align-items: flex-start; gap: .75rem; padding: .75rem 1rem; margin-bottom: 1rem; border-radius: 8px; background: var(--blue-soft); }
.notice--success { background: var(--green-soft); }
.notice--danger { background: var(--red-soft); }
.notice--warning { background: var(--amber-soft); }
.notice p { margin: 0; flex: 1; }
.notice button { background: none; border: 0; font-size: 1.4rem; line-height: 1; cursor: pointer; color: inherit; }
.toast {
  position: fixed; top: .75rem; left: 50%; transform: translateX(-50%); z-index: 120; max-width: 92vw;
  padding: .55rem 1rem; font-weight: 650; border-radius: 999px; background: var(--ink); color: var(--paper);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
}
.toast[hidden] { display: none; }
.toast--success { background: var(--green); color: #fff; }
.toast--danger { background: var(--red); color: #fff; }
[data-theme="dark"] .toast--success, [data-theme="dark"] .toast--danger { color: #0f131e; }

/* ---------- Tableau de bord ---------- */
.facts { display: grid; gap: 1rem 1.5rem; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); margin: 0; }
.facts dt { font-size: .8rem; color: var(--ink-2); margin-bottom: .15rem; }
.facts dd { margin: 0; font-weight: 650; }
.total { font-size: 1.6rem; font-weight: 750; letter-spacing: -.02em; }

.week { margin-bottom: 1.25rem; overflow: hidden; }
.week__title { font-size: 1.05rem; }
.week__total { margin-left: auto; font-size: 1.2rem; font-weight: 750; }
.meter { position: relative; flex: 1 1 12rem; height: .6rem; border-radius: 999px; background: var(--blue-soft); overflow: hidden; }
.meter__base, .meter__extra { position: absolute; top: 0; bottom: 0; transition: width .3s; }
.meter__base { left: 0; width: calc(var(--base) * 1%); background: var(--blue); }
.meter__extra { left: calc(var(--base) * 1%); width: calc(var(--extra) * 1%); background: var(--orange); }
.meter__tick { position: absolute; top: 0; bottom: 0; left: calc(35 / 45 * 100%); width: 2px; background: var(--card); }
.meter-legend { flex-basis: 100%; font-size: .8rem; color: var(--ink-2); margin: -.15rem 0 0; }

.table-wrap { overflow-x: auto; }
.sheet { width: 100%; min-width: 46rem; border-collapse: collapse; }
.sheet th, .sheet td { padding: .35rem .5rem; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); background: var(--row, var(--card)); }
.sheet thead th { font-size: .8rem; font-weight: 650; color: var(--ink-2); }
.sheet tbody tr:nth-child(even) { --row: var(--stripe); }
.sheet .day { position: sticky; left: 0; z-index: 1; font-weight: 400; }
.sheet .num { text-align: right; font-weight: 700; }
.sheet .field { min-height: 2.4rem; padding: .3rem .5rem; }
.sheet input[type="time"] { width: 6.25rem; }
.sheet .site { min-width: 10rem; }
.sheet .vehicle { width: 8rem; }
.sheet .km { width: 6rem; display: inline-block; }
.sheet tfoot th, .sheet tfoot td { border-bottom: 0; font-weight: 650; }
.is-today .day { box-shadow: inset 4px 0 0 var(--orange); }
.is-sunday > * { color: var(--ink-2); }

/* ---------- Fenêtres (balise <dialog>) ---------- */
.dialog { width: min(32rem, calc(100vw - 1.5rem)); max-height: calc(100dvh - 1.5rem); padding: 0; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.dialog::backdrop { background: rgba(15, 19, 30, .55); }
.dialog form { display: flex; flex-direction: column; max-height: inherit; }
.dialog__head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.dialog__body { padding: 1.25rem; overflow-y: auto; }
.dialog__foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .85rem 1.25rem; border-top: 1px solid var(--line); }
.icon-btn { width: 2.5rem; height: 2.5rem; font-size: 1.5rem; line-height: 1; color: var(--ink-2); background: none; border: 0; border-radius: 8px; cursor: pointer; }
.icon-btn:hover { background: var(--blue-soft); }
.recipients { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.recipients label { display: flex; align-items: center; gap: .75rem; padding: .6rem .85rem; cursor: pointer; }
.recipients label + label { border-top: 1px solid var(--line); }
.recipients label:hover { background: var(--blue-soft); }
.recipients small { display: block; color: var(--ink-2); }
.check-row { display: flex; align-items: center; gap: .6rem; }

/* ---------- Pages sans menu (connexion, erreurs) ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 1rem; }
.auth__box { width: min(26rem, 100%); }
.auth__logo { display: flex; justify-content: center; margin-bottom: 1.5rem; }
.auth h1 { font-size: 1.4rem; margin-bottom: .5rem; }
.auth .center { text-align: center; }

/* ---------- Feuille de présence (page publique et impression) ---------- */
.bare-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1rem; }
.paper { max-width: 62rem; margin: 0 auto 2rem; padding: 1.25rem; color: #111; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.paper__head { display: grid; gap: .75rem; margin-bottom: 1rem; }
@media (min-width: 45rem) { .paper__head { grid-template-columns: 1fr 2fr; } }
.paper__logo { width: 16rem; max-width: 100%; height: auto; }
.box { border: 1px solid #8a8a8a; padding: .35rem .75rem; margin-top: .5rem; }
.box--title { text-align: center; font-size: 1.3rem; font-weight: 800; margin-top: 0; }
.paper__who { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.paper table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; font-size: .95rem; }
.paper th, .paper td { padding: .2rem .4rem; text-align: center; border: 1px solid #cfc5c5; }
.paper thead th, .paper tfoot th, .paper tfoot td { background: #5675af; color: #fff; }
.paper tbody tr:nth-child(even) { background: #f3f1f1; }
.paper tbody th { font-weight: 400; }
.paper .total-cell { border: 2px solid #000; }
.paper__totals { max-width: 22rem; margin-left: auto; padding: .75rem 1rem; color: #fff; background: #5675af; border-radius: 6px; }

@media print {
  @page { size: A4; margin: 10mm; }
  * { print-color-adjust: exact !important; -webkit-print-color-adjust: exact !important; }
  body { background: #fff; }
  .bare-head, .no-print { display: none !important; }
  .paper { margin: 0; padding: 0; border: 0; max-width: none; }
  .paper table { break-inside: avoid; }
}
@media (prefers-reduced-motion: reduce) { .meter__base, .meter__extra { transition: none; } }
