:root {
  color-scheme: dark;
  --bg: #07100d;
  --panel: rgba(10, 24, 18, 0.76);
  --panel-strong: rgba(13, 31, 23, 0.92);
  --line: rgba(161, 207, 151, 0.24);
  --text: #f2f8ef;
  --muted: #b0c2b1;
  --cyan: #7ed6c8;
  --green: #9ce071;
  --green-deep: #426c3a;
  --red: #e96b58;
  --amber: #dca85e;
  --soil: #7f684d;
  --shadow: 0 24px 64px rgba(0, 0, 0, 0.42);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 56% 42%, rgba(156, 224, 113, 0.12), transparent 32%),
    radial-gradient(circle at 16% 76%, rgba(220, 168, 94, 0.11), transparent 30%),
    linear-gradient(135deg, #0d1a14 0%, #07100d 48%, #030705 100%);
  color: var(--text);
}

button,
select,
input {
  font: inherit;
}

.shell {
  position: relative;
  width: 100vw;
  height: 100vh;
}

.map-stage,
.deck-host {
  position: absolute;
  inset: 0;
}

.deck-host canvas {
  outline: none;
}

.scanline {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(156, 224, 113, 0.03) 1px, transparent 1px);
  background-size: 100% 5px, 52px 100%;
  mix-blend-mode: soft-light;
  opacity: 0.26;
}

.map-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(4, 9, 7, 0.66), transparent 34%, transparent 72%, rgba(4, 9, 7, 0.25)),
    radial-gradient(circle at 50% 50%, transparent 43%, rgba(3, 7, 5, 0.58) 100%);
}

.hud {
  position: absolute;
  top: 24px;
  left: 24px;
  z-index: 3;
  width: min(390px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  display: grid;
  gap: 14px;
  overflow: auto;
  scrollbar-width: thin;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(15, 38, 27, 0.84), rgba(9, 20, 16, 0.66)),
    radial-gradient(circle at 18% 16%, rgba(156, 224, 113, 0.17), transparent 30%);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand-copy {
  min-width: 0;
  flex: 1;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 1px solid rgba(156, 224, 113, 0.72);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(242, 248, 239, 0.9) 0 9%, transparent 10% 24%, rgba(156, 224, 113, 0.38) 25% 48%, transparent 49%),
    conic-gradient(from 40deg, rgba(126, 214, 200, 0), rgba(126, 214, 200, 0.74), rgba(220, 168, 94, 0.9), rgba(156, 224, 113, 0.86), rgba(126, 214, 200, 0));
  box-shadow: 0 0 28px rgba(156, 224, 113, 0.22);
  animation: breathe 3.8s ease-in-out infinite;
}

.brand h1 {
  margin: 0;
  font-size: 1.28rem;
  line-height: 1;
  letter-spacing: 0;
}

.brand p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.about-button {
  flex: 0 0 auto;
  border: 1px solid rgba(156, 224, 113, 0.32);
  border-radius: 999px;
  padding: 8px 11px;
  background: rgba(156, 224, 113, 0.1);
  color: var(--text);
  cursor: pointer;
  font-size: 0.78rem;
  white-space: nowrap;
  box-shadow: inset 0 0 18px rgba(156, 224, 113, 0.08);
}

.about-button:hover,
.about-button:focus-visible {
  border-color: rgba(156, 224, 113, 0.62);
  outline: none;
  box-shadow: 0 0 22px rgba(156, 224, 113, 0.18);
}

.metric-strip,
.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  border-radius: 8px;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.metric-strip div {
  min-width: 0;
  padding: 14px;
  border-right: 1px solid rgba(161, 207, 151, 0.13);
}

.metric-strip div:last-child {
  border-right: 0;
}

