/* ── Entity Dashboard — Light Minimalist Theme ─────────────────────────── */

:root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1a202c;
    --text-muted: #8898aa;
    --accent: #3182ce;
    --accent-light: #ebf4ff;
    --success: #38a169;
    --success-light: #f0fff4;
    --warning: #d69e2e;
    --warning-light: #fffff0;
    --danger: #e53e3e;
    --danger-light: #fff5f5;
    --thesis: #3182ce;
    --antithesis: #e53e3e;
    --synthesis: #38a169;
    --reflection: #805ad5;
    --decision: #d69e2e;
    --opus: #7c3aed;
    --gemini: #0891b2;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

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

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

/* ── Navbar ──────────────────────────────────────────────────────────────── */

.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.nav-brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 1rem; white-space: nowrap; }
.brand-icon { font-size: 1.3rem; }
.nav-links { display: flex; gap: 0.25rem; overflow-x: auto; }
.nav-links a { padding: 0.4rem 0.75rem; border-radius: 8px; text-decoration: none; color: var(--text-muted); font-size: 0.875rem; font-weight: 500; transition: all 0.15s; white-space: nowrap; }
.nav-links a:hover { background: var(--bg); color: var(--text); }
.nav-links a.active { background: var(--accent-light); color: var(--accent); }
.nav-status { margin-left: auto; }

/* ── Pulse Dot ───────────────────────────────────────────────────────────── */

.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); display: inline-block; animation: pulse 3s infinite; }
.pulse-dot.refreshing { animation: none; background: var(--accent); box-shadow: 0 0 0 4px rgba(49, 130, 206, 0.2); }
@keyframes pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }

.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.status-dot.alive { background: var(--success); box-shadow: 0 0 0 3px rgba(56, 161, 105, 0.2); animation: pulse 2s infinite; }
.status-dot.dead { background: var(--danger); box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.2); }

/* ── Container ───────────────────────────────────────────────────────────── */

.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }

