/* ===== static/css/style.css - ИСПРАВЛЕННАЯ ВЕРСИЯ ===== */

/* ===== Базовые стили и сброс ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #2c3e50;
    background: linear-gradient(135deg, #f5f7fa 0%, #e9edf2 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 30px 20px;
    flex: 1;
}

/* ===== Навигация ===== */
.navbar {
    background: linear-gradient(135deg, #1a2a3a 0%, #0f1a24 100%);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    position: relative;
}

.nav-logo {
    font-size: 1.8rem;
    font-weight: bold;
    background: linear-gradient(135deg, #f39c12, #e67e22);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-decoration: none;
    transition: opacity 0.2s;
}

.nav-logo:hover {
    opacity: 0.85;
}

.nav-links {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.nav-links a {
    color: #ecf0f1;
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    transition: all 0.2s;
}

.nav-links a:hover {
    background: rgba(243, 156, 18, 0.2);
    color: #f39c12;
}

.nav-user {
    color: #f39c12;
    font-weight: 600;
    background: rgba(243, 156, 18, 0.15);
    padding: 0.5rem 1.2rem;
    border-radius: 30px;
    font-size: 0.9rem;
    margin-right: 0.5rem;
}

/* Стиль для пункта Обмен */
.nav-exchange {
    color: #e67e22 !important;
    font-weight: bold;
}

.nav-exchange:hover {
    color: #f39c12 !important;
}

/* ===== Бургер-кнопка (скрыта на десктопе) ===== */
.menu-toggle {
    display: none;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: 8px;
    cursor: pointer;
    width: 44px;
    height: 44px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 0;
}

.menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}

.menu-toggle.open span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.menu-toggle.open span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.open span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* ===== Выпадающее меню коллекций ===== */
.collections-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-btn {
    background: none;
    border: none;
    color: #ffffff !important;
    cursor: pointer;
    font-size: 16px;
    padding: 8px 12px;
    text-decoration: none;
    display: inline-block;
    font-family: inherit;
    border-radius: 10px;
    transition: all 0.2s;
}

.dropdown-btn:hover {
    background: rgba(243, 156, 18, 0.2);
    color: #f39c12 !important;
}

/* По умолчанию скрыт */
.collections-dropdown .dropdown-content {
    display: none;
    position: absolute;
    background-color: #2c3e50;
    min-width: 220px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1000;
    border-radius: 10px;
    top: 100%;
    left: 0;
    
    /* ФИКС: Ограничение высоты и прокрутка для длинного списка */
    max-height: 65vh; /* Высота не более 65% экрана */
    overflow-y: auto; /* Включаем вертикальную прокрутку */
    scrollbar-width: thin; /* Тонкий скроллбар для Firefox */
}

/* Красивый скроллбар для Chrome/Safari/Edge */
.collections-dropdown .dropdown-content::-webkit-scrollbar {
    width: 6px;
}
.collections-dropdown .dropdown-content::-webkit-scrollbar-track {
    background: transparent;
}
.collections-dropdown .dropdown-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}
.collections-dropdown .dropdown-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

.dropdown-content a {
    color: #ecf0f1;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    transition: 0.3s;
    white-space: nowrap;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.dropdown-content a:last-child {
    border-bottom: none;
}

.dropdown-content a:hover {
    background-color: #34495e;
    color: #f39c12;
}

/* Открытие по клику (новое) */
.collections-dropdown.open .dropdown-content {
    display: block;
}

/* На десктопе hover тоже работает */
@media (min-width: 861px) {
    .collections-dropdown:hover .dropdown-content {
        display: block;
    }
}

/* ===== Кнопки ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(243, 156, 18, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(243, 156, 18, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
    color: white;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    background: linear-gradient(135deg, #7f8c8d 0%, #6c7a7b 100%);
}

.btn-danger {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    border-radius: 8px;
}

.btn-info {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    transition: all 0.3s ease;
}

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

.coin-card-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.coin-card-buttons .btn,
.coin-card-buttons .btn-info {
    flex: 1;
    text-align: center;
}

/* ===== Формы ===== */
.form-container {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}

.form-section {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f2f5;
}

.form-section h2 {
    margin-bottom: 20px;
    color: #1a2a3a;
    font-size: 1.5rem;
    border-left: 4px solid #f39c12;
    padding-left: 15px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="file"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e6ed;
    border-radius: 12px;
    font-size: 14px;
    transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #f39c12;
    box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.1);
}

.form-row {
    display: flex;
    gap: 20px;
}

.form-row .form-group {
    flex: 1;
}

.form-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 30px;
}

