/* ==========================================================================
   SeoStudio — design system
   Tokens sur :root, thème sombre automatique (préférence système) ou forcé
   via [data-theme]. Aucun style inline (CSP stricte).
   ========================================================================== */

:root {
    color-scheme: light;

    /* Surfaces */
    --page: #f9f9f7;
    --surface: #fcfcfb;
    --surface-sunken: #f3f2ee;
    --surface-hover: #f0efec;
    --border: rgba(11, 11, 11, 0.10);
    --border-strong: rgba(11, 11, 11, 0.18);

    /* Texte */
    --text: #0b0b0b;
    --text-secondary: #52514e;
    --text-muted: #6f6e69;

    /* Accent (rampe bleue) */
    --accent: #256abf;
    --accent-hover: #1c5cab;
    --accent-text: #ffffff;
    --accent-soft: #e6f0fc;
    --focus: #2a78d6;

    /* Statuts (toujours accompagnés d'une icône + d'un libellé) */
    --good: #006300;
    --good-soft: #e5f3e5;
    --bad: #b42f2f;
    --bad-soft: #fbeaea;
    --warning: #8a5a00;
    --warning-soft: #fdf3dc;
    --info: #1c5cab;
    --info-soft: #e6f0fc;

    /* Graphiques */
    --series-1: #2a78d6;
    --grid: #e1e0d9;
    --baseline: #c3c2b7;
    --axis: #898781;

    /* Échelle */
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgba(11, 11, 11, 0.05), 0 1px 1px rgba(11, 11, 11, 0.03);
    --sidebar-width: 248px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --page: #0d0d0d;
        --surface: #1a1a19;
        --surface-sunken: #141413;
        --surface-hover: #242422;
        --border: rgba(255, 255, 255, 0.10);
        --border-strong: rgba(255, 255, 255, 0.18);
        --text: #f0efec;
        --text-secondary: #c3c2b7;
        --text-muted: #9a9890;
        --accent: #5598e7;
        --accent-hover: #6da7ec;
        --accent-text: #0b0b0b;
        --accent-soft: rgba(57, 135, 229, 0.16);
        --focus: #6da7ec;
        --good: #0ca30c;
        --good-soft: rgba(12, 163, 12, 0.14);
        --bad: #e66767;
        --bad-soft: rgba(230, 103, 103, 0.14);
        --warning: #fab219;
        --warning-soft: rgba(250, 178, 25, 0.12);
        --info: #6da7ec;
        --info-soft: rgba(57, 135, 229, 0.14);
        --series-1: #3987e5;
        --grid: #2c2c2a;
        --baseline: #383835;
        --axis: #898781;
        --shadow: none;
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-sunken: #141413;
    --surface-hover: #242422;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.18);
    --text: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #9a9890;
    --accent: #5598e7;
    --accent-hover: #6da7ec;
    --accent-text: #0b0b0b;
    --accent-soft: rgba(57, 135, 229, 0.16);
    --focus: #6da7ec;
    --good: #0ca30c;
    --good-soft: rgba(12, 163, 12, 0.14);
    --bad: #e66767;
    --bad-soft: rgba(230, 103, 103, 0.14);
    --warning: #fab219;
    --warning-soft: rgba(250, 178, 25, 0.12);
    --info: #6da7ec;
    --info-soft: rgba(57, 135, 229, 0.14);
    --series-1: #3987e5;
    --grid: #2c2c2a;
    --baseline: #383835;
    --axis: #898781;
    --shadow: none;
}

/* ─── Base ──────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--page);
    color: var(--text);
    font: 15px/1.55 var(--font);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .h2, .h3 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; }
h2, .h2 { font-size: 1.25rem; }
h3, .h3 { font-size: 1.05rem; }
.h3 { display: flex; align-items: center; gap: .5rem; }
p { margin: 0 0 .75rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .88em; background: var(--surface-sunken); padding: .1em .35em; border-radius: 4px; overflow-wrap: anywhere; }
strong { font-weight: 650; }

.muted { color: var(--text-secondary); }
.small { font-size: .86rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: .5rem 1rem; border-radius: var(--radius-sm); }
.skip-link:focus { left: 8px; }

.icon { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.icon-xs { width: 13px; height: 13px; vertical-align: -1px; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 26px; height: 26px; }
.icon-xl { width: 40px; height: 40px; color: var(--text-muted); }

/* ─── Layout application ────────────────────────────────────── */

.layout-app { display: flex; min-height: 100vh; }

