/* Children & AI Governance Dashboard v3 */

:root {
    --bg-primary: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #263548;
    --border: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-light: #818cf8;
    --protection: #ef4444;
    --participation: #818cf8;
    --provision: #10b981;
    --governance: #f59e0b;
    --crosscutting: #8b5cf6;
    --radius: 10px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

[data-theme="light"] {
    --bg-primary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --border: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

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

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.header {
    position: sticky; top: 0; z-index: 100;
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}
.header h1 { font-size: 1.15rem; font-weight: 600; letter-spacing: -0.02em; }
.header-subtitle { font-size: 0.8rem; color: var(--text-secondary); margin-left: 12px; }
.theme-toggle {
    background: none; border: 1px solid var(--border); color: var(--text-secondary);
    border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 1rem;
}
.theme-toggle:hover { background: var(--bg-card-hover); }

.tab-nav {
    position: sticky; top: 52px; z-index: 90;
    display: flex; gap: 4px; padding: 8px 24px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}
.tab-btn {
    background: transparent; border: none; color: var(--text-muted);
    padding: 8px 16px; border-radius: 6px; cursor: pointer;
    font-size: 0.82rem; font-weight: 500; white-space: nowrap;
    transition: all 0.15s;
}
.tab-btn:hover { background: var(--bg-card); color: var(--text-primary); }
.tab-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tab-btn.active {
    background: var(--accent); color: #fff;
    box-shadow: 0 2px 6px rgba(99,102,241,0.3);
}

.kpi-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px; padding: 16px 24px;
}
.kpi-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; text-align: center;
}
.kpi-value { font-size: 1.8rem; font-weight: 700; color: var(--accent); }
.kpi-label { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-sub { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }

main { padding: 0 24px 40px; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.section-title {
    font-size: 1rem; font-weight: 600; margin: 24px 0 12px;
    padding-bottom: 8px; border-bottom: 1px solid var(--border);
}

.chart-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(460px, 100%), 1fr)); gap: 20px; margin-top: 16px; }
.chart-grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 20px; margin-top: 16px; }
.chart-full { margin-top: 16px; }

.chart-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px;
    box-shadow: var(--shadow);
}
.chart-card h3 { font-size: 0.85rem; font-weight: 600; margin-bottom: 8px; color: var(--text-primary); }
.chart-card .chart-subtitle { font-size: 0.72rem; color: var(--text-secondary); margin-bottom: 12px; }

