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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f5;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

header h1 {
    margin-bottom: 20px;
    font-size: 2em;
}

.header-stats {
    display: flex;
    gap: 30px;
    flex-wrap: nowrap;
    overflow-x: auto;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat-label {
    font-size: 0.9em;
    opacity: 0.9;
}

.stat-value {
    font-size: 1.5em;
    font-weight: bold;
}

.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    flex-wrap: nowrap;
    overflow-x: auto;
}

.tab-btn {
    padding: 6px 10px;
    border: none;
    background: white;
    cursor: pointer;
    border-radius: 8px;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.tab-btn:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
}

.tab-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.tab-content {
    display: none;
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.tab-content.active {
    display: block;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 1.5em;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

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

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.filters {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    align-items: center;
}

.filters select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

.filters label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.data-table th {
    background: #f8f9fa;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #dee2e6;
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid #dee2e6;
}

.data-table tr:hover {
    background: #f8f9fa;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
}

.status-available {
    background: #d4edda;
    color: #155724;
}

.status-unavailable {
    background: #f8d7da;
    color: #721c24;
}

.status-active {
    background: #d1ecf1;
    color: #0c5460;
}

.status-inactive {
    background: #f8d7da;
    color: #721c24;
}

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

.modal-content {
    background: white;
    margin: 50px auto;
    padding: 30px;
    border-radius: 10px;
    max-width: 500px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

.modal-content h2 {
    margin-bottom: 20px;
}

.modal-content form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-content label {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.modal-content input,
.modal-content select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header-stats {
        flex-direction: column;
        gap: 15px;
    }
    
    .data-table {
        font-size: 0.9em;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px;
    }
}

/* Фикс таблицы пользователей */
#tab-users .data-table {
    table-layout: fixed;
    width: 100%;
}

#tab-users .data-table th:nth-child(1) { width: 50px; }
#tab-users .data-table th:nth-child(2) { width: 160px; }
#tab-users .data-table th:nth-child(3) { width: 120px; }
#tab-users .data-table th:nth-child(4) { width: auto; }
#tab-users .data-table th:nth-child(5) { width: 130px; }
#tab-users .data-table th:nth-child(6) { width: 130px; }
#tab-users .data-table th:nth-child(7) { width: 260px; }

#tab-users .data-table td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#tab-users .data-table td:last-child {
    white-space: nowrap;
    text-align: center;
    overflow: visible;
}

/* Фикс таблицы пользователей */
#tab-users .data-table {
    table-layout: fixed !important;
    width: 100% !important;
}

#tab-users .data-table th:nth-child(1),
#tab-users .data-table td:nth-child(1) { width: 45px !important; }

#tab-users .data-table th:nth-child(2),
#tab-users .data-table td:nth-child(2) { width: 160px !important; }

#tab-users .data-table th:nth-child(3),
#tab-users .data-table td:nth-child(3) { width: 110px !important; }

#tab-users .data-table th:nth-child(4),
#tab-users .data-table td:nth-child(4) { width: auto !important; }

#tab-users .data-table th:nth-child(5),
#tab-users .data-table td:nth-child(5) { width: 130px !important; }

#tab-users .data-table th:nth-child(6),
#tab-users .data-table td:nth-child(6) { width: 130px !important; }

#tab-users .data-table th:nth-child(7),
#tab-users .data-table td:nth-child(7) { width: 260px !important; text-align: center !important; overflow: visible !important; }

#tab-users .data-table td {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

/* =========================================================== */
/* МОБИЛЬНАЯ ОПТИМИЗАЦИЯ (добавлено 2026-04-29)                 */
/* Add-only — десктоп >768px не затрагивается                   */
/* =========================================================== */
@media (max-width: 768px) {
    /* Базовое */
    html, body { overflow-x: hidden !important; -webkit-text-size-adjust: 100%; }
    body { font-size: 14px; }
    .container { padding: 8px !important; max-width: 100% !important; }

    /* Header */
    header { padding: 16px !important; margin-bottom: 12px !important; border-radius: 8px !important; }
    header h1 { font-size: 1.3em !important; margin-bottom: 12px !important; }
    .header-stats {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    .stat-item { gap: 2px !important; }
    .stat-label { font-size: 0.75em !important; }
    .stat-value { font-size: 1.05em !important; }

    /* Вкладки — горизонтальный скролл вместо переноса */
    .tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        gap: 6px !important;
        padding-bottom: 4px !important;
        margin-bottom: 12px !important;
    }
    .tabs::-webkit-scrollbar { height: 4px; }
    .tab-btn {
        padding: 8px 14px !important;
        font-size: 0.85em !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }

    /* Контент таба */
    .tab-content {
        padding: 12px !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        border-radius: 8px !important;
    }

    /* Шапка секции */
    .section-header {
        flex-wrap: wrap !important;
        gap: 10px !important;
        margin-bottom: 12px !important;
        align-items: flex-start !important;
    }
    .section-header h2 { font-size: 1.15em !important; }

    /* Кнопки */
    .btn { padding: 8px 14px !important; font-size: 0.9em !important; }

    /* Фильтры — столбиком */
    .filters {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
    }
    .filters label, .filters select, .filters input { width: 100% !important; }

    /* Таблицы — горизонтальный скролл, мельче шрифт */
    .data-table { font-size: 0.8em !important; min-width: 600px; }
    .data-table th, .data-table td { padding: 6px 8px !important; }

    /* Сброс fixed-layout таблицы пользователей (фиксированные ширины ломают узкий экран) */
    #tab-users .data-table { table-layout: auto !important; }
    #tab-users .data-table th, #tab-users .data-table td {
        width: auto !important;
        white-space: nowrap !important;
    }

    /* Модалки — на 95vw */
    .modal-content {
        margin: 10px auto !important;
        padding: 16px !important;
        max-width: 95vw !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
        border-radius: 10px !important;
    }
    /* Модалки с inline-стилем (расширенные до 1100px и т.п.) тоже зажимаем */
    .modal > div, .modal > div > div { max-width: 95vw !important; }

    /* Login overlay — компактнее */
    #login-overlay > div {
        padding: 28px 20px !important;
        max-width: 92vw !important;
    }

    /* Инпуты в формах — крупнее тапаются */
    input, select, textarea, button { font-size: 16px !important; }
}
