/* ============================================
   CoderAI Edge Command Center
   Premium UI - Vercel/Figma Inspired
   Light Blue Edition
   ============================================ */

/* CSS Custom Properties - Design Tokens */
:root {
    /* Colors - Light Blue Theme */
    --bg-primary: #eef2ff;
    --bg-secondary: #e4e9f7;
    --bg-tertiary: #dde3f0;
    --bg-elevated: #f8faff;
    --bg-hover: #e0e7ff;
    --bg-active: #c7d2fe;

    /* Border Colors */
    --border-subtle: rgba(99, 102, 241, 0.10);
    --border-default: rgba(99, 102, 241, 0.18);
    --border-strong: rgba(99, 102, 241, 0.28);

    /* Text Colors */
    --text-primary: #1a1a2e;
    --text-secondary: #4a4a6a;
    --text-tertiary: #6b6b8a;
    --text-quaternary: #8a8aaa;

    /* Accent Colors */
    --accent-primary: #4f46e5;
    --accent-primary-hover: #4338ca;
    --accent-secondary: #7c3aed;
    --accent-success: #16a34a;
    --accent-warning: #d97706;
    --accent-error: #dc2626;

    /* Unit Colors */
    --perception-color: #2563eb;
    --cognition-color: #7c3aed;
    --action-color: #d97706;
    --planner-color: #059669;
    --research-color: #0891b2;
    --execution-color: #d97706;
    --validator-color: #7c3aed;
    --memory-color: #db2777;
    --broker-color: #4f46e5;
    --cost-color: #16a34a;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(99, 102, 241, 0.08);
    --shadow-md: 0 4px 6px -1px rgba(99, 102, 241, 0.08), 0 2px 4px -2px rgba(99, 102, 241, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(99, 102, 241, 0.10), 0 4px 6px -4px rgba(99, 102, 241, 0.08);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.12);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, monospace;

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
}

/* Background Effects */
.bg-gradient {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(99, 102, 241, 0.08), transparent),
        radial-gradient(ellipse 60% 40% at 100% 100%, rgba(139, 92, 246, 0.06), transparent);
    pointer-events: none;
    z-index: 0;
}

.bg-noise {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0.015;
    pointer-events: none;
    z-index: 0;
}

.bg-grid-subtle {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        linear-gradient(rgba(99, 102, 241, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(99, 102, 241, 0.04) 1px, transparent 1px);
    background-size: 64px 64px;
    pointer-events: none;
    z-index: 0;
}

/* App Shell */
.app-shell {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* ============================================
   TOP NAVIGATION
   ============================================ */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 var(--space-5);
    background: rgba(238, 242, 255, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
}

.nav-left {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.brand-logo {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.brand-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.brand-tag {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-tertiary);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.nav-divider {
    width: 1px;
    height: 24px;
    background: var(--border-default);
}

.nav-breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 13px;
}

.breadcrumb-item {
    color: var(--text-tertiary);
}

.breadcrumb-item.active {
    color: var(--text-secondary);
}

.breadcrumb-separator {
    color: var(--text-quaternary);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.status-pill {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3);
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    color: var(--accent-success);
}

.status-pill.offline {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
    color: var(--accent-error);
}

.status-dot {
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.2); }
}

.edge-badge {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    color: var(--accent-primary-hover);
}

/* ============================================
   MAIN CONTENT LAYOUT
   ============================================ */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 280px 1fr 300px;
    gap: 1px;
    background: var(--border-subtle);
    overflow: hidden;
}

/* ============================================
   LEFT PANEL - AGENT FLEET
   ============================================ */
.left-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-elevated);
    overflow: hidden;
}

.panel-header {
    padding: var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
}

.panel-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-2);
}

.fleet-count {
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
}

.count-number {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.count-label {
    font-size: 13px;
    color: var(--text-tertiary);
}

/* Agent Grid Visualization */
.agent-grid-container {
    position: relative;
    flex: 1;
    min-height: 200px;
    overflow: hidden;
}

.agent-grid {
    display: grid;
    grid-template-columns: repeat(40, 1fr);
    gap: 2px;
    padding: var(--space-4);
    height: 100%;
}

.agent-dot {
    aspect-ratio: 1;
    background: var(--bg-hover);
    border-radius: 1px;
    transition: all var(--transition-fast);
}

.agent-dot.active {
    background: var(--accent-primary);
    box-shadow: 0 0 4px var(--accent-primary);
}

.agent-dot.spawning {
    animation: spawn-pulse 0.5s ease-out;
}

@keyframes spawn-pulse {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.5); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, transparent 60%, var(--bg-secondary));
    pointer-events: none;
}

