:root {
    --bg: #0e1014;
    --bg-card: #191c22;
    --bg-card-2: #22262f;
    --border: #2b3038;
    --text: #f2f3f5;
    --text-dim: #9aa1ad;
    --accent: #ff6a1a;
    --accent-dark: #cc4e00;
    --green: #2ecc71;
    --red: #e74c3c;
    --blue: #3d8bfd;
    --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem;
}

/* ---------- Structure : sidenav + colonne principale ---------- */

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

.sidenav {
    width: 230px;
    flex-shrink: 0;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidenav-brand {
    padding: 1.1rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border);
}
.sidenav-brand img {
    max-width: 100%;
    height: auto;
    display: block;
}

.sidenav-links {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.75rem;
    flex: 1;
    overflow-y: auto;
}
.sidenav-links a {
    color: var(--text-dim);
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
}
.sidenav-links a:hover { background: var(--bg-card-2); color: var(--text); text-decoration: none; }
.sidenav-links a.active { background: var(--accent); color: #fff; }

.sidenav-footer { padding: 0.75rem 1rem; border-top: 1px solid var(--border); }
.logout-link { color: var(--text-dim); font-size: 0.85rem; }

.sidenav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 15;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

header.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(14,16,20,0.95);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
}

.hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
    width: 2.3rem;
    height: 2.3rem;
    border-radius: 8px;
    font-size: 1.1rem;
    padding: 0;
    flex-shrink: 0;
}

.icon-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: 999px;
    width: 2.1rem;
    height: 2.1rem;
    padding: 0;
    font-size: 1.05rem;
    line-height: 1;
    flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-card-2); }
.icon-btn.on { color: var(--accent); border-color: var(--accent); }

/* ---------- Bandeau de chronos dans la navbar ---------- */

.navclocks {
    flex: 1;
    min-width: 0;
    display: flex;
    gap: 1.1rem;
    overflow-x: auto;
    scrollbar-width: none;
}
.navclocks::-webkit-scrollbar { display: none; }

