* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #eaf2ff;
    background: #07111d;
}

.topbar {
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 0 18px;
    background: linear-gradient(180deg, #0d1b2b, #091522);
    border-bottom: 1px solid rgba(148, 180, 215, 0.18);
    position: relative;
    z-index: 2000;
}

.brand {
    display: flex;
    align-items: center;
    min-width: 285px;
    gap: 12px;
}

.brand-icon {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 34px;
    font-weight: 700;
    color: #55a9ff;
    border: 2px solid #258cff;
    box-shadow: 0 0 18px rgba(37, 140, 255, 0.22);
}

.brand-title {
    font-weight: 750;
    font-size: 20px;
    line-height: 1.15;
}

.brand-subtitle {
    margin-top: 3px;
    font-size: 13px;
    color: #9cb0c8;
}

.topbar-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex: 1;
}

.search-wrap {
    position: relative;
    width: min(330px, 32vw);
}

#node-search {
    width: 100%;
    height: 42px;
    border: 1px solid #34485e;
    border-radius: 10px;
    background: #0b1724;
    color: #eef6ff;
    padding: 0 14px;
    outline: none;
    font-size: 14px;
}

#node-search:focus {
    border-color: #2f91ff;
    box-shadow: 0 0 0 2px rgba(47, 145, 255, 0.12);
}

.search-results {
    display: none;
    position: absolute;
    top: 48px;
    left: 0;
    right: 0;
    max-height: 320px;
    overflow-y: auto;
    background: #0d1a28;
    border: 1px solid #34485e;
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.38);
}

.search-result {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.search-result:last-child {
    border-bottom: 0;
}

.search-result:hover {
    background: #14273a;
}

.search-result strong {
    display: block;
    font-size: 13px;
}

.search-result small {
    color: #91a7be;
}

.summary {
    height: 42px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 12px;
    border: 1px solid #34485e;
    border-radius: 10px;
    background: #0b1724;
    font-size: 13px;
    white-space: nowrap;
}

.status-dot,
.legend-dot {
    display: inline-block;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.fresh {
    background: #18c765;
    box-shadow: 0 0 8px rgba(24, 199, 101, .45);
}

.recent {
    background: #f5b400;
}

.old {
    background: #8492a3;
}

.refresh-button {
    width: 42px;
    height: 42px;
    border: 1px solid #34485e;
    border-radius: 10px;
    background: #0b1724;
    color: #d8e7f7;
    cursor: pointer;
    font-size: 24px;
}

.refresh-button:hover {
    background: #14273a;
}

main {
    position: relative;
    height: calc(100% - 72px);
}

#map {
    width: 100%;
    height: 100%;
    background: #d7e1d1;
}

.map-panel {
    position: absolute;
    z-index: 1000;
    right: 16px;
    top: 16px;
    width: 245px;
    padding: 18px;
    border: 1px solid rgba(129, 165, 202, 0.25);
    border-radius: 14px;
    background: rgba(8, 20, 33, 0.94);
    box-shadow: 0 12px 35px rgba(0,0,0,.34);
    backdrop-filter: blur(6px);
}

.panel-title {
    font-size: 16px;
    font-weight: 650;
    color: #c7d6e6;
}

.big-count {
    margin-top: 3px;
    font-size: 38px;
    line-height: 1;
    font-weight: 750;
}

.separator {
    height: 1px;
    background: rgba(148, 180, 215, 0.22);
    margin: 16px 0;
}

.legend-row {
    display: grid;
    grid-template-columns: 16px 1fr auto;
    align-items: center;
    gap: 8px;
    margin: 12px 0;
    font-size: 13px;
}

.panel-note {
    color: #94a9bf;
    font-size: 12px;
    line-height: 1.45;
}

.map-legend {
    position: absolute;
    z-index: 1000;
    left: 16px;
    bottom: 18px;
    display: flex;
    gap: 16px;
    padding: 9px 12px;
    border-radius: 10px;
    color: #dbe8f5;
    background: rgba(8, 20, 33, .92);
    box-shadow: 0 6px 20px rgba(0,0,0,.25);
    font-size: 12px;
}

.map-legend span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.radio-marker {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 50% 50% 50% 8px;
    transform: rotate(-45deg);
    border: 3px solid white;
    box-shadow: 0 2px 9px rgba(0,0,0,.35);
}

.radio-marker.fresh-marker {
    background: #139e47;
}

.radio-marker.recent-marker {
    background: #e3a500;
}

.radio-marker.old-marker {
    background: #6f7d8d;
}

.radio-marker .antenna {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    transform: rotate(45deg);
    color: white;
    font-size: 19px;
    font-weight: 800;
}

.node-label {
    position: absolute;
    left: 31px;
    top: 8px;
    padding: 3px 7px;
    border-radius: 5px;
    background: rgba(8, 20, 33, .88);
    color: #fff;
    font-size: 11px;
    line-height: 1;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(0,0,0,.25);
}

.mesh-div-icon {
    overflow: visible !important;
    background: transparent !important;
    border: 0 !important;
}

.mesh-popup .leaflet-popup-content-wrapper {
    border-radius: 14px;
    box-shadow: 0 10px 34px rgba(0,0,0,.30);
}

.mesh-popup .leaflet-popup-content {
    width: 330px !important;
    margin: 0;
}

.node-popup {
    color: #172334;
    padding: 17px 18px 15px;
}

.popup-head {
    display: flex;
    align-items: center;
    gap: 11px;
}

.popup-radio {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: white;
    font-size: 23px;
    font-weight: 700;
    flex: 0 0 auto;
}

.popup-radio.fresh-marker {
    background: #139e47;
}

.popup-radio.recent-marker {
    background: #e3a500;
}

.popup-radio.old-marker {
    background: #6f7d8d;
}

.popup-name {
    font-size: 16px;
    font-weight: 750;
    line-height: 1.2;
}

.popup-sub {
    margin-top: 3px;
    color: #607087;
    font-size: 12px;
}

.popup-badge {
    display: inline-block;
    margin-top: 5px;
    padding: 2px 7px;
    border-radius: 10px;
    color: white;
    font-size: 10px;
    font-weight: 700;
}

.popup-badge.fresh-marker {
    background: #18b95b;
}

.popup-badge.recent-marker {
    background: #d49b00;
}

.popup-badge.old-marker {
    background: #748294;
}

.popup-section {
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px solid #e1e7ee;
}

.popup-section-title {
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 750;
    color: #26374c;
}

.signal-grid,
.telemetry-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px 12px;
    font-size: 12px;
}

