:root {
    --primary-bg: #1a2a1a;
    --panel-bg: #233a23;
    --panel-bg-light: #ece3c7;
    --text-dark: #233a23;
    --text-light: #ece3c7;
    --text-muted: #a4b08a;
    --accent-green-dark: #3c5c2e;
    --accent-green-mid: #7a9c5a;
    --accent-yellow: #c9b36a;
    --accent-orange: #c98c6a;
    --accent-red: #c96a6a;
    --glow-color: rgba(127, 255, 137, 0.3);
    --glass-dark: rgba(15, 25, 15, 0.95);
    --border-tech: 1px solid var(--accent-green-mid);
}

html, body {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Montserrat', sans-serif;
    background-color: var(--primary-bg);
    background-image: url('dashboard_bg.png');
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center center;
    background-attachment: fixed;
    color: var(--text-light);
    min-height: 100vh;
    min-width: 100vw;
    width: 100vw;
    height: 100vh;
    overflow-x: hidden;
}

/* --- DASHBOARD LAYOUT --- */

.dashboard-container {
    background-color: transparent;
    height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    box-sizing: border-box;
    padding: 0;
    transform: scale(0.92);
    transform-origin: top center;
}

header {
    text-align: left;
    margin: 0 0 8px 0;
    padding: 32px 48px 0 48px;
}

header h1 {
    font-family: 'Teko', sans-serif;
    text-transform: uppercase;
    text-shadow: 0 0 12px var(--glow-color);
    font-size: 3.2em;
    margin: 0;
    color: var(--text-light);
    letter-spacing: 6px;
}

header p {
    font-size: 1.2em;
    margin: 0;
    color: var(--accent-yellow);
    letter-spacing: 2px;
}

main {
    display: grid;
    grid-template-columns: 1fr 1.2fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 24px;
    height: calc(100vh - 110px);
    padding: 0 48px 32px 48px;
    box-sizing: border-box;
}

.left-panel, .center-panel, .right-panel {
    display: flex;
    flex-direction: column;
    gap: 24px;
    height: 100%;
}

/* --- PANELS & CONTAINERS --- */

.control-panel, .map-container, .climate-future-chart, .metrics-container, .energy-mix-chart {
    background-color: var(--panel-bg);
    border-radius: 24px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
    position: relative;
}

.control-panel {
    background-color: var(--panel-bg);
    padding: 32px 32px 24px 32px;
    flex: 1;
}

.map-container {
    flex: 1;
    min-height: 0;
    height: 100%;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--panel-bg-light);
    border-radius: 15px;
    box-shadow: 0 4px 30px rgba(30,40,50,0.15);
    border: none;
}

.climate-future-chart, .metrics-container, .energy-mix-chart {
    background-color: var(--panel-bg-light);
    color: var(--text-dark);
    padding: 24px;
}

.metrics-container, .energy-mix-chart {
    padding: 32px 32px 24px 32px;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.energy-mix-chart {
    padding: 32px 32px 24px 32px;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center; /* Center the chart horizontally */
}

/* --- CONTROLS & INPUTS --- */

.control-panel h2 {
    margin-top: 0;
    color: var(--accent-yellow);
    font-size: 2.2em;
    font-family: 'Teko', sans-serif;
    text-shadow: 0 0 8px var(--glow-color);
}

.control-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--accent-yellow);
    font-size: 1.1em;
}

.control-group .strategy-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.9em;
    color: var(--accent-yellow);
    margin-bottom: 4px;
}

/* Range Slider */
input[type="range"] {
    width: 100%;
    height: 8px;
    background: var(--accent-green-dark);
    border-radius: 5px;
    outline: none;
    margin-bottom: 16px;
    -webkit-appearance: none;
    appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent-yellow);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(201,179,106,0.5);
    transition: transform 0.2s;
}
input[type="range"]:hover::-webkit-slider-thumb {
    transform: scale(1.2);
}

/* Select & Buttons (Left Panel) */
.control-select {
    width: 100%;
    padding: 12px;
    background-color: var(--accent-green-dark);
    border: 1px solid var(--accent-green-mid);
    color: var(--accent-yellow);
    border-radius: 8px;
    font-size: 1em;
    margin-bottom: 16px;
}

.preprocess-button {
    width: 100%;
    padding: 12px;
    background-color: var(--primary-bg);
    border: 1px solid var(--accent-green-dark);
    color: var(--text-muted);
    font-size: 1em;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 8px;
    transition: all 0.3s;
    font-weight: bold;
}

