/* GRIDSK — dark "control room" theme: monospace type, navy panels,
   orange = power flowing in (import), teal = power flowing out (export). */
:root {
    --ground: #070c12;
    --panel: #101a24;
    --panel-2: #16232e;
    --line: #22333f;
    --ink: #e8f1f7;
    --ink-2: #a8bccc;
    --ink-3: #8195a6;
    --ink-title: #c2d2de;
    --in: #ff9b3d;
    --out: #3ddcc8;
    --pv: #ffd24a;
    --nuc: #6fa8ff;
    --hydro: #58b7f0;
    --ren: #5fbf6a;
    --foss: #c0705f;
    --misc: #6e7f8d;
    --alarm: #ff5470;
    --font-mono: ui-monospace, "SF Mono", SFMono-Regular, "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
    --font-sans: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 16px; }

body {
    margin: 0;
    background-color: var(--ground);
    background-image:
        linear-gradient(rgba(61, 220, 200, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(61, 220, 200, 0.035) 1px, transparent 1px);
    background-size: 48px 48px;
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.page {
    max-width: 1440px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ---------- panels ---------- */
.panel {
    background: linear-gradient(180deg, rgba(22, 35, 46, 0.92), rgba(16, 26, 36, 0.92));
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.panel-pad { padding: 18px 20px; }

.eyebrow {
    margin: 0;
    font-weight: 400; /* also used on h2/h3 section titles */
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-2);
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 16px 20px 0;
}

.muted { color: var(--ink-3); }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
.c-in { color: var(--in); }
.c-out { color: var(--out); }
.c-pv { color: var(--pv); }
.c-nuc { color: var(--nuc); }
.c-alarm { color: var(--alarm); }

/* ---------- header ---------- */
.topbar {
    display: grid;
    grid-template-columns: minmax(240px, 330px) 1fr auto;
    gap: 24px;
    align-items: start;
}

.brand h1 {
    margin: 0;
    font-size: 26px;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: var(--ink);
}

.brand h1 span { color: var(--out); text-shadow: 0 0 18px rgba(61, 220, 200, 0.45); }

.brand p {
    margin: 6px 0 12px;
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--ink-2);
}

.source-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid rgba(255, 155, 61, 0.55);
    border-radius: 4px;
    background: rgba(255, 155, 61, 0.08);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    box-shadow: 0 0 16px rgba(255, 155, 61, 0.15);
}

.pulse-line {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.pulse-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
}

.pulse-value { font-size: 26px; font-weight: 700; }
.pulse-unit { color: var(--ink-3); }
.pulse-note { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }

#pulse-spark { width: 100%; height: 44px; display: block; }

.clock-box {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.clock { font-size: 24px; font-weight: 700; letter-spacing: 0.04em; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border: 1px solid var(--line);
    border-radius: 3px;
    font-size: 12px;
    color: var(--ink-2);
}

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--out); box-shadow: 0 0 8px var(--out); }

.updated-box {
    padding: 8px 14px;
    border: 1px solid var(--out);
    border-radius: 3px;
    font-size: 13px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--out);
    box-shadow: inset 0 0 18px rgba(61, 220, 200, 0.08);
}

.updated-box .dot { display: inline-block; margin-right: 8px; background: var(--in); box-shadow: 0 0 8px var(--in); }
.updated-box.stale { border-color: var(--in); color: var(--in); }

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.tab {
    padding: 6px 12px;
    border: 1px solid #3a4d5c;
    border-radius: 4px;
    background: rgba(16, 26, 36, 0.6);
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 13px;
    text-decoration: none;
    transition: border-color 0.15s, color 0.15s;
}

.tab:hover, .tab.active { border-color: var(--out); color: var(--out); }

/* ---------- map ---------- */
.map-panel { position: relative; overflow: hidden; }

.map-hint { position: absolute; top: 16px; left: 20px; z-index: 2; }

#map-container { position: relative; }

#map-canvas {
    position: relative;
    height: 600px;
    background: radial-gradient(ellipse at 50% 45%, rgba(61, 220, 200, 0.08), transparent 60%);
    overflow: hidden;
}

#map-canvas canvas { display: block; }
.map3d-labels { position: absolute; inset: 0; touch-action: pan-y; }
.map-fallback { padding: 80px 20px; text-align: center; color: var(--ink-3); }

