:root {
  --bg: #f4f6f8; --surface: #ffffff; --text: #1a1d21; --muted: #6b7280;
  --primary: #2563eb; --success: #16a34a; --warning: #ea580c; --danger: #dc2626;
  --radius: 8px; --shadow: 0 2px 6px rgba(0,0,0,.08); --touch: 48px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: var(--surface); border-right: 1px solid #e5e7eb;
  padding: 1rem 0; position: fixed; height: 100vh; overflow-y: auto; z-index: 10;
}
/* Version Ordinateur (Desktop) */
.main {
  /* Assure que padding et bordures sont inclus dans le calcul de largeur */
  box-sizing: border-box;

  /* Laisse le conteneur flex occuper tout l'espace restant */
  flex: 1;

  /* Évite les débordements */
  width: auto;
  max-width: 100%;

  /* Décalage exact égal à la largeur de votre menu latéral */
  margin-left: 16%;

  /* Espacement intérieur agréable sans étouffer l'écran */
  padding: 2rem 2.5rem;
}

/* Version Téléphone / Mobile */
@media (max-width: 768px) {
  .main {
    /* Supprime le décalage quand le menu passe en haut ou se masque */
    margin-left: 0;

    /* Réduit les marges intérieures pour les petits écrans */
    padding: 1rem;
    width: 100%;
  }
}

/* Nav */
.nav-brand { font-size: 1.25rem; font-weight: 500; padding: 0.5rem 1rem 1.5rem; border-bottom: 1px solid #e5e7eb; margin-bottom: 0.5rem; }
.nav-item {
  display: flex;
  align-items: left;
  gap: 1rem;
  padding: 0.75rem 1rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  min-height: var(--touch);
  border-radius: 0.5rem;
  transition: color 0.2s ease, background-color 0.2s ease;
}
.nav-item:hover, .nav-item.active { background: #eff6ff; color: var(--primary); font-weight: 500; }

/* Cards & Grid */
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.card { background: var(--surface); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.kpi { font-size: 2rem; font-weight: 700; color: var(--primary); }
.kpi-label { font-size: 0.85rem; color: var(--muted); margin-top: 0.25rem; }

/* Forms */
.form-group { margin-bottom: 1rem; }
label { display: block; font-size: 0.9rem; margin-bottom: 0.35rem; font-weight: 500; }
input, select, textarea {
  width: 100%; padding: 0.75rem; border: 1px solid #d1d5db; border-radius: var(--radius);
  font-size: 1rem; background: var(--surface); min-height: var(--touch);
}
button {
  cursor: pointer; padding: 0.75rem 1.25rem; border: none; border-radius: var(--radius);
  font-size: 1rem; font-weight: 500; background: var(--primary); color: white; min-height: var(--touch);
}
button:hover { opacity: 0.9; }
.btn-danger { background: var(--danger); } .btn-success { background: var(--success); }
.btn-warning { background: var(--warning); }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.75rem; text-align: left; border-bottom: 1px solid #e5e7eb; white-space: nowrap; }
th { background: #f9fafb; font-weight: 600; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid #e5e7eb; }
  .main { margin-left: 0; padding: 1rem; }
  .nav-item { padding: 0.5rem 0.75rem; min-height: 44px; }
}


.filter-bar { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.kpi-card { background: var(--surface); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); border-left: 4px solid var(--primary); }
.kpi-card h3 { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.25rem; text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-value { font-size: 1.75rem; font-weight: 700; color: var(--text); }
.total-card { border-left-color: #4f46e5; background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%); }
.stage-1 { border-left-color: #ea580c; }
.stage-2 { border-left-color: #d97706; }
.stage-3 { border-left-color: #16a34a; }
.stage-4 { border-left-color: #2563eb; }



/* 1. Réinitialisation globale obligatoire pour verrouiller la largeur */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden; /* Empêche le défilement horizontal */
}

/* 2. Menu latéral fixe à gauche */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 240px; /* Largeur fixe plus stable que les pourcentages */
  overflow-y: auto;
}

/* 3. Zone principale qui ne déborde pas */
.main {
  margin-left: 240px; /* Décalage strict identique à la largeur du menu */
  width: calc(100% - 240px); /* Largeur restante exacte */
  min-height: 100vh;
  padding: 2rem;
}

/* 4. Adaptation téléphone portable */
@media (max-width: 768px) {
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
  }

  .main {
    margin-left: 0;
    width: 100%;
    padding: 1rem;
  }
}

/* 1. Verrouillage global anti-débordement */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden;
}

/* 2. Version Ordinateur : Menu vertical à gauche */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 240px;
  background-color: var(--bg-nav, #ffffff);
  border-right: 1px solid var(--border, #e2e8f0);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 100;
}

.main {
  margin-left: 240px;
  width: calc(100% - 240px);
  min-height: 100vh;
  padding: 2rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--muted, #64748b);
  text-decoration: none;
  font-size: 0.95rem;
  min-height: var(--touch, 44px);
  border-radius: 0.5rem;
}