.preprocess-button:hover {
    background-color: var(--accent-green-dark);
    color: var(--accent-yellow);
    box-shadow: 0 0 10px var(--glow-color);
}

/* --- MAP STYLES --- */

#malaysia-map {
    width: 100%;
    height: 180px;
    background-color: transparent;
    border-radius: 10px;
    margin: 0 auto;
    position: relative;
    transition: opacity 0.3s ease-in-out;
}

#malaysia-map svg {
    width: 100%;
    height: 100%;
    cursor: grab;
    user-select: none;
    touch-action: none;
}

#malaysia-map svg:active {
    cursor: grabbing;
}

.map-info-box {
    position: absolute;
    left: 24px;
    bottom: 18px;
    background: var(--panel-bg-light);
    color: var(--text-dark);
    font-family: 'Teko', sans-serif;
    font-size: 1.15em; /* Bigger font size */
    font-weight: 400; /* Normal weight, not bold */
    padding: 8px 18px; /* Adjusted padding */
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    max-width: 200px; /* Increased max-width for the info box */
    z-index: 2;
    pointer-events: none;
    letter-spacing: 0.8px; /* Adjusted letter-spacing */
}

.state {
    stroke: var(--accent-green-dark);
    stroke-width: 2px;
    transition: fill 0.2s;
}

.state:hover {
    fill: var(--accent-orange);
    cursor: pointer;
    stroke: #fff;
}

.map-legend {
    position: absolute;
    right: 18px;
    bottom: 18px;
    background: var(--panel-bg-light);
    color: var(--text-dark);
    font-family: 'Teko', sans-serif;
    padding: 6px 10px; /* Adjusted padding */
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    z-index: 2;
    font-size: 0.8em; /* Smaller base font size for the legend */
    letter-spacing: 0.4px; /* Adjusted letter-spacing */
}

.map-legend .legend-title {
    font-weight: bold;
    margin-bottom: 4px;
    color: var(--accent-green-dark);
    font-size: 1em; /* Ensure title is readable, relative to base legend font size */
}

.map-legend .small-legend-title {
    font-size: 0.9em; /* Adjusted to be relative to the new .map-legend font-size */
    letter-spacing: 0.2px;
}

.map-legend .legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 2px;
}

.map-legend .legend-color-box {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    margin-right: 6px;
    border: 1px solid rgba(0,0,0,0.1);
}

.map-legend .legend-label {
    color: var(--text-dark);
    font-size: 1em; /* Explicitly set to inherit/match parent font size for consistency */
    white-space: nowrap; /* Prevent labels from wrapping */
}

.state-rank {
    font-family: 'Teko', sans-serif;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000; /* Outline for readability */
}

/* --- CHARTS & METRICS --- */

.climate-future-chart h3, .energy-mix-chart h3 {
    color: var(--accent-green-dark);
    margin-top: 0;
    text-align: center;
    font-size: 1.3em;
    font-family: 'Teko', sans-serif;
    letter-spacing: 2px;
    font-weight: bold;
}

.metric { margin-bottom: 18px; min-height: 80px; /* Set a minimum height to accommodate longer titles */}
.metric:last-child { margin-bottom: 0; }
.metric p {
    margin: 0;
    line-height: 1.2;
}
.metric p:first-child {
    font-family: 'Teko', sans-serif;
    font-size: 1.3em; /* Adjusted font size */
    letter-spacing: 0.8px; /* Slightly reduced letter spacing */
    font-weight: 600; /* Adjusted font weight to be slightly bolder */
    color: var(--accent-green-dark);
    margin-bottom: 5px; /* Added margin to separate title from value */
    word-wrap: break-word;
    white-space: normal;
    flex-shrink: 0;
}

.metric .metric-value {
    font-family: 'Teko', sans-serif;
    font-size: 2.5em; /* Slightly increased font size for prominence */
    font-weight: 700;
    line-height: 1;
    color: var(--accent-orange);
    transition: all 0.5s ease-out;
}

#top-state { transition: opacity 0.5s ease-out; }

/* Chart Specifics */
.chart-and-labels {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    flex-grow: 1;
}

.chart-container {
    position: relative;
    width: 100%; /* Make width responsive */
    height: 180px; /* Increased height for better visibility */
    display: flex; /* Use flexbox to center content */
    justify-content: center;
    align-items: center;
}

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 12px;
}

.chart-legend > div {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1em;
    color: var(--accent-green-dark);
}

.legend-color {
    width: 13px;
    height: 13px;
    border-radius: 50%;
}

/* --- STATE SIDEBAR (RIGHT) - ENHANCED DARK THEME --- */

