:root {
    /* Premium Color Palette */
    --primary: #4F46E5;
    --primary-light: rgba(79, 70, 229, 0.15);
    --primary-gradient: linear-gradient(135deg, #4F46E5, #3B82F6);
    
    --secondary: #1E293B;
    
    --accent: #10B981;
    --accent-light: rgba(16, 185, 129, 0.15);
    --accent-gradient: linear-gradient(135deg, #10B981, #059669);
    
    --warning: #F59E0B;
    --warning-light: rgba(245, 158, 11, 0.15);
    --warning-gradient: linear-gradient(135deg, #F59E0B, #D97706);
    
    --danger: #EF4444;
    --danger-light: rgba(239, 68, 68, 0.15);
    --danger-gradient: linear-gradient(135deg, #EF4444, #B91C1C);
    
    /* Layout & Surface */
    --bg-main: #F1F5F9;
    --bg-gradient: linear-gradient(120deg, #fdfbfb 0%, #ebedee 100%);
    
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.4);
    
    --text-main: #0F172A;
    --text-muted: #64748B;
    --border-color: rgba(226, 232, 240, 0.8);
    
    --sidebar-width: 280px;
    --topbar-height: 75px;
    
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;
    
    --shadow-soft: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
    --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    --transition: 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

[data-theme="dark"] {
    --bg-main: #0F172A;
    --bg-gradient: linear-gradient(to right, #0f2027, #203a43, #2c5364);
    
    --glass-bg: rgba(30, 41, 59, 0.6);
    --glass-border: rgba(255, 255, 255, 0.05);
    
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --border-color: rgba(51, 65, 85, 0.6);
    
    --shadow-soft: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

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

body {
    background: var(--bg-gradient);
    background-size: 200% 200%;
    animation: gradientBG 15s ease infinite;
    color: var(--text-main);
    overflow-x: hidden;
    transition: background var(--transition), color var(--transition);
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Utilities */
.text-primary { color: var(--primary); }
.text-success { color: var(--accent); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); }

.bg-primary-light { background-color: var(--primary-light); color: var(--primary); }
.bg-success-light { background-color: var(--accent-light); color: var(--accent); }
.bg-warning-light { background-color: var(--warning-light); color: var(--warning); }
.bg-danger-light { background-color: var(--danger-light); color: var(--danger); }

.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.center-content { text-align: center; padding: 40px !important; }

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Glass Effect Core Class */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition);
    border-right: 1px solid var(--glass-border);
    box-shadow: var(--shadow-soft);
}

.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 25px;
    border-bottom: 1px solid var(--glass-border);
}

.sidebar-header h2 {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 1.6rem;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-header h2 i { -webkit-text-fill-color: initial; color: var(--primary); }
.sidebar-header .subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 25px 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.nav-item i {
    width: 28px;
    font-size: 1.2rem;
    transition: transform var(--transition);
}

.nav-item:hover {
    color: var(--primary);
    background: rgba(79, 70, 229, 0.05);
}

.nav-item:hover i {
    transform: scale(1.1);
}

.nav-item.active {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
}

.nav-item.active i { color: white; }

.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: auto;
    letter-spacing: 0.5px;
}
.badge-danger { background: var(--danger-gradient); color: white; box-shadow: 0 2px 5px rgba(239,68,68,0.3);}
.badge-warning { background: var(--warning-gradient); color: white; }
.badge-success { background: var(--accent-gradient); color: white; }

.sidebar-footer {
    padding: 20px 25px;
    border-top: 1px solid var(--glass-border);
}
.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}
.avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}
.details {
    display: flex;
    flex-direction: column;
}
.details .name { font-weight: 600; font-size: 0.95rem; }
.details .role { font-size: 0.8rem; color: var(--text-muted); }

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
    position: sticky;
    top: 0;
    z-index: 90;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.03);
}
.topbar-left { display: flex; align-items: center; gap: 20px; }
.topbar-right { display: flex; align-items: center; gap: 20px; }

#page-title {
    font-size: 1.4rem;
    font-weight: 600;
}

.time-widget {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
    background: var(--glass-bg);
    padding: 8px 15px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
}

