/* Переменные */
:root {
    --primary: #1e40af;
    --primary-light: #3b82f6;
    --primary-dark: #1e3a8a;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-lg: 12px;
}

/* Сброс */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Шапка */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1rem 2rem;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    font-size: 2.5rem;
}

.logo-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.logo-text .subtitle {
    font-size: 0.85rem;
    opacity: 0.9;
}

/* Табы навигации */
.nav-tabs {
    display: flex;
    gap: 0.5rem;
}

.tab-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.tab-btn:hover {
    background: rgba(255,255,255,0.2);
}

.tab-btn.active {
    background: white;
    color: var(--primary);
}

/* Основной контент */
.main-content {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Секция фильтров */
.filters-section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.filters-header h2 {
    font-size: 1.1rem;
    color: var(--text);
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-light);
}

.filter-group select,
.filter-group input {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    background: white;
    transition: border-color 0.2s;
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: var(--primary-light);
}

.filter-search {
    grid-column: span 2;
}

/* Кнопки */
.btn-secondary {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--border);
}

/* Секции контента */
.content-section {
    display: none;
}

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

/* Таблица */
.table-info {
    margin-bottom: 1rem;
    color: var(--text-light);
    font-size: 0.9rem;
}

.table-container {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow-x: auto;
    overflow-y: hidden;
}

.data-table {
    width: 100%;
    min-width: 1200px;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th {
    background: var(--bg);
    padding: 1rem 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--text);
    border-bottom: 2px solid var(--border);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    transition: background 0.2s;
}

.data-table th:hover {
    background: var(--border);
}

.data-table th.sorted {
    background: #e0e7ff;
    color: var(--primary);
}

.sort-icon {
    margin-left: 0.5rem;
    opacity: 0.5;
}

.data-table td {
    padding: 0.875rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tbody tr {
    cursor: pointer;
    transition: background 0.2s;
}

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

.data-table tbody tr:nth-child(even) {
    background: #fafafa;
}

.data-table tbody tr:nth-child(even):hover {
    background: #f1f5f9;
}

/* Бейджи */
.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 500;
}

.badge-viscosity {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-brand {
    background: #f0fdf4;
    color: #166534;
}

/* Ячейки с кодами */
.code-cell {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.8rem;
    color: var(--text-light);
}

/* Пустое состояние */
.no-data {
    text-align: center;
    padding: 3rem !important;
}

.no-data-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.no-data-icon {
    font-size: 3rem;
    opacity: 0.5;
}

.no-data-hint {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Статистика */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

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

.stat-label {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Графики */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.chart-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.chart-card h3 {
    margin-bottom: 1rem;
    font-size: 1rem;
    color: var(--text);
}

.chart-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.chart-label {
    width: 100px;
    font-size: 0.8rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chart-bar-container {
    flex: 1;
    height: 24px;
    background: var(--bg);
    border-radius: var(--radius);
    overflow: hidden;
}

.chart-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-light), var(--primary));
    border-radius: var(--radius);
    transition: width 0.5s ease-out;
}

.chart-value {
    width: 30px;
    text-align: right;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

/* Экспорт */
.export-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.export-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.export-card:hover {
    border-color: var(--primary-light);
    transform: translateY(-2px);
}

.export-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.export-card h3 {
    margin-bottom: 0.5rem;
    color: var(--text);
}

.export-card p {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    padding: 2rem;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--text);
}

.detail-grid {
    display: grid;
    gap: 1.5rem;
}

.detail-section {
    border-bottom: 1px solid var(--border);
    padding-bottom: 1.5rem;
}

.detail-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.detail-section h3 {
    margin-bottom: 1rem;
    color: var(--text);
    font-size: 1rem;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.detail-label {
    color: var(--text-light);
    font-size: 0.9rem;
}

.detail-value {
    font-weight: 500;
}

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

.code-box {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}

.code-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: 0.25rem;
}

.code-value {
    font-family: 'Monaco', 'Consolas', monospace;
    font-weight: 600;
    color: var(--primary);
}

/* Стандарты и допуски в модальном окне */
.detail-standards {
    grid-column: 1 / -1;
}

.standards-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.standard-item {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 1rem;
    border-left: 4px solid var(--primary);
}

.standard-badge {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.standard-info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.standard-desc {
    color: var(--text);
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 0;
}

.standard-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.85rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.standard-meta span {
    color: var(--text-light);
}

.standard-meta strong {
    color: var(--text);
    font-weight: 600;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--text);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 500;
    opacity: 0;
    transform: translateY(1rem);
    transition: all 0.3s;
    z-index: 2000;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.error {
    background: var(--danger);
}

/* Футер */
.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 1.5rem 2rem;
    margin-top: 2rem;
}

.footer-content {
    max-width: 1600px;
    margin: 0 auto;
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
}

.footer-stats {
    margin-top: 0.5rem;
}

/* Адаптивность */
@media (max-width: 1024px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .filter-search {
        grid-column: span 1;
    }
    
    .data-table {
        font-size: 0.8rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.625rem 0.5rem;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 1rem;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .nav-tabs {
        width: 100%;
        justify-content: center;
    }
    
    .tab-btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
    
    .filters-grid {
        grid-template-columns: 1fr;
    }
    
    .data-table {
        min-width: 1000px;
    }
    
    .codes-grid {
        grid-template-columns: 1fr;
    }
}

/* Печать */
@media print {
    .header, .filters-section, .nav-tabs, .footer {
        display: none !important;
    }
    
    .main-content {
        padding: 0;
    }
    
    .data-table {
        font-size: 10pt;
    }
    
    .badge {
        border: 1px solid #000;
        background: transparent !important;
        color: #000 !important;
    }
}
