:root {
    --blue: #009DE0;
    --action: #0072ce;
    --deep: #0f4f7f;
    --slate: #17324d;
    --muted: #6b8195;
    --border: #dbe6f0;
    --bg: #f7fafc;
    --white: #fff;
    --shadow: 0 14px 42px rgba(20, 55, 90, .16);
    --gold: #f5a623;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0
}

body {
    font-family: 'Source Sans 3', system-ui, sans-serif;
    background: var(--bg);
    color: var(--slate);
    min-height: 100vh
}

.topbar {
    height: 72px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    box-shadow: 0 2px 14px rgba(30, 60, 90, .06);
    position: sticky;
    top: 0;
    z-index: 20
}

.brand {
    display: flex;
    align-items: center;
    gap: 22px;
    font-weight: 700
}

.brand-mark {
    font-size: 1.55rem;
    font-family: 'Kaushan Script', cursive;
    color: #12385c
}

.brand-mark strong {
    color: var(--blue)
}

.divider {
    height: 36px;
    width: 1px;
    background: #8da4b7
}

.brand-title {
    color: var(--blue);
    font-size: 1.2rem;
    letter-spacing: .04em;
    text-transform: uppercase
}

.top-actions {
    display: flex;
    gap: 14px;
    align-items: center
}

.btn {
    border: 0;
    border-radius: 8px;
    background: var(--action);
    color: #fff;
    font-weight: 700;
    padding: .65rem 1rem;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(0, 114, 206, .22)
}

.btn.secondary {
    background: #fff;
    color: var(--slate);
    border: 1px solid #cbd7e3;
    box-shadow: none
}

.layout {
    display: grid;
    grid-template-columns:300px minmax(600px, 1fr) 370px;
    gap: 22px;
    padding: 22px;
    max-width: 1680px;
    margin: 0 auto
}

.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 4px 18px rgba(40, 70, 100, .06)
}

.sidebar {
    padding: 16px;
    max-height: calc(100vh - 116px);
    overflow: auto;
    display: flex;
    flex-direction: column
}

.tabs {
    display: flex;
    gap: 4px;
    background: var(--bg);
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 10px;
    flex-shrink: 0
}

.tab {
    flex: 1;
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: .9rem;
    font-weight: 600;
    padding: .45rem .5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background .15s, color .15s
}

.tab.active {
    background: #fff;
    color: var(--slate);
    box-shadow: 0 1px 4px rgba(20, 55, 90, .1)
}

.tab-panel {
    display: none;
    flex-direction: column;
    gap: 5px;
    overflow: auto
}

.tab-panel.active {
    display: flex
}

.search {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .72rem .85rem;
    font: inherit;
    margin-bottom: 14px
}

.muted {
    color: var(--muted);
    font-size: .92rem;
    margin: 10px 0 8px
}

.diagram-list, .building-list {
    gap: 5px
}

.diagram-list button, .building-list button {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 0;
    background: #fff;
    color: var(--slate);
    border-radius: 8px;
    padding: .5rem .6rem;
    font: inherit;
    text-align: left;
    cursor: pointer
}

.diagram-list button:hover, .diagram-list button.active, .building-list button:hover, .building-list button.active {
    background: #edf5fd;
    color: #005da8
}

.diagram-list button.set-hover, .building-list button.set-hover {
    background: #e8f6ff;
    color: #005da8
}

.num, .dnum {
    display: inline-grid;
    place-items: center;
    min-width: 25px;
    height: 25px;
    border-radius: 50%;
    background: #0d4d7d;
    color: #fff;
    font-size: .82rem;
    font-weight: 700
}

.dnum {
    border-radius: 7px;
    background: #0072ce
}

.dnum.d0 {
    background: var(--gold);
    color: #17212b
}

.mini {
    display: block;
    font-size: .78rem;
    color: var(--muted);
    line-height: 1.2
}

.divider-line {
    height: 1px;
    background: var(--border);
    margin: 14px 0
}

.map-card {
    padding: 16px;
    position: relative
}

.map-stage {
    position: relative;
    max-width: 960px;
    margin: 0 auto
}

.campus-bg {
    display: block;
    width: 100%;
    height: auto;
    filter: brightness(1.02) contrast(.98) drop-shadow(0 10px 22px rgba(25, 65, 100, .12))
}

.overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none
}

