GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Solar and storage design / globalgrid2050 / scripts

GIS Single-Line Diagram (SLD) V2 and 3 more files (part 2)

A style sheet in GlobalGrid2050 covering battery storage (BESS).

700 lines of CSS and Python from globalgrid2050, in 4 files. Topic: Solar and storage design. Section 73 of 2044.

Cut 2026-12-06T03:07:51+00:00. A copy for reading; the repository at the stated commit is the source.

In the State lines below, domain stage, users and canonical status are rule-based first approximations from code and path evidence (rules explore-agent-rules-v1), not observed facts: the rules.

In this section

  1. GlobalGrid2050 Test V7 GIS Single-Line Diagram (SLD) Array Sizing Math test · globalgrid2050 / scripts/test_v7_gis_sld_array_sizing_math.py lines 1–66
  2. GlobalGrid2050 Test V7 GIS Single-Line Diagram (SLD) Site Intelligence Panel test · globalgrid2050 / scripts/test_v7_gis_sld_site_intelligence_panel.py lines 1–21
  3. GlobalGrid2050 Wire Pvlive Solar UI V6 energy-data · globalgrid2050 / scripts/wire_pvlive_solar_ui_v6.py lines 1–93
  4. GIS Single-Line Diagram (SLD) V2 electrical · globalgrid2050 / solar-bess-topology-v2/gis-sld-v2.css lines 1–520

GlobalGrid2050 Test V7 GIS Single-Line Diagram (SLD) Array Sizing Math

A test in the scripts folder. It is built from the string sizing helper (`string_sizing`) and the central sizing helper (`central_sizing`).

testglobalgrid2050 / scripts/test_v7_gis_sld_array_sizing_math.py · lines 1–66 of 66 · Entry point · pattern central_sizing (shared by 2 files)

What it does
It tests its inputs. Defines string_sizing, central_sizing, main. Uses libraries __future__, math, pathlib. Side effects: reads or writes files.
Why it exists in the grid workflow
Domain stage sub33kv_design (path word 'array'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary.
Downstream impact
Used directly by 3 files: GlobalGrid2050 Add V7 GIS Single-Line Diagram (SLD) Array Visibility and Mwp Sizing (globalgrid2050); GlobalGrid2050 Add V7 GIS Single-Line Diagram (SLD) Array Visibility and Mwp Sizing Workflow (globalgrid2050); GlobalGrid2050 Project Signals Acid Workflow (globalgrid2050).
What it achieves
Static and maths checks for V7 GIS SLD array MWp sizing.
Why it matters
Run by GlobalGrid2050 Add V7 GIS Single-Line Diagram (SLD) Array Visibility and Mwp Sizing, GlobalGrid2050 Add V7 GIS Single-Line Diagram (SLD) Array Visibility and Mwp Sizing Workflow and GlobalGrid2050 Project Signals Acid Workflow.
Application
globalgrid2050 · scripts · test
Uses
__future__, math, pathlib
Used by
run by GlobalGrid2050 Add V7 GIS Single-Line Diagram (SLD) Array Visibility and Mwp Sizing (script call), run by GlobalGrid2050 Add V7 GIS Single-Line Diagram (SLD) Array Visibility and Mwp Sizing Workflow (workflow run), run by GlobalGrid2050 Project Signals Acid Workflow (workflow run)
Produces
string_sizing, central_sizing, main
Defines here
string_sizing, central_sizing, main
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 scripts/test_v7_gis_sld_array_sizing_math.py:1-66 · blob 3917546715a3eb75da48d5cb28160f2c69926fb3 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: ingest · effects: filesystem · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
#!/usr/bin/env python3
"""Static and maths checks for V7 GIS SLD array MWp sizing."""
from __future__ import annotations

import math
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]
APP = ROOT / "solar-bess-topology-v7" / "gis-sld-financial-sandbox"


