:root {
    --primary: #4f46e5;
    --secondary: #64748b;
    --accent: #e11d48;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --glass: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(0, 0, 0, 0.08);
    --text: #1e293b;
    --text-secondary: #64748b;
    --card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Cairo', sans-serif;
}

body {
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

.glass-card {
    background: var(--surface);
    border: 1px solid var(--glass-border);
    box-shadow: var(--card-shadow);
    border-radius: 20px;
}

/* Auth Page */
#auth-page {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
}

.login-container {
    width: 100%;
    max-width: 450px;
    padding: 48px;
    text-align: center;
}

/* Dashboard Layout */
#dashboard-page {
    display: none;
    height: 100vh;
}

aside {
    width: 280px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 32px 16px;
    background: var(--surface);
    border-left: 1px solid var(--glass-border) !important;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 48px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--primary);
}

.nav-link {
    padding: 14px 20px;
    margin-bottom: 8px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--text-secondary);
    font-weight: 500;
}

.nav-link:hover {
    background: #f8fafc;
    color: var(--primary);
}

.nav-link.active {
    background: #eef2ff;
    color: var(--primary);
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.1);
}

main {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 48px;
}

.search-bar input {
    background: transparent;
    border: none;
    color: var(--text);
    width: 100%;
    outline: none;
    font-size: 0.95rem;
}

.user-profile {
    display: flex;
    align-items: center;
    background: var(--surface);
    padding: 8px 20px;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
}

.avatar {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
}

/* Content */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
}

.stat-card {
    padding: 32px;
    text-align: center;
}

.stat-card h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.stat-card .value {
    font-size: 1.8rem;
    font-weight: 700;
}

/* Tables */
.table-container {
    overflow-x: auto;
    background: var(--surface);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
}

th {
    padding: 20px;
    border-bottom: 2px solid #f1f5f9;
    color: var(--text-secondary);
    font-weight: 600;
}

td {
    padding: 20px;
    border-bottom: 1px solid #f8fafc;
}

tr:hover td {
    background: #f8fafc;
}

.badge {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-low { background: #dcfce7; color: #166534; }
.badge-medium { background: #fef9c3; color: #854d0e; }
.badge-high { background: #ffedd5; color: #9a3412; }
.badge-critical { background: #fee2e2; color: #991b1b; }

/* Buttons */
.btn {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    font-size: 0.95rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover {
    background: #4338ca;
    transform: translateY(-2px);
}

/* Forms */
.input-group {
    margin-bottom: 24px;
    text-align: right;
}

.input-group label {
    display: block;
    margin-bottom: 10px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.input-group input, .input-group select, .input-group textarea {
    width: 100%;
    padding: 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    color: var(--text);
    outline: none;
    transition: border-color 0.3s;
}

.input-group input:focus {
    border-color: var(--primary);
    background: white;
}

/* Animations and Toast */
@keyframes slideIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.toast {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Modal Scrollbar */
.glass-card::-webkit-scrollbar {
    width: 6px;
}

.glass-card::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

/* Responsive Queries */
@media (max-width: 1024px) {
    aside {
        position: fixed;
        right: -280px;
        z-index: 1000;
        transition: right 0.3s ease;
        box-shadow: 10px 0 30px rgba(0,0,0,0.1);
    }

    aside.active {
        right: 0;
    }

    #mobile-menu-btn {
        display: block !important;
    }

    header {
        flex-direction: column-reverse;
        gap: 20px;
        align-items: flex-start;
    }

    .search-bar {
        width: 100% !important;
    }

    .user-profile {
        width: 100%;
        justify-content: space-between;
    }

    main {
        padding: 20px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    #table-actions {
        flex-direction: column;
        gap: 16px;
        align-items: stretch !important;
    }

    #btn-add-new, #btn-bulk-delete {
        width: 100% !important;
    }
}

@media (max-width: 640px) {
    .login-container {
        padding: 24px;
        margin: 16px;
    }

    th, td {
        padding: 12px 8px;
        font-size: 0.85rem;
    }

    .badge {
        padding: 4px 8px;
        font-size: 0.75rem;
    }
}
