:root {
  --red: #0077c8;
  --red-dark: #005a9e;
  --etp-navy: #003d7a;
  --sidebar: #141414;
  --sidebar-hover: #1f1f1f;
  --bg: #f4f8fb;
  --card: #ffffff;
  --text: #1a2b3c;
  --muted: #5c7a99;
  --border: #d8e6f2;
  --green: #2e7d32;
  --orange: #ef6c00;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(0, 61, 122, 0.08);
}

.dashboard-main { padding-top: 8px; }

/* Bannière projet épidémique actif */
.etp-project-banner {
  margin-bottom: 24px;
}

.etp-project-banner-inner {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px 24px;
  padding: 20px 24px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--banner-color, #c62828) 12%, white), #fff);
  border: 1px solid color-mix(in srgb, var(--banner-color, #c62828) 35%, #d8e6f2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.etp-project-banner-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--banner-color, #c62828);
  margin-bottom: 6px;
}

.etp-project-banner-main h3 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  color: var(--etp-navy);
}

.etp-project-banner-main h3 small {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.etp-project-banner-main p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  max-width: 520px;
}

.etp-project-banner-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  grid-column: 1 / -1;
}

.etp-project-chip,
.etp-project-chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
}

.etp-project-chip-btn {
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.etp-project-chip-btn:hover {
  border-color: var(--chip-color, var(--banner-color, #c62828));
}

.etp-project-chip.active {
  border-color: var(--banner-color, #c62828);
  background: color-mix(in srgb, var(--banner-color, #c62828) 10%, white);
}

.etp-project-chip span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.etp-project-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
}

.dash-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.dash-eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--red);
  margin-bottom: 4px;
}

.dash-header h2 {
  font-size: 26px;
  font-weight: 800;
  color: var(--etp-navy);
  margin: 0;
}

.dash-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  flex: 1 1 320px;
  justify-content: flex-end;
}

.dash-filters .etp-lang-toolbar-slot {
  margin-left: auto;
  order: 99;
}

.dash-filters select,
.dash-filters input[type='date'] {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  background: var(--card);
  min-width: 140px;
  font-family: inherit;
}

.btn-dash {
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: var(--red);
  color: #fff;
  text-decoration: none;
  font-family: inherit;
  transition: background 0.15s, box-shadow 0.15s;
}

.btn-dash:hover { background: var(--red-dark); }

.btn-dash-outline {
  background: #fff;
  color: var(--etp-navy);
  border: 1px solid var(--border);
}

.btn-dash-outline:hover {
  background: #e8f4fc;
  border-color: var(--red);
}

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

.btn-dash-ghost:hover {
  color: #b91c1c;
  background: #fef2f2;
}

.dash-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(216, 230, 242, 0.8);
}

.dash-scroll {
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}

.table-wrap { overflow-x: auto; }

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 100;
}

.brand {
  padding: 20px 18px;
  border-bottom: 1px solid #2a2a2a;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  background: var(--red);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.brand-text h1 {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

.brand-text h1 span { color: var(--red); }

.brand-text p {
  font-size: 9px;
  color: #888;
  margin-top: 4px;
  letter-spacing: 0.3px;
}

.user-card {
  margin: 16px;
  padding: 14px;
  background: var(--sidebar-hover);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--red), #8b0000);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.user-card .name { font-size: 13px; font-weight: 600; }
.user-card .role { font-size: 11px; color: #aaa; }
.user-card .online {
  font-size: 10px;
  color: #4caf50;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.user-card .online::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #4caf50;
  border-radius: 50%;
}

.nav { flex: 1; padding: 8px 12px; overflow-y: auto; }

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  color: #bbb;
  text-decoration: none;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 2px;
  transition: background 0.15s, color 0.15s;
}

.nav a:hover { background: var(--sidebar-hover); color: #fff; }
.nav a.active { background: var(--red); color: #fff; font-weight: 600; }
.nav a .icon { width: 20px; text-align: center; opacity: 0.9; }

/* Main */
.main {
  margin-left: 260px;
  flex: 1;
  padding: 24px 28px 40px;
  min-width: 0;
}

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

.header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.filters select,
.filters input {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  background: var(--card);
  min-width: 140px;
}

.btn-export {
  background: var(--red);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-export:hover { background: var(--red-dark); }

/* KPI */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}

@media (max-width: 1400px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .sidebar { display: none; }
  .main { margin-left: 0; }
}

.kpi-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  border-left: 4px solid var(--red);
  position: relative;
  overflow: hidden;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #e8f4fc, #fff);
  border: 1px solid #cce5f7;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--red);
}

.kpi-icon svg { width: 22px; height: 22px; }

.kpi-body { flex: 1; min-width: 0; }

.kpi-card.suspect { border-top-color: var(--orange); }
.kpi-card.recovered { border-top-color: var(--green); }
.kpi-card.deaths { border-top-color: #424242; }
.kpi-card.zones { border-top-color: #1565c0; }

.kpi-card .label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.kpi-card .value {
  font-size: 28px;
  font-weight: 800;
  margin: 8px 0 4px;
  color: var(--text);
}

.kpi-card .meta {
  font-size: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.kpi-card .trend-up { color: var(--red); font-weight: 600; }
.kpi-card .trend-down { color: var(--green); font-weight: 600; }
.kpi-card .today { color: var(--muted); }

/* Bandeau indicateurs */
.dash-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin-bottom: 18px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--muted);
}

.dash-meta strong {
  color: var(--etp-navy);
  font-weight: 700;
}

.dash-meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #e8f4fc;
  border-radius: 999px;
  color: var(--etp-navy);
  font-weight: 600;
}

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

.panel-head-row h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--etp-navy);
}

