/* KzAuto — démo PWA. Charte KzSuite (ui/kz_theme.py), bleu pétrole KzAuto.
   Couleurs vives pour les pastilles seulement ; le texte prend les teintes foncées. */
@font-face { font-family: "Lato"; src: url(polices/Lato-Medium.ttf); font-weight: 400 600; font-display: swap; }
@font-face { font-family: "Lato"; src: url(polices/Lato-Bold.ttf); font-weight: 700 800; font-display: swap; }
@font-face { font-family: "Lato"; src: url(polices/Lato-Black.ttf); font-weight: 900; font-display: swap; }
:root {
  --navy: #0B2545; --bleu: #1565D8; --bleu-fonce: #0E4CA8; --petrole: #0E7490; --petrole-clair: #67C9DA;
  --fond: #EEF4FF; --surface: #FFFFFF; --ligne: #E2E8F0; --texte: #0B2545; --texte2: #64748B;
  --side-texte: #B8C7DD; --side-survol: #16365F; --selection: #DCE8F9;
  --vert-bg: #E3F6EE; --vert-txt: #0F7A52;
  --ambre: #F5A524; --ambre-bg: #FFF4DD; --ambre-txt: #8A5300;
  --rouge: #E5484D; --rouge-bg: #FDE7E8; --rouge-txt: #B4232A;
  --bleu-bg: #E3EEFD; --bleu-txt: #0E4CA8; --gris-bg: #EEF1F5; --gris-txt: #475569;
  --rayon: 12px; --ombre: 0 1px 6px rgba(11, 37, 69, .07);
  font-family: "Lato", "Segoe UI", "Noto Naskh Arabic", "Tahoma", system-ui, sans-serif;
  color: var(--texte); background: var(--fond); font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { display: flex; overflow: hidden; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 10px; min-height: 40px; padding: 0 14px; }
button:active { transform: scale(.98); }
button:disabled { opacity: .45; cursor: not-allowed; }
.b-primaire { background: var(--bleu); color: #fff; font-weight: 700; }
.b-primaire:hover { background: var(--bleu-fonce); }
.b-clair { background: var(--fond); color: var(--texte); border: 1px solid var(--ligne); font-weight: 600; }
.b-clair:hover { background: var(--selection); }
.b-danger { background: var(--rouge-bg); color: var(--rouge-txt); font-weight: 600; }
.b-lien { background: none; color: var(--bleu); min-height: 30px; padding: 0 4px; text-decoration: underline; font-weight: 600; }
input, select, textarea { min-height: 40px; border: 1px solid var(--ligne); border-radius: 10px; padding: 0 12px; background: var(--surface); min-width: 0; }
textarea { padding: 8px 12px; min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--bleu); outline-offset: -1px; }
input[type=checkbox], input[type=radio] { min-height: 0; width: 18px; height: 18px; accent-color: var(--bleu); }

/* Menu latéral (bas de l'écran sur téléphone) */
.menu { width: 228px; flex: none; background: var(--navy); color: var(--side-texte); display: flex; flex-direction: column; padding: 14px 10px; gap: 3px; overflow-y: auto; }
.marque { display: flex; align-items: center; gap: 8px; font-weight: 900; font-size: 21px; color: #fff; padding: 4px 8px 16px; }
.marque b { color: var(--petrole-clair); font-weight: 900; }
.marque img { border-radius: 8px; }
.marque em { font-style: normal; font-size: 11px; font-weight: 700; background: var(--ambre); color: var(--navy); padding: 2px 8px; border-radius: 99px; }
.menu .groupe { font-size: 11px; font-weight: 800; letter-spacing: .08em; color: #5F7BA6; padding: 12px 10px 4px; }
.menu > button { display: flex; align-items: center; gap: 12px; background: none; color: var(--side-texte); text-align: start; font-weight: 600; }
.menu > button i { font-style: normal; width: 22px; text-align: center; color: #5F7BA6; font-weight: 900; }
.menu > button:hover { background: var(--side-survol); }
.menu > button.actif { background: var(--bleu); color: #fff; }
.menu > button.actif i { color: #fff; }
.menu > button b { margin-inline-start: auto; background: var(--rouge); color: #fff; border-radius: 99px; padding: 1px 8px; font-size: 12px; }
.menu-pied { margin-top: auto; padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.menu-pied select { background: var(--side-survol); color: #fff; border-color: #24497A; }
.licence-etat { font-size: 12px; color: var(--side-texte); padding: 0 8px; }

.contenu { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 22px 26px 40px; min-width: 0; min-height: 0; }
.titre { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-bottom: 16px; }
.titre h1 { margin: 0; font-size: 26px; font-weight: 900; }
.sous-titre { color: var(--texte2); }
.outils { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-inline-start: auto; }
.outils input[type=search] { width: 260px; }
.coche { display: inline-flex; align-items: center; gap: 8px; color: var(--texte); }
.aide { color: var(--texte2); font-size: 14px; margin: 0 0 10px; }
.onglets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.onglets button { background: var(--surface); border: 1px solid var(--ligne); font-weight: 700; color: var(--texte2); }
.onglets button.actif { background: var(--navy); color: #fff; border-color: var(--navy); }

.carte { background: var(--surface); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 16px; margin-bottom: 16px; }
.carte h2 { margin: 0 0 12px; font-size: 16px; font-weight: 800; }
.deux { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--surface); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 14px 16px; border-top: 4px solid var(--petrole); text-align: start; min-height: 0; display: block; width: 100%; }
button.kpi:hover { background: var(--selection); }
.kpi span { display: block; color: var(--texte2); font-size: 13px; font-weight: 600; }
.kpi b { display: block; font-size: 24px; font-weight: 900; margin-top: 4px; }
.kpi small { display: block; color: var(--texte2); font-size: 12px; margin-top: 2px; }
.kpi.alerte { border-top-color: var(--ambre); }
.kpi.danger { border-top-color: var(--rouge); }

.tableau-defile { overflow-x: auto; padding: 0; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: start; background: var(--fond); color: var(--texte2); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; white-space: nowrap; }
.table td { padding: 10px 12px; border-top: 1px solid var(--ligne); vertical-align: middle; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover td { background: var(--selection); }
.table .n { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .vide td { text-align: center; color: var(--texte2); cursor: default; padding: 28px; }
.table .vide:hover td { background: none; }
.sec { color: var(--texte2); font-size: 13px; }

.pastille { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.p-vert { background: var(--vert-bg); color: var(--vert-txt); }
.p-ambre { background: var(--ambre-bg); color: var(--ambre-txt); }
.p-rouge { background: var(--rouge-bg); color: var(--rouge-txt); }
.p-bleu { background: var(--bleu-bg); color: var(--bleu-txt); }
.p-gris { background: var(--gris-bg); color: var(--gris-txt); }

.liste { list-style: none; margin: 0; padding: 0; }
.liste li { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-top: 1px solid var(--ligne); }
.liste li:first-child { border-top: 0; }
.liste li > span:first-child { flex: 1; min-width: 0; }
.liste .vide { color: var(--texte2); }

/* Graphe : une série, barres fines, extrémités arrondies posées sur la ligne de base */
.graphe { display: flex; align-items: flex-end; gap: 10px; height: 190px; padding: 8px 4px 0; border-bottom: 1px solid var(--ligne); }
.graphe .col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.graphe .barre { width: min(34px, 70%); background: var(--petrole); border-radius: 4px 4px 0 0; min-height: 2px; }
.graphe .col:hover .barre { background: var(--navy); }
.graphe .col .bulle { position: absolute; bottom: calc(100% - 6px); background: var(--navy); color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .1s; z-index: 2; }
.graphe .col:hover .bulle, .graphe .col:focus .bulle { opacity: 1; }
.axe { display: flex; gap: 10px; padding: 6px 4px 0; }
.axe span { flex: 1; text-align: center; color: var(--texte2); font-size: 12px; }

/* Planning mensuel */
.planning { overflow-x: auto; }
.planning table { border-collapse: separate; border-spacing: 2px; font-size: 12px; min-width: 100%; }
.planning th { color: var(--texte2); font-weight: 700; padding: 4px 2px; text-align: center; }
.planning th.veh { text-align: start; white-space: nowrap; padding-inline-end: 10px; color: var(--texte); font-size: 13px; position: sticky; inset-inline-start: 0; background: var(--surface); z-index: 1; }
.planning td { width: 26px; min-width: 26px; height: 26px; border-radius: 4px; background: var(--fond); }
.planning td.loue { background: var(--petrole); cursor: pointer; }
.planning td.reserve { background: var(--ambre); cursor: pointer; }
.planning td.mission { background: var(--bleu); cursor: pointer; }
.planning td.atelier { background: var(--rouge); cursor: pointer; }
.planning th.auj { color: var(--bleu); }
.legende { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; color: var(--texte2); font-size: 13px; }
.legende i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-inline-end: 6px; }

/* Fenêtres */
.voile { position: fixed; inset: 0; background: rgba(11, 37, 69, .45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.voile[hidden] { display: none; }
.fenetre { background: var(--surface); border-radius: 16px; width: min(760px, 100%); max-height: 100%; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(11, 37, 69, .3); }
.fenetre header { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--ligne); }
.fenetre header h2 { margin: 0; font-size: 18px; font-weight: 900; flex: 1; }
.b-fermer { background: none; font-size: 26px; line-height: 1; min-height: 36px; padding: 0 10px; color: var(--texte2); }
.f-corps { padding: 16px 18px; overflow-y: auto; }
.fenetre footer { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--ligne); }
.fenetre footer .gauche { margin-inline-end: auto; }
.formulaire { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 16px; }
.formulaire label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 700; color: var(--texte2); }
.formulaire .large { grid-column: 1 / -1; }
.formulaire .info { grid-column: 1 / -1; background: var(--fond); border-radius: 10px; padding: 10px 12px; font-size: 14px; color: var(--texte); }
.avance[hidden] { display: none; }
.lignes-doc td input { width: 100%; }
.totaux { margin-inline-start: auto; width: min(320px, 100%); margin-top: 12px; }
.totaux div { display: flex; justify-content: space-between; padding: 4px 0; }
.totaux .total { font-weight: 900; font-size: 18px; border-top: 2px solid var(--navy); padding-top: 8px; margin-top: 4px; }
.erreur { color: var(--rouge-txt); background: var(--rouge-bg); border-radius: 8px; padding: 8px 12px; margin-top: 10px; font-weight: 600; }
.erreur:empty { display: none; }
.fiche-photo { height: 150px; border-radius: 12px; background: linear-gradient(135deg, var(--navy), var(--petrole)); color: #fff; display: flex; align-items: flex-end; padding: 14px; font-weight: 900; font-size: 20px; margin-bottom: 14px; }
.fiche-photo small { display: block; font-weight: 600; font-size: 13px; opacity: .85; }
.modules { display: grid; gap: 10px; }
.module { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--ligne); border-radius: 12px; padding: 12px; }
.module.ferme { background: var(--fond); }
.module p { margin: 2px 0 0; color: var(--texte2); font-size: 13px; }
.radios { display: flex; flex-wrap: wrap; gap: 16px; margin: 6px 0 12px; }

.toast { position: fixed; bottom: 22px; inset-inline-start: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 10px; font-weight: 600; z-index: 20; box-shadow: 0 6px 20px rgba(11, 37, 69, .3); }
[dir=rtl] .toast { transform: translateX(50%); }

/* Document imprimable */
.doc { font-size: 13px; color: #111; }
.doc .entete { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.doc .entete h3 { margin: 0; font-size: 20px; color: var(--navy); }
.doc .soc { font-weight: 900; color: var(--petrole); font-size: 16px; }
.doc table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.doc th { background: var(--fond); text-align: start; padding: 7px 8px; font-size: 12px; }
.doc td { padding: 7px 8px; border-bottom: 1px solid var(--ligne); }
.doc .signatures { display: flex; gap: 20px; margin-top: 28px; }
.doc .signatures div { flex: 1; border: 1px solid var(--ligne); border-radius: 8px; height: 90px; padding: 8px; font-weight: 700; font-size: 12px; }
.impression { display: none; }

@media (max-width: 900px) {
  body { flex-direction: column-reverse; }
  .menu { width: 100%; flex-direction: row; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); overflow-x: auto; gap: 2px; }
  .marque, .menu .groupe, .menu-pied { display: none; }
  .menu > button { flex-direction: column; gap: 2px; font-size: 11px; min-width: 66px; padding: 4px 6px; flex: none; }
  .menu > button b { position: absolute; margin: 0; }
  .contenu { padding: 16px 14px 30px; }
  .deux, .formulaire { grid-template-columns: 1fr; }
  .outils { margin-inline-start: 0; width: 100%; }
  .outils input[type=search] { width: 100%; flex: 1 1 100%; }
  .titre h1 { font-size: 22px; }
  .mobile-pied { display: flex !important; }
}
.mobile-pied { display: none; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
@media print {
  body > *:not(.impression) { display: none !important; }
  body { display: block; overflow: visible; background: #fff; }
  .impression { display: block; padding: 0; }
}
.table td:first-child b { white-space: nowrap; }
