:root {
  --bleu: #25618a;       /* bleu Titouh, foncé pour bien se lire */
  --bleu-fonce: #1c4b6b;
  --bleu-pale: #e6f0f6;
  --or: #e0a53a;         /* point jaune du i */
  --fond: #f3f5f8;
  --carte: #ffffff;
  --texte: #15202b;
  --doux: #4f5d6b;
  --trait: #d5dce4;
  --vert: #1d7a3a;
  --vert-pale: #e5f3e9;
  --rouge: #b3261e;
  --rouge-pale: #fbe9e7;
  --jaune: #ffc400;
  --rayon: 16px;
  --taille: 20px;
}
html.grand { --taille: 23px; }
html.tres-grand { --taille: 26px; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: var(--taille);
  line-height: 1.4;
  color: var(--texte);
  background: var(--fond);
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
  padding-bottom: calc(92px + env(safe-area-inset-bottom));
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

/* ---------- En-tête ---------- */
.haut {
  position: sticky; top: 0; z-index: 10;
  background: #fff; color: var(--texte);
  display: flex; align-items: center; gap: 14px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  border-bottom: 4px solid var(--bleu);
}
.haut-logo { height: 46px; width: auto; flex: none; }
.haut-texte { flex: 1; min-width: 0; text-align: right; }
.haut-titre { font-size: 1.1em; font-weight: 800; line-height: 1.2; color: var(--bleu); }
.haut-sous { font-size: .72em; color: var(--doux); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

main { max-width: 640px; margin: 0 auto; padding: 16px; outline: none; }

/* ---------- Menu du bas ---------- */
.bas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; background: #fff; border-top: 1px solid var(--trait);
  padding-bottom: env(safe-area-inset-bottom);
}
.bas button {
  flex: 1; border: 0; background: none; padding: 9px 2px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--doux); font-size: 14px; font-weight: 700;
  border-top: 4px solid transparent;
}
.bas svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bas button.actif { color: var(--bleu); border-top-color: var(--bleu); }

/* ---------- Blocs ---------- */
.carte {
  background: var(--carte); border-radius: var(--rayon);
  padding: 18px; margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(16, 32, 48, .08);
}
.carte h2 { font-size: 1em; margin: 0 0 12px; font-weight: 800; }
.aide { color: var(--doux); font-size: .85em; margin: 6px 0 0; }
.vide { color: var(--doux); text-align: center; padding: 22px 8px; }

/* Barre de date */
.date {
  display: flex; align-items: center; gap: 10px;
  background: var(--carte); border-radius: var(--rayon); padding: 10px;
  margin-bottom: 14px; box-shadow: 0 1px 3px rgba(16, 32, 48, .08);
}
.date .milieu { flex: 1; text-align: center; }
.date .jour-nom { font-weight: 800; font-size: 1.05em; }
.date .jour-etat { font-size: .78em; color: var(--doux); }
.date .jour-etat.ok { color: var(--vert); font-weight: 700; }
.rond {
  width: 56px; height: 56px; border-radius: 50%; border: 0; flex: none;
  background: var(--bleu-pale); color: var(--bleu); font-size: 30px; font-weight: 800; line-height: 1;
}
.rond:disabled { opacity: .3; }
.lien-auj { display: block; margin: -6px auto 14px; border: 0; background: none; color: var(--bleu); font-weight: 700; text-decoration: underline; font-size: .85em; }

