:root {

    --color-bg: #111827;

    --panel-bg: #243244;
    --panel-bg-secondary: #1f2937;

    --panel-header: #273548;

    --panel-border: #405067;

    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;

    --radius: 12px;

}

.card,
.card,
.driver-card,
.info-card,
.hero-item {
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
}

.app-navigation {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;

    margin-top: 25px;
    z-index: 2;
}

.app-navigation a {
    justify-content: center;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: 8px;
    background: #2b2b2b;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
}

.app-navigation a:hover {
    background: #3a3a3a;
}

.app-navigation a.active {
    background: #0d6efd;
}

#live-trackmap {
    display: block;
    width: 100%;
    max-width: 800px;
    height: auto;
    max-height: 600px;
    margin: 20px auto;
}

/* ==========================================================
   Layout
   ========================================================== */

.page-container {
    max-width: 1450px;
    margin: 25px auto;
    padding: 0 30px 25px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 28px;
    align-items: start;
}

@media (max-width: 1000px) {

    .grid-2 {
        grid-template-columns: 1fr;
    }

}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

/* ==========================================================
   Cards
   ========================================================== */

body {
    margin: 0;
    background: #111827;
    color: #f3f4f6;
    font-family: Arial, Helvetica, sans-serif;
}

.card {
    background: var(--panel-bg);
    margin-bottom: 18px;
}

.card-header {

    display: flex;

    justify-content: space-between;

    align-items: center;

    gap: 12px;

    margin: -20px -20px 20px;

    padding: 18px 20px;

    padding-right: 180px;

    background: #273548;

    border-bottom: 1px solid #3f4b5c;

    border-radius: 12px 12px 0 0;

}

.broadcast-status {

    font-size: 0.75rem;

    font-weight: 400;

    color: #cbd5e1;

    white-space: nowrap;

    margin-left: auto;

}

.card-title {
    font-size: 18px;
    font-weight: 700;
}

.card-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 20px;
}

/* ==========================================================
   Records
   ========================================================== */

.records-actions {

    margin-left: auto;

}

.records-actions form {

    margin: 0;

}

.records-page {
    gap: 18px;
}

.records-layout-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.records-layout-card {
    color: inherit;
    text-decoration: none;
    transition: transform .15s ease, border-color .15s ease;
}

.records-layout-card:hover,
.records-layout-card:focus-visible {
    transform: translateY(-2px);
    border-color: rgba(250, 204, 21, .55);
}

.records-search {
    width: min(100%, 560px);
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 8px;
    background: rgba(0, 0, 0, .22);
    color: inherit;
}

.records-search-label {
    font-weight: 700;
}

.records-unresolved-note,
.records-search-empty,
.records-empty,
.records-no-lap {
    color: var(--text-muted, #aeb7c4);
}

.records-unresolved-note {
    margin: 0;
    font-size: .9rem;
}

.records-card-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
}

.records-card-stats span {
    white-space: nowrap;
}

.records-card-stats-large {
    gap: 12px 24px;
}

.records-pilot-link {
    color: inherit;
    font-weight: 700;
}

.records-back a {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 7px 12px;
    border: 1px solid rgba(148, 163, 184, .28);
    border-radius: 8px;
    background: rgba(255, 255, 255, .045);
    color: inherit;
    font-size: .9rem;
    font-weight: 600;
    text-decoration: none;
    transition: background-color .15s ease, border-color .15s ease;
}

.records-back a:hover,
.records-back a:focus-visible {
    border-color: rgba(148, 178, 209, .48);
    background: rgba(148, 178, 209, .1);
}

.records-layout-header {
    align-items: flex-start;
    gap: 12px;
}

.records-class-filter {
    display: flex;
    align-items: center;
    gap: 8px;
}

.records-class-filter select {
    max-width: 320px;
    padding: 7px 9px;
}

.records-class-group + .records-class-group {
    margin-top: 18px;
}

.records-class-group h2 {
    margin: 0 0 8px;
    font-size: 1rem;
}

.records-table-wrap {
    overflow-x: auto;
}

.records-champion-row {
    background: rgba(214, 174, 70, .075);
    box-shadow: inset 3px 0 0 rgba(214, 174, 70, .62);
}

.records-champion-row td {
    border-top-color: rgba(214, 174, 70, .2);
    border-bottom-color: rgba(214, 174, 70, .2);
}

