* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    background: white;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

header h1 {
    color: #333;
    font-size: 2em;
}

.device-status {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}

.status-badge {
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9em;
}

.status-badge.online {
    background: #4caf50;
    color: white;
}

.status-badge.offline {
    background: #f44336;
    color: white;
}

#lastUpdate {
    font-size: 0.85em;
    color: #666;
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
}

.card-icon {
    font-size: 3em;
}

.card-content h3 {
    color: #666;
    font-size: 0.9em;
    margin-bottom: 10px;
}

.card-content .value {
    font-size: 2.5em;
    font-weight: bold;
    color: #333;
}

.card-content .unit {
    color: #999;
    font-size: 0.85em;
    margin-top: 5px;
}

.voltage-card .value { color: #ff6b6b; }
.current-card .value { color: #4ecdc4; }
.power-card .value { color: #45b7d1; }
.energy-card .value { color: #96ceb4; }

/* Statistics Section */
.stats-section {
    background: white;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.stats-section h2 {
    color: #333;
    margin-bottom: 20px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-item {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.stat-item label {
    display: block;
    color: #666;
    font-size: 0.9em;
    margin-bottom: 8px;
}

.stat-item span {
    display: block;
    font-size: 1.5em;
    font-weight: bold;
    color: #333;
}

/* Charts Section */
.charts-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.chart-container {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.chart-container h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.3em;
}

/* Table Section */
.table-section {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.table-section h2 {
    color: #333;
    margin-bottom: 20px;
}

.table-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.btn-refresh, .btn-clear {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: bold;
    transition: all 0.3s ease;
}

.btn-refresh {
    background: #4caf50;
    color: white;
}

.btn-refresh:hover {
    background: #45a049;
}

.btn-clear {
    background: #f44336;
    color: white;
}

.btn-clear:hover {
    background: #da190b;
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: #667eea;
    color: white;
}

th, td {
    padding: 12px;
    text-align: left;
}

tbody tr:nth-child(even) {
    background: #f8f9fa;
}

tbody tr:hover {
    background: #e9ecef;
}

.no-data {
    text-align: center;
    color: #999;
    padding: 20px !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .device-status {
        align-items: flex-start;
        margin-top: 15px;
    }
    
    .cards-grid {
        grid-template-columns: 1fr;
    }
    
    .charts-section {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
