:root {
    --bg-main: #0a0c14;
    --bg-card: #121624;
    --accent-red: #ff4a4a;
    --accent-green: #00ff88;
    --accent-yellow: #ffbc00;
    --accent-blue: #0088ff;
    --accent-purple: #b356ff;
    --accent-pink: #ff69b4;
    --accent-highlighter: #ccff00;
    --text-main: #ffffff;
    --text-muted: #7e86a9;

    --header: #011000;
    
    /* ESS Palette */
    --neon-orange: #ff9100;
    --neon-yellow: #ffdd00;
    --neon-red: #ff3b3b;

    /* MUTED INDUSTRIAL FRAMEWORK DIVIDERS */
    --matrix-divider-light: #1f2538;
    --matrix-divider-strong: #252b41; 
    --group-center-border: #252b41; 
}

body {
    margin: 0; padding: 0;
    background: var(--bg-main); color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    display: flex; flex-direction: column;
    width: 100vw; height: 100vh; overflow: hidden;
}

/* MASTER HEADER STYLING */
.master-header {
    background: var(--header); 
    position: relative;
    padding: 0 40px; 
    border-bottom: 2px solid var(--matrix-divider-light);
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    z-index: 100;
    height: 140px; 
    box-sizing: border-box;
}

.left-control-wrapper { 
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 8px;
    width: 280px; 
}

.sync-protection-block {
    font-size: 11px; 
    color: var(--text-muted); 
    display: flex; 
    align-items: center; 
    font-weight: bold;
    font-family: monospace;
}

