/* Hermes Command Center — Dark Theme */

:root {
    --bg: #0f0f13;
    --surface: #1a1a22;
    --surface-hover: #22222e;
    --accent: #4ade80;
    --accent-dim: #22c55e;
    --text: #e5e5e5;
    --muted: #6b7280;
    --border: #2a2a38;
    --error: #ef4444;
}

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

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

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

/* Header */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
}

h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text);
}

h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--muted);
    transition: background 0.3s;
}

.status-dot.connected { background: var(--accent); }
.status-dot.error { background: var(--error); }

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.tab {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.tab:hover { color: var(--text); }

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Tab content */
.tab-content { display: none; }
.tab-content.active { display: block; }

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

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

.card-label {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent);
}

/* Folders */
.folders { margin-top: 1rem; }

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

.folder-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.folder-name { font-weight: 500; }

.folder-meta {
    color: var(--muted);
    font-size: 0.85rem;
}

/* File browser */
.file-browser {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 1rem;
    min-height: 400px;
}

.file-list {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.file-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-item:last-child { border-bottom: none; }
.file-item:hover { background: var(--surface-hover); }
.file-item.active { background: var(--surface-hover); color: var(--accent); }

.file-name { font-size: 0.9rem; font-weight: 500; }
.file-size { font-size: 0.8rem; color: var(--muted); }

.file-viewer {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    overflow-y: auto;
    max-height: 600px;
}

.file-viewer .placeholder { color: var(--muted); font-style: italic; }

.file-viewer h1 {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
}

.file-viewer h2 {
    font-size: 1.1rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--accent);
}

.file-viewer p { margin-bottom: 0.75rem; color: var(--text); }

.file-viewer ul, .file-viewer ol {
    margin: 0.75rem 0;
    padding-left: 1.5rem;
}

.file-viewer li { margin-bottom: 0.4rem; }

.file-viewer strong { color: var(--accent); }
.file-viewer em { color: var(--muted); }

.file-viewer code {
    background: var(--bg);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
}

.file-viewer blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1rem;
    color: var(--muted);
    margin: 1rem 0;
}

/* Status section */
.status-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
}

.status-row {
    display: flex;
    justify-content: space-between;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}

.status-row:last-child { border-bottom: none; }
.status-label { color: var(--muted); }
.status-value { font-weight: 500; }

/* Loading */
.loading { color: var(--muted); padding: 1rem; font-style: italic; }

/* Error */
.error-msg { color: var(--error); padding: 1rem; }

/* Responsive */

/* Disease Library */
.disease-subtitle {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

#diseaseView {
    min-height: 300px;
}

.disease-placeholder {
    color: var(--muted);
    font-style: italic;
    padding: 2rem;
    text-align: center;
    font-size: 1rem;
}


/* ── Disease Grid ──────────────────────────────────────────────────────── */

/* Summary stats bar */
.disease-summary {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.disease-summary-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

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

.disease-summary-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
}

/* Filter bar */
.disease-filter-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.filter-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.8rem;
    padding: 0.4rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover { color: var(--text); border-color: var(--accent-dim); }
.filter-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg);
    font-weight: 600;
}

/* Category sections */
.disease-category {
    margin-bottom: 2rem;
}

.disease-category-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.disease-category-name {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text);
}

.disease-category-count {
    font-size: 0.75rem;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.1rem 0.5rem;
}

/* Disease cards grid */
.disease-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
}

/* Individual disease card */
.disease-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.disease-card:hover {
    border-color: var(--accent-dim);
    background: var(--surface-hover);
}

.disease-card.disabled {
    cursor: not-allowed;
    opacity: 0.85;
}

.disease-card-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}

