/* ============================================
   CSS Variables & Reset
   ============================================ */
:root {
    /* Colors */
    --primary: #3B82F6;
    --primary-hover: #2563EB;
    --primary-light: #DBEAFE;
    --secondary: #64748B;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    
    /* Backgrounds - Light theme */
    --bg-main: #FFFFFF;
    --bg-panel: #F8F9FA;
    --bg-card: #FFFFFF;
    --bg-input: #FFFFFF;
    --bg-hover: #E5E7EB;
    
    /* Text - Dark on light */
    --text-primary: #1F2937;
    --text-secondary: #4B5563;
    --text-muted: #6B7280;
    
    /* Borders */
    --border-color: #E5E7EB;
    --border-light: #D1D5DB;
    
    /* Spacing */
    --header-height: 60px;
    --sidebar-width: 280px;
    --sidebar-right-width: 360px;
    
    /* Effects */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --transition: all 0.2s ease;
    --radius: 8px;
    --radius-lg: 12px;
}

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

html {
    font-size: 14px;
}

body {
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
    border-top: 3px solid var(--primary);
}

/* ============================================
   Header Navigation
   ============================================ */
.nav-header {
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.nav-left {
    display: flex;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.nav-center {
    display: flex;
    align-items: center;
    gap: 24px;
}

.current-unit {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.current-unit:hover {
    background: var(--bg-hover);
}

.unit-badge {
    background: var(--primary);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.85rem;
}

.unit-name {
    font-weight: 500;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chevron {
    color: var(--text-secondary);
    transition: var(--transition);
}

.nav-buttons {
    display: flex;
    gap: 4px;
}

.nav-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.nav-btn:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

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

.nav-btn.save-btn:hover {
    background: var(--success);
    color: white;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.history-controls {
    display: flex;
    gap: 4px;
}

.history-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: none;
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.history-btn:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.history-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    background: var(--bg-card);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.user-menu:hover {
    background: var(--bg-hover);
}

.user-avatar {
    width: 28px;
    height: 28px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

/* ============================================
   Main Layout
   ============================================ */
.main-container {
    display: flex;
    height: calc(100vh - var(--header-height));
    margin-top: var(--header-height);
}

.content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    min-height: 0; /* Важно для правильной работы flex и overflow */
}

/* ============================================
   Left Sidebar - Sections
   ============================================ */
.sidebar-left {
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
}

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.equipment-type {
    font-size: 0.75rem;
    color: var(--primary);
    background: var(--primary-light);
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.sections-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.section-group {
    margin-bottom: 16px;
}

.group-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 12px 6px;
}

.section-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    font-size: 0.9rem;
    position: relative;
}

.section-btn::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: var(--primary);
    border-radius: 0 2px 2px 0;
    transition: var(--transition);
}

.section-btn:hover {
    background: var(--bg-card);
}

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

.section-btn.selected {
    background: var(--primary-light);
    color: var(--primary);
}

.section-btn.selected::before {
    height: 60%;
}

.section-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.automation-toggle {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
}

.toggle-container {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.toggle-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--bg-hover);
    border-radius: 12px;
    transition: var(--transition);
}

.toggle-slider::after {
    content: '';
    position: absolute;
    left: 2px;
    top: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
}

.toggle-container input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-container input:checked + .toggle-slider::after {
    transform: translateX(20px);
}

.toggle-container input {
    display: none;
}

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

/* ============================================
   Visualization Container
   ============================================ */
.visualization-container {
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 16px 24px;
    flex-shrink: 0;
}

.visualization-container .visualization-header {
    padding: 0;
    border-bottom: none;
    margin-bottom: 12px;
}

.visualization-container .visualization-area {
    margin: 0;
    padding: 0;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

/* ============================================
   Main Content Area
   ============================================ */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--bg-panel);
}

.content-panel {
    display: none;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

.panel-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.panel-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.panel-header.with-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-arrow {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: none;
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.nav-arrow:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ============================================
   Forms
   ============================================ */
.form-grid {
    padding: 24px;
    display: grid;
    gap: 20px;
}

.form-grid.cols-2 {
    grid-template-columns: 1fr 1fr;
}

.form-col h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group.required label::after {
    content: '*';
    color: var(--danger);
    margin-left: 4px;
}

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

.form-input,
.form-select {
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    transition: var(--transition);
}

.form-input:hover,
.form-select:hover {
    border-color: var(--primary);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.validation-msg {
    font-size: 0.8rem;
    color: var(--danger);
    display: none;
}

.form-group.error .form-input {
    border-color: var(--danger);
}

.form-group.error .validation-msg {
    display: block;
}

.form-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0 24px;
}

.section-subtitle {
    font-size: 1rem;
    font-weight: 600;
    padding: 16px 24px 0;
    color: var(--text-secondary);
}

/* ============================================
   Size Recommendations
   ============================================ */
.size-recommendations {
    padding: 24px;
    padding-top: 0;
}

.size-recommendations h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.sizes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}

.size-option {
    padding: 12px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.size-option:hover {
    background: var(--bg-hover);
}

.size-option.selected {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.size-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.size-dimensions {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.size-speed {
    font-size: 0.75rem;
    color: var(--success);
    margin-top: 4px;
    font-family: 'JetBrains Mono', monospace;
}

.size-speed.warning {
    color: var(--warning);
}

.size-speed.danger {
    color: var(--danger);
}

/* ============================================
   Units List
   ============================================ */
.units-toolbar {
    padding: 16px 24px;
    display: flex;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.units-list {
    padding: 16px 24px;
}

.unit-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
}

.unit-item:hover {
    background: var(--bg-hover);
}

.unit-item.selected {
    border-color: var(--primary);
}

.unit-item-badge {
    background: var(--primary);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 50px;
    text-align: center;
}

.unit-item-info {
    flex: 1;
}

.unit-item-name {
    font-weight: 500;
}

.unit-item-details {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.unit-item-qty {
    display: flex;
    align-items: center;
    gap: 8px;
}

.unit-item-qty input {
    width: 60px;
    padding: 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    text-align: center;
    font-size: 0.9rem;
}

/* ============================================
   Extra Cost
   ============================================ */
.extra-costs-list {
    padding: 24px;
}

.extra-cost-item {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 12px;
    margin-bottom: 12px;
    align-items: center;
}

.extra-cost-item .form-input {
    padding: 8px 12px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--danger);
    color: white;
}

#addExtraCostBtn {
    margin: 0 24px 24px;
}

.extra-cost-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    font-weight: 600;
}

#extraCostTotal {
    color: var(--primary);
    font-size: 1.1rem;
}

/* ============================================
   Notes
   ============================================ */
.notes-textarea {
    width: 100%;
    min-height: 300px;
    padding: 20px 24px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
}

.notes-textarea:focus {
    outline: none;
}

/* ============================================
   Right Sidebar
   ============================================ */
.sidebar-right {
    width: var(--sidebar-right-width);
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 4px rgba(0, 0, 0, 0.05);
    overflow-y: auto;
}

.visualization-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.visualization-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.viz-controls {
    display: flex;
    gap: 4px;
}

.viz-btn {
    padding: 6px 12px;
    background: var(--bg-card);
    border: none;
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: var(--transition);
}

.viz-btn:hover {
    background: var(--bg-hover);
}

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

.visualization-area {
    flex: 1;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    background: var(--bg-panel);
    margin: 16px;
    border-radius: var(--radius);
    min-height: 200px;
    overflow-x: auto;
    overflow-y: hidden;
    border: 1px solid var(--border-color);
}

#unitCanvas {
    max-width: 100%;
    max-height: 100%;
}

.selected-sections {
    padding: 0 20px 16px;
}

.selected-sections h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.sections-composition {

    overflow-y: auto;
}

.composition-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 0.85rem;
    transition: var(--transition);
}

