/* ============================================================
   F1 Fantasy League — Race-day theme
   Dark carbon UI, racing-red accents, podium highlights.
   ============================================================ */

:root {
    --f1-red: #e10600;
    --f1-red-dark: #b90500;
    --f1-red-glow: rgba(225, 6, 0, 0.45);

    --bg-base: #0d0d12;
    --bg-elevated: #15151e;
    --surface: #1c1c27;
    --surface-2: #23232f;
    --border: #2c2c3a;
    --border-strong: #3a3a4c;

    --text: #f3f3f6;
    --text-muted: #9a9aac;
    --text-dim: #6c6c7d;

    --gold: #ffd34e;
    --silver: #cfd4dc;
    --bronze: #e0915a;

    --ok: #28c76f;
    --warn: #ff9f43;
    --err: #ea5455;

    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.35);
}

/* ----------------------------- Base ----------------------------- */

* {
    scrollbar-color: var(--border-strong) transparent;
}

body {
    background-color: var(--bg-base);
    background-image:
        radial-gradient(1200px 600px at 100% -10%, rgba(225, 6, 0, 0.10), transparent 60%),
        radial-gradient(900px 500px at -10% 0%, rgba(50, 60, 120, 0.10), transparent 55%);
    background-attachment: fixed;
    color: var(--text);
    font-family: "Titillium Web", "Segoe UI", system-ui, -apple-system, sans-serif;
    letter-spacing: 0.2px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1 0 auto;
}

h1, h2, h3, h4, h5, h6,
.navbar-brand {
    font-family: "Titillium Web", "Segoe UI", sans-serif;
    font-weight: 700;
}

a {
    color: var(--f1-red);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: #ff4036;
}

.text-muted {
    color: var(--text-muted) !important;
}

/* Section heading with red speed bar */
.page-title {
    position: relative;
    padding-left: 18px;
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 800;
}

.page-title::before {
    content: "";
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 6px;
    border-radius: 3px;
    background: linear-gradient(180deg, var(--f1-red), var(--f1-red-dark));
    box-shadow: 0 0 14px var(--f1-red-glow);
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 3px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--f1-red);
}

/* ----------------------------- Navbar ----------------------------- */

.navbar {
    background: rgba(13, 13, 18, 0.92) !important;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
}

.navbar::after {
    content: "";
    display: block;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--f1-red-dark), var(--f1-red) 50%, var(--f1-red-dark));
    box-shadow: 0 0 12px var(--f1-red-glow);
}

.navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #fff !important;
}

.navbar-brand .brand-mark {
    display: inline-block;
    width: 30px;
    height: 22px;
    border-radius: 4px;
    background:
        repeating-conic-gradient(#fff 0% 25%, #111 0% 50%) 0 0 / 8px 8px;
    box-shadow: inset 0 0 0 2px var(--f1-red);
}

.navbar-brand .brand-accent {
    color: var(--f1-red);
}

.navbar .nav-link {
    color: var(--text-muted) !important;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-size: 0.82rem;
    padding: 0.5rem 0.85rem !important;
    position: relative;
}

.navbar .nav-link::after {
    content: "";
    position: absolute;
    left: 0.85rem;
    right: 0.85rem;
    bottom: 2px;
    height: 2px;
    background: var(--f1-red);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.2s ease;
}

.navbar .nav-link:hover,
.navbar .nav-link.active {
    color: #fff !important;
}

.navbar .nav-link:hover::after,
.navbar .nav-link.active::after {
    transform: scaleX(1);
}

.navbar-toggler {
    border-color: var(--border-strong);
}

/* ----------------------------- Cards ----------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.card.is-hoverable:hover {
    transform: translateY(-4px);
    border-color: var(--border-strong);
    box-shadow: var(--shadow);
}

.card-header {
    background: linear-gradient(180deg, var(--surface-2), var(--surface));
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.85rem;
    padding: 0.9rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header::before {
    content: "";
    width: 4px;
    height: 16px;
    border-radius: 2px;
    background: var(--f1-red);
    box-shadow: 0 0 10px var(--f1-red-glow);
}

.card-body {
    color: var(--text);
}

/* Stat card */
.stat-card {
    padding: 1.1rem 1.25rem;
}

.stat-card .stat-label {
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-size: 0.72rem;
    color: var(--text-dim);
    font-weight: 700;
}

.stat-card .stat-value {
    font-size: 1.9rem;
    font-weight: 800;
    line-height: 1.1;
    margin-top: 4px;
    color: #ffffff;
}

/* Leader name can be long — keep it readable on one line */
.stat-card .stat-value.is-name {
    font-size: 1.25rem;
}

.stat-card .stat-value.stat-value-sm {
    font-size: 1.05rem;
}

.stat-card .stat-sub {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.dashboard-stats > [class*="col-"] {
    display: flex;
}

.dashboard-stats .stat-card {
    flex: 1 1 auto;
    width: 100%;
}

.event-countdown-block.is-follow-on {
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border);
}

.event-countdown-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    margin: 2px 0 0.45rem;
    line-height: 1.25;
}