.metric-strip span,
.selected dt,
.control-row label,
.slider-field label,
.selected-kicker {
  color: var(--muted);
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.metric-strip strong {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1rem;
}

.panel {
  padding: 16px;
}

.mix-panel {
  padding: 14px;
}

.mix-panel .selected-chart {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.controls {
  display: grid;
  gap: 14px;
}

.control-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  align-items: center;
  gap: 12px;
}

select {
  min-width: 0;
  width: 100%;
  border: 1px solid rgba(161, 207, 151, 0.28);
  border-radius: 6px;
  padding: 9px 10px;
  background: rgba(6, 16, 12, 0.92);
  color: var(--text);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border: 1px solid rgba(161, 207, 151, 0.28);
  border-radius: 8px;
  overflow: hidden;
}

.segmented button {
  min-height: 42px;
  border: 0;
  background: rgba(6, 17, 12, 0.82);
  color: var(--muted);
  cursor: pointer;
}

.segmented button.active {
  background: linear-gradient(135deg, rgba(156, 224, 113, 0.22), rgba(126, 214, 200, 0.1));
  color: var(--text);
  box-shadow: inset 0 0 20px rgba(156, 224, 113, 0.12);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  cursor: pointer;
}

.toggle input {
  position: absolute;
  opacity: 0;
}

.toggle span {
  width: 46px;
  height: 26px;
  padding: 3px;
  border: 1px solid rgba(161, 207, 151, 0.3);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.46);
}

.toggle span::before {
  content: "";
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 16px rgba(233, 107, 88, 0.42);
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.toggle input:checked + span::before {
  transform: translateX(20px);
  background: var(--green);
  box-shadow: 0 0 20px rgba(156, 224, 113, 0.46);
}

.slider-field {
  display: grid;
  gap: 8px;
}

.slider-field > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

output {
  color: var(--cyan);
  font-size: 0.85rem;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--green);
}

.selected {
  background: var(--panel-strong);
}

.selected p {
  margin: 0 0 7px;
}

.selected h2 {
  margin: 0 0 16px;
  font-size: 1.28rem;
  line-height: 1.15;
}

.selected dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.selected dl div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid rgba(161, 207, 151, 0.13);
  padding-bottom: 9px;
}

.selected dl div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.selected dd {
  margin: 0;
  text-align: right;
  color: var(--text);
}

.selected-chart {
  display: grid;
  gap: 11px;
  margin-top: 15px;
  padding-top: 13px;
  border-top: 1px solid rgba(161, 207, 151, 0.16);
}

.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.chart-head strong {
  min-width: 0;
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.25;
}

.chart-head span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.72rem;
}

.chart-body {
  display: grid;
  grid-template-columns: 86px 1fr;
  align-items: center;
  gap: 13px;
}

.pie-chart {
  position: relative;
  width: 86px;
  height: 86px;
  border: 1px solid rgba(242, 248, 239, 0.22);
  border-radius: 50%;
  box-shadow:
    0 0 28px rgba(126, 214, 200, 0.14),
    inset 0 0 14px rgba(0, 0, 0, 0.28);
}

.pie-chart::after {
  content: "";
  position: absolute;
  inset: 24px;
  border-radius: 50%;
  background: rgba(9, 22, 16, 0.92);
  border: 1px solid rgba(242, 248, 239, 0.12);
}