.disease-card-category {
    font-size: 0.75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.disease-card-preview {
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.disease-card-badges {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-top: 0.25rem;
}

/* Status badges */
.badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-reviewed {
    background: rgba(74, 222, 128, 0.15);
    color: var(--accent);
    border: 1px solid rgba(74, 222, 128, 0.3);
}

.badge-scaffold {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.badge-complete {
    background: rgba(74, 222, 128, 0.15);
    color: var(--accent);
    border: 1px solid rgba(74, 222, 128, 0.3);
}

.badge-incomplete {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-size {
    background: var(--bg);
    color: var(--muted);
    border: 1px solid var(--border);
    font-size: 0.68rem;
}

/* Coming-soon overlay */
.disease-card-soon {
    font-size: 0.75rem;
    color: var(--muted);
    font-style: italic;
    margin-top: 0.25rem;
}

/* Layer toggle buttons (future) */
.layer-toggle {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.layer-btn {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.85rem;
    padding: 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.layer-btn:hover { border-color: var(--accent-dim); color: var(--text); }
.layer-btn.active {
    background: rgba(74, 222, 128, 0.1);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
}


/* ── Disease Detail ─────────────────────────────────────────────────────── */

/* Shell: always-rendered containers inside #diseaseView */
#diseaseGrid,
#diseaseDetail {
    min-height: 300px;
}

/* Detail panel */
#diseaseDetail {
    display: none;   /* shown only when diseaseView === 'detail' */
}

.detail-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

/* Back navigation */
.detail-back {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    width: 100%;
    text-align: left;
    transition: background 0.2s;
}

.detail-back:hover { background: var(--surface-hover); }

/* Detail header */
.detail-header {
    padding: 1.25rem 1.25rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.detail-disease-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.3rem;
}

.detail-meta-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.detail-category {
    font-size: 0.78rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Detail preview */
.detail-preview {
    padding: 0.75rem 1.25rem;
    font-size: 0.85rem;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    line-height: 1.5;
}

/* Detail stats grid */
.detail-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.detail-stat {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
}

.detail-stat-label {
    font-size: 0.7rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.detail-stat-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

/* Detail paths */
.detail-paths {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.78rem;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.detail-path-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin-top: 0.3rem;
}

.detail-path-value {
    font-family: 'Courier New', monospace;
    color: #9ca3af;
    font-size: 0.75rem;
    word-break: break-all;
}

/* Detail layer buttons */
.detail-layer-section {
    padding: 1rem 1.25rem;
}

.detail-layer-hint {
    font-size: 0.78rem;
    color: var(--muted);
    margin-bottom: 0.75rem;
    font-style: italic;
}

.layer-toggle.disabled .layer-btn {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Loading overlay inside detail */
.detail-loading {
    padding: 3rem;
    text-align: center;
    color: var(--muted);
    font-style: italic;
}


/* ── Layer Viewer ──────────────────────────────────────────────────────── */
.layer-viewer {
    min-height: 400px;
}

.layer-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-wrap: wrap;
}

.layer-back-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.82rem;
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    transition: background 0.2s;
    white-space: nowrap;
}

.layer-back-btn:hover { background: var(--surface-hover); }

.layer-title {
    font-size: 0.82rem;
    color: var(--muted);
    flex: 1;
    text-align: center;
}

.layer-size-badge {
    font-size: 0.72rem;
    color: var(--muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.15rem 0.5rem;
    white-space: nowrap;
}

.layer-content {
    padding: 1.25rem;
    max-height: 70vh;
    overflow-y: auto;
    font-size: 0.88rem;
    line-height: 1.65;
}

.layer-content h1,
.layer-content h2,
.layer-content h3 {
    color: var(--text);
    margin: 1.2rem 0 0.5rem;
    font-weight: 700;
    line-height: 1.3;
}

.layer-content h1 { font-size: 1.15rem; }
.layer-content h2 { font-size: 1.05rem; }
.layer-content h3 { font-size: 0.95rem; }

.layer-content p  { margin: 0.5rem 0; color: var(--text); }
.layer-content ul,
.layer-content ol { margin: 0.5rem 0 0.5rem 1.5rem; color: var(--text); }
.layer-content li { margin: 0.25rem 0; }

.layer-content blockquote {
    border-left: 3px solid var(--accent-dim);
    margin: 0.75rem 0;
    padding: 0.5rem 1rem;
    background: var(--surface);
    border-radius: 0 4px 4px 0;
    color: var(--muted);
    font-style: italic;
}

.layer-content pre {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    overflow-x: auto;
    margin: 0.75rem 0;
}

.layer-content code {
    font-size: 0.82rem;
    font-family: 'Courier New', monospace;
    color: #e2e8f0;
}

.layer-content pre code { display: block; color: #e2e8f0; }
.layer-content :not(pre) > code {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0.1rem 0.35rem;
    font-size: 0.82rem;
    color: #f472b6;
}

.layer-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.25rem 0;
}

.layer-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75rem 0;
    font-size: 0.85rem;
    overflow-x: auto;
    display: table;
}

.layer-content th {
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    text-align: left;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.layer-content td {
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--border);
    color: var(--text);
    vertical-align: top;
}

.layer-content tr:nth-child(even) td { background: rgba(255,255,255,0.02); }

.layer-loading {
    padding: 3rem;
    text-align: center;
    color: var(--muted);
    font-style: italic;
}

.layer-toggle:not(.disabled) .layer-btn { opacity: 1; cursor: pointer; }
.layer-toggle:not(.disabled) .layer-btn.active {
    background: rgba(74, 222, 128, 0.1);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
}

@media (max-width: 700px) {
    .container { padding: 1rem; }
    .file-browser { grid-template-columns: 1fr; }
    .card-grid { grid-template-columns: repeat(2, 1fr); }
}
/* Library Selector */
.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.library-label {
    font-size: 0.85rem;
    color: var(--muted);
}

#librarySelector {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
}

#librarySelector:hover {
    border-color: var(--accent-dim);
}

#librarySelector:focus {
    border-color: var(--accent);
}


/* ─── Search UI ─────────────────────────────────────────────────── */
#diseaseSearchBar {
    padding: 0 0 1rem 0;
}

.search-bar-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.search-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    background: var(--bg-card);
    color: var(--text);
}

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

