        /* ==================== DESIGN TOKENS ==================== */
        :root {
            /* Palette — Core */
            --accent: #6366f1;
            --accent-hover: #4f46e5;
            --accent-light: #818cf8;
            --accent-subtle: rgba(99, 102, 241, 0.1);
            --accent-muted: rgba(99, 102, 241, 0.2);

            /* Palette — Semantic */
            --success: #22c55e;
            --success-subtle: rgba(34, 197, 94, 0.15);
            --warning: #eab308;
            --warning-subtle: rgba(234, 179, 8, 0.15);
            --danger: #ef4444;
            --danger-subtle: rgba(239, 68, 68, 0.15);
            --info: #3b82f6;
            --info-subtle: rgba(59, 130, 246, 0.15);

            /* Backgrounds */
            --bg-base: #0a0a0f;
            --bg-surface: #111118;
            --bg-elevated: #1a1a24;
            --bg-overlay: rgba(0, 0, 0, 0.6);
            --bg-card: rgba(255, 255, 255, 0.03);
            --bg-card-hover: rgba(255, 255, 255, 0.06);

            /* Borders */
            --border: rgba(99, 102, 241, 0.15);
            --border-hover: rgba(99, 102, 241, 0.3);
            --border-active: var(--accent);

            /* Text */
            --text-primary: #e4e4e7;
            --text-secondary: #a1a1aa;
            --text-tertiary: #71717a;
            --text-muted: #52525b;
            --text-inverse: #ffffff;

            /* Typography — Inter + Major Third */
            --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
            --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
            --text-xs: 0.75rem;
            --text-sm: 0.8125rem;
            --text-base: 0.875rem;
            --text-md: 1rem;
            --text-lg: 1.125rem;
            --text-xl: 1.25rem;
            --text-2xl: 1.5rem;
            --text-3xl: 2rem;

            /* Spacing (4px base) */
            --space-1: 4px;
            --space-2: 8px;
            --space-3: 12px;
            --space-4: 16px;
            --space-5: 20px;
            --space-6: 24px;
            --space-8: 32px;

            /* Radii */
            --radius-sm: 6px;
            --radius-md: 8px;
            --radius-lg: 12px;
            --radius-xl: 16px;
            --radius-full: 9999px;

            /* Transitions */
            --transition-fast: 150ms ease;
            --transition-base: 200ms ease;
            --transition-slow: 300ms ease;

            /* Shadows */
            --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
            --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
            --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
            --shadow-xl: 0 20px 48px rgba(0, 0, 0, 0.6);
        }

        /* Light theme overrides */
        body.light-theme {
            --bg-base: #f4f4f5;
            --bg-surface: #ffffff;
            --bg-elevated: #fafafa;
            --bg-card: rgba(255, 255, 255, 0.7);
            --bg-card-hover: rgba(255, 255, 255, 0.9);
            --border: rgba(0, 0, 0, 0.08);
            --border-hover: rgba(99, 102, 241, 0.2);
            --text-primary: #18181b;
            --text-secondary: #52525b;
            --text-tertiary: #71717a;
            --text-muted: #a1a1aa;
        }

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

        body {
            font-family: var(--font-sans);
            background: var(--bg-base);
            color: var(--text-primary);
            min-height: 100vh;
            overflow-x: hidden;
        }

        /* ==================== HEADER ==================== */
        .header {
            background: var(--bg-surface);
            border-bottom: 1px solid var(--border);
            padding: var(--space-4) var(--space-5);
            position: sticky;
            top: 0;
            z-index: 100;
            backdrop-filter: blur(12px);
        }

        .header-top {
            max-width: 1800px;
            margin: 0 auto;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 20px;
            margin-bottom: 10px;
        }

        .header-logo {
            display: flex;
            align-items: center;
            gap: var(--space-3);
            font-weight: 700;
            color: var(--text-primary);
        }

        .header-logo h1 {
            font-size: var(--text-xl);
            margin: 0;
            font-weight: 700;
        }

        .header-metrics {
            display: flex;
            gap: 20px;
            flex-wrap: wrap;
            align-items: center;
            font-size: 0.9em;
        }

        .metric {
            display: flex;
            align-items: center;
            gap: var(--space-2);
            padding: var(--space-1) var(--space-3);
            background: var(--bg-card);
            border-radius: var(--radius-sm);
            border: 1px solid var(--border);
        }

        .metric.green {
            border-color: var(--success);
            background: var(--success-subtle);
        }

        .metric.yellow {
            border-color: var(--warning);
            background: var(--warning-subtle);
        }

        .metric-value {
            color: var(--accent-light);
            font-weight: 600;
        }

        .pulse-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: var(--success);
            animation: pulse 2s infinite;
        }

        @keyframes pulse {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.4; }
        }

        /* ==================== TABS ==================== */
        .tabs-row {
            max-width: 1800px;
            margin: 0 auto;
            display: flex;
            gap: 2px;
            overflow-x: auto;
            padding: 0 var(--space-5);
            align-items: center;
        }

        .tab-group-label {
            font-size: 0.6rem;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            font-weight: 600;
            padding: var(--space-3) 0 var(--space-3) var(--space-2);
            white-space: nowrap;
            pointer-events: none;
            user-select: none;
        }

        .tab-divider {
            width: 1px;
            height: 16px;
            background: var(--border);
            margin: 0 var(--space-2);
            flex-shrink: 0;
        }

        .tab-button {
            padding: var(--space-2) var(--space-3);
            background: transparent;
            border: none;
            color: var(--text-tertiary);
            cursor: pointer;
            font-size: var(--text-sm);
            font-weight: 500;
            border-bottom: 2px solid transparent;
            transition: all var(--transition-fast);
            white-space: nowrap;
        }

        .tab-button:hover {
            color: var(--text-primary);
            border-bottom-color: var(--border-hover);
        }

        .tab-button.active {
            color: var(--accent);
            border-bottom-color: var(--accent);
        }

        /* ==================== MAIN LAYOUT ==================== */
        .main-wrapper {
            display: flex;
            height: calc(100vh - 120px);
            max-width: 1800px;
            margin: 20px auto;
            gap: 20px;
            padding: 0 20px;
        }

        /* ==================== SIDEBAR ==================== */
        .sidebar {
            width: 280px;
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--radius-lg);
            padding: var(--space-4);
            overflow-y: auto;
            flex-shrink: 0;
        }

        .sidebar-group {
            margin-bottom: 20px;
        }

        .sidebar-group-title {
            display: flex;
            align-items: center;
            gap: var(--space-2);
            padding: var(--space-2) 0;
            font-size: var(--text-xs);
            font-weight: 600;
            color: var(--text-tertiary);
            text-transform: uppercase;
            letter-spacing: 1px;
            border-bottom: 1px solid var(--border);
            margin-bottom: var(--space-2);
        }

        .sidebar-group-count {
            display: inline-block;
            background: var(--accent-subtle);
            color: var(--accent);
            padding: 2px var(--space-2);
            border-radius: var(--radius-full);
            font-size: var(--text-xs);
            font-weight: 600;
        }

        .agent-item {
            padding: var(--space-3);
            background: transparent;
            border: 1px solid transparent;
            border-radius: var(--radius-md);
            margin-bottom: var(--space-1);
            cursor: pointer;
            transition: all var(--transition-fast);
            display: flex;
            align-items: center;
            gap: var(--space-3);
        }

        .agent-item:hover {
            background: var(--accent-subtle);
            border-color: var(--border);
        }

        .agent-item.active {
            background: var(--accent-subtle);
            border-color: var(--accent);
        }

        .agent-status {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            flex-shrink: 0;
        }

        .agent-status.working {
            background: var(--success);
            animation: pulse 2s infinite;
        }

        .agent-status.idle {
            background: var(--warning);
        }

        .agent-status.error {
            background: var(--danger);
        }

        .agent-status.offline {
            background: var(--text-muted);
        }

        .agent-name {
            font-size: var(--text-sm);
            color: var(--text-primary);
            font-weight: 500;
            flex: 1;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .agent-role {
            font-size: var(--text-xs);
            color: var(--text-tertiary);
        }

        /* ==================== MAIN CONTENT ==================== */
        .main-content {
            flex: 1;
            display: flex;
            flex-direction: column;
            gap: 20px;
            overflow-y: auto;
        }

        .tab-content {
            display: none;
            animation: fadeIn 0.3s ease;
        }

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

        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }

        /* ==================== MASTER-DETAIL PANEL ==================== */
        .agent-detail-panel {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--radius-lg);
            padding: var(--space-8);
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: var(--space-8);
            min-height: 400px;
        }

        .agent-controls {
            grid-column: 1 / -1;
            display: flex;
            gap: 12px;
            flex-wrap: wrap;
            padding-top: 15px;
            border-top: 1px solid rgba(78, 115, 223, 0.2);
        }

        .agent-ctrl-btn {
            padding: 10px 20px;
            border-radius: 8px;
            border: 1px solid;
            cursor: pointer;
            font-weight: 600;
            font-size: 0.85em;
            transition: all 0.3s ease;
        }

        .agent-ctrl-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0,0,0,0.3);
        }

        .agent-ctrl-btn:disabled {
            opacity: 0.4;
            cursor: not-allowed;
            transform: none;
        }

        .agent-ctrl-btn.start {
            background: var(--success-subtle);
            border-color: var(--success);
            color: var(--success);
        }

        .agent-ctrl-btn.stop {
            background: var(--danger-subtle);
            border-color: var(--danger);
            color: var(--danger);
        }

        .agent-ctrl-btn.restart {
            background: var(--warning-subtle);
            border-color: var(--warning);
            color: var(--warning);
        }

        .agent-ctrl-btn.chat {
            background: var(--accent-subtle);
            border-color: var(--accent);
            color: var(--accent);
        }

        .agent-ctrl-feedback {
            padding: 8px 14px;
            border-radius: 6px;
            font-size: 0.85em;
            animation: fadeIn 0.3s ease;
        }

        .agent-detail-empty {
            grid-column: 1 / -1;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            min-height: 400px;
            color: #666;
        }

        .agent-detail-empty-icon {
            font-size: 3em;
            margin-bottom: 20px;
            opacity: 0.5;
        }

        .agent-detail-section {
            padding: var(--space-5);
            background: var(--bg-surface);
            border-radius: var(--radius-md);
            border: 1px solid var(--border);
        }

        .agent-detail-section h3 {
            color: var(--text-primary);
            margin-bottom: var(--space-4);
            font-size: var(--text-md);
            font-weight: 600;
        }

        .agent-detail-item {
            display: flex;
            justify-content: space-between;
            margin-bottom: 10px;
            font-size: 0.95em;
        }

        .agent-detail-label {
            color: var(--text-tertiary);
        }

        .agent-detail-value {
            color: var(--text-primary);
            font-weight: 600;
        }

        /* ==================== CARDS GRID ==================== */
        .grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
            gap: 20px;
        }

        .card {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--radius-lg);
            padding: var(--space-5);
            transition: all var(--transition-fast);
        }

        .card:hover {
            background: var(--bg-card-hover);
            border-color: var(--border-hover);
            transform: translateY(-2px);
            box-shadow: var(--shadow-md);
        }

        .card-icon {
            font-size: var(--text-2xl);
            margin-bottom: var(--space-2);
        }

        .card-title {
            font-size: var(--text-xs);
            color: var(--text-tertiary);
            margin-bottom: var(--space-2);
            font-weight: 500;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .card-value {
            font-size: var(--text-3xl);
            color: var(--text-primary);
            font-weight: 700;
            margin-bottom: var(--space-1);
        }

        .card-subtitle {
            font-size: var(--text-sm);
            color: var(--text-tertiary);
        }

        /* ==================== SYSTEM INFO BAR ==================== */
        .system-info-bar {
            display: flex;
            gap: var(--space-4);
            flex-wrap: wrap;
            padding: var(--space-3) var(--space-4);
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--radius-md);
            margin-bottom: var(--space-5);
            font-size: var(--text-xs);
            color: var(--text-tertiary);
        }

        .spark-card {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--radius-md);
            padding: var(--space-4);
            margin-bottom: var(--space-5);
        }

        /* ==================== ACTION BUTTONS (inline style replacement) ==================== */
        .btn-export {
            background: var(--success-subtle);
            border: 1px solid var(--success);
            color: var(--success);
            padding: var(--space-2) var(--space-3);
            border-radius: var(--radius-sm);
            cursor: pointer;
            font-size: var(--text-xs);
            font-weight: 500;
            transition: all var(--transition-fast);
        }
        .btn-export:hover { opacity: 0.8; }

        .btn-refresh {
            background: var(--accent-subtle);
            border: 1px solid var(--accent);
            color: var(--accent);
            padding: var(--space-2) var(--space-3);
            border-radius: var(--radius-sm);
            cursor: pointer;
            font-size: var(--text-xs);
            font-weight: 500;
            transition: all var(--transition-fast);
        }
        .btn-refresh:hover { opacity: 0.8; }

        .btn-action {
            background: var(--accent-subtle);
            border: 1px solid var(--accent);
            color: var(--accent);
            padding: var(--space-2) var(--space-3);
            border-radius: var(--radius-sm);
            cursor: pointer;
            font-size: var(--text-xs);
            font-weight: 500;
            transition: all var(--transition-fast);
        }
        .btn-action:hover { opacity: 0.8; }

        /* System info bar value */
        .sys-value {
            color: var(--accent-light);
            font-weight: 500;
        }

        /* KPI large value */
        .kpi-value {
            color: var(--text-primary);
            font-size: var(--text-2xl);
            font-weight: 700;
        }

        /* ==================== KPI DELTA INDICATOR ==================== */
        .kpi-delta {
            display: inline-flex;
            align-items: center;
            gap: 2px;
            font-size: var(--text-xs);
            font-weight: 500;
            padding: 1px var(--space-2);
            border-radius: var(--radius-full);
            margin-left: var(--space-2);
        }

        .kpi-delta.up {
            color: var(--success);
            background: var(--success-subtle);
        }

        .kpi-delta.down {
            color: var(--danger);
            background: var(--danger-subtle);
        }

        .kpi-delta.neutral {
            color: var(--text-muted);
            background: var(--bg-card);
        }

        /* ==================== SECTION TITLES ==================== */
        .section-title {
            color: var(--text-primary);
            font-size: var(--text-md);
            font-weight: 600;
        }

        .section-title-sm {
            color: var(--text-primary);
            font-size: var(--text-base);
            font-weight: 600;
        }

        /* ==================== FLOATING CHAT WIDGET ==================== */
        .chat-widget-button {
            position: fixed;
            bottom: 30px;
            right: 30px;
            width: 52px;
            height: 52px;
            background: var(--accent);
            border: none;
            border-radius: var(--radius-full);
            font-size: 1.5em;
            cursor: pointer;
            z-index: 500;
            box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
            transition: all var(--transition-fast);
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .chat-widget-button:hover {
            transform: scale(1.05);
            box-shadow: 0 12px 32px rgba(99, 102, 241, 0.5);
        }

        .chat-widget-button.active {
            background: var(--accent-hover);
        }

        .chat-widget {
            position: fixed;
            bottom: 92px;
            right: 30px;
            width: 400px;
            height: 600px;
            background: var(--bg-surface);
            border: 1px solid var(--border);
            border-radius: var(--radius-xl);
            box-shadow: var(--shadow-xl);
            z-index: 499;
            display: none;
            flex-direction: column;
            overflow: hidden;
        }

        .chat-widget.active {
            display: flex;
            animation: slideUp 0.3s ease;
        }

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

        .chat-header {
            background: var(--bg-elevated);
            padding: var(--space-4);
            border-bottom: 1px solid var(--border);
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .chat-header-title {
            color: var(--text-primary);
            font-weight: 600;
            font-size: var(--text-base);
        }

        .chat-select {
            background: var(--bg-card);
            border: 1px solid var(--border);
            color: var(--text-primary);
            padding: var(--space-2) var(--space-3);
            border-radius: var(--radius-sm);
            font-size: var(--text-sm);
            width: 100%;
            margin-top: var(--space-3);
        }

        .chat-messages {
            flex: 1;
            overflow-y: auto;
            padding: 15px;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .message {
            display: flex;
            margin-bottom: 10px;
            animation: slideUp 0.3s ease;
        }

        .message.user {
            justify-content: flex-end;
        }

        .message.agent {
            justify-content: flex-start;
        }

        .message-content {
            max-width: 80%;
            padding: 10px 14px;
            border-radius: 8px;
            font-size: 0.9em;
            line-height: 1.4;
        }

        .message.user .message-content {
            background: var(--accent);
            color: var(--text-inverse);
        }

        .message.agent .message-content {
            background: var(--accent-subtle);
            color: var(--text-primary);
            border-left: 2px solid var(--accent);
        }

        .chat-input-area {
            padding: 15px;
            border-top: 2px solid rgba(78, 115, 223, 0.2);
            display: flex;
            gap: 10px;
        }

        .chat-input {
            flex: 1;
            background: var(--bg-card);
            border: 1px solid var(--border);
            color: var(--text-primary);
            padding: var(--space-3);
            border-radius: var(--radius-sm);
            font-size: var(--text-sm);
            font-family: inherit;
        }

        .chat-input:focus {
            outline: none;
            border-color: var(--accent);
            background: var(--accent-subtle);
        }

        .chat-send {
            background: var(--accent);
            border: none;
            color: var(--text-inverse);
            padding: var(--space-3) var(--space-5);
            border-radius: var(--radius-sm);
            cursor: pointer;
            font-weight: 600;
            transition: all var(--transition-fast);
        }

        .chat-send:hover {
            background: var(--accent-hover);
            color: var(--text-inverse);
        }

        .chat-send:disabled {
            opacity: 0.5;
            cursor: not-allowed;
            transform: none;
        }

        .typing-indicator {
            display: flex;
            align-items: center;
            gap: 4px;
            padding: 10px 14px;
            background: rgba(111, 143, 248, 0.1);
            border-left: 2px solid var(--accent);
            border-radius: 8px;
            max-width: 80%;
        }

        .typing-indicator span {
            width: 6px;
            height: 6px;
            background: var(--accent-light);
            border-radius: 50%;
            animation: typingBounce 1.4s infinite ease-in-out;
        }

        .typing-indicator span:nth-child(1) { animation-delay: 0s; }
        .typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
        .typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

        .typing-indicator .typing-text {
            width: auto;
            height: auto;
            background: none;
            border-radius: 0;
            animation: none;
            color: var(--accent-light);
            font-size: 0.85em;
            margin-left: 6px;
        }

        @keyframes typingBounce {
            0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
            40% { transform: scale(1); opacity: 1; }
        }

        /* ==================== TOAST NOTIFICATIONS ==================== */
        .toast-container {
            position: fixed;
            top: 80px;
            right: 20px;
            z-index: 600;
            display: flex;
            flex-direction: column;
            gap: 8px;
            max-width: 360px;
        }

        .toast {
            padding: 12px 16px;
            border-radius: 8px;
            font-size: 0.85em;
            display: flex;
            align-items: center;
            gap: 10px;
            animation: toastIn 0.3s ease, toastOut 0.3s ease 4.7s forwards;
            backdrop-filter: blur(10px);
            box-shadow: 0 8px 24px rgba(0,0,0,0.4);
            cursor: pointer;
        }

        .toast.success { background: var(--success-subtle); border: 1px solid var(--success); color: var(--success); }
        .toast.error   { background: var(--danger-subtle); border: 1px solid var(--danger); color: var(--danger); }
        .toast.warning { background: var(--warning-subtle); border: 1px solid var(--warning); color: var(--warning); }
        .toast.info    { background: var(--accent-subtle); border: 1px solid var(--accent); color: var(--accent); }

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

        /* ==================== SIDEBAR SEARCH ==================== */
        .sidebar-search {
            width: 100%;
            padding: var(--space-2) var(--space-3);
            background: var(--bg-surface);
            border: 1px solid var(--border);
            border-radius: var(--radius-md);
            color: var(--text-primary);
            font-size: var(--text-sm);
            margin-bottom: var(--space-3);
            font-family: inherit;
        }

        .sidebar-search:focus {
            outline: none;
            border-color: var(--accent);
            background: var(--accent-subtle);
        }

        .sidebar-filters {
            display: flex;
            gap: 6px;
            margin-bottom: 12px;
            flex-wrap: wrap;
        }

        .filter-chip {
            padding: var(--space-1) var(--space-3);
            border-radius: var(--radius-full);
            font-size: var(--text-xs);
            font-weight: 500;
            cursor: pointer;
            border: 1px solid var(--border);
            background: transparent;
            color: var(--text-tertiary);
            transition: all var(--transition-fast);
        }

        .filter-chip:hover { border-color: var(--accent); color: var(--accent); }
        .filter-chip.active { background: var(--accent-subtle); border-color: var(--accent); color: var(--accent); }

        /* ==================== REFRESH INDICATOR ==================== */
        .refresh-indicator {
            font-size: 0.75em;
            color: #666;
            padding: 2px 8px;
        }

        /* ==================== LIGHT THEME (overrides handled by CSS vars in :root) ==================== */
        /* Most light-theme rules are now automatic via --bg-*, --text-*, --border-* variables */

        .theme-toggle {
            background: rgba(255,255,255,0.1);
            border: 1px solid var(--border-hover);
            color: var(--accent-light);
            padding: 4px 10px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.85em;
            transition: all 0.3s ease;
        }

        .theme-toggle:hover { border-color: var(--accent); }

        /* ==================== CHART CONTAINERS ==================== */
        .chart-row {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 20px;
            margin-top: 20px;
        }

        .chart-card {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--radius-lg);
            padding: var(--space-5);
        }

        body.light-theme .chart-card {
            background: var(--bg-card);
        }

        .chart-card h3 {
            color: var(--text-primary);
            font-size: var(--text-base);
            margin-bottom: var(--space-4);
            font-weight: 600;
        }

        @media (max-width: 900px) {
            .chart-row { grid-template-columns: 1fr; }
        }

        /* ==================== SCROLLBAR ==================== */
        ::-webkit-scrollbar {
            width: 6px;
        }

        ::-webkit-scrollbar-track {
            background: transparent;
        }

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

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

        /* ==================== LOGIN OVERLAY ==================== */
        .login-overlay {
            position: fixed;
            top: 0; left: 0; right: 0; bottom: 0;
            background: var(--bg-base);
            z-index: 9999;
            display: flex;
            align-items: center;
            justify-content: center;
        }

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

        .login-box {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--radius-xl);
            padding: 40px;
            width: 360px;
            text-align: center;
        }

        .login-box h2 { color: var(--text-primary); margin-bottom: var(--space-2); font-size: var(--text-2xl); font-weight: 700; }
        .login-box p { color: var(--text-tertiary); margin-bottom: var(--space-6); font-size: var(--text-sm); }

        .login-input {
            width: 100%;
            padding: var(--space-3) var(--space-4);
            background: var(--bg-surface);
            border: 1px solid var(--border);
            border-radius: var(--radius-md);
            color: var(--text-primary);
            font-size: var(--text-base);
            margin-bottom: var(--space-3);
            font-family: inherit;
        }

        .login-input:focus { outline: none; border-color: var(--accent); }

        .login-btn {
            width: 100%;
            padding: 12px;
            background: var(--accent);
            border: none;
            border-radius: var(--radius-md);
            color: var(--text-inverse);
            font-size: var(--text-base);
            font-weight: 600;
            cursor: pointer;
            margin-top: var(--space-2);
            transition: all var(--transition-fast);
        }

        .login-btn:hover { background: var(--accent-hover); color: var(--text-inverse); }
        .login-btn:disabled { opacity: 0.5; cursor: not-allowed; }

        .login-error {
            color: var(--danger);
            font-size: var(--text-sm);
            margin-top: var(--space-3);
            min-height: 20px;
        }

        .logout-btn {
            background: transparent;
            border: 1px solid var(--border);
            color: var(--text-tertiary);
            padding: var(--space-1) var(--space-3);
            border-radius: var(--radius-sm);
            cursor: pointer;
            font-size: var(--text-xs);
            transition: all var(--transition-fast);
        }

        .logout-btn:hover { border-color: var(--danger); color: var(--danger); }

        /* ==================== LIVE LOG ==================== */
        .log-mode-toggle {
            display: flex;
            gap: 6px;
        }

        .log-mode-btn {
            padding: 4px 12px;
            border-radius: 6px;
            border: 1px solid var(--border-hover);
            background: transparent;
            color: #aaa;
            font-size: 0.8em;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .log-mode-btn.active {
            background: var(--accent-muted);
            color: var(--accent);
            border-color: var(--accent);
        }

        .live-dot {
            display: inline-block;
            width: 6px; height: 6px;
            background: var(--danger);
            border-radius: 50%;
            animation: pulse 1.5s infinite;
            margin-right: 4px;
        }

        /* ==================== MULTI-AGENT ==================== */
        .multi-agent-input {
            display: flex;
            gap: 10px;
            margin-bottom: 20px;
        }

        .multi-agent-input input {
            flex: 1;
            padding: 10px 14px;
            background: rgba(255,255,255,0.05);
            border: 1px solid var(--border-hover);
            border-radius: 8px;
            color: var(--text-primary);
            font-size: 0.9em;
            font-family: inherit;
        }

        .multi-agent-input input:focus { outline: none; border-color: var(--accent); }

        .multi-agent-input button {
            padding: 10px 20px;
            background: var(--accent);
            border: none;
            border-radius: 8px;
            color: var(--text-inverse);
            font-weight: 700;
            cursor: pointer;
        }

        .multi-agent-input button:disabled { opacity: 0.5; cursor: not-allowed; }

        .multi-agent-selector {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
            margin-bottom: 15px;
        }

        .multi-agent-chip {
            padding: 6px 12px;
            border-radius: 8px;
            border: 1px solid rgba(255,255,255,0.15);
            background: rgba(255,255,255,0.03);
            color: #aaa;
            font-size: 0.8em;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .multi-agent-chip.selected {
            background: var(--accent-muted);
            border-color: var(--accent);
            color: var(--accent);
        }

        .multi-results {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 15px;
        }

        .multi-result-card {
            background: rgba(0,0,0,0.2);
            border: 1px solid var(--accent-subtle);
            border-radius: 10px;
            padding: 15px;
            border-left: 3px solid var(--accent);
        }

        .multi-result-card h4 {
            color: var(--accent-light);
            margin-bottom: 10px;
            font-size: 0.95em;
        }

        .multi-result-card .response-text {
            color: #ccc;
            font-size: 0.85em;
            line-height: 1.6;
            white-space: pre-wrap;
        }

        .multi-result-card .response-meta {
            margin-top: 8px;
            font-size: 0.75em;
            color: #666;
        }

        /* Light theme login/multi-agent — handled by CSS vars */

        /* ==================== COMMAND PALETTE ==================== */
        .cmd-overlay {
            position: fixed; top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0,0,0,0.6); z-index: 9000;
            display: none; align-items: flex-start; justify-content: center;
            padding-top: 15vh; backdrop-filter: blur(3px);
        }
        .cmd-overlay.open { display: flex; }
        .cmd-box {
            width: 520px; max-height: 420px;
            background: var(--bg-elevated);
            border: 1px solid var(--border);
            border-radius: var(--radius-lg);
            box-shadow: var(--shadow-xl);
            overflow: hidden; display: flex; flex-direction: column;
        }
        .cmd-input-wrap {
            padding: 14px 16px; border-bottom: 1px solid var(--accent-muted);
            display: flex; align-items: center; gap: 10px;
        }
        .cmd-input-wrap span { color: var(--accent); font-size: 1.1em; }
        .cmd-input {
            flex: 1; background: none; border: none; color: var(--text-primary);
            font-size: var(--text-md); font-family: inherit; outline: none;
        }
        .cmd-input::placeholder { color: var(--text-muted); }
        .cmd-hint { color: #555; font-size: 0.7em; white-space: nowrap; }
        .cmd-results {
            overflow-y: auto; max-height: 340px; padding: 6px 0;
        }
        .cmd-group-label {
            padding: 6px 16px; font-size: 0.7em; color: #888;
            text-transform: uppercase; letter-spacing: 1px; font-weight: 700;
        }
        .cmd-item {
            padding: 10px 16px; display: flex; align-items: center; gap: 10px;
            cursor: pointer; transition: background 0.15s;
        }
        .cmd-item:hover, .cmd-item.active {
            background: var(--accent-subtle);
        }
        .cmd-item-icon { font-size: 1em; width: 24px; text-align: center; }
        .cmd-item-text { flex: 1; color: var(--text-primary); font-size: var(--text-sm); }
        .cmd-item-hint { color: var(--text-muted); font-size: var(--text-xs); }
        .cmd-empty { padding: var(--space-5); text-align: center; color: var(--text-muted); font-size: var(--text-sm); }

        /* Light theme cmd palette — handled by CSS vars */

        /* ==================== AGENT CONFIG MODAL ==================== */
        .modal-overlay {
            position: fixed; top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0,0,0,0.6); z-index: 8000;
            display: none; align-items: center; justify-content: center;
            backdrop-filter: blur(3px);
        }
        .modal-overlay.open { display: flex; }
        .modal-box {
            width: 480px; max-height: 80vh; overflow-y: auto;
            background: var(--bg-elevated);
            border: 1px solid var(--border); border-radius: var(--radius-lg);
            box-shadow: var(--shadow-xl); padding: var(--space-6);
        }
        .modal-box h2 { color: var(--text-primary); margin-bottom: var(--space-5); font-size: var(--text-lg); font-weight: 600; }
        .modal-field { margin-bottom: 14px; }
        .modal-field label { display: block; color: #888; font-size: 0.8em; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
        .modal-field input, .modal-field select, .modal-field textarea {
            width: 100%; padding: 8px 12px;
            background: rgba(255,255,255,0.05); border: 1px solid var(--border-hover);
            border-radius: 6px; color: var(--text-primary); font-size: 0.9em; font-family: inherit;
        }
        .modal-field input:focus, .modal-field select:focus, .modal-field textarea:focus {
            outline: none; border-color: var(--accent);
        }
        .modal-field textarea { min-height: 60px; resize: vertical; }
        .modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }
        .modal-actions button {
            padding: 8px 20px; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 0.85em; border: 1px solid;
        }
        .modal-btn-save { background: var(--accent); border-color: var(--accent); color: var(--text-inverse); }
        .modal-btn-save:hover { background: var(--accent-hover); color: var(--text-inverse); }
        .modal-btn-cancel { background: transparent; border-color: var(--border); color: var(--text-tertiary); }
        .modal-btn-cancel:hover { border-color: var(--accent); color: var(--accent); }

        /* Light theme modal — handled by CSS vars */

        /* ==================== BATCH SELECT ==================== */
        .batch-bar {
            display: none; padding: 10px 16px; margin-bottom: 10px;
            background: rgba(78,115,223,0.1); border: 1px solid var(--border-hover);
            border-radius: 8px; align-items: center; gap: 10px; font-size: 0.85em;
        }
        .batch-bar.active { display: flex; }
        .batch-bar button {
            padding: 4px 12px; border-radius: 5px; border: 1px solid;
            cursor: pointer; font-size: 0.8em; font-weight: 600;
        }
        .batch-bar .bb-start { background: var(--success-subtle); border-color: var(--success); color: var(--success); }
        .batch-bar .bb-stop { background: var(--danger-subtle); border-color: var(--danger); color: var(--danger); }
        .batch-bar .bb-restart { background: var(--warning-subtle); border-color: var(--warning); color: var(--warning); }
        .batch-count { color: var(--accent); font-weight: 700; }
        .agent-grid-row .batch-checkbox {
            width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent);
        }

        /* ==================== FULLSCREEN PANEL ==================== */
        .fullscreen-overlay {
            position: fixed; top: 0; left: 0; right: 0; bottom: 0;
            background: var(--bg-base);
            z-index: 7000; display: none; flex-direction: column;
            padding: 20px;
        }
        .fullscreen-overlay.open { display: flex; }
        .fullscreen-header {
            display: flex; justify-content: space-between; align-items: center;
            margin-bottom: 15px;
        }
        .fullscreen-header h2 { color: var(--accent-light); font-size: 1.2em; }
        .fullscreen-close {
            background: var(--danger-subtle); border: 1px solid var(--danger); color: var(--danger);
            padding: 6px 16px; border-radius: 6px; cursor: pointer; font-weight: 600;
        }
        .fullscreen-body { flex: 1; overflow-y: auto; }
        .expand-btn {
            background: rgba(255,255,255,0.05); border: 1px solid var(--accent-muted);
            color: #888; padding: 4px 8px; border-radius: 4px; cursor: pointer; font-size: 0.75em;
        }
        .expand-btn:hover { border-color: var(--accent); color: var(--accent); }

        /* Light theme fullscreen — handled by CSS vars */

        /* ==================== P7: CONVERSATION BROWSER ==================== */
        .conv-filters {
            display: flex; gap: 10px; margin-bottom: 15px; flex-wrap: wrap; align-items: center;
        }
        .conv-filters select, .conv-filters input {
            background: rgba(255,255,255,0.05); border: 1px solid var(--border-hover);
            color: var(--text-primary); padding: 7px 12px; border-radius: 6px; font-size: 0.85em; font-family: inherit;
        }
        .conv-filters select:focus, .conv-filters input:focus { outline: none; border-color: var(--accent); }
        .conv-item {
            padding: 12px 16px; border: 1px solid rgba(78,115,223,0.1); border-radius: 8px;
            margin-bottom: 8px; cursor: pointer; transition: all 0.2s;
            background: rgba(255,255,255,0.02);
        }
        .conv-item:hover { background: rgba(78,115,223,0.08); border-color: var(--border-hover); }
        .conv-item-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
        .conv-item-agent { color: var(--accent); font-weight: 600; font-size: 0.85em; }
        .conv-item-time { color: #666; font-size: 0.75em; }
        .conv-item-preview { color: #aaa; font-size: 0.82em; line-height: 1.4; }
        .conv-item-type { font-size: 0.7em; padding: 2px 6px; border-radius: 4px; font-weight: 600; }
        .conv-item-type.user { background: var(--accent-subtle); color: var(--accent-light); }
        .conv-item-type.agent { background: var(--success-subtle); color: var(--success); }
        .conv-pagination {
            display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 15px;
        }
        .conv-pagination button {
            background: rgba(78,115,223,0.1); border: 1px solid var(--border-hover);
            color: var(--accent); padding: 5px 14px; border-radius: 6px; cursor: pointer; font-size: 0.8em;
        }
        .conv-pagination button:disabled { opacity: 0.3; cursor: not-allowed; }
        .conv-pagination span { color: #888; font-size: 0.8em; }
        .conv-detail-overlay {
            position: fixed; top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0,0,0,0.7); z-index: 8500;
            display: none; align-items: center; justify-content: center;
            backdrop-filter: blur(3px);
        }
        .conv-detail-overlay.open { display: flex; }
        .conv-detail-box {
            width: 600px; max-height: 80vh; overflow-y: auto;
            background: var(--bg-elevated);
            border: 1px solid var(--border); border-radius: 14px;
            box-shadow: 0 25px 60px rgba(0,0,0,0.5); padding: 25px;
        }
        .conv-detail-box h3 { color: var(--accent); margin-bottom: 12px; }
        .conv-detail-content { color: #ddd; font-size: 0.9em; line-height: 1.7; white-space: pre-wrap; }
        .conv-detail-meta { color: #666; font-size: 0.75em; margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(78,115,223,0.1); }

        body.light-theme .conv-item { background: rgba(255,255,255,0.5); border-color: rgba(0,0,0,0.08); }
        body.light-theme .conv-item:hover { background: rgba(78,115,223,0.05); }
        body.light-theme .conv-detail-box { background: rgba(255,255,255,0.95); }
        body.light-theme .conv-detail-content { color: #333; }
        body.light-theme .conv-filters select, body.light-theme .conv-filters input { background: rgba(0,0,0,0.03); color: #333; }

        /* ==================== P7: AGENT TIMELINE ==================== */
        .timeline-row {
            display: flex; align-items: center; gap: 10px; padding: 6px 0;
            border-bottom: 1px solid rgba(255,255,255,0.03);
        }
        .timeline-name { width: 100px; font-size: 0.8em; color: var(--accent); font-weight: 600; text-align: right; flex-shrink: 0; }
        .timeline-bar {
            flex: 1; height: 20px; background: rgba(255,255,255,0.03);
            border-radius: 4px; position: relative; overflow: hidden;
        }
        .timeline-dot {
            position: absolute; width: 6px; height: 100%;
            background: var(--success); border-radius: 2px; opacity: 0.8;
        }
        .timeline-dot.user { background: var(--warning); }
        .timeline-count { width: 30px; font-size: 0.75em; color: #888; text-align: center; }
        .timeline-hours {
            display: flex; margin-left: 110px; margin-right: 40px; justify-content: space-between;
            font-size: 0.65em; color: #555; padding: 2px 0;
        }

        /* ==================== P7: SETTINGS PANEL ==================== */
        .settings-overlay {
            position: fixed; top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0,0,0,0.6); z-index: 8800;
            display: none; align-items: center; justify-content: center;
            backdrop-filter: blur(3px);
        }
        .settings-overlay.open { display: flex; }
        .settings-box {
            width: 500px; max-height: 80vh; overflow-y: auto;
            background: var(--bg-elevated);
            border: 1px solid var(--border); border-radius: 14px;
            box-shadow: 0 25px 60px rgba(0,0,0,0.5); padding: 25px;
        }
        .settings-box h2 { color: var(--accent); margin-bottom: 20px; font-size: 1.2em; }
        .settings-group { margin-bottom: 18px; }
        .settings-group label { display: block; color: #888; font-size: 0.8em; margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px; }
        .settings-group select, .settings-group input[type="number"] {
            width: 100%; padding: 8px 12px;
            background: rgba(255,255,255,0.05); border: 1px solid var(--border-hover);
            border-radius: 6px; color: var(--text-primary); font-size: 0.9em; font-family: inherit;
        }
        .settings-group select:focus, .settings-group input:focus { outline: none; border-color: var(--accent); }
        .settings-toggle { display: flex; align-items: center; gap: 10px; }
        .settings-toggle input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }
        .settings-toggle span { color: #ccc; font-size: 0.9em; }
        .settings-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }
        .settings-actions button {
            padding: 8px 20px; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 0.85em; border: 1px solid;
        }
        .settings-save { background: var(--accent); border-color: var(--accent); color: var(--text-inverse); }
        .settings-save:hover { background: var(--accent-hover); color: var(--text-inverse); }
        .settings-cancel { background: transparent; border-color: #666; color: #888; }

        body.light-theme .settings-box { background: rgba(255,255,255,0.95); }
        body.light-theme .settings-group select, body.light-theme .settings-group input { background: rgba(0,0,0,0.03); color: #333; }
        body.light-theme .settings-toggle span { color: #333; }

        /* ==================== P7: CONTEXT MENU ==================== */
        .ctx-menu {
            position: fixed; z-index: 9500;
            background: var(--bg-elevated);
            border: 1px solid var(--accent); border-radius: 8px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.6);
            padding: 4px 0; min-width: 160px; display: none;
        }
        .ctx-menu.open { display: block; }
        .ctx-menu-item {
            padding: 8px 14px; cursor: pointer; font-size: 0.85em;
            color: #ccc; display: flex; align-items: center; gap: 8px;
            transition: background 0.15s;
        }
        .ctx-menu-item:hover { background: rgba(78,115,223,0.12); color: var(--text-inverse); }
        .ctx-menu-sep { height: 1px; background: var(--accent-subtle); margin: 3px 0; }

        body.light-theme .ctx-menu { background: rgba(255,255,255,0.95); border-color: var(--accent); }
        body.light-theme .ctx-menu-item { color: #333; }
        body.light-theme .ctx-menu-item:hover { background: rgba(78,115,223,0.06); }

        /* ==================== P7: PINNED NOTES ==================== */
        .notes-grid {
            display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
            gap: 12px; margin-top: 15px;
        }
        .note-card {
            padding: 12px 14px; border-radius: 8px; min-height: 80px;
            position: relative; cursor: default;
            border: 1px solid rgba(255,255,255,0.1);
        }
        .note-card-text {
            color: var(--text-inverse); font-size: 0.85em; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
        }
        .note-card-actions {
            position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; opacity: 0;
            transition: opacity 0.2s;
        }
        .note-card:hover .note-card-actions { opacity: 1; }
        .note-card-actions button {
            background: rgba(0,0,0,0.3); border: none; color: var(--text-inverse); width: 22px; height: 22px;
            border-radius: 4px; cursor: pointer; font-size: 0.7em; display: flex; align-items: center; justify-content: center;
        }
        .note-card-actions button:hover { background: rgba(255,51,51,0.5); }
        .note-add-btn {
            border: 2px dashed var(--border-hover); border-radius: 8px; min-height: 80px;
            display: flex; align-items: center; justify-content: center;
            color: #666; font-size: 0.85em; cursor: pointer; transition: all 0.2s;
            background: transparent;
        }
        .note-add-btn:hover { border-color: var(--accent); color: var(--accent); }

        /* ==================== P8: AGENT COMPARISON ==================== */
        .compare-selector { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 15px; }
        .compare-selector select {
            background: rgba(255,255,255,0.05); border: 1px solid var(--border-hover);
            color: var(--text-primary); padding: 6px 10px; border-radius: 6px; font-size: 0.85em; font-family: inherit;
        }
        .compare-selector select:focus { outline: none; border-color: var(--accent); }
        .compare-table { width: 100%; border-collapse: collapse; font-size: 0.85em; }
        .compare-table th {
            text-align: left; padding: 8px 12px; color: var(--accent); border-bottom: 2px solid var(--accent-muted);
            font-weight: 700; font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.5px;
        }
        .compare-table td {
            padding: 8px 12px; border-bottom: 1px solid rgba(255,255,255,0.04); color: #ccc;
        }
        .compare-table tr:hover td { background: rgba(78,115,223,0.05); }
        .compare-metric-label { color: #888; font-weight: 600; }
        .compare-winner { color: var(--success); font-weight: 700; }

        body.light-theme .compare-selector select { background: rgba(0,0,0,0.03); color: #333; }
        body.light-theme .compare-table td { color: #444; }

        /* ==================== P8: AUDIT LOG ==================== */
        .audit-entry {
            display: flex; align-items: center; gap: 10px; padding: 6px 12px;
            border-bottom: 1px solid rgba(255,255,255,0.03); font-size: 0.82em;
        }
        .audit-time { color: #666; width: 130px; flex-shrink: 0; font-family: monospace; font-size: 0.9em; }
        .audit-action {
            padding: 2px 8px; border-radius: 4px; font-weight: 600; font-size: 0.8em;
            white-space: nowrap;
        }
        .audit-action.login { background: var(--success-subtle); color: var(--success); }
        .audit-action.logout { background: var(--accent-subtle); color: var(--accent-light); }
        .audit-action.agent_config { background: var(--accent-subtle); color: var(--accent); }
        .audit-action.batch_start, .audit-action.batch_restart { background: var(--success-subtle); color: var(--success); }
        .audit-action.batch_stop { background: var(--danger-subtle); color: var(--danger); }
        .audit-action.summary_generated { background: rgba(59,130,246,0.15); color: var(--info); }
        .audit-details { color: #888; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

        /* ==================== P8: FAVORITES ==================== */
        .fav-star {
            cursor: pointer; font-size: 0.9em; opacity: 0.3; transition: opacity 0.2s;
            user-select: none; padding: 0 2px;
        }
        .fav-star.active { opacity: 1; }
        .fav-star:hover { opacity: 0.8; }

        /* ==================== P8: SUMMARY CARD ==================== */
        .summary-card {
            background: linear-gradient(135deg, rgba(78,115,223,0.08), rgba(111,143,248,0.05));
            border: 1px solid var(--accent-muted); border-radius: 12px;
            padding: 18px; margin-top: 20px;
        }
        .summary-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
        .summary-card-title { color: var(--accent-light); font-weight: 700; font-size: 1em; }
        .summary-card-text { color: #ccc; font-size: 0.9em; line-height: 1.6; white-space: pre-wrap; }
        .summary-card-meta { color: #555; font-size: 0.75em; margin-top: 8px; }
        .summary-loading { color: #888; font-style: italic; }
        .summary-btn {
            background: var(--accent-muted); border: 1px solid var(--accent); color: var(--accent);
            padding: 5px 14px; border-radius: 6px; cursor: pointer; font-size: 0.8em; font-weight: 600;
        }
        .summary-btn:hover { background: var(--accent); color: var(--text-inverse); }
        .summary-btn:disabled { opacity: 0.4; cursor: not-allowed; }

        body.light-theme .summary-card { background: rgba(78,115,223,0.03); }
        body.light-theme .summary-card-text { color: #444; }

        /* ==================== P8: KEYBOARD HELP ==================== */
        .kb-help-overlay {
            position: fixed; top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0,0,0,0.6); z-index: 8900;
            display: none; align-items: center; justify-content: center;
            backdrop-filter: blur(3px);
        }
        .kb-help-overlay.open { display: flex; }
        .kb-help-box {
            width: 520px; max-height: 80vh; overflow-y: auto;
            background: var(--bg-elevated);
            border: 1px solid var(--border); border-radius: 14px;
            box-shadow: 0 25px 60px rgba(0,0,0,0.5); padding: 25px;
        }
        .kb-help-box h2 { color: var(--accent); margin-bottom: 18px; font-size: 1.2em; }
        .kb-row {
            display: flex; justify-content: space-between; align-items: center;
            padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.04);
        }
        .kb-key {
            display: inline-block; padding: 3px 8px; background: rgba(78,115,223,0.12);
            border: 1px solid var(--border-hover); border-radius: 4px;
            color: var(--accent-light); font-family: monospace; font-size: 0.85em; font-weight: 600;
        }
        .kb-desc { color: #aaa; font-size: 0.85em; }
        .kb-section { color: var(--accent); font-size: 0.75em; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; padding: 12px 0 4px; }

        body.light-theme .kb-help-box { background: rgba(255,255,255,0.95); }
        body.light-theme .kb-key { background: rgba(78,115,223,0.06); color: var(--accent); }
        body.light-theme .kb-desc { color: #555; }

        /* ==================== MARKDOWN IN CHAT ==================== */
        .message-content h1, .message-content h2, .message-content h3 {
            color: var(--accent-light); margin: 8px 0 4px; font-size: 1em;
        }
        .message-content h1 { font-size: 1.15em; }
        .message-content code {
            background: var(--accent-subtle); padding: 1px 5px; border-radius: 3px;
            font-family: monospace; font-size: 0.88em;
        }
        .message-content pre {
            background: rgba(0,0,0,0.4); padding: 10px 12px; border-radius: 6px;
            overflow-x: auto; margin: 6px 0; font-size: 0.82em; line-height: 1.5;
        }
        .message-content pre code {
            background: none; padding: 0;
        }
        .message-content ul, .message-content ol {
            margin: 4px 0; padding-left: 18px;
        }
        .message-content li { margin-bottom: 2px; }
        .message-content table {
            border-collapse: collapse; margin: 6px 0; font-size: 0.85em; width: 100%;
        }
        .message-content th, .message-content td {
            border: 1px solid var(--accent-muted); padding: 4px 8px; text-align: left;
        }
        .message-content th { background: rgba(78,115,223,0.1); color: var(--accent-light); }
        .message-content strong { color: var(--accent-light); }
        .message-content a { color: var(--accent); text-decoration: underline; }
        .message-content blockquote {
            border-left: 2px solid var(--accent); padding-left: 10px; margin: 6px 0;
            color: #aaa; font-style: italic;
        }
        body.light-theme .message-content pre { background: rgba(0,0,0,0.06); }
        body.light-theme .message-content code { background: rgba(78,115,223,0.08); }
        body.light-theme .message-content strong { color: #333; }

        /* ==================== NOTIFICATION CENTER ==================== */
        .notif-bell {
            position: relative;
            background: rgba(255,255,255,0.1);
            border: 1px solid var(--border-hover);
            color: var(--accent-light);
            padding: 4px 10px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.95em;
            transition: all 0.3s ease;
        }
        .notif-bell:hover { border-color: var(--accent); }
        .notif-badge {
            position: absolute; top: -5px; right: -5px;
            background: var(--danger); color: var(--text-inverse); font-size: 0.65em;
            min-width: 16px; height: 16px; border-radius: 50%;
            display: flex; align-items: center; justify-content: center;
            font-weight: 700;
        }
        .notif-badge.hidden { display: none; }
        .notif-dropdown {
            position: absolute; top: 100%; right: 0; margin-top: 8px;
            width: 340px; max-height: 400px; overflow-y: auto;
            background: var(--bg-elevated);
            border: 1px solid var(--border-hover); border-radius: 10px;
            box-shadow: 0 15px 40px rgba(0,0,0,0.5);
            z-index: 200; display: none;
        }
        .notif-dropdown.open { display: block; }
        .notif-dropdown-header {
            padding: 10px 14px; border-bottom: 1px solid var(--accent-muted);
            display: flex; justify-content: space-between; align-items: center;
            font-size: 0.85em; color: var(--accent-light); font-weight: 700;
        }
        .notif-dropdown-header button {
            background: none; border: none; color: #888; font-size: 0.8em; cursor: pointer;
        }
        .notif-dropdown-header button:hover { color: var(--accent); }
        .notif-item {
            padding: 8px 14px; border-bottom: 1px solid rgba(255,255,255,0.03);
            font-size: 0.82em; display: flex; gap: 8px; align-items: flex-start;
        }
        .notif-item:hover { background: rgba(78,115,223,0.05); }
        .notif-item .notif-time { color: #666; font-size: 0.85em; white-space: nowrap; }
        .notif-item .notif-msg { color: #ccc; flex: 1; }
        .notif-empty { padding: 20px; text-align: center; color: #666; font-size: 0.85em; }

        body.light-theme .notif-dropdown { background: rgba(255,255,255,0.95); border-color: rgba(0,0,0,0.1); }
        body.light-theme .notif-item .notif-msg { color: #444; }

        /* ==================== HEALTH INDICATOR ==================== */
        .health-indicator {
            display: flex; align-items: center; gap: 4px;
            font-size: 0.75em; color: #888;
        }
        .health-dot {
            width: 8px; height: 8px; border-radius: 50%;
        }
        .health-dot.healthy { background: var(--success); }
        .health-dot.warning { background: var(--warning); }
        .health-dot.critical { background: var(--danger); animation: pulse 1s infinite; }

        /* ==================== ROADMAP EDITABLE ==================== */
        .roadmap-category {
            margin-bottom: 20px;
        }
        .roadmap-category-header {
            display: flex; justify-content: space-between; align-items: center;
            margin-bottom: 10px;
        }
        .roadmap-category-header h3 { color: var(--accent-light); font-size: 1em; }
        .roadmap-item {
            display: flex; align-items: center; gap: 10px;
            padding: 8px 12px; margin-bottom: 4px;
            background: rgba(255,255,255,0.02); border-radius: 6px;
            border-left: 3px solid var(--accent-muted);
            cursor: pointer; transition: all 0.2s ease;
        }
        .roadmap-item:hover { background: rgba(78,115,223,0.05); }
        .roadmap-item.done { border-left-color: var(--success); }
        .roadmap-item.done .roadmap-text { text-decoration: line-through; color: #666; }
        .roadmap-check {
            width: 18px; height: 18px; border-radius: 4px;
            border: 2px solid var(--border-hover); cursor: pointer;
            display: flex; align-items: center; justify-content: center;
            font-size: 0.7em; transition: all 0.2s ease; flex-shrink: 0;
        }
        .roadmap-item.done .roadmap-check {
            background: var(--success); border-color: var(--success); color: var(--bg-base);
        }
        .roadmap-text { flex: 1; color: #ccc; font-size: 0.9em; }
        .roadmap-remove {
            background: none; border: none; color: #666; cursor: pointer;
            font-size: 0.8em; opacity: 0; transition: opacity 0.2s;
        }
        .roadmap-item:hover .roadmap-remove { opacity: 1; }
        .roadmap-remove:hover { color: var(--danger); }
        .roadmap-add {
            display: flex; gap: 8px; margin-top: 8px;
        }
        .roadmap-add input {
            flex: 1; padding: 6px 10px;
            background: rgba(255,255,255,0.05); border: 1px solid var(--accent-muted);
            border-radius: 6px; color: #ccc; font-size: 0.85em; font-family: inherit;
        }
        .roadmap-add input:focus { outline: none; border-color: var(--accent); }
        .roadmap-add button {
            padding: 6px 14px; background: var(--accent-muted); border: 1px solid var(--accent);
            border-radius: 6px; color: var(--accent-light); cursor: pointer; font-size: 0.85em;
        }
        .roadmap-progress {
            height: 6px; background: rgba(255,255,255,0.05); border-radius: 3px; overflow: hidden;
            margin-top: 6px;
        }
        .roadmap-progress-bar {
            height: 100%; background: linear-gradient(90deg, var(--accent), var(--success));
            border-radius: 3px; transition: width 0.5s ease;
        }

        body.light-theme .roadmap-item { background: rgba(255,255,255,0.5); }
        body.light-theme .roadmap-text { color: #444; }

        /* ==================== CONNECTION STATUS ==================== */
        .conn-banner {
            position: fixed; top: 0; left: 0; right: 0;
            background: rgba(255,51,51,0.95); color: var(--text-inverse);
            text-align: center; padding: 8px; font-size: 0.85em;
            font-weight: 600; z-index: 10000;
            transform: translateY(-100%); transition: transform 0.3s ease;
        }
        .conn-banner.show { transform: translateY(0); }

        /* ==================== AGENTS GRID ==================== */
        .agent-grid-row {
            display: grid;
            grid-template-columns: 24px 10px 1fr 40px 100px 120px 60px 60px 180px;
            gap: var(--space-3);
            align-items: center;
            padding: var(--space-3) var(--space-4);
            background: transparent;
            border: 1px solid transparent;
            border-radius: var(--radius-md);
            cursor: pointer;
            transition: all var(--transition-fast);
        }

        .agent-grid-row:hover {
            background: var(--bg-card-hover);
            border-color: var(--border);
        }

        .agent-grid-row.selected {
            background: var(--accent-subtle);
            border-color: var(--accent);
        }

        .agent-grid-header {
            display: grid;
            grid-template-columns: 24px 10px 1fr 40px 100px 120px 60px 60px 180px;
            gap: 12px;
            padding: 8px 16px;
            font-size: 0.75em;
            color: #888;
            text-transform: uppercase;
            letter-spacing: 1px;
            font-weight: 700;
        }

        .agent-grid-name {
            font-weight: 500;
            color: var(--text-primary);
        }

        .agent-grid-role {
            font-size: var(--text-xs);
            color: var(--text-tertiary);
        }

        .agent-grid-model {
            font-size: var(--text-xs);
            color: var(--text-secondary);
            font-family: var(--font-mono);
        }

        .agent-grid-badge {
            display: inline-block;
            padding: 3px 10px;
            border-radius: 12px;
            font-size: 0.75em;
            font-weight: 700;
            text-transform: uppercase;
        }

        .agent-grid-badge.working { background: var(--success-subtle); color: var(--success); }
        .agent-grid-badge.idle    { background: var(--warning-subtle); color: var(--warning); }
        .agent-grid-badge.offline { background: rgba(82,82,91,0.2); color: var(--text-tertiary); }
        .agent-grid-badge.error   { background: var(--danger-subtle); color: var(--danger); }

        .agent-grid-actions {
            display: flex;
            gap: 6px;
        }

        .agent-grid-actions button {
            padding: 4px 8px;
            border-radius: 5px;
            border: 1px solid;
            cursor: pointer;
            font-size: 0.75em;
            font-weight: 600;
            transition: all 0.2s ease;
        }

        .agent-grid-actions button:hover { transform: scale(1.05); }
        .agent-grid-actions button:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }
        .agent-grid-actions .ag-start { background: var(--success-subtle); border-color: var(--success); color: var(--success); }
        .agent-grid-actions .ag-stop { background: var(--danger-subtle); border-color: var(--danger); color: var(--danger); }
        .agent-grid-actions .ag-restart { background: var(--warning-subtle); border-color: var(--warning); color: var(--warning); }
        .agent-grid-actions .ag-chat { background: var(--accent-subtle); border-color: var(--accent); color: var(--accent); }

        body.light-theme .agent-grid-row { background: rgba(255,255,255,0.5); border-color: rgba(0,0,0,0.08); }
        body.light-theme .agent-grid-row:hover { background: rgba(78,115,223,0.05); }
        body.light-theme .agent-grid-name { color: #333; }
        body.light-theme .agent-grid-role { color: #666; }
        body.light-theme .agent-grid-model { color: #555; }

        @media (max-width: 1200px) {
            .agent-grid-row, .agent-grid-header {
                grid-template-columns: 24px 10px 1fr 40px 90px 60px 60px 160px;
            }
            .agent-grid-row > :nth-child(6) { display: none; }
            .agent-grid-header > :nth-child(6) { display: none; }
        }

        @media (max-width: 768px) {
            .agent-grid-row, .agent-grid-header {
                grid-template-columns: 24px 10px 1fr 40px 80px 140px;
            }
            .agent-grid-row > :nth-child(6),
            .agent-grid-row > :nth-child(7),
            .agent-grid-row > :nth-child(8),
            .agent-grid-header > :nth-child(6),
            .agent-grid-header > :nth-child(7),
            .agent-grid-header > :nth-child(8) { display: none; }
        }

        /* ==================== RESPONSIVE ==================== */
        @media (max-width: 1200px) {
            .main-wrapper {
                flex-direction: column;
            }

            .sidebar {
                width: 100%;
            }

            .agent-detail-panel {
                grid-template-columns: 1fr;
            }
        }

        @media (max-width: 768px) {
            .chat-widget {
                width: calc(100vw - 40px);
                height: 400px;
            }

            .header-metrics {
                flex-direction: column;
                gap: 8px;
            }

            .main-wrapper {
                margin: 10px auto;
                padding: 0 10px;
            }
        }

        /* ==================== MOBILE CSS (P9.4) ==================== */
        .hamburger-btn {
            display: none;
            background: none;
            border: none;
            color: var(--text-inverse);
            font-size: 1.5em;
            cursor: pointer;
            padding: 4px 8px;
            border-radius: 6px;
        }
        .hamburger-btn:hover { background: rgba(255,255,255,0.1); }

        @media (max-width: 768px) {
            .hamburger-btn { display: inline-block; }
            .sidebar {
                position: fixed;
                left: -260px;
                top: 0;
                bottom: 0;
                z-index: 6000;
                width: 250px;
                transition: left 0.3s ease;
                overflow-y: auto;
                background: var(--bg-base);
                border-right: 1px solid var(--border);
                padding-top: 60px;
            }
            .sidebar.mobile-open {
                left: 0;
                box-shadow: 4px 0 20px rgba(0,0,0,0.8);
            }
            .mobile-overlay {
                display: none;
                position: fixed;
                inset: 0;
                background: rgba(0,0,0,0.6);
                z-index: 5999;
            }
            .mobile-overlay.active { display: block; }
            .content-area { margin-left: 0 !important; }
            .tab-bar { flex-wrap: wrap; gap: 4px; }
            .tab-button { font-size: 0.7em; padding: 6px 10px; }
            .grid { grid-template-columns: 1fr !important; }
            .card { padding: 12px !important; }
            .agents-grid-row { font-size: 0.75em; }
            .agents-grid-row > span:nth-child(1) { display: none; } /* hide checkbox on mobile */
            .compare-selector { flex-direction: column; }
            .kb-help-box, .settings-box, .config-modal-box { width: 95vw !important; max-height: 85vh; }
            .cmd-box { width: 95vw !important; }
            .fullscreen-content { width: 98vw !important; height: 90vh !important; }
            .conv-detail-box { width: 95vw !important; }
        }

        @media (max-width: 480px) {
            .header-top { flex-direction: column; gap: 8px; }
            .header-logo h1 { font-size: 1em; }
            .header-metrics .metric { font-size: 0.75em; padding: 3px 8px; }
            .chat-widget { width: calc(100vw - 20px); right: 10px; bottom: 10px; }
            .tab-button { font-size: 0.65em; padding: 5px 8px; }
        }

        /* ==================== WEBHOOKS OVERLAY (P9.2) ==================== */
        .webhooks-overlay {
            display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7);
            z-index: 8700; justify-content: center; align-items: center;
        }
        .webhooks-overlay.open { display: flex; }
        .webhooks-box {
            background: var(--bg-surface); border: 1px solid var(--border); border-radius: 12px;
            padding: 30px; width: 550px; max-width: 95vw; max-height: 80vh; overflow-y: auto;
        }
        .webhooks-box h2 { color: var(--accent-light); margin-bottom: 15px; font-size: 1.2em; }
        .wh-field { margin-bottom: 14px; }
        .wh-field label { display: block; color: #aaa; font-size: 0.85em; margin-bottom: 4px; }
        .wh-field input, .wh-field textarea {
            width: 100%; background: var(--bg-base); border: 1px solid var(--border); color: var(--text-inverse);
            padding: 8px 12px; border-radius: 6px; font-size: 0.9em; box-sizing: border-box;
        }
        .wh-field textarea { min-height: 60px; resize: vertical; }
        .wh-actions { display: flex; gap: 8px; margin-top: 15px; }
        .wh-actions button {
            flex: 1; padding: 8px; border-radius: 6px; cursor: pointer; font-weight: 600;
            border: 1px solid; font-size: 0.9em;
        }
        .wh-save { background: var(--success-subtle); border-color: var(--success) !important; color: var(--success); }
        .wh-test { background: var(--warning-subtle); border-color: var(--warning) !important; color: var(--warning); }
        .wh-cancel { background: var(--accent-subtle); border-color: var(--accent) !important; color: var(--accent); }

        /* ==================== ANALYTICS CHART (P9.5) ==================== */
        .analytics-chart-wrap {
            background: rgba(26,26,46,0.3); border: 1px solid var(--border); border-radius: 10px;
            padding: 15px; margin-top: 25px;
        }
        .analytics-chart-wrap h3 { color: var(--accent-light); margin-bottom: 12px; font-size: 1em; }
        .analytics-bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding: 0 5px; }
        .analytics-bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
        .analytics-bar {
            width: 100%; min-width: 20px; border-radius: 4px 4px 0 0;
            transition: height 0.3s ease; position: relative;
        }
        .analytics-bar:hover { opacity: 0.8; }
        .analytics-bar-label { font-size: 0.65em; color: #666; text-align: center; }
        .analytics-legend { display: flex; gap: 15px; margin-top: 10px; justify-content: center; }
        .analytics-legend span { font-size: 0.75em; color: #888; display: flex; align-items: center; gap: 4px; }
        .analytics-legend span::before {
            content: ''; width: 10px; height: 10px; border-radius: 2px; display: inline-block;
        }
        .analytics-legend .leg-conv::before { background: var(--success); }
        .analytics-legend .leg-agents::before { background: var(--warning); }
        .analytics-legend .leg-cost::before { background: var(--accent); }

        /* ==================== UTILITY CLASSES ==================== */
        .flex-between { display: flex; justify-content: space-between; align-items: center; }
        .flex-between.mb-15 { margin-bottom: 15px; }
        .flex-between.mb-12 { margin-bottom: 12px; }
        .flex-between.mb-10 { margin-bottom: 10px; }
        .flex-gap { display: flex; gap: 8px; }
        .gap-4 { gap: 4px; }
        .text-center { text-align: center; }
        .text-muted { color: var(--text-muted); }
        .text-secondary { color: var(--text-secondary); }
        .text-sm { font-size: var(--text-sm); }
        .text-xs { font-size: var(--text-xs); }
        .mt-20 { margin-top: 20px; }
        .mt-25 { margin-top: 25px; }
        .mt-30 { margin-top: 30px; }
        .mb-12 { margin-bottom: 12px; }
        .mb-20 { margin-bottom: 20px; }
        .grid-4 { grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 20px; }
        .grid-2 { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 15px; }
        .grid-auto { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
        .placeholder { color: var(--text-muted); text-align: center; padding: var(--space-5); }
        .placeholder-lg { color: var(--text-muted); text-align: center; padding: 40px; }
        .data-list { font-size: 0.9em; color: var(--text-secondary); }
        .log-container { margin-top: 12px; font-family: var(--font-mono); font-size: 0.8em; line-height: 1.8; color: var(--text-secondary); max-height: 500px; overflow-y: auto; }
        .audit-container { margin-top: 12px; max-height: 300px; overflow-y: auto; }
        .wh-checkbox-label { color: var(--text-secondary); font-size: 0.85em; display: flex; align-items: center; gap: 4px; }
        .vs-label { color: var(--text-muted); align-self: center; }
        .filter-input { flex: 1; min-width: 200px; padding: 6px 12px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); font-size: var(--text-sm); font-family: inherit; }
        .select-inline { background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-primary); padding: 4px 8px; border-radius: var(--radius-sm); font-size: var(--text-xs); }
        .filter-error { color: var(--danger); border-color: var(--danger); }
        .filter-warning { color: var(--warning); border-color: var(--warning); }
        .filter-info { color: var(--success); border-color: var(--success); }
        .mt-8 { margin-top: 8px; }
        .mt-15 { margin-top: 15px; }
        .mb-15 { margin-bottom: 15px; }
        .flex-1 { flex: 1; }
        .containers-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
        .agents-list { display: flex; flex-direction: column; gap: 10px; }
        .cost-alert { display: none; background: var(--danger-subtle); border: 1px solid var(--danger); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); margin-bottom: var(--space-4); color: var(--danger); font-size: var(--text-sm); }
        .cost-alert strong { font-weight: 700; }
        .log-filters { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
        .wh-events { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
        .settings-divider { margin-top: 15px; padding-top: 15px; border-top: 1px solid var(--border); }
        .btn-close { color: var(--danger); border-color: var(--danger); }
        .btn-webhooks { width: 100%; padding: 8px 16px; color: var(--warning); border-color: var(--warning); }