.records-champion-row .records-time-link,
.records-champion-row td:last-child {
    color: #f0d58a;
    font-weight: 700;
}

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

    .records-card-stats-large {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ==========================================================
   Buttons
   ========================================================== */

.btn {

    display: inline-flex;

    align-items: center;

    justify-content: center;

    gap: 6px;

    padding: 8px 14px;

    border: none;

    border-radius: 6px;

    font-size: .9rem;

    font-weight: 600;

    cursor: pointer;

    transition:
        background .2s,
        transform .15s;

}

.btn:hover {

    transform: translateY(-1px);

}

.btn-primary {

    background: #2563eb;

    color: #ffffff;

}

.btn-primary:hover {

    background: #1d4ed8;

}

.btn-danger {

    background: #dc2626;

    color: #ffffff;

}

.btn-danger:hover {

    background: #b91c1c;

}

.btn-link {

    display: inline-flex;

    align-items: center;

    justify-content: center;

    gap: 6px;

    padding: 8px 14px;

    border-radius: 6px;

    background: #2563eb;

    color: #ffffff;

    text-decoration: none;

    font-weight: 600;

    transition:
        background .2s,
        transform .15s;

}

.btn-link:hover {

    background: #1d4ed8;

    transform: translateY(-1px);

}

/* ==========================================================
   Driver Cards
   ========================================================== */

.driver-card {
    background: #273548;
    border: 1px solid #3f4b5c;
    border-radius: 12px;
    border-radius: var(--radius);
    padding: 16px;
    transition: .2s ease;
}

.driver-card:hover {
    border-color: #3b82f6;
    transform: translateY(-2px);
}

.driver-header {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 14px;
    color: #fff;
}

.driver-body {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.driver-body div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.driver-body div span {
    color: #bbb;
}

.driver-delta {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #374151;
    text-align: center;
    font-size: 24px;
    font-weight: 700;
}

/* ==========================================================
   Information Cards
   ========================================================== */

.card-subtitle {
    margin-top: 10px;
    font-size: 1.35rem;
    font-weight: 600;
}

.card-description {
    margin-top: 4px;
    opacity: .8;
    font-size: .95rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.info-card {
    background: var(--panel-bg-secondary);
    padding: 16px;
}

.info-card-full {
    grid-column: 1 / -1;
}

.info-label {
    color: #9ca3af;
    font-size: .85rem;
    margin-bottom: 6px;
}

.info-value {
    font-size: 1.1rem;
    font-weight: 600;
}

.info-description {
    margin-top: 4px;
    color: #d1d5db;
}

/* ===========================
   Progression du pilote
   =========================== */

.progress {

    width: 100%;
    height: 12px;

    margin-top: 20px;

    border-radius: 999px;

    overflow: hidden;

    background: rgba(255, 255, 255, .08);

}

.progress-bar {

    height: 100%;

    background: linear-gradient(90deg,
            #3b82f6,
            #22c55e);

    transition: width .4s ease;

}

.progress-text {

    margin-top: 8px;

    text-align: center;

    font-size: .85rem;

    color: #94a3b8;

}

.section-spacing {
    margin-top: 20px;
}

/* ==========================================================
   Tables
   ========================================================== */

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px 16px;
    vertical-align: middle;
}

.table th {
    border-bottom: 1px solid var(--panel-border);
    font-size: .95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.table td {
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.table tbody tr:hover {
    background: rgba(255, 255, 255, .03);
}

.table th:first-child,
.table td:first-child {
    text-align: left;
    white-space: nowrap;
}

.table th:not(:first-child),
.table td:not(:first-child) {
    text-align: center;
}

.table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.03);
}

.table tbody tr:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* ==========================================================
   Metrics
   ========================================================== */

.metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 10px 0;
    border-bottom: 1px solid #374151;
}

.metric:last-child {
    border-bottom: none;
}

.metric-label {
    color: #9ca3af;
    font-weight: 500;
}

.metric-value {
    color: #ffffff;
    font-size: 16px;
}

/* ==========================================================
   Navigation
   ========================================================== */

.nav-toggle {

    position: absolute;

    top: 20px;
    right: 20px;

    display: flex;
    align-items: center;
    gap: 8px;

    padding: 10px 18px;

    background: rgba(25, 35, 50, .85);

    color: #ffffff;

    border: 1px solid rgba(255, 255, 255, .15);

    border-radius: 10px;

    font-size: .95rem;
    font-weight: 600;

    cursor: pointer;

    transition:
        background .2s,
        transform .2s;

    z-index: 1000;

}

.nav-toggle:hover {

    background: rgba(40, 55, 75, .95);

    transform: translateY(-1px);

}

.app-navigation {

    position: absolute;

    top: 70px;
    right: 20px;

    display: flex;
    flex-direction: column;

    gap: 8px;

    padding: 12px;

    background: rgba(20, 30, 45, .96);

    border: 1px solid var(--panel-border);

    border-radius: 12px;

    opacity: 0;
    visibility: hidden;

    transform: translateY(-10px);

    transition:
        opacity .25s,
        transform .25s,
        visibility .25s;

    z-index: 999;

}

.app-navigation.open {

    opacity: 1;

    visibility: visible;

    transform: translateY(0);

}

.app-navigation a {

    min-width: 220px;

}

/* ==========================================================
   Public Header
   ========================================================== */

.site-header {
    position: relative;
    background:
        linear-gradient(rgba(18, 30, 46, .40),
            rgba(18, 30, 46, .75)),
        url("../img/banner-header.png");

    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;

    min-height: 340px;

    display: flex;
    align-items: flex-end;
    justify-content: center;

    padding-top: 0;
    padding-right: 20px;
    padding-bottom: 35px;
    padding-left: 20px;

    box-shadow:
        inset 0 -80px 120px rgba(17, 24, 39, .65),
        0 8px 25px rgba(0, 0, 0, .25);
}

.site-brand {
    max-width: 1450px;
    margin: 0 auto 20px;

    padding-left: 260px;
    text-align: left;
}

.site-brand h1 {

    margin: 0;
    font-size: 38px;
    color: #fff;

    text-shadow: 0 3px 10px rgba(0, 0, 0, .8);

}

.site-brand p {

    margin-top: 12px;

    color: #e5e7eb;

    font-size: 18px;

    text-shadow: 0 2px 8px rgba(0, 0, 0, .8);

}

/* ==========================================================
   User Bar
   ========================================================== */

.user-info {

    display: flex;

    flex-direction: column;

    gap: 2px;

}

.user-name {

    color: #111827;

    font-size: 1.15rem;

    font-weight: 700;

    line-height: 1.2;

}

.user-role {

    color: #6b7280;

    font-size: .80rem;

    font-weight: 500;

    letter-spacing: .04em;

}

.user-bar {

    display: flex;

    justify-content: space-between;

    align-items: center;

    max-width: 1450px;

    margin: 0 auto;

    padding: 10px 24px;

}

.user-account {

    display: inline-flex;

    align-items: center;

    padding: 12px 18px;

    text-decoration: none;

    color: inherit;

    border-radius: 8px;

    transition: background .2s;

}

.user-account:hover {

    background: rgba(17, 24, 39, .05);

}

/* ==========================================================
   Hero
   ========================================================== */

.hero {

    max-width: 1450px;
    margin: 0 auto 30px;

    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 18px;

}

.hero-item {
    background: var(--panel-bg);
}

/* ==========================================================
   Responsive Mobile
   ========================================================== */

@media (max-width: 768px) {

    .site-header {
        min-height: 220px;
        padding: 0 15px 20px;
        background-size: cover;
        background-position: center top;
    }

    .app-navigation {
        gap: 4px;
    }

    .app-navigation a {
        padding: 8px 12px;
        font-size: 15px;
    }

    .page-container {
        padding: 0 15px 30px;
        margin-top: 20px;
    }

    .hero-item {
        min-width: 140px;
        max-width: none;
        font-size: 15px;
        padding: 12px;
    }

}

/* ===========================
   Journal du wizard
   =========================== */

.wizard-log {

    margin: 0;

    padding: 16px;

    background: #111827;

    border-radius: 8px;

    overflow-x: auto;

    white-space: pre-wrap;

    font-family: Consolas, monospace;

    font-size: .90rem;

    line-height: 1.5;

    color: #d1d5db;

}

.wizard-success {

    color: #22c55e;
    font-weight: bold;

}

.wizard-error {

    color: #ef4444;
    font-weight: bold;

}

.wizard-total {

    color: #60a5fa;
    font-weight: bold;

}

/* ===========================
   Message serveur
   =========================== */

.server-message {

    margin-top: 15px;

    padding: 12px 16px;

    border-radius: 8px;

    background: #1e293b;

    font-weight: 600;

    display: flex;

    align-items: center;

}

.server-message.running {

    color: #facc15;

}

.server-message.success {

    color: #22c55e;

}

#server-actions button:disabled {

    opacity: .55;

    cursor: not-allowed;

}

.server-running {
    color: #3ecf6d;
    font-weight: 600;
}

.server-stopped {
    color: #e74c3c;
    font-weight: 600;
}

/* ==========================================
   Outils Windows
   ========================================== */

.windows-tools-description {
    opacity: .8;
    margin-bottom: 15px;
}

.windows-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.windows-tools .btn-link {

    min-width: 260px;

}

/* ==========================================
   steam.php
   ========================================== */

#officialSearch {
    width: 100%;
    box-sizing: border-box;
}

.search-box {
    position: relative;
}

.search-box input {
    width: 100%;
}

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

[data-collapse-target] {
    cursor: pointer;
    user-select: none;
}

.card-collapse-arrow {
    margin-left: auto;
    padding-left: 12px;
    opacity: 0.8;
    font-size: 0.9rem;
}

.card-collapsed {
    display: none !important;
}

.driver-card.selected {

    border: 2px solid #22c55e;

    box-shadow: 0 0 10px rgba(34, 197, 94, .35);

}

/* =========================================
   Driver level up
   ========================================= */

.driver-card.level-up {
    animation: driver-level-up 1s ease-in-out infinite alternate;
}

.driver-card .level-up-message {
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 8px;
    letter-spacing: 0.04em;
}

@keyframes driver-level-up {
    from {
        box-shadow:
            0 0 6px rgba(250, 204, 21, 0.35);
        transform: scale(1);
    }

    to {
        box-shadow:
            0 0 22px rgba(250, 204, 21, 0.85);
        transform: scale(1.015);
    }
}

