/* =========================================================
   Merchant Portal — Design System v2.0
   Inspired by: Linear, Stripe, Vercel, GitHub, Notion
   Primary: Indigo  |  Accent: Emerald  |  Font: Inter
   ========================================================= */

/* ---- 1. Design Tokens ---------------------------------- */
:root {
  /* Primary — Indigo */
  --primary:            #6366f1;
  --primary-dark:       #4f46e5;
  --primary-darker:     #4338ca;
  --primary-light:      #818cf8;
  --primary-subtle:     #eef2ff;
  --primary-rgb:        99, 102, 241;

  /* Secondary — Blue */
  --secondary:          #3b82f6;
  --secondary-dark:     #2563eb;
  --secondary-light:    #60a5fa;
  --secondary-subtle:   #eff6ff;
  --secondary-rgb:      59, 130, 246;

  /* Accent — Violet */
  --accent:             #8b5cf6;
  --accent-dark:        #7c3aed;
  --accent-subtle:      #f5f3ff;
  --accent-rgb:         139, 92, 246;

  /* Status — Emerald */
  --success:            #10b981;
  --success-dark:       #059669;
  --success-light:      #34d399;
  --success-subtle:     #ecfdf5;
  --success-rgb:        16, 185, 129;

  /* Status — Amber */
  --warning:            #f59e0b;
  --warning-dark:       #d97706;
  --warning-light:      #fcd34d;
  --warning-subtle:     #fffbeb;
  --warning-rgb:        245, 158, 11;

  /* Status — Red */
  --danger:             #ef4444;
  --danger-dark:        #dc2626;
  --danger-light:       #f87171;
  --danger-subtle:      #fef2f2;
  --danger-rgb:         239, 68, 68;

  /* Status — Cyan */
  --info:               #06b6d4;
  --info-dark:          #0891b2;
  --info-subtle:        #ecfeff;
  --info-rgb:           6, 182, 212;

  /* Sidebar */
  --sidebar-bg:         #0f172a;
  --sidebar-bg-mid:     #1e293b;
  --sidebar-hover:      rgba(99, 102, 241, 0.08);
  --sidebar-active:     rgba(99, 102, 241, 0.15);
  --sidebar-text:       #94a3b8;
  --sidebar-text-active:#e2e8f0;
  --sidebar-text-muted: #64748b;
  --sidebar-border:     rgba(255, 255, 255, 0.06);
  --sidebar-width:      260px;
  --sidebar-collapsed-width: 64px;

  /* Surfaces */
  --bg-body:            #f8fafc;
  --bg-card:            #ffffff;
  --bg-header:          rgba(255, 255, 255, 0.9);
  --bg-surface:         #f1f5f9;
  --bg-muted:           #f8fafc;

  /* Text */
  --text-primary:       #0f172a;
  --text-secondary:     #475569;
  --text-muted:         #94a3b8;
  --text-disabled:      #cbd5e1;
  --text-on-primary:    #ffffff;

  /* Borders */
  --border-color:       #e2e8f0;
  --border-strong:      #cbd5e1;
  --border-focus:       rgba(99, 102, 241, 0.4);

  /* Radius */
  --radius-sm:          6px;
  --radius:             10px;
  --radius-lg:          14px;
  --radius-xl:          18px;
  --radius-2xl:         24px;
  --radius-full:        9999px;

  /* Shadows */
  --shadow-xs:          0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-sm:          0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow:             0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-md:          0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-lg:          0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --shadow-xl:          0 25px 50px -12px rgb(0 0 0 / 0.25);
  --shadow-ring:        0 0 0 3px rgba(99, 102, 241, 0.2);
  --shadow-inner:       inset 0 2px 4px 0 rgb(0 0 0 / 0.05);

  /* Glassmorphism */
  --glass-bg:           rgba(255, 255, 255, 0.75);
  --glass-border:       rgba(255, 255, 255, 0.5);
  --glass-blur:         blur(16px);

  /* Layout */
  --navbar-height:      60px;
  --content-max-width:  1440px;

  /* Spacing */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px;
  --space-4: 16px; --space-5: 20px; --space-6: 24px;
  --space-8: 32px; --space-10: 40px; --space-12: 48px;

  /* Typography */
  --font-sans:  'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  --font-mono:  'JetBrains Mono', 'Cascadia Code', 'Fira Code', 'Courier New', monospace;
  --font-size-xs:   0.75rem;
  --font-size-sm:   0.875rem;
  --font-size-base: 1rem;
  --font-size-lg:   1.125rem;
  --font-size-xl:   1.25rem;
  --font-size-2xl:  1.5rem;
  --font-size-3xl:  1.875rem;
  --font-size-4xl:  2.25rem;
  --font-weight-normal:   400;
  --font-weight-medium:   500;
  --font-weight-semibold: 600;
  --font-weight-bold:     700;
  --line-height-tight:   1.25;
  --line-height-normal:  1.5;
  --line-height-relaxed: 1.75;

  /* Z-index */
  --z-dropdown:       1000;
  --z-sticky:         1020;
  --z-fixed:          1030;
  --z-sidebar:        1080;
  --z-navbar:         1090;
  --z-modal-backdrop: 1095;
  --z-modal:          1100;
  --z-popover:        1105;
  --z-tooltip:        1106;
  --z-toast:          1110;
  --z-palette:        1200;

  /* Transitions */
  --transition-fast:   0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition:        0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow:   0.4s  cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 0.5s  cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Legacy aliases (page-specific CSS may still reference these) */
  --border-radius-sm: var(--radius-sm);
  --border-radius:    var(--radius);
  --border-radius-lg: var(--radius-lg);
  --border-radius-xl: var(--radius-xl);
  --success-light:    var(--success-subtle);
  --danger-light:     var(--danger-subtle);
  --warning-light:    var(--warning-subtle);
  --info-light:       var(--info-subtle);
  --bg-light:         var(--bg-surface);
  --primary-gradient: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  --transition-base:  var(--transition);
}

