/* ==========================================================================
   Fovix — design system
   ========================================================================== */

:root {
    --rv-font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --rv-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --rv-bg: #f5f7fb;
    --rv-surface: #ffffff;
    --rv-surface-2: #f8fafc;
    --rv-border: #e6e9f0;
    --rv-border-strong: #d5dae3;
    --rv-text: #0f172a;
    --rv-text-2: #334155;
    --rv-muted: #64748b;

    --rv-primary: #2563eb;
    --rv-primary-600: #1d4ed8;
    --rv-primary-700: #1e40af;
    --rv-primary-50: #eff6ff;
    --rv-success: #16a34a;
    --rv-warning: #d97706;
    --rv-danger: #dc2626;

    --rv-sidebar-bg: #0b1220;
    --rv-sidebar-w: 264px;
    --rv-topbar-h: 64px;

    --rv-radius: 12px;
    --rv-radius-sm: 8px;
    --rv-shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);
    --rv-shadow: 0 8px 24px rgba(15, 23, 42, .10);
    --rv-ring: 0 0 0 4px rgba(37, 99, 235, .14);

    /* Thème Bootstrap */
    --bs-body-font-family: var(--rv-font);
    --bs-body-font-size: .9375rem;
    --bs-body-bg: var(--rv-bg);
    --bs-body-color: var(--rv-text);
    --bs-primary: #2563eb;
    --bs-primary-rgb: 37, 99, 235;
    --bs-border-color: var(--rv-border);
    --bs-link-color: var(--rv-primary);
    --bs-link-color-rgb: 37, 99, 235;
    --bs-link-hover-color: var(--rv-primary-600);
    --bs-link-hover-color-rgb: 29, 78, 216;
    --bs-secondary-color: var(--rv-muted);
}

body {
    background: var(--rv-bg);
    -webkit-font-smoothing: antialiased;
}

code {
    color: #be185d;
    font-size: .85em;
}

.mono {
    font-family: var(--rv-mono);
    font-size: .8rem;
}

.min-w-0 {
    min-width: 0;
}

/* Éléments réservés à certaines permissions du rôle (classes perm-* posées sur <html>).
   Tant que le rôle n'est pas connu (perm-pending), tout reste visible, sauf l'administration. */
html:not(.perm-pending):not(.perm-edit) [data-perm="edit"],
html:not(.perm-pending):not(.perm-upload) [data-perm="upload"],
html:not(.perm-manage_team) [data-perm="manage_team"],
html:not(.perm-manage_subscription) [data-perm="manage_subscription"],
html:not(.perm-manage_platform) [data-perm="manage_platform"] {
    display: none !important;
}

/* ==================== Boutons ==================== */

.btn {
    --bs-btn-font-weight: 500;
    --bs-btn-font-size: .875rem;
    --bs-btn-padding-x: .95rem;
    --bs-btn-padding-y: .5rem;
    --bs-btn-border-radius: var(--rv-radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
}

.btn-sm {
    --bs-btn-padding-x: .65rem;
    --bs-btn-padding-y: .3rem;
    --bs-btn-font-size: .8rem;
}

.btn-primary {
    --bs-btn-bg: var(--rv-primary);
    --bs-btn-border-color: var(--rv-primary);
    --bs-btn-hover-bg: var(--rv-primary-600);
    --bs-btn-hover-border-color: var(--rv-primary-600);
    --bs-btn-active-bg: var(--rv-primary-700);
    --bs-btn-active-border-color: var(--rv-primary-700);
    --bs-btn-disabled-bg: var(--rv-primary);
    --bs-btn-disabled-border-color: var(--rv-primary);
    --bs-btn-focus-shadow-rgb: 37, 99, 235;
    box-shadow: 0 1px 2px rgba(37, 99, 235, .3);
}

.btn-white {
    --bs-btn-bg: #fff;
    --bs-btn-color: var(--rv-text-2);
    --bs-btn-border-color: var(--rv-border-strong);
    --bs-btn-hover-bg: var(--rv-surface-2);
    --bs-btn-hover-color: var(--rv-text);
    --bs-btn-hover-border-color: #c4cad6;
    --bs-btn-active-bg: #f1f5f9;
    --bs-btn-active-color: var(--rv-text);
    --bs-btn-active-border-color: #c4cad6;
    --bs-btn-disabled-bg: #fff;
    --bs-btn-disabled-border-color: var(--rv-border);
    --bs-btn-focus-shadow-rgb: 148, 163, 184;
    box-shadow: var(--rv-shadow-sm);
}

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
}

.btn-icon-ghost {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: var(--rv-radius-sm);
    background: transparent;
    color: var(--rv-muted);
    transition: background .15s, color .15s;
}

.btn-icon-ghost:hover,
.btn-icon-ghost[aria-expanded="true"] {
    background: #eef2f7;
    color: var(--rv-text);
}

/* ==================== Formulaires ==================== */

.form-label {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--rv-text-2);
    margin-bottom: .4rem;
}

.form-control,
.form-select {
    border-color: var(--rv-border-strong);
    border-radius: var(--rv-radius-sm);
    font-size: .875rem;
    color: var(--rv-text);
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    border-color: var(--rv-primary);
    box-shadow: var(--rv-ring);
}

.form-check-input:checked {
    background-color: var(--rv-primary);
    border-color: var(--rv-primary);
}

/* Validation (validation.js) : astérisque des champs obligatoires, champ en erreur et son message */
.form-label.required::after {
    content: " *";
    color: var(--rv-danger);
}

.form-control.is-invalid,
.form-select.is-invalid {
    border-color: var(--rv-danger);
    background-image: none;
}

.form-select.is-invalid {
    background-image: var(--bs-form-select-bg-img);
}

.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
    border-color: var(--rv-danger);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .15);
}

.commune-picker.is-invalid .form-control-auth,
.commune-picker.is-invalid .commune-modes {
    border-color: var(--rv-danger);
}

.commune-picker.is-invalid .commune-modes {
    box-shadow: inset 0 0 0 1px var(--rv-danger);
}

.role-options.is-invalid .role-option {
    border-color: var(--rv-danger);
}

.field-error {
    margin-top: .35rem;
    font-size: .8rem;
    color: var(--rv-danger);
}

.commune-picker > .field-error {
    margin: -.35rem 0 .75rem;
}

.input-icon {
    position: relative;
}

.input-icon > i {
    position: absolute;
    left: .85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--rv-muted);
    font-size: .85rem;
    pointer-events: none;
}

.input-icon .form-control,
.input-icon .form-select {
    padding-left: 2.4rem;
}

/* ==================== Layout : sidebar ==================== */

.sidebar {
    --bs-offcanvas-width: var(--rv-sidebar-w);
    --bs-offcanvas-bg: var(--rv-sidebar-bg);
    --bs-offcanvas-border-width: 0;
}

@media (min-width: 992px) {
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: var(--rv-sidebar-w);
        z-index: 1030;
    }
}

.sidebar-panel {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #0b1220 0%, #0f172a 100%);
    color: #94a3b8;
}

.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.25rem .75rem;
}

.breadcrumb-home {
    color: inherit;
    text-decoration: none;
}

.breadcrumb-home:hover {
    color: var(--rv-primary);
    text-decoration: underline;
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .35rem;
    color: #fff;
    text-decoration: none;
}

/* Logo Fovix : version claire, ou sombre (html[data-theme="dark"]) */
.brand-logo {
    display: inline-flex;
    flex-shrink: 0;
    height: 36px;
}

.brand-logo img {
    width: auto;
    height: 100%;
}

.brand-logo-dark,
html[data-theme="dark"] .brand-logo-light {
    display: none;
}

html[data-theme="dark"] .brand-logo-dark {
    display: block;
}

.brand-name {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -.01em;
    line-height: 1.15;
}

.brand-tagline {
    font-size: .72rem;
    color: #94a3b8;
}

.org-badge {
    display: flex;
    align-items: center;
    gap: .65rem;
    margin: .25rem .9rem .5rem;
    padding: .6rem .7rem;
    border: 1px solid rgba(148, 163, 184, .14);
    border-radius: 10px;
    background: rgba(148, 163, 184, .06);
}

.org-icon {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 8px;
    background: rgba(96, 165, 250, .15);
    color: #93c5fd;
    font-size: .85rem;
}

.org-name {
    overflow: hidden;
    color: #fff;
    font-size: .82rem;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.org-kind {
    font-size: .7rem;
    color: #94a3b8;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: .75rem .9rem;
}

.nav-section {
    padding: 1rem .75rem .4rem;
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #64748b;
}

.sidebar-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 2px;
    padding: .6rem .75rem;
    border-radius: var(--rv-radius-sm);
    color: #cbd5e1;
    font-size: .875rem;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s, color .15s;
}

.sidebar-link i {
    width: 18px;
    text-align: center;
    color: #64748b;
    transition: color .15s;
}

.sidebar-link:hover {
    background: rgba(148, 163, 184, .08);
    color: #fff;
}

.sidebar-link:hover i {
    color: #cbd5e1;
}

.sidebar-link.active {
    background: rgba(37, 99, 235, .2);
    color: #fff;
}

.sidebar-link.active i {
    color: #60a5fa;
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: -.9rem;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: #60a5fa;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(148, 163, 184, .12);
}

.model-status {
    display: flex;
    align-items: center;
    gap: .55rem;
    margin-bottom: .85rem;
    padding: .5rem .75rem;
    border-radius: var(--rv-radius-sm);
    background: rgba(148, 163, 184, .07);
    font-size: .75rem;
    color: #cbd5e1;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, .2);
    flex-shrink: 0;
}

.status-dot.off {
    background: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, .2);
}

.user-card {
    display: flex;
    align-items: center;
    gap: .7rem;
}

.avatar {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: #fff;
    font-size: .78rem;
    font-weight: 600;
}

.avatar-sm {
    width: 30px;
    height: 30px;
    font-size: .7rem;
}

.user-meta {
    flex: 1;
    min-width: 0;
}

