#datacenter-wrapper {
    position: relative;
    height: 120svh;
    background-color: #F1F1F1;
}
#datacenter-sticky {
    position: sticky;
    top: 0;
    z-index: 1;
}
#datacenter-charts {
    width: 100%;
    height: 800px;
    max-height: 100svh;
    background-color: #F7F7F7;
}
#datacenter-layer-controls {
    position: absolute;
    top: 20px;
    right: 360px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #ffffff;
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}
.layer-control-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}
.layer-control-label {
    flex-shrink: 0;
}
.layer-control-switch {
    margin-left: auto;
    font-size: 12px;
    color: #666666;
}
.layer-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.layer-dot--datacenter {
    background-color: #1D5BD0;
}
.layer-dot--substation {
    background-color: #F0A73F;
    border-radius: 2px;
    transform: rotate(45deg);
}
.substation-legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid #eeeeee;
    font-size: 12px;
    color: #666666;
}
.substation-legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.substation-legend-diamond {
    width: 9px;
    height: 9px;
    flex-shrink: 0;
    border-radius: 2px;
    transform: rotate(45deg);
}
.substation-legend-diamond--high {
    background-color: #FF5562;
}
.substation-legend-diamond--mid {
    background-color: #F0A73F;
}
.substation-legend-diamond--low {
    background-color: #59CEEE;
}
.datacenter-switch-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    cursor: pointer;
    user-select: none;
    font-size: 14px;
}
.datacenter-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}
.datacenter-switch input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}
.datacenter-switch-track {
    position: absolute;
    inset: 0;
    background-color: #cccccc;
    border-radius: 999px;
    transition: background-color 0.2s ease;
}
.datacenter-switch-track::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background-color: #ffffff;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.datacenter-switch input:checked + .datacenter-switch-track {
    background-color: #FF5562;
}
.datacenter-switch input:checked + .datacenter-switch-track::before {
    transform: translateX(16px);
}
.datacenter-switch input:focus-visible + .datacenter-switch-track {
    outline: 2px solid #1D5BD0;
    outline-offset: 2px;
}
#dc-metric-select-wrapper {
    position: absolute;
    right: 375px;
    bottom: 76px;
    z-index: 10;
}
#dc-metric-select {
    font-size: 14px;
    color: #969696;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}
#dc-metric-select:not(:has(option)) {
    display: none;
}
#datacenter-box {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
    width: 320px;
    max-height: calc(100% - 40px);
    overflow-y: auto;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
    padding: 20px;
    font-size: 13px;
    box-sizing: border-box;
    color: #333333;
}
/* 桌機版 #datacenter-box 一直都顯示，不需要開關按鈕；手機版才會在
   768px 那個區塊把它顯示出來 */
.dc-box-toggle {
    display: none;
}
.dc-stats-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.dc-stats-title {
    font-size: 18px;
    font-weight: 700;
}
.dc-stats-badge {
    background: #1D5BD0;
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 999px;
}
.dc-stats-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
    padding-bottom: 16px;
    margin-bottom: 12px;
    border-bottom: 1px solid #eeeeee;
}
.dc-stats-summary-item:nth-child(3) {
    flex-basis: 100%;
}
.dc-stats-summary-label {
    color: #969696;
    font-size: 12px;
    margin-bottom: 4px;
}
.dc-stats-summary-value {
    font-size: 22px;
    font-weight: 700;
}
.dc-stats-summary-unit {
    font-size: 12px;
    font-weight: 400;
    color: #969696;
    margin-left: 2px;
}
.dc-stats-summary-pct {
    font-size: 12px;
    font-weight: 400;
    color: #969696;
    margin-left: 6px;
}
.dc-stats-table-header {
    display: grid;
    grid-template-columns: 48px 1fr 32px;
    gap: 8px;
    align-items: center;
    color: #969696;
    font-size: 12px;
    padding-bottom: 8px;
}
.dc-stats-col-count {
    text-align: right;
}
.dc-stats-sort-arrow {
    font-size: 10px;
}
.dc-stats-row {
    display: grid;
    grid-template-columns: 48px 60px 1fr 32px;
    gap: 8px;
    align-items: center;
    padding: 6px 0;
}
.dc-stats-city {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dc-stats-bar-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.dc-stats-bar {
    height: 8px;
    border-radius: 4px;
    background: #FF5562;
    flex-shrink: 0;
}
.dc-stats-value {
    color: #666666;
    white-space: nowrap;
}
.dc-stats-count {
    text-align: right;
}
.dc-detail-card {
    padding: 12px 0;
    border-bottom: 1px solid #eeeeee;
}
.dc-detail-card:last-child {
    border-bottom: none;
}
.dc-detail-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.dc-detail-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
}
.dc-detail-badge--operational {
    background: #1D5BD0;
    color: #ffffff;
}
.dc-detail-badge--inactive {
    background: #e5e5e5;
    color: #666666;
}
.dc-detail-badge--type {
    background: #EEF2FA;
    color: #5B6B8C;
}
.dc-detail-name-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 10px;
}
.dc-detail-name {
    font-weight: 700;
}
.dc-detail-operator {
    color: #969696;
    font-size: 12px;
}
.dc-detail-stats {
    display: flex;
    gap: 24px;
}
.dc-detail-stat-label {
    color: #969696;
    font-size: 12px;
    margin-bottom: 2px;
}
.dc-detail-stat-value {
    font-size: 16px;
    font-weight: 700;
}
.dc-detail-stat-value--undisclosed {
    color: #d23a3a;
    font-size: 14px;
}
.dc-detail-unit {
    font-size: 12px;
    font-weight: 400;
    color: #969696;
}
.dc-detail-empty {
    color: #969696;
    padding: 24px 0;
    text-align: center;
}
.dc-detail-footnote {
    position: sticky;
    padding: 6px 0 10px;
    bottom: -24px;
    color: #969696;
    border-top: 1px solid #eeeeee;
    background-color: #ffffff;
    font-size: 11px;
}