.audio-btn-small {
    background: linear-gradient(90deg, #ff9900, #ff5500); color: #fff;
    padding: 6px 12px; font-size: 11px; font-weight: bold; cursor: pointer;
    border: none; border-radius: 4px; box-shadow: 0 2px 6px rgba(255, 85, 0, 0.3);
    transition: all 0.2s; white-space: nowrap;
}

.audio-btn-small.activated {
    background: linear-gradient(90deg, #0088ff, #00ff88); color: #0a0c14; cursor: default;
    box-shadow: 0 2px 6px rgba(0, 255, 136, 0.2);
}

.header-brand-box { 
    display: flex; 
    flex-direction: row; 
    align-items: center; 
    justify-content: center;
    gap: 20px; 
    z-index: 105;
    flex: 1;
}

.company-logo { height: 110px; width: auto; object-fit: contain; }

.header-title-group {
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: left;
}

.header-title-group h1 { 
    margin: 0; font-size: 34px; font-weight: 800; letter-spacing: 0.5px; color: var(--text-main); line-height: 1.2;
    display: flex; align-items: center; gap: 12px;
}

.header-title-group subtitle { 
    font-size: 13px; color: #ff7700; font-weight: bold; text-transform: uppercase; display: block; margin-top: 4px; letter-spacing: 0.5px; 
}

.header-status-box { 
    display: flex; flex-direction: column; align-items: flex-end; justify-content: center; width: 320px; font-family: monospace; z-index: 104;
}

/* UI OPTIMIZATIONS: TIME & WEATHER */
#live-clock-display {
    color: #ffbc00 !important;
    font-size: 28px !important;
    font-weight: 700 !important;
    position: absolute;
    top: 10px;
    right: 20px;
    text-shadow: 0 0 5px rgba(255, 188, 0, 0.3);
}

.heartbeat { display: inline-block; width: 8px; height: 8px; background-color: #00cc66; border-radius: 50%; margin-right: 6px; box-shadow: 0 0 8px rgba(0,204,102,0.6); }

.weather-monitor-box {
    font-size: 18px !important;
    margin-top: 10px !important;
    text-align: right;
    font-family: monospace;
    color: var(--text-muted);
}

#hk-weather-prediction {
    font-size: 15px !important;
    font-weight: 500;
    opacity: 1 !important;
    color: #ffffff !important;
    margin-top: 5px !important;
}

.weather-badge {
    /* Base styling for dynamic JS injected badges */
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    margin-left: 6px;
    text-transform: uppercase;
}

/* GRID LAYOUTS */
.workspace { flex: 1; display: flex; width: 100%; overflow: hidden; }

/* GROUP 1: LEFT PANEL CLUSTER (43.5%) */
.left-cluster-group { 
    width: 43.5%; 
    display: flex; 
    flex-direction: row; 
    height: 100%; 
    overflow: hidden; 
    border-right: 2px solid var(--group-center-border); 
    box-sizing: border-box;
}
.sub-panel-1 { width: 33.33%; background: #0600056a; border-right: 1px solid #1f2438; padding: 25px 15px; display: flex; flex-direction: column; box-sizing: border-box; }

/* PANEL 2: NEW EXPERIMENTAL GREY TREATMENT */
.sub-panel-2 { width: 33.33%; background: #0600056a; border-right: 1px solid #1f2438; padding: 25px 15px; display: flex; flex-direction: column; box-sizing: border-box; }
#panel2-offline-box div[style*="color: var(--accent-pink)"] { color: #8c94b5 !important; }
#panel2-offline-count { color: #ffffff !important; text-shadow: 0 0 6px rgba(140, 148, 181, 0.2); }
#label-panel2 { color: #8c94b5 !important; }
#panel2-offline-list .card-item { border-left: 4px solid #5e6685 !important; background: #1b1e29 !important; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); }

/* PANEL 3 BASE LAYOUT */
.sub-panel-3 { width: 33.33%; background: #0600056a; padding: 25px 15px; display: flex; flex-direction: column; box-sizing: border-box; }

/* GROUP 2: COMPLEX CENTER SPINE (13%) */
.center-spine-group { 
    width: 13%; 
    display: flex; 
    flex-direction: column; 
    height: 100%; 
    box-sizing: border-box;
    border-right: 2px solid var(--group-center-border); 
    background: #05060a;
}

.panel-4 { 
    height: 15%;
    background: #070c14; 
    box-sizing: border-box; 
    padding: 8px; 
    display: flex; 
    flex-direction: column;
    justify-content: center;
    border-bottom: 2px solid var(--matrix-divider-strong); 
    overflow: hidden;
}
.sub-panel-8 { 
    height: 85%;
    background: #010102; 
    box-sizing: border-box; 
    padding: 20px 12px; 
    display: flex; 
    flex-direction: column; 
}

/* GROUP 3: ESS CLUSTER (43.5%) */
.ess-cluster-group { 
    width: 43.5%; 
    display: flex; 
    flex-direction: row; 
    height: 100%; 
    overflow: hidden; 
    box-sizing: border-box;
}

/* PANEL 5 LAYOUT (MATCHES PANEL 3 BACKDROP AND PADDING) */
.sub-panel-5 { 
    width: 33.33%; 
    background: #0600056a; 
    border-right: 1px solid #1f2438; 
    padding: 25px 15px; 
    display: flex; 
    flex-direction: column; 
    box-sizing: border-box; 
}

.sub-panel-6 { width: 33.33%; background: #070707; border-right: 1px solid #2a2312; padding: 25px 12px; display: flex; flex-direction: column; box-sizing: border-box; }
.sub-panel-7 { width: 33.33%; background: #070707; padding: 25px 12px; display: flex; flex-direction: column; box-sizing: border-box; }


/* ==================== UNIFIED PURPLE THEME TREATMENT (PANEL 3 & PANEL 5) ==================== */
#panel3-station-count, #panel5-ess-count {
    color: var(--accent-purple) !important;
    text-shadow: 0 0 8px rgba(179, 86, 255, 0.4);
}

#panel3-station-list .card-item, #list-panel5 .card-item {
    border-left: 4px solid var(--accent-purple) !important;
    background: #14111f !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

#panel3-station-list .placeholder, #list-panel5 .placeholder {
    color: rgba(179, 86, 255, 0.5) !important;
}


/* REUSABLE MONITOR CARDS */
.counter-card { background: var(--bg-card); border: 1px solid #1f2438; border-radius: 10px; padding: 12px; text-align: center; margin-bottom: 15px; position: relative; }
.big-number { font-size: 42px; font-weight: 700; line-height: 1.1; margin-top: 5px; font-family: monospace; }

.live-counter-box {
    flex: 1; 
    display: flex; 
    flex-direction: row; 
    justify-content: center; 
    align-items: center;
    gap: 16px;
    background: radial-gradient(circle, rgba(0, 136, 255, 0.08) 0%, rgba(0,0,0,0) 80%);
    border: 1px dashed rgba(0, 136, 255, 0.25); 
    border-radius: 8px; 
    padding: 0 5px;
    height: 100%;
    box-sizing: border-box;
    overflow: visible;
}

#panel4-live-charging-count {
    color: var(--accent-blue);
    font-size: 68px; 
    font-weight: 900;
    line-height: 1;
    margin: 0;
    font-family: monospace;
    text-shadow: 0 0 8px rgba(0, 136, 255, 0.4);
    transition: color 0.4s ease, text-shadow 0.4s ease;
}

#panel4-live-charging-count.critical-blip {
    animation: matrixTextBlink 2s infinite ease-in-out;
    will-change: color, text-shadow;
}

@keyframes matrixTextBlink {
    0% { color: #0088ff; text-shadow: 0 0 10px rgba(0, 136, 255, 0.6); }
    50% { color: #8cd6ff; text-shadow: 0 0 25px rgba(0, 136, 255, 0.95), 0 0 45px rgba(140, 214, 255, 0.85); }
    100% { color: #0088ff; text-shadow: 0 0 10px rgba(0, 136, 255, 0.6); }
}

.vector-bolt {
    display: inline-block; width: 26px; height: 42px; background-color: var(--accent-blue);
    clip-path: polygon(55% 0%, 0% 55%, 45% 55%, 30% 100%, 100% 35%, 55% 35%);
    filter: drop-shadow(0 0 10px rgba(0, 136, 255, 0.8)); flex-shrink: 0;
}

.list-header { font-weight: bold; margin-bottom: 12px; font-size: 13px; display: flex; justify-content: space-between; border-bottom: 1px solid #1f2438; padding-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-header span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.scroller-list { 
    flex: 1; 
    overflow-y: auto; 
    padding-right: 4px; 
    min-height: 0;
}

.scroller-list::-webkit-scrollbar { width: 6px; }
.scroller-list::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.02); border-radius: 3px; }
.scroller-list::-webkit-scrollbar-thumb { background: #1f2438; border-radius: 3px; }
.scroller-list::-webkit-scrollbar-thumb:hover { background: var(--accent-blue); }

.card-item { background: var(--bg-card); padding: 12px; margin-bottom: 8px; border-radius: 6px; border: 1px solid #1f2438; box-shadow: 0 4px 6px rgba(0,0,0,0.15); font-size: 12px; }

.card-title { font-size: 14px; font-weight: bold; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; word-break: break-all; }
.card-tag { font-size: 11px; font-weight: bold; margin-top: 4px; display: block; }

.placeholder { color: var(--text-muted); text-align: center; padding-top: 40px; font-style: italic; font-size: 12px; width: 100%; }

/* STATE-SPECIFIC BADGES */
.ess-metric-badge { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: bold; margin-top: 5px; font-family: monospace; }
.ess-soc-warning { border-left: 4px solid var(--neon-yellow) !important; background: #24220c !important; }
.ess-soc-critical { border-left: 4px solid var(--neon-red) !important; background: #2b0e0e !important; }
.ess-fault-triggered { border-left: 4px solid var(--neon-red) !important; background: #300c0c !important; animation: essPulseGlow 2s infinite ease-in-out; will-change: box-shadow; }

@keyframes essPulseGlow {
    0% { box-shadow: 0 0 5px rgba(255, 59, 59, 0.2); }
    50% { box-shadow: 0 0 12px rgba(255, 59, 59, 0.4); }
    100% { box-shadow: 0 0 5px rgba(255, 59, 59, 0.2); }
}


/* ==================== 2-COLUMN AUTH OVERLAY LAYOUT ==================== */

.sandbox-maintenance-mode {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: #0d0f1a;
    z-index: 99999; 
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
}

.auth-control-bar {
    background: #161a2e;
    border: 2px solid #252b41;
    border-radius: 8px;
    padding: 15px 30px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.auth-control-bar h2 { margin: 0; color: var(--accent-yellow); font-size: 20px; }
.auth-control-bar p { margin: 5px 0 0 0; color: var(--text-muted); font-size: 13px; }

.activate-dash-btn {
    background: linear-gradient(135deg, #00ff88 0%, #0088ff 100%);
    color: #0a0c14;
    border: none;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 900;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 255, 136, 0.3);
    transition: transform 0.1s ease;
}
.activate-dash-btn:active { transform: scale(0.98); }

.sandbox-iframe-wrapper {
    flex: 1;
    display: flex;
    gap: 20px;
    min-height: 500px;
}

.iframe-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #05060a;
    border: 1px solid var(--matrix-divider-strong);
    border-radius: 6px;
    padding: 10px;
}
.iframe-box label {
    color: #ffffff;
    font-size: 13px;
    font-weight: bold;
    margin-bottom: 8px;
    display: block;
    font-family: monospace;
}
.iframe-box iframe {
    flex: 1;
    width: 100%;
    border: none;
    background: #ffffff; 
    border-radius: 4px;
}

.hidden-sandbox-active {
    position: absolute;
    top: -99999px;
    left: -99999px;
    width: 1px; height: 1px;
    opacity: 0.001;
    pointer-events: none;
    visibility: hidden;
}

.counter-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
}

.panel-counter-icon {
    font-size: 32px;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.2));
}

.icon-grey { filter: grayscale(1) brightness(0.8); }