* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

html.js-loading .tab-content {
    display: none !important;
}

html.js-loading .tabs {
    visibility: hidden;
}

body {
    background: linear-gradient(135deg, #1a3a5f, #2c5a8a);
    color: white;
    padding: 10px;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    /* На всю высоту экрана: подвал прижат к нижнему краю (margin-top: auto
       у .footer), вкладки растягивает flex: 1 у .tab-content.
       --page-fit-y — что вычесть сверху/снизу контейнера (задаёт
       fitPageHeight в index.html); --dev-banner-height — высота
       дев-баннера (preview_banner.js ставит её на body вместе с
       margin-top), в проде переменной нет и это 0.
       100dvh — динамический вьюпорт: на iPhone нижняя панель Chrome
       перекрывает контент при 100vh, dvh её учитывает; на ПК dvh = vh,
       поэтому вторая строка ничего не меняет. */
    min-height: calc(100vh - var(--page-fit-y, 20px) - var(--dev-banner-height, 0px));
    min-height: calc(100dvh - var(--page-fit-y, 20px) - var(--dev-banner-height, 0px));
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 7px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Шапка вынесена в site-header.css: её используют и index.html, и
   info.html. Одна копия стилей — значит одинаковый вид на обеих страницах. */

.tabs-section {
    margin-bottom: 10px;
}

/* Полоса под вкладками (трек) и белый ползунок живут внутри .tabs: трек
   растянут на всю ширину содержимого, поэтому на телефоне линия не
   обрывается, пока вкладки прокручиваются. Прокрутку даёт .tabs-scroll —
   сам .tabs не может быть скроллером, иначе ползунок обрезался бы по его
   нижней границе. */
.tabs-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.tabs-scroll::-webkit-scrollbar {
    display: none;
}

.tabs {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 22px;
    min-width: 100%;
    padding: 6px 10px 9px;
}

.tabs::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: rgba(255, 255, 255, 0.2);
    pointer-events: none;
}

/* Вкладка — просто подпись: без фона, иконки и фиксированной ширины.
   Неактивная серая, активная белая. */
.tab {
    display: flex;
    align-items: center;
    padding: 2px 0;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.2;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: color 0.2s ease;
}

.tab.active {
    color: #fff;
}

.tab:hover:not(.active) {
    color: rgba(255, 255, 255, 0.85);
}

/* Белый ползунок на полосе: ширину и сдвиг задаёт скрипт
   (updateTabsSlider в index.html) — по границам текста активной вкладки. */
.tabs-slider {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 0;
    height: 2px;
    background: #fff;
    border-radius: 1px;
    pointer-events: none;
    transition: transform 0.25s ease, width 0.25s ease;
}

.tab-text {
    white-space: nowrap;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
    flex: 1;
    min-height: 500px;
}

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

.tab-content.active {
    display: block;
}

/* Вкладка событий листается внутри списка, высота списка считается
   под размер экрана (EventsTimeline в index.html). Общий минимум 500px
   на коротких экранах выталкивал бы контент за вьюпорт и давал
   вертикальную прокрутку самой страницы — поэтому здесь её нет. */
#events-tab {
    min-height: 0;
}

.search-section {
    margin-bottom: 15px;
}

.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    position: relative;
}

.search-input {
    flex: 1;
    padding: 4px 10px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 1rem;
    backdrop-filter: blur(10px);
    padding-right: 40px !important;
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.search-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.2);
}

.search-stats {
    text-align: center;
    opacity: 0.8;
    font-size: 0.9rem;
}

.initial-state {
    text-align: center;
    padding: 40px 20px;
    opacity: 0.7;
}

.initial-state i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.initial-state h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.initial-state p {
    font-size: 1rem;
    line-height: 1.5;
}

.min-chars-warning {
    text-align: center;
    padding: 40px 20px;
    opacity: 0.7;
}

.min-chars-warning i {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.5;
}

.no-results {
    text-align: center;
    padding: 40px 20px;
    opacity: 0.7;
}

.no-results i {
    font-size: 3rem;
    margin-bottom: 15px;
}

