/* ================================================================
   SESAME HSE — Feuille de style dédiée
   Couvre toutes les classes hse-*, utilitaires et composants
   ================================================================ */

/* ── Variables ─────────────────────────────────────────────────── */
:root {
  --hse-navy:    #1a2b6b;
  --hse-blue:    #1e9de0;
  --hse-orange:  #f47c20;
  --hse-red:     #dc2626;
  --hse-green:   #16a34a;
  --hse-amber:   #d97706;
  --hse-cyan:    #0e7490;
  --hse-purple:  #7c3aed;
  --hse-bg:      #f1f4f9;
  --hse-surface: #ffffff;
  --hse-border:  #e2e8f0;
  --hse-text:    #1e293b;
  --hse-muted:   #64748b;
  --hse-radius:  10px;
  --hse-shadow:  0 2px 8px rgba(0,0,0,.08);
  --hse-shadow-md: 0 4px 16px rgba(0,0,0,.12);
}

/* ── Reset de base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--hse-bg);
  color: var(--hse-text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Layout principal ──────────────────────────────────────────── */
.hse-platform {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--hse-bg);
}

/* ── Header ────────────────────────────────────────────────────── */
.hse-header {
  background: linear-gradient(135deg, #1a2b6b 0%, #1e3a8a 100%);
  color: #fff;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 64px;
  box-shadow: 0 2px 12px rgba(26,43,107,.35);
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 100;
}

.hse-header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.hse-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(255,255,255,.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.hse-brand-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.3px;
  white-space: nowrap;
}

.hse-brand-sub {
  font-size: 11px;
  opacity: .75;
  white-space: nowrap;
}

.hse-header-kpis {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
  justify-content: flex-end;
  align-items: center;
}

/* KPI top-bar */
.hse-top-kpi {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  padding: 6px 12px;
  backdrop-filter: blur(4px);
  transition: background .2s;
  cursor: default;
}
.hse-top-kpi:hover { background: rgba(255,255,255,.2); }
.hse-top-kpi.loading {
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.6);
  font-size: 12px;
}
.hse-top-kpi.ok    { border-color: rgba(34,197,94,.4); }
.hse-top-kpi.warn  { border-color: rgba(251,191,36,.5); }
.hse-top-kpi.danger{ border-color: rgba(239,68,68,.5); }

.hse-top-kpi-val {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  color: #fff;
}
.hse-top-kpi-lbl {
  font-size: 10px;
  opacity: .8;
  white-space: nowrap;
  color: #fff;
}

/* ── Onglets ────────────────────────────────────────────────────── */
.hse-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 16px;
  background: var(--hse-surface);
  border-bottom: 2px solid var(--hse-border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex-wrap: nowrap;
  scrollbar-width: thin;
  position: sticky;
  top: 64px;
  z-index: 90;
}
.hse-tabs::-webkit-scrollbar { height: 3px; }
.hse-tabs::-webkit-scrollbar-thumb { background: var(--hse-border); border-radius: 3px; }

