:root {
    --track-black: #0f1115;
    --asphalt: #181c23;
    --pit-gray: #252b36;
    --f1-red: #e10600;
    --f1-red-dark: #b40000;
    --speed-yellow: #ffc82c;
    --text-light: #f7f7fb;
    --text-muted: #b4bccd;
    --line-soft: rgba(255, 255, 255, 0.12);
    --panel-bg: rgba(24, 28, 35, 0.86);
    --panel-bg-soft: rgba(37, 43, 54, 0.8);
    --radius-lg: 18px;
    --radius-md: 12px;
    --shadow-panel: 0 20px 48px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text-light);
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.02rem;
    background:
        radial-gradient(circle at 20% 8%, rgba(225, 6, 0, 0.27), transparent 42%),
        radial-gradient(circle at 92% 85%, rgba(255, 200, 44, 0.2), transparent 35%),
        linear-gradient(145deg, #0b0e12 0%, #11161d 45%, #141a22 100%);
}

.bg-grid {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        linear-gradient(to right, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 26px 26px;
}

.topbar {
    border-bottom: 1px solid var(--line-soft);
    background: linear-gradient(90deg, rgba(24, 28, 35, 0.96), rgba(14, 18, 24, 0.94));
    backdrop-filter: blur(5px);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    padding: 0.9rem 1rem;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    color: var(--text-light);
    text-decoration: none;
}

.brand-link:hover {
    color: var(--text-light);
    text-decoration: none;
}

.brand-logo {
    width: 58px;
    height: 58px;
    border-radius: 14px;
    object-fit: cover;
    border: 1px solid var(--line-soft);
    box-shadow: 0 10px 18px rgba(0, 0, 0, 0.4);
}

.brand-kicker {
    margin: 0;
    color: var(--speed-yellow);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    font-size: 0.68rem;
    font-weight: 600;
}

.brand-title {
    margin: 0;
    font-size: clamp(1.2rem, 2.2vw, 1.75rem);
    font-family: 'Orbitron', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.race-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
}

.nav-chip {
    border: 1px solid rgba(255, 255, 255, 0.24);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-light);
    border-radius: 999px;
    padding: 0.45rem 1.05rem;
    font-size: 0.93rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-decoration: none;
    transition: transform 0.22s ease, background 0.22s ease, border-color 0.22s ease;
}

.nav-chip:hover {
    color: var(--text-light);
    text-decoration: none;
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.45);
    background: rgba(255, 255, 255, 0.14);
}