.athletes-list, .ratings-list {
    display: grid;
    gap: 150px;
}

.events-list {
    display: grid;
    gap: 8px;
    /* Как в Google Photos: вкладка событий листается внутри списка,
       а не страницей. Нативный скроллбар скрыт — его роль играет
       полоса-таймлайн с годами справа (EventsTimeline в index.html),
       она лежит поверх контейнера. */
    position: relative;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    /* Окантовка вокруг списка событий. */
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 10px;
}

.events-list::-webkit-scrollbar {
    display: none;
}

.athlete-card, .rating-card, .event-card {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 15px;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-decoration: none;
    color: white;
    display: block;
    margin-bottom: 3px;
}

.event-card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-height: auto;
    align-items: center;
}

.rating-card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-height: auto;
}

.athlete-card:hover, .rating-card:hover, .event-card:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.event-card:hover, .rating-card:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.athlete-header, .rating-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

/* Левая часть карточки — колонка: бейджи, название, место, даты и ряд
   иконок идут отдельными строками. Так сразу видно, что где: одной
   строкой «всё в кучу» карточка читалась хуже, чем таблица. */
.event-left, .rating-left {
    flex: 1;
    min-width: 0;
}

.event-logo, .rating-logo {
    width: 80px;
    height: 80px;
    border-radius: 6px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.event-logo.has-logo, .rating-logo.has-logo {
    background: white;
}

.event-logo i, .rating-logo i {
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.7);
}

.event-logo img, .rating-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

.athlete-name {
    font-size: 1.2rem;
    font-weight: 600;
    flex: 1;
}

.athlete-birth {
    font-size: 0.85rem;
    opacity: 0.8;
    margin-left: 10px;
}

.athlete-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    opacity: 0.9;
}

.athlete-region {
    display: flex;
    align-items: center;
    gap: 5px;
}

.athlete-rank {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.8rem;
}

.rating-name {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 4px;
}

.event-name {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 4px;
}

.athlete-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    font-size: 0.9rem;
    opacity: 0.9;
}

.event-details, .rating-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.8rem;
    opacity: 0.9;
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.gender-m {
    color: #4fc3f7;
}

.gender-f {
    color: #f06292;
}

.rank-badge {
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 600;
    display: inline-block;
}

