:root{
  --bg: #0a0a0d;
  --surface: #16161b;
  --surface-2: #1f1f25;
  --border: #2a2a31;
  --text: #f5f5f7;
  --text-muted: #95959e;
  --primary: #e31937;
  --primary-dark: #b3132b;
  --glow-primary: 0 10px 28px -6px rgba(227,25,55,0.5);
  --affecte-bg: rgba(59,130,246,0.16); --affecte-text: #8fbdfb; --affecte-border: #3b6fc9;
  --libre-bg: rgba(34,197,94,0.16); --libre-text: #74e3a4; --libre-border: #2f9e5b;
  --charge-bg: rgba(245,158,11,0.16); --charge-text: #fcc463; --charge-border: #c9890f;
  --inop-bg: rgba(255,69,96,0.16); --inop-text: #ff9fb0; --inop-border: #ff4560;
  --radius-md: 10px;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --topbar-h: 64px;
  --sidebar-w: 264px;
}

/* ----- Mode jour (clair) : surcharge des variables ----- */
:root[data-theme="jour"]{
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #e9edf2;
  --border: #d4d9e0;
  --text: #14141a;
  --text-muted: #5c626c;
  --glow-primary: 0 8px 22px -8px rgba(227,25,55,0.35);
  --affecte-bg: rgba(59,130,246,0.12); --affecte-text: #1d4ed8; --affecte-border: #3b82f6;
  --libre-bg: rgba(34,197,94,0.14); --libre-text: #15803d; --libre-border: #22c55e;
  --charge-bg: rgba(245,158,11,0.18); --charge-text: #8a5a06; --charge-border: #f59e0b;
  --inop-bg: rgba(239,68,68,0.12); --inop-text: #c0273c; --inop-border: #ef4444;
}
:root[data-theme="jour"] .btn:hover{ background: #dde2e9; }
:root[data-theme="jour"] .auth-card{ box-shadow: 0 24px 60px rgba(20,30,50,0.18); }
:root[data-theme="jour"] .sidebar,
:root[data-theme="jour"] .topbar{ box-shadow: 0 1px 0 rgba(0,0,0,0.04); }

/* Bouton de thème flottant (page de connexion) */
.btn-theme-flottant{
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 20;
}

*{box-sizing:border-box;}

html, body{ touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

body{
  margin:0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

@media (prefers-reduced-motion: reduce){
  *{ transition: none !important; animation: none !important; }
}

.hidden{ display:none !important; }

/* ----- Topbar ----- */
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  position: sticky;
  top:0;
  z-index: 10;
  flex-wrap: wrap;
  gap: 12px;
}
.topbar-left{
  display:flex;
  align-items:center;
  gap:10px;
}
.topbar-left i{
  font-size: 26px;
  color: var(--primary);
}
.topbar-left h1{
  font-size: 18px;
  font-weight: 600;
  margin:0;
}
.topbar-right{
  display:flex;
  align-items:center;
  gap:16px;
  flex-wrap: wrap;
}

.user-pill{
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  color: var(--text-muted);
}

.legend{
  display:flex;
  align-items:center;
  gap:14px;
  font-size: 13px;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.dot{
  display:inline-block;
  width:10px;
  height:10px;
  border-radius:50%;
  margin-right:4px;
  vertical-align:middle;
}
.dot-affecte{ background: var(--affecte-border); }
.dot-libre{ background: var(--libre-border); }
.dot-charge{ background: var(--charge-border); }
.dot-inop{ background: var(--inop-border); }

/* ----- Buttons ----- */
.btn{
  border-radius: var(--radius-md);
  padding: 11px 18px;
  min-height: 44px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  gap:6px;
  transition: background .15s, transform .1s, box-shadow .15s;
}
.btn:hover{ background: #26262d; }
.btn:active{ transform: scale(0.98); }
.btn-primary{
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: var(--glow-primary);
}
.btn-primary:hover{ background: var(--primary-dark); }
.btn-secondary{ background: var(--surface-2); }
.btn-danger{
  background: var(--inop-bg);
  border-color: var(--inop-border);
  color: var(--inop-text);
}
.btn-danger:hover{ background: rgba(255,69,96,0.26); }
.btn-warning{
  background: var(--charge-bg);
  border-color: var(--charge-border);
  color: var(--charge-text);
}
.btn-warning:hover{ background: rgba(245,158,11,0.26); }
.btn-success{
  background: var(--libre-bg);
  border-color: var(--libre-border);
  color: var(--libre-text);
}
.btn-success:hover{ background: rgba(34,197,94,0.26); }
.btn-block{ width:100%; justify-content:center; }
.btn-pill{ border-radius: var(--radius-pill); padding: 13px 20px; font-size: 15px; font-weight: 600; }
.btn:disabled{ opacity: .6; cursor: default; }

.icon-btn{
  border:none;
  background:none;
  font-size:18px;
  cursor:pointer;
  color: var(--text-muted);
  padding:4px;
  min-width: 44px;
  min-height: 44px;
  border-radius:8px;
  display:flex;
  align-items:center;
  justify-content:center;
}
.icon-btn:hover{ background: var(--surface-2); color: var(--text); }

/* ----- Container / Stats ----- */
.container{
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.stats{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(140px,1fr));
  gap:12px;
  margin-bottom: 24px;
}
.stat-card{
  background: var(--surface);
  border:1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display:flex;
  flex-direction:column;
  gap:4px;
}
.stat-label{ font-size:13px; color: var(--text-muted); }
.stat-value{ font-size:24px; font-weight:600; }
.stat-hint{ font-size:11px; font-weight:500; opacity:.7; }
.stat-duo{ display:flex; align-items:baseline; gap:8px; }
.stat-duo-sep{ font-size:20px; font-weight:600; color: var(--text-muted); }
.stat-value-piste{ color: var(--libre-text) !important; }

/* ----- Répartition par zone (modale ouverte depuis la carte Total) ----- */
.zone-grid{
  display:grid;
  grid-template-columns: repeat(2, 1fr);
  gap:10px;
}
.zone-card{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  padding:14px 16px;
  border-radius: var(--radius-md);
  border:1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor:pointer;
  transition: border-color .12s, transform .12s;
}
.zone-card:hover{ border-color: var(--primary); transform: translateY(-2px); }
.zone-card-name{ display:inline-flex; align-items:center; gap:6px; font-weight:600; font-size:14px; }
.zone-card-count{ font-size:22px; font-weight:700; color: var(--primary); }

/* Cartes stats colorées par état */
.stat-card.stat-total{ border-color: var(--primary); }
.stat-card.stat-total .stat-value{ color: var(--primary); }
.stat-card.stat-affecte{ background: var(--affecte-bg); border-color: var(--affecte-border); }
.stat-card.stat-affecte .stat-value{ color: var(--affecte-text); }
.stat-card.stat-libre{ background: var(--libre-bg); border-color: var(--libre-border); }
.stat-card.stat-libre .stat-value{ color: var(--libre-text); }
.stat-card.stat-charge{ background: var(--charge-bg); border-color: var(--charge-border); }
.stat-card.stat-charge .stat-value{ color: var(--charge-text); }
.stat-card.stat-inop{ background: var(--inop-bg); border-color: var(--inop-border); }
.stat-card.stat-inop .stat-value{ color: var(--inop-text); }
.stat-card.stat-chargeur{ background: var(--charge-bg); border-color: var(--charge-border); }
.chargeur-stat-lignes{ display:flex; flex-direction:column; gap:4px; margin-top:2px; }
.chargeur-stat-ligne{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  font-size:13px;
  color: var(--text-muted);
}
.chargeur-stat-ligne strong{ font-size:19px; font-weight:700; color: var(--libre-text); }
.chargeur-stat-tot{ color: var(--text-muted); font-size:13px; }
.chargeur-stat-ligne + .chargeur-stat-ligne{ border-top:1px solid var(--border); padding-top:4px; }

/* Cartes stats cliquables → filtrent l'affichage */
.stat-clickable{
  cursor: pointer;
  transition: transform .12s ease, box-shadow .15s ease, filter .15s ease;
}
.stat-clickable:hover{
  transform: translateY(-2px);
  box-shadow: 0 8px 20px -10px rgba(0,0,0,0.6);
  filter: brightness(1.08);
}
.stat-clickable:active{ transform: translateY(0); }

/* ----- Tabs ----- */
.tabs{
  display:flex;
  gap:10px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}
.tab-btn{
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .15s, border-color .15s;
  border-bottom: 2px solid transparent;
  margin-bottom: -14px;
}
.tab-btn:hover{ color: var(--text); }
.tab-btn.active{ color: var(--primary); border-bottom-color: var(--primary); }

/* ----- Grid / Cards ----- */
.grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(190px,1fr));
  gap:16px;
}

/* Barre de recherche de tracteur (au-dessus de la grille / liste) */
.recherche-bar{
  position:relative;
  margin-bottom:16px;
}
.recherche-bar i{
  position:absolute;
  left:12px;
  top:50%;
  transform:translateY(-50%);
  color: var(--text-muted);
  font-size:18px;
  pointer-events:none;
}
.recherche-bar input{
  width:100%;
  padding-left:40px;
}

.card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  cursor:pointer;
  transition: transform .12s, box-shadow .12s, border-color .12s;
  display:flex;
  flex-direction:column;
  gap:10px;
  min-height: 150px;
  position: relative;
}
.card:hover{
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.card:active{ transform: translateY(0) scale(0.99); }

.grid-readonly .card{ cursor: default; }
.grid-readonly .card:hover{ transform: none; box-shadow: none; }

.card-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
}
.card-num{
  font-size: 18px;
  font-weight: 600;
}
.card-icon{
  width:36px;
  height:36px;
  border-radius:50%;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:18px;
}

.badge{
  align-self:flex-start;
  font-size:12px;
  font-weight:500;
  padding:4px 10px;
  border-radius:20px;
}

.card-badges{
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:6px;
}
.zone-tag{
  display:inline-flex;
  align-items:center;
  gap:4px;
  font-size:12px;
  font-weight:600;
  padding:4px 10px;
  border-radius:20px;
  background: var(--surface-2);
  color: var(--text-muted);
  border:1px solid var(--border);
}
.zone-tag i{ font-size:13px; }

.card-body{
  flex:1;
  display:flex;
  flex-direction:column;
  justify-content:center;
  gap:4px;
}
.card-cariste{
  font-size:15px;
  font-weight:500;
}
.card-sub{
  font-size:13px;
  color: var(--text-muted);
}
/* Cartes de la vue "Zones" (sélecteur de zone) */
.card-zone{ border-color: var(--primary); }
.card-zone .card-num{ display:inline-flex; align-items:center; gap:6px; }
.card-zone .card-num i{ color: var(--primary); }
.card-zone .card-body{ align-items:center; }
.card-zone-nombre{
  font-size:40px;
  font-weight:700;
  color: var(--primary);
  line-height:1;
}

/* Bouton retour (pleine largeur) au-dessus de la grille d'une zone */
.grid-back{
  grid-column: 1 / -1;
  display:inline-flex;
  align-items:center;
  gap:8px;
  align-self:start;
  width:max-content;
  padding:10px 16px;
  border-radius: var(--radius-md);
  border:1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size:14px;
  font-weight:600;
  cursor:pointer;
  transition: border-color .12s;
}
.grid-back:hover{ border-color: var(--primary); }
.grid-back i{ font-size:16px; }

.card-charge{
  display:inline-flex;
  align-items:center;
  gap:5px;
  margin-top:4px;
  font-size:13px;
  font-weight:600;
  color: var(--libre-text);
}
.card-charge i{ font-size:16px; }

/* Etats visuels carte */
.card.etat-affecte{ border-color: var(--affecte-border); }
.card.etat-affecte .card-icon{ background: var(--affecte-bg); color: var(--affecte-text); }
.card.etat-affecte .badge{ background: var(--affecte-bg); color: var(--affecte-text); }

.card.etat-libre{ border-color: var(--libre-border); }
.card.etat-libre .card-icon{ background: var(--libre-bg); color: var(--libre-text); }
.card.etat-libre .badge{ background: var(--libre-bg); color: var(--libre-text); }

.card.etat-charge{ border-color: var(--charge-border); }
.card.etat-charge .card-icon{ background: var(--charge-bg); color: var(--charge-text); }
.card.etat-charge .badge{ background: var(--charge-bg); color: var(--charge-text); }

.card.etat-inop{ border-color: var(--inop-border); opacity: 0.85; }
.card.etat-inop .card-icon{ background: var(--inop-bg); color: var(--inop-text); }
.card.etat-inop .badge{ background: var(--inop-bg); color: var(--inop-text); }

.empty-state{
  grid-column: 1/-1;
  text-align:center;
  color: var(--text-muted);
  padding: 60px 20px;
  font-size:14px;
}

/* ----- Modal ----- */
.modal-overlay{
  position: fixed;
  inset:0;
  background: rgba(0,0,0,0.65);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index: 100;
  padding: 20px;
}
.modal-overlay.hidden{ display:none; }

.modal{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y:auto;
  display:flex;
  flex-direction:column;
}
.modal-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2{
  font-size:17px;
  font-weight:600;
  margin:0;
}
.modal-body{
  padding: 20px;
  display:flex;
  flex-direction:column;
  gap:14px;
}
.modal-footer{
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display:flex;
  flex-direction:column;
  gap:10px;
}

/* Modale de confirmation moderne */
.modal-confirm{
  max-width: 380px;
  padding: 28px 24px 22px;
  align-items: center;
  text-align: center;
  animation: confirmPop .18s ease;
}
@keyframes confirmPop{
  from{ transform: scale(.94); opacity: 0; }
  to{ transform: scale(1); opacity: 1; }
}
.confirm-icon{
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--inop-bg);
  color: var(--inop-text);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 28px;
  margin-bottom: 16px;
}
.modal-confirm h2{
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 8px;
}
.confirm-message{
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 22px;
}
.confirm-actions{
  display:flex;
  gap: 10px;
  width: 100%;
}
.confirm-actions .btn{ flex: 1; justify-content: center; }

