:root {
    --primary: #E5B80B;
    --secondary: #003366;
    --dark: #001F3F;
    --light: #f5f7fa;
    --white: #ffffff;
    --shadow: 0 10px 28px rgba(0, 31, 63, 0.09);
    --success: #2ecc71;
    --danger: #d94444;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #eef3f8; color: #243041; overflow-x: hidden; }

.admin-container { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 250px;
    background: var(--dark);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100%;
}

.brand { padding: 20px; background: var(--secondary); text-align: center; border-bottom: 1px solid #333; }
.brand h2 { color: var(--primary); text-transform: uppercase; font-size: 1.2rem; letter-spacing: 1px; }

.sidebar nav { display: flex; flex-direction: column; padding: 20px 0; flex-grow: 1; }
.sidebar nav a {
    padding: 15px 25px;
    color: #ccc;
    text-decoration: none;
    transition: 0.3s;
    border-left: 4px solid transparent;
}
.sidebar nav a:hover, .sidebar nav a.active {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    border-left-color: var(--primary);
}
.sidebar nav a.logout { margin-top: auto; border-top: 1px solid #333; color: var(--danger); }

/* Main Content */
.main-content { flex: 1; padding: 30px; margin-left: 250px; min-width: 0; }

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    background: rgba(255,255,255,0.78);
    border: 1px solid rgba(255,255,255,0.9);
    border-radius: 8px;
    padding: 16px 18px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

header h1 { color: var(--dark); }

.user-profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-weight: 500;
    position: relative;
    cursor: pointer;
}

.profile-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #f8de65);
    border: 3px solid white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.profile-dropdown {
    display: none;
    position: absolute;
    top: 56px;
    right: 0;
    min-width: 150px;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
    z-index: 20;
}

.profile-dropdown.show { display: block; }
.profile-dropdown a { display: block; padding: 10px 14px; color: #333; text-decoration: none; }
.profile-dropdown a:hover { background: #f6f8fb; }

.section { display: none; animation: fadeIn 0.3s; }
.section.active { display: block; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInCentered { from { opacity: 0; transform: translate(-50%, -45%); } to { opacity: 1; transform: translate(-50%, -50%); } }

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}
.stat-card {
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    transition: 0.3s;
    border: 1px solid #edf1f5;
}
.stat-card:hover { transform: translateY(-5px); }
.stat-card h3 { font-size: 0.9rem; color: #666; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .number { font-size: 2rem; font-weight: 800; color: var(--primary); margin-top: 10px; }

/* Tables */
.table-container {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px; text-align: left; border-bottom: 1px solid #eee; white-space: nowrap; }
th { background: #f8f9fa; font-weight: 600; color: #555; }
tr:last-child td { border-bottom: none; }
small { color: #6b7280; white-space: normal; display: inline-block; max-width: 360px; margin-top: 4px; }

.section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.section-heading p { color: #64748b; margin-top: 4px; }

.tag {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 800;
}

.tag.active { background: #e6f9ed; color: #1f8f4d; }
.tag.locked { background: #eef2f7; color: #5b6472; }
.tag.expired { background: #fdeaea; color: var(--danger); }

.table-thumb {
    width: 52px;
    height: 52px;
    border-radius: 8px;
    object-fit: cover;
    background: #edf2f7;
    border: 1px solid #e5e7eb;
}

.actions-cell {
    display: flex;
    gap: 8px;
    align-items: center;
}

.status-tag { padding: 5px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: bold; background: #eee; color: #555; }
.status-active { background: #e6f9ed; color: var(--success); }
.status-expired { background: #fdeaea; color: var(--danger); }

.btn {
    background: var(--primary);
    color: var(--dark);
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: 0.2s;
    font-weight: 800;
}
.btn:hover { opacity: 0.9; }
.btn-danger { background: var(--danger); color: white; }

.card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    border: 1px solid #edf1f5;
}

/* Mobile Responsiveness */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

@media (max-width: 768px) {
    .sidebar { 
        transform: translateX(-100%); 
        width: 250px; 
        z-index: 1000; 
        transition: transform 0.3s ease;
    }
    .sidebar.active { transform: translateX(0); }
    .sidebar-overlay.active { display: block; }
    
    .main-content { margin-left: 0; padding: 15px; }
    
    #mobileMenuBtn { display: block !important; }
    
    .stats-grid { grid-template-columns: 1fr; }
    .user-profile .profile-name { font-size: 0.8rem; }
    .section-heading { flex-direction: column; }
    .section-heading .btn { width: 100%; }
    .actions-cell { flex-direction: column; align-items: stretch; }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: white;
    margin: 0;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 450px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-height: 90vh;
    overflow-y: auto;
    animation: fadeInCentered 0.3s;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.close-modal {
    float: right;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

.close-modal:hover { color: #333; }

.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 600; font-size: 0.9rem; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 10px; border: 1px solid #d6dde6; border-radius: 6px; font-size: 1rem; font-family: inherit; }
.form-group textarea { resize: vertical; }
.compact-setting { margin: 8px 0 15px; border-bottom: 0; padding: 10px 0; }

/* Switch Styles */
.settings-list {
    margin-top: 20px;
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #eee;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider { background-color: var(--primary); }
input:focus + .slider { box-shadow: 0 0 1px var(--primary); }
input:checked + .slider:before { transform: translateX(26px); }
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }

/* Activity Logs */
.activity-list {
    margin-top: 15px;
}

.activity-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: 50%;
    margin-right: 15px;
    flex-shrink: 0;
}

.activity-details p {
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.activity-time {
    font-size: 0.75rem;
    color: #888;
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--dark);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.admin-toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    color: white;
    padding: 12px 18px;
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(0,0,0,0.18);
    z-index: 3000;
    font-weight: 700;
    max-width: 320px;
}