.pie-chart span {
  position: absolute;
  inset: 30px 7px auto;
  z-index: 1;
  overflow: hidden;
  color: var(--text);
  font-size: 0.58rem;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-body ul {
  display: grid;
  gap: 6px;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chart-body li {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.chart-body li span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-body li strong {
  color: var(--text);
  font-size: 0.76rem;
}

.chart-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.chart-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.legend {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid rgba(161, 207, 151, 0.16);
  border-radius: 8px;
  background: rgba(8, 18, 13, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  color: var(--muted);
  font-size: 0.82rem;
}

.legend h3 {
  margin: 0;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 700;
}

.legend p {
  margin: 0 0 4px;
  color: rgba(237, 253, 248, 0.66);
  line-height: 1.35;
}

.legend div {
  display: grid;
  grid-template-columns: 12px 78px 1fr;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.legend strong {
  color: var(--text);
  font-weight: 700;
}

.legend div span:last-child {
  min-width: 0;
  line-height: 1.25;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.swatch.red {
  background: var(--red);
  box-shadow: 0 0 12px var(--red);
}

.swatch.cyan {
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
}

.swatch.green {
  background: var(--green);
  box-shadow: 0 0 12px var(--green);
}

.swatch.amber {
  background: var(--amber);
  box-shadow: 0 0 12px var(--amber);
}

.swatch.national {
  background: var(--text);
  box-shadow: 0 0 12px rgba(242, 248, 239, 0.72);
}

.swatch.solar {
  background: #f4cd65;
  box-shadow: 0 0 12px rgba(244, 205, 101, 0.78);
}

.swatch.wind {
  background: #7ed6c8;
  box-shadow: 0 0 12px rgba(126, 214, 200, 0.78);
}

.swatch.hydro {
  background: #58a0da;
  box-shadow: 0 0 12px rgba(88, 160, 218, 0.78);
}

.swatch.bio {
  background: #9ce071;
  box-shadow: 0 0 12px rgba(156, 224, 113, 0.78);
}

.swatch.geo {
  background: #e2875b;
  box-shadow: 0 0 12px rgba(226, 135, 91, 0.78);
}

.swatch.marine {
  background: #76c7e8;
  box-shadow: 0 0 12px rgba(118, 199, 232, 0.78);
}

.source-line {
  color: rgba(237, 253, 248, 0.48);
  font-size: 0.72rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(3, 9, 6, 0.7);
  backdrop-filter: blur(14px);
}

.modal-backdrop[hidden] {
  display: none;
}

.about-modal {
  position: relative;
  width: min(760px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  border: 1px solid rgba(161, 207, 151, 0.3);
  border-radius: 8px;
  background:
    linear-gradient(150deg, rgba(16, 35, 26, 0.97), rgba(7, 15, 11, 0.97)),
    radial-gradient(circle at 84% 8%, rgba(156, 224, 113, 0.18), transparent 34%);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.6);
  padding: 26px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(161, 207, 151, 0.24);
  border-radius: 50%;
  background: rgba(7, 16, 12, 0.8);
  color: var(--text);
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
}

.modal-close:hover,
.modal-close:focus-visible {
  outline: none;
  border-color: rgba(233, 107, 88, 0.65);
  box-shadow: 0 0 18px rgba(233, 107, 88, 0.22);
}

.modal-kicker {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.about-modal h2 {
  margin: 0 42px 12px 0;
  font-size: 1.7rem;
  line-height: 1.05;
}

.about-modal p {
  color: rgba(237, 253, 248, 0.76);
  line-height: 1.5;
}

#about-summary {
  margin: 0 0 18px;
  max-width: 64ch;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.about-grid article,
.about-definitions {
  border: 1px solid rgba(161, 207, 151, 0.16);
  border-radius: 8px;
  background: rgba(7, 17, 12, 0.52);
}

.about-grid article {
  padding: 14px;
}

.about-grid h3 {
  margin: 0 0 7px;
  color: var(--text);
  font-size: 0.98rem;
}

.about-grid p {
  margin: 0;
  font-size: 0.9rem;
}

.about-definitions {
  display: grid;
  gap: 0;
  margin: 14px 0 0;
  padding: 0 14px;
}

.about-definitions div {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(161, 207, 151, 0.13);
}

.about-definitions div:last-child {
  border-bottom: 0;
}

.about-definitions dt {
  color: var(--green);
  font-weight: 700;
}

.about-definitions dd {
  margin: 0;
  color: rgba(237, 253, 248, 0.75);
  line-height: 1.4;
}

.site-popup {
  position: fixed;
  z-index: 8;
  width: min(340px, calc(100vw - 36px));
  overflow: hidden;
  border: 1px solid rgba(161, 207, 151, 0.34);
  border-left: 3px solid var(--green);
  border-radius: 8px;
  background:
    linear-gradient(150deg, rgba(18, 39, 29, 0.97), rgba(7, 14, 11, 0.98)),
    radial-gradient(circle at 94% 8%, rgba(156, 224, 113, 0.16), transparent 34%);
  box-shadow: 0 26px 72px rgba(0, 0, 0, 0.56);
  color: var(--text);
  backdrop-filter: blur(16px);
}

.site-popup[hidden] {
  display: none;
}

.site-photo {
  position: relative;
  height: 150px;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(126, 214, 200, 0.18), rgba(156, 224, 113, 0.14)),
    rgba(7, 14, 11, 0.94);
}

.site-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.site-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 42%, rgba(4, 9, 7, 0.76));
  pointer-events: none;
}

.site-photo figcaption {
  position: absolute;
  right: 10px;
  bottom: 8px;
  z-index: 1;
  color: rgba(242, 248, 239, 0.7);
  font-size: 0.64rem;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
}

.site-photo.image-missing {
  display: grid;
  place-items: center;
}

.site-photo.image-missing::before {
  content: "Photo indisponible";
  color: var(--muted);
  font-size: 0.82rem;
}

.site-popup-body {
  display: grid;
  gap: 10px;
  padding: 13px;
}

.site-popup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.site-source {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.site-source::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--source-color);
  box-shadow: 0 0 12px var(--source-color);
}

.site-popup-close {
  width: 28px;
  height: 28px;
  border: 1px solid rgba(161, 207, 151, 0.22);
  border-radius: 50%;
  background: rgba(7, 16, 12, 0.82);
  color: var(--text);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.site-popup-close:hover,
.site-popup-close:focus-visible {
  outline: none;
  border-color: rgba(233, 107, 88, 0.65);
  box-shadow: 0 0 18px rgba(233, 107, 88, 0.22);
}

.site-popup-body > strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 0.98rem;
  line-height: 1.2;
}

.site-popup dl {
  display: grid;
  gap: 0;
  margin: 0;
}

.site-popup dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-top: 1px solid rgba(161, 207, 151, 0.12);
}

.site-popup dt {
  color: var(--muted);
  font-size: 0.74rem;
}

.site-popup dd {
  margin: 0;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: right;
}

.deck-tooltip {
  width: 310px;
  max-width: min(310px, calc(100vw - 24px));
  border: 1px solid rgba(161, 207, 151, 0.38);
  border-left: 3px solid var(--green);
  border-radius: 8px;
  background:
    linear-gradient(150deg, rgba(18, 39, 29, 0.96), rgba(7, 14, 11, 0.96)),
    radial-gradient(circle at 94% 8%, rgba(156, 224, 113, 0.16), transparent 34%);
  color: var(--text);
  padding: 12px;
  box-shadow: 0 20px 54px rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(14px);
}

.tooltip-photo {
  position: relative;
  height: 122px;
  margin: 0 0 11px;
  overflow: hidden;
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(126, 214, 200, 0.18), rgba(156, 224, 113, 0.14)),
    rgba(7, 14, 11, 0.94);
}

.tooltip-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tooltip-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 36%, rgba(4, 9, 7, 0.82));
  pointer-events: none;
}

