GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Solar and storage design / globalgrid2050 / solar-bess-topology-v8/bess-gis-sld-financial-sandbox

GIS Single-Line Diagram (SLD) V5 and 1 more file (part 2)

A style sheet in GlobalGrid2050 covering battery storage (BESS), solar, substations and wind. Served with the page at https://globalgrid2050.com/solar-bess-topology-v8/bess-gis-sld-financial-sandbox/.

700 lines of CSS and JavaScript from globalgrid2050, in 2 files. Topic: Solar and storage design. Section 111 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. GIS Single-Line Diagram (SLD) V5 UI electrical · globalgrid2050 / solar-bess-topology-v8/bess-gis-sld-financial-sandbox/gis-sld-v5-ui.js lines 1401–1667
  2. GIS Single-Line Diagram (SLD) V5 electrical · globalgrid2050 / solar-bess-topology-v8/bess-gis-sld-financial-sandbox/gis-sld-v5.css lines 1–433

GIS Single-Line Diagram (SLD) V5 UI

A JavaScript file in GlobalGrid2050 that maps Renewable Energy Planning Database (REPD) master and grid 66kV, using haversine, and uses data from OpenStreetMap Nominatim. Served with the page at https://globalgrid2050.com/solar-bess-topology-v8/bess-gis-sld-financial-sandbox/.

electricalglobalgrid2050 / solar-bess-topology-v8/bess-gis-sld-financial-sandbox/gis-sld-v5-ui.js · lines 1401–1667 of 1667 (continued from section 109) · Not reached from any entry point (candidate for review) · pattern wireAtlasV8PipelineDropdownWithStatus (shared by 2 files)

What it does
It maps REPD master, grid 66kV, grid 132kV and grid 275kV. Defines 116 functions or classes, including switchTab, applyLogisticsPreset, autoFillBifacial, updateExportCableLengthDisplay, updateArrayRotationDisplay. Side effects: changes the web page (DOM); makes network requests.
Why it exists in the grid workflow
Domain stage experimental (path word 'sandbox'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow. Domain terms in the code: 400kV, 275kV, 132kV, 66kV.
Inputs & outputs
In: data source: OpenStreetMap Nominatim; JSON file repd_master.json; GeoJSON file grid_66kv.geojson; GeoJSON file grid_132kv.geojson; GeoJSON file grid_275kv.geojson; GeoJSON file grid_400kv.geojson; form fields (user input). Out: GeoJSON file v8-bess-layout.geojson; downloaded file v8-bess-layout.geojson. Voltage levels named: 400kV, 275kV, 132kV, 66kV.
What it achieves
It applies logistics preset (`applyLogisticsPreset`), updates export cable length display (`updateExportCableLengthDisplay`) and updates array rotation display (`updateArrayRotationDisplay`). Defines `switchTab`, `applyLogisticsPreset`, `autoFillBifacial` and 113 more. Its code works with 132 kV, 275 kV and 400 kV. It reads `/dist/repd_master.json`. It responds to click, focus and input events.
Why it matters
No other file in the estate was found to import it.
Application
globalgrid2050 · solar-bess-topology-v8/bess-gis-sld-financial-sandbox · script
Uses
none found
Used by
none found
Produces
switchTab, applyLogisticsPreset, autoFillBifacial, updateExportCableLengthDisplay, updateArrayRotationDisplay, rotateArrayBy, resetArrayRotation, getCurrentArrayCenter, getArrayNudgeStepKm, clearRouteAfterArrayShift, nudgeArray, updateCableRouteStatus
Defines here
fitContextMapForPrint, setSatelliteForPrintPack, prepareGisSldPrintReport, v8n, v8s, v8Set, v8Fmt, v8BessCalc, v8UpdateBessSummary, v8MetresToLngLat, v8Rotate, v8RectFeature, v8PointFeature, v8LineFeature, v8BuildBessGeoJson, v8EnsureBessGeoLayers, v8RefreshBessGeo, v8DrawBessAtMapCentre, v8ResetBessGeo, v8ExportBessGeoJson, v8InitBessUi
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-v8/bess-gis-sld-financial-sandbox/gis-sld-v5-ui.js:1401-1667 · blob 4e77c00499d636771a34491f9e809f4bd9b34f41 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom, network · domain stage: experimental · users: none · canonical: unreached_review
        if (!bbox || bbox.length !== 4 || bbox.some(v => !Number.isFinite(v))) return null;
        return [[bbox[0], bbox[1]], [bbox[2], bbox[3]]];
    } catch (err) {
        console.warn("Print pack bbox failed", err);
        return null;
    }
}