.headline-banner {
    background: linear-gradient(135deg, #1e293b 0%, #312e81 100%);
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 24px; margin: 16px 0;
}
.headline-banner p { font-size: 0.95rem; line-height: 1.7; color: var(--text-primary); }
.headline-banner strong { color: var(--accent-light); }
[data-theme="light"] .headline-banner {
    background: linear-gradient(135deg, #e2e8f0 0%, #c7d2fe 100%);
}
[data-theme="light"] .headline-banner p { color: #1e293b; }
[data-theme="light"] .headline-banner strong { color: #4338ca; }

.findings-list { list-style: none; padding: 0; }
.findings-list li {
    padding: 10px 16px; margin: 6px 0;
    background: var(--bg-card); border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 0.82rem; color: var(--text-primary);
}

.stmt-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.stmt-table th {
    text-align: left; padding: 8px 12px; background: var(--bg-card);
    border-bottom: 2px solid var(--border); color: var(--text-secondary);
    font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.7rem;
}
.stmt-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.stmt-table tr:hover { background: var(--bg-card-hover); }
.cgi-badge {
    display: inline-block; padding: 2px 8px; border-radius: 4px;
    font-weight: 600; font-size: 0.75rem;
}
.cgi-high { background: rgba(16,185,129,0.15); color: #10b981; }
.cgi-mid { background: rgba(245,158,11,0.15); color: #f59e0b; }
.cgi-low { background: rgba(100,116,139,0.15); color: #94a3b8; }
.cgi-high::before { content: "H: "; font-weight: 400; }
.cgi-mid::before { content: "M: "; font-weight: 400; }
.cgi-low::before { content: "L: "; font-weight: 400; }

.status-badge {
    display: inline-block; padding: 2px 10px; border-radius: 4px;
    font-weight: 600; font-size: 0.72rem; text-transform: uppercase;
}
.status-green { background: rgba(16,185,129,0.15); color: #10b981; }
.status-yellow { background: rgba(245,158,11,0.15); color: #f59e0b; }
.status-red { background: rgba(239,68,68,0.15); color: #ef4444; }

/* Expert Interpretation Panels */
.tab-interpretation {
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(99,102,241,0.08) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin: 16px 0 20px 0;
    display: none;
}
.tab-interpretation.visible { display: block; }
.tab-interpretation .tab-headline {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 0.92rem;
}
.tab-interpretation .tab-overview {
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.65;
}
.tab-interpretation .tab-attribution {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 10px;
    font-style: italic;
}
.chart-interpretation {
    margin-top: 12px;
    padding: 14px 16px;
    background: var(--bg-primary);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 0.78rem;
    line-height: 1.6;
    display: none;
}
.chart-interpretation.visible { display: block; }
.chart-interpretation .interp-label {
    font-weight: 600;
    color: var(--accent-light, #818cf8);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
}
.chart-interpretation .interp-text {
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.chart-interpretation .interp-expert {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 6px;
    border-top: 1px solid var(--border);
    padding-top: 6px;
}
.interp-toggle-global {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.72rem;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 8px;
}
.interp-toggle-global:hover {
    color: var(--accent);
    border-color: var(--accent);
}
.interp-toggle-global.active {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(99,102,241,0.1);
}

.interp-data-method {
    background: rgba(0,0,0,0.15);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.74rem;
    font-style: italic;
    color: var(--text-muted);
    margin-bottom: 8px;
    line-height: 1.5;
}
[data-theme="light"] .interp-data-method { background: rgba(0,0,0,0.05); }
.interp-conclusion {
    border-bottom: 2px solid var(--accent);
    padding-bottom: 8px;
    margin-bottom: 4px;
    font-weight: 500;
    color: var(--text-primary);
}

/* ========== CHART SUMMARY (always visible) ========== */
.chart-summary {
    margin-top: 8px;
    padding: 10px 14px;
    font-size: 0.8rem;
    line-height: 1.5;
    display: none;
}
.chart-summary.visible { display: block; }
.chart-summary .summary-finding {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.chart-summary .summary-conclusion {
    font-style: italic;
    color: var(--text-secondary);
    font-size: 0.76rem;
}

@media (max-width: 768px) {
    .chart-grid-2, .chart-grid-3 { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .header { padding: 10px 16px; }
    main { padding: 0 12px 24px; }
}

/* ========== DETAIL PANEL ========== */
.detail-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    z-index: 10;
}
.detail-close:hover { color: var(--text-primary); }
.stmt-detail { position: relative; }

/* ========== SELECTED ROW ========== */
.stmt-table tbody tr.selected { background: var(--accent) !important; color: #fff; }
.stmt-table tbody tr.selected .cgi-badge { border: 1px solid rgba(255,255,255,0.3); }

/* ========== SKIP-TO-CONTENT ========== */
.skip-link {
    position: absolute; top: -100%; left: 0;
    background: var(--accent); color: #fff;
    padding: 8px 16px; font-size: 0.85rem; font-weight: 600;
    z-index: 200; text-decoration: none;
}
.skip-link:focus { top: 0; }

/* ========== FIGURE NUMBERING ========== */
.tab-pane { counter-reset: figure; }
.chart-card > h3::before {
    counter-increment: figure;
    content: "Fig. " counter(figure) ". ";
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.78rem;
}

/* ========== PRINT ========== */
@media print {
    body { background: #fff !important; color: #000 !important; }
    .header { position: static; background: #fff; border-bottom: 2px solid #000; }
    .tab-nav { display: none; }
    .theme-toggle, .interp-toggle-global, #interp-toggle { display: none; }
    .tab-pane { display: block !important; page-break-before: always; }
    .tab-pane:first-child { page-break-before: auto; }
    .chart-card { background: #fff; border: 1px solid #ccc; box-shadow: none; page-break-inside: avoid; }
    .chart-interpretation { display: block !important; background: #f8f8f8; border-left: 3px solid #333; }
    .chart-interpretation.visible { display: block !important; }
    .tab-interpretation { display: block !important; background: #f0f0f0; }
    .tab-interpretation.visible { display: block !important; }
    .kpi-card { background: #fff; border: 1px solid #ccc; }
    .kpi-value { color: #000; }
    .cgi-badge { border: 1px solid #666; }
    a { color: #000; text-decoration: underline; }
    .headline-banner { background: #f0f0f0 !important; color: #000 !important; }
    .chart-card h3 { font-size: 0.95rem; }
    .chart-subtitle { font-size: 0.82rem; }
    .stmt-table th, .stmt-table td { font-size: 0.85rem; }
}
