:root {
    --primary: #4f46e5; --primary-dark: #4338ca; --secondary: #ec4899;
    --success: #10b981; --warning: #f59e0b; --danger: #ef4444; --info: #3b82f6;
    --bg-light: #f3f4f6; --surface-light: #ffffff; --text-light: #111827; --text-muted-light: #6b7280; --border-light: #e5e7eb;
    --bg-dark: #0f172a; --surface-dark: #1e293b; --text-dark: #f8fafc; --text-muted-dark: #94a3b8; --border-dark: #334155;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1); --radius: 12px; --font: 'Plus Jakarta Sans', sans-serif;
}
[data-theme="light"] { --bg: var(--bg-light); --surface: var(--surface-light); --text: var(--text-light); --text-muted: var(--text-muted-light); --border: var(--border-light); }
[data-theme="dark"] { --bg: var(--bg-dark); --surface: var(--surface-dark); --text: var(--text-dark); --text-muted: var(--text-muted-dark); --border: var(--border-dark); }

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--font); background: var(--bg); color: var(--text); transition: background 0.3s, color 0.3s; }
.hidden { display: none !important; }
a { text-decoration: none; color: inherit; } button { font-family: var(--font); cursor: pointer; border: none; outline: none; }
input, select, textarea { font-family: var(--font); outline: none; }

/* Loader */
.loader-overlay { position: fixed; inset: 0; background: var(--primary); z-index: 9999; display: flex; align-items: center; justify-content: center; flex-direction: column; color: white; transition: opacity 0.5s; }
.spinner-ring { width: 60px; height: 60px; border: 4px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Auth Screen */
.auth-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-wrapper { display: flex; width: 100%; max-width: 1000px; height: 650px; background: var(--surface); border-radius: 24px; overflow: hidden; box-shadow: var(--shadow); }
.auth-branding { flex: 1; background: linear-gradient(135deg, var(--primary), var(--secondary)); color: white; padding: 40px; display: flex; flex-direction: column; justify-content: space-between; position: relative; }
.auth-branding::before { content: ''; position: absolute; inset: 0; background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.1'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"); }
.brand-content { position: relative; z-index: 1; }
.logo-large { font-size: 64px; margin-bottom: 20px; }
.brand-content h1 { font-size: 32px; font-weight: 800; margin-bottom: 8px; }
.brand-content .subtitle { font-size: 18px; opacity: 0.9; margin-bottom: 40px; }
.features-list { display: flex; flex-direction: column; gap: 12px; }
.feature-item { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; }
.feature-item i { background: rgba(255,255,255,0.2); width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.auth-footer { font-size: 12px; opacity: 0.7; position: relative; z-index: 1; }

.auth-forms { flex: 1; padding: 40px; overflow-y: auto; display: flex; flex-direction: column; justify-content: center; }
.auth-form { display: none; animation: fadeIn 0.4s; }
.auth-form.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.form-header { margin-bottom: 30px; }
.form-header h2 { font-size: 28px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.form-header p { color: var(--text-muted); }

.input-group { margin-bottom: 20px; }
.input-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.input-icon-wrapper { position: relative; }
.input-icon-wrapper i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 16px; }
.input-icon-wrapper input, .input-icon-wrapper select { width: 100%; padding: 12px 12px 12px 42px; border: 2px solid var(--border); border-radius: 10px; font-size: 14px; background: var(--bg); color: var(--text); transition: 0.2s; }
.input-icon-wrapper input:focus, .input-icon-wrapper select:focus { border-color: var(--primary); }
.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.form-actions-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; font-size: 13px; }
.checkbox-custom { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text-muted); }
.link-text { color: var(--primary); font-weight: 600; }
.btn-gradient { width: 100%; padding: 14px; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; border-radius: 10px; font-weight: 600; font-size: 15px; display: flex; align-items: center; justify-content: center; gap: 10px; transition: 0.3s; box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3); }
.btn-gradient:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(79, 70, 229, 0.4); }
.divider { text-align: center; margin: 20px 0; color: var(--text-muted); font-size: 12px; position: relative; }
.divider::before, .divider::after { content: ''; position: absolute; top: 50%; width: 40%; height: 1px; background: var(--border); }
.divider::before { left: 0; } .divider::after { right: 0; }
.switch-text { text-align: center; font-size: 13px; color: var(--text-muted); margin-top: 20px; }
.switch-text a { color: var(--primary); font-weight: 600; }