/* ===== Карточки монет ===== */
.random-coin-card {
    background: white;
    border-radius: 20px;
    padding: 25px;
    display: flex;
    gap: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    margin-bottom: 30px;
    transition: transform 0.2s;
}

.random-coin-card:hover {
    transform: translateY(-3px);
}

.coin-images {
    flex: 0 0 300px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.coin-image {
    width: 140px;
    height: 140px;
    object-fit: cover;
    border-radius: 16px;
    border: 2px solid #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    background: #f8f9fa;
}

.coin-image-placeholder {
    width: 140px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #e0e6ed, #cbd5e1);
    border-radius: 16px;
    color: #2c3e50;
    font-weight: 500;
    font-size: 14px;
}

.coin-info {
    flex: 1;
}

.coin-info h3 {
    font-size: 1.8rem;
    color: #1a2a3a;
    margin-bottom: 15px;
}

.coin-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.coin-details p {
    background: #f8f9fa;
    padding: 8px 15px;
    border-radius: 10px;
    border-left: 3px solid #f39c12;
}

/* ===== Сетка монет ===== */
.coins-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.coin-card {
    background: white;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.coin-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0,0,0,0.12);
}

.coin-card-images {
    display: flex;
    flex-direction: row;
    gap: 10px;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid #e0e6ed;
}

.coin-image-side {
    width: 110px;
    height: 110px;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.coin-card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.coin-card-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    color: #999;
    font-size: 11px;
    text-align: center;
}

.coin-card-info {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.coin-card-info h3 {
    font-size: 1.2rem;
    color: #1a2a3a;
    margin-bottom: 10px;
}

.coin-card-details {
    margin: 12px 0;
    flex: 1;
}

.coin-card-details p {
    margin: 6px 0;
    color: #666;
    font-size: 0.85rem;
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.exchange-badge {
    display: inline-block;
    background-color: #e67e22;
    color: white;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 12px;
    margin-left: 8px;
}

/* ===== Детальная страница монеты ===== */
.coin-detail-container {
    background: white;
    border-radius: 24px;
    padding: 35px;
    box-shadow: 0 10px 35px rgba(0,0,0,0.08);
}

.coin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f2f5;
    flex-wrap: wrap;
    gap: 15px;
}

.coin-header h1 {
    font-size: 2rem;
    color: #1a2a3a;
}

.coin-actions {
    display: flex;
    gap: 12px;
}

.coin-images-section {
    margin-bottom: 35px;
}

.coin-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.coin-image-container {
    text-align: center;
}

.coin-image-container h3 {
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 1.2rem;
}

.coin-detail-image {
    width: 100%;
    max-height: 350px;
    object-fit: contain;
    border-radius: 16px;
    background: #f8f9fa;
    padding: 15px;
    border: 1px solid #e0e6ed;
}

.coin-info-section {
    margin-top: 35px;
}

.coin-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-top: 20px;
}

.info-group h4 {
    margin-bottom: 15px;
    color: #1a2a3a;
    font-size: 1.2rem;
    border-left: 3px solid #f39c12;
    padding-left: 12px;
}

.info-table {
    width: 100%;
    background: #f8f9fa;
    border-radius: 16px;
    overflow: hidden;
}

.info-table tr {
    border-bottom: 1px solid #e0e6ed;
}

.info-table td {
    padding: 12px 15px;
}

.info-table td:first-child {
    width: 40%;
    font-weight: 600;
    color: #2c3e50;
}