.tooltip-photo figcaption {
  position: absolute;
  right: 9px;
  bottom: 8px;
  left: 9px;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  color: rgba(242, 248, 239, 0.86);
  font-size: 0.7rem;
  line-height: 1.1;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.68);
}

.tooltip-photo figcaption small {
  flex: 0 0 auto;
  color: rgba(242, 248, 239, 0.62);
  font-size: 0.62rem;
}

.deck-tooltip strong {
  display: block;
  margin-bottom: 9px;
  font-size: 0.95rem;
  line-height: 1.2;
}

.deck-tooltip span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
  padding: 6px 0;
  border-top: 1px solid rgba(161, 207, 151, 0.12);
}

.deck-tooltip em {
  color: var(--text);
  font-style: normal;
  font-weight: 700;
  text-align: right;
}

.deck-tooltip .tooltip-note {
  display: block;
  margin-top: 7px;
  padding: 8px 9px;
  border: 1px solid rgba(161, 207, 151, 0.14);
  border-radius: 6px;
  background: rgba(156, 224, 113, 0.08);
  color: rgba(242, 248, 239, 0.72);
  font-size: 0.74rem;
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(0.96);
    filter: brightness(0.9);
  }
  50% {
    transform: scale(1.05);
    filter: brightness(1.2);
  }
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .shell {
    min-height: 100vh;
    height: 100svh;
  }

  .hud {
    top: auto;
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
    max-height: 48vh;
  }

  .brand,
  .panel {
    padding: 13px;
  }

  .about-button {
    padding: 7px 9px;
    font-size: 0.72rem;
  }

  .brand h1,
  .selected h2 {
    font-size: 1.05rem;
  }

  .metric-strip div {
    padding: 11px;
  }

  .modal-backdrop {
    padding: 12px;
  }

  .about-modal {
    max-height: calc(100vh - 24px);
    padding: 20px;
  }

  .about-modal h2 {
    font-size: 1.3rem;
  }

  .about-grid,
  .about-definitions div {
    grid-template-columns: 1fr;
  }

  .about-definitions div {
    gap: 5px;
  }
}