.state-sidebar {
    position: fixed;
    top: 0;
    right: -450px;
    width: 400px;
    height: 100%;
    background: linear-gradient(180deg, #0d1a0d 0%, #1a2a1a 50%, #0f1f0f 100%);
    color: #e8f5e9;
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.5), -2px 0 20px rgba(127, 255, 137, 0.1);
    z-index: 1001;
    transition: right 0.5s cubic-bezier(0.23, 1, 0.32, 1);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.state-sidebar.open { right: 0; }

/* Animated particles background */
.sidebar-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, rgba(127, 255, 137, 0.4), transparent),
        radial-gradient(2px 2px at 80px 60px, rgba(201, 179, 106, 0.3), transparent),
        radial-gradient(1px 1px at 130px 120px, rgba(127, 255, 137, 0.3), transparent),
        radial-gradient(2px 2px at 180px 80px, rgba(127, 255, 137, 0.4), transparent),
        radial-gradient(1px 1px at 250px 150px, rgba(201, 179, 106, 0.3), transparent),
        radial-gradient(2px 2px at 320px 200px, rgba(127, 255, 137, 0.3), transparent);
    background-size: 400px 400px;
    animation: sidebarParticleFloat 20s linear infinite;
    pointer-events: none;
    opacity: 0.6;
}

@keyframes sidebarParticleFloat {
    0% { transform: translateY(0); }
    100% { transform: translateY(-400px); }
}

/* Glowing border effect */
.sidebar-glow-border {
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, 
        transparent 0%,
        #7fff89 20%,
        #C9B36A 50%,
        #7fff89 80%,
        transparent 100%
    );
    box-shadow: 0 0 20px rgba(127, 255, 137, 0.6), 0 0 40px rgba(127, 255, 137, 0.3);
    animation: glowPulse 2s ease-in-out infinite;
}

@keyframes glowPulse {
    0%, 100% { opacity: 0.7; box-shadow: 0 0 20px rgba(127, 255, 137, 0.6); }
    50% { opacity: 1; box-shadow: 0 0 30px rgba(127, 255, 137, 0.8), 0 0 60px rgba(127, 255, 137, 0.4); }
}

.sidebar-content {
    padding: 28px 28px 24px 28px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
    z-index: 2;
    height: 100%;
}