.nav-chip--accent {
    background: linear-gradient(90deg, var(--f1-red), #ff584d);
    border-color: transparent;
}

.nav-chip--danger {
    background: transparent;
    border-color: rgba(225, 6, 0, 0.75);
}

.logout-form {
    margin: 0;
}

.content-shell {
    padding: 1.5rem 0 2.1rem;
    animation: reveal 0.44s ease;
}

.flash-stack {
    display: grid;
    gap: 0.65rem;
    margin-bottom: 1rem;
}

.flash-item {
    border: 1px solid rgba(255, 200, 44, 0.5);
    background: rgba(255, 200, 44, 0.13);
    border-radius: 10px;
    padding: 0.7rem 0.85rem;
    color: #fff0b3;
    font-weight: 600;
}

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

.page-title {
    margin: 0;
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(1.35rem, 2.2vw, 2.1rem);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.page-subtitle {
    margin: 0.2rem 0 0;
    color: var(--text-muted);
    font-size: 0.98rem;
}

.f1-card {
    border: 1px solid var(--line-soft);
    background: linear-gradient(145deg, var(--panel-bg), var(--panel-bg-soft));
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-panel);
    padding: 1.15rem;
    margin-bottom: 1rem;
}

.f1-card + .f1-card {
    margin-top: 1rem;
}

.filter-row {
    display: flex;
    align-items: end;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filter-row .form-group,
.filter-row .form-inline-group {
    min-width: 170px;
}

label,
.form-label {
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.03em;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    font-size: 0.78rem;
}

.form-control,
.form-select,
select,
input[type='text'],
input[type='date'],
input[type='password'],
input[type='number'] {
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.24) !important;
    color: #fff !important;
    border-radius: 9px !important;
}

.form-control:focus,
.form-select:focus,
select:focus,
input:focus {
    box-shadow: 0 0 0 0.2rem rgba(225, 6, 0, 0.2) !important;
    border-color: rgba(225, 6, 0, 0.85) !important;
}

option {
    color: #10141b;
}

.form-check-input {
    transform: scale(1.1);
}

.btn,
button.btn {
    border-radius: 9px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.btn-primary {
    border-color: var(--f1-red);
    background: linear-gradient(90deg, var(--f1-red), #ff4135);
}

.btn-primary:hover {
    border-color: var(--f1-red-dark);
    background: linear-gradient(90deg, var(--f1-red-dark), #ff3023);
}

.btn-outline-dark,
.btn-secondary {
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.btn-outline-dark:hover,
.btn-secondary:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.45);
}

.btn-danger {
    background: linear-gradient(90deg, #8d0100, #d90404);
    border-color: #8d0100;
}

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

.team-grid img {
    width: 100%;
    height: 74px;
    object-fit: contain;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.13);
    padding: 0.45rem;
}

.quick-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.8rem;
    margin-top: 1rem;
}

.quick-link-card {
    display: block;
    border: 1px solid var(--line-soft);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.85rem;
    color: #fff;
    text-decoration: none;
    transition: transform 0.22s ease, border-color 0.22s ease, background 0.22s ease;
}

.quick-link-card:hover {
    transform: translateY(-3px);
    color: #fff;
    text-decoration: none;
    border-color: rgba(225, 6, 0, 0.72);
    background: rgba(225, 6, 0, 0.16);
}

.quick-link-card h3 {
    margin: 0;
    font-family: 'Orbitron', sans-serif;
    font-size: 1rem;
}

.quick-link-card p {
    margin: 0.35rem 0 0;
    color: var(--text-muted);
    line-height: 1.1;
}

.race-table-wrap {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.16);
}

.race-table {
    margin-bottom: 0;
    min-width: 760px;
    color: #f8f9ff;
}

.race-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: linear-gradient(90deg, #2e3542, #232a35);
    border: none;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.75rem;
    color: #f8f9ff;
    white-space: nowrap;
}

.race-table td,
.race-table th {
    padding: 0.65rem 0.58rem;
    border-top: 1px solid rgba(255, 255, 255, 0.11);
    vertical-align: middle;
}

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

.race-table tbody tr:hover {
    background: rgba(225, 6, 0, 0.12);
}

.position-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.14);
}

.position-badge--1 {
    background: linear-gradient(130deg, #ffd44d, #ffb703);
    color: #2c2100;
}

.position-badge--2 {
    background: linear-gradient(130deg, #d9dee7, #afb7c4);
    color: #1b222e;
}

.position-badge--3 {
    background: linear-gradient(130deg, #c7864f, #a36434);
    color: #1f1208;
}

.kpi-chip {
    display: inline-flex;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    padding: 0.35rem 0.65rem;
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    font-size: 0.84rem;
    font-weight: 600;
}

.empty-state {
    border: 1px dashed rgba(255, 255, 255, 0.28);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    padding: 1.2rem;
    text-align: center;
    color: var(--text-muted);
}

.form-stack p {
    margin-bottom: 0.68rem;
}

.form-stack ul.errorlist {
    margin: 0.25rem 0 0.35rem;
    padding-left: 1rem;
    color: #ffd2d2;
}

@keyframes reveal {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 992px) {
    .topbar-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .race-nav {
        width: 100%;
        justify-content: flex-start;
    }

    .content-shell {
        padding-top: 1rem;
    }
}

@media (max-width: 576px) {
    .brand-logo {
        width: 50px;
        height: 50px;
    }

    .page-header {
        margin-bottom: 0.7rem;
    }

    .f1-card {
        padding: 0.88rem;
    }

    .race-table td,
    .race-table th {
        padding: 0.45rem;
        font-size: 0.86rem;
    }
}

/* Checkbox inline no form.as_p para nao sobrepor o label */
.f1-checkbox,
.form-check-input {
    position: static !important;
    margin: 0 0 0 0.45rem !important;
    width: 1rem;
    height: 1rem;
    vertical-align: middle;
    transform: translateY(-1px) !important;
    accent-color: var(--f1-red);
}