.user-name,
.user-email {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.user-name {
    color: #fff;
    font-size: .85rem;
    font-weight: 600;
}

.user-email {
    font-size: .72rem;
}

.btn-sidebar-icon {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: var(--rv-radius-sm);
    background: transparent;
    color: #94a3b8;
    transition: background .15s, color .15s;
}

.btn-sidebar-icon:hover {
    background: rgba(148, 163, 184, .12);
    color: #fff;
}

/* ==================== Layout : contenu ==================== */

.app-main {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

@media (min-width: 992px) {
    .app-main {
        margin-left: var(--rv-sidebar-w);
    }
}

/* Menu latéral masquable (grand écran) : il glisse hors de l'écran, le contenu prend toute la largeur */
@media (min-width: 992px) {
    .sidebar {
        transition: transform .32s cubic-bezier(.4, 0, .2, 1), visibility 0s linear 0s;
    }

    .app-main {
        transition: margin-left .32s cubic-bezier(.4, 0, .2, 1);
    }

    html.sidebar-collapsed .sidebar {
        visibility: hidden;   /* hors de l'écran : plus atteignable au clavier */
        transform: translateX(-100%);
        transition: transform .32s cubic-bezier(.4, 0, .2, 1), visibility 0s linear .32s;
    }

    html.sidebar-collapsed .app-main {
        margin-left: 0;
    }
}

.sidebar-toggle i {
    transition: transform .2s ease;
}

@media (prefers-reduced-motion: reduce) {
    .sidebar,
    .app-main {
        transition: none !important;
    }
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    gap: 1rem;
    height: var(--rv-topbar-h);
    padding: 0 1.75rem;
    background: rgba(255, 255, 255, .85);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--rv-border);
}

.breadcrumb-rv {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: .875rem;
    color: var(--rv-muted);
}

.breadcrumb-rv i {
    font-size: .6rem;
}

.breadcrumb-rv strong {
    color: var(--rv-text);
    font-weight: 600;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-left: auto;
}

/* Équipe Fovix : commune consultée (sélecteur de l'en-tête), mise en évidence pendant la consultation */
.acting-switch {
    display: flex;
    align-items: center;
    gap: .45rem;
    margin: 0 0 0 auto;
    padding: .15rem .25rem .15rem .6rem;
    border: 1px solid var(--rv-border);
    border-radius: 999px;
    color: var(--rv-muted);
    min-width: 0;
}

.acting-switch + .topbar-actions {
    margin-left: 0;
}

.acting-switch.is-acting {
    border-color: var(--rv-primary);
    background: var(--rv-primary-50);
    color: var(--rv-primary);
}

.acting-switch .form-select {
    width: auto;
    max-width: 14rem;
    border: 0;
    background-color: transparent;
    box-shadow: none;
}

@media (max-width: 575.98px) {
    .acting-switch .form-select {
        max-width: 8.5rem;
    }
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .25rem .5rem .25rem .25rem;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: var(--rv-text);
    font-size: .875rem;
    font-weight: 500;
    transition: background .15s, border-color .15s;
}

.topbar-user:hover,
.topbar-user[aria-expanded="true"] {
    background: #fff;
    border-color: var(--rv-border);
}

.app-content {
    flex: 1;
    width: 100%;
    max-width: 1480px;
    margin: 0 auto;
    padding: 1.75rem 1.75rem 2.5rem;
}

@media (max-width: 575.98px) {
    .topbar {
        padding: 0 1rem;
    }

    .app-content {
        padding: 1.25rem 1rem 2rem;
    }
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-header-compact {
    margin-bottom: 1rem;
}

.page-title {
    margin: 0 0 .25rem;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -.02em;
    color: var(--rv-text);
}

.page-subtitle {
    margin: 0;
    font-size: .9rem;
    color: var(--rv-muted);
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
}

.dropdown-menu {
    --bs-dropdown-font-size: .875rem;
    --bs-dropdown-border-color: var(--rv-border);
    --bs-dropdown-border-radius: 10px;
    --bs-dropdown-link-active-bg: var(--rv-primary-50);
    --bs-dropdown-link-active-color: var(--rv-primary);
    padding: .35rem;
    box-shadow: var(--rv-shadow);
}

.dropdown-item {
    border-radius: 6px;
    padding: .45rem .7rem;
}

.dropdown-header {
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.alert {
    border-radius: var(--rv-radius);
    font-size: .875rem;
}

/* ==================== Cartes ==================== */

.card {
    --bs-card-border-color: var(--rv-border);
    --bs-card-border-radius: var(--rv-radius);
    --bs-card-inner-border-radius: calc(var(--rv-radius) - 1px);
    --bs-card-cap-bg: transparent;
    box-shadow: var(--rv-shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--rv-border);
}

.card-title {
    margin: 0;
    font-size: .95rem;
    font-weight: 600;
    color: var(--rv-text);
}

.card-subtitle-sm {
    margin-top: .1rem;
    font-size: .78rem;
    color: var(--rv-muted);
}

.card-body {
    padding: 1.25rem;
}

.card-table {
    overflow: hidden;
}

/* Indicateurs */
.kpi-card {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 1rem;
    height: 100%;
    padding: 1.25rem;
    color: inherit;
    text-decoration: none;
}

.kpi-link {
    transition: border-color .15s, box-shadow .15s, transform .15s;
}

.kpi-link:hover {
    border-color: #c7d2fe;
    box-shadow: var(--rv-shadow);
    transform: translateY(-1px);
}

.kpi-icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 10px;
    background: color-mix(in srgb, var(--c) 12%, white);
    color: var(--c);
    font-size: 1.05rem;
}

.kpi-label {
    margin-bottom: .2rem;
    font-size: .8rem;
    font-weight: 500;
    color: var(--rv-muted);
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -.02em;
    line-height: 1.15;
    color: var(--rv-text);
    font-variant-numeric: tabular-nums;
}

.kpi-sub {
    margin-top: .3rem;
    font-size: .78rem;
    color: var(--rv-muted);
}

@media (max-width: 575.98px) {
    .kpi-card {
        flex-direction: column;
        gap: .75rem;
        padding: 1rem;
    }

    .kpi-icon {
        width: 38px;
        height: 38px;
    }

    .kpi-value {
        font-size: 1.5rem;
    }
}

.chart-box {
    position: relative;
    height: 260px;
}

.status-row {
    display: block;
    margin: 0 -.5rem .35rem;
    padding: .5rem;
    border-radius: var(--rv-radius-sm);
    color: var(--rv-text-2);
    font-size: .85rem;
    text-decoration: none;
    transition: background .15s;
}

.status-row:hover {
    background: var(--rv-surface-2);
    color: var(--rv-text);
}

.progress-thin {
    height: 6px;
    overflow: hidden;
    border-radius: 99px;
    background: #eef2f7;
}

.progress-thin > span {
    display: block;
    height: 100%;
    border-radius: 99px;
    transition: width .4s ease;
}

.priority-list {
    padding: .35rem 0;
}

.priority-item {
    display: flex;
    align-items: center;
    gap: .85rem;
    width: 100%;
    padding: .75rem 1.25rem;
    border: 0;
    border-bottom: 1px solid #f1f4f8;
    background: transparent;
    font-size: .875rem;
    transition: background .15s;
}

.priority-item:last-child {
    border-bottom: 0;
}

.priority-item:hover {
    background: var(--rv-surface-2);
}

.priority-icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 10px;
    background: color-mix(in srgb, var(--c) 12%, white);
    color: var(--c);
}

/* ==================== Badges & puces ==================== */

.badge-soft {
    --c: #64748b;
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    padding: .25rem .6rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--c) 11%, white);
    color: var(--c);
    font-size: .75rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}

.dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--c, currentColor);
}

.type-chip {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    font-weight: 500;
    color: var(--rv-text);
    white-space: nowrap;
}

.type-chip .swatch,
.swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    flex-shrink: 0;
    border-radius: 3px;
    background: var(--c);
}

.code-pill {
    display: inline-block;
    padding: .05rem .35rem;
    border: 1px solid var(--rv-border);
    border-radius: 4px;
    background: var(--rv-surface-2);
    color: var(--rv-muted);
    font-family: var(--rv-mono);
    font-size: .7rem;
    font-weight: 500;
    vertical-align: middle;
}

.conf {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    min-width: 110px;
}

.conf-track {
    width: 64px;
    height: 6px;
    overflow: hidden;
    border-radius: 99px;
    background: #eef2f7;
}

.conf-fill {
    display: block;
    height: 100%;
    border-radius: 99px;
    background: var(--c, var(--rv-primary));
}

.conf-value {
    min-width: 2.8em;
    font-size: .8rem;
    font-weight: 500;
    color: var(--rv-text-2);
    font-variant-numeric: tabular-nums;
}

.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .28rem .65rem;
    border: 1px solid var(--rv-border-strong);
    border-radius: 999px;
    background: #fff;
    color: var(--rv-muted);
    font-size: .76rem;
    font-weight: 500;
    transition: all .15s;
}

.chip .dot {
    opacity: .35;
}

.chip[aria-pressed="true"] {
    border-color: color-mix(in srgb, var(--c) 45%, white);
    background: color-mix(in srgb, var(--c) 9%, white);
    color: var(--rv-text);
}

.chip[aria-pressed="true"] .dot {
    opacity: 1;
}

.segmented {
    display: inline-flex;
    padding: 3px;
    border-radius: 9px;
    background: #e9edf3;
}

.segmented button {
    padding: .35rem .8rem;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--rv-muted);
    font-size: .8rem;
    font-weight: 500;
    transition: all .15s;
}

.segmented button.active {
    background: #fff;
    color: var(--rv-text);
    box-shadow: var(--rv-shadow-sm);
}

/* ==================== Tableaux ==================== */

.table-rv {
    --bs-table-bg: transparent;
    margin: 0;
    font-size: .875rem;
}

.table-rv thead th {
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--rv-border);
    background: var(--rv-surface-2);
    color: var(--rv-muted);
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    white-space: nowrap;
}

.table-rv tbody td {
    padding: .8rem 1rem;
    border-color: #eef1f6;
    color: var(--rv-text-2);
    vertical-align: middle;
}

.table-rv tbody tr:last-child td {
    border-bottom: 0;
}

.table-rv tbody tr {
    transition: background .1s;
}

.table-rv tbody tr:hover {
    background: #f8fafc;
}

.table-rv tbody tr.is-clickable {
    cursor: pointer;
}

.table-rv tbody tr.is-selected {
    background: var(--rv-primary-50);
}

.table-rv .col-check {
    width: 44px;
    padding-right: 0;
}

/* Colonnes secondaires masquées quand la place manque */
@media (max-width: 1599.98px) {
    .table-rv .col-optional {
        display: none;
    }

    .table-rv .type-chip .code-pill {
        display: none;
    }
}

th.sortable {
    cursor: pointer;
    user-select: none;
}

th.sortable:hover {
    color: var(--rv-text);
}

th .sort-icon {
    margin-left: .35rem;
    opacity: .35;
}

th.sorted {
    color: var(--rv-text);
}

th.sorted .sort-icon {
    opacity: 1;
    color: var(--rv-primary);
}

.cell-main {
    font-weight: 500;
    color: var(--rv-text);
}

.cell-sub {
    font-size: .75rem;
    color: var(--rv-muted);
}

.status-tabs {
    display: flex;
    gap: .15rem;
    overflow-x: auto;
    padding: .5rem 1.25rem 0;
    border-bottom: 1px solid var(--rv-border);
}

.status-tab {
    display: flex;
    align-items: center;
    gap: .45rem;
    margin-bottom: -1px;
    padding: .65rem .8rem;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--rv-muted);
    font-size: .85rem;
    font-weight: 500;
    white-space: nowrap;
    transition: color .15s, border-color .15s;
}

.status-tab:hover {
    color: var(--rv-text);
}

.status-tab.active {
    border-bottom-color: var(--rv-primary);
    color: var(--rv-primary);
}

.status-tab .count {
    padding: .1rem .45rem;
    border-radius: 99px;
    background: #eef2f7;
    color: var(--rv-text-2);
    font-size: .7rem;
    font-weight: 600;
}

.status-tab.active .count {
    background: var(--rv-primary-50);
    color: var(--rv-primary);
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: .75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--rv-border);
}

.filter-item {
    flex: 1 1 150px;
    max-width: 210px;
}

.filter-item .form-label {
    font-size: .75rem;
    color: var(--rv-muted);
}

.filter-wide {
    flex-basis: 240px;
    max-width: 300px;
}

.filter-search {
    max-width: 380px;
    flex-basis: 280px;
}

.filter-actions {
    display: flex;
    gap: .5rem;
    margin-left: auto;
}

.bulk-bar {
    display: none;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem;
    padding: .6rem 1.25rem;
    border-bottom: 1px solid #dbeafe;
    background: var(--rv-primary-50);
    font-size: .875rem;
}

.bulk-bar.show {
    display: flex;
}

.table-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .85rem 1.25rem;
    border-top: 1px solid var(--rv-border);
    color: var(--rv-muted);
    font-size: .85rem;
}

.pagination-rv {
    display: flex;
    align-items: center;
    gap: .25rem;
}

.page-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 .5rem;
    border: 1px solid var(--rv-border-strong);
    border-radius: var(--rv-radius-sm);
    background: #fff;
    color: var(--rv-text-2);
    font-size: .8rem;
    font-weight: 500;
}

.page-btn:hover:not(:disabled):not(.active) {
    background: var(--rv-surface-2);
}

.page-btn.active {
    border-color: var(--rv-primary);
    background: var(--rv-primary);
    color: #fff;
}

.page-btn:disabled {
    opacity: .45;
}

.page-gap {
    padding: 0 .25rem;
}

/* ==================== États vides & chargement ==================== */

.empty-state {
    padding: 2.75rem 1.5rem;
    text-align: center;
}

.empty-icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: #eef2f7;
    color: var(--rv-muted);
    font-size: 1.25rem;
}

.empty-state h6 {
    margin-bottom: .35rem;
    font-weight: 600;
    color: var(--rv-text);
}

.empty-state p {
    max-width: 400px;
    margin: 0 auto 1rem;
    font-size: .875rem;
    color: var(--rv-muted);
}

.skeleton {
    display: block;
    border-radius: 6px;
    background: linear-gradient(90deg, #eef2f7 25%, #f6f8fb 37%, #eef2f7 63%);
    background-size: 400% 100%;
    animation: rv-shimmer 1.4s ease infinite;
}

.skeleton-text {
    height: .8rem;
    margin: .55rem 0;
}

.skeleton-value {
    width: 64px;
    height: 1.6rem;
    margin: .15rem 0;
}

@keyframes rv-shimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

/* ==================== Icônes de fichier & listes d'étapes ==================== */

.file-card-icon {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    border-radius: 10px;
    background: color-mix(in srgb, var(--c) 12%, white);
    color: var(--c);
    font-size: 1.1rem;
}

.file-card-icon.sm {
    width: 36px;
    height: 36px;
    font-size: .9rem;
}

.how-list {
    display: grid;
    gap: 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: .875rem;
    color: var(--rv-text-2);
}

.how-list li {
    display: flex;
    gap: .85rem;
}

.how-list li > span {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--rv-primary-50);
    color: var(--rv-primary);
    font-size: .75rem;
    font-weight: 700;
}

