:root {
  --bg-1: #f8f5ef;
  --bg-2: #e8f1ef;
  --text: #1a1f1d;
  --muted: #4e5a57;
  --card: #ffffff;
  --line: rgba(28, 37, 34, 0.12);
  --accent: #0f7a62;
  --accent-2: #203f57;
  --shadow: 0 10px 30px rgba(26, 31, 29, 0.08);
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 0%, var(--bg-2), transparent 40%),
    linear-gradient(180deg, var(--bg-1), #f4ede3 65%, #e9f0ea);
  min-height: 100vh;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.page {
  width: min(100vw, calc(100vh * 16 / 9));
  margin: 0 auto;
  padding: 0.4rem 0.5rem;
  height: min(100vh, calc(100vw * 9 / 16));
  display: grid;
  grid-template-rows: 1fr;
  gap: 0;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.hero,
.footnote {
  display: none;
}

.hero h1 { margin: 0; font-size: clamp(1.05rem, 1.35vw, 1.45rem); line-height: 1.08; }
.eyebrow { text-transform: uppercase; font-size: 0.68rem; letter-spacing: 0.08em; color: var(--accent); margin: 0 0 0.2rem; }
.subtitle { margin: 0.18rem 0 0; color: var(--muted); font-size: 0.8rem; line-height: 1.2; }

.actions {
  margin-top: 0.3rem;
  display: flex;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
}

button {
  border: 1px solid transparent;
  background: var(--accent);
  color: white;
  border-radius: 999px;
  padding: 0.38rem 0.8rem;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.82rem;
}

button:hover { filter: brightness(1.05); }
#status { margin: 0; font-size: 0.8rem; color: var(--muted); }

.page-tabs {
  margin-top: 0.25rem;
  display: flex;
  gap: 0.35rem;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: var(--accent-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.33rem 0.68rem;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.8rem;
}

.tab-btn.active {
  background: var(--accent-2);
  color: #fff;
  border-color: var(--accent-2);
}

.main-blocks { margin-top: 0; min-height: 0; height: 100%; }
.page-panel { display: none; }
.page-panel.active {
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) minmax(300px, 1fr);
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.4rem;
  min-height: 0;
  height: 100%;
}

#page-electricity.page-panel.active {
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 1fr);
}

#page-electricity .block-demand {
  grid-column: 1;
  grid-row: 1;
}

#page-electricity .block-wholesale,
#page-electricity .block-retail {
  display: none;
}

#page-gas.page-panel.active {
  grid-template-columns: minmax(0, 1.75fr) minmax(420px, 1.25fr);
}

#page-gas .block-wholesale .cards,
#page-gas .block-retail .cards {
  overflow-y: auto;
  padding-right: 0.2rem;
}

#page-gas .block-demand .cards {
  grid-template-columns: 1fr;
  height: 100%;
}

#page-gas .card[data-card-id="nlGasImport"] {
  height: 100%;
  display: flex;
  flex-direction: column;
}

#page-gas .card[data-card-id="nlGasImport"] .flow-map {
  flex: 1;
  min-height: 360px;
  height: 100%;
}

#page-gas .block-wholesale {
  grid-column: 2;
  grid-row: 1 / span 2;
}

#page-gas .block-retail {
  display: none;
}

