:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: rgba(20, 20, 30, 0.6);
    --bg-panel: rgba(255, 255, 255, 0.03);
    
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    
    --accent-glow: rgba(99, 102, 241, 0.15);
    --accent-color: #6366f1;
    --accent-color-hover: #818cf8;
    
    --log-info: #38bdf8;
    --log-warn: #f59e0b;
    --log-error: #ef4444;
    --log-success: #10b981;
    --log-timestamp: #64748b;
    
    --border-color: rgba(255, 255, 255, 0.08);
}

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

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    height: 100vh;
    overflow: hidden;
    background-image: 
        radial-gradient(circle at 15% 50%, var(--accent-glow), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(56, 189, 248, 0.1), transparent 25%);
}

.dashboard-container {
    display: flex;
    height: 100vh;
    padding: 1.5rem;
    gap: 1.5rem;
}

/* Sidebar Styling */
.sidebar {
    width: 300px;
    background: var(--bg-secondary);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 3px; }

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-header h2 {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.025em;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.pulse-ring {
    width: 12px;
    height: 12px;
    background: var(--log-success);
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.status-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.status-dot.green { background: var(--log-success); box-shadow: 0 0 8px var(--log-success); }
.status-dot.orange { background: var(--log-warn); box-shadow: 0 0 8px var(--log-warn); }
.status-dot.red { background: var(--log-error); box-shadow: 0 0 8px var(--log-error); }

.agent-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
    transition: transform 0.2s ease, background 0.2s ease;
}

.agent-card:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.05);
}

.agent-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    color: white;
}
.agent-avatar.ceo { background: linear-gradient(135deg, #6366f1, #a855f7); }
.agent-avatar.cto { background: linear-gradient(135deg, #3b82f6, #06b6d4); }
.agent-avatar.wrk { background: linear-gradient(135deg, #10b981, #3b82f6); }

.agent-info h4 { font-size: 0.875rem; margin-bottom: 0.25rem; }
.agent-info p { font-size: 0.75rem; color: var(--text-secondary); }


/* Main Terminal Area */
.terminal-area {
    flex: 1;
    background: #0d0d14;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

.terminal-header {
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.window-controls {
    display: flex;
    gap: 8px;
}
.window-controls span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}
.close { background: #ff5f56; }
.minimize { background: #ffbd2e; }
.maximize { background: #27c93f; }

.terminal-title {
    font-family: 'Fira Code', monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.actions { display: flex; gap: 0.5rem; }
.btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn:hover { background: rgba(255,255,255,0.1); }
.btn.active {
    background: var(--accent-glow);
    border-color: var(--accent-color);
    color: var(--accent-color-hover);
}

.terminal-body {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: #cbd5e1;
    scroll-behavior: smooth;
}

.terminal-body::-webkit-scrollbar { width: 8px; }
.terminal-body::-webkit-scrollbar-track { background: transparent; }
.terminal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
.terminal-body::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

/* Log Line Coloring */
.log-line {
    word-wrap: break-word;
    margin-bottom: 2px;
    padding-left: 1rem;
    text-indent: -1rem;
}
.log-line .timestamp { color: var(--log-timestamp); margin-right: 8px; }
.log-line.info { color: var(--text-primary); }
.log-line.warn { color: var(--log-warn); }
.log-line.error { color: var(--log-error); font-weight: 500; }
.log-line.success { color: var(--log-success); }
.log-line.system { color: var(--accent-color-hover); font-style: italic; }

/* --- Live-state additions --- */

.empty-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.5;
}
.empty-hint code {
    background: var(--bg-panel);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
}

.agent-card { justify-content: space-between; }
.agent-card .agent-status-badge {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    text-transform: uppercase;
    white-space: nowrap;
}
.agent-status-badge.status-IDLE { background: rgba(148, 163, 184, 0.15); color: var(--text-secondary); }
.agent-status-badge.status-THINKING,
.agent-status-badge.status-AWAITING_RESPONSE { background: rgba(245, 158, 11, 0.15); color: var(--log-warn); }
.agent-status-badge.status-PROCESSING,
.agent-status-badge.status-LEARNING { background: rgba(56, 189, 248, 0.15); color: var(--log-info); }
.agent-status-badge.status-DONE { background: rgba(16, 185, 129, 0.15); color: var(--log-success); }
.agent-status-badge.status-ERROR { background: rgba(239, 68, 68, 0.15); color: var(--log-error); }

.agent-avatar.ceo_ { background: linear-gradient(135deg, #6366f1, #a855f7); }
.agent-avatar.cto_ { background: linear-gradient(135deg, #3b82f6, #06b6d4); }
.agent-avatar.worker_ { background: linear-gradient(135deg, #10b981, #3b82f6); }
.agent-avatar.supervisor_ { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.agent-avatar.qualitycontroller_ { background: linear-gradient(135deg, #a855f7, #ec4899); }
.agent-avatar.humanproxy_ { background: linear-gradient(135deg, #64748b, #94a3b8); }

.budget-gauge {
    width: 100%;
    height: 8px;
    background: var(--bg-panel);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}
.budget-gauge-fill {
    height: 100%;
    width: 0%;
    background: var(--log-success);
    transition: width 0.4s ease, background 0.4s ease;
}
.budget-gauge-fill.level-CAUTIOUS { background: var(--log-info); }
.budget-gauge-fill.level-LOW { background: var(--log-warn); }
.budget-gauge-fill.level-CRITICAL,
.budget-gauge-fill.level-EXHAUSTED { background: var(--log-error); }
.budget-label { font-size: 0.75rem; color: var(--text-secondary); }

.trace-strip {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
}
.trace-stat {
    flex: 1;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.6rem;
    text-align: center;
}
.trace-stat span { display: block; font-size: 1rem; font-weight: 700; }
.trace-stat label { font-size: 0.65rem; color: var(--text-secondary); text-transform: uppercase; }

.event-timeline {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 220px;
    overflow-y: auto;
}
.event-item {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem 0.6rem;
    font-size: 0.7rem;
}
.event-item .event-topic { color: var(--accent-color-hover); font-weight: 600; }
.event-item .event-sender { color: var(--text-secondary); }
.event-item .event-payload { color: var(--text-secondary); margin-top: 0.2rem; word-break: break-word; }

.graph-diagram {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem;
    overflow-x: auto;
}
.graph-diagram svg { max-width: 100%; }
