/* ════════════════════════════════════════════════════════
   Sentinel — Design System v4 (Modern Light)
   ════════════════════════════════════════════════════════ */

/* ── Palette ────────────────────────────────────────────── */
:root {
  --bg: #fafbfc;
  --bg-card: #ffffff;
  --bg-hover: #f4f5f7;
  --bg-elevated: #ffffff;
  --bg-sidebar: #fbfbfc;
  --border: #e5e7eb;
  --border-subtle: #f0f1f3;
  --text: #111827;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37,99,235,0.06);
  --green: #059669;
  --green-soft: rgba(5,150,105,0.06);
  --red: #dc2626;
  --red-soft: rgba(220,38,38,0.06);
  --orange: #d97706;
  --orange-soft: rgba(217,119,6,0.06);
  --purple: #7c3aed;
  --purple-soft: rgba(124,58,237,0.06);
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --transition: 0.15s cubic-bezier(0.4,0,0.2,1);
}

[data-theme="dark"] {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-hover: #22262f;
  --bg-elevated: #1e2129;
  --bg-sidebar: #14161e;
  --border: #2a2e3a;
  --border-subtle: #1f222c;
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --text-faint: #6b7280;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59,130,246,0.1);
  --green: #34d399;
  --green-soft: rgba(52,211,153,0.1);
  --red: #f87171;
  --red-soft: rgba(248,113,113,0.1);
  --orange: #fbbf24;
  --orange-soft: rgba(251,191,36,0.1);
  --purple: #a78bfa;
  --purple-soft: rgba(167,139,250,0.1);
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.2);
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.2);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.4);
}

/* ── Reset & Base ───────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ─────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
  width: 232px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 20px 0 12px;
  padding-top: max(20px, env(safe-area-inset-top));
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  position: fixed;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 300;
}

.sidebar-logo {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 12px;
}

.sidebar-logo h1 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-logo h1::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  background: var(--accent);
}
.sidebar-logo small {
  color: var(--text-faint);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-top: 2px;
  display: block;
  padding-left: 28px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  margin: 1px 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  background: none;
  width: calc(100% - 16px);
  text-align: left;
  font-size: 0.84rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.main {
  flex: 1;
  margin-left: 232px;
  padding: 32px 48px;
  max-width: 1060px;
  margin-right: auto;
  overflow-x: hidden;
  min-width: 0;
  word-break: break-word;
}

/* ── Page headers ───────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 12px;
}

.page-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text);
}

/* ── Stats cards ────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.stat-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--border);
}

.stat-card .label {
  color: var(--text-faint);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.stat-card .value {
  font-size: 1.75rem;
  font-weight: 700;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
  color: var(--text);
}
.stat-card .value.alert { color: var(--red); }
.stat-card .value.accent { color: var(--accent); }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
  transition: box-shadow var(--transition);
  overflow-x: auto;
  min-width: 0;
}
.card:hover {
  box-shadow: var(--shadow-xs);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.card-header h2 {
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: -0.2px;
}

/* ── Section titles ─────────────────────────────────────── */
.section-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-faint);
  margin-bottom: 12px;
}

/* ── Profile cards (dashboard) ─────────────────────────── */
.profile-dash-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.profile-dash-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}
.profile-dash-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 0 3px 3px 0;
}

.profile-dash-card .profile-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.profile-dash-card .profile-meta {
  display: flex;
  gap: 16px;
  font-size: 0.76rem;
  color: var(--text-muted);
}
.profile-dash-card .profile-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Analysis items ─────────────────────────────────────── */
.analysis-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--transition);
}
.analysis-item:last-child { border-bottom: none; }
.analysis-item:hover {
  background: var(--bg-hover);
  margin: 0 -16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
}

.analysis-item .title {
  font-weight: 600;
  font-size: 0.86rem;
  margin-bottom: 4px;
  line-height: 1.4;
  color: var(--text);
}
.analysis-item .meta {
  color: var(--text-muted);
  font-size: 0.76rem;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.analysis-item .summary {
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.analysis-item-compact {
  padding: 10px 0;
}
.analysis-item-compact .title {
  font-size: 0.84rem;
  margin-bottom: 0;
}

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-alerte {
  background: var(--red-soft);
  color: var(--red);
}
.badge-rupture {
  background: var(--orange-soft);
  color: var(--orange);
}
.badge-inflexion {
  background: var(--purple-soft);
  color: var(--purple);
}
.badge-tendance {
  background: var(--accent-soft);
  color: var(--accent);
}
.badge-routine {
  background: var(--bg-hover);
  color: var(--text-faint);
}

.badge-category {
  display: inline-block;
  background: var(--bg-hover);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 500;
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-faint);
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: 0 1px 2px rgba(37,99,235,0.2);
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 6px rgba(37,99,235,0.25);
}
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }
.btn-danger { color: var(--red); border-color: var(--red-soft); }
.btn-danger:hover { background: var(--red-soft); }
.btn-secondary { background: var(--bg-hover); border-color: var(--border); color: var(--text-muted); }

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
}
.action-btn:hover { background: var(--bg-hover); color: var(--text); }