/* Close Button */
.close-sidebar {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(127, 255, 137, 0.1);
    border: 1px solid rgba(127, 255, 137, 0.3);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.close-sidebar:hover {
    background: rgba(201, 106, 106, 0.2);
    border-color: #c96a6a;
    transform: rotate(90deg) scale(1.1);
}

.close-icon {
    font-size: 1.5em;
    color: #7fff89;
    line-height: 1;
    transition: color 0.3s;
}

.close-sidebar:hover .close-icon {
    color: #ff7f7f;
}

/* Header Section */
.sidebar-header {
    text-align: center;
    margin-top: 20px;
    padding-bottom: 15px;
}

.state-icon-wrapper {
    width: 60px;
    height: 60px;
    margin: 0 auto 12px;
    background: linear-gradient(135deg, rgba(127, 255, 137, 0.2), rgba(201, 179, 106, 0.2));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(127, 255, 137, 0.4);
    box-shadow: 0 0 20px rgba(127, 255, 137, 0.3);
    animation: iconFloat 3s ease-in-out infinite;
}

@keyframes iconFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.state-icon {
    width: 30px;
    height: 30px;
    color: #7fff89;
}

.sidebar-title {
    font-family: 'Teko', sans-serif;
    font-size: 2.2em;
    font-weight: 700;
    color: #7fff89;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 3px;
    text-shadow: 0 0 20px rgba(127, 255, 137, 0.5);
}

.title-underline {
    width: 80px;
    height: 3px;
    background: linear-gradient(90deg, transparent, #C9B36A, transparent);
    margin: 10px auto 0;
    border-radius: 2px;
}

/* Stats Quick View */
.sidebar-stats-preview {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.stat-mini {
    flex: 1;
    background: rgba(26, 42, 26, 0.8);
    border: 1px solid rgba(127, 255, 137, 0.2);
    border-radius: 12px;
    padding: 12px 8px;
    text-align: center;
    transition: all 0.3s ease;
}

.stat-mini:hover {
    border-color: rgba(127, 255, 137, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(127, 255, 137, 0.15);
}

.stat-mini-icon {
    font-size: 1.4em;
    display: block;
    margin-bottom: 4px;
}

.stat-mini-label {
    font-size: 0.7em;
    color: #a4b08a;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: block;
}

.stat-mini-value {
    font-family: 'Teko', sans-serif;
    font-size: 1.3em;
    font-weight: 600;
    color: #C9B36A;
    display: block;
    margin-top: 2px;
}

/* Summary Section */
.sidebar-summary-wrapper {
    background: rgba(15, 25, 15, 0.6);
    border: 1px solid rgba(127, 255, 137, 0.15);
    border-radius: 12px;
    padding: 16px;
    flex: 1;
    overflow-y: auto;
}

.summary-label {
    font-family: 'Teko', sans-serif;
    font-size: 1.1em;
    color: #7fff89;
    margin: 0 0 10px 0;
    letter-spacing: 1px;
}

.sidebar-summary-text {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.9em;
    line-height: 1.7;
    color: #c8e8c8;
    margin: 0;
}

/* Action Buttons */
.sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar-action-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border: none;
    border-radius: 12px;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.sidebar-action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s ease;
}

.sidebar-action-btn:hover::before {
    left: 100%;
}

.sidebar-action-btn.primary {
    background: linear-gradient(135deg, #3c5c2e, #4a7a3a);
    color: #e8f5e9;
    border: 1px solid rgba(127, 255, 137, 0.3);
    box-shadow: 0 4px 15px rgba(60, 92, 46, 0.4);
}

.sidebar-action-btn.primary:hover {
    background: linear-gradient(135deg, #4a7a3a, #5a9a4a);
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(127, 255, 137, 0.3);
}

.sidebar-action-btn.secondary {
    background: linear-gradient(135deg, #6a4a3c, #8a5c4a);
    color: #f5e8e0;
    border: 1px solid rgba(201, 140, 106, 0.3);
    box-shadow: 0 4px 15px rgba(106, 74, 60, 0.4);
}

.sidebar-action-btn.secondary:hover {
    background: linear-gradient(135deg, #8a5c4a, #9a6c5a);
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(201, 140, 106, 0.3);
}

.btn-icon {
    font-size: 1.2em;
}

.btn-text {
    flex: 1;
    text-align: left;
}

.btn-arrow {
    font-size: 1.2em;
    transition: transform 0.3s ease;
}

.sidebar-action-btn:hover .btn-arrow {
    transform: translateX(5px);
}

/* Footer */
.sidebar-footer {
    text-align: center;
    padding-top: 10px;
    margin-top: auto;
}

.footer-decoration {
    width: 60%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(127, 255, 137, 0.3), transparent);
    margin: 0 auto 10px;
}

.footer-text {
    font-family: 'Teko', sans-serif;
    font-size: 0.8em;
    color: #5a7a5a;
    letter-spacing: 3px;
    text-transform: uppercase;
}

/* Custom Scrollbar for Sidebar */
.sidebar-summary-wrapper::-webkit-scrollbar {
    width: 6px;
}

.sidebar-summary-wrapper::-webkit-scrollbar-track {
    background: rgba(15, 25, 15, 0.5);
    border-radius: 3px;
}

.sidebar-summary-wrapper::-webkit-scrollbar-thumb {
    background: rgba(127, 255, 137, 0.3);
    border-radius: 3px;
}

.sidebar-summary-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(127, 255, 137, 0.5);
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(10, 20, 10, 0.6);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: none;
    opacity: 0;
    transition: opacity 0.4s;
}
.sidebar-overlay.open { display: block; opacity: 1; }

/* State Sidebar Content Enhancements */
.sidebar-state-header {
    font-family: 'Teko', sans-serif;
    font-size: 2em;
    color: var(--accent-green-dark);
    animation: fadeinDown 0.7s;
}
.state-summary-blk {
    display: flex; flex-direction: column; gap: 8px;
}
.sidebar-info-row {
    display: flex; 
    justify-content: space-between; 
    font-size: 0.95em; 
    padding: 10px 12px;
    background: rgba(26, 42, 26, 0.5);
    border: 1px solid rgba(127, 255, 137, 0.1);
    border-radius: 8px;
    transition: all 0.3s ease;
}
.sidebar-info-row:hover {
    background: rgba(26, 42, 26, 0.8);
    border-color: rgba(127, 255, 137, 0.25);
}
.sidebar-label {
    color: #a4b08a; 
    font-weight: 500;
}
.sidebar-info-row span:last-child {
    color: #e8f5e9;
    font-weight: 600;
}
.sidebar-info-row.highlight {
    color: #C9B36A; 
    font-size: 1em; 
    font-weight: bold;
    background: linear-gradient(135deg, rgba(201, 140, 106, 0.15), rgba(201, 179, 106, 0.15));
    border: 1px solid rgba(201, 179, 106, 0.3);
    border-radius: 8px; 
    padding: 12px;
    animation: fadeinDown 1.2s;
}
.sidebar-info-row.highlight span:last-child {
    color: #C9B36A;
}
.fun-msg-row {
    font-size: 0.95em; 
    color: #7fff89; 
    margin-top: 12px; 
    letter-spacing: 0.5px; 
    text-align: center;
    padding: 10px;
    background: rgba(127, 255, 137, 0.08);
    border-radius: 8px;
    border: 1px dashed rgba(127, 255, 137, 0.3);
    animation: fadeinDown 1.5s;
}
.sidebar-animated {
    font-variant-numeric: tabular-nums;
    transition: all 0.35s ease;
}

/* 
   ================================================================
   === DATA TABLE SIDEBAR STYLES ===
   ================================================================
*/

.data-table-sidebar {
    position: fixed;
    top: 0;
    right: -80vw;
    width: 75vw;
    height: 100%;
    background: var(--glass-dark);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-left: 2px solid var(--accent-yellow);
    color: var(--text-light);
    z-index: 1002;
    transition: right 0.5s cubic-bezier(0.23, 1, 0.32, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -20px 0 50px rgba(0,0,0,0.8);
}

.data-table-sidebar.open { right: 0; }

.table-sidebar-content {
    height: 100%;
    padding: 30px 40px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.sidebar-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--accent-green-mid);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.data-table-sidebar-header {
    font-family: 'Teko', sans-serif;
    font-size: 2.5em;
    color: var(--accent-yellow);
    margin: 0;
    text-shadow: 0 0 10px rgba(201, 179, 106, 0.4);
    letter-spacing: 2px;
}

/* Controls Area (Glass Panel) */
.glass-panel {
    background: rgba(60, 92, 46, 0.2);
    border: 1px solid var(--accent-green-mid);
    border-radius: 8px;
    padding: 20px;
    display: flex;
    gap: 20px;
    align-items: flex-end;
    margin-bottom: 15px;
}

.control-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.control-item label {
    font-family: 'Teko', sans-serif;
    font-size: 1.1em;
    color: var(--accent-green-mid);
    letter-spacing: 1px;
}

/* DROPDOWN VISIBILITY FIX */
.data-table-controls select,
.data-table-controls input[type="text"] {
    padding: 12px 16px;
    background-color: #0f150f; /* Solid dark background */
    border: 1px solid var(--accent-yellow); /* High contrast border */
    color: var(--accent-yellow); /* Bright text */
    border-radius: 4px;
    font-family: 'Montserrat', sans-serif;
    font-size: 1em;
    outline: none;
    transition: all 0.3s;
}

.data-table-controls select option {
    background-color: #0f150f;
    color: var(--text-light);
}

.data-table-controls select:focus,
.data-table-controls input:focus {
    border-color: #fff;
    box-shadow: 0 0 10px rgba(201, 179, 106, 0.4);
}

.control-actions { display: flex; gap: 10px; }

.sidebar-control-button {
    padding: 12px 24px;
    font-family: 'Teko', sans-serif;
    font-size: 1.1em;
    font-weight: bold;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    letter-spacing: 1px;
    transition: all 0.2s ease;
}

.action-btn {
    background-color: var(--accent-yellow);
    color: var(--primary-bg);
}
.action-btn:hover {
    background-color: #fff;
    box-shadow: 0 0 15px var(--accent-yellow);
}

.primary-action-btn {
    background-color: var(--accent-yellow);
    color: var(--primary-bg); /* Dark text on golden background */
    border: 2px solid var(--accent-yellow); /* Matching border */
    box-shadow: 0 0 20px rgba(201, 179, 106, 0.7), 0 0 10px var(--accent-yellow) inset; /* Golden glow */
    font-size: 1.2em;
    padding: 10px 20px;
    transform: scale(1.05);
    text-shadow: 0 0 8px rgba(0,0,0,0.3); /* Subtle dark text shadow */
}

.primary-action-btn:hover {
    background-color: var(--accent-orange); /* Slightly different hover color */
    color: var(--text-light);
    border-color: var(--accent-orange);
    box-shadow: 0 0 25px rgba(201, 140, 106, 0.9), 0 0 15px var(--accent-orange) inset;
    transform: scale(1.1);
}

.reset-btn {
    background-color: transparent;
    border: 1px solid var(--accent-green-mid);
    color: var(--text-muted);
}
.reset-btn:hover {
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.data-actions-row {
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
    justify-content: flex-start;
    flex-wrap: wrap;
}
.sm-btn {
    padding: 8px 14px;
    font-size: 0.85em;
    background: rgba(60, 92, 46, 0.3);
    color: var(--text-light);
    border: 1px solid var(--accent-green-dark);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}
.sm-btn:hover { 
    background: var(--accent-green-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.sm-btn:active {
    transform: translateY(0);
}

/* Table Styling */
.table-container {
    flex-grow: 1;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--accent-green-dark);
    border-radius: 4px;
    position: relative;
}

/* Custom Scrollbar */
.custom-scrollbar::-webkit-scrollbar { width: 8px; height: 8px; }
.custom-scrollbar::-webkit-scrollbar-track { background: #0f150f; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: var(--accent-green-dark); border-radius: 4px; }
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: var(--accent-green-mid); }

#csvDataTable {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Courier New', Courier, monospace;
}

#csvDataTable thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--primary-bg);
}

#csvDataTable th {
    background: var(--accent-green-dark);
    color: var(--accent-yellow);
    padding: 15px;
    text-align: left;
    text-transform: uppercase;
    font-family: 'Teko', sans-serif;
    font-size: 1.2em;
    letter-spacing: 1px;
    border-bottom: 2px solid var(--accent-yellow);
}

#csvDataTable td {
    padding: 12px 15px;
    color: var(--text-light);
    border-bottom: 1px solid rgba(60, 92, 46, 0.5);
    font-size: 0.95em;
}

#csvDataTable tbody tr { transition: background-color 0.2s; }
#csvDataTable tbody tr:nth-child(even) { background-color: rgba(255, 255, 255, 0.03); }
#csvDataTable tbody tr:hover {
    background-color: rgba(201, 179, 106, 0.15);
    box-shadow: inset 3px 0 0 var(--accent-yellow);
}

.table-footer {
    margin-top: 10px;
    text-align: right;
    font-family: 'Courier New', monospace;
    color: var(--accent-green-mid);
    font-size: 0.8em;
    letter-spacing: 1px;
}
/* --- MODAL STYLES (STATE SELECTOR) --- */

.modal-overlay {
    position: fixed;
    top: 0; 
    left: 0;
    width: 100vw; 
    height: 100vh;
    background: rgba(0, 0, 0, 0.85); /* Dark background */
    z-index: 9999; /* EXTREMELY HIGH Z-INDEX to sit on top of everything */
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none; /* Prevent clicking when hidden */
}

/* When the .open class is added by JS, this makes it visible */
.modal-overlay.open {
    display: flex !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.modal-box {
    width: 500px;
    max-width: 90%;
    background: #1a2a1a; /* Solid background fallback */
    background: var(--glass-dark);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--accent-yellow);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
    padding: 30px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    position: relative;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
    width: 100%;
    padding-right: 5px;
    margin-bottom: 20px;
    border: 1px solid rgba(60, 92, 46, 0.5);
    padding: 10px;
    border-radius: 6px;
}

.state-checkbox-label {
    display: flex;
    align-items: center;
    background: rgba(60, 92, 46, 0.3);
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: 0.2s;
    border: 1px solid transparent;
    font-size: 0.95em;
    color: var(--text-light);
    user-select: none;
}

.state-checkbox-label:hover {
    background: rgba(60, 92, 46, 0.6);
    border-color: var(--accent-yellow);
}

.state-checkbox-label input {
    margin-right: 12px;
    width: 18px;
    height: 18px;
    accent-color: var(--accent-yellow);
    cursor: pointer;
}

/* Add this to style.css */

.table-info-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 10px;
    padding: 0 4px;
    border-bottom: 1px solid var(--accent-green-mid);
}

.table-info-header h3 {
    font-family: 'Teko', sans-serif;
    font-size: 1.6em;
    color: var(--text-light);
    margin: 0;
    letter-spacing: 1px;
    text-transform: uppercase;
}
/* The following block for #table-row-count-display will be removed */
/*
#table-row-count-display {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: var(--accent-yellow);
    font-size: 1.1em;
    text-shadow: 0 0 5px rgba(201, 179, 106, 0.3);
}
*/
/* --- ANIMATIONS --- */
@keyframes popFlash {
    0% { transform: scale(0.8); opacity:0; }
    70% { transform: scale(1.3); opacity:1; }
    100% { transform: scale(1); opacity:1; }
}
@keyframes fadeinDown {
    0% {transform: translateY(-25px); opacity:0;} 100% {transform:none; opacity:1;}
}
@keyframes slideInLeft {
    0% { transform: translateX(-100%); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}
@keyframes slideInRight {
    0% { transform: translateX(100%); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}
@keyframes slideInUp {
    0% { transform: translateY(50px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}
@keyframes fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}
@keyframes tableRowFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === PREPROCESSING LOG STYLES === */
.preprocessing-log {
    background: linear-gradient(145deg, rgba(10, 18, 10, 0.95), rgba(20, 30, 20, 0.9));
    border: 1px solid var(--accent-green-mid);
    border-radius: 12px;
    margin: 12px 0;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(127, 255, 137, 0.1);
}

.preprocessing-log .log-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: linear-gradient(90deg, rgba(127, 255, 137, 0.15), transparent);
    border-bottom: 1px solid rgba(127, 255, 137, 0.2);
}

.preprocessing-log .log-icon {
    font-size: 1.2em;
    animation: logPulse 1.5s ease-in-out infinite;
}

@keyframes logPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}

.preprocessing-log .log-title {
    font-family: 'Teko', sans-serif;
    font-size: 1.1em;
    color: var(--accent-yellow);
    letter-spacing: 2px;
    flex-grow: 1;
}

.preprocessing-log .log-clear-btn {
    background: transparent;
    border: 1px solid var(--accent-orange);
    color: var(--accent-orange);
    padding: 4px 12px;
    border-radius: 4px;
    font-family: 'Teko', sans-serif;
    font-size: 0.85em;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s;
}

.preprocessing-log .log-clear-btn:hover {
    background: var(--accent-orange);
    color: var(--primary-bg);
}

.preprocessing-log .log-content {
    max-height: 150px;
    overflow-y: auto;
    padding: 8px 12px;
}

.preprocessing-log .log-entry {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(122, 156, 90, 0.1);
    font-size: 0.85em;
    animation: logEntrySlide 0.3s ease-out;
}

@keyframes logEntrySlide {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

.preprocessing-log .log-entry:last-child {
    border-bottom: none;
}

.preprocessing-log .log-entry .log-time {
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
    min-width: 65px;
}

.preprocessing-log .log-entry .log-message {
    color: var(--text-light);
    flex-grow: 1;
}

.preprocessing-log .log-entry .log-message.success {
    color: var(--accent-green-mid);
}

.preprocessing-log .log-entry .log-message.warning {
    color: var(--accent-orange);
}

.preprocessing-log .log-entry .log-message.error {
    color: #ff6b6b;
}

.preprocessing-log .log-entry .log-count {
    background: rgba(201, 179, 106, 0.2);
    color: var(--accent-yellow);
    padding: 2px 8px;
    border-radius: 10px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    font-weight: bold;
}

.preprocessing-log .log-summary {
    display: flex;
    justify-content: space-around;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(127, 255, 137, 0.2);
}

.preprocessing-log .summary-item {
    text-align: center;
}

.preprocessing-log .summary-label {
    display: block;
    font-size: 0.75em;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.preprocessing-log .summary-value {
    font-family: 'Teko', sans-serif;
    font-size: 1.5em;
    color: var(--text-light);
}

/* Data Status Indicator */
.data-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.85em;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    transition: all 0.3s ease;
}

.data-status.raw {
    background: rgba(255, 159, 67, 0.15);
    border: 1px solid var(--accent-orange);
    color: var(--accent-orange);
}

.data-status.processed {
    background: rgba(127, 255, 137, 0.15);
    border: 1px solid var(--accent-green-mid);
    color: var(--accent-green-mid);
}

.data-status .status-icon {
    font-size: 1.1em;
}

.data-status .status-text {
    flex: 1;
}
.preprocessing-log .summary-value.removed {
    color: #ff6b6b;
}

.preprocessing-log .summary-value.current {
    color: var(--accent-green-mid);
}

/* Row removal animation */
@keyframes rowRemove {
    0% { 
        opacity: 1; 
        transform: translateX(0);
        background-color: transparent;
    }
    30% {
        background-color: rgba(255, 107, 107, 0.3);
        transform: translateX(0);
    }
    100% { 
        opacity: 0; 
        transform: translateX(100%);
        height: 0;
        padding: 0;
        margin: 0;
    }
}

@keyframes rowHighlight {
    0% { background-color: transparent; }
    50% { background-color: rgba(255, 107, 107, 0.4); }
    100% { background-color: rgba(255, 107, 107, 0.2); }
}

@keyframes rowImprove {
    0% { background-color: transparent; }
    50% { background-color: rgba(127, 255, 137, 0.4); }
    100% { background-color: rgba(127, 255, 137, 0.15); }
}

#csvDataTable tbody tr.removing {
    animation: rowRemove 0.5s ease-out forwards;
}

#csvDataTable tbody tr.highlight-remove {
    animation: rowHighlight 0.4s ease-out forwards;
}

#csvDataTable tbody tr.highlight-improve {
    animation: rowImprove 0.4s ease-out forwards;
}

#csvDataTable tbody tr.duplicate-row {
    background: rgba(255, 159, 67, 0.15) !important;
    border-left: 3px solid var(--accent-orange);
}