.sidebar {
    position: sticky; top: 0;
    display: flex; flex-direction: column; gap: 1.5rem;
    width: var(--sidebar-width); height: 100vh; flex: none;
    padding: 1.25rem .9rem;
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

.brand { display: inline-flex; align-items: center; gap: .6rem; color: var(--text); font-weight: 700; font-size: 1.05rem; padding: 0 .5rem; }
.brand:hover { text-decoration: none; }
.brand-mark {
    display: grid; place-items: center;
    width: 30px; height: 30px; border-radius: 8px;
    background: var(--accent); color: var(--accent-text);
    font-weight: 800; font-size: .95rem;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
    display: flex; align-items: center; gap: .65rem;
    width: 100%; padding: .55rem .65rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary); font: inherit; font-weight: 500;
    background: none; border: 0; cursor: pointer; text-align: left;
}
.nav-link:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav-link.is-active { background: var(--accent-soft); color: var(--accent); }

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--border); padding-top: 1rem; }
.user-card { display: flex; align-items: center; gap: .65rem; padding: .35rem .65rem .75rem; }
.avatar {
    display: grid; place-items: center; width: 34px; height: 34px; flex: none;
    border-radius: 50%; background: var(--surface-sunken); border: 1px solid var(--border);
    font-size: .8rem; font-weight: 700; color: var(--text-secondary);
}
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .8rem; color: var(--text-muted); }

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.main { width: 100%; max-width: 1240px; margin: 0 auto; padding: 2rem 2.25rem 4rem; display: flex; flex-direction: column; gap: 1.25rem; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.page-header h1 { margin-bottom: .25rem; }
.page-header p { margin: 0; }
.header-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.breadcrumb { display: flex; align-items: center; gap: .35rem; font-size: .88rem; margin-bottom: .35rem !important; color: var(--text-muted); }

/* ─── Mobile ────────────────────────────────────────────────── */

@media (max-width: 880px) {
    .layout-app { display: block; }
    .sidebar {
        position: fixed; z-index: 50; left: 0; top: 0;
        transform: translateX(-100%); transition: transform .2s ease;
    }
    .sidebar.is-open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .2); }
    .topbar {
        display: flex; align-items: center; gap: .75rem;
        position: sticky; top: 0; z-index: 40;
        padding: .6rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border);
    }
    .main { padding: 1.25rem 1rem 3rem; }
    h1 { font-size: 1.35rem; }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar { transition: none; }
}

/* ─── Cartes & grilles ──────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    min-width: 0;
}
.card-flush { padding: 0; overflow: hidden; }
.card-narrow { max-width: 560px; }
.card-muted { background: var(--surface-sunken); box-shadow: none; }
.card-danger { border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.card-pad { padding: 1.25rem; margin: 0; }
.card-heading { font-size: 1rem; margin: 0; padding: 1rem 1.25rem; display: flex; align-items: center; gap: .5rem; }
.card-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-right: 1.25rem; flex-wrap: wrap; }
.card-heading-row .card-heading { padding-bottom: .25rem; }
.card-sub { margin: 0; padding: 0 1.25rem 1rem; color: var(--text-secondary); font-size: .9rem; max-width: 70ch; }

.card-link { display: flex; flex-direction: column; gap: .35rem; color: var(--text); transition: border-color .15s; }
.card-link:hover { text-decoration: none; border-color: var(--accent); }
.card-icon { color: var(--accent); }
.card-title { font-weight: 650; font-size: 1.02rem; }
.card-meta { color: var(--text-secondary); font-size: .88rem; }
.card-link .badge { align-self: flex-start; margin-top: .35rem; }

.grid { display: grid; gap: 1.25rem; }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1000px) {
    .grid-2, .grid-2-1 { grid-template-columns: minmax(0, 1fr); }
}

.callout {
    display: flex; gap: 1rem; align-items: flex-start;
    padding: 1.25rem; border-radius: var(--radius);
    background: var(--accent-soft); color: var(--text);
    border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.callout .icon-lg { color: var(--accent); }
.callout p { color: var(--text-secondary); max-width: 65ch; }

.empty-state {
    display: flex; flex-direction: column; align-items: center; text-align: center; gap: .5rem;
    padding: 3rem 1.5rem; border: 1px dashed var(--border-strong); border-radius: var(--radius);
}
.empty-state p { color: var(--text-secondary); max-width: 52ch; }

/* ─── Boutons ───────────────────────────────────────────────── */