async function fitContextMapForPrint() {
    const bounds = getTopologyBoundsForPrintPack();
    if (bounds) {
        map.fitBounds(bounds, { padding: 90, duration: 0, maxZoom: 12 });
    } else {
        const currentZoom = map.getZoom();
        map.setZoom(Math.max(currentZoom - 4, 7));
    }
    await sleepForPrintPack(750);
}

async function setSatelliteForPrintPack(active) {
    if (!map) return;
    if (typeof state !== "undefined") state.satActive = !!active;
    setLayerVisibilityForPrintPack("l-sat", !!active);
    const btn = $("btn_basemap");
    if (btn) {
        btn.textContent = active ? "DARK MATTER VIEW" : "SATELLITE VIEW";
        btn.classList.toggle("active", !!active);
    }
    await sleepForPrintPack(500);
}

async function prepareGisSldPrintReport() {
    if (!map) {
        window.print();
        return;
    }

    const btn = $("btn_print_report");
    const oldText = btn ? btn.textContent : "";
    if (btn) btn.textContent = "PREPARING";

    const saved = getMapPrintState();
    const pack = ensurePrintMapPackContainer();

    try {
        document.body.classList.add("preparing-print-pack");
        document.body.classList.remove("map-expanded");
        document.querySelector(".panel-right")?.classList.remove("map-expanded");
        $("map_tool_overlay")?.classList.add("tools-collapsed");
        $("map_legend")?.classList.add("key-collapsed");

        // Page 1 map: current working view, but clean with user selected layers retained.
        map.resize();
        await sleepForPrintPack(600);
        const currentMap = await captureCurrentMapForPrint();
        addPrintMapFigure(pack, "Map Figure 1: Current Project View", currentMap, "Current GIS SLD project view. Interactive controls are removed from print output.");

        // Page 2 map: zoomed out context. Keep current basemap and layer settings.
        await fitContextMapForPrint();
        const contextMap = await captureCurrentMapForPrint();
        addPrintMapFigure(pack, "Map Figure 2: Wider Grid And Route Context", contextMap, "Zoomed out context view showing wider relationship between project, route assumptions and grid geography.");

        // Page 3 map: satellite view, clean and full page.
        await setSatelliteForPrintPack(true);
        await fitContextMapForPrint();
        const satelliteMap = await captureCurrentMapForPrint();
        addPrintMapFigure(pack, "Map Figure 3: Satellite Context View", satelliteMap, "Satellite context view for visual land, route and surrounding area review. Indicative only.", true);

        await restoreMapPrintState(saved);
        document.body.classList.remove("preparing-print-pack");
        if (btn) btn.textContent = oldText || "PRINT";
        window.print();
    } catch (err) {
        console.error("GIS SLD print pack failed", err);
        await restoreMapPrintState(saved);
        document.body.classList.remove("preparing-print-pack");
        if (btn) btn.textContent = oldText || "PRINT";
        window.print();
    }
}

// Clean map defaults after the map and controls have loaded.
// setTimeout(enforceCleanDefaultMapLayers, 1200); // disabled by simple safe print fix


// --- V8 BESS geospatial drawing layer built on working V7 GIS frame ---
window.v8BessGeoJson = { type: 'FeatureCollection', features: [] };

function v8n(id, fallback = 0) {
    const el = document.getElementById(id);
    const value = parseFloat(el ? el.value : fallback);
    return Number.isFinite(value) ? value : fallback;
}

function v8s(id, fallback = '') {
    const el = document.getElementById(id);
    return el ? el.value : fallback;
}

function v8Set(id, text) {
    const el = document.getElementById(id);
    if (el) el.textContent = text;
}

function v8Fmt(value, digits = 2) {
    return Number.isFinite(value) ? value.toLocaleString(undefined, { maximumFractionDigits: digits }) : '0';
}