/* ==================== Modale anomalie ==================== */

.modal-content {
    border: 0;
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(15, 23, 42, .25);
}

.modal-header,
.modal-footer {
    padding: 1rem 1.5rem;
    border-color: var(--rv-border);
}

.modal-body {
    padding: 1.5rem;
}

.modal-title {
    font-weight: 700;
    letter-spacing: -.01em;
}

.frame-viewer {
    position: relative;
    display: grid;
    place-items: center;
    height: min(62vh, 560px);
    overflow: hidden;
    border-radius: var(--rv-radius);
    background: #0b1220;
}

.frame-viewer img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.frame-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .6rem;
    padding: 1rem;
    color: #94a3b8;
    font-size: .85rem;
    text-align: center;
}

@media (max-width: 991.98px) {
    .frame-viewer {
        height: 46vh;
    }
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem 1.25rem;
}

.info-label {
    margin-bottom: .25rem;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--rv-muted);
}

.info-value {
    font-size: .875rem;
    font-weight: 500;
    color: var(--rv-text);
}

.mini-map {
    height: 170px;
    border: 1px solid var(--rv-border);
    border-radius: var(--rv-radius-sm);
}

.section-label {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: 1.4rem 0 .75rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--rv-border);
    font-size: .85rem;
    font-weight: 600;
    color: var(--rv-text);
}

.section-label i {
    color: var(--rv-muted);
}

.confirm-icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 50%;
    background: #fee2e2;
    color: var(--rv-danger);
}

.confirm-icon.is-info {
    background: var(--rv-primary-50);
    color: var(--rv-primary);
}

/* ==================== Équipe ==================== */

.invitation-list > .invitation-item + .invitation-item {
    border-top: 1px solid var(--rv-border);
}

.invitation-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .85rem;
    padding: .85rem 1.25rem;
}

.invitation-item.is-expired {
    background: var(--rv-surface-2);
}

.invitation-item.is-expired .invitation-code {
    text-decoration: line-through;
    opacity: .6;
}

.invitation-icon,
.role-option-icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 10px;
    background: color-mix(in srgb, var(--c) 12%, white);
    color: var(--c);
}

.invitation-code {
    padding: .3rem .6rem;
    border-radius: 6px;
    background: var(--rv-surface-2);
    border: 1px solid var(--rv-border);
    color: var(--rv-text);
    font-family: var(--rv-mono);
    font-size: .85rem;
    font-weight: 600;
    letter-spacing: .06em;
}

.invitation-actions {
    display: flex;
    align-items: center;
    gap: .25rem;
}

.access-icons {
    display: inline-flex;
    gap: .55rem;
    color: var(--rv-primary);
    font-size: .85rem;
}

.access-icons .off {
    color: #cbd5e1;
}

.you-pill {
    margin-left: .3rem;
    padding: .1rem .45rem;
    border-radius: 999px;
    background: var(--rv-primary-50);
    color: var(--rv-primary);
    font-size: .68rem;
    font-weight: 600;
    vertical-align: middle;
}

.table-rv tbody tr.is-muted td:not(:last-child) {
    opacity: .55;
}

.role-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: .65rem;
}

.role-options-stacked {
    grid-template-columns: 1fr;
}

.role-option {
    display: flex;
    gap: .75rem;
    padding: .8rem .9rem;
    border: 1.5px solid var(--rv-border);
    border-radius: var(--rv-radius);
    background: var(--rv-surface);
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, background .15s;
}

.role-option:hover {
    border-color: var(--rv-border-strong);
}

.role-option:has(input:checked) {
    border-color: var(--c);
    background: color-mix(in srgb, var(--c) 5%, white);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 14%, transparent);
}

.role-option:has(input:focus-visible) {
    box-shadow: var(--rv-ring);
}

.role-option-title {
    display: block;
    font-size: .9rem;
    font-weight: 600;
    color: var(--rv-text);
}

.role-option-text {
    display: block;
    margin-top: .1rem;
    font-size: .78rem;
    line-height: 1.4;
    color: var(--rv-muted);
}

.role-option-access {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin-top: .4rem;
    font-size: .72rem;
    font-weight: 500;
    color: var(--rv-text-2);
}

.role-option-access .access-icons {
    font-size: .75rem;
    gap: .35rem;
}

.qr-box {
    width: 100%;
    max-width: 240px;
    margin: 0 auto;
    padding: .75rem;
    border: 1px solid var(--rv-border);
    border-radius: var(--rv-radius);
    background: #fff;
}

.qr-box svg {
    display: block;
    width: 100%;
    height: auto;
}

.qr-unavailable {
    display: grid;
    gap: .5rem;
    place-items: center;
    padding: 2rem .5rem;
    font-size: .8rem;
    color: var(--rv-muted);
}

.qr-unavailable i {
    font-size: 2rem;
    opacity: .4;
}

.invite-code-big {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.invite-code-big .mono {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: .12em;
    color: var(--rv-text);
}

/* ==================== Notifications ==================== */

.toast-container {
    z-index: 1090;
}

.rv-toast {
    --c: var(--rv-primary);
    overflow: hidden;
    border: 0;
    border-left: 4px solid var(--c);
    border-radius: 10px;
    background: #fff;
    box-shadow: var(--rv-shadow);
    font-size: .875rem;
}

.rv-toast > div > i {
    color: var(--c);
    font-size: 1.05rem;
}

.rv-toast-success { --c: var(--rv-success); }
.rv-toast-error { --c: var(--rv-danger); }
.rv-toast-warning { --c: var(--rv-warning); }
.rv-toast-info { --c: var(--rv-primary); }

/* ==================== Carte ==================== */

.map-layout {
    display: grid;
    grid-template-columns: 330px minmax(0, 1fr);
    height: calc(100vh - var(--rv-topbar-h) - 140px);
    min-height: 560px;
    overflow: hidden;
}

.map-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;   /* petit écran : le panneau défile, la liste garde une hauteur utile */
    border-right: 1px solid var(--rv-border);
    background: #fff;
}

.map-panel-section {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--rv-border);
}

.panel-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .85rem;
    font-size: .875rem;
    font-weight: 600;
}

.filter-label {
    display: block;
    margin-bottom: .4rem;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--rv-muted);
}

.roads-total {
    margin-bottom: .4rem;
    font-weight: 600;
    color: var(--rv-text);
}

.roads-bar {
    display: flex;
    margin-bottom: .5rem;
}

.roads-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    line-height: 1.7;
}

.map-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .65rem 1.25rem;
    border-bottom: 1px solid var(--rv-border);
    background: var(--rv-surface-2);
    font-size: .8rem;
    font-weight: 600;
}

.map-list {
    flex: 1 0 220px;
    min-height: 0;
    overflow-y: auto;
}

.map-list-item {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    width: 100%;
    padding: .7rem 1.25rem;
    border: 0;
    border-bottom: 1px solid #f1f4f8;
    background: transparent;
    font-size: .85rem;
    transition: background .1s;
}

.map-list-item:hover {
    background: var(--rv-surface-2);
}

.map-list-item.active {
    background: var(--rv-primary-50);
    box-shadow: inset 3px 0 0 var(--rv-primary);
}

.map-canvas {
    position: relative;
    min-height: 0;
}

#map {
    position: absolute;
    inset: 0;
    background: #e8edf3;
}

/* Bouton « Recentrer sur la commune » (même allure que les contrôles Leaflet) */
.map-recenter {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 2px solid rgba(0, 0, 0, .2);
    border-radius: 4px;
    background: #fff;
    background-clip: padding-box;
    color: var(--rv-text);
    font-size: .9rem;
}

.map-recenter:hover {
    background: #f4f4f4;
    color: var(--rv-primary);
}

.map-empty {
    position: absolute;
    top: 1rem;
    left: 50%;
    z-index: 500;
    width: min(400px, calc(100% - 2rem));
    transform: translateX(-50%);
}

.map-empty-card {
    border-radius: var(--rv-radius);
    background: rgba(255, 255, 255, .97);
    box-shadow: var(--rv-shadow);
}

.map-empty-card .empty-state {
    padding: 1.5rem;
}

@media (max-width: 991.98px) {
    .map-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .map-panel {
        max-height: 440px;
        border-right: 0;
        border-bottom: 1px solid var(--rv-border);
    }

    .map-canvas {
        height: 65vh;
        min-height: 420px;
    }
}

.leaflet-container {
    font-family: var(--rv-font);
}

.leaflet-popup-content-wrapper {
    border-radius: var(--rv-radius);
    box-shadow: var(--rv-shadow);
}

.leaflet-popup-content {
    margin: .9rem 1rem;
    font-size: .8rem;
}

.leaflet-bar a,
.leaflet-control-layers {
    border-radius: var(--rv-radius-sm) !important;
}

.rv-popup-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: .2rem 0;
    color: var(--rv-muted);
}

.rv-popup-row > :last-child {
    color: var(--rv-text);
}

.rv-marker {
    display: block;
    width: 100%;
    height: 100%;
    border: 2.5px solid #fff;
    border-radius: 50%;
    background: var(--c);
    box-shadow: 0 1px 4px rgba(15, 23, 42, .45);
    transition: transform .15s;
}

.rv-marker.selected {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 35%, transparent), 0 2px 6px rgba(15, 23, 42, .4);
}

.legend-marker {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    border-width: 2px;
}

.legend-line {
    display: inline-block;
    width: 18px;
    height: 4px;
    border-radius: 2px;
    background: var(--c);
}

.rv-cluster span {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(15, 23, 42, .88);
    color: #fff;
    font-size: .8rem;
    font-weight: 700;
    box-shadow: 0 0 0 5px rgba(15, 23, 42, .18);
}

.map-legend {
    padding: .7rem .9rem;
    border-radius: 10px;
    background: #fff;
    box-shadow: var(--rv-shadow);
    font-size: .76rem;
    line-height: 1.9;
}

.legend-title {
    margin-bottom: .15rem;
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--rv-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* ==================== Authentification ==================== */

.auth-body {
    background: #fff;
}

.auth-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    min-height: 100vh;
}

.auth-hero {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 2rem;
    overflow: hidden;
    padding: 2.5rem 3.5rem;
    background:
        radial-gradient(900px 500px at -10% -10%, rgba(37, 99, 235, .38), transparent 60%),
        radial-gradient(700px 420px at 110% 110%, rgba(251, 191, 36, .16), transparent 60%),
        #0b1220;
    color: #e2e8f0;
}

.auth-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(148, 163, 184, .07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, .07) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: radial-gradient(ellipse at 30% 40%, #000 20%, transparent 75%);
    pointer-events: none;
}

.auth-hero > * {
    position: relative;
}

.auth-brand,
.auth-mobile-brand {
    display: inline-flex;
    align-items: center;
    gap: .7rem;
    font-size: 1.1rem;
    font-weight: 700;
    text-decoration: none;
}

.auth-brand {
    color: #fff;
}

.auth-hero-content {
    max-width: 520px;
}

.auth-hero h1 {
    margin-bottom: 1rem;
    font-size: 2.3rem;
    font-weight: 700;
    letter-spacing: -.03em;
    line-height: 1.15;
    color: #fff;
}

.auth-lead {
    margin-bottom: 2rem;
    font-size: 1rem;
    line-height: 1.6;
    color: #94a3b8;
}

.auth-hero-footer {
    font-size: .75rem;
    color: #64748b;
}

.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.5rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
}

.auth-card h2 {
    margin-bottom: .35rem;
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -.02em;
}

.auth-card .subtitle {
    margin-bottom: 1.75rem;
    color: var(--rv-muted);
}

.auth-mobile-brand {
    display: none;
    margin-bottom: 2rem;
    color: var(--rv-text);
}

.form-control-auth {
    height: 46px;
}

.toggle-password {
    position: absolute;
    top: 50%;
    right: .4rem;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--rv-muted);
    transform: translateY(-50%);
}

.toggle-password:hover {
    background: #f1f5f9;
    color: var(--rv-text);
}

