body { font-family: system-ui, sans-serif; margin: 0; background: #f5f5f5; color: #222; }

/* ── Navigation ── */
nav {
  background: #1a1a2e;
  display: flex;
  align-items: center;
  padding: 0 2rem;
  position: relative;
  z-index: 200;
}
.nav-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  padding: .75rem 0;
  margin-right: 2rem;
}
.nav-logo {
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: .08em;
}
.nav-burger {
  display: none;
  background: none;
  border: none;
  color: #e0e0e0;
  font-size: 1.4rem;
  cursor: pointer;
  padding: .25rem .5rem;
  line-height: 1;
}
.nav-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: stretch;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #e0e0e0;
  text-decoration: none;
  font-weight: 500;
  font-size: .92rem;
  padding: 1rem 1.1rem;
  white-space: nowrap;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, color .15s;
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav-arrow { font-size: .6rem; opacity: .7; }

/* Dropdown */
.nav-dropdown { position: relative; }
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: #16213e;
  list-style: none;
  margin: 0;
  padding: 4px 0;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 6px 16px rgba(0,0,0,.35);
  min-width: 180px;
  z-index: 300;
}
.nav-dropdown.open .nav-dropdown-menu { display: block; }
.nav-dropdown-menu li a {
  display: block;
  color: #ccc;
  text-decoration: none;
  padding: .55rem 1.1rem;
  font-size: .88rem;
  white-space: nowrap;
}
.nav-dropdown-menu li a:hover { background: rgba(255,255,255,.1); color: #fff; }

main { padding: 2rem; max-width: 1200px; margin: 0 auto; }
h1 { font-size: 1.8rem; margin-bottom: 1rem; }
h2 { font-size: 1.2rem; margin-top: 2rem; border-bottom: 1px solid #ddd; padding-bottom: .5rem; }

/* KPI grid — display: grid pour que grid-template-columns fonctionne */
.kpi-grid { display: grid; gap: 1rem; margin-bottom: 1.5rem; }
.kpi-grid-5 { grid-template-columns: repeat(5, 1fr); }
.kpi-grid-4 { grid-template-columns: repeat(4, 1fr); }
.kpi-grid-3 { grid-template-columns: repeat(3, 1fr); }
.kpi-grid-2 { grid-template-columns: repeat(2, 1fr); }
.kpi { background: #fff; border-radius: 8px; padding: 1rem 1.5rem; box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.kpi span { display: block; font-size: .8rem; color: #666; text-transform: uppercase; letter-spacing: .05em; }
.kpi strong { font-size: 1.8rem; font-weight: 700; }
.kpi em { display: block; font-size: 11px; font-style: normal; }
.up   { color: #27a06a; }
.down { color: #e53e3e; }
.neutral { color: #888; }

/* Tables — scroll horizontal sur mobile */
.card-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: max-content; }
th, td { padding: .6rem 1rem; text-align: left; border-bottom: 1px solid #eee; white-space: nowrap; }
th { background: #f0f0f0; font-weight: 600; font-size: .85rem; }
button { background: #1a1a2e; color: #fff; border: none; padding: .6rem 1.2rem; border-radius: 6px; cursor: pointer; font-size: .9rem; margin-bottom: 1rem; }
button:hover { background: #16213e; }

/* Period selector */
.period-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 10px;
  background: #f8f8f8;
  border-radius: 6px;
}
.period-label { font-weight: 600; font-size: 12px; color: #555; }
.btn {
  background: #eee;
  border: none;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  color: #333;
}
.btn-active { background: #1a1a2e; color: #fff; }

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e0e0e0;
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab {
  padding: 8px 18px;
  font-size: 13px;
  color: #888;
  cursor: pointer;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
}
.tab-active {
  color: #1a1a2e;
  font-weight: 600;
  border-bottom-color: #1a1a2e;
}

/* Bar chart */
.chart-card {
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
  margin-bottom: 16px;
  overflow: visible;
}
.chart-title {
  font-size: 11px;
  font-weight: 600;
  color: #555;
  margin-bottom: 8px;
  letter-spacing: .05em;
}
.bar-chart {
  display: flex;
  gap: 5px;
  height: 65px; /* 50px zone barres + ~15px labels */
}
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; }
.bar {
  width: 100%;
  background: #cbd5e0;
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  cursor: pointer;
  margin-top: auto; /* pousse la barre vers le bas, au-dessus du label */
}
.bar-current { background: #1a1a2e; }
.bar-label { font-size: 9px; color: #aaa; margin-top: 3px; text-align: center; }

/* Horizontal bar (CA by type) */
.hbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.hbar-label { width: 120px; font-size: 12px; color: #555; }
.hbar-track { flex: 1; background: #f0f0f0; border-radius: 3px; height: 14px; }
.hbar-fill { background: #1a1a2e; border-radius: 3px; height: 14px; }
.hbar-value { width: 90px; text-align: right; font-size: 12px; font-weight: 600; }

/* Generic card */
.card {
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.card-title {
  font-size: 11px;
  font-weight: 600;
  color: #555;
  margin-bottom: 8px;
  letter-spacing: .05em;
}

/* Site header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.site-header h1 { margin: 0; }

/* Funnel */
.funnel2 { display: flex; flex-direction: column; gap: 0; padding: 0.5rem 0; }
.f-step { display: flex; align-items: baseline; gap: 0.75rem; padding: 0.6rem 0; }
.f-step-count { font-size: 2rem; font-weight: 700; color: #1a1a2e; min-width: 60px; text-align: right; }
.f-step-label { font-size: 0.85rem; color: #555; text-transform: uppercase; letter-spacing: .05em; }
.f-step-final .f-step-count { color: #10b981; }
.f-transition { display: grid; grid-template-columns: 52px 1fr 80px; align-items: center; gap: 0.75rem; padding: 0.3rem 0 0.3rem 60px; border-left: 3px solid #e5e7eb; margin-left: 29px; }
.f-pct { font-size: 1.1rem; font-weight: 700; color: #3b82f6; text-align: right; }
.f-bar-wrap { background: #e5e7eb; border-radius: 4px; height: 10px; overflow: hidden; }
.f-bar { height: 100%; border-radius: 4px; transition: width 0.4s; }
.f-bar-1 { background: #3b82f6; }
.f-bar-2 { background: #6366f1; }
.f-bar-3 { background: #10b981; }
.f-ratio { font-size: 0.8rem; color: #888; white-space: nowrap; }
select.btn { cursor: pointer; appearance: none; padding-right: 1.5rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23555'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.5rem center; }

/* Tooltip JS — injecté par script */
#bar-tooltip {
  position: fixed;
  background: #1a1a2e;
  color: #fff;
  padding: 3px 9px;
  border-radius: 4px;
  font-size: 11px;
  font-family: system-ui, sans-serif;
  pointer-events: none;
  z-index: 9999;
  display: none;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}

.chart-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── Responsive mobile ───────────────────────────────────── */
@media (max-width: 768px) {
  /* Nav mobile */
  nav { flex-direction: column; align-items: stretch; padding: 0 1rem; }
  .nav-brand { width: 100%; margin-right: 0; }
  .nav-burger { display: block; }
  .nav-links {
    display: none;
    flex-direction: column;
    align-items: stretch;
    border-top: 1px solid rgba(255,255,255,.1);
    padding-bottom: .5rem;
  }
  nav.nav-open .nav-links { display: flex; }
  .nav-link { padding: .75rem .5rem; }
  /* Dropdown mobile : positionné en flux normal, pas en absolu */
  .nav-dropdown-menu {
    position: static;
    box-shadow: none;
    border-radius: 0;
    background: rgba(0,0,0,.25);
    padding: 0 0 0 1rem;
    min-width: 0;
  }

  main { padding: 1rem; }
  h1 { font-size: 1.3rem; }

  .chart-grid-2 { grid-template-columns: 1fr; }
  .kpi-grid-5 { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .kpi { padding: .75rem 1rem; }
  .kpi strong { font-size: 1.4rem; }

  .site-header { flex-direction: column; align-items: flex-start; }

  .hbar-label { width: 80px; font-size: 11px; }
  .hbar-value { width: 70px; font-size: 11px; }
}

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