:root {
    --primary-color: #0078d4;
    --primary-hover: #005a9e;
    --primary-light: #e1f0fe;
    --success-color: #28a745;
    --success-hover: #218838;
    --success-light: #e2f5e9;
    --danger-color: #dc3545;
    --bg-light: #f4f4f9;
    --bg-card: #ffffff;
    --bg-table-zebra: #f8f9fa;
    --bg-table-hover: #f1f7fd;
    --bg-table-alt: #fafafa;
    --border-color: #ccc;
    --border-color-light: #e0e0e0;
    --border-color-card: #ddd;
    --text-dark: #333;
    --text-muted: #666;
    --text-gray-light: #999;
    --text-active-link: #005a9e;
    --font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: monospace;
    --shadow-default: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-small: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-detail: 0 2px 10px rgba(0,0,0,0.08);
}

/* Base HTML & Body Settings */
body, html {
    height: 100%;
    margin: 0;
    font-family: var(--font-sans);
    color: var(--text-dark);
    overflow: hidden;
}

.gis-body-centered {
    height: 100%;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-light);
    font-family: var(--font-sans);
}

/* Home / Menu layout */
.button-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 300px;
}

/* Standard buttons */
button.gis-menu-btn {
    padding: 15px;
    cursor: pointer;
    font-weight: 600;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-card);
    transition: all 0.2s;
    width: 100%;
    text-align: center;
    font-family: var(--font-sans);
}

    button.gis-menu-btn:hover {
        background-color: var(--primary-color);
        color: white;
        border-color: var(--primary-hover);
    }

.gis-button {
    /* Height 3 (standard action button): vertical padding + font match .btn-buildings.btn-sm
       (the "0201" reference pill) so every action button — 3D side-panel, modal, toolbar and
       form buttons — renders at the same ~28px height. Horizontal padding stays roomier than the
       table pills so standalone labels ("Add antenna", "Go to Administrative Areas") aren't cramped. */
    padding: 4px 16px;
    cursor: pointer;
    /* Explicit rem font so <a> and <button> variants match (a native button otherwise falls back to
       the UA default ~13.3px while an anchor inherits the document size) AND so the size is pinned to
       13.6px regardless of context, matching the reference pill's 0.85em in its 16px table. */
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    background-color: var(--primary-color);
    color: white;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-sans);
    text-decoration: none;
}

    .gis-button:hover {
        background-color: var(--primary-hover);
        border-color: var(--primary-hover);
    }

    .gis-button:disabled {
        background-color: var(--border-color);
        border-color: #bbb;
        cursor: not-allowed;
    }

/* Building Reference button / links */
/* Height 3: 4px vertical padding matches .btn-sm (the "0201" reference), so plain pills
   ("Buildings", pagers) sit at the same height as the code pills next to them. .btn-xs overrides
   this down to height 2 for breadcrumb / inline code chips. */
.btn-buildings {
    padding: 4px 12px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.85em;
    font-weight: 600;
    display: inline-block;
    /* Transparent 1px border (not `none`) so borderless states (.btn-disabled, .btn-pager-all)
       keep the same box height as bordered ones (.btn-active) — every pill lands on the 28px
       reference. Variants only recolor the border (.btn-active/.btn-pager-all). */
    border: 1px solid transparent;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: all 0.2s;
    box-sizing: border-box;
}

.btn-active {
    background-color: var(--primary-light);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

    .btn-active:hover {
        background-color: var(--primary-color);
        color: white;
    }

.btn-disabled {
    background-color: var(--border-color-light);
    color: #a1a1a1;
    cursor: not-allowed;
}

/* Card and container classes */
.gis-panel {
    max-width: 90%;
    margin: 40px auto;
}

.gis-card {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 8px;
    box-shadow: var(--shadow-default);
    margin-bottom: 20px;
}

.gis-about-card {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 8px;
    box-shadow: var(--shadow-default);
    text-align: center;
    max-width: 500px;
    width: 90%;
}

.gis-logo-placeholder {
    color: var(--primary-color);
    font-size: 3rem;
    margin-bottom: 10px;
    font-weight: bold;
}

.gis-table-container {
    margin: 20px auto;
    max-width: 95%;
    background: var(--bg-card);
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-default);
    overflow-x: auto;
}

    .gis-table-container.margin-large {
        margin: 40px auto;
        max-width: 90%;
    }

