:root {
    /* Color Palette - SaaS Professional */
    --bg-main: #f3f4f6;
    --bg-card: #ffffff;
    --bg-header: #ffffff;
    --border-color: #e5e7eb;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    
    --brand-primary: #2563eb;
    --brand-primary-hover: #1d4ed8;
    --brand-accent: #3b82f6;
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'ui-monospace', 'SFMono-Regular', 'Menlo', 'Monaco', 'Consolas', monospace;
}

[data-theme="dark"] {
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --bg-header: #1e293b;
    --border-color: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    
    --brand-primary: #3b82f6;
    --brand-primary-hover: #60a5fa;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
header {
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

header h1::before {
    content: '🦞';
    font-size: 1.5rem;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#search-input {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    border-radius: var(--radius-md);
    width: 280px;
    transition: all 0.2s;
}

#search-input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    background-color: var(--bg-card);
}

#dark-mode-toggle, #export-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#dark-mode-toggle:hover, #export-btn:hover {
    background: var(--bg-main);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

/* Navigation */
nav#main-nav {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border-color);
    padding-top: 0.5rem;
    justify-content: center;
}

nav#main-nav a {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.2s;
}

nav#main-nav a:hover {
    color: var(--brand-primary);
}

/* Container & Grid */
.container {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1.5rem;
    padding: 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.panel {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    grid-column: span 6; /* Default */
}

.panel h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Architecture Map */
#arch-svg-container {
    background-color: var(--bg-main);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.node-circle {
    fill: var(--bg-card);
    stroke: var(--border-color);
    stroke-width: 1.5;
    transition: all 0.2s;
}

.node-circle.core {
    stroke: var(--brand-primary);
    stroke-width: 2.5;
}

.svg-node:hover .node-circle {
    stroke: var(--brand-primary);
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
    cursor: pointer;
}

.node-label {
    fill: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
    pointer-events: none;
}

.status-dot {
    fill: var(--success);
}
.status-dot.warn { fill: var(--warning); }
.status-dot.err { fill: var(--danger); }

/* Telemetry Widgets */
.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    width: 100%;
}

.status-card {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.status-card .title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    letter-spacing: 0.025em;
}

.status-card .status {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.status-card .status.warn { color: var(--warning); }
.status-card .status.err { color: var(--danger); }

/* Neural Log & Content */
.neural-log-content {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.neural-log-content p {
    margin-bottom: 1rem;
}

.neural-log-content h1, .neural-log-content h2, .neural-log-content h3 {
    color: var(--text-primary);
    margin: 1.5rem 0 0.75rem 0;
    font-family: var(--font-sans);
}

/* Evolution Panel & Stream */
.evolution-panel {
    background-color: var(--bg-main);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1rem;
}

.progress-container {
    height: 0.5rem;
    background-color: var(--border-color);
    border-radius: 9999px;
    margin: 0.75rem 0;
    position: relative;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background-color: var(--brand-primary);
    border-radius: 9999px;
}

.progress-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-sans);
}

.intel-stream {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stream-item {
    font-size: 0.75rem;
    display: flex;
    gap: 0.75rem;
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

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

.timestamp { color: var(--text-muted); font-weight: 600; }
.action { color: var(--brand-primary); font-weight: 700; }

/* Project Cards */
.project-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.project-card {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    position: relative;
    transition: border-color 0.2s;
}

.project-card:hover {
    border-color: var(--brand-accent);
}

.status-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 0.625rem;
    font-weight: 700;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
}

.project-card h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.project-card p {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.mini-bar {
    height: 0.25rem;
    background-color: var(--border-color);
    border-radius: 9999px;
}

.mini-bar .fill {
    height: 100%;
    background-color: var(--brand-primary);
    border-radius: 9999px;
}

/* Timeline */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.timeline-event {
    padding-left: 1.5rem;
    border-left: 2px solid var(--border-color);
    position: relative;
}

.timeline-event::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 0.25rem;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--brand-primary);
}

.timeline-event .time {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.timeline-event p {
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.timeline-filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.filter-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn.active {
    background-color: var(--brand-primary);
    color: white;
    border-color: var(--brand-primary);
}

/* API Catalog */
.api-catalog {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.api-endpoint {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.api-endpoint:hover {
    border-color: var(--brand-accent);
}

.api-endpoint div {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.method {
    font-size: 0.625rem;
    font-weight: 800;
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    color: white;
}

.method.GET { background-color: #10b981; }
.method.POST { background-color: #3b82f6; }
.method.PUT { background-color: #f59e0b; }
.method.DELETE { background-color: #ef4444; }

.path {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 600;
}

.api-endpoint .desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.api-endpoint .example {
    display: none;
    background-color: var(--bg-card);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    margin-top: 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    white-space: pre-wrap;
    border: 1px solid var(--border-color);
}

.api-endpoint.expanded .example {
    display: block;
}

/* Slide-out Panel */
.component-panel {
    position: fixed;
    right: -400px;
    top: 0;
    width: 400px;
    height: 100vh;
    background-color: var(--bg-card);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    transition: right 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
}

.component-panel.open {
    right: 0;
}

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

.component-panel-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
}

.component-panel-header button {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.component-panel-body {
    padding: 1.5rem;
    flex: 1;
    overflow-y: auto;
}

.panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}

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

.spec-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.spec-label { color: var(--text-muted); }
.spec-value { font-weight: 600; text-align: right; }

/* Mobile Navigation Toggle */
.mobile-nav-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-primary);
}

/* Search Results */
.search-results {
    position: fixed;
    top: 4.5rem;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 60;
}

.search-highlight {
    background-color: rgba(254, 240, 138, 0.4);
    font-weight: 600;
}

/* Responsive */
@media (max-width: 1024px) {
    .panel { grid-column: span 12; }
    .search-results { width: 90%; }
}

@media (max-width: 768px) {
    .header-row { flex-direction: column; gap: 1rem; }
    #search-input { width: 100%; }
    .mobile-nav-btn { display: block; }
    nav#main-nav { display: none; flex-direction: column; align-items: center; gap: 1rem; width: 100%; }
    nav#main-nav.open { display: flex; }
}

/* Print */
@media print {
    header, .header-controls, #main-nav, .filter-btn, #dark-mode-toggle, #export-btn { display: none !important; }
    .container { display: block; }
    .panel { break-inside: avoid; border: 1px solid #ccc; margin-bottom: 2rem; }
}
