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

body {
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #1a1a2e;
}

#canvas {
    display: block;
    cursor: default;
}

#canvas.grabbing {
    cursor: grabbing;
}

#addNodeBtn {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
    transition: all 0.2s ease;
    z-index: 1000;
}

#addNodeBtn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

#addNodeBtn:active {
    transform: scale(0.95);
}

#addNodeBtn svg {
    width: 24px;
    height: 24px;
    stroke: white;
    stroke-width: 2.5;
    stroke-linecap: round;
}

#addNodeMenu {
    position: fixed;
    bottom: 80px;
    left: 24px;
    background: #2d3142;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    opacity: 0;
    transform: translateY(10px) scale(0.95);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    z-index: 999;
}

#addNodeMenu.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.menu-item {
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    min-width: 160px;
}

.menu-item:last-child {
    border-bottom: none;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.menu-item-icon {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.menu-item-icon.source {
    background: #10b981;
}

.menu-item-icon.node {
    background: #6366f1;
}

.menu-item-icon.sink {
    background: #ec4899;
}

.menu-item-label {
    font-size: 14px;
    font-weight: 500;
    color: #e5e7eb;
}

#contextMenu {
    position: fixed;
    background: #2d3142;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.15s cubic-bezier(0.4, 0, 0.2, 1), transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    z-index: 1000;
}

#contextMenu.open {
    opacity: 1;
    transform: scale(1);
    pointer-events: all;
}

.context-menu-item {
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    min-width: 160px;
}

.context-menu-item:last-child {
    border-bottom: none;
}

.context-menu-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.context-menu-item.danger {
    color: #ef4444;
}

.context-menu-item.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.context-menu-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.context-menu-item.danger .context-menu-icon {
    stroke: #ef4444;
}

.context-menu-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 4px 0;
}

.context-menu-item.hidden {
    display: none;
}

.context-menu-divider.hidden {
    display: none;
}

#componentContextMenu {
    position: fixed;
    background: #2d3142;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.15s cubic-bezier(0.4, 0, 0.2, 1), transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    z-index: 1000;
}

#componentContextMenu.open {
    opacity: 1;
    transform: scale(1);
    pointer-events: all;
}

#connectionContextMenu {
    position: fixed;
    background: #2d3142;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.15s cubic-bezier(0.4, 0, 0.2, 1), transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    z-index: 1000;
}

#connectionContextMenu.open {
    opacity: 1;
    transform: scale(1);
    pointer-events: all;
}

#menuBtn {
    position: fixed;
    top: 24px;
    left: 24px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: rgba(45, 49, 66, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 1000;
}

#menuBtn:hover {
    background: rgba(45, 49, 66, 1);
    border-color: rgba(255, 255, 255, 0.2);
}

#menuBtn svg {
    width: 20px;
    height: 20px;
    stroke: #9ca3af;
    stroke-width: 2;
    stroke-linecap: round;
}

#menuBtn:hover svg {
    stroke: #e5e7eb;
}

#modelInfoBtn {
    position: fixed;
    top: 72px;
    left: 24px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: rgba(45, 49, 66, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 1000;
}

#modelInfoBtn:hover {
    background: rgba(45, 49, 66, 1);
    border-color: rgba(255, 255, 255, 0.2);
}

#modelInfoBtn svg {
    width: 20px;
    height: 20px;
    stroke: #9ca3af;
    stroke-width: 2;
    stroke-linecap: round;
}

#modelInfoBtn:hover svg {
    stroke: #e5e7eb;
}

#modelInfoBtn.selected {
    border-color: #facc15;
    box-shadow: 0 0 0 1px #facc15;
}

#variablesBtn {
    position: fixed;
    top: 120px;
    left: 24px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: rgba(45, 49, 66, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 1000;
}

#variablesBtn:hover {
    background: rgba(45, 49, 66, 1);
    border-color: rgba(255, 255, 255, 0.2);
}

#variablesBtn svg {
    width: 20px;
    height: 20px;
    stroke: #9ca3af;
    stroke-width: 2;
    stroke-linecap: round;
}

#variablesBtn:hover svg {
    stroke: #e5e7eb;
}

