GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Cables and conductors / globalgrid2050 / solar-bess-topology-v5

Cable Geometry Visualiser V5 (part 1)

A web page in GlobalGrid2050 covering cables, 33kV, 132kV and solar, using BS EN 50618 and BS 7671, and uses data from UK Power Networks open data. Published at https://globalgrid2050.com/solar-bess-topology-v5/cable-geometry-visualiser-v5.html.

700 lines of HTML from globalgrid2050, in 1 file. Topic: Cables and conductors. Section 18 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. Cable Geometry Visualiser V5 electrical · globalgrid2050 / solar-bess-topology-v5/cable-geometry-visualiser-v5.html lines 1–700

Cable Geometry Visualiser V5

A web page in GlobalGrid2050 covering cables, 33kV, 132kV and solar, using BS EN 50618 and BS 7671, and uses data from UK Power Networks open data. Published at https://globalgrid2050.com/solar-bess-topology-v5/cable-geometry-visualiser-v5.html.

electricalglobalgrid2050 / solar-bess-topology-v5/cable-geometry-visualiser-v5.html · lines 1–700 of 2051 · Entry point · pattern normaliseBurialDepthFieldOnBlur (shared by 4 files)

What it does
It draws cables, 33kV, 132kV and solar. Defines 41 functions or classes, including lookupOD, byId, clampInteger, formatMm, effectiveGap. 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: cables, 33kV, 132kV, solar, 110kV, 66kV.
Inputs & outputs
In: form fields (user input). Out: web page; canvas drawing. Voltage levels named: 132kV, 110kV, 66kV, 33kV, 20kV, 15kV, 10kV, 6kV.
Downstream impact
Used directly by 13 files: Module Layout V5 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v5/module-layout-v5.html); Kuiper Tests (globalgrid2050); Kuiper Tests (globalgrid2050); Kuiper Tests (globalgrid2050); and 9 more. Reached from 94 other entry points, including DC AC LV Topology Review V5 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v5/dc-ac-lv-topology-review-v5.html); GlobalGrid2050 Historical Builds (globalgrid2050, https://globalgrid2050.com/historical_builds.html); GlobalGrid2050 Homepage Before Four Nests (globalgrid2050, https://globalgrid2050.com/homepage-before-four-nests-20260925.html). It is itself an entry point, published at https://globalgrid2050.com/solar-bess-topology-v5/cable-geometry-visualiser-v5.html.
What it achieves
It looks up od (`lookupOD`), clamps integer (`clampInteger`) and formats mm (`formatMm`). Defines `lookupOD`, `byId`, `clampInteger` and 38 more. Its code works with 1 kV, 33 kV and 132 kV. It responds to focus, click and touchend events.
Why it matters
Loaded by the Module Layout V5 page at https://globalgrid2050.com/solar-bess-topology-v5/module-layout-v5.html and 4 other pages. Also imported by Watch, from Time Stone. Checked by 7 tests, including Kuiper Tests.
Application
globalgrid2050 · solar-bess-topology-v5 · page
Uses
Module Layout V5 (link), DC AC LV Topology Review V5 (link)
Used by
linked from Module Layout V5 (link), named by URL in Kuiper Tests (estate URL), named by URL in Kuiper Tests (estate URL), named by URL in Kuiper Tests (estate URL), named by URL in Kuiper Tests (estate URL), named by URL in Kuiper Tests (estate URL), named by URL in Kuiper Tests (estate URL), named by URL in Kuiper Tests (estate URL), and 5 more
Produces
lookupOD, byId, clampInteger, formatMm, effectiveGap, getBurialDepthForComputation, normaliseBurialDepthFieldOnBlur, normaliseIntegerFields, getInputs, getGroupGeometry, computeLayout, buildReview
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-v5/cable-geometry-visualiser-v5.html:1-700 · blob aec703fef5d69bf8db682aa4a0f4dc769aaff445 · 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
<!DOCTYPE html>

<html lang="en">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Cable Geometry Visualiser V5 | GlobalGrid2050</title>
    <style>
        :root {
            --bg: #050505;
            --panel: rgba(10, 10, 10, 0.96);
            --panel-soft: #0b0e14;
            --line: #2f343d;
            --line-soft: #222;
            --text: #ffffff;
            --muted: #a6adbb;
            --muted-soft: #8d95a3;
            --accent: #00ffff;
            --accent-2: #ff00ff;
            --ok: #00ff88;
            --warn: #ffcc66;
            --warn-bg: rgba(80, 50, 0, 0.18);
            --warn-line: #5a3d00;
            --error: #ff6666;
            --error-bg: rgba(80, 10, 10, 0.18);
            --error-line: #5a1f1f;
            --info: #8fb2d9;
            --info-bg: rgba(14, 32, 48, 0.28);
            --info-line: #28455d;
            --input-bg: #111;
            --canvas-bg: #000;
            --shadow: 0 0 15px rgba(0, 0, 0, 0.5);
        }

        * { box-sizing: border-box; }

        html, body { max-width: 100%; overflow-x: hidden; }

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

        .dashboard {
            display: flex;
            gap: 20px;
            width: 100%;
            max-width: 1480px;
            min-width: 0;
            align-items: flex-start;
        }

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

        .panel-left {
            width: 470px;
            flex-shrink: 0;
        }

        .panel-right {
            flex: 1 1 auto;
            display: flex;
            flex-direction: column;
            gap: 20px;
        }

        h2 {
            margin: 0 0 15px 0;
            color: var(--accent);
            font-size: 18px;
            letter-spacing: 2px;
            text-transform: uppercase;
            border-bottom: 1px solid var(--line);
            padding-bottom: 10px;
        }

        h3 {
            margin: 0 0 10px 0;
            color: var(--muted-soft);
            font-size: 12px;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        .section-title { margin-top: 18px; }

        .subtle-note {
            font-size: 11px;
            color: #999;
            line-height: 1.45;
            margin: 0 0 14px 0;
        }

        .warning-box,
        .status-box,
        .guidance-box,
        .assumption-box,
        .review-box,
        .conflict-box {
            padding: 12px;
            font-size: 11px;
            line-height: 1.5;
            border-radius: 3px;
        }

        .warning-box {
            border: 1px solid var(--warn-line);
            background: var(--warn-bg);
            color: var(--warn);
            margin-bottom: 18px;
        }

        .guidance-box {
            border: 1px solid #30455a;
            background: #08101a;
            color: #bed1e2;
            margin-top: 16px;
        }

        .guidance-box strong,
        .assumption-box strong,
        .review-box strong,
        .conflict-box strong { color: #fff; }

        .guidance-box a { color: #8fd3ff; text-decoration: underline; }
        .guidance-box a:hover { color: #c5e7ff; }

        .guidance-box ul,
        .review-box ul,
        .conflict-box ul,
        .assumption-box ul { margin: 8px 0 0 18px; padding: 0; }

        .guidance-box li + li,
        .review-box li + li,
        .conflict-box li + li,
        .assumption-box li + li { margin-top: 4px; }

        .assumption-box {
            margin-top: 16px;
            border: 1px solid var(--info-line);
            background: var(--info-bg);
            color: var(--info);
        }

        .review-box {
            margin-top: 16px;
            border: 1px solid var(--warn-line);
            background: var(--warn-bg);
            color: var(--warn);
        }

        .conflict-box {
            margin-top: 16px;
            border: 1px solid var(--error-line);
            background: var(--error-bg);
            color: #ffb0b0;
        }

        .status-box {
            margin: 0 0 16px 0;
            border: 1px solid var(--line);
            background: #090c11;
            color: var(--muted);
        }

        .status-box.ok    { border-color: rgba(0,255,136,0.35);  color: #aef7d1; }
        .status-box.warn  { border-color: rgba(255,204,102,0.35); color: #ffd98a; }
        .status-box.error { border-color: rgba(255,102,102,0.35); color: #ffb0b0; }

        .input-group {
            display: flex;
            justify-content: space-between;
            gap: 12px;
            margin-bottom: 10px;
            font-size: 12px;
            color: var(--muted);
            align-items: center;
        }

        .input-group label { flex: 1 1 auto; min-width: 0; }

        .input-group input,
        .input-group select {
            width: 190px;
            background: var(--input-bg);
            color: var(--accent);
            border: 1px solid #444;
            padding: 7px 8px;
            font-family: monospace;
            border-radius: 3px;
        }

        .input-group input[data-numeric="true"] { text-align: right; }
        .input-group input[type="text"]:not([data-numeric]) { text-align: left; }

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

        .input-group input[disabled] { opacity: 0.55; cursor: not-allowed; }

        .inline-note {
            margin: -2px 0 10px 0;
            font-size: 10px;
            color: var(--muted-soft);
        }

        .stat-block {
            margin-top: 18px;
            border-top: 1px solid var(--line);
            padding-top: 14px;
        }

        .stat-row {
            display: flex;
            justify-content: space-between;
            gap: 12px;
            font-size: 12px;
            margin-bottom: 8px;
            color: var(--muted-soft);
            padding: 4px 0;
        }

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

        .canvas-container {
            background: var(--panel-soft);
            border: 1px solid var(--line-soft);
            border-radius: 4px;
            padding: 15px;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        canvas {
            background: var(--canvas-bg);
            border: 1px solid #333;
            box-shadow: var(--shadow);
            display: block;
            max-width: 100%;
            height: auto;
        }

        .button-row {
            display: flex;
            gap: 10px;
            margin-top: 14px;
        }

        .btn {
            flex: 1 1 auto;
            padding: 12px;
            background: var(--bg);
            color: var(--ok);
            border: 1px solid var(--ok);
            cursor: pointer;
            font-family: monospace;
            font-weight: bold;
            text-transform: uppercase;
            border-radius: 3px;
            transition: all 0.2s;
        }

        .btn:hover { background: var(--ok); color: #000; }
        .btn-alt { color: var(--accent-2); border-color: var(--accent-2); }
        .btn-alt:hover { background: var(--accent-2); color: #000; }

        .snapshot-box {
            margin-top: 16px;
            border: 1px solid var(--line-soft);
            background: #07090d;
            padding: 12px;
            border-radius: 3px;
            font-size: 11px;
            color: #cfcfcf;
            line-height: 1.45;
            white-space: pre-wrap;
        }

        .legend {
            display: flex;
            gap: 14px;
            align-self: flex-start;
            font-size: 11px;
            color: var(--muted);
            margin: 0 0 10px 0;
            flex-wrap: wrap;
        }

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

        .legend-swatch {
            width: 12px;
            height: 12px;
            border-radius: 50%;
            border: 1px solid #666;
        }

        /* Drawing view: hide left panel, maximise canvases */
        body.drawing-view .panel-left { display: none; }
        body.drawing-view .dashboard { max-width: 100%; }
        body.drawing-view .panel-right { width: 100%; }
        body.drawing-view .canvas-container { padding: 12px; }
        body.drawing-view .subtle-note { margin-bottom: 8px; }

        /* Landscape mobile */
        @media (orientation: landscape) and (max-width: 1200px) {
            body.landscape-mobile .panel-left { display: none; }
            body.landscape-mobile .dashboard { max-width: 100%; }
            body.landscape-mobile .panel-right { width: 100%; }
            body.landscape-mobile .canvas-container { padding: 10px; }
            body.landscape-mobile .subtle-note { margin-bottom: 8px; font-size: 10px; }
        }

        @media (max-width: 1080px) {
            .dashboard { flex-direction: column; }
            .panel-left { width: 100%; }
        }
    

        @media (max-width: 700px) {
            body { padding: 12px; }
            .panel { padding: 14px; width: 100%; max-width: 100%; overflow-x: hidden; }
            .panel-left { width: 100%; }
            .dashboard { width: 100%; max-width: 100%; overflow-x: hidden; }
            .input-group { flex-direction: column; align-items: stretch; gap: 4px; }
            .input-group input, .input-group select { width: 100%; max-width: 100%; }
            .button-row { flex-direction: column; }
            .btn { width: 100%; white-space: normal; }
            h2 { font-size: 16px; overflow-wrap: anywhere; }
            canvas { width: 100%; max-width: 100%; }
        }

    </style>
</head>
<body>
    <div class="dashboard">
        <div class="panel panel-left">
            <h2>Cable Geometry Visualiser V5</h2>
            <div class="guidance-box"><strong>GlobalGrid2050 V5 migration</strong><br>This page is migrated from the original cable geometry visualiser into the V5 toolset. It remains a geometry capture and visual review tool only. It does not perform electrical rating, thermal rating, cable sizing, protection grading or construction design.</div>

            <div class="button-row"><a class="btn" href="./module-layout-v5.html" style="text-align:center;text-decoration:none;">Module Layout V5</a><a class="btn btn-alt" href="./dc-ac-lv-topology-review-v5.html" style="text-align:center;text-decoration:none;">DC AC LV Topology Review</a></div>

            <h3 class="section-title">Geometry Inputs</h3>

            <div class="warning-box">
                This tool produces indicative geometry records only and must not be used for trench design, duct sizing, burial depth specification, electrical design or any construction document without independent verification by a competent engineer with responsibility for the project.<br>
                No electrical calculation is performed.<br>
                No thermal rating is performed.<br>
                No compliance verdict is produced.<br>
                No burial depth design advice is produced.<br>
                The user must verify safety, installation depth, protection, rating and utility compliance with a competent person in accordance with local law, site conditions and the relevant power utility or infrastructure owner requirements.
            </div>

            <div id="status_box" class="status-box ok" aria-live="polite">Geometry only. Ready for capture.</div>

            <h3>Route Identity</h3>
            <div class="input-group">
                <label for="route_name">Route ID</label>
                <input type="text" id="route_name" value="M_W3_BESS_to_PCS" />
            </div>
            <div class="input-group">
                <label for="section_length">Worst Case Section Length m</label>
                <input type="text" inputmode="decimal" enterkeyhint="done" autocomplete="off" autocorrect="off" spellcheck="false" data-numeric="true" id="section_length" value="30" />
            </div>

            <h3 class="section-title">Installation Basis</h3>
            <div class="input-group">
                <label for="installation_condition">Installation Condition</label>
                <select id="installation_condition">
                    <option value="buried_duct">Buried Duct</option>
                    <option value="direct_buried">Direct Buried</option>
                    <option value="open_trough">Open Trough</option>
                    <option value="free_air">Free Air on Cleats</option>
                    <option value="metallic_enclosure">Metallic Enclosure</option>
                </select>
            </div>
            <div class="input-group">
                <label for="service_type">Service Type</label>
                <select id="service_type">
                    <option value="lv" selected>LV AC</option>
                    <option value="mv">33kV AC</option>
                    <option value="ehv">132kV AC</option>
                    <option value="dc">DC</option>
                </select>
            </div>
            <div class="input-group">
                <label for="grouping_basis">Grouping Basis</label>
                <select id="grouping_basis">
                    <option value="same_circuit">Same Circuit</option>
                    <option value="same_service">Same Service</option>
                    <option value="mixed_service">Mixed Service</option>
                </select>
            </div>
            <div class="input-group">
                <label for="burial_depth">Burial Depth mm</label>
                <input type="text" inputmode="decimal" enterkeyhint="done" autocomplete="off" autocorrect="off" spellcheck="false" data-numeric="true" id="burial_depth" value="900" />
            </div>
            <div class="inline-note" id="burial_note">Indicative cover or depth input only. Verify with competent person and utility standard.</div>

            <h3 class="section-title">Cable OD Lookup</h3>
            <div class="input-group">
                <label for="lookup_cores">Cores</label>
                <select id="lookup_cores">
                    <option value="single">Single Core</option>
                    <option value="three">Three Core</option>
                </select>
            </div>
            <div class="input-group">
                <label for="lookup_voltage">Voltage Class</label>
                <select id="lookup_voltage">
                    <option value="">— manual OD entry —</option>
                    <optgroup label="LV Power — 0.6/1kV XLPE, Cu conductor">
                      <option value="lv_cu_sc">0.6/1kV Cu XLPE single core (AWA)</option>
                      <option value="lv_cu_2c">0.6/1kV Cu XLPE 2-core SWA</option>
                      <option value="lv_cu_3c">0.6/1kV Cu XLPE 3-core SWA</option>
                      <option value="lv_cu_4c">0.6/1kV Cu XLPE 4-core SWA</option>
                      <option value="lv_cu_5c">0.6/1kV Cu XLPE 5-core SWA</option>
                    </optgroup>
                    <optgroup label="LV Power — 0.6/1kV XLPE, Al conductor">
                      <option value="lv_al_sc">0.6/1kV Al XLPE single core (AWA)</option>
                      <option value="lv_al_3c">0.6/1kV Al XLPE 3-core SWA</option>
                      <option value="lv_al_4c">0.6/1kV Al XLPE 4-core SWA</option>
                      <option value="lv_al_5c">0.6/1kV Al XLPE 5-core SWA</option>
                    </optgroup>
                    <optgroup label="LV — Multicore, fixed installation">
                      <option value="lv3">LV 0.6/1kV 3-core</option>
                    </optgroup>
                    <optgroup label="Solar PV — DC string (flexible Cu, 1500V DC only)">
                      <option value="pv_string">1500V DC string — BS EN 50618 Class II</option>
                    </optgroup>
                    <optgroup label="Solar PV — Flexible screened (Cu screened, fixed/occasional)">
                      <option value="flex_hv_ac">1000/1000V AC — IT system (Uo=1000V ≥ inverter Vac)</option>
                      <option value="flex_hv_dc">1500V DC — flexible screened</option>
                    </optgroup>
                    <optgroup label="Solar PV — Rigid Al, Al tube armour (non-magnetic, fixed only)">
                      <option value="al_ata_ac">1000/1000V AC — Al tube armour, IT system</option>
                      <option value="al_ata_dc">1500/1500V DC — Al tube armour</option>
                    </optgroup>
                    <optgroup label="MV XLPE — fixed installation">
                      <option value="6">6 kV (3.6/6 kV)</option>
                      <option value="10">10 kV (5.8/10 kV)</option>
                      <option value="15">15 kV (8.7/15 kV)</option>
                      <option value="20">20 kV (12/20 kV)</option>
                      <option value="33">33 kV (19/33 kV) — Al</option>
                      <option value="33cu">33 kV (19/33 kV) — Cu 3-core</option>
                    </optgroup>
                    <optgroup label="HV XLPE — fixed installation ★ confirmed datasheets">
                      <option value="66">66 kV (38/66 kV) ★</option>
                      <option value="110">110 kV (64/110 kV) ★</option>
                      <option value="132">132 kV (76/132 kV) ★</option>
                    </optgroup>
                  </select>
            </div>
            <div class="input-group">
                <label for="lookup_csa">Conductor CSA mm²</label>
                <select id="lookup_csa">
                    <option value="">— select voltage first —</option>
                </select>
            </div>
            <div class="inline-note" id="lookup_note">Select voltage and CSA to auto-populate OD and bend factor. All values are for <strong>fixed installation</strong> only. Flexible applications, very tight bend radii, cleats and terminations must be verified with the cable manufacturer. ★ = anchored on confirmed datasheets. Others from catalogue model. Indicative only.</div>

            <h3 class="section-title">Formation</h3>
            <div class="input-group">
                <label for="formation_type">Formation Type</label>
                <select id="formation_type"></select>
            </div>
            <div class="input-group">
                <label for="circuit_qty">Number of Circuit Groups</label>
                <input type="text" inputmode="decimal" enterkeyhint="done" autocomplete="off" autocorrect="off" spellcheck="false" data-numeric="true" id="circuit_qty" value="4" />
            </div>
            <div class="input-group">
                <label for="max_per_row">Max Groups per Row</label>
                <input type="text" inputmode="decimal" enterkeyhint="done" autocomplete="off" autocorrect="off" spellcheck="false" data-numeric="true" id="max_per_row" value="2" />
            </div>
            <div class="input-group">
                <label for="cable_od">Cable Outer Diameter mm</label>
                <input type="text" inputmode="decimal" enterkeyhint="done" autocomplete="off" autocorrect="off" spellcheck="false" data-numeric="true" id="cable_od" value="45" />
            </div>
            <div class="inline-note" id="od_source_note">OD entered manually.</div>
            <div class="input-group">
                <label for="spacing_basis">Spacing Basis</label>
                <select id="spacing_basis">
                    <option value="clear_gap">Clear Gap</option>
                    <option value="touching">Touching</option>
                    <option value="centre_to_centre">Centre to Centre</option>
                </select>
            </div>
            <div class="input-group">
                <label for="spacing_h">Horizontal Spacing mm</label>
                <input type="text" inputmode="decimal" enterkeyhint="done" autocomplete="off" autocorrect="off" spellcheck="false" data-numeric="true" id="spacing_h" value="150" />
            </div>
            <div class="input-group">
                <label for="spacing_v">Vertical Spacing mm</label>
                <input type="text" inputmode="decimal" enterkeyhint="done" autocomplete="off" autocorrect="off" spellcheck="false" data-numeric="true" id="spacing_v" value="150" />
            </div>
            <div class="inline-note" id="spacing_note">Spacing inputs are active.</div>

            <h3 class="section-title">Bend Geometry</h3>
            <div class="input-group">
                <label for="bend_factor">Bend Radius x OD</label>
                <input type="text" inputmode="decimal" enterkeyhint="done" autocomplete="off" autocorrect="off" spellcheck="false" data-numeric="true" id="bend_factor" value="15" />
            </div>

            <div class="stat-block">
                <div class="stat-row"><span>Formation Width</span><span class="stat-val" id="out_width">0 mm</span></div>
                <div class="stat-row"><span>Formation Depth</span><span class="stat-val" id="out_depth">0 mm</span></div>
                <div class="stat-row"><span>Burial Depth Input</span><span class="stat-val" id="out_burial">0 mm</span></div>
                <div class="stat-row"><span>Indicative Trench Width</span><span class="stat-val" id="out_trench_width">0 mm</span></div>
                <div class="stat-row"><span>Indicative Trench Depth</span><span class="stat-val" id="out_trench_depth">0 mm</span></div>
                <div class="stat-row"><span>Applied Bend Radius</span><span class="stat-val" id="out_mbr" style="color: var(--accent-2);">0 mm</span></div>
                <div class="stat-row"><span>Rows</span><span class="stat-val" id="out_rows">0</span></div>
                <div class="stat-row"><span>Clear Gap Horizontal</span><span class="stat-val" id="out_gap_h">0 mm</span></div>
                <div class="stat-row"><span>Clear Gap Vertical</span><span class="stat-val" id="out_gap_v">0 mm</span></div>
                <div class="stat-row"><span>Approx Group CTC Horizontal</span><span class="stat-val" id="out_ctc_h">0 mm</span></div>
                <div class="stat-row"><span>Approx Group CTC Vertical</span><span class="stat-val" id="out_ctc_v">0 mm</span></div>
                <div class="stat-row"><span>Review Status</span><span class="stat-val" id="out_note" style="color: var(--ok);">OK</span></div>
            </div>

            <div class="button-row">
                <button class="btn" id="export_btn" type="button">Export JSON</button>
                <button class="btn btn-alt" id="copy_btn" type="button">Copy Snapshot</button>
                <button class="btn" id="drawing_view_btn" type="button">Drawing View</button>
            </div>

            <div class="conflict-box" id="conflict_box" aria-live="polite" hidden>
                <strong>Input conflicts</strong>
                <ul id="conflict_list"></ul>
            </div>

            <div class="review-box" id="review_box" aria-live="polite" hidden>
                <strong>Review points</strong>
                <ul id="review_list"></ul>
            </div>

            <div class="assumption-box">
                <strong>Standing assumptions</strong>
                <ul>
                    <li>Within group cable spacing is assumed touching unless separately modelled.</li>
                    <li>Mixed service visual uses one worst case OD for all shown services and is schematic only.</li>
                    <li>Bend visual shows a single cable body sweep only and does not model full multi cable sweep, trench profile, duct entry, pull path or installation forces.</li>
                    <li>Burial depth is recorded as an indicative input only and is not design advice.</li>
                    <li>4-core and 5-core multicore formations are drawn as a single cable OD. Within-cable core arrangement is not modelled.</li>
                </ul>
            </div>

            <div class="snapshot-box" id="snapshot_box"></div>

            <div class="guidance-box">
                <strong>Indicative burial depth guidance only</strong><br>
                Use this for early geometry capture only, not final design advice.
                <ul>
                    <li>Primary source for LV to 132kV burial depth guidance in this tool is <a href="https://g81.ukpowernetworks.co.uk/library/installation/cables/ecs-02-0019-installation-of-underground-cables-lv-to-132kv" target="_blank" rel="noopener noreferrer">UKPN ECS 02 0019 Installation of Underground Cables LV to 132kV v14.2</a>.</li>
                    <li>For this tool, burial depth should be read as depth to the top of duct or cable as applicable and then verified for the actual installation basis.</li>
                    <li>BS 7671 and ERA 69 30 give thermal rating reference depths, not utility minimum cover requirements. See the official <a href="https://electrical.theiet.org/bs-7671-18th-edition-wiring-regulations/" target="_blank" rel="noopener noreferrer">IET BS 7671 page</a>.</li>
                    <li>Street authority and underground apparatus context should be checked at the official <a href="https://www.gov.uk/government/publications/recording-of-underground-apparatus-in-streets-code-of-practice" target="_blank" rel="noopener noreferrer">GOV.UK underground apparatus code page</a>.</li>
                    <li>Street Works UK should be used as coordination context only, not as the source of the burial depth figures in this tool. See the official <a href="https://streetworks.org.uk/resources/publications/" target="_blank" rel="noopener noreferrer">Street Works UK publications page</a>.</li>
                    <li>DC minimum burial depth in this tool is a project default assumption only and has no normative source embedded in this release.</li>
                </ul>
                The user must verify safety, cover, backfill, duct arrangement, rating, separation, highway loading and protection with a competent person in accordance with the appropriate local regulation and the relevant power utility, infrastructure owner, highway authority or site designer requirements before use.
            </div>
        </div>

        <div class="panel panel-right">
            <div class="canvas-container">
                <h3 style="align-self:flex-start; color: var(--accent);">Worst Case Formation Cross Section</h3>
                <p class="subtle-note" style="align-self:flex-start;">
                    Cable group box only. Envelope width = the horizontal size of the cable group shown. Envelope depth = the vertical size of the cable group shown.
                </p>
                <div class="legend">
                    <span class="legend-item"><span class="legend-swatch" style="background:#666; border-color:#00ffff;"></span>LV AC</span>
                    <span class="legend-item"><span class="legend-swatch" style="background:#b87333; border-color:#ff5555;"></span>33kV AC</span>
                    <span class="legend-item"><span class="legend-swatch" style="background:#ffd700; border-color:#ff8800;"></span>132kV AC</span>
                    <span class="legend-item"><span class="legend-swatch" style="background:#777; border-color: var(--accent-2);"></span>DC</span>
                </div>
                <canvas id="formation_canvas" width="900" height="420" aria-label="Formation cross section visual"></canvas>
            </div>

            <div class="canvas-container">
                <h3 style="align-self:flex-start; color: #8fd3ff;">Indicative Trench Cross Section</h3>
                <p class="subtle-note" style="align-self:flex-start;">
                    Indicative trench size only. Trench width shown = worst case formation envelope width only. Trench depth shown = burial depth input to the top of duct or cable, plus cable formation depth. No bedding, side clearance, cover boards, duct OD, shoring or civil design is modelled.
                </p>
                <canvas id="trench_canvas" width="900" height="500" aria-label="Indicative trench cross section visual"></canvas>
            </div>

            <div class="canvas-container">
                <h3 style="align-self:flex-start; color: var(--accent-2);">Single Cable Bend Sweep</h3>
                <p class="subtle-note" style="align-self:flex-start;">
                    Single cable body sweep only. Not multi cable sweep, trench profile, duct entry or civil detail.
                </p>
                <canvas id="bend_canvas" width="900" height="380" aria-label="Single cable bend sweep visual"></canvas>
            </div>
        </div>
    </div>

<script>
    /* ── constants ──────────────────────────────────────────────────────────── */
    const DEFAULT_BURIAL_DEPTHS = { lv: 900, mv: 900, ehv: 900, dc: 900 };
    const MIN_BURIAL_DEPTHS     = { lv: 450, mv: 900, ehv: 900, dc: 600 };

    const FORMATION_LIBRARY = {
        lv:  [
            { value: "trefoil_single_row",  label: "Trefoil Single Row (1c×3ph)" },
            { value: "flat_single_row",     label: "Flat Single Row (1c×3ph)" },
            { value: "stacked_two_high",    label: "Stacked 2 High (1c×3ph)" },
            { value: "multicore_3c",        label: "Three Core Cable (3c)" },
            { value: "multicore_4c",        label: "Four Core Cable (4c)" },
            { value: "multicore_5c",        label: "Five Core Cable (5c)" }
        ],
        mv:  [
            { value: "trefoil_single_row",  label: "Trefoil Single Row (1c×3ph)" },
            { value: "flat_single_row",     label: "Flat Single Row (1c×3ph)" },
            { value: "stacked_two_high",    label: "Stacked 2 High (1c×3ph)" },
            { value: "multicore_3c",        label: "Three Core Cable (3c)" },
            { value: "multicore_4c",        label: "Four Core Cable (4c)" },
            { value: "multicore_5c",        label: "Five Core Cable (5c)" }
        ],
        ehv: [
            { value: "trefoil_single_row",  label: "Trefoil Single Row (1c×3ph)" },
            { value: "flat_single_row",     label: "Flat Single Row (1c×3ph)" }
        ],
        dc:  [
            { value: "dc_pair_horizontal",  label: "DC Pair Horizontal" },
            { value: "dc_pair_vertical",    label: "DC Pair Vertical" }
        ]
    };

    /* ── OD lookup database ───────────────────────────────────────────────────
     * Single-core: model OD = 21.408 + 1.3736·√CSA + 0.3530·Uo  (RMSE 0.64mm)
     * Anchored on: Utility 66kV (300,400mm²), Utility 132kV (300,630,1000,1200,1600mm²),
     * Manufacturer 110kV (630mm²), Catalogue 33kV full series.
     * Three-core Al: Catalogue direct values (33kV unarmoured Al).
     * Three-core Cu: Catalogue direct values (33kV unarmoured Cu).
     * Lower voltages from catalogue; 66kV+ single-core only —
     * three-core cables do not exist at 66 kV and above.
     * MBR: actual datasheet values where confirmed; 15×OD otherwise (Utility standard).
     * 110kV uses 25×OD (laying MBR per their datasheet).
     * All values indicative for routing/civils planning only.
     * Verify against manufacturer datasheet before any design or procurement.
     */

    // Model coefficients (single core, fitted to Utility/Manufacturer data)
    const OD_A = 21.408, OD_B = 1.3736, OD_C = 0.353;

    const OD_CONFIRMED = {
        // 66kV (Uo=38)
        "sc_38_300":  { od: 59,   mbr: 885,  src: "Utility schedule" },
        "sc_38_400":  { od: 62,   mbr: 930,  src: "Utility schedule" },
        // 132kV (Uo=76)
        "sc_76_300":  { od: 72,   mbr: 1080, src: "Utility schedule" },
        "sc_76_630":  { od: 83,   mbr: 1245, src: "Utility schedule" },
        "sc_76_1000": { od: 91,   mbr: 1365, src: "Utility schedule" },
        "sc_76_1200": { od: 97,   mbr: 1455, src: "Utility schedule" },
        "sc_76_1600": { od: 104,  mbr: 1560, src: "Utility schedule" },
        // 110kV (Uo=64)
        "sc_64_630":  { od: 76.4, mbr: 1910, src: "Manufacturer datasheet" },
        // 33kV single core (Uo=18) — catalogue values
        "sc_18_35":   { od: 36.5, mbr: 548,  src: "Generic catalogue" },
        "sc_18_50":   { od: 37.5, mbr: 563,  src: "Generic catalogue" },
        "sc_18_70":   { od: 39.5, mbr: 593,  src: "Generic catalogue" },
        "sc_18_95":   { od: 41.0, mbr: 615,  src: "Generic catalogue" },
        "sc_18_120":  { od: 43.0, mbr: 645,  src: "Generic catalogue" },
        "sc_18_150":  { od: 44.5, mbr: 668,  src: "Generic catalogue" },
        "sc_18_185":  { od: 46.5, mbr: 698,  src: "Generic catalogue" },
        "sc_18_240":  { od: 49.5, mbr: 743,  src: "Generic catalogue" },
        "sc_18_300":  { od: 51.5, mbr: 773,  src: "Generic catalogue" },
        "sc_18_400":  { od: 55.0, mbr: 825,  src: "Generic catalogue" },
        "sc_18_500":  { od: 58.0, mbr: 870,  src: "Generic catalogue" },
        "sc_18_630":  { od: 62.0, mbr: 930,  src: "Generic catalogue" },
        // 33kV three core ALUMINIUM unarmoured (Uo=18) — catalogue values
        "3c_18_35":   { od: 42.0, mbr: 630,  src: "Generic catalogue" },
        "3c_18_50":   { od: 45.0, mbr: 675,  src: "Generic catalogue" },
        "3c_18_70":   { od: 48.5, mbr: 728,  src: "Generic catalogue" },
        "3c_18_95":   { od: 53.0, mbr: 795,  src: "Generic catalogue" },
        "3c_18_120":  { od: 57.0, mbr: 855,  src: "Generic catalogue" },
        "3c_18_150":  { od: 60.5, mbr: 908,  src: "Generic catalogue" },
        "3c_18_185":  { od: 64.5, mbr: 968,  src: "Generic catalogue" },
        "3c_18_240":  { od: 71.0, mbr: 1065, src: "Generic catalogue" },
        "3c_18_300":  { od: 77.5, mbr: 1163, src: "Generic catalogue" },
        "3c_18_400":  { od: 86.0, mbr: 1290, src: "Generic catalogue" },
        // 33kV three core COPPER unarmoured (Uo=18) — Power Cable Catalogue
        // ODs confirmed from Power Cable Catalogue
        // IEC 60502-2 / VDE 0276-620
        // MBR = 15×OD per catalogue (Min. bending radius: 15 x D)
        "3c_cu18_35":   { od: 68.0,  mbr: 1020, src: "Generic catalogue Cu" },
        "3c_cu18_50":   { od: 71.5,  mbr: 1073, src: "Generic catalogue Cu" },
        "3c_cu18_70":   { od: 75.0,  mbr: 1125, src: "Generic catalogue Cu" },