/* ----------------------------- Hero ----------------------------- */

.hero {
    position: relative;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background:
        linear-gradient(120deg, rgba(225, 6, 0, 0.18), transparent 55%),
        linear-gradient(180deg, var(--surface-2), var(--bg-elevated));
    padding: 1.8rem 2rem;
    margin-bottom: 1.75rem;
    overflow: hidden;
}

.hero::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 160px;
    height: 100%;
    background: repeating-conic-gradient(rgba(255, 255, 255, 0.05) 0% 25%, transparent 0% 50%) 0 0 / 22px 22px;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000);
    mask-image: linear-gradient(90deg, transparent, #000);
    pointer-events: none;
}

.hero h1 {
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 800;
    margin-bottom: 0.35rem;
}

.hero .hero-sub {
    color: var(--text-muted);
    margin: 0;
}

.race-pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    position: relative;
    z-index: 1;
}

.race-pager-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: rgba(0, 0, 0, 0.2);
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    text-decoration: none;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

a.race-pager-btn:hover {
    color: #fff;
    border-color: var(--f1-red);
    background: rgba(225, 6, 0, 0.12);
}

.race-pager-btn.is-disabled {
    color: var(--text-dim);
    border-color: var(--border);
    background: transparent;
    cursor: default;
}

.race-pager-arrow {
    color: var(--f1-red);
    font-size: 1rem;
    line-height: 1;
}

.race-pager-btn.is-disabled .race-pager-arrow {
    color: var(--text-dim);
}

/* ----------------------------- Tables ----------------------------- */

.table {
    color: var(--text);
    margin-bottom: 0;
    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
    border-color: var(--border);
}

.table > :not(caption) > * > * {
    background-color: transparent;
    color: var(--text);
    border-bottom-color: var(--border);
    padding: 0.8rem 1rem;
}

.table thead th {
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-size: 0.74rem;
    color: var(--text-dim);
    font-weight: 700;
    border-bottom: 1px solid var(--border-strong) !important;
    background: var(--surface-2);
}

.table.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: rgba(255, 255, 255, 0.018);
    color: var(--text);
}

.table.table-hover > tbody > tr:hover > *,
.table-striped > tbody > tr:hover > * {
    background-color: rgba(225, 6, 0, 0.10);
    color: #fff;
}

.table a {
    color: var(--text);
    font-weight: 600;
    border-bottom: 1px dotted transparent;
}

.table a:hover {
    color: #fff;
    border-bottom-color: var(--f1-red);
}

/* Rank pill + podium colours */
.rank-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    border-radius: 8px;
    font-weight: 800;
    font-size: 0.9rem;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    color: var(--text);
}