.hse-tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  background: transparent;
  color: var(--hse-muted);
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
  font-family: inherit;
}
.hse-tab-btn:hover {
  background: #f1f5f9;
  color: var(--hse-navy);
}
.hse-tab-btn.active {
  background: linear-gradient(135deg, #eef2ff, #dbeafe);
  color: var(--hse-navy);
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(26,43,107,.12);
}
.hse-tab-btn i {
  font-size: 13px;
}

/* ── Zone de contenu ────────────────────────────────────────────── */
#hse-content {
  flex: 1;
  padding: 20px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ── KPI cards grille ───────────────────────────────────────────── */
.hse-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.hse-kpi-card {
  background: var(--hse-surface);
  border-radius: var(--hse-radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--hse-shadow);
  border-left: 4px solid var(--hse-border);
  transition: box-shadow .2s, transform .15s;
  cursor: default;
}
.hse-kpi-card:hover {
  box-shadow: var(--hse-shadow-md);
  transform: translateY(-1px);
}
.hse-kpi-card.ok     { border-left-color: var(--hse-green); }
.hse-kpi-card.warn   { border-left-color: var(--hse-amber); }
.hse-kpi-card.danger { border-left-color: var(--hse-red);   }
.hse-kpi-card.info   { border-left-color: var(--hse-blue);  }
.hse-kpi-card.navy   { border-left-color: var(--hse-navy);  }

.hse-kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  background: #f1f5f9;
  color: var(--hse-navy);
}
.hse-kpi-card.ok     .hse-kpi-icon { background: #f0fdf4; color: var(--hse-green); }
.hse-kpi-card.warn   .hse-kpi-icon { background: #fffbeb; color: var(--hse-amber); }
.hse-kpi-card.danger .hse-kpi-icon { background: #fef2f2; color: var(--hse-red);   }
.hse-kpi-card.info   .hse-kpi-icon { background: #eff8ff; color: var(--hse-blue);  }
.hse-kpi-card.navy   .hse-kpi-icon { background: #eef0f9; color: var(--hse-navy);  }

.hse-kpi-val {
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  color: var(--hse-text);
}
.hse-kpi-lbl {
  font-size: 11px;
  color: var(--hse-muted);
  margin-top: 3px;
  font-weight: 500;
}
.hse-kpi-sub {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 2px;
}

/* ── Mini KPI (inline row dans module-header) ───────────────────── */
.hse-mini-kpi {
  background: var(--hse-surface);
  border-radius: 10px;
  padding: 12px 20px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--hse-border);
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 140px;
  flex: 1 1 140px;
  transition: box-shadow .15s, transform .15s;
}
.hse-mini-kpi:hover { box-shadow: 0 2px 8px rgba(0,0,0,.1); transform: translateY(-1px); }
.hse-mini-kpi.ok     { border-left: 3px solid var(--hse-green);  }
.hse-mini-kpi.warn   { border-left: 3px solid var(--hse-amber);  }
.hse-mini-kpi.danger { border-left: 3px solid var(--hse-red);    }
.hse-mini-kpi.info   { border-left: 3px solid var(--hse-blue);   }
.hse-mini-kpi-val {
  font-size: 22px;
  font-weight: 800;
  color: var(--hse-navy);
  line-height: 1;
  flex-shrink: 0;
}
.hse-mini-kpi-lbl {
  font-size: 11px;
  color: var(--hse-muted);
  line-height: 1.3;
  max-width: 120px;
  white-space: normal;
}

/* ── Module header : KPI row + boutons sur la même ligne ─────────── */
.hse-module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: nowrap;
  gap: 12px;
  background: var(--hse-surface);
  border-radius: var(--hse-radius);
  padding: 14px 18px;
  border: 1px solid var(--hse-border);
  box-shadow: var(--hse-shadow);
  min-height: 64px;
}
.hse-module-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--hse-navy);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* KPI zone dans le module-header — flex horizontal scrollable */
.hse-module-kpis {
  display: flex;
  flex-direction: row;
  gap: 10px;
  flex: 1;
  flex-wrap: nowrap;
  align-items: stretch;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--hse-border) transparent;
}
.hse-module-kpis::-webkit-scrollbar { height: 3px; }
.hse-module-kpis::-webkit-scrollbar-thumb { background: var(--hse-border); border-radius: 3px; }

/* Actions boutons à droite du module-header */
.hse-module-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
  margin-left: auto;
}

/* ── Tableau de bord grille ─────────────────────────────────────── */
.hse-dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.hse-dash-card {
  background: var(--hse-surface);
  border-radius: var(--hse-radius);
  padding: 16px;
  box-shadow: var(--hse-shadow);
  border: 1px solid var(--hse-border);
  overflow: hidden;
}

