* {
    box-sizing: border-box;
}

:root {
    --primary: #2c3e50;
    --accent: #3498db;
    --bg: #f4f7f6;
    --danger: #e74c3c;
    --warning: #f1c40f;
    --success: #2ecc71;
    --purple: #9b59b6;
    --orange: #e67e22;
}

body {
    margin: 0;
    font-family: 'Segoe UI', Arial, sans-serif;
    background-color: var(--bg);
    overflow-x: hidden;
}

.navbar {
    background: var(--primary);
    color: white;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.nav-left { display: flex; flex-direction: column; }
.nav-brand { font-size: 1.2rem; font-weight: bold; letter-spacing: 1px; }
.nav-clock { font-size: 0.85rem; color: #bdc3c7; font-family: 'Courier New', Courier, monospace; margin-top: 5px; }
.nav-user { display: flex; align-items: center; }
.logout-link { text-decoration: none; color: #ff7675; margin-left: 20px; font-weight: bold; font-size: 1.1rem; }

.app-container {
    display: flex;
    min-height: calc(100vh - 70px);
    flex-direction: row;
}

.sidebar {
    width: 250px;
    background: #ffffff;
    box-shadow: 2px 0 5px rgba(0,0,0,0.05);
    padding: 20px;
    flex-shrink: 0;
}

.sidebar ul { list-style: none; padding: 0; margin: 0; }
.sidebar li {
    padding: 15px 20px;
    margin-bottom: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    color: #7f8c8d;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
}
.sidebar li:hover { background: #f1f2f6; color: var(--primary); }
.sidebar li.active { background: var(--accent); color: white; }
.sidebar li i { margin-right: 15px; width: 20px; text-align: center; }

.content {
    flex: 1;
}

.view-section { display: none; }
.view-section.active { display: block; animation: fadeIn 0.5s ease; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}
.card {
    background: white; padding: 20px; border-radius: 12px;
    display: flex; align-items: center; gap: 15px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    transition: background-color 0.3s ease;
}
.card i { font-size: 2.5rem; }
.card h3 { margin: 0; font-size: 0.9rem; color: #7f8c8d; }
.card h2 { margin: 5px 0 0 0; font-size: 1.8rem; color: #2d3436; }
.card small { font-size: 0.8rem; color: #636e72; }

.border-v { border-top: 4px solid var(--danger); }
.border-a { border-top: 4px solid var(--warning); }
.border-w { border-top: 4px solid var(--purple); }
.border-kwh { border-top: 4px solid var(--success); }
.border-temp { border-top: 4px solid var(--orange); }

.icon-v { color: var(--danger); }
.icon-a { color: var(--warning); }
.icon-w { color: var(--purple); }
.icon-kwh { color: var(--success); }
.icon-temp { color: var(--orange); }

.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}
.chart-box {
    background: white; padding: 20px; border-radius: 12px;
    height: 350px; box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    position: relative; width: 100%;
}

.table-container {
    background: white; padding: 20px; border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05); overflow-x: auto;
}
.data-table { width: 100%; border-collapse: collapse; margin-top: 15px; min-width: 700px; }
.data-table th, .data-table td { padding: 12px 15px; border-bottom: 1px solid #eee; text-align: left; }
.data-table th { background: var(--primary); color: white; white-space: nowrap; }

.export-form {
    display: flex; align-items: center; gap: 15px; margin-bottom: 15px; flex-wrap: wrap;
    background: #f9fbfd; padding: 15px; border-radius: 8px; border: 1px solid #e1e8ed;
}
.export-form select, .export-form input[type="date"], .export-form input[type="time"] {
    padding: 8px; border: 1px solid #ccc; border-radius: 5px; font-size: 0.95rem; outline: none;
}
.btn-export { background: #27ae60; color: white; padding: 10px 20px; border: none; border-radius: 5px; font-weight: bold; cursor: pointer; transition: 0.3s; }
.btn-export:hover { background: #219150; }

.warning-banner {
    background-color: #e74c3c; color: white; padding: 15px 20px;
    border-radius: 8px; margin-bottom: 20px; display: flex; align-items: center;
    gap: 15px; font-size: 1.1rem; box-shadow: 0 4px 10px rgba(231, 76, 60, 0.4);
    border: 2px solid #c0392b;
}
.warning-banner i { font-size: 1.8rem; color: #fff200; }
.blink-icon { animation: kedip 1s infinite; }
@keyframes kedip { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } }

.badge-normal { background-color: #2ecc71; color: white; padding: 5px 10px; border-radius: 12px; font-size: 0.85rem; font-weight: bold; }
.badge-danger { background-color: #e74c3c; color: white; padding: 5px 10px; border-radius: 12px; font-size: 0.85rem; font-weight: bold; }

.btn-floating-settings {
    position: fixed; bottom: 25px; left: 25px; background-color: #34495e;
    color: white; width: 55px; height: 55px; border-radius: 50%;
    text-align: center; line-height: 55px; font-size: 24px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3); cursor: pointer; z-index: 1000; transition: transform 0.3s;
}
.btn-floating-settings:hover { transform: scale(1.1); background-color: #2c3e50; }
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 1001; }
.modal-box { background: white; width: 90%; max-width: 400px; margin: 10vh auto; padding: 25px; border-radius: 8px; position: relative; }
.modal-box input { width: 100%; padding: 10px; margin: 8px 0 15px; border: 1px solid #ccc; border-radius: 4px; }
.btn-simpan-setting { width: 100%; padding: 12px; background: #2ecc71; color: white; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; font-size: 1rem;}
.btn-close-modal { position: absolute; top: 15px; right: 20px; font-size: 24px; cursor: pointer; color: #7f8c8d; }

.login-page {
    position: relative; display: flex; flex-direction: column; justify-content: center;
    align-items: center; height: 100vh; background: linear-gradient(135deg, #2c3e50 0%, #000000 100%);
}
.login-box { background: white; padding: 40px; border-radius: 10px; width: 90%; max-width: 350px; text-align: center; box-shadow: 0 10px 25px rgba(0,0,0,0.5); }
.login-box h2 { font-size: 1.3rem; margin-bottom: 20px; color: #2c3e50;}
.login-box input { width: 100%; padding: 12px; margin: 10px 0; border: 1px solid #ccc; border-radius: 5px; }
.login-box button { width: 100%; padding: 12px; background: #3498db; color: white; border: none; border-radius: 5px; cursor: pointer; font-size: 1rem; font-weight: bold; transition: 0.3s;}
.login-box button:hover { background: #2980b9; }
.logo-container { margin-bottom: 20px; text-align: center; }
.logo-kampus { width: 90px; height: auto; filter: drop-shadow(0px 2px 4px rgba(0,0,0,0.1)); }
.login-footer { position: absolute; bottom: 20px; width: 100%; text-align: center; color: #ecf0f1; font-size: 0.85rem; opacity: 0.8; }

@media (max-width: 768px) {
    .navbar { flex-direction: column; text-align: center; gap: 15px; padding: 15px; }
    .nav-user { justify-content: center; margin-top: 5px; width: 100%; }
    
    .app-container { flex-direction: column; }
    
    .sidebar { width: 100%; padding: 15px; display: flex; justify-content: center; }
    .sidebar ul { display: flex; flex-wrap: wrap; gap: 10px; width: 100%; justify-content: center; }
    .sidebar li { margin-bottom: 0; padding: 10px 15px; flex: 1; justify-content: center; text-align: center; min-width: 120px; }
    .sidebar li i { margin-right: 5px; }
    
    .content-area { padding: 15px; }
    
    .card-grid { grid-template-columns: repeat(2, 1fr); }
    
    .chart-grid { grid-template-columns: 1fr; }
    
    .export-form { flex-direction: column; align-items: stretch; }
    #custom-date-fields { flex-direction: column; align-items: stretch; }
}

@media (max-width: 480px) {
    .card-grid { grid-template-columns: 1fr; }
}