/* ========================================
   Pipeline Builder Styles
   ======================================== */

.page-pipeline-builder {
    overflow: hidden;
}

html.page-pipeline-builder,
body.page-pipeline-builder {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

.pipeline-main {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    padding-top: 72px;
}


/* Enterprise Required Banner */
.pipeline-main .enterprise-required-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(57, 151, 151, 0.1);
    border: 1px solid rgba(57, 151, 151, 0.3);
    border-radius: 8px;
    padding: 12px 20px;
    margin: 12px 20px 0;
    color: var(--text-medium);
    flex-shrink: 0;
}

.pipeline-main .enterprise-required-banner svg {
    color: var(--primary);
    flex-shrink: 0;
}

.pipeline-main .enterprise-required-banner span {
    flex: 1;
    font-size: 14px;
}

.pipeline-main .enterprise-required-banner .btn {
    padding: 4px 12px;
    font-size: 12px;
    flex-shrink: 0;
}

/* ========================================
   Toolbar
   ======================================== */

.pipeline-toolbar {
    background: var(--bg-pane);
    border-bottom: 1px solid var(--border-divider);
    flex-shrink: 0;
    row-gap: 8px;
}

/* Touch drag clone styling */
.touch-drag-clone {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Ensure toolbar buttons don't grow */
.pipeline-toolbar .btn {
    flex-shrink: 0;
}

/* Run button - match model-zoo test button size */
#btnExecute {
    padding: 6px 16px;
    font-size: 13px;
}

/* Pipeline name input - keep width constraint */
.pipeline-name-input {
    width: 220px;
    font-weight: 600;
}

/* Unsaved changes indicator on save button */
.btn.has-changes {
    border-style: dashed !important;
    border-color: var(--warning) !important;
}

/* Toolbar inline image drop */
.toolbar-image-drop {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    background: var(--bg-input);
    border: 2px dashed var(--border-input);
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 280px;
    height: 48px;
}

.toolbar-image-drop:hover {
    border-color: var(--border-primary);
    background: var(--hover-primary);
}

.toolbar-image-drop.drag-over {
    border-color: var(--teal-500);
    border-style: solid;
    background: rgba(57, 151, 151, 0.15);
}

.toolbar-image-drop.has-image {
    border-style: solid;
    border-color: var(--teal-500);
    padding: 4px;
    min-width: auto;
    max-width: 400px;
}

.drop-prompt {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-subtle);
    font-size: 13px;
}

.drop-prompt svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.drop-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: 100%;
}

.drop-preview.hidden {
    display: none;
}

.drop-preview img {
    height: 40px;
    max-width: 300px;
    object-fit: contain;
    border-radius: 4px;
}

.clear-image-btn {
    background: none;
    border: none;
    color: var(--text-subtle);
    font-size: 20px;
    cursor: pointer;
    padding: 0 6px;
    line-height: 1;
    margin-left: auto;
}

.clear-image-btn:hover {
    color: var(--error);
}

/* ========================================
   Workspace Layout
   ======================================== */

.pipeline-workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 360px;
    background: var(--bg-pane);
    border-right: 1px solid var(--border-divider);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.2s ease;
    position: relative;
}

.sidebar.collapsed {
    width: 48px;
}

.sidebar.collapsed .sidebar-header,
.sidebar.collapsed .model-list,
.sidebar.collapsed .nav-tabs,
.sidebar.collapsed .tab-content {
    display: none;
}

.sidebar-toggle {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    background: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: 6px;
    color: var(--text-subtle);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    z-index: 10;
}

.sidebar-toggle:hover {
    background: var(--hover-default);
    color: var(--text-high);
    border-color: var(--border-primary);
}

.sidebar.collapsed .sidebar-toggle {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
}

.sidebar.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

.right-sidebar .sidebar-toggle svg {
    transform: rotate(180deg);
}

.right-sidebar.collapsed .sidebar-toggle svg {
    transform: rotate(0deg);
}

.right-sidebar {
    border-right: none;
    border-left: 1px solid var(--border-divider);
}

/* Sidebar header uses Bootstrap classes now */
.sidebar-header {
    border-color: var(--border-divider) !important;
}

/* ========================================
   Model Palette
   ======================================== */

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

.model-section {
    margin-bottom: 20px;
}

.model-section h4 {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding: 0 4px;
}

.palette-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: grab;
    transition: all var(--transition-fast);
}

.palette-item:hover {
    border-color: var(--border-primary);
    background: var(--hover-primary);
}

.palette-item:active {
    cursor: grabbing;
}

.palette-item.dragging {
    opacity: 0.5;
}