.map3d-plant {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2px 6px;
    font-family: var(--font-mono);
    line-height: 1.25;
    text-shadow: 0 0 4px var(--ground), 0 0 8px var(--ground);
    cursor: pointer;
    white-space: nowrap;
}
.map3d-plant b { font-size: 11.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-title); }
.map3d-plant span { font-size: 10.5px; color: var(--ink-3); }
.map3d-plant.selected b { color: var(--out); }

.map3d-flow {
    display: flex;
    flex-direction: column;
    min-width: 128px;
    padding: 8px 12px 8px 14px;
    background: rgba(16, 26, 36, 0.94);
    border: 1.5px solid var(--flow);
    border-left-width: 5px;
    font-family: var(--font-mono);
    pointer-events: none;
}
.map3d-flow-country { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; color: var(--ink-title); }
.map3d-flow-dir { font-size: 11px; color: var(--ink-3); }
.map3d-flow-mw { font-size: 24px; font-weight: 700; line-height: 1.1; color: var(--flow); }
.map3d-flow-mw small { margin-left: 5px; font-size: 11px; font-weight: 400; color: var(--ink-3); }

.map-legend {
    position: absolute;
    right: 20px;
    bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 11px;
    color: var(--ink-2);
    z-index: 2;
}

.map-legend a { color: var(--ink-2); }

.legend-swatch { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 2px; vertical-align: -1px; }

.info-panel {
    position: absolute;
    left: 20px;
    bottom: 16px;
    width: min(340px, calc(100% - 40px));
    padding: 14px 16px;
    background: rgba(16, 26, 36, 0.94);
    border: 1px solid var(--line);
    border-left: 3px solid var(--out);
    border-radius: 4px;
    z-index: 10; /* above the 3D map's HTML labels */
    font-size: 12.5px;
}

.info-panel:empty, .info-panel[hidden] { display: none; }
.info-title { margin: 4px 0 8px; font-size: 15px; color: var(--ink); }
.info-row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border-bottom: 1px dashed var(--line); color: var(--ink-2); }
.info-row span:last-child { color: var(--ink); }
.info-note { margin: 8px 0 0; font-family: var(--font-sans); color: var(--ink-3); font-size: 12px; }

/* ---------- KPI cards ---------- */
.kpis {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
}

.kpi {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 18px 18px 26px;
    overflow: hidden;
}

.kpi-value { font-size: 40px; font-weight: 700; line-height: 1; letter-spacing: -0.01em; }
.kpi-value small { margin-left: 4px; font-size: 13px; font-weight: 400; color: var(--ink-3); }
.kpi-text { margin: 0; font-family: var(--font-sans); font-size: 14px; color: var(--ink-2); }
.kpi-text b { color: var(--ink); }
.kpi-delta { font-size: 12px; color: var(--ink-3); }
.kpi-delta b { font-weight: 700; }

.kpi-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(34, 51, 63, 0.8); }
.kpi-bar span { display: block; height: 100%; width: 0; transition: width 0.6s ease; }

/* ---------- domestic vs import ---------- */
.split {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 16px;
    align-items: center;
    padding: 12px 18px;
    font-size: 13px;
}

.split b { font-size: 15px; }

.split-bar { display: flex; height: 24px; overflow: hidden; border-radius: 2px; background: var(--panel-2); }
.split-bar span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    font-size: 11px;
    font-style: italic;
    font-weight: 700;
    color: #07131a;
    white-space: nowrap;
    transition: width 0.6s ease;
}