.rank-badge.rank-ms {
    background: linear-gradient(135deg, #FFD700, #FFA000);
    color: #333;
    border: 1px solid #FFA000;
}

.rank-badge.rank-kms {
    background: linear-gradient(135deg, #C0C0C0, #808080);
    color: white;
    border: 1px solid #808080;
}

.event-type-badge {
    background: linear-gradient(135deg, #4fc3f7, #0288d1);
    color: white;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.year-badge {
    background: linear-gradient(135deg, #66bb6a, #388e3c);
    color: white;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.year-badge.even-year {
    background: linear-gradient(135deg, #ffa726, #f57c00);
}

.badges-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.footer {
    text-align: center;
    margin-top: auto;
    padding-top: 5px;
    padding-bottom: 1px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    opacity: 0.7;
    font-size: 0.78rem;
    line-height: 1.3;
}

.clear-btn {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    display: none;
    padding: 5px;
    font-size: 0.9rem;
}

.clear-btn:hover {
    color: white;
}

.compact-filters {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 3px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    margin-left: auto;
    margin-right: auto;
}

/* Шапка фильтров — одна строка: слева «Фильтры», сразу за ним поиск,
   справа переключатель вида и кнопка сворачивания. */
.filter-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    padding: 0 3px;
}

/* Группа справа прижата к краю, а свободное место забирает поиск. */
.filter-header .filter-header-right {
    margin-left: auto;
}

/* Поиск тянется на свободное место, но не растягивается на пол-экрана,
   и ужимается первым: подписи «Фильтры» и кнопки справа не переносятся. */
.filter-header .events-search-box {
    width: auto;
    flex: 1 1 200px;
    min-width: 90px;
    max-width: 360px;
    margin-left: 2px;
    cursor: default;
}

.filter-header .events-search-box .search-input {
    cursor: text;
}

.filter-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.95rem;
}

.filter-header-left i {
    font-size: 0.95rem;
    color: #4fc3f7;
}

.toggle-filters-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    padding: 3px 9px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
}

.toggle-filters-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.filters-body {
    transition: all 0.3s ease;
    overflow: visible !important;
    position: relative;
    display: none;
}

.filters-body.show {
    display: block;
}

.filters-body.collapsed {
    display: none;
}

.filters-grid {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 5px;
    align-items: stretch;
}

.filter-dropdown {
    position: relative;
    display: flex;
    align-items: center;
    gap: 5px;
    display: none;
}

.filter-dropdown.visible {
    display: flex;
}

.filter-dropdown-btn {
    padding: 4px 6px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    color: white;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 100px;
    justify-content: space-between;
    font-size: 0.9rem;
}

.filter-dropdown-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Крестик в кнопке фильтра — на месте прежней стрелки: убирает фильтр
   из панели (и снимает его значения, см. initFilterRemoveButtons). */
.filter-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 2px;
    border-radius: 50%;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.65);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s, color 0.2s;
}

.filter-remove:hover,
.filter-remove:focus-visible {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    outline: none;
}

.filter-dropdown-btn.has-selection {
    background: rgba(79, 195, 247, 0.2);
    border-color: #4fc3f7;
    color: #4fc3f7;
    font-weight: 600;
}

.filter-dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #2c5a8a;
    min-width: 220px;
    max-height: min(300px, 50vh);
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    margin-top: 4px;
    padding: 8px;
}

.filter-dropdown-content.show {
    display: block;
}

.filter-dropdown-content.upward {
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 4px;
}

.filter-option {
    display: flex;
    align-items: center;
    padding: 4px 12px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-radius: 4px;
    font-size: 0.9rem;
    color: white;
}

.filter-option:hover {
    background: rgba(255, 255, 255, 0.15);
}

.filter-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 2px;
    margin-top: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    border-radius: 4px;
}

.filter-group-header:hover {
    background: rgba(255, 255, 255, 0.1);
}

.filter-group-header input[type="checkbox"] {
    margin-right: 0;
    cursor: pointer;
    accent-color: #4fc3f7;
}

.filter-group-header i {
    width: 16px;
    text-align: center;
}

.filter-option-nested {
    padding-left: 28px;
}

.filter-option input[type="checkbox"],
.filter-option input[type="radio"] {
    margin-right: 8px;
    cursor: pointer;
    accent-color: #4fc3f7;
}

.filter-stats {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.9);
    width: 100%;
    justify-content: flex-end;
}

.clear-filters {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid #ff6b6b;
    color: #ff6b6b;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.clear-filters:hover {
    background: #ff6b6b;
    color: white;
}

.icon-circle {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background-color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

.icon-circle:hover {
    transform: scale(1.1);
}

.icon-circle i {
    font-size: 0.9rem;
}

/* Ряд иконок дистанций и счётчика протоколов — отдельная строка карточки
   под датами, с разделителем сверху. */
.competition-icons-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    padding-top: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    flex-wrap: wrap;
}

.protocol-count {
    height: 25px;
    padding: 0 8px;
    border-radius: 12.5px;
    background-color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1;
    color: #1a3a5f;
}

.protocol-count i {
    font-size: 0.8rem;
    line-height: 1;
    display: flex;
    align-items: center;
    color: #2c5a8a;
}

.people-quatro::before {
    color: white !important;
    font-size: 0.9rem;
}

.filter-dropdown-btn.has-selection .people-quatro::before {
    color: #4fc3f7 !important;
}

.filter-header-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.3);
    margin-bottom: 8px;
}

.filters-body.collapsed .filter-header-divider {
    display: none;
}

.events-search-box {
    display: flex;
    align-items: center;
    gap: 5px;
    position: relative;
    width: 300px;
}

.events-search-box i {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
    min-width: 24px;
    text-align: center;
}

.events-search-box .search-input {
    flex: 1;
    padding-right: 40px !important;
}

