/* ==========================================================================
   TBG — TRÉSOR BUSINESS GROUP · SYSTÈME DE DESIGN « MERIDIAN »
   Typographie : Manrope · Palette : indigo & encre · Interface de gestion
   Toutes les classes historiques sont conservées (compatibilité pages & JS).
   ========================================================================== */

:root {
  /* Typographie */
  --font-body: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  /* Marque */
  --primary: #4F46E5;
  --primary-dark: #4338CA;
  --primary-light: #818CF8;
  --primary-soft: #EEF2FF;
  --primary-line: #E0E7FF;
  --primary-glow: rgba(79, 70, 229, 0.16);

  /* Encres & fonds */
  --ink: #0B0F1D;
  --ink-2: #141A33;
  --sidebar-1: #0B0F1D;
  --sidebar-2: #161C36;
  --card-dark: #1D2440;
  --bg: #F5F6FA;
  --card: #FFFFFF;

  /* Texte */
  --text-main: #101828;
  --text-muted: #5D6B82;
  --text-light: #98A2B3;
  --text-white: #ffffff;

  /* Sémantique */
  --green-active: #059669;
  --green-soft: #ECFDF5;
  --green-line: #A7F3D0;
  --green-glow: rgba(5, 150, 105, 0.18);
  --amber-prospect: #D97706;
  --amber-soft: #FFFBEB;
  --amber-line: #FDE68A;
  --amber-glow: rgba(217, 119, 6, 0.18);
  --red-danger: #DC2626;
  --red-soft: #FEF2F2;
  --red-line: #FECACA;
  --purple-accent: #7C3AED;
  --purple-soft: #F5F3FF;
  --sky-accent: #0284C7;

  /* Traits */
  --line: #E7EAF3;
  --line-soft: #F0F2F8;

  /* Rayons */
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  /* Ombres */
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 12px 28px -16px rgba(16, 24, 40, 0.18);
  --shadow-lg: 0 24px 48px -20px rgba(16, 24, 40, 0.24);
  --shadow-glow: 0 8px 20px -8px rgba(79, 70, 229, 0.55);
  --ring: 0 0 0 4px var(--primary-glow);

  /* Compatibilité anciens tokens */
  --dark-navy: var(--ink);
  --ice-bg: var(--primary-soft);
  --ice-card: var(--card);
  --ice-border: var(--primary-line);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  background:
    radial-gradient(900px 400px at 85% -10%, rgba(79, 70, 229, 0.05) 0%, transparent 60%),
    var(--bg);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--primary); color: #fff; }

h1, h2, h3, h4, h5, h6 { font-weight: 800; letter-spacing: -0.02em; color: var(--text-main); }

/* --------------------------------------------------------------------------
   LAYOUT : SIDEBAR & CONTENEUR PRINCIPAL
   -------------------------------------------------------------------------- */
.app-wrapper {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  width: 272px;
  background: linear-gradient(180deg, var(--sidebar-1) 0%, var(--sidebar-2) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: transform 0.28s ease;
  z-index: 1000;
}

.brand-header {
  padding: 22px 20px 18px;
  display: flex;
  align-items: center;
  gap: 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.brand-logo-icon {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #6366F1 0%, #4338CA 100%);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
}

.brand-logo-icon svg { width: 22px; height: 22px; color: #fff; }

.brand-text h1 {
  font-size: 1.22rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: #fff;
  line-height: 1.15;
}

.brand-text span {
  display: block;
  font-size: 0.64rem;
  color: #A5B4FC;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 14px 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
}

.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-section-title {
  font-size: 0.64rem;
  font-weight: 700;
  color: #6B7394;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 16px 12px 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.07);
}

.nav-item a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  color: #9AA3C0;
  text-decoration: none;
  font-size: 0.87rem;
  font-weight: 600;
  border-radius: 10px;
  transition: background 0.16s ease, color 0.16s ease;
}

.nav-item a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }

.nav-item a:hover { background: rgba(255, 255, 255, 0.06); color: #E6E9F5; }

.nav-item.active a {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.22) 0%, rgba(99, 102, 241, 0.06) 100%);
  color: #FFFFFF;
  font-weight: 700;
}

.nav-item.active a::before {
  content: '';
  position: absolute;
  left: -14px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 4px;
  background: var(--primary-light);
  box-shadow: 0 0 12px rgba(129, 140, 248, 0.8);
}

