/* ============================================================
   БАЗОВЫЕ СТИЛИ
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; font-family: system-ui, sans-serif; }
body { background: #f8fafc; color: #1e293b; line-height: 1.5; }
.container { max-width: 1200px; margin: 0 auto; padding: 16px; }
.card { background: #fff; border-radius: 8px; padding: 20px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* ============================================================
   ФОРМЫ
   ============================================================ */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 14px; }
.form-control {
    width: 100%; padding: 10px; border: 1px solid #e2e8f0;
    border-radius: 6px; font-size: 15px;
}
.form-control:focus {
    outline: none; border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.form-control-sm { padding: 4px 8px !important; font-size: 12px !important; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 200px; }

/* ============================================================
   КНОПКИ
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 16px; background: #2563eb; color: #fff;
    border: none; border-radius: 6px; font-size: 14px; cursor: pointer;
}
.btn:hover { background: #1d4ed8; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-outline { background: transparent; border: 1px solid #e2e8f0; color: #1e293b; }
.btn-danger { background: #dc2626; }

/* ============================================================
   ТАБЛИЦЫ
   ============================================================ */
.table-wrap { overflow-x: auto; width: 100%; }
table { width: 100%; border-collapse: collapse; min-width: 500px; }
th, td { padding: 10px; text-align: left; border-bottom: 1px solid #e2e8f0; font-size: 14px; }
th { background: #f8fafc; font-weight: 600; }

/* ============================================================
   НАВИГАЦИЯ (основная + выпадающие подменю)
   ============================================================ */
.nav { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.nav-btn {
    padding: 8px 16px; background: #fff; border: 1px solid #e2e8f0;
    border-radius: 6px; font-size: 14px; cursor: pointer;
}
.nav-btn.active { background: #2563eb; color: #fff; border-color: #2563eb; }

.main-nav {
    display: flex; gap: 8px; margin-bottom: 20px;
    flex-wrap: wrap; position: relative; z-index: 100;
}
.main-nav .nav-btn {
    padding: 8px 16px; background: #fff; border: 1px solid #e2e8f0;
    border-radius: 6px; font-size: 14px; cursor: pointer; transition: all 0.15s;
}
.main-nav .nav-btn:hover { background: #f1f5f9; border-color: #cbd5e1; }
.main-nav .nav-btn.active { background: #2563eb; color: #fff; border-color: #2563eb; }

.nav-group { position: relative; }
.nav-group-toggle { display: flex; align-items: center; gap: 6px; }
.nav-arrow { font-size: 10px; transition: transform 0.2s; }
.nav-group.open .nav-arrow { transform: rotate(180deg); }

.nav-dropdown {
    display: none; position: absolute; top: 100%; left: 0;
    margin-top: 4px; background: #fff; border: 1px solid #e2e8f0;
    border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    padding: 8px; min-width: 200px; z-index: 1000; flex-wrap: wrap; gap: 4px;
}
.nav-group.open .nav-dropdown { display: flex; }


/* ============================================================
   УТИЛИТЫ
   ============================================================ */
.hidden { display: none !important; }

.alert { padding: 10px; border-radius: 6px; margin-bottom: 12px; font-size: 14px; display: none; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; display: block; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; display: block; }

.badge {
    display: inline-block; padding: 4px 10px; border-radius: 12px;
    font-size: 12px; font-weight: 500;
}
.badge-primary { background: #dbeafe; color: #1e40af; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }

/* ============================================================
   ШАПКА
   ============================================================ */
.header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid #e2e8f0;
}

/* ============================================================
   МОДАЛКИ (объединено из 3 определений)
   ============================================================ */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 2000;
    display: flex; align-items: center; justify-content: center;
}
.modal.hidden { display: none; }
.modal-content {
    background: #fff; padding: 24px; border-radius: 8px;
    width: 90%; max-width: 600px; max-height: 90vh; overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}
.modal-header {
    display: flex; justify-content: space-between;
    margin-bottom: 20px; border-bottom: 1px solid #eee; padding-bottom: 10px;
}
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: #666; }

/* ============================================================
   УЧАСТНИКИ (groups.js, coaches.js)
   ============================================================ */
.participant-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px; border-bottom: 1px solid #f1f5f0; gap: 8px;
}
.participant-info { flex: 1; }
.participant-actions { display: flex; gap: 4px; }

.add-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; background: #f1f5f9; border: 1px solid #cbd5e1;
    border-radius: 6px; font-size: 13px; cursor: pointer; margin-bottom: 12px;
}
.add-btn:hover { background: #e2e8f0; }

.select-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px; border-bottom: 1px solid #f1f5f0; cursor: pointer;
}
.select-item:hover { background: #f8fafc; }

.participants-table {
    width: 100%; border-collapse: collapse; margin-bottom: 12px; font-size: 14px;
}
.participants-table th, .participants-table td {
    padding: 8px 10px; border: 1px solid #cbd5e1; text-align: left; vertical-align: middle;
}
.participants-table th { background-color: #f8fafc; font-weight: 600; }

.avatar-oval {
    width: 80px; height: 80px; border-radius: 50%;
    object-fit: cover; border: 3px solid #2563eb; display: block;
}
.avatar-placeholder {
    width: 80px; height: 80px; border-radius: 50%;
    background: #f1f5f9; display: flex; align-items: center; justify-content: center;
    font-size: 32px; color: #94a3b8; border: 3px solid #2563eb;
}
.group-header {
    display: flex; align-items: center; gap: 16px;
    margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid #e2e8f0;
}

/* ============================================================
   ПРОФИЛЬ СПОРТСМЕНА (athletes.js)
   ============================================================ */
.athlete-photo {
    width: 100px; height: 100px; border-radius: 50%;
    object-fit: cover; border: 3px solid #2563eb; cursor: pointer;
}
.athlete-photo-placeholder {
    width: 100px; height: 100px; border-radius: 50%;
    background: #f1f5f9; display: flex; align-items: center; justify-content: center;
    font-size: 40px; color: #94a3b8; border: 3px solid #2563eb; cursor: pointer;
}

.athlete-status-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 12px; border-radius: 16px; font-size: 12px;
    font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.athlete-status-draft { background: #f1f5f9; color: #64748b; border: 1px solid #cbd5e1; }
.athlete-status-pending { background: #fef3c7; color: #92400e; border: 1px solid #fbbf24; }
.athlete-status-active { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.athlete-status-archived { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

.athlete-meta-info {
    display: flex; flex-wrap: wrap; gap: 16px; padding: 10px 14px;
    background: #f8fafc; border-radius: 8px; border: 1px solid #e2e8f0;
    font-size: 13px; color: #64748b; margin-top: 12px;
}
.athlete-meta-info strong { color: #334155; font-weight: 600; }

.athlete-rejection-block {
    padding: 12px 16px; background: #fef2f2; border: 1px solid #fecaca;
    border-radius: 8px; margin-top: 12px; color: #991b1b; font-size: 13px;
}
.athlete-rejection-block strong { display: block; margin-bottom: 4px; font-size: 14px; }

.athlete-deletion-request-block {
    padding: 12px 16px; background: #fffbeb; border: 1px solid #fde68a;
    border-radius: 8px; margin-top: 12px; color: #92400e; font-size: 13px;
}

.visibility-toggle {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 12px; background: #f1f5f9; border: 1px solid #e2e8f0;
    border-radius: 6px; font-size: 13px; cursor: pointer; transition: all 0.2s;
}
.visibility-toggle:hover { background: #e2e8f0; }
.visibility-toggle.active { background: #dcfce7; border-color: #86efac; color: #166534; }
.visibility-toggle.inactive { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }

.athlete-action-buttons {
    display: flex; flex-wrap: wrap; gap: 8px;
    margin-top: 16px; padding-top: 16px; border-top: 1px solid #e2e8f0;
}
.athlete-action-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: 6px; font-size: 13px; font-weight: 500;
    cursor: pointer; border: 1px solid #e2e8f0; background: #fff; color: #334155;
    transition: all 0.15s;
}
.athlete-action-btn:hover { background: #f1f5f9; border-color: #cbd5e1; }
.athlete-action-btn.primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.athlete-action-btn.primary:hover { background: #1d4ed8; }
.athlete-action-btn.success { background: #16a34a; color: #fff; border-color: #16a34a; }
.athlete-action-btn.success:hover { background: #15803d; }
.athlete-action-btn.danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.athlete-action-btn.danger:hover { background: #b91c1c; }
.athlete-action-btn.warning { background: #f59e0b; color: #fff; border-color: #f59e0b; }
.athlete-action-btn.warning:hover { background: #d97706; }
.athlete-action-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Вкладки профиля спортсмена */
.athlete-tabs {
    display: flex; gap: 4px; margin: 20px 0 16px;
    border-bottom: 2px solid #e2e8f0;
}
.athlete-tab {
    padding: 10px 20px; border: none; background: transparent;
    color: #64748b; font-size: 14px; font-weight: 500; cursor: pointer;
    border-bottom: 2px solid transparent; margin-bottom: -2px;
    transition: all 0.2s ease; border-radius: 6px 6px 0 0;
}
.athlete-tab:hover { color: #334155; background: #f8fafc; }
.athlete-tab.active {
    color: #2563eb; font-weight: 600;
    border-bottom-color: #2563eb; background: transparent;
}
.athlete-tab-content { display: none; }
.athlete-tab-content.active { display: block; }

/* Кнопки групп в результатах */
.athlete-group-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.athlete-group-tab {
    padding: 6px 14px; border-radius: 6px; border: 1px solid #cbd5e1;
    font-size: 13px; cursor: pointer; transition: all 0.15s ease;
    background: #f1f5f9; color: #334155;
}
.athlete-group-tab:hover { background: #e2e8f0; }
.athlete-group-tab.active { background: #2563eb; color: #fff; border-color: #2563eb; }

/* Таблица результатов спортсмена */
.athlete-results-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.athlete-results-table thead { background: #f1f5f9; }
.athlete-results-table th {
    padding: 8px; text-align: center; border-bottom: 2px solid #cbd5e1;
    font-weight: 600; color: #334155;
}
.athlete-results-table th:first-child { text-align: left; }
.athlete-results-table td {
    padding: 8px; text-align: center; border-bottom: 1px solid #f1f5f9;
}
.athlete-results-table td:first-child { text-align: left; font-weight: 500; }
.athlete-results-table tbody tr:hover { background: #f8fafc; }

.groups-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.groups-table th, .groups-table td {
    padding: 8px; border: 1px solid #cbd5e1; text-align: left; font-size: 13px;
}
.groups-table th { background: #f8fafc; }

/* ============================================================
   ФИЛЬТРЫ СОБЫТИЙ
   ============================================================ */
.events-filters {
    background: #fff; border: 1px solid #e2e8f0;
    border-radius: 8px; margin-bottom: 16px; overflow: hidden;
}
.events-filters-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px; background: #f8fafc; cursor: pointer;
    font-weight: 600; font-size: 14px; color: #1e293b; user-select: none;
}
.events-filters-header:hover { background: #f1f5f9; }
.events-filters-arrow { transition: transform 0.2s; font-size: 12px; color: #64748b; }
.events-filters-content { padding: 16px; border-top: 1px solid #e2e8f0; }
.events-filters-row { display: flex; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.events-filter-group { flex: 1; min-width: 200px; }
.events-filter-group label {
    display: block; font-size: 12px; font-weight: 500;
    color: #64748b; margin-bottom: 4px;
}
.events-date-presets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.events-preset-btn {
    padding: 6px 12px; background: #f1f5f9; border: 1px solid #cbd5e1;
    border-radius: 6px; font-size: 12px; cursor: pointer; color: #334155;
}
.events-preset-btn:hover { background: #e2e8f0; }
.events-preset-btn-active {
    background: #2563eb !important; color: #fff !important; border-color: #2563eb !important;
}
.events-filters-actions {
    display: flex; justify-content: space-between; align-items: center;
    padding-top: 12px; border-top: 1px solid #f1f5f9;
}
.events-filters-count { font-size: 12px; color: #64748b; }

/* ============================================================
   КОНТРОЛЬНЫЕ СРЕЗЫ
   ============================================================ */
.cut-tab-btn {
    padding: 8px 16px; background: transparent; border: none;
    border-bottom: 2px solid transparent; cursor: pointer;
    color: #64748b; font-weight: 500; transition: all 0.2s;
}
.cut-tab-btn:hover { color: #3b82f6; }
.cut-tab-btn.active { color: #3b82f6; border-bottom: 2px solid #3b82f6; }

.selected-item-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px; border-bottom: 1px solid #f1f5f9;
}
.selected-item-row:hover { background: #f8fafc; }
.remove-item-btn {
    background: none; border: none; color: #ef4444;
    cursor: pointer; font-size: 16px;
}

/* ============================================================
   ФИЛЬТР ТЕГОВ
   ============================================================ */
#tagFilterDropdown {
    border: 1px solid #e2e8f0; border-radius: 8px;
    background: #ffffff; box-shadow: 0 4px 12px rgba(0,0,0,0.1); overflow: hidden;
}
#tagFilterDropdown div {
    padding: 8px 12px; font-size: 13px; color: #334155;
    cursor: pointer; transition: background 0.15s;
}
#tagFilterDropdown div:hover { background: #f1f5f9; }

#selectedTagsDisplay span {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 16px; font-size: 12px; font-weight: 500;
    background: #f8fafc; border: 1px solid #e2e8f0; transition: all 0.2s;
}
#selectedTagsDisplay span:hover { border-color: #cbd5e1; background: #f1f5f9; }
#selectedTagsDisplay span button {
    width: 16px; height: 16px; display: flex; align-items: center; justify-content: center;
    border-radius: 50%; background: #e2e8f0; color: #64748b;
    font-size: 10px; transition: all 0.15s;
}
#selectedTagsDisplay span button:hover { background: #dc2626; color: white; }

/* ============================================================
   ДАШБОРД РЕЗУЛЬТАТОВ
   ============================================================ */
#dashboardResultsView .form-group label {
    font-size: 13px; font-weight: 500; color: #334155;
    margin-bottom: 4px; display: block;
}
#dashboardResultsView select[multiple] { font-size: 13px; padding: 4px; }
#dashboardResultsView select[multiple] option { padding: 4px 8px; border-radius: 4px; }
#dashboardResultsView select[multiple] option:checked { background: #2563eb; color: white; }
#dashboardResultsView .table th { cursor: pointer; user-select: none; background: #f8fafc; }
#dashboardResultsView .table th:hover { background: #e2e8f0; }
#dashboardResultsView #selectedTests { display: flex; flex-wrap: wrap; gap: 6px; }
#dashboardResultsView .test-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px; border-radius: 16px; font-size: 12px; font-weight: 500;
    background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe;
}
#dashboardResultsView .test-chip .remove {
    background: none; border: none; color: #ef4444;
    cursor: pointer; font-size: 14px; padding: 0; margin-left: 4px;
}
#filtersContent { transition: all 0.2s ease; }
#filtersContent.hidden { display: none; }

#dashboardResultsView {
    max-height: 100vh; overflow-y: auto; padding-bottom: 20px;
}
#dashboardResultsView .chart-container {
    height: 400px; position: relative; margin-top: 16px;
}
#dashboardChart { max-height: 100%; width: 100%; }

/* ============================================================
   ПЕРСОНАЛЬНЫЙ ДАШБОРД
   ============================================================ */
#personalDashboardView { max-width: 1200px; margin: 0 auto; padding: 16px; }

.pd-preset-btn.active {
    background: #3b82f6 !important; color: #fff !important;
    border-color: #3b82f6 !important; font-weight: 600;
}
.pd-view-btn.active {
    background: #fff !important; color: #0f172a !important;
    font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.pd-view-btn:not(.active) {
    background: transparent !important; color: #64748b !important; box-shadow: none !important;
}
.pd-layout-btn.active {
    background: #fff !important; color: #0f172a !important;
    font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.pd-layout-btn:not(.active) {
    background: transparent !important; color: #64748b !important; box-shadow: none !important;
}

.pd-charts-grid { display: grid; gap: 16px; width: 100%; }
.pd-charts-grid.cols-1 { grid-template-columns: 1fr; }
.pd-charts-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

.pd-chart-card {
    background: #fff; border: 1px solid #e2e8f0;
    border-radius: 8px; padding: 12px; box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.pd-chart-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 8px; border-bottom: 1px solid #f1f5f9; padding-bottom: 8px;
}
.pd-chart-title { font-weight: 600; color: #0f172a; font-size: 15px; }
.pd-chart-meta { font-size: 12px; color: #64748b; }
.pd-chart-container { width: 100%; aspect-ratio: 1.5; position: relative; }

.pd-trend-indicator {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600;
}
.pd-trend-improving { background: #dcfce7; color: #166534; }
.pd-trend-declining { background: #fee2e2; color: #991b1b; }
.pd-trend-stable { background: #f1f5f9; color: #64748b; }

.pd-day-group {
    margin-bottom: 16px; border: 1px solid #e2e8f0;
    border-radius: 8px; overflow: hidden;
}
.pd-day-header {
    background: #f8fafc; padding: 10px 14px; font-weight: 600;
    color: #0f172a; border-bottom: 1px solid #e2e8f0;
    display: flex; justify-content: space-between; align-items: center;
}
.pd-day-date { font-size: 14px; }
.pd-day-count { font-size: 12px; color: #64748b; font-weight: 500; }

.pd-results-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.pd-results-table th {
    background: #f1f5f9; padding: 8px 12px; text-align: left;
    font-weight: 600; color: #334155; border-bottom: 1px solid #cbd5e1;
}
.pd-results-table td { padding: 8px 12px; border-bottom: 1px solid #f1f5f9; }
.pd-results-table tr:last-child td { border-bottom: none; }
.pd-results-table tr:hover { background: #f8fafc; }
.pd-result-value { font-weight: 600; color: #0f172a; }

/* ============================================================
   ШАБЛОНЫ ТЕСТИРОВАНИЯ
   ============================================================ */
.tpl-tab {
    padding: 8px 16px; cursor: pointer; border: none;
    background: transparent; font-weight: 500; color: #64748b;
    border-bottom: 2px solid transparent;
}
.tpl-tab.active { color: #2563eb; border-bottom-color: #2563eb; }
.tpl-tab-content { min-height: 200px; }

/* ============================================================
   ТУЛБАР БАЗЫ ЗНАНИЙ
   ============================================================ */
.kb-toolbar {
    display: flex; gap: 4px; padding: 8px; background: #f8fafc;
    border: 1px solid #e2e8f0; border-bottom: none;
    border-radius: 6px 6px 0 0; flex-wrap: wrap;
}
.kb-toolbar button {
    padding: 6px 10px; background: #fff; border: 1px solid #cbd5e1;
    border-radius: 4px; cursor: pointer; font-size: 13px; transition: all 0.15s;
}
.kb-toolbar button:hover { background: #e2e8f0; border-color: #94a3b8; }
.kb-toolbar button:active { background: #cbd5e1; }
#editArticleContent {
    border-radius: 0 0 6px 6px; font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px; line-height: 1.6;
}

/* ============================================================
   ТАБЛИЦА (исправление ширины)
   ============================================================ */
#tableView .card { width: 100%; max-width: 100%; }
#tableView .card > div:first-child { width: 100%; }
#mainTable { width: 100% !important; min-width: 100%; }

.view-section {
    max-width: 1200px; margin: 0 auto; padding: 16px;
}

/* ============================================================
   МОБИЛЬНАЯ АДАПТАЦИЯ (ОБЪЕДИНЕНО из 8 блоков)
   ============================================================ */

/* Планшеты */
@media (max-width: 1024px) {
    .container { padding: 12px; }
    .main-nav { gap: 6px; }
    .main-nav .nav-btn { padding: 8px 12px; font-size: 13px; }
    table { font-size: 13px; }
    th, td { padding: 8px; }
    #dashboardResultsView, .view-section { max-width: 100%; padding: 12px; }
    #personalDashboardView { max-width: 100%; padding: 12px; }
}

/* Мобильные */
@media (max-width: 768px) {
    /* Базовые отступы */
    .container { padding: 8px; max-width: 100%; }
    .card { padding: 12px; margin-bottom: 12px; }

    /* Навигация — вертикальная */
    .main-nav { flex-direction: column; gap: 4px; margin-bottom: 12px; }
    .main-nav .nav-btn {
        width: 100%; text-align: left; padding: 12px 16px;
        font-size: 15px; min-height: 48px;
    }
    .nav-dropdown {
        position: static; width: 100%; margin-top: 0;
        border-radius: 0; border-left: none; border-right: none;
        box-shadow: none; padding: 4px;
    }


    /* Шапка */
    .header { flex-direction: column; gap: 8px; align-items: flex-start; }
    .header h3 { font-size: 18px; }
    #headerUserInfo {
        width: 100%; justify-content: space-between;
        flex-wrap: wrap; font-size: 12px;
    }

    /* Таблицы */
    .table-wrap {
        overflow-x: auto; -webkit-overflow-scrolling: touch;
        border-radius: 8px; border: 1px solid #e2e8f0;
    }
    table { min-width: 600px; font-size: 12px; }
    th, td { padding: 6px 8px; white-space: nowrap; }
    .btn-sm { padding: 4px 8px; font-size: 11px; }

    /* Модалки */
    .modal-content { width: 95%; max-width: 100%; padding: 16px; max-height: 95vh; }
    .modal-header { margin-bottom: 12px; padding-bottom: 8px; }

    /* Формы */
    .form-row { flex-direction: column; gap: 8px; }
    .form-row .form-group { min-width: 100%; }
    .form-control { font-size: 16px; padding: 10px 12px; }

    /* Кнопки */
    .btn { padding: 10px 16px; font-size: 14px; min-height: 44px; }
    .btn-sm { padding: 8px 12px; font-size: 13px; min-height: 40px; }

    /* Дашборд результатов */
    #dashboardResultsView { padding: 8px; }
    #dashboardResultsView .chart-container { height: 250px; }

    /* Персональный дашборд */
    #personalDashboardView { padding: 8px; }
    .pd-charts-grid.cols-2 { grid-template-columns: 1fr; }
    .pd-chart-container { aspect-ratio: 1.2; }
    #dashboardResultsView select[multiple] { min-height: 60px; }

    /* Профиль спортсмена */
    .athlete-photo, .athlete-photo-placeholder { width: 80px; height: 80px; }
    .athlete-tabs { flex-wrap: wrap; }
    .athlete-tab { padding: 8px 14px; font-size: 13px; }
    .athlete-action-buttons { flex-direction: column; }
    .athlete-action-btn { width: 100%; justify-content: center; }

    /* Профиль тренера */
    #coachProfileModal .modal-content { padding: 12px; }
    .group-header { flex-direction: column; align-items: center; text-align: center; }

    /* Группы */
    #groupModal .modal-content { padding: 12px; }
    .participants-table { font-size: 12px; }
    .participants-table th, .participants-table td { padding: 6px; }

    /* Контрольные срезы */
    #controlCutModal .modal-content { width: 98%; height: 95vh; }
    #controlCutModal .cut-tab-btn { padding: 6px 10px; font-size: 12px; }
    .cut-tab-content { padding: 12px; }

    /* Рабочее место */
    #view-workspace { padding: 8px; }
    #wsViewSwitcher { flex-direction: column; gap: 8px; }
    #wsSwitchEventsBtn, #wsSwitchMetricsBtn { width: 100%; }
    #wsVizControls { flex-wrap: wrap; }

    /* Шаблоны */
    #templateModal .modal-content { width: 98%; padding: 12px; }
    .tpl-tab { padding: 6px 10px; font-size: 12px; }
    .tpl-tab-content { padding: 12px; }

    /* База знаний */
    #knowledgeModal > div { width: 98%; max-height: 95vh; }
    #knowledgeEditModal > div { padding: 12px; }
    .kb-toolbar { flex-wrap: wrap; gap: 2px; }
    .kb-toolbar button { padding: 4px 8px; font-size: 12px; }

    /* Уведомления и история */
    #notificationsPanel { min-width: 280px; max-width: 320px; }
    #navHistoryDropdown { min-width: 200px; max-width: 280px; }

    /* Фильтры событий */
    .events-filter-group { min-width: 100%; }
    .events-filters-row { flex-direction: column; gap: 8px; }
    .events-date-presets { flex-wrap: wrap; }
    .events-preset-btn { flex: 1; min-width: 80px; text-align: center; }

    /* Таблица */
    #tableView .card { padding: 12px; }
    #tableTitle { font-size: 16px; }
    #athleteValidationFilterBlock select { min-width: 120px; font-size: 12px; }
}

/* Маленькие мобильные */
@media (max-width: 480px) {
    .container { padding: 6px; }
    .main-nav .nav-btn { padding: 10px 14px; font-size: 14px; }
    table { font-size: 11px; }
    th, td { padding: 4px 6px; }
    .header h3 { font-size: 16px; }
    .modal-content { padding: 12px; }
    .form-control { font-size: 15px; padding: 8px 10px; }
    #dashboardResultsView .chart-container { height: 200px; }
    .btn { padding: 8px 14px; font-size: 13px; }
    .btn-sm { padding: 6px 10px; font-size: 12px; }
}

/* Очень маленькие экраны */
@media (max-width: 360px) {
    .container { padding: 4px; }
    .main-nav .nav-btn { padding: 8px 12px; font-size: 13px; }
    table { font-size: 10px; }
    th, td { padding: 3px 5px; }
}

/* ============================================================
   ПЕЧАТЬ
   ============================================================ */
@media print {
    .main-nav, .header, .btn, .modal,
    #filtersContent, #eventsFiltersBlock,
    .fast-menu, .nav, #pdLayoutToggle,
    button[onclick="exportPersonalDashboardCSV()"],
    button[onclick="printPersonalDashboard()"],
    button[onclick="refreshPersonalDashboard()"],
    button[onclick="applyPdFilters()"] {
        display: none !important;
    }
    .container { max-width: 100%; padding: 0; }
    .card { box-shadow: none; border: 1px solid #e2e8f0; }
    .pd-chart-card { break-inside: avoid; page-break-inside: avoid; }
    table { font-size: 10pt; }
    th, td { padding: 4pt 6pt; }
}

/* ============================================================
   🔧 ИСПРАВЛЕНИЯ МОБИЛЬНОГО МЕНЮ (после обновления)
   ============================================================ */
@media (max-width: 768px) {
  /* Центрирование текста в кнопках главного меню */
  .main-nav .nav-btn {
    text-align: center !important;
    justify-content: center !important;
    font-size: 15px !important;
    padding: 12px 16px !important;
    min-height: 48px;
  }
  
  /* Центрирование кнопок-переключателей групп (Справочники, Работа) */
  .nav-group-toggle {
    justify-content: center !important;
  }
  

  
  /* Исправление dropdown истории — не вылезает за левый край */
    #navHistoryDropdown {
        position: absolute;
        z-index: 10000;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        max-height: 400px;
        overflow-y: auto;
        min-width: 280px;
        max-width: 90vw; /* Не шире экрана */
    }
  
  /* Исправление dropdown уведомлений */
  #notificationsPanel {
    right: 8px !important;
    left: auto !important;
    max-width: 320px !important;
    min-width: 260px !important;
  }
}

/* ============================================================
   🔹 ВЫПАДАЮЩЕЕ МЕНЮ: КНОПКИ (ДЕСКТОП + МОБИЛЬНЫЕ)
   ============================================================ */

/* --- ДЕСКТОП: вертикальный список, одинаковая ширина --- */
.nav-dropdown {
    flex-direction: column !important;   /* ← ключевое: кнопки в столбик */
    flex-wrap: nowrap !important;        /* ← запрет переноса */
    min-width: 260px !important;         /* ← фиксированная ширина контейнера */
    padding: 6px !important;
}

.nav-dropdown .nav-btn {
    width: 100% !important;              /* ← все кнопки одной ширины */
    min-width: 100% !important;
    text-align: left !important;         /* ← выравнивание по левому краю */
    justify-content: flex-start !important;
    padding: 10px 14px !important;
    font-size: 14px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    border-radius: 6px !important;
    margin-bottom: 2px !important;
    border-bottom: none !important;      /* ← убираем разделитель на десктопе */
}

.nav-dropdown .nav-btn:hover {
    background: #eff6ff !important;
    color: #2563eb !important;
}

.nav-dropdown .nav-btn.active {
    background: #2563eb !important;
    color: #fff !important;
}

/* --- МОБИЛЬНЫЕ (до 768px): центрирование + увеличенные кнопки --- */
@media (max-width: 768px) {
    .nav-dropdown {
        min-width: auto !important;
        padding: 4px !important;
    }
    
    .nav-dropdown .nav-btn {
        text-align: center !important;
        justify-content: center !important;
        font-size: 14px !important;
        padding: 12px 16px !important;
        border-bottom: 1px solid #f1f5f9 !important;
        border-radius: 0 !important;
        margin-bottom: 0 !important;
    }
    
    .nav-dropdown .nav-btn:last-child {
        border-bottom: none !important;
    }
}