@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css');
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-bg: #1a1f2e;
  --sidebar-hover: #252d40;
  --sidebar-active: #3b5bdb;
  --primary: #3b5bdb;
  --primary-hover: #2f4ac4;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f97316;
  --info: #3b82f6;
  --text-dark: #1e293b;
  --text-medium: #475569;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --bg: #f1f5f9;
  --white: #ffffff;
  --card-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --card-shadow-hover: 0 4px 12px rgba(0,0,0,.12);
  --radius: 10px;
  --radius-sm: 6px;
}

body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; background: var(--bg); color: var(--text-dark); font-size: 14px; line-height: 1.5; }

a { text-decoration: none; color: inherit; }

button { cursor: pointer; border: none; outline: none; }

input, select, textarea { outline: none; font-family: inherit; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 10px; }

/* Layout */
.dashboard-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 18px;
}

.sidebar-logo .logo-text { color: white; font-weight: 700; font-size: 15px; line-height: 1.2; }
.sidebar-logo .logo-text span { display: block; font-size: 10px; font-weight: 400; color: rgba(255,255,255,.5); }

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,.3);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 12px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,.65);
  font-size: 13.5px;
  transition: all .15s;
  cursor: pointer;
  border-left: 3px solid transparent;
}

.nav-item:hover { background: var(--sidebar-hover); color: white; }
.nav-item.active { background: rgba(59,91,219,.15); color: white; border-left-color: var(--primary); }
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-item .nav-badge { margin-left: auto; background: var(--danger); color: white; font-size: 10px; padding: 2px 6px; border-radius: 10px; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.08); }

/* Main content */
.main-content { margin-left: 240px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-title { font-size: 18px; font-weight: 700; color: var(--text-dark); }
.topbar-subtitle { font-size: 12px; color: var(--text-light); }

.topbar-right { display: flex; align-items: center; gap: 16px; }

.topbar-icon-btn {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  color: var(--text-medium);
  cursor: pointer;
  position: relative;
  transition: all .15s;
}

.topbar-icon-btn:hover { background: var(--border); }
.topbar-icon-btn .badge { position: absolute; top: -4px; right: -4px; width: 16px; height: 16px; background: var(--danger); border-radius: 50%; font-size: 9px; color: white; display: flex; align-items: center; justify-content: center; }

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.user-info { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.user-info .user-name { font-weight: 600; font-size: 13px; }
.user-info .user-role { font-size: 11px; color: var(--text-light); }

/* Content area */
.content-area { padding: 24px; flex: 1; }

/* Stats cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow .2s;
}

.stat-card:hover { box-shadow: var(--card-shadow-hover); }

.stat-card .stat-label { font-size: 12px; color: var(--text-light); font-weight: 500; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; color: var(--text-dark); }
.stat-card .stat-change { font-size: 12px; display: flex; align-items: center; gap: 4px; }
.stat-card .stat-change.up { color: var(--success); }
.stat-card .stat-change.down { color: var(--danger); }
.stat-card .stat-icon { width: 42px; height: 42px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 20px; }

.stat-card-row { display: flex; align-items: flex-start; justify-content: space-between; }

/* Cards */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title { font-weight: 700; font-size: 15px; }
.card-body { padding: 20px; }

/* Tables */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
thead th { font-size: 11px; font-weight: 600; color: var(--text-light); text-transform: uppercase; letter-spacing: .04em; padding: 10px 16px; background: var(--bg); text-align: left; border-bottom: 1px solid var(--border); }
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13.5px; color: var(--text-dark); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}

.badge-success { background: #dcfce7; color: #16a34a; }
.badge-danger { background: #fee2e2; color: #dc2626; }
.badge-warning { background: #fff7ed; color: #c2410c; }
.badge-info { background: #dbeafe; color: #1d4ed8; }
.badge-gray { background: #f1f5f9; color: #64748b; }
.badge-purple { background: #f3e8ff; color: #7e22ce; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  transition: all .15s;
  cursor: pointer;
  border: none;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-dark); }
.btn-outline:hover { background: var(--bg); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-medium); margin-bottom: 6px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  background: var(--white);
  color: var(--text-dark);
  transition: border-color .15s;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,91,219,.1); }

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal {
  background: var(--white);
  border-radius: 14px;
  width: 100%; max-width: 480px;
  box-shadow: 0 20px 40px rgba(0,0,0,.2);
  transform: scale(.95);
  transition: transform .2s;
}
.modal-overlay.active .modal { transform: scale(1); }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header .modal-title { font-size: 16px; font-weight: 700; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* Avatar */
.avatar { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: white; flex-shrink: 0; }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 6px; justify-content: flex-end; padding: 16px; }
.page-btn { width: 32px; height: 32px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--white); display: flex; align-items: center; justify-content: center; font-size: 13px; cursor: pointer; transition: all .15s; }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.page-btn:hover:not(.active) { background: var(--bg); }

/* Toast */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text-dark); color: white; padding: 12px 20px; border-radius: var(--radius-sm); font-size: 13px; box-shadow: 0 4px 12px rgba(0,0,0,.2); display: flex; align-items: center; gap: 10px; animation: slideIn .3s; min-width: 250px; }
.toast.success { background: #16a34a; }
.toast.error { background: #dc2626; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Empty state */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-light); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* Search bar */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  min-width: 220px;
}
.search-bar input { background: none; border: none; font-size: 13px; color: var(--text-dark); flex: 1; }
.search-bar input::placeholder { color: var(--text-light); }

/* Section header */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.section-title { font-size: 16px; font-weight: 700; }

/* Login page */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.auth-card { background: var(--white); border-radius: 16px; padding: 40px; width: 100%; max-width: 420px; box-shadow: 0 4px 24px rgba(0,0,0,.1); }
.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo .logo-big { font-size: 36px; }
.auth-logo h2 { font-size: 22px; font-weight: 800; margin-top: 8px; }
.auth-logo p { color: var(--text-light); font-size: 13px; margin-top: 4px; }

/* Charts */
.chart-bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; }
.chart-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.chart-bar { width: 100%; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 4px; transition: height .3s; }
.chart-bar-label { font-size: 10px; color: var(--text-light); white-space: nowrap; }

/* Status dot */
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--success); }
.dot-red { background: var(--danger); }
.dot-orange { background: var(--warning); }
.dot-blue { background: var(--info); }

/* Mobile responsive */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .3s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