/* Dashboard Layout */
.dashboard { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 20px; display: flex; flex-direction: column; height: 100vh; position: sticky; top: 0; z-index: 100; overflow-y: auto; }
.sidebar-header { display: flex; align-items: center; gap: 12px; padding-bottom: 20px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.logo-icon { font-size: 28px; }
.logo-text span { display: block; font-weight: 800; font-size: 16px; color: var(--text); }
.logo-text small { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }

.user-profile { background: var(--bg); padding: 16px; border-radius: var(--radius); margin-bottom: 24px; text-align: center; border: 1px solid var(--border); }
.avatar-wrapper { position: relative; width: 60px; height: 60px; margin: 0 auto 10px; }
.avatar { width: 100%; height: 100%; background: linear-gradient(135deg, var(--primary), var(--secondary)); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 22px; }
.status-dot { width: 12px; height: 12px; background: var(--success); border: 2px solid var(--surface); border-radius: 50%; position: absolute; bottom: 0; right: 0; }
.user-meta h4 { font-size: 15px; font-weight: 700; }
.badge-role { display: inline-block; padding: 2px 8px; background: var(--primary); color: white; border-radius: 4px; font-size: 10px; font-weight: 600; margin-top: 4px; }
.user-stats { display: flex; justify-content: center; gap: 12px; margin-top: 10px; font-size: 11px; color: var(--text-muted); }

.nav-menu { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.nav-label { font-size: 11px; text-transform: uppercase; color: var(--text-muted); font-weight: 700; padding: 12px 12px 8px; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; color: var(--text-muted); font-weight: 500; transition: 0.2s; }
.nav-link:hover, .nav-link.active { background: var(--primary); color: white; }
.nav-link i { width: 20px; text-align: center; }
.count-badge { margin-left: auto; background: var(--danger); color: white; font-size: 10px; padding: 2px 6px; border-radius: 10px; min-width: 18px; text-align: center; }
.count-badge.warning { background: var(--warning); }
.logout { margin-top: auto; color: var(--danger); }
.logout:hover { background: var(--danger); color: white; }

/* Main Content */
.main-content { background: var(--bg); padding: 24px; overflow-y: auto; height: 100vh; }
.top-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; gap: 20px; flex-wrap: wrap; }
.toggle-sidebar-btn { display: none; font-size: 20px; color: var(--text); background: var(--surface); width: 40px; height: 40px; border-radius: 8px; align-items: center; justify-content: center; border: 1px solid var(--border); }
.search-bar-large { flex: 1; max-width: 400px; position: relative; }
.search-bar-large i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-bar-large input { width: 100%; padding: 12px 12px 12px 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.header-actions { display: flex; align-items: center; gap: 12px; }
.icon-btn { width: 40px; height: 40px; background: var(--surface); border-radius: 10px; display: flex; align-items: center; justify-content: center; color: var(--text); border: 1px solid var(--border); position: relative; transition: 0.2s; }
.icon-btn:hover { background: var(--primary); color: white; }
.dot { width: 8px; height: 8px; background: var(--danger); border-radius: 50%; position: absolute; top: 8px; right: 8px; border: 2px solid var(--surface); }
.user-avatar-sm { width: 40px; height: 40px; background: var(--primary); color: white; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 700; cursor: pointer; }

/* Sections & Cards */
.section { display: none; animation: fadeIn 0.4s; }
.section.active { display: block; }
.card { background: var(--surface); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow); border: 1px solid var(--border); margin-bottom: 24px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.card-header h2, .card-header h3 { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; }

/* Dashboard Specifics */
.welcome-banner { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: white; padding: 30px; border-radius: var(--radius-lg); margin-bottom: 24px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 20px; }
.welcome-text h2 { font-size: 28px; margin-bottom: 8px; }
.welcome-text p { opacity: 0.9; }
.welcome-actions .btn-primary { background: white; color: var(--primary); }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 24px; }
.stat-card { background: var(--surface); padding: 20px; border-radius: var(--radius); border: 1px solid var(--border); display: flex; align-items: center; gap: 16px; transition: 0.3s; }
.stat-card:hover { transform: translateY(-5px); }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: white; font-size: 20px; }
.stat-icon.blue { background: var(--info); }
.stat-icon.green { background: var(--success); }
.stat-icon.orange { background: var(--warning); }
.stat-icon.purple { background: var(--secondary); }
.stat-info h3 { font-size: 24px; font-weight: 800; }
.stat-info p { font-size: 13px; color: var(--text-muted); }

.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
.large { grid-column: span 2; }
.activity-feed { display: flex; flex-direction: column; gap: 16px; max-height: 300px; overflow-y: auto; }
.activity-item { display: flex; gap: 12px; align-items: start; }
.activity-icon { width: 32px; height: 32px; background: var(--bg); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--primary); font-size: 12px; flex-shrink: 0; }
.activity-content p { font-size: 14px; margin-bottom: 2px; }
.activity-content small { font-size: 12px; color: var(--text-muted); }

.quick-actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.action-item { padding: 16px; background: var(--bg); border-radius: 10px; display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: var(--text); border: 1px dashed var(--border); transition: 0.2s; }
.action-item:hover { border-color: var(--primary); background: rgba(79, 70, 229, 0.05); }
.action-item i { font-size: 20px; color: var(--primary); }