.events-search-box .clear-btn {
    position: absolute;
    right: 0px;
    top: 50%;
    transform: translateY(-50%);
}

.filter-icon-left {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.7);
    min-width: 24px;
    text-align: center;
    transition: color 0.2s;
}

.filter-dropdown.has-selection .filter-icon-left {
    color: #4fc3f7;
}

.search-icon-wrapper {
    position: absolute;
    left: 7px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.search-icon-wrapper i {
    color: rgba(255, 255, 255, 0.6);
    font-size: 1rem;
}

.events-search-box .search-input {
    flex: 1;
    padding: 4px 10px 6px 35px !important;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 0.9rem;
    width: 100%;
}

.events-search-box .search-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.2);
}

.events-search-box .clear-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    display: none;
    padding: 5px;
    z-index: 1;
}

.events-search-box .clear-btn:hover {
    color: white;
}

.filter-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-stats-left,
.filter-stats-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-stats-right {
    margin-left: auto;
}

.add-filters-btn {
    background: rgba(79, 195, 247, 0.2);
    border: 1px solid #4fc3f7;
    color: #4fc3f7;
    padding: 8px 6px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.add-filters-btn:hover {
    background: #4fc3f7;
    color: white;
}

.filters-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: #2c5a8a;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.2);
    min-width: 230px;
    z-index: 1002;
    overflow: hidden;
    backdrop-filter: blur(8px);
}

.filter-group-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    color: white;
    font-size: 0.9rem;
}

.filter-group-item:last-child {
    border-bottom: none;
}

.filter-group-item:hover {
    background: rgba(79, 195, 247, 0.2);
}

.filter-group-item i {
    width: 24px;
    color: rgba(255, 255, 255, 0.7);
    transition: color 0.2s ease;
}

.filter-group-item i.active {
    color: #4fc3f7;
}

.filter-stats-left {
    position: relative;
}

.filter-actions-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.filter-action-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 5px 3px;
    color: white;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.filter-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.select-all-btn {
    border-color: #4fc3f7;
    color: #4fc3f7;
}

.select-all-btn:hover {
    background: rgba(79, 195, 247, 0.2);
}

.deselect-all-btn {
    border-color: #ff6b6b;
    color: #ff6b6b;
}

.deselect-all-btn:hover {
    background: rgba(255, 107, 107, 0.2);
}

/* Кнопка добавления события */
.add-event-btn {
    background: linear-gradient(135deg, #4fc3f7, #0288d1);
    border: none;
    border-radius: 10px;
    padding: 6px 12px;
    margin-bottom: 6px;
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.add-event-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 195, 247, 0.4);
}

@media (max-width: 768px) {
    .container {
        padding: 5px;
    }
    .athlete-details {
        grid-template-columns: 1fr;
    }
    .search-box {
        flex-direction: column;
    }
    .initial-state {
        padding: 30px 15px;
    }
    .initial-state i {
        font-size: 3rem;
    }
    .filter-header-left {
        font-size: 0.9rem;
    }
    .filter-header-left i {
        font-size: 0.9rem;
    }
    .search-input {
        padding: 4px 10px;
    }
}

@media (max-width: 600px) {
    .filter-header-left {
        font-size: 0.85rem;
    }
    .filter-header-left i {
        font-size: 0.85rem;
    }
}

