* {
    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%);
    padding: 20px;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

h1 {
    color: white;
    text-align: center;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.status {
    background: white;
    padding: 10px 20px;
    border-radius: 8px;
    text-align: center;
    margin-bottom: 20px;
    font-weight: bold;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.status.connected {
    background: #10b981;
    color: white;
}

.status.disconnected {
    background: #ef4444;
    color: white;
}

/* View Toggle */
.view-toggle {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.toggle-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    background: white;
    color: #667eea;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.toggle-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* View Sections */
.view-section {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Metrics Grid */
.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.metric-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.metric-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.2);
}

.metric-label {
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
}

.metric-value {
    font-size: 32px;
    font-weight: bold;
    color: #333;
}

.metric-unit {
    font-size: 18px;
    color: #999;
    margin-left: 5px;
}

/* Charts */
.chart-container {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.chart-container h3 {
    color: #333;
    margin-bottom: 15px;
}

.chart-wrapper {
    position: relative;
    height: 300px;
}

/* History Controls */
.history-controls {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.history-controls label {
    font-weight: bold;
    color: #333;
}

.history-controls select {
    padding: 10px 15px;
    border: 2px solid #667eea;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.history-controls select:hover {
    border-color: #764ba2;
}

.history-controls select:focus {
    outline: none;
    border-color: #764ba2;
}

.btn-primary {
    padding: 10px 25px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.2);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.stat-card h4 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 18px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-label {
    color: #666;
    font-size: 14px;
}

.stat-value {
    color: #333;
    font-weight: bold;
    font-size: 14px;
}

/* Alerts */
.alerts {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.alerts h3 {
    color: #333;
    margin-bottom: 15px;
}

#alerts-list, #history-alerts-list {
    max-height: 400px;
    overflow-y: auto;
}

.alert-item {
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 8px;
    border-left: 4px solid;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.alert-item.info {
    background: #dbeafe;
    border-left-color: #3b82f6;
}

.alert-item.warning {
    background: #fef3c7;
    border-left-color: #f59e0b;
}

.alert-item.critical {
    background: #fee2e2;
    border-left-color: #ef4444;
}

.alert-time {
    font-size: 12px;
    color: #666;
    margin-bottom: 5px;
}

.alert-message {
    font-size: 14px;
    color: #333;
}

.alert-type {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    margin-left: 8px;
}

.alert-type.info {
    background: #3b82f6;
    color: white;
}

.alert-type.warning {
    background: #f59e0b;
    color: white;
}

.alert-type.critical {
    background: #ef4444;
    color: white;
}

/* Last Update */
.last-update {
    background: white;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    color: #666;
    font-size: 14px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

#last-update {
    font-weight: bold;
    color: #333;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    h1 {
        font-size: 24px;
        margin-bottom: 20px;
    }

    .metrics {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 10px;
    }

    .metric-card {
        padding: 15px;
    }

    .metric-value {
        font-size: 24px;
    }

    .chart-wrapper {
        height: 250px;
    }

    .history-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .history-controls select,
    .btn-primary {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .toggle-btn {
        padding: 10px 20px;
        font-size: 14px;
    }
}

/* Loading State */
.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% {
        content: '.';
    }
    40% {
        content: '..';
    }
    60%, 100% {
        content: '...';
    }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px;
    color: #999;
    font-style: italic;
}

/* Success/Error Messages */
.message {
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: bold;
    text-align: center;
}

.message.success {
    background: #d1fae5;
    color: #065f46;
}

.message.error {
    background: #fee2e2;
    color: #991b1b;
}
/* Header Layout */
.header {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.header-title {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    margin: 0;
}

/* Footer */
.footer {
    background: white;
    padding: 15px 20px;
    border-radius: 12px;
    margin-top: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.footer-left {
    flex: 1;
}

.footer-right {
    flex: 1;
    text-align: right;
}

.footer-right a {
    color: #667eea;
    text-decoration: none;
    font-size: 14px;
}

.footer-right a:hover {
    color: #764ba2;
    text-decoration: underline;
}