.btn-auth {
    height: 46px;
    font-size: .95rem;
}

/* Connexion avec Google : bouton officiel (Google Identity Services) + séparateur */
.google-button {
    display: flex;
    justify-content: center;
    min-height: 44px;
}

.google-signin.is-loading {
    opacity: .6;
    pointer-events: none;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: 1.25rem 0;
    font-size: .8rem;
    color: var(--rv-muted);
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--rv-border);
}

.google-badge {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 10px;
    background: #fff;
    border: 1px solid var(--rv-border);
    color: #ea4335;
}

/* Choix de la commune (inscription) : Région → Département → Commune, ou code INSEE */
.commune-modes {
    display: flex;
    gap: 4px;
    margin-bottom: .85rem;
    padding: 4px;
    border-radius: var(--rv-radius-sm);
    background: var(--rv-surface-2);
}

.commune-mode {
    flex: 1;
    padding: .45rem .5rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    font-size: .8rem;
    font-weight: 600;
    color: var(--rv-muted);
}

.commune-mode.active {
    background: #fff;
    box-shadow: var(--rv-shadow-sm);
    color: var(--rv-primary);
}

.commune-status:not(:empty) {
    margin-top: .45rem;
    font-size: .8rem;
}

/* Champ filtrable : liste déroulante sous le champ */
.combo {
    position: relative;
}

.combo .combo-input {
    padding-right: 2.25rem;
}

.combo-caret {
    position: absolute;
    top: 50%;
    right: .9rem;
    font-size: .7rem;
    color: var(--rv-muted);
    transform: translateY(-50%);
    pointer-events: none;
}

.combo-list {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    left: 0;
    z-index: 30;
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid var(--rv-border);
    border-radius: var(--rv-radius-sm);
    background: #fff;
    box-shadow: var(--rv-shadow);
}

.combo-option {
    display: flex;
    flex-direction: column;
    padding: .5rem .75rem;
    border-bottom: 1px solid var(--rv-border);
    cursor: pointer;
}

.combo-option:last-child {
    border-bottom: 0;
}

.combo-option:hover,
.combo-option.active {
    background: var(--rv-primary-50);
}

.combo-option-title {
    font-size: .875rem;
    font-weight: 600;
    color: var(--rv-text);
}

.combo-option-meta {
    font-size: .75rem;
    color: var(--rv-muted);
}

.combo-note {
    padding: .55rem .75rem;
    font-size: .78rem;
    color: var(--rv-muted);
}

.commune-selected {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem .85rem;
    border: 1px solid var(--rv-primary);
    border-radius: var(--rv-radius);
    background: var(--rv-primary-50);
}

.commune-selected-icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 10px;
    background: #fff;
    color: var(--rv-primary);
}

/* Règles du nouveau mot de passe : cochées pendant la saisie (auth.js) */
.password-rules {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: .8rem;
    color: #666666;
}

.password-rules li {
    display: flex;
    align-items: center;
    gap: .45rem;
    line-height: 1.6;
    transition: color .2s;
}

.password-rules li::before {
    content: "\f111";   /* cercle : règle pas encore respectée */
    font-family: "Font Awesome 6 Free";
    font-weight: 400;
    font-size: .7rem;
    width: .9rem;
    text-align: center;
}

.password-rules li.valid {
    color: #18753c;
}

.password-rules li.valid::before {
    content: "\f00c";   /* coche */
    font-weight: 900;
}

/* Mot de passe oublié : progression des 3 étapes */
.reset-progress {
    display: flex;
    gap: 6px;
    margin-bottom: 1.25rem;
}

.reset-progress span {
    flex: 1;
    height: 4px;
    border-radius: 99px;
    background: #e5e7eb;
    transition: background .2s;
}

.reset-progress span.active {
    background: var(--rv-primary);
}

.reset-step-label {
    margin-bottom: .35rem;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--rv-muted);
}

.auth-switch {
    margin: 1.75rem 0 0;
    text-align: center;
    font-size: .875rem;
    color: var(--rv-muted);
}

.auth-section-title {
    margin: 1.5rem 0 .85rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--rv-border);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--rv-muted);
}

.auth-section-title:first-of-type {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.auth-note {
    display: flex;
    gap: .6rem;
    margin-top: 1.25rem;
    padding: .75rem .85rem;
    border-radius: var(--rv-radius-sm);
    background: var(--rv-surface-2);
    font-size: .8rem;
    color: var(--rv-muted);
}

.agent-icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    margin-bottom: 1.25rem;
    border-radius: 16px;
    background: var(--rv-primary-50);
    color: var(--rv-primary);
    font-size: 1.5rem;
}

.join-org {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1.5rem;
    padding: .75rem .9rem;
    border: 1px solid var(--rv-border);
    border-radius: var(--rv-radius);
    background: var(--rv-surface-2);
}

.auth-note a {
    color: var(--rv-primary);
}

.auth-switch a {
    font-weight: 600;
    text-decoration: none;
}

@media (max-width: 991.98px) {
    .auth-layout {
        grid-template-columns: 1fr;
    }

    .auth-hero {
        display: none;
    }

    .auth-mobile-brand {
        display: inline-flex;
    }
}

/* ==================== Paiements : étapes de l'inscription, frais d'inscription, formules ==================== */

.signup-steps {
    display: flex;
    gap: .5rem;
    margin: 0 0 1.5rem;
    padding: 0;
    list-style: none;
}

.signup-steps li {
    display: flex;
    flex: 1;
    align-items: center;
    gap: .45rem;
    min-width: 0;
    font-size: .78rem;
    font-weight: 500;
    color: var(--rv-muted);
}

.signup-steps li + li::before {
    content: "";
    flex: 0 0 12px;
    height: 1px;
    background: var(--rv-border-strong);
}

.signup-step-dot {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 24px;
    height: 24px;
    border: 1px solid var(--rv-border-strong);
    border-radius: 50%;
    background: var(--rv-surface);
    font-size: .72rem;
    font-weight: 700;
}

.signup-step-label {
    line-height: 1.2;
}

.signup-steps .is-current {
    color: var(--rv-text);
    font-weight: 600;
}

.signup-steps .is-current .signup-step-dot {
    border-color: var(--rv-primary);
    background: var(--rv-primary);
    color: #fff;
}

.signup-steps .is-done .signup-step-dot {
    border-color: var(--rv-success);
    background: #f0fdf4;
    color: var(--rv-success);
}

.fee-card {
    margin-bottom: 1.25rem;
    padding: 1.25rem;
    border: 1px solid var(--rv-border);
    border-radius: var(--rv-radius);
    background: var(--rv-surface-2);
}

.fee-label {
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: .02em;
    color: var(--rv-text-2);
}

.fee-amount {
    margin: .2rem 0 .9rem;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
}

.fee-amount-loading {
    color: var(--rv-border-strong);
}

.fee-points {
    display: grid;
    gap: .5rem;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: .85rem;
    color: var(--rv-text-2);
}

.fee-points li {
    display: flex;
    gap: .55rem;
}

.fee-points i {
    margin-top: .2rem;
    color: var(--rv-success);
    font-size: .8rem;
}

.secure-note,
.test-mode-note {
    display: flex;
    gap: .55rem;
    margin-top: .85rem;
    font-size: .78rem;
    color: var(--rv-muted);
}

.secure-note .fa-stripe {
    margin-top: -.15rem;
    font-size: 1.35rem;
    color: #635bff;
}

.test-mode-note {
    padding: .6rem .75rem;
    border-radius: var(--rv-radius-sm);
    background: #fffbeb;
    color: #92400e;
}

.agent-icon-danger {
    background: #fef2f2;
    color: var(--rv-danger);
}

/* Page des formules (hors de l'application : accessible sans abonnement) */
.plans-body {
    min-height: 100vh;
    background: var(--rv-bg);
}

.plans-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .9rem 1.5rem;
    border-bottom: 1px solid var(--rv-border);
    background: var(--rv-surface);
}

.plans-topbar .auth-brand {
    color: var(--rv-text);
}

.plans-account {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-width: 0;
    font-size: .875rem;
}

.plans-main {
    max-width: 1120px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 3rem;
}

.plans-header {
    max-width: 640px;
    margin-bottom: 1.75rem;
}

.plans-header .signup-steps {
    max-width: 440px;
}

.plans-header h1 {
    margin-bottom: .4rem;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -.02em;
}

.plans-current {
    display: flex;
    align-items: center;
    gap: .9rem;
    margin-bottom: 1.5rem;
    padding: 1rem 1.15rem;
    border: 1px solid var(--rv-border);
    border-radius: var(--rv-radius);
    background: var(--rv-surface);
    box-shadow: var(--rv-shadow-sm);
}

.plans-current-icon {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: #f0fdf4;
    color: var(--rv-success);
    font-size: 1.15rem;
}

.plans-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.25rem;
    align-items: stretch;
}

.plan-card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    border: 1px solid var(--rv-border);
    border-radius: var(--rv-radius);
    background: var(--rv-surface);
    box-shadow: var(--rv-shadow-sm);
}

.plan-card.is-current {
    border-color: var(--rv-success);
    box-shadow: 0 0 0 1px var(--rv-success), var(--rv-shadow-sm);
}

.plan-audience {
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--rv-muted);
}

.plan-name {
    margin: .3rem 0 .9rem;
    font-size: 1.2rem;
    font-weight: 700;
}

.plan-price {
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
}

.plan-period {
    font-size: .95rem;
    font-weight: 500;
    color: var(--rv-muted);
}

.plan-billing {
    margin-bottom: 1rem;
    font-size: .78rem;
    color: var(--rv-muted);
}

.plan-description {
    flex: 1;
    margin-bottom: 1.25rem;
    font-size: .875rem;
    line-height: 1.55;
    color: var(--rv-text-2);
}

.plans-footnote {
    display: grid;
    gap: .4rem;
    margin-top: 1.5rem;
    font-size: .8rem;
    color: var(--rv-muted);
}

.plans-footnote .fa-stripe {
    font-size: 1.3rem;
    vertical-align: -.2rem;
    color: #635bff;
}

@media (max-width: 991.98px) {
    .plans-grid {
        grid-template-columns: 1fr;
        max-width: 520px;
    }
}

@media (max-width: 575.98px) {
    .plans-topbar {
        padding: .75rem 1rem;
    }

    .plans-main {
        padding: 1.75rem 1rem 2.5rem;
    }

    .signup-step-label {
        font-size: .72rem;
    }
}

/* Inscription : étapes suivantes, page des frais d'inscription */
.signup-next {
    margin: -.5rem 0 1.5rem;
}

.org-icon-lg {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--rv-primary-50);
    color: var(--rv-primary);
}

.plans-back {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    margin-bottom: 1.25rem;
    font-size: .875rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--rv-muted);
}

.plans-back:hover {
    color: var(--rv-text);
}

.plans-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    margin-bottom: .6rem;
    padding: .25rem .65rem;
    border-radius: 999px;
    background: linear-gradient(135deg, #eef2ff, #f5f3ff);
    font-size: .75rem;
    font-weight: 600;
    color: #4f46e5;
}

/* ==================== Proposition d'abonnement (détection IA) ==================== */

.nav-pill {
    margin-left: auto;
    padding: .05rem .45rem;
    border-radius: 999px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .04em;
    color: #fff;
}

.upgrade-banner {
    display: flex;
    align-items: center;
    gap: .85rem;
    width: calc(100% - 3.5rem);
    max-width: calc(1480px - 3.5rem);
    margin: 1.25rem auto 0;
    padding: .7rem .85rem .7rem 1rem;
    border-radius: var(--rv-radius);
    background: linear-gradient(110deg, #1e1b4b 0%, #312e81 45%, #4338ca 100%);
    box-shadow: 0 6px 20px rgba(67, 56, 202, .22);
    color: #e0e7ff;
}

.upgrade-banner-icon {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .12);
    color: #c7d2fe;
}

.upgrade-banner-text {
    flex: 1;
    min-width: 0;
    font-size: .875rem;
}

.upgrade-banner-text strong {
    margin-right: .25rem;
    color: #fff;
}

.upgrade-banner-btn {
    flex: 0 0 auto;
    border: 0;
    background: #fff;
    font-weight: 600;
    color: #3730a3;
}

.upgrade-banner-btn:hover,
.upgrade-banner-btn:focus-visible {
    background: #eef2ff;
    color: #312e81;
}