.button {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
    min-height: 38px; padding: .45rem .95rem;
    border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
    background: var(--surface); color: var(--text);
    font: inherit; font-weight: 550; line-height: 1.2; cursor: pointer; white-space: nowrap;
}
.button:hover { background: var(--surface-hover); text-decoration: none; }
.button-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.button-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.button-danger:hover { filter: brightness(.95); background: var(--bad); }
.button-ghost-danger { border-color: transparent; color: var(--bad); background: none; }
.button-ghost-danger:hover { background: var(--bad-soft); }
.button-small { min-height: 30px; padding: .25rem .65rem; font-size: .86rem; }
.button-block { width: 100%; }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); cursor: pointer; }

/* ─── Formulaires ───────────────────────────────────────────── */

.form { display: flex; flex-direction: column; gap: 1rem; }
.form-inline { flex-direction: row; align-items: flex-end; flex-wrap: wrap; }
.form-inline .field { flex: 1 1 200px; }
.form-actions { display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; }
.inline-form { display: inline-flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

.field { display: flex; flex-direction: column; gap: .35rem; border: 0; padding: 0; margin: 0; min-width: 0; }
.field-row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
label, legend { font-weight: 550; font-size: .92rem; padding: 0; }
.field-help { margin: 0; font-size: .84rem; color: var(--text-muted); }
.field-error { margin: 0; font-size: .86rem; color: var(--bad); font-weight: 500; }

input[type="text"], input[type="email"], input[type="password"], input[type="url"], select {
    width: 100%; min-height: 40px; padding: .5rem .7rem;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); font: inherit;
}
input:focus, select:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
.inline-form select, .inline-form input { width: auto; min-width: 160px; }
.input-code { font-family: var(--mono); font-size: 1.35rem; letter-spacing: .25em; text-align: center; }
.readonly-value { margin: 0; padding: .5rem .7rem; background: var(--surface-sunken); border-radius: var(--radius-sm); }

.choice-list { display: flex; flex-direction: column; gap: .4rem; }
.choice {
    display: flex; align-items: center; gap: .65rem; padding: .65rem .8rem;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer; font-weight: 500;
}
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice span { overflow-wrap: anywhere; }

