/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface: #ffffff;
  --surface-2: #f7f7f4;
  --surface-3: #ecece7;
  --border: #e2e1dc;
  --border-strong: #cfcec7;
  --text: #17181a;
  --text-2: #55565a;
  --text-3: #85868a;
  --accent: #1f6feb;
  --accent-soft: rgba(31, 111, 235, 0.12);
  --focus: #1f6feb;
  --ring: #ffffff; /* gap ring around overlapping marks */
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 6px 24px rgba(0, 0, 0, 0.08);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.08);
  --map-bg: #fafaf8;
  --radius: 10px;
  --panel-w: 360px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1012;
    --surface: #17181b;
    --surface-2: #1d1e22;
    --surface-3: #26272c;
    --border: #2b2c31;
    --border-strong: #3a3b41;
    --text: #ecedef;
    --text-2: #b3b4b9;
    --text-3: #85868c;
    --accent: #5b9bff;
    --accent-soft: rgba(91, 155, 255, 0.16);
    --focus: #5b9bff;
    --ring: #121212;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 28px rgba(0, 0, 0, 0.45);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --map-bg: #0e0e0e;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1012;
  --surface: #17181b;
  --surface-2: #1d1e22;
  --surface-3: #26272c;
  --border: #2b2c31;
  --border-strong: #3a3b41;
  --text: #ecedef;
  --text-2: #b3b4b9;
  --text-3: #85868c;
  --accent: #5b9bff;
  --accent-soft: rgba(91, 155, 255, 0.16);
  --focus: #5b9bff;
  --ring: #121212;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 28px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --map-bg: #0e0e0e;
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
  overflow: hidden;
}

h1,
h2 {
  margin: 0;
}

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

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: var(--panel-w) 1fr;
  height: 100vh;
  height: 100dvh;
}

.panel {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  z-index: 3;
}

.panel-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 20px 14px;
}

h1 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

.lede {
  margin: 6px 0 0;
  color: var(--text-2);
  font-size: 13px;
}

.header-actions {
  display: flex;
  gap: 4px;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 2px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scrollbar-width: thin;
}
.panel-body > * {
  flex-shrink: 0;
}

.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: var(--map-bg);
  overflow: hidden;
}

.view,
.view.maplibregl-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ---------- Controls ---------- */
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}
.icon-btn.small {
  width: 30px;
  height: 30px;
  border-color: var(--border);
  background: var(--surface);
}

.icon-sun {
  display: none;
}
:root[data-resolved-theme="dark"] .icon-sun {
  display: block;
}
:root[data-resolved-theme="dark"] .icon-moon {
  display: none;
}

.icon-pause {
  display: none;
}
.is-playing .icon-pause {
  display: block;
}
.is-playing .icon-play {
  display: none;
}

.panel-toggle {
  display: none;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 3px;
  gap: 3px;
  background: var(--surface-3);
  border-radius: 9px;
}
.segmented button {
  border: 0;
  background: transparent;
  border-radius: 7px;
  padding: 6px 8px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
}
.segmented button[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 11px;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
}
.btn:hover {
  border-color: var(--border-strong);
}
.btn .icon {
  width: 16px;
  height: 16px;
}
.btn.floating {
  box-shadow: var(--shadow);
}

.link-btn {
  border: 0;
  background: none;
  padding: 2px 4px;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 4px;
}
.link-btn:hover {
  text-decoration: underline;
}

/* Search */
.search {
  position: relative;
}
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  width: 16px;
  height: 16px;
  pointer-events: none;
}
.search input {
  width: 100%;
  padding: 8px 10px 8px 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}
.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface);
}
.search-results {
  position: absolute;
  z-index: 10;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 320px;
  overflow-y: auto;
}
.search-results li {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 7px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.search-results li[aria-selected="true"],
.search-results li:hover {
  background: var(--surface-3);
}
.search-results .sr-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-results .sr-sub {
  display: block;
  font-size: 12px;
  color: var(--text-3);
}
.search-results .sr-mec {
  color: var(--text-2);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.search-results .empty {
  display: block;
  color: var(--text-3);
  cursor: default;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
}

/* KPIs */
.kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.kpi {
  padding: 10px 12px;
}
.kpi + .kpi {
  border-left: 1px solid var(--border);
}
.kpi-label {
  font-size: 11.5px;
  color: var(--text-2);
  font-weight: 500;
}
.kpi-value {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.kpi-value small {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  margin-left: 2px;
  letter-spacing: 0;
}

/* Groups */
.group-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}
h2 {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
}
.link-actions {
  display: flex;
  gap: 4px;
}
.hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-3);
}