#variablesBtn.active {
    border-color: rgba(99, 102, 241, 0.5);
    background: rgba(99, 102, 241, 0.15);
}

#variablesBtn.active svg {
    stroke: #818cf8;
}

#appMenu {
    position: fixed;
    top: 168px;
    left: 24px;
    background: #2d3142;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    z-index: 999;
    min-width: 180px;
}

#appMenu.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.app-menu-item {
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.app-menu-item:last-child {
    border-bottom: none;
}

.app-menu-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.app-menu-item-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.app-menu-item-icon svg {
    width: 16px;
    height: 16px;
    stroke: #9ca3af;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.app-menu-item:hover .app-menu-item-icon svg {
    stroke: #e5e7eb;
}

.app-menu-item-label {
    font-size: 14px;
    font-weight: 500;
    color: #d1d5db;
}

.app-menu-item:hover .app-menu-item-label {
    color: #e5e7eb;
}

.app-menu-item.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.app-menu-item.danger .app-menu-item-icon svg {
    stroke: #ef4444;
}

.app-menu-item.danger .app-menu-item-label {
    color: #ef4444;
}

.app-menu-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

#sidebar {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    background: #2d3142;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#sidebar.open {
    transform: translateX(0);
}

#sidebarResizeHandle {
    position: absolute;
    left: 0;
    top: 0;
    width: 4px;
    height: 100%;
    cursor: ew-resize;
    background: transparent;
}

#sidebarResizeHandle:hover {
    background: rgba(99, 102, 241, 0.3);
}

#sidebarHeader {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#sidebarHeader h2 {
    font-size: 16px;
    font-weight: 600;
    color: #e5e7eb;
    margin: 0;
}

/* Sidebar tabs */
#sidebarTabs {
    display: flex;
    gap: 4px;
    flex: 1;
}

.sidebar-tab {
    padding: 6px 12px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #9ca3af;
    font-size: 13px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.2s;
}

.sidebar-tab:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #d1d5db;
}

.sidebar-tab.active {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
}

/* Metric rows for results */
.metric-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 13px;
}

.metric-row span:first-child {
    color: #9ca3af;
}

.metric-row span:last-child {
    color: #e5e7eb;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Result chart containers */
.result-chart-container {
    margin: 12px 0 16px 0;
    background: #1f2937;
    border-radius: 8px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.result-chart-container h4 {
    font-size: 11px;
    font-weight: 500;
    color: #9ca3af;
    margin: 0 0 8px 0;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.result-chart-container canvas {
    display: block;
    width: 100%;
    height: 60px;
}

.chart-stats {
    margin-top: 8px;
    font-size: 11px;
    color: #9ca3af;
    display: flex;
    justify-content: space-between;
}

#closeSidebar {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

#closeSidebar:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #e5e7eb;
}

#sidebarContent,
#connectionSidebarContent {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    min-height: 0;
}

.property-group {
    margin-bottom: 24px;
}

.property-group h3 {
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 12px 0;
}

.property-field {
    margin-bottom: 16px;
}

.property-field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #d1d5db;
    margin-bottom: 6px;
}

.property-field input[type="text"],
.property-field input[type="number"],
.property-field select {
    width: 100%;
    padding: 8px 12px;
    background: #1f2937;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #e5e7eb;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s;
}

.property-field 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='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.property-field select:focus {
    outline: none;
    border-color: #6366f1;
    background-color: #1a1f2e;
}

.property-field select option {
    background: #1f2937;
    color: #e5e7eb;
}

.distribution-chart-container {
    margin-top: 16px;
    background: #1f2937;
    border-radius: 8px;
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.distribution-chart-container canvas {
    display: block;
}

.curve-editor-container {
    margin-top: 8px;
    background: #252547;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.curve-editor-container canvas {
    display: block;
}

.property-field input:focus {
    outline: none;
    border-color: #6366f1;
    background: #1a1f2e;
}

.property-field input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.property-field textarea {
    width: 100%;
    min-height: 80px;
    padding: 8px 12px;
    background: #1f2937;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #e5e7eb;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s, background 0.2s;
}

.property-field textarea:focus {
    outline: none;
    border-color: #6366f1;
    background: #1a1f2e;
}

.property-field textarea::placeholder {
    color: #6b7280;
}

#noteTooltip {
    position: fixed;
    background: #2d3142;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    padding: 8px 12px;
    max-width: 250px;
    font-size: 12px;
    color: #e5e7eb;
    line-height: 1.4;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    z-index: 10000;
    pointer-events: none;
    white-space: pre-wrap;
    word-wrap: break-word;
}

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