@media (max-width: 334px) and (min-width: 0) {
    body {
        min-width: 335px !important;
        overflow-x: auto !important;
        background: linear-gradient(135deg, #1a3a5f, #2c5a8a) fixed !important;
    }
}

/* Обёртка списка событий: точка привязки полосы-таймлайна. */
.events-list-wrap {
    position: relative;
}

/* Полоса-таймлайн с годами на вкладке «События» (как в Google Photos):
   узкая вертикальная полоса с метками годов, перетаскивание прокручивает
   список. Абсолютно позиционируется в обёртке списка (.events-list-wrap)
   и занимает весь его прямоугольник — привязана к div.events-list без
   координатных расчётов в JS. Отступы 10px сверху и снизу дают трек и
   слой меток. Строится скриптом в index.html (EventsTimeline). */
.events-timeline {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    width: 52px;
    z-index: 500;
    display: none;
    touch-action: none;
    user-select: none;
    /* Скрыта по умолчанию, как в Photos: проявляется при прокрутке
       списка или наведении на область полосы (класс is-shown). */
    opacity: 0;
    transition: opacity 0.25s ease;
    /* Верхний отступ трека и меток. В табличном виде сверху списка
       липнет шапка столбцов — скрипт (EventsTimeline) меняет это
       значение на её высоту, иначе годы наезжают на заголовки. */
    --timeline-top: 10px;
}

.events-timeline.is-shown {
    opacity: 1;
}

.events-timeline.is-visible {
    display: block;
}

.events-timeline-track {
    position: absolute;
    right: 22px;
    /* Верхний отступ — переменная (см. .events-timeline): в табличном
       виде под ним шапка столбцов. Нижние 10px оставляют ручку, метки
       и подсказку внутри краёв списка. */
    top: var(--timeline-top, 10px);
    bottom: 10px;
    width: 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.22);
}

/* Ползунка нет: его роль играет пилюля «месяц год»
   (.events-timeline-bubble), она едет по шкале при прокрутке. */

/* Слой меток совпадает с треком, чтобы метки ходили по его координатам. */
.events-timeline-years {
    position: absolute;
    right: 0;
    left: 0;
    top: var(--timeline-top, 10px);
    bottom: 10px;
}

.events-timeline-year {
    position: absolute;
    right: 34px;
    transform: translateY(-50%);
    padding: 2px 7px;
    border: none;
    border-radius: 9px;
    /* Пилюля-фон: цифры не сливаются с текстом карточек под полосой. */
    background: rgba(13, 30, 51, 0.72);
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    color: #fff;
    cursor: pointer;
    white-space: nowrap;
}

.events-timeline-year:hover {
    background: rgba(13, 30, 51, 0.92);
}

.events-timeline-year.is-active {
    background: rgba(255, 255, 255, 0.92);
    color: #1a3a5f;
}

.events-timeline-bubble {
    position: absolute;
    /* Правый край подсказки — по правому краю events-list (он же правый
       край корня полосы), текст «Месяц ГГГГ» всегда в одну строку. */
    right: 0;
    top: 0;
    transform: translateY(-50%);
    padding: 4px 12px;
    border-radius: 20px;
    background: #fff;
    color: #1a3a5f;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.events-timeline.is-bubbling .events-timeline-bubble {
    opacity: 1;
}

@media (max-width: 768px) {
    /* Полоса показывается и на узких экранах: проявляется при прокрутке
       списка (наведения на тач-экране нет), лежит поверх карточек. */
    .events-timeline {
        width: 44px;
    }

    .events-timeline-track {
        right: 16px;
    }

    .events-timeline-year {
        right: 24px;
    }
}

/* ===== Вид списка событий: карточки / таблица =====
   Переключатель стоит в шапке фильтров (index.html), поэтому виден и при
   свёрнутой панели. В табличном виде та же информация укладывается в одну
   строку: высоту задаёт логотип, и на экран влезает в разы больше стартов.
   Разметку строки собирает createEventRow, данные и права — из общих с
   карточкой хелперов (createEventLogo, createEventActionParts).

   Колонки задаются одной переменной: строка и шапка таблицы обязаны
   совпадать, а на узких экранах набор колонок сокращается. Ячейки в
   разметке идут всегда и по порядку, поэтому скрытая колонка просто
   убирается из шаблона — строки не разъезжаются. */