/* ---- 2. Dark Mode -------------------------------------- */
/* Use data-dark="true" so it doesn't conflict with theme.js (which manages data-theme for color themes) */
[data-dark="true"] {
  --primary:            #818cf8;
  --primary-dark:       #6366f1;
  --primary-subtle:     rgba(99, 102, 241, 0.15);
  --success:            #34d399;
  --success-subtle:     rgba(16, 185, 129, 0.15);
  --warning:            #fcd34d;
  --warning-subtle:     rgba(245, 158, 11, 0.15);
  --danger:             #f87171;
  --danger-subtle:      rgba(239, 68, 68, 0.15);
  --info:               #22d3ee;
  --info-subtle:        rgba(6, 182, 212, 0.15);

  --sidebar-bg:         #020617;
  --sidebar-bg-mid:     #0f172a;

  --bg-body:            #0f172a;
  --bg-card:            #1e293b;
  --bg-header:          rgba(15, 23, 42, 0.9);
  --bg-surface:         #1e293b;
  --bg-muted:           #0f172a;

  --text-primary:       #f1f5f9;
  --text-secondary:     #94a3b8;
  --text-muted:         #64748b;
  --text-disabled:      #334155;

  --border-color:       #1e293b;
  --border-strong:      #334155;

  --glass-bg:           rgba(30, 41, 59, 0.8);
  --glass-border:       rgba(255, 255, 255, 0.08);
}

/* Theme variants */
[data-theme="black"] {
  --sidebar-bg: #000000;
  --sidebar-bg-mid: #111111;
  --primary: #ffffff;
  --primary-dark: #e2e8f0;
}
[data-theme="orange"] {
  --primary: #f97316;
  --primary-dark: #ea580c;
  --primary-subtle: #fff7ed;
  --sidebar-bg: #431407;
  --sidebar-bg-mid: #7c2d12;
}
[data-theme="gold"] {
  --primary: #d4af37;
  --primary-dark: #b8962e;
  --primary-subtle: #fefce8;
  --sidebar-bg: #1c1a08;
  --sidebar-bg-mid: #3a3510;
}

/* ---- 3. Base Reset / Typography ------------------------ */
*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  color: var(--text-primary);
  background-color: var(--bg-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  color: var(--text-primary);
  margin-top: 0;
  letter-spacing: -0.01em;
}
h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }
h5 { font-size: var(--font-size-base); }
h6 { font-size: var(--font-size-sm); }

p { color: var(--text-secondary); margin-bottom: 1rem; }

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--primary-dark); }

code, kbd, pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}
kbd {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: var(--font-weight-medium);
  line-height: 1.4;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 0 var(--border-color);
}

/* Tabular numbers for financial data */
.font-tabular, .amount, .currency-value {
  font-feature-settings: "tnum" 1, "zero" 1;
  font-variant-numeric: tabular-nums;
}

/* ---- 4. Skip Link --------------------------------------- */
.skip-link {
  position: fixed;
  top: -100%;
  left: var(--space-4);
  z-index: calc(var(--z-palette) + 10);
  padding: var(--space-3) var(--space-6);
  background: var(--primary);
  color: #fff;
  border-radius: 0 0 var(--radius) var(--radius);
  font-weight: var(--font-weight-semibold);
  transition: top var(--transition-fast);
}
.skip-link:focus {
  top: 0;
  color: #fff;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ---- 5. App Shell Layout ------------------------------- */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
}

.main-wrapper {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

/* Collapsed sidebar state */
body.sidebar-collapsed .main-wrapper {
  margin-left: var(--sidebar-collapsed-width);
}

/* ---- 6. App Header ------------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-navbar);
  height: var(--navbar-height);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-6);
  background: var(--bg-header);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition);
}

.header-start {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}
.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
  max-width: 480px;
  margin: 0 auto;
}
.header-end {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
  margin-left: auto;
}

/* Header icon buttons */
.header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  font-size: 1rem;
  position: relative;
}
.header-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}
.header-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.header-divider {
  width: 1px;
  height: 24px;
  background: var(--border-color);
  margin: 0 var(--space-1);
}

/* Notification badge */
.notification-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  line-height: 16px;
  text-align: center;
  background: var(--danger);
  color: #fff;
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-header);
}

/* Mobile sidebar toggle */
.mobile-sidebar-toggle {
  display: none;
}

