/* ═══════════════════════════════════════════════════════════
   DIAGNOSTIC BEF THIONVILLE-HAYANGE
   Design System — Éditorial Institutionnel
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,wght@0,400;0,600;0,700;1,400&family=DM+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

/* ─── TOKENS ────────────────────────────────────────────── */
:root {
  --bg: #f5f2eb;
  --bg-warm: #eee9df;
  --bg-card: #ffffff;
  --bg-sidebar: #1a1815;
  --bg-sidebar-hover: #2a2722;
  --bg-sidebar-active: #3a3530;
  --bg-input: #faf9f6;
  --bg-badge: #e8e4da;

  --border: #ddd8cc;
  --border-light: #eae6dc;
  --border-focus: #9a3412;

  --text: #2c2825;
  --text-secondary: #7a756d;
  --text-muted: #a09a90;
  --text-on-dark: #e8e4da;
  --text-on-dark-muted: #8a857d;

  --primary: #9a3412;
  --primary-light: #fdf2ec;
  --primary-hover: #7c2a0e;
  --secondary: #115e59;
  --secondary-light: #ecf8f7;
  --secondary-hover: #0d4f4a;
  --accent: #6d28d9;

  --success: #3d7a4a;
  --success-light: #edf7ef;
  --warning: #b5830e;
  --warning-light: #fef9ec;
  --danger: #a12b2b;
  --danger-light: #fdf0f0;

  --font-heading: 'Source Serif 4', 'Georgia', serif;
  --font-body: 'DM Sans', 'Segoe UI', sans-serif;

  --sidebar-width: 260px;
  --sidebar-collapsed: 64px;
  --header-height: 56px;
  --radius: 4px;
  --radius-lg: 8px;
  --shadow-sm: 0 1px 2px rgba(26,24,21,0.06);
  --shadow: 0 1px 4px rgba(26,24,21,0.08);
  --shadow-lg: 0 4px 16px rgba(26,24,21,0.1);
  --transition: 200ms ease;
}

/* ─── RESET ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }
body { font-family: var(--font-body); background: var(--bg); color: var(--text); line-height: 1.6; overflow: hidden; height: 100vh; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button { font-family: var(--font-body); cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: var(--font-body); font-size: 0.933rem; }
h1,h2,h3,h4 { font-family: var(--font-heading); font-weight: 600; color: var(--text); line-height: 1.3; }

/* ─── APP LAYOUT ────────────────────────────────────────── */
.app-container { display: flex; height: 100vh; overflow: hidden; }

/* ─── SIDEBAR ───────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  display: flex; flex-direction: column;
  flex-shrink: 0;
  transition: width var(--transition);
  z-index: 100;
  overflow: hidden;
}
.sidebar-brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-brand h1 {
  font-family: var(--font-heading);
  font-size: 1.1rem; font-weight: 700;
  color: #e8e4da;
  letter-spacing: -0.02em;
}
.sidebar-brand .brand-sub {
  font-size: 0.73rem; color: var(--text-on-dark-muted);
  margin-top: 2px; font-weight: 400;
  letter-spacing: 0.04em; text-transform: uppercase;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar-nav::-webkit-scrollbar { width: 0; }

.nav-section { margin-bottom: 4px; }
.nav-section-title {
  padding: 8px 18px 4px;
  font-size: 0.67rem; font-weight: 600;
  color: var(--text-on-dark-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 18px;
  color: var(--text-on-dark);
  font-size: 0.87rem; font-weight: 400;
  cursor: pointer;
  transition: all 120ms ease;
  border-left: 3px solid transparent;
  position: relative;
}
.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: #fff;
}
.nav-item.active {
  background: var(--bg-sidebar-active);
  border-left-color: var(--primary);
  color: #fff; font-weight: 500;
}
.nav-item .nav-icon {
  width: 18px; height: 18px; opacity: 0.7;
  flex-shrink: 0;
}
.nav-item.active .nav-icon { opacity: 1; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: 0.67rem; font-weight: 600;
  padding: 1px 7px; border-radius: 10px;
}

.sidebar-user {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
}
.sidebar-user:hover { background: var(--bg-sidebar-hover); }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 0.73rem; font-weight: 600;
  flex-shrink: 0;
}
.sidebar-user .user-info { overflow: hidden; }
.sidebar-user .user-name { font-size: 0.8rem; color: #e8e4da; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-role { font-size: 0.67rem; color: var(--text-on-dark-muted); }

/* ─── MAIN AREA ─────────────────────────────────────────── */
.main-area {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; min-width: 0;
}