def string_sizing(target_mwp, mod_wp, x_mods, z_strings, y_invs, current_skids_per_ring):
    dc_per_skid = (mod_wp * x_mods * z_strings * y_invs) / 1_000_000
    desired_skids = max(1, math.ceil(target_mwp / dc_per_skid))
    rings = max(1, math.ceil(desired_skids / current_skids_per_ring))
    skids_per_ring = max(1, math.ceil(desired_skids / rings))
    actual_skids = skids_per_ring * rings
    actual_mwp = actual_skids * dc_per_skid
    return dc_per_skid, desired_skids, skids_per_ring, rings, actual_skids, actual_mwp


def central_sizing(target_mwp, inv_dc_mwp, inv_per_skid, current_skids_per_ring):
    desired_inverters = max(1, math.ceil(target_mwp / inv_dc_mwp))
    desired_skids = max(1, math.ceil(desired_inverters / inv_per_skid))
    rings = max(1, math.ceil(desired_skids / current_skids_per_ring))
    skids_per_ring = max(1, math.ceil(desired_skids / rings))
    actual_inverters = inv_per_skid * skids_per_ring * rings
    actual_mwp = actual_inverters * inv_dc_mwp
    return desired_inverters, desired_skids, skids_per_ring, rings, actual_inverters, actual_mwp


def main():
    index = (APP / "index.html").read_text(encoding="utf-8")
    ui = (APP / "gis-sld-v5-ui.js").read_text(encoding="utf-8")
    drawing = (APP / "gis-sld-v5-drawing.js").read_text(encoding="utf-8")
    state = (APP / "gis-sld-v5-state.js").read_text(encoding="utf-8")

    for token in ["btn_array_toggle", "map_target_dc_mwp", "target_dc_mwp", "target_dc_mwp_c"]:
        assert token in index, token
    for token in ["toggleArrayVisibility", "applyTargetDcMwpFromActiveTab", "wireArraySizingControls"]:
        assert token in ui, token
    assert "arrayVisible: true" in state
    assert "setTopologyLayerVisibility?.(state.arrayVisible !== false);" in drawing

    # Default string mode maths: 660 W, 28 modules, 18 strings, 28 inverters.
    dc_per_skid, desired_skids, skids_per_ring, rings, actual_skids, actual_mwp = string_sizing(
        100, 660, 28, 18, 28, 5
    )
    assert round(dc_per_skid, 6) == round((660 * 28 * 18 * 28) / 1_000_000, 6)
    assert actual_skids >= desired_skids
    assert actual_mwp >= 100
    assert skids_per_ring >= 1 and rings >= 1

    # Default central mode maths: 5.28 MWdc inverter, 1 inverter per skid, 4 skids per ring.
    desired_inv, desired_skids, skids_per_ring, rings, actual_inv, actual_mwp = central_sizing(
        100, 5.28, 1, 4
    )
    assert actual_inv >= desired_inv
    assert actual_mwp >= 100
    assert skids_per_ring >= 1 and rings >= 1

    print("V7 GIS SLD array sizing static and maths checks passed.")


if __name__ == "__main__":
    main()

GlobalGrid2050 Test V7 GIS Single-Line Diagram (SLD) Site Intelligence Panel

A test in the scripts folder.

testglobalgrid2050 / scripts/test_v7_gis_sld_site_intelligence_panel.py · lines 1–21 of 21 · Entry point