.gis-main-content {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    margin-bottom: 30px;
}

.gis-info-section {
    flex: 1;
    border-left: 4px solid var(--primary-color);
    padding-left: 15px;
}

.gis-info-section-green {
    border-left-color: var(--success-color);
}

.gis-visual-side {
    flex: 0 0 320px;
    text-align: center;
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

/* Master Detail Split layout */
/* Fill the flex-column content wrapper rather than recomputing from 100vh: the viewport-based calc
   ignored the header's 1px bottom border, so the wrapper ran 1px taller than the space its parent
   actually provides and spilled a stray outer scrollbar onto .gis-content-wrapper. */
.master-detail-wrapper {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    gap: 12px;
    padding: 12px;
    background-color: #f0f2f5;
    box-sizing: border-box;
}

#listSide {
    flex: 0 0 450px;
    width: 450px;
    max-width: 450px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#detailsSide {
    flex: 1;
    background: var(--bg-card);
    overflow-y: auto;
    border-radius: 8px;
    box-shadow: var(--shadow-detail);
    position: relative;
    padding: 0;
}

#detailsContent {
    transition: opacity 0.2s ease-in-out;
}

.gis-master-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    background-color: var(--bg-card);
}

.master-header {
    flex: 0 0 auto;
    padding: 15px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid #eaeaea;
    z-index: 10;
}

.controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.table-scroll-container {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
}

/* Typography settings */
.gis-title {
    color: var(--text-dark);
    margin-top: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
    display: inline-block;
    font-size: 1.2rem;
    font-weight: 700;
}

h1.gis-title-large {
    color: var(--primary-color);
    margin-top: 0;
    border-bottom: 2px solid #eef2f5;
    padding-bottom: 15px;
    display: block;
}

.property-group {
    margin-bottom: 25px;
}

    .property-group h4 {
        margin-top: 0;
        margin-bottom: 12px;
        font-size: 1.1em;
        border-left: 4px solid var(--primary-color);
        padding-left: 10px;
        color: var(--primary-color);
    }

    .property-group.success h4 {
        border-left-color: var(--success-color);
        color: var(--success-color);
    }

/* Tables */
.gis-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.gis-master-wrapper .gis-table {
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}

.gis-table thead tr {
    background-color: var(--primary-color);
    color: white;
    text-align: left;
}

.gis-table thead th {
    padding: 12px 15px;
    font-weight: 600;
}

.gis-master-wrapper .gis-table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 12px 10px;
    font-size: 0.9em;
}

.gis-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color-light);
}

.gis-master-wrapper .gis-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.gis-table tbody tr:nth-of-type(even) {
    background-color: var(--bg-table-zebra);
}

.gis-table tbody tr:hover {
    background-color: var(--bg-table-hover);
    transition: background-color 0.2s;
}

.index-column {
    font-weight: bold;
    color: var(--text-muted);
    width: 50px;
}

.col-idx {
    width: 45px;
    text-align: center;
}

.col-ref {
    width: auto;
}

.btn-buildings.building-link {
    display: block;
    width: 100%;
    padding: 4px 12px;
    border: 1px solid var(--primary-color);
    background-color: var(--primary-light);
    color: var(--primary-color);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

    .btn-buildings.building-link:hover {
        background-color: var(--primary-color);
        color: white;
    }

/* Active selection row */
.active-selection {
    background-color: var(--primary-color) !important;
    color: white !important;
}

    .active-selection a, .active-selection .btn-buildings {
        color: white !important;
        background-color: var(--primary-hover) !important;
        border-color: var(--primary-hover) !important;
    }

.row-hidden {
    display: none;
}

/* Key-Value details layout (Property Tables) */
.gis-info-row {
    display: flex;
    margin-bottom: 12px;
    align-items: baseline;
}

.gis-info-label {
    font-weight: bold;
    min-width: 100px;
    color: #444;
}

.gis-info-value {
    color: #222;
    flex: 1;
}

.gis-property-table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--bg-table-alt);
    border-radius: 4px;
}

    .gis-property-table tr {
        border-bottom: 1px solid #eee;
    }

        .gis-property-table tr:last-child {
            border-bottom: none;
        }

    .gis-property-table td {
        padding: 12px;
        color: var(--text-dark);
    }

        .gis-property-table td.property-label {
            color: var(--text-muted);
            width: 45%;
            min-width: 360px;
            font-weight: 500;
        }

        .gis-property-table td:not(.property-label) {
            min-width: 400px;
        }