.icon-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    font-size: 1.2rem;
    cursor: pointer;
    width: 45px; height: 45px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transition);
}
.icon-btn:hover { 
    background: var(--primary-light); 
    color: var(--primary); 
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

.notification-wrapper { position: relative; }
.notification-dot {
    position: absolute;
    top: 10px; right: 10px;
    width: 10px; height: 10px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--bg-surface);
    animation: ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping {
    75%, 100% { transform: scale(2); opacity: 0; }
}

/* Views */
.view-section {
    display: none;
    padding: 40px;
    animation: slideFadeUp 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
}
.view-section.active {
    display: block;
}
@keyframes slideFadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cards */
.card {
    border-radius: var(--radius-lg);
    padding: 25px;
    box-shadow: var(--shadow-soft);
    margin-bottom: 25px;
    transition: all var(--transition);
}
.card:hover {
    box-shadow: var(--shadow-hover);
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.card-title {
    font-size: 1.2rem;
    font-weight: 600;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 25px;
    margin-bottom: 35px;
}
.stat-card {
    padding: 25px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow-soft);
    transition: transform var(--transition), box-shadow var(--transition);
    position: relative;
    overflow: hidden;
}
.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

/* Decorative circle inside stat card */
.stat-card::before {
    content: ''; position: absolute;
    top: -20px; right: -20px;
    width: 100px; height: 100px;
    background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, rgba(255,255,255,0) 70%);
    opacity: 0.1;
    border-radius: 50%;
}
[data-theme="dark"] .stat-card::before { background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 70%); }

