:root {
  --navy: #20267e;
  --blue: #3a41b8;
  --sky: #eef0fb;
  --ink: #1f2253;
  --muted: #4a4d7a;
  --line: #e1e3f3;
  --gold: #b8860b;
  --gold-text: #8a5f08;
  --gold-light: #e7c46b;
  --lilac: #c9c6e8;
  --card: #ffffff;
  --shadow: 0 1px 3px rgba(32, 38, 126, 0.12);
  --font-display: "Montserrat", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--sky);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
}
h1, h2, h3, p { margin: 0; }
a { color: var(--navy); }
a:hover { color: var(--gold-text); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Barre du haut */
.topbar {
  position: sticky; top: 0; z-index: 2000;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 16px clamp(16px, 4vw, 48px);
  background: var(--navy); color: #fff;
}
.badge {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: #b7b08a; color: var(--navy); font: 600 14px var(--font-display);
}
.topbar__title { font: 700 16px var(--font-display); }
.topbar__nav { flex: 1 1 auto; display: flex; flex-wrap: wrap; gap: 4px 4px; }
.topbar__nav a, .topbar__official { padding: 8px 12px; border-radius: 999px; color: #fff; font: 600 14px var(--font-body); text-decoration: none; }
.topbar__nav a:hover, .topbar__official:hover { background: rgba(255, 255, 255, 0.14); color: var(--gold-light); }
.topbar__official { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--gold-light); color: var(--gold-light); }
.topbar__meta { font-size: 13px; color: var(--lilac); }

.banner {
  margin: 0; padding: 12px clamp(16px, 4vw, 48px);
  background: #fff4d6; color: #5c3f00; font-weight: 500; border-bottom: 1px solid var(--gold-light);
}

.page { max-width: 1264px; margin: 0 auto; padding: 32px clamp(16px, 4vw, 48px) 24px; }
.stack { display: flex; flex-direction: column; gap: 32px; }

/* Cartes */
.card { padding: 28px; border-radius: 16px; background: var(--card); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card h2 { font: 700 22px var(--font-display); }
.card__head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.card__sub { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 14px; color: var(--muted); }
.caption { font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.card--error { align-items: flex-start; }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab, .button {
  min-height: 44px; padding: 10px 18px; border-radius: 999px; cursor: pointer;
  font: 600 14px var(--font-body); border: 1px solid var(--navy); background: transparent; color: var(--navy);
}
.tab:hover, .button:hover { background: var(--sky); }
.tab[aria-selected="true"], .button:not(.button--ghost) { background: var(--navy); color: #fff; }
.tab[aria-selected="true"]:hover, .button:not(.button--ghost):hover { background: var(--blue); }
.button--ghost { min-height: 36px; padding: 6px 14px; }

/* Graphiques */
.chart-host { width: 100%; min-height: 320px; }
.chart-host--small { min-height: 260px; }
.chart { display: block; max-width: 100%; touch-action: pan-y; cursor: crosshair; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-label { font: 400 11px var(--font-body); fill: var(--muted); }
.chart-line { fill: none; stroke: var(--navy); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot, .chart-cursor-dot { fill: var(--gold); stroke: #fff; stroke-width: 3; }
.chart-stop-top { stop-color: var(--navy); stop-opacity: 0.28; }
.chart-stop-bottom { stop-color: var(--navy); stop-opacity: 0; }
.chart-bar { fill: var(--navy); }
.chart-bar--record { fill: var(--gold); }
.chart-cursor { stroke: var(--gold); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart-brush { fill: var(--blue); fill-opacity: 0.15; stroke: var(--blue); }
.chart-empty { padding: 48px 16px; text-align: center; color: var(--muted); }

.tooltip {
  position: fixed; z-index: 10; pointer-events: none; max-width: 280px;
  padding: 10px 14px; border-radius: 10px; background: var(--navy); color: #fff;
  box-shadow: 0 6px 18px rgba(15, 18, 69, 0.35);
}
.tooltip__title { font-size: 12px; color: var(--lilac); }
.tooltip__value { font: 700 18px var(--font-display); }
.tooltip__sub { font-size: 12px; color: var(--gold-light); white-space: pre-line; }

/* Calendrier */
.heat-scroll { overflow-x: auto; }
.heat { display: grid; gap: 4px; min-width: 640px; grid-auto-rows: auto; }
.heat-month { font-size: 11px; color: var(--muted); }
.heat-cell { aspect-ratio: 1; border-radius: 4px; }
.heat-cell:hover { outline: 2px solid var(--gold); }
/* Un niveau par HEAT_LEVELS (public/analytics.mjs) : .heat-0 à .heat-4, plus .heat-record. */
.heat-0 { background: #e6e8f7; }
.heat-1 { background: #c3c7ea; }
.heat-2 { background: #8f95d6; }
.heat-3 { background: #4f56b8; }
.heat-4 { background: var(--navy); }
.heat-record { background: var(--gold); }
.heat-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; }

.footer { padding: 16px clamp(16px, 4vw, 48px) 40px; text-align: center; font-size: 13px; color: var(--muted); }

@media (max-width: 600px) {
  .card { padding: 20px 16px; }
  .chart-host { min-height: 280px; }
}

.tab[hidden] { display: none; }

/* Accueil : compteur, courbe de la dernière heure, fil du direct */
.hero-row { display: flex; flex-wrap: wrap; gap: 24px; align-items: stretch; }
.hero {
  flex: 2 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 12px;
  padding: clamp(24px, 4vw, 36px); border-radius: 24px; color: #fff;
  background: linear-gradient(160deg, #141a5c 0%, var(--navy) 60%, #2b33a0 100%);
  box-shadow: 0 8px 24px rgba(32, 38, 126, 0.25);
}
.rule { width: 48px; height: 3px; background: var(--gold-light); }
.hero__title { font: 700 clamp(22px, 3vw, 30px)/1.2 var(--font-display); }
.eyebrow { font: 600 12px var(--font-body); letter-spacing: 0.2em; color: var(--muted); margin: 0; }
.eyebrow--light { color: var(--gold-light); }
.eyebrow--gold { color: var(--gold-text); }
.hero .eyebrow--gold { color: var(--gold-light); }
.live-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hero__delta { font-size: 14px; color: var(--lilac); }
.hero__count { font: 700 clamp(48px, 9vw, 84px)/1 var(--font-display); letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.hero__sub { font-size: 18px; color: #dcdaf2; }
.hero__note { font-size: 14px; color: var(--lilac); max-width: 620px; }
.hero__auto { font-size: 14px; color: var(--gold-light); }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gold-light); animation: pulse 1.6s infinite; }
.live-dot--gold { background: var(--gold); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.hour { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.hour__head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; }
.hour__sum { font-size: 13px; color: var(--lilac); }
.hour__legend, .hour__empty { font-size: 12px; color: var(--lilac); }
.hourcurve { display: block; width: 100%; height: auto; }
.hourcurve__stop-top { stop-color: var(--gold-light); stop-opacity: 0.45; }
.hourcurve__stop-bottom { stop-color: var(--gold-light); stop-opacity: 0; }
.hourcurve__line { fill: none; stroke: var(--gold-light); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.hourcurve__estimate { fill: none; stroke: var(--gold-light); stroke-width: 3; stroke-dasharray: 2 6; stroke-linecap: round; }
.hourcurve__dot { fill: #fff; stroke: var(--gold-light); stroke-width: 2.5; }
.hourcurve__time { font: 400 11px var(--font-body); fill: var(--lilac); }
.hourcurve__gain { font: 600 11px var(--font-body); fill: #fff; }

.feed { flex: 1 1 340px; }
.feed__head { display: flex; align-items: center; gap: 10px; }
.feed__head h2 { font: 700 20px var(--font-display); }
.feed__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.feed__item, .feed__empty { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; background: #f4f5fd; font-size: 15px; }
.feed__item--latest { background: #fff4d6; }
.feed__time { color: var(--gold-text); min-width: 56px; }
.feed__gain { color: var(--gold-text); }
.cta {
  margin-top: auto; display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 0 24px;
  border-radius: 999px; background: linear-gradient(135deg, var(--navy) 0%, var(--blue) 100%); color: #fff;
  font: 700 16px var(--font-display); text-decoration: none;
  box-shadow: 0 6px 16px rgba(32, 38, 126, 0.35), inset 0 0 0 2px var(--gold-light);
}
.cta:hover { color: #fff; background: var(--blue); }
.cta svg { color: var(--gold-light); }

/* Paliers */
.card--warm { background: linear-gradient(135deg, #fff9e6, #fff); }
.lead { font-size: 15px; color: var(--muted); }
.lead--section { margin: 4px 0 14px; }
.route-host { overflow-x: auto; }
.route { display: block; width: 100%; min-width: 640px; height: auto; }
.route__track { fill: #e6e6f0; }
.route__done { fill: var(--navy); }
.route__node { fill: var(--navy); }
.route__check { fill: none; stroke: #fff; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.route__next { fill: #fff; stroke: var(--gold); stroke-width: 3; stroke-dasharray: 4 3; }
.route__here { fill: var(--gold-light); stroke: var(--navy); stroke-width: 3; }
.route__value { font: 700 12px var(--font-display); fill: var(--navy); }
.route__value--next { fill: var(--gold-text); }
.route__date { font: 600 11px var(--font-body); fill: var(--muted); }
.route__bubble { font: 700 12px var(--font-display); fill: var(--navy); paint-order: stroke; stroke: var(--gold-light); stroke-width: 10px; stroke-linejoin: round; }

/* Chiffres clés */
.section-title { font: 700 24px var(--font-display); margin-bottom: 14px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.tile { display: flex; flex-direction: column; gap: 6px; padding: 20px 22px; border-radius: 20px; background: var(--card); box-shadow: var(--shadow); min-width: 0; }
.tile b { font: 700 32px/1.1 var(--font-display); color: var(--navy); }
.tile span { font-size: 14px; color: var(--muted); line-height: 1.4; }
.tile--gold { background: #fff4d6; }
.tile--gold b { color: var(--gold-text); }
.duo { display: flex; flex-wrap: wrap; gap: 24px; }
.duo > .card { flex: 1 1 380px; }

/* Autres initiatives */
.initiatives { display: flex; flex-wrap: wrap; gap: 24px; }
.initiative { flex: 1 1 420px; min-width: 0; display: flex; flex-direction: column; gap: 10px; padding: 24px; border-radius: 20px; background: var(--card); box-shadow: var(--shadow); }
.initiative__name { font: 700 20px var(--font-display); }
.initiative p { color: var(--muted); }
.initiative__name { color: var(--ink); }
.go { align-self: flex-start; padding: 10px 18px; border-radius: 999px; background: var(--navy); color: #fff; font: 600 14px var(--font-body); text-decoration: none; }
.go:hover { background: var(--blue); color: #fff; }
.join-line { text-align: center; font-size: 14px; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
}

/* Agenda */
.agenda-layout { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.agenda-map-host { flex: 3 1 480px; height: 560px; border-radius: 16px; overflow: hidden; background: #f4f5fd; z-index: 0; }
.agenda-side { flex: 1 1 260px; display: flex; flex-direction: column; gap: 12px; }
.agenda-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.agenda-legend__item { display: flex; align-items: center; gap: 12px; }
.agenda-legend__count { margin-left: auto; color: var(--muted); }
.agenda-legend__dot, .agenda-marker { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; position: relative; }
.agenda-marker { border: 2px solid #fff; box-shadow: 0 2px 6px rgba(15, 18, 69, 0.4); cursor: pointer; }
.agenda-icon { fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.agenda-marker__count { position: absolute; top: -8px; right: -8px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: #fff; color: var(--navy); font: 700 12px/20px var(--font-body); text-align: center; box-shadow: 0 1px 3px rgba(15, 18, 69, 0.4); }
.agenda-type--reunion { background: #b8860b; }
.agenda-type--tour { background: #20267e; }
.agenda-type--afterwork { background: #3a41b8; }
.agenda-type--cafe { background: #5459ad; }
.agenda-type--autre { background: #4a4d7a; }
.agenda-reset { padding: 8px 14px; border: 2px solid rgba(0, 0, 0, 0.2); border-radius: 6px; background: #fff; color: var(--navy); font: 600 13px var(--font-body); cursor: pointer; }
.agenda-reset:hover { background: var(--sky); }
.agenda-popup { font-family: var(--font-body); color: var(--ink); display: flex; flex-direction: column; gap: 12px; }
.agenda-popup__event { display: flex; flex-direction: column; gap: 2px; }
.agenda-popup__event + .agenda-popup__event { padding-top: 10px; border-top: 1px solid var(--line); }
.agenda-popup p { margin: 0; }
.agenda-popup__date { font-size: 12px; color: var(--muted); }
.agenda-popup__title { font: 700 15px var(--font-display); }
.agenda-popup__place, .agenda-popup__note { font-size: 13px; color: var(--muted); }
.agenda-popup__links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.agenda-popup__links a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--navy); font: 600 13px var(--font-body); text-decoration: none; }
.agenda-popup__links a.agenda-popup__route { background: var(--navy); color: #fff; }
.agenda-off__title { font: 700 16px var(--font-display); margin-bottom: 8px; }
.agenda-off { margin: 0; padding-left: 20px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; font-size: 14px; }

@media (max-width: 600px) {
  .agenda-map-host { height: 380px; }
}

html { scroll-padding-top: 88px; }
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