.notes-section {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 16px;
}

/* ===== Поиск ===== */
.search-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.search-header h1 {
    font-size: 1.8rem;
    color: #1a2a3a;
}

.search-form-inline {
    display: flex;
    gap: 10px;
}

.search-input {
    min-width: 250px;
    padding: 14px 20px;
    border: 2px solid #e0e6ed;
    border-radius: 14px;
    font-size: 16px;
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: #f39c12;
    box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.1);
}

.search-stats {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 15px 20px;
    border-radius: 14px;
    margin-bottom: 20px;
    color: #2c3e50;
    font-weight: 500;
}

.exchange-description {
    color: #e67e22;
    font-size: 14px;
    margin-top: 5px;
}

/* ===== Пагинация ===== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 40px;
    padding: 20px;
}

.page-link {
    padding: 10px 24px;
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
    text-decoration: none;
    border-radius: 30px;
    transition: all 0.2s;
    font-weight: 600;
}

.page-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(243, 156, 18, 0.3);
}

.page-info {
    color: #2c3e50;
    font-weight: 500;
}

/* ===== Flash сообщения ===== */
.flash-messages {
    margin-bottom: 25px;
}

.flash {
    padding: 15px 20px;
    border-radius: 12px;
    margin-bottom: 12px;
    font-weight: 500;
    animation: slideIn 0.3s ease;
}

.flash-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border-left: 4px solid #28a745;
}

.flash-error {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    border-left: 4px solid #dc3545;
}

.flash-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeeba 100%);
    color: #856404;
    border-left: 4px solid #ffc107;
}

.flash-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    color: #0c5460;
    border-left: 4px solid #17a2b8;
}

@keyframes slideIn {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ===== Модальное окно ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    overflow: auto;
}

.modal-content {
    background-color: #fff;
    margin: 10% auto;
    width: 90%;
    max-width: 600px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    animation: modalSlideDown 0.3s ease;
}

@keyframes modalSlideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-radius: 12px 12px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.close-btn {
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
    line-height: 1;
}