.copy-field { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.copy-field code { padding: .45rem .65rem; font-size: .92rem; }

.disclosure summary { cursor: pointer; font-weight: 550; color: var(--accent); }
.disclosure[open] summary { margin-bottom: .75rem; }
details.card > summary { color: var(--text); }

/* ─── Alertes & badges ──────────────────────────────────────── */

.alert {
    display: flex; gap: .65rem; align-items: flex-start;
    padding: .8rem 1rem; border-radius: var(--radius-sm); border: 1px solid transparent;
    overflow-wrap: anywhere;
}
.alert p { margin: 0; }
.alert .icon { margin-top: 2px; }
.alert-success { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.alert-success .icon { color: var(--good); }
.alert-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.alert-info .icon { color: var(--info); }
.alert-warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.alert-warning .icon { color: var(--warning); }
.alert-error { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.alert-error .icon { color: var(--bad); }

.badge {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .15rem .55rem; border-radius: 999px;
    font-size: .8rem; font-weight: 550; white-space: nowrap;
    background: var(--surface-sunken); color: var(--text-secondary); border: 1px solid var(--border);
}
.badge-good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge-bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }

.tone-good { color: var(--good); }
.tone-bad { color: var(--bad); }
.tone-neutral { color: var(--text-muted); }

/* ─── Tableaux & listes ─────────────────────────────────────── */

.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th {
    text-align: left; font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em;
    color: var(--text-muted); padding: .6rem 1.25rem; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: .75rem 1.25rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table td:first-child { min-width: 180px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-hover); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: right; width: 1%; white-space: nowrap; }
.table-compact td { padding: .5rem 1.25rem; }
.cell-label { max-width: 0; width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-title { display: block; font-weight: 600; color: var(--text); overflow-wrap: break-word; }
a.row-title:hover { color: var(--accent); }
.row-sub { display: block; font-size: .84rem; color: var(--text-muted); overflow-wrap: break-word; }
.delta { display: block; font-size: .8rem; font-weight: 550; }

.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 1.25rem; border-top: 1px solid var(--border); }
.card .list-item:first-child { border-top: 0; }
.list-bordered { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 1rem; }
.step-body .list { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 1rem; }

.meta-list { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1rem; margin: 0 0 1rem; }
.meta-list dt { color: var(--text-muted); }
.meta-list dd { margin: 0; overflow-wrap: anywhere; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline-item { display: grid; grid-template-columns: 150px 1fr auto; gap: 1rem; padding: .7rem 1.25rem; border-top: 1px solid var(--border); font-size: .92rem; }
.timeline-item:first-child { border-top: 0; }
.timeline-date, .timeline-ip { color: var(--text-muted); font-size: .84rem; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
    .timeline-item { grid-template-columns: 1fr; gap: .15rem; }
}

/* ─── Onglets & segments ────────────────────────────────────── */

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
    display: inline-flex; align-items: center; gap: .45rem; padding: .6rem .9rem;
    color: var(--text-secondary); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

.segmented { display: inline-flex; align-self: flex-start; padding: 3px; gap: 2px; background: var(--surface-sunken); border: 1px solid var(--border); border-radius: 8px; flex-wrap: wrap; }
.segment { padding: .35rem .8rem; border-radius: 6px; color: var(--text-secondary); font-weight: 550; font-size: .9rem; }
.segment:hover { color: var(--text); text-decoration: none; }
.segment.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ─── Étapes (connexion Google) ─────────────────────────────── */

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1rem; }
.step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.step-head { display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.step-head h2 { margin: 0; }
.step-index {
    display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 50%;
    background: var(--surface-sunken); border: 1px solid var(--border-strong); font-weight: 700; font-size: .88rem;
}
.step.is-current { border-color: var(--accent); }
.step.is-current .step-index { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.step.is-done .step-index { background: var(--good-soft); color: var(--good); border-color: transparent; }
.step.is-upcoming { opacity: .65; }
.step-body { padding-left: calc(28px + .75rem); }
.step-body p { color: var(--text-secondary); }
@media (max-width: 640px) { .step-body { padding-left: 0; } }

.howto { margin: 0 0 1rem; padding-left: 1.25rem; display: flex; flex-direction: column; gap: .35rem; }

/* ─── Indicateurs (tuiles KPI) ──────────────────────────────── */

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
@media (max-width: 1000px) { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .kpi-grid { grid-template-columns: minmax(0, 1fr); } }

.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.15rem; box-shadow: var(--shadow); }
.kpi-label { margin: 0 0 .2rem; color: var(--text-secondary); font-size: .88rem; font-weight: 550; }
.kpi-value { margin: 0; font-size: 1.9rem; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; }
.kpi-delta { margin: .3rem 0 0; display: flex; align-items: center; gap: .3rem; font-size: .86rem; font-weight: 600; flex-wrap: wrap; }
.kpi-delta-ref { color: var(--text-muted); font-weight: 400; }
.kpi-hint { margin: .5rem 0 0; font-size: .8rem; color: var(--text-muted); }

/* ─── Graphiques (SVG serveur, voir AreaChart.php) ──────────── */

.viz { margin: 0; }
.viz-title { font-weight: 600; font-size: .95rem; margin-bottom: .5rem; }
.viz-canvas { position: relative; }
.viz svg { display: block; width: 100%; height: auto; overflow: visible; }
.viz-grid { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.viz-baseline { stroke: var(--baseline); stroke-width: 1; shape-rendering: crispEdges; }
.viz-tick { fill: var(--axis); font-size: 11px; font-variant-numeric: tabular-nums; font-family: var(--font); }
.viz-area { fill: var(--series-1); fill-opacity: .1; }
.viz-line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.viz-end-label { fill: var(--text-secondary); font-size: 12px; font-weight: 600; font-family: var(--font); }
.viz-crosshair { stroke: var(--axis); stroke-width: 1; opacity: 0; pointer-events: none; }
.viz-hover-dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; opacity: 0; pointer-events: none; }
.viz.is-hovering .viz-crosshair, .viz.is-hovering .viz-hover-dot { opacity: 1; }
.viz-hit { fill: transparent; cursor: crosshair; }
.viz-tooltip {
    position: absolute; top: 0; z-index: 5; pointer-events: none;
    padding: .4rem .6rem; border-radius: var(--radius-sm);
    background: var(--text); color: var(--page); font-size: .82rem; line-height: 1.35; white-space: nowrap;
    transform: translate(-50%, -110%);
}
.viz-tooltip strong { display: block; font-size: .95rem; }

/* ─── Pages d'authentification ──────────────────────────────── */

.layout-auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 1rem; }
.auth-shell { width: 100%; max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: 1.25rem; }
.auth-brand { font-size: 1.15rem; }
.auth-card {
    width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    padding: 1.75rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 1rem;
}
.auth-card .form { margin-top: .25rem; }
.auth-card > p:last-child { margin-bottom: 0; }
.auth-footnote { font-size: .82rem; color: var(--text-muted); margin: 0; }

.qr { display: block; margin: 1rem auto; background: #fff; padding: 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.recovery-codes { list-style: none; padding: 0; margin: 1rem 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.recovery-codes code { display: block; text-align: center; padding: .5rem; font-size: 1rem; }

.error-page { text-align: center; }
.error-code { font-size: 3rem; font-weight: 800; color: var(--text-muted); margin: 0; }
.debug-trace { text-align: left; font-size: .75rem; overflow: auto; max-height: 50vh; background: var(--surface-sunken); padding: 1rem; border-radius: var(--radius-sm); }

/* ─── Contraste forcé (Windows) ─────────────────────────────── */

@media (forced-colors: active) {
    .viz-line, .viz-dot { stroke: CanvasText; }
    .viz-area { fill: Highlight; }
    .badge, .button, .kpi, .card { border: 1px solid CanvasText; }
}

/* ==========================================================================
   Mouvement & effets « tech »
   Tout est piloté par classes (posées par app.js) : compatible CSP stricte.
   Désactivé intégralement si l'utilisateur demande moins d'animations.
   ========================================================================== */

:root {
    --ease-out: cubic-bezier(.16, 1, .3, 1);
    --accent-2: #6250d6;
    --dot: rgba(11, 11, 11, 0.07);
    --glow: rgba(42, 120, 214, 0.28);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) { --accent-2: #9085e9; --dot: rgba(255, 255, 255, 0.06); --glow: rgba(57, 135, 229, 0.35); }
}
:root[data-theme="dark"] { --accent-2: #9085e9; --dot: rgba(255, 255, 255, 0.06); --glow: rgba(57, 135, 229, 0.35); }

/* Trame de points discrète, estompée vers le bas */
.layout-app .main-wrap { position: relative; }
.layout-app .main-wrap::before {
    content: ""; position: fixed; inset: 0 0 0 var(--sidebar-width); z-index: 0; pointer-events: none;
    background-image: radial-gradient(var(--dot) 1px, transparent 1.3px);
    background-size: 22px 22px;
    -webkit-mask-image: linear-gradient(to bottom, #000 0%, transparent 70%);
    mask-image: linear-gradient(to bottom, #000 0%, transparent 70%);
}
.layout-app .main, .layout-app .topbar { position: relative; z-index: 1; }
@media (max-width: 880px) { .layout-app .main-wrap::before { left: 0; } }

/* Marque : dégradé + reflet qui balaie */
.brand-mark {
    position: relative; overflow: hidden;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 6px 18px -6px var(--glow);
}
.brand-mark::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, .55) 50%, transparent 70%);
    transform: translateX(-130%);
    animation: shine 6s ease-in-out 1.2s infinite;
}
@keyframes shine { 0%, 70% { transform: translateX(-130%); } 85%, 100% { transform: translateX(130%); } }

/* Navigation : indicateur actif animé */
.nav-link { position: relative; transition: background .2s, color .2s; }
.nav-link.is-active::before {
    content: ""; position: absolute; left: -.9rem; top: 22%; bottom: 22%; width: 3px; border-radius: 0 3px 3px 0;
    background: linear-gradient(var(--accent), var(--accent-2));
    animation: grow-y .5s var(--ease-out) both;
}
@keyframes grow-y { from { transform: scaleY(0); } to { transform: scaleY(1); } }

/* Boutons */
.button { transition: background .2s, border-color .2s, box-shadow .25s, transform .15s; }
.button:active { transform: translateY(1px) scale(.99); }
.button-primary { background-image: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, var(--accent-2))); }
.button-primary:hover { box-shadow: 0 6px 20px -6px var(--glow); }
form.is-busy .button-primary .icon, form.is-busy button[type="submit"] .icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Barre de chargement de page */
.page-loader {
    position: fixed; top: 0; left: 0; z-index: 300; height: 2px; width: 0; opacity: 0; pointer-events: none;
    background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent));
    box-shadow: 0 0 10px var(--glow);
}
.is-navigating .page-loader { opacity: 1; animation: loading 10s cubic-bezier(.08, .8, .2, 1) forwards; }
@keyframes loading { 0% { width: 0; } 8% { width: 40%; } 100% { width: 94%; } }