/* Progression XP pilote */

.driver-progression {
    margin-bottom: 2px;
}

.driver-xp-bar {
    height: 3px;
    margin-top: 3px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(148, 163, 184, 0.18);
}

.driver-xp-bar-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg,
            #3b82f6,
            #22c55e);
    transition: width 0.25s linear;
}
/* ==========================================================
   Public Header - bannière fixe au scroll
   ========================================================== */
@media (min-width: 769px) {

    body:not(.admin) .site-header {
        position: sticky;
        top: 0;
        z-index: 0;
    }

    body:not(.admin) .hero,
    body:not(.admin) .page-container {
        position: relative;
        z-index: 1;
    }

    body:not(.admin) .site-header:has(.app-navigation.open) {
        z-index: 1001;
    }
}
/* FCM Telemetry ---------------------------------------------------------- */

.fcm-telemetry-activation {
    align-items: center;
    gap: 0.4rem;
}

.fcm-telemetry-activate {
    color: #8fc2ff;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.fcm-telemetry-activate:hover,
.fcm-telemetry-activate:focus-visible {
    text-decoration: underline;
}

/* FCM Telemetry - pneus live */
.fcm-tire-live {
    display: grid;
    grid-template-columns: repeat(2, max-content);
    column-gap: 18px;
    row-gap: 1px;
    margin: 1px 0 2px 24px;
    font-size: 12px;
    line-height: 1.15;
}

.fcm-tire-cell {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    min-width: 58px;
}

.fcm-tire-cell strong {
    min-width: 25px;
    text-align: right;
}

.fcm-tire-cell small {
    opacity: .65;
    font-size: 10px;
}

.floating-driver-tires-brakes {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 1px 0 2px 24px;
}

.floating-driver-tires-brakes .fcm-tire-live {
    flex: 0 1 auto;
    margin: 0;
}

.floating-driver-brakes {
    flex: 0 0 auto;
    display: grid;
    grid-template-rows: repeat(3, auto);
    gap: 1px;
    padding-left: 10px;
    border-left: 1px solid rgba(148, 163, 184, .28);
    font-size: 11px;
    line-height: 1.15;
    text-align: right;
}

.floating-driver-brakes small {
    color: #94a3b8;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.floating-driver-brakes span {
    min-width: 38px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
    .floating-driver-tires-brakes {
        gap: 7px;
        margin-left: 12px;
    }

    .floating-driver-brakes {
        padding-left: 7px;
        font-size: 10px;
    }
}

/*
 * Première calibration visuelle proche du HUD rFactor 2.
 * Les seuils pourront être affinés ensuite sans toucher
 * aux données télémétriques.
 */
.tire-temp-cold {
    color: #3b82f6;
}

.tire-temp-warm {
    color: #a855f7;
}

.tire-temp-hot {
    color: #f97316;
}

.tire-temp-very-hot {
    color: #ef4444;
}

.tire-temp-overheat {
    color: #facc15;
}

/* Calibration thermique pneus proche du HUD rFactor 2 */
.tire-temp-cold {
    color: #3b82f6;
}

.tire-temp-warm {
    color: #8b5cf6;
}

.tire-temp-working {
    color: #ec4899;
}

.tire-temp-hot {
    color: #ef4444;
}

.tire-temp-very-hot {
    color: #f97316;
}

.tire-temp-overheat {
    color: #facc15;
}

/* =========================================================
   Fiche pilote détachable / flottante
   ========================================================= */

.driver-card {
    position: relative;
}

.driver-detach-button {
    position: absolute;
    top: 7px;
    right: 7px;
    z-index: 3;

    width: 28px;
    height: 28px;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 0;

    border: 1px solid rgba(148, 163, 184, .35);
    border-radius: 7px;

    background: rgba(15, 23, 42, .82);
    color: #e2e8f0;

    font-size: 15px;
    line-height: 1;

    cursor: pointer;

    opacity: .65;
    transition:
        opacity .15s ease,
        border-color .15s ease,
        background .15s ease;
}

.driver-detach-button:hover,
.driver-detach-button:focus-visible {
    opacity: 1;
    border-color: #3b82f6;
    background: rgba(30, 41, 59, .96);
}

.floating-driver-window {
    position: fixed;

    z-index: 10000;

    width: min(
        340px,
        calc(100vw - 24px)
    );

    max-height:
        calc(100dvh - 24px);

    overflow: hidden;

    border:
        1px solid
        rgba(96, 165, 250, .55);

    border-radius: 14px;

    background: #1e293b;

    box-shadow:
        0 18px 50px
        rgba(0, 0, 0, .48);

    backdrop-filter: blur(8px);

    -webkit-backdrop-filter:
        blur(8px);
}

.floating-driver-toolbar {
    height: 42px;

    display: flex;
    align-items: stretch;

    border-bottom:
        1px solid
        rgba(148, 163, 184, .20);

    background:
        rgba(15, 23, 42, .96);
}

.floating-driver-handle {
    min-width: 0;
    flex: 1;

    display: flex;
    align-items: center;

    gap: 8px;

    padding:
        0 8px
        0 12px;

    color: #cbd5e1;

    cursor: grab;

    /*
     * Important :
     * empêche le navigateur de transformer
     * le déplacement en scroll tactile.
     */
    touch-action: none;

    user-select: none;
    -webkit-user-select: none;
}

.floating-driver-handle.dragging {
    cursor: grabbing;
}

.floating-driver-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    font-size: 13px;
}

.floating-driver-close {
    width: 42px;
    min-width: 42px;

    border: 0;
    border-left:
        1px solid
        rgba(148, 163, 184, .16);

    background: transparent;
    color: #cbd5e1;

    font-size: 24px;
    line-height: 1;

    cursor: pointer;
}

.floating-driver-close:hover,
.floating-driver-close:focus-visible {
    background:
        rgba(239, 68, 68, .14);

    color: #fff;
}

.floating-driver-content {
    max-height:
        calc(100dvh - 66px);

    overflow-y: auto;
    overflow-x: hidden;

    overscroll-behavior: contain;

    -webkit-overflow-scrolling:
        touch;
}

.floating-driver-card-clone {
    margin: 0;

    border: 0 !important;
    border-radius: 0 0 13px 13px;

    box-shadow: none !important;

    transform: none !important;
}

.floating-driver-card-clone:hover {
    transform: none !important;
}

.floating-driver-card-clone
.driver-detach-button {
    display: none;
}

/*
 * Sur un appareil tactile, le bouton de détachement
 * reste toujours bien visible.
 */
@media (hover: none) {

    .driver-detach-button {
        opacity: 1;

        width: 32px;
        height: 32px;
    }
}

/* Tablette */
@media (max-width: 1024px) {

    .floating-driver-window {
        width: min(
            330px,
            calc(100vw - 20px)
        );
    }
}

/* Téléphone */
@media (max-width: 640px) {

    .floating-driver-window {
        width: min(
            320px,
            calc(100vw - 16px)
        );

        max-height: 76dvh;

        border-radius: 12px;
    }

    .floating-driver-toolbar {
        height: 46px;
    }

    .floating-driver-content {
        max-height:
            calc(76dvh - 46px);
    }

    .floating-driver-close {
        width: 46px;
        min-width: 46px;
    }

    .floating-driver-handle {
        padding-left: 10px;
    }
}

