/* =====================================================
   AL ADAB CBT SYSTEM - MAIN DESIGN SYSTEM
   Sekolah Islam Al Adab
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Amiri:ital,wght@0,400;0,700;1,400&display=swap');

/* ─── CSS VARIABLES / DESIGN TOKENS ─── */
:root {
  /* Primary Palette */
  --primary: #1E88E5;
  --primary-dark: #1565C0;
  --primary-light: #42A5F5;
  --primary-50: #E3F2FD;
  --primary-100: #BBDEFB;
  --primary-200: #90CAF9;

  /* Semantic Colors */
  --success: #2E7D32;
  --success-light: #4CAF50;
  --success-bg: #E8F5E9;
  --warning: #E65100;
  --warning-light: #FF9800;
  --warning-bg: #FFF3E0;
  --danger: #C62828;
  --danger-light: #F44336;
  --danger-bg: #FFEBEE;
  --info: #0277BD;
  --info-light: #29B6F6;
  --info-bg: #E1F5FE;

  /* Neutral Palette */
  --white: #FFFFFF;
  --gray-50: #FAFAFA;
  --gray-100: #F5F5F5;
  --gray-200: #EEEEEE;
  --gray-300: #E0E0E0;
  --gray-400: #BDBDBD;
  --gray-500: #9E9E9E;
  --gray-600: #757575;
  --gray-700: #616161;
  --gray-800: #424242;
  --gray-900: #212121;

  /* Background */
  --bg-primary: #F8FAFF;
  --bg-card: #FFFFFF;
  --bg-sidebar: #0D2137;
  --bg-sidebar-hover: #1a3a5c;
  --bg-sidebar-active: #1E88E5;

  /* Text */
  --text-primary: #1A2332;
  --text-secondary: #5A6A7A;
  --text-muted: #8A9BB0;
  --text-inverse: #FFFFFF;
  --text-link: #1E88E5;

  /* Border */
  --border-color: #E2E8F0;
  --border-radius-sm: 6px;
  --border-radius: 12px;
  --border-radius-lg: 16px;
  --border-radius-xl: 24px;
  --border-radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  --shadow-xl: 0 25px 50px -12px rgba(0,0,0,0.15);
  --shadow-primary: 0 4px 14px 0 rgba(30,136,229,0.3);
  --shadow-card: 0 2px 20px rgba(0,0,0,0.06);

  /* Transitions */
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Spacing */
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --topbar-height: 64px;

  /* Z-index */
  --z-sidebar: 100;
  --z-topbar: 90;
  --z-modal: 200;
  --z-tooltip: 300;
  --z-toast: 400;
}

/* ─── DARK MODE TOKENS ─── */
[data-theme="dark"] {
  --bg-primary: #0A1929;
  --bg-card: #132237;
  --bg-sidebar: #071525;
  --bg-sidebar-hover: #1a3a5c;
  --text-primary: #E8F4FD;
  --text-secondary: #9DB8CC;
  --text-muted: #607890;
  --border-color: #1E3A52;
  --gray-100: #132237;
  --gray-200: #1E3A52;
  --gray-300: #2A4D6B;
  --shadow-card: 0 2px 20px rgba(0,0,0,0.3);
}

/* ─── RESET & BASE ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
  overflow-x: hidden;
}

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ─── TYPOGRAPHY ─── */
h1, h2, h3, h4, h5, h6 { font-weight: 700; line-height: 1.3; color: var(--text-primary); }
h1 { font-size: 2.25rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.375rem; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

p { color: var(--text-secondary); }
a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

/* ─── APP LAYOUT ─── */
#app { display: flex; min-height: 100vh; }

/* ─── SIDEBAR ─── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  min-height: var(--topbar-height);
}

.brand-logo {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(30,136,229,0.4);
  overflow: hidden;
}

.brand-logo img { width: 100%; height: 100%; object-fit: cover; }
.brand-logo i { color: white; font-size: 18px; }

.brand-text { overflow: hidden; }
.brand-name {
  font-size: 0.9rem;
  font-weight: 800;
  color: #FFFFFF;
  white-space: nowrap;
  line-height: 1.2;
  letter-spacing: -0.3px;
}
.brand-sub {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.5);
  white-space: nowrap;
  font-weight: 400;
  margin-top: 1px;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0;
}

.nav-section-label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,0.3);
  padding: 8px 20px 4px;
  white-space: nowrap;
  overflow: hidden;
  transition: var(--transition);
}

.sidebar.collapsed .nav-section-label { opacity: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  transition: var(--transition);
  border-radius: 0;
  margin: 1px 10px;
  border-radius: 10px;
  position: relative;
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: #FFFFFF;
}

.nav-item.active {
  background: var(--primary);
  color: #FFFFFF;
  box-shadow: var(--shadow-primary);
}

.nav-item i {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item span { font-size: 0.85rem; font-weight: 500; }

.nav-badge {
  margin-left: auto;
  background: var(--danger-light);
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 99px;
  min-width: 18px;
  text-align: center;
}

.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-badge { display: none; }

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition);
}

.user-card:hover { background: rgba(255,255,255,0.07); }

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.user-info { overflow: hidden; }
.user-name { font-size: 0.8rem; font-weight: 600; color: white; white-space: nowrap; }
.user-role { font-size: 0.65rem; color: rgba(255,255,255,0.4); white-space: nowrap; }

.sidebar.collapsed .user-info { display: none; }

/* ─── MAIN CONTENT ─── */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-wrapper.sidebar-collapsed { margin-left: var(--sidebar-collapsed); }

/* ─── TOPBAR ─── */
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  height: var(--topbar-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: background 0.3s;
}

.topbar-toggle {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}

.topbar-toggle:hover { background: var(--gray-100); color: var(--primary); }

.topbar-search {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.topbar-search i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
}

.topbar-search input {
  width: 100%;
  padding: 9px 16px 9px 38px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition);
  font-family: inherit;
}