What it does
It tests its inputs. Uses libraries pathlib. Side effects: reads or writes files.
Why it exists in the grid workflow
Domain stage sub33kv_design (path word 'panel'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary. Domain terms in the code: 400kV, 275kV, 132kV, 66kV.
Inputs & outputs
In: JSON file repd_master.json. Voltage levels named: 400kV, 275kV, 132kV, 66kV.
Downstream impact
Used directly by 3 files: GlobalGrid2050 Add V7 GIS Single-Line Diagram (SLD) Site Intelligence Panel (globalgrid2050); GlobalGrid2050 Add V7 GIS Single-Line Diagram (SLD) Site Intelligence Panel Workflow (globalgrid2050); GlobalGrid2050 Project Signals Acid Workflow (globalgrid2050).
What it achieves
Static checks for V7 GIS SLD Site Intelligence Panel. Its code works with 132 kV, 275 kV and 400 kV.
Why it matters
Run by GlobalGrid2050 Add V7 GIS Single-Line Diagram (SLD) Site Intelligence Panel, GlobalGrid2050 Add V7 GIS Single-Line Diagram (SLD) Site Intelligence Panel Workflow and GlobalGrid2050 Project Signals Acid Workflow.
Application
globalgrid2050 · scripts · test
Uses
pathlib
Used by
run by GlobalGrid2050 Add V7 GIS Single-Line Diagram (SLD) Site Intelligence Panel (script call), run by GlobalGrid2050 Add V7 GIS Single-Line Diagram (SLD) Site Intelligence Panel Workflow (workflow run), run by GlobalGrid2050 Project Signals Acid Workflow (workflow run)
Produces
none declared
Defines here
none
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 scripts/test_v7_gis_sld_site_intelligence_panel.py:1-21 · blob 52ef4db242aa4563db69d708f1ad54c44f2e276f · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: ingest · effects: filesystem · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
#!/usr/bin/env python3
"""Static checks for V7 GIS SLD Site Intelligence Panel."""
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]
APP = ROOT / "solar-bess-topology-v7" / "gis-sld-financial-sandbox"

index = (APP / "index.html").read_text(encoding="utf-8")
ui = (APP / "gis-sld-v5-ui.js").read_text(encoding="utf-8")
css = (APP / "gis-sld-v5.css").read_text(encoding="utf-8")

for token in ["site_intel_panel", "site_intel_body", "site_intel_close"]:
    assert token in index, token
for token in ["inspectSiteIntelligenceAt", "nearestLineFeature", "nearestPointFeature", "wireSiteIntelligencePanel"]:
    assert token in ui, token
for token in ["66 kV", "132 kV", "275 kV", "400 kV", "/dist/repd_master.json", "SUBSTATIONS_URL"]:
    assert token in ui, token
for token in ["site-intel-panel", "site-intel-row", "SITE INTELLIGENCE PANEL"]:
    assert token in css, token

print("V7 GIS SLD site intelligence panel static checks passed.")

GlobalGrid2050 Wire Pvlive Solar UI V6

A Python command-line tool in the scripts folder that reads pvlive solar daily browser and Elexon generation sources. It patches loader (`patch_loader`).

energy-dataglobalgrid2050 / scripts/wire_pvlive_solar_ui_v6.py · lines 1–93 of 93 · Entry point · pattern patch_config (shared by 2 files)