.btn-locked {
    border: 1px dashed #a5b4fc;
    background: #eef2ff;
    font-weight: 500;
    color: #4338ca;
}

.btn-locked:hover,
.btn-locked:focus-visible {
    border-color: #6366f1;
    background: #e0e7ff;
    color: #3730a3;
}

.upgrade-modal .modal-content {
    position: relative;
    overflow: hidden;
    border: 0;
    border-radius: 18px;
    box-shadow: 0 24px 64px rgba(15, 23, 42, .28);
}

.upgrade-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 2;
    filter: invert(1) grayscale(1) brightness(2);
    opacity: .8;
}

.upgrade-hero {
    position: relative;
    padding: 2rem 2rem 1.75rem;
    background:
        radial-gradient(600px 220px at 85% -20%, rgba(139, 92, 246, .55), transparent 70%),
        radial-gradient(500px 240px at 0% 120%, rgba(37, 99, 235, .45), transparent 70%),
        #0f172a;
    color: #cbd5e1;
}

.upgrade-badge {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .25rem .65rem;
    border: 1px solid rgba(165, 180, 252, .35);
    border-radius: 999px;
    background: rgba(99, 102, 241, .18);
    font-size: .75rem;
    font-weight: 600;
    color: #c7d2fe;
}

.upgrade-hero h2 {
    margin: .85rem 0 .4rem;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -.02em;
    color: #fff;
}

.upgrade-hero p {
    max-width: 640px;
    margin-bottom: 1rem;
}

.upgrade-benefits {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: .85rem;
}

.upgrade-benefits li {
    display: flex;
    align-items: center;
    gap: .45rem;
}

.upgrade-benefits i {
    color: #86efac;
}

.upgrade-body {
    padding: 1.5rem 2rem .5rem;
    background: var(--rv-surface-2);
}

.upgrade-plans {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.upgrade-plan {
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
    border: 1px solid var(--rv-border);
    border-radius: 14px;
    background: var(--rv-surface);
    box-shadow: var(--rv-shadow-sm);
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.upgrade-plan:hover {
    border-color: #a5b4fc;
    box-shadow: 0 10px 28px rgba(79, 70, 229, .14);
    transform: translateY(-2px);
}

.upgrade-plan.is-loading {
    min-height: 220px;
    background: linear-gradient(90deg, #f1f5f9 0%, #f8fafc 50%, #f1f5f9 100%);
    background-size: 200% 100%;
    animation: upgrade-shimmer 1.2s linear infinite;
}

@keyframes upgrade-shimmer {
    to { background-position: -200% 0; }
}

.upgrade-plan-audience {
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--rv-muted);
}

.upgrade-plan-name {
    margin: .25rem 0 .6rem;
    font-size: 1.05rem;
    font-weight: 700;
}

.upgrade-plan-price {
    margin-bottom: .6rem;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
}

.upgrade-plan-price span {
    font-size: .85rem;
    font-weight: 500;
    color: var(--rv-muted);
}

.upgrade-plan-description {
    flex: 1;
    margin-bottom: 1rem;
    font-size: .8rem;
    line-height: 1.5;
    color: var(--rv-text-2);
}

.upgrade-member {
    display: flex;
    gap: .55rem;
    margin-top: 1rem;
    padding: .75rem .9rem;
    border-radius: var(--rv-radius-sm);
    background: #eef2ff;
    font-size: .85rem;
    color: #3730a3;
}

.upgrade-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: 1rem 2rem 1.25rem;
    background: var(--rv-surface-2);
}

.upgrade-secure {
    font-size: .8rem;
    color: var(--rv-muted);
}

.upgrade-secure .fa-stripe {
    font-size: 1.3rem;
    vertical-align: -.2rem;
    color: #635bff;
}

@media (max-width: 991.98px) {
    .upgrade-plans {
        grid-template-columns: 1fr;
    }

    .upgrade-plan.is-loading {
        min-height: 120px;
    }
}

@media (max-width: 575.98px) {
    .upgrade-banner {
        flex-wrap: wrap;
        width: calc(100% - 2rem);
        margin-top: .75rem;
    }

    .upgrade-banner-btn {
        width: 100%;
    }

    .upgrade-hero,
    .upgrade-body,
    .upgrade-footer {
        padding-right: 1.25rem;
        padding-left: 1.25rem;
    }

    .upgrade-hero h2 {
        font-size: 1.3rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .upgrade-plan,
    .upgrade-plan.is-loading {
        transition: none;
        animation: none;
    }
}

/* ==================== Abonnement : gestion, factures ==================== */

.plans-manage,
.plans-documents {
    margin-bottom: 1.5rem;
    border: 1px solid var(--rv-border);
    border-radius: var(--rv-radius);
    background: var(--rv-surface);
    box-shadow: var(--rv-shadow-sm);
}

.plans-manage {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 1.25rem;
}

.plans-manage-label {
    margin-bottom: .2rem;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--rv-muted);
}

.plans-manage-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.plans-cancel-note {
    display: flex;
    gap: .5rem;
    margin-top: .6rem;
    padding: .55rem .75rem;
    border-radius: var(--rv-radius-sm);
    background: #fff7ed;
    font-size: .82rem;
    color: #9a3412;
}

.plans-cancel-note i {
    margin-top: .15rem;
}

.cancel-points {
    display: grid;
    gap: .35rem;
    margin: 0;
    padding-left: 1.1rem;
    font-size: .875rem;
    color: var(--rv-text-2);
}

.plans-documents-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: .5rem;
    padding: 1rem 1.25rem .75rem;
}

.plans-documents-header h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.plans-documents-header h2 i {
    margin-right: .35rem;
    color: var(--rv-primary);
}

.plans-documents-table {
    font-size: .875rem;
}

.plans-documents-table th {
    padding: .55rem 1.25rem;
    border-bottom-color: var(--rv-border);
    background: var(--rv-surface-2);
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--rv-muted);
}

.plans-documents-table td {
    padding: .75rem 1.25rem;
    border-bottom-color: var(--rv-border);
    vertical-align: middle;
}

.plans-documents-table tr:last-child td {
    border-bottom: 0;
}

.plans-documents-empty {
    padding: 1.5rem 1.25rem;
    text-align: center;
    font-size: .875rem;
    color: var(--rv-muted);
}

.doc-status {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .15rem .55rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
}

.doc-status.is-paid {
    background: #f0fdf4;
    color: #166534;
}

.doc-status.is-open {
    background: #fff7ed;
    color: #9a3412;
}

/* ==========================================================================
   Thème institutionnel — inspiré du Système de design de l'État (DSFR)
   Couleurs, formes et composants publics du DSFR. Sans les éléments réservés aux sites de l'État
   (bloc-marque « République Française », Marianne, police Marianne) : Fovix garde son identité.
   Logo Fovix (static/images/brand/) aux couleurs du DSFR : bleu France, gris, rouge Marianne.
   ========================================================================== */

:root {
    --rv-font: 'Public Sans', Arial, sans-serif;

    --rv-bg: #f6f6f6;
    --rv-surface: #ffffff;
    --rv-surface-2: #f6f6f6;
    --rv-border: #dddddd;
    --rv-border-strong: #929292;
    --rv-text: #161616;
    --rv-text-2: #3a3a3a;
    --rv-muted: #666666;

    --rv-primary: #000091;
    --rv-primary-600: #1212ff;
    --rv-primary-700: #2323ff;
    --rv-primary-50: #f5f5fe;
    --rv-success: #18753c;
    --rv-warning: #b34000;
    --rv-danger: #ce0500;
    --rv-info: #0063cb;
    --rv-focus: #0a76f6;

    --rv-radius: 0;
    --rv-radius-sm: 4px;
    --rv-shadow-sm: none;
    --rv-shadow: 0 6px 18px rgba(0, 0, 18, .16);
    --rv-ring: none;

    --bs-body-color: var(--rv-text);
    --bs-primary: #000091;
    --bs-primary-rgb: 0, 0, 145;
    --bs-danger: #ce0500;
    --bs-danger-rgb: 206, 5, 0;
    --bs-success: #18753c;
    --bs-success-rgb: 24, 117, 60;
    --bs-link-color: #000091;
    --bs-link-color-rgb: 0, 0, 145;
    --bs-link-hover-color: #1212ff;
    --bs-link-hover-color-rgb: 18, 18, 255;
    --bs-border-color: #dddddd;
}

body {
    line-height: 1.5;
}

h1, h2, h3, h4, h5, h6,
.page-title,
.card-title {
    font-weight: 700;
    color: var(--rv-text);
    letter-spacing: 0;
}

/* Liens soulignés, focus visible (accessibilité) */
a {
    text-underline-offset: 3px;
}

.auth-switch a,
.auth-note a,
.alert a,
.empty-state a,
.plans-footnote a {
    text-decoration: underline;
}

:focus-visible,
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible {
    outline: 2px solid var(--rv-focus) !important;
    outline-offset: 2px;
    box-shadow: none;
}

code {
    color: var(--rv-primary);
}

/* ==================== Boutons ==================== */

.btn {
    --bs-btn-border-radius: 0;
    --bs-btn-font-weight: 500;
    --bs-btn-font-size: .9375rem;
    --bs-btn-padding-y: .5rem;
    --bs-btn-padding-x: 1rem;
    min-height: 2.5rem;
    box-shadow: none;
}

.btn-sm {
    --bs-btn-font-size: .875rem;
    --bs-btn-padding-x: .75rem;
    --bs-btn-padding-y: .25rem;
    min-height: 2rem;
}

.btn-primary {
    --bs-btn-bg: #000091;
    --bs-btn-border-color: #000091;
    --bs-btn-hover-bg: #1212ff;
    --bs-btn-hover-border-color: #1212ff;
    --bs-btn-active-bg: #2323ff;
    --bs-btn-active-border-color: #2323ff;
    --bs-btn-disabled-bg: #e5e5e5;
    --bs-btn-disabled-border-color: #e5e5e5;
    --bs-btn-disabled-color: #929292;
    --bs-btn-disabled-opacity: 1;
    box-shadow: none;
}

/* Bouton secondaire du DSFR : contour bleu */
.btn-white {
    --bs-btn-bg: transparent;
    --bs-btn-color: #000091;
    --bs-btn-border-color: #000091;
    --bs-btn-hover-bg: #f6f6f6;
    --bs-btn-hover-color: #000091;
    --bs-btn-hover-border-color: #000091;
    --bs-btn-active-bg: #ededed;
    --bs-btn-active-color: #000091;
    --bs-btn-active-border-color: #000091;
    --bs-btn-disabled-bg: transparent;
    --bs-btn-disabled-color: #929292;
    --bs-btn-disabled-border-color: #e5e5e5;
    background-color: #fff;
    box-shadow: none;
}

.btn-white.text-danger {
    --bs-btn-border-color: #ce0500;
    --bs-btn-hover-border-color: #ce0500;
    color: #ce0500 !important;
}

.btn-danger {
    --bs-btn-bg: #ce0500;
    --bs-btn-border-color: #ce0500;
    --bs-btn-hover-bg: #ff2725;
    --bs-btn-hover-border-color: #ff2725;
}

.btn-link {
    --bs-btn-color: #000091;
    --bs-btn-hover-color: #1212ff;
    text-decoration: underline;
}

.btn-icon-ghost {
    border-radius: 0;
}

.btn-icon-ghost:hover,
.btn-icon-ghost[aria-expanded="true"] {
    background: #f6f6f6;
    color: #000091;
}

/* ==================== Formulaires (champs du DSFR) ==================== */

.form-label {
    font-size: .9375rem;
    font-weight: 400;
    color: var(--rv-text);
}

.form-control,
.form-select {
    border: 0;
    border-radius: .25rem .25rem 0 0;
    background-color: #eeeeee;
    box-shadow: inset 0 -2px 0 0 #3a3a3a;
    font-size: .9375rem;
    color: var(--rv-text);
}

.form-control:focus,
.form-select:focus {
    border: 0;
    background-color: #eeeeee;
    box-shadow: inset 0 -2px 0 0 #3a3a3a;
    outline: 2px solid var(--rv-focus);
    outline-offset: 2px;
}

.form-control::placeholder {
    color: #666666;
    font-style: italic;
}

.form-control.is-invalid,
.form-select.is-invalid,
.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
    border: 0;
    box-shadow: inset 0 -2px 0 0 #ce0500;
}