/* Tables & Lists */
.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; padding: 12px; background: var(--bg); font-size: 12px; text-transform: uppercase; color: var(--text-muted); }
.data-table td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
.badge-large { padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-large.warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.badge-large.success { background: rgba(16, 185, 129, 0.1); color: var(--success); }

/* Forms */
.form-grid { display: grid; gap: 16px; }
.form-group.full-width { grid-column: span 2; }
.modern-select, textarea { width: 100%; padding: 12px; border: 2px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); font-size: 14px; }
.modern-select:focus, textarea:focus { border-color: var(--primary); }
.drop-zone { border: 2px dashed var(--border); border-radius: 10px; padding: 30px; text-align: center; cursor: pointer; transition: 0.2s; }
.drop-zone:hover { border-color: var(--primary); background: rgba(79, 70, 229, 0.05); }
.drop-zone i { font-size: 24px; color: var(--primary); margin-bottom: 8px; }
.file-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.file-tag { display: flex; align-items: center; gap: 6px; padding: 4px 10px; background: var(--bg); border-radius: 20px; font-size: 12px; }
.file-tag button { background: none; color: var(--danger); font-size: 14px; padding: 0; }
.btn-primary { padding: 10px 20px; background: var(--primary); color: white; border-radius: 8px; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 8px; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { padding: 10px 20px; background: var(--bg); color: var(--text); border-radius: 8px; font-weight: 600; border: 1px solid var(--border); }
.btn-sm { padding: 6px 12px; background: var(--bg); border-radius: 6px; font-size: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; }

/* Profile & Analytics */
.profile-card { background: var(--surface); border-radius: var(--radius-lg); overflow: hidden; }
.profile-cover { height: 120px; background: linear-gradient(135deg, var(--primary), var(--secondary)); }
.profile-details { padding: 0 24px; display: flex; align-items: flex-end; gap: 16px; margin-top: -40px; margin-bottom: 24px; }
.profile-avatar-lg { width: 80px; height: 80px; background: var(--surface); border: 4px solid var(--surface); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 32px; color: var(--primary); }
.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; padding: 0 24px 24px; }
.info-group label { font-size: 12px; color: var(--text-muted); display: block; margin-bottom: 4px; }
.info-group p { font-weight: 600; font-size: 15px; }

.analytics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.chart-card { background: var(--bg); padding: 20px; border-radius: 10px; }
.bar-chart { height: 150px; display: flex; align-items: flex-end; gap: 10px; padding-top: 20px; }
.bar { flex: 1; background: var(--primary); border-radius: 4px 4px 0 0; transition: height 0.5s; position: relative; }

/* Settings */
.settings-list { display: flex; flex-direction: column; gap: 16px; }
.setting-item { display: flex; justify-content: space-between; align-items: center; padding: 16px; background: var(--bg); border-radius: 10px; }
.setting-info h4 { font-size: 14px; margin-bottom: 4px; }
.setting-info p { font-size: 12px; color: var(--text-muted); }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background: var(--border); border-radius: 24px; transition: 0.3s; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.3s; }
input:checked + .slider { background: var(--primary); }
input:checked + .slider:before { transform: translateX(20px); }

/* Calendar */
.calendar-wrapper { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.calendar-header-nav { display: flex; justify-content: space-between; align-items: center; padding: 12px; background: var(--bg); }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; }
.calendar-day-header { padding: 10px; font-size: 12px; font-weight: 600; color: var(--text-muted); background: var(--bg); }
.calendar-day { padding: 15px 5px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); font-size: 14px; cursor: pointer; }
.calendar-day:hover { background: var(--bg); }
.calendar-day.today { background: var(--primary); color: white; font-weight: 700; }

/* Toast & Modal */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; }
.toast { padding: 14px 20px; background: var(--surface); color: var(--text); border-radius: 10px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px; min-width: 280px; animation: slideUp 0.3s; border-left: 4px solid var(--primary); }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 3000; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.modal-card { background: var(--surface); border-radius: 16px; width: 90%; max-width: 500px; max-height: 90vh; overflow-y: auto; animation: pop 0.3s; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header button { background: none; font-size: 24px; color: var(--text-muted); }
.modal-body { padding: 20px; }
@keyframes pop { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Responsive */
@media (max-width: 1024px) {
    .dashboard { grid-template-columns: 1fr; }
    .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); width: 260px; z-index: 200; transition: transform 0.3s; }
    .sidebar.open { transform: translateX(0); }
    .toggle-sidebar-btn { display: flex; }
    .dashboard.open { overflow: hidden; }
}
@media (max-width: 768px) {
    .auth-wrapper { flex-direction: column; height: auto; }
    .auth-branding { padding: 30px; text-align: center; }
    .auth-forms { padding: 30px; }
    .features-list { display: none; }
    .input-row { grid-template-columns: 1fr; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .large { grid-column: span 1; }
    .analytics-grid { grid-template-columns: 1fr; }
    .form-group.full-width { grid-column: span 1; }
}
@media (max-width: 480px) {
    .welcome-banner { text-align: center; justify-content: center; }
    .welcome-actions { width: 100%; }
    .stats-grid { grid-template-columns: 1fr; }
    .form-actions { flex-direction: column-reverse; }
    .form-actions button { width: 100%; }
}