/* Same look as stats-admin. Copied, not shared: the two tools stay independent. */

/* ── Fonts, hosted here: no request leaves for a third party ─ */
@font-face { font-family: 'Exo 2'; font-weight: 300; font-style: normal; font-display: swap; src: url('vendor/fonts/exo-2-300.woff2') format('woff2'); }
@font-face { font-family: 'Exo 2'; font-weight: 400; font-style: normal; font-display: swap; src: url('vendor/fonts/exo-2-400.woff2') format('woff2'); }
@font-face { font-family: 'Exo 2'; font-weight: 600; font-style: normal; font-display: swap; src: url('vendor/fonts/exo-2-600.woff2') format('woff2'); }
@font-face { font-family: 'Exo 2'; font-weight: 800; font-style: normal; font-display: swap; src: url('vendor/fonts/exo-2-800.woff2') format('woff2'); }
@font-face { font-family: 'Space Mono'; font-weight: 400; font-style: normal; font-display: swap; src: url('vendor/fonts/space-mono-400.woff2') format('woff2'); }
@font-face { font-family: 'Space Mono'; font-weight: 700; font-style: normal; font-display: swap; src: url('vendor/fonts/space-mono-700.woff2') format('woff2'); }

/* ── Reset & root ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    color-scheme: dark;
    --bg:          #060d14;
    --bg2:         #0c1a26;
    --bg3:         #112233;
    --border:      #1a3a5c;
    --accent:      #00d4aa;
    --accent2:     #ff6b35;
    --accent3:     #4ecdc4;
    --text:        #cce7f0;
    --text-dim:    #5a8a9f;
    --text-bright: #e8f8ff;
    --card-shadow: 0 4px 32px rgba(0,0,0,.6);
    --font-mono:   'Space Mono', monospace;
    --font-main:   'Exo 2', sans-serif;
    --radius:      12px;
}

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-main);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Background grid decoration ───────────────────────────── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(0,212,170,.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,212,170,.03) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 0;
}

/* ── Header ────────────────────────────────────────────────── */
header {
    position: relative;
    z-index: 1;
    padding: 40px 48px 32px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(0,212,170,.06) 0%, transparent 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.logo-block { display: flex; align-items: center; gap: 20px; }

h1 {
    font-family: var(--font-main);
    font-weight: 800;
    font-size: clamp(1.4rem, 3vw, 2rem);
    letter-spacing: -.02em;
    color: var(--text-bright);
}

h1 span { color: var(--accent); }

h1 a { color: inherit; text-decoration: none; }

.header-meta {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 4px;
}

.badge-live {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(0,212,170,.12);
    border: 1px solid rgba(0,212,170,.3);
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 6px 14px;
    border-radius: 999px;
    white-space: nowrap;
}

.badge-live::before {
    content: '';
    width: 7px; height: 7px;
    background: var(--accent);
    border-radius: 50%;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* ── Main layout ───────────────────────────────────────────── */
main {
    position: relative;
    z-index: 1;
    max-width: 1440px;
    margin: 0 auto;
    padding: 40px 48px 80px;
}

/* ── KPI row ───────────────────────────────────────────────── */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
}

.kpi-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 28px;
    position: relative;
    overflow: hidden;
    transition: border-color .2s, transform .2s;
}

.kpi-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.kpi-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent3));
}

.kpi-label {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: .15em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.kpi-value {
    font-family: var(--font-mono);
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
}

.kpi-value.alt { color: var(--accent3); }

.kpi-pair {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 40px;
}

.kpi-sub {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 6px;
}

/* ── Section title ─────────────────────────────────────────── */
.section-title {
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin: 48px 0 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title::before {
    content: '';
    display: inline-block;
    width: 4px; height: 20px;
    background: linear-gradient(180deg, var(--accent), var(--accent3));
    border-radius: 2px;
}

/* ── Charts grid ───────────────────────────────────────────── */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 20px;
}

.chart-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--card-shadow);
    transition: border-color .2s, transform .2s;
    display: flex;
    flex-direction: column;
}

.chart-card:hover {
    border-color: rgba(0,212,170,.3);
    transform: translateY(-2px);
}

.chart-title {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-title-icon {
    width: 22px; height: 22px;
    border-radius: 6px;
    background: rgba(0,212,170,.15);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
}

.chart-wrap {
    position: relative;
    flex: 1;
    min-height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-wrap canvas { max-height: 280px !important; }

/* A line chart fills its box: block and fixed height, or Chart.js keeps the
   width of its first measure and overflows the card on a narrow screen. */
.chart-wrap.wide { display: block; height: 300px; min-height: 0; }
.chart-wrap.wide canvas { max-width: 100%; max-height: 300px !important; }

.chart-empty {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-dim);
    text-align: center;
    padding: 0 12px;
}

/* Legend below chart */
.chart-legend {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    font-size: 11px;
    color: var(--text-dim);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    overflow-wrap: anywhere;
}

.legend-item strong { color: var(--text); }

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

.chart-card-footer {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-dim);
    text-align: center;
}

/* ── Wide card ─────────────────────────────────────────────── */
.wide-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    margin-bottom: 20px;
    box-shadow: var(--card-shadow);
}

/* ── About ─────────────────────────────────────────────────── */
.about-list {
    list-style: none;
    display: grid;
    gap: 10px;
    font-size: 14px;
}

.about-list strong { color: var(--text-bright); font-weight: 600; }

.about-text { font-size: 14px; margin-bottom: 14px; }

.about-text:last-child { margin-bottom: 0; }

main a { color: var(--accent); text-decoration: none; }
main a:hover { text-decoration: underline; }

/* ── Error / empty state ───────────────────────────────────── */
.alert {
    background: rgba(255,107,53,.1);
    border: 1px solid rgba(255,107,53,.3);
    border-radius: var(--radius);
    padding: 20px 24px;
    color: #ff8c5a;
    font-family: var(--font-mono);
    font-size: 13px;
    margin-bottom: 20px;
}

[hidden] { display: none !important; }

/* ── Footer ────────────────────────────────────────────────── */
footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 24px;
    border-top: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-dim);
}

footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
    header, main { padding: 24px 20px; }
    .charts-grid { grid-template-columns: minmax(0, 1fr); }
    .kpi-value   { font-size: 1.7rem; }
    .chart-card, .wide-card { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .kpi-card, .chart-card { transition: none; }
    .kpi-card:hover, .chart-card:hover { transform: none; }
}
