:root {
  --bg: #0B141E;
  --surface: #152232;
  --surface-alt: #1D2E42;
  --border: #2A3C52;
  --text: #F8FAFC;
  --text-secondary: #CBD5E1;
  --text-muted: #94A3B8;
  --accent: #3B82F6;
  --accent-strong: #2563EB;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --heading: #60A5FA;
  --success: #10B981;
  --success-bg: rgba(16, 185, 129, 0.14);
  --danger: #EF4444;
  --danger-bg: rgba(239, 68, 68, 0.14);
  --warning: #F59E0B;
  --warning-bg: rgba(245, 158, 11, 0.14);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(2, 6, 23, 0.35);
}

html[data-theme="light"] {
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-alt: #F1F5F9;
  --border: #E2E8F0;
  --text: #0F172A;
  --text-secondary: #334155;
  --text-muted: #64748B;
  --accent: #2563EB;
  --accent-strong: #1D4ED8;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --heading: #0B2545;
  --success: #059669;
  --success-bg: rgba(5, 150, 105, 0.1);
  --danger: #DC2626;
  --danger-bg: rgba(220, 38, 38, 0.1);
  --warning: #D97706;
  --warning-bg: rgba(217, 119, 6, 0.12);
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

.container {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand img { width: 30px; height: 30px; display: block; }

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
}
.nav-pill:hover { background: var(--surface-alt); text-decoration: none; color: var(--text); }
.nav-pill.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft); }

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); }

.lang-select {
  min-height: 44px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

/* Main Workspace Layout */
.page-main { padding: 24px 0 88px; min-height: calc(100vh - 130px); }

.shell-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 20px;
  align-items: start;
}

.sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  position: sticky;
  top: 76px;
}

.sidebar-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 6px 10px 8px;
  font-weight: 600;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 4px;
}
.sidebar-link:hover { background: var(--surface-alt); color: var(--text); text-decoration: none; }
.sidebar-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* Cards & Grids */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card-compact { padding: 16px; }

.card-title {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 700;
  color: var(--heading);
}

.card-subtitle {
  margin: 0 0 16px;
  font-size: 13.5px;
  color: var(--text-secondary);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.kpi-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.kpi-value { font-size: 24px; font-weight: 700; color: var(--heading); }

/* Auth centered layout */
.auth-wrap {
  max-width: 440px;
  margin: 24px auto;
}
.auth-wide { max-width: 520px; margin: 20px auto; }

/* Forms */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.input, select.input, textarea.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
textarea.input { min-height: 88px; resize: vertical; }
.input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.field-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}
.check-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent-strong); color: #FFFFFF; }
.btn-primary:hover { background: var(--accent); }
.btn-secondary { background: var(--surface-alt); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--accent); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: rgba(239, 68, 68, 0.35); }
.btn-danger:hover { background: var(--danger); color: #FFFFFF; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 12.5px; }

/* Tabs */
.tabs {
  display: flex;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 16px;
}
.tab-btn {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.tab-btn.active { background: var(--accent-strong); color: #FFFFFF; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Badges & Alerts */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-info { background: var(--accent-soft); color: var(--accent); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: rgba(239, 68, 68, 0.3); }
.alert-success { background: var(--success-bg); color: var(--success); border-color: rgba(16, 185, 129, 0.3); }
.alert-info { background: var(--accent-soft); color: var(--text); border-color: rgba(59, 130, 246, 0.3); }

/* Tables & Lists */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data-table th, table.data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data-table th {
  color: var(--text-muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.row-item:last-child { border-bottom: 0; }

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  word-break: break-all;
}

.empty-state {
  text-align: center;
  padding: 28px 16px;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

/* Hero Landing */
.hero {
  background: linear-gradient(135deg, #0B2545 0%, #152232 60%, #1D2E42 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  color: #F8FAFC;
  margin-bottom: 20px;
}
.hero h1 { margin: 0 0 10px; font-size: 28px; color: #FFFFFF; }
.hero p { margin: 0 0 20px; max-width: 680px; color: #CBD5E1; font-size: 15px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 18px 0;
  font-size: 12.5px;
  color: var(--text-muted);
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Mobile Bottom Nav (masque en desktop >= 1024px, QUALITE #14) */
.mobile-bottom-nav { display: none !important; }

/* Toast & Confirm Modal */
.eliam-toast-stack {
  position: fixed;
  right: 16px;
  bottom: 20px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}
.eliam-toast {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  font-size: 13.5px;
}
.eliam-toast.success { border-left-color: var(--success); }
.eliam-toast.error { border-left-color: var(--danger); }

.eliam-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(2, 6, 23, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.eliam-modal-backdrop.open { display: flex; }
.eliam-modal {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.eliam-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.inline-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hidden { display: none !important; }

@media (max-width: 1023.98px) {
  .topbar-nav { display: none; }
  .shell-grid { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .hero { padding: 22px 18px; }
  .hero h1 { font-size: 22px; }
  .site-footer { padding-bottom: 84px; }
  .eliam-toast-stack { bottom: 76px; left: 16px; right: 16px; max-width: none; }

  .mobile-bottom-nav {
    display: flex !important;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    background: var(--surface);
    border-top: 1px solid var(--border);
    min-height: 60px;
    padding: 4px 8px;
    justify-content: space-around;
    align-items: center;
  }
  .mobile-bottom-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 56px;
    padding: 4px 6px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    gap: 2px;
  }
  .mobile-bottom-link.active { color: var(--accent); font-weight: 600; }
}

