@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap');

/* ═══════════════ CSS VARIABLES ═══════════════ */
:root {
  --primary: #1a56db;
  --primary-light: #eff4ff;
  --primary-dark: #1341b0;
  --success: #0d9488;
  --success-light: #f0fdfa;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --neutral-50: #f9fafb;
  --neutral-100: #f3f4f6;
  --neutral-200: #e5e7eb;
  --neutral-300: #d1d5db;
  --neutral-400: #9ca3af;
  --neutral-500: #6b7280;
  --neutral-600: #4b5563;
  --neutral-700: #374151;
  --neutral-800: #1f2937;
  --neutral-900: #111827;
  --sidebar-w: 240px;
  --header-h: 60px;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 3px rgba(0,0,0,.1),0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1),0 4px 6px rgba(0,0,0,.05);
}

/* ═══════════════ RESET & BASE ═══════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'DM Sans', sans-serif; font-size: 14px; color: var(--neutral-800); display: flex; height: 100vh; overflow: hidden; background: var(--neutral-100); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--neutral-300); border-radius: 999px; }

/* ═══════════════ LAYOUT ═══════════════ */
.sidebar { width: var(--sidebar-w); background: #0f172a; height: 100vh; overflow-y: auto; flex-shrink: 0; display: flex; flex-direction: column; }
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.content { flex: 1; overflow-y: auto; padding: 24px; background: var(--neutral-100); }

/* ═══════════════ SIDEBAR ═══════════════ */
.sidebar-logo { display: flex; align-items: center; gap: 12px; padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-logo-icon { font-size: 28px; }
.sidebar-logo-title { color: white; font-weight: 700; font-size: 16px; }
.sidebar-logo-sub { color: rgba(255,255,255,.4); font-size: 11px; }
.sidebar-nav { flex: 1; padding: 12px 10px; }
.sidebar-section { margin-bottom: 8px; }
.sidebar-section-label { color: rgba(255,255,255,.3); font-size: 10px; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; padding: 12px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 8px; color: rgba(255,255,255,.55); border-radius: 7px; padding: 9px 10px; cursor: pointer; transition: background .15s,color .15s; font-size: 13px; font-weight: 500; text-decoration: none; }
.nav-item:hover { background: rgba(255,255,255,.07); color: white; text-decoration: none; }
.nav-item.active { background: var(--primary); color: white; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-badge { background: var(--danger); color: white; border-radius: 20px; font-size: 10px; padding: 2px 6px; margin-left: auto; font-weight: 700; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 16px; border-top: 1px solid rgba(255,255,255,.08); margin-top: auto; }
.user-info { flex: 1; min-width: 0; }
.user-name { color: white; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: rgba(255,255,255,.4); font-size: 11px; text-transform: capitalize; }
.logout-btn { background: none; border: none; color: rgba(255,255,255,.4); cursor: pointer; font-size: 18px; padding: 4px; border-radius: 4px; transition: color .15s; }
.logout-btn:hover { color: white; }

/* ═══════════════ TOPBAR ═══════════════ */
.topbar { height: var(--header-h); background: white; border-bottom: 1px solid var(--neutral-200); display: flex; align-items: center; padding: 0 24px; gap: 16px; flex-shrink: 0; box-shadow: var(--shadow-sm); }
.topbar-title { font-size: 15px; font-weight: 700; color: var(--neutral-900); flex-shrink: 0; }
.topbar-search { flex: 1; max-width: 360px; }
.search-bar { display: flex; align-items: center; background: var(--neutral-50); border: 1px solid var(--neutral-200); border-radius: 8px; padding: 0 12px; gap: 8px; }
.search-icon { color: var(--neutral-400); font-size: 13px; }
.search-input { border: none; background: none; outline: none; padding: 8px 0; width: 100%; font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.topbar-icon { font-size: 20px; padding: 6px; border-radius: 8px; cursor: pointer; transition: background .15s; }
.topbar-icon:hover { background: var(--neutral-100); text-decoration: none; }

/* ═══════════════ CARDS ═══════════════ */
.card { background: white; border-radius: var(--radius); border: 1px solid var(--neutral-200); box-shadow: var(--shadow-sm); }
.card-header { padding: 14px 20px; border-bottom: 1px solid var(--neutral-100); display: flex; justify-content: space-between; align-items: center; }
.card-body { padding: 20px; }
.card-title { font-size: 13px; font-weight: 700; color: var(--neutral-900); }

/* Stat cards */
.stat-card { background: white; border-radius: var(--radius); border: 1px solid var(--neutral-200); box-shadow: var(--shadow-sm); padding: 20px; display: flex; align-items: center; gap: 16px; }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.stat-label { font-size: 12px; color: var(--neutral-500); font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--neutral-900); line-height: 1; margin-top: 4px; }

/* ═══════════════ TABLES ═══════════════ */
table { width: 100%; border-collapse: collapse; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; color: var(--neutral-500); background: var(--neutral-50); padding: 10px 16px; text-align: left; white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--neutral-100); color: var(--neutral-800); vertical-align: middle; }
tbody tr:hover td { background: var(--neutral-50); }
tbody tr:last-child td { border-bottom: none; }

/* ═══════════════ BADGES ═══════════════ */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-gray { background: var(--neutral-100); color: var(--neutral-600); }
.badge-teal { background: #ccfbf1; color: #0f766e; }
.badge-violet { background: #ede9fe; color: #6d28d9; }
.badge-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ═══════════════ BUTTONS ═══════════════ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; border: none; transition: background .15s, color .15s, box-shadow .15s; white-space: nowrap; text-decoration: none; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); color: white; }
.btn-outline { background: white; color: var(--neutral-700); border: 1px solid var(--neutral-200); }
.btn-outline:hover { background: var(--neutral-50); border-color: var(--neutral-300); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #0f766e; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }

/* ═══════════════ FORMS ═══════════════ */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }
.form-label { font-size: 13px; font-weight: 600; color: var(--neutral-700); }
.form-input { padding: 9px 12px; border: 1.5px solid var(--neutral-200); border-radius: 8px; outline: none; background: white; transition: border-color .15s; }
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,.1); }
.form-input-sm { padding: 5px 8px; font-size: 12px; }
.form-select { padding: 9px 12px; border: 1.5px solid var(--neutral-200); border-radius: 8px; outline: none; background: white; cursor: pointer; transition: border-color .15s; }
.form-select:focus { border-color: var(--primary); }
.form-select-sm { padding: 5px 8px; font-size: 12px; }
.form-textarea { padding: 9px 12px; border: 1.5px solid var(--neutral-200); border-radius: 8px; outline: none; background: white; resize: vertical; transition: border-color .15s; min-height: 80px; }
.form-textarea:focus { border-color: var(--primary); }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; min-width: 0; }