.hse-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--hse-border);
}
.hse-card-header h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--hse-navy);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.hse-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--hse-navy);
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--hse-border);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Health grid ────────────────────────────────────────────────── */
.hse-health-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 20px;
}

/* ── Two panels ─────────────────────────────────────────────────── */
.hse-two-panels {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
/* Chaque panel avec card style */
.hse-two-panels > div {
  background: var(--hse-surface);
  border-radius: var(--hse-radius);
  border: 1px solid var(--hse-border);
  box-shadow: var(--hse-shadow);
  padding: 16px;
  width: 100%;
}

/* ── Plans grid ─────────────────────────────────────────────────── */
.hse-plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}
.hse-plan-card {
  background: var(--hse-surface);
  border-radius: var(--hse-radius);
  border: 1px solid var(--hse-border);
  overflow: hidden;
  box-shadow: var(--hse-shadow);
  transition: box-shadow .2s;
}
.hse-plan-card:hover { box-shadow: var(--hse-shadow-md); }
.hse-plan-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.hse-plan-body { padding: 14px; }
.hse-plan-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--hse-text);
  margin-bottom: 4px;
}
.hse-plan-meta {
  font-size: 11px;
  color: var(--hse-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.hse-plan-detail {
  font-size: 12px;
  color: var(--hse-muted);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--hse-border);
}

/* ── Badges ──────────────────────────────────────────────────────── */
.hse-sev-badge,
.hse-status-badge,
.hse-type-badge,
.hse-cat-badge,
.hse-num-badge,
.hse-prio-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: .3px;
}

