* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    background: #f4f6f9;
}

/* Приложение — флекс-контейнер на всю высоту */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-height: 100vh;
}

/* ========== ХЕДЕР (фикс) ========== */
.header {
    background: white;
    border-bottom: 1px solid #e2e8f0;
    padding: 16px 28px;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    max-width: 1400px;
    margin: 0 auto;
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    height: 36px;
    width: auto;
}

.logo-text {
    height: 28px;
    width: auto;
}

.header-titles h1 {
    font-size: 22px;
    margin: 0;
    color: #1e2a3a;
}

.header-titles .subtitle {
    margin: 4px 0 0 0;
    font-size: 13px;
    color: #5c6f87;
}

@media (max-width: 768px) {
    .header-inner {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ========== ПАНЕЛЬ УПРАВЛЕНИЯ КОЛОНКАМИ ========== */
.columns-panel {
    background: #f8fafc;
    padding: 10px 20px;
    border-radius: 12px;
    margin-bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
    font-size: 13px;
    border: 1px solid #e2e8f0;
}

.columns-label {
    font-weight: 600;
    color: #1e293b;
    margin-right: 4px;
}

.column-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 12px;
    color: #334155;
    user-select: none;
}

.column-toggle input {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #3b82f6;
}

/* ========== СТРОКА ПОИСКА ========== */
.search-panel {
    margin-bottom: 16px;
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    border: 1px solid #cbd5e1;
    border-radius: 40px;
    background: white;
    transition: 0.2s;
    outline: none;
}

.search-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59,130,246,0.2);
}

.search-input::placeholder {
    color: #94a3b8;
}

/* ========== ПАНЕЛЬ ФИЛЬТРОВ ========== */
.filters-panel {
    background: white;
    border-bottom: 1px solid #e2e8f0;
    padding: 16px 28px;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 16px;
    max-width: 1400px;
    margin: 0 auto;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 120px;
}

.filter-group label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #4a5a72;
}

/* Полупрозрачные фильтры, если колонка отключена */
.filter-group.disabled-filter {
    opacity: 0.5;
    pointer-events: none;
}

.filter-group select,
.filter-group input {
    padding: 7px 10px;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    background: white;
    font-size: 13px;
    min-width: 120px;
    transition: 0.2s;
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59,130,246,0.2);
}

button {
    background: #1e293b;
    color: white;
    border: none;
    padding: 7px 18px;
    border-radius: 30px;
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
    transition: 0.2s;
    height: 37px;
}

button:hover {
    background: #0f172a;
    transform: scale(1.01);
}

#resetFilters {
    background: #e2e8f0;
    color: #1e293b;
}

#resetFilters:hover {
    background: #cbd5e1;
}

/* ========== КОНТЕЙНЕР ТАБЛИЦЫ (скроллится) ========== */
.table-container {
    flex: 1;
    overflow-y: auto;
    padding: 0 28px 20px 28px;
    background: #f4f6f9;
}

.table-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 18px;
    border: 1px solid #edf2f7;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th {
    text-align: left;
    padding: 14px 12px;
    background-color: #f8fafc;
    font-weight: 600;
    color: #1e293b;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    background-color: #f8fafc;
    z-index: 10;
}

td {
    padding: 12px;
    border-bottom: 1px solid #f0f2f5;
    vertical-align: middle;
}

tr:hover td {
    background-color: #fafcff;
}

.product-img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 10px;
    background: #f1f5f9;
    display: block;
    border: 1px solid #eef2f8;
}

.stock-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 40px;
    font-size: 11px;
    font-weight: 500;
}

.stock-yes {
    background: #e0f2fe;
    color: #0369a1;
}

.stock-no {
    background: #ffe4e2;
    color: #b91c1c;
}

.price {
    font-weight: 600;
    color: #0f3b2c;
}