.rank-pill.p1 {
    background: linear-gradient(180deg, #ffe27a, var(--gold));
    color: #3a2c00;
    border-color: var(--gold);
    box-shadow: 0 0 16px rgba(255, 211, 78, 0.35);
}

.rank-pill.p2 {
    background: linear-gradient(180deg, #eef1f6, var(--silver));
    color: #2b2f36;
    border-color: var(--silver);
}

.rank-pill.p3 {
    background: linear-gradient(180deg, #f0ad7e, var(--bronze));
    color: #3a1f0a;
    border-color: var(--bronze);
}

tr.is-podium > * {
    background-color: rgba(255, 211, 78, 0.04);
}

.points-value {
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.points-value .unit {
    font-size: 0.7rem;
    color: var(--text-dim);
    font-weight: 600;
    margin-left: 3px;
}

/* ----------------------------- Buttons ----------------------------- */

.btn {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-size: 0.82rem;
    border-radius: var(--radius-sm);
    padding: 0.5rem 1.1rem;
    transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:active {
    transform: translateY(1px);
}

.btn-danger {
    background: linear-gradient(180deg, var(--f1-red), var(--f1-red-dark));
    border: none;
    box-shadow: 0 4px 14px var(--f1-red-glow);
}

.btn-danger:hover {
    background: linear-gradient(180deg, #ff1a14, var(--f1-red));
    box-shadow: 0 6px 20px var(--f1-red-glow);
}

.btn-outline-danger {
    color: #ff5b54;
    border: 1px solid var(--f1-red);
    background: transparent;
}

.btn-outline-danger:hover {
    background: var(--f1-red);
    border-color: var(--f1-red);
    color: #fff;
    box-shadow: 0 4px 14px var(--f1-red-glow);
}

.btn-outline-secondary {
    color: var(--text-muted);
    border: 1px solid var(--border-strong);
    background: transparent;
}

.btn-outline-secondary:hover {
    background: var(--surface-2);
    border-color: var(--border-strong);
    color: #fff;
}

/* ----------------------------- Badges ----------------------------- */

.badge {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-size: 0.68rem;
    padding: 0.4em 0.7em;
    border-radius: 6px;
}

.badge.bg-success { background: rgba(40, 199, 111, 0.16) !important; color: var(--ok) !important; border: 1px solid rgba(40, 199, 111, 0.4); }
.badge.bg-secondary { background: rgba(154, 154, 172, 0.14) !important; color: var(--text-muted) !important; border: 1px solid var(--border-strong); }
.badge.bg-danger { background: rgba(234, 84, 85, 0.16) !important; color: var(--err) !important; border: 1px solid rgba(234, 84, 85, 0.4); }
.badge.bg-warning { background: rgba(255, 159, 67, 0.16) !important; color: var(--warn) !important; border: 1px solid rgba(255, 159, 67, 0.4); }

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

.status-dot.ok { background: var(--ok); box-shadow: 0 0 8px rgba(40, 199, 111, 0.7); }
.status-dot.err { background: var(--err); box-shadow: 0 0 8px rgba(234, 84, 85, 0.7); }
.status-dot.run { background: var(--warn); box-shadow: 0 0 8px rgba(255, 159, 67, 0.7); }

/* ----------------------------- List groups ----------------------------- */

.list-group {
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

.list-group-item {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
    padding: 0.95rem 1.15rem;
    font-weight: 600;
}

.list-group-item-action:hover {
    background: rgba(225, 6, 0, 0.08);
    color: #fff;
}

.race-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.race-round {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--text-muted);
    flex: 0 0 auto;
}

/* ----------------------------- Forms ----------------------------- */

.form-control,
.form-select,
.form-check-input {
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    color: var(--text);
}

.form-control:focus,
.form-select:focus {
    background: var(--bg-elevated);
    border-color: var(--f1-red);
    box-shadow: 0 0 0 0.2rem var(--f1-red-glow);
    color: var(--text);
}

.prediction-model-select {
    min-width: 12rem;
}

.form-control::placeholder {
    color: var(--text-dim);
}

.form-check-input:checked {
    background-color: var(--f1-red);
    border-color: var(--f1-red);
}

.form-check-input:focus {
    border-color: var(--f1-red);
    box-shadow: 0 0 0 0.2rem var(--f1-red-glow);
}

.form-label {
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-size: 0.78rem;
}

.pick-toggle {
    display: block;
    cursor: pointer;
}

.pick-toggle .form-check-input {
    margin-top: 0.3rem;
}

/* ----------------------------- Alerts ----------------------------- */

.alert {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
}

.alert-danger {
    border-color: rgba(234, 84, 85, 0.5);
    background: rgba(234, 84, 85, 0.12);
    color: #ffb3b3;
}

.alert-success {
    border-color: rgba(40, 199, 111, 0.5);
    background: rgba(40, 199, 111, 0.12);
    color: #9be7bd;
}

/* ----------------------------- Login ----------------------------- */

.login-shell {
    min-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: 100%;
    max-width: 420px;
}

.login-card .login-flag {
    height: 8px;
    background: repeating-conic-gradient(#fff 0% 25%, #111 0% 50%) 0 0 / 16px 16px;
}

/* ----------------------------- Footer ----------------------------- */

.site-footer {
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-dim);
    font-size: 0.8rem;
    padding: 1.25rem 0;
    margin-top: 2.5rem;
}

.site-footer .footer-flag {
    display: inline-block;
    width: 22px;
    height: 14px;
    border-radius: 3px;
    background: repeating-conic-gradient(#fff 0% 25%, #111 0% 50%) 0 0 / 7px 7px;
    vertical-align: middle;
    margin-right: 8px;
}

/* ----------------------------- Chart ----------------------------- */

.chart-shell {
    position: relative;
    padding: 0.5rem;
}

/* ----------------------------- Utilities ----------------------------- */

.divider {
    height: 1px;
    background: var(--border);
    margin: 1.25rem 0;
}

.muted-empty {
    color: var(--text-dim);
    text-align: center;
    padding: 2.5rem 1rem;
}

.kv {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.kv:last-child {
    border-bottom: none;
}

.kv .kv-key {
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-size: 0.78rem;
    font-weight: 600;
}

.kv .kv-val {
    font-weight: 700;
}

/* ----------------------------- Countdown ----------------------------- */

.countdown {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.countdown-seg {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 52px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
}

.countdown-num {
    font-size: 1.35rem;
    font-weight: 800;
    color: #fff;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.countdown-lbl {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    font-weight: 700;
    margin-top: 2px;
}

.countdown.countdown-sm {
    gap: 6px;
}

.countdown.countdown-sm .countdown-seg {
    min-width: 40px;
    padding: 4px 6px;
}

.countdown.countdown-sm .countdown-num {
    font-size: 1rem;
}

.countdown.countdown-sm .countdown-lbl {
    font-size: 0.55rem;
}

.audit-event {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    color: var(--text-muted);
}

.audit-event-login_success,
.audit-event-password_change {
    color: var(--ok);
    border-color: rgba(40, 199, 111, 0.35);
}

.audit-event-login_failure,
.audit-event-access_denied {
    color: var(--err);
    border-color: rgba(234, 84, 85, 0.35);
}

.audit-event-sync_triggered,
.audit-event-action {
    color: var(--warn);
    border-color: rgba(255, 159, 67, 0.35);
}

.chip-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(225, 6, 0, 0.12);
    border: 1px solid rgba(225, 6, 0, 0.35);
    color: #ff6b63;
    white-space: nowrap;
}

.stat-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.35px;
    padding: 2px 8px;
    border-radius: 999px;
    margin-right: 0.25rem;
    white-space: nowrap;
}

.stat-dnf {
    background: rgba(255, 71, 87, 0.14);
    border: 1px solid rgba(255, 71, 87, 0.35);
    color: #ff7b88;
}

.stat-fl {
    background: rgba(40, 199, 111, 0.12);
    border: 1px solid rgba(40, 199, 111, 0.35);
    color: #5ce0a0;
}

.stat-pit {
    background: rgba(0, 210, 190, 0.12);
    border: 1px solid rgba(0, 210, 190, 0.35);
    color: #5de8d8;
}

.stat-captain {
    background: rgba(255, 211, 78, 0.12);
    border: 1px solid rgba(255, 211, 78, 0.35);
    color: #ffd34e;
}

.commentary-card .card-header {
    font-weight: 700;
    letter-spacing: 0.5px;
}

.commentary-body p {
    margin-bottom: 1rem;
    line-height: 1.7;
    color: var(--text);
}

.commentary-body p:last-child {
    margin-bottom: 0;
}

.commentary-meta {
    margin-top: 1rem;
    font-size: 0.78rem;
}

.timing-board .timing-num {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: var(--text-muted);
    font-family: "Titillium Web", monospace, sans-serif;
}

.move-up {
    color: var(--ok);
    font-weight: 800;
    font-size: 0.85rem;
}

.move-down {
    color: var(--err);
    font-weight: 800;
    font-size: 0.85rem;
}

.move-neutral {
    color: var(--text-dim);
    font-weight: 700;
}

/* ----------------------------- Compare charts ----------------------------- */

.compare-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}

.compare-stat {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.compare-stat .label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    font-weight: 700;
}

.compare-stat .value {
    font-size: 1.25rem;
    font-weight: 800;
    color: #fff;
    margin-top: 2px;
}

.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.25rem;
}

.chart-card .card-body {
    min-height: 280px;
}

.h2h-table td, .h2h-table th {
    font-variant-numeric: tabular-nums;
}

.team-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}
