/* ============================================================
   PrepAI — Design System v3 (Premium Clean)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;0,800&family=Inter:wght@400;500;600&display=swap');

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  /* Primary brand */
  --primary:        #1468E8;
  --primary-hover:  #0F59C8;
  --primary-dark:   #0D4DB0;
  --primary-light:  #EBF2FD;

  /* Semantic */
  --success:        #18A96B;
  --success-light:  #E6F7EF;
  --success-dark:   #127A4D;
  --warning:        #F59E0B;
  --warning-light:  #FEF3C7;
  --warning-dark:   #B45309;
  --danger:         #E5484D;
  --danger-light:   #FDECEA;
  --danger-dark:    #B81C21;
  --info:           #0BA5EC;
  --info-light:     #E0F2FE;
  --info-dark:      #0369A1;
  --purple:         #7C3AED;
  --purple-light:   #EDE9FE;
  --purple-dark:    #5B21B6;

  /* Sidebar */
  --sidebar-bg:           #071A33;
  --sidebar-bg-2:         #0B2342;
  --sidebar-text:         #D8E2F0;
  --sidebar-muted:        #7F91AA;
  --sidebar-active-bg:    #1468E8;
  --sidebar-active-text:  #FFFFFF;
  --sidebar-hover-bg:     rgba(255,255,255,0.07);
  --sidebar-border:       rgba(255,255,255,0.08);
  --sidebar-w:            260px;

  /* Surfaces */
  --bg-page:    #F6F8FB;
  --bg-surface: #FFFFFF;
  --border:     #E5EAF1;
  --border-dark: #D0D7E3;

  /* Text */
  --text-primary:   #0B1F3A;
  --text-secondary: #5E6B7E;
  --text-muted:     #8A96A8;

  /* Typography */
  --font-display: 'Plus Jakarta Sans', -apple-system, sans-serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  1.875rem;
  --text-4xl:  2.25rem;

  /* Spacing */
  --sp-1: 0.25rem;  --sp-2: 0.5rem;   --sp-3: 0.75rem;
  --sp-4: 1rem;     --sp-5: 1.25rem;  --sp-6: 1.5rem;
  --sp-8: 2rem;     --sp-10: 2.5rem;  --sp-12: 3rem;
  --sp-16: 4rem;

  /* Border radius */
  --r-sm:   6px;
  --r-md:   10px;
  --r-lg:   14px;
  --r-xl:   18px;
  --r-2xl:  24px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 1px 4px rgba(11,31,58,0.06), 0 1px 2px rgba(11,31,58,0.04);
  --shadow-md:  0 4px 16px rgba(11,31,58,0.08), 0 1px 4px rgba(11,31,58,0.04);
  --shadow-lg:  0 8px 32px rgba(11,31,58,0.10), 0 2px 8px rgba(11,31,58,0.05);
  --shadow-xl:  0 20px 48px rgba(11,31,58,0.12), 0 4px 16px rgba(11,31,58,0.07);

  /* Transitions */
  --t-fast:  150ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-base:  220ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow:  350ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Backward-compat aliases (used in inline HTML styles) */
  --color-primary:        var(--primary);
  --color-primary-dark:   var(--primary-dark);
  --color-primary-light:  var(--primary-light);
  --color-secondary:      var(--primary);
  --color-success:        var(--success);
  --color-success-light:  var(--success-light);
  --color-warning:        var(--warning);
  --color-warning-light:  var(--warning-light);
  --color-danger:         var(--danger);
  --color-danger-light:   var(--danger-light);
  --color-info:           var(--info);
  --color-info-light:     var(--info-light);
  --color-text-primary:   var(--text-primary);
  --color-text-secondary: var(--text-secondary);
  --color-text-muted:     var(--text-muted);
  --color-border:         var(--border);
  --color-bg-page:        var(--bg-page);
  --color-bg-card:        var(--bg-surface);
  --color-surface:        var(--bg-surface);
  --color-sidebar-text:   var(--sidebar-text);
  --color-sidebar-active: var(--sidebar-active-bg);
  --transition-fast:      var(--t-fast);
  --transition-base:      var(--t-base);
  --transition-slow:      var(--t-slow);
  --radius-sm:   var(--r-sm);
  --radius-md:   var(--r-md);
  --radius-lg:   var(--r-lg);
  --radius-xl:   var(--r-xl);
  --radius-2xl:  var(--r-2xl);
  --radius-full: var(--r-full);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-page);
  margin: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--t-fast);
}
a:hover { color: var(--primary-hover); }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.25;
  margin-top: 0;
  color: var(--text-primary);
}

/* Custom spacing not in Bootstrap */
.mb-6 { margin-bottom: 1.5rem !important; }
.mt-6 { margin-top: 1.5rem !important; }
.gap-6 { gap: 1.5rem !important; }

/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.app-sidebar {
  width: var(--sidebar-w);
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 200;
  scrollbar-width: none;
  transition: transform var(--t-base);
}
.app-sidebar::-webkit-scrollbar { display: none; }

/* Brand / logo */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-5);
  border-bottom: 1px solid var(--sidebar-border);
  min-height: 68px;
  flex-shrink: 0;
}

.sidebar-logo-mark {
  width: 36px;
  height: 36px;
  background-color: var(--primary);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-family: var(--font-display);
  font-size: 0.8rem;
  color: #fff;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.sidebar-brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-sm);
  color: #fff;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.sidebar-brand-tagline {
  font-size: 0.65rem;
  color: var(--sidebar-muted);
  letter-spacing: 0.01em;
}

/* Nav */
.sidebar-nav {
  padding: var(--sp-3) 0;
  flex: 1;
}

