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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    background-color: #1a1a1a;
    color: #e0e0e0;
    line-height: 1.6;
    padding: 20px;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
}

header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #333;
}

header h1 {
    color: #fff;
    font-size: 2rem;
}

/* Панель настроек */
.settings-panel {
    background: #2a2a2a;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
}

.settings-panel h2 {
    color: #fff;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.settings-group {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #444;
}

.settings-group:last-child {
    border-bottom: none;
}

.settings-group h3 {
    color: #fff;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.quantity-settings {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.quantity-settings label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    color: #ccc;
    font-size: 0.9rem;
}

.quantity-settings input {
    padding: 8px;
    border: 1px solid #555;
    border-radius: 4px;
    background: #1a1a1a;
    color: #fff;
    width: 120px;
}

.quantity-settings button {
    padding: 8px 16px;
    background: #4a9eff;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.quantity-settings button:hover {
    background: #3a8eef;
}

/* Формула */
.formula-display {
    background: #1a1a1a;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #444;
    font-family: 'Courier New', monospace;
    color: #4a9eff;
    white-space: pre-wrap;
    line-height: 1.8;
}

/* Редактор констант */
.constants-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.constants-controls button {
    padding: 8px 16px;
    background: #6c757d;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.constants-controls button:hover {
    background: #5a6268;
}

.constants-table,
.certificates-table {
    overflow-x: auto;
}

.constants-table table,
.certificates-table table {
    width: 100%;
    border-collapse: collapse;
    background: #1a1a1a;
}

.constants-table th,
.constants-table td,
.certificates-table th,
.certificates-table td {
    padding: 10px;
    text-align: left;
    border: 1px solid #444;
}

.constants-table th,
.certificates-table th {
    background: #2a2a2a;
    color: #fff;
    font-weight: 600;
}

.constants-table td,
.certificates-table td {
    color: #ccc;
}

.constants-table input,
.certificates-table input {
    width: 100%;
    padding: 6px;
    border: 1px solid #555;
    border-radius: 4px;
    background: #2a2a2a;
    color: #fff;
}

.constants-table input:focus,
.certificates-table input:focus {
    outline: none;
    border-color: #4a9eff;
}

.certificates-controls {
    margin-bottom: 15px;
}

.certificates-controls button {
    padding: 8px 16px;
    background: #4a9eff;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.certificates-controls button:hover {
    background: #3a8eef;
}

/* Таблица товаров */
.products-section {
    background: #2a2a2a;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
}

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

.products-header h2 {
    color: #fff;
    font-size: 1.5rem;
}

.pagination-info {
    color: #ccc;
    font-size: 0.9rem;
}

.table-container {
    overflow-x: auto;
    margin-bottom: 20px;
}

#products-table {
    width: 100%;
    border-collapse: collapse;
    background: #1a1a1a;
    font-size: 0.85rem;
}

#products-table thead {
    background: #2a2a2a;
    position: sticky;
    top: 0;
    z-index: 10;
}

#products-table th {
    padding: 10px 8px;
    text-align: left;
    color: #fff;
    font-weight: 600;
    border: 1px solid #444;
    white-space: nowrap;
}

#products-table .sub-header th {
    background: #333;
    font-size: 0.8rem;
    font-weight: 500;
}

#products-table td {
    padding: 8px;
    border: 1px solid #444;
    color: #ccc;
}

#products-table tbody tr:hover {
    background: #333;
}

#products-table tbody tr.loading {
    text-align: center;
    color: #888;
}

/* Редактируемые поля */
.editable-input {
    width: 80px;
    padding: 4px;
    border: 1px solid #555;
    border-radius: 4px;
    background: #2a2a2a;
    color: #fff;
    font-size: 0.85rem;
}

.editable-input:focus {
    outline: none;
    border-color: #4a9eff;
    background: #333;
}

.editable-select {
    width: 120px;
    padding: 4px;
    border: 1px solid #555;
    border-radius: 4px;
    background: #2a2a2a;
    color: #fff;
    font-size: 0.85rem;
}

.editable-select:focus {
    outline: none;
    border-color: #4a9eff;
}

/* Цветовая индикация */
.cell-improved {
    background-color: rgba(40, 167, 69, 0.2) !important;
}

.cell-worsened {
    background-color: rgba(220, 53, 69, 0.2) !important;
}

.cell-neutral {
    background-color: transparent;
}

.change-indicator {
    display: inline-block;
    margin-left: 5px;
    font-size: 0.9rem;
}

.change-up {
    color: #dc3545; /* Красный по умолчанию */
}

