:root {
    --p-main: #1E3A8A; 
    --p-sub: #64748B;
    --bg-main: #F8FAFC;
    --card-bg: #FFFFFF;
    --text-main: #1E293B;
    --border-color: #CBD5E1;
    --header-bg: linear-gradient(135deg, #1E3A8A 0%, #3B82F6 100%);
    --radius: 12px;
    --scanline-opacity: 0;
}

[data-theme="dark"] {
    --p-main: #FF0033; 
    --p-sub: #1E293B;
    --bg-main: #050505;
    --card-bg: #121212;
    --text-main: #E2E8F0;
    --border-color: #262626;
    --header-bg: #000000;
    --scanline-opacity: 0.2;
}

body {
    margin: 0; padding: 0;
    font-family: 'Segoe UI', 'Microsoft JhengHei', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex; flex-direction: column; height: 100vh; overflow: hidden;
}

body::before {
    content: " "; display: block; position: fixed; top: 0; left: 0; bottom: 0; right: 0;
    background: linear-gradient(rgba(18,16,16,0) 50%, rgba(0,0,0,0.1) 50%);
    background-size: 100% 4px; z-index: 9999; pointer-events: none; opacity: var(--scanline-opacity);
}

.header {
    background: var(--header-bg);
    border-bottom: 3px solid var(--p-main);
    padding: 0.8rem 1.5rem;
    display: flex; justify-content: space-between; align-items: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    z-index: 1002;
}

.header-left { display: flex; align-items: center; gap: 15px; }
.header h1 { margin: 0; color: #FFF; font-size: 1.3rem; letter-spacing: 1px; }

/* 手機版選單按鈕 */
.mobile-toggle-btn {
    display: none;
    background: rgba(255,255,255,0.1);
    color: white; border: 1px solid rgba(255,255,255,0.3);
    padding: 5px 12px; border-radius: 6px; cursor: pointer;
}

.content-container { display: flex; flex: 1; overflow: hidden; position: relative; }

.sidebar {
    width: 320px; padding: 15px;
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    overflow-y: auto; display: flex; flex-direction: column; gap: 12px;
    z-index: 1001;
    transition: transform 0.3s ease-in-out;
}

/* RWD 邏輯 */
@media (max-width: 768px) {
    .mobile-toggle-btn { display: block; }
    .sidebar {
        position: absolute; left: 0; top: 0; bottom: 0;
        transform: translateX(-100%);
        box-shadow: 10px 0 20px rgba(0,0,0,0.5);
    }
    .sidebar.active { transform: translateX(0); }
}

.section { background: rgba(128, 128, 128, 0.05); padding: 15px; border-radius: var(--radius); border: 1px solid var(--border-color); }
[data-theme="dark"] .section { border-left: 4px solid var(--p-main); }

.control-group label { display: block; font-size: 0.8rem; font-weight: bold; margin-bottom: 5px; color: var(--p-main); }
select { width: 100%; padding: 8px; border-radius: 6px; border: 1px solid var(--border-color); background: var(--card-bg); color: var(--text-main); }
input[type="range"] { width: 100%; accent-color: var(--p-main); }
.stat-value { font-size: 1.8rem; font-weight: 800; color: var(--p-main); text-align: center; }

.map-container { flex: 1; position: relative; }
#map { width: 100%; height: 100%; z-index: 1; }

.map-legend { position: absolute; bottom: 20px; right: 20px; background: var(--card-bg); padding: 12px; border-radius: 8px; border: 1px solid var(--border-color); width: 160px; z-index: 1000; }
.legend-title { font-size: 0.75rem; font-weight: bold; margin-bottom: 8px; color: var(--p-main); }
.legend-gradient { height: 8px; background: linear-gradient(to right, blue, cyan, lime, yellow, red); border-radius: 4px; }
.legend-scale { display: flex; justify-content: space-between; font-size: 0.65rem; margin-top: 5px; }

.action-button.primary { background: var(--p-main); color: #FFF; border: none; padding: 6px 15px; border-radius: 8px; cursor: pointer; }
.button-group { display: flex; gap: 8px; }
.toggle-button { flex: 1; padding: 10px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--card-bg); color: var(--text-main); cursor: pointer; font-size: 0.85rem; }