:root {
  --blue: #0752a2;
  --navy: #0d2d4b;
  --yellow: #f2c84b;
  --red: #a52a3e;
  --paper: #f5f1e8;
  --white: #ffffff;
  --muted: #6d7b88;
  --line: #ddd7cc;
  --green: #168a61;
  --cyan: #339d9b;
  --orange: #d97732;
  --sans: Verdana, Geneva, sans-serif;
  --display: Georgia, "Times New Roman", serif;
  --numbers: Tahoma, Verdana, sans-serif;
  --mono: Verdana, Geneva, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--navy); font: 13px/1.4 var(--sans); }
a { color: inherit; text-decoration: none; }

.terminal-bar {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 max(18px, calc((100vw - 1560px) / 2));
  background: rgba(245, 241, 232, .97);
  border-top: 4px solid var(--blue);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}
.terminal-bar nav { display: flex; align-items: center; gap: 5px; }
.terminal-bar nav a, .clock a {
  padding: 7px 10px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .02em;
}
.terminal-bar nav a:hover, .clock a:hover { background: var(--blue); color: #fff; }
.clock { margin-left: auto; display: flex; align-items: center; gap: 10px; font: 700 10px var(--mono); }
.clock i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(22, 138, 97, .1); }
.clock span { color: var(--green); font-size: 8px; font-weight: 850; letter-spacing: .1em; }
.clock b { color: var(--navy); }
.language-switch { display: flex; gap: 2px; padding-left: 8px; border-left: 1px solid var(--line); }
.language-switch button { min-width: 31px; border: 0; padding: 6px 7px; background: #e9e6de; color: var(--muted); font: 700 9px var(--sans); cursor: pointer; }
.language-switch button.active { background: var(--blue); color: #fff; }

.ticker {
  min-height: 34px;
  overflow: hidden;
  display: flex;
  align-items: center;
  background: var(--navy);
  color: #aebfce;
  font: 700 9px var(--mono);
  white-space: nowrap;
}
.ticker span { padding: 0 20px; border-right: 1px solid rgba(255,255,255,.13); }
.ticker b { color: #fff; margin-left: 7px; }
.ticker .up { color: #ff8b96; }
.ticker .down { color: #65d3aa; }

main { max-width: 1580px; margin: auto; padding: 14px 10px 36px; }
.metric-strip { display: grid; grid-template-columns: repeat(8, 1fr); gap: 7px; }
.metric-strip article {
  min-width: 0;
  min-height: 83px;
  padding: 14px 14px 12px;
  background: var(--white);
  border: 1px solid var(--line);
  border-top: 3px solid var(--blue);
}
.metric-strip article:nth-child(3), .metric-strip article:nth-child(4) { border-top-color: var(--yellow); }
.metric-strip article:nth-child(5), .metric-strip article:nth-child(6) { border-top-color: var(--red); }
.metric-strip article:nth-child(7), .metric-strip article:nth-child(8) { border-top-color: var(--orange); }
label { display: block; color: var(--muted); font-size: 7px; font-weight: 850; letter-spacing: .09em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-strip strong { font: 700 23px/1.1 var(--numbers); color: var(--navy); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.metric-strip small { margin-left: 4px; color: var(--muted); font-size: 7px; font-weight: 800; }

.workspace { display: grid; gap: 7px; margin-top: 7px; }
.primary-grid { grid-template-columns: minmax(0, 3fr) minmax(270px, 1fr); }
.map-top-grid { grid-template-columns: 1fr; margin-top: 0; margin-bottom: 7px; }
.secondary-grid { grid-template-columns: 1fr; }
.lower-grid { grid-template-columns: 1fr .72fr .62fr; }
.panel { min-width: 0; overflow: hidden; background: var(--white); border: 1px solid var(--line); }
.panel > header {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 15px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.panel > header > div:first-child { display: flex; align-items: center; gap: 9px; }
.panel header h1, .panel header h2 { margin: 0; color: var(--navy); font: 700 14px/1.1 var(--display); letter-spacing: 0; }
.panel header h1 small { color: var(--muted); font: 700 8px var(--sans); margin-left: 8px; }
.panel header > span, .panel-time { color: var(--muted); font: 700 8px var(--mono); }
.index { padding: 4px 6px; background: #e9f1fa; color: var(--blue); font: 700 8px var(--sans); }

.legend { display: flex; gap: 18px; padding: 11px 16px 0; color: var(--muted); font-size: 8px; font-weight: 800; }
.legend span::before { content: ""; display: inline-block; width: 15px; height: 2px; margin-right: 6px; vertical-align: middle; }
.legend .consumption::before { background: var(--yellow); }
.legend .production::before { background: var(--cyan); }
.legend .plan::before { background: var(--blue); }
.line-chart { display: block; width: 100%; height: 315px; padding: 0 8px; }
.chart-grid { stroke: #e8e4dc; stroke-width: 1; }
.chart-axis { fill: #7c8994; font: 9px var(--sans); }
.series-consumption, .series-production, .series-plan { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.series-consumption { stroke: #d3a512; }
.series-production { stroke: var(--cyan); }
.series-plan { stroke: var(--blue); stroke-dasharray: 4 5; opacity: .72; }
.chart-area { fill: url(#loadArea); }
.chart-last { fill: var(--yellow); stroke: #fff; stroke-width: 4; }
.chart-footer { min-height: 32px; padding: 0 14px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); color: var(--muted); font-size: 7px; font-weight: 800; }
.chart-footer i { font-style: normal; }

.mix-panel { min-height: 414px; }
.mix-total { display: grid; place-items: center; padding: 21px 0 8px; }
.donut { width: 135px; height: 135px; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; }
.donut::before { content: ""; position: absolute; inset: 16px; border-radius: 50%; background: #fff; }
.donut b, .donut small { position: relative; z-index: 2; }
.donut b { color: var(--navy); font: 700 25px var(--numbers); font-variant-numeric: tabular-nums; }
.donut small { color: var(--muted); font-size: 8px; font-weight: 800; }
.mix-bars { padding: 5px 18px 15px; }
.mix-row { display: grid; grid-template-columns: 70px 1fr 45px; align-items: center; gap: 8px; margin-top: 9px; }
.mix-row .bar { height: 6px; background: #e7e5df; }
.mix-row .bar i { display: block; height: 100%; }
.mix-row b { text-align: right; font: 700 10px var(--mono); }
.system-cells { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.system-cells div { padding: 13px 15px; }
.system-cells div + div { border-left: 1px solid var(--line); }
.system-cells b { font: 700 16px var(--numbers); font-variant-numeric: tabular-nums; }
.system-cells small { color: var(--muted); font-size: 7px; font-weight: 800; margin-left: 4px; }

.map-panel, .fx-panel { height: 510px; }
.map-stage {
  height: 463px;
  position: relative;
  overflow: hidden;
  background-color: #eef2f3;
  background-image: linear-gradient(rgba(7,82,162,.055) 1px, transparent 1px), linear-gradient(90deg, rgba(7,82,162,.055) 1px, transparent 1px);
  background-size: 32px 32px;
}
.country { position: absolute; width: 300px; height: 430px; left: 48%; top: 50%; transform: translate(-50%,-50%); color: var(--blue); filter: drop-shadow(8px 9px 0 rgba(13,45,75,.08)); }
.country .outline { fill: #dbeafb; stroke: var(--blue); stroke-width: 2; stroke-linejoin: round; }
.country .grid-fill { fill: url(#mapgrid); }
.city-layer { position: absolute; width: 300px; height: 430px; left: 48%; top: 50%; transform: translate(-50%,-50%); }
.flow { position: absolute; z-index: 5; padding: 8px 10px; background: #fff; border: 1px solid var(--line); box-shadow: 0 5px 15px rgba(13,45,75,.06); }
.flow::after { content: ""; position: absolute; top: 50%; width: 68px; border-top: 2px dashed var(--yellow); }
.flow span, .flow b { display: block; }
.flow span { color: var(--muted); font-size: 7px; font-weight: 850; }
.flow b { color: var(--navy); font: 700 12px var(--mono); }
.flow-ua { right: 22px; top: 88px; }
.flow-ua::after { right: 100%; }
.flow-ro { left: 20px; bottom: 105px; }
.flow-ro::after { left: 100%; }
.city { position: absolute; z-index: 8; transform: translate(-50%,-50%); }
.city-dot { width: 9px; height: 9px; background: var(--yellow); border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 5px rgba(7,82,162,.15); }
.city-label { position: absolute; left: 13px; top: -13px; padding: 5px 7px; background: rgba(255,255,255,.95); border-left: 2px solid var(--blue); box-shadow: 0 3px 12px rgba(13,45,75,.12); white-space: nowrap; }
.city-label b { color: var(--navy); font-size: 8px; }
.city-label span { margin-left: 5px; color: #8b6700; font-size: 9px; font-weight: 850; }
.city-label small { display: block; color: var(--muted); font-size: 6px; font-weight: 750; }
.map-legend { position: absolute; left: 14px; bottom: 12px; display: flex; gap: 16px; color: var(--muted); font-size: 7px; font-weight: 800; }
.map-legend i { display: inline-block; width: 7px; height: 7px; margin-right: 5px; }
.map-legend .warm { background: var(--yellow); }
.map-legend .node { border: 1px solid var(--blue); border-radius: 50%; }
.map-legend .flowkey { height: 2px; background: var(--yellow); }

.fx-majors { display: grid; grid-template-columns: repeat(5,1fr); border-bottom: 1px solid var(--line); }
.fx-major { padding: 11px 9px; border-right: 1px solid var(--line); }
.fx-major:last-child { border-right: 0; }
.fx-major span, .fx-major b { display: block; }
.fx-major span { color: var(--muted); font-size: 7px; font-weight: 850; }
.fx-major b { color: var(--navy); font: 700 16px var(--numbers); font-variant-numeric: tabular-nums; }
.fx-trend-head { height: 25px; display: flex; align-items: end; justify-content: space-between; padding: 0 12px; color: var(--muted); font-size: 7px; font-weight: 850; }
.fx-trend-head b { color: var(--green); font-size: 9px; }
.fx-trend-chart { display: block; width: 100%; height: 106px; }
.fx-trend-line { fill: none; stroke: var(--blue); stroke-width: 2.5; }
.fx-trend-area { fill: url(#fxArea); }
.fx-major { cursor: pointer; }
.fx-major.active { background: #e9f1fa; box-shadow: inset 0 -3px var(--blue); }
.table-wrap { height: 245px; overflow: auto; scrollbar-color: #b9c5cd #f0eee8; }
.fx-panel table { width: 100%; border-collapse: collapse; }
th { position: sticky; top: 0; z-index: 2; padding: 8px 11px; background: #eef2f5; border-bottom: 1px solid var(--line); color: var(--muted); text-align: right; font-size: 7px; }
th:first-child, td:first-child { text-align: left; }
td { padding: 7px 11px; border-bottom: 1px solid #ebe7df; text-align: right; font: 9px var(--mono); }
td:first-child { color: var(--blue); font-weight: 850; }
td:last-child { color: var(--muted); }

.fuel-panel, .macro-panel, .status-panel { height: 230px; }
.fuel-tabs { display: flex !important; gap: 2px !important; }
.fuel-tabs button { border: 0; padding: 6px 9px; background: #edf1f4; color: var(--muted); font-size: 7px; font-weight: 850; cursor: pointer; }
.fuel-tabs button.active { background: var(--blue); color: #fff; }
.fuel-summary { min-height: 48px; display: flex; align-items: baseline; gap: 5px; padding: 10px 14px 0; }
.fuel-summary strong { color: var(--navy); font: 700 24px var(--numbers); font-variant-numeric: tabular-nums; }
.fuel-summary span { margin-left: 5px; color: var(--muted); font-size: 7px; font-weight: 800; }
.fuel-summary b { margin-left: auto; font: 800 9px var(--mono); color: var(--green); }
.fuel-chart { display: block; width: 100%; height: 134px; }
.fuel-line { fill: none; stroke: var(--orange); stroke-width: 2.5; }
.fuel-area { fill: url(#fuelArea); }
.fuel-dot { fill: var(--yellow); stroke: #fff; stroke-width: 3; }
.macro-panel { position: relative; }
.inflation-gauge { padding: 24px 18px 14px; }
.gauge-track { height: 9px; position: relative; background: linear-gradient(90deg,#d7e0e7 0 35%,rgba(22,138,97,.55) 35% 65%,#e7c9cf 65% 100%); }
.gauge-track i { position: absolute; top: -6px; width: 3px; height: 21px; background: var(--navy); }
.gauge-labels { display: flex; justify-content: space-between; margin-top: 8px; color: var(--muted); font-size: 7px; font-weight: 800; }
.gauge-labels b { color: var(--green); }
.macro-grid { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); margin-top: 4px; }
.macro-grid div { padding: 13px 16px; }
.macro-grid div + div { border-left: 1px solid var(--line); }
.macro-grid b { display: block; color: var(--navy); font: 700 21px var(--numbers); font-variant-numeric: tabular-nums; }
.macro-grid small { color: var(--muted); font-size: 7px; font-weight: 800; }
.status-panel { position: relative; }
.source-status { padding: 3px 12px 30px; }
.source-row { display: grid; grid-template-columns: 9px 1fr auto; gap: 7px; align-items: center; padding: 5px 0; border-bottom: 1px solid #ebe7df; font-size: 7px; font-weight: 800; }
.source-row i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(22,138,97,.1); }
.source-row.bad i { background: var(--red); box-shadow: none; }
.source-row b { color: var(--muted); font-size: 7px; }
.status-panel footer { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; padding: 7px 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 7px; font-weight: 800; background: #fff; }
.status-panel footer b { color: var(--navy); }

.data-grid { grid-template-columns: 1fr; }
.stats-panel { height: 365px; }
.energy-kpis { display: grid; grid-template-columns: repeat(4,1fr); border-bottom: 1px solid var(--line); }
.energy-kpis div { padding: 10px 15px; border-right: 1px solid var(--line); }
.energy-kpis div:last-child { border-right: 0; }
.energy-kpis b { color: var(--navy); font: 700 19px var(--numbers); font-variant-numeric: tabular-nums; }
.energy-kpis small { margin-left: 5px; color: var(--muted); font-size: 7px; font-weight: 800; }
.energy-legend { display: flex; gap: 18px; padding: 8px 16px 0; color: var(--muted); font-size: 7px; font-weight: 850; }
.energy-legend span::before { content: ""; display: inline-block; width: 14px; height: 2px; margin-right: 5px; vertical-align: middle; }
.energy-legend .bns-consumption::before { background: var(--blue); }
.energy-legend .bns-production::before { background: var(--cyan); }
.energy-legend .bns-imports::before { background: var(--yellow); }
.bns-chart { display: block; width: 100%; height: 210px; }
.bns-line-consumption, .bns-line-production, .bns-line-imports { fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.bns-line-consumption { stroke: var(--blue); }
.bns-line-production { stroke: var(--cyan); }
.bns-line-imports { stroke: #c79a0a; }

.footer { max-width: 1560px; margin: 0 auto 15px; padding: 14px 5px; display: flex; justify-content: space-between; border-top: 1px solid var(--line); color: var(--muted); font-size: 7px; font-weight: 800; letter-spacing: .08em; }
.footer a { color: var(--blue); }

@media (max-width: 1100px) {
  .metric-strip { grid-template-columns: repeat(4,1fr); }
  .primary-grid, .secondary-grid { grid-template-columns: 1fr; }
  .lower-grid { grid-template-columns: 1fr 1fr; }
  .status-panel { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  .terminal-bar { padding-inline: 12px; }
  .terminal-bar nav a { padding-inline: 6px; font-size: 8px; }
  .clock b { display: none; }
  .language-switch { padding-left: 3px; }
  .metric-strip { grid-template-columns: repeat(2,1fr); }
  .primary-grid, .secondary-grid, .lower-grid { grid-template-columns: 1fr; }
  .status-panel { grid-column: auto; }
  .metric-strip strong { font-size: 21px; }
  .line-chart { height: 270px; }
  .power-panel { height: 390px; }
  .map-panel { height: 505px; }
  .country, .city-layer { left: 50%; }
  .flow::after { width: 28px; }
  .fx-majors { grid-template-columns: repeat(3,1fr); }
  .fx-major:nth-child(n+4) { display: none; }
  .footer span:nth-child(2) { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto; } }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
