:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface-hover: #22252f;
    --border: #2a2d37;
    --text: #e0e2e8;
    --text-dim: #8b8f9a;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
}

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

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

/* Sidebar */
.sidebar {
    width: 220px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    padding: 0 1.25rem 1.5rem;
    color: var(--accent);
    letter-spacing: 0.05em;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    min-height: 44px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.15s;
}

.nav-link:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.nav-link.active {
    color: var(--accent);
    background: rgba(99, 102, 241, 0.1);
    border-right: 2px solid var(--accent);
}

.nav-icon { font-size: 0.75rem; }

/* Main content */
.content {
    margin-left: 220px;
    flex: 1;
    padding: 2rem;
    min-width: 0;
}

/* Page header */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.page-header p {
    color: var(--text-dim);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Stats cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    margin-top: 0.25rem;
    font-variant-numeric: tabular-nums;
}

.stat-sub {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 0.25rem;
}

/* Charts */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
}

.chart-card h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    color: var(--text-dim);
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-variant-numeric: tabular-nums;
}

.data-table tr:hover td {
    background: var(--surface-hover);
}

.data-table a {
    color: var(--accent);
    text-decoration: none;
}

.data-table a:hover {
    color: var(--accent-hover);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-insight { background: rgba(99, 102, 241, 0.15); color: #a5b4fc; }
.badge-decision { background: rgba(34, 197, 94, 0.15); color: #86efac; }
.badge-error { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
.badge-pattern { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
.badge-question { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
.badge-milestone { background: rgba(168, 85, 247, 0.15); color: #d8b4fe; }
.badge-skill { background: rgba(20, 184, 166, 0.15); color: #5eead4; }
.badge-semantic { background: rgba(99, 102, 241, 0.15); color: #a5b4fc; }
.badge-grep { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }

/* Signals panel */
.signal-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 2rem;
}

.signal-panel h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.signal-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    padding: 0.25rem 0;
}

.signal-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.signal-dot.active { background: var(--success); }
.signal-dot.inactive { background: var(--text-dim); }

/* Search */
.search-box {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.search-input {
    flex: 1;
    padding: 0.625rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.875rem;
    outline: none;
}

.search-input:focus {
    border-color: var(--accent);
}

.btn {
    padding: 0.625rem 1.25rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s;
}

.btn:hover { background: var(--accent-hover); }

/* Search results */
.result-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
}

.result-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 0.8125rem;
}

.result-score {
    font-weight: 700;
    color: var(--accent);
}

.result-date { color: var(--text-dim); }

.result-content {
    font-size: 0.8125rem;
    line-height: 1.6;
    color: var(--text);
}

/* Log entries */
.log-entry {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.log-entry-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.log-entry-title {
    font-weight: 600;
    font-size: 0.9375rem;
}

.log-entry-meta {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-bottom: 0.75rem;
}

.log-entry-body {
    font-size: 0.8125rem;
    line-height: 1.6;
}

/* Filters bar */
.filters-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.filter-select {
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.8125rem;
}

/* Trend indicators */
.trend-up { color: var(--success); }
.trend-down { color: var(--error); }
.trend-flat { color: var(--text-dim); }

/* Effectiveness bar */
.eff-bar {
    width: 80px;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
}

.eff-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

/* Timeline */
.timeline {
    border-left: 2px solid var(--border);
    padding-left: 1.5rem;
    margin-left: 0.5rem;
}

.timeline-item {
    position: relative;
    padding-bottom: 1.25rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -1.75rem;
    top: 0.25rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg);
}

.timeline-date {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.timeline-text {
    font-size: 0.8125rem;
    margin-top: 0.25rem;
}

/* Section header */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

/* Detail page */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
}

/* Log list */
.log-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 0.5rem;
    text-decoration: none;
    color: var(--text);
    transition: background 0.15s;
}

.log-list-item:hover {
    background: var(--surface-hover);
}

.compact-badge {
    font-size: 0.6875rem;
    color: var(--text-dim);
    background: var(--border);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-dim);
}

/* HTMX indicator */
.htmx-indicator {
    display: none;
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.8125rem;
    color: var(--text-dim);
    z-index: 100;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: block;
}

/* Chart descriptions */
.chart-desc { font-size: 0.75rem; color: var(--text-dim); margin-bottom: 0.75rem; }

/* Language switch */
.lang-switch { margin-top: auto; padding: 1rem 1.25rem; border-top: 1px solid var(--border); display: flex; gap: 0.5rem; }
.lang-btn { padding: 0.5rem 0.75rem; min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 4px; font-size: 0.75rem; color: var(--text-dim); text-decoration: none; transition: all 0.15s; }
.lang-btn:hover { color: var(--text); background: var(--surface-hover); }
.lang-btn.active { color: var(--accent); background: rgba(99, 102, 241, 0.1); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal-content { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; max-width: 720px; width: 90%; max-height: 85vh; overflow-y: auto; padding: 1.5rem; }
.modal-close { float: right; background: none; border: none; color: var(--text-dim); font-size: 1.25rem; cursor: pointer; padding: 0.25rem; }
.modal-close:hover { color: var(--text); }

/* Log overview */
.log-overview { font-size: 0.8125rem; color: var(--text-dim); margin-top: 0.25rem; line-height: 1.5; }

/* Section title */
.section-title { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); margin-bottom: 0.75rem; font-weight: 600; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { width: 60px; padding: 1rem 0; }
    .sidebar-brand { display: none; }
    .nav-link span:not(.nav-icon) { display: none; }
    .nav-link { justify-content: center; padding: 0.75rem; }
    .content { margin-left: 60px; padding: 1rem; }
    .charts-grid { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
}