What it does
It loads pvlive solar daily browser and Elexon generation sources. Defines 7 functions or classes, including utc_now, replace_once, patch_config, patch_loader, patch_index_note. Uses libraries __future__, datetime, pathlib. Side effects: reads or writes files.
Why it exists in the grid workflow
Domain stage sub33kv_design (path word 'solar'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary.
Inputs & outputs
In: JSON file pvlive_solar_daily_browser.json; JSON file elexon_generation_sources_2016.json.
Downstream impact
Used directly by 1 file: GlobalGrid2050 Step3 Wire Pvlive Solar UI V6 Workflow (globalgrid2050).
What it achieves
Defines `utc_now`, `replace_once`, `patch_config` and 3 more.
Why it matters
Run by GlobalGrid2050 Step3 Wire Pvlive Solar UI V6 Workflow.
Application
globalgrid2050 · scripts · Python CLI
Uses
__future__, datetime, pathlib
Used by
run by GlobalGrid2050 Step3 Wire Pvlive Solar UI V6 Workflow (workflow run)
Produces
utc_now, replace_once, patch_config, patch_loader, patch_index_note, write_report, main
Defines here
utc_now, replace_once, patch_config, patch_loader, patch_index_note, write_report, main
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 scripts/wire_pvlive_solar_ui_v6.py:1-93 · blob f85bf6b43055f18d3cfb4a4a1e019703840ecbbb · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: filesystem · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
#!/usr/bin/env python3
from __future__ import annotations

import datetime as dt
from pathlib import Path

ROOT = Path(__file__).resolve().parent.parent
CONFIG = ROOT / "uk_energy_tracking_v6" / "generation_history" / "live-config.js"
LOADER = ROOT / "uk_energy_tracking_v6" / "generation_history" / "load_generation_history_data.js"
INDEX = ROOT / "uk_energy_tracking_v6" / "generation_history" / "index.md"
REPORT = ROOT / "uk_energy_tracking_v6" / "generation_history" / "PVLIVE_SOLAR_UI_WIRE_REPORT.md"

SOLAR_PATH = "/uk_energy_tracking_v6/generation_history/pvlive_solar_daily_browser.json"


def utc_now() -> str:
    return dt.datetime.now(dt.timezone.utc).isoformat().replace("+00:00", "Z")


def replace_once(text: str, old: str, new: str, label: str) -> tuple[str, bool]:
    if new in text:
        return text, False
    if old not in text:
        raise SystemExit(f"Expected text not found for {label}")
    return text.replace(old, new, 1), True


def patch_config() -> bool:
    text = CONFIG.read_text(encoding="utf-8")
    old = "  dailyHistoryFallback:'/data/generation/elexon_generation_sources_2016.json',\n"
    new = old + f"  solarDaily:'{SOLAR_PATH}',\n"
    text, changed = replace_once(text, old, new, "config solarDaily insertion")
    CONFIG.write_text(text, encoding="utf-8")
    return changed


def patch_loader() -> bool:
    text = LOADER.read_text(encoding="utf-8")
    old = "function loadDaily(){return loadJsonOnce('daily',cfg().dailyHistory)}\nfunction loadRecent(){return loadJsonOnce('recent',cfg().recentEcg||cfg().recentHalfHourly)}"
    new = "function loadDaily(){return loadJsonOnce('daily',cfg().dailyHistory)}\nfunction loadSolarDaily(){return loadJsonOnce('solarDaily',cfg().solarDaily||cfg().dailyHistory)}\nfunction loadRecent(){return loadJsonOnce('recent',cfg().recentEcg||cfg().recentHalfHourly)}"
    text, changed_a = replace_once(text, old, new, "loader solarDaily loader")
    old2 = "function loadDailyWindow(meta,technology){return loadDaily().then(function(all){var rows=all.filter(function(r){var t=new Date(r.date+'T12:00:00Z');return t>=meta.start&&t<=meta.end});rows=dedupe(sortDaily(rows),function(r){return r.date+'|'+r.technology});if(isAll(technology))return{rows:totalDaily(rows),series:seriesDaily(rows),technology:'All generation total'};var only=sortDaily(ro  … [line shortened here: 544 characters; full line on GitHub]
    new2 = "function loadDailyWindow(meta,technology){var source=technology==='Solar'?loadSolarDaily():loadDaily();return source.then(function(all){var rows=all.filter(function(r){var t=new Date(r.date+'T12:00:00Z');return t>=meta.start&&t<=meta.end});rows=dedupe(sortDaily(rows),function(r){return r.date+'|'+r.technology});if(isAll(technology))return{rows:totalDaily(rows),series:seriesDaily(rows),  … [line shortened here: 600 characters; full line on GitHub]
    text, changed_b = replace_once(text, old2, new2, "loader solarDaily routing")
    LOADER.write_text(text, encoding="utf-8")
    return changed_a or changed_b


def patch_index_note() -> bool:
    text = INDEX.read_text(encoding="utf-8")
    old = "Embedded or national solar output will be added as a separate layer."
    new = "Embedded solar output is now routed through a separate PVLive candidate layer where the solar browser file is present."
    if new in text:
        return False
    if old not in text:
        raise SystemExit("Expected source transparency sentence not found")
    INDEX.write_text(text.replace(old, new, 1), encoding="utf-8")
    return True


def write_report(changes: dict[str, bool]) -> None:
    REPORT.write_text("\n".join([
        "# PVLive Solar UI Wire Report",
        "",
        f"Generated UTC: `{utc_now()}`",
        "",
        "## Purpose",
        "Wire the Generation History V6 Solar selection to a separate PVLive solar browser file for historic daily solar views.",
        "",
        "## Changes",
        f"live-config.js solarDaily added or already present: `{changes['config']}`",
        f"load_generation_history_data.js solarDaily route added or already present: `{changes['loader']}`",
        f"index.md source note updated or already present: `{changes['index']}`",
        "",
        "## Guardrails",
        "recentEcg is not changed.",
        "FUELHH dailyHistory remains available for non solar historic technologies.",
        "PVLive is marked as a candidate embedded solar estimate layer, not confirmed FUELHH transmission data.",
    ]) + "\n", encoding="utf-8")


def main() -> int:
    changes = {
        "config": patch_config(),
        "loader": patch_loader(),
        "index": patch_index_note(),
    }
    write_report(changes)
    return 0


if __name__ == "__main__":
    raise SystemExit(main())

GIS Single-Line Diagram (SLD) V2

A style sheet in GlobalGrid2050 covering battery storage (BESS).

Set aside from the main view: 98% of its lines are the same as solar-bess-topology-v4/gis-sld-v4.css (globalgrid2050), which stays. (near-copy-of, proposed by families.py). 97% of lines shared with GIS Single-Line Diagram (SLD) V4; read that one first. All set-aside files, with reasons. Nothing was deleted.

Evidence
  • line-jaccard 0.9762 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-bess-topology-v4/gis-sld-v4.css:1-548 f18caa16bd7dec48a0e6a26b2a2abcba89060840
  • sha256 66968cb927933e879e7d202333f3b26d75135a2388fa90327d82b43fc8a2f110
  • target sha256 6f353755a42de4d5a57881943dd7b565ee32a2fe79c10ededcc1429e354337ae
  • group of 3 (identity.json near-copy edges >= 0.9)
  • canonical rule: reachable, newest stamp, core repo, most lines

electricalglobalgrid2050 / solar-bess-topology-v2/gis-sld-v2.css · lines 1–520 of 543 · Entry point

What it does
Side effects: changes the web page (DOM).
Why it exists in the grid workflow
Domain stage sub33kv_design (path word 'bess'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary. Domain terms in the code: battery storage (BESS).
Downstream impact
Used directly by 3 files: Indexforgis Single-Line Diagram (SLD) V2 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v2/indexforgis-sld-v2.html); Indexforgis Single-Line Diagram (SLD) V3 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v3/indexforgis-sld-v3.html); Module Layout V3 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v3/module-layout-v3.html). Reached from 1 other entry point, including GlobalGrid2050 — Solar Battery Energy Storage System (BESS) Topology V3 Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v3/).
What it achieves
No statement of purpose was found in the file, a README line naming it, or its name.
Why it matters
Feeds the Indexforgis Single-Line Diagram (SLD) V2 map page (battery storage (BESS)) at https://globalgrid2050.com/solar-bess-topology-v2/indexforgis-sld-v2.html and 2 other pages.
Application
globalgrid2050 · solar-bess-topology-v2 · style sheet
Uses
none found
Used by
loaded by Indexforgis Single-Line Diagram (SLD) V2 (stylesheet), loaded by Indexforgis Single-Line Diagram (SLD) V3 (stylesheet), loaded by Module Layout V3 (stylesheet)
Produces
none declared
Defines here
none
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-bess-topology-v2/gis-sld-v2.css:1-520 · blob a477f220621989c7b16b539b5393b34dbfc3d982 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
:root {
  /* Backgrounds & UI */
  --bg: #050505;
  --panel: rgba(10, 10, 10, 0.96);
  --line: #2f343d;
  
  /* Typography & Accents */
  --text: #ffffff;
  --muted: #a6adbb;
  --accent: #00ffff;
  --accent-alt: #ff9900;
  
  /* Status & Specific Elements */
  --ok: #00ff88;
  --substation: #ff3333;
  --private-sub: #00ff88;
  --inverter: #ffff00;
  --mv: #6633ff;
  --bess: #ff00aa;
  --array-blue: #0066ff;
  --warn: #ff4444;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  padding: 20px;
  background: var(--bg);
  color: var(--text);
  font-family: "Courier New", monospace;
  display: flex;
  justify-content: center;
  overflow: hidden;
}