.form-control:disabled,
.form-select:disabled {
    background-color: #e5e5e5;
    box-shadow: inset 0 -2px 0 0 #e5e5e5;
    color: #929292;
}

.field-error {
    color: #ce0500;
}

.form-check-input:checked {
    border-color: #000091;
    background-color: #000091;
}

.input-icon > i {
    color: #3a3a3a;
}

/* ==================== Navigation latérale (menu latéral du DSFR) ==================== */

.sidebar {
    --bs-offcanvas-bg: #fff;
}

.sidebar-panel {
    border-right: 1px solid #dddddd;
    background: #fff;
    color: var(--rv-text);
}

.sidebar-top {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid #dddddd;
}

.sidebar-brand,
.brand-name {
    color: var(--rv-text);
}

.brand-tagline {
    color: var(--rv-muted);
}

.sidebar .btn-close-white {
    filter: none;
}

.org-badge {
    margin: 1rem 1rem .25rem;
    border: 0;
    border-left: 4px solid #000091;
    border-radius: 0;
    background: #f5f5fe;
}

.org-icon {
    border-radius: 0;
    background: #000091;
    color: #fff;
}

.org-name {
    color: var(--rv-text);
    font-weight: 700;
}

.org-kind {
    color: var(--rv-muted);
}

.sidebar-nav {
    padding: .5rem 0;
}

.nav-section {
    padding: 1.25rem 1.25rem .4rem;
    color: var(--rv-muted);
    font-weight: 700;
}

.sidebar-link {
    margin: 0;
    padding: .75rem 1.25rem;
    border-radius: 0;
    color: var(--rv-text);
    font-size: .9375rem;
}

.sidebar-link i {
    color: var(--rv-text-2);
}

.sidebar-link:hover {
    background: #f6f6f6;
    color: var(--rv-text);
}

.sidebar-link:hover i {
    color: var(--rv-text);
}

.sidebar-link.active {
    background: transparent;
    color: #000091;
    font-weight: 700;
}

.sidebar-link.active i {
    color: #000091;
}

.sidebar-link.active::before {
    left: 0;
    top: .5rem;
    bottom: .5rem;
    width: 2px;
    border-radius: 0;
    background: #000091;
}

.sidebar-footer {
    border-top: 1px solid #dddddd;
}

.model-status {
    border-radius: 0;
    background: #f6f6f6;
    color: var(--rv-text-2);
}

.user-name {
    color: var(--rv-text);
}

.user-email {
    color: var(--rv-muted);
}

.avatar {
    border-radius: 50%;
    background: #000091;
    color: #fff;
}

.btn-sidebar-icon {
    border-radius: 0;
    color: #000091;
}

.btn-sidebar-icon:hover {
    background: #f6f6f6;
    color: #000091;
}

.nav-pill {
    border-radius: 4px;
    background: #000091;
}

/* ==================== En-tête ==================== */

.topbar {
    background: #fff;
    backdrop-filter: none;
    border-bottom: 1px solid #dddddd;
    box-shadow: 0 1px 3px rgba(0, 0, 18, .08);
}

.breadcrumb-rv strong {
    font-weight: 700;
}

.topbar-user {
    border-radius: 0;
}

.topbar-user:hover,
.topbar-user[aria-expanded="true"] {
    border-color: transparent;
    background: #f6f6f6;
}

.dropdown-menu {
    border-radius: 0;
    border-color: #dddddd;
    box-shadow: var(--rv-shadow);
}

.dropdown-item:hover,
.dropdown-item:focus {
    background: #f6f6f6;
    color: #000091;
}

/* ==================== Titres de page ==================== */

.page-title {
    font-size: 2rem;
    line-height: 2.5rem;
}

.page-subtitle {
    font-size: 1rem;
    color: var(--rv-muted);
}

/* ==================== Cartes, tuiles ==================== */

.card {
    --bs-card-bg: #fff;
    --bs-card-border-radius: 0;
    --bs-card-inner-border-radius: 0;
    --bs-card-border-color: #dddddd;
    box-shadow: none;
}

.card-header {
    border-bottom-color: #dddddd;
}

.card-title {
    font-size: 1.125rem;
}

.card-subtitle-sm {
    font-size: .8125rem;
}

/* Indicateurs : tuiles du DSFR (barre bleue en bas) */
.kpi-card {
    box-shadow: inset 0 -4px 0 0 #000091;
}

.kpi-icon {
    border-radius: 0;
}

.kpi-value {
    letter-spacing: 0;
}

.alert {
    border: 0;
    border-left: 4px solid currentColor;
    border-radius: 0;
}

.alert-danger {
    background: #ffe9e9;
    color: #ce0500;
}

.alert-success {
    background: #b8fec9;
    color: #18753c;
}

.alert-info {
    background: #e8edff;
    color: #0063cb;
}

.alert-warning {
    background: #ffe9e6;
    color: #b34000;
}

/* Badges du DSFR : petites capitales, coins peu arrondis */
.badge-soft {
    border-radius: 4px;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.type-chip {
    border-radius: 4px;
    font-weight: 500;
}

.code-pill {
    border-radius: 4px;
}

/* Étiquettes (filtres de la carte) : tags du DSFR */
.chip {
    border: 0;
    border-radius: 1rem;
    background: #eeeeee;
    color: var(--rv-text);
}

.chip[aria-pressed="true"] {
    border: 0;
    background: #000091;
    color: #fff;
}

.chip[aria-pressed="true"] .dot {
    box-shadow: 0 0 0 2px #fff;
}

.segmented {
    border-radius: 0;
}

.segmented button {
    border-radius: 0;
}

.segmented button.active {
    background: #000091;
    color: #fff;
    box-shadow: none;
}

/* ==================== Tableaux (tableaux du DSFR) ==================== */

.table-rv thead th {
    background: #f6f6f6;
    border-bottom: 2px solid #3a3a3a;
    color: var(--rv-text);
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
    font-size: .875rem;
}

.table-rv tbody tr:nth-child(even) td {
    background: #f6f6f6;
}

.table-rv tbody tr.is-selected td {
    background: #e3e3fd;
}

/* Onglets (statuts) : onglets du DSFR */
.status-tabs {
    border-bottom: 1px solid #dddddd;
}

.status-tab {
    border-radius: 0;
    color: var(--rv-text);
}

.status-tab.active {
    color: #000091;
    box-shadow: inset 0 -2px 0 0 #000091;
}

.status-tab .count {
    border-radius: 4px;
}

.page-btn {
    border-radius: 0;
}

.page-btn.active {
    background: #000091;
    color: #fff;
}

.bulk-bar {
    border-radius: 0;
    background: #f5f5fe;
    border-color: #cacafb;
}

.empty-icon,
.file-card-icon,
.priority-icon,
.confirm-icon {
    border-radius: 0;
}

.progress-thin {
    border-radius: 0;
}

.progress-thin > span {
    border-radius: 0;
}

/* ==================== Fenêtres, notifications ==================== */

.modal-content {
    border: 0;
    border-radius: 0;
    box-shadow: var(--rv-shadow);
}

.modal-header {
    border-bottom-color: #dddddd;
}

.rv-toast {
    border-radius: 0;
    border-left: 4px solid var(--c);
    box-shadow: var(--rv-shadow);
}

/* ==================== Carte ==================== */

.map-panel,
.map-canvas,
.map-legend,
.map-recenter,
.map-list-item,
.leaflet-popup-content-wrapper,
.leaflet-control-layers {
    border-radius: 0 !important;
}

.map-list-item.active {
    background: #f5f5fe;
    box-shadow: inset 2px 0 0 #000091;
}

/* ==================== Pages de connexion et d'inscription ==================== */

.auth-body {
    background: #fff;
}

.auth-hero {
    border-right: 1px solid #dddddd;
    background: #f5f5fe;
    color: var(--rv-text);
}

.auth-hero::before {
    display: none;
}

/* Silhouette du logo Fovix en filigrane : diaphragme qui s'ouvre puis tourne lentement, anneaux d'objectif */
.auth-hero > .auth-hero-mark {
    position: absolute;
    right: -220px;
    bottom: -170px;
    z-index: 0;
    width: 640px;
    height: 640px;
    pointer-events: none;
    animation: rv-mark-open 1.6s cubic-bezier(.2, .8, .2, 1) both;
}

.auth-hero > :not(.auth-hero-mark) {
    z-index: 1;
}

.auth-hero-mark::before {
    content: '';
    position: absolute;
    inset: 90px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(106, 106, 244, .22), transparent 68%);
    filter: blur(20px);
}

.mark-aperture {
    position: absolute;
    inset: 70px;
    background: linear-gradient(135deg, #000091 10%, #6a6af4 90%);
    opacity: .11;
    -webkit-mask: url('/static/images/brand/fovix-symbole-mono-asphalte.svg') center / contain no-repeat;
    mask: url('/static/images/brand/fovix-symbole-mono-asphalte.svg') center / contain no-repeat;
    animation: rv-mark-spin 120s linear infinite;
}

.mark-ring {
    position: absolute;
    inset: 30px;
    border: 1px solid rgba(0, 0, 145, .14);
    border-radius: 50%;
}

.mark-ring-outer {
    inset: -40px;
    border: 2px dashed rgba(0, 0, 145, .10);
    animation: rv-mark-spin 200s linear infinite reverse;
}

.mark-pupil {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 38px;
    height: 38px;
    margin: -19px 0 0 -19px;
    border-radius: 50%;
    background: #e1000f;
    opacity: .55;
    box-shadow: 0 0 0 10px rgba(225, 0, 15, .08);
    animation: rv-mark-pulse 3.2s ease-in-out infinite;
}

@keyframes rv-mark-open {
    from {
        opacity: 0;
        transform: scale(.82) rotate(-50deg);
    }
}

@keyframes rv-mark-spin {
    to { transform: rotate(360deg); }
}

@keyframes rv-mark-pulse {
    50% {
        box-shadow: 0 0 0 22px rgba(225, 0, 15, 0);
        transform: scale(.9);
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth-hero > .auth-hero-mark,
    .mark-aperture,
    .mark-ring-outer,
    .mark-pupil {
        animation: none;
    }
}

.auth-brand {
    color: var(--rv-text);
}

.auth-hero h1 {
    color: var(--rv-text);
    font-size: 2.5rem;
    line-height: 3rem;
    letter-spacing: 0;
}

.auth-lead {
    color: var(--rv-text-2);
    font-size: 1.125rem;
}

/* Trois étapes, sobres : numéro, titre, une phrase */
.hero-steps {
    max-width: 440px;
    margin: 2.5rem 0 0;
    padding: 0;
    list-style: none;
}

.hero-steps li {
    display: flex;
    gap: 1.25rem;
    padding: 1.1rem 0;
    border-top: 1px solid var(--rv-border);
}

.hero-steps li:last-child {
    border-bottom: 1px solid var(--rv-border);
}

.hero-step-number {
    padding-top: .15rem;
    color: var(--rv-primary);
    font-size: .8rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: .04em;
}

.hero-step-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--rv-text);
}

.hero-step-text {
    margin-top: .15rem;
    color: var(--rv-muted);
}

.auth-hero-footer {
    color: var(--rv-muted);
}

.auth-card h2 {
    font-size: 1.75rem;
    letter-spacing: 0;
}

.auth-card .subtitle {
    color: var(--rv-muted);
}

.auth-section-title {
    color: var(--rv-text);
}

.auth-note {
    border-left: 4px solid #000091;
    border-radius: 0;
    background: #f5f5fe;
    color: var(--rv-text-2);
}

.agent-icon,
.org-icon-lg,
.google-badge {
    border-radius: 0;
}

.join-org,
.commune-selected,
.combo-list {
    border-radius: 0;
}

.commune-modes {
    border-radius: 0;
    background: #f6f6f6;
}

.commune-mode {
    border-radius: 0;
}

.commune-mode.active {
    background: #fff;
    color: #000091;
    box-shadow: inset 0 -2px 0 0 #000091;
}

.combo-option.active,
.combo-option:hover {
    background: #e3e3fd;
}

.reset-progress span {
    border-radius: 0;
}

.toggle-password {
    border-radius: 0;
}

/* Étapes de l'inscription : indicateur d'étapes du DSFR */
.signup-step-dot {
    border-radius: 0;
}

.signup-steps .is-current .signup-step-dot {
    border-color: #000091;
    background: #000091;
}

.signup-steps .is-done .signup-step-dot {
    border-color: #18753c;
    background: #b8fec9;
    color: #18753c;
}