.gis-select {
    /* Vertical padding + font match .gis-button so the combobox is the same 28px height as the
       button it sits next to in a .gis-form-row. */
    padding: 4px 12px;
    font-size: 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    width: 100%;
    max-width: 300px;
    outline: none;
    cursor: pointer;
    font-family: var(--font-sans);
    box-sizing: border-box;
    height: 28px;
}

    .gis-select:focus {
        border-color: var(--primary-color);
    }

.code-badge {
    background: var(--primary-light);
    color: var(--text-active-link);
    padding: 4px 8px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.9em;
}

.gis-path-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.breadcrumb-item-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.breadcrumb-separator {
    color: #ccc;
    margin: 0 5px;
    font-weight: bold;
}

#svg-wrapper {
    background: white;
    border: 1px solid var(--border-color-card);
    border-radius: 8px;
    padding: 10px;
    width: 320px;
    height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#mainCanvas {
    width: 300px !important;
    height: 300px !important;
    display: block;
}

/* Progress/Coverage indicators */
.coverage-wrapper {
    display: flex;
    flex-direction: column;
    width: 170px;
}

.coverage-container {
    width: 100%;
    background-color: #eee;
    border-radius: 4px;
    height: 8px;
    overflow: hidden;
    border: 1px solid #ddd;
}

.coverage-bar {
    height: 100%;
    width: 0%;
    background-color: var(--primary-color);
    transition: width 0.6s ease-out;
}

.coverage-text {
    font-size: 11px;
    font-weight: bold;
    color: var(--text-dark);
    margin-bottom: 2px;
}

/* Loaders and animation keyframes */
.gis-loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

.details-loader .gis-loader {
    width: 40px;
    height: 40px;
    margin: 0 auto 10px;
}

.details-loader {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    background: rgba(255, 255, 255, 0.8);
    padding: 20px;
    border-radius: 50%;
    z-index: 100;
}

/* 3D viewer loading overlay */
.gltf-loader {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.65);
    pointer-events: none;
}

    .gltf-loader .gis-loader {
        width: 48px;
        height: 48px;
        border-width: 5px;
        margin: 0 0 12px 0;
    }

    .gltf-loader .gis-loader-text {
        color: rgba(255, 255, 255, 0.85);
        font-size: 1rem;
    }

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Orto data specific styles */
.orto-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    width: 100%;
    margin-top: 10px;
}

.orto-card {
    border: 1px solid var(--border-color-light);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: var(--shadow-small);
}

.orto-image {
    width: 100%;
    height: auto;
    aspect-ratio: attr(width) / attr(height);
    object-fit: contain;
    display: block;
    background-color: #f0f0f0;
}

.orto-footer {
    padding: 8px;
    background: #f8f9fa;
    width: 100%;
    text-align: center;
    border-top: 1px solid #eee;
    font-size: 0.9em;
    font-weight: bold;
    color: var(--text-dark);
}

.server-time {
    margin-top: 25px;
    padding: 10px;
    background-color: var(--primary-light);
    color: var(--primary-hover);
    border-radius: 4px;
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.9em;
}

.back-button {
    margin-top: 30px;
    display: block;
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 600;
    transition: color 0.2s;
}

    .back-button:hover {
        color: var(--primary-hover);
        text-decoration: underline;
    }

/* Header & Layout Additions */
.gis-app-body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    margin: 0;
    background-color: var(--bg-light);
    overflow: hidden;
}

.gis-header {
    height: 70px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    display: flex;
    align-items: center;
}

.gis-header-container {
    width: calc(100% - 40px);
    max-width: none;
    margin: 0 auto;
    padding: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
}

.gis-logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: transform 0.2s ease;
}

    .gis-logo-link:hover {
        transform: scale(1.02);
    }

.gis-header-logo {
    height: 44px;
    width: auto;
    display: block;
}

.gis-nav {
    display: flex;
    gap: 30px;
    align-items: center;
    position: relative; /* anchor for the absolutely positioned dropdown menu */
}