.topbar-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30,136,229,0.1);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
  position: relative;
  font-size: 15px;
}

.topbar-btn:hover { background: var(--gray-100); color: var(--primary); }

.notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--danger-light);
  border: 2px solid var(--bg-card);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid var(--border-color);
}

.topbar-user:hover { background: var(--gray-100); }

.topbar-avatar {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 12px;
}

.topbar-username { font-size: 0.82rem; font-weight: 600; }
.topbar-userrole { font-size: 0.7rem; color: var(--text-muted); }

/* ─── PAGE CONTENT ─── */
.page-content {
  flex: 1;
  padding: 28px;
  animation: pageIn 0.2s ease;
}

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

.page-header {
  margin-bottom: 24px;
}

.page-header-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.page-title { font-size: 1.5rem; font-weight: 800; margin-bottom: 2px; }
.page-subtitle { font-size: 0.85rem; color: var(--text-muted); }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.breadcrumb span { color: var(--text-muted); }
.breadcrumb .current { color: var(--primary); font-weight: 500; }

/* ─── CARDS ─── */
.card {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-card);
  transition: var(--transition);
  overflow: hidden;
}

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

.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title i { color: var(--primary); font-size: 16px; }

.card-body { padding: 22px; }

.card-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-color);
  background: var(--gray-50);
}

/* ─── KPI CARDS ─── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--border-color);
  padding: 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-card);
  transition: var(--transition-bounce);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--kpi-color, var(--primary));
}

.kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.kpi-icon {
  width: 54px; height: 54px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  background: var(--kpi-bg, var(--primary-50));
  color: var(--kpi-color, var(--primary));
  flex-shrink: 0;
}

.kpi-info { flex: 1; min-width: 0; }
.kpi-value { font-size: 1.75rem; font-weight: 800; line-height: 1; margin-bottom: 4px; }
.kpi-label { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; }
.kpi-change {
  font-size: 0.72rem;
  font-weight: 600;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 3px;
}
.kpi-change.up { color: var(--success-light); }
.kpi-change.down { color: var(--danger-light); }

/* ─── GRID LAYOUTS ─── */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-1-2 { grid-template-columns: 1fr 2fr; }
.grid-2-1 { grid-template-columns: 2fr 1fr; }

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  font-family: inherit;
  white-space: nowrap;
  text-decoration: none;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 6px 20px rgba(30,136,229,0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--gray-100);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover { background: var(--gray-200); }

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover { background: var(--success-light); }

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover { background: var(--danger-light); }

.btn-warning {
  background: var(--warning);
  color: white;
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary);
}

.btn-outline:hover { background: var(--primary-50); }

.btn-sm { padding: 6px 12px; font-size: 0.78rem; border-radius: 8px; gap: 5px; }
.btn-lg { padding: 12px 24px; font-size: 0.95rem; border-radius: 12px; }
.btn-icon { padding: 9px; aspect-ratio: 1; }
.btn-icon.btn-sm { padding: 6px; }

/* ─── FORM ELEMENTS ─── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-label .required { color: var(--danger-light); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 9px 14px;
  border: 1.5px solid var(--border-color);
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--text-primary);
  background: var(--bg-card);
  outline: none;
  transition: var(--transition);
  font-family: inherit;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30,136,229,0.1);
}

.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }

.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

.form-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 0.75rem; color: var(--danger-light); margin-top: 4px; }

/* Checkbox / Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.85rem;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 16px; height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ─── TABLES ─── */
.table-wrapper {
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
}

.table-toolbar {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-color);
}

.table-search {
  position: relative;
  min-width: 220px;
}

.table-search i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
}

.table-search input {
  padding: 7px 12px 7px 32px;
  border: 1.5px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.82rem;
  outline: none;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: inherit;
  transition: var(--transition);
  width: 100%;
}

.table-search input:focus { border-color: var(--primary); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

thead {
  background: var(--gray-50);
  border-bottom: 2px solid var(--border-color);
}

th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }

/* ─── BADGES ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--border-radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-primary { background: var(--primary-50); color: var(--primary-dark); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-gray { background: var(--gray-200); color: var(--gray-700); }

/* ─── MODAL ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg-card);
  border-radius: var(--border-radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalSlide 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-lg { max-width: 780px; }
.modal-xl { max-width: 1000px; }

@keyframes modalSlide {
  from { transform: scale(0.92) translateY(16px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title { font-size: 1.05rem; font-weight: 700; }

.modal-close {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: none;
  background: var(--gray-100);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
  font-size: 14px;
}

.modal-close:hover { background: var(--danger-bg); color: var(--danger); }

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

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* ─── TABS ─── */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--gray-100);
  border-radius: 12px;
  padding: 4px;
  width: fit-content;
}

.tab-btn {
  padding: 8px 18px;
  border-radius: 9px;
  border: none;
  background: transparent;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--primary);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

/* ─── PROGRESS ─── */
.progress {
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 3px;
  background: var(--primary);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-bar.success { background: var(--success-light); }
.progress-bar.warning { background: var(--warning-light); }
.progress-bar.danger { background: var(--danger-light); }

/* ─── AVATAR ─── */
.avatar {
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 32px; height: 32px; font-size: 12px; border-radius: 8px; }
.avatar-md { width: 40px; height: 40px; font-size: 14px; border-radius: 10px; }
.avatar-lg { width: 56px; height: 56px; font-size: 20px; border-radius: 14px; }
.avatar-xl { width: 80px; height: 80px; font-size: 28px; border-radius: 18px; }

/* ─── STATUS INDICATORS ─── */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.online { background: var(--success-light); box-shadow: 0 0 0 2px rgba(76,175,80,0.2); }
.status-dot.offline { background: var(--gray-400); }
.status-dot.warning { background: var(--warning-light); }
.status-dot.danger { background: var(--danger-light); }

/* ─── TOASTS ─── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px 18px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  max-width: 380px;
  animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-left: 4px solid var(--primary);
}

@keyframes toastIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast.success { border-left-color: var(--success-light); }
.toast.error { border-left-color: var(--danger-light); }
.toast.warning { border-left-color: var(--warning-light); }

.toast-icon { font-size: 18px; }
.toast.success .toast-icon { color: var(--success-light); }
.toast.error .toast-icon { color: var(--danger-light); }
.toast.warning .toast-icon { color: var(--warning-light); }
.toast-info { font-size: 13px; flex: 1; }
.toast-title { font-weight: 700; font-size: 0.85rem; }
.toast-msg { color: var(--text-muted); font-size: 0.8rem; }

/* ─── DROPDOWN ─── */
.dropdown { position: relative; }

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: var(--z-tooltip);
  overflow: hidden;
  animation: dropIn 0.15s ease;
}

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 0.84rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.dropdown-item:hover { background: var(--gray-100); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-bg); }
.dropdown-divider { height: 1px; background: var(--border-color); margin: 4px 0; }

/* ─── EMPTY STATE ─── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
}

.empty-state-icon {
  font-size: 48px;
  color: var(--gray-300);
  margin-bottom: 16px;
}

.empty-state-title { font-size: 1rem; font-weight: 700; margin-bottom: 8px; }
.empty-state-text { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 20px; }

/* ─── UTILITY CLASSES ─── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-5 { gap: 20px; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-primary-color { color: var(--primary); }
.text-success { color: var(--success-light); }
.text-danger { color: var(--danger-light); }
.text-warning { color: var(--warning-light); }
.fw-bold { font-weight: 700; }
.fw-600 { font-weight: 600; }
.fs-sm { font-size: 0.82rem; }
.fs-xs { font-size: 0.72rem; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }
.mb-6 { margin-bottom: 24px; }
.hidden { display: none !important; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rounded-full { border-radius: 9999px; }
.cursor-pointer { cursor: pointer; }

/* ─── LOADING SPINNER ─── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

.page-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ─── RESPONSIVE ─── */
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root {
    --sidebar-width: 260px;
  }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }

  .main-wrapper { margin-left: 0 !important; }

  .page-content { padding: 16px; }

  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }

  .grid-2, .grid-1-2, .grid-2-1 { grid-template-columns: 1fr; }

  .grid-3 { grid-template-columns: repeat(2, 1fr); }

  .form-row, .form-row-3 { grid-template-columns: 1fr; }

  .topbar-search { display: none; }

  .modal { max-width: 100%; margin: 0; border-radius: 20px 20px 0 0; align-self: flex-end; }
  .modal-overlay { align-items: flex-end; padding: 0; }

  .mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: calc(var(--z-sidebar) - 1);
    display: none;
  }

  .mobile-overlay.show { display: block; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  h1 { font-size: 1.6rem; }
}

/* ─── PRINT STYLES ─── */
@media print {
  .sidebar, .topbar, .toast-container { display: none !important; }
  .main-wrapper { margin-left: 0 !important; }
  .page-content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ─── ANIMATE HELPERS ─── */
.fade-in { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.slide-up { animation: slideUp 0.3s ease; }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ─── CHART CONTAINER ─── */
.chart-container { position: relative; }
.chart-container canvas { max-width: 100%; }