function v8BessCalc() {
    const exportMw = v8n('bess_export_mw', 50);
    const duration = v8n('bess_duration_h', 3);
    const energy = v8n('bess_energy_mwh', exportMw * duration);
    const containerMwh = Math.max(0.1, v8n('bess_container_mwh', 5));
    const pcsMw = Math.max(0.1, v8n('bess_pcs_mw', 50));
    const containersPerPcs = Math.max(1, Math.round(v8n('bess_containers_per_pcs', 30)));
    const containers = Math.max(1, Math.ceil(energy / containerMwh));
    const pcsByPower = Math.max(1, Math.ceil(exportMw / pcsMw));
    const pcsByContainers = Math.max(1, Math.ceil(containers / containersPerPcs));
    const pcsCount = Math.max(pcsByPower, pcsByContainers);
    const totalPcsMw = pcsCount * pcsMw;
    const containersPerRow = Math.max(1, Math.round(v8n('bess_containers_per_row', 10)));
    const rows = Math.max(1, Math.ceil(containers / containersPerRow));
    const lengthM = Math.max(1, v8n('bess_container_l', 12.2));
    const widthM = Math.max(1, v8n('bess_container_w', 2.44));
    const gapM = Math.max(0, v8n('bess_container_gap', 2.5));
    const rowGapM = Math.max(0, v8n('bess_row_gap', 6));
    const fieldLength = containersPerRow * lengthM + Math.max(0, containersPerRow - 1) * gapM;
    const fieldWidth = rows * widthM + Math.max(0, rows - 1) * rowGapM;
    return { exportMw, duration, energy, containerMwh, pcsMw, containersPerPcs, containers, pcsCount, totalPcsMw, containersPerRow, rows, lengthM, widthM, gapM, rowGapM, fieldLength, fieldWidth, layoutMode: v8s('bess_layout_mode', 'integrated'), accessRoadM: v8n('bess_access_road_m', 6), rotation: v8n('bess_rotation_deg', 0) };
}

function v8UpdateBessSummary() {
    const c = v8BessCalc();
    v8Set('bess_out_containers', String(c.containers));
    v8Set('bess_out_pcs', String(c.pcsCount));
    v8Set('bess_out_pcs_power', v8Fmt(c.totalPcsMw, 1) + ' MW');
    v8Set('bess_out_field', v8Fmt(c.fieldLength, 1) + ' m x ' + v8Fmt(c.fieldWidth, 1) + ' m');
    v8Set('bess_out_export', v8Fmt(c.exportMw, 1) + ' MW');
    v8Set('bess_out_duration', c.exportMw > 0 ? v8Fmt(c.energy / c.exportMw, 2) + ' h' : '0 h');
}

function v8MetresToLngLat(origin, eastM, northM) {
    const lat = origin.lat;
    const lng = origin.lng;
    return [lng + eastM / (111320 * Math.cos(lat * Math.PI / 180)), lat + northM / 111320];
}

function v8Rotate(x, y, deg) {
    const rad = deg * Math.PI / 180;
    return [x * Math.cos(rad) - y * Math.sin(rad), x * Math.sin(rad) + y * Math.cos(rad)];
}

function v8RectFeature(origin, cx, cy, w, h, rotation, props) {
    const coords = [[-w/2,-h/2],[w/2,-h/2],[w/2,h/2],[-w/2,h/2],[-w/2,-h/2]].map(([x,y]) => {
        const [rx, ry] = v8Rotate(cx + x, cy + y, rotation);
        return v8MetresToLngLat(origin, rx, ry);
    });
    return { type:'Feature', properties:props, geometry:{ type:'Polygon', coordinates:[coords] } };
}

function v8PointFeature(origin, x, y, rotation, props) {
    const [rx, ry] = v8Rotate(x, y, rotation);
    return { type:'Feature', properties:props, geometry:{ type:'Point', coordinates:v8MetresToLngLat(origin, rx, ry) } };
}

function v8LineFeature(origin, points, rotation, props) {
    return { type:'Feature', properties:props, geometry:{ type:'LineString', coordinates:points.map(([x,y]) => { const [rx, ry] = v8Rotate(x, y, rotation); return v8MetresToLngLat(origin, rx, ry); }) } };
}