.gis-nav-link {
    color: var(--text-dark);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 8px 0;
    position: relative;
    transition: color 0.2s ease;
}

    .gis-nav-link:hover {
        color: var(--primary-color);
    }

    .gis-nav-link::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 2px;
        background-color: var(--primary-color);
        transform: scaleX(0);
        transform-origin: right;
        transition: transform 0.25s ease-out;
    }

    .gis-nav-link:hover::after {
        transform: scaleX(1);
        transform-origin: left;
    }

    .gis-nav-link.active {
        color: var(--primary-color);
    }

        .gis-nav-link.active::after {
            transform: scaleX(1);
            background-color: var(--primary-color);
        }

/* Hamburger navigation toggle and its dropdown menu */
.gis-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    color: var(--text-dark);
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

    .gis-nav-toggle:hover,
    .gis-nav-toggle[aria-expanded="true"] {
        color: var(--primary-color);
        border-color: var(--primary-color);
        background: rgba(0, 0, 0, 0.02);
    }

.gis-nav-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 220px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    z-index: 1100;
}

    /* The hidden attribute must win over the flex display above. */
    .gis-nav-menu[hidden] {
        display: none;
    }

    .gis-nav-menu .gis-nav-link {
        display: block;
        padding: 10px 14px;
        border-radius: 6px;
        white-space: nowrap;
    }

        /* The animated underline is designed for the old horizontal bar; suppress it in the dropdown. */
        .gis-nav-menu .gis-nav-link::after {
            display: none;
        }

        .gis-nav-menu .gis-nav-link:hover {
            background: rgba(0, 0, 0, 0.04);
            color: var(--primary-color);
        }

        .gis-nav-menu .gis-nav-link.active {
            background: rgba(0, 0, 0, 0.05);
            color: var(--primary-color);
        }

.gis-content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

.gis-home-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
}

/* Footer & Layout Additions */
.gis-footer {
    height: 70px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.03);
    width: 100%;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    z-index: 1000;
}

.gis-footer-container {
    width: calc(100% - 40px);
    max-width: none;
    margin: 0 auto;
    padding: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
}

.gis-footer-logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: transform 0.2s ease;
}

    .gis-footer-logo-link:hover {
        transform: scale(1.03);
    }

.gis-footer-logo {
    height: 38px;
    width: auto;
    display: block;
}

.gis-footer-left {
    flex: 1;
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

.gis-footer-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.gis-footer-right {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.gis-footer-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease, text-decoration 0.2s ease;
}

    .gis-footer-link:hover {
        color: var(--primary-hover);
        text-decoration: underline;
    }

@media (max-width: 768px) {
    .gis-footer {
        height: auto;
        padding: 20px 0;
    }

    .gis-footer-container {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .gis-footer-left, .gis-footer-center, .gis-footer-right {
        justify-content: center;
    }
}

/* Custom Styled Tooltip */
.gis-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
}

    .gis-tooltip .gis-tooltiptext {
        visibility: hidden;
        width: 240px;
        background-color: rgba(51, 51, 51, 0.95);
        color: #ffffff;
        text-align: center;
        border-radius: 6px;
        padding: 8px 12px;
        position: absolute;
        z-index: 1000;
        bottom: 130%; /* Position the tooltip above the icon */
        left: 50%;
        transform: translateX(-50%);
        opacity: 0;
        transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
        font-size: 0.8rem;
        font-family: var(--font-sans);
        font-weight: 500;
        line-height: 1.4;
        box-shadow: var(--shadow-default);
        pointer-events: none;
        border: 1px solid rgba(255, 255, 255, 0.1);
        white-space: normal;
    }

        .gis-tooltip .gis-tooltiptext::after {
            content: "";
            position: absolute;
            top: 100%; /* At the bottom of the tooltip */
            left: 50%;
            margin-left: -6px;
            border-width: 6px;
            border-style: solid;
            border-color: rgba(51, 51, 51, 0.95) transparent transparent transparent;
        }

    .gis-tooltip:hover .gis-tooltiptext {
        visibility: visible;
        opacity: 1;
        transform: translateX(-50%) translateY(-2px);
    }

/* Collapsible right-panel cards. The card title becomes a clickable header with a chevron toggle
   (added by gltf-viewer.js); the card content is hidden while the card carries gltf-card-collapsed. */
/* Tighter vertical padding than the default card so more panels fit in the side panel. */
.gis-card.gltf-card {
    padding-top: 12px;
    padding-bottom: 12px;
}

.gltf-card-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 0 0 10px 0;
    font-size: 1rem;
    cursor: pointer;
    user-select: none;
}