#csvDataTable tbody tr.invalid-row {
    background: rgba(255, 107, 107, 0.15) !important;
    border-left: 3px solid #ff6b6b;
}

#csvDataTable tbody tr.missing-value-row {
    background: rgba(255, 193, 7, 0.1) !important;
    border-left: 3px solid var(--accent-yellow);
}

/* Processing overlay for buttons */
.sidebar-control-button.processing {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.sidebar-control-button.processing::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top-color: var(--accent-yellow);
    border-radius: 50%;
    animation: btnSpin 0.8s linear infinite;
}

@keyframes btnSpin {
    to { transform: rotate(360deg); }
}

.animate-onload {
    opacity: 0;
    animation-fill-mode: forwards;
}

/* --- MEDIA QUERIES --- */
@media (max-width: 1100px) {
    .dashboard-container { max-width: 100vw; padding: 0; }
    main { gap: 12px; padding: 0 12px 12px 12px; }
    header { padding: 24px 12px 0 12px; }
}

@media (max-width: 900px) {
    .dashboard-container { padding: 0; max-width: 100vw; margin: 0; height: auto; }
    main { grid-template-columns: 1fr; grid-template-rows: auto; gap: 12px; height: auto; padding: 0 4px 8px 4px; }
    .left-panel, .center-panel, .right-panel { gap: 12px; height: auto; }
    .map-container, .climate-future-chart, .metrics-container, .energy-mix-chart { padding: 8px; min-height: 120px; height: auto; }
    #malaysia-map { height: 100px; }
    .chart-container { width: 50px; height: 50px; }
    header { padding: 12px 4px 0 4px; }
}

