:root {
    --primary: #667eea;
    --secondary: #764ba2;
    --dark-bg: #0f172a;
    --panel-bg: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --border: rgba(255, 255, 255, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background: radial-gradient(circle at top right, #1e293b, var(--dark-bg));
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

/* Login Screen */
#login-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    padding: 40px;
    text-align: center;
}

#login-screen h2 {
    font-size: 28px;
    margin-bottom: 10px;
    color: #fff;
}

#login-screen p {
    color: var(--text-muted);
    margin-bottom: 30px;
}

#login-screen input {
    width: 100%;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(0,0,0,0.2);
    color: #fff;
    font-size: 16px;
    outline: none;
    transition: 0.3s;
}

#login-screen input:focus {
    border-color: var(--primary);
}

#login-screen button {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

#login-screen button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.error-msg {
    color: var(--danger);
    margin-top: 15px;
    font-size: 14px;
}

/* Dashboard Layout */
#dashboard-screen {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 260px;
    margin: 20px;
    display: flex;
    flex-direction: column;
}

.brand {
    font-size: 24px;
    font-weight: 700;
    padding: 30px 20px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(to right, #fff, var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    list-style: none;
    padding: 20px 0;
    flex: 1;
}

.nav-links li {
    padding: 15px 25px;
    margin: 5px 15px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.3s;
    font-weight: 500;
}

.nav-links li i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

.nav-links li:hover, .nav-links li.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.nav-links li.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.user-info {
    padding: 20px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.logout-btn {
    margin-top: 10px;
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
    border: 1px solid var(--danger);
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.3s;
    width: 100%;
}

.logout-btn:hover {
    background: var(--danger);
    color: white;
}

.content {
    flex: 1;
    padding: 20px 20px 20px 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.topbar {
    padding: 20px 30px;
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-indicator {
    display: flex;
    align-items: center;
    background: rgba(0,0,0,0.3);
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 14px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
}

.status-dot.connected { background: var(--success); box-shadow: 0 0 10px var(--success); }
.status-dot.disconnected { background: var(--danger); box-shadow: 0 0 10px var(--danger); }

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
}

.metric-card {
    padding: 30px;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s;
}

.metric-card:hover {
    transform: translateY(-5px);
}

.metric-icon {
    font-size: 40px;
    opacity: 0.8;
    margin-bottom: 15px;
    display: block;
}

.metric-card.gas-card {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(245, 158, 11, 0.1));
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.metric-card h3 {
    font-size: 16px;
    color: var(--text-muted);
    font-weight: 400;
}

.metric-card .value {
    font-size: 48px;
    font-weight: 700;
    margin: 10px 0;
}

.metric-card .value small {
    font-size: 20px;
    color: var(--text-muted);
}

.status-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-normal { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.status-danger { background: rgba(239, 68, 68, 0.2); color: var(--danger); animation: pulseBg 1.5s infinite; }
.status-warning { background: rgba(245, 158, 11, 0.2); color: var(--warning); }

@keyframes pulseBg {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Charts & Tables */
.chart-container {
    padding: 25px;
    height: 400px;
}

.table-container {
    padding: 25px;
}

.table-container h2 {
    margin-bottom: 20px;
    font-size: 20px;
    display: inline-block;
}

.refresh-btn {
    float: right;
    background: rgba(255,255,255,0.1);
    border: 1px solid var(--border);
    color: white;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.2s;
}

.refresh-btn:hover {
    background: rgba(255,255,255,0.2);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

th {
    color: var(--text-muted);
    font-weight: 500;
    background: rgba(0,0,0,0.2);
}

tr:hover {
    background: rgba(255,255,255,0.02);
}

/* Toast */
.toast {
    visibility: hidden;
    min-width: 250px;
    background-color: var(--danger);
    color: #fff;
    text-align: center;
    border-radius: 8px;
    padding: 16px;
    position: fixed;
    z-index: 1000;
    right: 30px;
    bottom: 30px;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 0 10px 30px rgba(239, 68, 68, 0.4);
}

.toast.show {
    visibility: visible;
    animation: fadein 0.5s, fadeout 0.5s 4.5s;
}

@keyframes fadein {
    from {bottom: 0; opacity: 0;} 
    to {bottom: 30px; opacity: 1;}
}

@keyframes fadeout {
    from {bottom: 30px; opacity: 1;} 
    to {bottom: 0; opacity: 0;}
}

@media (max-width: 900px) {
    #dashboard-screen { flex-direction: column; }
    .sidebar { width: auto; flex-direction: row; margin: 10px; align-items: center; justify-content: space-between; }
    .nav-links { display: flex; padding: 0; margin: 0 10px; }
    .nav-links li { padding: 10px; margin: 0 5px; }
    .user-info { border: none; padding: 0; }
    .content { padding: 10px; }
}