.hotspot {
    pointer-events: auto;
    cursor: pointer;
    fill: rgba(7, 59, 103, .01);
    stroke: rgba(255, 255, 255, 0);
    stroke-width: 3.5;
    transition: fill .18s, filter .18s, transform .18s, stroke .18s;
    transform-box: fill-box;
    transform-origin: center
}

.hotspot:hover, .hotspot.set-hover, .hotspot.active {
    fill: rgba(0, 114, 206, .34);
    stroke: rgba(255, 255, 255, .95);
    filter: drop-shadow(0 0 14px rgba(0, 157, 224, .7));
    transform: scale(1.018)
}

.hotspot.set-hover, .hotspot.active {
    animation: pulseGlow 1.55s ease-in-out infinite
}

@keyframes pulseGlow {
    0%, 100% {
        filter: drop-shadow(0 0 8px rgba(0, 157, 224, .45))
    }
    50% {
        filter: drop-shadow(0 0 22px rgba(0, 157, 224, .95))
    }
}

.transformer-icon {
    pointer-events: auto;
    cursor: pointer
}

.transformer-icon image {
    transition: transform .18s, filter .18s;
    transform-box: fill-box;
    transform-origin: center;
    filter: drop-shadow(0 5px 12px rgba(245, 166, 35, .35))
}

.transformer-icon:hover image, .transformer-icon.set-hover image, .transformer-icon.active image {
    transform: scale(1.1);
    animation: pulseAmber 1.4s ease-in-out infinite
}

@keyframes pulseAmber {
    0%, 100% {
        filter: drop-shadow(0 0 10px rgba(245, 166, 35, .55))
    }
    50% {
        filter: drop-shadow(0 0 28px rgba(245, 166, 35, .95))
    }
}

.transformer-label {
    fill: #17324d;
    font-weight: 800;
    font-size: 33px;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none
}

.tooltip {
    position: fixed;
    z-index: 40;
    pointer-events: none;
    background: #17324d;
    color: #fff;
    border-radius: 7px;
    padding: .4rem .65rem;
    font-size: .9rem;
    font-weight: 700;
    opacity: 0;
    transform: translate(-50%, -140%);
    box-shadow: var(--shadow);
    white-space: nowrap
}

.tooltip.show {
    opacity: 1
}

.preview {
    position: fixed;
    z-index: 35;
    pointer-events: none;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translate(18px, -50%);
    width: 280px;
    overflow: hidden
}

.preview.show {
    opacity: 1
}

.preview-head {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f0f7ff;
    border-bottom: 1px solid var(--border);
    padding: 8px 10px;
    font-weight: 700
}

.preview img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 210px;
    object-fit: contain;
    background: #fff
}

.info-strip {
    margin-top: 14px;
    padding: .75rem 1rem;
    border: 1px solid #cfe1f4;
    border-radius: 8px;
    background: #f0f7ff;
    color: #005da8;
    font-size: .95rem
}

.details {
    padding: 20px;
    position: sticky;
    top: 94px;
    max-height: calc(100vh - 116px);
    display: flex;
    flex-direction: column
}

.details-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 14px;
    margin-bottom: 16px
}

.details-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.28rem;
    font-weight: 700
}

.set-members {
    font-size: .9rem;
    color: var(--muted);
    margin: .25rem 0 .85rem
}

.diagram-frame {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    min-height: 260px;
    display: grid;
    place-items: center;
    overflow: auto;
    margin: 12px 0
}

.diagram-frame img {
    max-width: 100%;
    height: auto;
    display: block;
    cursor: zoom-in
}

.detail-text {
    color: #405b73;
    line-height: 1.65
}

.empty {
    padding: 2rem;
    text-align: center;
    color: #789
}

.open-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: auto
}

.open-row .btn {
    flex: 1;
    text-align: center;
    justify-content: center
}

.badge-note {
    font-size: .84rem;
    color: var(--muted);
    margin-top: 10px
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(10, 25, 45, .92);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    gap: 16px
}

.modal.open {
    display: flex
}

.modal-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-shrink: 0
}

.modal-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    width: 100%
}

.modal-body img {
    max-width: 100%;
    max-height: calc(100vh - 120px);
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .5)
}

@media (max-width: 1180px) {
    .layout {
        grid-template-columns:1fr
    }

    .details {
        position: static
    }

    .sidebar {
        max-height: none
    }

    .topbar {
        padding: 0 14px
    }

    .brand-title {
        display: none
    }

    .preview {
        display: none
    }
}

.map-no-image {
    padding: 4rem 2rem;
    text-align: center;
    color: var(--muted);
    font-size: 1.1rem;
}
