/* L'Atelier Hub - charte noir et blanc (le contraste est le signal), couleur réservée à la data. */
:root {
  --ink: #000000;
  --paper: #ffffff;
  --graphite: #5e5e5e;
  --mist: #eaeaea;
  --veil: #f6f6f6;
  --google: #f2a900;
  --meta: #0866ff;
  --tiktok: #00b2c4;
  --seo: #059669;
  --ai: #7c3aed;
  --prev: #a3a3a3;
  --good: #15803d;
  --bad: #b91c1c;
  --display: "Outfit", system-ui, sans-serif;
  --body: "DM Sans", system-ui, sans-serif;
  --side: 248px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--body);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------- Connexion ---------- */
.login { display: grid; grid-template-columns: minmax(320px, 46%) 1fr; min-height: 100vh; }
.login-brand {
  background: var(--ink); color: var(--paper);
  padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between;
}
.login-wordmark { width: 190px; height: auto; }
.login-pitch h1 { font-family: var(--display); font-weight: 600; font-size: 52px; line-height: 1.02; margin: 0 0 16px; letter-spacing: -0.02em; }
.login-pitch p { color: #b5b5b5; font-size: 16px; margin: 0; max-width: 32ch; }
.login-spark { width: 100%; max-width: 420px; }
.login-form-wrap { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 40px 24px; }
.login-form { width: 100%; max-width: 360px; display: grid; gap: 16px; }
.login-form h2 { font-family: var(--display); font-size: 28px; font-weight: 600; margin: 0 0 8px; }
.login-form label { display: grid; gap: 6px; font-weight: 500; font-size: 13px; }
.login-form input[type=email], .login-form input[type=password] {
  height: 46px; border: 1px solid #cfcfcf; border-radius: 6px; padding: 0 14px; font-size: 15px; background: var(--paper);
}
.login-form input:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgba(0,0,0,.08); }
.login-form .check { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--graphite); }
.form-error { color: var(--bad); margin: 0; font-size: 13px; }
.btn-primary {
  height: 46px; border: 0; border-radius: 6px; background: var(--ink); color: var(--paper);
  font-weight: 600; cursor: pointer; padding: 0 20px; transition: transform .08s ease, background .15s;
}
.btn-primary:hover { background: #262626; }
.btn-primary:active { transform: translateY(1px); }
.btn-primary[disabled] { opacity: .6; cursor: progress; }
.btn-ghost { height: 42px; border: 1px solid var(--mist); background: var(--paper); border-radius: 6px; padding: 0 16px; cursor: pointer; }
.muted-link { color: var(--graphite); font-size: 13px; text-align: center; }
.login-foot { color: var(--graphite); font-size: 12px; margin-top: 40px; }

/* ---------- Application ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--side); flex: none; background: var(--veil); border-right: 1px solid var(--mist);
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 24px 16px 18px;
}
.side-wordmark { width: 132px; margin: 0 8px 26px; }
.client-block { display: flex; align-items: center; gap: 12px; padding: 12px 8px 18px; border-bottom: 1px solid var(--mist); margin-bottom: 14px; }
.client-initials {
  width: 40px; height: 40px; border-radius: 50%; background: var(--ink); color: var(--paper);
  display: grid; place-items: center; font-family: var(--display); font-weight: 600; font-size: 14px;
}
.client-name { font-family: var(--display); font-weight: 600; font-size: 16px; }
.client-sub { color: var(--graphite); font-size: 12px; }
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 6px;
  color: var(--graphite); text-decoration: none; font-weight: 500;
}
.nav a .swatch { width: 8px; height: 8px; border-radius: 50%; background: var(--prev); flex: none; }
.nav a:hover { background: #ececec; color: var(--ink); }
.nav a[aria-current=page] { background: var(--paper); color: var(--ink); box-shadow: inset 2px 0 0 var(--ink); }
.side-foot { margin-top: auto; display: grid; gap: 2px; border-top: 1px solid var(--mist); padding-top: 12px; }
.side-link { background: none; border: 0; text-align: left; padding: 8px 10px; color: var(--graphite); text-decoration: none; cursor: pointer; border-radius: 6px; font-size: 13px; }
.side-link:hover { color: var(--ink); background: #ececec; }

.main { flex: 1; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--mist); padding: 14px 32px; display: grid;
  grid-template-columns: auto 1fr auto; grid-template-areas: "menu title controls" "menu updated controls"; align-items: center; column-gap: 16px;
}
.menu-btn { grid-area: menu; display: none; background: none; border: 0; padding: 6px; cursor: pointer; }
.page-title { grid-area: title; font-family: var(--display); font-size: 20px; font-weight: 600; margin: 0; }
.updated { grid-area: updated; color: var(--graphite); font-size: 12px; }
.controls { grid-area: controls; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.segmented { display: inline-flex; border: 1px solid var(--mist); border-radius: 6px; padding: 2px; background: var(--veil); }
.segmented button { border: 0; background: none; padding: 6px 10px; border-radius: 4px; cursor: pointer; color: var(--graphite); font-weight: 500; font-size: 13px; white-space: nowrap; }
.segmented button[aria-pressed=true] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.select { height: 34px; border: 1px solid var(--mist); border-radius: 6px; padding: 0 28px 0 10px; background: var(--paper); font-size: 13px; cursor: pointer; }
.select.active { border-color: var(--ink); }

.content { padding: 28px 32px 64px; max-width: 1280px; outline: none; }
.headline { font-family: var(--display); font-weight: 500; font-size: 36px; line-height: 1.12; letter-spacing: -0.015em; margin: 4px 0 26px; max-width: 26ch; }
.headline b { font-weight: 700; }
.note { color: var(--graphite); font-size: 13px; margin: -14px 0 24px; max-width: 70ch; }

/* Chiffres clés : à plat, un trait noir au-dessus, pas de cartes à ombre */
.kpis { display: grid; grid-template-columns: repeat(var(--n, 6), minmax(0, 1fr)); gap: 0; border-top: 2px solid var(--ink); margin-bottom: 36px; }
.kpi { padding: 14px 18px 16px 0; border-right: 1px solid var(--mist); margin-right: 18px; position: relative; cursor: default; }
.kpi:last-child { border-right: 0; margin-right: 0; }
.kpi-label { color: var(--graphite); font-size: 13px; font-weight: 500; }
.kpi-value { font-family: var(--display); font-size: 30px; font-weight: 600; letter-spacing: -0.01em; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.kpi-delta { font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.kpi-delta.good { color: var(--good); } .kpi-delta.bad { color: var(--bad); } .kpi-delta.flat { color: var(--graphite); }
.kpi-vs { color: var(--graphite); font-size: 12px; font-weight: 400; margin-left: 4px; }
.kpi .spark { display: block; width: 100%; height: 26px; margin-top: 8px; }
.kpi:hover .kpi-value { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 6px; }

.section { margin-bottom: 40px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; border-bottom: 1px solid var(--mist); padding-bottom: 10px; margin-bottom: 16px; }
.section-head h2 { font-family: var(--display); font-size: 18px; font-weight: 600; margin: 0; }
.section-head .src { color: var(--graphite); font-size: 12px; text-align: right; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--graphite); margin: -6px 0 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.legend i.line { height: 3px; border-radius: 0; vertical-align: 3px; }
.legend i.dash { height: 0; border-top: 2px dashed var(--prev); background: none !important; vertical-align: 3px; }
.chart-box { position: relative; height: 300px; }
.chart-box.small { height: 240px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 40px; }
.grid-2 > .section { min-width: 0; }

/* Tables */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.tbl th { text-align: right; font-weight: 600; color: var(--graphite); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--ink); white-space: nowrap; cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--paper); }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl th[aria-sort=descending]::after { content: " \2193"; color: var(--ink); }
.tbl th[aria-sort=ascending]::after { content: " \2191"; color: var(--ink); }
.tbl td { text-align: right; padding: 9px 10px; border-bottom: 1px solid var(--mist); white-space: nowrap; }
.tbl tbody tr:hover td { background: var(--veil); }
.tbl td .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; }
.tbl td .bar { display: inline-block; height: 6px; background: var(--ink); border-radius: 3px; vertical-align: middle; margin-left: 8px; opacity: .85; }
.tbl tfoot td { font-weight: 700; border-top: 1px solid var(--ink); border-bottom: 0; }
.tbl .muted { color: var(--graphite); }
.search { height: 32px; border: 1px solid var(--mist); border-radius: 6px; padding: 0 10px; width: 220px; font-size: 13px; }