/* Fuel list (legend + filter + breakdown) */
.fuel-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.fuel-row {
  position: relative;
  display: grid;
  grid-template-columns: 16px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 5px 6px;
  border-radius: 7px;
  cursor: pointer;
  user-select: none;
  border: 0;
  background: none;
  width: 100%;
  text-align: left;
}
.fuel-row:hover {
  background: var(--surface-3);
}
.fuel-check {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--swatch);
  background: var(--swatch);
  display: grid;
  place-items: center;
}
.fuel-check svg {
  width: 11px;
  height: 11px;
  stroke: #fff;
  stroke-width: 3;
  fill: none;
}
.fuel-row[aria-pressed="false"] .fuel-check {
  background: transparent;
}
.fuel-row[aria-pressed="false"] .fuel-check svg {
  display: none;
}
.fuel-row[aria-pressed="false"] .fuel-name,
.fuel-row[aria-pressed="false"] .fuel-value {
  color: var(--text-3);
}
.fuel-main {
  min-width: 0;
}
.fuel-name {
  font-size: 13.5px;
  display: block;
}
.fuel-bar {
  display: block;
  height: 3px;
  margin-top: 3px;
  border-radius: 2px;
  background: var(--swatch);
  opacity: 0.85;
  transition: width 240ms ease;
  min-width: 0;
}
.fuel-row[aria-pressed="false"] .fuel-bar {
  opacity: 0.2;
}
.fuel-value {
  font-size: 12.5px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Fields */
.field {
  margin-top: 12px;
}
.field:first-of-type {
  margin-top: 0;
}
.field-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.field-label {
  display: block;
  font-size: 12.5px;
  color: var(--text-2);
  margin-bottom: 6px;
  font-weight: 500;
}
.field-value {
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chips button {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12.5px;
  cursor: pointer;
  color: var(--text-2);
}
.chips button:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.chips button[aria-checked="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
  font-weight: 500;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  background: transparent;
  cursor: pointer;
  --fill: 100%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--surface-3) var(--fill));
}
input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--surface-3) var(--fill));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
  box-shadow: var(--shadow-sm);
}
input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
}

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  font-size: 13px;
  cursor: pointer;
}
.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.switch-track {
  position: relative;
  width: 32px;
  height: 18px;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background 150ms;
  flex: none;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 150ms;
}
.switch input:checked + .switch-track {
  background: var(--accent);
}
.switch input:checked + .switch-track::after {
  transform: translateX(14px);
}
.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.panel-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
}
.panel-footer p {
  margin: 0 0 6px;
}
.panel-footer strong {
  color: var(--text-2);
  font-weight: 600;
}
.source-block {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.panel-footer .source-title {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
}
.source-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.source-list li {
  margin: 0 0 5px;
  line-height: 1.45;
}

/* ---------- Overlays on the stage ---------- */
.map-overlay {
  position: absolute;
  z-index: 2;
}
.top-right {
  top: 12px;
  right: 12px;
}
.view-map ~ .top-right {
  right: 56px; /* clear of the map's navigation control */
}
.app[data-view="bubbles"] .top-right,
.app[data-view="table"] .top-right {
  right: 12px;
}
.app[data-view="table"] .top-right {
  display: none;
}

.size-legend {
  position: absolute;
  z-index: 2;
  left: 12px;
  bottom: 28px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px 6px;
  box-shadow: var(--shadow-sm);
  font-size: 11px;
  color: var(--text-2);
  pointer-events: none;
}
.app[data-view="table"] .size-legend {
  display: none;
}
.size-legend .sl-title {
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 2px;
}
.size-legend svg {
  display: block;
  overflow: visible;
}
.size-legend circle {
  fill: none;
  stroke: var(--text-3);
  stroke-width: 1;
}
.size-legend polyline {
  stroke: var(--text-3);
  stroke-width: 0.75;
  stroke-dasharray: 2 2;
}
.size-legend text {
  fill: var(--text-2);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.bubble-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--text-3);
  pointer-events: none;
  white-space: nowrap;
}

.tooltip {
  position: absolute;
  z-index: 6;
  pointer-events: none;
  min-width: 180px;
  max-width: 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: var(--shadow);
  padding: 9px 11px;
  font-size: 12.5px;
}
.tt-title {
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.3;
  margin-bottom: 4px;
}
.tt-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
  margin-bottom: 6px;
}
.tt-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
}
.tt-grid dt {
  color: var(--text-3);
}
.tt-grid dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.tt-foot {
  margin-top: 6px;
  color: var(--text-3);
  font-size: 11.5px;
}