.checkbox-field input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-field label {
    font-size: 13px;
    font-weight: 500;
    color: #d1d5db;
    margin: 0;
    cursor: pointer;
}

#sidebarFooter {
    flex-shrink: 0;
    padding: 16px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#deleteNodeBtn {
    width: 100%;
    padding: 10px 16px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

#deleteNodeBtn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.5);
}

#confirmDialog,
#clearDialog,
#saveDialog,
#simConfigDialog,
#simProgressDialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    backdrop-filter: blur(4px);
}

#confirmDialog.open,
#clearDialog.open,
#saveDialog.open,
#simConfigDialog.open,
#simProgressDialog.open {
    display: flex;
}

.dialog-content {
    background: #2d3142;
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#saveDialog .dialog-content {
    max-width: 1200px;
    width: 90vw;
}

.dialog-content h3 {
    margin: 0 0 12px 0;
    font-size: 18px;
    font-weight: 600;
    color: #e5e7eb;
}

.dialog-content p {
    margin: 0 0 24px 0;
    font-size: 14px;
    color: #9ca3af;
    line-height: 1.5;
}

.dialog-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.dialog-buttons button {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.btn-cancel {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #d1d5db;
}

.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.05);
}

.btn-delete {
    background: #ef4444;
    border: 1px solid #ef4444;
    color: white;
}

.btn-delete:hover {
    background: #dc2626;
    border-color: #dc2626;
}

.btn-primary {
    background: #6366f1;
    border: 1px solid #6366f1;
    color: white;
}

.btn-primary:hover {
    background: #4f46e5;
    border-color: #4f46e5;
}

#simControlBar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(45, 49, 66, 0.95);
    backdrop-filter: blur(12px);
    border-radius: 12px;
    padding: 8px 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1000;
}

.sim-separator {
    width: 1px;
    height: 32px;
    background: rgba(255, 255, 255, 0.15);
    margin: 0 4px;
}

.sim-control-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
    transition: all 0.2s ease;
    color: white;
}

.sim-control-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.sim-control-btn:active {
    transform: scale(0.95);
}

.sim-control-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: scale(1);
}

.sim-control-btn:disabled:hover {
    transform: scale(1);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.sim-control-btn.active {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.6);
}

#simTrafficBtn {
    width: 40px;
    height: 40px;
    background: rgba(99, 102, 241, 0.2);
    box-shadow: none;
}

#simTrafficBtn:hover {
    background: rgba(99, 102, 241, 0.3);
    box-shadow: none;
}

#simTrafficBtn.active {
    background: rgba(99, 102, 241, 0.4);
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.4);
}

.sim-control-btn svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#simConfigBtn {
    width: 40px;
    height: 40px;
    background: rgba(99, 102, 241, 0.2);
    box-shadow: none;
}

#simConfigBtn:hover {
    background: rgba(99, 102, 241, 0.3);
    box-shadow: none;
}

#simSpeedControls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
    padding-left: 16px;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.sim-speed-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #9ca3af;
}

.sim-speed-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: #e5e7eb;
}

.sim-speed-btn:active {
    transform: scale(0.9);
}

.sim-speed-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
}

.sim-speed-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

#simSpeedDisplay {
    font-size: 14px;
    font-weight: 600;
    color: #e5e7eb;
    min-width: 36px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

#simTimer {
    font-size: 16px;
    font-weight: 600;
    color: #e5e7eb;
    font-family: 'Inter', monospace;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.5px;
    padding: 0 16px;
    min-width: 100px;
    text-align: center;
}

/* Simulation running state */
#simControlBar.running #simPlayPauseBtn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4);
}

#simControlBar.running #simPlayPauseBtn:hover {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

#simControlBar.paused #simPlayPauseBtn {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.4);
}

