/* ===========================================================
   E-TRAK — thème industriel sombre
   Palette : fond #1A1A1A, cartes #2A2A2A, accent #0062CC/#3B82F6,
   bandeau #085591, texte clair, grille technique.
   =========================================================== */

:root {
  --bg:        #1A1A1A;
  --bg-grid:   #222;
  --card:      #2A2A2A;
  --card-2:    #323232;
  --border:    #3a3a3a;
  --accent:    #0062CC;
  --accent-2:  #3B82F6;
  --band:      #085591;
  --text:      #E6E9ED;
  --text-dim:  #9aa3ad;
  --ok:        #2FBF71;
  --warn:      #E0A800;
  --danger:    #E0392B;
  --radius:    8px;
  --sidebar:   #141414;
  --topbar:    #1d1d1d;
  --hover:     #1f1f1f;
  --tag:       #333333;
  --input:     #1f1f1f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 28px 28px;
  background-position: -1px -1px;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===========================================================
   Shell : nav latérale (style portail télématique) + zone principale
   =========================================================== */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 230px; flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .logo {
  display: block; padding: 20px 22px 18px;
  border-bottom: 1px solid var(--border); margin-bottom: 10px;
}
.sidebar .logo img { width: 150px; max-width: 100%; height: auto; display: block; }
/* Logo E-TRAK selon le thème : blanc (défaut, fond sombre) / bleu foncé (thème clair). */
.sidebar .logo .brand-logo-light { display: none; }
html[data-theme="light"] .sidebar .logo .brand-logo-default { display: none; }
html[data-theme="light"] .sidebar .logo .brand-logo-light { display: block; }
.sidebar .logo-sub {
  padding: 2px 22px 18px; font-size: 11px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--text-dim);
  border-bottom: 1px solid var(--border); margin-bottom: 10px;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; padding: 0 10px 16px;
  flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.sidebar nav::-webkit-scrollbar { width: 8px; }
.sidebar nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 6px;
  color: var(--text-dim); font-size: 14px; font-weight: 500;
  text-decoration: none; transition: background .12s, color .12s;
}
.nav-item svg { width: 19px; height: 19px; fill: currentColor; flex-shrink: 0; }
.nav-item:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: rgba(59,130,246,.14); color: #fff; box-shadow: inset 3px 0 0 var(--accent-2); }
.nav-item.disabled { opacity: .5; cursor: default; }
.nav-item.disabled::after {
  content: "bientôt"; margin-left: auto;
  font-size: 9px; text-transform: uppercase; letter-spacing: .5px;
  background: var(--tag); color: var(--text-dim); padding: 2px 6px; border-radius: 3px;
}
.nav-item.disabled:hover { background: transparent; color: var(--text-dim); }
.nav-item .nav-badge { margin-left: auto; background: var(--danger); color: #fff; font-size: 11px;
  font-weight: 700; font-style: normal; min-width: 18px; height: 18px; line-height: 18px; text-align: center;
  border-radius: 9px; padding: 0 5px; }

/* ---- Alertes ---- */
.danger-text { color: var(--danger) !important; }
.warn-text { color: var(--warn) !important; }
.alert-banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 8px;
  margin-bottom: 16px; background: rgba(224,57,43,.12); border: 1px solid rgba(224,57,43,.35); color: #ffb3ab; }