.close-btn:hover {
    transform: scale(1.2);
    opacity: 0.8;
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.loading-spinner {
    text-align: center;
    padding: 40px;
    font-size: 16px;
    color: #667eea;
}

.loading-spinner i {
    font-size: 48px;
    display: block;
    margin-bottom: 15px;
}

.ai-info-content {
    line-height: 1.6;
    font-size: 14px;
}

.ai-error {
    text-align: center;
    padding: 40px;
    color: #e74c3c;
}

.ai-error i {
    font-size: 48px;
    margin-bottom: 15px;
    display: block;
}

.fa-spin {
    animation: fa-spin 2s infinite linear;
}

@keyframes fa-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== Статистика ===== */
.statistics {
    background: white;
    border-radius: 20px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.05);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.stat-item {
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    text-align: center;
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: white;
    margin-bottom: 8px;
}

.stat-label {
    color: rgba(255,255,255,0.9);
    font-size: 0.85rem;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.stats-table th {
    background: linear-gradient(135deg, #1a2a3a 0%, #2c3e50 100%);
    color: white;
    padding: 12px 15px;
    font-weight: 600;
    font-size: 0.85rem;
}

.stats-table td {
    padding: 10px 15px;
    border-bottom: 1px solid #e0e6ed;
}

.count-badge {
    display: inline-block;
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 30px;
    font-size: 0.8rem;
}

.percent-bar-wrapper {
    position: relative;
    background: #e0e6ed;
    border-radius: 20px;
    height: 28px;
    overflow: hidden;
    width: 100%;
    min-width: 100px;
}

.percent-bar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: linear-gradient(90deg, #f39c12, #e67e22);
    border-radius: 20px;
}

.percent-text {
    position: relative;
    z-index: 1;
    padding: 0 12px;
    font-weight: 600;
    font-size: 0.8rem;
    color: white;
    display: flex;
    align-items: center;
    height: 100%;
}

.country-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.country-flag-img {
    width: 32px;
    height: 22px;
    object-fit: cover;
    border-radius: 4px;
}

/* ===== Hero секция ===== */
.hero {
    text-align: center;
    padding: 50px 30px;
    background: linear-gradient(135deg, white 0%, #f8f9fa 100%);
    border-radius: 24px;
    margin-bottom: 30px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.05);
}

.hero h1 {
    font-size: 2.5rem;
    color: #1a2a3a;
    margin-bottom: 15px;
}

.hero p {
    font-size: 1.2rem;
    color: #666;
}

.random-coin-section {
    background: white;
    border-radius: 24px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.05);
}

.random-coin-section h2 {
    margin-bottom: 20px;
    color: #1a2a3a;
    font-size: 1.5rem;
    border-left: 4px solid #f39c12;
    padding-left: 15px;
}

/* ===== Пустое состояние ===== */
.empty-state {
    text-align: center;
    padding: 60px 30px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.05);
}

.empty-state p {
    margin-bottom: 25px;
    color: #666;
    font-size: 1.1rem;
}

/* ===== Страница входа ===== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 250px);
}

.login-card {
    background: white;
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 420px;
}

.login-card h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #1a2a3a;
    font-size: 1.8rem;
}

/* ===== Футер ===== */
.footer {
    background: linear-gradient(135deg, #1a2a3a 0%, #0f1a24 100%);
    color: #ecf0f1;
    padding: 30px 0;
    margin-top: 50px;
}

.footer-content {
    max-width: 1300px;
    margin: 0 auto;
    text-align: center;
    padding: 0 20px;
    font-size: 0.85rem;
    opacity: 0.8;
}

/* ============================================================
   МОБИЛЬНАЯ ВЕРСИЯ (<= 860px)
   ============================================================ */
@media (max-width: 860px) {
    .container {
        padding: 15px;
    }

    .nav-container {
        padding: 0.8rem 1rem;
        flex-wrap: nowrap;
        gap: 10px;
    }

    .nav-logo {
        font-size: 1.3rem;
    }

    /* Бургер видим */
    .menu-toggle {
        display: flex;
        margin-left: auto;
    }

    /* Меню скрыто, выпадает поверх контента */
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: #0f172a;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        padding: 10px 12px;
        border-top: 1px solid rgba(255,255,255,0.08);
        box-shadow: 0 10px 24px rgba(0,0,0,0.35);
        max-height: 70vh;
        overflow-y: auto;
        z-index: 999;
    }

    .nav-links.open {
        display: flex;
    }

    .nav-links > a,
    .nav-links > span,
    .nav-links .dropdown-btn {
        display: block;
        width: 100%;
        text-align: left;
        padding: 13px 14px;
        border-radius: 8px;
        box-sizing: border-box;
        font-size: 1rem;
    }

    .nav-user {
        order: -2;
        background: rgba(243, 156, 18, 0.12);
        color: #f39c12 !important;
        font-weight: 600;
    }

    /* ===== Дропдаун "Коллекции" на мобильном ===== */
    .collections-dropdown {
        width: 100%;
        position: relative;
    }

    /* Отключаем hover-дропдаун на мобильном */
    .collections-dropdown:hover .dropdown-content {
        display: none;
    }

    /* Открытие по клику */
    .collections-dropdown.open .dropdown-content {
        display: block !important;
    }

    /* Дропдаун — как аккордеон внутри меню */
    .collections-dropdown .dropdown-content {
        position: static !important;
        width: 100% !important;
        min-width: 0 !important;
        box-shadow: none !important;
        background: rgba(255,255,255,0.06) !important;
        border-radius: 8px !important;
        margin: 4px 0 0 0 !important;
        padding: 4px !important;
        top: auto !important;
        left: auto !important;
        max-height: none !important; /* На мобильном пусть растягивается вместе с общим меню */
    }

    .collections-dropdown .dropdown-content a {
        padding: 10px 14px !important;
        border-bottom: none !important;
        border-radius: 6px !important;
        white-space: normal !important;
    }

    .collections-dropdown .dropdown-btn {
        width: 100% !important;
        text-align: left !important;
        padding: 13px 14px !important;
        background: transparent !important;
        color: #e2e8f0 !important;
        border-radius: 8px !important;
    }

    .collections-dropdown.open .dropdown-btn {
        background: rgba(255,255,255,0.08) !important;
    }

    /* ===== Статистика ===== */
    .statistics {
        padding: 15px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-number {
        font-size: 1.3rem;
    }

    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .stats-table {
        min-width: 500px;
    }

    .stats-table th,
    .stats-table td {
        padding: 6px 10px;
        font-size: 0.75rem;
        white-space: nowrap;
    }

    .percent-bar-wrapper {
        width: 80px;
        height: 20px;
    }

    .percent-text {
        font-size: 0.6rem;
        padding: 0 4px;
    }

    .country-flag-img {
        width: 20px !important;
        height: 14px !important;
    }

    /* ===== Карточки монет ===== */
    .random-coin-card {
        flex-direction: column;
    }

    .coin-images {
        flex: none;
        justify-content: center;
    }

    .coins-grid {
        grid-template-columns: 1fr;
    }

    .coin-card-buttons {
        flex-direction: column;
    }

    .coin-card-buttons .btn,
    .coin-card-buttons .btn-info {
        width: 100%;
    }

    .hero h1 {
        font-size: 1.5rem;
    }

    .hero p {
        font-size: 0.9rem;
    }

    .search-header {
        flex-direction: column;
        align-items: stretch;
    }

    .search-form-inline {
        width: 100%;
    }

    .search-input {
        flex: 1;
        min-width: auto;
    }

    .coin-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .footer {
        padding: 15px 0;
        margin-top: 30px;
    }

    .footer-content {
        font-size: 0.7rem;
    }
}

/* ===== Очень маленькие экраны ===== */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stats-table {
        min-width: 450px;
    }

    .percent-bar-wrapper {
        width: 60px;
    }
}

/* Десктоп — бургер скрыт */
@media (min-width: 861px) {
    .menu-toggle {
        display: none;
    }
}

/* ===== Анимации ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.coin-card {
    animation: slideUp 0.3s ease;
}

@media (max-width: 860px) {
    /* Обрезаем всё, что вылезает вбок */
    html, body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }

    /* Меню — не шире экрана, без переноса */
    .nav-links {
        flex-wrap: nowrap !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }

    /* Контейнер меню */
    .nav-container {
        max-width: 100vw !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }

    /* Пункты меню — строго по ширине */
    .nav-links > a,
    .nav-links > span,
    .nav-links .dropdown-btn {
        max-width: 100% !important;
        box-sizing: border-box !important;
        word-break: break-word !important;
        overflow-wrap: anywhere !important;
    }

    /* Дропдаун — не шире родителя */
    .collections-dropdown,
    .collections-dropdown .dropdown-content {
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }

    /* Ссылки внутри дропдауна — не тянут ширину */
    .collections-dropdown .dropdown-content a {
        max-width: 100% !important;
        box-sizing: border-box !important;
        word-break: break-word !important;
        overflow-wrap: anywhere !important;
        white-space: normal !important;
    }
}