/* Header */
.main-header {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px;
  flex-shrink: 0;
}
.header-breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 0.87rem; }
.header-breadcrumb .bc-sep { color: var(--text-muted); }
.header-breadcrumb .bc-current { font-weight: 600; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.btn-icon {
  width: 36px; height: 36px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition);
  position: relative;
}
.btn-icon:hover { background: var(--bg-warm); color: var(--text); }
.btn-icon .badge-dot {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); border: 2px solid var(--bg-card);
}

.mobile-toggle { display: none; }

/* ─── CONTENT ───────────────────────────────────────────── */
.main-content {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 24px;
}
.main-content::-webkit-scrollbar { width: 6px; }
.main-content::-webkit-scrollbar-track { background: transparent; }
.main-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── PAGE HEADER ───────────────────────────────────────── */
.page-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--border);
}
.page-header h2 {
  font-size: 1.6rem; font-weight: 700;
  letter-spacing: -0.02em;
}
.page-header .page-desc {
  color: var(--text-secondary); margin-top: 4px;
  font-size: 0.93rem;
}
.page-header-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }

/* ─── CARDS ─────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color var(--transition);
}
.card:hover { border-color: #ccc7bb; }
.card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 16px; gap: 12px;
}
.card-title {
  font-family: var(--font-heading);
  font-size: 1.07rem; font-weight: 600;
}
.card-subtitle { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }

/* Grid */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ─── STAT CARDS ────────────────────────────────────────── */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex; flex-direction: column; gap: 4px;
}
.stat-card .stat-label {
  font-size: 0.73rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted);
}
.stat-card .stat-value {
  font-family: var(--font-heading);
  font-size: 1.8rem; font-weight: 700;
  line-height: 1;
}
.stat-card .stat-sub {
  font-size: 0.8rem; color: var(--text-secondary);
}
.stat-card.stat-primary { border-left: 3px solid var(--primary); }
.stat-card.stat-secondary { border-left: 3px solid var(--secondary); }
.stat-card.stat-success { border-left: 3px solid var(--success); }
.stat-card.stat-warning { border-left: 3px solid var(--warning); }

/* ─── PROGRESS ──────────────────────────────────────────── */
.progress-bar {
  height: 6px; background: var(--bg-warm);
  border-radius: 3px; overflow: hidden;
}
.progress-bar .progress-fill {
  height: 100%; border-radius: 3px;
  transition: width 400ms ease;
  background: var(--secondary);
}
.progress-bar .progress-fill.p-low { background: var(--danger); }
.progress-bar .progress-fill.p-mid { background: var(--warning); }
.progress-bar .progress-fill.p-high { background: var(--success); }

.progress-pct {
  font-family: var(--font-heading);
  font-size: 0.87rem; font-weight: 600;
}

/* ─── CHAMP CARDS (Dashboard) ───────────────────────────── */
.champ-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }

.champ-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.champ-card::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 4px;
}
.champ-card:hover { border-color: #b5b0a5; transform: translateY(-1px); box-shadow: var(--shadow); }
.champ-card .champ-num {
  font-family: var(--font-heading);
  font-size: 0.73rem; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.06em; margin-bottom: 4px;
}
.champ-card .champ-titre {
  font-family: var(--font-heading);
  font-size: 0.93rem; font-weight: 600;
  margin-bottom: 10px; line-height: 1.35;
}
.champ-card .champ-meta {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.73rem; color: var(--text-secondary);
  margin-top: 8px;
}
.champ-card .champ-team {
  display: flex; gap: -4px;
}
.champ-card .team-dot {
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.6rem; font-weight: 600; color: #fff;
  margin-left: -4px;
  border: 2px solid var(--bg-card);
}

/* ─── BUTTONS ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  font-size: 0.87rem; font-weight: 500;
  border-radius: var(--radius);
  transition: all var(--transition);
  white-space: nowrap;
  border: 1px solid transparent;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { background: var(--secondary-hover); }
.btn-outline { border: 1px solid var(--border); color: var(--text); background: var(--bg-card); }
.btn-outline:hover { border-color: var(--text-muted); background: var(--bg-warm); }
.btn-ghost { color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text); background: var(--bg-warm); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8b2424; }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-lg { padding: 10px 24px; font-size: 1rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── FORMS ─────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; margin-bottom: 4px;
  font-size: 0.8rem; font-weight: 600;
  color: var(--text);
}
.form-label .required { color: var(--danger); }
.form-hint { font-size: 0.73rem; color: var(--text-muted); margin-top: 2px; }

.form-input, .form-select, .form-textarea {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  transition: border-color var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(154,52,18,0.08);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-input.error { border-color: var(--danger); }

.form-row { display: flex; gap: 16px; }
.form-row > * { flex: 1; }

.form-inline { display: flex; align-items: flex-end; gap: 8px; }

/* ─── TABLES ────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.87rem;
}
.data-table th {
  text-align: left; padding: 10px 14px;
  font-weight: 600; font-size: 0.73rem;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  background: var(--bg);
  position: sticky; top: 0;
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
.data-table tr:hover td { background: rgba(245,242,235,0.5); }

/* ─── BADGES / TAGS ─────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 3px;
  font-size: 0.73rem; font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-default { background: var(--bg-badge); color: var(--text-secondary); }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-secondary { background: var(--secondary-light); color: var(--secondary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }

/* Statuts spécifiques */
.status-non_demarre { background: var(--bg-badge); color: var(--text-muted); }
.status-en_cours { background: #eef0fa; color: #4a4fc7; }
.status-indicateurs_ok { background: var(--warning-light); color: var(--warning); }
.status-synthese_ok { background: var(--secondary-light); color: var(--secondary); }
.status-valide { background: var(--success-light); color: var(--success); }

.status-brouillon { background: var(--bg-badge); color: var(--text-muted); }
.status-en_validation { background: #eef0fa; color: #4a4fc7; }
.status-envoye { background: var(--primary-light); color: var(--primary); }
.status-cloture { background: var(--secondary-light); color: var(--secondary); }
.status-archive { background: var(--bg-badge); color: var(--text-muted); }

/* Tendances */
.tendance-hausse { color: var(--success); }
.tendance-baisse { color: var(--danger); }
.tendance-stable { color: var(--text-muted); }

/* ─── SWOT GRID ─────────────────────────────────────────── */
.swot-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.swot-quadrant {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.swot-quadrant-header {
  padding: 10px 16px;
  font-family: var(--font-heading);
  font-size: 0.93rem; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
  color: #fff;
}
.swot-forces .swot-quadrant-header { background: var(--success); }
.swot-faiblesses .swot-quadrant-header { background: var(--danger); }
.swot-opportunites .swot-quadrant-header { background: #2563eb; }
.swot-menaces .swot-quadrant-header { background: #7c2d12; }

.swot-quadrant-body { padding: 12px; background: var(--bg-card); min-height: 120px; }
.swot-item {
  padding: 8px 10px; margin-bottom: 6px;
  border-radius: var(--radius);
  font-size: 0.87rem;
  border-left: 3px solid;
  background: var(--bg);
}
.swot-item.impact-critique { border-left-color: var(--danger); }
.swot-item.impact-fort { border-left-color: var(--warning); }
.swot-item.impact-moyen { border-left-color: var(--secondary); }
.swot-item.impact-faible { border-left-color: var(--text-muted); }

/* ─── FORUM ─────────────────────────────────────────────── */
.topic-list { display: flex; flex-direction: column; gap: 1px; background: var(--border-light); border-radius: var(--radius-lg); overflow: hidden; }
.topic-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px;
  background: var(--bg-card);
  cursor: pointer;
  transition: background var(--transition);
}
.topic-item:hover { background: var(--bg); }
.topic-item.pinned { border-left: 3px solid var(--primary); }
.topic-cat {
  font-size: 0.6rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 2px 6px; border-radius: 2px;
  flex-shrink: 0;
}
.topic-cat-urgent { background: var(--danger); color: #fff; }
.topic-cat-question { background: #eef0fa; color: #4a4fc7; }
.topic-cat-indicateur { background: var(--primary-light); color: var(--primary); }
.topic-cat-methodologie { background: var(--secondary-light); color: var(--secondary); }
.topic-cat-general { background: var(--bg-badge); color: var(--text-secondary); }
.topic-cat-sondage { background: var(--warning-light); color: var(--warning); }

.post-item {
  display: flex; gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-light);
}
.post-item:last-child { border-bottom: none; }
.post-content { flex: 1; min-width: 0; }
.post-author {
  font-weight: 600; font-size: 0.87rem;
  display: flex; align-items: center; gap: 6px;
}
.post-date { font-size: 0.73rem; color: var(--text-muted); }
.post-body { margin-top: 6px; font-size: 0.93rem; line-height: 1.6; }
.post-body .mention { color: var(--primary); font-weight: 500; cursor: pointer; }
.post-body .ref-indicateur, .post-body .ref-champ {
  background: var(--primary-light); color: var(--primary);
  padding: 1px 6px; border-radius: 3px; font-size: 0.8rem;
  font-weight: 500; cursor: pointer;
}

/* ─── MODAL ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(26,24,21,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: fadeIn 150ms ease;
}
.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 90%; max-width: 640px;
  max-height: 85vh; overflow: hidden;
  display: flex; flex-direction: column;
  animation: slideUp 200ms ease;
  box-shadow: var(--shadow-lg);
}
.modal-lg { max-width: 860px; }
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-family: var(--font-heading); font-size: 1.13rem; font-weight: 600; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ─── TOAST ─────────────────────────────────────────────── */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 0.87rem; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn 200ms ease;
  max-width: 360px;
  display: flex; align-items: center; gap: 8px;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-warning { background: var(--warning); color: #fff; }
.toast-info { background: var(--secondary); color: #fff; }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ─── GANTT SIMPLE ──────────────────────────────────────── */
.gantt-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border-light); }
.gantt-label { width: 200px; flex-shrink: 0; font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gantt-bar-container { flex: 1; height: 24px; position: relative; background: var(--bg); border-radius: 3px; }
.gantt-bar {
  position: absolute; height: 100%; border-radius: 3px;
  font-size: 0.67rem; color: #fff; display: flex; align-items: center; padding: 0 6px;
  overflow: hidden; white-space: nowrap;
}
.gantt-bar.status-a_faire { background: #b5b0a5; }
.gantt-bar.status-en_cours { background: var(--secondary); }
.gantt-bar.status-termine { background: var(--success); }
.gantt-bar.status-en_retard { background: var(--danger); }

/* ─── LOGIN PAGE ────────────────────────────────────────── */
.login-page {
  height: 100vh; display: flex;
  background: var(--bg);
}
.login-left {
  flex: 1; display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  padding: 40px;
}
.login-right {
  width: 45%; background: var(--bg-sidebar);
  display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  padding: 60px;
}
.login-right h2 {
  font-family: var(--font-heading);
  font-size: 2rem; color: #e8e4da;
  margin-bottom: 12px; text-align: center;
}
.login-right p {
  color: var(--text-on-dark-muted);
  font-size: 0.93rem; text-align: center;
  line-height: 1.6; max-width: 360px;
}

.login-form {
  width: 100%; max-width: 380px;
}
.login-form h1 {
  font-family: var(--font-heading);
  font-size: 1.6rem; margin-bottom: 4px;
}
.login-form .login-sub {
  color: var(--text-secondary);
  margin-bottom: 28px; font-size: 0.93rem;
}
.login-form .btn { width: 100%; justify-content: center; padding: 10px; margin-top: 8px; }

/* ─── EMPTY STATE ───────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state h4 { font-size: 1.07rem; color: var(--text-secondary); margin-bottom: 4px; }
.empty-state p { font-size: 0.87rem; max-width: 400px; margin: 0 auto; }

/* ─── LOADING ───────────────────────────────────────────── */
.spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}
.loading-overlay {
  display: flex; align-items: center; justify-content: center;
  padding: 48px; color: var(--text-muted); gap: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── SPLIT PANEL (Saisie + Forum latéral) ──────────────── */
.split-layout { display: flex; gap: 0; height: 100%; }
.split-main { flex: 1; overflow-y: auto; padding-right: 16px; min-width: 0; }
.split-panel {
  width: 360px; flex-shrink: 0;
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  background: var(--bg);
}
.split-panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-heading);
  font-weight: 600; font-size: 0.93rem;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-card);
}
.split-panel-body { flex: 1; overflow-y: auto; padding: 12px 16px; }

/* ─── CHECKLIST ─────────────────────────────────────────── */
.checklist-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 6px 0;
  font-size: 0.87rem;
}
.checklist-item input[type="checkbox"] {
  margin-top: 3px; accent-color: var(--primary);
}
.checklist-item.done { color: var(--text-muted); text-decoration: line-through; }

/* ─── TABS ──────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; gap: 0; }
.tab-item {
  padding: 8px 16px; cursor: pointer;
  font-size: 0.87rem; font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
}
.tab-item:hover { color: var(--text); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ─── NOTIFICATION PANEL ────────────────────────────────── */
.notif-panel {
  position: absolute; top: var(--header-height);
  right: 16px; width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  max-height: 400px; overflow-y: auto;
}
.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background var(--transition);
}
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: var(--primary-light); }
.notif-item .notif-title { font-weight: 600; font-size: 0.87rem; }
.notif-item .notif-message { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }
.notif-item .notif-time { font-size: 0.67rem; color: var(--text-muted); margin-top: 4px; }

/* ─── MENTION AUTOCOMPLETE ──────────────────────────────── */
.mention-dropdown {
  position: absolute; background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 300; max-height: 200px; overflow-y: auto;
  width: 240px;
}
.mention-option {
  padding: 8px 12px; cursor: pointer;
  font-size: 0.87rem;
  display: flex; align-items: center; gap: 8px;
}
.mention-option:hover { background: var(--bg); }

/* ─── RESPONSIVE — see bottom of file ──────────────────── */

/* ─── UTILS ─────────────────────────────────────────────── */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 0.8rem; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-center { text-align: center; }
.font-heading { font-family: var(--font-heading); }
.font-bold { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.clickable { cursor: pointer; }
.no-wrap { white-space: nowrap; }

/* ── BUG FIXES: Missing status badge variants ──────────── */
.status-en_revue { background: #e0e7ff; color: #3730a3; }
.status-publie { background: #d1fae5; color: #065f46; }
.status-propose { background: #fef3c7; color: #92400e; }
.status-rejete { background: #fecaca; color: #991b1b; }
.status-en_attente { background: #fef3c7; color: #78350f; }
.status-transmise { background: #dbeafe; color: #1e40af; }
.status-recue { background: #d1fae5; color: #065f46; }
.status-integree { background: #a7f3d0; color: #047857; }
.status-manquant { background: #fecaca; color: #991b1b; }
.status-demande { background: #e0e7ff; color: #4338ca; }

/* ── BUG FIX: Topic category color variants ────────────── */
.topic-cat { font-size: 0.67rem; padding: 2px 8px; border-radius: 3px; text-transform: uppercase; font-weight: 600; letter-spacing: 0.04em; flex-shrink: 0; }
.topic-cat-general { background: #e5e5e5; color: #525252; }
.topic-cat-question { background: #dbeafe; color: #1e40af; }
.topic-cat-indicateur { background: #fef3c7; color: #92400e; }
.topic-cat-sondage { background: #d1fae5; color: #065f46; }
.topic-cat-methodologie { background: #e0e7ff; color: #4338ca; }
.topic-cat-urgent { background: #fecaca; color: #991b1b; }

/* ── BUG FIX: Tendance styling ─────────────────────────── */
.tendance-hausse { color: var(--success); font-weight: 600; }
.tendance-baisse { color: var(--danger); font-weight: 600; }
.tendance-stable { color: var(--text-muted); }

/* ── BUG FIX: Impact styling (SWOT) ───────────────────── */
.impact-critique { border-left: 3px solid var(--danger); }
.impact-fort { border-left: 3px solid var(--warning); }
.impact-moyen { border-left: 3px solid var(--primary); }
.impact-faible { border-left: 3px solid var(--text-muted); }

/* ── BUG FIX: Sondage question form classes ────────────── */
.q-row { padding: 12px; margin-bottom: 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.q-row .form-row { margin-bottom: 0; }
.q-text { flex: 3; }
.q-type { flex: 1; }
.q-opts-wrap { margin-top: 8px; }
.q-opts-wrap.hidden { display: none; }
.q-opts { font-size: 0.8rem; }

/* ── BUG FIX: Notification panel position ──────────────── */
.notif-panel { position: fixed; top: 56px; right: 16px; width: 360px; max-height: 70vh; overflow-y: auto; background: white; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: 0 8px 30px rgba(0,0,0,0.12); z-index: 1200; }
.notif-item { padding: 10px 16px; border-bottom: 1px solid var(--border-light); cursor: pointer; transition: background 0.15s; }
.notif-item:hover { background: var(--bg-warm); }
.notif-item.unread { background: #fdf8f0; border-left: 3px solid var(--primary); }
.notif-title { font-size: 0.87rem; font-weight: 500; }
.notif-message { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }
.notif-time { font-size: 0.73rem; color: var(--text-muted); margin-top: 4px; }
.badge-dot { position: absolute; top: 2px; right: 2px; width: 8px; height: 8px; background: var(--danger); border-radius: 50%; }
.badge-dot.hidden { display: none; }
#notifBtn { position: relative; }

/* ── BUG FIX: Sidebar backdrop ─────────────────────────── */
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 998; }

/* ── BUG FIX: Public sondage page (no shell) ───────────── */
.public-sondage-page { min-height: 100vh; background: var(--bg-page); padding: 24px 16px; }
.public-sondage-page .card { max-width: 700px; margin: 0 auto; }

/* ── BUG FIX: Mention & reference tags ─────────────────── */
.mention { background: #dbeafe; color: #1e40af; padding: 0 4px; border-radius: 3px; font-size: 0.87rem; font-weight: 500; }
.ref-indicateur { background: #fef3c7; color: #92400e; padding: 0 4px; border-radius: 3px; font-size: 0.8rem; }
.ref-champ { background: #d1fae5; color: #065f46; padding: 0 4px; border-radius: 3px; font-size: 0.8rem; }

/* ── BUG FIX: Pinned topic styling ─────────────────────── */
.topic-item.pinned { background: #fdf8f0; }
.topic-item.pinned::before { content: '📌'; margin-right: 6px; }

/* ── BUG FIX: Header breadcrumb ────────────────────────── */
.bc-current { font-weight: 600; color: var(--text-primary); }
.bc-sep { color: var(--text-muted); margin: 0 6px; }

/* ── BUG FIX: Priority badges ──────────────────────────── */
.badge-danger { background: #fecaca; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-primary { background: var(--primary-light); color: var(--primary); }

/* ── BUG FIX: Gantt status bars ────────────────────────── */
.gantt-bar.status-en_cours { background: var(--secondary); }
.gantt-bar.status-termine { background: var(--success); }
.gantt-bar.status-en_retard { background: var(--danger); }
.gantt-bar.status-non_demarre { background: #d5d0c6; }

/* ── BUG FIX: Form-row layout ─────────────────────────── */
.form-row { display: flex; gap: 12px; }
.form-row > .form-group { flex: 1; }
.form-hint { font-size: 0.73rem; color: var(--text-muted); margin-top: 2px; }
.required { color: var(--danger); }

/* ── BUG FIX: Modal footer ─────────────────────────────── */
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding-top: 16px; border-top: 1px solid var(--border); margin-top: 16px; }

/* ── BUG FIX: Text on dark colors ──────────────────────── */
.sidebar .nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ── BUG FIX: Improved responsive ──────────────────────── */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .form-row { flex-wrap: wrap; }
  .notif-panel { width: 320px; right: 8px; }
}

@media (max-width: 768px) {
  .sidebar { position: fixed; left: -280px; z-index: 999; transition: left 0.25s ease; height: 100vh; }
  .sidebar.open { left: 0; }
  .main-area { margin-left: 0; }
  .mobile-toggle { display: flex !important; }
  .grid-4, .grid-3 { grid-template-columns: 1fr; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 1.5rem; }
  .data-table { font-size: 0.8rem; }
  .data-table th, .data-table td { padding: 8px 10px; }
  .page-header { padding: 12px 16px; }
  .page-header h2 { font-size: 1.2rem; }
  .page-header-actions { width: 100%; }
  .swot-grid { grid-template-columns: 1fr; }
  .gantt-label { width: 120px; font-size: 0.73rem; }
  .form-row { flex-direction: column; gap: 0; }
  .topic-item { padding: 10px 12px; }
  .champ-grid { grid-template-columns: 1fr; }
  .notif-panel { width: calc(100vw - 32px); right: 16px; }
  .modal { width: 95vw; max-width: 95vw; max-height: 90vh; margin: 5vh auto; }
}

@media (max-width: 480px) {
  .main-header { padding: 0 12px; }
  .main-content { padding: 12px; }
  .login-page { flex-direction: column; }
  .login-left, .login-right { width: 100%; min-height: auto; }
  .login-right { padding: 24px; display: none; }
  .login-form { padding: 24px 16px; max-width: 100%; }
  .card { padding: 14px; }
  .btn-lg { padding: 10px 16px; font-size: 0.87rem; }
  .header-breadcrumb { display: none; }
}
