/*
 * STYLES DE SAHELIA STATS
 * -----------------------
 * Principe : le tableau de bord se lit comme un rapport adressé au client.
 * Le bilan (grande phrase en haut) est l'élément fort ; tout le reste est
 * calme : fond gris clair, panneaux blancs, une couleur principale (indigo).
 *
 * Toutes les couleurs sont des variables (bloc :root). Le mode sombre suit
 * le réglage de l'ordinateur ou du téléphone. Polices du système : rien à charger.
 */

:root {
  color-scheme: light;
  --bg: #eef0f4;          /* fond de page, gris froid */
  --surface: #ffffff;     /* panneaux */
  --surface-2: #f6f7fa;   /* zones secondaires dans un panneau */
  --ink: #161a23;         /* texte principal */
  --muted: #586070;       /* texte secondaire (contraste 6:1) */
  --line: #dde1e8;        /* bordures */
  --grid: #edf0f4;        /* quadrillage des graphiques */
  --primary: #2f3b8f;     /* indigo : boutons, liens, courbe principale */
  --primary-ink: #ffffff; /* texte posé sur --primary */
  --primary-soft: #e8eaf6;
  --series: #3346b8;      /* courbe et barres */
  --series-2: #128079;    /* 2e série (Bing) */
  --bar: #c3c9ec;         /* barres ordinaires (la plus haute prend --series) */
  --prev: #8d94a3;        /* période précédente */
  --good: #16794a;
  --good-soft: #e3f3ea;
  --bad: #b3372d;
  --bad-soft: #fbe8e6;
  --info: #3a4a9e;
  --info-soft: #e8ebf8;
  --warn-soft: #fdf1dc;
  --warn: #855700;
  --radius: 12px;
  --radius-s: 8px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f1218;
    --surface: #171b24;
    --surface-2: #1d222d;
    --ink: #eceef3;
    --muted: #a6acb9;
    --line: #2b313e;
    --grid: #232835;
    --primary: #9aa6f5;
    --primary-ink: #10131b;
    --primary-soft: #232a4a;
    --series: #8e9cf5;
    --series-2: #45bfb5;
    --bar: #3d4785;
    --prev: #7c8291;
    --good: #5fcf92;
    --good-soft: #15291f;
    --bad: #f08c82;
    --bad-soft: #351a18;
    --info: #a9b4f7;
    --info-soft: #1e2440;
    --warn-soft: #33270e;
    --warn: #e5b45c;
  }
}