.metric {
    color: #64758a;
}

.metric strong {
    color: #172334;
}

.popup-footer {
    margin-top: 13px;
    color: #69798c;
    font-size: 11px;
}

.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
    background: rgba(31, 119, 255, .26);
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
    background: #1f77ff;
    color: white;
    font-weight: 750;
    box-shadow: 0 0 0 2px white, 0 3px 10px rgba(0,0,0,.3);
}

@media (max-width: 850px) {
    .topbar {
        height: 64px;
        padding: 0 10px;
    }

    main {
        height: calc(100% - 64px);
    }

    .brand {
        min-width: 0;
    }

    .brand-icon {
        width: 38px;
        height: 38px;
        font-size: 26px;
    }

    .brand-title {
        font-size: 15px;
    }

    .brand-subtitle {
        font-size: 11px;
    }

    .summary {
        display: none;
    }

    .search-wrap {
        width: 180px;
    }

    .map-panel {
        display: none;
    }

    .map-legend {
        left: 10px;
        right: 10px;
        bottom: 10px;
        justify-content: center;
    }

    .node-label {
        display: none;
    }
}
/* Radio tower SVG */ .radio-svg {
    width: 25px;
    height: 25px;
    display: block;
    color: #fff;
}
.popup-radio .radio-svg {
    width: 30px;
    height: 30px;
}

/* Header radio tower */
.brand-icon .radio-svg {
    width: 36px;
    height: 36px;
    color: #55a9ff;
}

.brand-icon .radio-svg {
    width: 36px;
    height: 36px;
    color: #55a9ff;
    stroke: currentColor;
    stroke-width: 2.2;
    fill: none;
}


/* Primary channel messages */

.messages-title {
    margin-bottom: 9px;
    font-size: 13px;
    font-weight: 700;
    color: #c7d6e6;
}