/* Entonnoir */
.funnel { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; }
.funnel-step { padding: 16px 18px; border-left: 1px solid var(--mist); }
.funnel-step:first-child { border-left: 0; padding-left: 0; }
.funnel-step .n { font-family: var(--display); font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.funnel-step .l { color: var(--graphite); font-size: 13px; }
.funnel-step .rate { font-size: 12px; margin-top: 8px; }
.funnel-bar { height: 8px; background: var(--ink); border-radius: 4px; margin-top: 10px; transition: width .5s ease; }

/* Galerie des pubs */
.ads { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 20px; }
.ad { border-top: 2px solid var(--meta); padding-top: 10px; }
.ad img, .ad .noimg { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: var(--veil); display: block; }
.ad .name { font-weight: 600; font-size: 13px; margin: 10px 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad .stats { color: var(--graphite); font-size: 12px; font-variant-numeric: tabular-nums; }
.ad .stats b { color: var(--ink); }

/* Carte */
#map { height: 340px; border-radius: 6px; border: 1px solid var(--mist); z-index: 0; }
.leaflet-tooltip.city-tip { font-family: var(--body); border-radius: 6px; border: 0; box-shadow: 0 4px 16px rgba(0,0,0,.15); padding: 8px 10px; }

/* Barres horizontales */
.hbars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: 150px 1fr auto; align-items: center; gap: 12px; font-size: 13px; }
.hbar .track { height: 10px; background: var(--veil); border-radius: 5px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--ink); border-radius: 5px; transition: width .5s ease; }
.hbar .v { color: var(--graphite); font-variant-numeric: tabular-nums; }