/* =========================================================
   Copie / partage fiche pilote
   ========================================================= */

.driver-copy-button {
    position: absolute;
    top: 7px;
    right: 42px;
    z-index: 3;

    width: 28px;
    height: 28px;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 0;

    border: 1px solid rgba(148, 163, 184, .35);
    border-radius: 7px;

    background: rgba(15, 23, 42, .82);
    color: #e2e8f0;

    font-size: 14px;
    line-height: 1;

    cursor: pointer;

    opacity: .65;

    transition:
        opacity .15s ease,
        border-color .15s ease,
        background .15s ease;
}

.driver-copy-button:hover,
.driver-copy-button:focus-visible {
    opacity: 1;
    border-color: #22c55e;
    background: rgba(30, 41, 59, .96);
}

@media (hover: none) {

    .driver-copy-button {
        opacity: 1;

        width: 32px;
        height: 32px;

        right: 46px;
    }
}

/*
 * =========================================================
 * Sessions - lecture secteurs / usure pneus
 * =========================================================
 */

/*
 * La page publique conserve son habillage, mais adopte sur desktop
 * une densite proche de l'administration. Les dimensions mobiles
 * generiques restent volontairement inchangees.
 */
@media (min-width: 1025px) {

    .sessions-page-public .card-body {
        gap: 10px;
        padding: 12px 16px;
    }

    .sessions-page-public .info-grid {
        grid-template-columns:
            repeat(auto-fit, minmax(180px, 1fr));
        gap: 10px;
    }

    .sessions-page-public .info-card {
        padding: 10px 12px;
    }

    .sessions-page-public .info-label {
        margin-bottom: 3px;
        font-size: .75rem;
        line-height: 1.2;
    }

    .sessions-page-public .info-value {
        font-size: .95rem;
        line-height: 1.25;
    }

    .sessions-page-public #session-live-laps .card-body {
        overflow-x: auto;
    }

    .sessions-page-public #session-live-laps .table {
        font-size: .82rem;
        line-height: 1.2;
    }

    .sessions-page-public #session-live-laps .table th,
    .sessions-page-public #session-live-laps .table td {
        padding: 7px 8px;
    }

    .sessions-page-public #session-live-laps .table th {
        font-size: .78rem;
        white-space: nowrap;
    }

    .sessions-page-public .session-sector-comparison {
        min-width: 62px;
        padding: 4px 5px;
    }

    .sessions-page-public .session-sector-comparison strong {
        font-size: .8rem;
    }

    .sessions-page-public .session-tyre-wear-grid {
        grid-template-columns:
            repeat(2, minmax(48px, 1fr));
        gap: 3px;
        min-width: 104px;
    }

    .sessions-page-public .session-tyre-wear {
        gap: 4px;
        padding: 3px 5px;
    }

    .sessions-page-public .session-tyre-wear small {
        font-size: .58rem;
    }

    .sessions-page-public .session-tyre-wear strong {
        font-size: .7rem;
    }
}

.session-sector-comparison {
    min-width: 74px;
    padding: 5px 7px;
    border: 1px solid transparent;
    border-radius: 7px;
    line-height: 1.15;
    text-align: center;
}

.session-sector-comparison strong {
    display: block;
    white-space: nowrap;
    font-size: .9rem;
}

.session-sector-comparison small {
    display: block;
    margin-top: 3px;
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .02em;
}

/* Meilleur absolu de la session */
.session-sector-comparison.is-session-best {
    border-color: rgba(192, 132, 252, .55);
    background: rgba(168, 85, 247, .13);
    color: #d8b4fe;
}

/* Meilleur personnel du pilote */
.session-sector-comparison.is-personal-best {
    border-color: rgba(74, 222, 128, .45);
    background: rgba(34, 197, 94, .11);
    color: #86efac;
}

/* Plus lent que son PB */
.session-sector-comparison.is-slower {
    color: #facc15;
}

.session-sector-comparison.is-slower small {
    color: #a8a29e;
}


/*
 * Usure restante des quatre pneus.
 */
.session-tyre-wear-grid {
    display: grid;
    grid-template-columns:
        repeat(2, minmax(58px, 1fr));
    gap: 5px;
    min-width: 128px;
}

.session-tyre-wear {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;

    padding: 5px 7px;

    border: 1px solid transparent;
    border-radius: 7px;

    white-space: nowrap;
}

.session-tyre-wear small {
    font-size: .65rem;
    font-weight: 800;
    opacity: .82;
}

.session-tyre-wear strong {
    font-size: .78rem;
}

.session-tyre-wear.is-green {
    border-color: rgba(34, 197, 94, .45);
    background: rgba(34, 197, 94, .12);
    color: #86efac;
}

.session-tyre-wear.is-yellow {
    border-color: rgba(234, 179, 8, .48);
    background: rgba(234, 179, 8, .12);
    color: #fde047;
}

.session-tyre-wear.is-red {
    border-color: rgba(239, 68, 68, .50);
    background: rgba(239, 68, 68, .13);
    color: #fca5a5;
}

.session-tyre-wear.is-empty {
    border-color: #334155;
    background: rgba(15, 23, 42, .35);
    color: #64748b;
}

/*
 * Sessions - légende compacte des secteurs
 */
.session-sector-legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px 14px;

    margin: 0 0 12px;
    padding: 6px 10px;

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

.session-sector-legend span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.session-sector-legend i {
    width: 9px;
    height: 9px;
    border-radius: 3px;
    display: inline-block;
}

.session-sector-legend i.is-purple {
    background: #a855f7;
}

.session-sector-legend i.is-green {
    background: #22c55e;
}

.session-sector-legend i.is-yellow {
    background: #eab308;
}

.session-sector-legend-ideal {
    color: #a5b4fc;
}

.session-sector-comparison.is-session-best small {
    font-size: .58rem;
    letter-spacing: 0;
    white-space: nowrap;
}

/* Tour idéal : rester sur une seule ligne */
.session-ideal-compact {
    font-size: .68rem;
    white-space: nowrap;
    letter-spacing: -.01em;
}

.session-ideal-compact strong,
.session-ideal-compact span {
    white-space: nowrap;
}

/*
 * Historique -> détail du tour
 */
.history-lap-link,
.history-lap-link:visited {
    color: #7fc3ff;
    font-weight: 700;
    text-decoration: none;
}

.history-lap-link:hover {
    color: #b9ddff;
    text-decoration: underline;
}

.history-lap-time {
    font-variant-numeric: tabular-nums;
}

/*
 * Tour ciblé depuis l'historique.
 * Le fragment #lap-ID provoque aussi le scroll navigateur.
 */
.session-lap-row {
    scroll-margin-top: 110px;
}

.session-lap-row:target {
    outline: 2px solid rgba(168, 85, 247, .75);
    outline-offset: -2px;
    background: rgba(168, 85, 247, .12);
}

/* Historique : lignes ouvrant directement la session */
.history-clickable-row {
    cursor: pointer;
}

.history-clickable-row:hover td {
    background: rgba(77, 163, 255, .08);
}

.history-clickable-row:hover .history-lap-link {
    color: #b9ddff;
}

/*
 * Historique - record circuit + catégorie
 */
