/* ========== ПЛАНШЕТЫ (до 1024px) ========== */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px;
    }
    
    .stats-grid-small {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .funnel {
        flex-direction: column;
        gap: 16px;
    }
    
    .funnel-arrow {
        transform: rotate(90deg);
    }
}

/* ========== ТЕЛЕФОНЫ (до 768px) ========== */
@media (max-width: 768px) {
    /* Бургер-кнопка */
    .burger-btn {
        display: flex !important;
        position: fixed;
        top: 16px;
        left: 16px;
        z-index: 1001;
        width: 44px;
        height: 44px;
        border-radius: 12px;
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        color: var(--text-primary);
        font-size: 24px;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.2s;
        box-shadow: var(--card-shadow);
    }
    
    /* Сайдбар — скрыт по умолчанию, выезжает при открытии */
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        width: 280px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: none;
        background: var(--sidebar-bg);
        border-right: 1px solid var(--border);
    }
    
    /* Открытый сайдбар — ПОЛНОСТЬЮ ВИДЕН со всеми текстами */
    .sidebar.open {
        left: 0;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.2);
    }
    
    /* В открытом сайдбаре ВСЕ ЭЛЕМЕНТЫ видны */
    .sidebar.open .sidebar-header p,
    .sidebar.open .nav-btn span:not(.nav-icon),
    .sidebar.open .sidebar-footer .theme-toggle span,
    .sidebar.open .logout-btn span {
        display: inline-block !important;
    }
    
    .sidebar.open .nav-btn {
        justify-content: flex-start;
        padding: 12px 16px;
        gap: 12px;
    }
    
    .sidebar.open .nav-icon {
        font-size: 18px;
        margin: 0;
    }
    
    .sidebar.open .theme-toggle {
        justify-content: space-between;
        padding: 8px 12px;
    }
    
    .sidebar.open .logout-btn {
        font-size: 14px;
        padding: 10px;
    }
    
    .sidebar.open .logout-btn i {
        margin-right: 8px;
        font-size: 14px;
    }
    
    /* Основной контент */
    .main-content {
        margin-left: 0;
        padding: 70px 16px 20px 16px;
    }
    
    /* Карточки */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }
    
    .stat-card {
        padding: 16px;
    }
    
    .stat-card .value {
        font-size: 28px;
    }
    
    /* Карточка входа */
    .login-card {
        width: 90%;
        max-width: 360px;
        padding: 32px 24px;
        margin: 16px;
    }
    
    /* Заголовки */
    h1 {
        font-size: 20px !important;
        margin-bottom: 16px !important;
    }
    
    .card {
        padding: 16px;
        border-radius: 16px;
    }
    
    .card h2 {
        font-size: 16px;
        margin-bottom: 12px;
    }
    
    /* Маленькие карточки статистики */
    .stats-grid-small {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .stat-card-small {
        padding: 12px;
    }
    
    /* Воронка на мобильных */
    .funnel {
        flex-direction: column;
        gap: 8px;
    }
    
    .funnel-arrow {
        transform: rotate(90deg);
    }
    
    .funnel-step {
        width: 100%;
        padding: 16px;
    }
    
    .funnel-value {
        font-size: 24px;
    }
    
    /* Адаптивные таблицы */
    .responsive-table thead {
        display: none;
    }
    
    .responsive-table tbody tr {
        display: block;
        margin-bottom: 16px;
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: 12px;
    }
    
    .responsive-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border: none;
        padding: 8px 0;
    }
    
    .responsive-table tbody td:before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        margin-right: 16px;
    }
}

/* ========== ОЧЕНЬ МАЛЕНЬКИЕ ТЕЛЕФОНЫ (до 480px) ========== */
@media (max-width: 480px) {
    .stats-grid-small {
        grid-template-columns: 1fr;
    }
    
    .main-content {
        padding: 70px 12px 20px 12px;
    }
    
    .card h2 {
        font-size: 15px;
    }
    
    .funnel-step {
        min-width: auto;
        width: 100%;
    }
    
    /* Маленькие карточки в列 */
    .stat-card-small {
        display: flex;
        align-items: center;
        justify-content: space-between;
        text-align: left;
        padding: 12px;
    }
    
    .stat-card-small i {
        margin-bottom: 0;
        font-size: 20px;
    }
    
    .stat-card-small span {
        flex: 1;
        margin-left: 12px;
        margin-bottom: 0;
    }
    
    .stat-card-small strong {
        font-size: 18px;
    }
}

/* ========== ТАЧ-УСТРОЙСТВА ========== */
@media (hover: none) {
    .nav-btn:active,
    .logout-btn:active,
    button:active {
        opacity: 0.7;
    }
    
    .stat-card {
        cursor: pointer;
    }
}

/* ========== ОВЕРЛЕЙ (затемнение) ========== */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ========== ДЕСКТОПНАЯ ВЕРСИЯ ========== */
@media (min-width: 769px) {
    .burger-btn {
        display: none !important;
    }
    
    .overlay {
        display: none;
    }
    
    .sidebar {
        left: 0 !important;
        width: 280px;
    }
    
    .main-content {
        margin-left: 280px;
        padding: 32px;
    }
}

/* Стили для фильтров */
#eventSearchInput:focus,
#eventTypeFilter:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59,130,246,0.2);
}

#resetEventFilters:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Адаптив для фильтров */
@media (max-width: 768px) {
    #eventSearchInput,
    #eventTypeFilter,
    #resetEventFilters {
        width: 100%;
    }
}