.empty { border: 1px dashed #cfcfcf; border-radius: 6px; padding: 28px; color: var(--graphite); text-align: center; }
.settling { display: inline-block; font-size: 11px; color: var(--graphite); border: 1px solid var(--mist); border-radius: 10px; padding: 1px 8px; margin-left: 8px; }

/* Squelettes */
.skel { background: linear-gradient(90deg, var(--veil) 0%, #efefef 50%, var(--veil) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Info-bulle maison (KPI) */
.tip { position: fixed; z-index: 50; background: var(--ink); color: var(--paper); font-size: 12px; padding: 8px 10px; border-radius: 6px; pointer-events: none; max-width: 260px; line-height: 1.4; }

/* Accueil */
.welcome { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 60; padding: 20px; }
.welcome-card { background: var(--paper); border-radius: 10px; max-width: 460px; width: 100%; padding: 32px; }
.welcome-card h3 { font-family: var(--display); font-size: 26px; margin: 0 0 10px; font-weight: 600; }
.welcome-card p { color: var(--graphite); margin: 0; }
.welcome-actions { display: flex; justify-content: space-between; margin-top: 28px; }
.dots { display: flex; gap: 6px; margin-top: 18px; }
.dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--mist); }
.dots span.on { background: var(--ink); }

.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 29; }