/* Entrées en scène (au chargement) */
@keyframes rise {
    from { opacity: 0; transform: translateY(16px) scale(.985); filter: blur(4px); }
    to { opacity: 1; transform: none; filter: none; }
}
@keyframes row-in { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }

.js .main > * { animation: rise .7s var(--ease-out) both; }
.js .main > *:nth-child(2) { animation-delay: .06s; }
.js .main > *:nth-child(3) { animation-delay: .12s; }
.js .main > *:nth-child(4) { animation-delay: .18s; }
.js .main > *:nth-child(5) { animation-delay: .24s; }
.js .main > *:nth-child(6) { animation-delay: .30s; }
.js .main > *:nth-child(n+7) { animation-delay: .36s; }

.js .kpi-grid > .kpi, .js .grid-cards > *, .js .steps > .step { animation: rise .75s var(--ease-out) both; }
.js .kpi-grid > :nth-child(1), .js .grid-cards > :nth-child(1), .js .steps > :nth-child(1) { animation-delay: .15s; }
.js .kpi-grid > :nth-child(2), .js .grid-cards > :nth-child(2), .js .steps > :nth-child(2) { animation-delay: .23s; }
.js .kpi-grid > :nth-child(3), .js .grid-cards > :nth-child(3), .js .steps > :nth-child(3) { animation-delay: .31s; }
.js .kpi-grid > :nth-child(4), .js .grid-cards > :nth-child(4) { animation-delay: .39s; }
.js .grid-cards > :nth-child(n+5) { animation-delay: .45s; }