/* ---------- sections with columns ---------- */
.cols { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.col { padding: 16px 20px 20px; border-right: 1px solid var(--line); }
.col:last-child { border-right: 0; }
.col-value { margin: 10px 0 4px; font-size: 30px; font-weight: 700; line-height: 1.1; }
.col-value small { margin-left: 4px; font-size: 13px; font-weight: 400; color: var(--ink-3); }
.col-sub { font-size: 12.5px; color: var(--ink-3); }
.col-text { margin: 12px 0 0; font-size: 13px; color: var(--ink-2); }

.chart { min-height: 120px; }

/* ---------- mix ---------- */
.mix-grid { display: grid; grid-template-columns: minmax(280px, 1fr) 2fr; }
.mix-bars { padding: 16px 20px 20px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.mix-row { display: grid; grid-template-columns: 110px 1fr 76px; gap: 12px; align-items: center; font-size: 12.5px; }
.mix-track { height: 10px; background: var(--panel-2); border-radius: 2px; overflow: hidden; }
.mix-track span { display: block; height: 100%; border-radius: 2px; transition: width 0.6s ease; }
.mix-row .mix-mw { text-align: right; color: var(--ink); }

/* ---------- trend ---------- */
.range-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.range-chips button {
    padding: 4px 10px;
    border: 1px solid #3a4d5c;
    border-radius: 3px;
    background: transparent;
    color: var(--ink-2);
    font-family: var(--font-mono);
    font-size: 12px;
    cursor: pointer;
}
.range-chips button.active { border-color: var(--out); color: var(--out); }
.trend-body { padding: 8px 12px 12px; }

/* ---------- outages ---------- */
.outage-list { display: flex; flex-direction: column; padding: 10px 20px 4px; }
.outage {
    display: grid;
    grid-template-columns: 92px minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1.4fr);
    gap: 16px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px dashed var(--line);
    font-size: 13px;
}
.outage:last-child { border-bottom: 0; }
.outage-badge {
    justify-self: start;
    padding: 2px 8px;
    border: 1px solid currentColor;
    border-radius: 3px;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.outage-badge.forced { color: var(--alarm); }
.outage-badge.planned { color: var(--pv); }
.outage-name { color: var(--ink); font-weight: 700; }
.outage-sub { display: block; font-weight: 400; color: var(--ink-3); font-size: 12px; }
.outage-mw b { font-size: 18px; color: var(--alarm); }
.outage-when { color: var(--ink-2); }
.outage.upcoming .outage-mw b { color: var(--ink-2); }
.outage-empty { padding: 8px 0 14px; margin: 0; }
.outage-note { margin: 0; padding: 6px 20px 16px; font-family: var(--font-sans); font-size: 12px; color: var(--ink-3); }

@media (max-width: 760px) {
    .outage { grid-template-columns: 1fr; gap: 4px; }
}

/* ---------- distribution outages ---------- */
.dist-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 14px 20px; }
.dist-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-left: 3px solid var(--in);
    border-radius: 4px;
    background: rgba(16, 26, 36, 0.6);
    color: var(--ink);
    text-decoration: none;
    font-size: 13px;
}
a.dist-card:hover { border-color: var(--in); }
.dist-card b { font-size: 16px; }
.dist-card .muted { font-family: var(--font-sans); }

@media (max-width: 760px) {
    .dist-grid { grid-template-columns: 1fr; }
}

/* ---------- footer ---------- */
.foot {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    font-size: 12px;
    color: var(--ink-3);
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .col:nth-child(2) { border-right: 0; }
    .mix-grid { grid-template-columns: 1fr; }
    .mix-bars { border-right: 0; border-bottom: 1px solid var(--line); }
}

@media (max-width: 760px) {
    .topbar { grid-template-columns: 1fr; }
    .clock-box { align-items: flex-start; }
    .kpis, .cols { grid-template-columns: 1fr; }
    .col { border-right: 0; border-bottom: 1px solid var(--line); }
    /* Let the SVG take its natural (viewBox) height instead of a fixed
       box that leaves empty bands around a width-limited map. */
    /* Slovakia is wide and flat: a tall box only adds empty space. */
    #map-canvas { height: 300px; }
    .map3d-flow { min-width: 0; padding: 3px 6px 3px 8px; border-left-width: 3px; }
    .map3d-flow-country { font-size: 9px; }
    .map3d-flow-dir { display: none; }
    .map3d-flow-mw { font-size: 13px; }
    .map3d-flow-mw small { font-size: 9px; }
    /* Names only; MW is in the detail panel on tap. */
    .map3d-plant span { display: none; }
    .map3d-plant b { font-size: 8.5px; letter-spacing: 0.03em; }
    .map-hint { position: static; padding: 14px 16px 0; }
    .map-legend { position: static; padding: 0 16px 14px; }
    .info-panel { position: static; width: auto; margin: 0 16px 16px; }
    .split { grid-template-columns: 1fr; }
}

.flow-tooltip {
    position: fixed;
    z-index: 50;
    display: none;
    padding: 8px 10px;
    background: rgba(16, 26, 36, 0.96);
    border: 1px solid var(--line);
    border-radius: 3px;
    font-size: 12px;
    color: var(--ink);
    pointer-events: none;
}