.composition-item:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.1);
}

.composition-item.empty {
    color: var(--text-muted);
    justify-content: center;
}

.composition-item-icon {
    font-size: 1rem;
}

.composition-item-remove {
    margin-left: auto;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    font-size: 1rem;
}

.composition-item-remove:hover {
    background: var(--danger);
    color: white;
}

.drag-handle {
    cursor: move;
    color: var(--text-muted);
    font-size: 1.2rem;
    padding: 0 8px;
    user-select: none;
}

.drag-handle:hover {
    color: var(--text-primary);
}

.composition-item.draggable {
    cursor: move;
}

.composition-item.dragging {
    opacity: 0.5;
    border: 2px dashed var(--primary);
}

.composition-item.drag-over {
    border-top: 3px solid var(--primary);
    margin-top: 2px;
}

.composition-item-edit {
    margin-left: auto;
    margin-right: 8px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    font-size: 1rem;
}

.composition-item-edit:hover {
    background: var(--primary);
    color: white;
}

.composition-item-name {
    flex: 1;
    margin-left: 8px;
}

.price-summary {
    padding: 16px 20px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
}

.price-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.price-row.total {
    border-top: 1px solid var(--border-color);
    margin-top: 8px;
    padding-top: 12px;
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.price-row.total span:last-child {
    color: var(--primary);
    font-size: 1.1rem;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

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

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
}

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

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-calculate {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
    margin-top: 20px;
}

/* ============================================
   Section Content - Calculation Forms
   ============================================ */
#sectionContent {
    padding: 24px;
}