.primary-messages {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 5px;
    scrollbar-width: thin;
    scrollbar-color: #40566d transparent;
}

.primary-message {
    padding: 8px 0;
    border-bottom: 1px solid rgba(148, 180, 215, 0.13);
}

.primary-message:last-child {
    border-bottom: 0;
}

.message-head {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 3px;
    font-size: 11px;
}

.message-time {
    color: #71879e;
    font-variant-numeric: tabular-nums;
}

.message-node,
.message-node-static {
    overflow: hidden;
    color: #55a9ff;
    font-size: 11px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-node {
    padding: 0;
    border: 0;
    background: none;
    font-family: inherit;
    cursor: pointer;
}

.message-node:hover {
    color: #8bc5ff;
    text-decoration: underline;
}

.message-node-static {
    color: #a2b1c0;
}

.message-text {
    color: #e2ebf5;
    font-size: 12px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.messages-empty {
    padding: 8px 0;
    color: #71879e;
    font-size: 11px;
}


/* Mobile Primary messages panel */
@media (max-width: 850px) {

    .map-panel {
        display: block;
        top: auto;
        right: 10px;
        bottom: 58px;
        width: min(310px, calc(100vw - 20px));
        padding: 12px;
        max-height: 230px;
    }

    .map-panel > .panel-title,
    .map-panel > .big-count,
    .map-panel > .legend-row,
    .map-panel > .panel-note {
        display: none;
    }

    .map-panel > .separator {
        display: none;
    }

    .map-panel > .messages-title {
        display: block;
        margin: 0 0 7px 0;
    }

    .primary-messages {
        max-height: 175px;
    }

    .primary-message {
        padding: 6px 0;
    }

    .message-text {
        font-size: 12px;
    }
}


/* Mobile MSG toggle */
.messages-toggle {
    display: none;
}

@media (max-width: 850px) {

    .messages-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 2px 7px;
        border: 1px solid rgba(85, 169, 255, 0.45);
        border-radius: 6px;
        background: transparent;
        color: #55a9ff;
        font: inherit;
        font-size: 11px;
        font-weight: 700;
        cursor: pointer;
    }

    .messages-toggle.active {
        background: rgba(85, 169, 255, 0.18);
    }

    .map-panel {
        display: none;
        right: 14px;
        bottom: 68px;
        width: min(280px, calc(100vw - 28px));
        padding: 9px 11px;
        max-height: none;
        border-radius: 14px;
    }

    .map-panel.messages-open {
        display: block;
    }

    .map-panel > .panel-title,
    .map-panel > .big-count,
    .map-panel > .legend-row,
    .map-panel > .panel-note,
    .map-panel > .separator {
        display: none;
    }

    .map-panel > .messages-title {
        display: block;
        margin: 0 0 4px 0;
        font-size: 12px;
    }

    .primary-messages {
        max-height: 180px;
        overflow-y: auto;
        padding-right: 3px;
    }

    .primary-message {
        padding: 5px 0;
    }

    .message-head {
        gap: 5px;
        margin-bottom: 1px;
        font-size: 10px;
    }

    .message-time,
    .message-node,
    .message-node-static {
        font-size: 10px;
    }

    .message-text {
        font-size: 11px;
        line-height: 1.25;
    }
}

/* Nodes without location navigation */
.unlocated-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 9px;
    border: 1px solid rgba(85,169,255,.45);
    border-radius: 6px;
    background: rgba(85,169,255,.10);
    color: #80c5ff;
    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.unlocated-link:hover {
    background: rgba(85,169,255,.22);
    color: #ffffff;
}


/* Mobile legend layout */
@media (max-width: 850px) {

    .map-legend {
        position: absolute;
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-wrap: nowrap;
        gap: 8px;
        left: 10px;
        right: 10px;
        bottom: 10px;
    }

    .map-legend > span {
        display: inline-flex;
        align-items: center;
        flex: 0 0 auto;
        white-space: nowrap;
        gap: 4px;
    }

    .map-legend .unlocated-link {
        position: absolute;
        right: 0;
        bottom: calc(100% + 8px);
        padding: 7px 10px;
        background: rgba(8, 20, 33, .94);
        white-space: nowrap;
    }

    .map-legend .messages-toggle {
        flex: 0 0 auto;
    }
}