.filter-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.events-view-switch {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 1px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.events-view-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border: none;
    border-radius: 16px;
    background: transparent;
    color: rgba(255, 255, 255, 0.85);
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.events-view-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.events-view-btn.is-active {
    background: rgba(79, 195, 247, 0.9);
    color: #0d2138;
    font-weight: 600;
}

.events-view-btn i {
    font-size: 0.75rem;
}

/* Набор колонок табличного вида: логотип, тип, название, место, даты,
   протоколы, действия.
   Последняя колонка — фиксированной ширины, а не max-content: каждая
   строка это отдельная сетка, поэтому max-content считался бы по своему
   содержимому, и разная длина имени автора (event-created-by) сдвигала бы
   колонку названия от строки к строке. Фиксированная ширина выравнивает
   столбцы по вертикали, как в настоящей таблице; длинное имя обрезается
   многоточием (полное — в title). */
.events-list.is-table {
    --events-table-columns: 30px 84px minmax(0, 1fr) 148px 152px 96px 140px;
}

/* Аноним: кнопок правки/удаления и автора нет вовсе, поэтому последняя
   колонка не нужна — иначе она держала бы 140px пустоты и отнимала их
   у названия. Ячейка убирается из потока (display: none), иначе она
   переехала бы на следующую строку сетки, а трек из шаблона уходит. */
.events-list.is-table.no-actions {
    --events-table-columns: 30px 84px minmax(0, 1fr) 148px 152px 96px;
}

.events-list.is-table.no-actions .event-row-actions,
.events-list.is-table.no-actions .events-table-head .events-table-col-actions {
    display: none;
}

.events-table-head {
    position: sticky;
    top: 0;
    z-index: 2;
    display: grid;
    grid-template-columns: var(--events-table-columns);
    align-items: center;
    column-gap: 10px;
    margin-bottom: 2px;
    padding: 5px 8px;
    /* Прозрачная рамка в 1px — как у строки (.event-card несёт свою):
       без неё содержимое шапки на 1px левее ячеек строк, и столбцы
       перестают читаться как один вертикальный столбец. */
    border: 1px solid transparent;
    border-radius: 6px;
    background: rgba(26, 58, 95, 0.96);
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: rgba(255, 255, 255, 0.75);
}

.events-table-head > span {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
}

.events-table-head i {
    font-size: 0.65rem;
    opacity: 0.8;
}

/* Колонки шапки с фильтром кликабельны: клик «добавляет» фильтр сверху
   и раскрывает его список. Логотип и колонка действий — обычные.
   Подчёркивание вместо фона: у ячейки фиксированная ширина трека, и
   padding сдвинул бы подпись относительно значений в строках. */
.events-table-head .is-clickable {
    cursor: pointer;
    transition: color 0.2s ease;
}

.events-table-head .is-clickable:hover,
.events-table-head .is-clickable:focus-visible {
    color: #fff;
    text-decoration: underline;
    outline: none;
}

.events-list.is-table .event-row {
    display: grid;
    grid-template-columns: var(--events-table-columns);
    align-items: center;
    column-gap: 10px;
    padding: 4px 8px;
    border-radius: 6px;
    margin-bottom: 2px;
}

/* В табличном виде карточка — строка: «подъём» при наведении здесь только
   дёргает соседей. */
.events-list.is-table .event-row:hover {
    transform: none;
    box-shadow: none;
}

.events-list.is-table .event-row-logo {
    width: 30px;
    height: 30px;
    border-radius: 4px;
}

.events-list.is-table .event-row-logo i {
    font-size: 0.8rem;
}

.events-list.is-table .event-row-badges {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    overflow: hidden;
}

.events-list.is-table .event-row-badges .event-type-badge {
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.65rem;
}

/* Год — тот же чип, что в карточке (зелёный/оранжевый по чётности),
   только мельче: строка высотой с логотип. Стоит в колонке дат, и год
   показывается здесь один раз — из самих дат он убран (formatDayMonth). */
.events-list.is-table .event-row-dates .year-badge {
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.65rem;
    flex-shrink: 0;
}

.events-list.is-table .event-row-name,
.events-list.is-table .event-row-cell {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.8rem;
    line-height: 1.3;
}

.events-list.is-table .event-row-name {
    font-weight: 600;
}

.events-list.is-table .event-row-cell {
    display: flex;
    align-items: center;
    gap: 5px;
    opacity: 0.9;
}

.events-list.is-table .event-row-cell > i {
    flex-shrink: 0;
    font-size: 0.7rem;
    opacity: 0.8;
}

.events-list.is-table .event-row-cell > span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.events-list.is-table .event-row-protocols .icon-circle {
    width: 18px;
    height: 18px;
    box-shadow: none;
}

.events-list.is-table .event-row-protocols .icon-circle i {
    font-size: 0.6rem;
}

.events-list.is-table .event-row-protocols .protocol-count {
    height: 18px;
    padding: 0 5px;
    gap: 3px;
    border-radius: 9px;
    font-size: 0.65rem;
    box-shadow: none;
}

.events-list.is-table .event-row-protocols .protocol-count i {
    font-size: 0.6rem;
}

.events-list.is-table .event-row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    min-width: 0;
    overflow: hidden;
}

