:root {
    --bg-dark: #09090b;
    --bg-panel: #18181b;
    --border: #27272a;
    --text-main: #f4f4f5;
    --text-muted: #a1a1aa;
    --accent: #10b981; /* Matrix green */
    --accent-glow: rgba(16, 185, 129, 0.2);
    --query-bg: #222225;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {
    display: flex;
    width: 100%;
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 16px;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
    
    .logo-box {
        margin-bottom: 0 !important;
    }
    
    .nav-links {
        flex-direction: row !important;
        gap: 16px !important;
        flex: none !important;
    }
    
    .db-status {
        display: none !important;
    }
}

.logo-box {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}

.logo-box i {
    font-size: 28px;
    color: var(--accent);
}

.logo-box h2 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    padding: 10px 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: 0.2s ease;
}

.nav-links a:hover, .nav-links a.active {
    background: var(--query-bg);
    color: var(--text-main);
}

.nav-links a.active i {
    color: var(--accent);
}

.db-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px;
    background: #111113;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.status-indicator.online {
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}

/* Workspace */
.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 32px 48px;
    overflow-y: auto;
    min-width: 0;
}

@media (max-width: 768px) {
    .workspace {
        padding: 20px !important;
    }
    .topbar {
        margin-bottom: 20px !important;
    }
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.topbar h1 {
    font-size: 24px;
    font-weight: 600;
}

@media (max-width: 480px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .topbar h1 {
        font-size: 18px;
    }
}

.badge {
    background: var(--query-bg);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

/* Query Section */
.query-section {
    margin-bottom: 32px;
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    transition: border 0.3s ease;
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
}

.input-wrapper i.ph-terminal-window {
    font-size: 24px;
    color: var(--text-muted);
    margin-right: 16px;
}

.input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 16px;
    padding: 12px 0;
    outline: none;
    font-family: 'Fira Code', monospace;
}

.input-wrapper input::placeholder {
    color: #52525b;
}

.input-wrapper button {
    background: var(--text-main);
    color: var(--bg-dark);
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: 0.2s ease;
}

.input-wrapper button:hover {
    background: var(--accent);
    color: #fff;
    transform: translateY(-1px);
}

.suggestions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.suggestion-chip {
    font-size: 12px;
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 16px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: 0.2s ease;
}

.suggestion-chip:hover {
    background: var(--query-bg);
    color: var(--text-main);
}

/* Results Grid */
.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    flex: 1;
    min-height: 0;
}

@media (max-width: 1024px) {
    .results-grid {
        grid-template-columns: 1fr;
    }
}

.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

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

.panel-header h3 i {
    color: var(--accent);
    font-size: 18px;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top: 2px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: none;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.thought-stream {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    font-family: 'Fira Code', monospace;
    font-size: 13px;
    line-height: 1.6;
    background: #000;
}

/* Agent Logs */
.log-entry {
    margin-bottom: 16px;
    padding: 12px;
    border-radius: 6px;
    border-left: 3px solid transparent;
}

.log-entry.system {
    color: #52525b;
}

.log-entry.action {
    background: rgba(39, 39, 42, 0.4);
    border-left-color: #3b82f6;
    color: #d4d4d8;
}

.log-entry.query {
    background: rgba(16, 185, 129, 0.05);
    border-left-color: var(--accent);
    color: var(--accent);
    margin-top: 8px;
    padding: 8px 12px;
}

.log-entry.observation {
    background: #18181b;
    border: 1px dashed var(--border);
    color: #a1a1aa;
    margin-top: 8px;
    white-space: pre-wrap;
    word-break: break-all;
}

.result-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background: var(--bg-dark);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    color: #27272a;
}

.final-answer {
    font-size: 15px;
    line-height: 1.7;
    margin-bottom: 24px;
}

.sql-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(39, 39, 42, 0.8);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    color: #d4d4d8;
    margin-bottom: 12px;
    text-transform: uppercase;
}

.sql-block {
    background: #000;
    color: var(--accent);
    padding: 16px;
    border-radius: 8px;
    font-family: 'Fira Code', monospace;
    font-size: 13px;
    border: 1px solid var(--border);
    margin-bottom: 24px;
    overflow-x: auto;
}

/* Consolidated from index.html */
.page-body {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - 200px);
    gap: 16px;
}
.charts-row {
    display: none;
    grid-template-columns: 1fr 2fr;
    gap: 16px;
    height: auto;
    min-height: 240px;
    flex-shrink: 0;
}
@media (max-width: 768px) {
    .charts-row {
        grid-template-columns: 1fr;
    }
}
.chart-box {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 240px;
}
.chart-box canvas {
    flex: 1;
    min-height: 0;
}
.cards-container {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 12px;
    align-content: start;
    padding: 4px 2px;
}
@media (max-width: 480px) {
    .cards-container {
        grid-template-columns: 1fr;
    }
}
.incident-card {
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 10px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color 0.2s ease, background 0.2s ease;
}
.incident-card:hover {
    border-color: rgba(16, 185, 129, 0.3);
    background: #1c1c1f;
}
.card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}
.card-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.card-date {
    font-family: 'Fira Code', monospace;
    font-size: 12px;
    color: #10b981;
}
.card-location {
    font-size: 13px;
    font-weight: 600;
    color: #f4f4f5;
}
.card-state {
    font-size: 11px;
    color: #71717a;
}
.card-fatalities {
    text-align: right;
    flex-shrink: 0;
}
.fatalities-number {
    font-size: 22px;
    font-weight: 700;
    color: #ef4444;
    line-height: 1;
}
.fatalities-number.zero { color: #52525b; }
.fatalities-label {
    font-size: 10px;
    color: #52525b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.card-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    color: #a1a1aa;
    width: fit-content;
}
.card-summary {
    font-size: 13px;
    color: #9ca3af;
    line-height: 1.6;
    border-top: 1px solid #27272a;
    padding-top: 8px;
}
.empty-cards {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: #52525b;
}
.filter-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.filter-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: #9ca3af;
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
    display: flex;
    align-items: center;
    gap: 6px;
}
.filter-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-color: rgba(255,255,255,0.2);
}
.chart-header {
    font-size: 0.72rem;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    font-weight: 600;
    flex-shrink: 0;
}
.welcome-banner {
    background: rgba(16, 185, 129, 0.05);
    border: 1px solid rgba(16, 185, 129, 0.15);
    border-radius: 10px;
    padding: 10px 16px;
    margin-bottom: 10px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.welcome-banner i { color: #10b981; font-size: 22px; flex-shrink: 0; margin-top: 2px; }
.welcome-banner p { font-size: 13px; color: #9ca3af; line-height: 1.7; margin: 0; }
.welcome-banner p strong { color: #f4f4f5; }
.example-queries {
    margin-bottom: 8px;
}
.example-queries-label {
    font-size: 11px;
    color: #52525b;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    font-weight: 600;
}
.example-queries-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.example-chip {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    color: #a1a1aa;
    padding: 5px 12px;
    border-radius: 14px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Fira Code', monospace;
}
.example-chip:hover {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
    color: #10b981;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #3f3f46;
}