/* Password toggle */
.input-password-wrapper { position: relative; display: flex; }
.input-password-wrapper .form-input { flex: 1; padding-right: 44px; }
.toggle-password { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; font-size: 18px; padding: 4px; color: var(--neutral-400); }

/* ═══════════════ ALERTS ═══════════════ */
.alert { padding: 12px 16px; border-radius: 8px; border-left: 4px solid; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; font-size: 13px; }
.alert-success { background: var(--success-light); border-color: var(--success); color: #065f46; }
.alert-danger { background: var(--danger-light); border-color: var(--danger); color: #991b1b; }
.alert-warning { background: var(--warning-light); border-color: var(--warning); color: #78350f; }
.alert-info { background: var(--primary-light); border-color: var(--primary); color: #1e40af; }
.alert-close { background: none; border: none; cursor: pointer; font-size: 14px; opacity: 0.6; flex-shrink: 0; padding: 0; }
.alert-close:hover { opacity: 1; }
.flash-msg { margin-bottom: 12px; }

/* ═══════════════ GRID ═══════════════ */
.grid { display: grid; gap: 20px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g13 { grid-template-columns: 1fr 2fr; }
.g31 { grid-template-columns: 2fr 1fr; }

/* ═══════════════ AVATAR ═══════════════ */
.avatar { border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; color: white; flex-shrink: 0; font-size: 12px; }
.avatar-sm { width: 32px; height: 32px; font-size: 11px; }
.avatar-lg { width: 52px; height: 52px; font-size: 18px; }

/* ═══════════════ PROGRESS BAR ═══════════════ */
.progress-bar { height: 8px; background: var(--neutral-100); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s; }

/* ═══════════════ TABS ═══════════════ */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--neutral-200); }
.tab { padding: 10px 18px; font-size: 13px; font-weight: 600; color: var(--neutral-500); border-bottom: 2px solid transparent; margin-bottom: -2px; cursor: pointer; transition: color .15s,border-color .15s; text-decoration: none; }
.tab:hover { color: var(--primary); text-decoration: none; }
.tab.active { color: var(--primary); border-color: var(--primary); }

/* ═══════════════ FILTER BAR ═══════════════ */
.filter-bar { padding: 12px 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; width: 100%; }

/* ═══════════════ INFO ROW ═══════════════ */
.info-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--neutral-100); font-size: 13px; gap: 12px; }
.info-row:last-child { border-bottom: none; }
.info-row span:first-child { color: var(--neutral-500); flex-shrink: 0; }

/* ═══════════════ TIMELINE ═══════════════ */
.timeline { position: relative; padding-left: 20px; }
.tl-item { display: flex; gap: 12px; margin-bottom: 16px; position: relative; }
.tl-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; border: 2px solid white; box-shadow: 0 0 0 2px var(--neutral-300); }
.tl-dot-green { background: var(--success); box-shadow: 0 0 0 2px var(--success); }
.tl-dot-blue { background: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.tl-dot-red { background: var(--danger); box-shadow: 0 0 0 2px var(--danger); }
.tl-dot-amber { background: var(--warning); box-shadow: 0 0 0 2px var(--warning); }
.tl-dot-gray { background: var(--neutral-400); box-shadow: 0 0 0 2px var(--neutral-400); }
.tl-content { flex: 1; }
.tl-title { font-size: 13px; font-weight: 600; }
.tl-time { color: var(--neutral-500); font-size: 11px; }

/* ═══════════════ PAGE HEADER ═══════════════ */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; flex-wrap: wrap; gap: 12px; }
.page-header-title { font-size: 20px; font-weight: 700; color: var(--neutral-900); }
.page-header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ═══════════════ EMPTY STATE ═══════════════ */
.empty-state { text-align: center; padding: 48px 24px; color: var(--neutral-500); }
.empty-state span { font-size: 48px; display: block; margin-bottom: 12px; }
.empty-state p { font-size: 14px; margin-bottom: 16px; }

