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

:root {
    --bg: #fafbfc;
    --card-bg: rgba(255, 255, 255, 0.7);
    --text-primary: rgb(45, 55, 72);
    --text-secondary: rgb(71, 85, 105);
    --border: rgb(229, 231, 235);
    --accent: #4caf50;
    --accent-strong: #43a047;
    --danger: #f44336;
    --danger-strong: #d32f2f;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-hover: 0 10px 20px rgba(0, 0, 0, 0.08);
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition-fast: 0.2s ease;
    --transition: 0.3s ease;
}

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

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

.header {
    margin-bottom: 20px;
}

.search-bar {
    width: 100%;
    padding: 19px 20px;
    font-size: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    outline: none;
    box-shadow: rgba(0, 0, 0, 0.07) 0px 4px 6px 0px;
    box-sizing: border-box;
    background: var(--card-bg);
    color: var(--text-primary);
    transition: border-color var(--transition);
}

.search-bar:focus {
    border-color: var(--accent);
}

.main-content {
    display: grid;
    grid-template-columns: 280px 1fr 320px;
    gap: 20px;
    align-items: start;
}

.filters-panel {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.filters-panel h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
    font-size: 18px;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 10px;
}

.filter-group {
    margin-bottom: 20px;
}

.filter-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 14px;
}

.filter-group select,
.filter-group input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--card-bg);
    color: var(--text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.filter-group select,
.filter-group input:not([type='checkbox']) {
    height: 38px;
}

.filter-group input[type='checkbox'] {
    width: auto;
    margin-right: 8px;
}

.filter-group .two-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
}

.checkbox-group {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.checkbox-group label {
    margin: 0px;
}

.reset-filters {
    width: 100%;
    padding: 10px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    margin-top: 15px;
    transition: background var(--transition);
}

.reset-filters:hover {
    background: var(--danger-strong);
}

.products-grid {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    min-height: 600px;
}

#productsContainer {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.results-count {
    margin-bottom: 15px;
    color: var(--text-secondary);
    font-size: 14px;
}

.product-card {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 15px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
    gap: 10px;
}

.product-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.product-card.active {
    border-color: var(--accent);
    background: #f1faf2;
}

.product-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.product-header > div {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.product-code {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-primary);
}

.product-name {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.4;
    flex: 0 0 auto;
}

.product-specs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1 1 auto;
}

.spec-item {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--card-bg);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    border: 0px solid var(--border);
    flex: 0 1 calc(50% - 4px);
    min-width: 120px;
}

.spec-label {
    font-weight: 600;
    color: var(--text-primary);
}

.download-btn {
    padding: 8px 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: background var(--transition);
    width: 100%;
    flex-shrink: 0;
    align-self: stretch;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.download-btn:hover {
    background: var(--accent-strong);
}

.download-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.related-panel {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.related-panel h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
    font-size: 18px;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 10px;
}

.related-product {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 10px;
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.related-product:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.related-code {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.related-specs {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.no-results {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 16px;
}

.empty-related {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--accent);
    font-size: 16px;
}

.loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%,
    20% {
        content: '.';
    }
    40% {
        content: '..';
    }
    60%,
    100% {
        content: '...';
    }
}

@media (min-width: 1201px) {
    #productsContainer {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 12px;
    }

    .product-card {
        flex: 0 1 calc(50% - 6px);
        margin-bottom: 0;
    }
}

@media (max-width: 1400px) {
    .main-content {
        grid-template-columns: 250px 1fr 300px;
    }
}

@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .filters-panel,
    .related-panel {
        position: static;
        max-height: none;
    }
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    margin-right: 5px;
    border: 1px solid var(--border);
}

.badge-ip {
    background: #e3f2fd;
    color: #1976d2;
}

.badge-volt {
    background: #fff3e0;
    color: #f57c00;
}

.badge-brand {
    background: #f3e5f5;
    color: #7b1fa2;
}

.badge-ct {
    background: #fff9c4;
    color: #bf6312;
}

.badge-cri {
    background: #d5ffc4;
    color: #26aa0e;
}