.gltf-card-toggle {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease;
}

    .gltf-card-toggle:hover {
        color: var(--primary-color);
        background: rgba(0, 0, 0, 0.05);
    }

    .gltf-card-toggle svg {
        transition: transform 0.2s ease;
    }

/* Chevron points down when folded; rotate it up when the card is expanded. */
.gltf-card:not(.gltf-card-collapsed) .gltf-card-toggle svg {
    transform: rotate(180deg);
}

.gltf-card.gltf-card-collapsed .gltf-card-content {
    display: none;
}

/* Drop the title's bottom margin when folded so a collapsed card is just its header. */
.gltf-card.gltf-card-collapsed .gltf-card-title {
    margin-bottom: 0;
}

/* Text & layout utilities */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

.text-success {
    color: var(--success-color);
}

.text-danger {
    color: var(--danger-color);
}

.fw-medium {
    font-weight: 500;
}

.fw-bold {
    font-weight: bold;
}

/* Button size modifiers for .btn-buildings */
.btn-buildings.btn-xs {
    padding: 2px 8px;
    font-size: 0.8em;
    line-height: 1.5;
}

.btn-buildings.btn-sm {
    padding: 4px 12px;
}

/* Hero / start-page cards */
.gis-hero-card {
    text-align: center;
    padding: 50px 20px;
}

.gis-hero-icon {
    margin-bottom: 20px;
    color: var(--primary-color);
    font-size: 4rem;
    line-height: 1;
}

    .gis-hero-icon svg {
        display: inline-block;
        vertical-align: middle;
    }

.gis-title.gis-title-hero {
    border: none;
    padding: 0;
    margin-bottom: 15px;
    display: block;
    font-size: 1.8rem;
}

.gis-hero-text {
    color: var(--text-muted);
    max-width: 520px;
    margin: 0 auto 30px;
    font-size: 1.1rem;
    line-height: 1.6;
}

/* Inline parameter forms on hero cards */
.gis-inline-form {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
}

    .gis-inline-form label {
        color: var(--text-muted);
    }

    .gis-inline-form input {
        margin-left: 6px;
        /* Match .gis-button height (28px): same vertical padding + font, an explicit 1px border and
           radius so the text boxes line up with the "Open" button in the same row. */
        padding: 4px 8px;
        font-size: 0.85rem;
        border: 1px solid var(--border-color);
        border-radius: 4px;
        box-sizing: border-box;
        height: 28px;
        width: 100px;
    }

        .gis-inline-form input.gis-input-md {
            width: 80px;
        }

        .gis-inline-form input.gis-input-sm {
            width: 70px;
        }

/* Narrow centered card (single control panel) */
.gis-card-narrow {
    max-width: 520px;
    width: 100%;
    box-sizing: border-box;
    margin-left: auto;
    margin-right: auto;
}

/* Horizontal control rows inside cards */
.gis-form-row {
    display: flex;
    gap: 15px;
    align-items: center;
}

    /* The shrink-to-fit panel gives percentage widths nothing to resolve against — pin the select. */
    .gis-form-row .gis-select {
        width: 300px;
        max-width: 100%;
    }

    .gis-form-row .gis-button {
        flex-shrink: 0;
    }

/* AJAX results target below a control card */
.gis-results-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* Loader caption below .gis-loader */
.gis-loader-text {
    text-align: center;
    color: var(--primary-color);
    font-size: 0.9em;
    font-weight: 500;
}

/* Empty-state and placeholder messages */
.gis-empty-state {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
}

.gis-placeholder {
    padding: 40px;
    text-align: center;
    color: var(--text-gray-light);
}

.gis-placeholder-icon {
    font-size: 48px;
    font-style: normal;
    display: block;
    margin-bottom: 10px;
}

/* Section separated by a top border (detail pages) */
.gis-section-divider {
    border-top: 1px solid #eee;
    padding-top: 20px;
}

