:root {
    --primary: #FF6D5A;
    --secondary: #7E3AF2;
    --bg: #1F2937;
    --bg-card: #283548;
    --bg-input: #374151;
    --text: #F9FAFB;
    --text-muted: #9CA3AF;
    --success: #10B981;
    --accent: #3B82F6;
    --error: #EF4444;
    --warning: #F59E0B;
    --border: #374151;
    --radius: 10px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.app { max-width: 1400px; margin: 0 auto; padding: 0 24px; }

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.header-left { display: flex; align-items: center; gap: 12px; }

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 600;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
}

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

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

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid var(--border);
    transition: border-color 0.2s;
}

.stat-card:hover { border-color: var(--primary); }

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.doc-icon { background: rgba(255,109,90,0.15); color: var(--primary); }
.chunk-icon { background: rgba(126,58,242,0.15); color: var(--secondary); }
.session-icon { background: rgba(16,185,129,0.15); color: var(--success); }
.webhook-icon { background: rgba(59,130,246,0.15); color: var(--accent); }

.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 28px; font-weight: 700; font-family: 'Roboto Mono', monospace; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.panels-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

.panel.full-width { grid-column: 1 / -1; }

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

.panel-header h2 {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.avg-time {
    font-family: 'Roboto Mono', monospace;
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg);
    padding: 4px 10px;
    border-radius: 6px;
}

.panel-body { padding: 20px; }

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--primary);
    background: rgba(255,109,90,0.05);
}

.upload-zone p { margin-top: 12px; color: var(--text-muted); font-size: 14px; }
.upload-zone small { color: var(--text-muted); font-size: 12px; }
.upload-link { color: var(--primary); cursor: pointer; text-decoration: underline; }

.upload-progress { margin-top: 16px; }

.progress-bar {
    height: 4px;
    background: var(--bg);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.3s;
    border-radius: 2px;
}

#uploadStatus { font-size: 13px; color: var(--text-muted); margin-top: 8px; display: block; }

.doc-list { max-height: 320px; overflow-y: auto; }

.doc-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

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

.doc-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.doc-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-meta { font-size: 11px; color: var(--text-muted); font-family: 'Roboto Mono', monospace; }

.doc-status {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 500;
    margin-left: 12px;
    flex-shrink: 0;
}

.doc-status.completed { background: rgba(16,185,129,0.15); color: var(--success); }
.doc-status.processing { background: rgba(245,158,11,0.15); color: var(--warning); }
.doc-status.failed { background: rgba(239,68,68,0.15); color: var(--error); }
.doc-status.pending { background: rgba(156,163,175,0.15); color: var(--text-muted); }

.doc-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    margin-left: 8px;
    border-radius: 4px;
    transition: color 0.2s;
}

.doc-delete:hover { color: var(--error); }

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 30px;
    font-size: 13px;
}

.log-list { max-height: 300px; overflow-y: auto; }

.log-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

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

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

.log-status.success { background: var(--success); }
.log-status.error { background: var(--error); }

.log-session { color: var(--accent); font-family: 'Roboto Mono', monospace; font-size: 11px; min-width: 80px; }
.log-time-val { color: var(--text-muted); font-family: 'Roboto Mono', monospace; font-size: 11px; min-width: 60px; }
.log-timestamp { color: var(--text-muted); font-size: 11px; margin-left: auto; }

.chat-container { display: flex; flex-direction: column; height: 350px; }

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

.chat-msg {
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.5;
    max-width: 85%;
    word-wrap: break-word;
}

.chat-msg.system { background: var(--bg); color: var(--text-muted); align-self: center; text-align: center; font-size: 12px; }
.chat-msg.user { background: var(--primary); color: white; align-self: flex-end; border-bottom-right-radius: 2px; }
.chat-msg.assistant { background: var(--bg-input); color: var(--text); align-self: flex-start; border-bottom-left-radius: 2px; }

.chat-input-row { display: flex; gap: 10px; margin-top: 12px; }

.chat-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text);
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus { border-color: var(--primary); }

.btn-send {
    background: var(--primary);
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.btn-send:hover { opacity: 0.9; }
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }

.workflow-view { padding: 10px 0; }

.workflow-nodes {
    display: flex;
    align-items: center;
    gap: 0;
    overflow-x: auto;
    padding: 10px 0;
}

.wf-node {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    min-width: 150px;
    text-align: center;
    transition: border-color 0.2s;
    flex-shrink: 0;
}

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

.trigger-node { border-color: var(--primary); }
.agent-node { border-color: var(--secondary); }
.vector-node { border-color: var(--accent); }
.memory-node { border-color: var(--success); }
.code-node { border-color: var(--warning); }

.node-icon { margin-bottom: 8px; }
.trigger-node .node-icon { color: var(--primary); }
.agent-node .node-icon { color: var(--secondary); }
.vector-node .node-icon { color: var(--accent); }
.memory-node .node-icon { color: var(--success); }
.code-node .node-icon { color: var(--warning); }

.node-label { font-size: 12px; font-weight: 600; margin-bottom: 4px; }

.node-status {
    font-size: 10px;
    color: var(--text-muted);
    font-family: 'Roboto Mono', monospace;
}

.node-status.active { color: var(--success); }

.wf-connector {
    width: 40px;
    height: 2px;
    background: var(--border);
    flex-shrink: 0;
    position: relative;
}

.wf-connector::after {
    content: '';
    position: absolute;
    right: 0;
    top: -3px;
    width: 0;
    height: 0;
    border-left: 6px solid var(--border);
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
}

.workflow-sub-nodes {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.wf-sub-group { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.sub-label { font-size: 12px; color: var(--text-muted); margin-right: 8px; }

.wf-sub-node {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    background: var(--bg);
    padding: 6px 12px;
    border-radius: 6px;
}

.sub-dot { width: 6px; height: 6px; border-radius: 50%; }
.sub-dot.gemini { background: var(--warning); }
.sub-dot.openai { background: var(--success); }
.sub-dot.postgres { background: var(--accent); }

.btn-cleanup {
    background: var(--success);
    border: none;
    border-radius: 6px;
    padding: 6px 14px;
    color: white;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-cleanup:hover { opacity: 0.85; }

.cleanup-info {
    font-size: 13px;
    color: var(--text-muted);
    font-family: 'Roboto Mono', monospace;
}

.content { padding-bottom: 40px; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

@media (max-width: 900px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .panels-grid { grid-template-columns: 1fr; }
    .workflow-nodes { flex-wrap: wrap; justify-content: center; }
    .wf-connector { display: none; }
}

@media (max-width: 600px) {
    .stats-grid { grid-template-columns: 1fr; }
    .app { padding: 0 12px; }
}