#simControlBar.paused #simPlayPauseBtn:hover {
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.5);
}

/* Stop button styling */
#simStopBtn {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
}

#simStopBtn:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5);
}

#simStopBtn:disabled {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    opacity: 0.5;
}

/* Chart tooltip */
#chartTooltip {
    position: fixed;
    padding: 6px 10px;
    background: rgba(17, 24, 39, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    font-size: 11px;
    color: #e5e7eb;
    pointer-events: none;
    z-index: 10000;
    display: none;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Load Profile UI */
#loadProfileSection h3 {
    font-size: 14px;
    font-weight: 600;
    color: #e5e7eb;
    margin: 0 0 16px 0;
}

#loadProfileSection h4 {
    font-size: 12px;
    font-weight: 500;
    color: #9ca3af;
    margin: 12px 0 8px 0;
}

.stages-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 12px 0 8px 0;
}

.stages-header span {
    font-size: 12px;
    font-weight: 500;
    color: #9ca3af;
}

.small-btn {
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 500;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 4px;
    color: #818cf8;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.small-btn:hover {
    background: rgba(99, 102, 241, 0.25);
    border-color: rgba(99, 102, 241, 0.5);
}

#stagesList {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 200px;
    overflow-y: auto;
}

.stage-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
}

.stage-row input[type="number"] {
    width: 50px;
    padding: 4px 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    color: #e5e7eb;
    font-size: 12px;
    font-family: 'Inter', sans-serif;
    text-align: center;
}

.stage-row input[type="number"]:focus {
    outline: none;
    border-color: #6366f1;
    background: rgba(99, 102, 241, 0.1);
}

.stage-row input[type="number"]::-webkit-inner-spin-button {
    opacity: 0.5;
}

.stage-unit {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
}

.stage-row select {
    padding: 4px 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    color: #e5e7eb;
    font-size: 11px;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
}

.stage-row select:focus {
    outline: none;
    border-color: #6366f1;
}

.stage-delete {
    padding: 2px 6px;
    background: transparent;
    border: none;
    color: rgba(239, 68, 68, 0.6);
    font-size: 14px;
    cursor: pointer;
    transition: color 0.2s;
}

.stage-delete:hover {
    color: #ef4444;
}

.stage-summary {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 8px;
    padding-left: 4px;
}

/* Curve Editor */
.curve-editor-container {
    background: #252547;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
    margin-top: 8px;
}

#curveEditorCanvas {
    width: 100%;
    height: 150px;
    display: block;
}

.curve-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.curve-controls span {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
}

/* Profile Preview */
.profile-preview-container {
    margin-top: 16px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
}

.profile-preview-container h4 {
    padding: 8px 12px;
    margin: 0;
    font-size: 11px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

#profilePreviewChart {
    width: 100%;
    height: 120px;
    display: block;
}

/* Toast notification */
#toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #334155;
    color: #e2e8f0;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    z-index: 10000;
}

#toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* =============================================================================
   SLO Section Styles
   ============================================================================= */

/* SLO Status Banner */
.slo-status-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
    font-size: 14px;
}

.slo-status-banner.slo-passing {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #10b981;
}