.history-class-best-time {
    display: inline-flex;
    align-items: center;
    gap: 5px;

    padding: 3px 7px;

    border: 1px solid rgba(250, 204, 21, .38);
    border-radius: 7px;

    background: rgba(250, 204, 21, .08);
    color: #fde68a;

    font-weight: 800;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.history-best-trophy {
    font-size: .78rem;
}

/* =========================================================
   Records — chronos et références
   ========================================================= */

.records-time-link {
    color: inherit;
    font-weight: 700;
    text-decoration: none;
    font-variant-numeric: tabular-nums;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.28);
    transition:
        color 0.15s ease,
        border-color 0.15s ease;
}

.records-time-link:visited {
    color: inherit;
}

.records-time-link:hover,
.records-time-link:focus-visible {
    color: #ffffff;
    border-bottom-color: rgba(255, 255, 255, 0.8);
}

.record-status {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;

    padding: 0.28rem 0.55rem;

    border: 1px solid transparent;
    border-radius: 0.45rem;

    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1.15;

    white-space: nowrap;
}

.record-status-first {
    color: #ffd86b;
    background: rgba(255, 193, 7, 0.10);
    border-color: rgba(255, 193, 7, 0.38);
}

.record-status-new {
    color: #72e0a6;
    background: rgba(46, 204, 113, 0.10);
    border-color: rgba(46, 204, 113, 0.38);
}

.record-status-equal {
    color: #c8a9ff;
    background: rgba(155, 89, 182, 0.12);
    border-color: rgba(155, 89, 182, 0.42);
}

.record-status-behind {
    color: #ffd36a;
    background: rgba(241, 196, 15, 0.09);
    border-color: rgba(241, 196, 15, 0.32);
}


.record-reference-link,
.record-reference-link:visited {
    display: inline-block;
    color: inherit;
    text-decoration: none;
}

.record-reference-link:hover .record-status,
.record-reference-link:focus-visible .record-status {
    filter: brightness(1.15);
}

.record-reference-link:focus-visible {
    outline: none;
}


/* =========================================================
   Profil pilote — navigation Circuits / Voitures
   ========================================================= */

.pilot-stat-link,
.pilot-stat-link:visited {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.24);
}

.pilot-stat-link:hover,
.pilot-stat-link:focus-visible {
    color: #ffffff;
    border-bottom-color: rgba(255, 255, 255, 0.75);
}

.pilot-stat-time {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}


/* =========================================================
   Profil pilote — finition navigation Circuits / Voitures
   ========================================================= */

.pilot-stats-table tbody tr {
    transition:
        background-color 0.15s ease,
        box-shadow 0.15s ease;
}

.pilot-stats-table tbody tr:hover {
    background: rgba(139, 92, 246, 0.055);
    box-shadow:
        inset 3px 0 0 rgba(167, 139, 250, 0.45);
}

.pilot-stats-table .pilot-stat-link,
.pilot-stats-table .pilot-stat-link:visited {
    display: inline-flex;
    align-items: center;

    margin: -0.18rem -0.28rem;
    padding: 0.18rem 0.28rem;

    border: 0;
    border-radius: 0.32rem;

    color: inherit;
    text-decoration: none;

    transition:
        color 0.15s ease,
        background-color 0.15s ease;
}

.pilot-stats-table .pilot-stat-link:hover,
.pilot-stats-table .pilot-stat-link:focus-visible {
    color: #ffffff;
    background: rgba(139, 92, 246, 0.14);
    outline: none;
}

/* Nom du circuit / voiture */
.pilot-stats-table td:first-child .pilot-stat-link {
    font-weight: 500;
}

/* Petit indicateur visuel de navigation */
.pilot-stats-table td:first-child .pilot-stat-link::after {
    content: "›";
    margin-left: 0.35rem;

    color: rgba(196, 181, 253, 0);
    transform: translateX(-3px);

    transition:
        color 0.15s ease,
        transform 0.15s ease;
}

.pilot-stats-table td:first-child .pilot-stat-link:hover::after,
.pilot-stats-table td:first-child .pilot-stat-link:focus-visible::after {
    color: rgba(196, 181, 253, 0.9);
    transform: translateX(0);
}

