:root {
            --panel-bg: rgba(255,255,255,.96);
            --panel-border: rgba(17,17,17,.08);
            --panel-shadow: 0 10px 30px rgba(0,0,0,.16);
            --panel-radius: 14px;
            --safe-gap: 12px;
            --toolbar-height: 72px;
            --address-search-offset: 0px;
        }
        html, body { margin:0; width:100%; height:100%; overflow:hidden; font-family:Arial,sans-serif; }
        #layout { display:grid; grid-template-columns:60% 40%; width:100%; height:100%; position:relative; }
        #mapWrap, #rightWrap { position:relative; width:100%; height:100%; }
        #map { width:100%; height:100%; }
        #layout.layout-map, #layout.layout-3d { display: block; }
        #layout.layout-map #mapWrap { position:absolute; inset:0; z-index:1; }
        #layout.layout-map #rightWrap { position:absolute; top:10px; right:10px; width:320px; height:240px; z-index:2; border-radius:8px; overflow:hidden; box-shadow:0 4px 20px rgba(0,0,0,.2); }
        #layout.layout-map #profileWrap { display:none !important; }
        #layout.layout-3d #rightWrap { position:absolute; inset:0; z-index:1; }
        #layout.layout-3d #mapWrap { position:absolute; top:10px; right:10px; width:320px; height:240px; z-index:2; border-radius:8px; overflow:hidden; box-shadow:0 4px 20px rgba(0,0,0,.2); }
        #rightWrap { display:flex; flex-direction:column; }
        #rightWrap.lineSelected { display:grid; grid-template-rows:52% 48%; gap:0; }
        #three, #profileWrap { width:100%; position:relative; }
        #three { flex:1; min-height:0; }
        #profileWrap { display:none; flex:0 0 42%; min-height:0; }
        #rightWrap.lineSelected #profileWrap { display:flex; flex-direction:column; }
        #rightWrap { border-left:1px solid #ddd; background:#f4f4f4; }
        .toolbar {
            position:fixed; top:var(--safe-gap); left:var(--safe-gap); z-index:1200;
            display:flex; gap:10px; flex-wrap:wrap; align-items:flex-start;
            max-width:min(960px, calc(100% - 24px));
        }
        .toolbar button, .toolbar select, .toolbar input { padding:8px 10px; font-size:14px; }
        .toolbar button.active { background:#111; color:#fff; }
        .toolbar button:disabled { opacity:.45; cursor:not-allowed; }
        .cancelDrawBtn {
            background:#c00; color:#fff; border:1px solid #a00; border-radius:8px; cursor:pointer;
        }
        .cancelDrawBtn:hover { background:#e00; }
        .panelTitle {
            position:absolute; top:10px; left:10px; z-index:10; background:rgba(255,255,255,.96);
            padding:8px 10px; border-radius:8px; box-shadow:0 2px 10px rgba(0,0,0,.15);
        }
        .threeDControlStack {
            position:fixed;
            top:calc(var(--toolbar-height) + var(--safe-gap));
            right:var(--safe-gap);
            z-index:1260;
            display:flex;
            flex-direction:column;
            gap:10px;
            align-items:flex-end;
            max-width:min(380px, calc(100% - 24px));
        }
        body.layout-3d-mode .threeDControlStack {
            right:calc(320px + 24px);
        }
        .threeDControls {
            background:var(--panel-bg);
            padding:10px 12px; border-radius:var(--panel-radius); box-shadow:var(--panel-shadow);
            display:flex; gap:10px; align-items:center; font-size:13px;
            border:1px solid var(--panel-border);
            max-width:min(380px, calc(100% - 24px));
        }
        .threeDControls label { display:inline-flex; align-items:center; gap:4px; }
        .threeDControls select, .threeDControls input { padding:4px 6px; }
        .mobileProfileToggle {
            display:none;
        }
        .itemsPanel {
            position:fixed; top:calc(var(--toolbar-height) + var(--safe-gap) + var(--address-search-offset)); left:var(--safe-gap); z-index:1230; width:min(286px, calc(100% - 24px));
            max-height:min(58vh, 560px); overflow:hidden; background:var(--panel-bg); border-radius:var(--panel-radius);
            box-shadow:var(--panel-shadow); padding:10px 10px 10px 8px; border:1px solid var(--panel-border);
            transition:transform .2s ease, opacity .2s ease;
            display:flex;
            flex-direction:column;
        }
        .itemsPanel.collapsed {
            transform:translateX(calc(-100% + 32px));
        }
        .itemsPanelHeader {
            display:flex; align-items:center; justify-content:space-between; gap:8px; margin:0 0 8px;
        }
        .itemsPanelHeader h3 { margin:0; font-size:14px; }
        .panelTabs {
            display:flex;
            gap:6px;
            margin:0 0 10px;
        }
        .panelTabBtn {
            flex:1;
            border:1px solid #ccc;
            background:#fff;
            border-radius:8px;
            padding:7px 10px;
            font-size:12px;
            cursor:pointer;
        }
        .panelTabBtn.active {
            background:#111;
            color:#fff;
            border-color:#111;
        }
        .panelContent {
            min-height:0;
            display:flex;
            flex-direction:column;
            flex:1;
        }
        .panelPane {
            display:none;
            min-height:0;
            flex:1;
            overflow:auto;
            padding-right:2px;
        }
        .panelPane.active {
            display:block;
        }
        .itemsPanelFooter {
            display:flex;
            justify-content:flex-start;
            padding-top:10px;
            border-top:1px solid rgba(17,17,17,.08);
            margin-top:10px;
        }
        .itemsPanelFooter .cancelDrawBtn {
            padding:8px 12px;
            font-size:13px;
        }
        .itemsPanelToggleBtn {
            border:1px solid #ccc; background:#fafafa; border-radius:12px; padding:2px 6px; font-size:11px; cursor:pointer;
        }
        .mobileItemsFab {
            display:none;
            position:fixed;
            left:var(--safe-gap);
            bottom:calc(var(--safe-gap) + 72px);
            z-index:1270;
            width:52px;
            height:52px;
            border:none;
            border-radius:999px;
            background:#111;
            color:#fff;
            box-shadow:0 10px 24px rgba(0,0,0,.24);
            align-items:center;
            justify-content:center;
            cursor:pointer;
        }
        .mobileItemsFab .bi {
            font-size:1.2rem;
        }
        .ol-zoom {
            top:auto;
            left:auto;
            right:12px;
            bottom:12px;
        }
        .itemRow {
            border:1px solid #ddd; border-radius:8px; padding:8px; margin-bottom:8px; cursor:pointer;
            background:#fff;
        }
        .itemRow.active { border-color:#111; box-shadow:inset 0 0 0 1px #111; }
        .itemName {
            width:100%; border:1px solid #ccc; border-radius:6px; padding:6px 8px; font-size:13px; box-sizing:border-box;
        }
        .itemMeta { margin-top:6px; font-size:12px; color:#555; white-space:pre-wrap; }
        .itemActions { display:flex; justify-content:flex-end; gap:6px; margin-top:6px; }
        .itemExport,
        .itemDelete {
            border:1px solid #ccc; background:#fff; border-radius:6px; padding:4px 8px; font-size:12px; cursor:pointer;
        }
        .sectionTitle {
            position:absolute; top:10px; left:10px; z-index:10; background:rgba(255,255,255,.96);
            padding:8px 10px; border-radius:8px; box-shadow:0 2px 10px rgba(0,0,0,.15);
        }
        .profileInner {
            position:absolute; inset:0; padding:44px 10px 10px; box-sizing:border-box; background:#f8f6f1;
            display:flex; flex-direction:column; overflow:hidden;
        }
        .profileChartScroll {
            flex:0 0 auto; overflow-x:auto; overflow-y:hidden; min-height:0;
            border:1px solid #ddd; border-radius:8px; background:#fff;
        }
        .profileChart {
            min-height:180px; min-width:min-content;
            display:inline-block;
        }
        .profileInfo { flex-shrink:0; }
        .profileTableScroll { flex:1; min-height:0; overflow:auto; margin-top:10px; }
        .profileInfo {
            margin-top:10px; font-size:12px; white-space:pre-wrap;
        }
        .profileTable {
            width:100%; border-collapse:collapse; margin-top:10px; background:#fff; font-size:12px;
        }
        .profileTable th, .profileTable td {
            border:1px solid #ddd; padding:4px 6px; text-align:right;
        }
        .profileTable th:first-child, .profileTable td:first-child { text-align:left; }
        #threeDPointTooltip {
            position:absolute; pointer-events:none; z-index:100; background:rgba(0,0,0,.85); color:#fff;
            padding:8px 10px; border-radius:6px; font-size:12px; white-space:pre-line; max-width:200px;
            display:none; box-shadow:0 2px 8px rgba(0,0,0,.3);
        }
        #threeDPointTooltip.visible { display:block; }
        .viewLayoutBtns { display:flex; gap:6px; }
        .toolbarGroup {
            display:flex; gap:6px; align-items:flex-end; padding:8px;
            background:var(--panel-bg); border-radius:var(--panel-radius); box-shadow:var(--panel-shadow);
            border:1px solid var(--panel-border);
        }
        .toolbarIconBtn { display:inline-flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; min-width:44px; padding:6px 8px; font-size:14px; border:1px solid #ccc; border-radius:8px; background:#fff; cursor:pointer; }
        .toolbarIconBtn:hover { background:#f0f0f0; }
        .toolbarIconBtn.active { background:#111; color:#fff; border-color:#111; }
        .toolbarIconBtn.switchOn { background:#111; color:#fff; border-color:#111; }
        .toolbarIconBtn.switchReady { border-color:#2f9e44; color:#2f9e44; }
        .toolbarIconBtn.switchOn.switchReady { background:#2f9e44; border-color:#2f9e44; color:#fff; }
        .toolbarIconBtn .bi { font-size:1.25rem; }
        .toolbarBtnLabel { font-size:10px; line-height:1.2; white-space:nowrap; }
        .itemsPanelHeaderActions { display:flex; align-items:center; gap:6px; }
        .clearBtn { font-size:12px; padding:4px 8px; border:1px solid #c00; background:#fff; color:#c00; border-radius:6px; cursor:pointer; }
        .clearBtn:hover { background:#fee; }
        .toolbarLabel {
            display:flex; align-items:center; gap:4px; flex-wrap:wrap; padding:8px 10px;
            background:var(--panel-bg); border-radius:var(--panel-radius); box-shadow:var(--panel-shadow);
            border:1px solid var(--panel-border);
        }
        .toolbarCheckLabel { cursor:pointer; user-select:none; }
        #rightWrap.emptyState { display:none; }
        #infoContent {
            white-space:pre-wrap;
            font-size:13px;
            line-height:1.4;
        }
        .statusPanel {
            position:fixed;
            left:var(--safe-gap);
            bottom:var(--safe-gap);
            z-index:1220;
            width:min(340px, calc(100% - 24px));
            background:var(--panel-bg);
            border:1px solid var(--panel-border);
            border-radius:var(--panel-radius);
            box-shadow:var(--panel-shadow);
            padding:10px 12px;
            font-size:13px;
            line-height:1.4;
        }
        #statusContent {
            white-space:pre-wrap;
        }
        .introModal {
            position:fixed;
            inset:0;
            z-index:2000;
            display:none;
            align-items:center;
            justify-content:center;
            padding:20px;
            background:rgba(15, 23, 42, 0.42);
        }
        .introModal.visible {
            display:flex;
        }
        .introModalDialog {
            width:min(760px, calc(100% - 24px));
            max-height:min(86vh, 760px);
            overflow:auto;
            background:#fffdf8;
            border:1px solid rgba(17,17,17,.08);
            border-radius:20px;
            box-shadow:0 24px 60px rgba(0,0,0,.24);
            padding:18px;
        }
        .introModalHeader h2 {
            margin:0 0 6px;
            font-size:22px;
        }
        .introModalHeader p {
            margin:0;
            font-size:14px;
            color:#555;
            line-height:1.45;
        }
        .introOptions {
            display:grid;
            grid-template-columns:repeat(3, minmax(0, 1fr));
            gap:12px;
            margin:16px 0;
        }
        .introOptionBtn {
            text-align:left;
            border:1px solid #d7d7d7;
            border-radius:16px;
            background:#fff;
            padding:14px;
            cursor:pointer;
        }
        .introOptionBtn.active {
            border-color:#111;
            box-shadow:inset 0 0 0 1px #111;
            background:#f7f7f7;
        }
        .introOptionIcon {
            display:inline-flex;
            align-items:center;
            justify-content:center;
            width:42px;
            height:42px;
            border-radius:12px;
            background:#111;
            color:#fff;
            font-size:1.2rem;
            margin-bottom:10px;
        }
        .introOptionTitle {
            display:block;
            margin-bottom:6px;
            font-size:15px;
            font-weight:700;
        }
        .introOptionText {
            display:block;
            font-size:13px;
            line-height:1.5;
            color:#444;
        }
        .introModalActions {
            display:flex;
            justify-content:flex-end;
            gap:10px;
        }
        .introPrimaryBtn,
        .introSecondaryBtn {
            border-radius:10px;
            padding:10px 14px;
            font-size:14px;
            cursor:pointer;
        }
        .introPrimaryBtn {
            border:1px solid #111;
            background:#111;
            color:#fff;
        }
        .introSecondaryBtn {
            border:1px solid #ccc;
            background:#fff;
            color:#111;
        }
        @media (max-width: 960px) {
            #layout { grid-template-columns:1fr; }
            #rightWrap {
                position:fixed; inset:auto 0 0 0; height:min(48vh, 360px); z-index:900;
                border-left:none; border-top:1px solid #ddd;
            }
            #layout.layout-map #rightWrap,
            #rightWrap.emptyState { display:none; }
            #layout.layout-map #mapWrap { width:100%; }
            #layout.layout-3d #rightWrap {
                position:absolute;
                inset:0;
                width:100%;
                height:auto;
                z-index:1;
                border-top:none;
            }
            #layout.layout-3d #mapWrap {
                position:absolute;
                inset:0;
                width:100%;
                height:100%;
                top:0;
                right:auto;
                z-index:2;
                border-radius:0;
                overflow:visible;
                box-shadow:none;
                background:transparent;
                pointer-events:none;
            }
            #layout.layout-3d #map {
                display:none;
            }
            #layout.layout-3d #mapWrap .toolbar,
            #layout.layout-3d #mapWrap .itemsPanel,
            #layout.layout-3d #mapWrap .statusPanel,
            #layout.layout-3d #mapWrap .mobileItemsFab {
                pointer-events:auto;
            }
            #layout.layout-3d #rightWrap.lineSelected {
                display:flex;
            }
            .toolbar {
                left:8px; right:8px; max-width:none; gap:8px; flex-wrap:nowrap; overflow-x:auto; align-items:stretch;
            }
            .toolbarGroup, .toolbarLabel { width:auto; box-sizing:border-box; flex:0 0 auto; }
            .toolbarGroup { justify-content:flex-start; overflow:visible; }
            #viewDouble { display:none; }
            .itemsPanel {
                top:auto; bottom:84px; left:8px; width:min(320px, calc(100% - 16px)); max-height:32vh;
            }
            .itemsPanel.collapsed {
                transform:translateY(calc(100% + 16px));
                opacity:0;
                pointer-events:none;
            }
            .mobileItemsFab {
                display:inline-flex;
            }
            .ol-zoom {
                right:8px;
                bottom:8px;
            }
            .threeDControlStack {
                top:calc(var(--toolbar-height) + 8px);
                right:8px;
                bottom:auto;
                left:auto;
                max-width:min(320px, calc(100% - 16px));
                z-index:1265;
            }
            body.layout-3d-mode .threeDControlStack {
                right:8px;
            }
            .threeDControls {
                width:min(320px, calc(100% - 16px)); justify-content:flex-start; flex-wrap:wrap;
            }
            .mobileProfileToggle {
                display:inline-flex;
                width:min(320px, calc(100% - 16px));
                justify-content:center;
            }
            #profileWrap {
                display:none !important;
            }
            #rightWrap.mobileProfileVisible #profileWrap {
                display:flex !important;
                position:absolute;
                inset:calc(var(--toolbar-height) + 8px) 0 0 0;
                height:auto;
                z-index:3;
                border-top:none;
            }
            #rightWrap.mobileProfileVisible #three {
                display:none;
            }
            #rightWrap.mobileProfileVisible .panelTitle {
                display:none !important;
            }
            #rightWrap.mobileProfileVisible #threeDMapControls,
            #rightWrap.mobileProfileVisible #threeDControls {
                display:none !important;
            }
            #rightWrap.mobileProfileVisible .threeDControlStack {
                top:calc(var(--toolbar-height) + 8px);
                right:8px;
                left:auto;
                z-index:1275;
            }
            #rightWrap.mobileProfileVisible .mobileProfileToggle {
                display:inline-flex !important;
            }
            #rightWrap.mobileProfileVisible .profileInner {
                inset:0;
                padding:44px 8px 12px;
                display:grid;
                grid-template-rows:minmax(180px, 44%) minmax(56px, auto) minmax(0, 1fr);
                gap:8px;
            }
            #rightWrap.mobileProfileVisible .profileChartScroll {
                min-height:0;
            }
            #rightWrap.mobileProfileVisible .profileTableScroll {
                min-height:0;
                margin-top:0;
                padding-bottom:12px;
                box-sizing:border-box;
            }
            #rightWrap.mobileProfileVisible .profileInfo {
                margin-top:0;
                overflow:auto;
            }
            .statusPanel {
                left:8px;
                bottom:8px;
                width:min(320px, calc(100% - 16px));
            }
            .introOptions {
                grid-template-columns:1fr;
            }
        }
        @media (max-width: 640px) {
            .toolbar { top:8px; }
            .toolbarIconBtn { min-width:40px; padding:6px; }
            .toolbarBtnLabel { font-size:9px; }
            .itemsPanel {
                width:calc(100% - 16px);
                left:8px;
                right:auto;
            }
            .threeDControlStack {
                max-width:min(260px, calc(100% - 16px));
            }
            .threeDControls {
                width:min(260px, calc(100% - 16px));
            }
            .statusPanel {
                width:min(calc(100% - 16px), calc(100% - 88px));
            }
        }

