/* INLINE STYLES ДЛЯ ЛИДЕРБОРДА - ВРЕМЕННО ДЛЯ ТЕСТА */

/* Базовые стили страницы */
body {
    margin: 0;
    padding: 0;
    background: #f5f7fa;
    color: #333;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    /* Безопасная зона для мобильных устройств с "челкой" */
    padding-top: env(safe-area-inset-top);
    line-height: 1.6;
}

/* Улучшенная типографика для больших экранов */
@media (min-width: 1200px) {
    body {
        font-size: 16px;
    }
}

/* Общие стили для заголовков */
h1 {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 24px 0;
    color: #333;
    line-height: 1.3;
}

@media (min-width: 1200px) {
    h1 {
        font-size: 32px;
        margin-bottom: 30px;
    }
}

.profile-card {
    max-width: 1200px;
    margin: 24px auto;
    padding: 0 24px;
}

/* Улучшенные отступы для больших экранов */
@media (min-width: 1400px) {
    .profile-card {
        max-width: 1400px;
        padding: 0 32px;
    }
}

/* Дополнительный отступ сверху для мобильных устройств */
@media (max-width: 768px) {
    body {
        padding-top: max(env(safe-area-inset-top), 24px);
    }
    
    .profile-card,
    .container {
        margin-top: max(env(safe-area-inset-top), 16px);
        padding-top: 8px;
    }
    
    .card {
        margin-top: max(env(safe-area-inset-top), 24px);
    }
}

/* Базовая структура */
.leader-item {
    margin-bottom: 0;
}

/* DESKTOP VERSION */
.desktop-row {
    display: flex;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid #e9eef5;
    gap: 20px;
    transition: background 0.18s;
    background: #fff;
}

/* Улучшенная верстка для больших экранов */
@media (min-width: 1400px) {
    .desktop-row {
        padding: 18px 32px;
        gap: 24px;
    }
}

.desktop-row:hover {
    background: #f8f9fa;
}

.desktop-row .rank-cell {
    flex-shrink: 0;
    width: 90px;
    text-align: center;
    font-weight: bold;
    font-size: 22px;
}

@media (min-width: 1400px) {
    .desktop-row .rank-cell {
        width: 100px;
        font-size: 24px;
    }
}

.desktop-row .user-cell {
    flex: 1;
    min-width: 0;
}

.desktop-row .user-name {
    font-weight: 600;
    font-size: 16px;
    color: #333;
}

@media (min-width: 1400px) {
    .desktop-row .user-name {
        font-size: 18px;
    }
}

.desktop-row .user-stats {
    font-size: 13px;
    color: #666;
    margin-top: 4px;
}

.desktop-row .correct-count {
    flex-shrink: 0;
    width: 180px;
    font-weight: 600;
    font-size: 17px;
    text-align: center;
}

@media (min-width: 1400px) {
    .desktop-row .correct-count {
        width: 200px;
        font-size: 18px;
    }
}

.desktop-row .accuracy {
    flex-shrink: 0;
    width: 100px;
    font-weight: 700;
    font-size: 20px;
    text-align: center;
}

@media (min-width: 1400px) {
    .desktop-row .accuracy {
        width: 120px;
        font-size: 22px;
    }
}

/* MOBILE VERSION */
.mobile-card {
    display: flex;
    align-items: center;
    background: #fff;
    border: 2px solid #e9eef5;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: all 0.2s;
}

.mobile-card:active {
    transform: scale(0.98);
}