function v8BuildBessGeoJson(origin) {
    const c = v8BessCalc();
    const features = [];
    const cols = Math.max(1, Math.min(c.containersPerRow, 30));
    const rows = Math.max(1, Math.ceil(c.containers / cols));
    const pitchX = c.lengthM + c.gapM;
    const pitchY = c.widthM + c.rowGapM;
    const fieldW = cols * c.lengthM + Math.max(0, cols - 1) * c.gapM;
    const fieldH = rows * c.widthM + Math.max(0, rows - 1) * c.rowGapM;
    const startX = -fieldW / 2 + c.lengthM / 2;
    const startY = fieldH / 2 - c.widthM / 2;
    const pad = Math.max(25, c.accessRoadM * 3);
    const electricalX = fieldW / 2 + 55;
    const roadY = -fieldH / 2 - Math.max(18, c.accessRoadM);

    features.push(v8RectFeature(origin, 0, 0, fieldW + pad * 2 + 220, fieldH + pad * 2 + 120, c.rotation, { role:'compound_boundary', label:'BESS compound boundary', layout_mode:c.layoutMode }));
    features.push(v8RectFeature(origin, 0, roadY, fieldW + pad * 2 + 160, Math.max(6, c.accessRoadM), c.rotation, { role:'access_road', label:'Access road and maintenance corridor' }));

    for (let i = 0; i < c.containers; i++) {
        const col = i % cols;
        const row = Math.floor(i / cols);
        features.push(v8RectFeature(origin, startX + col * pitchX, startY - row * pitchY, c.lengthM, c.widthM, c.rotation, { role:'bess_container', label:'BESS container ' + (i + 1), container_mwh:c.containerMwh }));
    }

    const pcsShown = Math.min(c.pcsCount, 40);
    for (let i = 0; i < pcsShown; i++) {
        let x = electricalX;
        let y = fieldH / 2 - i * 16;
        if (c.layoutMode === 'distributed') { x = startX + (i % cols) * pitchX; y = fieldH / 2 + 26 + Math.floor(i / Math.max(1, cols)) * 16; }
        if (c.layoutMode === 'corridor') { x = 0; y = roadY - 25 - i * 15; }
        if (c.layoutMode === 'central') { x = electricalX; y = 0; }
        features.push(v8RectFeature(origin, x, y, c.layoutMode === 'integrated' ? 22 : 14, 10, c.rotation, { role:c.layoutMode === 'integrated' ? 'integrated_pcs_transformer' : 'pcs_block', label:c.layoutMode === 'integrated' ? 'Integrated PCS transformer ' + (i + 1) : 'PCS block ' + (i + 1), pcs_mw:c.pcsMw }));
    }

    if (c.layoutMode !== 'integrated') features.push(v8RectFeature(origin, electricalX + 42, 0, 28, 18, c.rotation, { role:'external_transformer', label:'External transformer zone' }));
    if (c.layoutMode === 'hv_compound') features.push(v8RectFeature(origin, electricalX + 88, -36, 58, 38, c.rotation, { role:'hv_compound_placeholder', label:'Future HV compound placeholder' }));
    features.push(v8PointFeature(origin, electricalX + 120, roadY - 50, c.rotation, { role:'grid_export_point', label:'Grid export point', export_mw:c.exportMw }));
    features.push(v8LineFeature(origin, [[fieldW / 2, 0], [electricalX - 10, 0]], c.rotation, { role:'dc_collection_path', label:'Indicative DC collection path, not cable sizing' }));
    return { type:'FeatureCollection', features };
}

function v8EnsureBessGeoLayers() {
    if (!window.map) return;
    if (!map.getSource('v8-bess-layout')) map.addSource('v8-bess-layout', { type:'geojson', data:window.v8BessGeoJson });
    const layers = [
        ['v8-bess-boundary', ['==',['get','role'],'compound_boundary'], 'rgba(43,124,255,0.08)', 'rgba(43,124,255,0.75)'],
        ['v8-bess-containers', ['==',['get','role'],'bess_container'], 'rgba(0,255,136,0.38)', 'rgba(0,255,136,0.95)'],
        ['v8-bess-pcs', ['any',['==',['get','role'],'pcs_block'],['==',['get','role'],'integrated_pcs_transformer']], 'rgba(0,255,255,0.38)', 'rgba(0,255,255,0.95)'],
        ['v8-bess-transformer', ['any',['==',['get','role'],'external_transformer'],['==',['get','role'],'hv_compound_placeholder']], 'rgba(255,153,0,0.38)', 'rgba(255,153,0,0.95)'],
        ['v8-bess-road', ['==',['get','role'],'access_road'], 'rgba(120,80,40,0.55)', 'rgba(120,80,40,0.95)']
    ];
    layers.forEach(([id, filter, fill, outline]) => { if (!map.getLayer(id)) map.addLayer({ id, type:'fill', source:'v8-bess-layout', filter, paint:{ 'fill-color':fill, 'fill-outline-color':outline } }); });
    if (!map.getLayer('v8-bess-path')) map.addLayer({ id:'v8-bess-path', type:'line', source:'v8-bess-layout', filter:['==',['get','role'],'dc_collection_path'], paint:{ 'line-color':'#ff9900', 'line-width':3, 'line-dasharray':[2,2] } });
    if (!map.getLayer('v8-bess-export')) map.addLayer({ id:'v8-bess-export', type:'circle', source:'v8-bess-layout', filter:['==',['get','role'],'grid_export_point'], paint:{ 'circle-radius':7, 'circle-color':'#ffffff', 'circle-stroke-color':'#00ffff', 'circle-stroke-width':2 } });
}