/* Layout */
.dashboard {
  display: flex;
  gap: 20px;
  width: 100%;
  max-width: 1600px;
  height: 100%;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
}

.panel-left {
  width: 440px;
  padding: 20px;
  flex-shrink: 0;
  overflow-y: auto;
}

.panel-right {
  flex: 1 1 auto;
  position: relative;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--line);
  min-height: 400px;
}

/* Typography */
h2 {
  margin: 0 0 10px 0;
  color: var(--text);
  font-size: 18px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

h3 {
  margin: 15px 0 5px 0;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  border-bottom: 1px dashed #333;
  padding-bottom: 3px;
}

/* Tabs */
.tab-container {
  display: flex;
  border-bottom: 1px solid var(--line);
  margin-bottom: 15px;
}

.tab-btn {
  flex: 1;
  padding: 10px 5px;
  background: transparent;
  color: var(--muted);
  border: none;
  cursor: pointer;
  font-family: monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: 0.2s;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  font-weight: bold;
  background: rgba(0, 255, 255, 0.05);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Inputs & Forms */
.input-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}

.input-group input[type="text"], 
.input-group input[type="number"], 
.input-group select {
  width: 95px;
  background: #111;
  color: var(--accent);
  border: 1px solid #444;
  padding: 5px;
  text-align: right;
  border-radius: 3px;
  font-family: monospace;
  font-size: 11px;
}

.input-group input[type="text"] {
  text-align: left;
}

.input-group select {
  width: auto;
  min-width: 140px;
  text-align: left;
}

.tab-content#central_tab .input-group input[type="number"], 
.tab-content#central_tab .input-group select {
  color: var(--accent-alt);
}