@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi:nth-child(3n) { border-right: 0; margin-right: 0; }
  .kpi:nth-child(n+4) { border-top: 1px solid var(--mist); }
}
@media (max-width: 760px) {
  .login { grid-template-columns: 1fr; }
  .login-brand { padding: 28px 24px; gap: 28px; }
  .login-pitch h1 { font-size: 36px; }
  .login-spark { display: none; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: none; }
  .menu-btn { display: block; }
  .topbar { padding: 10px 16px; grid-template-areas: "menu title" "controls controls" "updated updated"; grid-template-columns: auto 1fr; row-gap: 8px; }
  .controls { justify-content: flex-start; }
  .content { padding: 20px 16px 48px; }
  .headline { font-size: 26px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { margin-right: 12px; }
  .kpi:nth-child(3n) { border-right: 1px solid var(--mist); margin-right: 12px; }
  .kpi:nth-child(2n) { border-right: 0; margin-right: 0; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--mist); }
  .kpi-value { font-size: 24px; }
  .funnel { grid-template-columns: repeat(2, 1fr); }
  .hbar { grid-template-columns: 110px 1fr auto; }
  .chart-box { height: 240px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Carte : fond sans étiquettes (CARTO light), nos noms de villes à côté des bulles */
.city-label { background: none; border: 0; }
.city-label span { display: inline-block; white-space: nowrap; font-family: var(--body); font-size: 12px; font-weight: 600; color: var(--ink); background: rgba(255,255,255,.85); padding: 1px 6px; border-radius: 4px; transform: translateY(-50%); }

/* Classement des catégories */
.ranks { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.rank { display: grid; grid-template-columns: 1fr auto; row-gap: 6px; }
.rank-name { font-weight: 500; }
.rank-val { font-family: var(--display); font-weight: 600; font-variant-numeric: tabular-nums; }
.rank-track { grid-column: 1 / -1; display: block; height: 8px; background: var(--veil); border-radius: 4px; overflow: hidden; }
.rank-fill { display: block; height: 100%; background: #9a9a9a; border-radius: 4px; transition: width .5s ease; }
.rank.top .rank-fill { background: var(--ink); }
.rank-meta { grid-column: 1 / -1; color: var(--graphite); font-size: 12px; }
.hbar .fill { display: block; }

/* Galerie : médias en HD, badge vidéo, tuile catalogue */
.ad-media { position: relative; }
.ad-media img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; display: block; background: var(--veil); }
.badge { position: absolute; left: 8px; top: 8px; background: rgba(0,0,0,.75); color: #fff; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.catalog-tile { aspect-ratio: 1; border-radius: 6px; background: var(--veil); border: 1px solid var(--mist); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 18px; text-align: center; }
.catalog-tile b { font-family: var(--display); font-size: 16px; font-weight: 600; }
.catalog-tile span { color: var(--graphite); font-size: 12px; line-height: 1.35; }

/* Sous-titre des KPI (le nom du métier, puis sa traduction), icône d'aide, phrases à retenir */
.kpi-sub { color: var(--graphite); font-size: 11px; margin-top: 1px; }
.info { display: inline-grid; place-items: center; width: 14px; height: 14px; border-radius: 50%; border: 1px solid #b5b5b5; color: #8a8a8a; font-size: 9px; font-weight: 700; margin-left: 6px; vertical-align: 1px; font-family: var(--body); }
.takeaway { margin: 0 0 14px; font-size: 14px; }
.takeaway b { font-weight: 700; }
.nav-group { color: #8a8a8a; font-size: 11px; font-weight: 600; padding: 14px 10px 4px; }
.nav-group:first-child { padding-top: 0; }
.split { margin-top: 18px; }
.split-label { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.split-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--veil); }
.split-bar span { display: block; height: 100%; }
.split-legend { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 8px; font-size: 12px; color: var(--graphite); }
.split-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.split-legend b { color: var(--ink); }

/* Alignement des cartes KPI : chaque ligne a la même hauteur partout */
.kpi { display: grid; grid-template-rows: 20px 16px 44px 20px 34px; align-content: start; }
.kpi-label { display: flex; align-items: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 0; }
.kpi-value { margin: 0; line-height: 44px; }
.kpi .spark, .spark-empty { display: block; width: 100%; height: 26px; margin-top: 8px; }
@media (max-width: 760px) { .kpi { grid-template-rows: 20px 16px 36px 20px 34px; } .kpi-value { line-height: 36px; } }

/* Budget du mois */
.budget { margin: -18px 0 34px; }
.budget-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--graphite); margin-bottom: 8px; }
.budget-head b { color: var(--ink); }
.budget-track { position: relative; height: 10px; background: var(--veil); border-radius: 5px; }
.budget-track span { display: block; height: 100%; background: var(--ink); border-radius: 5px; }
.budget-track i { position: absolute; top: -4px; width: 2px; height: 18px; background: var(--graphite); }

.client-switch { width: 100%; margin: -6px 0 14px; }

/* Connexion : aperçu en verre, courbe tracée une seule fois, bouton Google, séparateur */
.login-preview { position: relative; width: 100%; max-width: 440px; }
.login-preview .login-spark { width: 100%; display: block; margin-top: 18px; }
.login-preview .draw { stroke-dasharray: 600; stroke-dashoffset: 600; animation: draw 1.6s .2s ease-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.glass { display: inline-flex; flex-direction: column; gap: 2px; padding: 12px 16px; margin-right: 10px; border-radius: 10px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.15); backdrop-filter: blur(6px); }
.glass span { color: rgba(255,255,255,.55); font-size: 12px; }
.glass b { font-family: var(--display); font-weight: 600; font-size: 22px; color: #fff; }
.google-wrap { display: grid; gap: 18px; margin-bottom: 2px; }
.google-slot { position: relative; }
.btn-google { width: 100%; height: 46px; border: 1.5px solid var(--ink); border-radius: 6px; background: var(--paper); color: var(--ink); display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 600; font-size: 14px; cursor: pointer; transition: background .15s; }
.google-slot:hover .btn-google { background: #f4f4f4; }
/* Le vrai bouton Google est rendu par-dessus, invisible : le clic lui revient, le style reste le nôtre. */
.google-official { position: absolute; inset: 0; overflow: hidden; opacity: .01; }
.google-official > div { transform-origin: 0 0; }
.or { display: flex; align-items: center; gap: 12px; color: var(--graphite); font-size: 12px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--mist); }
.login-foot { font-family: var(--display); font-weight: 500; font-size: 14px; color: var(--ink); }

/* Mobile : le formulaire doit être visible sans défiler, le panneau noir devient un en-tête court */
@media (max-width: 760px) {
  .login-brand { padding: 22px 20px 26px; gap: 18px; }
  .login-wordmark { width: 150px; }
  .login-pitch h1 { font-size: 30px; margin-bottom: 8px; }
  .login-pitch p { font-size: 14px; }
  .login-preview { display: none; }
  .login-form-wrap { justify-content: flex-start; padding: 28px 20px; }
  .login-foot { margin-top: 28px; }
}

/* Mobile : la barre du haut ne reste plus collée (elle prenait un quart de l'écran) */
@media (max-width: 760px) {
  .topbar { position: relative; }
  .segmented button { padding: 6px 8px; }
  .section-head { flex-wrap: wrap; }
  .section-head .src { text-align: left; }
}

/* ---------- Toutes tailles d'écran ----------
   < 400 petit téléphone · < 760 téléphone · 760 à 1023 tablette (menu en tiroir)
   1024 à 1279 laptop compact · 1280 à 1599 desktop · >= 1600 grand écran (contenu centré, plus d'air) */
.main { display: flex; flex-direction: column; }
.content { width: 100%; margin: 0 auto; }

@media (max-width: 1279px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi:nth-child(3n) { border-right: 0; margin-right: 0; }
  .kpi:nth-child(n+4) { border-top: 1px solid var(--mist); }
  .kpis[style*="--n:4"], .kpis[style*="--n:5"] { grid-template-columns: repeat(var(--n), minmax(0, 1fr)); }
  .kpis[style*="--n:4"] .kpi, .kpis[style*="--n:5"] .kpi { border-top: 0; }
  .kpis[style*="--n:4"] .kpi:nth-child(3n), .kpis[style*="--n:5"] .kpi:nth-child(3n) { border-right: 1px solid var(--mist); margin-right: 18px; }
  .kpis[style*="--n:4"] .kpi:last-child, .kpis[style*="--n:5"] .kpi:last-child { border-right: 0; margin-right: 0; }
}

/* Tablette : le menu passe en tiroir pour rendre toute la largeur au contenu */
@media (max-width: 1023px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.12); }
  .sidebar.open { transform: none; }
  .menu-btn { display: block; }
  .topbar { padding: 12px 24px; grid-template-areas: "menu title" "controls controls" "updated updated"; grid-template-columns: auto 1fr; row-gap: 8px; }
  .controls { justify-content: flex-start; }
  .content { padding: 24px 24px 56px; }
  .grid-2 { grid-template-columns: 1fr; gap: 0; }
  .kpis[style*="--n:5"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpis[style*="--n:5"] .kpi:nth-child(3n) { border-right: 0; margin-right: 0; }
  .kpis[style*="--n:5"] .kpi:nth-child(n+4) { border-top: 1px solid var(--mist); }
  .headline { font-size: 32px; }
}

/* Téléphone */
@media (max-width: 759px) {
  .kpis, .kpis[style*="--n:4"], .kpis[style*="--n:5"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis .kpi, .kpis[style*="--n:4"] .kpi, .kpis[style*="--n:5"] .kpi { border-right: 1px solid var(--mist); margin-right: 12px; border-top: 0; }
  .kpis .kpi:nth-child(2n) { border-right: 0; margin-right: 0; }
  .kpis .kpi:nth-child(n+3) { border-top: 1px solid var(--mist); }
  /* Téléphone : les périodes sur une ligne pleine largeur, les deux menus sur la ligne suivante.
     Plus de défilement horizontal caché (les boutons sortaient de l'écran sans aucun indice). */
  .controls { flex-wrap: wrap; overflow: visible; gap: 8px; }
  .segmented { display: flex; width: 100%; }
  .segmented button { flex: 1; padding: 7px 4px; text-align: center; }
  .controls .select { flex: 1 1 0; min-width: 0; }
  .tbl { font-size: 12px; }
  .tbl td, .tbl th { padding: 8px 8px; }
  .tbl th:first-child, .tbl td:first-child { position: sticky; left: 0; background: var(--paper); z-index: 1; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
  .ads { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  #map { height: 280px; }
  .search { width: 100%; }
}

/* Petit téléphone */
@media (max-width: 399px) {
  .content { padding: 18px 14px 44px; }
  .topbar { padding: 10px 14px; }
  .headline { font-size: 23px; }
  .kpi-value { font-size: 21px; }
  .kpi { margin-right: 8px !important; }
  .budget-head { font-size: 12px; }
  .funnel { grid-template-columns: 1fr 1fr; }
}

/* Grand écran : contenu centré, plus d'espace, graphiques plus hauts */
@media (min-width: 1600px) {
  :root { --side: 264px; }
  .content { max-width: 1480px; padding: 36px 48px 72px; }
  .topbar { padding: 16px 48px; }
  .headline { font-size: 42px; }
  .kpi-value { font-size: 34px; }
  .chart-box { height: 360px; }
  .chart-box.small { height: 280px; }
  #map { height: 400px; }
}
@media (min-width: 2200px) {
  html { font-size: 16px; }
  body { font-size: 15px; }
  .content { max-width: 1720px; }
  .chart-box { height: 420px; }
}

/* Menus déroulants : flèche maison, avec de l'air à droite */
.select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  height: 34px; padding: 0 34px 0 12px; border: 1px solid var(--mist); border-radius: 6px;
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%235e5e5e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center;
}
.select:hover { border-color: #cfcfcf; }
.select:focus-visible { outline: none; border-color: var(--ink); }
.client-switch { height: 32px; font-size: 12.5px; font-weight: 500; padding-left: 10px; color: var(--graphite); }

/* Navigation : état actif sobre, sans barre latérale ni arrondi marqué */
.nav a { border-radius: 4px; padding: 8px 10px; }
.nav a[aria-current=page] { background: none; box-shadow: none; color: var(--ink); font-weight: 600; }
.nav a[aria-current=page] .swatch { box-shadow: 0 0 0 3px var(--paper), 0 0 0 4px currentColor; }
.nav a:hover { background: none; color: var(--ink); }

/* En-tête de section : la pastille « still settling » et la source ne se touchent plus */
.section-head .src { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px 12px; }
.settling { margin-left: 0; }

/* ---------- Creatives ---------- */
.fmts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 32px; }
.fmt-name { font-family: var(--display); font-weight: 600; font-size: 17px; margin-bottom: 14px; }
.fmt-name span { font-family: var(--body); font-weight: 400; font-size: 13px; color: var(--graphite); margin-left: 6px; }
.fmt-bars { display: grid; gap: 14px; }
.fmt-bars div { display: grid; grid-template-columns: 1fr auto; row-gap: 6px; font-size: 13px; color: var(--graphite); }
.fmt-bars b { color: var(--ink); font-variant-numeric: tabular-nums; }
.fmt-bars i { grid-column: 1 / -1; display: block; height: 8px; border-radius: 4px; }
.fmt-foot { margin-top: 14px; font-size: 13px; color: var(--graphite); }
.crea-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips button { height: 34px; padding: 0 14px; border: 1px solid var(--mist); border-radius: 17px; background: var(--paper); cursor: pointer; font-size: 13px; color: var(--graphite); }
.chips button[aria-pressed=true] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.crea-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 32px 24px; }
.crea { all: unset; cursor: pointer; display: grid; gap: 10px; align-content: start; }
.crea:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; border-radius: 8px; }
.crea-media { position: relative; display: block; aspect-ratio: 4 / 5; border-radius: 8px; overflow: hidden; background: var(--veil); }
.crea-media img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease; }
.crea:hover .crea-media img { transform: scale(1.03); }
.crea-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crea-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: 12px; color: var(--graphite); font-variant-numeric: tabular-nums; }
.crea-stats b { color: var(--ink); }
.verdict { position: absolute; right: 10px; bottom: 10px; font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 12px; background: rgba(255,255,255,.94); color: var(--ink); }
.verdict.v-win { background: #15803d; color: #fff; }
.verdict.v-no { background: #fff; color: #b91c1c; }
.crea-legend { display: grid; gap: 6px; margin-top: 28px; font-size: 12px; }
.crea-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; background: #a3a3a3; }
.crea-legend i.v-win { background: #15803d; } .crea-legend i.v-ok { background: #000; } .crea-legend i.v-no { background: #b91c1c; }
.catalog-tile.small { aspect-ratio: auto; height: 100%; border: 0; border-radius: 0; }
.crea-modal { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 24px; }
.crea-modal-card { position: relative; background: var(--paper); border-radius: 12px; width: min(920px, 100%); max-height: calc(100vh - 48px); overflow: auto; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.crea-modal-media { background: var(--veil); display: grid; place-items: center; min-height: 360px; }
.crea-modal-media img { width: 100%; height: 100%; object-fit: contain; max-height: calc(100vh - 48px); }
.crea-modal-body { padding: 36px 32px; }
.crea-modal-body h3 { font-family: var(--display); font-size: 24px; font-weight: 600; margin: 0 0 8px; }
.crea-dl { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 24px; margin: 0; }
.crea-dl dt { font-size: 12px; color: var(--graphite); }
.crea-dl dd { margin: 2px 0 0; font-family: var(--display); font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.crea-close { position: absolute; right: 14px; top: 10px; z-index: 2; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(255,255,255,.92); font-size: 22px; cursor: pointer; }
.client-initials.has-logo { background: var(--paper); border: 1px solid var(--mist); overflow: hidden; }
.client-initials.has-logo img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }

/* ---------- Espacements : plus d'air, partout ---------- */
.content { padding-top: 36px; padding-bottom: 80px; }
.headline { margin: 0 0 36px; line-height: 1.15; }
.note { margin: -18px 0 28px; line-height: 1.55; }
.kpis { margin-bottom: 48px; }
.kpi { padding-top: 18px; padding-bottom: 20px; }
.section { margin-bottom: 56px; }
.section-head { padding-bottom: 14px; margin-bottom: 22px; }
.legend { margin: 0 0 16px; gap: 20px; }
.grid-2 { gap: 56px; }
.tbl td { padding: 12px 12px; }
.tbl th { padding: 10px 12px; }
.takeaway { margin-bottom: 18px; line-height: 1.5; }
.ranks { gap: 18px; }
.ads { gap: 28px 24px; }
.ad .name { margin-top: 12px; }
.budget { margin: -24px 0 44px; }
.split { margin-top: 24px; }
.funnel-step { padding: 18px 22px; }
.nav { gap: 4px; }
.nav-group { padding: 18px 10px 6px; }
.client-block { padding-bottom: 20px; margin-bottom: 16px; }
@media (max-width: 1023px) {
  .content { padding: 28px 24px 64px; }
  .grid-2 { gap: 0; }
  .crea-modal-card { grid-template-columns: 1fr; }
  .crea-modal-media { min-height: 260px; }
}
@media (max-width: 759px) {
  .content { padding: 24px 20px 56px; }
  .headline { margin-bottom: 28px; }
  .kpis { margin-bottom: 36px; }
  .section { margin-bottom: 44px; }
  .crea-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 14px; }
  .crea-stats { grid-template-columns: 1fr; }
  .crea-bar .select { width: 100%; }
  .crea-modal { padding: 0; place-items: end stretch; }
  .crea-modal-card { border-radius: 14px 14px 0 0; max-height: 92vh; }
  .crea-modal-body { padding: 24px 20px 32px; }
}
@media (max-width: 399px) { .content { padding: 20px 16px 48px; } }
@media (min-width: 1600px) { .content { padding: 44px 56px 96px; } .section { margin-bottom: 64px; } .crea-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); } }

/* Légende des verdicts : bloc à part, jamais de marge négative */
.crea-legend { margin: 36px 0 0; color: var(--graphite); line-height: 1.5; }
.crea-legend span { display: block; }

.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 11px; }
.pill-bad { background: #fde8e8; color: #b91c1c; }
.pill-warn { background: #fdf3e2; color: #92400e; }

.show-all { margin-top: 12px; background: none; border: 0; padding: 6px 0; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
.link-more { color: var(--ink); font-weight: 600; text-underline-offset: 4px; }
.scope { margin: 0 0 18px; }

/* Ce que chaque plateforme rapporte */
.credit { display: grid; gap: 22px; }
.credit-row { display: grid; grid-template-columns: 110px 1fr; grid-template-areas: "name track" "name val"; column-gap: 16px; row-gap: 8px; align-items: center; }
.credit-name { grid-area: name; font-weight: 600; align-self: start; padding-top: 2px; }
.credit-name .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; }
.credit-track { grid-area: track; height: 10px; background: var(--veil); border-radius: 5px; overflow: hidden; }
.credit-track span { display: block; height: 100%; border-radius: 5px; }
.credit-val { grid-area: val; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; font-size: 13px; color: var(--graphite); }
.credit-val b { font-family: var(--display); font-size: 18px; color: var(--ink); }
.badges { position: absolute; left: 10px; top: 10px; display: flex; gap: 6px; }
.badges .badge { position: static; }
.badge.plat { color: #fff; }
.coming { margin: 0; padding-left: 18px; display: grid; gap: 8px; }

/* Pubs TikTok : tuile sombre et lecteur officiel */
.tt-tile { width: 100%; height: 100%; min-height: 260px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: #0b0b0b; color: #fff; }
.tt-tile b { font-family: var(--display); font-weight: 600; font-size: 15px; }
.tt-player { width: 100%; height: min(78vh, 740px); border: 0; display: block; background: #000; }
.ad { border-top-color: var(--meta); }

.meta-preview { width: 100%; height: min(78vh, 720px); border: 0; display: block; background: #fff; }

/* Chargement d'une vidéo dans la fiche : vignette floutée et spinner, retirés dès que le cadre a chargé */
.crea-modal-media { position: relative; }
.media-loading { position: absolute; inset: 0; z-index: 1; display: grid; place-items: center; align-content: center; gap: 14px; background: var(--veil); overflow: hidden; }
.media-loading img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: blur(14px) brightness(.85); transform: scale(1.08); }
.media-loading .spinner { position: relative; width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255,255,255,.45); border-top-color: #fff; animation: spin .9s linear infinite; }
.media-loading span { position: relative; color: #fff; font-weight: 600; font-size: 14px; text-shadow: 0 1px 8px rgba(0,0,0,.5); text-align: center; padding: 0 20px; }
.media-loading span a { color: #fff; }
.crea-modal-media.loaded .media-loading { display: none; }
/* Pub image rendue comme un post Instagram, dans notre charte */
.ig-frame { width: 100%; max-width: 420px; margin: 0 auto; background: #fff; border: 1px solid var(--mist); border-radius: 10px; overflow: hidden; align-self: center; }
.ig-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; font-size: 13px; }
.ig-head span { display: grid; line-height: 1.2; }
.ig-head b { font-weight: 600; }
.ig-head small { color: var(--graphite); font-size: 11px; }
.ig-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: #fff; place-items: center; font-family: var(--display); font-weight: 600; font-size: 11px; }
.ig-media { display: block; width: 100%; height: auto; background: var(--veil); }
.ig-media-wrap { position: relative; }
.ig-play { all: unset; position: absolute; inset: 0; cursor: pointer; display: block; }
.ig-play .play { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; }
.ig-play .play::after { left: 26px; top: 20px; border-width: 12px 0 12px 20px; }
.ig-play:hover .play { transform: scale(1.08); background: rgba(0,0,0,.75); }
.ig-play:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.ig-cta { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; background: var(--veil); font-size: 13px; }
.ig-cta span { color: var(--graphite); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ig-cta b { flex: none; font-weight: 600; }
.ig-body { margin: 0; padding: 10px 12px 12px; font-size: 13px; line-height: 1.45; white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.crea-modal-media:has(.ig-frame) { padding: 20px; align-items: start; overflow: auto; }
.media-caption { position: absolute; left: 12px; right: 12px; bottom: 12px; background: rgba(0,0,0,.72); color: #fff; font-size: 12px; line-height: 1.4; padding: 8px 10px; border-radius: 6px; }
.tt-tile span { color: #b5b5b5; font-size: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

.best-ad { display: grid; grid-template-columns: 180px 1fr; gap: 28px; align-items: center; }
.best-ad-media { aspect-ratio: 4 / 5; border-radius: 8px; overflow: hidden; background: var(--veil); }
.best-ad-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.best-ad-media .tt-tile, .best-ad-media .catalog-tile { min-height: 0; height: 100%; aspect-ratio: auto; border: 0; }
.best-ad-name { font-family: var(--display); font-weight: 600; font-size: 20px; margin-bottom: 16px; }
.best-ad-stats { display: flex; gap: 36px; margin-bottom: 20px; }
.best-ad-stats span { display: block; color: var(--graphite); font-size: 12px; }
.best-ad-stats b { font-family: var(--display); font-size: 24px; font-weight: 600; }
@media (max-width: 759px) { .best-ad { grid-template-columns: 110px 1fr; gap: 16px; } .best-ad-stats { gap: 18px; } .best-ad-stats b { font-size: 19px; } }

/* Formats : une ligne par format, budget contre ventes, verdict en clair */
.fmt-rows { display: grid; gap: 0; }
.fmt-row { display: grid; grid-template-columns: 150px 1fr 1fr 260px; gap: 24px; align-items: center; padding: 18px 0; border-bottom: 1px solid var(--mist); }
.fmt-row:first-child { border-top: 1px solid var(--mist); }
.fmt-row .fmt-name { font-family: var(--display); font-weight: 600; font-size: 17px; margin: 0; display: grid; gap: 2px; }
.fmt-row .fmt-name span { font-family: var(--body); font-weight: 400; font-size: 12px; color: var(--graphite); margin: 0; }
.fmt-bar { display: grid; grid-template-columns: 52px 1fr 52px; gap: 10px; align-items: center; font-size: 13px; }
.fmt-bar .lbl { color: var(--graphite); }
.fmt-bar .trk { height: 8px; background: var(--veil); border-radius: 4px; overflow: hidden; }
.fmt-bar .trk i { display: block; height: 100%; border-radius: 4px; }
.fmt-bar b { text-align: right; font-variant-numeric: tabular-nums; }
.fmt-verdict { display: grid; gap: 6px; justify-items: start; font-size: 12px; }
.fmt-verdict .muted { color: var(--graphite); }
.pill-good { background: #e3f4e8; color: #15803d; }
.pill-flat { background: var(--veil); color: var(--graphite); }
@media (max-width: 1023px) { .fmt-row { grid-template-columns: 1fr 1fr; } .fmt-row .fmt-name, .fmt-verdict { grid-column: 1 / -1; } }
@media (max-width: 759px) { .fmt-row { grid-template-columns: 1fr; gap: 12px; } }

.crea-multi { font-size: 11px; color: var(--graphite); margin-top: -6px; }

/* Lecture possible : bouton discret au centre de la vignette */
.play { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(0,0,0,.55); backdrop-filter: blur(4px); transition: transform .2s ease, background .2s ease; }
.play::after { content: ""; position: absolute; left: 21px; top: 16px; border-style: solid; border-width: 10px 0 10px 16px; border-color: transparent transparent transparent #fff; }
.crea:hover .play { transform: scale(1.08); background: rgba(0,0,0,.75); }

/* Entonnoir en rangée principale (trait noir au-dessus, comme les chiffres clés) */
.funnel-main { border-top: 2px solid var(--ink); margin-bottom: 36px; }
.funnel-main .funnel-step { padding-top: 22px; }

/* Repères numérotés des graphiques : la légende datée sous le graphique */
.notes-legend { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 10px 0 0; font-size: 12px; color: var(--graphite); }
.notes-legend i { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--ink); color: #fff; font-style: normal; font-size: 10px; font-weight: 700; margin-right: 6px; vertical-align: -4px; }

/* Ligne TikTok du bloc plateformes : pas de barre de ventes, des clics et des paniers */
.credit-row-discovery { grid-template-areas: "name val"; }
.credit-row-discovery .credit-val b { font-size: 18px; }

.tbl-actions { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 4px; }
.csv { margin-left: auto; margin-top: 12px; background: none; border: 0; padding: 6px 0; font-size: 12px; color: var(--graphite); cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
.csv:hover { color: var(--ink); }
