/* ============================================================
   Governance Genome Explorer v2-response — Dark-first theme
   Design system matched to Fingerprint Explorer
   Response to Peer Review edition
   ============================================================ */

:root {
    --bg-primary: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --bg-input: #1e293b;
    --border: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.15);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --green: #22c55e;
    --red: #ef4444;
    --yellow: #f59e0b;
    --cyan: #22d3ee;
    --pink: #ec4899;
    --orange: #f97316;
    --violet: #8b5cf6;
    --teal: #14b8a6;
    --sky: #38bdf8;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --z-sticky: 10;
    --z-dropdown: 100;
}

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --bg-input: #ffffff;
    --border: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent-glow: rgba(99, 102, 241, 0.08);
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background 0.3s;
    min-height: 100vh;
}
a { color: var(--accent-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Header / Hero ---- */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
}
.header-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.header h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}
.header h1 span { color: var(--accent-light); }
.header-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
    line-height: 1.4;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.theme-toggle {
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition: color 0.2s, border-color 0.2s;
}
.theme-toggle:hover { color: var(--text-primary); border-color: var(--accent); }

/* ---- Tab Navigation ---- */
.tab-nav {
    display: flex;
    gap: 2px;
    padding: 0 16px;
    background: var(--bg-card);
    border-bottom: 2px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
    position: sticky;
    top: 62px;
    z-index: var(--z-sticky);
    height: 56px;
    align-items: stretch;
}
.tab-nav::-webkit-scrollbar { display: none; }
.tab-btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
    display: flex;
    align-items: center;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
    color: var(--accent-light);
    border-bottom-color: var(--accent);
}

/* ---- Sub-tab Pills ---- */
.sub-nav {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.sub-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}
.sub-btn:hover { border-color: var(--accent); color: var(--text-primary); }
.sub-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---- Main Content ---- */
.tab-content { padding: 20px 24px; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.sub-pane { display: none; }
.sub-pane.active { display: block; }

/* ---- KPI Cards ---- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}
.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-light);
    line-height: 1.2;
}
.kpi-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

/* ---- Chart Cards ---- */
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}
.chart-card h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}
.chart-container { width: 100%; height: 350px; }
.chart-container.chart-sm { height: 250px; }
.chart-container.chart-tall { height: 500px; }
.chart-container.chart-xl { height: 600px; }

/* ---- Grid Layouts ---- */
.chart-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
.chart-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
.chart-grid-9-3 {
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

/* ---- Finding Cards ---- */
.findings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.finding-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    padding: 16px;
}
.finding-num {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-light);
    line-height: 1;
    margin-bottom: 4px;
}
.finding-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.finding-body {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ---- Family / Cluster Buttons ---- */
.family-btn-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.family-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.family-btn:hover { border-color: var(--accent); color: var(--text-primary); }
.family-btn.active {
    color: #fff;
    border-color: transparent;
}

/* ---- Narrative Box ---- */
.narrative-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 20px;
    font-size: 14px;
    font-style: italic;
    line-height: 1.7;
    color: var(--text-secondary);
}
.narrative-box strong { color: var(--text-primary); font-style: normal; }

/* ---- UMAP Controls / Sidebar ---- */
.umap-sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.umap-sidebar label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}
.umap-sidebar select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    width: 100%;
}
.umap-legend {
    background: var(--bg-card-hover);
    border-radius: 6px;
    padding: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* ---- Pipeline / Architecture Diagram ---- */
.pipeline-flow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    flex-wrap: wrap;
    margin: 20px 0;
}
.pipeline-step {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 24px;
    text-align: center;
    min-width: 140px;
}
.pipeline-step .step-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent-light);
}
.pipeline-step .step-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}
.pipeline-step.highlight { border-color: var(--success); }
.pipeline-step.highlight .step-value { color: var(--success); }
.pipeline-arrow {
    font-size: 24px;
    color: var(--text-muted);
    padding: 0 8px;
}