.palette-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--icon-medium);
}

.palette-icon.start {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.palette-icon.end {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.palette-icon.detector {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
}

.palette-icon.classifier {
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
}

.palette-icon.adaptive {
    background: rgba(57, 151, 151, 0.15);
    color: var(--teal-500);
}

.palette-item span {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-high);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.palette-item .model-type-tag {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-subtle);
    margin-left: auto;
}

/* ========================================
   Canvas
   ======================================== */

.canvas-container {
    flex: 1;
    position: relative;
    background: var(--bg-app);
    background-image:
        radial-gradient(circle, var(--neutral-800) 1px, transparent 1px);
    background-size: 20px 20px;
    overflow: hidden;
    cursor: grab;
}

.canvas-container.panning {
    cursor: grabbing;
}

.canvas-viewport {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: 0 0;
    will-change: transform;
}

#pipelineCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.canvas-nodes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.canvas-nodes .pipeline-node {
    pointer-events: auto;
}

.canvas-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-subtle);
    font-size: 14px;
    pointer-events: none;
    text-align: center;
}

.zoom-indicator {
    position: absolute;
    bottom: 16px;
    right: 16px;
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-medium);
    pointer-events: none;
    opacity: 0.8;
    z-index: 10;
}

/* ========================================
   Pipeline Nodes
   ======================================== */

.pipeline-node {
    position: absolute;
    min-width: 160px;
    background: var(--bg-card);
    border: 2px solid var(--border-card);
    border-radius: 12px;
    cursor: grab;
    user-select: none;
    transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
    /* For handle positioning */
    overflow: visible;
}

.pipeline-node:active {
    cursor: grabbing;
}

.pipeline-node:hover {
    border-color: var(--border-primary);
}

.pipeline-node.selected {
    border-color: var(--teal-500);
    box-shadow: 0 0 0 3px rgba(57, 151, 151, 0.2), 0 8px 24px rgba(0, 0, 0, 0.3);
}

.pipeline-node.running {
    border-color: var(--warning);
    animation: nodePulse 1.5s ease-in-out infinite;
}

.pipeline-node.completed {
    border-color: var(--success);
}

.pipeline-node.failed {
    border-color: var(--error);
}

.pipeline-node.empty {
    border-color: #f97316;
    opacity: 0.8;
}

.pipeline-node.empty::after {
    content: '∅';
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 12px;
    color: #f97316;
    z-index: 5;
}

@keyframes nodePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); }
}

.node-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-divider);
}

.node-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    flex-shrink: 0;
}

.node-icon.start {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.node-icon.end {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.node-icon.detector {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
}

.node-icon.classifier,
.node-icon.adaptive {
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
}

.node-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-high);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.node-body {
    padding: 8px 12px;
    font-size: 11px;
    color: var(--text-subtle);
}

/* Node Handles */
.node-handles {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.node-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background: var(--bg-input);
    border: 2px solid var(--teal-600);
    border-radius: 50%;
    cursor: crosshair;
    transition: all var(--transition-fast);
    z-index: 10;
    pointer-events: auto;
}

.node-handle:hover {
    background: var(--teal-500);
    border-color: var(--teal-500);
    transform: scale(1.4);
    box-shadow: 0 0 8px rgba(57, 151, 151, 0.5);
}

.node-handle.input {
    top: 50%;
    left: -7px;
    transform: translateY(-50%);
}

.node-handle.output {
    top: 50%;
    right: -7px;
    transform: translateY(-50%);
}

.node-handle.connecting {
    background: var(--teal-500);
    border-color: var(--teal-500);
}

/* Output ports for conditional routing */
.node-outputs {
    padding: 4px 12px 10px;
    border-top: 1px solid var(--border-divider);
}

.output-port {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
    margin-top: 4px;
    position: relative;
    background: var(--bg-input);
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-medium);
    position: relative;
}

.output-port .node-handle {
    position: absolute;
    right: -19px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: auto;
}

.output-port .count-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 8px;
    background: var(--teal-600);
    color: white;
    margin-left: auto;
    margin-right: 20px;
}

.output-port .count-badge.zero {
    background: var(--bg-card);
    color: var(--text-subtle);
}

/* ========================================
   Right Sidebar Tabs (Bootstrap nav-tabs override)
   ======================================== */

.right-sidebar .nav-tabs {
    border-bottom-color: var(--border-divider);
}

.right-sidebar .nav-link {
    color: var(--text-subtle);
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
}

.right-sidebar .nav-link:hover {
    color: var(--text-medium);
    border-color: transparent;
}