/* Kilomètres */
.km-grille { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.case {
  border: 2px solid var(--trait); border-radius: 14px; background: #fafbfc;
  padding: 12px; text-align: left; width: 100%; min-height: 92px;
}
.case .etiquette { display: block; font-size: .75em; color: var(--doux); font-weight: 700; }
.case .valeur { display: block; font-size: 1.35em; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.case .valeur.attente { color: var(--bleu); font-size: .95em; font-weight: 700; }
.case.rempli { border-color: var(--bleu); background: #fff; }
.total {
  margin-top: 12px; padding: 12px 14px; border-radius: 12px;
  background: var(--vert-pale); color: var(--vert); font-weight: 800; text-align: center;
}
.total.alerte { background: var(--rouge-pale); color: var(--rouge); }

/* Horaires */
.ligne-h { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.ligne-h:last-of-type { margin-bottom: 0; }
.ligne-h .nom { grid-column: 1 / -1; font-weight: 800; font-size: .9em; margin-bottom: -4px; }
.case.h { min-height: 72px; padding: 8px 10px; text-align: center; }
.case.h .valeur { font-size: 1.3em; white-space: nowrap; }
.case.h .valeur.attente { font-size: .85em; white-space: normal; }

/* Compteur */
.compteur { display: flex; align-items: center; justify-content: center; gap: 26px; }
.compteur .nb { font-size: 2em; font-weight: 800; min-width: 2.2em; text-align: center; font-variant-numeric: tabular-nums; }

/* Boutons */
.bouton {
  display: block; width: 100%; border: 0; border-radius: 14px;
  padding: 16px; font-weight: 800; text-align: center;
  background: var(--bleu); color: #fff; margin-top: 10px; min-height: 60px;
}
.bouton.vert { background: var(--vert); }
.bouton.clair { background: #fff; color: var(--bleu); border: 2px solid var(--bleu); }
.bouton.rouge { background: #fff; color: var(--rouge); border: 2px solid var(--rouge); }
.bouton.petit { padding: 10px 14px; min-height: 48px; font-size: .9em; }
.bouton:disabled { opacity: .45; }

/* Pleins */
.plein { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--trait); }
.plein:last-of-type { border-bottom: 0; }
.plein button { border: 0; background: var(--rouge-pale); color: var(--rouge); border-radius: 10px; padding: 8px 12px; font-weight: 700; font-size: .8em; }

/* Mois */
.totaux { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.totaux div { background: var(--bleu); color: #fff; border-radius: var(--rayon); padding: 14px 12px; text-align: center; }
.totaux strong { display: block; font-size: 1.4em; font-variant-numeric: tabular-nums; }
.totaux span { font-size: .78em; opacity: .92; }
.liste-jour {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  width: 100%; background: var(--carte); border: 0; border-radius: 14px;
  padding: 14px 16px; margin-bottom: 8px; text-align: left;
  box-shadow: 0 1px 2px rgba(16, 32, 48, .07);
}
.liste-jour .g { font-weight: 800; }
.liste-jour .p { font-size: .78em; color: var(--doux); }
.liste-jour .d { font-weight: 800; color: var(--vert); white-space: nowrap; }
.liste-jour .d.manque { color: var(--rouge); font-size: .8em; }

/* Arrêts */
.arret { background: var(--carte); border-radius: 14px; padding: 16px; margin-bottom: 10px; box-shadow: 0 1px 2px rgba(16, 32, 48, .07); }
.arret .ordre { display: inline-block; min-width: 1.8em; height: 1.8em; line-height: 1.8em; text-align: center; border-radius: 50%; background: var(--bleu); color: #fff; font-weight: 800; font-size: .8em; margin-right: 8px; }
.arret .nom { font-weight: 800; }
.arret .detail { color: var(--doux); font-size: .85em; margin-top: 4px; }
.arret .actions { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; margin-top: 10px; }
.arret .actions .bouton { margin-top: 0; }
.fleches { display: flex; gap: 8px; margin-top: 8px; }
.fleches button { flex: 1; border: 1px solid var(--trait); background: #fff; border-radius: 10px; padding: 8px; font-size: .8em; font-weight: 700; color: var(--doux); }

/* Formulaires */
label.champ { display: block; margin-bottom: 14px; }
label.champ span { display: block; font-weight: 700; font-size: .85em; color: var(--doux); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=tel], input[type=time], textarea, select {
  width: 100%; border: 2px solid var(--trait); border-radius: 12px; background: #fafbfc;
  padding: 14px 12px; font-size: 1em;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--bleu); background: #fff; }
input.gros { font-size: 1.8em; font-weight: 800; text-align: center; letter-spacing: .03em; font-variant-numeric: tabular-nums; }
textarea { min-height: 96px; resize: vertical; }
.choix { display: flex; gap: 8px; flex-wrap: wrap; }
.choix button { flex: 1; min-width: 4.5em; border: 2px solid var(--trait); background: #fff; border-radius: 12px; padding: 12px 6px; font-weight: 700; }
.choix button.oui { border-color: var(--bleu); background: var(--bleu); color: #fff; }

/* Fenêtre (remplace les alertes du navigateur) */
.voile { position: fixed; inset: 0; z-index: 50; background: rgba(10, 20, 30, .55); display: flex; align-items: flex-end; justify-content: center; }
.fenetre {
  background: #fff; width: 100%; max-width: 640px; max-height: 92vh; overflow: auto;
  border-radius: 22px 22px 0 0; padding: 22px 18px calc(18px + env(safe-area-inset-bottom));
}
.fenetre h3 { margin: 0 0 10px; font-size: 1.1em; }
.fenetre p { margin: 0 0 10px; }
.erreur { color: var(--rouge); font-weight: 700; font-size: .85em; min-height: 1.2em; margin: 4px 0 0; }
.astuce { background: var(--bleu-pale); border-radius: 12px; padding: 12px 14px; font-size: .85em; margin: 10px 0 0; }

/* Message bref */
.message {
  position: fixed; left: 50%; bottom: calc(104px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translateX(-50%) translateY(16px); opacity: 0; pointer-events: none;
  background: var(--texte); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-weight: 700; font-size: .85em; transition: opacity .2s, transform .2s;
  max-width: calc(100% - 32px); text-align: center;
}
.message.vu { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Bandeau installation */
.installer { background: #fff7d6; border: 2px solid var(--jaune); border-radius: var(--rayon); padding: 14px 16px; margin-bottom: 14px; }
.installer strong { display: block; }
.installer .bouton { margin-top: 10px; }
.installer .plus-tard { display: block; margin: 8px auto 0; border: 0; background: none; color: var(--doux); text-decoration: underline; font-size: .8em; }
ol.etapes { padding-left: 1.3em; margin: 8px 0 0; }
ol.etapes li { margin-bottom: 8px; }
.icone-partage { display: inline-block; width: 1.1em; height: 1.1em; vertical-align: -0.15em; fill: none; stroke: var(--bleu); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

@media (min-width: 700px) {
  .voile { align-items: center; }
  .fenetre { border-radius: 22px; }
}
@media (prefers-reduced-motion: reduce) { .message { transition: none; } }
