:root {
    --bg-color: #0b0e14;
    --sidebar-bg: rgba(255, 255, 255, 0.03);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --accent-color: #00d2ff;
    --accent-glow: rgba(0, 210, 255, 0.3);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --error-color: #ff4b2b;
    --success-color: #38ef7d;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(0, 210, 255, 0.05) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(56, 239, 125, 0.05) 0%, transparent 20%),
        radial-gradient(circle at 50% 50%, #161b22 0%, var(--bg-color) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.hidden { display: none !important; }

/* Dashboard Layout */
.app-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
@media (min-width: 768px) {
    .app-layout {
        flex-direction: row;
    }
}

.sidebar {
    width: 100%;
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(40px);
    border-bottom: 1px solid var(--glass-border);
    padding: 20px;
    display: flex;
    flex-direction: column;
}
@media (min-width: 768px) {
    .sidebar {
        width: 260px;
        border-bottom: none;
        border-right: 1px solid var(--glass-border);
        padding: 40px 20px;
    }
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 0 10px;
}
@media (min-width: 768px) {
    .brand {
        margin-bottom: 50px;
    }
}

.brand-logo {
    font-size: 2rem;
    color: var(--accent-color);
    text-shadow: 0 0 15px var(--accent-glow);
}

.brand-name { display: flex; flex-direction: column; }
.brand-name span { font-weight: 800; font-size: 1.2rem; }
.brand-name small { opacity: 0.5; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1px; }

#mobile-menu-btn {
    margin-left: auto;
    display: flex;
}
@media (min-width: 768px) {
    #mobile-menu-btn {
        display: none;
    }
}

.user-profile {
    display: none;
    align-items: center;
    gap: 12px;
    background: rgba(255,255,255,0.03);
    padding: 15px;
    border-radius: 18px;
    margin-bottom: 20px;
    border: 1px solid var(--glass-border);
}
.sidebar.menu-open .user-profile {
    display: flex;
}
@media (min-width: 768px) {
    .user-profile {
        display: flex;
        margin-bottom: 40px;
    }
}

.user-profile img { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--accent-color); padding: 2px; }
.user-info { display: flex; flex-direction: column; }
.user-info span { font-weight: 600; font-size: 0.9rem; }
.user-info small { opacity: 0.5; font-size: 0.75rem; }

nav {
    display: none;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 10px;
}
.sidebar.menu-open nav {
    display: flex;
}
nav::-webkit-scrollbar {
    display: none;
}

nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 14px 18px;
    border-radius: 12px;
    margin-bottom: 0;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    border: 1px solid transparent;
    white-space: normal;
}

@media (min-width: 768px) {
    nav {
        display: block;
        padding-bottom: 0;
    }
    nav a {
        margin-bottom: 8px;
    }
}

nav a i { width: 20px; height: 20px; }
nav a:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}

nav a.active {
    background: var(--accent-color);
    color: var(--bg-color);
    font-weight: 700;
    box-shadow: 0 10px 20px rgba(0, 210, 255, 0.2);
}

/* Content Area */
.content-area {
    flex: 1;
    padding: 20px 15px;
}
@media (min-width: 768px) {
    .content-area {
        padding: 40px 60px;
    }
}

.content-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 30px;
}
@media (min-width: 768px) {
    .content-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 40px;
    }
}

.header-tools { display: flex; align-items: center; gap: 15px; width: 100%; justify-content: space-between; }
@media (min-width: 768px) {
    .header-tools { width: auto; justify-content: flex-start; }
}
#current-date { color: var(--text-secondary); font-size: 0.9rem; margin-right: 10px; }

/* Cards */
.glass-card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    padding: 30px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* Stat Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
.card-header h3 { font-size: 0.75rem; letter-spacing: 1.5px; opacity: 0.5; font-weight: 700; text-transform: uppercase; }

.gauge-container { text-align: center; }
.gauge { font-size: 3.5rem; font-weight: 800; color: var(--accent-color); text-shadow: 0 0 25px var(--accent-glow); margin-bottom: 15px; }
.gauge small { font-size: 1.2rem; opacity: 0.4; }
.gauge-label { font-size: 0.8rem; color: var(--accent-color); opacity: 0.8; }

.status-content { flex: 1; text-align: left; }
.status-text { font-size: 1.8rem; font-weight: 700; display: block; }
.status-text.online { color: var(--success-color); }
.status-icon { font-size: 1.2rem; }
.status-icon.online { color: var(--success-color); filter: drop-shadow(0 0 10px rgba(56, 239, 125, 0.4)); }

.usage-total { font-size: 2.2rem; font-weight: 700; display: flex; align-items: last baseline; gap: 10px; }
.usage-total small { font-size: 1rem; opacity: 0.3; }
.trend-badge { background: rgba(56, 239, 125, 0.1); color: var(--success-color); padding: 5px 12px; border-radius: 50px; font-size: 0.8rem; font-weight: 600; }

/* Chart Styling */
.main-chart-card { min-height: auto; }
@media (min-width: 768px) {
    .main-chart-card { min-height: 450px; }
}

.chart-header { display: flex; flex-direction: column; gap: 15px; align-items: flex-start; margin-bottom: 25px; }
@media (min-width: 768px) {
    .chart-header { flex-direction: row; justify-content: space-between; align-items: center; margin-bottom: 35px; }
}