.input-group input:focus, 
.input-group select:focus {
  border-color: var(--text);
  outline: none;
}

/* Hide native number input arrows while preserving numeric typing */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* Search Box */
.search-box {
  display: flex;
  gap: 5px;
  margin-bottom: 15px;
}

.search-box input {
  flex: 1;
  background: #111;
  color: #fff;
  border: 1px solid #444;
  padding: 8px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 12px;
}

.search-box button {
  background: #222;
  color: var(--text);
  border: 1px solid #555;
  padding: 8px 12px;
  border-radius: 3px;
  cursor: pointer;
  font-family: monospace;
  font-weight: bold;
}

.search-box button:hover {
  background: #444;
  color: #fff;
}

/* Stats */
.stat-box {
  background: rgba(0, 255, 255, 0.05);
  border: 1px solid var(--accent);
  padding: 12px;
  border-radius: 3px;
  margin-top: 15px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  margin-bottom: 6px;
  color: var(--muted);
}

.stat-val {
  color: var(--text);
  font-weight: bold;
  text-align: right;
}

.stat-val.cyan {
  color: var(--accent);
  font-size: 13px;
}

.stat-val.orange {
  color: var(--accent-alt);
  font-size: 13px;
}

/* Finance Elements */
.finance-box {
  background: rgba(0, 255, 136, 0.05);
  border: 1px solid var(--ok);
  border-radius: 3px;
  padding: 10px;
  margin-top: 15px;
}