/* ═══════════════ CHART BARS ═══════════════ */
.chart-bars { display: flex; align-items: flex-end; gap: 8px; height: 120px; }
.chart-bar-col { display: flex; flex-direction: column; align-items: center; flex: 1; }
.chart-bar-label { font-size: 10px; color: var(--neutral-500); margin-bottom: 4px; }
.chart-bar-wrap { flex: 1; width: 100%; background: var(--neutral-100); border-radius: 4px 4px 0 0; display: flex; align-items: flex-end; min-height: 4px; }
.chart-bar-fill { width: 100%; background: var(--primary); border-radius: 4px 4px 0 0; transition: height .3s; min-height: 4px; }
.chart-bar-date { font-size: 10px; color: var(--neutral-400); margin-top: 4px; }

/* ═══════════════ PAGINATION ═══════════════ */
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 16px; border-top: 1px solid var(--neutral-100); }
.pag-info { font-size: 13px; color: var(--neutral-500); }

/* ═══════════════ AUTH PAGE ═══════════════ */
.auth-body { display: block; height: 100vh; background: #0f172a; overflow-y: auto; }
.auth-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { background: white; border-radius: 16px; padding: 40px; width: 100%; max-width: 420px; box-shadow: var(--shadow-lg); animation: fadeIn .3s ease; }
.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo-icon { font-size: 48px; display: block; margin-bottom: 8px; }
.auth-title { font-size: 24px; font-weight: 700; color: var(--neutral-900); margin: 0; }
.auth-subtitle { font-size: 14px; color: var(--neutral-500); margin: 4px 0 0; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-hint { text-align: center; font-size: 12px; color: var(--neutral-400); margin-top: 24px; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ═══════════════ UTILITIES ═══════════════ */
.text-sm { font-size: 12px; }
.text-mono { font-family: 'Courier New', monospace; }
.fw600 { font-weight: 600; }
.fw700 { font-weight: 700; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.mt8 { margin-top: 8px; }
.mt16 { margin-top: 16px; }
.mt20 { margin-top: 20px; }
.mb16 { margin-bottom: 16px; }

/* ═══════════════ RESPONSIVE ═══════════════ */
@media (max-width: 1024px) {
  .g4 { grid-template-columns: repeat(2, 1fr); }
  .g3 { grid-template-columns: repeat(2, 1fr); }
  .g13, .g31 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { display: none; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px; }
}