/* Inline tooltip trigger next to a label */
.tooltip-hint {
    margin-left: 4px;
    color: var(--text-muted);
}

/* Master list paging controls */
.paging-status {
    font-size: 0.8em;
    color: var(--text-muted);
    white-space: nowrap;
}

.btn-buildings.btn-pager {
    min-width: 60px;
}

.btn-buildings.btn-pager-all {
    background-color: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

    .btn-buildings.btn-pager-all:hover {
        background-color: var(--success-hover);
        border-color: var(--success-hover);
    }

.gis-master-wrapper .gis-table td.col-idx {
    color: var(--text-gray-light);
    font-size: 0.8em;
}

/* Scrollable raw-data tables (e.g. EPW weather records) */
.gis-scroll-box {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 500px;
    border: 1px solid #eee;
    border-radius: 4px;
    margin-top: 10px;
}

.gis-data-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    margin: 0;
    font-size: 0.85em;
    background-color: var(--bg-table-alt);
}

    .gis-data-table thead tr {
        border-bottom: 2px solid var(--border-color-card);
        position: sticky;
        top: 0;
        background-color: var(--bg-card);
        z-index: 1;
    }

    .gis-data-table th {
        padding: 6px;
        text-align: left;
        background-color: #f9f9f9;
        font-weight: bold;
        border-right: 1px solid #eee;
        white-space: normal;
        word-wrap: break-word;
    }

    .gis-data-table td {
        padding: 6px;
        border-right: 1px solid #eee;
    }

        .gis-data-table th:last-child,
        .gis-data-table td:last-child {
            border-right: none;
        }

    .gis-data-table tbody tr {
        border-bottom: 1px solid #eee;
    }

    .gis-data-table .num {
        text-align: right;
    }

    .gis-data-table .nowrap {
        white-space: nowrap;
    }

/* 3D viewer pages (GLTF & Communication scene views) */

/* The theme panel shrinks to fit (auto cross-axis margins prevent flex stretching) — force full width on viewer pages so the 3D view can stretch with the window. */
.gis-panel.gis-panel-full {
    width: calc(100% - 40px);
    max-width: none;
    margin: 20px auto;
}

/* The 3D view always stretches with the window; the side panel stays docked on the right. */
.gltf-layout {
    display: flex;
    gap: 0;
    align-items: stretch;
    height: calc(100vh - 180px);
    min-height: 480px;
}

    /* Variant for pages with an extra toolbar row above the canvas (communication view). */
    .gltf-layout.gltf-layout-toolbar {
        height: calc(100vh - 230px);
    }

#gltf-viewer-container {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    border-radius: 8px;
    overflow: hidden;
    background: #171a21;
}

/* Small toggle in the top-right corner that folds/unfolds the right side panel. */
.gltf-panel-toggle {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 5;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: rgba(255, 255, 255, 0.92);
    color: var(--text-dark);
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

    .gltf-panel-toggle:hover {
        color: var(--primary-color);
        background: #ffffff;
    }

    .gltf-panel-toggle svg {
        transition: transform 0.2s ease;
    }

/* Folded state: hide the side panel (the viewer expands to fill) and flip the chevron. */
.gltf-layout.gltf-panel-collapsed .gltf-side-panel {
    display: none;
}

.gltf-layout.gltf-panel-collapsed #gltf-resizer {
    display: none;
}

.gltf-layout.gltf-panel-collapsed .gltf-panel-toggle svg {
    transform: rotate(180deg);
}

.gltf-side-panel {
    flex: 0 0 340px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
    overflow-y: auto;
}

.gltf-slider-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

    .gltf-slider-label input[type="range"] {
        width: 100%;
        display: block;
    }

    /* Date picker in the Lighting panel: matches the 28px standard control height. */
    .gltf-slider-label input[type="date"] {
        display: block;
        width: 100%;
        box-sizing: border-box;
        height: 28px;
        padding: 4px 8px;
        font-size: 0.85rem;
        font-family: var(--font-sans);
        border: 1px solid var(--border-color);
        border-radius: 4px;
        margin-top: 2px;
    }

