:root {
    --background: #050b11;
    --panel: #07131d;
    --panel2: #0a1b28;
    --line: #1e4257;
    --text: #e7f7ff;
    --muted: #7f9bad;
    --cyan: #20d4ed;
    --blue: #328cff;
    --green: #36e47e;
    --yellow: #f0d83d;
    --orange: #ff8c3a;
    --red: #ff4b5f;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: var(--background);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
    font: inherit;
}

.topbar {
    height: 74px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 20px;
    background: linear-gradient(90deg, #06111a, #0d2b3d, #06111a);
    border-bottom: 1px solid var(--line);
}

.brand-icon {
    width: 46px;
    height: 46px;
    display: grid;
    place-content: center;
    gap: 5px;
    border: 1px solid #267b9d;
    border-radius: 7px;
    background: rgba(32, 212, 237, 0.08);
}

.brand-icon span {
    width: 27px;
    height: 3px;
    background: var(--cyan);
    box-shadow: 0 0 9px var(--cyan);
}

.brand-copy h1 {
    margin: 0;
    font-size: 22px;
    letter-spacing: 0.18em;
}

.brand-copy p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.13em;
}

.platform-status {
    margin-left: auto;
    padding: 8px 12px;
    border: 1px solid #236746;
    border-radius: 20px;
    background: rgba(54, 228, 126, 0.08);
    color: #b9ffd5;
    font-size: 10px;
    letter-spacing: 0.1em;
}

.status-light {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 7px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 9px var(--green);
}

.clock {
    width: 180px;
    text-align: right;
    color: #9cc0d4;
    font-family: monospace;
    font-size: 12px;
}

.layout {
    height: calc(100% - 104px);
    display: grid;
    grid-template-columns: 280px minmax(500px, 1fr) 320px;
}

.sidebar {
    overflow-y: auto;
    background: rgba(7, 19, 29, 0.98);
}

.left-sidebar {
    border-right: 1px solid var(--line);
}

.right-sidebar {
    border-left: 1px solid var(--line);
}

.sidebar section {
    padding: 17px;
    border-bottom: 1px solid rgba(30, 66, 87, 0.75);
}

.sidebar h2 {
    margin: 0 0 13px;
    color: #87d3eb;
    font-size: 10px;
    letter-spacing: 0.14em;
}

.sidebar h3 {
    margin: 0;
    font-size: 16px;
}

.search-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px;
}

input,
select {
    width: 100%;
    padding: 10px;
    border: 1px solid #28516a;
    border-radius: 4px;
    outline: 0;
    background: #06131e;
    color: var(--text);
}

input:focus,
select:focus {
    border-color: var(--cyan);
}

button {
    padding: 9px 11px;
    border: 1px solid #2b7392;
    border-radius: 4px;
    background: linear-gradient(#174059, #0b293b);
    color: var(--text);
    cursor: pointer;
}

button:hover {
    border-color: var(--cyan);
}

.search-results {
    margin-top: 12px;
    color: var(--muted);
    font-size: 11px;
}

.search-result {
    padding: 9px 0;
    border-bottom: 1px solid #17364a;
    cursor: pointer;
}

.search-result strong,
.search-result span {
    display: block;
}

.search-result span {
    margin-top: 3px;
    color: var(--muted);
}

.check-row {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 11px 0;
    color: #c6dbe6;
    font-size: 12px;
}

.check-row input {
    width: auto;
    accent-color: var(--cyan);
}

.legend-row {
    margin: 9px 0;
    color: #b5ccd8;
    font-size: 11px;
}

.dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    margin-right: 8px;
    border-radius: 50%;
}

.green {
    background: var(--green);
}

.yellow {
    background: var(--yellow);
}

.orange {
    background: var(--orange);
}

.red {
    background: var(--red);
}

.gray {
    background: #738696;
}

.center {
    position: relative;
    min-width: 0;
}

.stats {
    height: 72px;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    background: #07131d;
    border-bottom: 1px solid var(--line);
}

.stats div {
    padding: 12px 14px;
    border-right: 1px solid #19374a;
}

.stats small {
    display: block;
    color: var(--muted);
    font-size: 9px;
    letter-spacing: 0.08em;
}

.stats strong {
    display: block;
    margin-top: 6px;
    font-size: 20px;
}

#map {
    position: absolute;
    top: 72px;
    right: 0;
    bottom: 0;
    left: 0;
    background: #03080d;
}

.leaflet-container {
    background: #03080d;
}

.leaflet-tile {
    filter:
        brightness(0.52)
        saturate(0.3)
        contrast(1.3)
        hue-rotate(165deg);
}

