:root {
    --bg-primary: #0f0f23;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16213e;
    --text-primary: #e4e4e7;
    --text-secondary: #a1a1aa;
    --accent-blue: #4D8BFF;
    --accent-blue-glow: rgba(77, 139, 255, 0.4);
    --accent-green: #10b981;
    --accent-purple: #8b5cf6;
    --accent-orange: #f59e0b;
    --accent-red: #ef4444;
    --accent-teal: #14b8a6;
    --border-color: #27272a;
    --hover-bg: #1e1e2e;
    --shadow: rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%; /* Предотвращает автоматическое изменение размера текста на iOS */
}

body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #050B18; /* Основной фон из гайда */
    color: var(--text-primary);
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
    min-height: -webkit-fill-available; /* Для мобильных браузеров */
    position: relative;
    -webkit-tap-highlight-color: transparent; /* Убираем подсветку при тапе на мобильных */
    touch-action: manipulation; /* Улучшает отзывчивость на touch */
}

/* Контейнер фона */
.bg-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

/* Базовые стили для blob форм */
.blob {
    position: absolute;
    filter: blur(80px);
    opacity: 0.3;
}

/* Blob 1 - Верхний левый */
.blob-1 {
    top: -10%;
    left: -10%;
    width: 70%;
    height: 80%;
    background: #1e40af;
    /* Органическая форма через border-radius */
    border-radius: 43% 57% 70% 30% / 30% 45% 55% 70%;
    transform: rotate(-20deg);
}

/* Blob 2 - Нижний правый */
.blob-2 {
    bottom: -15%;
    right: -5%;
    width: 60%;
    height: 70%;
    background: #312e81;
    border-radius: 70% 30% 46% 54% / 30% 29% 71% 70%;
    transform: rotate(15deg);
}

/* Blob 3 - Средняя "жила" света */
.blob-3 {
    top: 30%;
    left: 10%;
    width: 110%;
    height: 150px;
    background: #3b82f6;
    border-radius: 100% 0% 100% 0% / 50% 50% 50% 50%;
    transform: rotate(-10deg);
    filter: blur(100px);
}

/* Эффект грануляции */
.grain-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    filter: url(#noiseFilter);
    opacity: 0.3;
    pointer-events: none;
    mix-blend-mode: screen;
}
/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 12px;
    left: 12px;
    right: 12px;
    background: rgba(26, 26, 26, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    border-radius: 100px;
    max-width: calc(100vw - 24px);
    margin: 0 auto;
}

.nav-indicator {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: calc(25%);
    height: calc(100% - 16px);
    background: rgba(77, 139, 255, 0.15);
    border-radius: 50px;
    z-index: -1;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    will-change: left, width;
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 11px;
    cursor: pointer;
    padding: 8px 12px;
    transition: all 0.2s ease;
    flex: 1;
    position: relative;
    height: 100%;
    text-decoration: none;
}

.nav-btn.active {
    color: var(--accent-blue);
}

.nav-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.nav-label {
    font-size: 11px;
    font-weight: 500;
    line-height: 1;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: -webkit-fill-available; /* Для мобильных браузеров */
    position: relative;
    z-index: 10; /* Поверх фона */
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    padding-top: env(safe-area-inset-top, 0px); /* Безопасная зона сверху для iPhone */
}

/* Overlay до проверки initData (загрузка / доступ запрещён) */
.auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    padding: 2rem;
}
.auth-overlay-inner {
    text-align: center;
    max-width: 420px;
}
.auth-loading {
    font-size: 1.125rem;
    color: var(--text-secondary);
}
.auth-denied .auth-denied-icon { font-size: 4rem; margin-bottom: 1rem; }
.auth-denied h2 { font-size: 1.75rem; margin-bottom: 1rem; color: var(--text-primary); }
.auth-denied p { color: var(--text-secondary); margin-bottom: 0.5rem; }
.auth-denied-hint { font-size: 0.875rem; color: var(--text-muted); margin-top: 1rem; }
.auth-no-tg p { color: var(--text-secondary); font-size: 1rem; }