.slo-status-banner.slo-failing {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.slo-status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.slo-passing .slo-status-indicator {
    background: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.slo-failing .slo-status-indicator {
    background: #ef4444;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
    animation: slo-pulse 1.5s ease-in-out infinite;
}

@keyframes slo-pulse {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
    }
    50% {
        opacity: 0.7;
        box-shadow: 0 0 16px rgba(239, 68, 68, 0.8);
    }
}

.slo-status-banner.slo-unconfigured {
    background: rgba(107, 114, 128, 0.15);
    border: 1px solid rgba(107, 114, 128, 0.3);
    color: #9ca3af;
}

.slo-unconfigured .slo-status-indicator {
    background: #6b7280;
}

/* SLO Checks List */
.slo-checks-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.slo-check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.slo-check-icon {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.slo-check-icon.passing {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.slo-check-icon.failing {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.slo-check-icon svg {
    width: 12px;
    height: 12px;
}

.slo-check-label {
    flex: 1;
    font-size: 13px;
    color: #e2e8f0;
}

.slo-check-value {
    font-size: 12px;
    color: #94a3b8;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
}

/* SLO Risks List */
.slo-risks-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.slo-risk-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
}

.slo-risk-item.warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #fbbf24;
}

.slo-risk-item.critical {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.slo-risk-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}

.slo-risk-icon svg {
    width: 18px;
    height: 18px;
}

.slo-risk-message {
    flex: 1;
    line-height: 1.4;
}

.slo-risk-node {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 4px;
}

/* SLO Empty State */
.slo-empty-state {
    padding: 16px;
    text-align: center;
    color: #6b7280;
    font-size: 13px;
    font-style: italic;
}

/* SLO Dropdown Selector */
.slo-add-container {
    margin-bottom: 16px;
}

.slo-dropdown-wrapper {
    position: relative;
}

.slo-search-input {
    width: 100%;
    padding: 10px 12px;
    background: #1f2937;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #e5e7eb;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.slo-search-input:focus {
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.slo-search-input::placeholder {
    color: #6b7280;
}

.slo-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: #2d3142;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    max-height: 240px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.slo-dropdown-menu.open {
    display: block;
}

.slo-dropdown-option {
    padding: 10px 12px;
    font-size: 13px;
    color: #e2e8f0;
    cursor: pointer;
    transition: background-color 0.15s;
}

.slo-dropdown-option:hover,
.slo-dropdown-option.highlighted {
    background: rgba(99, 102, 241, 0.15);
}

.slo-dropdown-empty {
    padding: 16px 12px;
    font-size: 13px;
    color: #6b7280;
    font-style: italic;
    text-align: center;
}

/* Configured SLOs List */
.slo-configured-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.slo-config-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.slo-config-label {
    flex: 1;
    font-size: 13px;
    color: #e2e8f0;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.slo-config-input-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
}

.slo-config-input {
    width: 80px;
    padding: 6px 8px;
    background: #1f2937;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: #e5e7eb;
    font-size: 13px;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    text-align: right;
    outline: none;
    transition: border-color 0.2s;
}

.slo-config-input:focus {
    border-color: rgba(99, 102, 241, 0.5);
}

.slo-config-input.invalid {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.slo-config-unit {
    font-size: 12px;
    color: #9ca3af;
    width: 24px;
}

.slo-delete-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #6b7280;
    font-size: 18px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s;
    flex-shrink: 0;
}

.slo-delete-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* SLO Delete Dialog */
#sloDeleteDialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    backdrop-filter: blur(4px);
}

#sloDeleteDialog.open {
    display: flex;
}

/* =============================================================================
   Variables Panel Styles
   ============================================================================= */

#variablesPanel {
    position: fixed;
    top: 168px;
    left: 24px;
    width: 340px;
    background: rgba(45, 49, 66, 0.95);
    backdrop-filter: blur(12px);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 900;
    overflow: hidden;
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
}

#variablesPanel.open {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
}

#variablesPanelHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    cursor: move;
    user-select: none;
}

#variablesPanelButtons {
    display: flex;
    align-items: center;
    gap: 6px;
}

#closeVariablesBtn {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#closeVariablesBtn:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
}

#closeVariablesBtn svg {
    width: 14px;
    height: 14px;
    stroke: #6b7280;
    stroke-width: 2.5;
    stroke-linecap: round;
}

#closeVariablesBtn:hover svg {
    stroke: #ef4444;
}

#variablesPanelTitle {
    font-size: 13px;
    font-weight: 600;
    color: #e2e8f0;
    letter-spacing: 0.3px;
}

#addVariableBtn {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#addVariableBtn:hover {
    background: rgba(99, 102, 241, 0.25);
    border-color: rgba(99, 102, 241, 0.5);
}

#addVariableBtn svg {
    width: 14px;
    height: 14px;
    stroke: #818cf8;
    stroke-width: 2.5;
    stroke-linecap: round;
}

#variablesPinnedList,
#variablesUnpinnedList {
    display: flex;
    flex-direction: column;
}

.variable-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background-color 0.15s;
}

.variable-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.variable-row.selected {
    background: rgba(99, 102, 241, 0.1);
}