.gltf-properties {
    font-size: 0.85rem;
    word-break: break-word;
    max-height: 320px;
    overflow-y: auto;
}

    .gltf-properties table {
        width: 100%;
        border-collapse: collapse;
    }

    .gltf-properties td {
        padding: 3px 6px;
        vertical-align: top;
        border-bottom: 1px solid rgba(128, 128, 128, 0.15);
    }

        .gltf-properties td:first-child {
            font-weight: 600;
            white-space: nowrap;
        }

.gltf-muted {
    color: var(--text-muted);
}

/* Selection card: the "Details" and "Export" buttons fill the card width like the other panels'
   content, with centered labels. border-box keeps the padding inside the 100% so it doesn't
   overflow the card. */
#building-details-card .gis-button,
#building-general-card .gis-button {
    width: 100%;
    box-sizing: border-box;
    justify-content: center;
}

    #building-details-card .gis-button + .gis-button {
        margin-top: 8px;
    }

/* Communication card buttons match the Selection panel layout. */
#communication-card .gis-button {
    width: 100%;
    box-sizing: border-box;
    justify-content: center;
}

    #communication-card .gis-button + .gis-button {
        margin-top: 8px;
    }

/* Results panel "Details" button matches the Selection/Communication panel layout. */
#communication-results-card .gis-button {
    width: 100%;
    box-sizing: border-box;
    justify-content: center;
    margin-top: 8px;
}

/* Usage hint closing the Results panel, below the "Details" button. */
.communication-results-note {
    margin-top: 8px;
}

/* Scene panel "Change" button matches the Selection/Communication panel layout. */
#gltf-scene-info .gis-button {
    width: 100%;
    box-sizing: border-box;
    justify-content: center;
    margin-top: 6px;
}

#communication-card .communication-mode-hint {
    display: block;
    margin-top: 12px;
}

/* Communication viewer: toolbar between the page header and the 3D canvas. */
.communication-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin: 0 0 12px 0;
}

/* The hint must never wrap: growing the toolbar would shift the 3D canvas mid-interaction. */
.communication-mode-hint {
    color: var(--text-muted);
    font-size: 0.85rem;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Modal dialogs (communication calculation inputs, antenna placement, selection export). */
.gis-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
}

.gis-modal {
    width: 320px;
    max-width: 90vw;
    /* Cancel the gis-card bottom margin so flex centering in the overlay is exact. */
    margin: 0;
}

    .gis-modal.gis-modal-wide {
        width: 800px;
    }

    /* Wider still, for the scattering hit table: a column per hit value does not fit 800px. The
       max-width overrides the 90vw of .gis-modal, which would otherwise cap it first. */
    .gis-modal.gis-modal-wider {
        width: 1400px;
        max-width: 95vw;
    }