* { box-sizing: border-box; }
/* L'attribut hidden doit toujours l'emporter (sinon « label { display: grid } » l'annule). */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-underline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 1.9rem; font-weight: 700; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; font-weight: 650; margin: 2rem 0 .75rem; }
h3 { font-size: 1rem; font-weight: 600; margin: 0; }
code { font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.text-error { color: var(--bad); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.breadcrumb { margin: 0 0 .25rem; font-size: .9rem; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 1rem; top: .5rem; background: var(--surface); padding: .5rem 1rem; z-index: 10; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

/* =================== En-tête =================== */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1.5rem;
  padding: .5rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: inline-flex; align-items: center; gap: .6rem; font-family: var(--font-display); font-weight: 700; color: var(--ink); text-decoration: none; min-height: 44px; }
.brand svg { width: 28px; height: 28px; flex: none; }
.brand-mark { fill: var(--primary); }
.brand-line { fill: none; stroke: var(--primary-ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.nav { display: flex; flex-wrap: wrap; gap: .15rem; flex: 1; }
.nav a, .account a {
  color: var(--muted); text-decoration: none; padding: .45rem .7rem; border-radius: var(--radius-s);
  min-height: 44px; display: inline-flex; align-items: center;
}
.nav a:hover, .account a:hover { color: var(--ink); background: var(--surface-2); }
.nav a[aria-current] { color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.account a[aria-current] { color: var(--ink); font-weight: 600; }
.account { display: flex; align-items: center; gap: .15rem; }
.account form { margin: 0; }
.linklike {
  background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer;
  padding: .45rem .7rem; min-height: 44px; border-radius: var(--radius-s);
}
.linklike:hover { color: var(--ink); background: var(--surface-2); }

/* =================== Mise en page =================== */
.main { max-width: 1240px; margin: 0 auto; padding: 1.75rem 1.25rem 5rem; }
.narrow { max-width: 460px; margin: 2rem auto; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.5rem; margin: 1rem 0;
}
.card h2:first-child, .card h2:first-of-type { margin-top: 0; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }
.page-head p { margin: .25rem 0 0; }
.empty { color: var(--muted); padding: 1rem 0; }
.empty-state {
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 2rem; margin-top: 1.5rem; max-width: 640px;
}
.empty-state h2 { margin-top: 0; }

/* =================== Messages =================== */
.notice { padding: .8rem 1rem; border-radius: var(--radius-s); margin: 0 0 1rem; }
.notice p { margin: .25rem 0; }
.notice--ok { background: var(--good-soft); }
.notice--error { background: var(--bad-soft); }
.notice--info { background: var(--info-soft); }
.copy { display: inline-block; word-break: break-all; background: var(--surface-2); border: 1px solid var(--line); padding: .25rem .5rem; border-radius: 6px; user-select: all; }

.badge {
  display: inline-block; font-size: .8rem; padding: .1rem .55rem; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap; text-decoration: none; font-weight: 500;
}
.badge--ok { background: var(--good-soft); color: var(--good); }
.badge--error { background: var(--bad-soft); color: var(--bad); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }

.checks { list-style: none; padding: 0; }
.checks .is-ok { color: var(--good); }
.checks .is-error { color: var(--bad); font-weight: 600; }

/* =================== Formulaires =================== */
.form { display: grid; gap: 1rem; }
.form--grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-items: end; }
.form--grid h2 { grid-column: 1 / -1; margin: 0; }
label { display: grid; gap: .35rem; font-weight: 500; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-s); padding: .55rem .7rem; min-height: 44px; width: 100%;
}
textarea { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: 2px solid var(--primary-soft); outline-offset: 0; }
.inline-form { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.inline-form label { flex: 1 1 260px; }
.row-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; margin: 0; }
.row-form .grow { flex: 1 1 240px; }
.row-form input { min-width: 12rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--primary); color: var(--primary-ink); border: 1px solid var(--primary);
  border-radius: var(--radius-s); padding: .55rem 1.1rem; min-height: 44px;
}
.btn:hover { filter: brightness(1.1); }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn--ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { background: var(--surface-2); filter: none; }
.btn--danger { background: transparent; color: var(--bad); border-color: var(--line); }
.btn--danger:hover { background: var(--bad-soft); filter: none; }
.btn--small { padding: .35rem .75rem; font-size: .875rem; min-height: 38px; }
.danger-zone { margin-top: 2.5rem; }

/* =================== Tableaux =================== */
.table-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: .925rem; }
th, td { text-align: left; padding: .65rem .85rem; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { font-size: .82rem; color: var(--muted); font-weight: 600; white-space: nowrap; background: var(--surface-2); }
tbody tr:last-child > * { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.actions form { margin: 0; }

/* =================== Connexion =================== */
.auth { display: grid; place-items: center; min-height: calc(100vh - 12rem); }
.auth .card { width: 100%; max-width: 420px; padding: 2rem; }
.auth h1 { font-size: 1.6rem; }

/* =================== Liste des sites =================== */
.site-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.site-list li {
  display: grid; gap: .25rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  position: relative;
}
.site-list li:hover { border-color: var(--primary); }
.site-link { display: grid; gap: .15rem; padding: 1.1rem 1.25rem .5rem; text-decoration: none; color: var(--ink); }
.site-link::after { content: ""; position: absolute; inset: 0; } /* toute la carte est cliquable */
.site-name { font-family: var(--font-display); font-weight: 650; font-size: 1.1rem; }
.site-preview { padding: 0 1.25rem; }
.site-preview p { margin: 0; font-size: .9rem; color: var(--muted); }
.site-preview strong { font-family: var(--font-display); font-size: 1.35rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.site-preview .is-good { color: var(--good); }
.site-preview .is-bad { color: var(--bad); }
.site-meta { color: var(--muted); font-size: .85rem; display: flex; gap: .5rem; align-items: center; padding: 0 1.25rem 1rem; }
.site-meta .badge { position: relative; z-index: 1; }

/* =================== Rapport d'un site ===================
 * Une seule feuille blanche ; chaque partie est une rangée :
 * titre + explication à gauche (colonne étroite), contenu à droite,
 * séparées par un filet. */
.report-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1rem; }
.report-head h1 { margin: 0; }
.report-client { margin: 0 0 .15rem; color: var(--muted); font-weight: 500; }
.report-url { font-size: .9rem; color: var(--muted); }
.switcher label { font-size: .85rem; color: var(--muted); }
.switcher select { min-width: 16rem; }

.period { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; align-items: center; margin: 1.5rem 0 1rem; }
.segmented { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.segmented a {
  padding: .4rem 1rem; min-height: 38px; display: inline-flex; align-items: center; border-radius: 999px;
  color: var(--ink); text-decoration: none; font-size: .92rem;
}
.segmented a:hover { background: var(--surface-2); }
.segmented a[aria-current] { background: var(--primary); color: var(--primary-ink); font-weight: 600; }
.custom-period summary { cursor: pointer; color: var(--primary); min-height: 44px; display: inline-flex; align-items: center; font-size: .92rem; }
.custom-dates { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; margin-top: .25rem; }
.custom-dates label { font-size: .85rem; color: var(--muted); }
.custom-dates input { width: auto; }

.sheet {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 2.5rem 3rem 1rem;
}

/* Bilan : le chiffre principal en très grand, puis une phrase. */
.headline { padding-bottom: 2rem; }
.headline-figure { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .75rem; }
.headline-value {
  font-family: var(--font-display); font-weight: 700; letter-spacing: -0.035em; line-height: 1;
  font-size: clamp(3.25rem, 2rem + 5vw, 5.5rem); font-variant-numeric: tabular-nums;
}
.headline-unit { font-family: var(--font-display); font-size: clamp(1.3rem, 1rem + 1vw, 1.75rem); font-weight: 600; color: var(--muted); }
.headline--good .headline-value { color: var(--good); }
.headline--bad .headline-value { color: var(--bad); }
.headline-summary { margin: 1rem 0 0; max-width: 46ch; font-size: clamp(1.1rem, 1rem + .5vw, 1.35rem); line-height: 1.5; }
.headline-meta { margin: .75rem 0 0; color: var(--muted); font-size: .88rem; }

/* Chiffres clés : une rangée sobre, filets verticaux entre les valeurs. */
.kpis { display: flex; flex-wrap: wrap; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.kpi { flex: 1 1 170px; padding: 1.1rem 1.25rem 1.2rem 0; margin-right: 1.25rem; border-right: 1px solid var(--line); }
.kpi:last-child { border-right: 0; margin-right: 0; }
.kpi-label { margin: 0; font-family: var(--font); font-size: .85rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.kpi-value { margin: .2rem 0 0; font-family: var(--font-display); font-size: 1.85rem; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kpi-unit { font-size: .95rem; font-weight: 600; margin-left: .1rem; vertical-align: super; }
.kpi-delta { margin: .2rem 0 0; font-size: .82rem; color: var(--muted); }
.kpi-delta.is-good { color: var(--good); font-weight: 600; }
.kpi-delta.is-bad { color: var(--bad); font-weight: 600; }
.kpis-help { margin: .6rem 0 0; font-size: .85rem; }

.rsec { display: grid; grid-template-columns: minmax(0, 15rem) minmax(0, 1fr); gap: 1rem 3rem; padding: 2.5rem 0; border-top: 1px solid var(--line); }
.kpis-help + .rsec { margin-top: 2rem; }
.rsec-head h2 { margin: 0 0 .5rem; font-size: 1.25rem; }
.rsec-head p { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.rsec-body { min-width: 0; }
.rsec-body--split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2rem 2.5rem; align-items: start; }
.block-title { margin: 0 0 .9rem; font-size: .95rem; }
.block-note { margin: .6rem 0 0; font-size: .8rem; color: var(--muted); }

/* Ce qu'il faut retenir */
.points { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.4rem 2rem; }
.point { display: grid; grid-template-columns: 22px 1fr; gap: .75rem; align-items: start; }
.point h3 { font-size: .98rem; margin: 0 0 .2rem; }
.point p { margin: 0; font-size: .9rem; color: var(--muted); }
.point-icon { width: 22px; height: 22px; margin-top: 1px; }
.point-icon path { fill: none; stroke: var(--surface); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.point--good .point-icon circle { fill: var(--good); }
.point--bad .point-icon circle { fill: var(--bad); }
.point--info .point-icon circle { fill: var(--info); }
.todo { margin-top: 2rem; padding: 1.25rem 1.5rem; background: var(--primary-soft); border-radius: var(--radius-s); }
.todo h3 { margin: 0 0 .6rem; font-size: 1rem; }
.todo ul { margin: 0; padding-left: 1.2rem; display: grid; gap: .55rem; font-size: .93rem; }
.todo li::marker { color: var(--primary); }
.todo-note { margin: .9rem 0 0; font-size: .82rem; color: var(--muted); }

.chart-tabs { display: flex; flex-wrap: wrap; gap: .25rem; margin-bottom: .75rem; }
.chart-tabs button {
  font: inherit; font-size: .85rem; cursor: pointer; color: var(--muted);
  background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: .3rem .85rem; min-height: 36px;
}
.chart-tabs button:hover { color: var(--ink); background: var(--surface-2); }
.chart-tabs button[aria-selected="true"] { color: var(--primary-ink); background: var(--primary); border-color: var(--primary); font-weight: 600; }

/* Comment on vous trouve : trois étapes chiffrées */
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.step { padding: 0 1.5rem; border-left: 1px solid var(--line); position: relative; }
.step:first-child { padding-left: 0; border-left: 0; }
.step + .step::before {
  content: ""; position: absolute; left: -7px; top: .9rem; width: 12px; height: 12px;
  background: var(--surface); border-top: 1px solid var(--line); border-right: 1px solid var(--line); transform: rotate(45deg);
}
.step-value { margin: 0; font-family: var(--font-display); font-size: 2rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.step-label { margin: .35rem 0 0; font-size: .88rem; color: var(--muted); }
.engines { margin-top: 2rem; max-width: 30rem; }
.engines h3 { margin: 0 0 .75rem; font-size: .95rem; }

/* Mots tapés : tableau + encadré des occasions */
.opportunities { background: var(--surface-2); border-radius: var(--radius-s); padding: 1.1rem 1.25rem; }
.opportunities h3 { margin: 0 0 .35rem; font-size: 1rem; }
.opportunities > p { margin: 0 0 .9rem; font-size: .85rem; color: var(--muted); }
.opportunities ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; }
.opportunities li { display: grid; gap: .1rem; font-size: .9rem; }
.opportunities li span { font-size: .8rem; color: var(--muted); }

/* Pages les plus consultées */
.page-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem; max-width: 46rem; }
.page-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .1rem 1rem; }
.page-name { word-break: break-all; font-size: .93rem; }
.page-value { font-variant-numeric: tabular-nums; font-size: .9rem; font-weight: 600; white-space: nowrap; }
.page-list .hbar { grid-column: 1 / -1; height: 6px; margin-top: .1rem; }

/* Barres horizontales (pages, provenance, pays) */
.hbar { display: block; width: 100%; height: 8px; margin-top: .4rem; border-radius: 4px; overflow: hidden; }
.hbar-track { fill: var(--surface-2); }
.hbar-fill { fill: var(--series); }

/* Google / Bing, appareils */
.share-bar { display: block; width: 100%; height: 18px; border-radius: 5px; overflow: hidden; }
.share-bar .s1 { fill: var(--series); }
.share-bar .s2 { fill: var(--series-2); }
.share-bar .s3 { fill: var(--prev); }
.share-bar .s4 { fill: var(--bar); }
.share-legend { list-style: none; padding: 0; margin: .8rem 0 0; display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; font-size: .9rem; }
.share-legend li { display: flex; align-items: baseline; gap: .35rem; }
.share-legend li::before { content: ""; width: 10px; height: 10px; border-radius: 3px; flex: none; align-self: center; }
.share-legend .s1::before { background: var(--series); }
.share-legend .s2::before { background: var(--series-2); }
.share-legend .s3::before { background: var(--prev); }
.share-legend .s4::before { background: var(--bar); }
.share-legend strong { font-variant-numeric: tabular-nums; }

/* Listes classées (provenance, pays) */
.ranked { list-style: none; margin: 0; padding: 0; display: grid; gap: .9rem; }
.ranked-line { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; }
.ranked-label { font-weight: 550; font-size: .93rem; }
.ranked-value { font-size: .85rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ranked .hbar { height: 6px; margin-top: .3rem; }
.ranked-note { margin: .3rem 0 0; font-size: .8rem; color: var(--muted); }
.stack { display: grid; gap: 2rem; align-content: start; }

/* Tableaux de classement (mots tapés) */
.table-scroll--flat { border: 0; border-radius: 0; background: transparent; }
.rank-table th, .rank-table td { padding: .5rem .5rem; }
.rank-table th:first-child { padding-left: 0; }
.rank-table thead th { background: transparent; padding-top: 0; }
.rank-table tbody th { font-weight: 500; }

/* Barres verticales (jours, mois) */
.bars { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: .35rem; align-items: stretch; height: 180px; }
/* minmax(0, 1fr) : la zone du dessin ne peut pas dépasser la hauteur prévue. */
.bar { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; min-height: 0; text-align: center; }
.bar svg { width: 100%; max-width: 48px; height: 100%; min-height: 0; display: block; justify-self: center; overflow: hidden; }
.bar rect { fill: var(--bar); }
.bar.is-top rect { fill: var(--series); }
.bar.is-muted rect { fill: var(--grid); }
.bar-value { min-height: 1.3em; font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Le chiffre de la barre la plus haute peut déborder un peu sur les voisines. */
.bar.is-top .bar-value { position: relative; z-index: 1; margin: 0 -1rem; }
.bar.is-top .bar-value { color: var(--ink); font-weight: 600; }
.bar-label { font-size: .74rem; color: var(--muted); margin-top: .3rem; white-space: nowrap; overflow: hidden; }

/* Graphique principal (dessiné par app.js) */
.chart { margin: 0; position: relative; }
.chart-legend { display: flex; gap: 1.25rem; font-size: .82rem; color: var(--muted); margin-bottom: .25rem; }
.key::before { content: ""; display: inline-block; width: 18px; height: 0; vertical-align: middle; margin-right: .4rem; }
.key--cur::before { border-top: 2.5px solid var(--series); }
.key--prev::before { border-top: 2px dashed var(--prev); }
.chart-plot { position: relative; height: 280px; }
.chart-plot--small { height: 220px; }
.chart-plot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart-plot .axis text { fill: var(--muted); font-size: 12px; font-family: var(--font); }
.chart-plot .grid line { stroke: var(--grid); stroke-width: 1; }
.chart-plot .baseline { stroke: var(--line); }
.chart-plot .line-cur { fill: none; stroke: var(--series); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart-plot .line-prev { fill: none; stroke: var(--prev); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart-plot .cross { stroke: var(--muted); stroke-width: 1; }
.chart-plot .dot-cur { fill: var(--series); stroke: var(--surface); stroke-width: 2; }
.chart-plot .dot-prev { fill: var(--prev); stroke: var(--surface); stroke-width: 2; }
.tooltip {
  position: absolute; top: 0; pointer-events: none; z-index: 2;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: .5rem .7rem; font-size: .8rem; line-height: 1.45; white-space: nowrap;
  box-shadow: 0 4px 16px rgba(20, 26, 40, .12);
}
.tooltip strong { font-variant-numeric: tabular-nums; }

.table-view { margin-top: 1rem; }
.table-view summary { cursor: pointer; color: var(--primary); min-height: 44px; display: flex; align-items: center; font-size: .92rem; }
.table-view .table-scroll { max-height: 420px; overflow-y: auto; }

/* Détail par source (repliable) */
.source { border: 1px solid var(--line); border-radius: var(--radius-s); margin-bottom: .6rem; }
.source > summary {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem;
  padding: .8rem 1rem; cursor: pointer; min-height: 52px; list-style: none;
}
.source > summary::-webkit-details-marker { display: none; }
.source > summary::before { content: "+"; font-weight: 600; color: var(--primary); width: 1rem; }
.source[open] > summary::before { content: "\2212"; }
.source-name { font-weight: 600; flex: 1; }
.source-status { font-size: .82rem; color: var(--muted); display: flex; gap: .5rem; align-items: center; }
.source > *:not(summary) { margin-left: 1rem; margin-right: 1rem; }
.source > figure { margin-bottom: 1rem; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .5rem; margin: .25rem 0 1rem; }
.tile {
  display: grid; gap: .1rem; text-align: left; cursor: pointer; font: inherit; color: var(--ink);
  background: var(--surface-2); border: 1px solid transparent; border-radius: var(--radius-s); padding: .7rem .85rem;
}
.tile:hover { border-color: var(--line); }
.tile[aria-selected="true"] { border-color: var(--primary); background: var(--primary-soft); }
.tile-label { font-size: .82rem; color: var(--muted); }
.tile-value { font-size: 1.3rem; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile-delta { font-size: .8rem; color: var(--muted); }
.tile-delta.is-good { color: var(--good); }
.tile-delta.is-bad { color: var(--bad); }

.glossary { display: grid; grid-template-columns: minmax(9rem, max-content) 1fr; gap: .7rem 1.5rem; margin: 0; font-size: .92rem; max-width: 52rem; }
.glossary dt { font-weight: 600; }
.glossary dd { margin: 0; color: var(--muted); }

/* =================== Administration d'un site =================== */
.conn-list { display: grid; gap: .75rem; }
.conn { margin: 0; }
.conn-head { display: flex; gap: .75rem; align-items: center; }
.conn p { margin: .4rem 0; }
.conn-actions { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; margin-top: .75rem; }
.conn-actions form { margin: 0; }
.conn-actions .row-form:first-child { flex: 1 1 320px; }
.replace summary { cursor: pointer; color: var(--primary); font-size: .875rem; margin-bottom: .5rem; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* =================== Écrans moyens et petits =================== */
@media (max-width: 1000px) {
  .rsec { grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
  .sheet { padding: 2rem 2rem .5rem; }
}
@media (max-width: 760px) {
  .rsec-body--split, .points { grid-template-columns: minmax(0, 1fr); }
  .steps { grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
  .step, .step:first-child { padding: 0 0 0 1rem; border-left: 3px solid var(--primary-soft); }
  .step + .step::before { display: none; }
}

/* En-tête : nom + compte sur la 1re ligne, menu dessous (défile s'il est trop long). */
@media (max-width: 1100px) {
  .brand { flex: 1; }
  .account { order: 2; }
  .nav { order: 3; flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; margin: 0 -1.25rem; padding: 0 1rem .25rem; }
  .nav a { white-space: nowrap; }
}

@media (max-width: 600px) {
  .main { padding: 1.25rem 1rem 4rem; }
  h1 { font-size: 1.55rem; }
  .sheet { padding: 1.5rem 1.1rem .25rem; border-radius: var(--radius-s); }
  .kpi { flex: 1 1 40%; padding: .9rem .75rem .9rem 0; margin-right: .75rem; }
  .kpi:nth-child(2n) { border-right: 0; margin-right: 0; }
  .kpi-value { font-size: 1.45rem; }
  .rsec { padding: 2rem 0; }
  .glossary { grid-template-columns: 1fr; gap: .15rem; }
  .glossary dd { margin-bottom: .6rem; }
  .segmented { width: 100%; }
  .segmented a { flex: 1; justify-content: center; padding: .4rem .3rem; }
  .chart-plot { height: 230px; }
  .bars { height: 160px; gap: .25rem; }
  .bar-value { font-size: .65rem; }
  /* Graphique à 10 barres ou plus (les mois) : un nom sur deux, sinon ils se touchent. */
  .bars:has(> .bar:nth-child(10)) .bar:nth-child(even) .bar-label { visibility: hidden; }
  .switcher, .switcher select { width: 100%; min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