/* ---- Data Tables ---- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-bottom: 16px;
}
.data-table th {
    background: var(--bg-card-hover);
    color: var(--text-secondary);
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}
.data-table tr:hover td { background: var(--bg-card-hover); }
.data-table code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 12px;
    background: var(--bg-card-hover);
    padding: 2px 6px;
    border-radius: 4px;
}

/* ---- Score Scale ---- */
.score-scale {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    margin: 12px 0;
}
.score-scale .scale-item {
    background: var(--bg-card-hover);
    border-radius: 6px;
    padding: 8px 12px;
    text-align: center;
}
.scale-item .scale-range {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-light);
}
.scale-item .scale-label {
    font-size: 11px;
    color: var(--text-muted);
}

/* ---- Methodology Section ---- */
.method-section {
    margin-bottom: 24px;
}
.method-section h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.method-section p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 8px;
}
.params-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.params-table th {
    background: var(--bg-card-hover);
    text-align: left;
    padding: 8px 12px;
    color: var(--text-secondary);
    font-weight: 600;
    width: 40%;
    border-bottom: 1px solid var(--border);
}
.params-table td {
    padding: 8px 12px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
}

/* ---- LLM Methodology Attribution ---- */
.council-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-top: 12px;
}
.council-member {
    background: var(--bg-card-hover);
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 12px;
    color: var(--text-secondary);
}
.council-member strong {
    color: var(--text-primary);
    display: block;
    margin-bottom: 2px;
}

/* ---- Correlation Table ---- */
.corr-table-wrapper {
    overflow-x: auto;
    margin-bottom: 16px;
}

/* ---- Caveat/warning boxes ---- */
.caveat-box {
    border-left: 4px solid var(--accent);
    background: rgba(99, 102, 241, 0.08);
    padding: 1rem 1.2rem;
    border-radius: 0 6px 6px 0;
    margin: 1rem 0;
    font-size: 0.92rem;
    line-height: 1.6;
}
.caveat-box h4 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    color: var(--accent-light);
}
.caveat-box ul { margin: 0.5rem 0; padding-left: 1.2rem; }

/* ---- Provenance table ---- */
.provenance-table {
    width: 100%;
    font-size: 0.85rem;
    border-collapse: collapse;
}
.provenance-table th,
.provenance-table td {
    padding: 0.4rem 0.8rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}
.provenance-table th {
    color: var(--text-secondary);
    font-weight: 600;
    width: 35%;
}

/* ---- Sensitivity highlight ---- */
.sensitivity-highlight {
    background: rgba(99, 102, 241, 0.12) !important;
    font-weight: 600;
}

/* ---- Footer ---- */
.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 16px 24px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .chart-grid-2, .chart-grid-3, .chart-grid-9-3 { grid-template-columns: 1fr; }
    .pipeline-flow { flex-direction: column; align-items: stretch; }
    .pipeline-arrow { transform: rotate(90deg); text-align: center; }
    .findings-grid { grid-template-columns: 1fr; }
    .family-btn-row { flex-direction: column; }
}
@media (max-width: 600px) {
    .header { padding: 12px 16px; }
    .header h1 { font-size: 16px; }
    .header-subtitle { font-size: 11px; }
    .tab-content { padding: 12px; }
    .tab-btn { padding: 8px 10px; font-size: 12px; }
    .chart-container { height: 280px; }
    .chart-container.chart-sm { height: 220px; }
    .chart-container.chart-tall { height: 400px; }
    .chart-container.chart-xl { height: 450px; }
    .kpi-value { font-size: 22px; }
    .kpi-grid { grid-template-columns: repeat(3, 1fr); }
    .score-scale { grid-template-columns: repeat(3, 1fr); }
}