/* Active Units */
.active-units {
    padding: var(--space-4);
    border-top: 1px solid var(--border-subtle);
}

.units-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-3);
}

.units-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.units-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    background: var(--bg-hover);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
}

.unit-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.unit-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.unit-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-default);
}

.unit-item.active {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 1px var(--accent-primary);
}

.unit-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-quaternary);
}

.unit-item.perception .unit-indicator { background: var(--perception-color); }
.unit-item.cognition .unit-indicator { background: var(--cognition-color); }
.unit-item.action .unit-indicator { background: var(--action-color); }
.unit-item.planner .unit-indicator { background: var(--planner-color); }
.unit-item.research .unit-indicator { background: var(--research-color); }
.unit-item.execution .unit-indicator { background: var(--execution-color); }
.unit-item.validator .unit-indicator { background: var(--validator-color); }
.unit-item.memory .unit-indicator { background: var(--memory-color); }
.unit-item.broker .unit-indicator { background: var(--broker-color); }
.unit-item.cost .unit-indicator { background: var(--cost-color); }

.unit-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.unit-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.unit-status {
    font-size: 11px;
    color: var(--text-tertiary);
}

.unit-metric {
    display: flex;
    align-items: baseline;
    gap: 2px;
    font-family: var(--font-mono);
}

.unit-metric .metric-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.unit-metric .metric-unit {
    font-size: 10px;
    color: var(--text-tertiary);
}

/* Spawn Controls */
.spawn-controls {
    padding: var(--space-4);
    border-top: 1px solid var(--border-subtle);
}

.spawn-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    width: 100%;
    padding: var(--space-3);
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border: none;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    color: #f8faff;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.spawn-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

.spawn-btn:active {
    transform: translateY(0);
}

.spawn-stats {
    display: flex;
    justify-content: space-between;
    margin-top: var(--space-3);
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-item .stat-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.stat-item .stat-label {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* ============================================
   CENTER PANEL - COMMAND INTERFACE
   ============================================ */
.center-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    overflow: hidden;
}

/* Pipeline Visualization */
.pipeline-viz {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: var(--space-6) var(--space-8);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
}

.pipeline-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3);
    transition: all var(--transition-base);
}

.pipeline-stage.active .stage-icon {
    transform: scale(1.1);
    box-shadow: 0 0 20px currentColor;
}

.stage-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    color: var(--text-tertiary);
    transition: all var(--transition-base);
}

.stage-icon.perception { color: var(--perception-color); border-color: rgba(37, 99, 235, 0.3); }
.stage-icon.cognition { color: var(--cognition-color); border-color: rgba(124, 58, 237, 0.3); }
.stage-icon.action { color: var(--action-color); border-color: rgba(217, 119, 6, 0.3); }

.stage-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.pipeline-connector {
    width: 40px;
    height: 2px;
    background: var(--border-default);
    position: relative;
    overflow: hidden;
}

.connector-line {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--border-default);
}

.connector-pulse {
    position: absolute;
    top: 0;
    left: -20px;
    width: 20px;
    height: 100%;
    background: linear-gradient(90deg, transparent, var(--accent-primary), transparent);
    animation: connector-flow 2s linear infinite;
    opacity: 0;
}

.pipeline-stage.active + .pipeline-connector .connector-pulse,
.pipeline-connector:has(+ .pipeline-stage.active) .connector-pulse {
    opacity: 1;
}

@keyframes connector-flow {
    0% { left: -20px; }
    100% { left: 100%; }
}

/* Response Area */
.response-area {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-6);
}

.response-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-tertiary);
}

.welcome-icon {
    margin-bottom: var(--space-4);
    color: var(--text-quaternary);
}

.welcome-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.welcome-text {
    font-size: 14px;
    color: var(--text-tertiary);
}