/* Header search trigger */
.header-search-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  max-width: 360px;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  text-align: left;
}
.header-search-trigger:hover {
  background: var(--bg-card);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.header-search-trigger:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--shadow-ring);
}
.search-placeholder { flex: 1; }
.search-kbd {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

/* Page header area inside content */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}
.page-title {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin: 0;
}
.page-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin: var(--space-1) 0 0;
}
.page-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin: var(--space-1) 0 0;
}
.page-breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}
.page-breadcrumb a:hover { color: var(--primary); }
.page-breadcrumb .bi-chevron-right { font-size: 10px; color: var(--text-disabled); }
.page-breadcrumb span { color: var(--text-primary); font-weight: var(--font-weight-medium); }

/* Breadcrumb */
.header-breadcrumb .breadcrumb {
  margin: 0;
  padding: 0;
  background: none;
  font-size: var(--font-size-sm);
}
.header-breadcrumb .breadcrumb-item { color: var(--text-secondary); }
.header-breadcrumb .breadcrumb-item.active { color: var(--text-primary); font-weight: var(--font-weight-medium); }
.header-breadcrumb .breadcrumb-item + .breadcrumb-item::before {
  color: var(--text-muted);
  content: "/";
}
.header-breadcrumb .breadcrumb-item a { color: var(--text-secondary); }
.header-breadcrumb .breadcrumb-item a:hover { color: var(--primary); }

/* User menu in header */
.user-menu-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2) var(--space-1) var(--space-1);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  color: var(--text-primary);
}
.user-menu-btn:hover, .user-menu-btn.show {
  background: var(--bg-surface);
  border-color: var(--border-color);
}
.user-menu-btn::after { display: none; } /* Remove Bootstrap dropdown arrow */
.user-avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #fff;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.user-menu-info { text-align: left; line-height: 1.2; }
.user-menu-name {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-menu-chevron {
  font-size: 0.625rem;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
}
.user-menu-btn.show .user-menu-chevron { transform: rotate(180deg); }

/* ---- 7. Page Content / Footer -------------------------- */
.page-content {
  flex: 1;
  padding: var(--space-6);
  max-width: var(--content-max-width);
  width: 100%;
  margin: 0 auto;
}

.app-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* ---- 8. Cards ------------------------------------------ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}
.card:hover { box-shadow: var(--shadow-sm); }

.card-header {
  padding: var(--space-4) var(--space-5);
  background: transparent;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.card-header-title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin: 0;
}
.card-body { padding: var(--space-5); }
.card-footer {
  padding: var(--space-3) var(--space-5);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

/* KPI / Metric Cards */
.metric-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-5) var(--space-4);
  overflow: hidden;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  cursor: pointer;
  text-decoration: none;
  display: block;
  color: inherit;
}
.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  color: inherit;
}
.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--metric-accent, var(--primary));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.metric-card-success { --metric-accent: var(--success); }
.metric-card-warning { --metric-accent: var(--warning); }
.metric-card-danger  { --metric-accent: var(--danger); }
.metric-card-info    { --metric-accent: var(--info); }
.metric-card-accent  { --metric-accent: var(--accent); }

.metric-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  background: rgba(var(--metric-color-rgb, 99, 102, 241), 0.1);
  color: var(--metric-color, var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: var(--space-3);
}
.metric-value {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1;
  font-feature-settings: "tnum" 1;
  font-variant-numeric: tabular-nums;
}
.metric-label {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  font-weight: var(--font-weight-medium);
  margin-top: var(--space-1);
}
.metric-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: var(--font-weight-semibold);
}
.metric-badge-success { background: var(--success-subtle); color: var(--success-dark); }
.metric-badge-danger  { background: var(--danger-subtle);  color: var(--danger-dark); }
.metric-badge-warning { background: var(--warning-subtle); color: var(--warning-dark); }

/* Status Cards (existing trend cards) */
.trend-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  position: relative;
  overflow: hidden;
}
.trend-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.trend-success { border-top: 3px solid var(--success); }
.trend-danger  { border-top: 3px solid var(--danger); }
.trend-primary { border-top: 3px solid var(--primary); }
.trend-warning { border-top: 3px solid var(--warning); }
.trend-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
}
.trend-value {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* ---- 9. Buttons ---------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color var(--transition-fast),
    border-color    var(--transition-fast),
    box-shadow      var(--transition-fast),
    color           var(--transition-fast),
    transform       var(--transition-fast);
  vertical-align: middle;
}
.btn:active { transform: scale(0.98); }
.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.btn-sm { padding: 0.375rem 0.75rem; font-size: var(--font-size-xs); }
.btn-lg { padding: 0.75rem 1.5rem;  font-size: var(--font-size-base); }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
  box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.35);
}
.btn-secondary {
  background: var(--secondary);
  border-color: var(--secondary);
  color: #fff;
}
.btn-secondary:hover {
  background: var(--secondary-dark);
  border-color: var(--secondary-dark);
  color: #fff;
}
.btn-success {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.btn-success:hover {
  background: var(--success-dark);
  border-color: var(--success-dark);
  color: #fff;
  box-shadow: 0 4px 12px rgba(var(--success-rgb), 0.35);
}
.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: var(--danger-dark);
  border-color: var(--danger-dark);
  color: #fff;
}
.btn-warning {
  background: var(--warning);
  border-color: var(--warning);
  color: #fff;
}
.btn-warning:hover {
  background: var(--warning-dark);
  border-color: var(--warning-dark);
  color: #fff;
}
.btn-outline-primary {
  background: transparent;
  border-color: var(--primary);
  color: var(--primary);
}
.btn-outline-primary:hover {
  background: var(--primary-subtle);
  color: var(--primary-dark);
}
.btn-outline-secondary {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-secondary);
}
.btn-outline-secondary:hover {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: var(--danger-dark);
  border-color: var(--danger-dark);
  color: #fff;
}
.btn-outline-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.btn-outline-danger:hover {
  background: var(--danger-subtle);
  border-color: var(--danger-dark);
  color: var(--danger-dark);
}
.btn-outline-success {
  background: transparent;
  border-color: var(--success);
  color: var(--success);
}
.btn-outline-success:hover {
  background: var(--success-subtle);
  border-color: var(--success-dark);
  color: var(--success-dark);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}