.chart-filters { display: flex; flex-wrap: wrap; background: rgba(255,255,255,0.04); border-radius: 12px; padding: 4px; border: 1px solid var(--glass-border); gap: 5px; }
.chart-filters button { background: transparent; border: none; color: var(--text-secondary); padding: 8px 18px; cursor: pointer; font-size: 0.75rem; font-weight: 700; border-radius: 8px; transition: all 0.2s; flex: 1; text-align: center; }
@media (min-width: 768px) {
    .chart-filters button { flex: none; }
}
.chart-filters button.active { background: var(--accent-color); color: var(--bg-color); box-shadow: 0 4px 10px rgba(0, 210, 255, 0.2); }

.chart-wrapper { height: 250px; }
@media (min-width: 768px) {
    .chart-wrapper { height: 320px; }
}

/* Buttons & Inputs */
.icon-btn { background: rgba(255, 255, 255, 0.05); border: 1px solid var(--glass-border); color: var(--text-secondary); cursor: pointer; padding: 10px; border-radius: 12px; transition: all 0.2s; line-height: 0; }
.icon-btn:hover { background: rgba(255, 255, 255, 0.1); color: white; transform: translateY(-2px); }

.icon-btn-sm { background: rgba(255, 255, 255, 0.05); border: 1px solid var(--glass-border); color: var(--text-secondary); cursor: pointer; padding: 6px; border-radius: 8px; transition: all 0.2s; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; }
.icon-btn-sm:hover { transform: scale(1.1); color: white; }
.icon-btn-sm.edit:hover { background: var(--accent-color); color: var(--bg-color); }
.icon-btn-sm.delete:hover { background: var(--error-color); color: white; }

.btn-primary { background: var(--accent-color); color: var(--bg-color); border: none; padding: 16px 32px; border-radius: 14px; font-weight: 700; cursor: pointer; width: 100%; transition: all 0.3s; box-shadow: 0 10px 20px rgba(0, 210, 255, 0.2); }
.btn-primary:hover { transform: translateY(-3px); box-shadow: 0 15px 30px rgba(0, 210, 255, 0.3); }

.btn-primary-sm { background: var(--accent-color); color: var(--bg-color); border: none; padding: 10px 20px; border-radius: 10px; font-weight: 700; cursor: pointer; font-size: 0.85rem; }

.btn-secondary { background: rgba(255,255,255,0.05); color: white; border: 1px solid var(--glass-border); padding: 12px 24px; border-radius: 12px; cursor: pointer; font-weight: 600; }

/* Tables */
.data-table { width: 100%; border-collapse: separate; border-spacing: 0 10px; margin-top: -10px; display: block; overflow-x: auto; white-space: nowrap; }
@media (min-width: 768px) {
    .data-table { display: table; overflow-x: visible; white-space: normal; }
}
.data-table th { padding: 15px 20px; opacity: 0.4; font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; text-align: left; border: none; }
.data-table td { padding: 20px; background: rgba(255,255,255,0.02); border-top: 1px solid var(--glass-border); border-bottom: 1px solid var(--glass-border); font-size: 0.9rem; }
.data-table td:first-child { border-left: 1px solid var(--glass-border); border-radius: 15px 0 0 15px; }
.data-table td:last-child { border-right: 1px solid var(--glass-border); border-radius: 0 15px 15px 0; }
.data-table tr:hover td { background: rgba(255,255,255,0.05); }

/* Modals & Forms */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.85); backdrop-filter: blur(10px); display: flex; justify-content: center; align-items: center; z-index: 1000; }
.modal-content { width: 100%; max-width: 480px; }
.modal-content form input, .modal-content form select { width: 100%; margin: 15px 0; background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); padding: 15px; border-radius: 12px; color: white; outline: none; appearance: none; -webkit-appearance: none; color-scheme: dark; }
.modal-content form select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.5)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 15px center; background-size: 16px; padding-right: 45px; cursor: pointer; }
.modal-content form select option { background-color: #161b22; color: white; }
.modal-content form input:focus, .modal-content form select:focus { border-color: var(--accent-color); box-shadow: 0 0 15px var(--accent-glow); }
.modal-actions { display: flex; justify-content: flex-end; gap: 15px; margin-top: 25px; }

/* Rule Builder Styling */
#rule-list-container {
    padding: 10px;
    background: rgba(0,0,0,0.2);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
}

.rule-row {
    animation: fadeIn 0.3s ease;
}

.rule-row select, .rule-row input {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid var(--glass-border) !important;
    color: white !important;
    border-radius: 10px !important;
    padding: 8px 12px !important;
    outline: none !important;
    font-size: 0.85rem;
}

.rule-row select:focus, .rule-row input:focus {
    border-color: var(--accent-color) !important;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-container { display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 20px; }
.login-card { width: 100%; max-width: 420px; text-align: center; }
.login-card h1 { margin-bottom: 40px; font-weight: 900; letter-spacing: -1px; font-size: 2.2rem; }
.login-card form { display: flex; flex-direction: column; gap: 20px; text-align: left; }
.login-card form input { background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); padding: 16px; border-radius: 12px; color: white; outline: none; transition: all 0.2s; }
.login-card form input:focus { border-color: var(--accent-color); box-shadow: 0 0 15px var(--accent-glow); }