@media (max-width: 768px) {
    .data-table-sidebar { width: 100vw; right: -100vw; }
    .glass-panel { flex-direction: column; align-items: stretch; }
    .control-actions { justify-content: flex-end; }
    .checkbox-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .dashboard-container { padding: 0; border-radius: 12px; height: auto; }
    header h1 { font-size: 1em; }
    .map-container, .climate-future-chart, .metrics-container, .energy-mix-chart { min-height: 60px; padding: 2px; height: auto; }
    #malaysia-map { height: 40px; }
    .chart-container { width: 30px; height: 30px; }
    header { padding: 8px 2px 0 2px; }
}


/* --- Data Quality Modal Styles --- */
.dq-content-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 6px;
}

.dq-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(201, 140, 106, 0.3); /* Orange tint */
    padding: 8px 0;
    margin-bottom: 8px;
}

.dq-label {
    color: var(--text-muted);
    font-family: 'Montserrat', sans-serif;
    font-size: 0.95em;
}

.dq-value {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 1.1em;
    color: var(--text-light);
}

.dq-value.alert {
    color: var(--accent-red) !important;
    text-shadow: 0 0 8px rgba(201, 106, 106, 0.6);
}

.dq-value.warn {
    color: var(--accent-orange) !important;
    text-shadow: 0 0 8px rgba(255, 152, 0, 0.4);
}

.dq-value.safe {
    color: var(--accent-green-mid) !important;
}

.dq-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px dashed rgba(255,255,255,0.1);
}

.dq-stat:last-child {
    border-bottom: none;
}

.dq-stat .dq-label {
    font-size: 0.9em;
}

.dq-stat .dq-value {
    font-size: 1em;
}

#themeModal .modal-box {
    background: var(--glass-dark);
    border-radius: 15px;
    box-shadow: 0 0 40px rgba(200,200,90,0.1), 0 0 7px var(--accent-yellow) inset;
    padding: 28px 30px 18px 30px;
    display: flex;
    flex-direction: column;
}
#themeModal h3 {
    font-size: 1.5em;
    margin-bottom: 8px;
}
#themeModalContent {
    color: var(--text-light);
    font-size: 1.1em;
    margin-bottom: 0;
}