.sidebar-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--sidebar-muted);
  padding: var(--sp-4) var(--sp-5) var(--sp-2);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0.6rem var(--sp-4);
  margin: 1px var(--sp-3);
  color: var(--sidebar-text);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--r-md);
  transition: background var(--t-fast), color var(--t-fast);
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: transparent;
  width: calc(100% - 1.5rem);
}

.sidebar-link:hover {
  background: var(--sidebar-hover-bg);
  color: #fff;
}

.sidebar-link.active {
  background-color: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
}

.sidebar-link.active i { opacity: 1; }

.sidebar-link i {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  font-size: 1rem;
  opacity: 0.75;
  transition: opacity var(--t-fast);
}
.sidebar-link:hover i { opacity: 1; }

/* Footer */
.sidebar-footer {
  border-top: 1px solid var(--sidebar-border);
  padding: var(--sp-4);
  flex-shrink: 0;
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-2);
  border-radius: var(--r-md);
  background: rgba(255,255,255,0.06);
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  background-color: var(--primary);
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-family: var(--font-display);
  font-size: 0.75rem;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-display);
  line-height: 1.2;
}

.sidebar-user-role {
  font-size: 0.7rem;
  color: var(--sidebar-muted);
  letter-spacing: 0.02em;
}

/* ============================================================
   SIDEBAR OVERLAY (mobile)
   ============================================================ */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7,26,51,0.5);
  z-index: 199;
  animation: fade-in var(--t-base) forwards;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ============================================================
   APP MAIN
   ============================================================ */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background-color: var(--bg-page);
}

/* ============================================================
   TOPBAR
   ============================================================ */
.app-topbar {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-8);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: var(--sp-4);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  min-width: 0;
}

.topbar-toggle {
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  flex-shrink: 0;
  font-size: 1.1rem;
}
.topbar-toggle:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.topbar-title-wrap { min-width: 0; }
.breadcrumb-app {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: 1px;
}
.breadcrumb-app a { color: var(--primary); opacity: 0.8; }
.breadcrumb-app a:hover { opacity: 1; }

.app-topbar-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: linear-gradient(120deg, var(--text-primary) 0%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Topbar search */
.topbar-center { flex: 1; max-width: 400px; margin: 0 var(--sp-4); }

.topbar-search {
  position: relative;
  width: 100%;
}

.topbar-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.875rem;
  pointer-events: none;
}

.topbar-search-input {
  width: 100%;
  height: 38px;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: 0 var(--sp-4) 0 2.25rem;
  font-size: var(--text-sm);
  font-family: var(--font-body);
  color: var(--text-primary);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  outline: none;
}
.topbar-search-input::placeholder { color: var(--text-muted); }
.topbar-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(20,104,232,0.1);
  background: var(--bg-surface);
}

/* Topbar right actions */
.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-shrink: 0;
}

.topbar-icon-btn {
  position: relative;
  width: 38px;
  height: 38px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--t-fast);
  font-size: 1rem;
}
.topbar-icon-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.topbar-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: var(--r-full);
  border: 2px solid var(--bg-surface);
}

/* User button */
.topbar-user-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: all var(--t-fast);
}
.topbar-user-btn:hover {
  background: var(--bg-page);
  border-color: var(--border-dark);
}
.topbar-user-btn::after { display: none; } /* remove bootstrap caret */

.topbar-avatar {
  width: 32px;
  height: 32px;
  background-color: var(--primary);
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-family: var(--font-display);
  font-size: 0.7rem;
  color: #fff;
  flex-shrink: 0;
}

.topbar-user-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
  font-family: var(--font-display);
}

