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

:root {
    --bg: #1a1a2e;
    --surface: #16213e;
    --primary: #e94560;
    --text: #eee;
    --text-dim: #888;
    --success: #4ade80;
    --warning: #fbbf24;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid #ffffff10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--success);
}

.status-dot.offline { background: var(--primary); }
.status-dot.degraded { background: var(--warning); }

.agent-name {
    font-weight: 600;
    font-size: 16px;
}

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

.model-badge {
    font-size: 11px;
    padding: 4px 8px;
    background: #ffffff15;
    border-radius: 12px;
    color: var(--text-dim);
}

.menu-btn {
    background: none;
    border: none;
    color: var(--text);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
}

/* Chat Area */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 14px;
    white-space: pre-wrap;
}

.message.user {
    align-self: flex-end;
    background: var(--primary);
    border-bottom-right-radius: 4px;
}

.message.assistant {
    align-self: flex-start;
    background: var(--surface);
    border-bottom-left-radius: 4px;
}

.message .model-tag {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 6px;
}

/* Input Area */
.input-area {
    padding: 12px 16px;
    background: var(--surface);
    border-top: 1px solid #ffffff10;
    display: flex;
    gap: 10px;
}

.input-area input {
    flex: 1;
    padding: 12px 16px;
    border-radius: 24px;
    border: 1px solid #ffffff20;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    outline: none;
}

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

.send-btn {
    padding: 12px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 24px;
    font-weight: 600;
    cursor: pointer;
}

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

/* Menu Overlay */
.menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: #00000080;
    z-index: 100;
}

.menu-overlay.open { display: block; }

.menu-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 280px;
    background: var(--surface);
    padding: 20px;
    z-index: 101;
    transform: translateX(100%);
    transition: transform 0.3s;
    overflow-y: auto;
}

.menu-overlay.open .menu-panel {
    transform: translateX(0);
}

.menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #ffffff10;
}

.menu-title { font-weight: 600; }

.close-btn {
    background: none;
    border: none;
    color: var(--text);
    font-size: 24px;
    cursor: pointer;
}

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

.menu-section-title {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 10px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.menu-item:hover { background: #ffffff10; }

.menu-item-icon { font-size: 18px; }

.status-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    font-size: 13px;
}

.status-value { color: var(--success); }
.status-value.error { color: var(--primary); }

.model-select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid #ffffff20;
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
}

/* Loading Animation */
.typing {
    display: flex;
    gap: 4px;
    padding: 16px;
}

.typing span {
    width: 8px;
    height: 8px;
    background: var(--text-dim);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing span:nth-child(1) { animation-delay: -0.32s; }
.typing span:nth-child(2) { animation-delay: -0.16s; }

.waiting {
    padding: 12px 16px;
    font-size: 14px;
    color: var(--text-dim);
}
.waiting .timer {
    color: var(--warning);
    margin-left: 8px;
}

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Modal Styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000000cc;
    z-index: 200;
    justify-content: center;
    align-items: center;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--surface);
    border-radius: 16px;
    padding: 24px;
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #ffffff10;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text);
    font-size: 24px;
    cursor: pointer;
}

.setting-group {
    margin-bottom: 24px;
}

.setting-label {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.speed-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.speed-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg);
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.speed-option:hover { border-color: #ffffff20; }
.speed-option.active { border-color: var(--primary); }
.speed-option input { display: none; }

.speed-icon { font-size: 24px; }
.speed-icon.slow { animation: pulse 3s infinite; }
.speed-icon.medium { animation: pulse 1.5s infinite; }
.speed-icon.fast { animation: pulse 0.5s infinite; }

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

.speed-info { flex: 1; }
.speed-name { font-weight: 500; font-size: 14px; }
.speed-desc { font-size: 12px; color: var(--text-dim); }

.setting-select, .setting-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid #ffffff20;
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
}

.setting-textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid #ffffff20;
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    min-height: 80px;
    resize: vertical;
    font-family: inherit;
}

.token-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.token-item { display: flex; flex-direction: column; gap: 4px; }
.token-item.full { grid-column: span 2; }
.token-label { font-size: 12px; color: var(--text-dim); }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #ffffff10;
}

.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    font-size: 14px;
}

.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: #ffffff15; color: var(--text); }
.btn:hover { opacity: 0.9; }

/* Facts list */
.facts-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.fact-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg);
    border-radius: 8px;
    font-size: 13px;
}

.fact-item span { flex: 1; }

.fact-delete {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
}

.add-fact-row {
    display: flex;
    gap: 8px;
}

.add-fact-row input { flex: 1; }

.add-fact-btn {
    padding: 10px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

/* Workspace File Chips */
.workspace-files {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #ffffff10;
}

.file-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #ffffff12;
    border: 1px solid #ffffff20;
    border-radius: 14px;
    font-size: 12px;
    cursor: pointer;
    color: var(--text);
    transition: all 0.2s;
}

.file-chip:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.file-chip .chip-icon { font-size: 11px; }
.file-chip.created { border-color: var(--success); }
.file-chip.created:hover { background: var(--success); }

/* File Viewer Modal */
.file-viewer-content {
    background: var(--bg);
    border: 1px solid #ffffff15;
    border-radius: 8px;
    padding: 16px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 50vh;
    overflow-y: auto;
    color: var(--text);
}

.file-viewer-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.file-viewer-path {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 8px;
}

/* Financial Panel */