.right-sidebar .nav-link.active {
    color: var(--teal-500);
    background: transparent;
    border-bottom-color: var(--teal-500);
}

.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

/* ========================================
   Inspector
   ======================================== */

/* Results content layout */
.results-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

.results-visualization {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    cursor: pointer;
}

.results-visualization canvas {
    display: block;
    width: 100%;
    height: auto;
}

.results-visualization:hover {
    border-color: var(--border-primary);
}

/* Fullscreen visualization overlay */
.viz-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    cursor: zoom-out;
}

.viz-overlay canvas {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
}

/* Lightbox for detection thumbnails */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: lightbox-fade-in 0.2s ease;
}

@keyframes lightbox-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.lightbox-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    max-width: 90vw;
    max-height: 90vh;
}

.lightbox-image {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.lightbox-label {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    text-align: center;
}

.lightbox-close {
    position: absolute;
    top: 24px;
    right: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 8px;
    color: var(--text-high);
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    z-index: 2001;
}

.lightbox-close:hover {
    background: var(--bg-input);
    border-color: var(--border-primary);
}

/* Output label chips - Bootstrap badge style */
.output-label-chip {
    padding: 4px 10px;
    background: var(--bg-input);
    border-radius: 12px;
    font-size: 12px;
    color: var(--text-medium);
}

/* ========================================
   Results Panel
   ======================================== */

.results-summary {
    padding: 12px;
    background: var(--bg-input);
    border-radius: 8px;
    flex-shrink: 0;
}

.results-nodes {
    flex: 1;
    overflow-y: auto;
}

.results-summary .summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 6px;
}

.results-summary .summary-row:last-child {
    margin-bottom: 0;
}

.results-summary .summary-label {
    color: var(--text-subtle);
}

.results-summary .summary-value {
    color: var(--text-high);
    font-weight: 500;
}

.result-node {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}

.result-node-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-input);
    cursor: pointer;
}

.result-node-header .node-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-high);
}

.result-node-header .node-status {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.result-node-header .node-status.completed {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.result-node-header .node-status.failed {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.result-node-header .node-status.skipped {
    background: rgba(100, 116, 139, 0.15);
    color: #64748b;
}

.result-node-header .node-status.empty {
    background: rgba(249, 115, 22, 0.15);
    color: #f97316;
}

.result-node-header .node-status.running {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
    display: flex;
    align-items: center;
    gap: 4px;
}

.result-node-header .node-status.running::before {
    content: '';
    width: 10px;
    height: 10px;
    border: 2px solid var(--warning);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spinnerRotate 0.8s linear infinite;
}

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

.result-node-header .result-count {
    font-size: 11px;
    color: var(--text-subtle);
    margin-left: 6px;
}

.result-node-body {
    padding: 12px;
}

.result-node:not(.expanded) .result-node-body {
    display: none;
}

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

.detection-item {
    text-align: center;
}

.detection-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border-card);
    cursor: zoom-in;
    transition: border-color var(--transition-fast), opacity var(--transition-fast);
}

.detection-item img:hover {
    border-color: var(--border-primary);
    opacity: 0.9;
}

.detection-item .detection-label {
    font-size: 11px;
    color: var(--text-medium);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detection-item .detection-conf {
    font-size: 10px;
    color: var(--text-subtle);
}

.result-classification {
    padding: 8px;
    background: var(--bg-input);
    border-radius: 6px;
}

.classification-thumb {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border-default);
    margin-bottom: 8px;
    cursor: zoom-in;
}

.classification-thumb:hover {
    border-color: var(--border-primary);
    opacity: 0.9;
}

.classification-result {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.classification-scores {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.score-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.score-label {
    width: 80px;
    color: var(--text-medium);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.score-bar {
    flex: 1;
    height: 6px;
    background: var(--bg-card);
    border-radius: 3px;
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    background: var(--teal-500);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.score-value {
    width: 40px;
    text-align: right;
    color: var(--text-subtle);
}

/* Multi-classification grid (for classifiers receiving multiple inputs) */
.result-classifications {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
}

.classification-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 8px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border-default);
}

.classification-item .classification-thumb {
    width: 80px;
    height: 80px;
    margin-bottom: 6px;
}

.classification-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-word;
}

.classification-conf {
    font-size: 11px;
    color: var(--text-subtle);
}

/* Classification scores grid layout */
.classification-scores-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.score-grid-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    background: var(--bg-card);
    border-radius: 6px;
    border: 1px solid var(--border-card);
}

.score-grid-item.predicted {
    border-color: var(--teal-500);
    background: rgba(57, 151, 151, 0.1);
}

.score-grid-item .score-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-high);
    width: auto;
}