.navclock { flex: 0 0 auto; text-align: center; }
.navclock .navclock-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    white-space: nowrap;
}
.navclock .navclock-value {
    font-size: 0.95rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.navclock .navclock-value.dim { color: var(--text-dim); font-weight: 600; }

@media (max-width: 860px) {
    .sidenav {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 20;
        width: 250px;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }
    .sidenav.open { transform: translateX(0); }
    .sidenav-backdrop.open { display: block; }
    .hamburger { display: inline-flex; }
    .navclocks { gap: 0.8rem; }
    .navclock .navclock-value { font-size: 0.85rem; }
}

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

.card h2, .card h3 { margin-top: 0; }

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

.stat {
    background: var(--bg-card-2);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}

.stat .label { color: var(--text-dim); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.stat .value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 0.25rem; }

.chrono {
    font-size: clamp(2.5rem, 12vw, 5rem);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    text-align: center;
    margin: 0.5rem 0;
}

.chrono.running { color: var(--green); }
.chrono.stopped { color: var(--text-dim); }

.pill {
    display: inline-block;
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.pill.live { background: rgba(46,204,113,0.15); color: var(--green); }
.pill.idle { background: rgba(154,161,173,0.15); color: var(--text-dim); }
.pill.done { background: rgba(61,139,253,0.15); color: var(--blue); }
.pill.warn { background: rgba(245,166,35,0.15); color: #f5a623; }

.driver-name { font-size: 1.4rem; font-weight: 700; text-align: center; }
.driver-number { color: var(--accent); }

form.inline { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

label { display: block; margin: 0.6rem 0 0.25rem; font-size: 0.85rem; color: var(--text-dim); }

input[type=text], input[type=number], input[type=date], input[type=password],
input[type=datetime-local], select, textarea {
    width: 100%;
    padding: 0.65rem 0.75rem;
    background: var(--bg-card-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    font-size: 1rem;
}

input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

button, .btn {
    display: inline-block;
    cursor: pointer;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.7rem 1.2rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
}
button:hover, .btn:hover { background: var(--accent-dark); text-decoration: none; }
button.secondary, .btn.secondary { background: var(--bg-card-2); color: var(--text); border: 1px solid var(--border); }
button.danger, .btn.danger { background: var(--red); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.75rem; }

.btn-suggested {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    background: var(--green);
}
.btn-suggested:hover { background: #26a85e; }

.link-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    font-weight: 600;
    font-size: 0.85rem;
    text-decoration: underline;
    padding: 0.4rem;
}
.link-btn:hover { color: var(--text); background: none; }

.card details {
    margin-top: 0.6rem;
    border-top: 1px solid var(--border);
    padding-top: 0.6rem;
}
.card details summary {
    cursor: pointer;
    color: var(--text-dim);
    font-weight: 600;
    font-size: 0.9rem;
    list-style: none;
}
.card details summary::-webkit-details-marker { display: none; }
.card details summary::before { content: '▸ '; }
.card details[open] summary::before { content: '▾ '; }
.card details summary:hover { color: var(--text); }

table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { padding: 0.6rem 0.5rem; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

.rank-1 { color: #ffd54a; font-weight: 800; }
.rank-2 { color: #d6d6d6; font-weight: 700; }
.rank-3 { color: #cd8a4d; font-weight: 700; }

.muted { color: var(--text-dim); }
.center { text-align: center; }
.mt0 { margin-top: 0; }
.flash {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-weight: 600;
}
.flash.ok { background: rgba(46,204,113,0.15); color: var(--green); }
.flash.error { background: rgba(231,76,60,0.15); color: var(--red); }

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.login-box { width: 100%; max-width: 380px; }
.login-box .brand-title {
    text-align: center;
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
}
.login-box .brand-title .accent { color: var(--accent); }

@media (max-width: 560px) {
    nav.tabs a { padding: 0.5rem 0.6rem; font-size: 0.85rem; }
    .card { padding: 1rem; }
}

/* ---------- Écran TV / affichage stand ---------- */

.tv-body {
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
}

.tv-wrap {
    max-width: 1700px;
    margin: 0 auto;
    padding: 1.5rem 2rem 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.tv-header { display: flex; align-items: center; gap: 1.5rem; }
.tv-logo { height: 64px; width: auto; flex-shrink: 0; }
.tv-clock {
    flex: 1;
    text-align: center;
    font-size: clamp(1.6rem, 3vw, 2.6rem);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}
.tv-header .icon-btn { width: 2.8rem; height: 2.8rem; font-size: 1.3rem; flex-shrink: 0; }

.tv-alert {
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-size: clamp(1.1rem, 2vw, 1.5rem);
    font-weight: 800;
    text-align: center;
}
.tv-alert.error { background: rgba(231,76,60,0.2); color: var(--red); }
.tv-alert.warn { background: rgba(255,106,26,0.2); color: var(--accent); }

.tv-main {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    flex: 1;
    min-height: 0;
}

.tv-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.tv-label {
    font-size: clamp(0.9rem, 1.3vw, 1.15rem);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
}
.tv-huge {
    font-size: clamp(2.6rem, 6.5vw, 5.5rem);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
.tv-huge.running { color: var(--green); }
.tv-huge.stopped { color: var(--text-dim); }
.tv-huge.dim { color: var(--text-dim); }
.tv-subline { margin-top: 0.75rem; font-size: clamp(0.95rem, 1.4vw, 1.15rem); color: var(--text-dim); }
.tv-driver-name { font-size: clamp(1.4rem, 2.6vw, 2.1rem); font-weight: 800; margin: 0.5rem 0; }
.tv-driver-panel .pill, .tv-next-panel .pill { font-size: 1rem; padding: 0.4rem 1rem; }

.tv-leaderboard table { font-size: clamp(0.95rem, 1.3vw, 1.2rem); }
.tv-leaderboard th { font-size: 0.85rem; }
.tv-leaderboard.tv-panel { display: block; }

@media (max-width: 900px) {
    .tv-main { grid-template-columns: 1fr; }
}