.addressSearchPanel {
    position: fixed;
    top: calc(var(--safe-gap) + var(--toolbar-height));
    left: var(--safe-gap);
    z-index: 1245;
    width: min(286px, calc(100% - 24px));
}
.addressSearchPanelInner {
    display: flex;
    gap: 8px;
    align-items: center;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--panel-radius);
    box-shadow: var(--panel-shadow);
    padding: 8px;
}
.addressSearchBox {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 10px;
    padding: 0 10px;
}
#addressSearchInput {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    padding: 10px 0;
    font-size: 14px;
}
.addressSearchResults {
    margin-top: 8px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--panel-radius);
    box-shadow: var(--panel-shadow);
    max-height: min(42vh, 360px);
    overflow: auto;
    padding: 6px;
}
.addressSearchResultBtn {
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    border-radius: 10px;
    padding: 10px;
    cursor: pointer;
}
.addressSearchResultBtn:hover, .addressSearchResultBtn.active { background: rgba(17,17,17,.06); }
.addressSearchPrimary { display:block; font-size: 13px; font-weight: 700; }
.addressSearchMeta { display:block; margin-top: 4px; font-size: 12px; color: #555; }
.mapPointTooltip {
    position: absolute;
    transform: translate(-50%, calc(-100% - 14px));
    pointer-events: auto;
    z-index: 1260;
    background: rgba(17,17,17,.92);
    color: #fff;
    padding: 10px 12px 12px;
    border-radius: 10px;
    box-shadow: 0 10px 24px rgba(0,0,0,.22);
    font-size: 12px;
    line-height: 1.35;
    white-space: normal;
    min-width: 240px;
    max-width: min(420px, calc(100vw - 32px));
}
.mapPointTooltip[hidden] {
    display: none;
}
.mapPointTooltipBody {
    display: grid;
    gap: 6px;
}
.mapPointTooltipTitle {
    font-size: 13px;
    font-weight: 700;
    padding-right: 18px;
}
.mapPointTooltipRow {
    display: grid;
    gap: 2px;
}
.mapPointTooltipLabel {
    font-size: 11px;
    color: rgba(255,255,255,.72);
}
.mapPointTooltipValue,
.mapPointTooltipLine {
    word-break: break-word;
}
.mapPointTooltipClose {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 999px;
    background: rgba(255,255,255,.14);
    color: #fff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}
.mapPointTooltipClose:hover {
    background: rgba(255,255,255,.22);
}
.mapPointTooltip::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -6px;
    width: 12px;
    height: 12px;
    background: rgba(17,17,17,.92);
    transform: translateX(-50%) rotate(45deg);
}
@media (max-width: 960px) {
    .addressSearchPanel {
        left: 8px;
        width: min(320px, calc(100% - 16px));
    }
}