/* ========== ФУТЕР (фикс) ========== */
.footer {
    background: white;
    border-top: 1px solid #e2e8f0;
    padding: 12px 28px;
    text-align: center;
    font-size: 12px;
    color: #6c7a8e;
    flex-shrink: 0;
}

.pagination-wrapper {
    margin-top: 20px;
    padding: 15px 20px;
    background: white;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
}

.pagination-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

.pagination-controls button {
    background: #1e293b;
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
}

// Стили для отключенных кнопок пагинации

.pagination-controls button:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}

.pagination-controls select {
    padding: 6px 10px;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
}


/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: white;
    border-radius: 24px;
    max-width: 700px;
    width: 90%;
    max-height: 90%;
    overflow-y: auto;
    position: relative;
    padding: 24px 28px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 24px;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
    transition: 0.2s;
}

.modal-close:hover {
    color: #000;
}

/* Карточка внутри модалки */
.product-card {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.product-card-image {
    text-align: center;
}

.product-card-image img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 16px;
    object-fit: contain;
    background: #f5f7fb;
    padding: 12px;
}

.product-card-details {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 12px 16px;
    font-size: 14px;
}

.detail-label {
    font-weight: 600;
    color: #4a5a72;
}

.detail-value {
    color: #1e293b;
}

.modal-product-name {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 8px 0;
    color: #1e293b;
}

.modal-product-price {
    font-size: 28px;
    font-weight: 700;
    color: #0f3b2c;
    margin: 16px 0;
}

.thumbnails {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    justify-content: center;
}

.thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 12px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: 0.2s;
}

.thumb:hover {
    border-color: #3b82f6;
    transform: scale(1.05);
}

.detail-link {
    display: inline-block;
    margin-top: 16px;
    color: #3b82f6;
    text-decoration: none;
    font-weight: 500;
}

.detail-link:hover {
    text-decoration: underline;
}


/* ========== МОБИЛЬНАЯ АДАПТАЦИЯ ========== */
@media (max-width: 768px) {
    .header {
        padding: 12px 16px;
    }
    
    .header-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .logo-group {
        gap: 8px;
    }
    
    .logo-icon {
        height: 28px;
    }
    
    .logo-text {
        height: 22px;
    }
    
    .header-titles h1 {
        font-size: 18px;
    }
    
    .header-titles .subtitle {
        font-size: 11px;
    }
    
    .filters-panel {
        padding: 12px 16px;
    }
    
    .filters-row {
        gap: 8px;
    }
    
    .filter-group {
        min-width: calc(50% - 8px);
    }
    
    .filter-group select,
    .filter-group input {
        min-width: auto;
        font-size: 12px;
        padding: 6px 8px;
    }
    
    button {
        padding: 6px 14px;
        font-size: 12px;
        height: auto;
    }
    
    .columns-panel {
        padding: 8px 12px;
        gap: 8px 12px;
    }
    
    .columns-label {
        font-size: 11px;
        width: 100%;
        margin-bottom: 4px;
    }
    
    .column-toggle {
        font-size: 11px;
    }
    
    .table-container {
        padding: 0 12px 12px 12px;
    }
    
    /* Таблица превращается в карточки */
    .table-wrapper {
        border-radius: 12px;
    }
    
    #materialsTable thead {
        display: none; /* Скрываем шапку */
    }
    
    #materialsTable tbody tr {
        display: block;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        margin-bottom: 12px;
        background: white;
        padding: 12px;
    }
    
    #materialsTable tbody td {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 6px 0;
        border-bottom: none;
        font-size: 12px;
    }
    
    #materialsTable tbody td:before {
        content: attr(data-label);
        font-weight: 600;
        min-width: 90px;
        color: #4a5a72;
        font-size: 11px;
    }
    
    .product-img {
        width: 60px;
        height: 60px;
        margin-right: 0;
    }
    
    /* Цена и наличие выделяем */
    .price {
        font-size: 14px;
    }
    
    .stock-badge {
        display: inline-block;
        padding: 2px 10px;
    }
}