.js .table tbody tr { animation: row-in .5s var(--ease-out) both; }
.js .table tbody tr:nth-child(1) { animation-delay: .25s; }
.js .table tbody tr:nth-child(2) { animation-delay: .29s; }
.js .table tbody tr:nth-child(3) { animation-delay: .33s; }
.js .table tbody tr:nth-child(4) { animation-delay: .37s; }
.js .table tbody tr:nth-child(5) { animation-delay: .41s; }
.js .table tbody tr:nth-child(6) { animation-delay: .45s; }
.js .table tbody tr:nth-child(7) { animation-delay: .49s; }
.js .table tbody tr:nth-child(8) { animation-delay: .53s; }
.js .table tbody tr:nth-child(9) { animation-delay: .57s; }
.js .table tbody tr:nth-child(n+10) { animation-delay: .6s; }

/* Apparition au défilement (éléments hors écran au chargement) */
.js .will-reveal { animation: none !important; opacity: 0; transform: translateY(28px); filter: blur(3px); transition: opacity .8s var(--ease-out), transform .8s var(--ease-out), filter .8s var(--ease-out); }
.js .will-reveal.is-revealed { opacity: 1; transform: none; filter: none; }

/* Effet projecteur : halo qui suit la souris */
.card, .kpi, .step { position: relative; isolation: isolate; transition: border-color .25s, box-shadow .25s, transform .25s var(--ease-out); }
.card::before, .kpi::before, .step::before {
    content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
    opacity: 0; transition: opacity .35s;
    background: radial-gradient(380px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--accent) 11%, transparent), transparent 55%);
}
.card:hover::before, .kpi:hover::before, .step:hover::before { opacity: 1; }
.kpi:hover, .card-link:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 45%, transparent); box-shadow: 0 10px 30px -14px var(--glow); }

/* Compteurs */
.kpi-value { font-variant-numeric: tabular-nums; }
.kpi-value.is-done { animation: settle .45s var(--ease-out); }
@keyframes settle { 0% { text-shadow: 0 0 18px var(--glow); } 100% { text-shadow: none; } }

/* Graphiques : tracé progressif, grille qui se déploie, point « live » */
.js .viz .viz-line { transition: stroke-dashoffset 1.8s var(--ease-out); }
.js .viz .viz-area { opacity: 0; transition: opacity 1.2s ease .5s; }
.js .viz.is-drawn .viz-area { opacity: 1; }
.js .viz .viz-dot, .js .viz .viz-end-label { opacity: 0; transition: opacity .5s ease 1.4s; }
.js .viz.is-drawn .viz-dot, .js .viz.is-drawn .viz-end-label { opacity: 1; }
.js .viz .viz-grid { transform-box: fill-box; transform-origin: left center; transform: scaleX(0); transition: transform 1s var(--ease-out); }
.js .viz.is-drawn .viz-grid { transform: scaleX(1); }
.viz-pulse { fill: var(--series-1); opacity: 0; transform-box: fill-box; transform-origin: center; pointer-events: none; }
.viz.is-drawn .viz-pulse { animation: pulse 2.6s ease-out 1.8s infinite; }
@keyframes pulse { 0% { opacity: .55; transform: scale(1); } 100% { opacity: 0; transform: scale(4.5); } }
.viz-hover-dot { transition: opacity .15s; }
.viz-tooltip { box-shadow: 0 8px 24px -10px rgba(0, 0, 0, .45); }

