/* ============================================================================
 * km-app.css — Styles de l'app Indemnités Km.
 * Hérite des variables du design system (/css/styles-v2.css) mais les redéfinit
 * LOCALEMENT (scope .km-body) pour la refonte visuelle « Kinetic Ledger »
 * (maquette Google Stitch 2026-07-10) — sans toucher au CSS global du site.
 * --primary, --accent, --success, --bg-*, --text-*, --radius-*, --shadow-*,
 * --font-heading, --font-body.
 * ==========================================================================*/

/* ---- Polices self-hébergées (CSP : pas de Google Fonts) ----
 * Inter (corps/labels) + Plus Jakarta Sans (titres). Latin only, ~96 Ko.
 * font-display: swap → texte visible immédiatement, pas de FOIT. */
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('fonts/inter-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('fonts/inter-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('fonts/inter-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Plus Jakarta Sans'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('fonts/jakarta-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Plus Jakarta Sans'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('fonts/jakarta-700.woff2') format('woff2');
}

/* ---- Variables refonte Kinetic Ledger (scopées à l'app) ----
 * Redéfinies sur .km-body pour ne PAS impacter le reste du site.
 * L'essentiel colle déjà au branding existant (primary/accent/polices) ;
 * on ajoute surtout le vert des montants, le canvas gris et les ombres douces. */
/* Filet de sécurité : box-sizing partout dans l'app (évite les débordements dus
   au padding qui s'ajoute à width:100%). Scopé à .km-body → n'affecte pas le site. */
.km-body, .km-body *, .km-body *::before, .km-body *::after { box-sizing: border-box; }

.km-body {
  --primary: #0f2b46;          /* bleu marine — header, actions primaires */
  --primary-deep: #00162c;     /* variante très sombre (dégradés header) */
  --accent: #ff6b4a;           /* coral — CTA / onglet actif */
  --accent-hover: #e85a3a;
  --success: #10b981;          /* vert — montants / indemnités */
  --success-muted: #ecfdf5;    /* fond vert pâle (pastilles, badges) */
  --bg-canvas: #f8f9fa;        /* fond appli (Level 0) */
  --bg-warm: #f8f9fa;          /* alias — l'app utilisait --bg-warm comme fond */
  --bg-light: #f5f3f3;
  --border: #e2e8f0;           /* bordures fines (Stitch border-light) */
  --text-primary: #1b1c1c;
  --text-secondary: #43474d;
  --text-light: #74777e;       /* labels/outline */
  --radius-sm: 8px;            /* boutons / champs */
  --radius-md: 16px;           /* cartes / modales */
  --radius-lg: 24px;           /* grandes modales (bottom sheet) */
  --shadow-sm: 0 4px 20px rgba(15, 43, 70, 0.05);   /* Level 1 : cartes */
  --shadow-md: 0 10px 30px rgba(15, 43, 70, 0.10);  /* Level 2 : modales/flottant */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Layout en colonne flex : header (haut) + main (zone scrollable) + tab bar (bas).
   La tab bar n'est PLUS en position:fixed — elle est un enfant flex, donc
   TOUJOURS visible en bas quel que soit le device. `position:fixed` sur un body
   scrollable était cassé en WebView iOS (Capacitor contentInset) : la barre
   sortait de l'écran. Le flex column règle ça définitivement. */
.km-body {
  font-family: var(--font-body);
  background: var(--bg-warm);
  color: var(--text-primary);
  margin: 0;
  display: flex;
  flex-direction: column;
  /* 100dvh (dynamic viewport) = zone réellement visible en WebView iOS. */
  height: 100vh;
  height: 100dvh;
  overflow: hidden; /* seul .km-main scrolle, pas le body entier */
}

/* ---- Header (bandeau bleu marine plein, style Kinetic Ledger) ---- */
.km-header {
  flex: none; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 14px;
  /* Dégradé subtil du marine profond vers le primary : donne de la profondeur
     au bandeau sans le rendre plat. */
  background: linear-gradient(135deg, var(--primary-deep), var(--primary));
  color: #fff;
  box-shadow: 0 2px 12px rgba(15, 43, 70, 0.18);
}
.km-header-logo {
  flex: none; width: 38px; height: 38px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.12); color: #fff;
}
.km-header-logo svg { width: 22px; height: 22px; }
.km-header-title { display: flex; flex-direction: column; line-height: 1.15; flex: 1; }
.km-header-title strong { font-family: var(--font-heading); font-weight: 700; font-size: 1.12rem; letter-spacing: -0.01em; }
.km-header-title span { font-size: 0.72rem; opacity: 0.72; margin-top: 1px; }
.km-icon-btn {
  background: rgba(255,255,255,.12); border: none; color: #fff;
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: background .15s;
}
.km-icon-btn:hover { background: rgba(255,255,255,.22); }
.km-icon-btn svg { display: block; }

/* ---- Layout ---- */
/* Zone scrollable unique. flex:1 -> occupe toute la place entre header et tab bar.
   -webkit-overflow-scrolling pour un scroll fluide en WebView iOS. */
.km-main {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%; max-width: 720px; margin: 0 auto; padding: 16px;
}
.km-tab { animation: kmfade .2s ease; }
@keyframes kmfade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.km-hidden { display: none !important; }

/* ---- Cartes / champs ---- */
.km-card {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
  padding: 18px; margin-bottom: 16px;
}
.km-card h2 { font-family: var(--font-heading); font-size: 1.1rem; margin: 0 0 14px; color: var(--primary); }
.km-field { margin-bottom: 14px; position: relative; }
.km-field > label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.km-field small { color: var(--text-light); font-weight: 400; }
.km-field input[type="text"], .km-field input[type="number"], .km-field input[type="date"], .km-field select {
  box-sizing: border-box;
  width: 100%; padding: 12px 14px; border: 2px solid var(--border);
  border-radius: var(--radius-sm); font-family: var(--font-body); font-size: 1rem;
  background: #fff; color: var(--text-primary);
}
.km-field input:focus, .km-field select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,43,70,.10); }