/* Meilleurs chronos */
.pilot-stats-table .pilot-stat-time {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Dernière session */
.pilot-stats-table td:last-child .pilot-stat-link {
    color: rgba(255, 255, 255, 0.88);
    font-variant-numeric: tabular-nums;
}

.pilot-stats-table td:last-child .pilot-stat-link:hover,
.pilot-stats-table td:last-child .pilot-stat-link:focus-visible {
    color: #ffffff;
}


/* =========================================================
   Profil pilote — rendre les liens identifiables
   ========================================================= */

.pilot-stats-table .pilot-stat-link {
    cursor: pointer;
}

/* Nom circuit / voiture : flèche visible en permanence */
.pilot-stats-table td:first-child .pilot-stat-link::after {
    content: "›";
    margin-left: 0.4rem;

    color: rgba(196, 181, 253, 0.60);
    transform: none;
}

/* Chronos et dates : indication discrète de lien */
.pilot-stats-table .pilot-stat-time,
.pilot-stats-table td:last-child .pilot-stat-link {
    border-bottom: 1px dotted rgba(196, 181, 253, 0.45);
    border-radius: 0;
}

/* Survol un peu plus explicite */
.pilot-stats-table .pilot-stat-time:hover,
.pilot-stats-table td:last-child .pilot-stat-link:hover {
    border-bottom-color: rgba(196, 181, 253, 0.95);
}


/* =========================================================
   Profil pilote — tri des statistiques
   ========================================================= */

.pilot-sortable-header {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.pilot-sortable-header::after {
    content: " ⇅";
    margin-left: 0.3rem;
    color: rgba(196, 181, 253, 0.38);
    font-size: 0.8em;
}

.pilot-sortable-header[data-sort-direction="asc"]::after {
    content: " ▲";
    color: rgba(196, 181, 253, 0.95);
}

.pilot-sortable-header[data-sort-direction="desc"]::after {
    content: " ▼";
    color: rgba(196, 181, 253, 0.95);
}

.pilot-sortable-header:hover {
    color: #ffffff;
}


/* =========================================================
   Historique — tri des chronos
   ========================================================= */

.history-sortable-header {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.history-sortable-header::after {
    content: " ⇅";
    margin-left: 0.3rem;

    color: rgba(196, 181, 253, 0.38);
    font-size: 0.8em;
}

.history-sortable-header[data-sort-direction="asc"]::after {
    content: " ▲";
    color: rgba(196, 181, 253, 0.95);
}

.history-sortable-header[data-sort-direction="desc"]::after {
    content: " ▼";
    color: rgba(196, 181, 253, 0.95);
}

.history-sortable-header:hover,
.history-sortable-header:focus-visible {
    color: #ffffff;
    outline: none;
}


/*
 * =========================================================
 * Carte pilote flottante — télémétrie / stratégie essence
 * =========================================================
 */

.floating-driver-card-clone .floating-driver-extra-telemetry,
.floating-driver-card-clone .floating-driver-fuel-strategy {
    grid-column: 1 / -1;
}

.floating-driver-extra-telemetry {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.floating-driver-extra-telemetry > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.floating-driver-fuel-strategy {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.floating-driver-fuel-title {
    display: block;
}

.floating-driver-fuel-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 5px 12px;
    align-items: baseline;
}

.floating-driver-fuel-grid strong {
    text-align: right;
}

.floating-driver-fuel-verdict {
    margin-top: 2px;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
}

@media (max-width: 640px) {
    .floating-driver-extra-telemetry {
        grid-template-columns: 1fr 1fr;
    }

    .floating-driver-fuel-grid {
        gap: 4px 8px;
    }
}

/*
 * =========================================================
 * TrackMap — Relative du pilote sélectionné
 * =========================================================
 */

#trackmap-container {
    position: relative;
}

.trackmap-relative {
    position: absolute;

    z-index: 9950;

    left: 50%;
    top: 140px;

    transform:
        translateX(-50%);

    width: min(
        340px,
        calc(100vw - 20px)
    );

    margin: 0;
    padding: 8px 12px;

    border:
        1px solid
        rgba(96, 165, 250, .32);

    border-radius: 9px;

    background:
        rgba(15, 23, 42, .94);

    box-shadow:
        0 10px 30px
        rgba(0, 0, 0, .30);

    backdrop-filter:
        blur(6px);

    -webkit-backdrop-filter:
        blur(6px);
}

.trackmap-relative[hidden] {
    display: none !important;
}

.trackmap-relative {
    cursor: grab;
    touch-action: none;

    user-select: none;
    -webkit-user-select: none;
}

.trackmap-relative.dragging {
    cursor: grabbing;
}

.trackmap-relative-row {
    min-width: 0;

    display: grid;

    grid-template-columns:
        78px minmax(0, 1fr);

    gap: 9px;

    align-items: baseline;

    padding: 2px 0;

    font-size: .82rem;
}

.trackmap-relative-row > span {
    color: #94a3b8;

    white-space: nowrap;
}

.trackmap-relative-row > strong {
    min-width: 0;

    display: flex;

    justify-content:
        space-between;

    align-items: baseline;

    gap: 10px;
}

.trackmap-relative-name {
    min-width: 0;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.trackmap-relative-gap {
    flex: 0 0 auto;

    color: #f1f5f9;

    font-weight: 700;

    font-variant-numeric:
        tabular-nums;
}

.trackmap-relative-center {
    display: flex;

    align-items: center;
    justify-content: center;

    gap: 5px;

    margin: 4px -4px;
    padding: 5px 6px;

    border-top:
        1px solid
        rgba(148, 163, 184, .18);

    border-bottom:
        1px solid
        rgba(148, 163, 184, .18);

    color: #94a3b8;

    font-size: .79rem;

    cursor: inherit;
}

.trackmap-relative-center strong {
    color: #ffffff;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.trackmap-relative-dot {
    color: #60a5fa;
}

@media (max-width: 640px) {

    .trackmap-relative {
        width:
            calc(100vw - 16px);

        padding:
            7px 10px;
    }

    .trackmap-relative-row {
        grid-template-columns:
            72px minmax(0, 1fr);

        gap: 7px;

        font-size: .78rem;
    }

    .trackmap-relative-center {
        font-size: .76rem;
    }
}


/* =========================================================
   Mobile - fiches pilotes / Relative
   ========================================================= */

@media (max-width: 640px) {

    /*
     * Sur téléphone la fiche pilote devient
     * un panneau unique ancré en bas.
     */
    .floating-driver-window {
        left: 8px !important;
        right: 8px !important;

        top: auto !important;

        bottom:
            max(
                8px,
                env(safe-area-inset-bottom)
            ) !important;

        width: auto !important;

        max-height: 58dvh;

        border-radius: 12px;
    }

    .floating-driver-content {
        max-height:
            calc(58dvh - 46px);

        overflow-y: auto;
        overflow-x: hidden;
    }

    /*
     * Plus de poignée de déplacement
     * sur téléphone.
     */
    .floating-driver-handle {
        cursor: default;
        touch-action: manipulation;
    }

    .floating-driver-handle
    > span[aria-hidden="true"] {
        display: none;
    }

    /*
     * Le Relative appartient à la TrackMap.
     * Sur téléphone il reste centré
     * et ne peut plus être déplacé.
     */
    .trackmap-relative {
        left: 50% !important;
        right: auto !important;
        top: 18px !important;

        transform:
            translateX(-50%) !important;

        width:
            min(
                340px,
                calc(100% - 16px)
            );

        cursor: default;
        touch-action: auto;
    }
}

/*
 * Mobile — réserve de défilement pour la fiche pilote flottante.
 *
 * Une fenêtre fixed ne participe pas à la hauteur du document.
 * On ajoute donc de l'espace sous la page uniquement lorsqu'une
 * fiche pilote est réellement ouverte.
 */
@media (max-width: 640px) {

    body:has(.floating-driver-window:not([hidden])) {
        padding-bottom:
            calc(
                72dvh
                + 32px
                + env(safe-area-inset-bottom)
            );
    }
}


/*
 * Mobile — permettre au scroll de quitter la fiche pilote
 * et de continuer naturellement dans la page.
 */
@media (max-width: 640px) {

    .floating-driver-content {
        overscroll-behavior-y: auto;
        touch-action: pan-y;
    }
}


/*
 * Mobile — éviter les repositionnements automatiques
 * de Chrome pendant les rafraîchissements du Live.
 */
@media (max-width: 640px) {

    body:has(.floating-driver-window:not([hidden])) {
        overflow-anchor: none;
    }

    #live-drivers,
    #trackmap-container,
    .floating-driver-window,
    .floating-driver-content {
        overflow-anchor: none;
    }
}


/*
 * Mobile — éviter le double scroll sur les fiches pilotes
 * riches en télémétrie.
 */
@media (max-width: 640px) {

    .floating-driver-window {
        max-height: 72dvh;
    }

    .floating-driver-content {
        max-height: calc(72dvh - 46px);
    }
}

/*
 * Serveur — pilotes connectés sur toute la largeur.
 *
 * #live-drivers possède déjà sa propre grille responsive.
 * On retire simplement la contrainte 400px / 1fr du parent.
 */
.server-drivers-stream-grid {
    grid-template-columns: minmax(0, 1fr);
}

#live-drivers {
    align-items: start;
}

/* =========================================================
   Portail utilisateur FCM
   ========================================================= */

.portal-page *,
.users-admin-page * {
    box-sizing: border-box;
}

.app-navigation form {
    margin: 0;
}

.app-navigation button {
    width: 100%;
    min-width: 220px;
    padding: 10px 16px;
    border: 0;
    border-radius: 8px;
    background: #2b2b2b;
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.app-navigation button:hover,
.app-navigation button:focus-visible {
    background: #3a3a3a;
}

.nav-toggle:focus-visible,
.app-navigation a:focus-visible,
.btn:focus-visible,
.portal-form input:focus-visible,
.portal-secondary-action a:focus-visible,
.portal-back-link:focus-visible {
    outline: 3px solid #facc15;
    outline-offset: 3px;
}

.portal-page .site-header {
    min-height: 240px;
}

.portal-shell {
    width: min(100%, 560px);
}

.portal-auth-card,
.portal-card {
    overflow: hidden;
}

.portal-auth-card .card-header,
.portal-card .card-header {
    margin: 0;
    padding: 18px 20px;
}

.portal-auth-card .card-description,
.portal-card .card-description {
    margin-top: 5px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.portal-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.portal-form label {
    margin-top: 8px;
    font-weight: 700;
}

.portal-form input {
    width: 100%;
    min-width: 0;
    padding: 11px 12px;
    border: 1px solid var(--panel-border);
    border-radius: 7px;
    background: #111827;
    color: var(--text-primary);
    font: inherit;
}

.portal-form input:focus-visible {
    border-color: #60a5fa;
}

.portal-submit {
    width: 100%;
    margin-top: 12px;
    padding: 11px 16px;
}

.portal-secondary-action {
    margin: 8px 0 0;
    color: var(--text-secondary);
    text-align: center;
}

.portal-secondary-action a,
.portal-back-link,
.portal-card a {
    color: #8fc2ff;
}

.portal-back-link {
    display: inline-block;
    margin-bottom: 8px;
    font-weight: 700;
    text-decoration: none;
}

.portal-message {
    margin: 0 0 18px;
    padding: 12px 14px;
    border: 1px solid transparent;
    border-radius: 8px;
    line-height: 1.45;
}

.portal-message-error {
    border-color: rgba(248, 113, 113, .55);
    background: rgba(127, 29, 29, .4);
    color: #fecaca;
}

.portal-message-success {
    border-color: rgba(74, 222, 128, .45);
    background: rgba(20, 83, 45, .45);
    color: #bbf7d0;
}

.portal-account {
    max-width: 1050px;
}

.portal-account h1,
.users-admin h1 {
    margin: 8px 0 18px;
}

.portal-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.portal-card {
    min-width: 0;
    margin: 0;
}

.portal-details > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 9px 0;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.portal-details > div:last-child {
    border-bottom: 0;
}

.portal-details > div > span:first-child {
    color: var(--text-secondary);
}

.portal-badge-list,
.users-action-list {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.portal-badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 4px 9px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 800;
    line-height: 1.2;
}

.portal-badge-active {
    border-color: rgba(74, 222, 128, .45);
    background: rgba(20, 83, 45, .6);
    color: #bbf7d0;
}

.portal-badge-pending {
    border-color: rgba(250, 204, 21, .45);
    background: rgba(113, 63, 18, .6);
    color: #fef08a;
}

.portal-badge-disabled {
    border-color: rgba(248, 113, 113, .45);
    background: rgba(127, 29, 29, .5);
    color: #fecaca;
}

.portal-badge-neutral {
    border-color: rgba(148, 163, 184, .4);
    background: rgba(30, 41, 59, .8);
    color: #e2e8f0;
}

.portal-status-line {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    font-weight: 700;
}

.portal-status-ok {
    color: #86efac;
}

.pilot-links {
    display: grid;
    gap: 9px;
    margin: 0;
    padding-left: 20px;
}

.pilot-links li {
    padding-left: 3px;
}

.pilot-links .portal-badge {
    margin-left: 6px;
}

.portal-race-engineer {
    border-color: rgba(96, 165, 250, .55);
    background: linear-gradient(145deg, #243244, #1d2b40);
}

/* Race Engineer FCM — portail public */
.race-engineer-shell { max-width: 1480px; padding-top: 42px; }
.race-engineer-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.race-engineer-heading h1 { margin: 4px 0 8px; font-size: clamp(2rem, 5vw, 3.8rem); letter-spacing: -.045em; }
.race-engineer-heading p { max-width: 780px; color: var(--text-secondary); }
.race-engineer-kicker { margin: 16px 0 0 !important; color: #60a5fa !important; font-size: .76rem; font-weight: 900; letter-spacing: .16em; }
.engineer-state { padding: 7px 12px; border: 1px solid rgba(96,165,250,.55); border-radius: 999px; background: rgba(30,64,175,.18); color: #bfdbfe; font-size: .76rem; font-weight: 900; }
.race-engineer-toolbar { margin-bottom: 18px; }
.race-engineer-toolbar .card-body { display: grid; gap: 12px; }
.race-engineer-toolbar-fields { display: grid; grid-template-columns: minmax(260px,1.4fr) minmax(180px,.7fr) minmax(260px,1fr); align-items: end; gap: 14px; }
.race-engineer-toolbar-field { display: grid; align-content: end; gap: 7px; min-width: 0; }
.race-engineer-toolbar-actions { display: flex; justify-content: flex-end; }
.engineer-scope-status { margin: 0; color: #fef08a; font-size: .82rem; font-weight: 700; }
.race-engineer-toolbar label, .engineer-composer > label { color: var(--text-secondary); font-size: .82rem; font-weight: 800; }
.race-engineer-toolbar select, .engineer-composer textarea { width: 100%; border: 1px solid var(--panel-border); border-radius: 9px; background: #111b2a; color: var(--text-primary); padding: 10px 12px; }
.race-engineer-context { margin-bottom: 24px; }
.engineer-context-grid { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 1px; padding: 0 !important; overflow: hidden; border-radius: 0 0 10px 10px; background: rgba(148,163,184,.13); }
.engineer-context-item { min-height: 82px; padding: 16px; background: var(--panel-bg-secondary); }
.engineer-context-item span { display: block; margin-bottom: 7px; color: var(--text-secondary); font-size: .72rem; font-weight: 800; text-transform: uppercase; }
.engineer-context-item strong { overflow-wrap: anywhere; }
.engineer-section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.engineer-section-title h2 { margin-bottom: 12px; }
.engineer-section-title p { color: var(--text-secondary); }
.engineer-summary-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; margin-bottom: 24px; }
.engineer-summary-card { min-height: 170px; }
.engineer-summary-item + .engineer-summary-item { margin-top: 13px; padding-top: 13px; border-top: 1px solid rgba(148,163,184,.18); }
.engineer-summary-item > strong { font-size: .9rem; overflow-wrap: anywhere; }
.engineer-summary-meta, .conversation-evidence, .evidence-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.engineer-test-plan-state { padding: 10px 0; }
.engineer-test-plan-state + .engineer-summary-item { margin-top: 8px; padding-top: 13px; border-top: 1px solid rgba(148,163,184,.18); }
.engineer-test-plan-badge { display: inline-flex; padding: 4px 9px; border-radius: 999px; background: rgba(45,212,191,.12); color: #99f6e4; font-size: .72rem; font-weight: 800; letter-spacing: .04em; overflow-wrap: anywhere; }
.engineer-test-plan-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.evidence-chip, .confidence-chip { display: inline-flex; width: fit-content; padding: 4px 8px; border: 1px solid transparent; border-radius: 999px; font-size: .66rem; font-weight: 900; letter-spacing: .025em; }
.evidence-measured { border-color: rgba(34,197,94,.5); background: rgba(20,83,45,.55); color: #bbf7d0; }
.evidence-subjective { border-color: rgba(168,85,247,.5); background: rgba(88,28,135,.45); color: #e9d5ff; }
.evidence-plausible { border-color: rgba(250,204,21,.5); background: rgba(113,63,18,.5); color: #fef08a; }
.evidence-unknown, .confidence-chip { border-color: rgba(148,163,184,.4); background: rgba(30,41,59,.8); color: #cbd5e1; }
.engineer-insufficient { color: var(--text-secondary); font-style: italic; }
.evidence-legend { margin-bottom: 24px; }
.engineer-conversation .card-header { align-items: center; }
.engineer-conversation .card-header p { margin: 4px 0 0; color: var(--text-secondary); font-size: .82rem; }
.engineer-auto-read { display: flex; align-items: center; gap: 8px; font-size: .82rem; }
.conversation-log { display: grid; gap: 14px; min-height: 210px; max-height: 650px; padding: 20px; overflow-y: auto; background: #101927; }
.conversation-empty { margin: auto; color: var(--text-secondary); text-align: center; }
.conversation-message { max-width: min(780px,88%); padding: 14px 16px; border: 1px solid var(--panel-border); border-radius: 14px; background: #1c2939; }
.conversation-pilot { justify-self: end; border-color: rgba(96,165,250,.45); background: rgba(30,64,175,.2); }
.conversation-engineer { justify-self: start; }
.conversation-role { margin-bottom: 5px; color: #93c5fd; font-size: .72rem; font-weight: 900; text-transform: uppercase; }
.conversation-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.conversation-listen { margin-top: 12px; }
.conversation-download { display: inline-flex; margin: 12px 0 0 8px; }
.conversation-legacy-title { margin-top: 10px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.15); font-weight: 700; color: #c7d2e2; }
.engineer-composer { display: grid; gap: 10px; padding: 20px; border-top: 1px solid var(--panel-border); }
.strategy-constraints { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px; margin: 0; padding: 14px; border: 1px solid var(--panel-border); border-radius: 9px; }
.strategy-constraints[hidden] { display: none; }
.strategy-constraints legend, .strategy-constraints label { color: var(--text-secondary); font-size: .82rem; font-weight: 800; }
.strategy-constraints label { display: grid; gap: 6px; }
.strategy-constraints input[type="number"] { width: 100%; border: 1px solid var(--panel-border); border-radius: 9px; background: #111b2a; color: var(--text-primary); padding: 9px 10px; }
.strategy-constraints .strategy-tyre-rule { display: flex; align-items: center; align-self: end; min-height: 39px; }
.strategy-constraints p { grid-column: 1 / -1; margin: 0; color: var(--text-secondary); font-size: .78rem; }
.engineer-composer-options, .engineer-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.engineer-composer-options { color: var(--text-secondary); font-size: .8rem; }
.race-engineer-blocked { max-width: 760px; margin: 34px auto; text-align: center; }

@media (max-width: 920px) {
    .engineer-context-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .engineer-summary-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .race-engineer-toolbar-fields { grid-template-columns: 1fr; }
    .race-engineer-toolbar-actions { justify-content: stretch; }
    .race-engineer-toolbar-actions .btn { width: 100%; }
}

@media (max-width: 600px) {
    .race-engineer-heading, .engineer-section-title { align-items: flex-start; flex-direction: column; }
    .engineer-context-grid, .engineer-summary-grid { grid-template-columns: 1fr; }
    .conversation-message { max-width: 95%; }
    .engineer-auto-read { margin-top: 10px; }
}

/* Administration des utilisateurs */

.users-admin {
    max-width: 1600px;
    padding-top: 52px;
}

.users-admin-heading p {
    margin: -10px 0 18px;
    color: var(--text-secondary);
}

.users-admin-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}

.ai-quota-admin {
    max-width: 1300px;
    padding-top: 52px;
}

.ai-quota-user-picker,
.ai-quota-permission,
.ai-quota-form {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-quota-user-picker,
.ai-quota-permission {
    margin-bottom: 18px;
    padding: 16px;
}

.ai-quota-user-picker select,
.ai-quota-form input {
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--panel-border);
    border-radius: 7px;
    background: #111827;
    color: var(--text-primary);
}

.ai-quota-permission > div {
    flex: 1;
}

.ai-quota-permission h2,
.ai-quota-permission p,
.ai-quota-card h2 {
    margin: 0;
}

.ai-quota-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.ai-quota-card {
    min-width: 0;
    overflow: hidden;
}

.ai-quota-card .card-header {
    align-items: flex-start;
    gap: 12px;
}

.ai-quota-card .portal-details,
.ai-quota-card form,
.ai-quota-card > p {
    margin: 16px;
}

.ai-quota-card .portal-details dd {
    margin: 0;
    text-align: right;
}

.ai-quota-form {
    flex-wrap: wrap;
}

.ai-quota-form label {
    width: 100%;
    font-weight: 700;
}

.ai-quota-form input {
    flex: 1;
}

.ai-quota-audio-state {
    color: var(--text-secondary);
}

.users-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.users-filters .btn {
    text-decoration: none;
}

.users-filter {
    border: 1px solid var(--panel-border);
    background: var(--panel-bg-secondary);
    color: var(--text-primary);
    text-decoration: none;
}

.users-table-card {
    overflow: hidden;
}

.users-table-wrap {
    overflow-x: auto;
}

.users-admin .table {
    min-width: 1180px;
}

.users-admin .table th,
.users-admin .table td {
    padding: 11px 10px;
}

.users-action-list {
    justify-content: center;
}

.users-action-list form {
    margin: 0;
}

@media (max-width: 720px) {
    .strategy-constraints { grid-template-columns: 1fr; }
    .portal-page .site-header {
        min-height: 190px;
    }

    .portal-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .portal-details > div {
        align-items: flex-start;
        flex-direction: column;
        gap: 7px;
    }

    .users-admin {
        padding-top: 52px;
    }

    .users-admin-heading,
    .ai-quota-user-picker,
    .ai-quota-permission {
        align-items: stretch;
        flex-direction: column;
    }

    .ai-quota-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .users-table-card,
    .users-table-wrap {
        overflow: visible;
    }

    .users-admin .table,
    .users-admin .table tbody,
    .users-admin .table tr,
    .users-admin .table td {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .users-admin .table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .users-admin .table tr {
        margin-bottom: 14px;
        padding: 10px 12px;
        border: 1px solid var(--panel-border);
        border-radius: 10px;
        background: var(--panel-bg-secondary);
    }

    .users-admin .table td,
    .users-admin .table td:first-child,
    .users-admin .table td:not(:first-child) {
        display: grid;
        grid-template-columns: minmax(92px, .8fr) minmax(0, 1.2fr);
        gap: 10px;
        border-bottom: 1px solid rgba(255, 255, 255, .07);
        text-align: left;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .users-admin .table td::before {
        content: attr(data-label);
        color: var(--text-secondary);
        font-size: .78rem;
        font-weight: 700;
        text-transform: uppercase;
    }

    .users-admin .table td:last-child {
        border-bottom: 0;
    }

    .users-action-list {
        justify-content: flex-start;
    }
}


/*
 * Mobile — fiche pilote moins envahissante.
 * Une réserve de défilement permet de conserver
 * la TrackMap accessible derrière la fiche fixe.
 */
@media (max-width: 640px) {

    .floating-driver-window {
        max-height: 60dvh;
    }

    .floating-driver-content {
        max-height: calc(60dvh - 46px);
    }

    body:has(.floating-driver-window:not([hidden])) {
        padding-bottom:
            calc(
                60dvh
                + 32px
                + env(safe-area-inset-bottom)
            );
    }
}

/*
 * Mobile — les fiches enrichies FCM sont plus hautes en contenu.
 * On limite uniquement celles-ci pour conserver davantage
 * de TrackMap visible au-dessus.
 */
@media (max-width: 640px) {

    .floating-driver-window:has(.fcm-tire-live) {
        max-height: 50dvh;
    }

    .floating-driver-window:has(.fcm-tire-live)
    .floating-driver-content {
        max-height: calc(50dvh - 46px);
    }
}