.leader-item.top-3 .mobile-card {
    border-width: 3px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    background: linear-gradient(135deg, #fff 0%, #f8f9ff 100%);
}

.mobile-card .card-rank {
    flex-shrink: 0;
    width: 56px;
    text-align: center;
}

.mobile-card .card-medal {
    font-size: 28px;
    display: block;
    margin-bottom: 2px;
    line-height: 1;
}

.mobile-card .card-number {
    font-weight: 700;
    font-size: 16px;
    line-height: 1;
}

.mobile-card .card-info {
    flex: 1;
    min-width: 0;
}

.mobile-card .card-name {
    font-weight: 600;
    font-size: 15px;
    color: #333;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-card .card-stats {
    display: flex;
    gap: 12px;
    font-size: 12px;
    flex-wrap: wrap;
}

.mobile-card .card-stat {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.mobile-card .card-stat-value {
    font-weight: 700;
    font-size: 15px;
    color: #333;
    line-height: 1.2;
}

.mobile-card .card-stat-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #999;
    line-height: 1;
}

.mobile-card .card-accuracy {
    flex-shrink: 0;
    min-width: 56px;
    text-align: right;
}

.mobile-card .card-accuracy-value {
    font-weight: 700;
    font-size: 22px;
    line-height: 1;
}

/* Цвета */
.rank-1 .rank-cell { color: #FFD700; }
.rank-2 .rank-cell { color: #C0C0C0; }
.rank-3 .rank-cell { color: #CD7F32; }

.rank-1 .mobile-card .card-number { color: #FFD700; }
.rank-2 .mobile-card .card-number { color: #C0C0C0; }
.rank-3 .mobile-card .card-number { color: #CD7F32; }

.accuracy.good,
.card-accuracy-value.good { color: #28a745; }

.accuracy.warn,
.card-accuracy-value.warn { color: #ffc107; }

.accuracy.bad,
.card-accuracy-value.bad { color: #dc3545; }

/* Responsive */
.desktop-row { display: flex; }
.mobile-card { display: none; }

@media (max-width: 768px) {
    .desktop-row { display: none !important; }
    .mobile-card { display: flex !important; }
}

/* Forced modes */
.leaderboard.mobile-mode .desktop-row { display: none !important; }
.leaderboard.mobile-mode .mobile-card { display: flex !important; }
.leaderboard.desktop-mode .desktop-row { display: flex !important; }
.leaderboard.desktop-mode .mobile-card { display: none !important; }

/* Улучшенная верстка для средних экранов (планшеты в альбомной ориентации) */
@media (max-width: 1200px) and (min-width: 769px) {
    .desktop-row {
        padding: 12px 16px;
        gap: 12px;
    }

    .desktop-row .rank-cell {
        width: 70px;
        font-size: 18px;
    }

    .desktop-row .correct-count {
        width: 140px;
        font-size: 15px;
    }

    .desktop-row .accuracy {
        width: 70px;
        font-size: 16px;
    }
}

@media (max-width: 400px) {
    .mobile-card {
        padding: 12px;
        gap: 10px;
    }
    .mobile-card .card-rank {
        width: 48px;
    }
    .mobile-card .card-medal {
        font-size: 24px;
    }
    .mobile-card .card-number {
        font-size: 14px;
    }
    .mobile-card .card-name {
        font-size: 14px;
    }
    .mobile-card .card-stat-value {
        font-size: 14px;
    }
    .mobile-card .card-accuracy-value {
        font-size: 18px;
    }
    .mobile-card .card-stats {
        flex-direction: column;
        gap: 6px;
    }
}

/* Защита от переполнения */
*, *::before, *::after {
    box-sizing: border-box;
}

.mobile-card .card-info {
    overflow: hidden;
}

.mobile-card .card-name {
    max-width: 100%;
}

/* Гибкая статистика */
.mobile-card .card-stats {
    flex-wrap: wrap;
}

/* ============================================
   СТИЛИ ДЛЯ СТРАНИЦЫ ТЕСТИРОВАНИЯ
   ============================================ */

/* Контейнер для тестирования */
.testing-container {
    border: 2px solid #667eea;
    padding: 30px;
    border-radius: 12px;
    background: white;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    max-width: 100%;
}

@media (min-width: 1200px) {
    .testing-container {
        padding: 40px;
    }
}

/* Прогресс бар */
.testing-progress {
    margin-bottom: 20px;
}

.testing-progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
    color: #666;
}

.testing-progress-bar {
    height: 8px;
    background: #e1e8ed;
    border-radius: 4px;
    overflow: hidden;
}

.testing-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #28a745, #20c997);
    transition: width 0.5s;
}

/* Блок попытки */
.testing-attempt {
    background: #fff3cd;
    border: 2px solid #ffc107;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 15px;
    text-align: center;
    color: #856404;
    font-weight: 600;
}

/* Блок вопроса */
.testing-question-block {
    background: linear-gradient(135deg, #667eea15, #764ba215);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #667eea;
}

.testing-question-title {
    color: #333;
    margin: 0 0 15px 0;
    font-size: 20px;
}

.testing-question-text {
    font-size: 18px;
    margin: 0;
    line-height: 1.6;
    color: #444;
}

/* Варианты ответов */
.testing-answer-option {
    cursor: pointer;
    display: block;
    padding: 14px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    transition: all 0.3s;
    background: white;
    margin: 10px 0;
}

.testing-answer-option:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.testing-answer-option input[type="radio"] {
    margin-right: 12px;
}

.testing-answer-option.selected {
    border-color: #667eea;
    background: #f0f4ff;
    font-weight: 600;
}

.testing-answer-option.disabled {
    pointer-events: none;
    opacity: 0.6;
}

/* Кнопки */
.testing-btn {
    margin-top: 20px;
    padding: 14px 35px;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 17px;
    font-weight: bold;
    transition: all 0.3s;
    width: 100%;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.testing-btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.testing-btn-success {
    background: linear-gradient(135deg, #28a745, #20c997);
}

.testing-btn-info {
    background: linear-gradient(135deg, #007bff, #0056b3);
}

.testing-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Блок результата */
.testing-result-block {
    margin-top: 20px;
}

.testing-result-success {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    border: 2px solid #28a745;
    padding: 20px;
    border-radius: 8px;
    animation: slideIn 0.3s;
}

.testing-result-error {
    background: linear-gradient(135deg, #f8d7da, #f5c6cb);
    border: 2px solid #dc3545;
    padding: 20px;
    border-radius: 8px;
    animation: shake 0.5s;
}

.testing-result-title {
    margin: 0 0 12px 0;
    font-size: 20px;
}

.testing-result-success .testing-result-title {
    color: #28a745;
}

.testing-result-error .testing-result-title {
    color: #dc3545;
}

.testing-result-text {
    margin: 8px 0;
    font-size: 15px;
}

.testing-result-success .testing-result-text {
    color: #155724;
}

.testing-result-error .testing-result-text {
    color: #721c24;
}

.testing-explanation {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid;
}

.testing-result-success .testing-explanation {
    border-color: #28a745;
    color: #155724;
}

.testing-result-error .testing-explanation {
    border-color: #dc3545;
    color: #721c24;
}

/* Блок результатов теста */
.testing-results {
    border: 3px solid;
    padding: 35px;
    border-radius: 12px;
    text-align: center;
    background: white;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.testing-results-emoji {
    font-size: 64px;
    margin-bottom: 15px;
}

.testing-results-title {
    font-size: 32px;
    margin: 0 0 10px 0;
}

.testing-results-subtitle {
    color: #666;
    margin: 0 0 30px 0;
    font-weight: normal;
}

.testing-results-stats {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 10px;
    margin: 25px 0;
}

.testing-results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.testing-results-stat-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 2px solid #e1e8ed;
}

.testing-results-stat-label {
    font-size: 14px;
    color: #999;
    margin-bottom: 8px;
}

.testing-results-stat-value {
    font-size: 36px;
    font-weight: bold;
}

.testing-results-stat-sub {
    font-size: 14px;
    color: #666;
    margin-top: 5px;
}

.testing-results-time {
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 2px solid #e1e8ed;
}

.testing-results-time-label {
    font-size: 14px;
    color: #999;
    margin-bottom: 8px;
}

.testing-results-time-value {
    font-size: 24px;
    font-weight: bold;
    color: #666;
}

.testing-results-actions {
    margin-top: 30px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.testing-results-btn {
    flex: 1;
    min-width: 200px;
    padding: 16px 30px;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.testing-results-btn-success {
    background: linear-gradient(135deg, #28a745, #20c997);
}

.testing-results-btn-primary {
    background: linear-gradient(135deg, #007bff, #0056b3);
}

.testing-results-btn-secondary {
    background: linear-gradient(135deg, #6c757d, #5a6268);
}

/* Блок ошибки */
.testing-error {
    border: 2px solid #dc3545;
    padding: 20px;
    border-radius: 10px;
    background: #f8d7da;
    color: #721c24;
}

.testing-error-title {
    margin: 0 0 10px 0;
}

.testing-error-btn {
    margin-top: 15px;
    padding: 10px 20px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

/* Анимации */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* ============================================
   ОБЩИЕ СТИЛИ
   ============================================ */

.container {
    max-width: 1200px;
    margin: 24px auto;
    padding: 0 24px;
}

/* Улучшенные отступы для больших экранов */
@media (min-width: 1400px) {
    .container {
        max-width: 1400px;
        padding: 0 32px;
    }
}

/* Стили для профиля */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 24px;
    margin-top: 30px;
}

@media (min-width: 1200px) {
    .stats {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 30px;
    }
}

.stat-item {
    background: #f8fafc;
    padding: 1.1rem 1rem;
    border-radius: 10px;
    border: 1px solid #e8ecf1;
    text-align: center;
}
.profile-section-stats .stats {
    margin-top: 0.5rem;
    gap: 0.75rem;
}
.profile-section-stats .stat-item {
    background: #f8fafc;
    padding: 1rem;
}
@media (max-width: 600px) {
    .profile-section-stats .stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.65rem;
    }
    .profile-section-stats .stat-value { font-size: 1.5rem; }
}

.stat-value {
    font-size: 1.85rem;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.875rem;
    color: #6b7280;
}

/* Контент блока «Профиль» в личном кабинете */
.profile-section-info .profile-info {
    background: transparent;
    padding: 0;
    border: none;
    margin: 0;
}
.profile-section-info .profile-info h2 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    color: #374151;
}
.profile-section-info .profile-avatar {
    margin-bottom: 1rem;
}
.profile-section-info .profile-avatar img {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e8ecf1;
}
.profile-section-info .profile-info p {
    margin: 0 0 0.6rem 0;
    font-size: 0.95rem;
    color: #374151;
    line-height: 1.45;
}
.profile-section-info .profile-link {
    color: #667eea;
    text-decoration: none;
}
.profile-section-info .profile-link:hover {
    text-decoration: underline;
}
.profile-section-info .profile-level-block {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e8ecf1;
}
.profile-section-info .profile-level-block select {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-size: 1rem;
    margin-right: 8px;
}
.profile-section-info .profile-level-save-btn {
    padding: 8px 16px;
    border-radius: 8px;
    background: #667eea;
    color: #fff;
    border: none;
    font-weight: 500;
    cursor: pointer;
    margin-right: 8px;
}
.profile-section-info .profile-level-save-btn:hover {
    background: #5568d3;
}
.profile-section-info .profile-level-hint {
    font-size: 0.85rem !important;
    color: #6b7280 !important;
    margin-top: 0.5rem !important;
}
.profile-level-message { font-size: 0.9rem; margin-top: 0.5rem; }
.profile-level-message-ok { color: #059669; }
.profile-level-message-err { color: #dc2626; }
.profile-error { margin-top: 1rem; }
.profile-retry-btn { margin-top: 0.5rem; padding: 8px 16px; cursor: pointer; }

.profile-info {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 2px solid #e1e8ed;
    margin-bottom: 20px;
}

.profile-info h2 {
    margin: 0 0 24px 0;
    color: #333;
    font-size: 26px;
}

@media (min-width: 1200px) {
    .profile-info h2 {
        font-size: 28px;
        margin-bottom: 30px;
    }
}

.profile-info p {
    margin: 12px 0;
    color: #666;
    line-height: 1.6;
}

.profile-info strong {
    color: #333;
    font-weight: 600;
}

.profile-avatar {
    text-align: center;
    margin-bottom: 20px;
}

.profile-avatar img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 3px solid #0088cc;
    object-fit: cover;
}

.profile-link {
    color: #0088cc;
    text-decoration: none;
    transition: color 0.3s;
}

.profile-link:hover {
    color: #006ba3;
    text-decoration: underline;
}

.profile-error {
    color: #c33;
    padding: 15px;
    background: #f8d7da;
    border: 2px solid #dc3545;
    border-radius: 8px;
    margin-bottom: 15px;
}

.profile-retry-btn {
    margin-top: 10px;
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.profile-retry-btn:hover {
    background: #5568d3;
}

.profile-level-block {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 8px 0;
}
.profile-level-block select {
    padding: 8px 12px;
    min-width: 72px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 1rem;
}
.profile-level-save-btn {
    padding: 8px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}
.profile-level-save-btn:hover:not(:disabled) {
    background: #5568d3;
}
.profile-level-save-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}
.profile-level-message {
    font-size: 14px;
}
.profile-level-message-ok {
    color: #2d7a3e;
}
.profile-level-message-err {
    color: #c33;
}
.profile-level-hint {
    font-size: 0.9rem;
    color: #666;
    margin: 4px 0 0 0;
}

/* Личный кабинет: секции и актуальные тесты */
.profile-cabinet {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
/* Личный кабинет: структура */
.page-profile .profile-card { padding-bottom: 2rem; }
.profile-cabinet-header {
    margin-bottom: 1.5rem;
}
.profile-cabinet-title {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 700;
    color: #1a1a2e;
}
.profile-section {
    background: #fff;
    border-radius: 14px;
    border: 1px solid #e8ecf1;
    padding: 1.35rem 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.profile-section-title {
    margin: 0 0 0.35rem 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: #1a1a2e;
}
.profile-section-desc {
    margin: 0 0 1rem 0;
    font-size: 0.9rem;
    color: #6b7280;
}
.profile-assigned-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}
.profile-assigned-list .profile-loading-text {
    color: #6b7280;
    margin: 0;
    min-height: 2.5rem;
    display: flex;
    align-items: center;
}
.profile-assigned-list .profile-assigned-empty {
    color: #6b7280;
    margin: 0;
    padding: 0.75rem 0;
    font-size: 0.95rem;
    line-height: 1.45;
}
.profile-assigned-item {
    display: block;
    padding: 1rem 1.2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    text-decoration: none;
    border-radius: 12px;
    font-weight: 500;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.25);
}
.profile-assigned-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.35);
}
.profile-assigned-item:active {
    transform: translateY(0);
}
.profile-assigned-item-sub {
    font-size: 0.85rem;
    opacity: 0.92;
    margin-top: 4px;
    display: block;
}
.profile-assigned-group {
    margin-bottom: 1rem;
}
.profile-assigned-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}
.profile-assigned-group-name {
    font-weight: 600;
    color: #374151;
    font-size: 0.95rem;
}
.profile-leave-group-btn {
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
    color: #b91c1c;
    background: transparent;
    border: 1px solid #fca5a5;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.profile-leave-group-btn:hover:not(:disabled) {
    background: #fef2f2;
    color: #991b1b;
}
.profile-leave-group-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.profile-assigned-group-items {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}
.profile-action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.profile-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 12px 20px;
    border-radius: 12px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s, transform 0.15s;
    font-size: 1rem;
}
.profile-action-btn-primary {
    background: #667eea;
    color: #fff;
    border: none;
}
.profile-action-btn-primary:hover {
    background: #5568d3;
}
.profile-action-btn-secondary {
    background: #fff;
    color: #667eea;
    border: 2px solid #667eea;
}
.profile-action-btn-secondary:hover {
    background: #f0f2ff;
}
.profile-cabinet-footer {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid #e8ecf1;
    text-align: left;
}
.profile-cabinet-footer .logout-btn {
    padding: 10px 20px;
    font-size: 0.95rem;
}
@media (max-width: 768px) {
    .profile-cabinet-title { font-size: 1.45rem; }
    .profile-section { padding: 1.1rem 1.25rem; margin-bottom: 0.85rem; }
    .profile-action-buttons { flex-direction: column; }
    .profile-action-btn { width: 100%; min-height: 44px; }
}

/* Навигация */
.nav-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 30px;
    padding-top: 24px;
    border-top: 1px solid #e1e8ed;
}

@media (min-width: 1200px) {
    .nav-buttons {
        gap: 16px;
        padding-top: 30px;
    }
}

.nav-buttons button {
    padding: 14px 28px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    transition: all 0.3s;
    font-weight: 500;
}

@media (min-width: 1200px) {
    .nav-buttons button {
        padding: 16px 32px;
        font-size: 16px;
    }
}

.nav-buttons button:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

/* Кнопка выхода */
.logout-btn {
    padding: 12px 24px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.logout-btn:hover {
    background: #c82333;
}

/* Список предметов */
.subject-list {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-top: 20px;
}

@media (min-width: 1200px) {
    .subject-list {
        gap: 30px;
    }
}

.subject-card {
    background: #e3f2fd; /* Светло-голубой фон для предмета */
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 0;
}

@media (min-width: 1200px) {
    .subject-card {
        padding: 24px;
        border-radius: 14px;
    }
}

@media (max-width: 768px) {
    .subject-card {
        padding: 16px;
        border-radius: 10px;
    }
}

.subject-title {
    margin: 0 0 18px 0;
    color: #333;
    font-weight: bold;
    font-size: 22px;
}

@media (min-width: 1200px) {
    .subject-title {
        font-size: 24px;
        margin-bottom: 20px;
    }
}

.clickable-subject {
    cursor: pointer;
    transition: color 0.2s, background 0.2s, transform 0.2s;
    padding: 4px 8px;
    border-radius: 6px;
    display: inline-block;
    color: #1565c0;
    text-decoration: none;
    border-bottom: 1px solid transparent;
}
.clickable-subject:hover {
    color: #0d47a1;
    border-bottom-color: #1565c0;
    background: rgba(33, 150, 243, 0.12);
    transform: translateX(4px);
}
.clickable-subject::after {
    content: ' →';
    font-size: 0.9em;
    opacity: 0.8;
}

/* Заголовок предмета: название + кнопка «Развернуть» в одну строку */
.subject-header {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.subject-header .subject-title {
    margin: 0;
    flex: 1;
    min-width: 0;
}
.subject-themes-wrap {
    margin-top: 14px;
}
.subject-themes-wrap.collapsed {
    display: none;
}

/* Кнопка «Развернуть» / «Свернуть» — визуально выделена */
.expand-btn {
    flex-shrink: 0;
    padding: 8px 16px;
    font-weight: 600;
    font-size: 14px;
    color: #fff;
    background: #1976d2;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(25, 118, 210, 0.4);
    transition: background 0.2s, box-shadow 0.2s;
}
.expand-btn:hover {
    background: #1565c0;
    box-shadow: 0 3px 8px rgba(25, 118, 210, 0.5);
}
.expand-btn:focus {
    outline: 2px solid #1976d2;
    outline-offset: 2px;
}

.theme-card {
    background: #90caf9; /* Темно-голубой фон для темы */
    padding: 15px;
    border-radius: 10px;
    margin: 12px 0;
    margin-left: 20px; /* Каскадный отступ для темы */
    border-left: 4px solid #1976d2; /* Цветной акцент слева - более яркий синий */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

@media (min-width: 1200px) {
    .theme-card {
        padding: 18px;
        border-radius: 12px;
        margin: 14px 0;
        margin-left: 24px;
        border-left-width: 5px;
    }
}

@media (max-width: 768px) {
    .theme-card {
        padding: 12px;
        border-radius: 8px;
        margin: 10px 0;
        margin-left: 16px;
        border-left-width: 3px;
    }
}

/* Заголовок темы: название + кнопка «Развернуть» */
.theme-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.theme-header .theme-title {
    margin: 0;
    flex: 1;
    min-width: 0;
}
.theme-stages-wrap {
    margin-top: 12px;
}
.theme-stages-wrap.collapsed {
    display: none;
}

.theme-title {
    margin: 0 0 14px 0;
    color: #333;
    font-weight: bold;
    font-size: 18px;
}

@media (min-width: 1200px) {
    .theme-title {
        font-size: 20px;
        margin-bottom: 16px;
    }
}

.clickable-theme {
    cursor: pointer;
    transition: color 0.2s, background 0.2s, transform 0.2s;
    padding: 4px 8px;
    border-radius: 6px;
    display: inline-block;
    color: #0d47a1;
    text-decoration: none;
    border-bottom: 1px solid rgba(13, 71, 161, 0.4);
}
.clickable-theme:hover {
    color: #0d47a1;
    border-bottom-color: #0d47a1;
    background: rgba(255, 255, 255, 0.4);
    transform: translateX(4px);
}
.clickable-theme::after {
    content: ' →';
    font-size: 0.9em;
    opacity: 0.9;
}

.topic-stages-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-left: 16px; /* Каскадный отступ для этапов темы */
}

@media (min-width: 1200px) {
    .topic-stages-list {
        margin-left: 20px;
    }
}

@media (max-width: 768px) {
    .topic-stages-list {
        margin-left: 12px;
    }
}

.topic-stage-item {
    color: #333;
    padding: 8px 12px;
    padding-left: 20px; /* Отступ для цветного акцента */
    border-radius: 6px;
    background: transparent;
    transition: all 0.2s;
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
    position: relative;
}

.topic-stage-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 70%;
    background: #1976d2; /* Цветной акцент для этапа - яркий синий */
    border-radius: 2px;
    transition: all 0.2s;
    z-index: 1;
}

@media (min-width: 1200px) {
    .topic-stage-item {
        font-size: 15px;
        padding: 10px 14px;
        padding-left: 24px;
    }
    
    .topic-stage-item::before {
        width: 4px;
    }
}

@media (max-width: 768px) {
    .topic-stage-item {
        font-size: 13px;
        padding: 6px 10px;
        padding-left: 18px;
    }
    
    .topic-stage-item::before {
        width: 2px;
    }
}

.clickable-topic-stage {
    cursor: pointer;
    color: #1565c0;
    font-weight: 600;
    border-bottom: 1px solid transparent;
    transition: color 0.2s, background 0.2s, transform 0.2s, border-color 0.2s;
}

.clickable-topic-stage:hover {
    color: #0d47a1;
    border-bottom-color: #1565c0;
    background: rgba(255, 255, 255, 0.25);
    transform: translateX(4px);
}

.clickable-topic-stage::after {
    content: ' →';
    font-size: 0.85em;
    opacity: 0.85;
    margin-left: 2px;
}

.clickable-topic-stage:hover::before {
    width: 5px;
    background: #0d47a1;
    height: 80%;
}

@media (min-width: 1200px) {
    .clickable-topic-stage:hover::before {
        width: 6px;
    }
}

@media (max-width: 768px) {
    .clickable-topic-stage:hover::before {
        width: 4px;
    }
}

.topic-stage-item.no-stages {
    color: #666;
    font-style: italic;
    cursor: default;
}

.topic-stage-item.no-stages::before {
    display: none; /* Убираем акцент для неактивных элементов */
}

.topic-stage-item.no-stages:hover {
    background: transparent;
    transform: none;
}

/* Старые стили для обратной совместимости */
.theme-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.theme-list li {
    margin: 8px 0;
}

.theme-link {
    color: #667eea;
    text-decoration: none;
    padding: 8px 12px;
    display: inline-block;
    border-radius: 4px;
    transition: background 0.3s;
}

.theme-link:hover {
    background: #f0f4ff;
    text-decoration: underline;
}

.no-themes {
    color: #999;
    font-style: italic;
}

/* Сообщение об отсутствии данных */
.no-data {
    text-align: center;
    padding: 40px;
    color: #666;
}

.no-data-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

/* ============================================
   СТИЛИ ДЛЯ ТАБЛИЦЫ ЛИДЕРОВ (ОБНОВЛЕННЫЕ)
   ============================================ */

.leaderboard-section {
    margin-bottom: 50px;
}

@media (min-width: 1200px) {
    .leaderboard-section {
        margin-bottom: 60px;
    }
}

.leaderboard-section h2 {
    margin: 0 0 24px 0;
    color: #333;
    font-size: 26px;
    font-weight: 600;
}

@media (min-width: 1200px) {
    .leaderboard-section h2 {
        font-size: 28px;
        margin-bottom: 30px;
    }
}

.leaderboard-items {
    margin-bottom: 20px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    overflow: hidden;
}

@media (min-width: 1200px) {
    .leaderboard-items {
        border-radius: 16px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    }
}

.leaderboard-hidden {
    display: none;
}

.leaderboard-hidden .leader-item {
    display: none;
}

.leaderboard-separator {
    height: 2px;
    background: linear-gradient(90deg, transparent, #e1e8ed, transparent);
    margin: 20px 0;
    position: relative;
}

.leaderboard-separator::before {
    content: '...';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: #f5f7fa;
    padding: 0 15px;
    color: #999;
    font-size: 20px;
}

/* Выделение текущего пользователя */
.leader-item.current-user {
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    border: 2px solid #2196f3;
    border-radius: 8px;
    margin: 8px 0;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.2);
}

.leader-item.current-user .desktop-row {
    background: transparent;
    border-bottom: none;
}

.leader-item.current-user .mobile-card {
    background: transparent;
    border: none;
    box-shadow: none;
}

.you-badge {
    display: inline-block;
    background: #2196f3;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
    vertical-align: middle;
}

/* Кнопки управления таблицей */
.leaderboard-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid #e1e8ed;
}

@media (min-width: 1200px) {
    .leaderboard-controls {
        gap: 16px;
        margin-top: 30px;
        padding-top: 30px;
    }
}

.leaderboard-expand-btn,
.leaderboard-collapse-btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

.leaderboard-expand-btn:hover,
.leaderboard-collapse-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.4);
}

.leaderboard-expand-btn:active,
.leaderboard-collapse-btn:active {
    transform: translateY(0);
}

.leaderboard-expand-btn:disabled,
.leaderboard-collapse-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Адаптивность для кнопок */
@media (max-width: 768px) {
    .leaderboard-controls {
        flex-direction: column;
    }
    
    .leaderboard-expand-btn,
    .leaderboard-collapse-btn {
        width: 100%;
    }
    
    .leader-item.current-user {
        margin: 6px 0;
    }
}

/* ============================================
   СТИЛИ ДЛЯ СТРАНИЦЫ ВХОДА (LOGIN)
   ============================================ */

.card {
    max-width: 450px;
    margin: 40px auto;
    padding: 30px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

@media (min-width: 1200px) {
    .card {
        max-width: 500px;
        padding: 40px;
    }
}

.card h1 {
    margin: 0 0 24px 0;
    text-align: center;
    color: #333;
    font-size: 28px;
}

.test-mode {
    background: #fff3cd;
    border: 2px solid #ffc107;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 20px;
    color: #856404;
    text-align: center;
    font-size: 14px;
}

.telegram-login {
    width: 100%;
    padding: 14px;
    background: #0088cc;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
    margin-bottom: 20px;
}

.telegram-login:hover {
    background: #006ba3;
}

.telegram-login:active {
    transform: scale(0.98);
}

.divider {
    text-align: center;
    margin: 24px 0;
    color: #999;
    position: relative;
    font-size: 14px;
}

.divider::before,
.divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 45%;
    height: 1px;
    background: #e1e8ed;
}

.divider::before {
    left: 0;
}

.divider::after {
    right: 0;
}

.actions {
    margin-top: 20px;
}

.actions form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.actions label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.form-input {
    padding: 12px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
    font-family: inherit;
}

.form-input:focus {
    outline: none;
    border-color: #667eea;
}

.form-input::placeholder {
    color: #999;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 6px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.note {
    margin-top: 20px;
    padding: 12px;
    background: #f8f9fa;
    border-left: 4px solid #667eea;
    border-radius: 4px;
    font-size: 13px;
    color: #666;
    line-height: 1.5;
}

/* Адаптивность для страницы входа */
@media (max-width: 480px) {
    body {
        padding-top: max(env(safe-area-inset-top), 16px);
    }
    
    .card {
        margin: 16px;
        padding: 20px;
        margin-top: max(env(safe-area-inset-top), 12px);
    }
    
    .card h1 {
        font-size: 24px;
    }
}

/* Админ-панель */
.admin-links {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
}
.admin-card {
    display: inline-block;
    padding: 1rem 1.5rem;
    background: #e3f2fd;
    border-radius: 10px;
    text-decoration: none;
    color: #1565c0;
    font-weight: 500;
    border: 1px solid #90caf9;
    transition: background 0.2s;
}
.admin-card:hover {
    background: #bbdefb;
}

/* ========== Общие UI: toast и загрузка ========== */
.app-toast-container {
    position: fixed;
    top: max(16px, env(safe-area-inset-top));
    right: max(16px, env(safe-area-inset-right));
    left: auto;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    max-width: min(360px, calc(100vw - 32px));
}
.app-toast {
    padding: 12px 18px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    font-size: 14px;
    line-height: 1.4;
    pointer-events: auto;
    animation: app-toast-in 0.25s ease;
    border: 1px solid transparent;
}
@keyframes app-toast-in {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}
.app-toast.success {
    background: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}
.app-toast.error {
    background: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}
.app-toast.info {
    background: #cce5ff;
    color: #004085;
    border-color: #b8daff;
}

.app-loading-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(0,0,0,0.1);
    border-top-color: #333;
    border-radius: 50%;
    animation: app-spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 10px;
}
@keyframes app-spin {
    to { transform: rotate(360deg); }
}
.app-loading-block {
    text-align: center;
    padding: 32px 24px;
    color: #666;
}
.app-loading-block .app-loading-spinner {
    display: block;
    margin: 0 auto 12px;
}

/* Страница проверки миграций в админке */
.migration-result { margin-top: 1rem; }
.migration-result .success { color: #155724; margin-bottom: 0.5rem; }
.migration-result .warning { color: #856404; margin-bottom: 0.5rem; }
.migration-result .error { color: #721c24; }
.migration-item { padding: 0.5rem 0; border-bottom: 1px solid #eee; }
.migration-item.ok { color: #155724; }
.migration-item.missing { color: #856404; }
.migration-result code { background: #f5f5f5; padding: 0.1em 0.4em; border-radius: 4px; }