/* ============================================
   EV Charger Dashboard - Design System
   ============================================ */

/* CSS Variables - Color Palette */
:root {
    /* Primary Colors */
    --primary-dark: #1a2f4a;
    --primary-teal: #3d8b99;
    --primary-light: #5ba3b0;

    /* Status Colors */
    --status-fault: #e53935;
    --status-available: #43a047;
    --status-charging: #1e88e5;
    --status-close: #757575;

    /* Background Colors */
    --bg-dark: #263546;
    --bg-card: #ffffff;
    --bg-table-header: #4a7c8b;
    --bg-table-row: #e8eef1;
    --bg-table-alt: #f5f7f9;

    /* Text Colors */
    --text-primary: #1a2f4a;
    --text-secondary: #5a6a7a;
    --text-light: #ffffff;
    --text-muted: #8a9aaa;

    /* Border Colors */
    --border-light: #d0dce5;
    --border-dark: #3d5a6a;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.16);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* ============================================
   Reset & Base Styles
   ============================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #1a2f4a 0%, #2c4a5e 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.5;
}

/* ============================================
   Dashboard Container
   ============================================ */
.dashboard-container {
    display: grid;
    grid-template-columns: 0.7fr 0.35fr 1fr;
    grid-template-rows: calc(75vh - 8px) calc(25vh - 8px);
    grid-template-areas:
        "map station monitoring"
        "trend trend monitoring";
    gap: var(--space-sm);
    padding: var(--space-sm);
    max-width: 100%;
    margin: 0 auto;
    height: 100vh;
    overflow: hidden;
}

.map-section {
    grid-area: map;
    max-height: calc(75vh - 8px);
    overflow: hidden;
}

.station-monitor-section {
    grid-area: station;
    overflow-y: auto;
    max-height: calc(75vh - 8px);
    min-height: 0;
}

.monitoring-section {
    grid-area: monitoring;
    overflow-y: auto;
}

.offline-trend-section {
    grid-area: trend;
}

.dashboard-container.fullscreen {
    max-width: 100%;
    padding: var(--space-sm);
}

/* ============================================
   Map Section (Left Panel) - Full Size with Overlays
   ============================================ */
.map-section {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

/* Region Tabs - Overlay on Map */
.region-tabs {
    position: absolute;
    top: var(--space-md);
    left: 60px;
    z-index: 1000;
    display: flex;
    gap: var(--space-xs);
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.60);
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.region-tab {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.region-tab:hover {
    background: var(--bg-table-row);
    border-color: var(--primary-teal);
}

.region-tab.active {
    background: var(--primary-teal);
    color: var(--text-light);
    border-color: var(--primary-teal);
}

/* Map Container - Full Size */
.map-container {
    position: relative;
    background: #6b7b8b;
    border: 3px solid var(--primary-dark);
    border-radius: var(--radius-md);
    flex: 1;
    min-height: calc(100vh - 48px);
    overflow: hidden;
}

/* Leaflet Map */
#thailandMap {
    width: 100%;
    height: 100%;
    min-height: calc(100vh - 48px);
    z-index: 1;
}

.thailand-svg {
    width: 80%;
    max-width: 300px;
    height: auto;
    opacity: 0.3;
}

.thailand-outline {
    fill: rgba(255, 255, 255, 0.1);
    stroke: rgba(255, 255, 255, 0.3);
    stroke-width: 2;
}

.map-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

/* Station Markers */
.station-marker {
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.station-marker:hover {
    transform: scale(1.3);
}

/* Map Legend */
.map-legend {
    position: absolute;
    bottom: var(--space-lg);
    left: var(--space-lg);
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    box-shadow: var(--shadow-md);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.legend-dot.fault {
    background: var(--status-fault);
}

.legend-dot.available {
    background: var(--status-available);
}

.legend-dot.charging {
    background: var(--status-charging);
}

.legend-dot.close {
    background: var(--status-close);
}

.legend-text {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* ============================================
   Filter Panel - Overlay on Map
   ============================================ */
.filter-panel {
    position: absolute;
    top: 70px;
    right: var(--space-md);
    z-index: 1000;
    background: rgba(255, 255, 255, 0.20);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    box-shadow: var(--shadow-lg);
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    min-width: 160px;
    backdrop-filter: blur(10px);
}

.filter-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    padding-bottom: var(--space-sm);
    border-bottom: 2px solid var(--primary-teal);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.filter-group-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

/* Custom Checkbox */
.filter-checkbox {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-primary);
    padding: 2px 0;
    transition: color var(--transition-fast);
}

.filter-checkbox:hover {
    color: var(--primary-teal);
}

.filter-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-teal);
    cursor: pointer;
}

/* Status Pin Icons in Filter */
.status-pin-icon {
    flex-shrink: 0;
    margin-left: 2px;
}

/* ============================================
   Station Monitor Section (Middle Panel)
   ============================================ */
.station-monitor-section {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 32px);
}

.station-monitor-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    box-shadow: var(--shadow-md);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.station-monitor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.station-monitor-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.station-monitor-legend {
    display: flex;
    gap: var(--space-md);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.station-monitor-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.station-monitor-legend .status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.station-monitor-legend .status-dot.normal {
    background: #4ade80;
}

.station-monitor-legend .status-dot.degraded {
    background: #fbbf24;
}

.station-monitor-legend .status-dot.down {
    background: #f87171;
}

.station-dots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(18px, 1fr));
    gap: 6px;
    flex: 1;
    overflow-y: auto;
    padding: var(--space-xs);
    align-content: start;
}

