* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow-x: auto;
    overflow-y: auto;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: white;
    min-height: 100vh;
    padding: 0;
    margin: 0;
    color: #333;
    width: 100%;
    overflow-x: auto;
}

.container {
    width: 100%;
    min-width: 100%;
    margin: 0;
    padding: 0;
    background: white;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    width: 100%;
}

header h1 {
    font-size: 2em;
    font-weight: 600;
}

.last-update {
    font-size: 0.9em;
    opacity: 0.9;
}

/* Поиск */
.search-container {
    padding: 20px 30px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-clear {
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    background: #dc3545;
    color: white;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.2s;
}

.btn-clear:hover {
    background: #c82333;
    transform: translateY(-1px);
}

/* Фильтры */
.filters {
    padding: 20px 30px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: flex-end;
    flex-shrink: 0;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label {
    font-size: 0.85em;
    color: #666;
    font-weight: 500;
}

.filter-group select,
.filter-group input[type="text"],
.filter-group input[type="date"] {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9em;
    min-width: 200px;
    max-width: 400px;
}

.filter-group select optgroup {
    font-weight: 600;
    color: #667eea;
}

.filter-group select option {
    padding: 5px 10px;
    font-weight: normal;
}

.filter-group input[type="checkbox"] {
    margin-right: 5px;
}

.btn-primary,
.btn-secondary,
.btn-refresh {
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.9em;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-refresh {
    background: #28a745;
    color: white;
    padding: 8px 15px;
    transition: all 0.2s;
}

.btn-refresh:hover:not(:disabled) {
    background: #218838;
}

.btn-refresh:disabled {
    background: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-reorder {
    padding: 4px 10px;
    font-size: 0.85em;
    background: #fd7e14;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}
.btn-reorder:hover:not(:disabled) {
    background: #e96b00;
}
.btn-reorder:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-reorder-api {
    padding: 4px 10px;
    font-size: 0.85em;
    background: #6f42c1;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}
.btn-reorder-api:hover:not(:disabled) {
    background: #5a32a3;
}
.btn-reorder-api:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-set-supplier {
    padding: 4px 10px;
    font-size: 0.85em;
    background: #17a2b8;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}
.btn-set-supplier:hover:not(:disabled) {
    background: #138496;
}
.btn-set-supplier:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.loading-indicator {
    color: #667eea;
    font-size: 0.9em;
    margin-right: 10px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Статистика */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    padding: 30px;
    background: #f8f9fa;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #667eea;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.stat-card.problem {
    border-left-color: #dc3545;
}

.stat-card.status-new {
    border-left-color: #17a2b8;
}

.stat-card.status-arrived {
    border-left-color: #ffc107;
}

.stat-card.status-labeled {
    border-left-color: #28a745;
}

.stat-card.status-shipped {
    border-left-color: #6c757d;
}

.stat-label {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 8px;
    font-weight: 500;
}

.stat-value {
    font-size: 2em;
    font-weight: 700;
    color: #333;
}

/* Таблица */
.table-container {
    padding: 30px;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Горизонтальный скроллбар для таблицы */
.table-container::-webkit-scrollbar {
    height: 14px;
}

.table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 7px;
    margin: 0 30px;
}

.table-container::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 7px;
    border: 2px solid #f1f1f1;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}

/* Горизонтальный скроллбар для всего body (если таблица шире экрана) */
body::-webkit-scrollbar {
    height: 14px;
}

body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

body::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 7px;
}

body::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.table-header h2 {
    font-size: 1.5em;
    color: #333;
}

.table-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

table {
    width: 100%;
    min-width: 1400px;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: opacity 0.2s;
    margin-bottom: 20px;
}

tbody {
    transition: opacity 0.1s;
}

thead {
    background: #667eea;
    color: white;
}

th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid #e9ecef;
    transition: background 0.2s;
}

tbody tr:hover {
    background: #f8f9fa;
}

tbody tr.problem-row {
    background: #fff5f5;
}

td {
    padding: 10px 12px;
    font-size: 0.85em;
}

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
    text-transform: uppercase;
}

.status-NEW {
    background: #d1ecf1;
    color: #0c5460;
}

.status-SUPPLIER_ORDERED {
    background: #d4edda;
    color: #155724;
}

.status-ARRIVED {
    background: #fff3cd;
    color: #856404;
}

.status-LABELED {
    background: #d1f2eb;
    color: #0c5460;
}

.status-SHIPPED {
    background: #e2e3e5;
    color: #383d41;
}

.status-CANCELLED {
    background: #f8d7da;
    color: #721c24;
}

.status-IN_PROGRESS,
.status-IN_ASSEMBLY {
    background: #fff3cd;
    color: #856404;
}

.status-IN_ACCEPTANCE {
    background: #cfe2ff;
    color: #084298;
}

.status-IN_DELIVERY {
    background: #d1f2eb;
    color: #0c5460;
}

.status-DELIVERED {
    background: #d4edda;
    color: #155724;
}

/* Fallback для неизвестных статусов */
.status-UNKNOWN,
.status-badge:not([class*="status-"]) {
    background: #e2e3e5;
    color: #383d41;
}

.mp-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
}

.mp-ozon {
    background: #005bff;
    color: white;
}

.mp-wb {
    background: #7c3aed;
    color: white;
}

.problem-badge {
    color: #dc3545;
    font-weight: 600;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #666;
    font-style: italic;
}

/* Пагинация */
.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    padding: 20px;
    flex-shrink: 0;
}

.pagination button {
    padding: 8px 15px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination button:hover:not(:disabled) {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination .active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* Адаптивность */
@media (max-width: 768px) {
    .filters {
        flex-direction: column;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    table {
        font-size: 0.85em;
    }
    
    th, td {
        padding: 8px;
    }
}