.score-grid-item .score-bar {
    height: 4px;
}

.score-grid-item .score-value {
    font-size: 11px;
    width: auto;
    text-align: left;
}

/* ========================================
   JSON Viewer
   ======================================== */

.results-json-section {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 8px;
    margin-top: 12px;
    overflow: hidden;
}

.json-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-input);
    cursor: pointer;
    user-select: none;
}

.json-header:hover {
    background: var(--hover-default);
}

.json-chevron {
    transition: transform 0.2s ease;
    color: var(--text-subtle);
}

.results-json-section.expanded .json-chevron {
    transform: rotate(90deg);
}

.json-header span {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-medium);
}

.json-copy-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-subtle);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.json-copy-btn:hover {
    color: var(--text-high);
    background: var(--bg-card);
}

.json-content {
    display: none;
    max-height: 300px;
    overflow: auto;
}

.results-json-section.expanded .json-content {
    display: block;
}

.json-content pre {
    margin: 0;
    padding: 12px;
    font-size: 11px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    color: var(--text-medium);
    white-space: pre-wrap;
    word-break: break-all;
}

/* ========================================
   Node Thumbnail Badge
   ======================================== */

.node-thumbnail-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 2px solid var(--teal-500);
    background: var(--bg-card);
    overflow: hidden;
    cursor: pointer;
    z-index: 20;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.node-thumbnail-badge:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 30;
}

.node-thumbnail-badge img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.node-thumbnail-badge .badge-count {
    position: absolute;
    bottom: 0;
    right: 0;
    background: var(--teal-600);
    color: white;
    font-size: 9px;
    font-weight: 600;
    padding: 1px 4px;
    border-radius: 3px 0 0 0;
}

/* ========================================
   Legacy Modals (scoped to .modal-overlay)
   Bootstrap modals use .modal as the overlay itself
   ======================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none;
}

/* Scoped to .modal-overlay to avoid Bootstrap conflicts */
.modal-overlay .modal {
    background: var(--bg-pane);
    border: 1px solid var(--border-divider);
    border-radius: 16px;
    width: 90%;
    max-width: 480px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

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

.modal-overlay .modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-high);
}

.modal-overlay .modal-close {
    background: none;
    border: none;
    color: var(--text-subtle);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

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

.modal-overlay .modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-overlay .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-divider);
}

/* Bootstrap handles btn styles via bootstrap-theme.css */

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--border-input);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.upload-zone:hover {
    border-color: var(--border-primary);
    background: var(--hover-primary);
}

.upload-zone svg {
    color: var(--text-subtle);
    margin-bottom: 12px;
}

.upload-zone p {
    color: var(--text-medium);
    font-size: 14px;
}

.upload-zone.drag-over {
    border-color: var(--teal-500);
    background: rgba(57, 151, 151, 0.1);
}

.upload-preview {
    text-align: center;
}

.upload-preview.hidden {
    display: none;
}

.upload-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    margin-bottom: 12px;
}

.change-image-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
}

.change-image-btn:hover {
    text-decoration: underline;
}

/* Pipeline List in Load Modal */
.pipeline-list {
    max-height: 400px;
    overflow-y: auto;
}

.pipeline-list .loading {
    color: var(--text-subtle);
    text-align: center;
    padding: 20px;
}

.pipeline-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.pipeline-list-item:hover {
    border-color: var(--border-primary);
}

.pipeline-list-item .pipeline-info {
    flex: 1;
}

.pipeline-list-item .pipeline-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-high);
}

.pipeline-list-item .pipeline-meta {
    font-size: 12px;
    color: var(--text-subtle);
    margin-top: 2px;
}

.pipeline-list-item .pipeline-actions {
    display: flex;
    gap: 8px;
}

.pipeline-list-item .delete-btn {
    padding: 6px;
    background: none;
    border: none;
    color: var(--text-subtle);
    cursor: pointer;
    border-radius: 4px;
    transition: all var(--transition-fast);
}

.pipeline-list-item .delete-btn:hover {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

.pipeline-list-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-subtle);
}

/* ========================================
   Toast Notifications (custom style, Bootstrap positioning)
   ======================================== */