/* ── Forms ──────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  margin-bottom: 5px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
}

input, textarea, select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.85rem;
  font-family: var(--font);
  transition: border-color var(--transition), box-shadow var(--transition);
}

/* Checkboxes et radios : ne pas hériter des styles de texte/select */
input[type="checkbox"], input[type="radio"] {
  width: auto;
  padding: 0;
  background: initial;
  border: initial;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input::placeholder, textarea::placeholder {
  color: var(--text-faint);
}

textarea { resize: vertical; min-height: 80px; }

.tag-input {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 40px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 500;
}

.tag .remove { cursor: pointer; font-weight: bold; opacity: 0.6; }
.tag .remove:hover { opacity: 1; }

span.tag {
  display: inline-block;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── Tables ─────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
table thead tr th {
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-faint);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
table tbody tr { transition: background 0.1s; }
table tbody tr:hover { background: var(--bg-hover); }
table td { padding: 10px 12px; font-size: 0.85rem; }

/* Signal chart */
.signal-chart { overflow: hidden; }
.signal-chart svg text { font-family: var(--font); }

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 720px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { transform: translateY(8px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal h2 {
  margin-bottom: 16px;
  font-size: 1.1rem;
  font-weight: 700;
}

/* ── Digest content ─────────────────────────────────────── */
.digest-content { line-height: 1.8; font-size: 0.9rem; }
.digest-content h1 { font-size: 1.15rem; margin: 24px 0 10px; color: var(--accent); font-weight: 700; }
.digest-content h2 { font-size: 1rem; margin: 20px 0 10px; color: var(--text); border-bottom: 1px solid var(--border-subtle); padding-bottom: 6px; }
.digest-content h3 { font-size: 0.92rem; margin: 16px 0 8px; color: var(--text); font-weight: 600; }
.digest-content ul { padding-left: 20px; margin: 8px 0; }
.digest-content li { margin: 4px 0; }
.digest-content p { margin: 8px 0; }
.digest-content table { width: 100%; border-collapse: collapse; font-size: 0.82rem; margin: 16px 0; }
.digest-content th { background: var(--bg-hover); font-weight: 600; text-align: left; padding: 8px 10px; border: 1px solid var(--border); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.3px; }
.digest-content td { padding: 6px 10px; border: 1px solid var(--border); }
.digest-content blockquote { border-left: 3px solid var(--accent); margin: 12px 0; padding: 8px 16px; color: var(--text-muted); background: var(--bg-hover); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.digest-content hr { border: none; border-top: 1px solid var(--border-subtle); margin: 20px 0; }

/* ── Toolbar ────────────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar select, .toolbar input { width: auto; min-width: 140px; }

/* ── Feedback stars ─────────────────────────────────────── */
.stars { display: flex; gap: 4px; }
.star { cursor: pointer; font-size: 1.2rem; color: var(--border); transition: color var(--transition); }
.star.active, .star:hover { color: var(--orange); }

/* ── Mobile header ──────────────────────────────────────── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: calc(52px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  align-items: center;
  gap: 12px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  z-index: 200;
}

.mobile-title { font-size: 1rem; font-weight: 700; color: var(--text); }

.hamburger {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 44px;
  height: 44px;
  padding: 14px 12px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.hamburger:hover { background: var(--bg-hover); }

.hamburger span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.25s;
  transform-origin: center;
}
.hamburger.active span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 299;
}
.sidebar-overlay.active { display: block; }

/* ── Responsive — Tablette (≤1024px) ───────────────────── */
@media (max-width: 1024px) {
  .mobile-header { display: flex; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
    background: var(--bg-card);
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; padding: 24px; padding-top: calc(52px + env(safe-area-inset-top) + 16px); max-width: 100%; width: 100%; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .profiles-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .digest-layout { grid-template-columns: 1fr !important; }
  .digest-sidebar { position: static !important; }
  .prof-grid-2 { grid-template-columns: 1fr !important; }
  .prof-grid-3 { grid-template-columns: 1fr 1fr !important; }
  .dash-grid-2 { grid-template-columns: 1fr !important; }
  .page-header { flex-wrap: wrap; }
  .card { padding: 16px; }
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ── Responsive — Mobile (≤768px) ──────────────────────── */
@media (max-width: 768px) {
  .main { padding: 12px; padding-top: calc(52px + env(safe-area-inset-top) + 12px); padding-bottom: max(16px, env(safe-area-inset-bottom)); max-width: 100vw; }
  .card { padding: 12px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .nav-item { min-height: 44px; font-size: 0.9rem; padding: 10px 16px; }
  .modal { width: 100%; max-width: 100%; border-radius: var(--radius-lg) var(--radius-lg) 0 0; position: fixed; bottom: 0; left: 0; max-height: 85vh; }
  #toast-container { bottom: max(16px, env(safe-area-inset-bottom)); right: 16px; left: 16px; }
  .toast { min-width: 0; max-width: 100%; font-size: 0.88rem; }
  .toolbar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .toolbar select, .toolbar input { min-width: 120px; }
  input, textarea, select { font-size: 16px; }
  .stat-card .value { font-size: 1.4rem; }
  .stat-card { padding: 12px; }
  .profiles-grid { grid-template-columns: 1fr; }
  .analysis-item { padding: 12px 0; }
  .analysis-item .title { font-size: 0.9rem; }
  .prof-grid-3 { grid-template-columns: 1fr !important; }
  .btn { min-height: 44px; font-size: 0.85rem; }
  .action-btn { min-height: 44px; }
  .settings-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .settings-row input[type="email"],
  .settings-row select { width: 100% !important; }
  .page-header h1 { font-size: 1.2rem; }
}

/* ── Responsive — Petit mobile (≤480px) ────────────────── */
@media (max-width: 480px) {
  .main { padding: 12px; padding-top: calc(52px + env(safe-area-inset-top) + 8px); }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .stat-card .label { font-size: 0.7rem; }
  .stat-card .value { font-size: 1.2rem; }
  h1 { font-size: 1.1rem; }
}

/* ── Spinner ────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; padding: 40px; color: var(--text-muted); }

/* ── Profile cards grid ─────────────────────────────────── */
.profiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.profile-card {
  padding: 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.profile-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

/* ── Toasts ─────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  min-width: 240px;
  max-width: 400px;
  font-size: 0.85rem;
  animation: toastIn 0.25s ease;
  pointer-events: all;
  box-shadow: var(--shadow-lg);
}

.toast-success { border-left: 3px solid var(--green); }
.toast-error { border-left: 3px solid var(--red); }
.toast-info { border-left: 3px solid var(--accent); }
.toast-warn { border-left: 3px solid var(--orange); }

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

/* ── Pagination ─────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  color: var(--text-muted);
  font-size: 0.82rem;
}
.pagination .pages { display: flex; gap: 4px; }
.pagination .pages button { min-width: 32px; text-align: center; }

/* ── Nav separator ──────────────────────────────────────── */
.nav-separator {
  margin: 8px 16px;
  border-top: 1px solid var(--border-subtle);
}

/* ── Help sections ──────────────────────────────────────── */
.help-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 12px;
}
.help-section h2 {
  font-size: 0.88rem;
  color: var(--text);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
  font-weight: 600;
}

kbd {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

/* ── Sidebar user ───────────────────────────────────────── */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  border: 1px solid transparent;
}
.sidebar-user:hover { background: var(--bg-hover); }

.sidebar-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.72rem;
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 0.82rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 0.68rem; color: var(--text-faint); text-transform: capitalize; }
.sidebar-user-gear { color: var(--text-faint); font-size: 0.82rem; flex-shrink: 0; }

/* ── Settings ───────────────────────────────────────────── */
.settings-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 12px;
}
.settings-section h2 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-faint);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
  font-weight: 600;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.settings-row:last-child { border-bottom: none; }
.settings-row-label { font-size: 0.88rem; color: var(--text); }
.settings-row-desc { font-size: 0.75rem; color: var(--text-faint); margin-top: 2px; }
.settings-toggle { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.settings-toggle input { opacity: 0; width: 0; height: 0; }
.settings-toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: var(--border);
  cursor: pointer;
  transition: background 0.2s;
}
.settings-toggle input:checked + .settings-toggle-track { background: var(--accent); }
.settings-toggle-track::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.settings-toggle input:checked + .settings-toggle-track::after { transform: translateX(20px); }

/* ── Tooltips ───────────────────────────────────────────── */
.global-tip {
  position: fixed;
  z-index: 99999;
  background: var(--text);
  color: var(--bg);
  font-size: 0.72rem;
  line-height: 1.5;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  max-width: 260px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  box-shadow: var(--shadow-md);
  white-space: normal;
}
.global-tip.visible { opacity: 1; }

[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.5;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  white-space: normal;
  width: max-content;
  max-width: 240px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 9999;
  box-shadow: var(--shadow-md);
  text-align: left;
}
[data-tip]::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--text);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 9999;
}
[data-tip]:hover::after, [data-tip]:hover::before { opacity: 1; }
[data-tip-left]::after { left: auto; right: 0; transform: none; }
[data-tip-left]::before { left: auto; right: 12px; transform: none; }

/* ── Accessibility ──────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #fff;
  z-index: 10000;
  font-size: 0.9rem;
  text-decoration: none;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus {
  top: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:focus-visible, a:focus-visible, .nav-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ── Empty states ───────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.4; }
.empty-state-text { font-size: 0.88rem; margin-bottom: 16px; line-height: 1.6; }
.empty-state p { font-size: 1.05rem; margin-bottom: 0.5rem; }
.empty-state small { font-size: 0.82rem; opacity: 0.7; }

/* ── Pulse animation for generating ────────────────────── */
@keyframes pulse-glow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.pulse-generating { animation: pulse-glow 1.5s ease-in-out infinite; }

/* ── Status dot ────────────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 5px;
  flex-shrink: 0;
}
.status-dot.active { background: var(--green); box-shadow: 0 0 4px var(--green); }
.status-dot.inactive { background: var(--red); }

/* ── Count badges ──────────────────────────────────────── */
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  font-size: 0.68rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.count-badge.alert { background: var(--red-soft); color: var(--red); }
.count-badge.info { background: var(--accent-soft); color: var(--accent); }
.count-badge.muted { background: var(--bg-hover); color: var(--text-faint); }

/* ── Loading placeholder (vues principales) ─────────────── */
.loading-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
  gap: 1rem;
}
.loading-placeholder .spinner {
  width: 36px;
  height: 36px;
  border-width: 3px;
}

/* ── Icônes SVG Lucide inline ───────────────────────────── */
.btn svg, button svg, .nav-item svg { vertical-align: middle; flex-shrink: 0; }
.sidebar-user-gear svg { width: 14px; height: 14px; opacity: 0.6; }

/* ── Onboarding wizard ──────────────────────────────────── */
.onboarding-wizard-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 1100; padding: 16px;
}
.onboarding-wizard {
  background: var(--bg-card); border-radius: 16px;
  padding: 36px 32px; max-width: 520px; width: 100%;
  box-shadow: 0 24px 80px rgba(0,0,0,0.18);
}
.onboarding-wizard h2 { font-size: 1.25rem; margin: 0 0 12px; }
.onboarding-wizard .wizard-steps {
  display: flex; gap: 6px; margin-bottom: 28px;
}
.onboarding-wizard .wizard-step-dot {
  flex: 1; height: 4px; border-radius: 2px;
  background: var(--border); transition: background 0.25s;
}
.onboarding-wizard .wizard-step-dot.active { background: var(--accent); }
.onboarding-wizard textarea {
  width: 100%; min-height: 110px; resize: vertical;
  padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 0.93rem;
  background: var(--bg-input, var(--bg)); color: var(--text);
  box-sizing: border-box;
}
.onboarding-wizard .wizard-actions {
  display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end;
}
.onboarding-empty-cta {
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; padding: 48px 24px; text-align: center;
}
.onboarding-empty-cta .cta-title {
  font-size: 1.1rem; font-weight: 700; color: var(--text);
}
.onboarding-empty-cta .cta-desc {
  font-size: 0.93rem; color: var(--text-muted); max-width: 360px;
}

/* ── Footer légal ──────────────────────────────────────── */
.app-footer {
  position: fixed; bottom: 0.5rem; right: 1rem;
  font-size: 0.75rem; color: var(--text-faint); opacity: 0.7;
  z-index: 100;
}
.app-footer a { color: inherit; text-decoration: none; margin: 0 0.25rem; }
.app-footer a:hover { text-decoration: underline; color: var(--text-muted); }
@media (max-width: 768px) { .app-footer { display: none; } }