/* Sévérité incidents */
.hse-inc-critical, [class*="hse-sev-"][class*="critical"] { background:#fef2f2; color:#dc2626; }
.hse-inc-major,    [class*="hse-sev-"][class*="major"]    { background:#fff7ed; color:#ea580c; }
.hse-inc-minor,    [class*="hse-sev-"][class*="minor"]    { background:#fefce8; color:#ca8a04; }
.hse-inc-near_miss,[class*="hse-sev-"][class*="near"]     { background:#eff6ff; color:#2563eb; }
.hse-inc-observation                                       { background:#f0fdf4; color:#16a34a; }

/* Statuts */
.hse-inc-status-open      { background:#fef2f2; color:#dc2626; }
.hse-inc-status-closed    { background:#f0fdf4; color:#16a34a; }
.hse-inc-status-under_investigation { background:#fff7ed; color:#d97706; }
.hse-inc-status-pending   { background:#fffbeb; color:#d97706; }
.hse-inc-status-approved  { background:#f0fdf4; color:#16a34a; }
.hse-inc-status-rejected  { background:#fef2f2; color:#dc2626; }
.hse-inc-status-active    { background:#eff6ff; color:#2563eb; }
.hse-inc-status-expired   { background:#fef2f2; color:#dc2626; }
.hse-inc-status-planned   { background:#f5f3ff; color:#7c3aed; }
.hse-inc-status-completed { background:#f0fdf4; color:#16a34a; }

/* Audits */
.hse-audit-status-planned   { background:#f5f3ff; color:#7c3aed; }
.hse-audit-status-in_progress { background:#eff6ff; color:#2563eb; }
.hse-audit-status-completed { background:#f0fdf4; color:#16a34a; }
.hse-audit-status-overdue   { background:#fef2f2; color:#dc2626; }

/* Actions / CAPA */
.hse-action-status-open     { background:#fff7ed; color:#d97706; }
.hse-action-status-in_progress { background:#eff6ff; color:#2563eb; }
.hse-action-status-completed { background:#f0fdf4; color:#16a34a; }
.hse-action-status-overdue  { background:#fef2f2; color:#dc2626; }
.hse-action-status-cancelled { background:#f1f5f9; color:#64748b; }

/* Agents santé */
.hse-agent-permanent { background:#eff6ff; color:#2563eb; }
.hse-agent-temporary { background:#fff7ed; color:#d97706; }
.hse-agent-contractor { background:#f5f3ff; color:#7c3aed; }

/* Résultats médicaux */
.hse-result-apte     { background:#f0fdf4; color:#16a34a; font-weight:700; }
.hse-result-inapte   { background:#fef2f2; color:#dc2626; font-weight:700; }
.hse-result-restrict { background:#fff7ed; color:#d97706; font-weight:700; }

/* Environnement */
.hse-env-air        { background:#eff6ff; color:#2563eb; }
.hse-env-water      { background:#ecfeff; color:#0891b2; }
.hse-env-soil       { background:#fefce8; color:#ca8a04; }
.hse-env-noise      { background:#f5f3ff; color:#7c3aed; }
.hse-env-waste      { background:#f0fdf4; color:#16a34a; }
.hse-env-chemical   { background:#fff7ed; color:#d97706; }

/* Types audit */
.hse-audit-internal { background:#eff6ff; color:#2563eb; }
.hse-audit-external { background:#f5f3ff; color:#7c3aed; }
.hse-audit-regulatory { background:#fff7ed; color:#d97706; }

/* Priorités */
.hse-prio-badge[class*="high"]     { background:#fef2f2; color:#dc2626; }
.hse-prio-badge[class*="medium"]   { background:#fff7ed; color:#d97706; }
.hse-prio-badge[class*="low"]      { background:#f0fdf4; color:#16a34a; }
.hse-prio-badge[class*="critical"] { background:#fdf2f8; color:#9333ea; }

/* Urgences */
.hse-plan-emergency { background:#fef2f2; color:#dc2626; }
.hse-plan-fire      { background:#fff7ed; color:#ea580c; }
.hse-plan-spill     { background:#ecfeff; color:#0891b2; }
.hse-plan-medical   { background:#f0fdf4; color:#16a34a; }

.hse-drill-fire      { background:#fff7ed; color:#ea580c; }
.hse-drill-spill     { background:#ecfeff; color:#0891b2; }
.hse-drill-medical   { background:#f0fdf4; color:#16a34a; }
.hse-drill-evacuation { background:#fef2f2; color:#dc2626; }
.hse-drill-status-planned   { background:#f5f3ff; color:#7c3aed; }
.hse-drill-status-completed { background:#f0fdf4; color:#16a34a; }
.hse-drill-status-cancelled { background:#f1f5f9; color:#64748b; }

/* Produits chimiques */
.hse-camp-internal  { background:#eff6ff; color:#2563eb; }
.hse-camp-external  { background:#f5f3ff; color:#7c3aed; }
.hse-camp-status-planned   { background:#f5f3ff; color:#7c3aed; }
.hse-camp-status-active    { background:#eff6ff; color:#2563eb; }
.hse-camp-status-completed { background:#f0fdf4; color:#16a34a; }
.hse-insp-status-planned   { background:#f5f3ff; color:#7c3aed; }
.hse-insp-status-completed { background:#f0fdf4; color:#16a34a; }
.hse-insp-status-overdue   { background:#fef2f2; color:#dc2626; }

/* Findings */
.hse-finding-major    { background:#fef2f2; color:#dc2626; }
.hse-finding-minor    { background:#fff7ed; color:#d97706; }
.hse-finding-positive { background:#f0fdf4; color:#16a34a; }

/* Ligne en retard */
.hse-row-overdue { background: #fef2f2 !important; }

/* ── Table container scrollable ─────────────────────────────────── */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--hse-radius);
  border: 1px solid var(--hse-border);
}
.table-container::-webkit-scrollbar { height: 4px; }
.table-container::-webkit-scrollbar-thumb { background: var(--hse-border); border-radius: 4px; }

/* ── Tables ──────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  min-width: 560px;   /* force scroll horizontal plutôt que compression */
  border-collapse: collapse;
  font-size: 13px;
  background: var(--hse-surface);
}
.data-table thead tr {
  background: #f8fafc;
  border-bottom: 2px solid var(--hse-border);
}
.data-table th {
  padding: 9px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--hse-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 1;
}
.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--hse-border);
  vertical-align: middle;
  color: var(--hse-text);
}
.data-table td.td-truncate {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f8fafc; cursor: pointer; }

/* ── Filtres ─────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.filter-select {
  border: 1.5px solid var(--hse-border);
  background: var(--hse-surface);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12px;
  font-family: inherit;
  color: var(--hse-text);
  cursor: pointer;
  outline: none;
  transition: border-color .15s;
  appearance: auto;
}
.filter-select:focus { border-color: var(--hse-navy); }

/* ── Boutons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity .15s, transform .1s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover   { opacity: .9; transform: translateY(-1px); }
.btn:active  { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(135deg, var(--hse-navy), #2563eb);
  color: #fff;
  box-shadow: 0 2px 6px rgba(26,43,107,.3);
}
.btn-secondary {
  background: #f1f5f9;
  color: var(--hse-navy);
  border: 1.5px solid var(--hse-border);
}
.btn-secondary:hover { background: #e2e8f0; }

.btn-danger {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  color: #fff;
}
.btn-sm {
  padding: 5px 10px;
  font-size: 11px;
  border-radius: 6px;
}
.btn-icon {
  padding: 6px 8px;
  background: #f1f5f9;
  color: var(--hse-navy);
  border: 1px solid var(--hse-border);
}
.btn-icon:hover { background: #dbeafe; color: var(--hse-navy); }

/* ── Alertes ─────────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--hse-radius);
  font-size: 13px;
  margin-bottom: 12px;
  border: 1px solid transparent;
}
.alert-danger {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}
.alert-warning {
  background: #fffbeb;
  color: #92400e;
  border-color: #fde68a;
}
.alert-success {
  background: #f0fdf4;
  color: #166534;
  border-color: #bbf7d0;
}
.alert-info {
  background: #eff6ff;
  color: #1e40af;
  border-color: #bfdbfe;
}

/* ── Loader ──────────────────────────────────────────────────────── */
.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 20px;
  color: var(--hse-muted);
  font-size: 14px;
}
.loader i { font-size: 20px; color: var(--hse-navy); }

/* ── Empty state ─────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  color: var(--hse-muted);
  text-align: center;
  gap: 10px;
}
.empty-state i  { font-size: 36px; color: #cbd5e1; }
.empty-state h3 { margin: 0; font-size: 15px; color: var(--hse-text); }
.empty-state p  { margin: 0; font-size: 13px; }

/* ── Detail view ─────────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
  background: #f8fafc;
  border-radius: 8px;
  padding: 14px;
  border: 1px solid var(--hse-border);
}
.detail-section {
  margin-bottom: 12px;
  font-size: 13px;
}
.detail-section b {
  color: var(--hse-navy);
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
}
.detail-section p {
  margin: 0;
  color: var(--hse-text);
  line-height: 1.5;
}

/* ── Modal ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-box {
  background: var(--hse-surface);
  border-radius: 14px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--hse-border);
  position: sticky;
  top: 0;
  background: var(--hse-surface);
  z-index: 1;
}
.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--hse-navy);
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-body   { padding: 20px; }
.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 14px 20px;
  border-top: 1px solid var(--hse-border);
  background: #f8fafc;
  border-radius: 0 0 14px 14px;
}

/* ── Formulaires ─────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--hse-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  border: 1.5px solid var(--hse-border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--hse-text);
  background: var(--hse-surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--hse-navy);
  box-shadow: 0 0 0 3px rgba(26,43,107,.1);
}
.form-group textarea { resize: vertical; min-height: 80px; }

/* ── FDS (Fiche de Données de Sécurité) ─────────────────────────── */
.fds-header {
  background: linear-gradient(135deg, var(--hse-navy), #2563eb);
  color: #fff;
  padding: 16px 20px;
  border-radius: var(--hse-radius);
  margin-bottom: 14px;
}
.fds-sections {
  display: grid;
  gap: 10px;
}
.fds-section {
  background: var(--hse-surface);
  border-radius: 8px;
  padding: 12px 16px;
  border: 1px solid var(--hse-border);
  font-size: 13px;
}
.fds-section h4 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--hse-navy);
  text-transform: uppercase;
  letter-spacing: .3px;
}

/* ── Toast notifications ─────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  pointer-events: all;
  animation: toastIn .3s cubic-bezier(.34,1.56,.64,1);
  min-width: 260px;
  max-width: 360px;
}
@keyframes toastIn {
  from { opacity:0; transform:translateX(40px) scale(.9); }
  to   { opacity:1; transform:translateX(0)    scale(1);  }
}
.toast-success { background:#166534; color:#fff; }
.toast-error   { background:#991b1b; color:#fff; }
.toast-warning { background:#92400e; color:#fff; }
.toast-info    { background:var(--hse-navy); color:#fff; }

/* ── Responsive ──────────────────────────────────────────────────── */

/* Tablette large */
@media (max-width: 1024px) {
  .hse-module-kpis { flex-wrap: nowrap; overflow-x: auto; }
  .hse-module-actions { margin-left: 0; }
}

/* ── Tablette (≤ 768px) ───────────────────────────────── */
@media (max-width: 768px) {

  /* ── Body scroll activé sur HSE (app.css peut override) ── */
  .hse-platform { min-height: 100vh; min-height: 100dvh; }

  /* ── Header HSE compact ── */
  #hse-content { padding: 10px; }
  .hse-header  { padding: 0 12px; min-height: 52px; flex-wrap: nowrap; gap: 8px; position: sticky; top: 0; z-index: 100; }
  .hse-header-kpis { display: none; }
  .hse-brand-title { font-size: 15px; }
  .hse-brand-sub   { display: none; }
  .hse-logo { width: 34px; height: 34px; font-size: 16px; }

  /* ── Onglets : scroll horizontal compact, sticky sous header ── */
  .hse-tabs {
    padding: 4px 6px;
    top: 52px; /* hauteur du header sur mobile */
    gap: 2px;
    position: sticky;
    z-index: 90;
    /* Forcer le scroll horizontal sans friction */
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scrollbar-width: none; /* masquer scrollbar sur mobile */
  }
  .hse-tabs::-webkit-scrollbar { display: none; }
  .hse-tab-btn {
    padding: 9px 11px;
    font-size: 11px;
    flex-shrink: 0;
    min-height: 40px; /* zone tactile iOS */
    min-width: 40px;
    scroll-snap-align: start;
  }
  .hse-tab-btn span { display: none; } /* icône seule sur mobile */

  /* ── Dashboard KPIs ── */
  .hse-kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .hse-kpi-card { padding: 12px 14px; gap: 10px; }
  .hse-kpi-val  { font-size: 20px; }
  .hse-kpi-icon { width: 36px; height: 36px; font-size: 15px; }
  .hse-dash-grid  { grid-template-columns: 1fr; }
  .hse-plans-grid { grid-template-columns: 1fr; }

  /* ── Module header : empilé en colonne ── */
  .hse-module-header {
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    padding: 10px 12px;
    gap: 8px;
  }
  .hse-module-kpis {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .hse-module-kpis::-webkit-scrollbar { display: none; }
  .hse-mini-kpi { min-width: 110px; flex: 0 0 auto; padding: 8px 12px; }
  .hse-mini-kpi-val { font-size: 18px; }
  .hse-module-actions { width: 100%; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
  .hse-module-actions .btn { flex: 1; min-width: 100px; justify-content: center; font-size: 12px; }

  /* ── Tables : wrapper scroll horizontal ── */
  .table-container {
    border-radius: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .data-table { font-size: 12px; min-width: 500px; }
  .data-table th { font-size: 10px; padding: 7px 8px; white-space: nowrap; }
  .data-table td { padding: 7px 8px; }

  /* ── Modal HSE ── */
  .modal-box {
    max-width: 100%;
    margin: 0;
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    overflow-y: auto;
  }

  /* ── Formation guidée ── */
  .hse-formation-btn span { display: none; }
  .hse-formation-btn { padding: 8px 10px !important; }

  /* ── Charts ── */
  canvas { max-width: 100% !important; touch-action: pan-y; }
}

/* ── Mobile strict (≤ 480px — iPhone/Android standard) ── */
@media (max-width: 480px) {
  /* Header encore plus compact */
  .hse-header { min-height: 48px; padding: 0 10px; }
  .hse-tabs   { top: 48px; padding: 3px 4px; }
  .hse-tab-btn { padding: 8px 10px; min-width: 38px; min-height: 38px; }

  /* KPIs → 2 colonnes (assez compact) */
  .hse-kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }

  /* Tables scroll horizontal */
  .table-container { overflow-x: auto; }
  .data-table { min-width: 420px; }

  /* Contenu */
  #hse-content { padding: 8px; }

  /* Section titles */
  .hse-section-title { font-size: 12px; }

  /* Mini KPIs encore plus compacts */
  .hse-mini-kpi { min-width: 95px; padding: 7px 10px; }
  .hse-mini-kpi-val  { font-size: 16px; }
  .hse-mini-kpi-lbl  { font-size: 10px; max-width: 75px; }

  /* Boutons */
  .btn { padding: 8px 12px; font-size: 12px; min-height: 40px; }
  .btn-sm { padding: 5px 8px; font-size: 11px; }
  .hse-module-actions .btn { padding: 8px 10px; }

  /* Status badges */
  .hse-status-badge { font-size: 10px; padding: 2px 6px; }

  /* Two panels en colonne */
  .hse-two-panels { gap: 10px; }
  .hse-two-panels > div { padding: 12px; }

  /* Plans grid */
  .hse-plans-grid { gap: 8px; }
  .hse-plan-card  { padding: 14px; }

  /* Formulaires modals */
  .hse-form-section { padding: 12px; }
}

/* ── Très petit (≤ 360px — Galaxy A, iPhone SE) ── */
@media (max-width: 360px) {
  .hse-tab-btn { padding: 7px 8px; min-width: 34px; }
  .hse-tab-btn i { font-size: 11px; }
  .hse-kpi-val   { font-size: 18px; }
  .hse-kpi-grid  { grid-template-columns: 1fr; }
  #hse-content   { padding: 6px; }
  .hse-two-panels > div { padding: 10px; }
  .data-table { min-width: 300px; font-size: 11px; }
  .data-table th { font-size: 9px; padding: 6px; }
  .data-table td { padding: 6px; }
  .hse-header { min-height: 46px; }
  .hse-tabs   { top: 46px; }
}

/* ── iOS Safe Area ── */
@supports (padding: env(safe-area-inset-bottom)) {
  .hse-header { padding-top: env(safe-area-inset-top); }
  .hse-platform { padding-bottom: env(safe-area-inset-bottom); }
}

/* ── Touch devices — tap targets 44px, pas de hover transform ── */
@media (hover: none) and (pointer: coarse) {
  .hse-tab-btn,
  .hse-module-actions .btn,
  .btn { min-height: 44px; }
  * { -webkit-tap-highlight-color: transparent; }
  /* Supprime les effets hover desktop qui ne s'affichent pas bien au touch */
  .hse-tab-btn:hover { background: transparent; color: var(--hse-muted); }
  .hse-tab-btn.active:hover { background: linear-gradient(135deg, #eef2ff, #dbeafe); color: var(--hse-navy); }
}

/* ── Tutoriel onboarding mobile — bottom-sheet ── */
@media (max-width: 768px) {
  #hse-onboard-tooltip {
    /* S'assure que la bottom-sheet reste au-dessus de la barre système */
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}