.variable-row.glowing {
    box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.5), 0 0 12px rgba(99, 102, 241, 0.3);
    animation: variable-glow 0.5s ease-out;
}

@keyframes variable-glow {
    0% {
        box-shadow: inset 0 0 0 2px rgba(99, 102, 241, 0.8), 0 0 20px rgba(99, 102, 241, 0.5);
    }
    100% {
        box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.5), 0 0 12px rgba(99, 102, 241, 0.3);
    }
}

.variable-pin-btn {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
    color: #4b5563;
}

.variable-pin-btn:hover {
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
}

.variable-pin-btn.pinned {
    color: #f59e0b;
}

.variable-pin-btn svg {
    width: 14px;
    height: 14px;
}

.variable-label {
    width: 90px;
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 500;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.variable-value-input {
    flex: 1;
    min-width: 0;
    padding: 5px 10px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    color: #e2e8f0;
    font-size: 13px;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    text-align: right;
    transition: border-color 0.2s, box-shadow 0.2s;
    /* Hide spinner buttons */
    -moz-appearance: textfield;
}

.variable-value-input::-webkit-outer-spin-button,
.variable-value-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.variable-value-input:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.variable-unit {
    font-size: 11px;
    color: #64748b;
    width: 24px;
    flex-shrink: 0;
    text-align: left;
}

.variable-delete-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border-radius: 4px;
    background: rgba(45, 49, 66, 0.95);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    color: #4b5563;
    opacity: 0;
    pointer-events: none;
}

.variable-row:hover .variable-delete-btn {
    opacity: 1;
    pointer-events: all;
}

.variable-delete-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.variable-delete-btn svg {
    width: 14px;
    height: 14px;
}

#variablesExpandSection {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

#variablesExpandHeader {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background-color 0.15s;
    color: #64748b;
    font-size: 12px;
}

#variablesExpandHeader:hover {
    background: rgba(255, 255, 255, 0.03);
}

#variablesExpandHeader .expand-icon {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2;
    transition: transform 0.2s;
}

#variablesExpandHeader.expanded .expand-icon {
    transform: rotate(180deg);
}

#variablesExpandLabel {
    flex: 1;
}

/* Add Variable Dialog */
#addVariableDialog,
#deleteVariableDialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    backdrop-filter: blur(4px);
}

#addVariableDialog.open,
#deleteVariableDialog.open {
    display: flex;
}

/* Variable Reference Styles (for sidebar inputs) */
.property-field input.has-variable-ref,
.property-field input[data-variable-ref] {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
    color: #818cf8;
}

.property-field .variable-ref-hint {
    display: block;
    font-size: 11px;
    color: #64748b;
    margin-top: 4px;
}

.property-field .variable-ref-hint.resolved {
    color: #818cf8;
}

/* Variable Glow Effect on Canvas Nodes */
.node-variable-glow {
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.6), 0 0 40px rgba(99, 102, 241, 0.3);
    animation: node-variable-glow 0.5s ease-out;
}

@keyframes node-variable-glow {
    0% {
        box-shadow: 0 0 30px rgba(99, 102, 241, 0.8), 0 0 60px rgba(99, 102, 241, 0.5);
    }
    100% {
        box-shadow: 0 0 20px rgba(99, 102, 241, 0.6), 0 0 40px rgba(99, 102, 241, 0.3);
    }
}

/* Variable autocomplete dropdown */
.variable-autocomplete {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: #2d3142;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.variable-autocomplete-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.15s;
}

.variable-autocomplete-item:hover,
.variable-autocomplete-item.highlighted {
    background: rgba(99, 102, 241, 0.15);
}

.variable-autocomplete-item .var-name {
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 12px;
    color: #818cf8;
}

.variable-autocomplete-item .var-label {
    flex: 1;
    font-size: 12px;
    color: #94a3b8;
}

.variable-autocomplete-item .var-value {
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 11px;
    color: #64748b;
}

/* Variable pill display in inputs */
.variable-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 4px;
    color: #818cf8;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.variable-pill:hover {
    background: rgba(99, 102, 241, 0.25);
    border-color: rgba(99, 102, 241, 0.5);
}