.nav-item.active a svg { color: #A5B4FC; opacity: 1; }

.sidebar-user {
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.04);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.user-badge-info { display: flex; align-items: center; gap: 10px; min-width: 0; }

.user-avatar-circle {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, #6366F1 0%, #4338CA 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.82rem;
  color: #fff;
  letter-spacing: 0.02em;
}

.user-details h4 { font-size: 0.84rem; color: #fff; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-details span { font-size: 0.68rem; color: #A5B4FC; font-weight: 600; }

.sidebar-logout {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  color: #9AA3C0;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-logout:hover { background: rgba(220, 38, 38, 0.18); color: #FCA5A5; border-color: rgba(248, 113, 113, 0.35); }
.sidebar-logout svg { width: 15px; height: 15px; }

.sidebar-version {
  text-align: center;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #4A5275;
  padding: 0 16px 14px;
}

/* --------------------------------------------------------------------------
   TOPBAR & CONTENUS
   -------------------------------------------------------------------------- */
.main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 900;
}

.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }

.topbar-context { display: flex; align-items: baseline; gap: 8px; min-width: 0; }

.topbar-crumb {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.04em;
}

.topbar-crumb-sep { color: #C6CBDC; font-weight: 600; }

.topbar-page {
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right { display: flex; align-items: center; gap: 14px; }

.topbar-date {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.topbar-date svg { width: 13px; height: 13px; color: var(--primary); }

.db-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.74rem;
  font-weight: 700;
  color: #067647;
  background: var(--green-soft);
  border: 1px solid var(--green-line);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.db-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #12B76A;
  box-shadow: 0 0 0 3px rgba(18, 183, 106, 0.2);
  animation: db-pulse 2.4s ease-out infinite;
}

@keyframes db-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(18, 183, 106, 0.2); }
  50% { box-shadow: 0 0 0 5px rgba(18, 183, 106, 0.08); }
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px 5px 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  min-width: 0;
}

.user-chip-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366F1 0%, #4338CA 100%);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-chip-info { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.user-chip-info strong { font-size: 0.78rem; font-weight: 700; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.user-chip-info small { font-size: 0.64rem; font-weight: 600; color: var(--text-muted); white-space: nowrap; }

.logout-form { display: inline-flex; }

.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--red-line);
  background: var(--red-soft);
  color: #B42318;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-logout:hover { background: #FEE4E2; border-color: #FDA29B; }
.btn-logout svg { width: 14px; height: 14px; }

.content-body {
  padding: 28px 32px 56px;
  flex-grow: 1;
  max-width: 1500px;
  margin: 0 auto;
  width: 100%;
}

/* --------------------------------------------------------------------------
   BANNIÈRES FLASH
   -------------------------------------------------------------------------- */
.flash-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px auto 0;
  width: calc(100% - 64px);
  max-width: 1500px;
  padding: 13px 18px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid transparent;
  animation: content-fade-in 0.3s ease both;
}

.flash-banner svg { width: 18px; height: 18px; flex-shrink: 0; }
.flash-banner span { flex: 1; }