/* Response Messages */
.response-message {
    max-width: 720px;
    margin: 0 auto var(--space-4);
    animation: message-in 0.3s ease-out;
}

@keyframes message-in {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

.message-user {
    display: flex;
    justify-content: flex-end;
}

.message-user .message-content {
    background: var(--accent-primary);
    color: #f8faff;
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-lg);
}

.message-system {
    display: flex;
    justify-content: flex-start;
}

.message-system .message-content {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-sm);
}

.message-content {
    padding: var(--space-4);
    font-size: 14px;
    line-height: 1.6;
    max-width: 80%;
}

.message-meta {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-2);
    font-size: 11px;
    color: var(--text-quaternary);
}

/* Command Input Area */
.command-area {
    padding: var(--space-4) var(--space-6);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
}

.input-container {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    transition: all var(--transition-fast);
}

.input-container:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.voice-btn-container {
    position: relative;
}

.voice-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-hover);
    border: none;
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.voice-btn:hover {
    background: var(--bg-active);
    color: var(--text-primary);
}

.voice-btn.listening {
    background: var(--accent-error);
    color: #fef2f2;
}

.voice-btn.listening .mic-icon {
    display: none;
}

.voice-btn .voice-waves {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 20px;
}

.voice-btn.listening .voice-waves {
    display: flex;
}

.voice-waves span {
    width: 3px;
    height: 100%;
    background: var(--accent-primary);
    border-radius: 2px;
    animation: wave 0.5s ease-in-out infinite;
}

.voice-waves span:nth-child(1) { animation-delay: 0s; }
.voice-waves span:nth-child(2) { animation-delay: 0.1s; }
.voice-waves span:nth-child(3) { animation-delay: 0.2s; }
.voice-waves span:nth-child(4) { animation-delay: 0.1s; }
.voice-waves span:nth-child(5) { animation-delay: 0s; }

@keyframes wave {
    0%, 100% { height: 30%; }
    50% { height: 100%; }
}

#command-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--text-primary);
    resize: none;
    line-height: 1.5;
    max-height: 120px;
}

#command-input::placeholder {
    color: var(--text-quaternary);
}

.send-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-lg);
    color: #f8faff;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.send-btn:hover {
    background: var(--accent-primary-hover);
    transform: scale(1.05);
}

.send-btn:active {
    transform: scale(0.95);
}

.upload-btn,
.ocr-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-hover);
    border: none;
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.upload-btn:hover,
.ocr-btn:hover:not(:disabled) {
    background: var(--bg-active);
    color: var(--accent-primary);
}

.upload-btn:active,
.ocr-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.ocr-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ocr-btn.active {
    background: var(--accent-success);
    color: #f0fdf4;
}

.upload-preview-area {
    padding: var(--space-4);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-4);
}

.upload-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-3);
}

.upload-preview-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.clear-uploads-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.clear-uploads-btn:hover {
    background: var(--bg-hover);
    color: var(--accent-error);
}

.upload-preview-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    max-height: 200px;
    overflow-y: auto;
}

.upload-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.upload-item:hover {
    border-color: var(--border-default);
}

.upload-item-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    color: var(--accent-primary);
    flex-shrink: 0;
}

.upload-item-icon.image { color: var(--perception-color); }
.upload-item-icon.document { color: var(--cognition-color); }
.upload-item-icon.archive { color: var(--action-color); }
.upload-item-icon.ocr { color: var(--accent-success); }

.upload-item-info {
    flex: 1;
    min-width: 0;
}

.upload-item-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.upload-item-meta {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.upload-item-size {
    font-family: var(--font-mono);
}

.upload-item-status {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.upload-item-status.processing {
    color: var(--accent-warning);
}

.upload-item-status.complete {
    color: var(--accent-success);
}

.upload-item-status.error {
    color: var(--accent-error);
}

.upload-item-remove {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.upload-item-remove:hover {
    background: var(--bg-hover);
    color: var(--accent-error);
}

.spinner-small {
    width: 12px;
    height: 12px;
    border: 2px solid var(--bg-tertiary);
    border-top-color: var(--accent-warning);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.input-hints {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    margin-top: var(--space-2);
    font-size: 11px;
    color: var(--text-quaternary);
}

.hint kbd {
    padding: 2px 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 10px;
}

.hint-divider {
    color: var(--border-default);
}

/* ============================================
   RIGHT PANEL - METRICS & ACTIVITY
   ============================================ */
.right-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    overflow-y: auto;
}

.panel-section {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-3);
}

.section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.section-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.section-badge.live {
    background: rgba(34, 197, 94, 0.1);
    color: var(--accent-success);
}

/* Capabilities Grid */
.capabilities-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
}

.capability-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.capability-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-default);
}