.toast-container {
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Custom toast styling (not using Bootstrap toast component) */
.toast-container > .toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    animation: toastSlideIn 0.3s ease;
    max-width: 360px;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast-container > .toast.success {
    border-color: rgba(34, 197, 94, 0.3);
}

.toast-container > .toast.error {
    border-color: rgba(239, 68, 68, 0.3);
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.toast-container > .toast.success .toast-icon {
    color: var(--success);
}

.toast-container > .toast.error .toast-icon {
    color: var(--error);
}

.toast-message {
    font-size: 13px;
    color: var(--text-high);
}

/* ========================================
   Accessibility
   ======================================== */

/* Focus states for custom interactive elements (Bootstrap handles .btn, .form-control) */
.sidebar-toggle:focus-visible,
.palette-item:focus-visible,
.pipeline-list-item:focus-visible,
.node-handle:focus-visible,
.json-copy-btn:focus-visible,
.lightbox-close:focus-visible {
    outline: 2px solid var(--teal-500);
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 1200px) {
    .sidebar {
        width: 300px;
    }
}

/* Tablet/landscape mobile breakpoint */
@media (max-width: 991px) {
    .pipeline-main {
        padding-top: 60px;
    }

    .pipeline-name-input {
        width: min(180px, 100%);
    }

    .toolbar-image-drop {
        min-width: min(200px, 100%);
        height: 44px;
    }

    /* Toast responsive - move above mobile toggles */
    .toast-container {
        bottom: 80px !important;
    }

    .toast-container > .toast {
        max-width: 320px;
    }

    .lightbox-close {
        top: 12px;
        right: 12px;
    }

    .classification-scores-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   Portrait Phone - Show rotate message
   ======================================== */

.rotate-device-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-app);
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
}

.rotate-device-overlay svg {
    width: 64px;
    height: 64px;
    color: var(--teal-500);
    margin-bottom: 24px;
    animation: rotateHint 2s ease-in-out infinite;
}

@keyframes rotateHint {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
}

.rotate-device-overlay h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-high);
    margin-bottom: 12px;
}

.rotate-device-overlay p {
    font-size: 14px;
    color: var(--text-subtle);
    max-width: 280px;
}

/* Show overlay and hide app on portrait phones */
@media (max-width: 767px) and (orientation: portrait) {
    .rotate-device-overlay {
        display: flex;
    }

    .pipeline-main,
    .page-pipeline-builder .navbar {
        display: none !important;
    }
}

/* ========================================
   Pipeline Result Lightbox
   ======================================== */

.pipeline-result-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.pipeline-result-lightbox.hidden {
    display: none;
}

.pipeline-result-lightbox-dialog {
    background: var(--bg-app, #0a0d0d);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    width: 90vw;
    max-width: 1400px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pipeline-result-lightbox-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.pipeline-result-lightbox-title {
    font-size: 0.875rem;
    color: #94a3b8;
}

.pipeline-result-lightbox-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.pipeline-result-lightbox-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.pipeline-result-lightbox-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    min-height: 0;
    overflow: hidden;
}

.pipeline-result-lightbox-body canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

/* Make inline result canvas clickable */
.results-visualization {
    cursor: pointer;
}

.results-visualization:hover {
    opacity: 0.9;
}

/* ========================================
   Landscape Phone — Compact header/toolbar
   Targets phones in landscape (short viewports)
   ======================================== */

@media (max-height: 500px) and (orientation: landscape) {
    /* Compact navbar — hide nav links, keep brand + user badge */
    .page-pipeline-builder .navbar {
        --bs-navbar-padding-y: 0.25rem;
    }
    .page-pipeline-builder .navbar .navbar-brand img {
        height: 24px !important;  /* override inline style */
    }
    .page-pipeline-builder .navbar .brand-text {
        font-size: 1rem;
    }
    /* Hide expanded nav links + toggler — user is already on the page */
    .page-pipeline-builder .navbar .navbar-collapse {
        display: none !important;
    }
    .page-pipeline-builder .navbar .navbar-toggler {
        display: none !important;
    }
    /* Force user badge area visible even on <768px phones */
    .page-pipeline-builder .navbar .d-none.d-md-flex {
        display: flex !important;
    }
    /* Hide Enquire button — save horizontal space for badge */
    .page-pipeline-builder .navbar .navbar-enquire-btn {
        display: none !important;
    }

    .pipeline-main {
        padding-top: 44px;
    }

    /* Task 2: Compact toolbar */
    .pipeline-toolbar {
        padding-top: 2px !important;
        padding-bottom: 2px !important;
        row-gap: 2px;
    }
    .pipeline-toolbar .btn-sm {
        padding: 2px 6px;
        font-size: 12px;
    }
    .pipeline-toolbar .form-control-sm {
        padding: 2px 8px;
        height: 28px;
    }
    .toolbar-image-drop {
        height: 32px !important;
        min-height: 32px;
    }

    /* Hide enterprise banner — too expensive in landscape phone */
    .enterprise-required-banner {
        display: none !important;
    }
}