.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  padding: 0;
  font-weight: var(--font-weight-medium);
}
.btn-link:hover { color: var(--primary-dark); }
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  justify-content: center;
}
.btn-icon.btn-lg { width: 44px; height: 44px; }
.btn-icon.btn-sm { width: 28px; height: 28px; }

/* Loading state */
.btn.is-loading {
  pointer-events: none;
  opacity: 0.75;
  position: relative;
}
.btn.is-loading .btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ---- 10. Forms ----------------------------------------- */
.form-label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}
.form-control, .form-select {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-family: var(--font-sans);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-normal);
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
  appearance: none;
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--shadow-ring);
  background-color: var(--bg-card);
}
.form-control:disabled, .form-select:disabled {
  background-color: var(--bg-surface);
  color: var(--text-disabled);
  cursor: not-allowed;
}
.form-control.is-invalid, .was-validated .form-control:invalid {
  border-color: var(--danger);
  background-image: none;
}
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(var(--danger-rgb), 0.2); }
.invalid-feedback {
  font-size: var(--font-size-xs);
  color: var(--danger);
  margin-top: var(--space-1);
}
.form-check-input {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  background-color: var(--bg-card);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}
.form-check-input:focus {
  outline: none;
  box-shadow: var(--shadow-ring);
}
.form-check-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  cursor: pointer;
}
.form-text {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

/* Input group */
.input-group .form-control:focus { z-index: 3; }
.input-group-text {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
}

/* Floating labels */
.form-floating .form-control { padding-top: 1.5rem; padding-bottom: 0.5rem; }
.form-floating label {
  color: var(--text-muted);
  padding: 0.75rem 0.75rem;
  transition: all var(--transition-fast);
}
.form-floating .form-control:focus ~ label,
.form-floating .form-control:not(:placeholder-shown) ~ label {
  color: var(--primary);
  transform: scale(0.85) translateY(-0.6rem) translateX(0.1rem);
}

/* Filter / search accordion */
.filter-accordion {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
}
.filter-accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  cursor: pointer;
  user-select: none;
}
.filter-accordion-header h5, .filter-accordion-header h6 {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.filter-accordion-body { padding: 0 var(--space-5) var(--space-5); }

/* ── Compact Bootstrap card inside filter-accordion ──── */
.filter-accordion .card-header {
  padding: .5rem 1rem;
  background: rgba(var(--primary-rgb), .03);
  border-bottom-color: var(--border-color);
  cursor: pointer;
  user-select: none;
  transition: background .15s;
}
.filter-accordion .card-header:hover {
  background: rgba(var(--primary-rgb), .07);
}
.filter-accordion .card-header .card-title {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted, #64748b);
}
.filter-accordion .card-header .card-title i {
  color: var(--primary);
}
.filter-accordion .card-header .bi-chevron-down {
  font-size: .7rem;
  color: var(--text-muted, #64748b);
  transition: transform .2s ease;
}
.filter-accordion .card-header[aria-expanded="false"] .bi-chevron-down {
  transform: rotate(-90deg);
}
.filter-accordion .card-body {
  padding: .75rem 1rem;
}
/* compact in-row group labels */
.filter-group-label,
.dd-filter-group-label {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted, #64748b);
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .1rem 0;
}
.filter-group-label::after,
.dd-filter-group-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color, #e2e8f0);
}

/* ---- 11. Tables ---------------------------------------- */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  margin: 0;
}
.table thead th {
  padding: var(--space-3) var(--space-4);
  font-size: 11px;
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.table tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
  color: var(--text-primary);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr {
  transition: background var(--transition-fast);
}
.table tbody tr:hover { background: var(--bg-surface); }
.table-striped tbody tr:nth-of-type(even) { background: var(--bg-muted); }
.table-striped tbody tr:nth-of-type(even):hover { background: var(--bg-surface); }

/* DataTables overrides */
.dataTables_wrapper .dataTables_filter input {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  background: var(--bg-card);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.dataTables_wrapper .dataTables_filter input:focus {
  border-color: var(--primary);
  box-shadow: var(--shadow-ring);
  outline: none;
}
.dataTables_wrapper .dataTables_length select {
  padding: 0.35rem 1.75rem 0.35rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: var(--font-size-sm);
  background: var(--bg-card);
  color: var(--text-primary);
}
.dataTables_wrapper .dataTables_info {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  padding-top: var(--space-3);
}
.dataTables_wrapper .dataTables_paginate { padding-top: var(--space-2); }
.dataTables_wrapper .dataTables_paginate .paginate_button {
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--bg-surface);
  border-color: var(--border-color);
  color: var(--text-primary);
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: var(--primary-dark);
  color: #fff !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
  opacity: 0.4;
  cursor: default;
}
table.dataTable thead th.sorting::after,
table.dataTable thead th.sorting_asc::after,
table.dataTable thead th.sorting_desc::after {
  opacity: 0.5;
}

/* DataTables processing indicator — fixed center so it never gets clipped */
.dataTables_wrapper .dataTables_processing {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%);
  z-index: var(--z-modal, 1100);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1rem 1.5rem;
  min-width: 180px;
  text-align: center;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
}