/* ---- Finding Detail View ---- */
.back-btn { display:inline-flex; align-items:center; gap:0.4rem; padding:0.5rem 1rem; background:var(--bg-card); color:var(--accent-light); border:1px solid var(--border); border-radius:6px; cursor:pointer; font-size:0.95rem; margin-bottom:1.2rem; transition:background 0.15s; }
.back-btn:hover { background:var(--bg-card-hover); }
.finding-detail-header { margin-bottom:1.5rem; }
.finding-detail-header h2 { font-size:1.5rem; color:var(--text-primary); margin:0 0 0.5rem; }
.finding-detail-claim { font-size:1.1rem; color:var(--accent-light); font-style:italic; margin:0; line-height:1.5; }
.expert-badges { display:flex; flex-wrap:wrap; gap:0.5rem; margin:1rem 0; }
.expert-badge { display:inline-block; padding:0.3rem 0.8rem; background:rgba(99,102,241,0.12); border:1px solid rgba(99,102,241,0.25); border-radius:20px; font-size:0.85rem; color:var(--accent-light); }
.expert-badge small { color:var(--text-muted); font-size:0.78rem; }
.argument-section { margin:1.5rem 0; }
.argument-paragraph { padding:0.8rem 1rem; margin-bottom:0.8rem; background:var(--bg-card); border-radius:6px; border-left:3px solid var(--accent); line-height:1.65; font-size:0.95rem; color:var(--text-primary); }
.argument-paragraph strong { color:var(--accent-light); }
.evidence-charts { display:grid; grid-template-columns:1fr 1fr; gap:1rem; margin:1.5rem 0; }
@media(max-width:768px) { .evidence-charts { grid-template-columns:1fr; } }
.disclosure-box { margin-top:1.5rem; padding:0.6rem 1rem; background:rgba(100,116,139,0.1); border-radius:4px; font-size:0.82rem; color:var(--text-muted); text-align:center; }
.finding-card { cursor:pointer; transition:transform 0.15s, box-shadow 0.15s; }
.finding-card:hover { transform:translateY(-2px); box-shadow:0 4px 12px rgba(0,0,0,0.15); }

.lit-venue { color: var(--text-muted); font-size: 0.82rem; }

/* ---- Literature Context Section ---- */
.literature-section {
    margin: 1.5rem 0;
    padding: 1rem 0;
    border-top: 1px solid var(--border);
}
.literature-section h4 {
    color: var(--accent-light);
    font-size: 1.1rem;
    margin: 0 0 1rem;
}
.literature-citation {
    padding: 0.8rem 1rem;
    margin-bottom: 0.8rem;
    background: var(--bg-card);
    border-radius: 6px;
    border-left: 3px solid #E69F00;
    line-height: 1.6;
}
.lit-ref {
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
    color: var(--text-primary);
}
.lit-ref em {
    color: var(--text-secondary);
}
.lit-context {
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.65;
}

