:root {
    --bg: #061a37;
    --bg-soft: #082044;
    --panel: #0a254b;
    --panel-2: #0b2a52;
    --line: #1f4f86;
    --line-soft: #1b3f69;
    --text: #edf5ff;
    --muted: #9ec1e9;
    --accent: #2f8bff;
    --accent-2: #ff9d2e;
    --danger: #ff676f;
    --radius: 12px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background:
        radial-gradient(1200px 460px at 12% -140px, rgba(21, 62, 113, 0.55), transparent 70%),
        radial-gradient(900px 360px at 88% -100px, rgba(12, 46, 90, 0.3), transparent 70%),
        var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Tahoma, Verdana, sans-serif;
    font-size: 13px;
}

a {
    color: #b9d8ff;
    text-decoration: none;
}

a:hover {
    color: #ffffff;
}

.container {
    width: min(100%, 1500px);
    margin: 0 auto;
    padding: 0 14px;
}

.container--public {
    width: 100%;
    max-width: none;
    padding: 0 8px;
}

.page {
    padding: 10px 0 18px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    border-bottom: 1px solid var(--line-soft);
    background: linear-gradient(180deg, rgba(5, 16, 33, 0.96), rgba(4, 13, 28, 0.96));
    backdrop-filter: blur(8px);
}

