* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #2563eb; --primary-dark: #1d4ed8; --primary-light: #dbeafe;
  --sidebar-bg: #1e293b; --sidebar-text: #94a3b8; --sidebar-hover: #334155;
  --sidebar-active: var(--primary); --header-bg: #ffffff;
  --card-bg: #ffffff; --bg: #f1f5f9; --text: #1e293b; --text-muted: #64748b;
  --border: #e2e8f0; --success: #22c55e; --warning: #f59e0b; --danger: #ef4444; --info: #3b82f6;
  --shadow: 0 1px 3px rgba(0,0,0,.1); --shadow-lg: 0 4px 12px rgba(0,0,0,.1);
  --radius: 8px; --radius-sm: 4px; --transition: .2s ease;
}
.dark { --sidebar-bg: #0f172a; --header-bg: #1e293b; --card-bg: #1e293b; --bg: #0f172a; --text: #f1f5f9; --text-muted: #94a3b8; --border: #334155; --shadow: 0 1px 3px rgba(0,0,0,.3); --shadow-lg: 0 4px 12px rgba(0,0,0,.4); }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); height: 100vh; overflow: hidden; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.layout { display: flex; height: 100vh; }
.sidebar { width: 260px; background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; transition: width var(--transition); overflow: hidden; flex-shrink: 0; z-index: 100; }
.sidebar.collapsed { width: 60px; }
.sidebar.collapsed .sidebar-link span, .sidebar.collapsed .sidebar-section span, .sidebar.collapsed .sidebar-heading, .sidebar.collapsed .brand-text { display: none; }
.sidebar.collapsed .brand-logo { margin: 0 auto; }
.sidebar.collapsed .sidebar-link { justify-content: center; padding: 12px; }
.sidebar.collapsed .sidebar-link i { margin: 0; font-size: 18px; }
.sidebar.collapsed .sidebar-section { padding: 8px 0; }
.sidebar-header { padding: 16px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-logo { width: 36px; height: 36px; background: var(--primary); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 18px; flex-shrink: 0; }
.brand-text { font-size: 16px; font-weight: 600; color: #fff; white-space: nowrap; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.sidebar-heading { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; padding: 16px 16px 6px; opacity: .6; }
.sidebar-section { margin-bottom: 4px; }
.sidebar-link { display: flex; align-items: center; gap: 12px; padding: 10px 16px; color: var(--sidebar-text); text-decoration: none; cursor: pointer; transition: all var(--transition); border-left: 3px solid transparent; font-size: 14px; }
.sidebar-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-link.active { background: var(--sidebar-hover); color: #fff; border-left-color: var(--primary); }
.sidebar-link i { width: 20px; text-align: center; font-size: 16px; flex-shrink: 0; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-toggle-btn { background: none; border: none; color: var(--sidebar-text); cursor: pointer; padding: 8px; border-radius: var(--radius-sm); width: 100%; text-align: left; display: flex; align-items: center; gap: 12px; font-size: 14px; }
.sidebar-toggle-btn:hover { background: var(--sidebar-hover); color: #fff; }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.header { background: var(--header-bg); padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); box-shadow: var(--shadow); }
.header-left { display: flex; align-items: center; gap: 16px; }
.header-right { display: flex; align-items: center; gap: 16px; }
.header-title { font-size: 18px; font-weight: 600; }
.theme-btn, .notif-btn { background: none; border: 1px solid var(--border); padding: 8px 12px; border-radius: var(--radius-sm); cursor: pointer; color: var(--text-muted); transition: all var(--transition); }
.theme-btn:hover, .notif-btn:hover { background: var(--bg); color: var(--text); }
.user-info { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; }
.user-name { font-size: 14px; font-weight: 500; }

.content { flex: 1; padding: 24px; overflow-y: auto; }

.page { display: none; }
.page.active { display: block; animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Cards & Stats */
.row { display: grid; gap: 16px; margin-bottom: 20px; }
.row-2 { grid-template-columns: 1fr 1fr; }
.row-3 { grid-template-columns: 1fr 1fr 1fr; }
.row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.row-2-1 { grid-template-columns: 2fr 1fr; }
.row-1-2 { grid-template-columns: 1fr 2fr; }
@media (max-width: 1000px) { .row-4 { grid-template-columns: 1fr 1fr; } .row-2-1, .row-1-2 { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .row-2, .row-3, .row-4 { grid-template-columns: 1fr; } }

.card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }
.stat-card { padding: 20px; display: flex; align-items: flex-start; gap: 16px; }
.stat-icon { width: 48px; height: 48px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.stat-info h4 { font-size: 13px; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.stat-info .value { font-size: 24px; font-weight: 700; }
.stat-info .change { font-size: 12px; margin-top: 2px; }
.stat-info .change.up { color: var(--success); }
.stat-info .change.down { color: var(--danger); }

/* Tables */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th { text-align: left; padding: 10px 12px; border-bottom: 2px solid var(--border); color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; }
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
tbody tr:hover { background: var(--bg); }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; text-transform: capitalize; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #f1f5f9; color: #475569; }
.dark .badge-success { background: #052e16; color: #86efac; }
.dark .badge-warning { background: #451a03; color: #fcd34d; }
.dark .badge-danger { background: #450a0a; color: #fca5a5; }
.dark .badge-info { background: #0c1929; color: #93c5fd; }
.dark .badge-secondary { background: #1e293b; color: #cbd5e1; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius-sm); border: 1px solid transparent; font-size: 13px; font-weight: 500; cursor: pointer; transition: all var(--transition); text-decoration: none; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #16a34a; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--bg); }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; color: var(--text); }
.form-control { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; background: var(--card-bg); color: var(--text); transition: border var(--transition); }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { appearance: auto; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 700px) { .form-row { grid-template-columns: 1fr; } }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: none; align-items: center; justify-content: center; z-index: 1000; }
.modal-overlay.show { display: flex; }
.modal { background: var(--card-bg); border-radius: var(--radius); width: 90%; max-width: 600px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: fadeIn .2s ease; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); padding: 4px; }
.modal-body { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* Toolbar */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }
.search-box { display: flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card-bg); }
.search-box i { padding: 0 10px; color: var(--text-muted); }
.search-box input { border: none; padding: 8px 10px 8px 0; background: transparent; color: var(--text); font-size: 13px; min-width: 200px; }
.search-box input:focus { outline: none; }

/* Empty state */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state i { font-size: 48px; margin-bottom: 16px; opacity: .4; }
.empty-state p { font-size: 14px; }

/* Responsive Grid for forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

.mt-2 { margin-top: 8px; }
.mb-2 { margin-bottom: 8px; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); font-size: 12px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-2 { gap: 8px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chart-container { position: relative; height: 280px; }

/* Login */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.login-card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 40px; width: 400px; max-width: 90%; }
.login-card .brand { text-align: center; margin-bottom: 32px; }
.login-card .brand .brand-logo { margin: 0 auto 12px; width: 56px; height: 56px; font-size: 24px; }
.login-card .brand h1 { font-size: 22px; font-weight: 700; }
.login-card .brand p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* Premium animations */
@keyframes slideIn { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
.card { transition: all .3s ease; }
.card:hover { box-shadow: var(--shadow-lg); }
.stat-card { transition: all .3s ease; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.sidebar-link { position: relative; }
.sidebar-link::after { content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 3px; height: 0; background: var(--primary); transition: height .2s; border-radius: 0 3px 3px 0; }
.sidebar-link.active::after { height: 60%; }
.gradient-bg { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.gradient-green { background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); }
.gradient-orange { background: linear-gradient(135deg, #fa709a 0%, #fee140 100%); }
.gradient-blue { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }
.badge { transition: all .2s; }
.btn { position: relative; overflow: hidden; }
.btn:active { transform: scale(.97); }
.btn::after { content: ''; position: absolute; inset: 0; background: rgba(255,255,255,.2); opacity: 0; transition: opacity .2s; }
.btn:active::after { opacity: 1; }
.modal { animation: scaleIn .25s ease; }

/* Responsive improvements */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: -260px; top: 0; bottom: 0; z-index: 1000; transition: left .3s; }
  .sidebar.mobile-open { left: 0; }
  .sidebar.collapsed { width: 260px; left: -260px; }
  .sidebar.collapsed.mobile-open { left: 0; }
  .sidebar.collapsed .sidebar-link span { display: inline; }
  .sidebar.collapsed .brand-text { display: inline; }
  .sidebar-header { padding: 12px; }
  .content { padding: 12px; }
  .header { padding: 10px 12px; }
  .header-title { font-size: 16px; }
}

/* Print */
@media print {
  .sidebar, .header, .toolbar, .btn { display: none !important; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