.capability-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--bg-hover);
    border-radius: var(--radius-md);
    color: var(--accent-primary);
}

.capability-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.capability-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
}

.capability-status {
    font-size: 10px;
    color: var(--text-tertiary);
}

/* Metrics Cards */
.metrics-cards {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.metric-card {
    padding: var(--space-3);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

.metric-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-2);
}

.metric-label {
    font-size: 12px;
    color: var(--text-tertiary);
}

.metric-trend {
    font-size: 11px;
    font-weight: 600;
}

.metric-trend.down { color: var(--accent-success); }
.metric-trend.up { color: var(--accent-error); }
.metric-trend.neutral { color: var(--text-quaternary); }

.metric-value-large {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.metric-suffix {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-tertiary);
    margin-left: 2px;
}

.metric-bar {
    height: 4px;
    background: var(--bg-hover);
    border-radius: var(--radius-full);
    margin-top: var(--space-2);
    overflow: hidden;
}

.metric-bar-fill {
    height: 100%;
    background: var(--accent-primary);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

.metric-bar-fill.power { background: var(--accent-success); }
.metric-bar-fill.memory { background: var(--accent-warning); }

/* Activity Stream */
.activity-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 200px;
}

.activity-stream {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    overflow-y: auto;
    max-height: 300px;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-2);
    border-radius: var(--radius-md);
    animation: activity-in 0.3s ease-out;
}

@keyframes activity-in {
    0% { opacity: 0; transform: translateX(-10px); }
    100% { opacity: 1; transform: translateX(0); }
}

.activity-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.activity-icon.perception { color: var(--perception-color); }
.activity-icon.cognition { color: var(--cognition-color); }
.activity-icon.action { color: var(--action-color); }
.activity-icon.spawn { color: var(--accent-success); }

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-text {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.activity-time {
    font-size: 10px;
    color: var(--text-quaternary);
    font-family: var(--font-mono);
}

/* Evolution Section */
.evolution-section {
    border-bottom: none;
}

.evolution-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-tertiary);
}

.evolution-indicator.active {
    color: var(--accent-success);
}

.evo-dot {
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
}

.evolution-stats {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.evo-stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border-subtle);
}

.evo-stat:last-child {
    border-bottom: none;
}

.evo-label {
    font-size: 12px;
    color: var(--text-tertiary);
}

.evo-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

/* ============================================
   STATUS BAR
   ============================================ */
.status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 32px;
    padding: 0 var(--space-4);
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-subtle);
    font-size: 11px;
}

.status-left, .status-center, .status-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.status-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-tertiary);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-dot.green { background: var(--accent-success); }
.status-dot.yellow { background: var(--accent-warning); }
.status-dot.red { background: var(--accent-error); }

/* ============================================
   LOADING OVERLAY
   ============================================ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 10, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.loading-overlay.active {
    display: flex;
}

.loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-default);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loader-text {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    z-index: 1001;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: toast-in 0.3s ease-out;
}

@keyframes toast-in {
    0% { opacity: 0; transform: translateX(20px); }
    100% { opacity: 1; transform: translateX(0); }
}

.toast.success { border-color: rgba(34, 197, 94, 0.3); }
.toast.error { border-color: rgba(239, 68, 68, 0.3); }

.toast-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast.success .toast-icon { color: var(--accent-success); }
.toast.error .toast-icon { color: var(--accent-error); }

.toast-message {
    font-size: 13px;
    color: var(--text-primary);
}

/* ============================================
   FLEET ARCHITECTURE PANELS
   ============================================ */
.archetype-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: var(--space-3);
    margin-top: var(--space-3);
}

.archetype-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.archetype-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-default);
    transform: translateY(-1px);
}