/* Mini-courbes du tableau de bord */
.col-spark { width: 132px; }
.spark { display: block; width: 120px; height: 32px; overflow: visible; }
.spark-line { stroke-width: 1.75; }
.spark-area { fill: var(--series-1); opacity: 0; transition: opacity .9s ease .6s; }
.spark.is-drawn .spark-area { opacity: .1; }
.spark-dot { fill: var(--series-1); opacity: 0; transition: opacity .4s ease 1.3s; }
.spark.is-drawn .spark-dot { opacity: 1; }
.spark-empty { color: var(--text-muted); }
.js .spark .viz-line { transition: stroke-dashoffset 1.6s var(--ease-out); }

/* Barres de volume derrière les libellés de tableaux */
td[data-bar] { position: relative; }
td[data-bar]::before {
    content: ""; position: absolute; left: 0; top: 5px; bottom: 5px; z-index: 0;
    width: calc(var(--bar, 0) * 100%); border-radius: 0 4px 4px 0;
    background: linear-gradient(90deg, color-mix(in srgb, var(--series-1) 18%, transparent), color-mix(in srgb, var(--series-1) 5%, transparent));
    transition: width 1.2s var(--ease-out);
}
td[data-bar] > * { position: relative; z-index: 1; }

/* Points « en direct » */
.live-dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none;
    color: var(--good); background: currentColor;
    animation: live 1.8s ease-out infinite;
}
@keyframes live {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 60%, transparent); }
    70%, 100% { box-shadow: 0 0 0 8px transparent; }
}
.live-badge {
    display: inline-flex; align-items: center; gap: .4rem; margin-left: .4rem; padding: .1rem .6rem;
    border-radius: 999px; background: var(--good-soft); color: var(--good); font-size: .78rem; font-weight: 600;
}

/* Import en cours : progression en direct */
.import-progress {
    position: relative; overflow: hidden; padding: 1rem 1.25rem;
    background: var(--surface); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); border-radius: var(--radius);
    box-shadow: 0 10px 30px -18px var(--glow);
}
.import-progress .live-dot { color: var(--accent); }
.import-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .75rem; }
.import-count { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--text-secondary); font-weight: 600; }
.import-progress p { margin: .6rem 0 0; }
.import-progress.is-complete { border-color: color-mix(in srgb, var(--good) 45%, transparent); }
.import-progress.is-complete .live-dot { color: var(--good); }
.progress { height: 8px; border-radius: 999px; background: var(--surface-sunken); overflow: hidden; }
.progress-bar {
    position: relative; height: 100%; width: 0; border-radius: inherit; overflow: hidden;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    transition: width .9s var(--ease-out);
}
.progress-bar::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .5), transparent);
    transform: translateX(-100%); animation: shimmer 1.6s ease-in-out infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* Connexion : fond réseau animé + carte translucide */
.bg-network { position: fixed; inset: 0; z-index: 0; width: 100%; height: 100%; pointer-events: none; }
.layout-auth .auth-shell { position: relative; z-index: 1; }
.layout-auth .auth-card {
    background: color-mix(in srgb, var(--surface) 84%, transparent);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    box-shadow: 0 30px 80px -40px var(--glow);
}
.js .layout-auth .auth-card { animation: rise .8s var(--ease-out) .1s both; }
.js .layout-auth .auth-brand { animation: rise .8s var(--ease-out) both; }

/* Moins d'animations demandé : on coupe tout */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important;
        transition-duration: .001ms !important; transition-delay: 0s !important;
    }
    .bg-network { display: none; }
}

/* ==========================================================================
   GA4 · Vitesse · Bing
   ========================================================================== */

.badge-warn { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.tab-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.kpi-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1000px) { .kpi-grid-3 { grid-template-columns: minmax(0, 1fr); } }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.section-head p { margin: 0; max-width: 75ch; }
.list-caption { margin: 1.25rem 0 0; font-size: .86rem; font-weight: 600; color: var(--text-secondary); }