.block {
  border-top: 2px solid var(--line);
  padding-top: 0.32rem;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.block-title { margin: 0 0 0.25rem; font-size: 0.92rem; color: #2e3935; }

.block-demand {
  grid-column: 1;
  grid-row: 1 / span 2;
}

.block-wholesale {
  grid-column: 2;
  grid-row: 1;
}

.block-retail {
  grid-column: 2;
  grid-row: 2;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
  gap: 0.38rem;
  min-height: 0;
  overflow: hidden;
  padding-right: 0;
}

.block-demand .cards {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.block-wholesale .cards,
.block-retail .cards {
  grid-template-columns: 1fr;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 0.52rem;
  min-height: 0;
  overflow: hidden;
}

.card.card-wide { grid-column: 1 / -1; }
.card-title { margin: 0; font-size: 0.94rem; color: #2e3935; line-height: 1.2; }
.card-value { margin: 0.3rem 0 0.15rem; font-size: 1.28rem; font-weight: 700; line-height: 1.12; }
.card-meta { margin: 0; color: var(--muted); font-size: 0.78rem; line-height: 1.2; }
.card-source { display: inline-block; margin-top: 0.33rem; color: var(--accent); text-decoration: none; font-weight: 600; font-size: 0.7rem; }
.card-source:hover { text-decoration: underline; }

.dayahead-chart,
.flow-map,
.gas-flow-map {
  margin-top: 0.28rem;
  width: 100%;
  min-height: 125px;
  height: min(24vh, 220px);
  height: auto;
  display: block;
  border-top: 1px solid var(--line);
  padding-top: 0.24rem;
}

.mix-embed {
  margin-top: 0.8rem;
  width: 100%;
  min-height: 360px;
  height: 360px;
  display: block;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.dayahead-plot-bg { fill: rgba(15, 122, 98, 0.04); }
.dayahead-grid { stroke: rgba(26, 31, 29, 0.12); stroke-width: 1; }
.dayahead-axis { stroke: rgba(26, 31, 29, 0.45); stroke-width: 1; }
.dayahead-axis-label { fill: var(--muted); font-size: 15px; }
.dayahead-line { fill: none; stroke: var(--accent); stroke-width: 2; }
.dayahead-now-line { stroke: #111; stroke-width: 2; stroke-dasharray: 4 4; opacity: 0.85; }
.dayahead-now-label { fill: #111; font-size: 13px; font-weight: 700; }

.flow-map-line { stroke-linecap: round; opacity: 0.9; }
.flow-map-line-import { stroke: #1a1f1d; }
.flow-map-line-export { stroke: #0f7a62; }
.flow-sankey-band { opacity: 0.72; stroke: rgba(255, 255, 255, 0.45); stroke-width: 0.9; }
.flow-sankey-band-import { fill: rgba(26, 31, 29, 0.45); }
.flow-sankey-band-export { fill: rgba(15, 122, 98, 0.55); }
.flow-map-country-shape { fill: #f5f8f7; stroke: #dbe6e1; stroke-width: 1.2; }
.flow-map-country-shape-nl { fill: #eefaf6; stroke: #b7ddd1; }
.flow-map-country-code { fill: #5a6a64; font-size: 12px; font-weight: 700; }
.flow-map-country-name { fill: #8ba099; font-size: 11px; }
.flow-map-node { fill: #f2faf7; stroke: var(--accent); }
.flow-map-node-lng { fill: #ffe7c2; stroke: #d48b1d; }
.flow-map-node-storage { fill: #e6f0ff; stroke: #2d7ff9; }
.flow-map-node-nl { fill: var(--accent); }
.flow-map-label { fill: #2e3935; font-size: 13px; font-weight: 700; }
.flow-map-label-nl { fill: #fff; font-size: 13px; font-weight: 700; }
.flow-map-country { fill: var(--muted); font-size: 12px; }
.flow-map-value { fill: var(--muted); font-size: 17px; }
.flow-map-value-import { fill: #111; }
.flow-map-value-export { fill: #0f7a62; }
.flow-map-value { paint-order: stroke; stroke: rgba(255, 255, 255, 0.92); stroke-width: 3px; stroke-linejoin: round; }

.gas-node { fill: #f2faf7; stroke: var(--accent); }
.gas-node-major { fill: var(--accent); stroke: var(--accent-2); }
.gas-node-label { fill: #2e3935; font-size: 13px; font-weight: 600; }
.gas-flow-line { stroke-linecap: round; opacity: 0.9; }
.gas-flow-in { stroke: #14546a; }
.gas-flow-out { stroke: #2f7f45; }
.gas-flow-value { fill: #273533; font-size: 13px; font-weight: 600; }
.gas-flow-note { fill: var(--muted); font-size: 13px; }

.card-series {
  margin-top: 0.32rem;
  border-top: 1px solid var(--line);
  padding-top: 0.25rem;
  max-height: none;
  overflow: visible;
}

.card-series-row { font-size: 0.68rem; color: var(--muted); line-height: 1.16; padding: 0.06rem 0; }
.card-series-label { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-series-bar-wrap { display: block; margin-top: 0.18rem; width: 100%; background: rgba(15, 122, 98, 0.12); border-radius: 999px; height: 6px; }
.card-series-bar { display: block; height: 6px; border-radius: 999px; background: var(--accent); }

.pie-wrap { display: grid; grid-template-columns: 220px 1fr; gap: 0.7rem; margin-top: 0.6rem; align-items: center; }
.pie-chart { width: 100%; max-width: 220px; height: auto; }
.pie-hole { fill: #f8fbfa; stroke: #d9e8e2; stroke-width: 1; }
.pie-center-label { fill: #486157; font-size: 14px; font-weight: 700; }
.pie-legend { display: grid; gap: 0.22rem; }
.pie-legend-item { display: flex; align-items: center; gap: 0.42rem; font-size: 0.82rem; color: var(--muted); }
.pie-legend-dot { width: 10px; height: 10px; border-radius: 999px; display: inline-block; }
.pie-legend-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.footnote { margin-top: 0; color: var(--muted); font-size: 0.64rem; opacity: 0.9; }

html.mode-landscape,
html.mode-landscape body {
  width: 100%;
  height: 100%;
}

html.mode-landscape body {
  overflow: hidden;
}

html.mode-landscape .page {
  width: 100vw;
  max-width: none;
  min-height: 100vh;
  padding: 0.55rem 0.75rem;
  overflow: hidden;
}

html.mode-widget .page {
  width: 100vw;
  max-width: none;
  min-height: 100vh;
  padding: 0.45rem 0.55rem;
}

html.mode-widget .eyebrow,
html.mode-widget .subtitle,
html.mode-widget .actions,
html.mode-widget .page-tabs,
html.mode-widget .footnote {
  display: none;
}

html.mode-widget .hero h1 {
  font-size: clamp(1.15rem, 1.8vw, 1.7rem);
}

html.mode-widget .main-blocks {
  margin-top: 0.6rem;
}

html.mode-widget .page-panel.active {
  gap: 0.7rem;
}

html.mode-widget .cards {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.5rem;
}

html.mode-widget .card {
  padding: 0.58rem;
}

html.mode-widget .card-value {
  margin: 0.38rem 0 0.2rem;
  font-size: 1.04rem;
}

html.mode-widget .dayahead-chart,
html.mode-widget .flow-map,
html.mode-widget .gas-flow-map,
html.mode-widget .mix-embed {
  min-height: 130px;
  height: min(18vh, 170px);
}

@media (orientation: portrait) {
  html.mode-landscape .page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vh;
    height: 100vw;
    transform-origin: top left;
    transform: rotate(90deg) translateY(-100%);
  }
}

@media (max-width: 760px) {
  body { overflow: auto; }
  .page {
    height: auto;
    min-height: 100vh;
    overflow: visible;
    width: 100%;
    border-radius: 0;
    border: none;
    grid-template-rows: 1fr;
  }
  .page-panel.active {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }
  .block-demand,
  .block-wholesale,
  .block-retail {
    grid-column: auto;
    grid-row: auto;
  }
  .block-demand .cards {
    grid-template-columns: 1fr;
  }
  .cards { grid-template-columns: 1fr; }
}