.topbar__inner {
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand__mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: linear-gradient(145deg, #ff7f52, #ff6334);
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.brand__title {
    font-weight: 700;
    letter-spacing: 0.02em;
    font-size: 1.02rem;
}

.topnav {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.92rem;
}

.panel {
    background: linear-gradient(180deg, rgba(10, 35, 70, 0.98), rgba(8, 31, 62, 0.98));
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.24);
}

.panel--narrow {
    max-width: 460px;
    margin: 26px auto 14px;
}

.panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.panel__head--stack {
    align-items: flex-start;
    flex-direction: column;
}

h1, h2, h3, h4 {
    margin: 0 0 6px;
    line-height: 1.2;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.22rem; }

p {
    margin: 0 0 8px;
}

.muted {
    color: var(--muted);
    font-size: 0.92em;
}

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

label {
    display: grid;
    gap: 5px;
    font-size: 0.88rem;
    color: #d9e9ff;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #2a5d95;
    border-radius: 8px;
    background: #082043;
    color: var(--text);
    padding: 8px 10px;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(47, 139, 255, 0.35);
    border-color: #3f86d6;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox input[type="checkbox"] {
    width: auto;
}

.btn {
    border: 1px solid transparent;
    background: linear-gradient(90deg, #2f8bff, #5ca9ff);
    color: #fff;
    border-radius: 10px;
    padding: 7px 12px;
    cursor: pointer;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:hover {
    filter: brightness(1.08);
}

.btn--ghost {
    background: #0b2a51;
    border-color: #2b67a3;
    color: #d8ebff;
}

.btn--danger {
    background: rgba(255, 103, 111, 0.15);
    border-color: rgba(255, 103, 111, 0.55);
    color: #ffd4d8;
}

.table-wrap {
    width: 100%;
    overflow: auto;
    border: 1px solid var(--line-soft);
    border-radius: 10px;
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 100%;
}

.table th,
.table td {
    border-bottom: 1px solid #1b3f69;
    border-right: 1px solid #1b3f69;
    padding: 6px 8px;
    text-align: left;
    white-space: nowrap;
    vertical-align: middle;
}

.table th {
    position: sticky;
    top: 0;
    z-index: 12;
    background: #0f345f;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

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

.table td:last-child,
.table th:last-child {
    border-right: 0;
}

.table--compact input,
.table--compact select {
    padding: 6px 8px;
}

.ranking-table .sticky-col {
    position: sticky;
    z-index: 10;
    background: #062148;
}

.ranking-table thead .sticky-col {
    z-index: 20;
    background: #0d3765;
}

.ranking-table {
    table-layout: fixed;
    width: 100%;
    min-width: 0;
}

.ranking-table .sticky-col--1 { left: 0; width: 46px; min-width: 46px; }
.ranking-table .sticky-col--2 { left: 46px; width: 58px; min-width: 58px; }
.ranking-table .sticky-col--3 { left: 104px; width: 240px; min-width: 240px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.ranking-table .sticky-col--4 { left: 344px; width: 56px; min-width: 56px; text-align: center; }

.ranking-table .th-event {
    width: 82px;
    min-width: 82px;
    max-width: 82px;
}

.th-main {
    display: block;
    color: #ffffff;
    font-weight: 700;
    font-size: 0.84rem;
}

.th-sub {
    display: block;
    font-size: 0.62rem;
    color: #a7c8ed;
    text-transform: none;
    white-space: normal;
    line-height: 1.1;
}

.score-cell {
    text-align: center;
    min-width: 70px;
    width: 70px;
    max-width: 70px;
}

.score-value {
    display: block;
    font-weight: 700;
    color: #f1f7ff;
    font-size: 0.88rem;
}

.score-meta {
    display: block;
    font-size: 0.61rem;
    color: #95b6da;
}

.th-total--pre,
.score-total--pre {
    min-width: 70px;
    width: 70px;
    max-width: 70px;
}

.score-total {
    font-weight: 800;
    color: #ffe9cf;
    background: rgba(255, 164, 70, 0.16);
    text-align: center;
}

.is-dropped .score-value {
    opacity: 0.62;
    text-decoration: line-through;
    text-decoration-thickness: 2px;
    text-decoration-color: #f3a58d;
}

.is-top3 td {
    background: linear-gradient(90deg, rgba(255, 157, 46, 0.1), rgba(255, 157, 46, 0.02));
}

.is-top3 .sticky-col {
    background: #12345a;
}

.classification-switch {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: auto;
    align-items: flex-start;
}

.mode-tabs,
.tabs {
    display: inline-flex;
    flex-wrap: nowrap;
    align-self: flex-start;
    border: 0;
    border-radius: 0;
    padding: 0;
    background: transparent;
    gap: 6px;
    width: fit-content;
    max-width: 100%;
}

.mode-tab,
.tab {
    border: 1px solid #2a6aae;
    border-radius: 9px;
    background: #062652;
    color: #b2d5ff;
    padding: 6px 13px;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.91rem;
    letter-spacing: 0.01em;
}

.mode-tab.is-active,
.tab.is-active {
    border-color: #f08f61;
    background: linear-gradient(180deg, #0b3f7e, #0a3467);
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(255, 178, 141, 0.18);
}

.mode-tab:hover,
.tab:hover {
    background: #0b3465;
    color: #f2f8ff;
}

.classes-dropdown-label {
    display: grid;
    gap: 6px;
    width: min(100%, 260px);
}

.summary-line {
    margin-bottom: 3px;
}

.classification-line {
    margin-bottom: 7px;
}

.country-cell {
    text-align: center;
}

.country-flag-img {
    width: 18px;
    height: 13px;
    display: inline-block;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(183, 214, 247, 0.4);
}

.country-code {
    display: inline-block;
    font-size: 0.72rem;
    color: #c6def8;
    font-weight: 600;
}

.driver-name {
    display: block;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.driver-car {
    display: block;
    color: #9fc0e2;
    font-size: 0.75rem;
    line-height: 1.1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.team-ranking-table .sticky-col--1 {
    left: 0;
    width: 46px;
    min-width: 46px;
}

.team-ranking-table .sticky-col--2 {
    left: 46px;
    width: 348px;
    min-width: 348px;
    max-width: 348px;
}

.team-name {
    display: block;
    font-weight: 800;
    color: #f2f8ff;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.team-members {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 1px;
}

.team-member {
    font-size: 0.73rem;
    color: #a9c9ea;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.team-members__more {
    display: none;
    font-size: 0.66rem;
    color: #87add2;
}

.team-score-trigger {
    appearance: none;
    border: 0;
    background: transparent;
    color: inherit;
    width: 100%;
    min-height: 32px;
    cursor: pointer;
    border-radius: 6px;
    padding: 0;
}

.team-score-trigger:hover,
.team-score-trigger:focus-visible {
    background: rgba(255, 255, 255, 0.06);
    outline: none;
}

.score-open-hint {
    display: block;
    margin-top: 1px;
    font-size: 0.54rem;
    line-height: 1;
    color: #8db3dd;
    letter-spacing: 0.02em;
}

.team-ranking-table .th-total--pre,
.team-ranking-table .score-total--pre {
    text-align: center;
}

.team-score-modal[hidden] {
    display: none;
}

.team-score-modal {
    position: fixed;
    inset: 0;
    z-index: 120;
}

.team-score-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(2, 10, 22, 0.72);
}

.team-score-modal__dialog {
    position: relative;
    width: min(92vw, 560px);
    margin: 8vh auto 0;
    background: linear-gradient(180deg, rgba(9, 33, 66, 0.98), rgba(7, 27, 56, 0.98));
    border: 1px solid #2a5d95;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.team-score-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.team-score-modal__close {
    min-height: 30px;
    padding: 4px 8px;
}

.team-score-modal__row--counted td {
    font-weight: 800;
    color: #ffffff;
}

.team-score-modal-open {
    overflow: hidden;
}

.flash {
    border-radius: 10px;
    padding: 9px 11px;
    margin-bottom: 10px;
    border: 1px solid transparent;
    font-size: 0.92rem;
}

.flash--success {
    background: rgba(36, 212, 138, 0.15);
    border-color: rgba(36, 212, 138, 0.4);
}

.flash--error {
    background: rgba(255, 103, 111, 0.15);
    border-color: rgba(255, 103, 111, 0.45);
}

.flash--warning {
    background: rgba(255, 179, 71, 0.15);
    border-color: rgba(255, 179, 71, 0.45);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 12px;
}

.sep {
    border: 0;
    border-top: 1px solid var(--line-soft);
    margin: 14px 0;
}

.nowrap {
    white-space: nowrap;
}

.hidden-form {
    display: none;
}

.inline-form {
    display: inline;
}

.inline-form + .inline-form {
    margin-left: 6px;
}

@media (max-width: 1100px) {
    h1 { font-size: 1.6rem; }
    .ranking-table .sticky-col--3 { width: 205px; min-width: 205px; max-width: 205px; left: 104px; }
    .ranking-table .sticky-col--4 { left: 309px; width: 50px; min-width: 50px; }
    .ranking-table .th-event { width: 74px; min-width: 74px; max-width: 74px; }
    .score-cell { width: 64px; min-width: 64px; max-width: 64px; }
    .team-ranking-table .sticky-col--2 { width: 300px; min-width: 300px; max-width: 300px; }
}

@media (max-width: 860px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 1.3rem;
    }

    .container--public {
        padding: 0;
    }

    .panel {
        border-radius: 0;
        border-left: 0;
        border-right: 0;
        padding: 10px 6px;
    }

    .mode-tab,
    .tab {
        min-height: 32px;
        padding: 5px 9px;
        font-size: 0.78rem;
    }

    .classes-dropdown-label {
        width: min(100%, 210px);
    }

    .ranking-table .sticky-col--1 { width: 34px; min-width: 34px; }
    .ranking-table .sticky-col--2 { left: 34px; width: 48px; min-width: 48px; }
    .ranking-table .sticky-col--3 { left: 82px; width: 132px; min-width: 132px; max-width: 132px; }
    .ranking-table .sticky-col--4 { left: 214px; width: 38px; min-width: 38px; }
    .ranking-table .th-event { width: 66px; min-width: 66px; max-width: 66px; }
    .score-cell { width: 58px; min-width: 58px; max-width: 58px; }
    .score-total--pre,
    .th-total--pre { width: 58px; min-width: 58px; max-width: 58px; }

    .table th,
    .table td {
        padding: 3px 4px;
    }

    .th-main {
        font-size: 0.58rem;
    }

    .th-sub {
        font-size: 0.46rem;
    }

    .ranking-table th { font-size: 0.58rem; }
    .ranking-table td { font-size: 0.72rem; }
    .driver-name { font-size: 0.72rem; }
    .driver-car { font-size: 0.52rem; }
    .score-value { font-size: 0.7rem; }
    .score-meta { font-size: 0.46rem; }
    .country-flag-img { width: 14px; height: 11px; }

    .team-ranking-table .sticky-col--1 { width: 34px; min-width: 34px; }
    .team-ranking-table .sticky-col--2 {
        left: 34px;
        width: 204px;
        min-width: 204px;
        max-width: 204px;
    }
    .team-name { font-size: 0.72rem; margin-bottom: 2px; }
    .team-member { font-size: 0.58rem; line-height: 1.2; }
    .score-open-hint { font-size: 0.48rem; }
    .team-score-modal__dialog {
        width: min(96vw, 520px);
        margin-top: 6vh;
    }
}