/* Barres de valeur génériques (listes) */
.bar-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.bar-list li {
    position: relative; display: flex; justify-content: space-between; align-items: center; gap: 1rem;
    padding: .45rem .65rem; border-radius: var(--radius-sm); font-size: .92rem;
}
.bar-list li > * { position: relative; z-index: 1; }
.bar-list li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-list strong { font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-list small { color: var(--text-muted); font-weight: 500; margin-left: .25rem; }
[data-bar] { position: relative; }
.bar-list li[data-bar]::before {
    content: ""; position: absolute; inset: 0 auto 0 0; z-index: 0; border-radius: inherit;
    width: calc(var(--bar, 0) * 100%);
    background: linear-gradient(90deg, color-mix(in srgb, var(--series-1) 20%, transparent), color-mix(in srgb, var(--series-1) 7%, transparent));
    transition: width 1.2s var(--ease-out);
}

/* Encart GEO : trafic venant des IA */
.card-geo {
    background:
        radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--accent-2) 14%, transparent), transparent 60%),
        var(--surface);
    border-color: color-mix(in srgb, var(--accent-2) 30%, transparent);
}
.card-geo .h3 .icon { color: var(--accent-2); }
.geo-total { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; margin: .25rem 0 1rem; }
.geo-total > span:first-child { font-size: 2.1rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.geo-unit { color: var(--text-secondary); }
.geo-total .delta { display: inline-flex; }

/* Core Web Vitals */
.vitals { display: grid; gap: .9rem; margin-top: .75rem; }
.vital { padding: .9rem 1rem; border-radius: var(--radius-sm); background: var(--surface-sunken); border: 1px solid var(--border); }
.vital-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.vital-label { font-weight: 600; font-size: .92rem; }
.vital-value { margin: .35rem 0 .5rem; font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; display: flex; align-items: baseline; gap: .6rem; }
.vital-value .delta { display: inline-flex; font-size: .82rem; }
.vital-hint { margin: .5rem 0 0; font-size: .8rem; color: var(--text-muted); }
.vital-gauge {
    position: relative; height: 6px; border-radius: 999px;
    background: linear-gradient(90deg, #0ca30c 0 33.3%, #fab219 33.3% 66.6%, #d03b3b 66.6% 100%);
    opacity: .9;
}
.vital-cursor {
    position: absolute; top: 50%; left: var(--gauge, 0%); width: 14px; height: 14px; margin: -7px 0 0 -7px;
    border-radius: 50%; background: var(--surface); border: 3px solid var(--text);
    box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
    transition: left 1.3s var(--ease-out);
}

/* Scores Lighthouse en anneau */
.scores { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin: 1rem 0; }
@media (max-width: 640px) { .scores { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.score { position: relative; display: flex; flex-direction: column; align-items: center; gap: .35rem; text-align: center; }
.score svg { width: 84px; height: 84px; transform: rotate(-90deg); }
.score-track { fill: none; stroke: var(--surface-sunken); stroke-width: 4; }
.score-fill { fill: none; stroke: var(--axis); stroke-width: 4; stroke-linecap: round; transition: stroke-dasharray 1.4s var(--ease-out); }
.score-good .score-fill { stroke: #0ca30c; }
.score-warning .score-fill { stroke: #fab219; }
.score-poor .score-fill { stroke: #d03b3b; }
.score-value { position: absolute; top: 0; left: 50%; width: 84px; height: 84px; margin-left: -42px; display: grid; place-items: center; font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.score-label { font-size: .84rem; color: var(--text-secondary); font-weight: 550; }
.score-good .score-value { color: var(--good); }
.score-poor .score-value { color: var(--bad); }

.psi-run { display: flex; flex-direction: column; }
.psi-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.psi-head p { margin: 0; }
.psi-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; margin: 0 0 1rem; }
@media (max-width: 640px) { .psi-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.psi-metrics div { padding: .6rem .75rem; background: var(--surface-sunken); border-radius: var(--radius-sm); }
.psi-metrics dt { font-size: .78rem; color: var(--text-muted); }
.psi-metrics dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.psi-subtitle { margin: .25rem 0 .5rem; font-size: .9rem; }

/* Réglages : sources de données */
.sources { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-top: .75rem; }
@media (max-width: 1100px) { .sources { grid-template-columns: minmax(0, 1fr); } }
.source { display: flex; flex-direction: column; gap: .6rem; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-sunken); min-width: 0; }
.source-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.source-name { display: inline-flex; align-items: center; gap: .45rem; font-weight: 600; }
.source p { margin: 0; overflow-wrap: anywhere; }
.source .form-inline .field { flex-basis: 100%; }

#bing .form-inline { margin-top: 1.25rem; }
#bing .inline-form { margin-top: .25rem; }