.alert-banner.warn { background: rgba(224,168,0,.10); border-color: rgba(224,168,0,.3); color: #f0c85a; }
.alert-banner a { color: #fff; font-weight: 600; margin-left: auto; white-space: nowrap; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---- Top bar ---- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px; height: 60px;
  background: var(--topbar);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 500;
}
.topbar .spacer { flex: 1; }
/* Identité de page dans la topbar : logo société + nom + libellé de page (séparateur fin). */
.topbar .page-context { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar .page-logo { max-height: 42px; max-width: 190px; width: auto; display: block; flex: 0 0 auto; }
/* Logo compagnie selon le thème : par défaut (sombre) → variante inversée ; thème clair → variante claire.
   Si une seule variante existe, le repli serveur rend deux fois le même fichier → comportement identique. */
.topbar .page-logo.logo-primary { display: none; }
.topbar .page-logo.logo-inverse { display: block; }
html[data-theme="light"] .topbar .page-logo.logo-primary { display: block; }
html[data-theme="light"] .topbar .page-logo.logo-inverse { display: none; }
.topbar .brand-name { font-size: 15px; font-weight: 700; color: var(--text); white-space: nowrap; }
.topbar .page-lbl { font-size: 14px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .page-context .page-lbl:not(:first-child) { padding-left: 10px; border-left: 1px solid var(--border); }
.topbar .user { display: flex; align-items: center; gap: 10px; }
.topbar .user-name { color: var(--text); font-size: 14px; font-weight: 600; }
.topbar .user-role { color: var(--text-dim); font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  border: 1px solid var(--border); border-radius: 4px; padding: 2px 7px; }
.topbar .logout { display: flex; color: var(--text-dim); }
.topbar .logout svg { width: 18px; height: 18px; fill: currentColor; }
.topbar .logout:hover { color: var(--accent-2); }

/* ---- Contenu ---- */
/* isolation:isolate → le contenu forme son propre contexte d'empilement. Sans ça, les z-index
   internes des cartes (Leaflet contrôles z-index 1000, .etk-mapctl 1200, contrôles carte météo/zones)
   remontent au contexte racine et passent DEVANT la topbar sticky (z-index 500) au scroll, surtout en
   mobile. Confiné ici, tout le contenu reste SOUS la topbar. Les overlays plein écran (modales, fab,
   tiroir nav, toast/caméra plein écran) sont hors .content (dans .main ou attachés à <body>) → non affectés. */
.content { padding: 24px; max-width: 1400px; width: 100%; isolation: isolate; }

/* Hamburger + voile : masqués sur desktop, activés dans le tiroir mobile (voir §Responsive). */
.nav-toggle { display: none; align-items: center; justify-content: center; width: 38px; height: 38px;
  border: 1px solid var(--border); border-radius: var(--radius); background: transparent; color: var(--text);
  cursor: pointer; flex-shrink: 0; }
.nav-toggle:hover { border-color: var(--accent-2); color: var(--accent-2); }
.nav-toggle svg { width: 20px; height: 20px; fill: currentColor; }
/* Assistant IA : bouton dans la barre du haut sur desktop, item de menu sur mobile (bascule au breakpoint). */
.asst-open-top { display: inline-flex; }
.asst-open-top:hover { background: var(--accent-2) !important; }
.asst-nav-mobile { display: none; }
.nav-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 900;
  opacity: 0; transition: opacity .2s ease; }

/* Modale flottante générique (carnet de bord, etc.). */
.etk-modal { display: none; position: fixed; inset: 0; z-index: 1100; background: rgba(0,0,0,.55);
  align-items: flex-start; justify-content: center; padding: 6vh 16px; }
.etk-modal.open { display: flex; }
.etk-modal-dialog { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  width: min(580px, 100%); max-height: 84vh; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 16px 50px rgba(0,0,0,.5); }
.etk-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border); }
.etk-modal-head h3 { margin: 0; }
.etk-modal-close { background: none; border: 0; color: var(--text-dim); font-size: 24px; line-height: 1;
  cursor: pointer; padding: 0 4px; }
.etk-modal-close:hover { color: var(--text); }
.etk-modal-body { padding: 16px 18px; overflow: auto; }

.page-title { font-size: 22px; font-weight: 600; margin: 0 0 16px; }
.muted { color: var(--text-dim); }

/* ---- Cartes & grille ---- */
.grid { display: grid; gap: 16px; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card h3 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-dim); }

.kpi .value { font-size: 30px; font-weight: 700; }
.kpi .unit { font-size: 14px; color: var(--text-dim); margin-left: 4px; }
.kpi .label { color: var(--text-dim); font-size: 13px; margin-top: 4px; }
.kpi .value.accent { color: var(--accent-2); }

/* ---- Tableaux ---- */
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); }
/* Conteneur de table à défilement horizontal (tables larges, sur PC ET mobile) */
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table.data { min-width: 720px; }
.table-scroll table.data th { white-space: nowrap; }
table.data th { color: var(--text-dim); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .5px; }
table.data tbody tr:hover { background: var(--card-2); cursor: pointer; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; }
.badge.ok { background: rgba(47,191,113,.15); color: var(--ok); }
.badge.warn { background: rgba(224,168,0,.15); color: var(--warn); }
.badge.danger { background: rgba(224,57,43,.15); color: var(--danger); }

.chart { width: 100%; height: 300px; }
#map { width: 100%; height: 380px; border-radius: var(--radius); }