.flash-success { background: var(--green-soft); color: #067647; border-color: var(--green-line); }
.flash-danger  { background: var(--red-soft);   color: #B42318; border-color: var(--red-line); }
.flash-info    { background: var(--primary-soft); color: #3730A3; border-color: var(--primary-line); }

.flash-close {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  opacity: 0.6;
  padding: 0 2px;
  line-height: 1;
}

.flash-close:hover { opacity: 1; }

/* --------------------------------------------------------------------------
   EN-TÊTE DE PAGE (page-head)
   -------------------------------------------------------------------------- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
  padding: 4px 2px 22px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.page-head-main { min-width: 0; }

.page-head-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--primary-dark);
  background: var(--primary-soft);
  border: 1px solid var(--primary-line);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.page-head-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.page-head h1 {
  font-size: clamp(1.45rem, 2.2vw, 1.8rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
  margin: 0 0 5px;
  line-height: 1.15;
}

.page-head .page-head-sub {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: 0;
  max-width: 78ch;
  line-height: 1.55;
}

.page-head-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Chips KPI compacts dans l'en-tête */
.kpi-chip {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  min-width: 112px;
  box-shadow: var(--shadow-sm);
}

.kpi-chip .kpi-value {
  font-variant-numeric: tabular-nums;
  font-size: 1.38rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
  line-height: 1.1;
}

.kpi-chip .kpi-label {
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi-chip.accent-sky .kpi-value { color: var(--sky-accent); }
.kpi-chip.accent-amber .kpi-value { color: var(--amber-prospect); }
.kpi-chip.accent-green .kpi-value { color: var(--green-active); }
.kpi-chip.accent-rose .kpi-value { color: #E11D48; }
.kpi-chip.accent-indigo .kpi-value { color: var(--primary-dark); }

.head-progress { min-width: 200px; }
.head-progress .kpi-value small { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; }
.head-progress .quota-progress-container { height: 6px; margin-top: 8px; }

/* --------------------------------------------------------------------------
   CARTES KPI (stats-grid / stat-card)
   -------------------------------------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 16px;
  margin-bottom: 26px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #D9DEEC;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
  opacity: 0.85;
}

.stat-card.stat-green::after { background: linear-gradient(90deg, #059669, #34D399); }
.stat-card.stat-amber::after { background: linear-gradient(90deg, #D97706, #FBBF24); }
.stat-card.stat-purple::after { background: linear-gradient(90deg, #7C3AED, #A78BFA); }
.stat-card.stat-red::after { background: linear-gradient(90deg, #DC2626, #F87171); }

.stat-info { min-width: 0; }

.stat-info h5 {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 8px;
}

.stat-info .stat-value {
  font-variant-numeric: tabular-nums;
  font-size: 1.62rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
  line-height: 1.05;
}

.stat-info .stat-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}

.stat-icon-wrapper {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon-wrapper svg { width: 20px; height: 20px; }

.stat-green .stat-icon-wrapper { background: var(--green-soft); color: var(--green-active); }
.stat-amber .stat-icon-wrapper { background: var(--amber-soft); color: var(--amber-prospect); }
.stat-purple .stat-icon-wrapper { background: var(--purple-soft); color: var(--purple-accent); }
.stat-red .stat-icon-wrapper { background: var(--red-soft); color: var(--red-danger); }

/* --------------------------------------------------------------------------
   PANNEAUX (panel) & DÉTAILS REPLIABLES
   -------------------------------------------------------------------------- */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 26px;
  overflow: hidden;
}

.panel-header {
  padding: 17px 22px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--card);
}

.panel-header h3 {
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.panel-header h3 svg { width: 18px; height: 18px; color: var(--primary); flex-shrink: 0; }

.panel-body { padding: 22px; }

/* <details> utilisés pour les formulaires inline (ajustements, modifiers…) */
.panel details > summary,
details.st-details > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}

.panel details > summary::-webkit-details-marker,
details.st-details > summary::-webkit-details-marker { display: none; }

.panel details[open] > summary { margin-bottom: 12px; }

/* Alias de robustesse (certaines pages utilisent ces noms) */
.table-wrap { width: 100%; overflow-x: auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }

/* --------------------------------------------------------------------------
   TABLES
   -------------------------------------------------------------------------- */
.table-responsive { width: 100%; overflow-x: auto; }

.tundra-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
}

.tundra-table th {
  background: #F8F9FD;
  color: #667085;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.tundra-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.87rem;
  color: #1D2939;
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

.tundra-table tbody tr { transition: background 0.12s ease; }
.tundra-table tbody tr:hover { background: #F7F8FF; }
.tundra-table tbody tr:last-child td { border-bottom: none; }

.tundra-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.tundra-table strong { font-weight: 700; color: var(--text-main); }

/* --------------------------------------------------------------------------
   BADGES
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.45;
  white-space: nowrap;
}

.badge-green-active {
  background: var(--green-soft);
  color: #067647;
  border: 1px solid var(--green-line);
}

.badge-green-active::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #12B76A;
  animation: pulse-green 2s ease-out infinite;
  flex-shrink: 0;
}

@keyframes pulse-green {
  0% { box-shadow: 0 0 0 0 rgba(18, 183, 106, 0.45); }
  70% { box-shadow: 0 0 0 6px rgba(18, 183, 106, 0); }
  100% { box-shadow: 0 0 0 0 rgba(18, 183, 106, 0); }
}

.badge-amber-prospect {
  background: var(--amber-soft);
  color: #93370D;
  border: 1px solid var(--amber-line);
}

.badge-amber-prospect::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber-prospect);
  flex-shrink: 0;
}

.badge-category {
  background: var(--primary-soft);
  color: #3730A3;
  border: 1px solid var(--primary-line);
  font-weight: 700;
}

.badge-fifo {
  background: var(--ink);
  color: #E0E4FF;
  font-weight: 700;
  font-family: 'Cascadia Mono', 'Consolas', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
}

/* --------------------------------------------------------------------------
   BOUTONS
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  border-radius: 11px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 14px -6px rgba(79, 70, 229, 0.55);
}

.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }

.btn-success {
  background: var(--green-active);
  color: #fff;
  box-shadow: 0 6px 14px -6px rgba(5, 150, 105, 0.5);
}

.btn-success:hover { background: #047857; transform: translateY(-1px); }

.btn-danger {
  background: var(--red-danger);
  color: #fff;
  box-shadow: 0 6px 14px -6px rgba(220, 38, 38, 0.45);
}

.btn-danger:hover { background: #B91C1C; transform: translateY(-1px); }

.btn-outline {
  background: var(--card);
  color: var(--primary-dark);
  border: 1px solid #D7DCEA;
}

.btn-outline:hover { background: var(--primary-soft); border-color: var(--primary-light); color: var(--primary-dark); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
}

.btn-ghost:hover { background: var(--line-soft); color: var(--text-main); }

.btn-sm { padding: 6px 12px; font-size: 0.78rem; border-radius: 9px; }
.btn-sm svg { width: 13px; height: 13px; }

.btn:active { transform: translateY(1px); }

.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

button[type="submit"].btn { border: none; }
button[type="submit"].btn-outline, button[type="submit"].btn-ghost { border: 1px solid; }

/* Petit indicateur de rotation dans les boutons (capture GPS en cours) */
.btn-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
  vertical-align: -2px;
  margin-right: 4px;
}

@keyframes btn-spin { to { transform: rotate(360deg); } }

/* Bouton de capture de position automatique */
.btn-auto-location {
  background: var(--primary) !important;
  color: #ffffff !important;
  border: none !important;
  box-shadow: 0 8px 18px -6px rgba(79, 70, 229, 0.6);
  font-weight: 700;
}

.btn-auto-location:hover { background: var(--primary-dark) !important; transform: translateY(-1px); }

.btn-auto-location:disabled { opacity: 0.75; cursor: wait; transform: none; }

/* --------------------------------------------------------------------------
   FORMULAIRES
   -------------------------------------------------------------------------- */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: #344054;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid #D7DCEA;
  border-radius: 11px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-main);
  background-color: var(--card);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}

select.form-control {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235D6B82' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

textarea.form-control { resize: vertical; min-height: 84px; }

.form-control::placeholder { color: #A8B0C3; }

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}

input[type="checkbox"] { accent-color: var(--primary); width: 16px; height: 16px; }
input[type="radio"] { accent-color: var(--primary); }

/* --------------------------------------------------------------------------
   ZONES SPÉCIALISÉES : GPS, PROGRESSION
   -------------------------------------------------------------------------- */
.gps-live-box {
  background: var(--green-soft);
  border: 1px solid var(--green-line);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.gps-live-coords {
  font-family: 'Cascadia Mono', 'Consolas', monospace;
  font-weight: 700;
  color: #067647;
  font-size: 0.88rem;
  letter-spacing: 0.01em;
}

.quota-progress-container {
  background: #E9EBF4;
  border-radius: var(--radius-full);
  height: 8px;
  width: 100%;
  overflow: hidden;
  position: relative;
}

.quota-progress-fill {
  background: linear-gradient(90deg, var(--primary) 0%, #12B76A 100%);
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --------------------------------------------------------------------------
   CARTES MAPLIBRE : CONTENEURS, FILTRES, LÉGENDE
   -------------------------------------------------------------------------- */
#pdv-map,
.pdv-explorer-map {
  height: 460px;
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid #D7DCEA;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}

.map-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--line);
}

.map-chips { display: flex; gap: 6px; flex-wrap: wrap; }

.map-chip {
  border: 1px solid #D7DCEA;
  background: var(--card);
  color: #475467;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 6px 13px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.16s ease;
}

.map-chip:hover { border-color: var(--primary-light); color: var(--primary-dark); }

.map-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px -4px rgba(79, 70, 229, 0.55);
}

.map-chip.chip-green.active {
  background: var(--green-active);
  border-color: var(--green-active);
  box-shadow: 0 4px 12px -4px rgba(5, 150, 105, 0.55);
}

.map-chip.chip-amber.active {
  background: var(--amber-prospect);
  border-color: var(--amber-prospect);
  box-shadow: 0 4px 12px -4px rgba(217, 119, 6, 0.55);
}

.map-chip.chip-dormant.active {
  background: #BE185D;
  border-color: #BE185D;
  box-shadow: 0 4px 12px -4px rgba(190, 24, 93, 0.55);
}

.map-filter-select {
  width: auto;
  min-width: 180px;
  padding: 6px 34px 6px 12px !important;
  font-size: 0.78rem !important;
}

.map-filter-search {
  flex: 1;
  min-width: 200px;
  max-width: 330px;
  padding: 7px 12px !important;
  font-size: 0.78rem !important;
}

.map-legend {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding: 9px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  color: #475467;
  font-weight: 600;
}

.legend-item { display: inline-flex; align-items: center; gap: 6px; }

.legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px rgba(16, 24, 40, 0.14);
}

.dot-green { background: var(--green-active); }
.dot-amber { background: var(--amber-prospect); }
.dot-dormant { background: linear-gradient(135deg, #98A2B3 0%, #667085 100%); }

.legend-hint { color: var(--text-light); font-weight: 500; font-size: 0.7rem; margin-left: auto; }

/* Bannière dormance dans la fiche PDV */
.pdv-card-dormant-banner {
  background: #FDF2F8;
  border-bottom: 1px solid #FBCFE8;
  color: #BE185D;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 8px 12px;
  text-align: center;
}

/* --------------------------------------------------------------------------
   ÉPINGLES MAPLIBRE (marqueurs PDV & tournées)
   -------------------------------------------------------------------------- */
.tour-stop-marker {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366F1 0%, #4338CA 100%);
  border: 2.5px solid #ffffff;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px -2px rgba(67, 56, 202, 0.55);
  cursor: pointer;
}

.tour-stop-marker.is-dormant {
  background: linear-gradient(135deg, #F472B6 0%, #BE185D 100%);
  box-shadow: 0 4px 12px -2px rgba(190, 24, 93, 0.55);
}

.tour-stop-marker.is-start {
  background: linear-gradient(135deg, #10B981 0%, #059669 100%);
  font-size: 0.92rem;
  box-shadow: 0 4px 12px -2px rgba(5, 150, 105, 0.55);
}

.map-style-switcher {
  background: rgba(255, 255, 255, 0.96);
  border-radius: 9px;
  box-shadow: 0 4px 14px rgba(16, 24, 40, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.map-style-btn {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.6rem;
  font-weight: 800;
  color: #475467;
  padding: 5px 9px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.map-style-btn:hover { background: #F1F3FA; }

.map-style-btn.active { background: var(--primary); color: #ffffff; }

.tour-stops-list {
  max-height: 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tour-stop-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 9px;
  border: 1px solid var(--line-soft);
  background: var(--card);
  cursor: pointer;
  font-size: 0.79rem;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.tour-stop-item:hover { background: #F8F9FE; border-color: #D9DEEC; }

.tour-stop-item input[type="checkbox"] {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  accent-color: var(--primary);
}

.tour-stop-name {
  flex: 1;
  font-weight: 700;
  color: var(--text-main);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tour-stop-name small { display: block; font-weight: 500; color: var(--text-muted); font-size: 0.66rem; }

.tour-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.03em;
}

.tour-badge.active { background: var(--green-soft); color: #067647; }
.tour-badge.prospect { background: var(--amber-soft); color: #93370D; }
.tour-badge.dormant { background: #FDF2F8; color: #BE185D; }

.tour-order { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }

.tour-order-header {
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--green-active);
  padding: 2px 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tour-order-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  padding: 9px 12px;
}

.tour-order-rank {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366F1 0%, #4338CA 100%);
  color: #ffffff;
  font-size: 0.76rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tour-order-info { flex: 1; min-width: 0; }

.tour-order-info strong {
  display: block;
  font-size: 0.83rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tour-order-info small { font-size: 0.7rem; color: var(--text-muted); }

/* Marqueurs PDV (carte riche) */
.pdv-marker {
  position: relative;
  cursor: pointer;
  width: 38px;
  height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pdv-marker-pin {
  width: 36px;
  height: 36px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid #ffffff;
  box-shadow: 0 4px 12px rgba(11, 15, 29, 0.35);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  z-index: 2;
}

.pdv-marker-pin b { font-weight: 800; font-size: 0.82rem; line-height: 1; }
.pdv-marker-pin > * { transform: rotate(45deg); }

.pdv-marker.is-active .pdv-marker-pin {
  background: linear-gradient(135deg, #34D399 0%, #059669 100%);
  color: #ffffff;
}

.pdv-marker.is-prospect .pdv-marker-pin {
  background: linear-gradient(135deg, #FBBF24 0%, #D97706 100%);
  color: #ffffff;
}

.pdv-marker.is-dormant .pdv-marker-pin {
  background: linear-gradient(135deg, #98A2B3 0%, #667085 100%);
  color: #ffffff;
  opacity: 0.92;
}

.pdv-marker.is-dormant .pdv-marker-pulse {
  background: rgba(244, 114, 182, 0.35);
  animation: marker-pulse 3.2s ease-out infinite;
}

.pdv-marker-tip {
  width: 2px;
  height: 10px;
  margin-top: -2px;
  background: rgba(255, 255, 255, 0);
  z-index: 1;
}

.pdv-marker-pulse {
  position: absolute;
  top: 1px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  z-index: 0;
}

.pdv-marker.is-active .pdv-marker-pulse { background: rgba(16, 185, 129, 0.35); animation: marker-pulse 2s ease-out infinite; }
.pdv-marker.is-prospect .pdv-marker-pulse { background: rgba(245, 158, 11, 0.3); animation: marker-pulse 2.6s ease-out infinite; }

@keyframes marker-pulse {
  0% { transform: translateX(-50%) scale(0.8); opacity: 0.8; }
  70% { transform: translateX(-50%) scale(2.1); opacity: 0; }
  100% { transform: translateX(-50%) scale(2.1); opacity: 0; }
}

.pdv-marker:hover .pdv-marker-pin {
  transform: rotate(-45deg) scale(1.18);
  box-shadow: 0 8px 20px rgba(11, 15, 29, 0.45);
}

/* Épingle de sélection (formulaire de création) */
.pdv-picker-pin {
  position: relative;
  width: 40px;
  height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: grab;
}

.pdv-picker-pin:active { cursor: grabbing; }

.pdv-picker-pin-head {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #818CF8 0%, #4338CA 100%);
  border: 3px solid #ffffff;
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  z-index: 2;
}

.pdv-picker-pin-head svg { width: 18px; height: 18px; }

.pdv-picker-pin-shadow {
  width: 14px;
  height: 5px;
  border-radius: 50%;
  background: rgba(11, 15, 29, 0.35);
  margin-top: 2px;
  filter: blur(1px);
}

.pdv-location-map {
  height: 340px;
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid #D7DCEA;
  z-index: 10;
}

/* Recherche d'adresse */
.map-search-wrapper { position: relative; margin-bottom: 10px; }

.map-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 60;
  max-height: 240px;
  overflow-y: auto;
}

.map-search-item {
  padding: 9px 14px;
  font-size: 0.8rem;
  color: #344054;
  cursor: pointer;
  border-bottom: 1px solid var(--line-soft);
  transition: background 0.14s ease;
}

.map-search-item:last-child { border-bottom: none; }
.map-search-item:hover { background: var(--primary-soft); color: var(--primary-dark); }
.map-search-item.muted { color: var(--text-light); cursor: default; }
.map-search-item.muted:hover { background: transparent; }

.coord-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--green-soft);
  border: 1px solid var(--green-line);
  color: #067647;
  font-family: 'Cascadia Mono', 'Consolas', monospace;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: var(--radius-full);
}

/* --------------------------------------------------------------------------
   POPUPS & FICHE PDV FLOTTANTE
   -------------------------------------------------------------------------- */
.maplibregl-popup-content {
  padding: 0 !important;
  border-radius: var(--radius-md) !important;
  overflow: hidden;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(16, 24, 40, 0.06) !important;
  max-height: min(68vh, 320px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.maplibregl-popup-close-button {
  width: 26px;
  height: 26px;
  font-size: 1rem;
  line-height: 26px;
  color: #ffffff;
  z-index: 5;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  padding: 0;
}

.maplibregl-popup-anchor-bottom .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip { border-top-color: #ffffff !important; }

.maplibregl-popup-anchor-top .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-right .maplibregl-popup-tip { border-bottom-color: #ffffff !important; }

.maplibregl-ctrl-group {
  border-radius: var(--radius-sm) !important;
  overflow: hidden;
  box-shadow: 0 4px 14px -4px rgba(16, 24, 40, 0.25) !important;
}

.maplibregl-ctrl-scale {
  border-radius: 4px;
  font-size: 0.68rem !important;
  color: #475467 !important;
}

.pdv-flyout {
  position: absolute;
  top: 14px;
  left: 14px;
  width: min(320px, calc(100% - 28px));
  max-height: calc(100% - 28px);
  overflow-y: auto;
  overscroll-behavior: contain;
  z-index: 25;
  border-radius: 16px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(16, 24, 40, 0.08);
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.pdv-flyout.open { opacity: 1; transform: none; pointer-events: auto; }

.pdv-flyout-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: rgba(11, 15, 29, 0.72);
  color: #fff;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease;
}

.pdv-flyout-close:hover { background: rgba(11, 15, 29, 0.92); }

.pdv-flyout .pdv-card-popup { border-radius: 16px; box-shadow: none; }

.pdv-card-popup {
  background: var(--card);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-family: var(--font-body);
}

.pdv-card-photo-wrapper { position: relative; width: 100%; height: 92px; background: var(--ink); overflow: hidden; }

.pdv-card-photo { width: 100%; height: 100%; object-fit: cover; }

.pdv-card-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  letter-spacing: 0.04em;
}

.pdv-card-badge.green { background: var(--green-active); color: #ffffff; }
.pdv-card-badge.orange { background: var(--amber-prospect); color: #ffffff; }

.pdv-card-body { padding: 11px 13px; }

.pdv-card-title {
  font-size: 0.94rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 2px;
  line-height: 1.25;
}

.pdv-card-category { font-size: 0.7rem; font-weight: 700; color: var(--primary); margin-bottom: 8px; }

.pdv-card-info-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.77rem;
  color: #475467;
  margin-bottom: 4px;
}

.pdv-card-rep-box {
  background: var(--green-soft);
  border: 1px solid var(--green-line);
  border-radius: 8px;
  padding: 6px 10px;
  margin: 8px 0;
  font-size: 0.74rem;
  color: #067647;
}

.pdv-card-action-btn {
  display: block;
  text-align: center;
  background: var(--primary);
  color: #ffffff;
  text-decoration: none;
  font-size: 0.77rem;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 9px;
  margin-top: 8px;
  transition: background 0.15s ease;
}

.pdv-card-action-btn:hover { background: var(--primary-dark); color: #ffffff; }

/* --------------------------------------------------------------------------
   TOASTS TEMPS RÉEL
   -------------------------------------------------------------------------- */
.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
}

.toast-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid #98A2B3;
  border-radius: var(--radius-md);
  padding: 13px 14px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateX(24px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast-item.open { opacity: 1; transform: none; }

.toast-item.level-danger { border-left-color: var(--red-danger); }
.toast-item.level-warning { border-left-color: var(--amber-prospect); }
.toast-item.level-info { border-left-color: var(--primary); }

.toast-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.toast-title { font-size: 0.84rem; font-weight: 800; color: var(--text-main); }

.level-danger .toast-title { color: #B42318; }
.level-warning .toast-title { color: #B54708; }

.toast-msg { font-size: 0.77rem; color: #475467; line-height: 1.5; }

.toast-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.toast-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 800;
  text-decoration: none;
  transition: background 0.15s ease;
}

.toast-link:hover { background: var(--primary-line); }

.toast-close {
  border: none;
  background: transparent;
  color: var(--text-light);
  font-size: 0.85rem;
  cursor: pointer;
  width: 22px;
  height: 22px;
  border-radius: 6px;
}

.toast-close:hover { background: var(--line-soft); color: #475467; }

/* --------------------------------------------------------------------------
   DIALOGUES & MODALES
   -------------------------------------------------------------------------- */
dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 0;
  max-width: min(480px, calc(100vw - 32px));
  width: 100%;
}

dialog::backdrop { background: rgba(11, 15, 29, 0.55); backdrop-filter: blur(2px); }

dialog .proof-dialog,
dialog .panel-header,
dialog .panel-body { font-family: var(--font-body); }

/* --------------------------------------------------------------------------
   MODALES MAISON (remplacement des popups natives alert/confirm)
   -------------------------------------------------------------------------- */
.st-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(11, 15, 29, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.st-modal-overlay.open { opacity: 1; }
.st-modal-overlay[hidden] { display: none; }

.st-modal {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 420px;
  width: 100%;
  padding: 26px 26px 22px;
  text-align: center;
  transform: translateY(10px) scale(0.97);
  transition: transform 0.18s ease;
}

.st-modal-overlay.open .st-modal { transform: none; }

.st-modal-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.st-modal-icon svg { width: 26px; height: 26px; }

.st-modal.danger .st-modal-icon { background: var(--red-soft); color: var(--red-danger); }

.st-modal-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
  margin-bottom: 8px;
}

.st-modal-message {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 20px;
  overflow-wrap: break-word;
}

.st-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.st-modal-actions .btn { min-width: 120px; }

@media (max-width: 480px) {
  .st-modal { padding: 22px 18px 18px; }
  .st-modal-actions { flex-direction: column-reverse; }
  .st-modal-actions .btn { width: 100%; }
}

/* --------------------------------------------------------------------------
   MENU MOBILE & OVERLAY
   -------------------------------------------------------------------------- */
.mobile-menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: #344054;
  cursor: pointer;
  transition: background 0.15s ease;
}

.mobile-menu-toggle:hover { background: var(--line-soft); }
.mobile-menu-toggle svg { width: 18px; height: 18px; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 29, 0.55);
  z-index: 998;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.sidebar-overlay.visible { display: block; opacity: 1; }

/* --------------------------------------------------------------------------
   GRILLES RESPONSIVES
   -------------------------------------------------------------------------- */
.grid-eq {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 22px;
  margin-bottom: 26px;
}

.grid-main {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 22px;
  margin-bottom: 26px;
}

.grid-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 22px;
  margin-bottom: 26px;
}

.grid-side {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: 22px;
  margin-bottom: 26px;
}

.tour-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
}

.tour-col-side {
  border-right: 1px solid var(--line-soft);
  padding: 14px 16px;
}

.grid-mv {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 2fr auto;
  gap: 10px;
  align-items: end;
}

@media (max-width: 1100px) {
  .grid-hero, .grid-main, .grid-side { grid-template-columns: 1fr; }
  .tour-grid { grid-template-columns: 1fr; }
  .tour-grid > .tour-col-side { border-right: none; border-bottom: 1px solid var(--line-soft); }
  .grid-mv { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 620px) {
  .tour-grid, .grid-eq { grid-template-columns: 1fr; }
  .grid-mv { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------------------------
   ONGLETS (st-tabs) & PAGINATION
   -------------------------------------------------------------------------- */
.st-tabs {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 5px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 74px;
  z-index: 40;
}

.st-tab-btn {
  border: none;
  background: transparent;
  color: #5D6B82;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 9px 16px;
  border-radius: 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background 0.14s ease, color 0.14s ease;
  white-space: nowrap;
}

.st-tab-btn svg { width: 14px; height: 14px; opacity: 0.75; }
.st-tab-btn:hover { background: var(--line-soft); color: var(--text-main); }

.st-tab-btn.active {
  background: var(--ink);
  color: #ffffff;
  box-shadow: 0 6px 16px -6px rgba(11, 15, 29, 0.55);
}

.st-tab-btn .st-tab-count {
  font-size: 0.66rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.2);
  color: inherit;
  padding: 1px 8px;
  border-radius: var(--radius-full);
  font-variant-numeric: tabular-nums;
}

.st-tab-btn:not(.active) .st-tab-count { background: #E9EBF4; color: #5D6B82; }

.st-tab-panel { display: none; }
.st-tab-panel.active { display: block; animation: st-tab-fade 0.18s ease; }

@keyframes st-tab-fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.st-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px;
  border-top: 1px solid var(--line-soft);
  background: #FAFBFE;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.st-pager-info { font-size: 0.76rem; color: var(--text-muted); font-weight: 600; }

.st-pager-controls { display: flex; align-items: center; gap: 6px; }

.st-pager-btn {
  border: 1px solid #D7DCEA;
  background: var(--card);
  color: #344054;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.st-pager-btn:hover:not(:disabled) { background: var(--primary-soft); border-color: var(--primary-line); color: var(--primary-dark); }
.st-pager-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.st-pager-page {
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--primary-dark);
  background: var(--card);
  border: 1px solid #D7DCEA;
  border-radius: 9px;
  padding: 5px 11px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}

.st-pager-page.current { background: var(--primary); color: #fff; border-color: var(--primary); cursor: default; }

/* --------------------------------------------------------------------------
   ANIMATIONS, POLISH & ACCESSIBILITÉ
   -------------------------------------------------------------------------- */
@keyframes content-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.content-body > * { animation: content-fade-in 0.32s ease both; }
.content-body > *:nth-child(2) { animation-delay: 0.04s; }
.content-body > *:nth-child(3) { animation-delay: 0.08s; }
.content-body > *:nth-child(4) { animation-delay: 0.12s; }

@keyframes st-glow {
  0% { box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.7); }
  100% { box-shadow: 0 0 0 3px rgba(99, 102, 241, 0); }
}

.st-highlight { animation: st-glow 1.6s ease-out 2; }

/* Barres de défilement discrètes */
.sidebar::-webkit-scrollbar,
.panel-body::-webkit-scrollbar,
.nav-scroll::-webkit-scrollbar,
.map-search-results::-webkit-scrollbar { width: 8px; }

.sidebar::-webkit-scrollbar-thumb,
.panel-body::-webkit-scrollbar-thumb,
.nav-scroll::-webkit-scrollbar-thumb,
.map-search-results::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.4);
  border-radius: var(--radius-full);
}

.sidebar::-webkit-scrollbar-track,
.nav-scroll::-webkit-scrollbar-track { background: transparent; }

/* Focus clavier visible partout */
a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

.btn:focus-visible,
.form-control:focus-visible,
.st-tab-btn:focus-visible,
.map-chip:focus-visible,
.st-pager-btn:focus-visible,
.st-pager-page:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Chiffres tabulaires partout où ça compte */
.stat-value, .tundra-table td, .kpi-chip .kpi-value, .topbar-date { font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  .st-highlight, .st-tab-panel.active, .content-body > * { animation: none; }
  .pdv-flyout, .toast-item { transition: opacity 0.2s ease; transform: none; }
  .badge-green-active::before, .db-dot, .pdv-marker-pulse { animation: none; }
}

/* --------------------------------------------------------------------------
   RESPONSIVE
   -------------------------------------------------------------------------- */
@media (max-width: 992px) {
  .sidebar {
    position: fixed;
    left: -280px;
    height: 100vh;
  }

  .sidebar.open { left: 0; box-shadow: var(--shadow-lg); }

  .content-body { padding: 18px 16px 40px; }
  .topbar { padding: 0 16px; }
  .flash-banner { width: calc(100% - 32px); }

  .mobile-menu-toggle { display: inline-flex; }
  .db-status-pill { display: none !important; }
  .topbar-date { display: none; }
  .logout-label { display: none; }

  .content-body div[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }

  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-card { padding: 16px; }
  .stat-info .stat-value { font-size: 1.35rem; }

  #pdv-map, .pdv-explorer-map { height: 360px; }
  .pdv-location-map { height: 280px; }
  .legend-hint { display: none; }
}

@media (max-width: 900px) {
  .page-head { padding: 2px 2px 16px; }
  .page-head h1 { font-size: 1.2rem; }
  .page-head-meta { width: 100%; }
  .kpi-chip { flex: 1 1 30%; min-width: 96px; }
  .st-tabs { top: 66px; border-radius: 12px; }
  .st-tab-btn { font-size: 0.76rem; padding: 8px 12px; }
  .user-chip-info { display: none; }
}

@media (max-width: 576px) {
  .stats-grid { grid-template-columns: 1fr; }
  .topbar { height: 58px; }
  .st-tabs { top: 60px; }
  .tundra-table th, .tundra-table td { padding: 10px 12px; font-size: 0.82rem; }
  .panel-header { padding: 14px 16px; }
  .panel-body { padding: 16px; }
}

@media (max-width: 620px) {
  .st-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }

  .st-tab-btn { flex-shrink: 0; }
  .pdv-explorer-map, #tour-map { height: 300px !important; }
  .tour-stop-item { padding: 8px; }
  .toast-stack { left: 12px; right: 12px; bottom: 12px; max-width: none; }

  .pdv-flyout {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 62%;
    border-radius: 18px 18px 0 0;
  }

  .pdv-flyout .pdv-card-popup { border-radius: 18px 18px 0 0; }
}