/* ============================================================
   手機 RWD -- 768px 沿用 style.css 既有斷點（440px 是這個主題另一個更窄
   的斷點，畫面真的擠不下再開）。

   桌機版是「地圖滿版 + 幾個 position: absolute 面板疊在上面」，面板彼此
   的位置是互相卡死的 (#datacenter-layer-controls 的 right: 360px 是刻意
   留給 #datacenter-box 320px 寬度的空間)。手機螢幕窄，這種疊加式面板會
   互相蓋住，所以手機版改成：
     - #datacenter-box 資料面板從「浮在地圖右上角」改成貼底部的
       bottom sheet（手機地圖 App 常見模式），撐滿寬度，預設收合
       (opacity:0)，由 .dc-box-toggle 按鈕或點縣市時展開 (見
       tcan-datacenter-map.js 的 setDcBoxOpen())
     - 圖層開關 / 指標切換改貼地圖頂部左右兩側，不用再閃避資料面板；
       資料面板展開時 (.is-dc-box-open) 圖層開關跟開關按鈕都要跟著往上
       讓開，不然會被蓋住
     - 地圖高度縮小，把畫面讓給下面的資料面板
   ============================================================ */
@media (max-width: 768px) {
    #datacenter-wrapper {
        height: 120svh;
        padding: 8px;
    }
    #datacenter-sticky {
        height: 100svh;
        top: 8px;
    }
    #datacenter-charts {
        height: 100svh;
    }

    #datacenter-layer-controls {
        top: auto;
        bottom: 16px;
        left: 8px;
        right: auto;
        padding: 8px 12px;
        gap: 4px;
        background: rgba(255, 255, 255, 0.75);
    }
    .is-dc-box-open #datacenter-layer-controls {
        bottom: 250px;
    }
    .layer-control-row {
        font-size: 16px;
    }

    #dc-metric-select-wrapper {
        top: 18px;
        right: auto;
        bottom: auto;
        left: 8px;
    }
    #dc-metric-select {
        font-size: 16px;
        width: 200px;
    }
     #dc-metric-select option {
        font-size: 1em;
        max-width: fit-content;
     }

    #datacenter-box {
        opacity: 0;
        pointer-events: none; /* 隱藏時完全不擋底下地圖的點擊/拖曳，opacity:0 本身不會做到這件事 */
        transition: opacity 0.2s ease;
        top: auto;
        left: 0;
        right: 0;
        bottom: 0px;
        width: calc(100% - 16px);
        margin: 0 auto;
        height: 240px;
        max-height: 40svh;
        border-radius: 16px;
        padding: 16px;
    }
    .dc-stats-summary-label {
        font-size: 14px;
    }
    .dc-stats-table-header {
        font-size: 14px;
    }
    /* dc-box-toggle 按鈕（見 tcan-datacenter-map.js）幫 #datacenter-box 加/拿掉這個 class */
    #datacenter-box.is-open {
        opacity: 1;
        pointer-events: auto;
    }

    /* 手機版右下角的資訊 box 開關按鈕。z-index 故意比 #datacenter-box 高，
       這樣不管面板是開是關，按鈕都還是點得到（面板打開時按鈕會浮在
       面板右上角，是常見的收合手把位置）。 */
    .dc-box-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        right: 12px;
        bottom: 16px;
        width: fit-content;
        aspect-ratio: 1 / 1;
        border: 1px solid #1D5BD0;
        border-radius: 6px;
        background: #ffffff;
        color: #1D5BD0;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
        z-index: 100000;
        font-size: 16px;
        cursor: pointer;
        padding: 12px;
    }
    .dc-box-toggle-icon {
        pointer-events: none; /* 圖示本身不用接點擊，交給外層 button 處理 */
        transform: rotate(180deg);
    }
    .is-dc-box-open .dc-box-toggle {
        bottom: 250px;
    }
    .is-dc-box-open .dc-box-toggle-icon {
        transform: rotate(0deg);
    }
    .dc-stats-summary-item {
        flex-basis: initial;
    }
    .dc-stats-summary-item:nth-child(3) {
        flex-basis: initial;
    }
}