/* ==================== Paiements, abonnement ==================== */

.fee-card {
    border-radius: 0;
    background: #fff;
    box-shadow: inset 0 -4px 0 0 #000091;
}

.fee-label {
    color: var(--rv-text);
    font-weight: 700;
}

.fee-points i,
.upgrade-benefits i {
    color: #18753c;
}

.test-mode-note {
    border-left: 4px solid #b34000;
    border-radius: 0;
    background: #ffe9e6;
    color: #b34000;
}

.plans-body {
    background: #f6f6f6;
}

.plans-topbar {
    border-bottom: 1px solid #dddddd;
    box-shadow: 0 1px 3px rgba(0, 0, 18, .08);
}

.plans-eyebrow {
    border-radius: 4px;
    background: #e3e3fd;
    color: #000091;
    text-transform: uppercase;
    font-weight: 700;
}

.plans-current,
.plans-manage,
.plans-documents,
.plan-card {
    border-radius: 0;
    box-shadow: none;
}

.plan-card {
    box-shadow: inset 0 -4px 0 0 #000091;
}

.plan-card.is-current {
    border-color: #18753c;
    box-shadow: inset 0 -4px 0 0 #18753c, 0 0 0 1px #18753c;
}

.plans-current-icon {
    border-radius: 0;
}

.plans-cancel-note {
    border-left: 4px solid #b34000;
    border-radius: 0;
    background: #ffe9e6;
    color: #b34000;
}

.plans-documents-table th {
    background: #f6f6f6;
    border-bottom: 2px solid #3a3a3a;
    color: var(--rv-text);
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
    font-size: .875rem;
}

.doc-status {
    border-radius: 4px;
    text-transform: uppercase;
}

.doc-status.is-paid {
    background: #b8fec9;
    color: #18753c;
}

.doc-status.is-open {
    background: #ffe9e6;
    color: #b34000;
}

/* Proposition d'abonnement : bandeau d'information (notice du DSFR) et fenêtre sobre */
.upgrade-banner {
    border-left: 4px solid #000091;
    border-radius: 0;
    background: #f5f5fe;
    box-shadow: none;
    color: var(--rv-text);
}

.upgrade-banner-icon {
    border-radius: 0;
    background: #000091;
    color: #fff;
}

.upgrade-banner-text strong {
    color: var(--rv-text);
}

.upgrade-banner-btn {
    border-radius: 0;
    background: #000091;
    color: #fff;
}

.upgrade-banner-btn:hover,
.upgrade-banner-btn:focus-visible {
    background: #1212ff;
    color: #fff;
}

.btn-locked {
    border: 1px solid #000091;
    border-radius: 0;
    background: #fff;
    color: #000091;
}

.btn-locked:hover,
.btn-locked:focus-visible {
    border-color: #000091;
    background: #f5f5fe;
    color: #000091;
}

.upgrade-modal .modal-content {
    border-radius: 0;
}

.upgrade-close {
    filter: none;
}

.upgrade-hero {
    border-bottom: 1px solid #dddddd;
    background: #fff;
    color: var(--rv-text-2);
}

.upgrade-badge {
    border: 0;
    border-radius: 4px;
    background: #e3e3fd;
    color: #000091;
    text-transform: uppercase;
}

.upgrade-hero h2 {
    color: var(--rv-text);
}

.upgrade-plan {
    border-radius: 0;
    box-shadow: inset 0 -4px 0 0 #000091;
}

.upgrade-plan:hover {
    border-color: #000091;
    box-shadow: inset 0 -4px 0 0 #000091;
    transform: none;
}

.upgrade-member {
    border-left: 4px solid #000091;
    border-radius: 0;
    background: #f5f5fe;
    color: var(--rv-text);
}

/* ==========================================================================
   Thème sombre — palette sombre du DSFR (html[data-theme="dark"], voir preferences.js)
   ========================================================================== */

html.i18n-pending body {
    visibility: hidden;   /* anglais : page affichée une fois traduite (au plus 1 s) */
}

html[data-theme="dark"] {
    color-scheme: dark;

    --rv-bg: #161616;
    --rv-surface: #1e1e1e;
    --rv-surface-2: #2a2a2a;
    --rv-border: #353535;
    --rv-border-strong: #666666;
    --rv-text: #eeeeee;
    --rv-text-2: #cecece;
    --rv-muted: #a0a0a0;

    --rv-primary: #8585f6;
    --rv-primary-600: #b1b1f9;
    --rv-primary-700: #c6c6fb;
    --rv-primary-50: #1b1b35;
    --rv-success: #27a658;
    --rv-warning: #fc5d00;
    --rv-danger: #ff5655;
    --rv-info: #518fff;
    --rv-focus: #8585f6;
    --rv-shadow: 0 6px 18px rgba(0, 0, 0, .55);

    --bs-body-bg: #161616;
    --bs-body-color: #eeeeee;
    --bs-secondary-color: #a0a0a0;
    --bs-tertiary-bg: #2a2a2a;
    --bs-border-color: #353535;
    --bs-emphasis-color: #ffffff;
    --bs-link-color: #8585f6;
    --bs-link-color-rgb: 133, 133, 246;
    --bs-link-hover-color: #b1b1f9;
    --bs-link-hover-color-rgb: 177, 177, 249;
    --bs-primary: #8585f6;
    --bs-primary-rgb: 133, 133, 246;
}

html[data-theme="dark"] body {
    background: var(--rv-bg);
    color: var(--rv-text);
}

html[data-theme="dark"] .text-muted {
    color: var(--rv-muted) !important;
}

html[data-theme="dark"] code {
    color: #b1b1f9;
}

/* Boutons */
html[data-theme="dark"] .btn-primary {
    --bs-btn-color: #161616;
    --bs-btn-bg: #8585f6;
    --bs-btn-border-color: #8585f6;
    --bs-btn-hover-color: #161616;
    --bs-btn-hover-bg: #b1b1f9;
    --bs-btn-hover-border-color: #b1b1f9;
    --bs-btn-active-color: #161616;
    --bs-btn-active-bg: #c6c6fb;
    --bs-btn-active-border-color: #c6c6fb;
    --bs-btn-disabled-bg: #2a2a2a;
    --bs-btn-disabled-border-color: #2a2a2a;
    --bs-btn-disabled-color: #666666;
}

html[data-theme="dark"] .btn-white {
    --bs-btn-color: #8585f6;
    --bs-btn-border-color: #8585f6;
    --bs-btn-hover-bg: #2a2a2a;
    --bs-btn-hover-color: #b1b1f9;
    --bs-btn-hover-border-color: #b1b1f9;
    --bs-btn-active-bg: #353535;
    --bs-btn-active-color: #b1b1f9;
    --bs-btn-active-border-color: #b1b1f9;
    --bs-btn-disabled-color: #666666;
    --bs-btn-disabled-border-color: #353535;
    background-color: transparent;
}

html[data-theme="dark"] .btn-white.text-danger {
    --bs-btn-border-color: #ff5655;
    --bs-btn-hover-border-color: #ff5655;
    color: #ff5655 !important;
}

html[data-theme="dark"] .btn-danger {
    --bs-btn-color: #161616;
    --bs-btn-bg: #ff5655;
    --bs-btn-border-color: #ff5655;
    --bs-btn-hover-color: #161616;
    --bs-btn-hover-bg: #ff8a89;
    --bs-btn-hover-border-color: #ff8a89;
}

html[data-theme="dark"] .btn-link {
    --bs-btn-color: #8585f6;
    --bs-btn-hover-color: #b1b1f9;
}

html[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(1) brightness(2);
}

html[data-theme="dark"] .btn-icon-ghost:hover,
html[data-theme="dark"] .btn-icon-ghost[aria-expanded="true"] {
    background: #2a2a2a;
    color: #8585f6;
}

/* Formulaires */
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-select:focus {
    background-color: #2a2a2a;
    box-shadow: inset 0 -2px 0 0 #cecece;
    color: var(--rv-text);
}

html[data-theme="dark"] .form-control::placeholder {
    color: #a0a0a0;
}

html[data-theme="dark"] .form-control:disabled,
html[data-theme="dark"] .form-select:disabled {
    background-color: #242424;
    box-shadow: inset 0 -2px 0 0 #353535;
    color: #666666;
}

html[data-theme="dark"] .form-control.is-invalid,
html[data-theme="dark"] .form-select.is-invalid {
    box-shadow: inset 0 -2px 0 0 #ff5655;
}

html[data-theme="dark"] .field-error {
    color: #ff5655;
}

html[data-theme="dark"] .form-check-input {
    background-color: #2a2a2a;
    border-color: #a0a0a0;
}

html[data-theme="dark"] .form-check-input:checked {
    border-color: #8585f6;
    background-color: #8585f6;
}

html[data-theme="dark"] .input-icon > i {
    color: #cecece;
}

/* Navigation latérale, en-tête */
html[data-theme="dark"] .sidebar {
    --bs-offcanvas-bg: #1e1e1e;
}

html[data-theme="dark"] .sidebar-panel,
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .plans-topbar {
    border-color: #353535;
    background: #1e1e1e;
}

html[data-theme="dark"] .sidebar-top,
html[data-theme="dark"] .sidebar-footer {
    border-color: #353535;
}

html[data-theme="dark"] .org-badge {
    border-left-color: #8585f6;
    background: #1b1b35;
}

html[data-theme="dark"] .org-icon,
html[data-theme="dark"] .avatar,
html[data-theme="dark"] .nav-pill,
html[data-theme="dark"] .upgrade-banner-icon,
html[data-theme="dark"] .page-btn.active,
html[data-theme="dark"] .segmented button.active,
html[data-theme="dark"] .signup-steps .is-current .signup-step-dot {
    border-color: #8585f6;
    background: #8585f6;
    color: #161616;
}

html[data-theme="dark"] .sidebar-link:hover,
html[data-theme="dark"] .topbar-user:hover,
html[data-theme="dark"] .topbar-user[aria-expanded="true"],
html[data-theme="dark"] .btn-sidebar-icon:hover,
html[data-theme="dark"] .model-status {
    background: #2a2a2a;
}

html[data-theme="dark"] .sidebar-link.active,
html[data-theme="dark"] .sidebar-link.active i,
html[data-theme="dark"] .btn-sidebar-icon,
html[data-theme="dark"] .status-tab.active,
html[data-theme="dark"] .commune-mode.active {
    color: #8585f6;
}

html[data-theme="dark"] .sidebar-link.active::before {
    background: #8585f6;
}

html[data-theme="dark"] .status-tab.active,
html[data-theme="dark"] .commune-mode.active {
    box-shadow: inset 0 -2px 0 0 #8585f6;
}

html[data-theme="dark"] .commune-mode.active {
    background: #1e1e1e;
}

html[data-theme="dark"] .commune-modes {
    background: #2a2a2a;
}

html[data-theme="dark"] .dropdown-menu {
    --bs-dropdown-bg: #1e1e1e;
    --bs-dropdown-color: #eeeeee;
    --bs-dropdown-border-color: #353535;
    --bs-dropdown-link-color: #eeeeee;
    --bs-dropdown-header-color: #a0a0a0;
    --bs-dropdown-divider-bg: #353535;
}

html[data-theme="dark"] .dropdown-item:hover,
html[data-theme="dark"] .dropdown-item:focus {
    background: #2a2a2a;
    color: #8585f6;
}

/* Cartes, tuiles, tableaux */
html[data-theme="dark"] .card {
    --bs-card-bg: #1e1e1e;
    --bs-card-color: #eeeeee;
    --bs-card-border-color: #353535;
}

html[data-theme="dark"] .card-header {
    border-color: #353535;
}

html[data-theme="dark"] .kpi-card,
html[data-theme="dark"] .fee-card,
html[data-theme="dark"] .plan-card,
html[data-theme="dark"] .upgrade-plan {
    box-shadow: inset 0 -4px 0 0 #8585f6;
}

html[data-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: #eeeeee;
    --bs-table-border-color: #353535;
}

html[data-theme="dark"] .table-rv thead th,
html[data-theme="dark"] .plans-documents-table th {
    border-bottom-color: #cecece;
    background: #2a2a2a;
    color: var(--rv-text);
}

html[data-theme="dark"] .table-rv tbody td,
html[data-theme="dark"] .plans-documents-table td {
    border-color: #353535;
    color: var(--rv-text);
}