/* Details card */
.details {
  position: absolute;
  z-index: 5;
  top: 12px;
  left: 12px;
  width: 340px;
  max-height: calc(100% - 24px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 16px;
}
.d-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}
.d-title {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.d-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
}
.d-mec {
  margin-top: 14px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.d-mec small {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  margin-left: 4px;
  letter-spacing: 0;
}
.d-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 14px;
  margin: 12px 0 0;
  font-size: 13px;
}
.d-grid dt {
  color: var(--text-3);
}
.d-grid dd {
  margin: 0;
  word-break: break-word;
}
.d-units {
  margin-top: 14px;
}
.d-units h3 {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  margin: 0 0 6px;
}
.d-units table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.d-units td {
  padding: 4px 0;
  border-top: 1px solid var(--border);
}
.d-units td + td {
  padding-left: 8px;
}
.d-units .muted {
  color: var(--text-3);
}
.d-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.toast {
  position: absolute;
  z-index: 8;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--surface);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow);
  max-width: calc(100% - 32px);
}

.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-3);
  z-index: 9;
  background: var(--map-bg);
}
.loading.is-error {
  color: var(--text);
  padding: 24px;
  text-align: center;
}

/* ---------- Bubble chart ---------- */
.view-bubbles {
  background:
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--text) 7%, transparent) 1px, transparent 0) 0 0 / 22px 22px,
    var(--bg);
  cursor: grab;
  touch-action: none;
  font-family: var(--font);
}
.view-bubbles:active {
  cursor: grabbing;
}
.bubble-group {
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  cursor: zoom-in;
  transition: fill-opacity 150ms;
}
.bubble-group:hover {
  fill-opacity: 0.13;
}
.bubble {
  cursor: pointer;
}
.bubble circle {
  stroke-width: 0.75;
  stroke-opacity: 0.55;
  vector-effect: non-scaling-stroke;
  transition: stroke-width 120ms;
}
.bubble:hover circle {
  stroke: var(--text);
  stroke-opacity: 1;
  stroke-width: 2;
}
.bubble.is-selected circle {
  stroke: var(--text);
  stroke-opacity: 1;
  stroke-width: 2.5;
}
.bubble text {
  pointer-events: none;
  letter-spacing: -0.01em;
}
.bubble .b-name {
  font-weight: 600;
}
.bubble .b-mec {
  font-weight: 450;
  opacity: 0.82;
  font-variant-numeric: tabular-nums;
}
.group-label {
  cursor: zoom-in;
}
.gl-pill {
  fill: var(--surface);
  stroke: var(--border);
  stroke-width: 1;
}
.gl-text {
  font-size: 12px;
  fill: var(--text);
}
.gl-name {
  font-weight: 600;
}
.gl-value {
  font-weight: 450;
  fill: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.bubbles-empty {
  fill: var(--text-3);
  font-size: 14px;
}

/* Layout toggle (bubbles view only) */
.top-right {
  display: flex;
  gap: 8px;
  align-items: center;
}
.layout-toggle {
  display: none;
  padding: 3px;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: var(--shadow);
}
.app[data-view="bubbles"] .layout-toggle {
  display: inline-flex;
}
.layout-toggle button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  border-radius: 6px;
  padding: 4px 10px 4px 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.layout-toggle button .icon {
  width: 16px;
  height: 16px;
}
.layout-toggle button:hover {
  color: var(--text);
}
.layout-toggle button[aria-checked="true"] {
  background: var(--accent-soft);
  color: var(--text);
}

/* ---------- Table ---------- */
.view-table {
  display: flex;
  flex-direction: column;
  background: var(--surface);
}
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.table-caption {
  color: var(--text-2);
  font-size: 13px;
}
.table-scroll {
  flex: 1;
  overflow: auto;
}
table#table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
#table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-2);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
#table th.num {
  text-align: right;
}
#table th[aria-sort]::after {
  content: "";
  display: inline-block;
  margin-left: 4px;
  border: 4px solid transparent;
  vertical-align: middle;
}
#table th[aria-sort="ascending"]::after {
  border-bottom-color: currentColor;
  margin-top: -4px;
}
#table th[aria-sort="descending"]::after {
  border-top-color: currentColor;
  margin-top: 4px;
}
#table td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
#table td.name {
  white-space: normal;
  min-width: 200px;
}
#table tbody tr {
  cursor: pointer;
}
#table tbody tr:hover {
  background: var(--surface-2);
}
#table tbody tr.is-selected {
  background: var(--accent-soft);
}
.fuel-cell {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.table-more {
  padding: 12px 16px;
  color: var(--text-3);
  font-size: 12.5px;
}

/* ---------- MapLibre ---------- */
.maplibregl-ctrl-group {
  background: var(--surface) !important;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm) !important;
}
.maplibregl-ctrl-group button + button {
  border-top-color: var(--border) !important;
}
:root[data-resolved-theme="dark"] .maplibregl-ctrl button .maplibregl-ctrl-icon {
  filter: invert(1);
}
.maplibregl-ctrl-attrib {
  font-size: 11px;
}
:root[data-resolved-theme="dark"] .maplibregl-ctrl-attrib {
  background: rgba(23, 24, 27, 0.75) !important;
  color: var(--text-2);
}
:root[data-resolved-theme="dark"] .maplibregl-ctrl-attrib a {
  color: var(--text-2);
}
:root[data-resolved-theme="dark"] .maplibregl-ctrl-attrib-button {
  filter: invert(1);
}