/* Literature Section (census-dashboard pattern) */
.literature-section {
    background: var(--bg-card, #1e293b);
    border: 1px solid var(--border, #334155);
    border-left: 3px solid #a78bfa;
    border-radius: 8px;
    padding: 24px;
    margin: 20px 0;
}
.literature-heading {
    font-size: 16px;
    font-weight: 700;
    color: #a78bfa;
    margin: 0 0 16px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.literature-subsection {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border, #334155);
}
.literature-subsection:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}
.literature-subsection-heading {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin: 0 0 12px 0;
}
.literature-subsection-heading.vault { color: #a78bfa; }
.literature-subsection-heading.web { color: #22d3ee; }
.literature-narrative {
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.65;
    margin: 0 0 16px 0;
}
.citation-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
    margin-bottom: 16px;
}
.citation-table th {
    background: var(--bg-primary, #0f172a);
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.5px;
    padding: 8px 10px;
    text-align: left;
    border-bottom: 2px solid var(--border, #334155);
}
.citation-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border, #334155);
    color: #cbd5e1;
    vertical-align: top;
}
.citation-table tr:hover td {
    background: rgba(99, 102, 241, 0.05);
}
.citation-relationship {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.rel-confirms { background: rgba(16, 185, 129, 0.2); color: #10b981; }
.rel-extends { background: rgba(99, 102, 241, 0.2); color: #818cf8; }
.rel-challenges { background: rgba(239, 68, 68, 0.2); color: #ef4444; }
.rel-complements { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.literature-quote {
    border-left: 3px solid #a78bfa;
    padding: 10px 16px;
    margin: 12px 0;
    font-style: italic;
    font-size: 13px;
    line-height: 1.6;
    color: #94a3b8;
    background: rgba(167, 139, 250, 0.05);
    border-radius: 0 8px 8px 0;
}
.literature-quote .quote-source {
    display: block;
    margin-top: 6px;
    font-style: normal;
    font-size: 11px;
    color: #64748b;
    font-weight: 600;
}

/* ======== Features Tab ======== */
.channel-badge {
    display: inline-block;
    padding: 0.15em 0.5em;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}
.channel-badge.c1 { background: rgba(99,102,241,0.25); color: #a5b4fc; }
.channel-badge.c2 { background: rgba(56,189,248,0.25); color: #7dd3fc; }
.channel-badge.c3 { background: rgba(245,158,11,0.25); color: #fcd34d; }

.feature-search-input {
    background: var(--card-bg, #1e293b);
    border: 1px solid var(--border, #334155);
    color: var(--text, #e2e8f0);
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    width: 220px;
}
.feature-search-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99,102,241,0.25);
}

.feature-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.feature-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}
.feature-table th {
    background: var(--card-bg, #1e293b);
    color: var(--text-muted, #94a3b8);
    padding: 0.5rem 0.6rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border, #334155);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.feature-table th:hover { color: var(--text, #e2e8f0); }
.feature-table td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid rgba(51,65,85,0.4);
    white-space: nowrap;
}
.feature-table tbody tr { cursor: pointer; }
.feature-table tbody tr:hover { background: rgba(99,102,241,0.08); }
.feature-table tbody tr:nth-child(even) { background: rgba(30,41,59,0.3); }
.feature-table tbody tr:nth-child(even):hover { background: rgba(99,102,241,0.12); }

.feature-detail-row {
    display: none;
}
.feature-detail-row.open {
    display: table-row;
}
.feature-detail-row td {
    padding: 1rem;
    background: rgba(30,41,59,0.6);
    border-bottom: 2px solid rgba(99,102,241,0.3);
}
.feature-detail-content {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}
.feature-detail-desc {
    grid-column: 1 / -1;
    font-style: italic;
    color: var(--text-muted, #94a3b8);
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.feature-cluster-card {
    background: var(--card-bg, #1e293b);
    border: 1px solid var(--border, #334155);
    border-radius: 8px;
    padding: 1rem;
}
.feature-cluster-card h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.95rem;
}
.feature-cluster-member {
    display: inline-block;
    background: rgba(99,102,241,0.12);
    color: #a5b4fc;
    padding: 0.15em 0.5em;
    border-radius: 4px;
    font-size: 0.75rem;
    margin: 0.15rem;
    font-family: monospace;
}

.chart-tall { height: 500px; }

/* ======== Heatmap Tab ======== */
.heatmap-controls {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    padding: 10px 16px;
    background: var(--card-bg, #1e293b);
    border: 1px solid var(--border, #334155);
    border-radius: 8px;
    margin-bottom: 12px;
}
.heatmap-controls label {
    color: var(--text-muted, #94a3b8);
    font-size: 0.82rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}
.heatmap-controls select {
    background: var(--card-bg, #0f172a);
    color: var(--text, #e2e8f0);
    border: 1px solid var(--border, #334155);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 0.8rem;
}

.heatmap-viewport {
    position: relative;
    display: flex;
    gap: 2px;
    background: #0f172a;
    border: 1px solid var(--border, #334155);
    border-radius: 8px;
    padding: 8px;
    overflow: hidden;
}
.heatmap-main-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

#hm-canvas {
    cursor: crosshair;
    image-rendering: pixelated;
    width: 100%;
    display: block;
}
#hm-col-tracks {
    width: 100%;
    height: 40px;
    display: block;
}
#hm-row-tracks {
    width: 60px;
    image-rendering: pixelated;
    display: block;
    flex-shrink: 0;
}
#hm-minimap {
    position: absolute;
    bottom: 16px;
    right: 16px;
    border: 2px solid #6366f1;
    border-radius: 4px;
    background: rgba(0,0,0,0.85);
    cursor: pointer;
    z-index: 10;
}

.hm-feature-bar {
    background: rgba(15,23,42,0.85);
    border: 1px solid var(--border, #334155);
    border-radius: 4px;
    padding: 3px 10px;
    font-size: 0.75rem;
    color: #94a3b8;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 22px;
    line-height: 16px;
    transition: color 0.15s;
}
.hm-feature-bar .feat-name { color: #a5b4fc; font-weight: 600; }
.hm-feature-bar .feat-channel { color: #94a3b8; }
.hm-feature-bar .feat-pillar { color: #94a3b8; }

.hm-tooltip {
    position: fixed;
    z-index: 1000;
    background: rgba(15,23,42,0.95);
    border: 1px solid var(--border, #334155);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.78rem;
    color: var(--text, #e2e8f0);
    pointer-events: none;
    max-width: 350px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    line-height: 1.5;
}
.hm-tooltip strong { color: #a5b4fc; }

.hm-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    margin-top: 8px;
}
.hm-legend-gradient {
    width: 220px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid var(--border, #334155);
    background: linear-gradient(to right, #000000, #0d1b3e, #0f6b6b, #d4d418, #fffff0);
}
.hm-legend-label {
    font-size: 0.75rem;
    color: var(--text-muted, #94a3b8);
    font-weight: 600;
}

.pattern-nav {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.pattern-btn {
    background: var(--card-bg, #1e293b);
    border: 1px solid var(--border, #334155);
    color: var(--text-muted, #94a3b8);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
}
.pattern-btn:hover {
    border-color: #6366f1;
    color: var(--text, #e2e8f0);
}
.pattern-btn.active {
    background: #6366f1;
    color: white;
    border-color: #6366f1;
}

/* ---- Heatmap Track Legends ---- */
.hm-track-legend {
    flex: 1;
    min-width: 280px;
    background: rgba(15,23,42,0.5);
    border: 1px solid var(--border, #334155);
    border-radius: 6px;
    padding: 8px 12px;
}
.hm-track-legend-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: #a5b4fc;
    margin-bottom: 6px;
}
.hm-track-legend-row {
    font-size: 0.72rem;
    color: var(--text-muted, #94a3b8);
    line-height: 1.8;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 4px;
}
.hm-track-legend-label {
    font-weight: 600;
    color: #cbd5e1;
    margin-right: 4px;
    white-space: nowrap;
}
.hm-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    vertical-align: middle;
    margin-left: 4px;
}

/* ======== Statement Detail Panel ======== */
.hm-stmt-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: min(520px, 90vw);
    height: 100vh;
    background: var(--bg-primary);
    border-left: 2px solid var(--accent);
    z-index: 1100;
    overflow-y: auto;
    box-shadow: -8px 0 32px rgba(0,0,0,0.5);
    animation: hm-slide-in 0.2s ease-out;
}
@keyframes hm-slide-in {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}
.hm-stmt-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 2;
}
.hm-stmt-panel-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 40px);
}
.hm-stmt-panel-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    flex-shrink: 0;
}
.hm-stmt-panel-close:hover {
    color: var(--text-primary);
}
.hm-stmt-panel-body {
    padding: 16px 20px;
}

/* Meta grid */
.hm-stmt-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}
.hm-stmt-meta-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
}
.hm-stmt-meta-label {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.hm-stmt-meta-value {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Stats row */
.hm-stmt-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin-bottom: 16px;
}
.hm-stmt-stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    text-align: center;
}
.hm-stmt-stat-val {
    display: block;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent-light);
}
.hm-stmt-stat-label {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Section headers */
.hm-stmt-section {
    margin-bottom: 16px;
}
.hm-stmt-section h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 8px 0;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

/* Channel badge — crosswalk (extends existing c1/c2/c3 badges) */
.channel-badge.crosswalk { background: rgba(168,85,247,0.2); color: #a855f7; }