.search-submit-btn {
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
}

.search-submit-btn:hover { opacity: 0.85; }

.search-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.5rem 0;
}

.search-filter-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.search-filter-label {
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-right: 0.25rem;
}

.search-type-btn,
.search-layer-btn {
    padding: 0.25rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
}

.search-type-btn:hover,
.search-layer-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.search-type-btn.active,
.search-layer-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ─── Search Results ────────────────────────────────────────────── */
#searchResults {
    padding: 0.5rem 0;
}

.search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.75rem;
}

.search-results-count {
    font-size: 0.85rem;
    color: var(--muted);
}

.search-results-count em {
    font-style: italic;
    color: var(--text);
}

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

.search-result-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.search-result-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.search-result-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
    flex-wrap: wrap;
}

.search-result-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}

.search-result-id {
    font-size: 0.7rem;
    color: var(--muted);
    font-family: monospace;
}

.search-result-section {
    font-size: 0.72rem;
    color: var(--accent);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 0.3rem;
}

.search-result-snippet {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.search-result-line {
    font-size: 0.68rem;
    color: var(--muted);
    font-family: monospace;
    margin-right: 0.3rem;
    background: var(--bg-main);
    padding: 0 0.2rem;
    border-radius: 3px;
}

/* ─── Search States ────────────────────────────────────────────── */
.search-loading {
    text-align: center;
    padding: 3rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.search-empty {
    text-align: center;
    padding: 3rem 1rem;
}

.search-empty-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.3;
}

.search-empty-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.search-empty-sub {
    font-size: 0.85rem;
    color: var(--muted);
}

.search-message {
    text-align: center;
    padding: 2rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.search-message.error {
    color: #e53e3e;
}

/* ─── Badges ────────────────────────────────────────────────────── */
.badge-disease {
    background: #805ad5 !important;
    color: #fff !important;
}

.badge-pmid {
    background: #319795 !important;
    color: #fff !important;
}

/* ─── Clear Search Button ───────────────────────────────────────── */
.clear-search-btn {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.35rem 0.85rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
}

.clear-search-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* ─── Library Badge ─────────────────────────────────────────────────── */
.library-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    text-transform: capitalize;
    letter-spacing: 0.03em;
    white-space: nowrap;
    vertical-align: middle;
}

.library-type-disease {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.library-type-knowledge {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.library-type-content {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* header right — ensure badge aligns with selector */
.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#currentLibraryBadge {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
}

/* ── Surgical Edit Executive Overview — Phase 04E ─────────────────────────── */

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

.se-header-left {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.se-header-left h2 {
    margin-bottom: 0;
}

.se-tagline {
    font-size: 0.82rem;
    color: var(--muted);
}

.se-version-badge {
    font-size: 0.72rem;
    background: rgba(74, 222, 128, 0.12);
    color: var(--accent);
    border: 1px solid rgba(74, 222, 128, 0.25);
    border-radius: 20px;
    padding: 0.2rem 0.7rem;
}

/* BRS Hero Card */
.se-brs-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem 2rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.se-brs-score {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
    min-width: 80px;
}

.se-brs-meta {
    flex: 1;
    min-width: 160px;
}

.se-brs-label {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.se-brs-sub {
    font-size: 0.78rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.se-brs-bar {
    flex: 2;
    min-width: 180px;
    height: 10px;
    background: var(--border);
    border-radius: 5px;
    overflow: hidden;
}

.se-brs-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 5px;
    transition: width 1s ease;
}

/* Sub-score cards */
.se-sub-scores {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

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

.se-ss-score {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 0.4rem;
}

.se-ss-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.15rem;
}

.se-ss-sub-label {
    font-size: 0.72rem;
    color: var(--muted);
    margin-bottom: 0.6rem;
}

.se-ss-bar {
    height: 5px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.se-ss-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.8s ease;
}

/* Milestones */
.se-section-title {
    font-size: 0.78rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.75rem;
    margin-top: 1.5rem;
    font-weight: 600;
}

.se-milestones {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.se-ms-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.se-ms-icon {
    font-size: 1rem;
    line-height: 1.4;
    min-width: 20px;
}

.se-ms-complete { color: var(--accent); }
.se-ms-pending  { color: var(--muted); }

.se-ms-body {
    flex: 1;
}

.se-ms-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.15rem;
}

.se-ms-detail {
    font-size: 0.78rem;
    color: var(--muted);
}

.se-ms-status-complete,
.se-ms-status-pending {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    white-space: nowrap;
}

.se-ms-status-complete {
    background: rgba(74, 222, 128, 0.12);
    color: var(--accent);
}

.se-ms-status-pending {
    background: rgba(107, 114, 128, 0.15);
    color: var(--muted);
}

/* Stat Grid */
.se-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

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

.se-stat-label {
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}

.se-stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent);
}

/* Attention Items */
.se-attention {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

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

.se-attention-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.se-att-priority-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.se-att-area {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.se-att-priority {
    font-size: 0.68rem;
    font-weight: 700;
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    margin-left: auto;
}

.se-att-message {
    font-size: 0.85rem;
    color: var(--text);
    margin-bottom: 0.4rem;
    line-height: 1.4;
}

.se-att-action {
    font-size: 0.78rem;
    color: var(--muted);
}

.se-att-action-label {
    font-weight: 600;
    color: var(--accent-dim);
}

.se-attention-empty {
    font-size: 0.85rem;
    color: var(--muted);
    font-style: italic;
}

/* VPS Status Grid */
.se-vps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
}

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

.se-vps-label {
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.3rem;
}

.se-vps-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}


/* Phase 04F: Decision Engine Panels */
.se-decision-engine {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
.se-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.se-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.se-panel-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.se-panel-icon { font-size: 16px; }

/* Bottleneck */
.se-bottleneck-body { display: flex; flex-direction: column; gap: 10px; }
.se-bottleneck-field { display: flex; flex-direction: column; gap: 2px; }
.se-bottleneck-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted);
}
.se-bottleneck-value { font-size: 13px; color: var(--text); line-height: 1.4; }

/* Checklist */
.se-checklist-grid { display: flex; flex-direction: column; gap: 6px; }
.se-checklist-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px; font-size: 13px;
}
.se-checklist-done { background: rgba(34,197,94,0.1); color: #22c55e; }
.se-checklist-pending { background: rgba(239,68,68,0.08); color: #ef4444; }
.se-check-icon { font-size: 14px; flex-shrink: 0; }
.se-check-label { font-weight: 500; }

/* Products */
.se-products-list { display: flex; flex-direction: column; gap: 12px; }
.se-product-item { display: flex; flex-direction: column; gap: 4px; }
.se-product-name { font-size: 13px; font-weight: 600; color: var(--text); }
.se-product-status {
  display: inline-block; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 2px 8px; border-radius: 20px; width: fit-content;
}
.se-status-idea     { background: rgba(107,114,128,0.2); color: #6b7280; }
.se-status-research  { background: rgba(59,130,246,0.15); color: #3b82f6; }
.se-status-building  { background: rgba(168,85,247,0.15); color: #a855f7; }
.se-status-validation{ background: rgba(245,158,11,0.15); color: #f59e0b; }
.se-status-ready     { background: rgba(34,197,94,0.15); color: #22c55e; }
.se-product-explanation { font-size: 12px; color: var(--muted); line-height: 1.4; }

/* Next Actions */
.se-actions-list { display: flex; flex-direction: column; gap: 12px; }
.se-action-item {
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px; background: rgba(255,255,255,0.03);
  border-radius: 8px; border-left: 3px solid var(--accent);
}
.se-action-header { display: flex; align-items: center; gap: 8px; }
.se-action-priority {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.se-action-name { font-size: 13px; font-weight: 600; color: var(--text); }
.se-action-specifics, .se-action-why { font-size: 12px; color: var(--muted); line-height: 1.4; padding-left: 28px; }
.se-action-why { font-style: italic; border-left: 2px solid var(--border); padding-left: 10px; }


/* Phase 04G: Priorities Table */
.se-priorities-panel {
  grid-column: 1 / -1;
}
.se-priorities-table {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.se-priorities-thead {
  display: grid;
  grid-template-columns: 32px 1fr 120px 90px;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.se-prio-col {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  display: flex;
  align-items: center;
}
.se-priorities-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.se-priorities-row {
  display: grid;
  grid-template-columns: 32px 1fr 120px 90px;
  gap: 8px;
  padding: 8px 8px;
  border-radius: 6px;
  align-items: center;
  transition: background 0.15s;
}
.se-priorities-row:hover {
  background: rgba(255,255,255,0.04);
}
.se-priorities-row .se-prio-col {
  font-size: 13px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
}
.se-priorities-row .se-prio-col-num {
  font-weight: 700;
  color: var(--muted);
  justify-content: center;
}
.se-priorities-row .se-prio-col-updated {
  font-size: 11px;
  color: var(--muted);
}
.se-prio-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 20px;
  width: fit-content;
}
.se-prio-not-started { background: rgba(107,114,128,0.15); color: #9ca3af; }
.se-prio-in-progress  { background: rgba(59,130,246,0.15); color: #3b82f6; }
.se-prio-completed    { background: rgba(34,197,94,0.12); color: #22c55e; }
.se-priorities-empty  { font-size: 13px; color: var(--muted); padding: 16px 0; text-align: center; }


/* ═══════════════════════════════════════════════════════════════════════════
   PHASE 04I — AGENT CENTER
   ═══════════════════════════════════════════════════════════════════════════ */

.agents-header {
    padding: 24px 0 8px;
}
.agents-header h2 {
    margin: 0 0 4px;
    font-size: 20px;
    color: #e2e8f0;
    letter-spacing: 0.5px;
}
.agents-subtitle {
    margin: 0;
    font-size: 13px;
    color: #64748b;
}

/* Status bar */
.agent-status-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.agent-status-pill {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.agent-status-pill.healthy { background: rgba(34,197,94,0.15); color: #22c55e; }
.agent-status-pill.idle    { background: rgba(107,114,128,0.15); color: #94a3b8; }
.agent-status-pill.error   { background: rgba(239,68,68,0.15); color: #ef4444; }
.agent-status-pill.updated { margin-left: auto; font-size: 11px; color: #475569; }

/* Cards grid */
.agent-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.agent-card {
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    border: 1px solid rgba(255,255,255,0.06);
}
.agent-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.35);
}
.agent-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.agent-card-icon { font-size: 20px; }
.agent-card-name {
    font-size: 15px;
    font-weight: 700;
    flex: 1;
}
.agent-card-badge {
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.agent-card-role {
    font-size: 11px;
    color: #64748b;
    margin-bottom: 12px;
}
.agent-card-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}
.agent-stat-label {
    font-size: 10px;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}
.agent-stat-value { font-size: 13px; color: #e2e8f0; }
.agent-card-output {
    font-size: 11px;
    color: #475569;
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-left: 2px solid #334155;
    padding-left: 6px;
    margin-bottom: 8px;
}
.agent-sr-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

/* Detail panel */
.agent-detail-panel {
    background: #0f1923;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 14px;
    padding: 20px;
    margin-top: 4px;
    animation: slideIn 0.2s ease;
}
@keyframes slideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.agent-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}
.agent-detail-header h3 {
    margin: 0 0 4px;
    font-size: 18px;
    color: #e2e8f0;
}
.agent-detail-role { margin: 0; font-size: 13px; color: #64748b; }
.agent-detail-desc {
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.6;
    margin-bottom: 16px;
}
.agent-detail-close {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: #94a3b8;
    border-radius: 8px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 14px;
}
.agent-detail-close:hover { background: rgba(239,68,68,0.15); color: #ef4444; }
.agent-detail-status {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.agent-detail-stat-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #475569;
    margin-bottom: 2px;
}
.agent-detail-stat-value {
    font-size: 14px;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    gap: 4px;
}
.agent-detail-runs-header {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #475569;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.agent-runs-list { display: flex; flex-direction: column; gap: 4px; }
.agent-run-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.04);
}
.agent-run-icon { font-size: 14px; flex-shrink: 0; }
.agent-run-info { flex: 1; min-width: 0; }
.agent-run-title {
    font-size: 13px;
    color: #cbd5e1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.agent-run-meta { font-size: 11px; color: #475569; }
.agent-run-source {
    font-size: 10px;
    color: #475569;
    background: rgba(255,255,255,0.04);
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
}