.change-down {
    color: #28a745; /* Зеленый по умолчанию */
}

.change-improved {
    color: #28a745 !important; /* Зеленый для улучшения */
}

.change-worsened {
    color: #dc3545 !important; /* Красный для ухудшения */
}

.change-equal {
    color: #6c757d;
}

/* Кнопки действий */
.action-buttons {
    display: flex;
    gap: 5px;
}

.btn-reset {
    padding: 4px 8px;
    background: #6c757d;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: background 0.2s;
}

.btn-reset:hover {
    background: #5a6268;
}

/* Пагинация */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.pagination button {
    padding: 8px 12px;
    background: #4a9eff;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.pagination button:hover:not(:disabled) {
    background: #3a8eef;
}

.pagination button:disabled {
    background: #555;
    cursor: not-allowed;
    opacity: 0.5;
}

.pagination .page-input {
    width: 60px;
    padding: 8px;
    border: 1px solid #555;
    border-radius: 4px;
    background: #1a1a1a;
    color: #fff;
    text-align: center;
}

.pagination .page-info {
    color: #ccc;
    font-size: 0.9rem;
}

/* Аналитика */
.analytics-panel {
    background: #2a2a2a;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
}

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

.analytics-panel h2 {
    color: #fff;
    font-size: 1.5rem;
    margin: 0;
}

.btn-calculate {
    padding: 10px 20px;
    background: #4a9eff;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}

.btn-calculate:hover:not(:disabled) {
    background: #3a8eef;
}

.btn-calculate:disabled {
    background: #555;
    cursor: not-allowed;
    opacity: 0.7;
}

.analytics-progress {
    margin-bottom: 20px;
    padding: 15px;
    background: #1a1a1a;
    border-radius: 4px;
    border: 1px solid #444;
}

.progress-bar-container {
    width: 100%;
    height: 20px;
    background: #333;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #4a9eff, #3a8eef);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 10px;
}

.progress-text {
    text-align: center;
    color: #ccc;
    font-size: 0.9rem;
}

.analytics-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: #1a1a1a;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #444;
}

.stat-card h4 {
    color: #4a9eff;
    margin-bottom: 10px;
    font-size: 1rem;
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #fff;
    margin-bottom: 5px;
}

.stat-card .stat-change {
    font-size: 0.9rem;
    color: #ccc;
}

.stat-card .stat-change.positive {
    color: #28a745;
}

.stat-card .stat-change.negative {
    color: #dc3545;
}

.analytics-table {
    width: 100%;
    border-collapse: collapse;
    background: #1a1a1a;
    margin-top: 20px;
}

.analytics-table th,
.analytics-table td {
    padding: 10px;
    text-align: left;
    border: 1px solid #444;
}

.analytics-table th {
    background: #2a2a2a;
    color: #fff;
    font-weight: 600;
}

.analytics-table td {
    color: #ccc;
}

/* Изображения */
.product-image {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #555;
}

/* Ссылки */
.product-link {
    color: #4a9eff;
    text-decoration: none;
}

.product-link:hover {
    text-decoration: underline;
}

/* Загрузка */
.loading {
    text-align: center;
    color: #888;
    padding: 20px;
}

/* Фильтр по предметам */
.products-header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.search-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-group label {
    color: #ccc;
    font-size: 0.9rem;
    white-space: nowrap;
}

.sku-search-input {
    padding: 8px 12px;
    border: 1px solid #555;
    border-radius: 4px;
    background: #1a1a1a;
    color: #fff;
    font-size: 0.9rem;
    min-width: 200px;
    max-width: 300px;
}

.sku-search-input:focus {
    outline: none;
    border-color: #4a9eff;
    background: #2a2a2a;
}

.sku-search-input::placeholder {
    color: #888;
}

.subject-filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.subject-filter-group label {
    color: #ccc;
    font-size: 0.9rem;
    white-space: nowrap;
}

.subject-filter-select {
    padding: 8px 12px;
    border: 1px solid #555;
    border-radius: 4px;
    background: #1a1a1a;
    color: #fff;
    font-size: 0.9rem;
    min-width: 200px;
    max-width: 300px;
    cursor: pointer;
}

.subject-filter-select:focus {
    outline: none;
    border-color: #4a9eff;
    background: #2a2a2a;
}

.subject-filter-select option {
    background: #1a1a1a;
    color: #fff;
    padding: 8px;
}

/* Адаптивность */
@media (max-width: 1200px) {
    .table-container {
        overflow-x: scroll;
    }
    
    #products-table {
        font-size: 0.75rem;
    }
    
    .editable-input {
        width: 60px;
    }
}