.field-label{
  font-size:11px;
  font-weight:600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
select, input[type="text"], input[type="password"]{
  width:100%;
  padding:11px 12px;
  border-radius: var(--radius-md);
  border:1px solid var(--border);
  font-size:15px;
  background: var(--surface-2);
  color: var(--text);
  min-height: 44px;
}
select:focus, input[type="text"]:focus, input[type="password"]:focus{
  outline: 2px solid var(--primary);
  outline-offset:1px;
}

.info-line{
  display:flex;
  align-items:center;
  justify-content:space-between;
  font-size:14px;
  padding: 6px 0;
}
.info-line span:first-child{ color: var(--text-muted); }
.info-line span:last-child{ font-weight:500; }

.divider{
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

.section-title{
  font-size:13px;
  font-weight:500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}

/* ----- Zone d'affectation (pills dans la modale régulateur) ----- */
.zone-pills{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin:8px 0 2px;
}
.zone-pill{
  flex:0 0 auto;
  padding:7px 14px;
  border-radius: var(--radius-pill);
  border:1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size:13px;
  font-weight:600;
  cursor:pointer;
  min-height:36px;
  transition: background .12s, color .12s, border-color .12s;
}
.zone-pill:hover{ border-color: var(--primary); color: var(--text); }
.zone-pill.active{
  background: var(--primary);
  border-color: var(--primary);
  color:#fff;
}

/* ----- Recherche / liste des caristes (affectation) ----- */
.cariste-liste{
  display:flex;
  flex-direction:column;
  gap:6px;
  margin-top:10px;
  max-height:46vh;
  overflow-y:auto;
}
.cariste-item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  width:100%;
  padding:12px 14px;
  border-radius: var(--radius-md);
  border:1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size:15px;
  font-weight:500;
  cursor:pointer;
  transition: border-color .12s, background .12s;
}
.cariste-item:hover{ border-color: var(--primary); }
.cariste-item i{ color: var(--text-muted); font-size:18px; }
.cariste-item.actuel{ border-color: var(--affecte-border); background: var(--affecte-bg); }
.cariste-matricule{
  font-size:12px;
  font-weight:600;
  color: var(--text-muted);
  margin-left:6px;
}
.cariste-actuel-tag{
  font-size:11px;
  font-weight:600;
  text-transform:uppercase;
  letter-spacing:.04em;
  color: var(--affecte-text);
}
.cariste-vide{
  padding:14px;
  text-align:center;
  font-size:14px;
  color: var(--text-muted);
}

/* ----- Onglets Anciens / Nouveaux (modale chargeurs) ----- */
.chargeur-tabs{
  display:flex;
  gap:8px;
  margin-bottom:12px;
}
.chargeur-tab{
  flex:1;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:11px 12px;
  border-radius: var(--radius-md);
  border:1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size:14px;
  font-weight:600;
  cursor:pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.chargeur-tab:hover{ border-color: var(--primary); color: var(--text); }
.chargeur-tab.active{ background: var(--primary); border-color: var(--primary); color:#fff; }
.chargeur-tab-num{
  font-size:13px;
  font-weight:700;
  padding:1px 8px;
  border-radius: var(--radius-pill);
  background: rgba(0,0,0,0.22);
}

/* ----- Liste des chargeurs électriques (modale régulateur) ----- */
.chargeur-liste{
  display:flex;
  flex-direction:column;
  gap:8px;
  max-height:52vh;
  overflow-y:auto;
}
.chargeur-item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:12px 14px;
  border-radius: var(--radius-md);
  border:1px solid var(--border);
  background: var(--surface-2);
}
.chargeur-item.op{ border-color: var(--libre-border); }
.chargeur-item.inop{ border-color: var(--inop-border); background: var(--inop-bg); }
.chargeur-info{ display:flex; flex-direction:column; gap:2px; }
.chargeur-nom{ display:inline-flex; align-items:center; gap:6px; font-weight:600; font-size:15px; }
.chargeur-etat{ font-size:12px; color: var(--text-muted); }
.chargeur-item.op .chargeur-etat{ color: var(--libre-text); }
.chargeur-item.inop .chargeur-etat{ color: var(--inop-text); }
.chargeur-toggle{ flex:0 0 auto; font-size:13px; padding:8px 12px; }

/* Footer modale pendant un appel réseau */
.modal-footer.en-cours{ opacity:.6; pointer-events:none; }
.modal-footer button:disabled{ cursor:progress; }

/* ----- Panels / Tables (vue manager) ----- */
.panel{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 24px;
  overflow-x: auto;
}
.panel-title{
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 14px;
}

/* En-tête de panneau avec sélecteur de vue (tableau / cartes) */
.panel-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
}
.panel-head .panel-title{ margin: 0 0 14px; }
.view-toggle{
  display:inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 3px;
  margin-bottom: 14px;
}
.view-btn{
  display:inline-flex;
  align-items:center;
  gap:6px;
  border:none;
  background:transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 7px;
  cursor:pointer;
  transition: background .15s, color .15s;
}
.view-btn:hover{ color: var(--text); }
.view-btn.active{
  background: var(--primary);
  color:#fff;
}

/* Bouton supprimer dans une carte (vue cartes du manager) */
.card-delete{ margin-top: auto; }
.table{
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th{
  text-align: left;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.table td{
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
}
.table tbody tr:last-child td{ border-bottom: none; }
.table tbody tr:hover{ background: var(--surface-2); }

.badge-table{
  font-size: 12px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 20px;
  display: inline-block;
}
.badge-table.etat-affecte{ background: var(--affecte-bg); color: var(--affecte-text); }
.badge-table.etat-libre{ background: var(--libre-bg); color: var(--libre-text); }
.badge-table.etat-charge{ background: var(--charge-bg); color: var(--charge-text); }
.badge-table.etat-inop{ background: var(--inop-bg); color: var(--inop-text); }

.inline-form{
  display:flex;
  gap:10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.inline-form input{ flex:1; min-width: 180px; }
.inline-form .btn{ flex-shrink:0; }
.inline-form-comptes input, .inline-form-comptes select{ flex: 1; min-width: 150px; }
.inline-form-filtres{ margin-bottom: 0; flex-wrap: nowrap; }
.inline-form-filtres select{ width: auto; min-width: 150px; }

.table-delete{
  color: var(--text-muted);
}
.table-delete:hover{ color: var(--inop-text); }

/* ----- Page d'accueil ----- */
.home-container{
  max-width: 720px;
  margin: 60px auto;
  padding: 0 24px;
  text-align: center;
}
.home-title{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 10px;
}
.home-subtitle{
  color: var(--text-muted);
  margin-bottom: 36px;
}
.home-choices{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(220px,1fr));
  gap: 20px;
}
.home-card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 20px;
  text-decoration: none;
  color: var(--text);
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:10px;
  transition: transform .12s, box-shadow .12s;
}
.home-card:hover{
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.home-card i{
  font-size: 32px;
  color: var(--primary);
}
.home-card-title{ font-weight: 600; font-size: 16px; }
.home-card-desc{ font-size: 13px; color: var(--text-muted); }

/* ----- Auth (ecran de connexion) ----- */
.auth-page{
  min-height: 100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 24px;
}
.auth-card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 30px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,0.55);
}
.auth-logo{
  width: 168px;
  margin: 0 auto 18px;
  padding: 14px 18px;
  background: #fff;
  border-radius: var(--radius-lg);
  display:flex;
  align-items:center;
  justify-content:center;
  box-shadow: var(--glow-primary);
}
.auth-logo img{ width: 100%; height: auto; display: block; }
.auth-title{ font-size: 18px; font-weight: 600; margin: 0; color: var(--text); }
.auth-brand{
  color: var(--primary);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: .08em;
  margin: 2px 0 10px;
}
.auth-subtitle{ color: var(--text-muted); font-size: 13px; margin: 0 0 22px; }
.auth-divider{ border-top: 1px solid var(--border); margin-bottom: 22px; }
.auth-card form{ text-align: left; }
.auth-card form .field-label{ display:block; margin: 16px 0 6px; }
.auth-card form .field-label:first-of-type{ margin-top: 0; }
.auth-card .btn-pill{ margin-top: 20px; }
.auth-error{ color: var(--inop-text); font-size: 13px; margin: 12px 0 0; text-align: left; }

.password-wrapper{ position: relative; }
.password-wrapper input{ padding-right: 44px; }
.password-toggle{
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
}

/* ----- Toast ----- */
.toast{
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  z-index: 200;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  max-width: calc(100vw - 32px);
}
.toast.hidden{ display:none; }

/* ----- Layout avec Sidebar (régulateur / consultation / manager) ----- */
.page-wrap{
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}
.page-wrap .stats{ margin-bottom: 20px; }

/* Mise en page type tableau de bord :
   sidebar pleine hauteur collé à gauche + zone de contenu à droite. */
.app-layout{
  display:flex;
  gap:0;
  align-items: stretch;
  min-height: calc(100vh - var(--topbar-h));
}

/* Bouton pour ouvrir/fermer le sidebar */
.btn-toggle-sidebar{ font-size: 22px; }

/* Sidebar masquée : glisse hors écran vers la gauche (le contenu reprend
   toute la largeur car la sidebar est en position fixe, hors flux). */
.app-layout.sidebar-collapsed .sidebar{
  transform: translateX(-100%);
  pointer-events: none;
}

/* Sidebar = colonne fixe pleine hauteur qui démarre tout en haut (au-dessus
   de la topbar), aussi bien sur bureau que sur mobile. */
.sidebar{
  flex-shrink: 0;
  width: var(--sidebar-w);
  display:flex;
  flex-direction:column;
  gap:16px;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 30;
  height: 100vh;
  height: 100dvh;
  background: var(--surface);
  border: none;
  border-right: 1px solid var(--border);
  border-radius: 0;
  padding: 20px 14px;
  overflow-y: auto;
  overflow-x: hidden;
  white-space: nowrap;
  transform: translateX(0);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Quand la sidebar est ouverte (bureau), la topbar et le contenu se décalent
   à droite pour lui faire de la place (mise en page « push », pas overlay). */
@media (min-width: 641px){
  .topbar,
  .app-layout{
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  body.nav-ouverte .topbar,
  body.nav-ouverte .app-layout{
    margin-left: var(--sidebar-w);
  }
}

/* Zone de contenu à droite du sidebar (cartes + tableaux/grille) */
.content-area{
  flex: 1;
  min-width: 0;
  padding: 24px;
}
.content-area > .stats{ margin-bottom: 20px; }

/* Logo de marque */
.sidebar-brand{ display:flex; justify-content:center; }
.sidebar-logo-box{
  width: 100%;
  background: #fff;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display:flex;
  align-items:center;
  justify-content:center;
  box-shadow: var(--glow-primary);
}
.sidebar-logo-box img{ max-width: 100%; height: 36px; object-fit: contain; display:block; }
.sidebar-logo-fallback{
  display:none;
  color: var(--primary);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: .08em;
  line-height: 1.1;
  text-align:center;
}

/* Carte utilisateur */
.sidebar-user-section{
  display:flex;
  align-items:center;
  gap:10px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-user-avatar{
  flex-shrink:0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color:#fff;
  font-weight: 700;
  font-size: 14px;
  display:flex;
  align-items:center;
  justify-content:center;
}
.sidebar-user-info{ display:flex; flex-direction:column; min-width:0; }
.sidebar-user-name{
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-status{
  font-size: 10px;
  font-weight: 600;
  color: var(--libre-text);
  letter-spacing: .06em;
}

/* Libellé de section */
.sidebar-section-label{
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}

/* Navigation / filtres */
.sidebar-nav{
  display:flex;
  flex-direction:column;
  gap:6px;
}
.sidebar-link{
  display:flex;
  align-items:center;
  gap:10px;
  width:100%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  text-align:left;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.sidebar-link:hover{ background: var(--surface-2); color: var(--text); }
.sidebar-link.active{
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: var(--glow-primary);
}
.sidebar-icon{
  font-size: 16px;
  width: 20px;
  text-align:center;
  flex-shrink:0;
}
.sidebar-link-label{ flex:1; }
.sidebar-badge{
  flex-shrink:0;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  display:flex;
  align-items:center;
  justify-content:center;
}
.sidebar-link.active .sidebar-badge{ background: rgba(255,255,255,0.25); color:#fff; }

/* Bascule de module (Tracteurs / Tapis) dans le sidebar */
.module-switch{
  display:flex;
  gap:6px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: var(--radius-md);
}
.module-btn{
  flex:1;
  padding: 8px 6px;
  border:none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.module-btn:hover{ color: var(--text); }
.module-btn.active{
  background: var(--primary);
  color:#fff;
  box-shadow: var(--glow-primary);
}

/* Vignettes photo (tapis à bagages / tracteur) en remplacement des icônes/emojis */
.img-tapis,
.img-tracteur{
  height: 18px;
  width: auto;
  max-width: 32px;
  object-fit: contain;
  vertical-align: middle;
  border-radius: 3px;
  background: #fff;
  padding: 1px 2px;
}
.zone-tag .img-tapis,
.zone-tag .img-tracteur{ height: 15px; }
.card-icon .img-tapis,
.card-icon .img-tracteur{ height: 24px; max-width: 44px; }
.topbar-left .img-tapis,
.topbar-left .img-tracteur{ height: 26px; max-width: 46px; }

/* Pied : email */
.sidebar-footer-email{
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display:flex;
  align-items:center;
  gap:6px;
  font-size: 11px;
  color: var(--text-muted);
  word-break: break-all;
}

.app-layout .grid,
.app-layout .app-main{
  flex: 1;
  min-width: 0;
}
.app-main > .panel:last-child{ margin-bottom: 0; }

/* ----- Sections de cartes du tableau de bord manager ----- */
.dash-bloc{ margin-bottom: 18px; }
.dash-bloc-titre{
  display:flex;
  align-items:center;
  gap:8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 2px 10px;
}
.dash-bloc-hint{ font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--text-muted); opacity: .8; }
.stat-tapis-nav{ cursor: pointer; }
.stat-split{
  display:flex;
  align-items:center;
  gap:6px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.stat-split strong{ color: var(--text); font-size: 14px; }

/* ----- Statistiques (graphiques SVG/CSS) ----- */
.kpi-grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}
.kpi{
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--text-muted);
  padding: 14px 16px;
  display:flex;
  flex-direction:column;
  gap: 4px;
}
.kpi-val{ font-size: 26px; font-weight: 800; line-height: 1; }
.kpi-label{ font-size: 12px; color: var(--text-muted); }
.kpi-affecte{ border-left-color: var(--affecte-border); }
.kpi-libre{ border-left-color: var(--libre-border); }
.kpi-charge{ border-left-color: var(--charge-border); }
.kpi-inop{ border-left-color: var(--inop-border); }

.stats-charts{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.chart-panel{ margin-bottom: 0; }
.chart-titre{
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 14px;
  color: var(--text);
}

/* Donut */
.donut-wrap{ display:flex; flex-direction:column; align-items:center; gap: 14px; }
.donut-svg{ width: 160px; height: 160px; }
.donut-centre{ fill: var(--text); font-size: 30px; font-weight: 800; }
.donut-centre-sub{ fill: var(--text-muted); font-size: 12px; }
.chart-legend{
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  gap: 8px 16px;
}
.legende-item{ display:flex; align-items:center; gap:6px; font-size: 13px; color: var(--text-muted); }
.legende-item strong{ color: var(--text); }
.legende-pastille{ width: 11px; height: 11px; border-radius: 3px; flex-shrink:0; }

/* Barres horizontales */
.barres{ display:flex; flex-direction:column; gap: 12px; }
.barre-ligne{ display:flex; align-items:center; gap: 10px; }
.barre-label{ width: 96px; flex-shrink:0; font-size: 13px; color: var(--text-muted); }
.barre-piste{
  flex:1;
  height: 12px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow:hidden;
}
.barre-remplissage{
  height: 100%;
  border-radius: 999px;
  min-width: 3px;
  transition: width .4s ease;
}
.barre-valeur{ width: 28px; text-align:right; font-weight: 700; font-size: 13px; }

/* Activité (barres verticales) */
.activite-graph{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap: 6px;
  height: 160px;
}
.activite-col{ flex:1; display:flex; flex-direction:column; align-items:center; gap: 6px; height: 100%; }
.activite-barre-zone{ flex:1; width: 100%; display:flex; align-items:flex-end; }
.activite-barre{
  width: 100%;
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  border-radius: 6px 6px 0 0;
  min-height: 3px;
  transition: height .4s ease;
}
.activite-val{ font-size: 12px; font-weight: 700; }
.activite-jour{ font-size: 11px; color: var(--text-muted); text-transform: capitalize; }

/* Voile sombre derrière le tiroir (mobile uniquement) */
.sidebar-backdrop{ display: none; }

/* ----- Responsive ----- */
@media (max-width: 640px){
  .container{ padding: 16px; }
  .topbar{ padding: 12px 16px; }
  .stats{ grid-template-columns: repeat(2, 1fr); }
  .grid{ grid-template-columns: 1fr; }
  .home-choices{ grid-template-columns: 1fr; }

  .page-wrap{ padding: 16px; }
  .app-layout{
    flex-direction: column;
    gap: 0;
  }
  .content-area{ padding: 16px; }

  /* Sidebar = tiroir plein écran qui démarre tout en haut (au-dessus de la
     topbar), glisse depuis la gauche, et recouvre le contenu sur mobile. */
  .sidebar{
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    width: 284px;
    max-width: 84vw;
    z-index: 60;
    border: none;
    border-right: 1px solid var(--border);
    border-radius: 0;
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.5);
    padding: 18px 14px;
    transform: translateX(0);
    opacity: 1;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  /* Tiroir fermé : neutralise les règles desktop (width:0…) et glisse hors écran */
  .app-layout.sidebar-collapsed .sidebar{
    width: 284px;
    max-width: 84vw;
    min-width: 0;
    padding: 18px 14px;
    border-width: 0 1px 0 0;
    opacity: 1;
    pointer-events: none;
    transform: translateX(-100%);
  }
  /* Navigation en colonne dans le tiroir (pas une rangée de boutons) */
  .sidebar-nav{ flex-direction: column; flex-wrap: nowrap; }
  .sidebar-link{ flex: none; min-width: 0; }

  /* Voile : visible seulement quand le tiroir est ouvert */
  .sidebar-backdrop{
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }
  .app-layout:not(.sidebar-collapsed) .sidebar-backdrop{
    opacity: 1;
    pointer-events: auto;
  }
  /* Bloque le défilement du contenu quand le tiroir est ouvert */
  body.nav-ouverte{ overflow: hidden; }
}