/* Preformatted payload block inside a modal (selection export JSON). */
.gis-modal-pre {
    max-height: 60vh;
    overflow: auto;
    background: var(--bg-table-alt);
    border: 1px solid var(--border-color-light);
    border-radius: 4px;
    padding: 10px;
    margin: 0 0 12px 0;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.communication-modal-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

    .communication-modal-label input,
    .communication-modal-label select {
        display: block;
        width: 100%;
        box-sizing: border-box;
        padding: 6px 8px;
        margin-top: 4px;
    }

.communication-modal-functions {
    border: 1px solid rgba(128, 128, 128, 0.35);
    border-radius: 4px;
    margin: 0 0 12px 0;
    padding: 8px 10px;
}

    .communication-modal-functions legend {
        font-size: 0.85rem;
        color: var(--text-muted);
        padding: 0 4px;
    }

.communication-modal-checkbox {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.gis-modal-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Scattering hit matrix (azimuth ranges across, elevation ranges down). */
.communication-matrix-caption {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 10px 0 0 0;
}

/* .gis-data-table is table-layout: fixed, which would squeeze a matrix of many azimuth columns into
   illegible slivers. Size to content instead and let .gis-scroll-box scroll horizontally. */
.communication-matrix-table {
    table-layout: auto;
    width: auto;
    min-width: 100%;
}

    .communication-matrix-table th,
    .communication-matrix-table td {
        min-width: 84px;
        text-align: center;
        white-space: nowrap;
    }

    /* The elevation labels stay readable while scrolling across, matching the sticky thead. */
    .communication-matrix-table th:first-child,
    .communication-matrix-table td:first-child {
        position: sticky;
        left: 0;
        z-index: 1;
        text-align: left;
        background-color: var(--bg-card);
    }

    .communication-matrix-table thead th:first-child {
        z-index: 2;
    }

/* The hit columns are sized to content rather than by the .gis-data-table fixed layout, which would
   squeeze thirteen columns into illegible slivers. Overflow scrolls inside .gis-scroll-box. */
.communication-hits-table {
    table-layout: auto;
    width: auto;
    min-width: 100%;
}

/* Scattering object reference in the hits table: only the last step of the reference chain is shown,
   which is a single identifier, so it sits on one line. The full reference is the cell title. */
.communication-hit-reference {
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    cursor: help;
}

/* Compact .gis-button variant filling a matrix cell. */
.communication-matrix-cell {
    width: 100%;
    box-sizing: border-box;
    justify-content: center;
    padding: 2px 8px;
    font-size: 0.8rem;
}

/* Layout Toggle Button */
.gis-layout-toggle {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translate(-50%, 0);
    z-index: 1001;
    width: 50px;
    height: 24px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-top: none;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.03);
    color: var(--text-dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: top 0.3s ease, background 0.2s ease, color 0.2s ease;
}

    .gis-layout-toggle:hover {
        background: #ffffff;
        color: var(--primary-color);
    }

.gis-layout-toggle-icon {
    transition: transform 0.3s ease;
}

/* Collapsed state adjustments */
.gis-layout-collapsed .gis-header {
    margin-top: -70px;
    transform: translateY(-100%);
}

.gis-layout-collapsed .gis-footer {
    margin-bottom: -70px;
    transform: translateY(100%);
}

.gis-layout-collapsed .gis-layout-toggle {
    top: 0;
}

.gis-layout-collapsed .gis-layout-toggle-icon {
    transform: rotate(180deg);
}

/* Transition settings for layout elements */
.gis-header {
    transition: margin-top 0.3s ease, transform 0.3s ease;
}

.gis-footer {
    transition: margin-bottom 0.3s ease, transform 0.3s ease;
}

.gltf-layout {
    transition: height 0.3s ease;
}

/* Update height for GLTF scenes when header/footer are collapsed */
.gis-layout-collapsed .gltf-layout {
    height: calc(100vh - 40px);
}

    .gis-layout-collapsed .gltf-layout.gltf-layout-toolbar {
        height: calc(100vh - 90px);
    }

/* Side panel vertical splitter/resizer */
.gltf-resizer {
    width: 16px;
    background: transparent;
    cursor: col-resize;
    flex: 0 0 auto;
    position: relative;
    user-select: none;
    z-index: 10;
}

    .gltf-resizer::after {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 2px;
        height: 100%;
        background: rgba(0, 0, 0, 0.05);
        transition: background 0.2s ease, width 0.2s ease;
    }

    .gltf-resizer:hover::after,
    .gltf-resizer.is-dragging::after {
        background: var(--primary-color);
        width: 4px;
    }

/* Left side panel layout */
.gltf-left-panel {
    flex: 0 0 280px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
    overflow-y: auto;
}

/* Left side panel toggle button */
.gltf-left-panel-toggle {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 5;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: rgba(255, 255, 255, 0.92);
    color: var(--text-dark);
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

    .gltf-left-panel-toggle:hover {
        color: var(--primary-color);
        background: #ffffff;
    }

    .gltf-left-panel-toggle svg {
        transition: transform 0.2s ease;
    }

/* Rotate left chevron when expanded */
.gltf-layout:not(.gltf-left-panel-collapsed) .gltf-left-panel-toggle svg {
    transform: rotate(180deg);
}

/* Keyboard keycap controls hint styling */
.gltf-controls-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 5px 0;
}

.gltf-control-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

    .gltf-control-row:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

.gltf-control-key {
    font-weight: 600;
    color: var(--text-dark);
    background: #f1f3f5;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
    font-family: inherit;
}

.gltf-control-val {
    color: var(--text-muted);
    font-weight: 500;
}

/* Collapse state for left side panel and resizer */
.gltf-layout.gltf-left-panel-collapsed .gltf-left-panel {
    display: none;
}

.gltf-layout.gltf-left-panel-collapsed #gltf-left-resizer {
    display: none;
}