/* ---- Champ avec icône (adresses) ---- */
.km-input-icon { position: relative; }
.km-input-icon .km-field-ico {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--text-light); pointer-events: none;
}
.km-input-icon input { padding-left: 40px !important; }

/* ---- Timeline départ → arrivée (style Kinetic Ledger) ----
   Ligne verticale pointillée reliant deux pastilles ; départ plein, arrivée creuse.
   Le décalage (28px) est porté par les LIGNES, pas par le conteneur, pour que les
   champs (width:100%) restent dans la carte sans déborder à droite. */
.km-timeline { position: relative; margin: 4px 0 14px; }
.km-timeline::before {
  content: ''; position: absolute; left: 6px; top: 36px; bottom: 40px;
  border-left: 2px dashed var(--border);
}
.km-timeline-row { position: relative; padding-left: 28px; }
.km-timeline-row .km-field { margin-bottom: 14px; }
.km-timeline-node {
  position: absolute; left: 0; top: 36px; width: 14px; height: 14px;
  border-radius: 50%; box-shadow: 0 0 0 4px #fff; z-index: 1;
}
.km-timeline-node.is-start { background: var(--primary); }
.km-timeline-node.is-end { background: #fff; border: 2px solid var(--primary); }
/* Bouton d'inversion départ ⇄ arrivée : petit rond posé à droite, centré
   verticalement entre les deux champs de la timeline. */
.km-swap-btn {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  z-index: 2; width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: #fff; border: 1px solid var(--border); color: var(--primary);
  cursor: pointer; box-shadow: var(--shadow-sm, 0 2px 8px rgba(15,43,70,.08));
  transition: transform .3s ease, border-color .15s, background .15s;
}
.km-swap-btn:hover { border-color: var(--primary); background: var(--bg-light, #f8f9fa); }
.km-swap-btn:active { background: var(--success-muted, #ecfdf5); }
.km-swap-btn svg { width: 18px; height: 18px; }
.km-swap-btn.is-swapping { transform: translateY(-50%) rotate(180deg); }

/* Lien texte discret (ex. « Télécharger un modèle CSV »). */
.km-btn-link {
  display: inline-block; background: none; border: none; padding: 4px 0;
  color: var(--primary); font-size: 0.85rem; font-weight: 600; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}
.km-btn-link:hover { color: var(--accent); }

/* ============================================================================
 * Réglages : navigation « à la iOS » (menu racine <-> pages détail).
 * ==========================================================================*/
.km-settings-box { padding-top: 14px; }
.km-settings-head { position: relative; }
.km-settings-head h2 { flex: 1; text-align: center; }
.km-settings-back { font-size: 1.5rem; line-height: 1; font-weight: 400; }
/* Menu racine : lignes cliquables avec icône + libellé + chevron. */
.km-settings-menu { display: flex; flex-direction: column; gap: 8px; padding: 4px 0 2px; }
.km-settings-row {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--bg-light, #f8f9fa); border: 1px solid var(--border);
  border-radius: var(--radius-md, 16px); padding: 14px 16px; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.km-settings-row:hover { background: #fff; border-color: var(--primary); }
.km-settings-ico { font-size: 1.35rem; flex: none; width: 30px; text-align: center; }
.km-settings-label { flex: 1; font-family: var(--font-heading); font-weight: 600; color: var(--primary); font-size: 0.98rem; display: flex; flex-direction: column; gap: 2px; }
.km-settings-label small { font-family: var(--font-body); font-weight: 400; font-size: 0.76rem; color: var(--text-light); text-transform: none; letter-spacing: 0; }
.km-settings-chev { flex: none; color: var(--text-light); font-size: 1.3rem; }
/* Pages détail : légère apparition par glissement. */
.km-settings-page { animation: km-slide-in .22s ease; }
@keyframes km-slide-in { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }

/* Badge « par défaut » (salarié présélectionné en Saisie). */
.km-badge-def {
  display: inline-block; font-size: 0.68rem; font-weight: 700; letter-spacing: .02em;
  color: var(--accent); background: #fff2ee; border: 1px solid #ffd7cc;
  padding: 1px 7px; border-radius: 999px; margin-left: 6px; vertical-align: middle;
  text-transform: uppercase;
}
/* Champ date : hauteur alignée sur les autres inputs (Safari/iOS ne respecte pas
   le padding vertical sur le picker natif → on force via box-sizing + line-height). */
.km-field input[type="date"] { box-sizing: border-box; min-height: 48px; line-height: 1.2; -webkit-appearance: none; appearance: none; }
.km-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-light); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 14px;
}
.km-toggle-row label { margin: 0; flex: 1; padding-right: 12px; font-weight: 600; color: var(--text-primary); font-size: 0.92rem; }
/* Switch iOS moderne (vert = actif) construit sur la checkbox native. */
.km-toggle-row input[type="checkbox"] {
  -webkit-appearance: none; appearance: none; position: relative;
  width: 46px; height: 26px; flex: none; border-radius: 50px;
  background: #cbd2dc; cursor: pointer; transition: background .18s; margin: 0;
}
.km-toggle-row input[type="checkbox"]::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .18s;
}
.km-toggle-row input[type="checkbox"]:checked { background: var(--success); }
.km-toggle-row input[type="checkbox"]:checked::after { transform: translateX(20px); }
.km-radio-group { display: flex; flex-direction: column; gap: 8px; }
.km-radio-group label { font-weight: 500; color: var(--text-primary); font-size: 0.92rem; }

/* ---- Boutons ----
   Kinetic Ledger : primaire = bleu marine (autorité) ; le coral est réservé à
   l'onglet actif et aux CTA d'attention. */
.km-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px 18px; border: none; border-radius: var(--radius-sm);
  background: var(--primary); color: #fff; font-family: var(--font-heading);
  font-weight: 700; font-size: 0.95rem; cursor: pointer; transition: background .15s, box-shadow .15s;
  box-shadow: var(--shadow-sm);
}
.km-btn:hover { background: var(--primary-deep); }
.km-btn svg { width: 18px; height: 18px; }
.km-btn-ghost { background: #fff; color: var(--primary); border: 1px solid var(--border); box-shadow: none; }
.km-btn-ghost:hover { border-color: var(--primary); background: var(--bg-light); }
.km-btn-big { padding: 18px; font-size: 1.1rem; border-radius: var(--radius-md); }
.km-actions { display: flex; gap: 10px; margin-top: 14px; }
.km-actions .km-btn { width: auto; flex: 1; }

/* ---- Résultat (carte de calcul) ---- */
.km-result {
  background: linear-gradient(135deg, var(--primary-deep), var(--primary));
  color: #fff; border-radius: var(--radius-md); padding: 24px; text-align: center;
  box-shadow: var(--shadow-sm); margin-bottom: 12px;
}
/* Montant calculé = valeur → vert clair sur fond marine. */
.km-result-amount { font-family: var(--font-heading); font-size: 2.5rem; font-weight: 800; color: #4edea3; }
.km-result-detail { font-size: 0.85rem; opacity: 0.82; margin-top: 6px; }
.km-note { font-size: 0.78rem; color: var(--text-light); line-height: 1.5; margin: 4px 2px 0; }

/* ---- Carte / suggestions ---- */
.km-map { height: 300px; border-radius: var(--radius-md); overflow: hidden; margin-bottom: 14px; border: 1px solid var(--border); }
.km-suggest {
  list-style: none; margin: 4px 0 0; padding: 0; position: absolute; z-index: 30;
  left: 0; right: 0; background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md); max-height: 220px; overflow-y: auto;
}
.km-suggest:empty { display: none; }
.km-suggest li { padding: 10px 12px; font-size: 0.85rem; cursor: pointer; border-bottom: 1px solid var(--bg-light);
  display: flex; align-items: center; gap: 8px; }
.km-suggest li:hover { background: var(--bg-warm); }
.km-suggest-label { flex: 1; min-width: 0; }
/* Tag « ≈ approx. » : adresse imprécise (rue/lieu-dit sans numéro exact). */
.km-suggest-approx {
  flex: none; font-size: 0.68rem; font-weight: 700; white-space: nowrap;
  color: #9a6a00; background: #fff4d6; border-radius: 50px; padding: 2px 8px;
}

/* ---- GPS ---- */
.km-gps-card { text-align: center; }
.km-gps-live { margin-bottom: 18px; }
.km-gps-km { font-family: var(--font-heading); font-size: 3rem; font-weight: 800; color: var(--primary); }
.km-gps-status { color: var(--text-secondary); font-size: 0.9rem; }
.km-gps-card.is-active .km-gps-km { color: var(--accent); }
.km-gps-recover { background: var(--teal-light); border-radius: var(--radius-sm); padding: 12px; margin-top: 12px; font-size: 0.85rem; }

/* Bandeau "enregistrement en cours" : visible seulement pendant le suivi actif. */
.km-gps-banner {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  background: #fdecea; color: #c0392b; border: 1px solid #f5c6cb;
  border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 16px;
  font-size: 0.85rem; font-weight: 700;
}
.km-gps-live-dot {
  width: 11px; height: 11px; border-radius: 50%; background: #e74c3c;
  animation: gpspulse 1.2s ease-in-out infinite;
}
@keyframes gpspulse {
  0%,100% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 0 rgba(231,76,60,.5); }
  50% { opacity: .6; transform: scale(1.15); box-shadow: 0 0 0 6px rgba(231,76,60,0); }
}
/* Bloc d'explication du fonctionnement GPS (transparence). */
.km-gps-explain { margin-top: 16px; text-align: left; }
.km-gps-explain p { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.55; margin-bottom: 8px; }
.km-gps-explain strong { color: var(--text-primary); }

/* ---- Filtres / listes ---- */
.km-filters { display: flex; gap: 10px; margin-bottom: 14px; }
.km-filters select { flex: 1; padding: 11px; border: 2px solid var(--border); border-radius: var(--radius-sm); background: #fff; font-size: 0.9rem; }
.km-list { display: flex; flex-direction: column; gap: 12px; }
.km-item {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 16px; display: flex; align-items: center; gap: 12px;
}
.km-item-main { flex: 1; min-width: 0; }
.km-item-main .km-item-motif { font-family: var(--font-heading); font-weight: 600; font-size: 0.95rem; color: var(--primary); display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.km-item-main .km-item-meta { font-size: 0.78rem; color: var(--text-light); margin-top: 4px; }
.km-item-km { font-family: var(--font-heading); font-weight: 700; font-size: 1.05rem; color: var(--primary); white-space: nowrap; }
.km-item-del { background: none; border: none; color: var(--text-light); font-size: 20px; cursor: pointer; line-height: 1; padding: 2px 4px; border-radius: 6px; }
.km-item-del:hover { background: #fdecea; color: #c0392b; }
/* Badge source (pill) : neutre par défaut, teinté selon la source. */
.km-badge {
  display: inline-block; font-size: 0.64rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .02em; padding: 2px 8px; border-radius: 50px;
  background: var(--bg-light); color: var(--text-secondary);
}

/* Historique : sélection multiple (cases à cocher + suppression en masse). */
.km-histo-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 10px; padding: 4px 2px;
}
.km-histo-selall { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text-secondary); cursor: pointer; }
.km-histo-selall input { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.km-histo-check { width: 20px; height: 20px; flex: none; accent-color: var(--accent); cursor: pointer; }
.km-btn-danger { background: var(--danger, #e74c3c); color: #fff; border: none; }
.km-btn-danger:hover { filter: brightness(0.94); }
.km-empty { text-align: center; color: var(--text-light); padding: 40px 0; }

/* ---- Récap ---- */
.km-recap-group { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 16px; margin-bottom: 12px; }
.km-recap-group h3 { font-family: var(--font-heading); font-size: 1rem; color: var(--primary); margin: 0 0 4px; }
.km-recap-veh { font-size: 0.85rem; color: var(--text-primary); font-weight: 600; margin: 2px 0 4px; }
.km-recap-sub { font-size: 0.8rem; color: var(--text-light); margin-bottom: 10px; }
.km-recap-detail { display: flex; justify-content: space-between; font-size: 0.82rem; color: var(--text-secondary); padding: 2px 0; }
.km-recap-total { display: flex; justify-content: space-between; font-weight: 700; padding-top: 10px; margin-top: 4px; border-top: 1px solid var(--border); }
/* Montants = indemnités dues → vert (Kinetic Ledger : le vert renforce la valeur). */
.km-recap-total .amount { color: var(--success); font-family: var(--font-heading); }
.km-recap-grandtotal {
  background: linear-gradient(135deg, var(--primary-deep), var(--primary));
  color: #fff; border-radius: var(--radius-md); padding: 20px; text-align: center;
  margin: 14px 0; box-shadow: var(--shadow-sm);
}
.km-recap-grandtotal .amount { font-family: var(--font-heading); font-size: 1.9rem; font-weight: 800; color: #4edea3; }
.km-export-actions { margin-top: 8px; }

/* ---- Carte de synthèse annuelle (tête du récap) ---- */
.km-year-card {
  background: linear-gradient(135deg, var(--primary), var(--primary-light, #163a5f));
  color: #fff; border-radius: var(--radius-md); padding: 16px 18px; margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.km-year-title { font-family: var(--font-heading); font-size: 0.95rem; font-weight: 700; opacity: 0.9; margin-bottom: 12px; }
.km-year-grid { display: flex; gap: 10px; }
.km-year-stat { flex: 1; min-width: 0; text-align: center; }
.km-year-val { display: block; font-family: var(--font-heading); font-size: 1.35rem; font-weight: 800; line-height: 1.1; }
.km-year-lbl { display: block; font-size: 0.68rem; opacity: 0.82; margin-top: 3px; }
.km-year-constante {
  margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.2);
  display: flex; flex-direction: column; gap: 4px; font-size: 0.78rem;
}
.km-year-constante span { opacity: 0.85; }
.km-year-constante strong { font-weight: 700; }
.km-year-constante > * { display: flex; justify-content: space-between; }

/* ---- Tab bar ---- */
/* Enfant flex du body (plus de position:fixed, cassé en WebView iOS). flex:none
   -> elle garde sa hauteur et reste TOUJOURS visible en bas de l'écran. */
.km-tabbar {
  flex: none; z-index: 60;
  display: flex; background: #fff; border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -4px 20px rgba(15,43,70,.06);
}
.km-tabbtn {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; padding: 9px 2px 7px; cursor: pointer;
  /* 5 onglets : label lisible, pas de retour à la ligne, coupe propre si étroit. */
  font-size: 0.66rem; color: var(--text-light); font-family: var(--font-body);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.km-tabbtn.is-active { color: var(--accent); }
.km-tabico { font-size: 1.1rem; line-height: 1; }

/* ---- Modale ---- */
/* z-index très élevé : Leaflet monte ses panes/contrôles jusqu'à ~1000,
   la modale doit passer au-dessus de la carte de l'onglet Trajet. */
.km-modal {
  position: fixed; inset: 0; z-index: 4000; background: rgba(10,22,40,.5);
  display: flex; align-items: flex-end; justify-content: center;
}
.km-modal-box { position: relative; z-index: 4001; }
/* Les contrôles Leaflet (zoom, attribution) ne doivent jamais dépasser la modale. */
.leaflet-pane, .leaflet-top, .leaflet-bottom, .leaflet-control { z-index: 400 !important; }
.km-modal-box {
  box-sizing: border-box;
  background: #fff; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: 18px;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
}
.km-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.km-modal-head h2 { font-family: var(--font-heading); font-size: 1.15rem; color: var(--primary); margin: 0; }
.km-modal-head .km-icon-btn { background: var(--bg-light); color: var(--text-primary); }
.km-sub-block { margin-bottom: 20px; }
.km-sub-block h4 { font-size: 0.9rem; color: var(--text-secondary); margin: 0 0 8px; text-transform: uppercase; letter-spacing: .04em; }
.km-legal-links { list-style: none; padding: 0; margin: 0 0 8px; }
.km-legal-links li { margin-bottom: 6px; }
.km-legal-links a { color: var(--accent); text-decoration: none; font-size: 0.92rem; font-weight: 600; }
.km-legal-links a:hover { text-decoration: underline; }

/* ---- Aide & guide : liste d'articles + lecture ---- */
.km-help-list { display: flex; flex-direction: column; gap: 8px; padding: 4px 0 2px; animation: km-slide-in .22s ease; }
.km-help-intro { font-size: 0.82rem; color: var(--text-light); line-height: 1.5; margin: 0 2px 6px; }
.km-help-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 13px 14px; background: var(--surface, #f7f8fa); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; transition: border-color .15s, background .15s;
}
.km-help-row:hover { background: #fff; border-color: var(--primary); }
.km-help-row-ico { font-size: 1.3rem; flex: none; width: 30px; text-align: center; }
.km-help-row-txt { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.km-help-row-txt strong { font-family: var(--font-heading); font-weight: 600; color: var(--primary); font-size: 0.96rem; }
.km-help-row-txt small { font-family: var(--font-body); font-size: 0.76rem; color: var(--text-light); line-height: 1.4; }
.km-help-row-chev { flex: none; color: var(--text-light); font-size: 1.3rem; }

.km-help-article { animation: km-slide-in .22s ease; }
.km-help-article h3 { font-family: var(--font-heading); color: var(--primary); font-size: 1.25rem; margin: 2px 0 4px; line-height: 1.25; }
.km-help-article .km-help-lead { font-size: 0.9rem; color: var(--text-secondary); line-height: 1.55; margin: 0 0 16px; }
.km-help-article h4 { font-family: var(--font-heading); color: var(--primary); font-size: 1rem; margin: 20px 0 7px; }
.km-help-article p { font-size: 0.9rem; color: var(--text-secondary); line-height: 1.6; margin: 0 0 10px; }
.km-help-article ul, .km-help-article ol { margin: 0 0 12px; padding-left: 20px; }
.km-help-article li { font-size: 0.9rem; color: var(--text-secondary); line-height: 1.55; margin-bottom: 6px; }
.km-help-article strong { color: var(--primary); }
.km-help-article code { background: rgba(15,43,70,.07); border-radius: 4px; padding: 1px 6px; font-size: 0.85em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.km-help-tip {
  display: flex; gap: 10px; align-items: flex-start; background: rgba(46,164,138,.09);
  border: 1px solid rgba(46,164,138,.28); border-radius: var(--radius-sm);
  padding: 11px 13px; margin: 4px 0 14px; font-size: 0.86rem; color: var(--text-secondary); line-height: 1.5;
}
.km-help-tip::before { content: "💡"; flex: none; font-size: 1rem; }
.km-help-steps { counter-reset: km-step; list-style: none; padding-left: 0; }
.km-help-steps li { position: relative; padding-left: 34px; margin-bottom: 12px; }
.km-help-steps li::before {
  counter-increment: km-step; content: counter(km-step);
  position: absolute; left: 0; top: -1px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--primary); color: #fff; font-family: var(--font-heading); font-weight: 700;
  font-size: 0.82rem; display: flex; align-items: center; justify-content: center;
}

/* ---- Favoris / récurrents / carte-head ---- */
.km-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.km-card-head h2 { margin: 0; }
.km-btn-sm { width: auto; padding: 8px 14px; font-size: 0.82rem; }
.km-empty-inline { color: var(--text-light); font-size: 0.85rem; text-align: center; padding: 10px 0; }
.km-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.km-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--teal-light); color: var(--primary); border: 1px solid transparent;
  border-radius: 50px; padding: 8px 12px; font-size: 0.85rem; cursor: pointer;
}
.km-chip:hover { border-color: var(--teal); }
.km-chip .km-chip-del { color: var(--text-light); font-weight: 700; }

/* ---- Bouton dépliant « Ajouter d'autres dates » (calendrier masqué par défaut) ---- */
.km-minical-toggle {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 12px 14px; border: 2px dashed var(--border); border-radius: var(--radius-sm);
  background: #fff; color: var(--text-secondary); font-family: var(--font-body);
  font-size: 0.9rem; font-weight: 600; cursor: pointer; text-align: left;
}
.km-minical-toggle:hover { border-color: var(--accent); color: var(--accent); }
.km-minical-toggle small { color: var(--text-light); font-weight: 400; }
.km-minical-toggle-ico { font-weight: 700; font-size: 1.05rem; line-height: 1; transition: transform .15s; }
.km-minical-toggle[aria-expanded="true"] { border-style: solid; border-color: var(--accent); color: var(--accent); margin-bottom: 10px; }
.km-minical-toggle[aria-expanded="true"] .km-minical-toggle-ico { transform: rotate(45deg); }

/* ---- Mini-calendrier multi-sélection (dates supplémentaires) ----
   Calendrier maison (le <input type=date> natif ne permet pas de sélectionner
   plusieurs jours). On clique autant de jours qu'on veut → surbrillance → un
   bouton empile toutes les dates sélectionnées d'un coup. MASQUÉ par défaut,
   déplié via .km-minical-toggle. */
.km-minical {
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; padding: 10px; user-select: none;
}
.km-minical-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.km-minical-title { font-family: var(--font-heading); font-weight: 700; color: var(--primary); font-size: 0.92rem; text-transform: capitalize; }
.km-minical-nav { display: flex; gap: 4px; }
.km-minical-nav button {
  width: 32px; height: 32px; border: 1px solid var(--border); background: #fff;
  border-radius: var(--radius-sm); color: var(--text-secondary); cursor: pointer;
  font-size: 1rem; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.km-minical-nav button:hover { border-color: var(--accent); color: var(--accent); }
.km-minical-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.km-minical-dow { text-align: center; font-size: 0.68rem; font-weight: 700; color: var(--text-light); padding: 2px 0; }
.km-minical-cell {
  aspect-ratio: 1; border: none; background: none; border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: 0.82rem; color: var(--text-primary); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.km-minical-cell:hover:not(:disabled) { background: var(--teal-light); }
.km-minical-cell.is-empty { visibility: hidden; cursor: default; }
.km-minical-cell.is-today { box-shadow: inset 0 0 0 1.5px var(--teal); font-weight: 700; }
.km-minical-cell.is-sel { background: var(--accent); color: #fff; font-weight: 700; }
.km-minical-cell.is-sel:hover { background: var(--accent); }
.km-minical-cell:disabled { color: var(--text-light); opacity: .4; cursor: default; }
.km-minical-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; gap: 8px; }
.km-minical-count { font-size: 0.8rem; color: var(--text-secondary); }
.km-minical-count strong { color: var(--accent); }

.km-rec-generate { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.km-rec-generate > label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.km-rec-days-badge { font-size: 0.72rem; color: var(--accent); font-weight: 700; }

/* ---- Sélecteur jours de semaine ---- */
.km-days { display: flex; gap: 6px; }
.km-days button {
  flex: 1; aspect-ratio: 1; border: 2px solid var(--border); background: #fff;
  border-radius: var(--radius-sm); font-family: var(--font-heading); font-weight: 700;
  color: var(--text-secondary); cursor: pointer; font-size: 0.9rem;
}
.km-days button.is-on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---- Aperçu modale trajet ---- */
.km-trajet-preview { background: var(--bg-warm); border-radius: var(--radius-sm); padding: 12px; text-align: center; font-weight: 600; color: var(--primary); margin-bottom: 12px; min-height: 20px; }
.km-trajet-preview .amount { color: var(--accent); font-family: var(--font-heading); }

.km-modal-body .km-field select { box-sizing: border-box; width: 100%; padding: 12px 14px; border: 2px solid var(--border); border-radius: var(--radius-sm); font-size: 1rem; background: #fff; }
.km-modal-body .km-field input { box-sizing: border-box; width: 100%; padding: 12px 14px; border: 2px solid var(--border); border-radius: var(--radius-sm); font-size: 1rem; }
/* Exception : les switches (toggle) dans une modale ne doivent PAS hériter du
   width:100%/padding/border des inputs texte (sinon le switch s'étire et déborde
   de la modale — cas du toggle « 100 % électrique » de la fiche véhicule). */
.km-modal-body .km-toggle-row input[type="checkbox"] {
  width: 46px; height: 26px; padding: 0; border: none; border-radius: 50px; flex: none;
}

@media (min-width: 720px) {
  .km-modal { align-items: center; }
  .km-modal-box { border-radius: var(--radius-lg); }
}

/* ============================================================================
 * Compte & synchronisation (modale connexion/inscription + bloc Réglages).
 * ==========================================================================*/
.km-auth-box { max-width: 440px; padding-top: 28px; }
.km-auth-close {
  position: absolute; top: 14px; right: 14px; background: var(--bg-light);
  color: var(--text-primary); z-index: 2;
}
.km-auth-hero { text-align: center; margin-bottom: 22px; }
.km-auth-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--success-muted); color: var(--success); margin-bottom: 12px;
}
.km-auth-hero h2 { font-family: var(--font-heading); font-size: 1.5rem; color: var(--primary); margin: 0 0 6px; }
.km-auth-hero p { font-size: 0.9rem; color: var(--text-secondary); line-height: 1.45; margin: 0 auto; max-width: 320px; }
.km-auth-form { margin-bottom: 6px; }
.km-auth-form .km-field input {
  box-sizing: border-box; width: 100%; padding: 13px 14px;
  border: 2px solid var(--border); border-radius: var(--radius-sm); font-size: 1rem;
}
.km-auth-form .km-field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,43,70,.10); }
.km-auth-form .km-btn-big { margin-top: 6px; }
.km-auth-error {
  background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca;
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: 0.85rem;
  line-height: 1.4; margin: 4px 0 12px;
}
.km-auth-error.km-auth-info { background: var(--success-muted); color: #047857; border-color: #a7f3d0; }
.km-auth-link {
  display: block; margin: 12px auto 0; background: none; border: none;
  color: var(--primary); font-size: 0.9rem; font-weight: 600; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px; padding: 4px;
}
.km-auth-link:hover { color: var(--accent); }
.km-auth-switch {
  text-align: center; margin-top: 18px; padding-top: 16px;
  border-top: 1px solid var(--border); font-size: 0.9rem; color: var(--text-secondary);
}
.km-auth-switch .km-auth-link { display: inline; margin: 0; }
.km-auth-legal { font-size: 0.72rem; color: var(--text-light); text-align: center; line-height: 1.5; margin: 16px 0 0; }
.km-auth-legal a { color: var(--text-secondary); }

/* Bloc "Mon compte" dans les Réglages */
.km-account-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--success-muted); border: 1px solid #a7f3d0;
  border-radius: var(--radius-md); padding: 14px; margin-bottom: 12px;
}
.km-account-card .km-account-ico {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--success); color: #fff;
}
.km-account-card .km-account-mail { font-weight: 600; color: var(--primary); font-size: 0.92rem; word-break: break-all; }
.km-account-card .km-account-state { font-size: 0.78rem; color: #047857; }
.km-account-signed-out { background: var(--bg-light); border-color: var(--border); }
.km-account-signed-out .km-account-ico { background: var(--text-light); }
.km-account-signed-out .km-account-state { color: var(--text-secondary); }
.km-sync-status { font-size: 0.78rem; color: var(--text-light); margin: 6px 2px 0; min-height: 1.1em; }
.km-btn-textdanger {
  background: none; border: none; color: #b91c1c; font-size: 0.85rem;
  font-weight: 600; cursor: pointer; text-decoration: underline;
  text-underline-offset: 2px; padding: 6px 0; margin-top: 4px;
}
.km-btn-textdanger:hover { color: #7f1d1d; }

/* ===== Liens « source officielle » du barème =====
   Conformité Play Store : les renseignements gouvernementaux (barème fiscal)
   doivent pointer clairement vers leur source d'origine (.gouv.fr). */
.km-header-title .km-header-source {
  color: inherit;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}
.km-source-note a { color: var(--primary); font-weight: 600; }