.topbar-user-role {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.topbar-chevron {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: var(--sp-1);
}

/* Topbar dropdown */
.topbar-dropdown {
  border: 1px solid var(--border) !important;
  border-radius: var(--r-lg) !important;
  box-shadow: var(--shadow-lg) !important;
  padding: var(--sp-2) !important;
  min-width: 200px;
  margin-top: var(--sp-2) !important;
}

.topbar-dropdown .dropdown-item {
  border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  transition: background var(--t-fast), color var(--t-fast);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.topbar-dropdown .dropdown-item:hover {
  background: var(--primary-light);
  color: var(--primary);
}
.topbar-dropdown .dropdown-item.text-danger {
  color: var(--danger) !important;
}
.topbar-dropdown .dropdown-item.text-danger:hover {
  background: var(--danger-light) !important;
  color: var(--danger-dark) !important;
}
.topbar-dropdown .dropdown-divider {
  border-color: var(--border);
  margin: var(--sp-2) var(--sp-1);
}
.topbar-dropdown .dropdown-item i { width: 16px; text-align: center; }

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */
.app-content {
  padding: var(--sp-8);
  flex: 1;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
  gap: var(--sp-4);
}

.page-header-title {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 800;
  margin: 0;
  /* Gradient from dark navy → primary blue */
  background: linear-gradient(120deg, var(--text-primary) 20%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--sp-1);
}

/* ============================================================
   CARDS
   ============================================================ */
.card-app {
  background: var(--bg-surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: var(--sp-6);
  transition: box-shadow var(--t-base), border-color var(--t-base);
}

a.card-app:hover,
.card-app.card-clickable:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-dark);
}

/* Dashboard section card (with header) */
.card-section {
  background: var(--bg-surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: var(--sp-3);
}

.card-section-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.card-section-title i { color: var(--primary); }

.card-section-body {
  padding: var(--sp-6);
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-card {
  background: var(--bg-surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: var(--sp-5) var(--sp-6);
  transition: box-shadow var(--t-base), transform var(--t-base);
  position: relative;
  overflow: hidden;
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* Accent strip on left edge */
.stat-card::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--stat-accent, var(--primary));
}

/* Color variants */
.stat-card.stat-blue   { --stat-accent: #1468E8; }
.stat-card.stat-green  { --stat-accent: #18A96B; }
.stat-card.stat-orange { --stat-accent: #F59E0B; }
.stat-card.stat-red    { --stat-accent: #E5484D; }
.stat-card.stat-purple { --stat-accent: #7C3AED; }
.stat-card.stat-teal   { --stat-accent: #0BA5EC; }

.stat-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
}

.stat-card-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  font-family: var(--font-display);
}

.stat-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.stat-card-icon-blue   { background: #EBF2FD; color: #1468E8; }
.stat-card-icon-green  { background: #E6F7EF; color: #18A96B; }
.stat-card-icon-orange { background: #FEF3C7; color: #D97706; }
.stat-card-icon-red    { background: #FDECEA; color: #E5484D; }
.stat-card-icon-purple { background: #EDE9FE; color: #7C3AED; }
.stat-card-icon-teal   { background: #E0F2FE; color: #0BA5EC; }

.stat-card-value {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--stat-accent, var(--primary));
  line-height: 1;
  margin-bottom: var(--sp-1);
}

.stat-card-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.stat-card-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--text-xs);
  font-weight: 600;
  margin-top: var(--sp-2);
}
.stat-card-trend.trend-up   { color: var(--success); }
.stat-card-trend.trend-down { color: var(--danger); }

/* Quick-action card */
.quick-action-card {
  background: var(--bg-surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: var(--sp-5) var(--sp-6);
  transition: box-shadow var(--t-base), border-color var(--t-base), transform var(--t-base);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.quick-action-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
  transform: translateY(-2px);
  color: inherit;
  text-decoration: none;
}

.qa-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.qa-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-base);
  color: var(--text-primary);
  transition: color var(--t-fast);
}
.quick-action-card:hover .qa-title { color: var(--primary); }

.qa-desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.qa-arrow {
  color: var(--primary);
  font-size: 0.875rem;
  transition: transform var(--t-fast);
}
.quick-action-card:hover .qa-arrow { transform: translateX(3px); }

/* ============================================================
   WELCOME BANNER — Text-first, no heavy background
   ============================================================ */
.welcome-banner {
  padding: var(--sp-2) 0 var(--sp-6);
  margin-bottom: var(--sp-2);
  position: relative;
}

.welcome-greeting {
  font-family: var(--font-display);
  font-size: var(--text-4xl);
  font-weight: 800;
  margin: 0 0 var(--sp-1);
  /* Gradient text: dark navy → brand blue */
  background: linear-gradient(120deg, var(--text-primary) 0%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.15;
}

.welcome-sub {
  font-size: var(--text-base);
  color: var(--text-muted);
  margin: 0;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge-success {
  background: var(--success-light);
  color: var(--success-dark);
  border: 1px solid rgba(24,169,107,0.2);
  border-radius: var(--r-full);
  padding: 3px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge-warning {
  background: var(--warning-light);
  color: var(--warning-dark);
  border: 1px solid rgba(245,158,11,0.25);
  border-radius: var(--r-full);
  padding: 3px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge-danger {
  background: var(--danger-light);
  color: var(--danger-dark);
  border: 1px solid rgba(229,72,77,0.2);
  border-radius: var(--r-full);
  padding: 3px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge-info {
  background: var(--info-light);
  color: var(--info-dark);
  border: 1px solid rgba(11,165,236,0.2);
  border-radius: var(--r-full);
  padding: 3px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge-neutral {
  background: #F1F4F8;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: 3px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge-primary {
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid rgba(20,104,232,0.2);
  border-radius: var(--r-full);
  padding: 3px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge-purple {
  background: var(--purple-light);
  color: var(--purple-dark);
  border: 1px solid rgba(124,58,237,0.2);
  border-radius: var(--r-full);
  padding: 3px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Status dot */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: var(--sp-2);
  vertical-align: middle;
}
.status-dot-success { background: var(--success); }
.status-dot-danger  { background: var(--danger); }
.status-dot-warning { background: var(--warning); }
.status-dot-muted   { background: var(--text-muted); }

/* ============================================================
   BUTTONS — Override Bootstrap
   ============================================================ */

/* Primary */
.btn-primary {
  background-color: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
  border-radius: var(--r-md) !important;
  font-weight: 600 !important;
  font-family: var(--font-display) !important;
  transition: all var(--t-fast) !important;
  box-shadow: 0 2px 8px rgba(20,104,232,0.25) !important;
}
.btn-primary:hover {
  background-color: var(--primary-hover) !important;
  border-color: var(--primary-hover) !important;
  box-shadow: 0 4px 16px rgba(20,104,232,0.35) !important;
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0) !important; }
.btn-primary:focus-visible {
  outline: 3px solid rgba(20,104,232,0.4) !important;
  outline-offset: 2px;
}

/* Secondary */
.btn-secondary, .btn-outline-secondary {
  background-color: #fff !important;
  border: 1px solid var(--border) !important;
  color: var(--text-secondary) !important;
  border-radius: var(--r-md) !important;
  font-weight: 500 !important;
  transition: all var(--t-fast) !important;
  box-shadow: var(--shadow-sm) !important;
}
.btn-secondary:hover, .btn-outline-secondary:hover {
  background-color: var(--bg-page) !important;
  border-color: var(--border-dark) !important;
  color: var(--text-primary) !important;
}

/* Outline primary */
.btn-outline-primary {
  background: transparent !important;
  border: 1.5px solid var(--primary) !important;
  color: var(--primary) !important;
  border-radius: var(--r-md) !important;
  font-weight: 600 !important;
  transition: all var(--t-fast) !important;
}
.btn-outline-primary:hover {
  background-color: var(--primary-light) !important;
}

/* Success */
.btn-success {
  background-color: var(--success) !important;
  border-color: var(--success) !important;
  color: #fff !important;
  border-radius: var(--r-md) !important;
  font-weight: 600 !important;
  transition: all var(--t-fast) !important;
}
.btn-success:hover {
  background-color: var(--success-dark) !important;
  border-color: var(--success-dark) !important;
}

/* Warning */
.btn-warning {
  background-color: var(--warning) !important;
  border-color: var(--warning) !important;
  color: #fff !important;
  border-radius: var(--r-md) !important;
  font-weight: 600 !important;
  transition: all var(--t-fast) !important;
}
.btn-warning:hover {
  background-color: var(--warning-dark) !important;
  border-color: var(--warning-dark) !important;
}

/* Danger */
.btn-danger {
  background-color: var(--danger) !important;
  border-color: var(--danger) !important;
  color: #fff !important;
  border-radius: var(--r-md) !important;
  font-weight: 600 !important;
  transition: all var(--t-fast) !important;
}
.btn-danger:hover {
  background-color: var(--danger-dark) !important;
  border-color: var(--danger-dark) !important;
}

/* Ghost / link button */
.btn-ghost {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  border-radius: var(--r-md);
  font-weight: 500;
  padding: 0.375rem 0.75rem;
  transition: background var(--t-fast), color var(--t-fast);
  cursor: pointer;
}
.btn-ghost:hover {
  background: var(--bg-page);
  color: var(--text-primary);
}

/* Icon button */
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
}

/* Loading state */
.btn-loading {
  position: relative;
  color: transparent !important;
}
.btn-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%; left: 50%;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* Global border-radius for all .btn */
.btn { border-radius: var(--r-md) !important; }

/* ============================================================
   FORM CONTROLS
   ============================================================ */
.form-control, .form-select {
  background-color: var(--bg-surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-md) !important;
  color: var(--text-primary) !important;
  font-family: var(--font-body) !important;
  font-size: var(--text-sm) !important;
  height: 40px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast) !important;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(20,104,232,0.1) !important;
  outline: none !important;
  background-color: var(--bg-surface) !important;
}
textarea.form-control { height: auto; min-height: 100px; }

.form-control::placeholder { color: var(--text-muted) !important; }
.form-control.is-invalid { border-color: var(--danger) !important; }
.form-control.is-valid   { border-color: var(--success) !important; }

.form-label {
  font-weight: 600 !important;
  font-size: var(--text-sm) !important;
  color: var(--text-secondary) !important;
  margin-bottom: 0.375rem !important;
  font-family: var(--font-display) !important;
}

.form-text {
  font-size: var(--text-xs) !important;
  color: var(--text-muted) !important;
}

.invalid-feedback {
  font-size: var(--text-xs) !important;
  color: var(--danger) !important;
}

.input-group .form-control { height: 40px; }

/* ============================================================
   DATA TABLE
   ============================================================ */
.table-app {
  background: var(--bg-surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.table-app .table {
  margin-bottom: 0;
  font-size: var(--text-sm);
}

.table-app .table thead th {
  background: #F9FAFB;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.875rem var(--sp-4);
  font-family: var(--font-display);
  white-space: nowrap;
}

.table-app .table tbody td {
  padding: 0.875rem var(--sp-4);
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.table-app .table tbody tr:last-child td { border-bottom: none; }

.table-app .table tbody tr {
  transition: background var(--t-fast);
}
.table-app .table tbody tr:hover {
  background: #F9FAFB;
}

/* Table search + filter bar */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
}

.table-toolbar-left  { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.table-toolbar-right { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; flex-shrink: 0; }

/* Pagination */
.page-link {
  color: var(--primary) !important;
  border-color: var(--border) !important;
  font-size: var(--text-sm) !important;
  padding: 0.375rem 0.75rem !important;
  border-radius: var(--r-md) !important;
  transition: all var(--t-fast) !important;
}
.page-link:hover {
  background-color: var(--primary-light) !important;
  border-color: var(--primary) !important;
}
.page-item.active .page-link {
  background-color: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}
.pagination { gap: var(--sp-1); }

/* ============================================================
   ALERTS — Override Bootstrap
   ============================================================ */
.alert {
  border-radius: var(--r-lg) !important;
  border: none !important;
  font-size: var(--text-sm) !important;
  border-left: 4px solid transparent !important;
}
.alert-success {
  background: var(--success-light) !important;
  color: var(--success-dark) !important;
  border-left-color: var(--success) !important;
}
.alert-danger {
  background: var(--danger-light) !important;
  color: var(--danger-dark) !important;
  border-left-color: var(--danger) !important;
}
.alert-warning {
  background: var(--warning-light) !important;
  color: var(--warning-dark) !important;
  border-left-color: var(--warning) !important;
}
.alert-info {
  background: var(--info-light) !important;
  color: var(--info-dark) !important;
  border-left-color: var(--info) !important;
}

/* ============================================================
   MODAL — Clean style
   ============================================================ */
.modal-content {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-2xl) !important;
  box-shadow: var(--shadow-xl) !important;
}
.modal-header {
  border-bottom: 1px solid var(--border) !important;
  padding: var(--sp-5) var(--sp-6) !important;
}
.modal-title {
  font-family: var(--font-display) !important;
  font-weight: 700 !important;
  color: var(--text-primary) !important;
  font-size: var(--text-xl) !important;
}
.modal-body  { padding: var(--sp-6) !important; }
.modal-footer {
  border-top: 1px solid var(--border) !important;
  padding: var(--sp-4) var(--sp-6) !important;
}

.modal-backdrop.show { opacity: 0.35 !important; }

/* ============================================================
   TOAST NOTIFICATION (CSS-based)
   ============================================================ */
#toast-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast-prepai {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: 14px 18px;
  min-width: 280px;
  max-width: 360px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  pointer-events: all;
  animation: toast-in 0.3s cubic-bezier(0.34, 1.4, 0.64, 1) forwards;
  position: relative;
  overflow: hidden;
}

.toast-prepai.toast-out {
  animation: toast-out 0.2s ease forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(110%) scale(0.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(110%); }
}

.toast-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.toast-icon-success { background: var(--success-light); color: var(--success); }
.toast-icon-danger  { background: var(--danger-light);  color: var(--danger); }
.toast-icon-warning { background: var(--warning-light); color: var(--warning-dark); }
.toast-icon-info    { background: var(--primary-light); color: var(--primary); }

.toast-body { flex: 1; }
.toast-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--text-primary);
  margin-bottom: 2px;
}
.toast-message {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background-color: var(--primary);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
  animation: toast-progress 3.5s linear forwards;
}
@keyframes toast-progress { from { width: 100%; } to { width: 0%; } }

/* ============================================================
   LOADING SKELETON
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg,
    #F1F4F8 25%,
    #E8EDF4 50%,
    #F1F4F8 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--r-sm);
}
@keyframes skeleton-loading {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
   SPINNER
   ============================================================ */
.spinner-app {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(20,104,232,0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-12) var(--sp-8);
  text-align: center;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  background: var(--bg-page);
  border-radius: var(--r-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  margin-bottom: var(--sp-4);
  color: var(--text-muted);
}

.empty-state-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--sp-2);
}

.empty-state-desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 360px;
}

/* ============================================================
   AUTH PAGES
   ============================================================ */
.bg-auth {
  background: linear-gradient(160deg, #071A33 0%, #0B2342 50%, #0A1E40 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: var(--sp-8) var(--sp-4);
}

.bg-auth::before {
  content: '';
  position: absolute;
  top: -15%;
  right: -10%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(20,104,232,0.18) 0%, transparent 65%);
  pointer-events: none;
}
.bg-auth::after {
  content: '';
  position: absolute;
  bottom: -15%;
  left: -10%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(20,104,232,0.12) 0%, transparent 65%);
  pointer-events: none;
}

.auth-wrapper {
  width: 100%;
  max-width: 460px;
  position: relative;
  z-index: 1;
}

.auth-card {
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-radius: var(--r-2xl);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 32px 64px rgba(0,0,0,0.3);
  padding: var(--sp-10) var(--sp-8);
  color: #fff;
}

.auth-card .form-control,
.auth-card .form-select {
  background: rgba(255,255,255,0.08) !important;
  border: 1px solid rgba(255,255,255,0.18) !important;
  color: #fff !important;
  border-radius: var(--r-md) !important;
}
.auth-card .form-control::placeholder { color: rgba(255,255,255,0.4) !important; }
.auth-card .form-control:focus {
  background: rgba(255,255,255,0.12) !important;
  border-color: rgba(20,104,232,0.7) !important;
  box-shadow: 0 0 0 3px rgba(20,104,232,0.2) !important;
}
.auth-card .form-label { color: rgba(255,255,255,0.75) !important; }
.auth-card .form-text  { color: rgba(255,255,255,0.45) !important; }
.auth-card a { color: #93BBFF; }
.auth-card a:hover { color: #C0D7FF; }

.auth-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
}

.auth-logo-mark {
  width: 44px;
  height: 44px;
  background-color: var(--primary);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  color: #fff;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

/* White-label: an institute's uploaded logo inside the default mark box
   (set by assets/js/branding.js). */
.auth-logo-mark.has-brand-logo,
.sidebar-logo-mark.has-brand-logo {
  background-color: #fff;
  padding: 3px;
}
.auth-logo-mark img,
.sidebar-logo-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.brand-logo-preview {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--r-md);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.brand-logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.auth-logo-name {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: #fff;
}

.auth-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 800;
  margin-bottom: var(--sp-2);
  color: #fff;
}

.auth-subtitle {
  color: rgba(255,255,255,0.55);
  margin-bottom: var(--sp-6);
  font-size: var(--text-sm);
}

.auth-footer {
  text-align: center;
  color: rgba(255,255,255,0.4);
  font-size: var(--text-xs);
  margin-top: var(--sp-4);
}

/* ============================================================
   PUBLIC NAVBAR (index.html)
   ============================================================ */
.navbar-prepai {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 0 var(--sp-8);
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand-prepai {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

/* ============================================================
   PUBLIC HERO (index.html)
   ============================================================ */
.hero-prepai {
  background: linear-gradient(160deg, #071A33 0%, #0B2342 60%, #112B50 100%);
  color: #fff;
  padding: var(--sp-16) var(--sp-8);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero-prepai::before {
  content: '';
  position: absolute;
  top: -20%; left: 30%;
  width: 50%; height: 200%;
  background: radial-gradient(ellipse, rgba(20,104,232,0.25) 0%, transparent 70%);
  pointer-events: none;
}
.hero-prepai h1 {
  font-family: var(--font-display);
  color: #fff;
  font-size: 3rem;
  font-weight: 800;
  margin-bottom: var(--sp-4);
  position: relative;
}
.hero-prepai p {
  color: rgba(255,255,255,0.72);
  font-size: var(--text-lg);
  max-width: 560px;
  margin: 0 auto var(--sp-8);
  line-height: 1.75;
  position: relative;
}

/* ============================================================
   STATUS GRID (index.html)
   ============================================================ */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-4);
}

.status-card {
  background: var(--bg-surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: var(--sp-5) var(--sp-6);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  transition: all var(--t-base);
}
.status-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.status-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.status-card-icon-blue   { background: var(--primary-light); color: var(--primary); }
.status-card-icon-green  { background: var(--success-light); color: var(--success); }
.status-card-icon-orange { background: var(--warning-light); color: var(--warning-dark); }
.status-card-icon-teal   { background: var(--info-light);    color: var(--info); }

.status-card-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  font-family: var(--font-display);
  margin-bottom: var(--sp-1);
}

.status-card-value {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-primary);
}

/* ============================================================
   SECTION / FOOTER (public page)
   ============================================================ */
.section-prepai {
  padding: var(--sp-12) var(--sp-8);
  max-width: 1100px;
  margin: 0 auto;
}

.section-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 800;
  margin-bottom: var(--sp-6);
  color: var(--text-primary);
}

.footer-prepai {
  border-top: 1px solid var(--border);
  padding: var(--sp-6) var(--sp-8);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
  background: var(--bg-surface);
}

/* App footer (inside authenticated portal) */
.app-footer {
  border-top: 1px solid var(--border);
  padding: var(--sp-4) var(--sp-8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  font-size: var(--text-xs);
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-muted-app     { color: var(--text-muted); }
.text-secondary-app { color: var(--text-secondary); }
.text-primary-app   { color: var(--primary); }
.fw-medium-app      { font-weight: 500; }
.fw-semibold-app    { font-weight: 600; }

/* Gradient text utilities */
.gradient-text,
.text-gradient {
  background: linear-gradient(120deg, var(--text-primary) 0%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.text-gradient-blue {
  background: linear-gradient(120deg, #1468E8, #0BA5EC);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.text-gradient-green {
  background: linear-gradient(120deg, #18A96B, #0BA5EC);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.text-gradient-purple {
  background: linear-gradient(120deg, #7C3AED, #1468E8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.text-gradient-warm {
  background: linear-gradient(120deg, #F59E0B, #E5484D);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Divider */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--sp-6) 0;
}

/* Section heading used in cards */
.section-heading {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: var(--sp-4);
}

/* ============================================================
   RESPONSIVE — Mobile Sidebar Drawer
   ============================================================ */
/* Keep the navigation visible on tablet-sized screens such as the template
   editor layout; use the drawer only on narrow phone screens. */
@media (max-width: 575px) {
  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    transform: translateX(-100%);
    z-index: 300;
  }

  body.sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  .topbar-toggle { display: flex !important; }

  .topbar-center { display: none !important; }

  .app-content { padding: var(--sp-5); }
  .app-topbar  { padding: 0 var(--sp-5); }
}

@media (min-width: 576px) {
  .topbar-toggle { display: none !important; }
}

@media (max-width: 767px) {
  .app-content { padding: var(--sp-4); }
  .app-topbar  { padding: 0 var(--sp-4); gap: var(--sp-3); }
  .welcome-greeting { font-size: var(--text-2xl); }
  .page-header-title { font-size: var(--text-2xl); }
  .hero-prepai { padding: var(--sp-10) var(--sp-4); }
  .hero-prepai h1 { font-size: var(--text-3xl); }
  .section-prepai { padding: var(--sp-8) var(--sp-4); }
  .navbar-prepai  { padding: 0 var(--sp-4); }

  #toast-container { right: 12px; left: 12px; }
  .toast-prepai { min-width: unset; width: 100%; }

  /* Responsive table: scroll on mobile */
  .table-app { overflow-x: auto; }

  /* Stack columns on mobile */
  .topbar-right .topbar-user-info { display: none; }
}

@media (max-width: 576px) {
  .stat-card-value { font-size: var(--text-2xl); }
  .app-footer { flex-direction: column; gap: var(--sp-2); text-align: center; }
}

/* ============================================================
   NOTIFICATION DROPDOWN
   Use .dropdown-menu.notif-dropdown for higher specificity
   so these rules beat the global .dropdown-menu overrides below.
   ============================================================ */
.dropdown-menu.notif-dropdown {
  width: 360px !important;
  padding: 0 !important;
  border-radius: var(--r-xl) !important;
  border: 1px solid var(--border) !important;
  box-shadow: var(--shadow-xl) !important;
  overflow: hidden;
  max-height: 480px;
  min-width: unset !important;
  /* Do NOT set display here — Bootstrap controls show/hide via display:none */
  flex-direction: column;
}
/* Only apply flex layout when Bootstrap has opened the dropdown */
.dropdown-menu.notif-dropdown.show {
  display: flex !important;
}

.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.notif-header-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.notif-mark-all {
  font-size: var(--text-xs);
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 500;
  padding: 0;
  transition: color var(--t-fast);
}
.notif-mark-all:hover { color: var(--primary-hover); text-decoration: underline; }

.notif-body {
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  transition: background var(--t-fast);
  cursor: default;
  position: relative;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-page); }

.notif-item.unread { background: var(--primary-light); }
.notif-item.unread:hover { background: #dce9fb; }

.notif-item.unread::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
}

.notif-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
  margin-left: 8px;
}
.notif-icon-info    { background: var(--primary-light); color: var(--primary); }
.notif-icon-success { background: var(--success-light); color: var(--success); }
.notif-icon-warning { background: var(--warning-light); color: var(--warning-dark); }
.notif-icon-danger  { background: var(--danger-light);  color: var(--danger); }

.notif-content { flex: 1; min-width: 0; }
.notif-text {
  font-size: var(--text-sm);
  color: var(--text-primary);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notif-time {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 3px;
}

.notif-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-10) var(--sp-6);
  color: var(--text-muted);
  gap: var(--sp-3);
  font-size: var(--text-sm);
}
.notif-empty i { font-size: 1.75rem; opacity: 0.5; }

.notif-footer {
  border-top: 1px solid var(--border);
  padding: var(--sp-3) var(--sp-5);
  text-align: center;
  background: var(--bg-surface);
  flex-shrink: 0;
}
.notif-view-all {
  font-size: var(--text-xs);
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}
.notif-view-all:hover { text-decoration: underline; }

.notif-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-8);
  color: var(--text-muted);
  gap: var(--sp-3);
  font-size: var(--text-sm);
}

@media (max-width: 480px) {
  .notif-dropdown { width: calc(100vw - 24px) !important; }
}

/* ============================================================
   TOAST — position & z-index fix
   ============================================================ */
#toast-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 380px;
  width: calc(100vw - 48px);
}

/* ============================================================
   BOOTSTRAP COLOR UTILITY OVERRIDES
   Align Bootstrap's color utilities with our design tokens
   so text-primary, bg-success, etc. are consistent everywhere.
   ============================================================ */

/* Text colors */
.text-primary   { color: var(--primary)        !important; }
.text-success   { color: var(--success)        !important; }
.text-warning   { color: var(--warning-dark)   !important; }
.text-danger    { color: var(--danger)         !important; }
.text-info      { color: var(--info)           !important; }
.text-muted     { color: var(--text-muted)     !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-dark      { color: var(--text-primary)   !important; }
.text-light     { color: var(--text-muted)     !important; }

/* Background colors */
.bg-primary { background-color: var(--primary)       !important; color: #fff !important; }
.bg-success { background-color: var(--success)       !important; color: #fff !important; }
.bg-warning { background-color: var(--warning)       !important; color: #fff !important; }
.bg-danger  { background-color: var(--danger)        !important; color: #fff !important; }
.bg-info    { background-color: var(--info)          !important; color: #fff !important; }
.bg-light   { background-color: var(--bg-page)       !important; }
.bg-white   { background-color: var(--bg-surface)    !important; }
.bg-dark    { background-color: var(--sidebar-bg)    !important; color: #fff !important; }

/* Bootstrap badge overrides to use our palette */
.badge.bg-primary { background-color: var(--primary)       !important; }
.badge.bg-success { background-color: var(--success)       !important; }
.badge.bg-warning { background-color: var(--warning)       !important; color: #fff !important; }
.badge.bg-danger  { background-color: var(--danger)        !important; }
.badge.bg-info    { background-color: var(--info)          !important; }
.badge.bg-secondary { background-color: var(--text-muted)  !important; }
.badge.bg-dark    { background-color: var(--text-primary)  !important; }
.badge.bg-light   { background-color: var(--bg-page)       !important; color: var(--text-secondary) !important; }

/* ============================================================
   FORM CONTROL SIZE FIXES
   Respect Bootstrap's sm/lg modifiers while keeping our style
   ============================================================ */
.form-control-sm,
.form-select-sm,
input.form-control-sm,
select.form-select-sm {
  height: 34px !important;
  font-size: var(--text-sm) !important;
  padding-top: 0.3rem !important;
  padding-bottom: 0.3rem !important;
}
textarea.form-control-sm { height: auto !important; min-height: 80px !important; }

/* Align .btn-sm height with sm form controls */
.btn-sm {
  height: 34px !important;
  font-size: var(--text-sm) !important;
  padding-top: 0.25rem !important;
  padding-bottom: 0.25rem !important;
}

.form-control-lg,
.form-select-lg {
  height: 48px !important;
  font-size: var(--text-lg) !important;
}

/* ============================================================
   MISSING ICON COLOR — stat-card-icon-purple
   ============================================================ */
.stat-card-icon-purple { background: #EDE9FE; color: #7C3AED; }

/* ============================================================
   BORDER / OUTLINE CONSISTENCY
   ============================================================ */
.border         { border-color: var(--border) !important; }
.border-primary { border-color: var(--primary) !important; }
.border-success { border-color: var(--success) !important; }
.border-warning { border-color: var(--warning) !important; }
.border-danger  { border-color: var(--danger)  !important; }

/* ============================================================
   LINK COLOR CONSISTENCY
   ============================================================ */
a.link-primary { color: var(--primary)   !important; }
a.link-success { color: var(--success)   !important; }
a.link-danger  { color: var(--danger)    !important; }
a.link-warning { color: var(--warning-dark) !important; }

/* ============================================================
   DROPDOWN MENUS (non-topbar)
   ============================================================ */
.dropdown-menu {
  border: 1px solid var(--border) !important;
  border-radius: var(--r-lg) !important;
  box-shadow: var(--shadow-md) !important;
  padding: var(--sp-2) !important;
}
.dropdown-item {
  border-radius: var(--r-sm);
  font-size: var(--text-sm);
  color: var(--text-secondary) !important;
  padding: 0.4rem var(--sp-3) !important;
  transition: background var(--t-fast), color var(--t-fast);
}
.dropdown-item:hover, .dropdown-item:focus {
  background-color: var(--primary-light) !important;
  color: var(--primary) !important;
}
.dropdown-item.active, .dropdown-item:active {
  background-color: var(--primary) !important;
  color: #fff !important;
}
.dropdown-divider { border-color: var(--border) !important; }

/* ============================================================
   BOOTSTRAP CARD (used in some pages alongside card-app)
   ============================================================ */
.card {
  border: 1px solid var(--border) !important;
  border-radius: var(--r-xl) !important;
  box-shadow: var(--shadow-sm) !important;
  background: var(--bg-surface) !important;
}
.card-header {
  background: #F9FAFB !important;
  border-bottom: 1px solid var(--border) !important;
  font-family: var(--font-display);
  font-weight: 700;
}
.card-footer {
  background: #F9FAFB !important;
  border-top: 1px solid var(--border) !important;
}

/* ============================================================
   NAV TABS (used in template editor)
   ============================================================ */
.nav-tabs {
  border-bottom: 2px solid var(--border) !important;
  gap: var(--sp-1);
}
.nav-tabs .nav-link {
  border: none !important;
  border-radius: var(--r-md) var(--r-md) 0 0 !important;
  color: var(--text-secondary) !important;
  font-size: var(--text-sm) !important;
  font-weight: 500 !important;
  padding: 0.5rem 1rem !important;
  transition: color var(--t-fast), background var(--t-fast) !important;
}
.nav-tabs .nav-link:hover {
  color: var(--primary) !important;
  background: var(--primary-light) !important;
}
.nav-tabs .nav-link.active {
  background: var(--bg-surface) !important;
  color: var(--primary) !important;
  border-bottom: 2px solid var(--primary) !important;
  font-weight: 700 !important;
  margin-bottom: -2px !important;
}

/* ============================================================
   BOOTSTRAP TABLE (plain .table, not .table-app)
   ============================================================ */
.table > :not(caption) > * > * {
  background-color: transparent !important;
  color: var(--text-primary) !important;
}
.table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: #F9FAFB !important;
}
.table thead th {
  color: var(--text-secondary) !important;
  font-size: var(--text-xs) !important;
  font-weight: 700 !important;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ============================================================
   INPUT GROUP
   ============================================================ */
.input-group-text {
  background: var(--bg-page) !important;
  border-color: var(--border) !important;
  color: var(--text-muted) !important;
  border-radius: var(--r-md) !important;
}

/* ============================================================
   CHECK / RADIO / SWITCH
   ============================================================ */
.form-check-input:checked {
  background-color: var(--primary) !important;
  border-color: var(--primary) !important;
}
.form-check-input:focus {
  box-shadow: 0 0 0 3px rgba(20,104,232,0.15) !important;
}

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress { background-color: var(--bg-page) !important; border-radius: var(--r-full) !important; }
.progress-bar { background-color: var(--primary) !important; }
.progress-bar.bg-success { background-color: var(--success) !important; }
.progress-bar.bg-warning { background-color: var(--warning) !important; }
.progress-bar.bg-danger  { background-color: var(--danger)  !important; }

/* ============================================================
   CODE / PRE
   ============================================================ */
code {
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 2px 6px;
  font-size: 0.85em;
  color: var(--primary);
}

/* ============================================================
   SCROLLBAR (webkit)
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   ERROR STATE (distinct from empty-state — used after a failed
   fetch, with an optional retry action)
   ============================================================ */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-12) var(--sp-8);
  text-align: center;
}
.error-state-icon {
  width: 64px;
  height: 64px;
  background: var(--danger-light);
  border-radius: var(--r-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  margin-bottom: var(--sp-4);
  color: var(--danger);
}
.error-state-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--sp-2);
}
.error-state-desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 360px;
  margin-bottom: var(--sp-4);
}

/* ============================================================
   SKELETON — composed variants built on the base .skeleton block
   ============================================================ */
.skeleton-text {
  height: 0.9em;
  margin-bottom: var(--sp-2);
}
.skeleton-title {
  height: 1.4em;
  width: 40%;
  margin-bottom: var(--sp-3);
}
.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--r-full);
}
.skeleton-row {
  height: 44px;
  margin-bottom: var(--sp-2);
  border-radius: var(--r-md);
}

/* ============================================================
   FULLCALENDAR THEMING — align FullCalendar with design tokens
   ============================================================ */
.fc {
  font-family: var(--font-body);
  --fc-border-color: var(--border);
  --fc-page-bg-color: var(--bg-surface);
  --fc-neutral-bg-color: var(--bg-page);
  --fc-list-event-hover-bg-color: var(--bg-page);
  --fc-today-bg-color: var(--primary-light);
}
.fc .fc-toolbar-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
}
.fc .fc-button {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  box-shadow: none;
  font-weight: 500;
  text-transform: capitalize;
  transition: all var(--t-fast);
}
.fc .fc-button:hover {
  background: var(--bg-page);
  border-color: var(--border-dark);
  color: var(--text-primary);
}
.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.fc .fc-button:focus-visible {
  outline: 3px solid rgba(20,104,232,0.35);
  outline-offset: 1px;
  box-shadow: none;
}
.fc .fc-col-header-cell {
  background: #F9FAFB;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}
.fc .fc-daygrid-day-number,
.fc .fc-timegrid-slot-label-cushion {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.fc-event {
  border-radius: var(--r-sm);
  border: none;
  font-size: var(--text-xs);
  padding: 1px 4px;
  cursor: pointer;
}
.fc .fc-today-button {
  background: var(--primary-light);
  border-color: rgba(20,104,232,0.25);
  color: var(--primary);
  font-weight: 600;
}
.fc .fc-today-button:not(:disabled):hover {
  background: var(--primary);
  color: #fff;
}

/* ============================================================
   ACCESSIBILITY — keyboard focus visibility
   ============================================================ */
a:focus-visible,
button:focus-visible,
.sidebar-link:focus-visible,
.dropdown-item:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