.archetype-icon {
    width: 24px;
    height: 24px;
    color: var(--accent-primary-hover);
}

.archetype-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.archetype-label {
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.archetype-count {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.controller-stats {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin-top: var(--space-3);
}

.controller-metric {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.controller-metric:hover {
    background: var(--bg-hover);
    border-color: var(--border-default);
}

.controller-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.controller-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.controller-value.health {
    color: var(--accent-success);
}

.controller-unit {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-tertiary);
    margin-left: 2px;
}

.fabric-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-3);
    margin-top: var(--space-3);
}

.fabric-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-3);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.fabric-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-default);
}

.fabric-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.fabric-header svg {
    color: var(--accent-primary);
}

.fabric-label {
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.fabric-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.fabric-unit {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-tertiary);
    margin-left: 2px;
}

.memory-tiers {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin-top: var(--space-3);
}

.memory-tier {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.memory-tier-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.memory-tier-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.memory-tier-usage {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
}

.memory-tier-bar {
    width: 100%;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.memory-tier-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

.section-badge.live {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.2);
    color: var(--accent-success);
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bg-active);
}

/* ============================================
   TAB NAVIGATION
   ============================================ */
.nav-tabs {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.nav-tab svg {
    opacity: 0.6;
    transition: opacity var(--transition-fast);
}

.nav-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-tab:hover svg {
    opacity: 1;
}

.nav-tab.active {
    background: var(--bg-active);
    color: var(--text-primary);
}

.nav-tab.active svg {
    opacity: 1;
    color: var(--accent-primary);
}

.nav-divider {
    width: 1px;
    height: 24px;
    background: var(--border-subtle);
}

/* ============================================
   TAB CONTENT
   ============================================ */
.tab-content {
    display: none;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    padding: var(--space-6);
    gap: var(--space-6);
}

.tab-content.active {
    display: flex;
}

.tab-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.tab-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.refresh-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.refresh-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-default);
    color: var(--text-primary);
}

/* ============================================
   METRICS GRID (Fleet Tab)
   ============================================ */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
}

.metric-card {
    padding: var(--space-5);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
}

.metric-card:hover {
    border-color: var(--border-default);
    box-shadow: var(--shadow-md);
}

.metric-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.metric-header svg {
    opacity: 0.6;
}

.metric-value-large {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    margin-bottom: var(--space-1);
}

.metric-change {
    font-size: 12px;
    color: var(--text-tertiary);
}

.metric-change.positive {
    color: var(--accent-success);
}

.metric-change.negative {
    color: var(--accent-error);
}

/* ============================================
   FLEET AGENTS LIST
   ============================================ */
.fleet-agents-list {
    margin-top: var(--space-4);
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-4);
}

.fleet-agent-item {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: var(--space-4);
    padding: var(--space-4);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-2);
    transition: all var(--transition-fast);
}

.fleet-agent-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-default);
}

.agent-id {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-primary);
}

.agent-archetype {
    font-size: 13px;
    color: var(--text-secondary);
}

.agent-status {
    font-size: 12px;
    color: var(--accent-success);
    text-align: right;
}

/* ============================================
   EVOLUTION TAB
   ============================================ */
.evolution-metrics {
    display: flex;
    gap: var(--space-8);
    padding: var(--space-5);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
}

.evo-stat {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.evo-label {
    font-size: 12px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.evo-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.evolution-agents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-6);
}

.evo-agent-card {
    padding: var(--space-4);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.evo-agent-card:hover {
    background: var(--bg-hover);
    border-color: var(--border-default);
}

.evo-agent-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.evo-agent-version {
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-tertiary);
    margin-bottom: var(--space-3);
}

.evo-agent-metrics {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    font-size: 11px;
    color: var(--text-secondary);
}

.evolution-plans-section,
.evolution-history-section {
    margin-top: var(--space-6);
}

.evolution-plan-item,
.evolution-history-item {
    padding: var(--space-4);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-2);
}

.plan-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-2);
}

.plan-id {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-primary);
}

.plan-status {
    font-size: 11px;
    padding: 2px 8px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: var(--radius-full);
    color: var(--accent-primary);
}

.plan-agent {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}

.plan-created {
    font-size: 11px;
    color: var(--text-tertiary);
}