/* ── Cards ────────────────────────────────────────────────────────────────── */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.card-grid.two-col { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.card-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 600; }
.card-badge { font-size: 0.65rem; padding: 0.15rem 0.5rem; border-radius: 20px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.card-badge.opus { background: #ede9fe; color: var(--opus); }
.card-badge.gemini { background: #ecfeff; color: var(--gemini); }
.card-value { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.5rem; }
.card-detail { font-size: 0.85rem; margin-top: 0.25rem; }

/* ── Progress Bars ────────────────────────────────────────────────────────── */

.progress-bar { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; margin: 0.5rem 0; }
.progress-bar.large { height: 10px; border-radius: 5px; }
.progress-fill { height: 100%; border-radius: inherit; transition: width 0.5s ease; min-width: 2px; }
.progress-fill.opus { background: var(--opus); }
.progress-fill.gemini { background: var(--gemini); }

/* ── Stats ────────────────────────────────────────────────────────────────── */

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; text-align: center; }
.stat-value { font-size: 1.5rem; font-weight: 700; display: block; }
.stat-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Heartbeat Groups ────────────────────────────────────────────────────── */

.heartbeat-group {
    margin-bottom: 2rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.heartbeat-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.hb-group-left { display: flex; align-items: center; gap: 0.75rem; }
.hb-group-right { display: flex; align-items: center; gap: 1rem; }

.hb-cycle-badge {
    background: var(--accent);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.7rem;
    border-radius: 20px;
    letter-spacing: 0.03em;
}

.hb-cycle-badge.orphan { background: var(--text-muted); }

.hb-group-time { font-size: 0.8rem; color: var(--text-muted); }
.hb-group-stat { font-size: 0.8rem; color: var(--text-muted); font-family: 'SF Mono', monospace; }

.triad-group {
    padding: 0.75rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.triad-group + .triad-group {
    border-top: 1px solid var(--border);
}

/* ── Thoughts ─────────────────────────────────────────────────────────────── */

.filter-bar { display: flex; gap: 0.4rem; margin-bottom: 1.5rem; flex-wrap: wrap; }

.filter-btn {
    padding: 0.4rem 0.9rem; border-radius: 20px; text-decoration: none; font-size: 0.8rem;
    font-weight: 500; background: var(--surface); color: var(--text-muted);
    border: 1px solid var(--border); transition: all 0.15s;
}
.filter-btn:hover { border-color: var(--text-muted); }
.filter-btn.active { color: #fff; border-color: transparent; }
.filter-btn.active:not(.thesis):not(.antithesis):not(.synthesis):not(.reflection):not(.decision) { background: var(--accent); color: #fff; }
.filter-btn.thesis.active { background: var(--thesis); }
.filter-btn.antithesis.active { background: var(--antithesis); }
.filter-btn.synthesis.active { background: var(--synthesis); }
.filter-btn.reflection.active { background: var(--reflection); }
.filter-btn.decision.active { background: var(--decision); }

.thoughts-list { display: flex; flex-direction: column; gap: 0.5rem; }

.thought-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    padding: 0.85rem 1rem; border-left: 4px solid var(--border);
    transition: all 0.15s; text-decoration: none; color: inherit; display: block;
}

.thought-card.thesis { border-left-color: var(--thesis); }
.thought-card.antithesis { border-left-color: var(--antithesis); }
.thought-card.synthesis { border-left-color: var(--synthesis); }
.thought-card.reflection { border-left-color: var(--reflection); }
.thought-card.decision { border-left-color: var(--decision); }

.thought-card.action-card { background: #faf5ff; }

.thought-header { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }

.thought-type-badge {
    font-size: 0.7rem; padding: 0.15rem 0.6rem; border-radius: 20px;
    font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: #fff;
}
.thought-type-badge.large { font-size: 0.85rem; padding: 0.3rem 1rem; }
.thought-type-badge.thesis { background: var(--thesis); }
.thought-type-badge.antithesis { background: var(--antithesis); }
.thought-type-badge.synthesis { background: var(--synthesis); }
.thought-type-badge.reflection { background: var(--reflection); }
.thought-type-badge.decision { background: var(--decision); }

.thought-model { font-size: 0.8rem; }
.thought-time { font-size: 0.8rem; }
.thought-cost { font-size: 0.75rem; color: var(--text-muted); font-family: 'SF Mono', monospace; }

.thought-link {
    font-size: 0.75rem; color: var(--accent); text-decoration: none;
    font-weight: 600; margin-left: auto;
}
.thought-link:hover { text-decoration: underline; }

.thought-preview { margin-top: 0.5rem; font-size: 0.85rem; color: var(--text); line-height: 1.5; white-space: pre-wrap; }
.mono-preview { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.78rem; }

.action-error { margin-top: 0.4rem; font-size: 0.78rem; color: var(--danger); font-family: 'SF Mono', monospace; }

/* ── Triad Nav ────────────────────────────────────────────────────────────── */

.triad-nav { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.triad-nav-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }
.triad-nav-item {
    font-size: 0.75rem; padding: 0.25rem 0.7rem; border-radius: 20px;
    text-decoration: none; color: var(--text-muted); border: 1px solid var(--border);
    transition: all 0.15s;
}
.triad-nav-item:hover { border-color: var(--text-muted); }
.triad-nav-item.current { font-weight: 700; }
.triad-nav-item.thesis.current { background: var(--thesis); color: #fff; border-color: var(--thesis); }
.triad-nav-item.antithesis.current { background: var(--antithesis); color: #fff; border-color: var(--antithesis); }
.triad-nav-item.synthesis.current { background: var(--synthesis); color: #fff; border-color: var(--synthesis); }
.triad-nav-item.reflection.current { background: var(--reflection); color: #fff; border-color: var(--reflection); }

/* ── Thought Detail ───────────────────────────────────────────────────────── */

.thought-content { line-height: 1.7; font-size: 0.95rem; }
.thought-content h1, .thought-content h2, .thought-content h3 { margin-top: 1.5rem; margin-bottom: 0.75rem; }
.thought-content h1 { font-size: 1.4rem; }
.thought-content h2 { font-size: 1.2rem; }
.thought-content h3 { font-size: 1.05rem; }
.thought-content p { margin-bottom: 0.75rem; }
.thought-content pre { background: var(--bg); padding: 1rem; border-radius: 8px; overflow-x: auto; font-size: 0.85rem; margin: 1rem 0; }
.thought-content code { font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace; font-size: 0.85em; }
.thought-content ul, .thought-content ol { padding-left: 1.5rem; margin-bottom: 0.75rem; }
.thought-detail-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.thought-meta { font-size: 0.9rem; }

/* ── Tables ───────────────────────────────────────────────────────────────── */

.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.data-table thead th { background: var(--bg); padding: 0.6rem 0.75rem; text-align: left; font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.data-table td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover { background: var(--bg); }
.data-table tr.row-error { background: var(--danger-light); }

.small-text { font-size: 0.75rem; display: block; }

.status-badge { font-size: 0.7rem; padding: 0.15rem 0.5rem; border-radius: 20px; font-weight: 600; }
.status-badge.success { background: var(--success-light); color: var(--success); }
.status-badge.warning { background: var(--warning-light); color: var(--warning); }
.status-badge.error { background: var(--danger-light); color: var(--danger); }

/* ── Budget ───────────────────────────────────────────────────────────────── */

.budget-display { text-align: center; padding: 1rem 0; }
.budget-big { font-size: 2.2rem; font-weight: 700; }
.budget-sub { font-size: 0.85rem; margin-top: 0.25rem; }
.budget-stats { font-size: 0.85rem; margin-top: 0.75rem; }
.info-card { margin-top: 1rem; }

/* ── Logs ──────────────────────────────────────────────────────────────────── */

.log-layout { display: grid; grid-template-columns: 220px 1fr; gap: 1rem; min-height: 500px; }
.log-sidebar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.log-sidebar h3 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 0.75rem; }
.log-file-link { display: flex; justify-content: space-between; padding: 0.4rem 0.5rem; border-radius: 6px; text-decoration: none; color: var(--text); font-size: 0.8rem; transition: all 0.1s; }
.log-file-link:hover { background: var(--bg); }
.log-file-link.active { background: var(--accent-light); color: var(--accent); }
.log-file-size { font-size: 0.7rem; }
.log-content-area { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; }
.log-header { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; font-size: 0.8rem; }
.log-viewer { padding: 1rem; font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace; font-size: 0.78rem; line-height: 1.5; overflow: auto; max-height: 600px; white-space: pre-wrap; word-break: break-all; flex: 1; }

/* ── Genesis ──────────────────────────────────────────────────────────────── */

.genesis-container { max-width: 800px; margin: 0 auto; }
.genesis-content { line-height: 1.8; font-size: 0.95rem; padding: 2rem; }
.genesis-content h1 { font-size: 1.8rem; margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 2px solid var(--border); }
.genesis-content h2 { font-size: 1.3rem; margin-top: 2rem; margin-bottom: 0.75rem; }
.genesis-content h3 { font-size: 1.1rem; margin-top: 1.5rem; margin-bottom: 0.5rem; }
.genesis-content p { margin-bottom: 0.75rem; }
.genesis-content ul, .genesis-content ol { padding-left: 1.5rem; margin-bottom: 0.75rem; }
.genesis-content blockquote { border-left: 3px solid var(--accent); padding-left: 1rem; color: var(--text-muted); font-style: italic; margin: 1.5rem 0; }
.genesis-content pre { background: var(--bg); padding: 1rem; border-radius: 8px; overflow-x: auto; font-size: 0.85rem; }
.genesis-content code { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.85em; background: var(--bg); padding: 0.15rem 0.4rem; border-radius: 4px; }
.genesis-content pre code { background: none; padding: 0; }
.genesis-content hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
.genesis-content strong { font-weight: 600; }
.genesis-content em { color: var(--text-muted); }

/* ── Misc ──────────────────────────────────────────────────────────────────── */

.page-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 1.25rem; }
.section-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 1rem; }
.muted { color: var(--text-muted); }
.mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.85em; }
.breadcrumb { margin-bottom: 1rem; }
.breadcrumb a { color: var(--accent); text-decoration: none; font-size: 0.85rem; }
.breadcrumb a:hover { text-decoration: underline; }
.empty-state { text-align: center; padding: 3rem 1rem; }
.empty-state p { font-size: 1rem; margin-bottom: 0.5rem; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.5rem; }
.page-btn { padding: 0.4rem 0.9rem; border-radius: 8px; text-decoration: none; color: var(--accent); background: var(--surface); border: 1px solid var(--border); font-size: 0.85rem; }
.page-btn:hover { background: var(--accent-light); }
.page-info { font-size: 0.85rem; color: var(--text-muted); }
.footer { text-align: center; padding: 2rem 1rem; font-size: 0.75rem; color: var(--text-muted); }

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .navbar { padding: 0 0.75rem; gap: 0.75rem; }
    .brand-text { display: none; }
    .nav-links a { padding: 0.3rem 0.5rem; font-size: 0.8rem; }
    .container { padding: 1rem; }
    .card-grid { grid-template-columns: 1fr; }
    .log-layout { grid-template-columns: 1fr; }
    .log-sidebar { display: flex; gap: 0.5rem; overflow-x: auto; padding: 0.5rem; }
    .log-sidebar h3 { display: none; }
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
    .heartbeat-group-header { flex-direction: column; align-items: flex-start; }
    .hb-group-right { flex-wrap: wrap; }
}