.map-buttons {
    position: absolute;
    z-index: 800;
    top: 87px;
    right: 14px;
    display: flex;
    gap: 5px;
}

.map-buttons button {
    padding: 7px 9px;
    font-size: 9px;
}

.map-status {
    position: absolute;
    z-index: 800;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 9px 16px;
    border: 1px solid #286987;
    border-radius: 18px;
    background: rgba(4, 17, 26, 0.92);
    color: #bdeeff;
    font-size: 11px;
}

dl {
    margin: 0;
    display: grid;
    grid-template-columns: 105px 1fr;
    gap: 9px 10px;
    font-size: 11px;
}

dt {
    color: var(--muted);
}

dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.health-state {
    margin-bottom: 15px;
    padding: 11px;
    border: 1px solid #30495a;
    border-radius: 4px;
    color: #8297a5;
    font-size: 11px;
}

footer {
    height: 30px;
    padding: 0 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--line);
    background: #050f17;
    color: #6f91a5;
    font-size: 9px;
    letter-spacing: 0.06em;
}

.facility-marker {
    width: 11px;
    height: 11px;
    border: 1px solid #e2fcff;
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 0 9px var(--cyan);
}

@media (max-width: 1050px) {
    .layout {
        grid-template-columns: 230px minmax(400px, 1fr) 270px;
    }

    .stats strong {
        font-size: 16px;
    }
}

select:active,
select:focus,
input:focus,
button:active {
    box-shadow: 0 0 0 2px rgba(32, 212, 237, 0.22);
}

.check-row:hover,
.legend-row:hover {
    color: #ffffff;
}

.control-feedback-active {
    border-color: #20d4ed !important;
}

/* SATELLITE BASEMAP FIX */
.leaflet-tile-pane .leaflet-tile {
    filter: none !important;
}

.leaflet-control-layers {
    background: rgba(5, 17, 26, 0.94);
    color: #e7f7ff;
    border: 1px solid #2b7392;
}

.leaflet-control-layers label {
    color: #e7f7ff;
}

.leaflet-control-layers-separator {
    border-top-color: #2b5268;
}

/* GLOBAL FIBER CLEAN SATELLITE DISPLAY */
.leaflet-tile {
    filter: none !important;
}

.leaflet-tile-pane {
    opacity: 1 !important;
}

.leaflet-overlay-pane {
    z-index: 450;
}

.leaflet-marker-pane {
    z-index: 650;
}

.leaflet-tooltip-pane {
    z-index: 700;
}

.leaflet-control-layers {
    max-width: 220px;
    background: rgba(4, 15, 24, 0.92);
    color: #eaf9ff;
    border: 1px solid #39718d;
    font-size: 11px;
}

.leaflet-control-layers label {
    color: #eaf9ff;
}

.leaflet-control-attribution {
    background: rgba(4, 15, 24, 0.72) !important;
    color: #d6e8f2 !important;
}

.leaflet-control-attribution a {
    color: #9edfff !important;
}

.leaflet-tooltip {
    background: rgba(4, 15, 24, 0.95);
    color: #ffffff;
    border: 1px solid #58bfdc;
    box-shadow: none;
}

/* GLOBAL_FIBER_MOBILE_BEGIN */

