:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-tertiary: #232733;
    --bg-hover: #2a2e3b;
    --text-primary: #e4e4e7;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-light: rgba(99, 102, 241, 0.15);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --border: #2d3140;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* App Layout */
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.logo {
    font-size: 1.2em;
    font-weight: 700;
    color: var(--text-primary) !important;
}

.nav-list {
    list-style: none;
    padding: 12px;
    flex: 1;
}

.nav-link {
    display: block;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary) !important;
    font-size: 0.95em;
    transition: all 0.2s;
    margin-bottom: 4px;
}

.nav-link:hover { background: var(--bg-hover); color: var(--text-primary) !important; }
.nav-link.active { background: var(--accent-light); color: var(--accent) !important; }

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

.user-info { display: flex; align-items: center; justify-content: space-between; }
.user-name { font-size: 0.9em; color: var(--text-secondary); }
.btn-logout { font-size: 0.85em; color: var(--danger) !important; }

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 32px;
    max-width: 1200px;
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-title {
    font-size: 1.15em;
    font-weight: 600;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 0.85em; }
.btn-block { display: flex; justify-content: center; width: 100%; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95em;
    transition: border-color 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.form-textarea { min-height: 120px; resize: vertical; font-family: inherit; }

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.9em;
}

.alert-success { background: rgba(16, 185, 129, 0.15); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.3); }
.alert-error, .alert-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.alert-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.3); }
.alert-info { background: var(--accent-light); color: var(--accent); border: 1px solid rgba(99, 102, 241, 0.3); }

/* Tags / Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 500;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-info { background: var(--accent-light); color: var(--accent); }

/* Grid */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Stat cards */
.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.stat-value { font-size: 2em; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.9em; color: var(--text-secondary); margin-top: 4px; }

/* Chat layout */
.chat-layout {
    display: flex;
    height: calc(100vh - 64px);
    margin: -32px;
}

.chat-sidebar {
    width: 300px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.chat-sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chat-item {
    display: block;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary) !important;
    font-size: 0.9em;
    margin-bottom: 4px;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item:hover { background: var(--bg-hover); color: var(--text-primary) !important; }
.chat-item.active { background: var(--accent-light); color: var(--accent) !important; }

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.message {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    max-width: 800px;
}

.message-user { flex-direction: row-reverse; margin-left: auto; }

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9em;
    flex-shrink: 0;
}

.message-user .message-avatar { background: var(--accent); color: #fff; }
.message-assistant .message-avatar { background: var(--bg-tertiary); color: var(--accent); }

.message-content {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.95em;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.message-user .message-content { background: var(--accent); color: #fff; }
.message-assistant .message-content { background: var(--bg-tertiary); }

.message-meta {
    font-size: 0.75em;
    color: var(--text-muted);
    margin-top: 6px;
}

.chat-input-area {
    padding: 20px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.chat-input-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chat-input-form textarea {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.95em;
    font-family: inherit;
    resize: none;
    min-height: 48px;
    max-height: 200px;
}

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

.chat-input-form button {
    padding: 12px 24px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
}

.chat-input-form button:hover { background: var(--accent-hover); }
.chat-input-form button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Agent cards */
.agent-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: all 0.2s;
}

.agent-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.agent-card-name { font-size: 1.1em; font-weight: 600; margin-bottom: 8px; }
.agent-card-desc { font-size: 0.9em; color: var(--text-secondary); }

/* Auth pages */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}

.auth-title { font-size: 1.5em; font-weight: 700; margin-bottom: 8px; text-align: center; }
.auth-subtitle { color: var(--text-secondary); text-align: center; margin-bottom: 32px; }

/* Landing */
.landing { min-height: 100vh; display: flex; flex-direction: column; }

.hero {
    text-align: center;
    padding: 120px 20px 80px;
    max-width: 800px;
    margin: 0 auto;
}

.hero h1 { font-size: 3em; font-weight: 800; margin-bottom: 16px; line-height: 1.2; }
.hero p { font-size: 1.2em; color: var(--text-secondary); margin-bottom: 40px; }

.hero-buttons { display: flex; gap: 16px; justify-content: center; }
.hero-buttons .btn { padding: 14px 32px; font-size: 1.05em; }

.features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px 20px 80px;
}

.feature-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
}

.feature-icon { font-size: 2.5em; margin-bottom: 16px; }
.feature-title { font-size: 1.1em; font-weight: 600; margin-bottom: 8px; }
.feature-desc { font-size: 0.9em; color: var(--text-secondary); }

.pricing {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 80px 20px;
    text-align: center;
}

.pricing h2 { font-size: 2em; margin-bottom: 40px; }

.price-card {
    background: var(--bg-tertiary);
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    padding: 40px;
    max-width: 400px;
    margin: 0 auto;
}

.price-amount { font-size: 2.5em; font-weight: 800; color: var(--accent); }
.price-period { color: var(--text-secondary); font-size: 0.9em; margin-bottom: 24px; }

.price-features {
    list-style: none;
    text-align: left;
    margin-bottom: 32px;
}

.price-features li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.95em;
    color: var(--text-secondary);
}

.price-features li::before { content: '✓ '; color: var(--success); font-weight: 600; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .features { grid-template-columns: 1fr; }
    .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .hero h1 { font-size: 2em; }
    .chat-sidebar { width: 220px; }
}