/* ---------- Small screens ---------- */
.scrim {
  display: none;
}

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .panel {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    position: relative;
  }
  .panel-header {
    padding: 12px 16px;
    align-items: center;
  }
  h1 {
    font-size: 17px;
  }
  .lede {
    display: none;
  }
  .panel-toggle {
    display: inline-grid;
  }
  .panel-body {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: calc(100dvh - 64px);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 4px 16px 16px;
    display: none;
  }
  .app.panel-open .panel-body {
    display: flex;
  }
  .app.panel-open .scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 2;
  }
  .details {
    top: auto;
    bottom: 12px;
    left: 12px;
    right: 12px;
    width: auto;
    max-height: 55%;
  }
  .size-legend {
    bottom: 24px;
    padding: 6px 10px 4px;
  }
  .app.has-details .size-legend {
    display: none;
  }
  .bubble-hint {
    display: none;
  }
  .layout-toggle button {
    padding: 4px 8px;
  }
  .top-right .btn.floating {
    padding: 6px 9px;
  }
  #table td,
  #table th {
    padding: 6px 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* =====================================================================
   Site navigation (shared by both pages)
   ===================================================================== */
:root {
  --bar-neutral: #8e8d87;
  --grid: #e8e7e1;
  --axis-ink: #85868a;
}
:root[data-resolved-theme="dark"] {
  --bar-neutral: #77766f;
  --grid: #2a2b2f;
  --axis-ink: #8c8d92;
}

.site-nav {
  display: flex;
  gap: 2px;
  margin: 14px 20px 0;
  padding: 3px;
  border-radius: 9px;
  background: var(--surface-3);
}
.site-nav a {
  flex: 1;
  text-align: center;
  white-space: nowrap;
  padding: 4px 6px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
}
.site-nav a:hover {
  color: var(--text);
  text-decoration: none;
}
.site-nav a[aria-current="page"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.site-nav + .panel-header {
  padding-top: 12px;
}

/* =====================================================================
   Grid headroom page
   ===================================================================== */
.report-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.report-toggle button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
}
.report-toggle button:hover {
  border-color: var(--border-strong);
}
.report-toggle button[aria-checked="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.rt-title {
  font-weight: 600;
  font-size: 14px;
}
.rt-sub {
  font-size: 12px;
  color: var(--text-2);
}

.scenario-chips button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.scenario-chips .dot {
  width: 8px;
  height: 8px;
}
.chips.compact button {
  padding: 3px 9px;
  font-size: 12px;
}

.year-ticks {
  position: relative;
  height: 14px;
  margin: 2px 0 0 40px;
  font-size: 10.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.year-ticks span {
  position: absolute;
  transform: translateX(-50%);
}

.band-list .fuel-value {
  min-width: 2.5em;
}

/* Map band legend */
.band-legend {
  max-width: calc(100% - 140px);
}
.band-legend .bl-rows {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 4px;
}
.bl-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.bl-item .dot {
  width: 9px;
  height: 9px;
}
.bl-item.is-off {
  opacity: 0.35;
  text-decoration: line-through;
}
.app[data-view="outlook"] .band-legend,
.app[data-view="table"] .band-legend {
  display: none;
}
.page-headroom .app[data-view="outlook"] .top-right,
.page-headroom .app[data-view="table"] .top-right {
  display: none;
}

/* Outlook dashboard */
.view-outlook {
  overflow-y: auto;
  background: var(--bg);
  padding: 22px 24px 40px;
}
.outlook-head {
  max-width: 1180px;
  margin: 0 auto 16px;
}
.outlook-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.015em;
  text-transform: none;
  color: var(--text);
}
.outlook-sub {
  margin: 4px 0 0;
  color: var(--text-2);
  font-size: 13px;
  max-width: 760px;
}
.outlook-grid {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px 14px;
  min-width: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.card-wide {
  grid-column: 1 / -1;
}
/* Cards in a row share its height; a "fill" chart grows into the spare space. */
.outlook-grid .card {
  display: flex;
  flex-direction: column;
}
.outlook-grid .card > .chart.fill {
  flex: 1 1 auto;
  min-height: 0;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.card h3 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: -0.005em;
}
.card-sub {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--text-2);
  max-width: 560px;
}
.card-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 12px;
  color: var(--text-2);
}
.scenario-legend {
  margin-bottom: 8px;
}
.lg-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.lg-item.is-active {
  color: var(--text);
  font-weight: 600;
}
.lg-line {
  width: 14px;
  height: 3px;
  border-radius: 2px;
}
.lg-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}
.chart {
  position: relative;
  width: 100%;
}
.chart svg {
  display: block;
  overflow: visible;
  font-family: var(--font);
}