.history-timestamp,
.history-agent,
.history-result {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}

.history-result {
    font-weight: 600;
}

/* ============================================
   GOVERNANCE TAB
   ============================================ */
.governance-grid,
.governance-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.governance-card,
.gov-card {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-5);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
}

.gov-card:hover {
    border-color: var(--border-default);
    box-shadow: var(--shadow-md);
}

.gov-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    background: rgba(99, 102, 241, 0.1);
}

.gov-icon svg {
    color: var(--accent-primary);
}

.gov-icon.self-trigger svg { color: var(--accent-warning); }
.gov-icon.self-planner svg { color: var(--planner-color); }
.gov-icon.evaluator svg { color: var(--accent-success); }
.gov-icon.cost-control svg { color: var(--cost-color); }
.gov-icon.learning svg { color: var(--accent-secondary); }

.gov-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.gov-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.gov-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.gov-meta {
    font-size: 11px;
    color: var(--text-tertiary);
}

.gov-card-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.gov-card-icon {
    width: 20px;
    height: 20px;
    color: var(--accent-primary);
}

.gov-card-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.gov-card-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums);
}

.tasks-section {
    margin-top: var(--space-6);
}

.governance-tasks-list {
    margin-top: var(--space-6);
}

.governance-task-item {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: var(--space-4);
    padding: var(--space-4);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-2);
}

.task-title {
    font-size: 13px;
    color: var(--text-primary);
}

.task-status,
.task-assigned {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ============================================
   SYSTEM TAB
   ============================================ */
.system-monitoring,
.system-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.monitor-card,
.sys-card {
    padding: var(--space-5);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
}

.sys-card:hover {
    border-color: var(--border-default);
    box-shadow: var(--shadow-md);
}

.monitor-label,
.sys-card-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.monitor-value,
.sys-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-3);
    font-variant-numeric: tabular-nums;
}

.monitor-bar,
.sys-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.monitor-fill,
.sys-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

.health-status-section,
.rate-limit-section {
    margin-top: var(--space-6);
}

.system-health-section,
.rate-limit-section {
    margin-top: var(--space-6);
}

.health-item,
.rate-limit-item {
    display: flex;
    justify-content: space-between;
    padding: var(--space-3);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-2);
}

.health-label,
.rate-limit-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.health-value,
.rate-limit-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.health-value.healthy {
    color: var(--accent-success);
}

.health-value.unhealthy {
    color: var(--accent-error);
}

/* ============================================
   TOOLS TAB
   ============================================ */
.tools-capabilities,
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.tool-card {
    padding: var(--space-4);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
}

.tool-card h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-3);
}

.tool-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.tool-list div {
    font-size: 12px;
    color: var(--text-secondary);
    padding: var(--space-2);
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.api-keys-section {
    margin-top: var(--space-6);
}

.api-key-item {
    display: grid;
    grid-template-columns: 2fr 2fr 1fr;
    gap: var(--space-4);
    padding: var(--space-4);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-2);
}

.key-name,
.key-id {
    font-size: 13px;
    color: var(--text-primary);
}

.key-id {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-secondary);
}

.key-status {
    font-size: 12px;
    color: var(--accent-success);
    text-align: right;
}

.create-key-btn,
.create-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-md);
    color: #f8faff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: var(--space-4);
}

.create-key-btn:hover,
.create-btn:hover {
    background: var(--accent-primary-hover);
    box-shadow: var(--shadow-md);
}

/* ============================================
   EMPTY STATES
   ============================================ */
.empty-state {
    padding: var(--space-8);
    text-align: center;
    color: var(--text-tertiary);
    font-size: 13px;
}

/* ============================================
   FACTORY TAB - Autonomous Operations
   ============================================ */

.factory-status-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    margin-bottom: 24px;
}

.factory-status-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.factory-status-item .status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border-muted);
    transition: all 0.2s ease;
}

.factory-status-item .status-dot.green {
    background: #10b981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.factory-status-item .status-label {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.factory-status-item strong {
    color: var(--text-primary);
    font-weight: 600;
}

.factory-pipeline {
    padding: 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    margin-bottom: 24px;
}

.pipeline-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    margin-bottom: 16px;
    text-align: center;
}

