:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: #1e293b;
    --border: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --green: #22c55e;
    --red: #ef4444;
    --yellow: #f59e0b;
    --orange: #f97316;
    --blue: #06b6d4;
    --purple: #a78bfa;
    --pink: #ec4899;
    --score-poor: #ef4444;
    --score-fair: #f59e0b;
    --score-good: #22c55e;
    --score-excellent: #06b6d4;
}

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

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

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header { margin-bottom: 24px; }
header h1 { color: var(--blue); font-size: 1.8em; margin-bottom: 4px; }
header .subtitle { color: var(--text-muted); font-size: 0.9em; }

/* Alert banner */
.alert-banner {
    background: rgba(239, 68, 68, 0.15);
    border-left: 4px solid var(--red);
    padding: 14px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.9em;
}
.alert-banner.hidden { display: none; }

/* ── Cards Grid ─────────────────────────────────── */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border);
    transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
    position: relative;
}

.card.expandable {
    cursor: pointer;
}

.card.expandable:hover {
    border-color: var(--blue);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(6, 182, 212, 0.1);
}

.card.expandable.active {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.3);
}

.card .label {
    color: var(--text-muted);
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}

.card .value {
    font-family: 'JetBrains Mono', 'SF Mono', monospace;
    font-size: 2em;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 4px;
}

.card .qualifier {
    font-size: 0.75em;
    font-weight: 600;
    margin-bottom: 4px;
}
.card .qualifier.poor { color: var(--red); }
.card .qualifier.fair { color: var(--yellow); }
.card .qualifier.good { color: var(--green); }
.card .qualifier.excellent { color: var(--blue); }

.card .delta {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8em;
    margin-bottom: 2px;
}
.card .delta.positive { color: var(--green); }
.card .delta.negative { color: var(--red); }

.card .sub-values {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em;
    margin-bottom: 4px;
}
.sub-green { color: var(--green); margin-right: 8px; }
.sub-red { color: var(--red); }

.card .target {
    font-size: 0.7em;
    color: var(--text-muted);
    margin-top: 4px;
}

.card .expand-hint {
    font-size: 0.65em;
    color: var(--text-muted);
    position: absolute;
    bottom: 8px;
    right: 12px;
    opacity: 0;
    transition: opacity 0.2s;
}
.card.expandable:hover .expand-hint { opacity: 1; }

/* ── Section Header ────────────────────────────── */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1em;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.compliance-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em;
    color: var(--green);
}

/* ── Checklist ──────────────────────────────────── */
.checklist-bar { margin-bottom: 12px; }

.compliance-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.compliance-fill {
    height: 100%;
    background: var(--green);
    border-radius: 3px;
    transition: width 0.3s;
}

.checklist-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 24px;
}

.checklist-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 0.82em;
    color: var(--text-secondary);
    transition: border-color 0.2s;
    user-select: none;
}
.checklist-item:hover { border-color: var(--green); }
.checklist-item.checked {
    border-left: 3px solid var(--green);
    color: var(--text-primary);
}
.checklist-item input[type="checkbox"] {
    accent-color: var(--green);
    width: 16px;
    height: 16px;
    margin-right: 8px;
    flex-shrink: 0;
}

/* ── Detail Panels ──────────────────────────────── */
.detail-panel {
    display: none;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    animation: slideDown 0.25s ease-out;
}
.detail-panel.open { display: block; }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.panel-header h2 {
    font-size: 1.2em;
    color: var(--blue);
}
.panel-close {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, border-color 0.2s;
}
.panel-close:hover { color: var(--red); border-color: var(--red); }

/* Chart containers */
.chart-container {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
}
.chart-container canvas {
    width: 100% !important;
    height: 280px !important;
}
.chart-title {
    color: var(--text-secondary);
    font-size: 0.85em;
    margin-bottom: 12px;
}

/* Activity list */
#activity-list { margin-top: 16px; }
.activity-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 8px;
}
.activity-name {
    font-weight: 600;
    font-size: 0.9em;
    margin-bottom: 4px;
}
.activity-meta {
    font-size: 0.8em;
    color: var(--text-muted);
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

/* Refresh FAB */
.refresh-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--blue);
    color: white;
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    cursor: pointer;
    font-size: 1.4em;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    z-index: 100;
}
.refresh-btn:hover { transform: scale(1.1); }
.refresh-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 900px) {
    .cards-grid { grid-template-columns: repeat(2, 1fr); }
    .checklist-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 500px) {
    .cards-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .checklist-grid { grid-template-columns: 1fr; }
    .container { padding: 12px; }
    .card { padding: 14px; }
    .card .value { font-size: 1.5em; }
    header h1 { font-size: 1.3em; }
    .detail-panel { padding: 16px; }
}