/* Chart anatomy */
.axis text {
  fill: var(--axis-ink);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.axis .gridline {
  stroke: var(--grid);
  stroke-width: 1;
}
.axis .baseline {
  stroke: var(--border-strong);
}
.axis-title {
  fill: var(--text-2);
  font-size: 11.5px;
  font-weight: 500;
}
.year-marker {
  stroke: var(--text);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: 0.55;
}
.year-marker.on-fill {
  stroke: var(--surface);
  stroke-dasharray: none;
  stroke-width: 2;
  opacity: 0.9;
}
.crosshair line,
.crosshair-line {
  stroke: var(--text-3);
  stroke-width: 1;
}
.crosshair circle {
  stroke: var(--surface);
  stroke-width: 2;
}
.end-label {
  fill: var(--text-2);
  font-size: 11.5px;
}
.end-label.is-active {
  fill: var(--text);
  font-weight: 600;
}
.band-seam {
  fill: none;
  stroke: var(--surface);
  stroke-width: 1.5;
}
.bar {
  transition: opacity 120ms;
}
.bar:hover {
  opacity: 0.8;
}
.bar.is-current {
  fill: var(--accent);
}
.bar-break {
  fill: none;
  stroke: var(--surface);
  stroke-width: 3;
}
.bar-value {
  fill: var(--text-2);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.row-label {
  fill: var(--text);
  font-size: 12px;
}
.row:hover .row-label {
  text-decoration: underline;
}
.whisker-halo {
  fill: none;
  stroke: var(--surface);
  stroke-width: 4.5;
  stroke-linecap: round;
  stroke-opacity: 0.9;
}
.whisker {
  fill: none;
  stroke: var(--text);
  stroke-width: 1.6;
  stroke-linecap: round;
}
.whisker-dot {
  stroke: var(--surface);
  stroke-width: 1.4;
}
.range-line {
  stroke: var(--grid);
  stroke-width: 3;
  stroke-linecap: round;
}
#chart-growth circle {
  stroke: var(--surface);
  stroke-width: 1.5;
}
.pt {
  stroke: var(--surface);
  stroke-width: 1;
  cursor: pointer;
}
.pt:hover,
.pt.is-selected {
  stroke: var(--text);
  stroke-width: 2;
  fill-opacity: 1;
}
.empty-note {
  fill: var(--text-3);
  font-size: 12.5px;
}
.quad-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 14px;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--text-2);
}
.quad {
  display: flex;
  align-items: center;
  gap: 7px;
}
.quad strong {
  margin-left: auto;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.quad em {
  font-style: normal;
  color: var(--text-3);
  min-width: 3em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.tt-keyed dt {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
}
.tt-keyed .dot {
  width: 8px;
  height: 8px;
}

/* Details card additions */
.details-wide {
  width: 380px;
}
.d-hero {
  margin-top: 12px;
}
.d-hero .d-mec {
  margin-top: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.d-hero-sub {
  font-size: 12.5px;
  color: var(--text-2);
  margin-top: 2px;
}
.d-hero-sub strong {
  color: var(--text);
}
.cell-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
}
.cell-dot.big {
  width: 12px;
  height: 12px;
  margin: 0;
}
.d-chart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}
.d-chart-head h3,
.d-units h3 {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  margin: 0;
}
.d-chart {
  margin-top: 8px;
}
.d-option {
  font-size: 12px;
  color: var(--text-2);
}
.select {
  font: inherit;
  font-size: 12.5px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 3px 6px;
  max-width: 190px;
}
.d-options th {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  text-align: left;
  padding: 2px 0 4px;
}
.d-options th.num {
  text-align: right;
}
.d-options td.num {
  text-align: right;
  white-space: nowrap;
}
.d-options tr.is-focus td:first-child {
  font-weight: 600;
}
.d-note,
.d-empty {
  font-size: 11.5px;
  color: var(--text-3);
  margin: 6px 0 0;
}

/* Table extras */
#table td.trend-col,
#table th.trend-col {
  width: 112px;
  padding-top: 3px;
  padding-bottom: 3px;
  vertical-align: middle;
}
.spark {
  display: block;
  overflow: visible;
}
.spark path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.spark .spark-area {
  fill: var(--text-2);
  fill-opacity: 0.1;
  stroke: none;
}
.spark .spark-base {
  stroke: var(--border-strong, var(--border));
  stroke-width: 1;
}
.spark .spark-line {
  stroke: var(--text-2);
  stroke-width: 1.5;
}
.spark .spark-est {
  stroke: var(--text-2);
  stroke-width: 1.5;
  stroke-dasharray: 2 2.5;
  stroke-linecap: butt;
}
.spark .spark-gap {
  stroke: var(--text-3);
  stroke-width: 1;
  stroke-dasharray: 1 3;
}
.spark .spark-dot {
  stroke: var(--surface);
  stroke-width: 1.5;
}
tr:hover .spark .spark-dot,
tr.is-selected .spark .spark-dot {
  stroke: var(--surface-2, var(--surface));
}