.stat-icon {
    width: 60px; height: 60px;
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem;
    box-shadow: inset 0 2px 4px rgba(255,255,255,0.3);
}
.stat-details h3 { font-size: 0.9rem; color: var(--text-muted); font-weight: 500; margin-bottom: 5px; }
.stat-number { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat-number span { font-size: 0.85rem; font-weight: 400; color: var(--text-muted); }

.alert-pulse {
    animation: pulseBorder 2s infinite;
}
@keyframes pulseBorder {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 15px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Charts Area */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 25px;
    margin-bottom: 35px;
}
.chart-container {
    position: relative;
    height: 380px;
}

/* Table */
.table-actions {
    display: flex; gap: 15px;
}
.table-responsive { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
}
.data-table th {
    padding: 15px 20px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.data-table td {
    padding: 16px 20px;
    text-align: left;
    background: var(--glass-bg);
    backdrop-filter: blur(5px);
    border-top: 1px solid var(--glass-border);
    border-bottom: 1px solid var(--glass-border);
    transition: all 0.3s;
}
.data-table td:first-child { border-left: 1px solid var(--glass-border); border-top-left-radius: var(--radius-sm); border-bottom-left-radius: var(--radius-sm); }
.data-table td:last-child { border-right: 1px solid var(--glass-border); border-top-right-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm); }

.data-table tbody tr {
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}
.data-table tbody tr:hover td {
    background: var(--primary-light);
    transform: scale(1.01);
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Form Styles */
.form-container { max-width: 800px; margin: 0 auto; }
.form-group-row {
    display: flex; gap: 25px; margin-bottom: 25px;
}
.form-group { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.form-group label { font-size: 0.95rem; font-weight: 600; }
.form-input {
    padding: 14px 20px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--glass-bg);
    color: var(--text-main);
    outline: none; transition: all var(--transition);
    font-size: 0.95rem;
}
.form-input:focus { 
    border-color: var(--primary); 
    box-shadow: 0 0 0 4px var(--primary-light);
}
.form-actions { display: flex; justify-content: flex-end; gap: 15px; margin-top: 20px;}

/* Buttons */
.btn {
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600; cursor: pointer;
    border: none; transition: all var(--transition);
    display: inline-flex; align-items: center; gap: 10px;
    font-size: 0.95rem;
}
.btn-primary { 
    background: var(--primary-gradient); 
    color: white; 
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4);
}
.btn-primary:hover { 
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(79, 70, 229, 0.5);
}
.btn-outline { 
    background: var(--glass-bg); 
    border: 1px solid var(--border-color); 
    color: var(--text-main); 
}
.btn-outline:hover { 
    background: var(--border-color); 
    transform: translateY(-2px);
}
.btn-outline-danger { 
    background: transparent; 
    border: 2px solid var(--danger); 
    color: var(--danger); 
}
.btn-outline-danger:hover { 
    background: var(--danger-gradient);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

/* Alerts List */
.alert-item {
    display: flex; gap: 20px;
    padding: 20px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    background: var(--glass-bg);
    border-radius: var(--radius-md);
    margin-bottom: 15px;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}
.alert-item::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: var(--danger-gradient);
}
.alert-item.warning { border-color: rgba(245, 158, 11, 0.3); }
.alert-item.warning::before { background: var(--warning-gradient); }

.alert-item:hover { transform: translateX(5px); box-shadow: var(--shadow-hover); }

.alert-icon { font-size: 1.8rem; display: flex; align-items: center;}
.alert-item.warning .alert-icon { color: var(--warning); }
.alert-item:not(.warning) .alert-icon { color: var(--danger); }

.alert-content h4 { margin-bottom: 5px; font-size: 1.1rem;}
.alert-content p { font-size: 0.95rem; color: var(--text-muted); line-height: 1.6;}
.alert-time { margin-left: auto; font-size: 0.85rem; color: var(--text-muted); font-weight: 500;}

/* Toast */
.toast {
    position: fixed;
    bottom: -100px; left: 50%;
    transform: translateX(-50%);
    background: var(--accent-gradient);
    color: white; padding: 12px 30px;
    border-radius: 30px; font-weight: 600;
    transition: bottom 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000; box-shadow: 0 10px 25px rgba(16, 185, 129, 0.4);
    display: flex; align-items: center; gap: 10px;
}
.toast i { font-size: 1.2rem; }
.toast.show { bottom: 40px; }

/* Responsive */
.mobile-only { display: none; }
@media (max-width: 1200px) {
    .charts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .mobile-only { display: flex; }
    .sidebar { transform: translateX(-100%); }
    .sidebar.active { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .topbar { padding: 0 20px; }
    .view-section { padding: 20px; }
    .form-group-row { flex-direction: column; gap: 0; }
    .time-widget { display: none; }
    .alert-item { flex-direction: column; gap: 10px; align-items: flex-start;}
    .alert-time { margin-left: 0; }
}
@media print {
    body { background: white !important; }
    .sidebar, .topbar, .btn, .no-print, .action-btn { display: none !important; }
    .main-content { margin: 0 !important; width: 100% !important; }
    .card { box-shadow: none !important; border: none !important; }
    .view-section { padding: 0 !important; }
    .pdf-header { display: block !important; }
    #exportable-area { width: 100% !important; }
}

/* --- New Styles: Modal, Timeline, Action Buttons --- */

/* Action Buttons in Table */
.action-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 6px;
    border-radius: 6px;
    transition: all var(--transition);
}
.btn-edit { color: var(--primary); }
.btn-edit:hover { background: var(--primary-light); }
.btn-delete { color: var(--danger); }
.btn-delete:hover { background: var(--danger-light); }

/* Modal */
.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(5px);
    align-items: center; justify-content: center;
}
.modal.show { display: flex; animation: fadeIn 0.3s ease; }
.modal-content {
    width: 90%; max-width: 600px;
    margin: auto;
    position: relative;
    animation: slideFadeUp 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 15px;
}
.close-btn {
    color: var(--text-muted); font-size: 28px; font-weight: bold; cursor: pointer;
    transition: color 0.2s;
}
.close-btn:hover { color: var(--danger); }

/* Audit Timeline */
.audit-timeline {
    position: relative;
    padding-left: 30px;
}
.audit-timeline::before {
    content: ''; position: absolute;
    left: 7px; top: 0; bottom: 0; width: 2px;
    background: var(--glass-border);
}
.audit-item {
    position: relative; margin-bottom: 25px;
    background: var(--glass-bg); padding: 15px 20px;
    border-radius: var(--radius-md); border: 1px solid var(--glass-border);
}
.audit-item::before {
    content: ''; position: absolute;
    left: -29px; top: 20px;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--primary);
    border: 3px solid var(--bg-main);
    box-shadow: 0 0 0 2px var(--primary-light);
}
.audit-item.action-add::before { background: var(--accent); }
.audit-item.action-delete::before { background: var(--danger); }
.audit-item.action-edit::before { background: var(--warning); }

.audit-meta { display: flex; justify-content: space-between; margin-bottom: 5px; }
.audit-user { font-weight: 600; font-size: 0.9rem; color: var(--primary); }
.audit-time { font-size: 0.8rem; color: var(--text-muted); }
.audit-desc { font-size: 0.95rem; color: var(--text-main); }