/* ---- Boutons / formulaires ---- */
.btn {
  display: inline-block; background: var(--accent); color: #fff; border: none;
  padding: 10px 18px; border-radius: 6px; font-size: 14px; cursor: pointer;
  transition: background .15s ease;
}
.btn:hover { background: var(--accent-2); }
.btn-mini {
  background: transparent; color: var(--text-dim); border: 1px solid var(--border);
  padding: 2px 10px; border-radius: 999px; font-size: 12px; cursor: pointer;
  transition: all .15s ease;
}
.btn-mini:hover { color: #fff; background: var(--accent); border-color: var(--accent); }
input, select {
  width: 100%; padding: 10px 12px; background: var(--input); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; font-size: 14px;
}
input:focus, select:focus { outline: none; border-color: var(--accent-2); }
/* Tous les textbox multi-lignes (messages, notes, support…) : pleine largeur, hauteur lisible. */
textarea {
  width: 100%; box-sizing: border-box; padding: 10px 12px; background: var(--input); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; font-size: 14px; font-family: inherit;
  line-height: 1.45; min-height: 110px; resize: vertical;
}
textarea:focus { outline: none; border-color: var(--accent-2); }
/* Icône du sélecteur de date : l'icône native est noire → illisible sur fond sombre. On l'éclaircit
   en thème sombre (défaut) et on la laisse normale en thème clair. */
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); opacity: .6; cursor: pointer; }
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 1; }
html[data-theme="light"] input[type="date"]::-webkit-calendar-picker-indicator { filter: none; opacity: .6; }
label { display: block; margin: 14px 0 6px; color: var(--text-dim); font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }

/* ---- Login ---- */
.login-wrap { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-card {
  width: 360px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px; box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.login-card .brand { text-align: center; margin-bottom: 6px; }
.login-card .brand img { width: 200px; max-width: 80%; height: auto; }
.login-card .sub { text-align: center; color: var(--text-dim); font-size: 13px; margin-bottom: 20px; }
.login-card .btn { width: 100%; margin-top: 20px; }
.error { background: rgba(224,57,43,.12); color: #ff8b80; border: 1px solid rgba(224,57,43,.3); padding: 10px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 12px; }

/* ===========================================================
   Barres de filtres — dates, raccourcis de période, sélecteurs
   Composants partagés (rapport, machines, opérateurs, parc, util.,
   activité, jour, facture, recherche, carte). Remplace les styles
   inline répétés dans chaque template.
   =========================================================== */

/* Conteneur en ligne (form/card) : champs alignés sur leur base, repli fluide */
.filterbar { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }

/* Grille de champs (rapport, facture) : colonnes auto-ajustées */
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
/* Formulaires d'ajout compagnie/client/transporteur : nom + adresse LARGES, le reste passe à la ligne. */
.biz-form .filter-grid { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.biz-form .filter-grid > div { flex: 1 1 160px; min-width: 150px; }
.biz-form .filter-grid > div:first-child { flex: 1 1 340px; min-width: 300px; }   /* nom de l'entreprise */
.biz-form .filter-grid input { width: 100%; box-sizing: border-box; }

/* Champ = label au-dessus de son input ; largeur mini stable */
.filterbar .field { display: flex; flex-direction: column; min-width: 150px; }
.filterbar .field.grow { flex: 1 1 240px; }

/* Labels compacts dans les barres (pas la marge généreuse globale) */
.filterbar label, .filter-grid label { margin: 0 0 5px; }

/* Actions (Appliquer / Réinitialiser / Export) */
.filter-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; align-items: center; }

/* Raccourcis de période : poussés à droite, repli sur ligne suivante */
.period-presets { display: flex; flex-direction: row; gap: 6px; align-items: center;
  flex-wrap: wrap; margin-left: auto; }
.period-presets .lbl { margin: 0; font-size: 12px; color: var(--text-dim); }
.period-presets .preset { padding: 6px 11px; font-size: 12px; }
/* Raccourci de période ACTIF (= période affichée) : surligné accent. */
.preset.preset-on { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; }

/* Bloc « Période » : calendrier Du/Au + raccourcis groupés dans un même conteneur.
   Dates côte à côte sur la 1re rangée, presets juste en dessous. */
.daterange { display: flex; flex-direction: column; gap: 8px; }
.daterange .dr-fields { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.daterange .dr-fields > div { display: flex; flex-direction: column; min-width: 140px; }
.daterange label { margin: 0 0 5px; }
.daterange .period-presets { margin-left: 0; }          /* annule le push-droite hérité */
.filter-grid .daterange { grid-column: 1 / -1; }        /* pleine largeur dans les grilles */

/* Sélection multiple (machines / opérateurs) */
.chk-field { flex: 1 1 240px; }
.chk-head { display: flex; align-items: center; gap: 10px; }
.chk-toggle { display: inline-flex; gap: 6px; text-transform: none; letter-spacing: 0; font-weight: 400; }
.chk-group { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 5px; }
.chk-group label { display: flex; gap: 6px; align-items: center; text-transform: none;
  letter-spacing: 0; margin: 0; }
.chk-group input[type=checkbox] { width: auto; }

/* ===========================================================
   Filtres en SECTIONS — sous-conteneurs délimités subtilement
   dans un même conteneur (.filterbox = .card sans padding).
   Même fond que la carte ; séparation = simple filet 1px
   var(--border) → rendu homogène, « plusieurs blocs très
   similaires ». Chaque .fsec porte un intitulé discret.
   =========================================================== */
.filterbox { padding: 0; overflow: hidden; }       /* la carte ne pad plus : chaque section gère son espace */
.fsec { padding: 13px 16px; display: flex; flex-direction: column; gap: 9px; }
.fsec + .fsec { border-top: 1px solid var(--border); }   /* séparation subtile entre sections */
.fsec-title { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text-dim); }
.fsec-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fsec-body { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.fsec .daterange { width: 100%; }
.fsec .field { display: flex; flex-direction: column; min-width: 160px; }
.fsec .field.grow { flex: 1 1 240px; }
.fsec.fsec-actions { flex-direction: row; justify-content: flex-end; }
/* Léger relief au survol pour signaler le groupe actif sans rompre l'homogénéité */
.filterbox .fsec:hover { background: var(--card-2); }

.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.ghost:hover { background: var(--card-2); border-color: var(--accent-2); }

/* Bouton « Ticket » (lien vers le bordereau de pesée) : identité visuelle propre
   plutôt qu'un ghost générique — c'est l'action clé d'une rangée. Ciblé par le href
   /ticket/… → s'applique partout (jour, rapport, détails machine/opérateur, cartes
   mobile) sans toucher les gabarits. Teinte accent + icône bordereau (mask = suit la
   couleur du texte : bleu au repos, blanc au survol). Desktop ET mobile. */
a.btn[href*="/ticket/"] {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(59,130,246,.12); border: 1px solid var(--accent-2); color: var(--accent-2); font-weight: 600;
}
a.btn[href*="/ticket/"]:hover { background: var(--accent-2); color: #fff; border-color: var(--accent-2); }
a.btn[href*="/ticket/"]::before {
  content: ""; width: 13px; height: 13px; flex: 0 0 auto; background: currentColor;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M5 3a1 1 0 00-1 1v17l2.5-1.5L9 21l2.5-1.5L14 21l2.5-1.5L19 21V4a1 1 0 00-1-1H5zm2 4h10v2H7V7zm0 4h10v2H7v-2zm0 4h7v2H7v-2z'/></svg>") no-repeat center / contain;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M5 3a1 1 0 00-1 1v17l2.5-1.5L9 21l2.5-1.5L14 21l2.5-1.5L19 21V4a1 1 0 00-1-1H5zm2 4h10v2H7V7zm0 4h10v2H7v-2zm0 4h7v2H7v-2z'/></svg>") no-repeat center / contain;
}
.pager { margin-top: 14px; display: flex; gap: 10px; align-items: center; }
table.data th a { color: var(--text-dim); }
table.data th a:hover { color: var(--accent-2); text-decoration: none; }

/* ---- Admin ---- */
.admin-tabs { display: flex; gap: 4px; align-items: center; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.admin-tabs a { padding: 10px 16px; color: var(--text-dim); font-size: 14px; font-weight: 600;
  border-bottom: 2px solid transparent; text-decoration: none; }
.admin-tabs a:hover { color: var(--text); }
.admin-tabs a.on { color: #fff; border-bottom-color: var(--accent-2); }
.admin-tabs .admin-ctx { margin-left: auto; color: var(--text-dim); font-size: 13px; }
.flash { padding: 11px 14px; border-radius: 6px; font-size: 14px; margin-bottom: 16px; }
.flash.ok  { background: rgba(47,191,113,.14); color: #7ee2a8; border: 1px solid rgba(47,191,113,.3); }
.flash.err { background: rgba(224,57,43,.12); color: #ff8b80; border: 1px solid rgba(224,57,43,.3); }
.flash.token { background: rgba(59,130,246,.12); color: #cfe0ff; border: 1px solid rgba(59,130,246,.35); }
.flash.token code { display: block; margin-top: 8px; padding: 10px; background: #111; border-radius: 6px;
  color: #6ee7ff; font-size: 14px; word-break: break-all; user-select: all; }

/* ---- Barre de part (productivité) ---- */
.share { display: inline-block; width: 120px; height: 8px; background: #1f1f1f; border-radius: 4px; overflow: hidden; vertical-align: middle; margin-right: 8px; }
.share span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* Deltas de comparaison de période (dashboard) */
.trend { font-size: 12px; font-weight: 600; margin-left: 6px; white-space: nowrap; }
.trend.up { color: var(--ok); }
.trend.down { color: var(--danger); }
.trend.muted { color: var(--text-dim); }

/* Barres de proportion (classements / utilisation) */
.bar-track { background: rgba(255,255,255,.07); border-radius: 4px; height: 10px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 4px; }

/* Mini tableau clé/valeur (santé) */
.mini-kv { width: 100%; font-size: 13px; }
.mini-kv td { padding: 3px 0; }
.mini-kv td:first-child { color: var(--text-dim); }
.mini-kv td:last-child { text-align: right; font-weight: 600; }

/* Anneau de score (santé de la flotte) */
.score-ring { --p: 0; width: 88px; height: 88px; border-radius: 50%; flex: 0 0 88px;
  display: grid; place-items: center; position: relative;
  background: conic-gradient(var(--ring) calc(var(--p) * 1%), rgba(255,255,255,.08) 0); }
.score-ring::before { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--card); }
.score-ring span { position: relative; font-size: 22px; font-weight: 700; }
.score-ring.ok { --ring: var(--ok); }
.score-ring.warn { --ring: var(--warn); }
.score-ring.danger { --ring: var(--danger); }

/* Pastille de couleur (zones) */
.dot { display:inline-block; width:10px; height:10px; border-radius:50%; margin-right:7px; vertical-align:middle; }

/* Zones : boutons d'action compacts, checkbox en ligne, ligne désactivée grisée */
.btn-act { padding: 3px 10px; font-size: 12px; }
.chk-inline { display: inline-flex; align-items: center; gap: 7px; text-transform: none;
  letter-spacing: 0; margin: 0; }
.chk-inline input[type=checkbox] { width: auto; }
tr.row-off td { opacity: .55; }
.z-zoom { color: inherit; }
.z-zoom:hover strong { color: var(--accent-2); }

/* ===========================================================
   Thème clair (bascule via le bouton de la topbar, persistant)
   =========================================================== */
html[data-theme="light"] {
  --bg:        #EEF1F5;
  --bg-grid:   #E4E8EE;
  --card:      #FFFFFF;
  --card-2:    #F1F4F8;
  --border:    #D4DAE2;
  --accent:    #0062CC;
  --accent-2:  #1D6FE0;
  --band:      #0A5FA8;
  --text:      #1A2330;
  --text-dim:  #5B6675;
  --ok:        #1E9E5A;
  --warn:      #B7860B;
  --danger:    #C5281C;
  --sidebar:   #FFFFFF;
  --topbar:    #FFFFFF;
  --hover:     #EEF2F7;
  --tag:       #E2E7EE;
  --input:     #FFFFFF;
}
html[data-theme="light"] body { background-color: var(--bg); }
html[data-theme="light"] .bar-track { background: rgba(0,0,0,.08); }
html[data-theme="light"] .topbar .theme-toggle { color: var(--text); }
/* Ombres douces pour distinguer les surfaces blanches sur fond clair */
html[data-theme="light"] .card { box-shadow: 0 1px 2px rgba(16,24,40,.06); }
html[data-theme="light"] .sidebar { box-shadow: 1px 0 0 var(--border); }
html[data-theme="light"] .topbar { box-shadow: 0 1px 3px rgba(16,24,40,.05); }
html[data-theme="light"] .nav-item.active { color: var(--accent); }
html[data-theme="light"] input, html[data-theme="light"] select { box-shadow: inset 0 1px 2px rgba(16,24,40,.04); }
/* Bannières / flash : texte lisible sur fond clair (au lieu des tons pâles du thème sombre) */
html[data-theme="light"] .alert-banner { color: var(--danger); }
html[data-theme="light"] .alert-banner.warn { color: #8a6d00; }
html[data-theme="light"] .alert-banner a { color: var(--accent); }
html[data-theme="light"] .error, html[data-theme="light"] .flash.err { color: var(--danger); }
html[data-theme="light"] .flash.ok { color: #137a43; }
html[data-theme="light"] .flash.token { color: #0a4ea8; }
html[data-theme="light"] .flash.token code { background: #0f1b2d; color: #6ee7ff; }

/* Bouton bascule de thème */
.theme-toggle { background: none; border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius); width: 34px; height: 34px; cursor: pointer; display: grid;
  place-items: center; }
.theme-toggle:hover { border-color: var(--accent-2); color: var(--accent-2); }
.theme-toggle svg { width: 18px; height: 18px; fill: currentColor; }
.theme-toggle .icon-sun { display: none; }
html[data-theme="light"] .theme-toggle .icon-sun { display: block; }
html[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* Cluster de contrôles de la topbar (langue · unité · thème) — tailles homogènes */
.topbar-actions { display: flex; align-items: center; gap: 8px; }
/* Tous les contrôles de la barre du haut : même hauteur RÉELLE (34px, bordure comprise) → alignés verticalement. */
.topbar-actions > * { box-sizing: border-box; height: 34px; }
.topbar-btn { height: 34px; min-width: 34px; padding: 0 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: transparent; color: var(--text);
  font-size: 13px; font-weight: 600; cursor: pointer; display: grid; place-items: center; }
.topbar-btn:hover { border-color: var(--accent-2); color: var(--accent-2); }
.topbar-select { display: flex; align-items: center; gap: 7px; height: 34px; margin: 0; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--card-2); cursor: pointer; }
.topbar-select:hover { border-color: var(--accent-2); }
.topbar-select .ts-cap { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-dim); }
.topbar-select select { appearance: none; -webkit-appearance: none; background: transparent; border: none;
  outline: none; color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer;
  width: auto; height: auto; line-height: 1; padding: 0 16px 0 0; box-shadow: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%238a93a3' stroke-width='3'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right center; background-size: 10px; }
.topbar-select option { color: #1F2937; }

/* Onglets de vue (hubs Analyse, Activité…) */
.viewtabs { display: flex; gap: 6px; margin: 0 0 16px; flex-wrap: wrap; }
.viewtabs a { padding: 9px 18px; border-radius: var(--radius); text-decoration: none; font-weight: 600;
  font-size: 14px; border: 1px solid var(--border); color: var(--text); background: var(--surface, var(--card-2)); }
.viewtabs a.on { background: #135090; border-color: #135090; color: #fff; }

/* Recherche : box topbar + liste de résultats */
.topbar-search { display: flex; align-items: center; gap: 6px; background: var(--card-2);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 5px 10px; min-width: 220px; }
.topbar-search svg { width: 16px; height: 16px; fill: var(--text-dim); flex: 0 0 16px; }
.topbar-search input { background: none; border: none; color: var(--text); outline: none; width: 100%; font-size: 13px; }
.topbar-search input::placeholder { color: var(--text-dim); }
.search-list { list-style: none; margin: 0; padding: 0; }
.search-list li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.search-list li:last-child { border-bottom: 0; }
@media (max-width: 720px) { .topbar-search { display: none; } }

/* Mode kiosque : plein écran sans navigation */
html.kiosk .sidebar, html.kiosk .topbar { display: none; }
html.kiosk .content { max-width: none; padding: 18px; }
/* Bouton « Kiosque » de la barre du haut (icône). Sortie = touche Échap (pas de bouton flottant). */
.kiosk-toggle:hover { border-color: var(--accent-2) !important; color: var(--accent-2) !important; }
/* Kiosque = écran d'affichage : réservé au desktop. Sous le breakpoint tiroir, on masque le bouton. */
@media (max-width: 860px) { .kiosk-toggle { display: none !important; } }

/* ===========================================================
   CONSOLE D'ADMINISTRATION (etrak_admin) — shell distinct
   =========================================================== */
.admin-mode { --accent: #B45309; --accent-2: #F59E0B; }  /* accent ambre = mode opérateur */
.admin-sidebar { background: #0f1115; box-shadow: inset -1px 0 0 #23262d; }
.admin-sidebar .logo { position: relative; }
.admin-badge { position: absolute; top: 8px; right: 10px; background: var(--accent-2); color: #1a1a1a;
  font-size: 9px; font-weight: 800; letter-spacing: .1em; padding: 2px 6px; border-radius: 4px; }
.admin-sidebar .nav-item.active { background: rgba(245,158,11,.16); color: #fff; box-shadow: inset 3px 0 0 var(--accent-2); }
/* Hiérarchie de nav à 3 niveaux, lisible au premier coup d'œil :
   CATÉGORIE = trait de séparation + MAJUSCULES vives ; sous-catégorie = italique indentée, discrète ;
   page (.nav-item) = libellé normal avec icône (déjà distinct). */
.sidebar nav .nav-section { margin-top: 14px; padding: 12px 16px 6px; border-top: 1px solid var(--border);
  font-size: 10px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; color: var(--text); opacity: .92; }
.sidebar nav .nav-subsection { padding: 9px 16px 2px 18px; font-size: 10px; font-weight: 600; letter-spacing: .01em;
  text-transform: none; font-style: italic; color: var(--text-dim); opacity: .6; }
/* Une sous-catégorie qui suit directement sa catégorie ne reprend pas la marge du séparateur. */
.sidebar nav .nav-section + .nav-subsection { margin-top: 0; }
/* Modale générique (utilisée par « Ajouter un véhicule ») : overlay plein écran + boîte centrée scrollable. */
.veh-modal, .ui-modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow: auto; }
.veh-modal[hidden], .ui-modal[hidden] { display: none; }
.veh-modal-backdrop, .ui-modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); }
.veh-modal-box, .ui-modal-box { position: relative; z-index: 1; width: 100%; max-width: 980px; margin: auto; }
.admin-sidebar .nav-back { margin-top: 4px; color: var(--text-dim); border-top: 1px solid #23262d; border-radius: 0; }
.admin-sidebar .nav-back:hover { color: var(--accent-2); }

.admin-topbar { box-shadow: inset 0 -2px 0 var(--accent-2); }
.admin-ctx { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim);
  background: var(--card-2); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; }
.admin-ctx.scoped { color: #fff; border-color: var(--accent-2); }
.admin-ctx.scoped a { margin-left: 6px; color: var(--accent-2); font-weight: 700; text-decoration: none; }
.admin-ctx svg { fill: var(--accent-2); }
.topbar .user-role.admin { background: var(--accent-2); color: #1a1a1a; padding: 1px 7px; border-radius: 4px; font-weight: 700; }

.admin-hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.admin-hero .page-title { margin-bottom: 2px; }
.admin-kpis .kpi .value.accent { color: var(--accent-2); }
.kpi-sub { color: var(--text-dim); font-size: 12px; margin-top: 6px; }

.role-bars { display: flex; flex-direction: column; gap: 9px; }
.role-row { display: grid; grid-template-columns: 120px 1fr 40px; align-items: center; gap: 10px; }
.role-row .role-name { font-size: 13px; text-transform: capitalize; }
.role-row .role-n { text-align: right; font-weight: 700; }
.quick-links { display: flex; flex-wrap: wrap; gap: 8px; }
.link-form { display: flex; gap: 6px; align-items: center; }
.link-form select { min-width: 130px; }
.link-form .btn, .data td form .btn.ghost { padding: 6px 10px; font-size: 12px; }

/* ===========================================================
   RESPONSIVE — mobile / tablette
   Tiroir off-canvas (hamburger + voile), tableaux scrollables,
   topbar condensée, cibles tactiles. S'applique au portail client
   ET à la console admin (mêmes .shell/.sidebar/.topbar).
   =========================================================== */
@media (max-width: 860px) {
  .shell { display: block; }                /* la sidebar sort du flux (tiroir) */
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; height: 100dvh; width: 272px; max-width: 84vw;
    transform: translateX(-100%); transition: transform .25s ease; z-index: 1000;
    box-shadow: 2px 0 22px rgba(0,0,0,.5);
  }
  /* Le tiroir doit défiler jusqu'au dernier item (ex. Administration) malgré la barre
     d'outils mobile : inertie tactile + marge basse de sécurité (encoche/barre système). */
  .sidebar nav {
    -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }
  body.nav-open { overflow: hidden; }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .nav-backdrop { display: block; opacity: 1; }
  .nav-toggle { display: inline-flex; }
  .main { min-height: 100vh; }
  .asst-open-top { display: none; }        /* AI : bouton top-bar masqué sur mobile */
  .asst-nav-mobile { display: flex; }       /* AI : item de menu visible sur mobile (bas du menu) */

  .topbar { padding: 0 14px; gap: 10px; }
  .topbar .page-context { display: none; }
  .content { padding: 16px 14px; }
  .page-title { font-size: 19px; }
  .admin-hero { gap: 10px; }
}

@media (max-width: 700px) {
  /* Tableaux larges : défilement horizontal propre (jamais de débordement de page) */
  table.data { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.data thead th { white-space: nowrap; }
  .grid { gap: 12px; }
  .card { padding: 14px; }
  .kpi .value { font-size: 26px; }
  .topbar-actions { gap: 6px; }
  .topbar .user-name { display: none; }     /* on garde rôle + déconnexion */
  .viewtabs a, .admin-tabs a { padding: 8px 12px; font-size: 13px; }

  /* Barres de filtres : Du/Au côte à côte, sélecteurs/checkboxes pleine largeur,
     raccourcis de période repliés sur leur propre ligne (alignés à gauche). */
  .filterbar { gap: 10px; }
  .filterbar .field { flex: 1 1 140px; min-width: 130px; }
  .filterbar .field.grow, .chk-field { flex-basis: 100%; }
  .period-presets { margin-left: 0; width: 100%; }
  .filter-actions { width: 100%; }
  .daterange { width: 100%; }
  .daterange .dr-fields > div { flex: 1 1 140px; min-width: 130px; }   /* Du/Au côte à côte */
  /* Sections de filtres : padding réduit, sélecteurs fluides */
  .fsec { padding: 12px 14px; }
  .fsec .field { flex: 1 1 140px; min-width: 0; }
}

@media (max-width: 480px) {
  .topbar { height: 54px; gap: 8px; }
  .topbar .user-role { display: none; }
  .topbar-select .ts-cap { display: none; }
  .topbar-search { display: none; }
  .filter-grid { grid-template-columns: 1fr; }
  .link-form { flex-wrap: wrap; }
  .link-form select { min-width: 0; flex: 1; }
  .login-card { width: 92%; padding: 24px; }
  .btn { padding: 12px 16px; }               /* cible tactile ≥44px */
  .page-title { font-size: 18px; }
  .admin-hero { flex-direction: column; align-items: stretch; }
  .admin-hero .btn { width: 100%; text-align: center; }
  .role-row { grid-template-columns: 90px 1fr 34px; }
}

/* Écrans tactiles : pas de surbrillance "collante" au survol, tap discret */
@media (hover: none) {
  table.data tbody tr:hover { background: transparent; cursor: default; }
}
body { -webkit-tap-highlight-color: rgba(0,0,0,0); }

/* ===========================================================
   POLISH / ACCESSIBILITÉ / PERF (passe d'optimisation)
   =========================================================== */
html { scroll-behavior: smooth; }

/* Anneau de focus clavier visible et cohérent (a11y, sans gêner la souris) */
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; border-radius: 4px; }
.btn:focus-visible, .nav-item:focus-visible { outline-offset: 3px; }

/* Respect de la préférence "réduire les animations" */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .001ms !important; animation-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* Classes utilitaires (réduisent le style inline répété) */
.mt-0 { margin-top: 0; }
.mb-16 { margin-bottom: 16px; }
.mb-0 { margin-bottom: 0; }
.row-end { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.w-100 { width: 100%; }

/* Liens dans les tableaux de données : lisibles et cohérents */
table.data td a { color: var(--accent-2); }
table.data td a:hover { text-decoration: underline; }

/* Cohérence visuelle des cartes en thème clair (ombres déjà gérées) et focus */
.card:focus-within { border-color: var(--accent-2); }

/* Barre de période (réutilisée sur toutes les pages à intervalle) — base, valable aussi en thème classique. */
.dashf-period { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 12px; }
.dashf-period-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-dim); }
.dashf-period input { width: auto; padding: 5px 9px; font-size: 13px; }
.dashf-period .period-presets { margin-left: 0; gap: 5px; }
.dashf-period .period-presets .lbl { display: none; }
.dashf-period .period-presets .preset { padding: 5px 10px; font-size: 12px; }
.dashf-sep { color: var(--text-dim); }

/* Boutons d'export CSV/PDF — colorés au repos, partagés (rapport + analyses). */
.rep-exp-btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 8px;
  font-size: 14px; font-weight: 600; text-decoration: none; border: 1px solid transparent; color: #fff; }
/* Style « teinté » (fond translucide + bordure + texte colorés) plutôt qu'aplat
   saturé blanc-sur-couleur : action d'export secondaire discrète, code couleur
   CSV=vert / PDF=rouge conservé. Translucide → fonctionne sur thème clair ET sombre. */
.rep-exp-btn.csv { background: rgba(30,158,90,.13); border-color: rgba(30,158,90,.55); color: #36b873; }   /* vert export */
.rep-exp-btn.pdf { background: rgba(197,40,28,.13); border-color: rgba(197,40,28,.55); color: #e06257; }   /* rouge PDF */
.rep-exp-btn:hover { text-decoration: none; }
.rep-exp-btn.csv:hover { background: rgba(30,158,90,.22); }
.rep-exp-btn.pdf:hover { background: rgba(197,40,28,.22); }
.exp-bar { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.exp-bar .mac-back { color: var(--accent-2); text-decoration: none; font-size: 14px; }
.exp-bar .mac-back:hover { text-decoration: underline; }

/* Contrôles de carte (recentrer ⌂ / position 📍 / opacité ◐) — surcouche en haut à droite DE la carte. */
.etk-mapctl { position: absolute; top: 10px; right: 10px; z-index: 1200; display: flex; flex-direction: column; gap: 6px; pointer-events: auto; }
.etk-mapbtn { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text);
  font-size: 16px; line-height: 1; cursor: pointer; box-shadow: 0 1px 6px rgba(0,0,0,.3); }
.etk-mapbtn:hover { border-color: var(--accent-2); color: var(--accent-2); }
.etk-mapbtn.on { background: var(--accent); color: #fff; border-color: var(--accent); }
/* Carte en plein écran (bouton ⛶ de etkMapControls) : le conteneur Leaflet occupe tout l'écran.
   Inerte hors plein écran (la pseudo-classe :fullscreen ne matche que pendant le mode). */
.leaflet-container:fullscreen { width: 100% !important; height: 100% !important; }
.leaflet-container:-webkit-full-screen { width: 100% !important; height: 100% !important; }

/* Sélecteur natif : flèche cohérente déjà gérée pour .topbar-select ; ici, confort tactile */
select, input, .btn { font-family: inherit; }