/* Interpolated (not studied) years */
.est-line {
  stroke-dasharray: 3 4;
  stroke-linecap: butt;
}
.est-tag {
  font-size: 10.5px;
  font-weight: 500;
  font-style: italic;
  color: var(--text-3);
}
.is-est {
  font-style: italic;
  color: var(--text-2);
}
.year-note {
  margin-top: 6px;
}
.hatch-stripe {
  fill: var(--surface);
  fill-opacity: 0.45;
}
.lg-hatch {
  background: repeating-linear-gradient(45deg, var(--text-3) 0 2px, transparent 2px 4.5px);
  opacity: 0.7;
}
.lg-est svg line {
  stroke: var(--text-2);
  stroke-width: 2;
  stroke-dasharray: 3 3;
}
.hit.is-pickable {
  cursor: pointer;
}
.tt-grid dt.is-near {
  font-weight: 600;
  color: var(--text);
}
.none-text {
  color: #d03b3b;
  font-weight: 600;
}
.muted {
  color: var(--text-3);
}

@media (max-width: 1100px) {
  .outlook-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  .site-nav {
    margin: 10px 16px 0;
  }
  .site-nav + .panel-header {
    padding-top: 8px;
  }
  .view-outlook {
    padding: 16px 12px 32px;
  }
  .card {
    padding: 14px 12px 12px;
  }
  .details-wide {
    width: auto;
  }
  /* Legends sit low in the corner, small, clear of the scale bar on the right. While the
     map attribution is open (it wraps onto two or three lines on phones, and the CARTO and
     OpenStreetMap credits must stay readable) they move up above it. */
  .size-legend {
    bottom: calc(8px + env(safe-area-inset-bottom));
    left: 8px;
    padding: 4px 8px 3px;
    font-size: 10.5px;
    transition: bottom 0.2s ease;
  }
  .size-legend .sl-title {
    margin-bottom: 1px;
  }
  .band-legend {
    max-width: calc(100% - 118px);
  }
  .band-legend .bl-rows {
    gap: 2px 9px;
    margin-top: 2px;
  }
  .band-legend .bl-item {
    gap: 4px;
  }
  /* Only the map has credits to clear; the bubble chart's key stays low. */
  .app[data-view="map"] .stage:has(.maplibregl-compact-show) .size-legend {
    bottom: calc(76px + env(safe-area-inset-bottom));
  }
  .details {
    bottom: calc(12px + env(safe-area-inset-bottom));
  }

  /* Edge to edge on phones. The views run on beneath the browser's bottom toolbar
     (Safari's floating glass bar sits below 100dvh, and 100lvh stops halfway down it), by
     --ext beyond the foot of the stage; what sits on them (keys, credits, scale) stays above
     the bar. --ext is only generous on iOS: elsewhere it is just the toolbar's travel. */
  :root {
    --under-bar: max(0px, 100lvh - 100dvh);
    --ext: var(--under-bar);
  }
  @supports (-webkit-touch-callout: none) {
    :root {
      --ext: calc(var(--under-bar) + 140px);
    }
  }
  html {
    background-color: var(--surface); /* Safari tints the status bar from this */
  }
  body {
    background: transparent;
  }
  .app {
    position: fixed; /* nothing overhanging the screen's foot can scroll the page */
    top: 0;
    left: 0;
    right: 0;
  }
  .stage {
    overflow: visible;
  }
  .view,
  .view.maplibregl-map {
    bottom: auto;
    height: calc(100% + var(--ext)); /* a height, not insets: the bubble chart is an <svg> */
  }
  .maplibregl-ctrl-bottom-left,
  .maplibregl-ctrl-bottom-right {
    bottom: calc(var(--ext) + env(safe-area-inset-bottom));
  }
  .table-scroll {
    padding-bottom: var(--ext);
  }
  .view-outlook {
    padding-bottom: calc(32px + var(--ext));
  }
  .panel {
    padding-top: env(safe-area-inset-top); /* home-screen app: clear of the notch */
  }
}