/* Filter form row: ensure all field groups in a row share the same height baseline */
.row.g-3 .form-label,
.row.g-4 .form-label,
.dd-filter-row .form-label {
  display: block;
  min-height: 1.4em;
}

/* Search-actions / filter button rows — always on a new col-12 row,
   right-aligned, uniform button width, compact top spacing. */
.search-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .5rem;
  flex-wrap: wrap;
  padding-top: .5rem;
}
.search-actions .btn {
  min-width: 108px;
}

/* ---- 12. Badges ---------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.01em;
  border-radius: var(--radius-full);
  line-height: 1.5;
  white-space: nowrap;
}
.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  background: currentColor;
}
.bg-primary    { background: var(--primary-subtle) !important; color: var(--primary-dark) !important; }
.bg-success    { background: var(--success-subtle) !important; color: var(--success-dark) !important; }
.bg-warning    { background: var(--warning-subtle) !important; color: var(--warning-dark) !important; }
.bg-danger     { background: var(--danger-subtle)  !important; color: var(--danger-dark)  !important; }
.bg-info       { background: var(--info-subtle)    !important; color: var(--info-dark)    !important; }
.bg-secondary  { background: var(--bg-surface)     !important; color: var(--text-secondary) !important; }
.text-success  { color: var(--success) !important; }
.text-danger   { color: var(--danger)  !important; }
.text-warning  { color: var(--warning) !important; }
.text-primary  { color: var(--primary) !important; }
.text-muted    { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }

/* Status badge (used in tables) */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: var(--font-weight-semibold);
  border-radius: var(--radius-full);
}
.status-badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.status-success { background: var(--success-subtle); color: var(--success-dark); }
.status-failed,
.status-danger  { background: var(--danger-subtle);  color: var(--danger-dark); }
.status-pending { background: var(--warning-subtle); color: var(--warning-dark); }
.status-info    { background: var(--info-subtle);    color: var(--info-dark); }
.status-secondary { background: var(--bg-surface);  color: var(--text-secondary); }

/* ---- 13. Alerts ---------------------------------------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid;
  font-size: var(--font-size-sm);
}
.alert-success {
  background: var(--success-subtle);
  border-color: rgba(var(--success-rgb), 0.2);
  color: var(--success-dark);
}
.alert-danger {
  background: var(--danger-subtle);
  border-color: rgba(var(--danger-rgb), 0.2);
  color: var(--danger-dark);
}
.alert-warning {
  background: var(--warning-subtle);
  border-color: rgba(var(--warning-rgb), 0.2);
  color: var(--warning-dark);
}
.alert-info {
  background: var(--info-subtle);
  border-color: rgba(var(--info-rgb), 0.2);
  color: var(--info-dark);
}
.alert-dismissible .btn-close { padding: 0; filter: none; }

/* ---- 14. Dropdowns ------------------------------------- */
.dropdown-menu {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-1);
  min-width: 180px;
  font-size: var(--font-size-sm);
  animation: dropdownIn 0.15s ease;
}
@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  color: var(--text-secondary);
  border-radius: var(--radius);
  transition: background var(--transition-fast), color var(--transition-fast);
  font-size: var(--font-size-sm);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.dropdown-item:hover, .dropdown-item:focus {
  background: var(--bg-surface);
  color: var(--text-primary);
  text-decoration: none;
}
.dropdown-item.active {
  background: var(--primary-subtle);
  color: var(--primary-dark);
}
.dropdown-divider {
  border-top: 1px solid var(--border-color);
  margin: var(--space-1) 0;
}
.dropdown-header {
  font-size: 11px;
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: var(--space-2) var(--space-3) var(--space-1);
}

/* ---- 15. Modals ---------------------------------------- */
.modal-content {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  background: var(--bg-card);
  overflow: hidden;
}
.modal-header {
  background: linear-gradient(135deg, var(--primary-subtle) 0%, rgba(139,92,246,0.05) 100%);
  border-bottom: 1px solid var(--border-color);
  padding: var(--space-5) var(--space-6);
}
.modal-title {
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}
.modal-body { padding: var(--space-6); }
.modal-footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: var(--space-4) var(--space-6);
  gap: var(--space-3);
}
.btn-close:focus {
  box-shadow: var(--shadow-ring);
  outline: none;
}