function v8RefreshBessGeo() {
    if (!window.map) return;
    v8EnsureBessGeoLayers();
    const source = map.getSource('v8-bess-layout');
    if (source) source.setData(window.v8BessGeoJson);
}

function v8DrawBessAtMapCentre() {
    if (!window.map) return;
    window.v8BessGeoJson = v8BuildBessGeoJson(map.getCenter());
    v8RefreshBessGeo();
}

function v8ResetBessGeo() {
    window.v8BessGeoJson = { type:'FeatureCollection', features:[] };
    v8RefreshBessGeo();
}

function v8ExportBessGeoJson() {
    const blob = new Blob([JSON.stringify(window.v8BessGeoJson, null, 2)], { type:'application/geo+json' });
    const url = URL.createObjectURL(blob);
    const a = document.createElement('a');
    a.href = url;
    a.download = 'v8-bess-layout.geojson';
    document.body.appendChild(a);
    a.click();
    a.remove();
    URL.revokeObjectURL(url);
}

function v8InitBessUi() {
    document.getElementById('btn_bess_sync_energy')?.addEventListener('click', () => { document.getElementById('bess_energy_mwh').value = v8Fmt(v8n('bess_export_mw', 50) * v8n('bess_duration_h', 3), 2); v8UpdateBessSummary(); });
    document.getElementById('btn_bess_draw_geo')?.addEventListener('click', v8DrawBessAtMapCentre);
    document.getElementById('btn_bess_reset_geo')?.addEventListener('click', v8ResetBessGeo);
    document.getElementById('btn_bess_export_geojson')?.addEventListener('click', v8ExportBessGeoJson);
    document.querySelectorAll('#v8_bess_panel input, #v8_bess_panel select').forEach(el => { el.addEventListener('input', v8UpdateBessSummary); el.addEventListener('change', v8UpdateBessSummary); });
    setTimeout(() => { if (window.map) { map.on('style.load', v8RefreshBessGeo); map.on('load', v8RefreshBessGeo); } }, 1000);
    v8UpdateBessSummary();
}

document.addEventListener('DOMContentLoaded', v8InitBessUi);

GIS Single-Line Diagram (SLD) V5

A style sheet in GlobalGrid2050 covering battery storage (BESS), solar, substations and wind. Served with the page at https://globalgrid2050.com/solar-bess-topology-v8/bess-gis-sld-financial-sandbox/.

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

Evidence
  • line-jaccard 0.9825 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-bess-topology-v7/gis-sld-financial-sandbox/gis-sld-v5.css:1-1937 36ce2f996340b4091a4731d485cb5ff81aba65a6
  • sha256 1f99fea4021db2516957c5db64bb2c9528c281af167c48ecdd195711af1d5e92
  • target sha256 cb958bf2f64e56899dad834c3445a2dbaa487555f7939aa3fe2c5f726cc2f983
  • group of 2 (identity.json near-copy edges >= 0.9)
  • canonical rule: reachable, newest stamp, core repo, most lines

electricalglobalgrid2050 / solar-bess-topology-v8/bess-gis-sld-financial-sandbox/gis-sld-v5.css · lines 1–433 of 1967 · Not reached from any entry point (candidate for review)

What it does
Side effects: changes the web page (DOM).
Why it exists in the grid workflow
Domain stage experimental (path word 'sandbox'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow. Domain terms in the code: battery storage (BESS), solar, substations, wind, 400kV, 275kV.
Inputs & outputs
Voltage levels named: 400kV, 275kV, 132kV, 66kV.
What it achieves
No statement of purpose was found in the file, a README line naming it, or its name.
Why it matters
No other file in the estate was found to import it.
Application
globalgrid2050 · solar-bess-topology-v8/bess-gis-sld-financial-sandbox · style sheet
Uses
none found
Used by
none found
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-v8/bess-gis-sld-financial-sandbox/gis-sld-v5.css:1-433 · blob 789814a3ca636e34e5a4b70ec78d9887db63a782 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: experimental · users: none · canonical: unreached_review
: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 20px 80px 20px;
  flex-shrink: 0;
  overflow-y: auto;
  align-items: stretch;
}

.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 12px 28px 12px;
  border-radius: 3px;
  margin-top: 15px;
  line-height: 1.55;
  text-align: justify;
  flex: 0 0 auto;
  max-height: none;
  overflow: visible;
}

.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-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.map-toggle-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;