.station-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.station-dot:hover {
    transform: scale(1.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.station-dot.normal {
    background: linear-gradient(135deg, #86efac 0%, #4ade80 100%);
}

.station-dot.degraded {
    background: linear-gradient(135deg, #fde68a 0%, #fbbf24 100%);
    animation: blink-yellow 1.2s ease-in-out infinite;
}

@keyframes blink-yellow {

    0%,
    100% {
        opacity: 1;
        box-shadow: 0 0 4px rgba(251, 191, 36, 0.6);
    }

    50% {
        opacity: 0.5;
        box-shadow: 0 0 8px rgba(251, 191, 36, 0.9);
    }
}

.station-dot.down {
    background: linear-gradient(135deg, #fca5a5 0%, #f87171 100%);
}

.station-dot.offline {
    background: linear-gradient(135deg, #d1d5db 0%, #9ca3af 100%);
}

/* Station Tooltip */
.station-tooltip {
    position: fixed;
    z-index: 10000;
    background: #1a2f4a;
    border-radius: 8px;
    padding: 12px 14px;
    min-width: 200px;
    max-width: 280px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    animation: tooltip-fade-in 0.15s ease;
}

@keyframes tooltip-fade-in {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tooltip-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.tooltip-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.tooltip-status-text {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tooltip-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 4px;
    line-height: 1.3;
}

.tooltip-address {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 8px;
}

.tooltip-info {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ============================================
   Offline Trend Section
   ============================================ */
.offline-trend-section {
    background: linear-gradient(180deg, #0d1a2d 0%, #0a1525 100%);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.trend-header {
    margin-bottom: var(--space-sm);
}

.trend-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    letter-spacing: 0.5px;
}

.trend-chart {
    height: 120px;
    width: 100%;
}

.trend-svg {
    width: 100%;
    height: 100%;
}

.axis-label {
    fill: rgba(255, 255, 255, 0.4);
    font-size: 10px;
}

.grid-line {
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 1;
}

.trend-line {
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.trend-line.orange {
    stroke: #f59e0b;
    filter: drop-shadow(0 0 4px rgba(245, 158, 11, 0.5));
}

.trend-line.blue {
    stroke: #3b82f6;
    filter: drop-shadow(0 0 4px rgba(59, 130, 246, 0.5));
}

.data-point.orange {
    fill: #f59e0b;
}

.data-point.blue {
    fill: #3b82f6;
}

.trend-legend {
    display: flex;
    gap: var(--space-md);
    margin-top: var(--space-sm);
    justify-content: flex-end;
}

.trend-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
}

.legend-color {
    width: 12px;
    height: 3px;
    border-radius: 2px;
}

.legend-color.orange {
    background: #f59e0b;
}

.legend-color.blue {
    background: #3b82f6;
}

/* ============================================
   Critical Sites Section
   ============================================ */
.critical-sites-section {
    background: linear-gradient(180deg, #1e2a38 0%, #141c26 100%);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
}

.critical-sites-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.critical-icon {
    width: 24px;
    height: 24px;
    background: #ef4444;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: white;
}

.critical-title {
    font-size: 1rem;
    font-weight: 600;
    color: white;
}

.critical-sites-list {
    display: flex;
    gap: var(--space-sm);
    overflow-x: auto;
}

.critical-site-item {
    flex: 1;
    min-width: 180px;
    border-radius: 8px;
    padding: 12px;
    position: relative;
    overflow: hidden;
}

.critical-site-item.high {
    background: linear-gradient(180deg, rgba(185, 28, 28, 0.8) 0%, rgba(127, 29, 29, 0.9) 100%);
    border-left: 4px solid #ef4444;
}

.critical-site-item.med {
    background: linear-gradient(180deg, rgba(146, 64, 14, 0.7) 0%, rgba(120, 53, 15, 0.8) 100%);
    border-left: 4px solid #f59e0b;
}

.critical-site-item.low {
    background: linear-gradient(180deg, rgba(30, 58, 95, 0.8) 0%, rgba(23, 37, 58, 0.9) 100%);
    border-left: 4px solid #3b82f6;
}

.critical-site-item.normal {
    background: linear-gradient(180deg, rgba(22, 78, 55, 0.7) 0%, rgba(20, 55, 42, 0.8) 100%);
    border-left: 4px solid #22c55e;
}

.critical-site-main {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
}

.critical-rank {
    font-size: 1rem;
    font-weight: 700;
    color: white;
}

.critical-info {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.critical-id {
    font-size: 1rem;
    font-weight: 700;
    color: white;
}

.critical-impact {
    font-size: 0.75rem;
}

.impact-label {
    color: rgba(255, 255, 255, 0.6);
}

.impact-value {
    font-weight: 700;
}

.impact-value.high {
    color: #fca5a5;
}

.impact-value.med {
    color: #fcd34d;
}

.impact-value.low {
    color: #93c5fd;
}

.impact-value.normal {
    color: #86efac;
}

.critical-stat {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
}

/* Server Sites Layout */
.server-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.server-name {
    font-size: 1rem;
    font-weight: 700;
    color: white;
}

.server-status {
    font-size: 0.75rem;
    font-weight: 600;
}

.server-status.normal {
    color: #86efac;
}

.server-status.med {
    color: #fcd34d;
}

.server-status.high {
    color: #fca5a5;
}

.server-stats {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
}

.critical-details {
    margin-left: 0;
}

.critical-issue {
    font-size: 0.85rem;
    font-weight: 500;
    color: white;
    margin-bottom: 2px;
}

.critical-downtime {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
}

.critical-icon-flash {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
    opacity: 0.3;
}

/* ============================================
   Monitoring Section (Right Panel)
   ============================================ */
.monitoring-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* Monitoring Navbar */
.monitoring-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    background: var(--primary-dark);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-xs);
}

.navbar-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-light);
    margin: 0;
    letter-spacing: 0.5px;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--primary-teal);
}

.user-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-light);
}

/* Monitoring Tabs */
.monitoring-tabs {
    display: flex;
    gap: var(--space-xs);
    align-items: center;
}

.monitoring-tab {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.monitoring-tab:hover {
    background: var(--bg-table-row);
    border-color: var(--primary-teal);
}

.monitoring-tab.active {
    background: var(--primary-teal);
    color: var(--text-light);
    border-color: var(--primary-teal);
}

/* Status Indicators */
.status-indicators {
    gap: var(--space-sm);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    cursor: default;
}

.status-indicator .status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-indicator .status-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* Normal Status - Green */
.status-indicator.normal .status-dot {
    background: #43a047;
    box-shadow: 0 0 6px rgba(67, 160, 71, 0.5);
}

/* Warning Status - Orange */
.status-indicator.warning .status-dot {
    background: #ff9800;
    box-shadow: 0 0 6px rgba(255, 152, 0, 0.5);
    animation: pulse-warning 1.5s ease-in-out infinite;
}

/* Error Status - Red */
.status-indicator.error .status-dot {
    background: #e53935;
    box-shadow: 0 0 6px rgba(229, 57, 53, 0.5);
    animation: pulse-error 1s ease-in-out infinite;
}

@keyframes pulse-warning {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

@keyframes pulse-error {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(1.15);
    }
}

/* Fullscreen Button */
.fullscreen-btn {
    margin-left: auto;
    padding: var(--space-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    color: var(--text-secondary);
}

.fullscreen-btn:hover {
    background: var(--primary-teal);
    color: var(--text-light);
    border-color: var(--primary-teal);
}

/* Status Cards */
.status-cards {
    display: flex;
    gap: var(--space-sm);
}

.status-card {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-light);
}

.status-card .status-label {
    font-size: 0.8rem;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}

.status-card .status-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.status-card.open .status-label {
    background: rgba(67, 160, 71, 0.15);
    color: var(--status-available);
}

.status-card.close .status-label {
    background: rgba(117, 117, 117, 0.15);
    color: var(--status-close);
}

.status-card.used .status-label {
    background: rgba(30, 136, 229, 0.15);
    color: var(--status-charging);
}

.status-card.fault .status-label {
    background: rgba(229, 57, 53, 0.15);
    color: var(--status-fault);
}

/* ============================================
   Gauge Cards (Dashboard 4K) - Progress Bar Style
   ============================================ */
.gauge-cards {
    display: flex;
    gap: 10px;
    padding: var(--space-sm) 0;
    flex-wrap: wrap;
}

.gauge-card {
    background: linear-gradient(180deg, #2a3544 0%, #1e2833 100%);
    border-radius: 8px;
    padding: 14px 18px 12px;
    min-width: 160px;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.gauge-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    width: 100%;
}

.gauge-icon {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    flex-shrink: 0;
}

.gauge-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    letter-spacing: 0.3px;
}

.gauge-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 8px;
}

.gauge-unit {
    font-size: 1rem;
    font-weight: 500;
    opacity: 0.8;
    margin-left: 2px;
}

.gauge-progress {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.gauge-progress .progress-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
    min-width: 4px;
}

/* Open - Green Theme */
.gauge-card.open .gauge-icon {
    background: #4ade80;
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.5);
}

.gauge-card.open .gauge-value {
    color: #4ade80;
}

.gauge-card.open .progress-bar {
    background: linear-gradient(90deg, #22c55e 0%, #4ade80 100%);
}

/* Maintain(Avail) - Orange Theme */
.gauge-card.maintain-avail .gauge-icon {
    background: #fbbf24;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
}

.gauge-card.maintain-avail .gauge-value {
    color: #fbbf24;
}

.gauge-card.maintain-avail .progress-bar {
    background: linear-gradient(90deg, #d97706 0%, #fbbf24 100%);
}

/* Maintain(Inused) - Red Theme */
.gauge-card.maintain-inused .gauge-icon {
    background: #f87171;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(248, 113, 113, 0.5);
}

.gauge-card.maintain-inused .gauge-value {
    color: #f87171;
}

.gauge-card.maintain-inused .progress-bar {
    background: linear-gradient(90deg, #ef4444 0%, #f87171 100%);
}

/* Close - Gray Theme */
.gauge-card.close .gauge-icon {
    background: #9ca3af;
    box-shadow: 0 0 8px rgba(156, 163, 175, 0.5);
}

.gauge-card.close .gauge-value {
    color: #9ca3af;
}

.gauge-card.close .progress-bar {
    background: linear-gradient(90deg, #6b7280 0%, #9ca3af 100%);
}

/* Used - Blue Theme */
.gauge-card.used .gauge-icon {
    background: #60a5fa;
    box-shadow: 0 0 8px rgba(96, 165, 250, 0.5);
}

.gauge-card.used .gauge-value {
    color: #60a5fa;
}

.gauge-card.used .progress-bar {
    background: linear-gradient(90deg, #3b82f6 0%, #60a5fa 100%);
}

/* Fault - Red Theme */
.gauge-card.fault .gauge-icon {
    background: #ef4444;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

.gauge-card.fault .gauge-value {
    color: #ef4444;
}

.gauge-card.fault .progress-bar {
    background: linear-gradient(90deg, #dc2626 0%, #ef4444 100%);
}

/* ============================================
   System Status Bar (Dashboard 4K)
   ============================================ */
.system-status-bar {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-sm) 0;
}

.system-status-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: white;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    min-width: 80px;
    justify-content: center;
}

.system-status-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.system-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.system-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* System Status Colors */
.system-status-item.normal .system-dot {
    background: #43a047;
}

.system-status-item.warning .system-dot {
    background: #ff9800;
}

.system-status-item.error .system-dot {
    background: #e53935;
}

/* ============================================
   System Detail Cards (Expandable)
   ============================================ */
.system-detail-cards {
    display: flex;
    gap: 10px;
    padding: var(--space-sm) 0;
    flex-wrap: wrap;
}

.system-detail-card {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 8px;
    min-width: 90px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    border: 2px solid transparent;
    transition: all var(--transition-fast);
}

.system-detail-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Border colors based on status */
.system-detail-card.normal {
    border-color: #66bb6a;
}

.system-detail-card.warning {
    border-color: #ffb74d;
}

.system-detail-card.error {
    border-color: #ef5350;
}

.system-card-header {
    padding: 5px 8px;
    margin: -8px -8px 8px -8px;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 0;
}

/* Header background based on status */
.system-detail-card.normal .system-card-header {
    background: #66bb6a;
}

.system-detail-card.warning .system-card-header {
    background: #ffb74d;
}

.system-detail-card.error .system-card-header {
    background: #ef5350;
}

.system-card-stats {
    padding: 0;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    font-size: 0.7rem;
    line-height: 1.4;
}

.stat-label {
    color: #888;
    font-weight: 400;
}

.stat-value {
    font-weight: 400;
}

/* Stat value colors based on parent status */
.system-detail-card.normal .stat-value {
    color: #66bb6a;
}

.system-detail-card.warning .stat-value {
    color: #ffb74d;
}

.system-detail-card.error .stat-value {
    color: #ef5350;
}

/* ============================================
   Monitoring Tables
   ============================================ */

/* Tables Grid Layout - 2 columns per row */
.tables-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    flex: 1;
    min-height: 0;
}

.tables-row {
    display: flex;
    gap: var(--space-sm);
    flex: 1;
    min-height: 0;
}

.tables-row .monitoring-table-container {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.tables-row .monitoring-table-container:first-child {
    flex: 65;
}

.tables-row .monitoring-table-container:last-child {
    flex: 35;
}

.tables-row .monitoring-table-container .monitoring-table {
    flex: 1;
}

.tables-row .monitoring-table-container tbody {
    display: block;
    overflow-y: auto;
    max-height: calc(100% - 60px);
}

.tables-row .monitoring-table-container thead,
.tables-row .monitoring-table-container tbody tr {
    display: table;
    width: 100%;
    table-layout: fixed;
}

.monitoring-table-container {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.table-title {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-table-row);
    border-bottom: 1px solid var(--border-light);
}

.monitoring-table {
    width: 100%;
    border-collapse: collapse;
}

.monitoring-table thead {
    background: var(--bg-table-header);
}

.monitoring-table th {
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-light);
    white-space: nowrap;
}

.monitoring-table tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition-fast);
}

.monitoring-table tbody tr:nth-child(even) {
    background: var(--bg-table-alt);
}

.monitoring-table tbody tr:hover {
    background: rgba(61, 139, 153, 0.1);
}

.monitoring-table td {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.85rem;
    color: var(--text-primary);
}

/* Empty Table State */
.monitoring-table tbody:empty::after {
    content: 'No data available';
    display: block;
    padding: var(--space-lg);
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
}

/* Action Buttons in Table */
.table-action-btn {
    padding: 4px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.table-action-btn.ack {
    background: var(--status-charging);
    color: var(--text-light);
}

.table-action-btn.ack:hover {
    background: #1565c0;
}

.table-action-btn.reset {
    background: var(--status-fault);
    color: var(--text-light);
}

.table-action-btn.reset:hover {
    background: #c62828;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 1200px) {
    .dashboard-container {
        grid-template-columns: 1fr;
        gap: var(--space-lg);
    }

    .map-section {
        order: 1;
    }

    .filter-panel {
        order: 2;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .filter-group {
        flex: 1;
        min-width: 150px;
    }

    .monitoring-section {
        order: 3;
    }
}

@media (max-width: 768px) {
    html {
        font-size: 13px;
    }

    .dashboard-container {
        padding: var(--space-md);
    }

    .region-tabs,
    .monitoring-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: var(--space-sm);
    }

    .status-cards {
        flex-wrap: wrap;
    }

    .status-card {
        flex: 1;
        min-width: 80px;
        justify-content: center;
    }
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease forwards;
}

.station-marker.fault {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Warn-Offline blinking animation */
@keyframes blink-orange {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

.station-marker-icon.warn-offline {
    animation: blink-orange 1s ease-in-out infinite;
}

.warn-offline-icon {
    animation: blink-orange 1s ease-in-out infinite;
}

/* ============================================
   Scrollbar Styling
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-table-row);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-teal);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-light);
}

/* ============================================
   Station Detail Page Styles
   ============================================ */

/* Main Container */
.station-detail-container {
    display: flex;
    flex-direction: column;
    padding: var(--space-md);
    max-width: 1600px;
    margin: 0 auto;
    min-height: 100vh;
    gap: var(--space-md);
}

.station-detail-container.fullscreen {
    max-width: 100%;
    padding: var(--space-sm);
}

/* Station Header */
.station-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    border: 2px solid var(--border-dark);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    gap: var(--space-md);
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex: 1;
}

.back-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--bg-table-row);
    color: var(--text-primary);
    text-decoration: none;
    transition: all var(--transition-fast);
}

.back-link:hover {
    background: var(--primary-teal);
    color: var(--text-light);
}

.station-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* Inline Location Badge (next to station name) */
.station-location-inline {
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-table-row);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Station Selector Dropdowns */
.station-selector-group {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex: 1;
}

.station-dropdown {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.95rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 180px;
    max-width: 350px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%231a2f4a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.station-dropdown:hover {
    border-color: var(--primary-teal);
}

.station-dropdown:focus {
    outline: none;
    border-color: var(--primary-teal);
    box-shadow: 0 0 0 3px rgba(61, 139, 153, 0.2);
}

#stationSelect {
    min-width: 280px;
    flex: 1;
}

/* Searchable Dropdown (Combobox) */
.searchable-dropdown {
    position: relative;
    min-width: 320px;
    flex: 1;
}

.searchable-input {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    padding-right: 36px;
    font-size: 0.95rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%231a2f4a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.searchable-input:focus {
    outline: none;
    border-color: var(--primary-teal);
    box-shadow: 0 0 0 3px rgba(61, 139, 153, 0.2);
}

.searchable-input::placeholder {
    color: var(--text-muted);
}

.dropdown-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 300px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 2px solid var(--primary-teal);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 1000;
}

.dropdown-list.show {
    display: block;
}

.dropdown-item {
    padding: var(--space-sm) var(--space-md);
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-primary);
    transition: background 0.15s;
    border-bottom: 1px solid var(--border-light);
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover,
.dropdown-item.highlighted {
    background: rgba(61, 139, 153, 0.15);
}

.dropdown-item.selected {
    background: rgba(61, 139, 153, 0.25);
    font-weight: 600;
}

.dropdown-item.no-results {
    color: var(--text-muted);
    font-style: italic;
    cursor: default;
}

.dropdown-item.no-results:hover {
    background: transparent;
}

.header-center {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.station-location {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-table-row);
    border-radius: var(--radius-sm);
    font-weight: 500;
    color: var(--text-primary);
}

.performance-badge {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.badge-label {
    padding: var(--space-sm) var(--space-md);
    background: var(--primary-teal);
    color: var(--text-light);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
}

.badge-value {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-weight: 600;
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.header-user {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.header-right .fullscreen-btn {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.header-right .fullscreen-btn span {
    font-size: 0.85rem;
}

/* Main Grid Layout */
.detail-main-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr 1fr;
    gap: var(--space-md);
    flex: 1;
}

/* Left Column */
.left-column {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* SCADA Panel */
.scada-panel {
    flex: 1;
    min-height: 300px;
    background: #1e2a3a;
    border: 3px solid var(--primary-dark);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.scada-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
}

.scada-svg {
    width: 100%;
    height: 100%;
    max-height: 400px;
}

/* SLD Elements */
.sld-line {
    stroke: #7f8c8d;
    /* Neutral grey for disconnected/initial */
    stroke-width: 3;
    fill: none;
    stroke-linecap: round;
    transition: stroke 0.3s ease;
}

.sld-line.has-power {
    stroke: #2ecc71;
    /* Green: Has Power */
}

.sld-line.no-power {
    stroke: #e74c3c;
    /* Red: No Power */
}

.sld-busbar {
    stroke-width: 6;
    stroke: #2ecc71;
    /* Main busbar usually has power */
}

.sld-box {
    fill: #2c4a5e;
    stroke: #5ba3b0;
    stroke-width: 2;
}

.sld-grid {
    fill: #e67e22;
    stroke: #d35400;
}

.sld-breaker {
    fill: #34495e;
    stroke: #fff;
    stroke-width: 1.5;
}

.sld-charger {
    fill: #27ae60;
    stroke: #2ecc71;
}

.sld-charger.fault {
    fill: #c0392b;
    stroke: #e74c3c;
}

.sld-charger.charging {
    fill: #2980b9;
    stroke: #3498db;
    animation: charger-glow 2s infinite;
}

.sld-text {
    fill: #fff;
    font-size: 14px;
    font-weight: 700;
    pointer-events: none;
}

.sld-text-small {
    fill: #fff;
    font-size: 11px;
    font-weight: 600;
    pointer-events: none;
}

.sld-temp-text {
    fill: #f1c40f;
    /* Yellow for visibility */
    font-size: 10px;
    font-weight: 700;
    pointer-events: none;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}

.sld-temp-text-large {
    fill: #f1c40f;
    font-size: 13px;
    font-weight: 700;
    pointer-events: none;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}

.sld-status-text {
    fill: #fff;
    font-size: 11px;
    font-weight: 600;
    pointer-events: none;
}

.sld-fan-icon {
    color: #ecf0f1;
}

.sld-fan-icon.active .fan-blades {
    animation: fan-spin 1s linear infinite;
    transform-origin: center;
    transform-box: fill-box;
}

.fan-base {
    fill: #34495e;
    stroke: #7f8c8d;
    stroke-width: 1;
}

@keyframes fan-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Animations */
.sld-line-flow {
    stroke-dasharray: 10, 5;
    animation: flow 1s linear infinite;
}

@keyframes flow {
    from {
        stroke-dashoffset: 15;
    }

    to {
        stroke-dashoffset: 0;
    }
}

@keyframes charger-glow {

    0%,
    100% {
        filter: drop-shadow(0 0 2px #3498db);
    }

    50% {
        filter: drop-shadow(0 0 10px #3498db);
    }
}

.sld-dot {
    fill: #f1c40f;
    filter: blur(2px);
    opacity: 0;
}

.sld-dot.active {
    opacity: 1;
    animation: move-dot 3s linear infinite;
}

@keyframes move-dot {
    0% {
        transform: translateY(0);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        transform: translateY(130px);
        opacity: 0;
    }
}

/* CPID Table Container */
.cpid-table-container {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-light);
}

/* Detail Tables */
.detail-table {
    width: 100%;
    border-collapse: collapse;
}

.detail-table thead {
    background: var(--bg-table-header);
}

.detail-table th {
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light);
    white-space: nowrap;
    border: 1px solid var(--border-dark);
}

.detail-table tbody tr {
    border-bottom: 1px solid var(--border-light);
    background: #ffffff;
}

.detail-table tbody tr:nth-child(even) {
    background: #f0f4f8;
}

.detail-table tbody tr:nth-child(odd) {
    background: #ffffff;
}

.detail-table td {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.8rem;
    color: #1a2f4a;
    border: 1px solid var(--border-light);
    min-height: 32px;
}

.cpid-table td,
.cpid-table th {
    text-align: center;
}

/* Center Column */
.center-column {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* Info/Log/Command Panels */
.info-panel,
.log-panel,
.command-panel {
    background: #a8c8d8;
    border-radius: var(--radius-md);
    padding: var(--space-md);
    border: 1px solid var(--border-light);
}

.panel-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary-teal);
    margin: 0 0 var(--space-sm) 0;
}

.info-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.info-list li {
    padding: var(--space-xs) 0;
    font-size: 0.85rem;
    color: var(--text-primary);
    position: relative;
    padding-left: var(--space-md);
}

.info-list li::before {
    content: '-';
    position: absolute;
    left: 0;
    color: var(--text-secondary);
}

.log-content {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.log-content p {
    margin: 0;
}

/* Command Panel */
.command-panel {
    flex: 1;
}

.command-buttons {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.command-btn {
    padding: var(--space-sm) var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.command-btn:hover {
    background: var(--primary-teal);
    color: var(--text-light);
    border-color: var(--primary-teal);
}

/* Right Column */
.right-column {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* CCTV Panel */
.cctv-panel {
    flex: 1;
    min-height: 200px;
    overflow: hidden;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-dark);
}

.cctv-container {
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cctv-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.9;
}

/* Right Side Tables */
.right-tables {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.mini-table-container {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.mini-table th,
.mini-table td {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.75rem;
}

.mini-table thead {
    background: var(--bg-table-header);
}

.fault-detail-table th:first-child,
.fault-detail-table td:first-child {
    width: 35%;
}

/* Responsive for Station Detail */
@media (max-width: 1200px) {
    .detail-main-grid {
        grid-template-columns: 1fr 1fr;
    }

    .right-column {
        grid-column: span 2;
        flex-direction: row;
    }

    .cctv-panel {
        flex: 1;
    }

    .right-tables {
        flex: 1;
    }
}

@media (max-width: 768px) {
    .detail-main-grid {
        grid-template-columns: 1fr;
    }

    .right-column {
        grid-column: span 1;
        flex-direction: column;
    }

    .station-header {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-sm);
    }

    .header-left,
    .header-center,
    .header-right {
        justify-content: center;
    }

    .station-name {
        min-width: auto;
        text-align: center;
    }
}

/* ============================================
   Charger Detail Page Styles
   ============================================ */

.charger-detail-page {
    background: var(--bg-dark);
    min-height: 100vh;
}

.charger-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: var(--space-md);
    padding: var(--space-md);
    max-width: 1600px;
    margin: 0 auto;
}

.charger-left-column,
.charger-right-column {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* Charger Info Panel */
.charger-info-panel .info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
}

.charger-info-panel .info-item {
    display: flex;
    flex-direction: column;
    padding: var(--space-xs);
}

.charger-info-panel .info-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.charger-info-panel .info-value {
    font-size: 0.9rem;
    color: #ffffff;
    font-weight: 600;
}

/* Day Chart */
.chart-panel .chart-container {
    background: var(--bg-dark);
    border-radius: var(--radius-sm);
    padding: var(--space-sm);
}

.day-chart-svg {
    width: 100%;
    height: auto;
    max-height: 150px;
}

/* Availability Bar */
.availability-bar {
    display: flex;
    height: 24px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: var(--space-sm);
}

.avail-segment {
    transition: width var(--transition-normal);
}

.avail-available {
    background: var(--status-available);
}

.avail-charging {
    background: #f1c40f;
}

.avail-offline {
    background: #7f8c8d;
}

.avail-legend {
    display: flex;
    gap: var(--space-md);
    font-size: 0.75rem;
    color: #ffffff;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

/* Stats Grid */
.stats-grid-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-sm);
}

.stat-box {
    background: var(--primary-light);
    color: var(--text-light);
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    text-align: center;
    display: flex;
    flex-direction: column;
}

.stat-box.stat-kwh {
    background: #3498db;
}

.stat-label {
    font-size: 0.7rem;
    opacity: 0.9;
}

.stat-value {
    font-size: 0.7rem;
}

/* Performance Panel */
.performance-panel .perf-row {
    display: flex;
    gap: var(--space-md);
    align-items: center;
}

.perf-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    background: #f8f9fa;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

.perf-item.perf-score {
    background: var(--primary-light);
    color: var(--text-light);
    border: none;
}

.perf-label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.perf-item.perf-score .perf-label {
    color: rgba(255, 255, 255, 0.8);
}

.perf-value {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Weekly Panel */
.weekly-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-sm);
}

.weekly-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    text-align: center;
}

.weekly-start-total {
    background: #3498db;
    color: white;
}

.weekly-start-error {
    background: #2ecc71;
    color: white;
}

.weekly-start-time {
    background: #9b59b6;
    color: white;
}

.weekly-stop-time {
    background: #e67e22;
    color: white;
}

.weekly-stop-error {
    background: #e74c3c;
    color: white;
}

.weekly-label {
    font-size: 0.65rem;
    opacity: 0.9;
}

.weekly-value {
    font-size: 1.1rem;
    font-weight: 700;
}

/* Command Panel */
.command-buttons {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.cmd-btn {
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--primary-teal);
    background: white;
    color: var(--primary-teal);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.cmd-btn:hover {
    background: var(--primary-teal);
    color: white;
}

.cmd-btn.cmd-danger {
    border-color: var(--status-fault);
    color: var(--status-fault);
}

.cmd-btn.cmd-danger:hover {
    background: var(--status-fault);
    color: white;
}

/* Log Fault Row */
.log-fault-row {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: var(--space-md);
}

.log-issue-panel .log-issue-content {
    padding: var(--space-sm);
    background: #fef9e7;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-primary);
}

/* Log Table with Filters */
.log-table-header {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--space-md);
}

.log-filters {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    padding: var(--space-sm);
    background: #f8f9fa;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
}

.log-filters h4 {
    margin: 0 0 var(--space-xs) 0;
    font-size: 0.8rem;
}

.log-filters label {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    cursor: pointer;
}

.log-filters input[type="checkbox"] {
    accent-color: var(--primary-teal);
}

/* Responsive */
@media (max-width: 1024px) {
    .charger-detail-grid {
        grid-template-columns: 1fr;
    }

    .log-fault-row {
        grid-template-columns: 1fr;
    }

    .weekly-row {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============================================
   Performance Ranking Page Styles
   ============================================ */

.ranking-page {
    background: linear-gradient(135deg, #1a2f4a 0%, #2c4a5e 100%);
    min-height: 100vh;
    padding: var(--space-lg);
}

.ranking-container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Ranking Header */
.ranking-header {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
}

.ranking-header .back-btn {
    color: var(--text-light);
    text-decoration: none;
    padding: var(--space-sm) var(--space-md);
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.ranking-header .back-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.ranking-title {
    color: var(--text-light);
    font-size: 1.5rem;
    font-weight: 600;
    flex: 1;
}

.week-selector {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-light);
}

.week-selector select {
    padding: var(--space-sm) var(--space-md);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    font-size: 0.9rem;
    cursor: pointer;
}

.week-selector select option {
    background: var(--primary-dark);
    color: var(--text-light);
}

/* Summary Cards */
.ranking-summary {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
}

.summary-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-md) var(--space-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 120px;
    flex: 1;
    box-shadow: var(--shadow-md);
}

.summary-card .summary-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.summary-card .summary-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.summary-card.good {
    border-bottom: 3px solid var(--status-available);
}

.summary-card.good .summary-value {
    color: var(--status-available);
}

.summary-card.warning {
    border-bottom: 3px solid #fb8c00;
}

.summary-card.warning .summary-value {
    color: #fb8c00;
}

.summary-card.danger {
    border-bottom: 3px solid var(--status-fault);
}

.summary-card.danger .summary-value {
    color: var(--status-fault);
}

/* Ranking Filters */
.ranking-filters {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.05);
    padding: var(--space-md);
    border-radius: var(--radius-md);
}

.ranking-filters .filter-group {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.ranking-filters label {
    color: var(--text-light);
    font-size: 0.85rem;
}

.ranking-filters select {
    padding: var(--space-sm) var(--space-md);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    font-size: 0.85rem;
    cursor: pointer;
}

.ranking-filters select option {
    background: var(--primary-dark);
    color: var(--text-light);
}

.search-group {
    flex: 1;
    min-width: 200px;
}

.search-group input {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    font-size: 0.85rem;
}

.search-group input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* Ranking Table */
.ranking-table-container {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.ranking-table {
    width: 100%;
    border-collapse: collapse;
}

.ranking-table thead {
    background: var(--bg-table-header);
}

.ranking-table th {
    padding: var(--space-md);
    text-align: left;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-light);
    white-space: nowrap;
}

.ranking-table tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition-fast);
}

.ranking-table tbody tr:nth-child(even) {
    background: var(--bg-table-alt);
}

.ranking-table tbody tr:hover {
    background: rgba(61, 139, 153, 0.1);
}

.ranking-table td {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.85rem;
    color: var(--text-primary);
}

.ranking-table .col-rank {
    width: 50px;
    text-align: center;
    font-weight: 600;
    color: var(--text-secondary);
}

.ranking-table .col-charger {
    min-width: 250px;
}

.ranking-table .charger-link {
    color: var(--primary-teal);
    text-decoration: none;
    font-weight: 500;
}

.ranking-table .charger-link:hover {
    text-decoration: underline;
}

.ranking-table .col-vendor {
    min-width: 150px;
}

.ranking-table .col-count,
.ranking-table .col-total {
    text-align: center;
    width: 80px;
}

.ranking-table .col-percent {
    width: 200px;
}

/* Percent Bar */
.percent-cell {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.percent-bar-bg {
    flex: 1;
    height: 16px;
    background: #e0e0e0;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.percent-bar {
    height: 100%;
    border-radius: var(--radius-sm);
    transition: width 0.3s ease;
}

.percent-value {
    min-width: 45px;
    text-align: right;
    font-weight: 600;
    font-size: 0.85rem;
}

.ranking-table .no-data {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-muted);
    font-style: italic;
}

/* Responsive Ranking */
@media (max-width: 768px) {
    .ranking-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .ranking-title {
        order: -1;
    }

    .ranking-summary {
        flex-direction: column;
    }

    .ranking-table-container {
        overflow-x: auto;
    }

    .ranking-table .col-charger {
        min-width: 180px;
    }
}

/* ============================================
   CCTV Camera Switcher
   ============================================ */
.cctv-panel {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.cctv-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    background: var(--primary-dark);
    border-bottom: 1px solid var(--border-dark);
}

.cctv-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.cctv-title::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #e53935;
    border-radius: 50%;
    animation: blink-recording 1s ease-in-out infinite;
}

@keyframes blink-recording {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

.camera-switcher {
    display: flex;
    gap: var(--space-xs);
}

.camera-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.camera-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-light);
    border-color: rgba(255, 255, 255, 0.4);
}

.camera-btn.active {
    background: var(--primary-teal);
    border-color: var(--primary-teal);
    color: var(--text-light);
}

.camera-btn svg {
    flex-shrink: 0;
}

.cctv-container {
    position: relative;
    background: #1a1a1a;
    aspect-ratio: 16/9;
    overflow: hidden;
}

.cctv-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #1a1a1a;
    transition: opacity 0.3s ease;
}

.cctv-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--space-sm) var(--space-md);
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.camera-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.camera-time {
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
    font-family: 'Consolas', monospace;
}

/* ============================================
   SCADA Panel Header
   ============================================ */
.scada-panel {
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.scada-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    background: var(--primary-dark);
    border-bottom: 1px solid var(--border-dark);
}

.scada-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.scada-title svg {
    opacity: 0.8;
}

.scada-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
}

.scada-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.scada-status .status-dot.online {
    background: #43a047;
    box-shadow: 0 0 6px rgba(67, 160, 71, 0.6);
    animation: pulse-online 2s ease-in-out infinite;
}

.scada-status .status-dot.offline {
    background: #e53935;
}

@keyframes pulse-online {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

/* ============================================
   Log Panel Styles (Mac Notes Style)
   ============================================ */
.log-panel {
    background: #fefcf3;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    padding: 0;
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    background: linear-gradient(180deg, #fbf5e6 0%, #f5edda 100%);
}

.log-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #8b7355;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.log-title svg {
    opacity: 0.8;
    stroke: #a08060;
}

.log-content {
    padding: var(--space-md);
    background: #fffef8;
    color: #5a4a3a;
    font-size: 0.9rem;
    line-height: 1.6;
}

.log-edit-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(139, 115, 85, 0.15);
    border: 1px solid rgba(139, 115, 85, 0.3);
    border-radius: var(--radius-sm);
    color: #8b7355;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.log-edit-btn:hover {
    background: rgba(139, 115, 85, 0.25);
    border-color: #8b7355;
}

.log-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    border-top: 1px solid #e0d8c0;
    font-size: 0.75rem;
    color: #8b7355;
}

.log-editor strong {
    color: #6a5a4a;
}

.log-time {
    font-family: 'Consolas', monospace;
    opacity: 0.8;
}