/* ---- 16. Pagination ------------------------------------ */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
}
.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 var(--space-2);
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  transition: all var(--transition-fast);
  cursor: pointer;
}
.page-link:hover {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.page-item.disabled .page-link {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

/* ---- 17. Loading States -------------------------------- */
/* Global loading overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-modal) + 50);
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
}
.loading-overlay.transparent { background: rgba(255,255,255,0.6); }
.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(var(--primary-rgb), 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.loading-spinner-sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
}
.loading-text {
  color: #fff;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}

/* Page-scoped loading */
.content-loading {
  position: relative;
  pointer-events: none;
}
.content-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.6);
  border-radius: inherit;
  z-index: 5;
}

/* Skeleton loader */
.skeleton {
  background: linear-gradient(90deg, var(--bg-surface) 25%, var(--border-color) 50%, var(--bg-surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}
.skeleton-text  { height: 14px; border-radius: var(--radius-sm); margin-bottom: 8px; }
.skeleton-title { height: 20px; border-radius: var(--radius-sm); margin-bottom: 12px; }
.skeleton-card  { height: 120px; border-radius: var(--radius-lg); }
.skeleton-avatar { width: 40px; height: 40px; border-radius: 50%; }

/* Button loading state */
.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}

/* ---- 18. Toasts ---------------------------------------- */
.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 400px;
  animation: toastIn 0.3s var(--transition-spring);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast-success { border-left: 4px solid var(--success); }
.toast-error   { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }
.toast-info    { border-left: 4px solid var(--primary); }
.toast-icon {
  font-size: 1rem;
  margin-top: 2px;
  flex-shrink: 0;
}
.toast-success .toast-icon { color: var(--success); }
.toast-error   .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info    .toast-icon { color: var(--primary); }
.toast-body { flex: 1; }
.toast-title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin-bottom: 2px;
}
.toast-message { font-size: var(--font-size-xs); color: var(--text-secondary); }
.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.toast-close:hover { color: var(--text-primary); background: var(--bg-surface); }

/* ---- 19. Command Palette ------------------------------- */
.cmd-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-palette);
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  animation: fadeIn 0.15s ease;
  opacity: 1;
}
.cmd-overlay.hidden {
  display: none;
}
.cmd-palette {
  width: 100%;
  max-width: 560px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: slideDown 0.2s var(--transition-spring);
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}
.cmd-search {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-color);
}
.cmd-search-icon { color: var(--text-muted); font-size: 1rem; flex-shrink: 0; }
.cmd-input {
  flex: 1;
  border: none;
  outline: none;
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background: transparent;
}
.cmd-input::placeholder { color: var(--text-muted); }
.cmd-esc {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-muted);
}
.cmd-results {
  max-height: 360px;
  overflow-y: auto;
  padding: var(--space-2);
}
.cmd-group-label {
  font-size: 11px;
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: var(--space-2) var(--space-3);
}
.cmd-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition-fast);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}
.cmd-item:hover, .cmd-item.active {
  background: var(--primary-subtle);
  color: var(--primary-dark);
}
.cmd-item-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  flex-shrink: 0;
  color: var(--text-muted);
}
.cmd-item.active .cmd-item-icon {
  background: var(--primary-subtle);
  color: var(--primary);
}
.cmd-item-label { flex: 1; font-weight: var(--font-weight-medium); }
.cmd-item-hint { font-size: 11px; color: var(--text-muted); }
.cmd-empty {
  text-align: center;
  padding: var(--space-8) var(--space-5);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}