.calc-results {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.calc-results h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.results-grid {
    display: grid;
    gap: 12px;
}

.result-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
}

.result-item:hover {
    background: var(--bg-hover);
}

.result-item.selected {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.result-radio {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-light);
    border-radius: 50%;
    margin-right: 14px;
    position: relative;
    flex-shrink: 0;
}

.result-item.selected .result-radio {
    border-color: var(--primary);
}

.result-item.selected .result-radio::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
}

.result-info {
    flex: 1;
}

.result-name {
    font-weight: 500;
    margin-bottom: 4px;
}

.result-details {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.result-specs {
    display: flex;
    gap: 20px;
    margin-top: 8px;
}

.spec-item {
    font-size: 0.8rem;
    font-family: 'JetBrains Mono', monospace;
}

.spec-label {
    color: var(--text-muted);
}

.spec-value {
    color: var(--text-primary);
    font-weight: 500;
}

.result-price {
    font-weight: 600;
    font-size: 1rem;
    color: var(--primary);
    margin-left: 16px;
}

/* ============================================
   Characteristics Display
   ============================================ */
.characteristics {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.char-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.char-row:last-child {
    border-bottom: none;
}

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

.char-value {
    font-weight: 500;
    font-family: 'JetBrains Mono', monospace;
}

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 450px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    animation: modalSlide 0.2s ease;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    font-size: 1.4rem;
}

.modal-close:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    margin-top: 16px;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* ============================================
   Notifications
   ============================================ */
.notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-card);
    padding: 14px 20px;
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: none;
    z-index: 1000;
    border-left: 4px solid var(--success);
    border: 1px solid var(--border-color);
    animation: notificationSlide 0.3s ease;
}

.notification.show {
    display: block;
}

.notification.error {
    border-color: var(--danger);
}

@keyframes notificationSlide {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ============================================
   Loading
   ============================================ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.9);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 2000;
}

.loading-overlay.show {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   Scrollbar
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-panel);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1400px) {
    :root {
        --sidebar-width: 240px;
        --sidebar-right-width: 320px;
    }
}

@media (max-width: 1200px) {
    .main-container {
        flex-direction: column;
    }
    
    .content-wrapper {
        order: 2;
    }
    
    .sidebar-left,
    .sidebar-right {
        width: 100%;
        max-height: 300px;
    }
    
    .visualization-container {
        order: 1;
    }
    
    .main-content {
        flex: none;
        min-height: 500px;
    }
}