@media (max-width: 860px) {
    .navbar,
    .nav-container {
        overflow: visible !important;
    }
}

/* ============================================================
   ФИКС: длинные числа в статистике не растягивают страницу
   ============================================================ */

/* Глобально — контейнер не шире экрана */
.container {
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

@media (max-width: 860px) {
    .container {
        width: 100% !important;
        max-width: 100% !important;
        padding: 12px !important;
        overflow-x: hidden !important;
    }

    .statistics {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
        padding: 12px !important;
    }

    /* ГЛАВНОЕ: сетка сжимается */
    .stats-grid {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Карточка не может быть шире ячейки */
    .stat-item {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        padding: 12px 8px !important;
        overflow: hidden !important;   /* ← обрезает всё, что вылезает */
    }

    /* Число сжимается и переносится */
    .stat-number {
        font-size: 1.2rem !important;
        width: 100% !important;
        max-width: 100% !important;
        word-break: break-all !important;      /* ← для цифр без пробелов */
        overflow-wrap: anywhere !important;
        hyphens: auto !important;
        line-height: 1.2 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    .stat-label {
        font-size: 0.75rem !important;
        width: 100% !important;
        max-width: 100% !important;
        word-break: break-word !important;
        overflow-wrap: anywhere !important;
    }

    /* Заголовки */
    .statistics h1,
    .stats-section h2,
    .stats-actions,
    .additional-info,
    .stats-section {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow-wrap: anywhere !important;
        word-break: break-word !important;
    }
}

/* ============================================================
   СТРАНЫ НА МОБИЛЬНОМ — без горизонтальной прокрутки + кликабельность
   ============================================================ */
@media (max-width: 860px) {

    /* Убираем скролл-обёртку */
    .stats-section .table-wrapper {
        overflow-x: visible !important;
        box-shadow: none !important;
        border-radius: 0 !important;
    }

    /* Таблицу превращаем в список */
    .stats-table.simple-table {
        width: 100% !important;
        min-width: 0 !important;
        display: block !important;
    }

    .stats-table.simple-table thead {
        display: none !important;
    }

    .stats-table.simple-table tbody {
        display: block !important;
        width: 100% !important;
    }

    /* Строка = карточка, вся кликабельна */
    .stats-table.simple-table tr {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        width: 100% !important;
        padding: 8px 10px !important;
        margin-bottom: 4px !important;
        background: #f8f9fa !important;
        border-radius: 8px !important;
        border: 1px solid #eef0f3 !important;
        box-sizing: border-box !important;
        gap: 8px !important;

        /* Кликабельность */
        cursor: pointer !important;
        -webkit-tap-highlight-color: rgba(52, 152, 219, 0.15) !important;
        transition: background-color 0.15s ease, transform 0.1s ease !important;
        user-select: none !important;
    }

    /* Тап на карточку — визуальная реакция */
    .stats-table.simple-table tr:active {
        background-color: #e3f2fd !important;
        transform: scale(0.99) !important;
    }

    .stats-table.simple-table tr.clickable-row:active {
        background-color: #d6ebfb !important;
    }

    .stats-table.simple-table td {
        display: block !important;
        padding: 0 !important;
        border: none !important;
        width: auto !important;
        white-space: normal !important;
        min-width: 0 !important;

        /* Чтобы тап на td всплывал на tr и обрабатывался как клик */
        pointer-events: none !important;
    }

    /* Но ссылки внутри (если будут) — снова кликабельны */
    .stats-table.simple-table td a {
        pointer-events: auto !important;
    }

    .stats-table.simple-table td:empty {
        display: none !important;
    }

    /* Левая часть — флаг + название */
    .stats-table.simple-table td.country-cell {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        flex: 1 1 auto !important;
        min-width: 0 !important;
        overflow: hidden !important;
    }

    .stats-table.simple-table td.country-cell .country-name {
        font-size: 0.9rem !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        min-width: 0 !important;
        flex: 1 1 auto !important;
    }

    .stats-table.simple-table td.country-cell .country-flag-img {
        width: 26px !important;
        height: 18px !important;
        flex-shrink: 0 !important;
    }

    .stats-table.simple-table td.country-cell .country-flag-placeholder {
        width: 26px !important;
        font-size: 16px !important;
        flex-shrink: 0 !important;
    }

    /* Правая часть — количество */
    .stats-table.simple-table td.count-cell.numeric {
        flex: 0 0 auto !important;
        text-align: right !important;
    }

    .stats-table.simple-table td.count-cell.numeric .count-badge {
        min-width: 36px !important;
        padding: 3px 10px !important;
        font-size: 0.8rem !important;
    }
}

/* ============================================================
   КАТЕГОРИИ НА МОБИЛЬНОМ — карточки, без скролла
   ============================================================ */
@media (max-width: 860px) {

    /* Убираем скролл-обёртку */
    .stats-section .table-wrapper {
        overflow-x: visible !important;
        box-shadow: none !important;
        border-radius: 0 !important;
    }

    /* Таблица категорий — превращаем в карточки */
    .stats-table:not(.simple-table) {
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
    }

    .stats-table:not(.simple-table) thead {
        display: none !important;
    }

    .stats-table:not(.simple-table) tbody {
        display: block !important;
        width: 100% !important;
    }

    /* Карточка категории */
    .stats-table:not(.simple-table) tr {
        display: grid !important;
        grid-template-columns: 1fr auto !important;
        grid-template-areas:
            "name  count"
            "percent percent"
            "price price" !important;
        gap: 8px 12px !important;
        width: 100% !important;
        padding: 12px !important;
        margin-bottom: 10px !important;
        background: #fff !important;
        border-radius: 10px !important;
        border: 1px solid #eef0f3 !important;
        box-shadow: 0 2px 6px rgba(0,0,0,0.05) !important;
        box-sizing: border-box !important;

        cursor: pointer !important;
        -webkit-tap-highlight-color: rgba(52, 152, 219, 0.15) !important;
        transition: background-color 0.15s ease, transform 0.1s ease !important;
    }

    .stats-table:not(.simple-table) tr:active {
        background-color: #e3f2fd !important;
        transform: scale(0.99) !important;
    }

    /* Ячейки */
    .stats-table:not(.simple-table) td {
        display: block !important;
        padding: 0 !important;
        border: none !important;
        min-width: 0 !important;
        pointer-events: none !important;
    }

    /* Категория — заголовок карточки */
    .stats-table:not(.simple-table) td.category-cell {
        grid-area: name !important;
        font-weight: 600 !important;
        min-width: 0 !important;
    }

    .stats-table:not(.simple-table) td.category-cell .category-name {
        display: inline-block !important;
        padding: 4px 10px !important;
        background: rgba(102, 126, 234, 0.12) !important;
        border-radius: 16px !important;
        font-size: 0.9rem !important;
        word-break: break-word !important;
        overflow-wrap: anywhere !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Количество — справа сверху */
    .stats-table:not(.simple-table) td.count-cell {
        grid-area: count !important;
        text-align: right !important;
        align-self: start !important;
    }

    .stats-table:not(.simple-table) td.count-cell .count-badge {
        background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%) !important;
        color: #fff !important;
        padding: 4px 12px !important;
        border-radius: 20px !important;
        font-size: 0.85rem !important;
        font-weight: 600 !important;
    }

    /* Прогресс-бар — на всю ширину */
    .stats-table:not(.simple-table) td.percent-cell {
        grid-area: percent !important;
        width: 100% !important;
    }

    .stats-table:not(.simple-table) .percent-bar-wrapper {
        width: 100% !important;
        min-width: 0 !important;
        height: 22px !important;
        position: relative !important;
    }

    .stats-table:not(.simple-table) .percent-bar {
        height: 100% !important;
    }

    .stats-table:not(.simple-table) .percent-text {
        color: #fff !important;
        text-shadow: 0 1px 2px rgba(0,0,0,0.4) !important;
        padding: 0 10px !important;
        font-size: 0.8rem !important;
        font-weight: 600 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        height: 100% !important;
        position: absolute !important;
        left: 0 !important;
        right: 0 !important;
        top: 0 !important;
    }

    /* Стоимость — снизу */
    .stats-table:not(.simple-table) td.price-cell {
        grid-area: price !important;
        text-align: right !important;
        font-weight: 700 !important;
        border-top: 1px solid #f0f2f5 !important;
        padding-top: 8px !important;
    }

    .stats-table:not(.simple-table) td.price-cell .price-value {
        color: #27ae60 !important;
        font-weight: 700 !important;
        font-size: 1rem !important;
    }

    .stats-table:not(.simple-table) td.price-cell .currency {
        color: #7f8c8d !important;
        font-size: 0.85rem !important;
        margin-left: 2px !important;
    }
}