/* View tabs (map, chart, table): outside the panel's collapsible body, so they stay in
   view on phones. */
.view-tabs {
  margin: 2px 20px 16px;
  flex-shrink: 0;
}

/* Phone header: the page switcher, then the title with its two buttons, then the view
   tabs as an underlined tab bar resting on the panel's lower edge (a second pill control
   under the first looked heavy). */
@media (max-width: 860px) {
  .site-nav {
    margin: 8px 12px 0;
  }
  .site-nav a {
    padding: 5px 6px;
    font-size: 13px;
  }
  .site-nav + .panel-header {
    padding: 12px 10px 4px 16px;
  }
  h1 {
    font-size: 18px;
    line-height: 1.2;
  }
  .header-actions {
    gap: 0;
  }
  .header-actions .icon-btn {
    width: 38px;
    height: 38px;
  }
  .view-tabs {
    margin: 0 16px;
    padding: 0;
    gap: 20px;
    display: flex;
    background: none;
    border-radius: 0;
  }
  .view-tabs button {
    flex: none;
    padding: 9px 0 10px;
    border-radius: 0;
    font-size: 14px;
    color: var(--text-3);
    box-shadow: inset 0 -2px 0 transparent;
  }
  .view-tabs button[aria-selected="true"] {
    background: none;
    color: var(--text);
    font-weight: 600;
    box-shadow: inset 0 -2px 0 var(--text);
  }
  .panel-body {
    max-height: calc(100dvh - var(--panel-h, 140px) - env(safe-area-inset-top));
    border-top: 1px solid var(--border);
  }
}

.kpi-value small.kpi-of {
  display: block;
  margin: 0;
  font-size: 11.5px;
}
.page-headroom .kpi-value small {
  white-space: nowrap;
}

/* =====================================================================
   Substations page
   ===================================================================== */
.row-meta {
  font-size: 11.5px;
  color: var(--text-3);
  margin-left: 4px;
}
.lg-dash {
  width: 16px;
  height: 0;
  border-top: 2.5px dashed var(--text-2);
}
.lg-swatch.hatched {
  background: repeating-linear-gradient(45deg, var(--text-2) 0 2px, transparent 2px 4px);
}
.kv-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.kv-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 2px 9px 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--surface);
}
.kv-chip::before {
  content: "";
  width: 12px;
  height: 3px;
  border-radius: 2px;
  background: var(--swatch);
}
.d-kv {
  margin-top: 12px;
}
.d-section {
  margin-top: 16px;
}
.d-section h3 {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  margin: 0 0 8px;
}
.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.mini-stats > div {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mini-stats > div + div {
  border-left: 1px solid var(--border);
}
.mini-stats span {
  font-size: 11px;
  color: var(--text-3);
}
.mini-stats strong {
  font-size: 16px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.mini-stats small {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2);
}
.d-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 12.5px;
  font-weight: 500;
}
.fuel-strip {
  display: flex;
  gap: 2px;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}