html[data-theme="dark"] .table-rv tbody tr:nth-child(even) td {
    background: #242424;
}

html[data-theme="dark"] .table-rv tbody tr:hover td {
    background: #2a2a2a;
}

html[data-theme="dark"] .table-rv tbody tr.is-selected td {
    background: #1b1b35;
}

html[data-theme="dark"] .bulk-bar {
    border-color: #313178;
    background: #1b1b35;
}

html[data-theme="dark"] .status-tabs {
    border-color: #353535;
}

/* Badges et icônes teintés (couleur --c) : couleurs éclaircies, fond sombre */
html[data-theme="dark"] .badge-soft,
html[data-theme="dark"] .kpi-icon,
html[data-theme="dark"] .priority-icon,
html[data-theme="dark"] .file-card-icon,
html[data-theme="dark"] .role-option-icon {
    background: color-mix(in srgb, var(--c) 28%, #1e1e1e);
    color: color-mix(in srgb, var(--c) 45%, white);
}

html[data-theme="dark"] .type-chip,
html[data-theme="dark"] .rv-toast > div > i {
    color: color-mix(in srgb, var(--c) 45%, white);
}

html[data-theme="dark"] .role-option:has(input:checked) {
    background: color-mix(in srgb, var(--c) 18%, #1e1e1e);
}

html[data-theme="dark"] .chip {
    background: #2a2a2a;
    color: var(--rv-text);
}

html[data-theme="dark"] .chip[aria-pressed="true"] {
    background: #8585f6;
    color: #161616;
}

html[data-theme="dark"] .code-pill,
html[data-theme="dark"] .status-tab .count {
    background: #2a2a2a;
    color: var(--rv-text-2);
}

/* Messages */
html[data-theme="dark"] .alert-danger,
html[data-theme="dark"] .test-mode-note,
html[data-theme="dark"] .plans-cancel-note {
    background: #391c1c;
    color: #ff8a89;
}

html[data-theme="dark"] .test-mode-note,
html[data-theme="dark"] .plans-cancel-note {
    border-left-color: #fc5d00;
    background: #3a2516;
    color: #ff9c5e;
}

html[data-theme="dark"] .alert-success {
    background: #1b2e22;
    color: #4fd07e;
}

html[data-theme="dark"] .alert-info {
    background: #1d2437;
    color: #8db3ff;
}

html[data-theme="dark"] .alert-warning {
    background: #3a2516;
    color: #ff9c5e;
}

html[data-theme="dark"] .doc-status.is-paid,
html[data-theme="dark"] .signup-steps .is-done .signup-step-dot {
    border-color: #27a658;
    background: #1b2e22;
    color: #4fd07e;
}

html[data-theme="dark"] .doc-status.is-open {
    background: #3a2516;
    color: #ff9c5e;
}

html[data-theme="dark"] .modal-content {
    --bs-modal-bg: #1e1e1e;
    --bs-modal-color: #eeeeee;
    background: #1e1e1e;
}

html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer {
    border-color: #353535;
}

html[data-theme="dark"] .rv-toast {
    background: #1e1e1e;
    color: var(--rv-text);
}

/* Pages de connexion, paiements, abonnement */
html[data-theme="dark"] .auth-body {
    background: #161616;
}

html[data-theme="dark"] .auth-hero {
    border-color: #353535;
    background: #1b1b35;
}

html[data-theme="dark"] .mark-aperture {
    background: linear-gradient(135deg, #6a6af4 10%, #b1b1f9 90%);
    opacity: .12;
}

html[data-theme="dark"] .mark-ring {
    border-color: rgba(133, 133, 246, .18);
}

html[data-theme="dark"] .mark-ring-outer {
    border-color: rgba(133, 133, 246, .12);
}

html[data-theme="dark"] .mark-pupil {
    background: #f95c5e;
    opacity: .5;
}

html[data-theme="dark"] .fee-card,
html[data-theme="dark"] .plans-current,
html[data-theme="dark"] .plans-manage,
html[data-theme="dark"] .plans-documents,
html[data-theme="dark"] .plan-card,
html[data-theme="dark"] .upgrade-plan,
html[data-theme="dark"] .join-org,
html[data-theme="dark"] .commune-selected,
html[data-theme="dark"] .combo-list {
    border-color: #353535;
    background: #1e1e1e;
}

html[data-theme="dark"] .frame-sky { fill: #2b2d38; }
html[data-theme="dark"] .frame-verge { fill: #3a4036; }
html[data-theme="dark"] .frame-road { fill: #47494e; }
html[data-theme="dark"] .frame-line { stroke: #d6d6d6; }

html[data-theme="dark"] .auth-note,
html[data-theme="dark"] .upgrade-banner,
html[data-theme="dark"] .upgrade-member {
    border-left-color: #8585f6;
    background: #1b1b35;
    color: var(--rv-text);
}

html[data-theme="dark"] .combo-option.active,
html[data-theme="dark"] .combo-option:hover {
    background: #1b1b35;
}

html[data-theme="dark"] .plans-body {
    background: #161616;
}

html[data-theme="dark"] .plans-eyebrow,
html[data-theme="dark"] .upgrade-badge {
    background: #1b1b35;
    color: #b1b1f9;
}

html[data-theme="dark"] .plan-card.is-current {
    border-color: #27a658;
    box-shadow: inset 0 -4px 0 0 #27a658, 0 0 0 1px #27a658;
}

html[data-theme="dark"] .upgrade-hero,
html[data-theme="dark"] .upgrade-body,
html[data-theme="dark"] .upgrade-footer {
    border-color: #353535;
    background: #1e1e1e;
}

html[data-theme="dark"] .upgrade-body,
html[data-theme="dark"] .upgrade-footer {
    background: #161616;
}

html[data-theme="dark"] .upgrade-banner-btn {
    background: #8585f6;
    color: #161616;
}

html[data-theme="dark"] .upgrade-banner-btn:hover,
html[data-theme="dark"] .upgrade-banner-btn:focus-visible {
    background: #b1b1f9;
    color: #161616;
}

html[data-theme="dark"] .btn-locked {
    border-color: #8585f6;
    background: transparent;
    color: #8585f6;
}

html[data-theme="dark"] .btn-locked:hover {
    background: #1b1b35;
    color: #b1b1f9;
}

/* Carte : panneaux sombres, fond de carte inchangé (lisibilité des rues) */
html[data-theme="dark"] .map-panel,
html[data-theme="dark"] .map-legend,
html[data-theme="dark"] .map-recenter,
html[data-theme="dark"] .leaflet-popup-content-wrapper,
html[data-theme="dark"] .leaflet-popup-tip,
html[data-theme="dark"] .leaflet-control-layers,
html[data-theme="dark"] .leaflet-bar a {
    border-color: #353535;
    background: #1e1e1e;
    color: var(--rv-text);
}

html[data-theme="dark"] .map-list-item:hover,
html[data-theme="dark"] .map-list-item.active {
    background: #1b1b35;
}

html[data-theme="dark"] .progress-thin,
html[data-theme="dark"] .conf-track,
html[data-theme="dark"] .reset-progress span:not(.active) {
    background: #353535;
}

html[data-theme="dark"] .password-rules {
    color: #929292;
}

html[data-theme="dark"] .password-rules li.valid {
    color: #27a658;
}

/* QR code : toujours sur fond blanc (lisible par les téléphones) */
html[data-theme="dark"] .qr-box {
    background: #fff;
}

/* ==================== Boutons thème et langue ==================== */

.pref-toggles {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}

.btn-pref {
    display: inline-grid;
    place-items: center;
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0 .5rem;
    border: 1px solid var(--rv-border);
    border-radius: 0;
    background: transparent;
    color: var(--rv-primary);
    font-size: .875rem;
    font-weight: 700;
    letter-spacing: .03em;
}

.btn-pref:hover {
    background: var(--rv-surface-2);
}

.pref-bar {
    position: absolute;
    top: 1.25rem;
    right: 1.5rem;
}

.auth-panel {
    position: relative;
}

/* ==================== Notifications (composants du DSFR : badges, mise en avant, liens soulignés) ==================== */

.notif-bell-btn {
    position: relative;
}

.notif-count {
    position: absolute;
    top: -7px;
    right: -7px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--rv-danger);
    color: #fff;
    font-size: .6875rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

.notif-nav-count {
    background: var(--rv-danger);
    color: #fff;
}

.notif-menu {
    width: min(420px, calc(100vw - 2rem));
    padding: 0;
}

.notif-menu-header,
.notif-menu-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .75rem 1rem;
}

.notif-menu-header {
    border-bottom: 1px solid var(--rv-border);
}

.notif-menu-header .btn-link:disabled {
    color: var(--rv-muted);
    text-decoration: none;
}

.notif-menu-footer {
    border-top: 1px solid var(--rv-border);
    font-size: .875rem;
}

.notif-menu-footer a {
    color: var(--rv-primary);
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.notif-menu-state {
    padding: 1.5rem 1rem;
    color: var(--rv-muted);
    font-size: .875rem;
    text-align: center;
}

.notif-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.notif-menu .notif-list {
    max-height: min(420px, 60vh);
    overflow-y: auto;
}

.notif-item {
    position: relative;
    display: flex;
    gap: .75rem;
    padding: .875rem 1rem;
    border-bottom: 1px solid var(--rv-border);
}

.notif-list > .notif-item:last-child {
    border-bottom: 0;
}

/* Non lue : filet bleu France à gauche, fond teinté, mention « Non lue » (jamais la couleur seule) */
.notif-item.is-unread {
    background: var(--rv-primary-50);
    box-shadow: inset 4px 0 0 var(--rv-primary);
}

.notif-icon {
    display: inline-grid;
    flex-shrink: 0;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 4px;
    background: color-mix(in srgb, var(--c) 11%, var(--rv-surface));
    color: var(--c);
    font-size: .875rem;
}

.notif-content {
    flex: 1;
    min-width: 0;
}

.notif-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem .5rem;
    margin-bottom: .25rem;
    color: var(--rv-muted);
    font-size: .75rem;
}

.notif-tag {
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.notif-unread-tag {
    padding: 0 .375rem;
    border-radius: 4px;
    background: var(--rv-primary);
    color: #fff;
    font-weight: 700;
    letter-spacing: .02em;
    line-height: 1.25rem;
    text-transform: uppercase;
}

.notif-title {
    display: block;
    color: var(--rv-text);
    font-size: .9375rem;
    font-weight: 700;
    line-height: 1.375rem;
    overflow-wrap: anywhere;
    text-decoration: none;
}

a.notif-title:hover {
    color: var(--rv-primary);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Toute la ligne est cliquable */
a.notif-title::after {
    content: "";
    position: absolute;
    inset: 0;
}

.notif-item:has(a.notif-title):hover {
    background: var(--rv-surface-2);
}

.notif-item.is-unread:has(a.notif-title):hover {
    background: var(--rv-primary-50);
}

.notif-text {
    margin: .125rem 0 0;
    color: var(--rv-text-2);
    font-size: .875rem;
    line-height: 1.375rem;
    overflow-wrap: anywhere;
    white-space: pre-line;
}

.notif-menu .notif-text {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    white-space: normal;
}

.notif-mark {
    position: relative;
    margin-top: .25rem;
    font-size: .8125rem;
}

/* Page Notifications */
.notif-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--rv-border);
}

.notif-filter-kind {
    width: min(280px, 100%);
}

.notif-filter-count {
    margin-left: auto;
    color: var(--rv-muted);
    font-size: .875rem;
}

.notif-list-page .notif-item {
    padding: 1rem 1.25rem;
}

/* Message de l'équipe Fovix : texte en entier, comme une mise en avant du DSFR */
.notif-list-page .notif-item.is-fovix .notif-text {
    margin-top: .5rem;
    padding-left: .875rem;
    border-left: 2px solid var(--rv-primary);
}

.notif-more {
    padding: 1rem;
    border-top: 1px solid var(--rv-border);
    text-align: center;
}

.notif-composer {
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    box-shadow: inset 4px 0 0 var(--rv-primary);
}

.notif-composer-title {
    margin-bottom: .25rem;
    font-size: 1.25rem;
    font-weight: 700;
}

html[data-theme="dark"] .notif-count,
html[data-theme="dark"] .notif-nav-count,
html[data-theme="dark"] .notif-unread-tag {
    color: #161616;
}

html[data-theme="dark"] .segmented {
    background: var(--rv-surface-2);
}