.cmd-footer {
  border-top: 1px solid var(--border-color);
  padding: var(--space-2) var(--space-4);
  display: flex;
  gap: var(--space-4);
  align-items: center;
  background: var(--bg-surface);
}
.cmd-hint {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* ---- 20. Glassmorphism Utilities ----------------------- */
.glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
}
.glass-dark {
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* ---- 21. Gradient Utilities ---------------------------- */
.gradient-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
}
.gradient-success {
  background: linear-gradient(135deg, var(--success) 0%, var(--info) 100%);
}
.gradient-warm {
  background: linear-gradient(135deg, var(--warning) 0%, var(--danger) 100%);
}
.gradient-text {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ---- 22. Animation Utilities --------------------------- */
@keyframes spin      { to { transform: rotate(360deg); } }
@keyframes shimmer   { to { background-position: -200% 0; } }
@keyframes fadeIn    { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp  { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse     { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes bounce    { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

.animate-fade-in    { animation: fadeIn 0.3s ease; }
.animate-fade-in-up { animation: fadeInUp 0.4s ease; }
.animate-spin       { animation: spin 1s linear infinite; }
.animate-pulse      { animation: pulse 2s ease-in-out infinite; }

/* Staggered children */
.stagger-children > * { animation: fadeInUp 0.4s ease both; }
.stagger-children > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.10s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.20s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.30s; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---- 23. Utility Classes ------------------------------- */
.shadow-sm  { box-shadow: var(--shadow-sm)  !important; }
.shadow     { box-shadow: var(--shadow)     !important; }
.shadow-md  { box-shadow: var(--shadow-md)  !important; }
.shadow-lg  { box-shadow: var(--shadow-lg)  !important; }
.shadow-none { box-shadow: none !important; }
.rounded    { border-radius: var(--radius)    !important; }
.rounded-lg { border-radius: var(--radius-lg) !important; }
.rounded-xl { border-radius: var(--radius-xl) !important; }
.rounded-full { border-radius: var(--radius-full) !important; }
.border     { border: 1px solid var(--border-color) !important; }
.border-0   { border: none !important; }
.bg-card    { background: var(--bg-card)    !important; }
.bg-surface { background: var(--bg-surface) !important; }
.bg-body    { background: var(--bg-body)    !important; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.divider { border: none; border-top: 1px solid var(--border-color); margin: var(--space-4) 0; }
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-6);
  text-align: center;
}
.empty-state-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-xl);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
}
.empty-state-title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}
.empty-state-body {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  max-width: 320px;
}

/* Confirm delete, form validation classes used by site.js */
[data-confirm-delete] { cursor: pointer; }
.form-submit-loading { opacity: 0.65; pointer-events: none; }

/* Report download link overlay (used by site.js) */
a.rsp-report-download-link,
form[data-rsp-legacy-loading] button[type="submit"] {
  position: relative;
}

/* ---- 24. Dashboard Section Titles ---------------------- */
.section-title {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.section-title h5, .section-title h6 {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin: 0;
}
.section-title .section-line {
  flex: 1;
  height: 1px;
  background: var(--border-color);
}
.section-badge {
  font-size: 11px;
  font-weight: var(--font-weight-semibold);
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 2px 8px;
}

/* ---- 25. Progress Bar ---------------------------------- */
.progress {
  height: 6px;
  background: var(--bg-surface);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-bar {
  background: var(--primary);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}
.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger  { background: var(--danger); }

/* ---- 26. Tabs ------------------------------------------ */
.nav-tabs {
  border-bottom: 2px solid var(--border-color);
  gap: 0;
}
.nav-tabs .nav-link {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  padding: var(--space-3) var(--space-4);
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: 0;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}
.nav-tabs .nav-link:hover {
  color: var(--text-primary);
  border-bottom-color: var(--border-strong);
}
.nav-tabs .nav-link.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: transparent;
  font-weight: var(--font-weight-semibold);
}

/* ---- 27. Select2 Theme --------------------------------- */
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  height: auto;
  min-height: 38px;
  background: var(--bg-card);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--default.select2-container--open .select2-selection--single {
  border-color: var(--primary);
  box-shadow: var(--shadow-ring);
  outline: none;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  color: var(--text-primary);
  line-height: 36px;
  padding-left: 12px;
  font-size: var(--font-size-sm);
}
.select2-container--default .select2-selection--single .select2-selection__placeholder {
  color: var(--text-muted);
}
.select2-dropdown {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  background: var(--bg-card);
  overflow: hidden;
}
.select2-search--dropdown .select2-search__field {
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  background: var(--bg-card);
}
.select2-results__option {
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  margin: 2px var(--space-1);
  transition: background var(--transition-fast);
}
.select2-results__option--highlighted {
  background: var(--primary-subtle) !important;
  color: var(--primary-dark) !important;
}
.select2-results__option[aria-selected="true"] {
  background: var(--bg-surface);
  color: var(--text-primary);
}

/* ---- 28. Responsive ------------------------------------ */
@media (max-width: 1024px) {
  .main-wrapper { margin-left: 0; }
  body.sidebar-collapsed .main-wrapper { margin-left: 0; }
  .mobile-sidebar-toggle { display: inline-flex; }
  .header-search-trigger .search-kbd { display: none; }
}

@media (max-width: 768px) {
  .page-content { padding: var(--space-4); }
  .app-header   { padding: 0 var(--space-4); }
  .app-footer   { padding: var(--space-3) var(--space-4); }
  .header-center { display: none; }
  .card-body { padding: var(--space-4); }
  .table thead th, .table tbody td { padding: var(--space-2) var(--space-3); }
  .metric-value { font-size: var(--font-size-2xl); }
}

@media (max-width: 576px) {
  .page-content { padding: var(--space-3); }
  h1 { font-size: var(--font-size-2xl); }
  h2 { font-size: var(--font-size-xl); }
  .page-header { flex-direction: column; align-items: flex-start; }
}

/* ---- 28b. Breadcrumb Modern ----------------------------- */
/* Used across views as <ol class="breadcrumb-modern"> */
.breadcrumb-modern {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}
.breadcrumb-modern li {
  display: flex;
  align-items: center;
}
.breadcrumb-modern a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}
.breadcrumb-modern a:hover { color: var(--primary); }
.breadcrumb-modern .active {
  color: var(--text-primary);
  font-weight: var(--font-weight-medium);
}
.breadcrumb-modern .bi-chevron-right {
  font-size: 10px;
  color: var(--text-disabled);
}

/* ---- 29. Print ----------------------------------------- */
@media print {
  .sidebar, .app-header, .app-footer, .cmd-overlay { display: none !important; }
  .main-wrapper { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  body { background: white; }
}

/* ---- 30. Legacy compat — keep old class names working -- */
.admin-wrapper { display: flex; min-height: 100vh; }
.main-content  { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.top-navbar    { /* now handled by .app-header */ }
.main-footer   { /* now handled by .app-footer */ }
.sidebar-brand-text { /* inside sidebar header */ }
.sidebar-user  { /* inside sidebar footer */ }

/* ---- Login Page ----------------------------------------- */
.changing-gradient {
    background: linear-gradient(-45deg, #ee7752, #e73c7e, #9e0ab5, #e18b14);
    background-size: 400% 400%;
    animation: gradientShift 20s ease infinite;
}
@keyframes gradientShift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.login-container {
    min-height: 100vh;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.parent-box {
    display: flex;
    flex: 1;
    min-height: 100vh;
    width: 100%;
}

.left-title {
    width: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    background: transparent;
    color: #fff;
    padding: 3rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.description-text {
    font-size: 42px;
    line-height: 1.6;
    color: #fff;
    max-width: 500px;
    text-align: center;
}

.login-card {
    width: 50%;
    /* background: #fff; */
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 4rem;
    /* box-shadow: -5px 0 30px rgba(0,0,0,.18); */
    position: relative;
    z-index: 1;
}

.main-text {
    font-size: 2rem;
    font-weight: 700;
    color: #0f172a;
    text-align: center;
    width: 100%;
    margin-bottom: 1.5rem;
}

.login-body {
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

.login-body .form-label {
    display: block;
    font-weight: 600;
    color: #0f172a;
    margin-bottom: .5rem;
    font-size: .95rem;
}

.login-body .form-control {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    font-size: 1rem;
    transition: all .3s ease;
    margin-bottom: 1.25rem;
    background-color: #f8fafc;
    color: #0f172a;
}
.login-body .form-control:hover  { border-color: #cbd5e1; background-color: #fff; }
.login-body .form-control:focus  { outline: none; border-color: #6366f1; background-color: #fff; box-shadow: 0 0 0 4px rgba(99,102,241,.12); }
.login-body .form-control::placeholder { color: #94a3b8; opacity: .7; }

#passwordInput { padding-right: 3rem; margin-bottom: 0; }
#togglePasswordBtn {
    position: absolute;
    right: 1rem; top: 50%;
    transform: translateY(-50%);
    background: none; border: none;
    padding: .5rem; cursor: pointer;
    color: #94a3b8; z-index: 10;
    display: flex; align-items: center; justify-content: center;
    transition: color .3s;
}
#togglePasswordBtn:hover { color: #6366f1; }
#togglePasswordBtn i { font-size: 1.2rem; }

.login-body .btn-primary {
    width: 100%;
    padding: 1rem;
    /* background: linear-gradient(-45deg, #ee7752, #e73c7e, #9e0ab5, #e18b14); */
    /* background-size: 400% 400%; */
    /* animation: gradientShift 20s ease infinite; */
    color: #fff;
    border: none;
    border-radius: 14px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform .3s, box-shadow .3s;
    display: flex; align-items: center; justify-content: center;
    gap: .75rem;
    margin: 1.5rem 0 1rem;
}
.login-body .btn-primary:hover  { transform: translateY(-2px); box-shadow: 0 10px 25px rgba(0,0,0,.2); }
.login-body .btn-primary:active { transform: translateY(0); }

.footer-text {
    font-size: .875rem;
    color: #94a3b8;
    margin: 0; padding: 0;
}

.login-footer {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    margin-top: 2.5rem;
    text-align: center;
    color: #9ca3af;
    font-size: .85rem;
    border-top: 1px solid #e5e7eb;
    padding-top: 2rem;
}

.login-powered-by {
    display: inline-flex;
    align-items: baseline;
    justify-content: center;
    gap: 10px;
    line-height: 1;
}
.login-powered-by-logo {
    display: inline-block;
    height: 29px;
    width: auto;
    object-fit: contain;
    vertical-align: baseline;
}

@media (max-width: 968px) {
    .parent-box { flex-direction: column; }
    .left-title, .login-card { width: 100%; }
    .left-title { padding: 4rem 2rem; min-height: 200px; }
    .login-card { padding: 3rem 2rem; }
    .login-body { max-width: 100%; }
}
@media (max-width: 480px) {
    .left-title { padding: 3rem 1.5rem; }
    .login-card { padding: 2rem 1.5rem; }
}

/* ---- 31. Bootstrap modal z-index fix ------------------- */
/* Bootstrap's default modal z-index (1055) is below our sticky
   .app-header (--z-navbar: 1090). Override so modals always sit on top. */
.modal          { z-index: var(--z-modal, 1100) !important; }
.modal-backdrop { z-index: var(--z-modal-backdrop, 1095) !important; }

/* Modal body used as a form container — remove default padding so injected
   form content can own its own spacing */
.modal-body.p-0 { padding: 0 !important; }
.co-modal-body  { padding: 1.5rem; }