.fuel-strip span {
  min-width: 2px;
}
.src-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
}
.src-list li {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 8px;
  align-items: baseline;
}
.src-tag {
  font-size: 11px;
  color: var(--text-3);
}
.src-cell {
  white-space: nowrap;
}
.src-pill {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  margin-right: 3px;
  background: var(--surface-3);
  color: var(--text-2);
}
.src-pill.src-csv {
  background: color-mix(in srgb, #2a78d6 16%, transparent);
  color: var(--text);
}
.src-pill.src-headroom {
  background: color-mix(in srgb, #eb6834 16%, transparent);
  color: var(--text);
}
.src-pill.src-nie {
  background: color-mix(in srgb, #1baf7a 18%, transparent);
  color: var(--text);
}
.src-pill.src-ps {
  background: color-mix(in srgb, #eda100 20%, transparent);
  color: var(--text);
}
.upset-dot {
  fill: var(--border-strong);
}
.upset-dot.is-on {
  fill: var(--text);
}
.upset-link {
  stroke: var(--text);
  stroke-width: 2;
}
.col-label {
  fill: var(--text-2);
  font-size: 11px;
  font-weight: 500;
}
.upset-col {
  fill: var(--surface-2);
}
.bar-share {
  fill: var(--text-3);
}
#chart-sources .row:hover .upset-dot.is-on,
#chart-sources .row:hover .upset-link {
  fill: var(--accent);
  stroke: var(--accent);
}
.bar.seg:hover {
  opacity: 0.8;
}
.more-row td {
  text-align: center;
  padding: 14px;
}
p.empty-note {
  color: var(--text-3);
  font-size: 13px;
  margin: 8px 0;
}
.page-substations .app[data-view="overview"] .top-right,
.page-substations .app[data-view="table"] .top-right,
.app[data-view="overview"] .band-legend {
  display: none;
}
.band-legend .lg-line {
  width: 14px;
}

/* Headroom: one scenario panel per network */
#chart-scenarios.is-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.net-panel h4 {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}
.net-panel .chart {
  min-width: 0;
}
.cap-map {
  margin-top: 16px;
}
.d-grid.compact {
  font-size: 12.5px;
  gap: 3px 12px;
  margin-top: 8px;
}
@media (max-width: 860px) {
  #chart-scenarios.is-split {
    grid-template-columns: minmax(0, 1fr);
  }
}
#chart-top .bar {
  fill-opacity: 0.62;
}

/* Timeline playback speed */
.speed-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.speed-label {
  font-size: 12px;
  color: var(--text-3);
}

/* Disclaimer and credit line at the foot of each page's panel */
.panel-footer .disclaimer {
  margin-top: 10px;
  font-size: 11.5px;
}
.credit {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  color: var(--text-2);
}
.credit a {
  color: inherit;
  font-weight: 600;
}

/* =====================================================================
   Timeline mini-player (power sources page, phones only)
   On phones the panel with the timeline control is folded away, so a compact player
   floats over the foot of the map and bubble chart: play/pause, the year with what is in
   service then, a scrubber, and a speed button. The keys and map credits stack above it.
   ===================================================================== */
.mini-player {
  display: none;
}
@media (max-width: 860px) {
  .mini-player {
    position: absolute;
    z-index: 3;
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px 7px 7px;
    background: color-mix(in srgb, var(--surface) 84%, transparent);
    -webkit-backdrop-filter: blur(16px) saturate(1.5);
    backdrop-filter: blur(16px) saturate(1.5);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
  }
  .app[data-view="table"] .mini-player,
  .app.has-details .mini-player {
    display: none;
  }
  .mp-play {
    flex: none;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    background: var(--text);
    color: var(--surface);
    cursor: pointer;
  }
  .mp-play .icon {
    width: 18px;
    height: 18px;
  }
  .mp-play .icon-play path {
    fill: currentColor;
    stroke-width: 1.4;
  }
  .mp-play .icon-pause {
    stroke-width: 2.6;
  }
  .mp-main {
    flex: 1;
    min-width: 0;
  }
  .mp-readout {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    padding: 0 2px;
  }
  .mp-year {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    color: var(--text);
  }
  .mp-stats {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    color: var(--text-2);
    font-variant-numeric: tabular-nums;
  }
  .mp-stats small {
    font-size: inherit;
    margin-left: 0.2em;
  }
  .mp-main input[type="range"] {
    display: block;
    height: 18px;
  }
  .mp-speed {
    flex: none;
    min-width: 58px;
    height: 30px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: var(--surface);
    color: var(--text-2);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
  }

  /* The keys and map credits stack above the player (58px tall). */
  .page-sources .app:not(.has-details):not([data-view="table"]) .size-legend {
    bottom: calc(74px + env(safe-area-inset-bottom));
  }
  .page-sources .app[data-view="map"]:not(.has-details) .stage:has(.maplibregl-compact-show) .size-legend {
    bottom: calc(124px + env(safe-area-inset-bottom));
  }
  .page-sources .app:not(.has-details) .maplibregl-ctrl-bottom-left,
  .page-sources .app:not(.has-details) .maplibregl-ctrl-bottom-right {
    bottom: calc(var(--ext) + 66px + env(safe-area-inset-bottom));
  }
}

/* A station's references in the details panel */
.d-refs {
  margin: 14px 0 0;
}
.d-refs h3 {
  margin: 0 0 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
}
.d-refs ol {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.45;
}
.d-refs li + li {
  margin-top: 3px;
}
