/* ==========================================================
   Tableau de bord SEO — Media Squad
   Pour adapter l'identité : modifiez les variables de :root.
   ========================================================== */

@font-face {
  font-family: "Instrument Sans";
  src: url("fonts/instrument-sans.woff2") format("woff2");
  font-weight: 400 700; font-stretch: 75% 100%; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("fonts/instrument-sans-italic.woff2") format("woff2");
  font-weight: 400 700; font-stretch: 75% 100%; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("fonts/bricolage-grotesque.woff2") format("woff2");
  font-weight: 200 800; font-stretch: 75% 100%; font-style: normal; font-display: swap;
}

:root {
  --font: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Bricolage Grotesque", "Instrument Sans", system-ui, sans-serif;

  /* Identité */
  --ink: #0f1f45;            /* encre : bandeau, titres */
  --ink-2: #1b2d5c;          /* encre claire : survols sur fond sombre */
  --brand: var(--ink);
  --brand-accent: #2f6bff;   /* actions, liens, focus */

  /* Surfaces */
  --surface-0: #f3f5fa;      /* fond de page, gris-bleu froid */
  --surface-1: #ffffff;      /* panneaux */
  --surface-2: #f7f8fc;      /* survol de ligne, zones secondaires */
  --border: #e3e7f0;
  --border-strong: #cdd4e3;
  --grid: #edf0f6;

  --text-primary: #16213a;
  --text-secondary: #5d6782;
  --on-dark: #ffffff;
  --on-dark-2: rgba(255, 255, 255, .68);

  /* Séries de graphiques (palette validée daltonisme) */
  --series-1: #257de0;
  --series-2: #f47230;
  --ai: #7c4dcc;

  /* Tranches de positions (rampe bleue ordinale validée) */
  --rank-1: #0e3d7e;
  --rank-2: #1b64be;
  --rank-3: #338ced;
  --rank-4: #84b9f3;

  /* Statuts */
  --good: #0b7a4b;
  --good-bg: #e3f5ec;
  --bad: #c2362f;
  --bad-bg: #fdeceb;
  --warn-bg: #fff4e0;

  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-lift: 0 1px 2px rgba(15, 31, 69, .06), 0 10px 28px -12px rgba(15, 31, 69, .22);
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { overflow-x: clip; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-primary);
  background: var(--surface-0);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01";
}
a { color: var(--brand-accent); text-underline-offset: 2px; }
h1, h2, h3 { color: var(--ink); line-height: 1.2; font-family: var(--font-display); font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; margin: 0 0 .25rem; }
h2 { font-size: 1.2rem; margin: 0 0 1rem; display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
h3 { font-size: 1rem; margin: 0 0 .75rem; }
code { background: #eceff7; padding: .1rem .4rem; border-radius: 5px; font-size: .86em; word-break: break-all; }
.muted { color: var(--text-secondary); }
.small { font-size: .85rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.inline { display: inline; }
:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; }

/* ---------- Pictogrammes ---------- */
.ico {
  width: 1.15em; height: 1.15em; flex-shrink: 0; vertical-align: -.2em;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.btn .ico { width: 16px; height: 16px; vertical-align: 0; }
.with-ico { display: inline-flex; align-items: center; gap: .4rem; }
.with-ico .ico { opacity: .75; }
.h-ico {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; margin-right: .55rem;
  background: #eaf0ff; color: var(--brand-accent); vertical-align: middle; flex-shrink: 0;
}
.h-ico .ico { width: 17px; height: 17px; }
h2 .h-ico { width: 34px; height: 34px; border-radius: 10px; margin-right: .15rem; }
h2 .h-ico .ico { width: 19px; height: 19px; }
figcaption, .list-head h3, .rank-head h3, .table-card h3 { display: flex; align-items: center; flex-wrap: wrap; }
.chart-card figcaption .muted { margin-left: .35rem; }
.kpi-ico {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; margin-right: .2rem;
  background: #eaf0ff; color: var(--brand-accent); flex-shrink: 0;
}
.kpi-ico .ico { width: 16px; height: 16px; }
.kpi-ico.tone-orange { background: #fff1e8; color: #d4570f; }
.kpi-ico.tone-green { background: var(--good-bg); color: var(--good); }
.kpi-ico.tone-ai { background: #f0eafb; color: #6a3fc0; }
.masthead + .block > h2:first-child .h-ico { background: rgba(255, 255, 255, .12); color: #fff; }

/* Favicon du client */
.client-title { display: flex; align-items: center; gap: .9rem; }
.client-icon {
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: clamp(44px, 4.4vw, 56px); height: clamp(44px, 4.4vw, 56px); border-radius: 14px; background: #fff;
  box-shadow: 0 6px 18px -6px rgba(0, 0, 0, .45);
}
.client-icon img { width: 66%; height: 66%; object-fit: contain; border-radius: 4px; }
.client-cell { display: inline-flex; align-items: center; gap: .55rem; }
.client-icon-sm { width: 22px; height: 22px; border-radius: 6px; object-fit: contain; background: #fff; box-shadow: 0 0 0 1px var(--border); padding: 2px; }
.masthead-site .ico { width: 13px; height: 13px; opacity: .6; }

/* ---------- Barre supérieure ---------- */
.topbar {
  background: var(--ink);
  color: var(--on-dark);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .85rem max(1.5rem, calc((100vw - 1240px) / 2 + 1.5rem));
  flex-wrap: wrap;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.brand { display: flex; align-items: center; gap: .65rem; color: inherit; text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--brand-accent); color: #fff;
}
.brand-text { font-size: .95rem; }
.brand-text strong { font-family: var(--font-display); font-weight: 700; letter-spacing: -.01em; }
.brand-text span { opacity: .62; font-weight: 400; margin-left: .15rem; }
.topnav { display: flex; align-items: center; gap: 1.25rem; font-size: .9rem; }
.topnav a, .topnav .link { color: var(--on-dark-2); text-decoration: none; transition: color .15s; white-space: nowrap; display: inline-flex; align-items: center; gap: .4rem; }
.topnav .ico { width: 17px; height: 17px; }
.topnav a:hover, .topnav .link:hover, .topnav a.current { color: #fff; }
.topnav .who { display: inline-flex; align-items: center; gap: .5rem; color: var(--on-dark-2); }
.avatar {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: rgba(255, 255, 255, .12); color: #fff; font-weight: 700; font-size: .78rem;
}
button.link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }

.container { max-width: 1240px; margin: 0 auto; padding: 1.75rem 1.5rem 2.5rem; }
.footer {
  max-width: 1240px; margin: 0 auto; padding: 1.25rem 1.5rem 2.5rem;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
  color: var(--text-secondary); font-size: .85rem; border-top: 1px solid var(--border);
}
.footer a { color: inherit; }

/* ---------- Boutons & formulaires ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-size: .9rem; font-weight: 600;
  padding: .55rem 1rem; border-radius: 10px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; line-height: 1.2; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s, transform .15s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand-accent); color: #fff; }
.btn-primary:hover { background: #1f58e6; }
.btn-ghost { background: var(--surface-1); color: var(--ink); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--border-strong); background: var(--surface-2); }
.btn-danger { background: var(--surface-1); color: var(--bad); border-color: #f2c9c6; }
.btn-danger:hover { background: var(--bad-bg); }
.btn-on-dark { background: rgba(255, 255, 255, .08); color: #fff; border-color: rgba(255, 255, 255, .16); }
.btn-on-dark:hover { background: rgba(255, 255, 255, .15); }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; border-radius: 8px; }
.btn-block { width: 100%; }
summary.btn { list-style: none; }
summary.btn::-webkit-details-marker { display: none; }

.form { display: grid; gap: 1rem; }
.form label { display: grid; gap: .35rem; font-size: .88rem; font-weight: 600; color: var(--ink); }
input, select, textarea {
  font: inherit; font-size: .95rem; font-weight: 400; color: var(--text-primary);
  padding: .6rem .75rem; border: 1px solid var(--border-strong); border-radius: 10px; background: #fff; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: #b5bfd3; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-accent); box-shadow: 0 0 0 3px rgba(47, 107, 255, .18); }
.form-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-items: end; margin-top: 1rem; }
.check, .form label.check { display: flex; align-items: center; gap: .55rem; font-weight: 400 !important; color: var(--text-primary) !important; font-size: .9rem; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand-accent); }

.alert { padding: .85rem 1.1rem; border-radius: var(--radius); margin-bottom: 1.25rem; font-size: .92rem; border: 1px solid transparent; }
.alert ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.alert-success { background: var(--good-bg); color: #075c38; border-color: #bfe6d2; }
.alert-error { background: var(--bad-bg); color: #8f201b; border-color: #f4c9c5; }
.alert-info { background: #eaf0ff; color: #1c3f9e; border-color: #cddafc; }
.badge {
  display: inline-block; font-size: .75rem; font-weight: 600;
  padding: .15rem .6rem; border-radius: 99px; background: #eaf0ff; color: #1c3f9e; margin-left: .4rem; vertical-align: 1px;
}

/* ---------- Connexion & installation ---------- */
body.page-login {
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(47, 107, 255, .35), transparent 60%),
    radial-gradient(700px 500px at -10% 110%, rgba(37, 125, 224, .22), transparent 60%),
    var(--ink);
}
.page-login .container { min-height: 86vh; display: grid; place-items: center; }
.page-login .footer { border-top-color: rgba(255, 255, 255, .1); color: var(--on-dark-2); }
.login-card {
  width: 100%; max-width: 420px; background: var(--surface-1); border-radius: 20px;
  padding: 2.4rem 2.2rem; box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .55);
}
.login-card .brand { color: var(--ink); margin-bottom: 1.75rem; }
.login-card h1 { font-size: 1.6rem; }
.login-card > .muted { margin-top: 0; }
.install-card { max-width: 480px; }
.checks { list-style: none; padding: 0; margin: 0 0 1.25rem; display: grid; gap: .1rem; font-size: .85rem; }
.checks .ok { color: var(--good); }
.checks .warn { color: #a15c00; }

/* ---------- Bandeau client ---------- */
.masthead {
  margin: -1.75rem calc(50% - 50vw) 0;
  background:
    radial-gradient(800px 380px at 92% -20%, rgba(47, 107, 255, .32), transparent 65%),
    var(--ink);
  color: var(--on-dark);
  padding: 2.25rem 0 4.75rem;
}
.masthead:has(+ .block > h2:first-child) { padding-bottom: 7.25rem; }
.masthead-inner { max-width: 1240px; margin: 0 auto; padding: 0 1.5rem; }
.masthead-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 1.25rem 2rem; flex-wrap: wrap; }
.masthead h1 {
  color: #fff; font-size: clamp(2rem, 4.2vw, 3.1rem); font-weight: 700; font-stretch: 92%;
  letter-spacing: -.03em; line-height: 1.02; margin: 0 0 .6rem;
}
.masthead-period { margin: 0; color: var(--on-dark-2); font-size: .92rem; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .9rem; }
.masthead-site { color: #fff; text-decoration: none; font-weight: 600; display: inline-flex; align-items: center; gap: .35rem; }
.masthead-site::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #36d39a; box-shadow: 0 0 0 3px rgba(54, 211, 154, .2); }
.masthead-site:hover { text-decoration: underline; }
.masthead .badge { background: rgba(255, 255, 255, .12); color: #fff; margin: 0; }
.masthead-title { flex: 1 1 420px; min-width: 0; }
.masthead-controls { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; flex: 0 0 auto; }
.client-switch { margin-bottom: .75rem; }
.client-switch select {
  width: auto; min-width: 200px; padding: .35rem 2rem .35rem .7rem; font-size: .85rem; font-weight: 600;
  background-color: rgba(255, 255, 255, .08); color: #fff; border-color: rgba(255, 255, 255, .18);
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='white' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center;
}
.client-switch select option { color: var(--text-primary); }
.masthead-bottom { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-top: 1.75rem; }

/* Sélecteur de période */
.btn-icon { padding: .55rem .65rem; }
.daterange { position: relative; }
.daterange > summary { list-style: none; }
.daterange > summary::-webkit-details-marker { display: none; }
.daterange-trigger { gap: .55rem; }
.daterange[open] .daterange-trigger { background: rgba(255, 255, 255, .18); }
.daterange-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30;
  display: grid; grid-template-columns: 190px auto; background: var(--surface-1); color: var(--text-primary);
  border-radius: var(--radius-lg); box-shadow: 0 24px 60px -18px rgba(15, 31, 69, .45), 0 0 0 1px rgba(15, 31, 69, .06);
  overflow: hidden; animation: pop .16s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.daterange-presets { display: flex; flex-direction: column; padding: .6rem; background: var(--surface-2); border-right: 1px solid var(--border); gap: 1px; }
.daterange-presets a {
  padding: .45rem .7rem; border-radius: 8px; color: var(--text-primary); text-decoration: none; font-size: .86rem; font-weight: 500;
}
.daterange-presets a:hover { background: #e9eef9; }
.daterange-presets a.active { background: var(--ink); color: #fff; font-weight: 600; }
.daterange-form { padding: 1rem 1.2rem 1rem; display: grid; gap: .8rem; min-width: 300px; }
.daterange.is-enhanced .daterange-form { width: 540px; }
.daterange-calendar { position: relative; }
.daterange:not(.is-enhanced) .daterange-calendar { display: none; }
.cal-nav { position: absolute; inset: 0 0 auto 0; display: flex; justify-content: space-between; pointer-events: none; }
.cal-nav button {
  pointer-events: auto; width: 30px; height: 30px; border-radius: 8px; border: 0; background: none; font-size: 1.25rem; line-height: 1;
  color: var(--ink); cursor: pointer;
}
.cal-nav button:hover { background: var(--surface-2); }
.cal-nav button:disabled { opacity: .25; cursor: default; }
.cal-months { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.cal-title { text-align: center; font-family: var(--font-display); font-weight: 650; color: var(--ink); text-transform: capitalize; line-height: 30px; margin-bottom: .35rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 34px); gap: 2px 0; }
.cal-wd { text-align: center; font-size: .72rem; font-weight: 600; color: var(--text-secondary); padding-bottom: .25rem; }
.cal-day {
  height: 34px; border: 0; background: none; font: inherit; font-size: .85rem; font-variant-numeric: tabular-nums; color: var(--text-primary);
  cursor: pointer; border-radius: 0;
}
.cal-day:hover:not(:disabled) { background: #e9eef9; border-radius: 8px; }
.cal-day:disabled { color: #c2c8d6; cursor: not-allowed; }
.cal-day.is-today { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.cal-day.in-range { background: #e6edff; }
.cal-day.is-start, .cal-day.is-end { background: var(--brand-accent); color: #fff; font-weight: 700; }
.cal-day.is-start { border-radius: 8px 0 0 8px; }
.cal-day.is-end { border-radius: 0 8px 8px 0; }
.cal-day.is-start.is-end { border-radius: 8px; }
.daterange-inputs { display: flex; gap: .6rem; }
.daterange-inputs label { display: flex; align-items: center; gap: .4rem; font-size: .82rem; font-weight: 600; color: var(--text-secondary); }
.daterange-inputs input { padding: .35rem .5rem; font-size: .85rem; width: auto; }
.daterange-summary { margin: 0; min-height: 1.2em; }
.daterange-actions { display: flex; justify-content: flex-end; gap: .5rem; }

/* Contrôles segmentés (clair par défaut, version sombre dans le bandeau) */
.segmented { display: inline-flex; background: var(--surface-1); border: 1px solid var(--border); border-radius: 11px; padding: 3px; gap: 2px; }
.segmented a, .segmented button {
  padding: .4rem .8rem; border-radius: 8px; font: inherit; font-size: .85rem; font-weight: 600; color: var(--text-secondary);
  text-decoration: none; background: none; border: 0; cursor: pointer; transition: background-color .15s, color .15s; white-space: nowrap;
}
.segmented a:hover, .segmented button:hover { color: var(--ink); }
.segmented a.active, .segmented button.active { background: var(--ink); color: #fff; }
.masthead .segmented { background: rgba(255, 255, 255, .07); border-color: rgba(255, 255, 255, .14); }
.masthead .segmented a { color: var(--on-dark-2); }
.masthead .segmented a:hover { color: #fff; }
.masthead .segmented a.active { background: #fff; color: var(--ink); }

/* Onglets dans le bandeau */
.tabs { display: flex; gap: .35rem; }
.tabs a {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .5rem 1rem; font-weight: 600; font-size: .92rem; color: var(--on-dark-2); text-decoration: none;
  border-radius: 99px; transition: background-color .15s, color .15s;
}
.tabs a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.tabs a.active { color: var(--ink); background: #fff; }
.source-switch { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; color: var(--on-dark-2); font-size: .85rem; }

/* Le contenu qui suit le bandeau vient chevaucher son bord inférieur */
.masthead + * { position: relative; margin-top: -3rem; }
.masthead + .block:has(> h2:first-child) { margin-top: -5.6rem; }
.masthead + .block > h2:first-child { color: #fff; margin-bottom: 1.1rem; }
.masthead + .block > h2:first-child .source { background: rgba(255, 255, 255, .12); color: #fff; }
.masthead + .alert { box-shadow: var(--shadow-lift); }

/* ---------- Blocs ---------- */
.block { margin-bottom: 2.5rem; }
.block > h2 { margin-top: .25rem; }
.source { font-family: var(--font); font-size: .75rem; font-weight: 600; color: var(--text-secondary); background: #e9edf6; padding: .2rem .6rem; border-radius: 99px; letter-spacing: 0; }

/* ---------- Tuiles d'indicateurs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kpi {
  position: relative; overflow: hidden;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem 1.1rem; min-height: 148px;
  display: flex; flex-direction: column;
}
.masthead + .block .kpi { box-shadow: var(--shadow-lift); border-color: transparent; }
.kpi-label { font-size: .85rem; color: var(--text-secondary); font-weight: 600; display: flex; align-items: center; gap: .4rem; position: relative; z-index: 1; }
.kpi-value {
  font-family: var(--font-display); font-size: 2.35rem; font-weight: 700; font-stretch: 88%;
  color: var(--ink); margin: .35rem 0 .7rem; white-space: nowrap; font-variant-numeric: tabular-nums; letter-spacing: -.035em; line-height: 1;
  position: relative; z-index: 1;
}
.kpi-of { font-size: 1.15rem; font-weight: 600; color: var(--text-secondary); letter-spacing: 0; }
.kpi-foot-row { display: flex; align-items: center; flex-wrap: wrap; gap: .3rem .5rem; font-size: .8rem; position: relative; z-index: 1; margin-top: auto; }
.kpi-delta {
  display: inline-flex; align-items: center; gap: .2rem; font-weight: 700; font-variant-numeric: tabular-nums;
  padding: .12rem .5rem; border-radius: 99px; font-size: .8rem;
}
.kpi-delta.good { color: var(--good); background: var(--good-bg); }
.kpi-delta.bad { color: var(--bad); background: var(--bad-bg); }
.kpi-delta.flat { color: var(--text-secondary); background: #eef1f6; }
.kpi-vs { color: var(--text-secondary); }
.kpi-sub { color: var(--text-secondary); display: flex; gap: .75rem; flex-wrap: wrap; }
.kpi-main { display: flex; align-items: flex-end; justify-content: space-between; gap: .75rem; margin: .35rem 0 .7rem; }
.kpi-main .kpi-value { margin: 0; }
.kpi-spark { flex: 0 1 46%; min-width: 70px; height: 40px; color: var(--series-1); overflow: visible; }
.kpi-spark-line { stroke-dasharray: 1; stroke-dashoffset: 0; }
.hint {
  display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%;
  background: #e9edf5; color: var(--text-secondary); font-size: .66rem; font-weight: 700; cursor: help;
}
.kpi-foot { margin: -.35rem 0 1.25rem; }

/* ---------- Panneaux, graphiques et tableaux ---------- */
.chart-card, .table-card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.15rem 1.25rem; margin: 0;
}
.chart-card figcaption { font-family: var(--font-display); font-weight: 650; color: var(--ink); font-size: 1.02rem; margin-bottom: .75rem; letter-spacing: -.01em; }
.chart-card figcaption .muted { font-family: var(--font); font-weight: 400; letter-spacing: 0; }
.table-card h3 { font-size: 1.02rem; }
.chart-wrap { position: relative; height: 230px; }
.chart-wrap.tall { height: 300px; }
.charts-2, .tables-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.block > .chart-card { margin-bottom: 1rem; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .88rem; }
th {
  text-align: left; font-size: .78rem; color: var(--text-secondary); font-weight: 600;
  padding: .55rem .6rem; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-1);
}
td { padding: .6rem; border-bottom: 1px solid var(--grid); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color .12s; }
tbody tr:hover td { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.url { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.url a { color: var(--text-primary); text-decoration: none; }
td.url a:hover { color: var(--brand-accent); text-decoration: underline; }
td.actions, th.actions { text-align: right; white-space: nowrap; }
td.actions .btn, td.actions form { margin-left: .25rem; }
.delta-good { color: var(--good); font-weight: 600; }
.delta-bad { color: var(--bad); font-weight: 600; }
.delta-flat { color: var(--text-secondary); }

.channels .bar-col { width: 30%; min-width: 90px; }
.channels .bar { display: block; height: 8px; border-radius: 99px; background: #c9dcf7; min-width: 3px; transform-origin: left; }
.channels tr.highlight td { font-weight: 600; }
.channels tr.highlight .bar { background: var(--series-1); }

.updated { margin-top: -1rem; }
.empty { text-align: center; padding: 3.5rem 1rem; background: var(--surface-1); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); }
.empty h1, .empty h2 { justify-content: center; }

/* ---------- Tri et listes dépliables ---------- */
table th.sortable { cursor: pointer; user-select: none; }
table th.sortable:hover { color: var(--ink); }
table th[aria-sort] { color: var(--ink); }
table th.sortable::after { content: " ↕"; color: #b7bfd1; font-size: .9em; }
table th[aria-sort=ascending]::after { content: " ↑"; color: var(--brand-accent); }
table th[aria-sort=descending]::after { content: " ↓"; color: var(--brand-accent); }
.list-card { display: flex; flex-direction: column; }
.list-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; margin-bottom: .6rem; }
.list-head h3 { margin: 0; }
.rank-head { margin-bottom: .9rem; }
.rank-head p { margin: .3rem 0 0; }
.list-tools { margin-bottom: .6rem; }
.list-tools input[type=search] {
  padding: .45rem .8rem .45rem 2.1rem; font-size: .88rem;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%235d6782' stroke-width='1.6'%3E%3Ccircle cx='6' cy='6' r='4.5'/%3E%3Cpath d='M9.5 9.5 13 13' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat .75rem center;
}
tr.is-extra { display: none; }
.list-card.is-expanded .list-scroll { max-height: 560px; overflow-y: auto; }
.list-card.is-expanded .list-scroll thead th { position: sticky; top: 0; z-index: 1; }
.list-foot { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: auto; padding-top: .8rem; }
.list-foot [data-list-csv] { margin-left: auto; }
[data-list-toggle] .ico { transition: transform .2s var(--ease); }
.list-card.is-expanded [data-list-toggle] .ico { transform: rotate(180deg); }

/* ---------- Suivi de positions ---------- */
.table-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-bottom: .9rem; }
.table-toolbar h3 { margin: 0 auto 0 0; }
.table-toolbar input[type=search] {
  flex: 1 1 220px; max-width: 320px; padding: .5rem .8rem .5rem 2.1rem; font-size: .9rem;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%235d6782' stroke-width='1.6'%3E%3Ccircle cx='6' cy='6' r='4.5'/%3E%3Cpath d='M9.5 9.5 13 13' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat .75rem center;
}
.table-toolbar select, .input-sm { width: auto; padding: .45rem .7rem; font-size: .88rem; }
.table-toolbar .btn:last-child { margin-left: auto; }
.rank-table thead th { position: sticky; top: 0; z-index: 1; }
.rank-table td { padding: .5rem .6rem; }
.spark-col { width: 104px; }
td.spark-col { color: var(--series-1); }
.page-positions .updated { margin-top: .75rem; }
.spark { display: block; }
.pos {
  display: inline-block; min-width: 2.6em; text-align: center; padding: .15rem .5rem; border-radius: 8px;
  font-family: var(--font-display); font-weight: 700; font-variant-numeric: tabular-nums;
}
.pos-top3 { background: var(--rank-1); color: #fff; }
.pos-top10 { background: #dbe8fb; color: var(--rank-1); }
.pos-top20 { background: #eef2f8; color: var(--text-primary); }
.pos-beyond { color: var(--text-secondary); font-weight: 600; }
.tag {
  display: inline-block; font-size: .74rem; font-weight: 600; padding: .1rem .5rem; border-radius: 99px;
  background: #eef1f6; color: var(--text-secondary); margin-left: .35rem; vertical-align: 1px; white-space: nowrap;
}
.tag-good { background: var(--good-bg); color: var(--good); margin: 0; }
.tag-bad { background: var(--bad-bg); color: var(--bad); margin: 0; }
.tag-ai { background: #f0eafb; color: #5b35a8; margin: 0 .35rem 0 0; }
.tag-ai::before { content: "✦ "; }
.rank-table td.num .tag { vertical-align: 1px; }
.manage-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; align-items: start; }
.manage-grid h3 { margin: 0; }
.suggestions { display: grid; gap: .1rem; max-height: 290px; overflow: auto; border: 1px solid var(--grid); border-radius: 10px; padding: .4rem .7rem; }
.suggestions .check { display: grid; grid-template-columns: auto 1fr auto; padding: .25rem 0; }
.kw-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .35rem 1rem; max-height: 320px; overflow: auto; }

.semrush-import { margin-bottom: 1rem; }
.semrush-import h3 { margin: 0; }
.semrush-import p { margin: 0; }
.import-row { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; }
.import-row input[type=file] { width: auto; flex: 1 1 260px; padding: .45rem; border-style: dashed; background: var(--surface-2); }
table.imports { margin-top: 1rem; font-size: .82rem; }

/* ---------- Évolution de la position moyenne ---------- */
.trend-card { margin-bottom: 1rem; }
.trend-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.trend-head figcaption { margin: 0; }
.trend-toggles { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.trend-toggles legend { float: left; padding: 0; margin-right: .35rem; }
.trend-toggles .check {
  font-size: .82rem !important; font-weight: 600 !important; padding: .3rem .7rem .3rem .55rem; border: 1px solid var(--border);
  border-radius: 99px; transition: background-color .15s, border-color .15s, color .15s;
}
.trend-toggles .check:hover { border-color: var(--border-strong); }
.trend-toggles .check:has(input:checked) { background: #fff1e8; border-color: #f8c6a7; color: #9a3f0b !important; }
.trend-toggles .check input { accent-color: var(--series-2); }
.trend-panel + .trend-panel { border-top: 1px dashed var(--border); margin-top: .6rem; padding-top: .45rem; }
.trend-label { margin: 0 0 .15rem; font-size: .84rem; font-weight: 700; color: var(--ink); }
.chart-wrap.trend-sub { height: 110px; }
.trend-note { margin: .75rem 0 0; }

/* ---------- Tableaux de bord actifs / à paramétrer ---------- */
.tabs a.is-off { opacity: .7; }
.tab-off { font-size: .7rem; font-weight: 600; padding: .05rem .45rem; border-radius: 99px; background: rgba(255, 255, 255, .12); margin-left: .15rem; }
.tabs a.active .tab-off { background: var(--warn-bg); color: #a15c00; }
.alert-setup { margin-top: 0; }
.feature-chips { white-space: nowrap; }
.chip { display: inline-block; font-size: .72rem; font-weight: 600; padding: .12rem .5rem; border-radius: 99px; margin: 0 .2rem .2rem 0; }
.chip-on { background: var(--good-bg); color: var(--good); }
.chip-off { background: #eef1f6; color: #8a93a8; text-decoration: line-through; }

/* ---------- Google Ads ---------- */
.kpis-secondary .kpi { min-height: 0; padding: .9rem 1.1rem; }
.kpis-secondary .kpi-value { font-size: 1.65rem; }
.masthead + .block .kpis-secondary .kpi { box-shadow: none; border-color: var(--border); animation: none; }
.status { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-good { color: var(--good); }
.status-muted { color: var(--text-secondary); }
.status-bad { color: var(--bad); }
.qs { display: inline-grid; place-items: center; min-width: 1.9em; height: 1.9em; border-radius: 50%; font-weight: 700; font-variant-numeric: tabular-nums; font-size: .82rem; }
.qs-good { background: var(--good-bg); color: var(--good); }
.qs-mid { background: var(--warn-bg); color: #a15c00; }
.qs-bad { background: var(--bad-bg); color: var(--bad); }
.tag-warn { background: var(--warn-bg); color: #a15c00; }
.stack { display: grid; gap: 1rem; }
.stack .list-card td .muted.small { white-space: nowrap; }
.page-ads .list-card td .kw { font-weight: 600; }

/* ---------- Fiche mot-clé (panneau latéral) ---------- */
.kw-link {
  background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--ink);
  cursor: pointer; text-align: left; text-decoration: underline; text-decoration-color: var(--border-strong);
  text-underline-offset: 4px; text-decoration-thickness: 1px; transition: color .15s, text-decoration-color .15s;
}
.kw-link:hover { color: var(--brand-accent); text-decoration-color: currentColor; }
.kw-link:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; border-radius: 3px; }
body.drawer-open { overflow: hidden; }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(15, 31, 69, .42); backdrop-filter: blur(2px); opacity: 0; transition: opacity .25s; z-index: 40; }
.drawer-backdrop.open { opacity: 1; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(660px, 100vw); background: var(--surface-0);
  box-shadow: -24px 0 60px -20px rgba(15, 31, 69, .35); z-index: 50; display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .32s var(--ease);
}
.drawer.open { transform: none; }
.drawer[hidden], .drawer-backdrop[hidden] { display: none; }
.drawer-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: 1.3rem 1.5rem 1.2rem;
  background: var(--ink); color: #fff;
}
.drawer-head h2 { margin: .1rem 0 .45rem; font-size: 1.55rem; color: #fff; font-weight: 700; font-stretch: 92%; letter-spacing: -.025em; }
.drawer-kicker .ico { width: 14px; height: 14px; }
.drawer-kicker { margin: 0; font-size: .8rem; font-weight: 600; color: var(--on-dark-2) !important; }
.drawer-meta { margin: 0; font-size: .85rem; color: var(--on-dark-2); }
.drawer-meta strong { color: #fff; }
.drawer-meta .tag { margin-left: 0; background: rgba(255, 255, 255, .12); color: #fff; }
.drawer-close {
  background: rgba(255, 255, 255, .08); border: 0; width: 36px; height: 36px; border-radius: 50%;
  font-size: 1.35rem; line-height: 1; color: #fff; cursor: pointer; flex-shrink: 0; transition: background-color .15s;
}
.drawer-close:hover { background: rgba(255, 255, 255, .18); }
.drawer-body { overflow-y: auto; overflow-x: hidden; padding: 1.2rem 1.5rem 2rem; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-content: start; }
.drawer-toolbar { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.kw-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.kw-kpi { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; }
.kw-kpi-value { font-family: var(--font-display); font-size: 1.75rem; font-weight: 700; font-stretch: 90%; color: var(--ink); font-variant-numeric: tabular-nums; margin: .15rem 0 .2rem; letter-spacing: -.03em; line-height: 1.05; }
.kw-kpi-of { font-size: .95rem; color: var(--text-secondary); font-weight: 600; letter-spacing: 0; }
.kw-kpi .kpi-delta { padding: 0; background: none; font-weight: 600; }
.chart-card.flat { box-shadow: none; }
.chart-card p.small { margin: .5rem 0 0; }
.chart-wrap.short { height: 140px; }
#kw-details h3 { margin: .5rem 0 .5rem; }
#kw-details table { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
#kw-details td.url { max-width: 300px; }
.type-chips .tag { margin: 0 .3rem .35rem 0; font-size: .8rem; padding: .2rem .6rem; }

/* ---------- Administration ---------- */
.page-admin h1 { margin-bottom: 1.5rem; font-size: 2rem; letter-spacing: -.025em; }
.page-admin .block > .table-card, .page-admin .block > p, .page-admin .block > ul { max-width: 100%; }
.copy-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.add-panel { margin-top: 1rem; }
.add-panel > form, .inline-details > form { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; margin-top: .6rem; }
.inline-details { display: inline-block; text-align: left; }
.inline-details[open] { display: block; margin-top: .5rem; }
.inline-details[open] > form + form { border: 0; padding: .5rem 0 0; background: none; }

/* ---------- Animation d'entrée (un seul moment, au chargement) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .js .masthead h1, .js .masthead-period { animation: rise .6s var(--ease) both; }
  .js .masthead-period { animation-delay: .06s; }
  .js .masthead + .block .kpi { animation: rise .6s var(--ease) both; }
  .js .masthead + .block .kpi:nth-child(2) { animation-delay: .06s; }
  .js .masthead + .block .kpi:nth-child(3) { animation-delay: .12s; }
  .js .masthead + .block .kpi:nth-child(4) { animation-delay: .18s; }
  .js .kpi-spark-line { animation: draw 1.1s .25s var(--ease) both; }
  .js .channels .bar { animation: grow .8s .2s var(--ease) both; }
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .charts-2, .tables-2, .manage-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .container { padding: 1.25rem 1rem 2rem; }
  .masthead { margin-top: -1.25rem; padding: 1.5rem 0 4.25rem; }
  .masthead:has(+ .block > h2:first-child) { padding-bottom: 6.75rem; }
  .masthead-controls { flex: 1 1 100%; }
  .daterange-panel { position: fixed; left: .75rem; right: .75rem; top: 4.5rem; grid-template-columns: 1fr; max-height: calc(100vh - 6rem); overflow-y: auto; }
  .daterange-presets { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--border); }
  .cal-months { grid-template-columns: 1fr; }
  .cal-month + .cal-month { display: none; }
  .cal-grid { grid-template-columns: repeat(7, 1fr); }
  .daterange.is-enhanced .daterange-form { width: auto; }
  .masthead-inner { padding: 0 1rem; }
  .masthead-controls { width: 100%; }
  .masthead-bottom { margin-top: 1.25rem; }
  .kpis { gap: .7rem; }
  .kpi { padding: .9rem .95rem 1rem; min-height: 132px; }
  .kpi-value { font-size: 1.8rem; }
  .kpi-main { flex-direction: column; align-items: stretch; gap: .45rem; }
  .kpi-spark { flex: 0 0 auto; width: 100%; height: 28px; }
  .topnav { gap: .9rem; font-size: .85rem; }
  .kpi-vs { display: none; }
  .topnav .who-name, .logout-label { display: none; }
  .topnav a { font-size: 0; gap: 0; }
  .topnav a .ico { font-size: 15px; }
  .topbar { padding: .75rem 1rem; }
  .drawer-head, .drawer-body { padding-left: 1rem; padding-right: 1rem; }
  .kw-kpi-value { font-size: 1.35rem; }
}

/* ---------- Impression / PDF ---------- */
@media print {
  table th.sortable::after { content: none; }
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 11.5px; }
  .topbar, .no-print, .footer form, .hint, .drawer, .drawer-backdrop { display: none !important; }
  .container { padding: 0; max-width: none; }
  .masthead, .masthead:has(+ .block > h2:first-child) { margin: 0 0 1rem; padding: 0 0 .75rem; background: none; color: var(--ink); border-bottom: 2px solid var(--ink); }
  .masthead h1 { color: var(--ink); font-size: 26px; }
  .masthead-period, .masthead-site { color: var(--text-secondary); }
  .masthead-bottom { margin-top: 0; }
  .masthead .badge { background: #eef1f6; color: var(--text-secondary); }
  .masthead + .block > h2:first-child .source { background: #eef1f6; color: var(--text-secondary); }
  .chart-wrap { width: 100% !important; }
  canvas { max-width: 100% !important; }
  .table-card { break-inside: auto; }
  tr { break-inside: avoid; }
  .masthead + *, .masthead + .block:has(> h2:first-child) { margin-top: 0; }
  .masthead + .block > h2:first-child { color: var(--ink); }
  .masthead + .block > h2:first-child .h-ico { background: #eaf0ff; color: var(--brand-accent); }
  .client-icon { box-shadow: 0 0 0 1px var(--border); }
  .kpi, .chart-card, .table-card { box-shadow: none !important; border-color: var(--border) !important; }
  .kpi, .chart-card { break-inside: avoid; }
  .kpi { min-height: 0; }
  .block { break-inside: auto; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .charts-2, .tables-2 { grid-template-columns: 1fr 1fr; }
}

/* Ligne Total */
tfoot .total-row > * { border-top: 2px solid var(--border-strong); background: #f4f6fb; font-weight: 600; padding-top: .6rem; padding-bottom: .6rem; white-space: nowrap; }
tfoot .total-row th { text-align: left; font-weight: 700; }
tfoot .total-row .total-count { font-weight: 500; color: var(--text-secondary); font-size: .85em; margin-left: .35rem; }
tfoot .total-row td.num { font-variant-numeric: tabular-nums; }
.list-card.is-expanded tfoot .total-row > *, .rank-table tfoot .total-row > * { position: sticky; bottom: 0; z-index: 1; }
@media print { tfoot .total-row > * { position: static; background: #f4f6fb; } }

/* Listes : sélecteur de densité et vue compacte */
.list-meta { display: inline-flex; align-items: center; gap: .6rem; }
.density { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 2px; background: #fff; }
.density button { border: 0; background: transparent; font: inherit; font-size: .75rem; font-weight: 600; color: var(--text-secondary);
  padding: .2rem .65rem; border-radius: 999px; cursor: pointer; }
.density button[aria-pressed="true"] { background: var(--brand-accent); color: #fff; }
.density button:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; }
.list-card .sub { display: block; margin-top: .1rem; }
.list-card .kw-tags { display: inline-flex; gap: .25rem; vertical-align: 1px; margin-left: .35rem; }
.list-card .kw-tags .tag, .list-card .kw-tags .qs { margin: 0; }
.list-card .qs-mini { display: inline-grid; place-items: center; min-width: 1.6em; height: 1.6em; border-radius: 50%; font-size: .7rem; font-weight: 700; }
.list-card.is-compact table { font-size: .8rem; }
.list-card.is-compact th, .list-card.is-compact td { padding: .32rem .5rem; white-space: nowrap; }
.list-card.is-compact thead th { font-size: .72rem; }
.list-card.is-compact .sub { display: none; }
.list-card.is-compact .status-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.list-card.is-compact .status::before { width: 8px; height: 8px; }
.list-card.is-compact .kw { display: inline-block; max-width: 30ch; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.list-card.is-compact .tag { font-size: .66rem; padding: .05rem .35rem; }
.list-card.is-compact tbody td:first-child, .list-card.is-compact tfoot .total-row > :first-child { position: sticky; left: 0; background: var(--surface-1); z-index: 1; }
.list-card.is-compact tfoot .total-row > :first-child { background: #f4f6fb; }

/* Tableau large (campagnes) : pas de retour à la ligne, première colonne fixe au défilement horizontal */
table.wide-table th, table.wide-table td { white-space: nowrap; }
table.wide-table tbody td:first-child, table.wide-table tfoot .total-row > :first-child, table.wide-table thead th:first-child { position: sticky; left: 0; z-index: 2; }
table.wide-table tbody td:first-child, table.wide-table thead th:first-child { background: var(--surface-1); }
table.wide-table tfoot .total-row > :first-child { background: #f4f6fb; }
table.wide-table tbody td:first-child, .list-card.is-compact tbody td:first-child { box-shadow: inset -1px 0 0 var(--grid); }

/* Rôles et associations agence ↔ clients */
.role-badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: .12rem .5rem; border-radius: 999px; white-space: nowrap; }
.role-admin { background: #1b2a55; color: #fff; }
.role-agency { background: #e7efff; color: #1f4fd1; }
.role-client { background: var(--surface-2); color: var(--text-secondary); border: 1px solid var(--border); }
.topnav .role-badge { margin-right: -.3rem; }
.topnav .role-admin { background: rgba(255,255,255,.16); }
.topnav .role-agency, .topnav .role-client { background: rgba(255,255,255,.12); color: #fff; border: 0; }
.agency-card { margin-bottom: 1rem; scroll-margin-top: 1rem; }
.agency-card:target { outline: 2px solid var(--brand-accent); outline-offset: 2px; }
.agency-matrix th.center, .agency-matrix td.center { text-align: center; }
.agency-matrix .check-cell { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; }
.agency-matrix input[type=checkbox] { width: 1.05rem; height: 1.05rem; accent-color: var(--brand-accent); cursor: pointer; }
.agency-matrix tr.is-unlinked td:not(:first-child) { opacity: .45; }
.agency-matrix .tab-off { font-size: .66rem; background: var(--warn-bg); color: #a15c00; }

/* Journal d'activité */
.activity-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem; align-items: end; padding: 1rem 1.2rem; margin-bottom: 1rem; }
.activity-filters label { margin: 0; }
.activity-filter-actions { display: flex; gap: .5rem; }
.activity-kpis { margin-bottom: 1.2rem; }
.activity-table td { vertical-align: top; }
.activity-table td.activity-details { white-space: normal; max-width: 42ch; color: var(--text-secondary); font-size: .85rem; }
.activity-table .role-badge { margin-left: .3rem; }
.tag-info { background: #e7efff; color: #1f4fd1; }
.tag-admin { background: #ece8fb; color: #5b3cc4; }
.tag-bad { background: var(--bad-bg); color: var(--bad); }
tr.edit-row > td { background: var(--surface-2); padding: 1rem 1.2rem 1.2rem; }
.account-edit h3 { margin: 0 0 .7rem; font-size: 1rem; }
.account-form { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); align-items: end; background: transparent; border: 0; padding: 0; }
.account-edit .field-note { grid-column: 1 / -1; margin: 0; }
.account-edit .form-actions { display: flex; align-items: end; gap: .5rem; }
.account-edit form + form { margin-top: .9rem; padding-top: .9rem; border-top: 1px solid var(--border); }
label.client-field[hidden] { display: none; }

/* Administration : sources connectées d'un client, sur trois lignes */
td.sources .source-line { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: .5rem; line-height: 1.5; }
td.sources .source-name { color: var(--text-secondary); white-space: nowrap; }
td.sources .source-val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 22ch; font-variant-numeric: tabular-nums; }
.page-admin td.actions { white-space: nowrap; }

/* Barre du haut : sélecteur de client et menu Administration */
.topbar-switch { margin: 0; display: inline-flex; align-items: center; position: relative; }
.topbar-switch .switch-ico { position: absolute; left: .7rem; display: inline-flex; color: var(--on-dark-2); pointer-events: none; }
.topbar-switch .switch-ico .ico { width: 15px; height: 15px; }
.topbar-switch select { min-width: 220px; max-width: 280px; padding-left: 2.1rem; text-overflow: ellipsis; }
.topbar-switch select:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.nav-menu { position: relative; }
.nav-menu > summary { list-style: none; cursor: pointer; color: var(--on-dark-2); display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; transition: color .15s; }
.nav-menu > summary::-webkit-details-marker { display: none; }
.nav-menu > summary:hover, .nav-menu[open] > summary, .nav-menu.current > summary { color: #fff; }
.nav-menu > summary .caret { transition: transform .15s; opacity: .7; }
.nav-menu[open] > summary .caret { transform: rotate(180deg); }
.nav-menu-panel {
  position: absolute; right: 0; top: calc(100% + .7rem); z-index: 50; min-width: 230px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: .4rem;
  box-shadow: 0 12px 32px rgba(15, 31, 69, .18); display: flex; flex-direction: column;
}
.topnav .nav-menu-panel a { color: var(--text-primary); padding: .55rem .7rem; border-radius: 8px; gap: .6rem; }
.topnav .nav-menu-panel a .ico { color: var(--text-secondary); }
.topnav .nav-menu-panel a:hover, .topnav .nav-menu-panel a:focus-visible, .topnav .nav-menu-panel a.current { background: var(--surface-2); color: var(--text-primary); outline: none; }
.nav-menu-sep { height: 1px; background: var(--border); margin: .3rem .2rem; }
@media (max-width: 760px) {
  .topbar-switch { order: 3; flex: 1 1 100%; }
  .topbar-switch select { max-width: none; width: 100%; }
  .nav-menu > summary { font-size: 0; gap: 0; }
  .nav-menu > summary .caret { display: none; }
}

.topbar-left { display: flex; align-items: center; gap: 1.4rem; min-width: 0; flex-wrap: wrap; }

.topnav { gap: 1.1rem; }
.who-name { display: inline-flex; flex-direction: column; line-height: 1.15; }
.who-role { font-size: .68rem; opacity: .7; letter-spacing: .01em; }
.topbar-switch select { min-width: 200px; max-width: 240px; }
@media (max-width: 1480px) { .topbar-left .brand-text span { display: none; } }

/* Page d'accueil */
.page-home .container { padding-top: 2rem; }
.home-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.home-head h1 { margin: 0 0 .25rem; }
.home-head p { margin: 0; }
.home-client { display: flex; align-items: center; gap: 1rem; }
.home-client .client-icon img, .client-card-head .client-icon img { display: block; border-radius: 10px; }
.home-search { position: relative; display: inline-flex; align-items: center; }
.home-search .ico { position: absolute; left: .75rem; width: 16px; height: 16px; color: var(--text-secondary); }
.home-search input { padding-left: 2.2rem; min-width: 260px; }

.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.25rem; }
.client-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; display: flex; flex-direction: column;
  transition: box-shadow .2s, transform .2s; }
.client-card:hover { box-shadow: 0 10px 28px rgba(15, 31, 69, .10); }
.client-card[hidden] { display: none; }
.client-preview { display: block; aspect-ratio: 16 / 10; background: var(--surface-2); border-bottom: 1px solid var(--border); overflow: hidden; }
.client-preview img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; transition: transform .4s; }
.client-card:hover .client-preview img { transform: scale(1.02); }
.client-card-body { padding: 1rem 1.1rem 1.15rem; display: flex; flex-direction: column; gap: .9rem; flex: 1; }
.client-card-head { display: flex; align-items: center; gap: .75rem; margin-top: -2.4rem; }
.client-card-head .client-icon { background: #fff; border-radius: 12px; padding: 4px; box-shadow: 0 2px 8px rgba(15, 31, 69, .15); flex: 0 0 auto; }
.client-card-title { min-width: 0; padding-top: 1.4rem; }
.client-card-title h2 { font-size: 1.05rem; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-card-title a { display: inline-flex; align-items: center; gap: .25rem; text-decoration: none; }
.client-card-title a .ico { width: 12px; height: 12px; }
.report-links { display: grid; grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); gap: .4rem; margin-top: auto; }
.report-link { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem; padding: .7rem .35rem .6rem;
  border: 1px solid var(--border); border-radius: 10px; color: var(--text-primary); text-decoration: none; font-weight: 600; font-size: .8rem;
  text-align: center; line-height: 1.2; transition: border-color .15s, background .15s, color .15s; }
.report-link .ico { width: 20px; height: 20px; color: var(--brand-accent); }
a.report-link:hover, a.report-link:focus-visible { border-color: var(--brand-accent); background: #f4f7ff; color: var(--brand-accent); }
.report-link.is-off { color: var(--text-secondary); }
.report-link.is-off .ico { color: var(--text-secondary); }
.report-link.is-closed { color: #b4bbcb; border-style: dashed; background: transparent; cursor: not-allowed; }
.report-link.is-closed .ico { color: #c9cfdc; }
.report-dot { position: absolute; top: .45rem; right: .45rem; width: 8px; height: 8px; border-radius: 50%; background: #e09100; box-shadow: 0 0 0 2px #fff; }
.client-card-title h2 a { color: inherit; text-decoration: none; }
.client-card-title h2 a:hover { color: var(--brand-accent); }
.home-legend { display: flex; gap: 1rem; flex-wrap: wrap; margin: -.75rem 0 1.25rem; }
.home-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.home-legend .report-dot { position: static; box-shadow: none; }
.home-legend .legend-closed { width: 14px; height: 10px; border: 1px dashed #b4bbcb; border-radius: 3px; }

.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.25rem; }
.report-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 16px; padding: 1.2rem 1.3rem; display: flex; flex-direction: column; gap: .9rem; }
.report-card-head { display: flex; align-items: center; gap: .6rem; }
.report-card-head h2 { margin: 0; font-size: 1.1rem; flex: 1; }
.report-card-head .kpi-spark { width: 120px; height: 36px; flex: 0 0 auto; }
.home-metrics { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: .9rem 1.2rem; }
.home-metric dt { font-size: .8rem; color: var(--text-secondary); margin-bottom: .15rem; }
.home-metric dd { margin: 0; display: flex; align-items: baseline; gap: .45rem; flex-wrap: wrap; }
.home-metric strong { font-family: var(--font-display); font-size: 1.45rem; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.home-metric .kpi-delta { font-size: .75rem; }
.report-note { margin: -.3rem 0 0; }
.report-card-link { align-self: flex-start; margin-top: auto; display: inline-flex; align-items: center; gap: .35rem; }
.report-card-link .ico { width: 14px; height: 14px; transform: rotate(-90deg); }

/* Accueil : le favicon reste au-dessus de l'aperçu (agrandi au survol) */
.client-preview { position: relative; z-index: 0; }
.client-card-body { position: relative; z-index: 1; }
.client-card-head .client-icon { position: relative; z-index: 2; }

/* Barre des rapports : onglets + période, collée en haut de l'écran au défilement */
.report-bar-sentinel { height: 1px; margin-bottom: -1px; }
.report-bar { position: sticky; top: 0; z-index: 40; background: var(--ink); border-bottom: 1px solid rgba(255, 255, 255, .08); transition: box-shadow .2s; }
.report-bar.is-stuck { box-shadow: 0 8px 24px rgba(15, 31, 69, .28); }
.report-bar-inner { max-width: 1240px; margin: 0 auto; padding: .55rem 1.5rem; display: flex; align-items: center; gap: .75rem 1rem; flex-wrap: wrap; }
.report-bar-client { display: none; align-items: center; gap: .5rem; color: #fff; text-decoration: none; font-weight: 700; font-family: var(--font-display);
  max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: .9rem; border-right: 1px solid rgba(255, 255, 255, .14); }
.report-bar-client img { border-radius: 6px; flex: 0 0 auto; background: #fff; }
.report-bar-client span { overflow: hidden; text-overflow: ellipsis; }
.report-bar.is-stuck .report-bar-client { display: inline-flex; }
.report-tabs { flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.report-tabs::-webkit-scrollbar { display: none; }
.report-bar-controls { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-left: auto; }
.report-bar .segmented { background: rgba(255, 255, 255, .07); border-color: rgba(255, 255, 255, .14); }
.report-bar .segmented a { color: var(--on-dark-2); }
.report-bar .segmented a:hover { color: #fff; }
.report-bar .segmented a.active { background: #fff; color: var(--ink); }
.report-bar + .masthead, .report-bar-sentinel + .report-bar + .masthead { padding-top: 1.9rem; }
.masthead-top { align-items: flex-start; }
@media (max-width: 760px) {
  .report-bar-inner { padding: .5rem 1rem; }
  .report-bar-controls { margin-left: 0; width: 100%; }
}
.report-bar { margin: -1.75rem calc(50% - 50vw) 0; }
.report-bar-sentinel { margin-top: -1.75rem; margin-bottom: calc(1.75rem - 1px); }
.report-bar + .masthead { margin-top: 0; }
.report-bar-client { max-width: 150px; padding-right: .75rem; }
.report-bar.is-stuck .report-tabs a { padding-left: .8rem; padding-right: .8rem; }
@media (min-width: 1000px) {
  .report-bar-inner { flex-wrap: nowrap; }
  .report-bar-controls { flex-wrap: nowrap; flex: 0 0 auto; }
}
.report-bar-side { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; margin-left: auto; flex: 0 0 auto; }
.report-bar-side .report-bar-controls { margin-left: 0; }
.report-bar-period { margin: 0; font-size: .74rem; color: var(--on-dark-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.report-bar.is-stuck .report-bar-period { display: none; }
.print-only { display: none; }
@media print { .print-only { display: inline; } }
@media (max-width: 760px) {
  .report-bar-side { width: 100%; align-items: flex-start; margin-left: 0; }
  .report-bar-period { white-space: normal; }
}
.report-tabs { display: flex; flex-wrap: nowrap; }
.report-tabs a { white-space: nowrap; flex: 0 0 auto; }
.report-bar.is-stuck .report-tabs a .ico { display: none; }
.report-bar.is-stuck .report-tabs a { padding-left: .75rem; padding-right: .75rem; }
@media (max-width: 760px) { .report-tabs { width: 100%; } }
@media (max-width: 760px) { .report-bar { position: static; } }

/* Analyse du mois */
.analysis { background: var(--surface-1); border: 1px solid var(--border); border-radius: 16px; padding: 1.2rem 1.4rem 1rem; box-shadow: var(--shadow-lift); }
.analysis-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem 1rem; flex-wrap: wrap; margin-bottom: .9rem; }
.analysis-head h2 { margin: 0; color: var(--text-primary); }
.masthead + .analysis-block > .analysis h2 { color: var(--text-primary); }
.analysis-tools { display: flex; gap: .4rem; flex-wrap: wrap; }
.analysis-tools .btn { display: inline-flex; align-items: center; gap: .35rem; }
.analysis-tools .ico { width: 15px; height: 15px; }
.analysis-figures { display: flex; flex-wrap: wrap; gap: .6rem 1.6rem; margin: 0 0 .8rem; }
.analysis-figures dt { font-size: .76rem; color: var(--text-secondary); }
.analysis-figures dd { margin: 0; display: flex; align-items: baseline; gap: .4rem; }
.analysis-figures strong { font-family: var(--font-display); font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.analysis-figures .kpi-delta { font-size: .72rem; }
.analysis-summary { margin: 0 0 .6rem; max-width: 95ch; line-height: 1.6; }
.analysis-details > summary { cursor: pointer; color: var(--brand-accent); font-weight: 600; font-size: .85rem; list-style: none; display: inline-block; margin-bottom: .4rem; }
.analysis-details > summary::-webkit-details-marker { display: none; }
.analysis-details .when-open, .analysis-details[open] .when-closed { display: none; }
.analysis-details[open] .when-open { display: inline; }
.analysis-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin-top: .3rem; }
.analysis-col { border-radius: 12px; padding: .85rem 1rem; background: var(--surface-2); }
.analysis-col h3 { display: flex; align-items: center; gap: .4rem; font-size: .9rem; margin: 0 0 .5rem; }
.analysis-col h3 .ico { width: 16px; height: 16px; }
.analysis-col ul { margin: 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: .45rem; font-size: .88rem; line-height: 1.5; }
.analysis-good h3 { color: var(--good); }
.analysis-watch h3 { color: #a15c00; }
.analysis-actions h3 { color: var(--brand-accent); }
.analysis-note { margin: .8rem 0 0; }
.analysis-plain { position: absolute; left: -9999px; width: 1px; height: 1px; }
@media print { .analysis { box-shadow: none; break-inside: avoid; } .analysis-details > .analysis-cols { display: grid !important; } }
.analysis.is-hidden-client { border-style: dashed; box-shadow: none; }
.analysis.is-hidden-client .analysis-summary, .analysis.is-hidden-client .analysis-figures { opacity: .65; }
.analysis-toggle { margin: 0; }
.switch-btn { display: inline-flex; align-items: center; gap: .5rem; }
.switch { width: 30px; height: 18px; border-radius: 999px; background: #c9cfdc; position: relative; transition: background .15s; flex: 0 0 auto; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch-btn[aria-checked="true"] .switch { background: var(--good); }
.switch-btn[aria-checked="true"] .switch::after { transform: translateX(12px); }
.analysis-metrics { margin: .4rem 0 1rem; }
.analysis-metrics h3 { display: flex; align-items: center; gap: .4rem; font-size: .9rem; margin: 0 0 .5rem; }
.analysis-metrics h3 .ico { width: 16px; height: 16px; color: var(--brand-accent); }
.analysis-table { width: 100%; font-size: .86rem; }
.analysis-table th[scope=row] { font-weight: 600; white-space: nowrap; }
.analysis-table td, .analysis-table th { padding: .45rem .6rem; vertical-align: top; }
.analysis-table td.num { white-space: nowrap; }
.analysis-table .analysis-read { color: var(--text-secondary); min-width: 260px; }
.analysis-table .kpi-delta { font-size: .74rem; }
.kpis-single { grid-template-columns: minmax(0, 1fr) minmax(0, 3fr); align-items: center; }
.kpis-single .kpi-note { margin: 0; max-width: 60ch; }
@media (max-width: 900px) { .kpis-single { grid-template-columns: 1fr; } }

/* ===== Demandes (CRM) ===== */
.setup-card { padding: 1.4rem 1.5rem; }
.setup-card h2 { margin-top: 0; color: var(--text-primary); }
.setup-steps { margin: .8rem 0 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: .6rem; }
.setup-steps .btn, .leads-connect .btn { display: inline-flex; align-items: center; gap: .4rem; }
.setup-steps .ico, .leads-connect .ico { width: 15px; height: 15px; }
.leads-overview { grid-template-columns: 3fr 2fr; }
.channel-card { padding: 1.1rem 1.2rem; }
.channel-card h3 { display: flex; align-items: center; gap: .4rem; margin: 0 0 .9rem; font-size: 1rem; }
.channel-bars { list-style: none; margin: 0 0 .8rem; padding: 0; display: flex; flex-direction: column; gap: .55rem; }
.channel-bars li { display: grid; grid-template-columns: 10.5rem 1fr 5.5rem; align-items: center; gap: .6rem; font-size: .88rem; }
.channel-bar { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.channel-bar span { display: block; height: 100%; background: var(--series-1); border-radius: 999px; }
.channel-val { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.status-filter { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .8rem; }
.status-filter a { display: inline-flex; align-items: center; gap: .4rem; padding: .38rem .75rem; border: 1px solid var(--border); border-radius: 999px;
  text-decoration: none; color: var(--text-primary); font-weight: 600; font-size: .84rem; background: var(--surface-1); }
.status-filter a .count { font-weight: 500; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.status-filter a:hover { border-color: var(--brand-accent); }
.status-filter a.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.status-filter a.active .count { color: rgba(255, 255, 255, .7); }
.lead-row { cursor: pointer; }
.lead-row.is-new td:first-child { box-shadow: inset 3px 0 0 var(--brand-accent); }
.lead-row.is-new .kw { font-weight: 700; }
.lead-excerpt { display: inline-block; max-width: 38ch; white-space: normal; color: var(--text-secondary); font-size: .86rem; line-height: 1.4; }
.leads-table td { vertical-align: top; }
.lead-status.status-new { background: #e7efff; color: #1f4fd1; }
.lead-status.status-in_progress { background: var(--warn-bg); color: #a15c00; }
.lead-status.status-quoted { background: #ece8fb; color: #5b3cc4; }
.lead-status.status-won { background: var(--good-bg, #e3f6ec); color: var(--good); }
.lead-status.status-lost { background: var(--surface-2); color: var(--text-secondary); }
.lead-status.status-spam { background: var(--bad-bg); color: var(--bad); }
.tag[class*="channel-"] { background: var(--surface-2); color: var(--text-primary); }
.tag.channel-seo { background: #e3f6ec; color: #0b7a4b; }
.tag.channel-ads { background: #fff1e6; color: #b4530b; }
.leads-connect { padding: 1.2rem 1.3rem; }
.connect-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.4rem; }
.connect-grid h3 { margin: 0 0 .6rem; font-size: .95rem; }
.connect-grid label { display: block; margin-bottom: .35rem; }
.connect-grid input.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; width: 100%; }
.connect-grid form.inline { display: inline-block; margin-top: .5rem; }

.lead-backdrop { position: fixed; inset: 0; background: rgba(15, 31, 69, .42); backdrop-filter: blur(2px); z-index: 80; }
.lead-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100%); background: var(--surface-1); z-index: 81; display: flex; flex-direction: column;
  box-shadow: -12px 0 40px rgba(15, 31, 69, .25); outline: none; animation: lead-in .22s ease-out; }
@keyframes lead-in { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .lead-drawer { animation: none; } }
.lead-drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: 1.2rem 1.4rem .9rem; border-bottom: 1px solid var(--border); }
.lead-drawer-head h2 { margin: .15rem 0 .45rem; font-size: 1.35rem; color: var(--text-primary); }
.lead-drawer-head p { margin: 0; }
.lead-drawer-body { padding: 1.1rem 1.4rem 2rem; overflow-y: auto; }
.lead-drawer-body h3 { font-size: .95rem; margin: 1.3rem 0 .55rem; }
.lead-contact { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }
.lead-contact .btn { display: inline-flex; align-items: center; gap: .4rem; }
.lead-contact .ico { width: 15px; height: 15px; }
.lead-message { margin: .7rem 0 0; padding: .9rem 1rem; background: var(--surface-2); border-radius: 10px; line-height: 1.55; white-space: normal; }
.lead-update { margin-top: 1.1rem; padding: 1rem; border: 1px solid var(--border); border-radius: 12px; display: flex; flex-direction: column; gap: .6rem; }
.lead-update-row { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.lead-update .btn { align-self: flex-start; }
.lead-timeline { list-style: none; margin: 0; padding: 0 0 0 .9rem; border-left: 2px solid var(--border); display: flex; flex-direction: column; gap: .7rem; }
.lead-timeline li { display: flex; flex-direction: column; gap: .15rem; font-size: .88rem; position: relative; }
.lead-timeline li::before { content: ""; position: absolute; left: calc(-.9rem - 6px); top: .3rem; width: 10px; height: 10px; border-radius: 50%; background: var(--surface-1); border: 2px solid var(--brand-accent); }
.lead-timeline li.kind-status::before { border-color: #a15c00; }
.lead-fields { margin: 0; display: flex; flex-direction: column; gap: .5rem; font-size: .88rem; }
.lead-fields > div { display: grid; grid-template-columns: 9.5rem 1fr; gap: .8rem; }
.lead-fields dt { color: var(--text-secondary); }
.lead-fields dd { margin: 0; word-break: break-word; }
.lead-delete { margin-top: 1.6rem; padding-top: 1rem; border-top: 1px solid var(--border); display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
@media (max-width: 900px) { .leads-overview { grid-template-columns: 1fr; } .channel-bars li { grid-template-columns: 8rem 1fr 4.5rem; } }
@media print { .lead-drawer, .lead-backdrop { display: none; } }

/* ---------- Google Maps : grille de classement local ---------- */
:root {
  --rk-top3: #138a4f; --rk-top10: #8fd17a; --rk-top20: #f4cf4a; --rk-top50: #f08a3c; --rk-beyond: #d1423d;
}
.rank-top3 { background: var(--rk-top3); color: #fff; }
.rank-top10 { background: var(--rk-top10); color: #123a1d; }
.rank-top20 { background: var(--rk-top20); color: #4a3800; }
.rank-top50 { background: var(--rk-top50); color: #3d1a00; }
.rank-beyond { background: var(--rk-beyond); color: #fff; }
.rank-error { background: #9aa3b8; color: #fff; }

.maps-head { margin-bottom: 0; }
.maps-pickers { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.maps-pickers .segmented { background: var(--surface-1); border: 1px solid var(--border); }
.maps-pickers .segmented a { color: var(--text-secondary); }
.maps-pickers .segmented a.active { background: var(--ink); color: #fff; }
.maps-scan-pick label { display: flex; align-items: center; gap: .5rem; font-size: .9rem; color: var(--text-secondary); }
.maps-scan-pick select { padding: .35rem .6rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-1); font: inherit; color: var(--text-primary); }

.maps-report { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; align-items: start; }
.maps-map-card { padding: 1.15rem 1.25rem 1rem; }
.maps-map-card figcaption h2 { margin: 0; font-size: 1.12rem; display: flex; align-items: center; gap: .1rem; }
.maps-map-card figcaption p { margin: .2rem 0 .85rem; }
.maps-map { height: 560px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: #e8ecf3; z-index: 0; }
.maps-legend { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; list-style: none; padding: 0; margin: .8rem 0 .3rem; font-size: .85rem; color: var(--text-secondary); }
.maps-legend li, .maps-dist-list li { display: inline-flex; align-items: center; gap: .4rem; }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; flex: none; }
.maps-meta { margin: .3rem 0 0; }

.grid-pin { background: none; border: 0; }
.grid-dot {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  font: 700 .86rem/1 var(--font); font-variant-numeric: tabular-nums;
  border: 2px solid #fff; box-shadow: 0 1px 3px rgba(15, 31, 69, .35);
  transition: transform .15s var(--ease);
}
.grid-dot.is-long { font-size: .72rem; letter-spacing: -.02em; }
.grid-pin:hover .grid-dot, .grid-pin:focus .grid-dot { transform: scale(1.12); }
.grid-pin:focus { outline: none; }
.grid-pin:focus-visible .grid-dot { outline: 3px solid var(--brand-accent); outline-offset: 2px; }
.grid-biz { background: none; border: 0; filter: drop-shadow(0 2px 3px rgba(15, 31, 69, .35)); }
.grid-popup { font: .88rem/1.4 var(--font); min-width: 180px; }
.grid-popup strong { display: block; margin-bottom: .3rem; color: var(--ink); }
.grid-popup .muted { font-size: .8rem; }
.grid-popup ol { margin: .25rem 0 0; padding-left: 1.2rem; }
.grid-popup li.own { font-weight: 700; color: var(--good); }
.leaflet-container { font-family: var(--font); }

.maps-side { display: flex; flex-direction: column; gap: 1rem; }
.kpis.kpis-stack { grid-template-columns: 1fr; gap: .75rem; margin: 0; }
.maps-dist { padding: 1rem 1.1rem; }
.maps-dist h3 { margin: 0 0 .7rem; font-size: .95rem; }
.maps-dist-bar { display: flex; gap: 2px; height: 10px; border-radius: 999px; overflow: hidden; margin-bottom: .75rem; }
.maps-dist-bar span { min-width: 4px; }
.maps-dist-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; font-size: .88rem; }
.maps-dist-list strong { margin-left: auto; font-variant-numeric: tabular-nums; }

.chart-empty { margin: 2rem 0; text-align: center; }
.maps-comp tr.is-own td { background: var(--good-bg); font-weight: 600; }
#historique tr.is-current td { background: var(--surface-2); font-weight: 600; }
#historique tr[data-href] { cursor: pointer; }

.maps-settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 1rem; align-items: start; }
.maps-settings-grid h3 { margin-top: 0; }
.maps-find { display: flex; gap: .5rem; margin: .6rem 0; }
.maps-find input { flex: 1; min-width: 0; }
.maps-found { list-style: none; padding: 0; margin: .5rem 0; display: grid; gap: .5rem; }
.maps-found li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.maps-manual { margin-top: .75rem; }
.maps-manual summary { cursor: pointer; }
.maps-manual .form { margin-top: .6rem; }
.maps-manual .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.maps-kw-list { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .6rem; }
.maps-kw-list li { display: grid; grid-template-columns: minmax(140px, 1fr) auto auto; gap: .5rem .75rem; align-items: center; padding: .7rem .8rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.maps-kw-name { display: flex; flex-direction: column; }
.maps-kw-form, .maps-kw-actions { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.maps-kw-form select, .maps-kw-add select { padding: .3rem .45rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-1); font: inherit; font-size: .85rem; }
.maps-kw-add { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; padding-top: .9rem; border-top: 1px solid var(--border); }
.maps-kw-add label { display: flex; flex-direction: column; gap: .25rem; font-size: .82rem; color: var(--text-secondary); }
.maps-kw-add input { min-width: 200px; }
.btn.is-busy { opacity: .8; cursor: progress; }
.maps-provider { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .75rem; }
.maps-provider legend { font-weight: 600; margin-bottom: .5rem; }
.radio-card { display: flex !important; flex-direction: row !important; gap: .6rem; align-items: flex-start; padding: .8rem .9rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-1); cursor: pointer; font-weight: 400; }
.radio-card:has(input:checked) { border-color: var(--brand-accent); box-shadow: 0 0 0 1px var(--brand-accent); }
.radio-card input { margin-top: .2rem; }

@media (max-width: 1100px) {
  .maps-report { grid-template-columns: 1fr; }
  .kpis.kpis-stack { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .maps-settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .maps-map { height: 420px; }
  .maps-kw-list li { grid-template-columns: 1fr; }
  .grid-dot { width: 28px; height: 28px; font-size: .74rem; }
}
@media print {
  .maps-report { grid-template-columns: minmax(0, 1fr) 220px; }
  .maps-map { height: 520px; }
  .grid-dot, .dot, .maps-dist-bar span, .rank-top3, .rank-top10, .rank-top20, .rank-top50, .rank-beyond { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .leaflet-control-zoom { display: none; }
}
.grid-dot.is-center { box-shadow: 0 0 0 3px var(--ink), 0 2px 6px rgba(15, 31, 69, .45); width: 40px; height: 40px; margin: -3px; }
.maps-legend .legend-center { width: 13px; height: 13px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 2px var(--ink); background: var(--surface-2); }
.masthead .maps-pickers { margin: 0; width: 100%; }
.masthead .maps-pickers .segmented { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .16); }
.masthead .maps-pickers .segmented a { color: var(--on-dark-2); }
.masthead .maps-pickers .segmented a:hover { color: #fff; }
.masthead .maps-pickers .segmented a.active { background: #fff; color: var(--ink); }
.masthead .maps-scan-pick label { color: var(--on-dark-2); white-space: nowrap; }
.maps-kw-form select, .maps-kw-add select { width: auto; }
.maps-kw-list li { grid-template-columns: minmax(130px, 1fr) auto; }
.maps-kw-actions { grid-column: 1 / -1; justify-content: flex-end; }
@media print { .masthead .maps-pickers { display: none; } }
.report-links[style*="--n: 5"] { gap: .3rem; }
.report-links[style*="--n: 5"] .report-link { padding-inline: .1rem; font-size: .74rem; }
.radio-card input[type=radio] { width: auto; flex: none; margin: .25rem 0 0; accent-color: var(--brand-accent); }
.maps-settings .form-grid { display: grid; gap: 1rem; align-items: start; }
.maps-settings .form-grid label { display: flex; flex-direction: column; gap: .35rem; }
.maps-settings .form-grid .muted { font-weight: 400; }
.maps-tiles-error { position: absolute; left: 50%; bottom: 2.2rem; transform: translateX(-50%); z-index: 800; margin: 0; max-width: 90%;
  padding: .5rem .8rem; border-radius: var(--radius-sm); background: rgba(255, 255, 255, .95); box-shadow: var(--shadow-lift); font-size: .85rem; color: var(--text-secondary); text-align: center; }