.phase-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.phase-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    min-width: 72px;
}

.phase-step .phase-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--bg-hover);
    color: var(--text-tertiary);
    transition: all 0.2s ease;
}

.phase-step .phase-name {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: color 0.2s ease;
    text-align: center;
}

.phase-step.pending { opacity: 0.4; }

.phase-step.done {
    background: rgba(99, 102, 241, 0.08);
    border-color: var(--accent-primary);
}

.phase-step.done .phase-icon {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-primary);
}

.phase-step.active {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--accent-primary);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.3);
}

.phase-step.active .phase-icon {
    background: var(--accent-primary);
    color: #fff;
}

.phase-step.active .phase-name {
    color: var(--accent-primary);
    font-weight: 600;
}

.phase-arrow {
    color: var(--text-tertiary);
    font-size: 16px;
    font-weight: 300;
    margin-top: -8px;
    flex-shrink: 0;
}

.factory-goal-section,
.factory-result-section,
.factory-runs-section,
.factory-queue-section {
    margin-bottom: 24px;
}

.goal-display,
.result-display,
.runs-list,
.queue-list {
    padding: 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    min-height: 48px;
}

.goal-text,
.result-review {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.55;
    white-space: pre-wrap;
}

.goal-placeholder,
.result-placeholder {
    font-size: 13px;
    color: var(--text-tertiary);
    font-style: italic;
}

.result-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.result-badge {
    padding: 3px 10px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.result-badge.success {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.result-badge.error {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.result-phases,
.result-baro,
.result-decision,
.result-error {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.result-phases { color: var(--accent-primary); font-weight: 500; }

.result-pr {
    font-size: 12px;
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
}

.result-pr:hover { text-decoration: underline; }

.result-error { color: #ef4444 !important; font-weight: 500; word-break: break-all; }

.factory-run-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 6px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.factory-run-item:hover { border-color: var(--border-default); }

.run-id {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-primary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.run-status {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 9999px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.run-status.success { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.run-status.error { background: rgba(239, 68, 68, 0.12); color: #ef4444; }
.run-status.pending, .run-status.launching, .run-status.planning, .run-status.building, .run-status.gating, .run-status.pr_opened, .run-status.timeout, .run-status.stopped, .run-status.error {
    background: rgba(100, 116, 139, 0.12);
    color: var(--text-secondary);
}

.run-duration {
    font-size: 11px;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    flex-shrink: 0;
}

.run-pr-link {
    font-size: 11px;
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
    white-space: nowrap;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.run-pr-link:hover { background: rgba(99, 102, 241, 0.1); text-decoration: none; }

.factory-queue-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 6px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.factory-queue-item:hover { border-color: var(--border-default); }

.queue-priority {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 9999px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    flex-shrink: 0;
}

.queue-priority.high { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.queue-priority.medium { background: rgba(245, 158, 11, 0.15); color: #d97706; }
.queue-priority.low { background: rgba(100, 116, 139, 0.15); color: var(--text-tertiary); }

.queue-desc {
    font-size: 13px;
    color: var(--text-primary);
    flex: 1;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.queue-status {
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: capitalize;
    flex-shrink: 0;
}

.queue-id {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.tab-header-actions { display: flex; gap: 8px; }

.control-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.control-btn:hover { background: var(--bg-hover); border-color: var(--border-default); color: var(--text-primary); }
.control-btn.start-btn { background: rgba(16, 185, 129, 0.12); border-color: #10b981; color: #10b981; }
.control-btn.start-btn:hover { background: rgba(16, 185, 129, 0.2); box-shadow: 0 0 8px rgba(16, 185, 129, 0.25); }
.control-btn.stop-btn { background: rgba(239, 68, 68, 0.12); border-color: #ef4444; color: #ef4444; }
.control-btn.stop-btn:hover { background: rgba(239, 68, 68, 0.2); box-shadow: 0 0 8px rgba(239, 68, 68, 0.25); }

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 240px 1fr 260px;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .system-monitoring {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .left-panel, .right-panel {
        display: none;
    }

    .nav-tabs {
        overflow-x: auto;
        scrollbar-width: none;
    }

    .nav-tabs::-webkit-scrollbar {
        display: none;
    }
}