.chart-hint {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 4px 8px;
  background: #f4f8fb;
  border-radius: 6px;
}

.chart-wrap--tall { height: 300px; }
.chart-wrap--compact { height: 200px; }

.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 8px;
  text-align: center;
  padding: 16px;
}

.chart-empty[hidden] { display: none !important; }

.chart-empty--donut { border-radius: 50%; max-width: 220px; margin: 0 auto; }

.rates-legend {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
}

.rates-legend span { display: inline-flex; align-items: center; gap: 6px; }
.rates-legend .dot { width: 10px; height: 10px; border-radius: 3px; }

.loading-pulse .kpi-card,
.loading-pulse .dash-card {
  opacity: 0.65;
  pointer-events: none;
}

.map-fallback {
  flex: 1;
  min-height: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  background: linear-gradient(160deg, #0d2137 0%, #1a3a5c 100%);
  color: #b8d4ea;
  text-align: center;
  font-size: 13px;
}

.map-fallback strong { color: #fff; font-size: 15px; }

/* Grid layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 320px;
  grid-template-rows: auto auto;
  gap: 18px;
}

.dashboard-grid--pro {
  grid-template-columns: minmax(280px, 1.15fr) 1fr 1fr minmax(260px, 280px);
  grid-template-rows: auto auto auto auto;
}

.dashboard-grid--pro .map-panel {
  grid-column: 1;
  grid-row: 1 / span 2;
  min-height: 480px;
}

.dashboard-grid--pro .chart-panel--evolution {
  grid-column: 2 / span 2;
  grid-row: 1;
}

.dashboard-grid--pro .chart-panel--country {
  grid-column: 2;
  grid-row: 2;
}

.dashboard-grid--pro .chart-panel--stacked {
  grid-column: 3;
  grid-row: 2;
}

.dashboard-grid--pro .side-panel {
  grid-column: 4;
  grid-row: 1 / span 4;
}

.dashboard-grid--pro .table-panel {
  grid-column: 1 / span 2;
  grid-row: 3;
}

.dashboard-grid--pro .donut-panel {
  grid-column: 3;
  grid-row: 3;
}

.dashboard-grid--pro .chart-panel--rates {
  grid-column: 1;
  grid-row: 4;
}

.dashboard-grid--pro .chart-panel--risk {
  grid-column: 2;
  grid-row: 4;
}

.dashboard-grid--pro .chart-panel--province {
  grid-column: 3;
  grid-row: 4;
}

.dashboard-grid--pro .chart-panel--province[hidden] {
  display: none;
}

.map-panel {
  grid-row: span 2;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 420px;
}

.map-panel .panel-head {
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.map-panel .panel-head h3 { font-size: 15px; font-weight: 600; }

.btn-map-expand {
  background: #f5f5f5;
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
}

.btn-map-expand:hover { background: var(--red); color: #fff; border-color: var(--red); }

#dashboardMap { flex: 1; min-height: 360px; background: #1a1a1a; }

.chart-panel,
.table-panel,
.donut-panel,
.side-panel {
  padding: 18px;
}

.chart-panel h3,
.table-panel h3,
.donut-panel h3,
.side-panel h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
}

.chart-wrap {
  position: relative;
  height: 280px;
  min-height: 180px;
}
.donut-wrap { height: 220px; max-width: 280px; margin: 0 auto; }

.side-panel { grid-row: span 2; }

.alert-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.alert-item:last-child { border-bottom: none; }

.alert-item .title { font-weight: 600; color: var(--text); margin-bottom: 4px; }
.alert-item .time { color: var(--muted); font-size: 11px; }
.alert-item.critical .title { color: var(--red); }

.activity-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

.activity-item strong { color: var(--text); display: block; margin-bottom: 2px; }

.dash-empty-msg {
  font-size: 12px;
  color: var(--muted);
  padding: 12px 0;
  font-style: italic;
}

.kpi-card.screenings { border-left-color: #7b1fa2; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.data-table th {
  text-align: left;
  padding: 10px 8px;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
}

.data-table td { padding: 12px 8px; border-bottom: 1px solid #f0f0f0; }

.progress-bar {
  height: 6px;
  background: #eee;
  border-radius: 3px;
  overflow: hidden;
  min-width: 80px;
}

.progress-bar span {
  display: block;
  height: 100%;
  background: var(--green);
  border-radius: 3px;
}

.map-legend {
  display: flex;
  gap: 12px;
  padding: 10px 18px;
  font-size: 11px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
}

.map-legend span { display: flex; align-items: center; gap: 4px; }
.map-legend .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  background: var(--card);
  padding: 36px;
  border-radius: var(--radius);
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.login-brand img {
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(0, 119, 200, 0.25);
  flex-shrink: 0;
}

.login-brand h2 {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 800;
  color: var(--etp-accent, #003d7a);
  letter-spacing: 0.02em;
}

.login-brand h2 span { color: var(--red); }

.login-brand p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.login-box h2 { color: var(--red); margin-bottom: 8px; }
.login-box > p { color: var(--muted); font-size: 13px; margin-bottom: 20px; }

.login-box input {
  width: 100%;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
}

.login-box button,
.login-submit {
  width: 100%;
  padding: 14px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.login-submit svg {
  width: 18px;
  height: 18px;
}

.login-box button:hover { background: var(--red-dark); }

.login-error { color: var(--red); font-size: 12px; margin-top: 8px; display: none; }

.loading-pulse { opacity: 0.5; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 0.8; } }

.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin: 16px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ——— Tableau de bord responsive ——— */
@media (max-width: 1280px) {
  .dashboard-grid,
  .dashboard-grid--pro {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto;
  }

  .dashboard-grid--pro .map-panel,
  .dashboard-grid--pro .chart-panel--evolution,
  .dashboard-grid--pro .chart-panel--country,
  .dashboard-grid--pro .chart-panel--stacked,
  .dashboard-grid--pro .side-panel,
  .dashboard-grid--pro .table-panel,
  .dashboard-grid--pro .donut-panel,
  .dashboard-grid--pro .chart-panel--rates,
  .dashboard-grid--pro .chart-panel--risk,
  .dashboard-grid--pro .chart-panel--province {
    grid-column: auto;
    grid-row: auto;
  }

  .map-panel {
    grid-column: 1 / -1;
    grid-row: auto;
    min-height: 380px;
  }

  .side-panel {
    grid-row: auto;
  }
}

@media (max-width: 900px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .map-panel,
  .side-panel {
    grid-column: auto;
    grid-row: auto;
  }

  .map-panel {
    min-height: 300px;
  }

  #dashboardMap {
    min-height: 260px;
  }

  .dash-header {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    margin-bottom: 20px;
    padding-bottom: 16px;
  }

  .dash-header h2 {
    font-size: 22px;
  }

  .dash-filters {
    width: 100%;
    gap: 8px;
  }

  .dash-filters select,
  .dash-filters input[type='date'] {
    flex: 1 1 100%;
    min-width: 0;
    width: 100%;
  }

  .btn-dash {
    flex: 1 1 calc(50% - 4px);
    text-align: center;
    justify-content: center;
  }

  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .chart-wrap {
    height: 240px;
  }

  .donut-wrap {
    max-width: 100%;
    height: 200px;
  }

  .panel-head {
    flex-wrap: wrap;
    gap: 8px;
  }
}

@media (max-width: 600px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .kpi-card .value {
    font-size: 24px;
  }

  .btn-dash {
    flex: 1 1 100%;
  }

  .dash-eyebrow {
    font-size: 10px;
  }

  .data-table {
    font-size: 11px;
  }

  .data-table th,
  .data-table td {
    padding: 10px 6px;
  }
}