@media (max-width: 700px) {

    html,
    body {
        width: 100%;
        height: auto;
        min-height: 100%;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    .topbar {
        width: 100%;
        height: auto;
        min-height: 66px;
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        align-items: center;
        gap: 9px;
        padding:
            calc(8px + env(safe-area-inset-top))
            10px
            8px;
    }

    .brand-icon {
        width: 40px;
        height: 40px;
    }

    .brand-icon span {
        width: 23px;
    }

    .brand-copy {
        min-width: 0;
    }

    .brand-copy h1 {
        font-size: 17px;
        line-height: 1.15;
        letter-spacing: 0.11em;
        overflow-wrap: anywhere;
    }

    .brand-copy p {
        margin-top: 3px;
        font-size: 8px;
        line-height: 1.35;
        letter-spacing: 0.08em;
        overflow-wrap: anywhere;
    }

    .platform-status {
        grid-column: 1 / -1;
        width: fit-content;
        margin: 0;
        padding: 6px 9px;
        font-size: 9px;
    }

    .clock {
        grid-column: 1 / -1;
        width: 100%;
        text-align: left;
        font-size: 10px;
    }


    /* MAP FIRST */

    .layout {
        width: 100%;
        height: auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    .center {
        order: 1;
        width: 100%;
        height: 72vh;
        min-height: 510px;
        max-height: 760px;
        display: flex;
        flex-direction: column;
        position: relative;
    }

    .left-sidebar {
        order: 2;
        width: 100%;
        border-right: none;
        border-top: 1px solid var(--line);
    }

    .right-sidebar {
        order: 3;
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--line);
    }

    .sidebar {
        overflow: visible;
    }

    .sidebar section {
        padding: 14px 12px;
    }


    /* STATISTICS */

    .stats {
        flex: 0 0 auto;
        width: 100%;
        height: auto;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stats div {
        min-width: 0;
        padding: 8px 9px;
        border-right: 1px solid #19374a;
        border-bottom: 1px solid #19374a;
    }

    .stats small {
        font-size: 8px;
        line-height: 1.25;
        overflow-wrap: anywhere;
    }

    .stats strong {
        margin-top: 3px;
        font-size: 16px;
        line-height: 1.15;
        overflow-wrap: anywhere;
    }


    /* MAP */

    #map {
        position: relative;
        top: auto;
        right: auto;
        bottom: auto;
        left: auto;
        flex: 1 1 auto;
        width: 100%;
        min-height: 350px;
    }


    /* MAP BUTTONS */

    .map-buttons {
        top: auto;
        right: 8px;
        bottom: 42px;
        max-width: calc(100% - 16px);
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 5px;
    }

    .map-buttons button {
        min-height: 40px;
        padding: 7px 9px;
        font-size: 10px;
        touch-action: manipulation;
    }


    /* MAP STATUS */

    .map-status {
        right: 8px;
        bottom: 6px;
        left: 8px;
        width: auto;
        transform: none;
        padding: 7px 10px;
        border-radius: 6px;
        font-size: 9px;
        line-height: 1.3;
        text-align: center;
        overflow-wrap: anywhere;
        pointer-events: none;
    }


    /* TOUCH CONTROLS */

    .search-row {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 7px;
    }

    input,
    select,
    button {
        min-height: 44px;
    }

    input,
    select {
        padding: 10px;
        font-size: 16px;
    }

    button {
        padding: 9px 12px;
        touch-action: manipulation;
    }

    .search-results {
        font-size: 12px;
    }

    .search-result {
        padding: 11px 0;
    }

    .check-row {
        min-height: 44px;
        margin: 5px 0;
        font-size: 13px;
    }

    .check-row input {
        width: 21px;
        height: 21px;
    }


    /* DETAIL PANEL */

    dl {
        grid-template-columns:
            minmax(85px, 105px)
            minmax(0, 1fr);

        gap: 8px;
        font-size: 12px;
        line-height: 1.4;
    }

    dd {
        min-width: 0;
        overflow-wrap: anywhere;
        word-break: break-word;
    }


    /* LEAFLET */

    .leaflet-control-zoom a {
        width: 44px !important;
        height: 44px !important;
        line-height: 44px !important;
        font-size: 22px !important;
    }

    .leaflet-control-layers {
        max-width: calc(100vw - 30px);
        font-size: 12px;
    }

    .leaflet-control-layers-expanded {
        max-height: 55vh;
        padding: 10px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .leaflet-popup {
        max-width: calc(100vw - 40px);
    }

    .leaflet-popup-content-wrapper {
        max-width: calc(100vw - 40px);
    }

    .leaflet-popup-content {
        width: auto !important;
        max-width: calc(100vw - 72px);
        margin: 12px 14px;
        font-size: 12px;
        line-height: 1.45;
        overflow-wrap: anywhere;
        word-break: break-word;
    }


    /* FOOTER */

    footer {
        width: 100%;
        height: auto;
        min-height: 30px;
        flex-direction: column;
        align-items: flex-start;
        gap: 3px;
        padding:
            7px
            10px
            calc(7px + env(safe-area-inset-bottom));
        font-size: 8px;
        line-height: 1.4;
    }
}


@media (max-width: 430px) {

    .brand-copy h1 {
        font-size: 15px;
    }

    .brand-copy p {
        font-size: 7px;
    }

    .center {
        height: 69vh;
        min-height: 480px;
    }

    .stats strong {
        font-size: 15px;
    }

    #map {
        min-height: 330px;
    }

}


@media
    (max-width: 900px)
    and (orientation: landscape)
    and (max-height: 520px) {

    .center {
        height: 92vh;
        min-height: 430px;
        max-height: none;
    }

    .stats {
        grid-template-columns:
            repeat(3, minmax(0, 1fr));
    }

    .stats div {
        padding: 5px 8px;
    }

}

/* GLOBAL_FIBER_MOBILE_END */