.finance-box summary {
  color: var(--ok);
  cursor: pointer;
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.finance-headline {
  border: 1px solid #264d3a;
  padding: 10px;
  margin-bottom: 10px;
  background: rgba(0, 255, 136, 0.04);
}

.finance-box input[type="number"] {
  width: 95px;
  background: #111;
  color: var(--ok);
  border: 1px solid #444;
  padding: 5px;
  text-align: right;
  border-radius: 3px;
  font-family: monospace;
  font-size: 11px;
}

.finance-box input[type="checkbox"] {
  accent-color: var(--ok);
  cursor: pointer;
  margin: 0;
}

/* Messages & Notes */
.warning-box {
  color: #ffcc00;
  font-size: 10px;
  margin-top: 8px;
  line-height: 1.4;
}

.ux-note {
  font-size: 9px;
  color: var(--muted);
  margin-top: 4px;
  font-style: italic;
}

.benchmark-box {
  background: rgba(17, 17, 17, 0.8);
  border: 1px solid #444;
  border-radius: 3px;
  padding: 10px;
  margin-top: 15px;
}

.disclaimer-box {
  background: rgba(255, 68, 68, 0.05);
  border: 1px solid #ff4444;
  color: #ff9999;
  font-size: 10px;
  padding: 12px;
  border-radius: 3px;
  margin-top: 15px;
  line-height: 1.5;
  text-align: justify;
}

.explainer-box {
  background: rgba(0, 255, 255, 0.04);
  border: 1px solid var(--accent);
  color: var(--muted);
  font-size: 10px;
  padding: 12px;
  border-radius: 3px;
  margin-top: 15px;
  line-height: 1.55;
  text-align: justify;
}

.explainer-box strong {
  color: var(--text);
}

.explainer-box h3 {
  color: var(--accent);
  margin-top: 0;
}

/* Buttons */
.btn {
  padding: 10px;
  background: #000;
  color: var(--text);
  border: 1px solid #555;
  cursor: pointer;
  font-family: monospace;
  font-weight: bold;
  text-transform: uppercase;
  border-radius: 3px;
  margin-top: 10px;
  width: 100%;
  transition: 0.2s;
}

.btn:hover {
  background: #222;
  color: #fff;
}

.btn.draw-btn {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
}

.btn.draw-btn.central {
  background: var(--accent-alt);
  border-color: var(--accent-alt);
}

.map-toggle-btn {
  background: rgba(5, 5, 5, 0.85);
  color: var(--muted);
  border: 1px solid #444;
  padding: 6px 12px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
  transition: 0.2s;
}

.map-toggle-btn:hover {
  background: #222;
  border-color: #888;
}

.map-toggle-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(0, 255, 255, 0.05);
}

/* Map Elements */
#map {
  width: 100%;
  height: 100%;
  min-height: 400px;
}

.crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 24px;
  pointer-events: none;
  z-index: 10;
  text-shadow: 0 0 5px #000;
}

.legend {
  position: absolute;
  bottom: 20px;
  left: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 10px;
  font-size: 10px;
  z-index: 1;
  border-radius: 4px;
  pointer-events: none;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.swatch {
  width: 12px;
  height: 12px;
  border: 1px solid #666;
}

/* Maplibre Popups */
.maplibregl-popup-content {
  background: #111;
  color: #fff;
  border: 1px solid #444;
  border-radius: 4px;
  font-family: "Courier New", monospace;
  padding: 12px;
  font-size: 11px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.maplibregl-popup-close-button {
  color: #888;
  padding: 4px;
}

.maplibregl-popup-close-button:hover {
  color: #fff;
}

.popup-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  border-bottom: 1px solid #222;
  padding-bottom: 2px;
  gap: 15px;
}

.popup-val {
  font-weight: bold;
  color: var(--accent);
}

/* Status Indicator */
#fetch_status {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 20;
  background: rgba(5, 5, 5, 0.9);
  border: 1px solid #555;
  padding: 6px 10px;
  border-radius: 3px;
  font-size: 10px;
  color: var(--muted);
  display: none;
}

#fetch_status.error {
  color: #ff6666;
  border-color: #ff4444;
  display: block;
}

/* Responsive Design */
@media (max-width: 800px) {
  html, body {
    height: auto;
  }