.events-list.is-table .event-row-actions .event-edit-btn,
.events-list.is-table .event-row-actions .event-delete-btn,
.events-list.is-table .event-row-actions .event-lock {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    font-size: 0.65rem;
    flex-shrink: 0;
}

/* Имя автора ужимается первым: кнопки справа остаются целыми, длинное имя
   обрезается многоточием, а не растягивает колонку. */
.events-list.is-table .event-row-actions .event-created-by {
    margin-left: 0;
    font-size: 0.7rem;
    max-width: 110px;
    flex: 0 1 auto;
}

/* Узкие экраны: набор колонок сокращается, начиная с менее важных.
   Скрытая ячейка уходит из потока, поэтому шаблон пересчитывается под
   оставшиеся. */
@media (max-width: 820px) {
    .events-list.is-table {
        --events-table-columns: 30px minmax(0, 1fr) 136px 152px 88px 140px;
    }

    .events-list.is-table.no-actions {
        --events-table-columns: 30px minmax(0, 1fr) 136px 152px 88px;
    }

    .events-list.is-table .event-row-badges,
    .events-table-head .events-table-col-type {
        display: none;
    }
}

@media (max-width: 650px) {
    .events-list.is-table {
        --events-table-columns: 30px minmax(0, 1fr) 152px 84px 140px;
    }

    .events-list.is-table.no-actions {
        --events-table-columns: 30px minmax(0, 1fr) 152px 84px;
    }

    .events-list.is-table .event-row-location,
    .events-table-head .events-table-col-location {
        display: none;
    }

    /* Шапка остаётся и на телефоне: подписи столбцов нужны, чтобы строка
       читалась как таблица. Экономим высоту мелкими шрифтом и отступами,
       а не скрытием. Иконки в шапке на узком экране убираются — они же
       стоят у значений в строках. */
    .events-table-head {
        padding: 3px 8px;
        font-size: 0.62rem;
        letter-spacing: 0.02em;
    }

    .events-table-head i {
        display: none;
    }
}

@media (max-width: 520px) {
    .events-list.is-table {
        --events-table-columns: 28px minmax(0, 1fr) 84px 120px;
    }

    .events-list.is-table.no-actions {
        --events-table-columns: 28px minmax(0, 1fr) 84px;
    }

    .events-list.is-table .event-row-protocols,
    .events-table-head .events-table-col-protocols {
        display: none;
    }

    /* В датах остаётся только дата начала: «[2024] 12.10 - 20.10»
       в строку не влезает. */
    .events-list.is-table .event-date-to {
        display: none;
    }

    /* Иконка календаря уступает место чипу года: без неё «[2024] 12.10»
       укладывается в 84px колонки дат. */
    .events-list.is-table .event-row-dates > i {
        display: none;
    }

    /* Колонка дат не режется: значение выводится целиком, а уступает
       названию, у которого есть подсказка с полным текстом. */
    .events-list.is-table .event-row-dates > span {
        flex-shrink: 0;
        overflow: visible;
    }

    .events-list.is-table .event-row,
    .events-list.is-table .events-table-head {
        column-gap: 8px;
    }

    .events-list.is-table .event-row-logo {
        width: 28px;
        height: 28px;
    }
}

@media (max-width: 600px) {
    /* В шапке фильтров остаются только иконки: подписи не помещаются. */
    .events-view-btn span {
        display: none;
    }

    .events-view-btn {
        padding: 4px 9px;
    }
}