.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 600;
}

.header-actions {
    display: none; /* Скрываем timestamp на всех вкладках */
}

.timestamp {
    display: none; /* Скрываем timestamp */
}

.content {
    padding: 2rem;
    flex: 1;
}

/* SPA: вкладки-виды */
.view {
    display: none;
    animation: viewFadeIn 0.3s ease;
}

.view.active {
    display: block;
}

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

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--shadow);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.stat-icon.blue { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.stat-icon.green { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
.stat-icon.purple { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }
.stat-icon.orange { background: linear-gradient(135deg, #fa709a 0%, #fee140 100%); }
.stat-icon.red { background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%); }
.stat-icon.teal { background: linear-gradient(135deg, #30cfd0 0%, #330867 100%); }

.stat-info {
    flex: 1;
}

.stat-info h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.stat-change {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.stat-change.positive {
    color: var(--accent-green);
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
    max-width: 800px;
}

.chart-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    min-height: 280px;
}

.chart-card canvas {
    max-height: 220px;
    display: block;
}

.chart-card h3 {
    font-size: 1.125rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.chart-card h3 i {
    color: var(--accent-blue);
}

/* Tables */
.tables-grid {
    display: grid;
    gap: 1.5rem;
}

.table-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.table-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.table-header h3 {
    font-size: 1.125rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.table-header h3 i {
    color: var(--accent-blue);
}

.table-search {
    position: relative;
    display: flex;
    align-items: center;
}

.table-search input {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem 2.5rem 0.5rem 1rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    width: 250px;
    transition: border-color 0.2s;
}

.table-search input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.table-search i {
    position: absolute;
    right: 0.75rem;
    color: var(--text-secondary);
}

.table-container {
    overflow-x: visible;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    box-sizing: border-box;
}

thead {
    background: var(--bg-tertiary);
}

th {
    padding: 1rem;
    text-align: left;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.875rem;
}

tbody tr {
    transition: background 0.2s;
}

tbody tr:hover {
    background: var(--hover-bg);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.badge.success {
    background: rgba(16, 185, 129, 0.2);
    color: var(--accent-green);
}

.badge.warning {
    background: rgba(245, 158, 11, 0.2);
    color: var(--accent-orange);
}

/* Buttons */
.btn-export, .btn-link {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-export {
    background: var(--accent-blue);
    color: white;
}

.btn-export:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.btn-link {
    background: transparent;
    color: var(--accent-blue);
    padding: 0.25rem 0.5rem;
}

.btn-link:hover {
    background: rgba(59, 130, 246, 0.1);
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-stats {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.header-stat {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.header-stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.header-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.header-stat-value.success {
    color: var(--accent-green);
}

.header-stat-value.warning {
    color: var(--accent-orange);
}

/* Filters */
.table-filters {
    display: flex;
    gap: 1rem;
}

.table-filters select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

.table-filters select:focus {
    outline: none;
    border-color: var(--accent-blue);
}

/* Responsive */
@media (max-width: 768px) {
    /* Header */
    .header {
        padding: 1rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .header h1 {
        font-size: 1.25rem;
        line-height: 1.3;
        width: 100%;
    }

    .header-actions {
        display: none; /* Скрываем timestamp */
    }

    /* Content */
    .content {
        padding: 1rem;
        overflow-x: hidden; /* Предотвращаем горизонтальную прокрутку */
        max-width: 100vw;
        box-sizing: border-box;
    }

    /* Stats Grid */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .stat-card {
        padding: 1rem;
        gap: 1rem;
    }

    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 1.25rem;
        flex-shrink: 0;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .stat-info h3 {
        font-size: 0.8125rem;
    }

    .stat-change {
        font-size: 0.6875rem;
    }

    /* Charts */
    .charts-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        max-width: 100%;
    }

    .chart-card {
        padding: 1rem;
        min-height: 240px;
    }

    .chart-card h3 {
        font-size: 1rem;
        margin-bottom: 1rem;
    }

    .chart-card canvas {
        max-height: 180px;
    }

    /* Tables */
    .table-card {
        border-radius: 8px;
        width: 100%;
        max-width: 100%;
        margin: 0;
        box-sizing: border-box;
    }

    .table-header {
        padding: 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .table-header h3 {
        font-size: 0.9375rem;
        line-height: 1.3;
        word-break: break-word;
        width: 100%;
    }
    
    .table-header h3 i {
        font-size: 0.875rem;
        flex-shrink: 0;
    }

    .table-search {
        width: 100%;
        position: relative;
    }

    .table-search input {
        width: 100%;
        font-size: 0.875rem;
        padding: 0.625rem 2.5rem 0.625rem 0.875rem;
        box-sizing: border-box;
    }

    .table-search i {
        right: 0.75rem;
        font-size: 0.875rem;
        pointer-events: none;
    }

    .table-container {
        overflow-x: visible;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        margin: 0;
        padding: 0;
    }
    
    .table-card {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow: hidden;
        margin: 0;
    }
    
    table {
        width: 100% !important;
        max-width: 100% !important;
        table-layout: fixed !important;
    }

    table {
        font-size: 0.8125rem;
        width: 100%;
        table-layout: fixed; /* Фиксированная ширина колонок */
    }

    th, td {
        padding: 0.625rem 0.375rem;
        font-size: 0.8125rem;
        word-wrap: break-word;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    th {
        font-size: 0.75rem;
    }

    /* Адаптация колонок для разных таблиц */
    #leadsTable th:nth-child(1),
    #leadsTable td:nth-child(1) { width: 22%; font-size: 0.75rem; } /* User ID */
    #leadsTable th:nth-child(2),
    #leadsTable td:nth-child(2) { width: 28%; } /* Username */
    #leadsTable th:nth-child(3),
    #leadsTable td:nth-child(3) { width: 25%; font-size: 0.75rem; } /* Дата */
    #leadsTable th:nth-child(4),
    #leadsTable td:nth-child(4) { width: 25%; } /* Действия */

    #usersTable th:nth-child(1),
    #usersTable td:nth-child(1) { width: 20%; } /* User ID */
    #usersTable th:nth-child(2),
    #usersTable td:nth-child(2) { width: 25%; } /* Username */
    #usersTable th:nth-child(3),
    #usersTable td:nth-child(3) { width: 20%; } /* Имя */
    #usersTable th:nth-child(4),
    #usersTable td:nth-child(4) { width: 20%; } /* Дата */
    #usersTable th:nth-child(5),
    #usersTable td:nth-child(5) { width: 15%; } /* UTM */

    #paymentsTable th:nth-child(1),
    #paymentsTable td:nth-child(1) { width: 10%; } /* ID */
    #paymentsTable th:nth-child(2),
    #paymentsTable td:nth-child(2) { width: 20%; } /* User ID */
    #paymentsTable th:nth-child(3),
    #paymentsTable td:nth-child(3) { width: 25%; } /* Username */
    #paymentsTable th:nth-child(4),
    #paymentsTable td:nth-child(4) { width: 20%; } /* Статус */
    #paymentsTable th:nth-child(5),
    #paymentsTable td:nth-child(5) { width: 25%; } /* Дата */

    #dashboardUsersTable th:nth-child(1),
    #dashboardUsersTable td:nth-child(1) { width: 15%; } /* ID */
    #dashboardUsersTable th:nth-child(2),
    #dashboardUsersTable td:nth-child(2) { width: 25%; } /* Username */
    #dashboardUsersTable th:nth-child(3),
    #dashboardUsersTable td:nth-child(3) { width: 20%; } /* Имя */
    #dashboardUsersTable th:nth-child(4),
    #dashboardUsersTable td:nth-child(4) { width: 25%; } /* Дата */
    #dashboardUsersTable th:nth-child(5),
    #dashboardUsersTable td:nth-child(5) { width: 15%; } /* UTM */

    /* Кнопки действий в таблицах */
    .btn-link {
        white-space: nowrap;
        display: inline-flex;
        align-items: center;
        gap: 0.25rem;
        font-size: 0.6875rem;
        padding: 0.375rem 0.5rem;
        min-width: fit-content;
    }

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

    /* Скрываем текст в кнопках на мобильных, оставляем только иконку */
    @media (max-width: 768px) {
        .btn-link {
            padding: 0.5rem;
            min-width: 36px;
            width: 36px;
            height: 36px;
            justify-content: center;
            font-size: 0;
            line-height: 0;
        }
        
        .btn-link i {
            font-size: 0.875rem;
            margin: 0;
            display: inline-block;
        }
        
        /* Скрываем текст после иконки */
        .btn-link::after {
            content: '';
            display: none;
        }
        
        /* Альтернативный способ - скрываем все текстовые узлы */
        .btn-link {
            color: transparent;
        }
        
        .btn-link i {
            color: var(--accent-blue);
        }
    }

    /* Page Header */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }

    .header-stats {
        gap: 1.5rem;
        width: 100%;
    }

    .header-stat-value {
        font-size: 1.25rem;
    }

    .header-stat-label {
        font-size: 0.8125rem;
    }

    .btn-export {
        width: 100%;
        justify-content: center;
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    .btn-link {
        padding: 0.375rem 0.5rem;
        font-size: 0.8125rem;
    }

    /* Filters */
    .table-filters {
        width: 100%;
    }

    .table-filters select {
        width: 100%;
        font-size: 0.875rem;
        padding: 0.625rem 0.875rem;
    }

    /* Поиск в таблицах */
    .table-search {
        position: relative;
    }

    .table-search i {
        font-size: 0.875rem;
    }

    /* Navigation */
    .bottom-nav {
        bottom: 8px;
        left: 8px;
        right: 8px;
        padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
        border-radius: 80px;
        max-width: calc(100vw - 16px);
    }

    .nav-icon {
        width: 20px;
        height: 20px;
        font-size: 18px;
    }

    .nav-label {
        font-size: 10px;
    }

    .nav-btn {
        padding: 6px 8px;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    /* Header */
    .header h1 {
        font-size: 1.125rem;
    }

    .header-actions {
        display: none; /* Скрываем timestamp */
    }

    /* Content */
    .content {
        padding: 0.75rem;
        overflow-x: hidden;
        max-width: 100vw;
        box-sizing: border-box;
    }

    /* Stats */
    .stat-card {
        padding: 0.875rem;
        gap: 0.75rem;
    }

    .stat-icon {
        width: 45px;
        height: 45px;
        font-size: 1.125rem;
    }

    .stat-value {
        font-size: 1.375rem;
    }

    .stat-info h3 {
        font-size: 0.75rem;
        margin-bottom: 0.375rem;
    }

    .stat-change {
        font-size: 0.625rem;
    }

    /* Charts */
    .chart-card {
        padding: 0.875rem;
        min-height: 220px;
    }

    .chart-card h3 {
        font-size: 0.9375rem;
        margin-bottom: 0.875rem;
    }

    .chart-card canvas {
        max-height: 160px;
    }

    /* Tables */
    .table-header {
        padding: 0.875rem;
    }

    .table-header h3 {
        font-size: 0.875rem;
        line-height: 1.3;
    }
    
    .table-header h3 i {
        font-size: 0.8125rem;
    }

    table {
        font-size: 0.75rem;
        width: 100%;
        table-layout: fixed;
    }

    .table-container {
        margin: 0;
        padding: 0;
        overflow-x: visible;
    }

    th, td {
        padding: 0.5rem 0.25rem;
        font-size: 0.75rem;
        word-wrap: break-word;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    th {
        font-size: 0.6875rem;
    }

    /* Ещё более компактные колонки на маленьких экранах */
    #leadsTable th:nth-child(1),
    #leadsTable td:nth-child(1) { width: 20%; font-size: 0.6875rem; }
    #leadsTable th:nth-child(2),
    #leadsTable td:nth-child(2) { width: 26%; }
    #leadsTable th:nth-child(3),
    #leadsTable td:nth-child(3) { width: 30%; font-size: 0.6875rem; }
    #leadsTable th:nth-child(4),
    #leadsTable td:nth-child(4) { width: 24%; }

    #usersTable th:nth-child(1),
    #usersTable td:nth-child(1) { width: 18%; font-size: 0.6875rem; }
    #usersTable th:nth-child(2),
    #usersTable td:nth-child(2) { width: 25%; }
    #usersTable th:nth-child(3),
    #usersTable td:nth-child(3) { width: 20%; }
    #usersTable th:nth-child(4),
    #usersTable td:nth-child(4) { width: 22%; font-size: 0.6875rem; }
    #usersTable th:nth-child(5),
    #usersTable td:nth-child(5) { width: 15%; font-size: 0.625rem; }

    #paymentsTable th:nth-child(1),
    #paymentsTable td:nth-child(1) { width: 8%; font-size: 0.6875rem; }
    #paymentsTable th:nth-child(2),
    #paymentsTable td:nth-child(2) { width: 18%; font-size: 0.6875rem; }
    #paymentsTable th:nth-child(3),
    #paymentsTable td:nth-child(3) { width: 25%; }
    #paymentsTable th:nth-child(4),
    #paymentsTable td:nth-child(4) { width: 22%; }
    #paymentsTable th:nth-child(5),
    #paymentsTable td:nth-child(5) { width: 27%; font-size: 0.6875rem; }

    #dashboardUsersTable th:nth-child(1),
    #dashboardUsersTable td:nth-child(1) { width: 15%; font-size: 0.6875rem; }
    #dashboardUsersTable th:nth-child(2),
    #dashboardUsersTable td:nth-child(2) { width: 25%; }
    #dashboardUsersTable th:nth-child(3),
    #dashboardUsersTable td:nth-child(3) { width: 20%; }
    #dashboardUsersTable th:nth-child(4),
    #dashboardUsersTable td:nth-child(4) { width: 25%; font-size: 0.6875rem; }
    #dashboardUsersTable th:nth-child(5),
    #dashboardUsersTable td:nth-child(5) { width: 15%; font-size: 0.625rem; }

    /* Кнопки действий на маленьких экранах - только иконка */
    .btn-link {
        padding: 0.375rem;
        font-size: 0;
        min-width: 32px;
        width: 32px;
        height: 32px;
        justify-content: center;
        border-radius: 6px;
        display: inline-flex;
        align-items: center;
        color: transparent;
        line-height: 0;
    }

    .btn-link i {
        font-size: 0.875rem;
        margin: 0;
        color: var(--accent-blue);
        display: inline-block;
    }

    /* Фильтры на маленьких экранах */
    .table-filters {
        width: 100%;
    }

    .table-filters select {
        width: 100%;
        font-size: 0.8125rem;
        padding: 0.5rem 0.75rem;
    }

    /* Page Header */
    .header-stats {
        gap: 1rem;
        flex-wrap: wrap;
    }

    .header-stat {
        min-width: calc(50% - 0.5rem);
    }

    .header-stat-value {
        font-size: 1.125rem;
    }

    .header-stat-label {
        font-size: 0.75rem;
    }

    /* Улучшения для кнопки экспорта */
    .btn-export {
        font-size: 0.8125rem;
        padding: 0.625rem 0.875rem;
    }

    .btn-export i {
        font-size: 0.875rem;
    }

    /* Navigation */
    .bottom-nav {
        bottom: 6px;
        left: 6px;
        right: 6px;
        padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
        max-width: calc(100vw - 12px);
    }

    .nav-icon {
        width: 18px;
        height: 18px;
        font-size: 16px;
    }

    .nav-label {
        font-size: 9px;
    }

    .nav-btn {
        padding: 5px 6px;
        gap: 3px;
    }

    /* Badges */
    .badge {
        font-size: 0.6875rem;
        padding: 0.2rem 0.5rem;
    }

    /* Улучшения для touch */
    .nav-btn,
    .btn-export,
    .btn-link {
        -webkit-tap-highlight-color: rgba(77, 139, 255, 0.2);
        touch-action: manipulation;
    }

    /* Улучшения для таблиц на touch устройствах */
    tbody tr {
        -webkit-tap-highlight-color: rgba(77, 139, 255, 0.1);
    }

    /* Компактные отступы для таблиц */
    .table-card {
        margin-bottom: 1rem;
    }

    /* Улучшения для всех вкладок */
    .view-checklist,
    .view-users,
    .view-payments {
        padding-top: 0;
    }

    /* Улучшенная читаемость для таблиц */
    tbody tr:hover {
        background: rgba(30, 30, 46, 0.5);
    }

    /* Компактные заголовки таблиц */
    .table-header h3 i {
        font-size: 0.875rem;
    }
}

    /* Landscape orientation на мобильных */
@media (max-width: 768px) and (orientation: landscape) {
    .header {
        padding: 0.75rem 1rem;
        justify-content: flex-start; /* Убираем space-between, так как нет timestamp */
    }

    .header h1 {
        font-size: 1.125rem;
    }

    .content {
        padding: 0.75rem;
    }

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

    .stat-card {
        padding: 0.75rem;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .chart-card {
        min-height: 200px;
    }

    .chart-card canvas {
        max-height: 140px;
    }

    /* Таблицы в landscape */
    .table-header {
        padding: 0.75rem;
    }

    .table-header h3 {
        font-size: 0.9375rem;
    }

    table {
        width: 100%;
        table-layout: fixed;
        font-size: 0.75rem;
    }

    th, td {
        padding: 0.5rem 0.375rem;
        font-size: 0.75rem;
    }

    /* Page header в landscape */
    .page-header {
        margin-bottom: 1rem;
    }

    .header-stats {
        gap: 1rem;
    }

    .header-stat-value {
        font-size: 1.125rem;
    }

    .bottom-nav {
        bottom: 6px;
        padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    }
}

/* Очень маленькие экраны в landscape */
@media (max-width: 480px) and (orientation: landscape) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .stat-card {
        padding: 0.625rem;
    }

    .stat-icon {
        width: 35px;
        height: 35px;
        font-size: 0.9375rem;
    }

    .stat-value {
        font-size: 1.125rem;
    }

    .chart-card {
        min-height: 180px;
    }

    /* Таблицы в landscape на маленьких экранах */
    table {
        min-width: 480px;
        font-size: 0.6875rem;
    }

    th, td {
        padding: 0.375rem 0.25rem;
        font-size: 0.6875rem;
    }

    .table-header {
        padding: 0.625rem;
    }

    .table-header h3 {
        font-size: 0.875rem;
    }

    .page-header {
        margin-bottom: 0.75rem;
    }

    .header-stats {
        gap: 0.75rem;
    }

    .header-stat-value {
        font-size: 1rem;
    }

    .header-stat-label {
        font-size: 0.6875rem;
    }

    /* Дополнительные улучшения для всех вкладок на маленьких экранах */
    .table-header h3 i {
        font-size: 0.8125rem;
    }

    /* Улучшенная прокрутка таблиц */
    .table-container {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }

    /* Компактные бейджи */
    .badge {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 120px;
        display: inline-block;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-color);
}
