/* ============================================
   SimRacing GT — Global Styles (dark theme)
   ============================================ */

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    max-width: 1300px;
    margin: 0 auto;
    padding: 0 30px;
    background: transparent;
    color: #e6e8eb;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
}

/* ===== ФОН ===== */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image: url('/static/img/bmw-m4-gt3-evo-4k-04.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    filter: blur(25px) brightness(0.35) saturate(1.1);
    transform: scale(1.15);
}

/* ===== NAV ===== */
nav.top-nav {
    background: rgba(15, 16, 20, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #fff;
    margin: 0 -30px 40px;
    padding: 18px 30px;
    display: flex;
    align-items: center;
    gap: 32px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
nav.top-nav h1 { margin: 0; font-size: 20px; letter-spacing: -0.3px; }
nav.top-nav h1 a { color: #fff; text-decoration: none; }
nav.top-nav a {
    color: #9aa0a9;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: color 0.15s;
}
nav.top-nav a:hover { color: #fff; }

main { flex: 1 0 auto; }

/* ===== HEADINGS ===== */
h2 {
    margin: 40px 0 6px;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0,0,0,0.6);
}
h2 + p {
    color: rgba(255, 255, 255, 0.6);
    margin-top: 0;
    margin-bottom: 25px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
h3 {
    margin: 40px 0 15px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.2px;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0,0,0,0.6);
}

/* ===== TABLE ===== */
.table-wrap {
    width: 100%;
    border-radius: 8px;
    margin: 20px 0 30px;
    position: relative;
    overflow-x: auto;
}

.table-wrap table {
    width: 100%;
    min-width: 100%;
    margin: 0;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: transparent;
    border-radius: 8px;
    overflow: hidden;
    margin: 20px 0 30px;
    font-size: 14px;
    color: #e6e8eb;
    table-layout: auto;
}

th, td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    vertical-align: middle;
    background: transparent;
}

th {
    font-weight: 500;
    font-size: 12px;
    color: #9aa0a9;
    letter-spacing: 0;
    position: sticky;
    top: 0;
    z-index: 2;
    background: rgba(15, 16, 20, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding: 10px 16px;
    white-space: nowrap;
}

tbody tr {
    background: rgba(10, 11, 14, 0.35);
    transition: background 0.15s;
}
tbody tr:nth-child(even) {
    background: rgba(10, 11, 14, 0.55);
}
tbody tr:hover {
    background: rgba(120, 125, 135, 0.35);
}
tbody tr:last-child td { border-bottom: none; }

td a {
    color: #d1d5db;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s;
}
td a:hover { color: #fff; }

.time {
    font-family: 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;
    font-size: 13px;
    color: #fff;
    font-weight: 600;
    letter-spacing: -0.2px;
    white-space: nowrap;
}

.pos-1 { font-weight: 700; color: #f4c430; }
.pos-2 { font-weight: 700; color: #c0c0c0; }
.pos-3 { font-weight: 700; color: #cd7f32; }

td.best-time {
    color: #a78bfa !important;
    font-weight: 700;
    background: rgba(167, 139, 250, 0.14) !important;
    box-shadow: inset 0 0 0 1px rgba(167, 139, 250, 0.3);
}

/* ===== CAR BRAND ===== */
.car-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}
.car-brand img {
    height: 16px;
    width: auto;
    opacity: 0.9;
}

/* ===== TRACK CELL (для таблицы трасс) ===== */
.track-cell {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
}
.track-icon {
    width: 40px;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
    display: block;
}
.track-icon-placeholder {
    width: 40px;
    height: 28px;
    flex-shrink: 0;
    display: block;
}
.track-cell .track-name {
    font-weight: 600;
    white-space: nowrap;
}

/* ===== ROW LINK ===== */
.row-link {
    color: #9aa0a9;
    text-decoration: none;
    font-weight: 600;
    font-size: 16px;
    transition: color 0.15s, transform 0.15s;
    display: inline-block;
}
tbody tr:hover .row-link {
    color: #22c55e;
    transform: translateX(3px);
}
.row-link:hover {
    color: #16a34a;
    text-decoration: none;
}

/* ===== CLASS BADGES ===== */
.badge-class {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.badge-gt3 { background: #1e3a8a; color: #c7d2fe; }
.badge-gt4 { background: #b45309; color: #fde68a; }
.badge-gt2 { background: #7e22ce; color: #e9d5ff; }
.badge-gtc { background: #166534; color: #bbf7d0; }
.badge-tcx { background: #be123c; color: #fecdd3; }

/* ===== CARDS / EMPTY ===== */
.empty {
    text-align: center;
    padding: 60px 30px;
    color: #9aa0a9;
    background: rgba(15, 16, 20, 0.82);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}
.card {
    background: rgba(15, 16, 20, 0.82);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    padding: 25px 30px;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.4);
    margin: 20px 0 30px;
    color: #d1d5db;
}

/* ===== STAT GRID ===== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 25px 0 35px;
}
.stat {
    background: rgba(15, 16, 20, 0.82);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    padding: 24px 26px;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    color: #d1d5db;
    transition: transform 0.15s, box-shadow 0.15s;
}
.stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
.stat .label {
    font-size: 11px;
    color: #7a7e86;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.8px;
}
.stat .value {
    font-size: 32px;
    font-weight: 700;
    margin-top: 6px;
    letter-spacing: -0.5px;
    color: #fff;
}
.stat .value.time {
    font-size: 26px;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    letter-spacing: 0;
}

/* ===== SESSION CARD ===== */
.stat-session {
    padding: 0 !important;
    overflow: hidden;
    position: relative;
    min-height: 220px;
    background-size: cover;
    background-position: center;
    background-color: #0f1012;
}
.stat-session .overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0.9) 100%);
    z-index: 1;
}
.stat-session .content {
    position: relative;
    z-index: 2;
    padding: 22px 24px;
    color: #fff;
    display: flex;
    flex-direction: column;
    min-height: 220px;
}
.stat-session .label {
    color: rgba(255,255,255,0.65);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
}
.stat-session .title {
    font-size: 22px;
    font-weight: 700;
    margin-top: 12px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.6);
}
.stat-session .badge {
    margin-top: 14px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,0.12);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    padding: 8px 14px;
}
.stat-session .badge .type { font-size: 15px; font-weight: 600; }
.stat-session .badge .timer { font-size: 14px; opacity: 0.9; font-family: monospace; }

.stat-session .progress {
    margin-top: 12px;
    height: 4px;
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
    overflow: hidden;
}
.stat-session .progress-bar {
    height: 100%;
    width: 0%;
    background: #22c55e;
    transition: width 1s linear;
}

.stat-session .chips {
    margin-top: auto;
    padding-top: 16px;
    display: flex;
    gap: 8px;
}
.stat-session .chip {
    flex: 1;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    padding: 8px;
    text-align: center;
}
.stat-session .chip .m { font-size: 16px; font-weight: 700; }
.stat-session .chip .t { font-size: 11px; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.5px; }

/* ===== FORM ===== */
form select, form input[type="text"] {
    padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    font-size: 14px;
    background: rgba(15, 16, 20, 0.7);
    color: #e6e8eb;
    transition: border-color 0.15s, box-shadow 0.15s;
    min-width: 160px;
    font-family: inherit;
}
form select:focus, form input:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0,102,204,0.2);
}
form button {
    padding: 10px 22px;
    background: #fff;
    color: #16171a;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    transition: background 0.15s, transform 0.1s;
}
form button:hover { background: #e0e0e0; }
form button:active { transform: scale(0.98); }
form label { color: #9aa0a9 !important; }

/* ===== CHAMPIONSHIP BANNER ===== */
.champ-banner {
    background: rgba(15, 16, 20, 0.82);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 30px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}
.champ-banner .hero {
    position: relative;
    height: 260px;
    background: linear-gradient(135deg, #1d1d1f 0%, #2a2c30 100%);
    background-size: cover;
    background-position: center;
}
.champ-banner .hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0.7) 100%);
    z-index: 1;
}
.champ-banner .hero-content {
    position: relative;
    z-index: 2;
    padding: 30px 35px;
    color: #fff;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.champ-banner .hero-sub {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0.75;
    margin-bottom: 8px;
}
.champ-banner .hero-title {
    font-size: 42px;
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1;
    text-shadow: 0 3px 12px rgba(0,0,0,0.6);
}
.champ-banner .hero-subtitle {
    font-size: 20px;
    font-weight: 600;
    opacity: 0.95;
    margin-top: 6px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.champ-banner .body { padding: 24px 30px; }
.champ-banner .btn-register {
    display: block;
    text-align: center;
    background: #22c55e;
    color: #fff;
    padding: 16px 24px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    transition: background 0.2s, transform 0.1s;
    letter-spacing: 0.3px;
}
.champ-banner .btn-register:hover { background: #16a34a; }

.champ-banner .countdown-wrap {
    margin-top: 22px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.champ-banner .countdown-label {
    font-size: 13px;
    color: #9aa0a9;
    font-weight: 600;
}
.champ-banner .countdown {
    display: flex;
    gap: 18px;
    font-weight: 700;
    color: #fff;
}
.champ-banner .countdown > div { text-align: center; }
.champ-banner .countdown .num { font-size: 22px; line-height: 1; }
.champ-banner .countdown .unit {
    font-size: 10px;
    color: #7a7e86;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* ===== FOOTER ===== */
footer {
    background: rgba(15, 16, 20, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    flex-shrink: 0;
    color: #9aa0a9;
    margin: 60px -30px 0;
    padding: 30px 30px;
    font-size: 13px;
    line-height: 1.7;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}
footer a { color: #6cb6ff; text-decoration: none; }
footer a:hover { color: #fff; text-decoration: underline; }
footer .champ {
    color: #fff;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== UTILITIES ===== */
.hide-mobile { }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: #7a7e86; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
    display: none;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {

    body {
        padding: 0 15px;
        padding-bottom: 100px;
        font-size: 14px;
    }

    .top-nav { display: none !important; }

    h2 { font-size: 22px; margin: 25px 0 6px; }
    h3 { font-size: 16px; margin: 25px 0 12px; }

    .stat-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        margin: 15px 0 25px;
    }
    .stat { padding: 18px 20px; }
    .stat .value { font-size: 24px; }
    .stat .value.time { font-size: 22px; }

    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 15px 0 25px;
    }
    th, td {
        padding: 10px 12px;
        font-size: 13px;
        white-space: nowrap;
    }
    th { font-size: 10px; }

    form.card {
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 16px !important;
        gap: 12px !important;
    }
    form.card > div { width: 100%; }
    form.card select,
    form.card input[type="text"] { width: 100%; min-width: 0; }
    form.card button { width: 100%; }

    .champ-banner .hero { height: 180px; }
    .champ-banner .hero-title { font-size: 28px; }
    .champ-banner .hero-subtitle { font-size: 16px; }
    .champ-banner .hero-content { padding: 20px 22px; }
    .champ-banner .body { padding: 18px 22px; }
    .champ-banner .countdown { gap: 12px; }
    .champ-banner .countdown .num { font-size: 18px; }

    footer {
        margin: 40px -15px 90px;
        padding: 22px 15px 30px;
        font-size: 12px;
        line-height: 1.5;
    }
    footer .champ { display: none; }

    body::before {
        background-attachment: scroll;
    }

    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 999;
        background: rgba(15, 16, 20, 0.98);
        backdrop-filter: blur(24px);
        -webkit-backdrop-filter: blur(24px);
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        padding: 8px 0;
        padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
        justify-content: space-around;
        align-items: center;
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.5);
        min-height: 60px;
        margin: 0;
        gap: 0;
    }

    .bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 4px 8px;
        text-decoration: none;
        color: #7a7e86;
        font-size: 10px;
        font-weight: 500;
        transition: color 0.15s, transform 0.1s;
        -webkit-tap-highlight-color: transparent;
        cursor: pointer;
        min-height: 48px;
    }

    .bottom-nav-item svg {
        width: 24px;
        height: 24px;
        stroke: currentColor;
        transition: stroke 0.15s, transform 0.15s;
        display: block;
    }

    .bottom-nav-item span {
        font-size: 10px;
        letter-spacing: 0.2px;
        line-height: 1;
    }

    .bottom-nav-item.active { color: #e63946; }
    .bottom-nav-item.active svg {
        stroke: #e63946;
        transform: scale(1.05);
    }
    .bottom-nav-item:hover,
    .bottom-nav-item:active { color: #fff; }
    .bottom-nav-item:hover svg,
    .bottom-nav-item:active svg { stroke: #fff; }
}

@media (max-width: 480px) {
    .hide-mobile { display: none !important; }
    nav.top-nav h1 { font-size: 16px; }
    h2 { font-size: 20px; }
}
/* ============================================
   SESSION ACCORDION (раскрывающиеся строки в сессии)
   ============================================ */

.session-accordion {
    margin: 20px 0 30px;
    border-radius: 8px;
    overflow: hidden;
}

/* Шапка таблицы */
.session-header {
    background: rgba(20, 22, 27, 0.95);
    padding: 12px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 11px;
    color: #7a7e86;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}
.session-header .cell {
    color: #7a7e86;
}

/* Строки */
.session-row {
    background: rgba(10, 11, 14, 0.55);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: background 0.15s;
}
.session-row:nth-child(even) {
    background: rgba(10, 11, 14, 0.35);
}
.session-row:hover {
    background: rgba(120, 125, 135, 0.25);
}
.session-row[open] {
    background: rgba(20, 22, 27, 0.75);
}

.session-row summary {
    list-style: none;
    cursor: pointer;
    padding: 14px 18px;
    display: block;
    outline: none;
}
.session-row summary::-webkit-details-marker {
    display: none;
}

.row-grid {
    display: grid;
    grid-template-columns: 40px 1.5fr 2fr 110px 130px 70px 60px 1.5fr;
    gap: 12px;
    align-items: center;
    font-size: 14px;
}

.row-grid .cell {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cell-pos {
    text-align: center;
    font-weight: 700;
}

.cell-driver {
    font-weight: 600;
    color: #fff;
}

.cell-car {
    color: #d1d5db;
    font-size: 13px;
}

.cell-time {
    font-family: 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;
    font-size: 13px;
    color: #fff;
    font-weight: 600;
}

.cell-num {
    text-align: center;
    color: #d1d5db;
}

.cell-penalties {
    color: #ff6b6b;
    font-size: 12px;
}

/* Развёрнутый блок */
.row-expand {
    padding: 10px 18px 20px 70px;
    background: rgba(0, 0, 0, 0.3);
}

.laps-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin: 0;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
}
.laps-table th,
.laps-table td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    text-align: left;
    background: transparent;
}
.laps-table th {
    font-size: 11px;
    color: #7a7e86;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: transparent;
    position: static;
    box-shadow: none;
}
.laps-table tr:hover td {
    background: rgba(120, 125, 135, 0.15);
}

/* Стрелка раскрытия */
.session-row summary::before {
    content: "▸";
    display: inline-block;
    margin-right: 8px;
    color: #7a7e86;
    transition: transform 0.15s;
    font-size: 12px;
}
.session-row[open] summary::before {
    transform: rotate(90deg);
    color: #fff;
}

/* Мобильная версия */
@media (max-width: 900px) {
    .row-grid {
        grid-template-columns: 32px 1fr 60px 60px;
        gap: 8px;
        font-size: 13px;
    }
    .cell-car,
    .cell-time:first-of-type,
    .cell-penalties {
        display: none;
    }
    .session-header .cell-car,
    .session-header .cell-time:first-of-type,
    .session-header .cell-penalties {
        display: none;
    }
    .row-expand {
        padding: 10px 12px 15px 12px;
    }
    .laps-table th:nth-child(3),
    .laps-table th:nth-child(4),
    .laps-table th:nth-child(5),
    .laps-table td:nth-child(3),
    .laps-table td:nth-child(4),
    .laps-table td:nth-child(5) {
        display: none;
    }
}
