/* ==========================================================================
   SCIMS Design System
   Modern SaaS aesthetic — Inter font, indigo/slate palette, soft shadows
   ========================================================================== */

/* ---------- 1. Design Tokens ---------- */
:root,
[data-bs-theme="light"] {
  /* Brand */
  --scims-primary:        #4f46e5;   /* indigo-600 */
  --scims-primary-hover:  #4338ca;   /* indigo-700 */
  --scims-primary-soft:   #eef2ff;   /* indigo-50  */
  --scims-primary-ink:    #312e81;   /* indigo-900 */

  /* Status */
  --scims-success:        #10b981;
  --scims-success-soft:   #d1fae5;
  --scims-warning:        #f59e0b;
  --scims-warning-soft:   #fef3c7;
  --scims-danger:         #ef4444;
  --scims-danger-soft:    #fee2e2;
  --scims-info:           #06b6d4;
  --scims-info-soft:      #cffafe;

  /* Neutrals (slate scale) */
  --scims-bg:             #f8fafc;   /* page bg     */
  --scims-surface:        #ffffff;   /* card / topbar */
  --scims-surface-2:      #f1f5f9;   /* hover, alt rows */
  --scims-border:         #e2e8f0;
  --scims-border-strong:  #cbd5e1;
  --scims-text:           #0f172a;   /* headings   */
  --scims-text-secondary: #475569;   /* body       */
  --scims-text-muted:     #94a3b8;

  /* Sidebar */
  --scims-sidebar-bg:        #ffffff;
  --scims-sidebar-border:    #e2e8f0;
  --scims-sidebar-text:      #475569;
  --scims-sidebar-text-strong:#0f172a;
  --scims-sidebar-hover:     #f1f5f9;
  --scims-sidebar-active-bg: #eef2ff;
  --scims-sidebar-active-fg: #4f46e5;

  /* Typography */
  --scims-font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
                     Roboto, Helvetica, Arial, sans-serif;
  --scims-font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo,
                     Monaco, Consolas, monospace;

  /* Spacing scale */
  --scims-s-1:  4px;
  --scims-s-2:  8px;
  --scims-s-3:  12px;
  --scims-s-4:  16px;
  --scims-s-5:  24px;
  --scims-s-6:  32px;
  --scims-s-7:  48px;

  /* Radius */
  --scims-r-sm: 6px;
  --scims-r-md: 10px;
  --scims-r-lg: 14px;
  --scims-r-xl: 20px;

  /* Shadows */
  --scims-shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --scims-shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --scims-shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --scims-shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.10), 0 8px 10px -6px rgba(15, 23, 42, 0.05);

  /* Bootstrap variable overrides */
  --bs-body-font-family: var(--scims-font-sans);
  --bs-body-color: var(--scims-text);
  --bs-body-bg: var(--scims-bg);
  --bs-primary: var(--scims-primary);
  --bs-primary-rgb: 79, 70, 229;
  --bs-success-rgb: 16, 185, 129;
  --bs-warning-rgb: 245, 158, 11;
  --bs-danger-rgb: 239, 68, 68;
  --bs-info-rgb: 6, 182, 212;
  --bs-border-color: var(--scims-border);
  --bs-border-radius: var(--scims-r-md);
  --bs-border-radius-sm: var(--scims-r-sm);
  --bs-border-radius-lg: var(--scims-r-lg);
}

[data-bs-theme="dark"] {
  --scims-primary:        #818cf8;
  --scims-primary-hover:  #6366f1;
  --scims-primary-soft:   #1e1b4b;
  --scims-primary-ink:    #c7d2fe;

  --scims-success:        #34d399;
  --scims-success-soft:   #064e3b;
  --scims-warning:        #fbbf24;
  --scims-warning-soft:   #78350f;
  --scims-danger:         #f87171;
  --scims-danger-soft:    #7f1d1d;
  --scims-info:           #22d3ee;
  --scims-info-soft:      #164e63;

  --scims-bg:             #0b1220;
  --scims-surface:        #111827;
  --scims-surface-2:      #1f2937;
  --scims-border:         #1f2937;
  --scims-border-strong:  #334155;
  --scims-text:           #f1f5f9;
  --scims-text-secondary: #cbd5e1;
  --scims-text-muted:     #64748b;

  --scims-sidebar-bg:        #0f172a;
  --scims-sidebar-border:    #1e293b;
  --scims-sidebar-text:      #cbd5e1;
  --scims-sidebar-text-strong:#f8fafc;
  --scims-sidebar-hover:     #1e293b;
  --scims-sidebar-active-bg: rgba(79, 70, 229, 0.15);
  --scims-sidebar-active-fg: #a5b4fc;

  --bs-body-color: var(--scims-text);
  --bs-body-bg: var(--scims-bg);
  --bs-border-color: var(--scims-border);
}

/* ---------- 2. Base ---------- */
* { box-sizing: border-box; }

html, body {
  font-family: var(--scims-font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  letter-spacing: -0.005em;
}

body {
  background-color: var(--scims-bg);
  color: var(--scims-text);
  font-size: 14px;
  line-height: 1.55;
  margin: 0;
}

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
  color: var(--scims-text);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

h1, .h1 { font-size: 1.875rem; }   /* 30 */
h2, .h2 { font-size: 1.5rem; }     /* 24 */
h3, .h3 { font-size: 1.25rem; }    /* 20 */
h4, .h4 { font-size: 1.125rem; }   /* 18 */
h5, .h5 { font-size: 1rem; }       /* 16 */
h6, .h6 { font-size: 0.875rem; }

p, li, td, th, label, input, select, textarea, button {
  font-family: var(--scims-font-sans);
}

a { color: var(--scims-primary); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--scims-primary-hover); }

code, pre, .font-monospace { font-family: var(--scims-font-mono); font-size: 0.85em; }

.text-muted { color: var(--scims-text-muted) !important; }
.text-secondary { color: var(--scims-text-secondary) !important; }

/* ---------- 3. App Layout Shell ---------- */
.d-flex > .flex-grow-1 { min-width: 0; }      /* prevent overflow */

/* container padding for main content */
.container-fluid.p-4 {
  padding: var(--scims-s-6) !important;
  max-width: 1600px;
}

/* ---------- 4. Sidebar ---------- */
.sidebar-container {
  background: var(--scims-sidebar-bg) !important;
  border-right: 1px solid var(--scims-sidebar-border) !important;
  width: 256px !important;
  box-shadow: var(--scims-shadow-xs);
}

.sidebar-container::-webkit-scrollbar { width: 0; height: 0; }

.sidebar-header {
  padding: var(--scims-s-5) var(--scims-s-5) var(--scims-s-4) !important;
  border-bottom: 1px solid var(--scims-sidebar-border) !important;
}

.sidebar-title {
  font-size: 1.125rem !important;
  font-weight: 700 !important;
  color: var(--scims-sidebar-text-strong) !important;
  display: flex;
  align-items: center;
  letter-spacing: -0.02em;
}

.sidebar-title i {
  color: var(--scims-primary);
  margin-right: 8px;
}

.sidebar-subtitle {
  color: var(--scims-text-muted) !important;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.sidebar-container nav { padding: var(--scims-s-2) var(--scims-s-3); }

/* Sidebar nav items */
.sidebar-link,
.sidebar-accordion-btn {
  background: transparent !important;
  color: var(--scims-sidebar-text) !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  padding: 0.5rem 0.75rem !important;
  border-radius: var(--scims-r-sm) !important;
  margin: 1px 0 !important;
  border: 0 !important;
  box-shadow: none !important;
  transition: all .15s ease !important;
  display: flex !important;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none !important;
}

.sidebar-link i,
.sidebar-accordion-btn i {
  font-size: 1rem;
  width: 18px;
  text-align: center;
  color: var(--scims-text-muted);
  transition: color .15s ease;
}

.sidebar-link:hover,
.sidebar-accordion-btn:hover {
  background: var(--scims-sidebar-hover) !important;
  color: var(--scims-sidebar-text-strong) !important;
}

.sidebar-link:hover i,
.sidebar-accordion-btn:hover i {
  color: var(--scims-sidebar-text-strong);
}

.sidebar-link.active,
.sidebar-accordion-btn:not(.collapsed) {
  background: var(--scims-sidebar-active-bg) !important;
  color: var(--scims-sidebar-active-fg) !important;
  font-weight: 600 !important;
}

.sidebar-accordion-btn:not(.collapsed) i,
.sidebar-link.active i {
  color: var(--scims-sidebar-active-fg);
}

/* Sub-links inside accordion */
.sidebar-container .accordion-body {
  padding: 2px 0 6px 0 !important;
  background: transparent !important;
}

.sidebar-container .accordion-body .sidebar-link {
  font-size: 0.8125rem !important;
  padding-left: 2.625rem !important;
  color: var(--scims-text-secondary) !important;
}

.sidebar-container .accordion-body .sidebar-link:hover {
  color: var(--scims-sidebar-text-strong) !important;
  background: var(--scims-sidebar-hover) !important;
}

/* Accordion chevron */
.accordion-button::after {
  width: 0.85rem;
  height: 0.85rem;
  background-size: 0.85rem;
  filter: opacity(0.5);
}

[data-bs-theme="dark"] .accordion-button::after {
  filter: invert(1) opacity(0.6);
}

.sidebar-accordion-item {
  background: transparent !important;
  border: 0 !important;
}

/* Sidebar footer */
.sidebar-footer {
  padding: var(--scims-s-4) var(--scims-s-4) !important;
  border-top: 1px solid var(--scims-sidebar-border) !important;
  background: var(--scims-sidebar-bg);
}

.sidebar-user-name {
  color: var(--scims-sidebar-text-strong) !important;
  font-size: 0.875rem;
  font-weight: 600;
}

.sidebar-user-role {
  color: var(--scims-text-muted) !important;
  font-size: 0.75rem;
  text-transform: capitalize;
}

.sidebar-logout-btn {
  background: var(--scims-surface-2) !important;
  border: 1px solid var(--scims-border) !important;
  color: var(--scims-text-secondary) !important;
  width: 36px; height: 36px;
  border-radius: var(--scims-r-sm) !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  transition: all .15s ease;
  margin: 0 !important;
  transform: none !important;
}

.sidebar-logout-btn:hover {
  background: var(--scims-danger) !important;
  color: #fff !important;
  border-color: var(--scims-danger) !important;
}

/* Adjust main content offset */
.d-flex > .flex-grow-1[style*="margin-left: 260px"] {
  margin-left: 256px !important;
}

/* ---------- 5. Topbar ---------- */
.navbar.topbar,
[data-bs-theme="light"] .navbar.topbar,
[data-bs-theme="dark"] .navbar.topbar {
  background: var(--scims-surface) !important;
  height: 60px !important;
  border-bottom: 1px solid var(--scims-border) !important;
  box-shadow: var(--scims-shadow-xs) !important;
  padding: 0 var(--scims-s-5) !important;
  margin-bottom: 0 !important;
}

.navbar.topbar .nav-link,
.navbar.topbar .navbar-text,
[data-bs-theme="light"] .navbar.topbar .nav-link,
[data-bs-theme="light"] .navbar.topbar .navbar-text,
[data-bs-theme="light"] .navbar.topbar .text-muted {
  color: var(--scims-text-secondary) !important;
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem !important;
}

.navbar.topbar .nav-link:hover,
[data-bs-theme="light"] .navbar.topbar .nav-link:hover {
  color: var(--scims-text) !important;
}

.navbar.topbar .navbar-text strong,
[data-bs-theme="light"] .navbar.topbar .navbar-text strong {
  color: var(--scims-text) !important;
  font-weight: 600;
}

.navbar.topbar .badge.bg-primary {
  background: var(--scims-primary-soft) !important;
  color: var(--scims-primary) !important;
  font-weight: 600;
  border: 1px solid transparent;
}

[data-bs-theme="dark"] .navbar.topbar .badge.bg-primary {
  background: rgba(79, 70, 229, 0.15) !important;
  color: var(--scims-primary) !important;
}

.navbar.topbar .dropdown-toggle::after {
  margin-left: 0.4rem;
  opacity: 0.5;
}

/* User avatar in topbar */
.navbar.topbar .nav-item .bg-primary.rounded-circle {
  background: linear-gradient(135deg, var(--scims-primary) 0%, var(--scims-primary-hover) 100%) !important;
  width: 34px !important;
  height: 34px !important;
  font-size: 0.8125rem;
  font-weight: 600;
  box-shadow: var(--scims-shadow-sm);
}

/* ---------- 6. Cards ---------- */
.card,
[data-bs-theme="light"] .card {
  background: var(--scims-surface) !important;
  border: 1px solid var(--scims-border) !important;
  border-radius: var(--scims-r-lg) !important;
  box-shadow: var(--scims-shadow-xs) !important;
  color: var(--scims-text) !important;
  overflow: hidden;
  transition: box-shadow .2s ease, transform .2s ease;
}

[data-bs-theme="dark"] .card {
  background: var(--scims-surface) !important;
  border-color: var(--scims-border) !important;
  color: var(--scims-text) !important;
}

.card + .card { margin-top: var(--scims-s-4); }

.card-header,
[data-bs-theme="light"] .card-header {
  background: var(--scims-surface) !important;
  border-bottom: 1px solid var(--scims-border) !important;
  padding: var(--scims-s-4) var(--scims-s-5) !important;
  font-weight: 600 !important;
  color: var(--scims-text) !important;
  font-size: 0.9375rem;
}

.card-header h1, .card-header h2, .card-header h3,
.card-header h4, .card-header h5, .card-header h6 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

.card-body,
[data-bs-theme="light"] .card-body {
  padding: var(--scims-s-5);
  color: var(--scims-text) !important;
}

[data-bs-theme="dark"] .card-body { color: var(--scims-text) !important; }

/* When a card-body contains only a responsive table, drop the body padding so
   the table edges flush with the card. Gated behind @supports so older browsers
   without :has() simply fall back to normal padded body — safe either way. */
@supports selector(:has(> *)) {
  .card > .card-body:has(> .table-responsive:only-child),
  .card > .card-body:has(> .table:only-child) {
    padding: 0;
  }
}

.card-footer {
  background: var(--scims-surface-2) !important;
  border-top: 1px solid var(--scims-border) !important;
  padding: var(--scims-s-3) var(--scims-s-5) !important;
}

/* Stat-card border-left utility (used on dashboard).
   Class-based, so it survives any markup change to inline style attributes. */
.card.border-left-primary,
.card.border-left-success,
.card.border-left-info,
.card.border-left-warning,
.card.border-left-danger,
.card.border-left-secondary,
.card[style*="border-left"] {
  border-left-width: 0 !important;
  position: relative;
}
.card.border-left-primary::before,
.card.border-left-success::before,
.card.border-left-info::before,
.card.border-left-warning::before,
.card.border-left-danger::before,
.card.border-left-secondary::before,
.card[style*="border-left"]::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: 3px 0 0 3px;
  background: var(--scims-primary);
}
.card.border-left-success::before,
.card[style*="#1cc88a"]::before { background: var(--scims-success); }
.card.border-left-info::before,
.card[style*="#36b9cc"]::before { background: var(--scims-info); }
.card.border-left-warning::before,
.card[style*="#f6c23e"]::before { background: var(--scims-warning); }
.card.border-left-danger::before,
.card[style*="#e74a3b"]::before { background: var(--scims-danger); }
.card.border-left-secondary::before { background: var(--scims-text-muted); }

.text-gray-300 { color: var(--scims-border-strong) !important; }
.text-gray-800 { color: var(--scims-text) !important; }
.text-xs       { font-size: 0.6875rem !important; letter-spacing: 0.05em; }
.font-weight-bold { font-weight: 600 !important; }

/* ---------- 7. Buttons ---------- */
.btn {
  font-family: var(--scims-font-sans) !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  padding: 0.5rem 1rem !important;
  border-radius: var(--scims-r-sm) !important;
  border-width: 1px !important;
  letter-spacing: -0.005em;
  transition: all .15s ease !important;
  box-shadow: var(--scims-shadow-xs);
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  white-space: nowrap;
}
.btn:focus-visible {
  outline: 2px solid var(--scims-primary);
  outline-offset: 2px;
  box-shadow: none;
}
.btn:active { transform: translateY(1px); }
.btn i.bi { font-size: 1em; }

.btn-sm {
  padding: 0.3125rem 0.625rem !important;
  font-size: 0.8125rem !important;
  border-radius: var(--scims-r-sm) !important;
}
.btn-lg {
  padding: 0.75rem 1.25rem !important;
  font-size: 0.9375rem !important;
  border-radius: var(--scims-r-md) !important;
}

.btn-primary,
[data-bs-theme="dark"] .btn-primary {
  background: var(--scims-primary) !important;
  border-color: var(--scims-primary) !important;
  color: #fff !important;
}
.btn-primary:hover,
[data-bs-theme="dark"] .btn-primary:hover {
  background: var(--scims-primary-hover) !important;
  border-color: var(--scims-primary-hover) !important;
  color: #fff !important;
}

.btn-secondary {
  background: var(--scims-surface) !important;
  border-color: var(--scims-border-strong) !important;
  color: var(--scims-text-secondary) !important;
}
.btn-secondary:hover {
  background: var(--scims-surface-2) !important;
  border-color: var(--scims-border-strong) !important;
  color: var(--scims-text) !important;
}

.btn-success { background: var(--scims-success) !important; border-color: var(--scims-success) !important; color: #fff !important; }
.btn-success:hover { background: #059669 !important; border-color: #059669 !important; }

.btn-warning { background: var(--scims-warning) !important; border-color: var(--scims-warning) !important; color: #78350f !important; }
.btn-warning:hover { background: #d97706 !important; border-color: #d97706 !important; color: #fff !important; }

.btn-danger { background: var(--scims-danger) !important; border-color: var(--scims-danger) !important; color: #fff !important; }
.btn-danger:hover { background: #dc2626 !important; border-color: #dc2626 !important; }

.btn-info { background: var(--scims-info) !important; border-color: var(--scims-info) !important; color: #fff !important; }
.btn-info:hover { background: #0891b2 !important; border-color: #0891b2 !important; color: #fff !important; }

.btn-outline-primary,
[data-bs-theme="dark"] .btn-outline-primary {
  background: transparent !important;
  border-color: var(--scims-primary) !important;
  color: var(--scims-primary) !important;
}
.btn-outline-primary:hover,
[data-bs-theme="dark"] .btn-outline-primary:hover {
  background: var(--scims-primary) !important;
  color: #fff !important;
}

.btn-outline-secondary {
  border-color: var(--scims-border-strong) !important;
  color: var(--scims-text-secondary) !important;
  background: transparent !important;
}
.btn-outline-secondary:hover {
  background: var(--scims-surface-2) !important;
  color: var(--scims-text) !important;
}

.btn-outline-danger {
  border-color: var(--scims-danger) !important;
  color: var(--scims-danger) !important;
  background: transparent !important;
}
.btn-outline-danger:hover {
  background: var(--scims-danger) !important;
  color: #fff !important;
}

.btn-link {
  box-shadow: none !important;
  color: var(--scims-primary) !important;
  padding: 0.25rem 0.5rem !important;
  text-decoration: none !important;
}
.btn-link:hover { color: var(--scims-primary-hover) !important; }

.btn-close {
  filter: opacity(0.5);
  transition: filter .15s ease;
}
.btn-close:hover { filter: opacity(0.9); }
[data-bs-theme="dark"] .btn-close { filter: invert(1) opacity(0.6); }
[data-bs-theme="dark"] .btn-close:hover { filter: invert(1) opacity(0.95); }

/* ---------- 8. Forms ---------- */
.form-label,
[data-bs-theme="light"] .form-label {
  color: var(--scims-text) !important;
  font-weight: 500 !important;
  font-size: 0.8125rem;
  margin-bottom: 0.4rem;
  letter-spacing: -0.005em;
}

.form-label .text-danger,
.form-label.required::after {
  content: ' *';
  color: var(--scims-danger);
}

.form-control,
.form-select,
[data-bs-theme="light"] .form-control,
[data-bs-theme="light"] .form-select {
  background: var(--scims-surface) !important;
  border: 1px solid var(--scims-border-strong) !important;
  color: var(--scims-text) !important;
  border-radius: var(--scims-r-sm) !important;
  font-size: 0.875rem !important;
  padding: 0.5rem 0.75rem !important;
  transition: border-color .15s ease, box-shadow .15s ease !important;
  box-shadow: var(--scims-shadow-xs);
  line-height: 1.4;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  background: var(--scims-surface-2) !important;
  border-color: var(--scims-border-strong) !important;
  color: var(--scims-text) !important;
}

.form-control:focus,
.form-select:focus,
[data-bs-theme="light"] .form-control:focus,
[data-bs-theme="light"] .form-select:focus {
  border-color: var(--scims-primary) !important;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15) !important;
  outline: none;
}

.form-control::placeholder,
[data-bs-theme="light"] .form-control::placeholder {
  color: var(--scims-text-muted) !important;
  opacity: 1;
}

.form-control:disabled,
.form-select:disabled {
  background: var(--scims-surface-2) !important;
  cursor: not-allowed;
  opacity: 0.7;
}

.form-control.is-invalid,
.form-select.is-invalid {
  border-color: var(--scims-danger) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12) !important;
}

.invalid-feedback {
  font-size: 0.75rem;
  color: var(--scims-danger);
  font-weight: 500;
  margin-top: 0.25rem;
}

.form-text, small.text-muted {
  font-size: 0.75rem !important;
  color: var(--scims-text-muted) !important;
  margin-top: 0.25rem;
}

.form-check-input {
  border-color: var(--scims-border-strong);
  width: 1rem; height: 1rem;
  margin-top: 0.2rem;
}
.form-check-input:checked {
  background-color: var(--scims-primary);
  border-color: var(--scims-primary);
}
.form-check-input:focus {
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
  border-color: var(--scims-primary);
}
.form-check-label { color: var(--scims-text-secondary); font-size: 0.875rem; }

/* Input groups */
.input-group-text {
  background: var(--scims-surface-2) !important;
  border-color: var(--scims-border-strong) !important;
  color: var(--scims-text-muted) !important;
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
}

/* Form spacing */
.mb-3 { margin-bottom: 1.125rem !important; }

/* ---------- 9. Tables ---------- */
.table,
[data-bs-theme="light"] .table {
  color: var(--scims-text) !important;
  margin-bottom: 0;
  border-color: var(--scims-border) !important;
  font-size: 0.875rem;
}

.table thead th,
[data-bs-theme="light"] .table thead th {
  background: var(--scims-surface-2) !important;
  color: var(--scims-text-secondary) !important;
  font-weight: 600 !important;
  font-size: 0.6875rem !important;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.75rem 1rem !important;
  border-top: 0 !important;
  border-bottom: 1px solid var(--scims-border) !important;
  white-space: nowrap;
}

[data-bs-theme="dark"] .table thead th {
  background: var(--scims-surface-2) !important;
  color: var(--scims-text-secondary) !important;
  border-bottom-color: var(--scims-border) !important;
}

.table tbody td,
[data-bs-theme="light"] .table tbody td {
  color: var(--scims-text) !important;
  padding: 0.75rem 1rem !important;
  vertical-align: middle;
  border-top: 1px solid var(--scims-border);
}

[data-bs-theme="dark"] .table tbody td {
  color: var(--scims-text) !important;
  border-top-color: var(--scims-border);
}

.table tbody tr { transition: background .12s ease; }
.table-hover tbody tr:hover {
  background: var(--scims-surface-2) !important;
}

.table tbody tr:first-child td { border-top: 0; }

/* Cards containing tables: tighten padding */
.card > .table-responsive > .table,
.card > .card-body > .table-responsive > .table { margin-bottom: 0; }
.card > .card-body { padding: 0 !important; }
.card > .card-header + .card-body > .table-responsive { padding: 0; }
.card > .card-body > .table-responsive { padding: 0; }
.card > .card-body > *:not(.table-responsive):not(table) {
  padding: var(--scims-s-5);
}
/* Restore body padding when no table */
.card > .card-body:not(:has(.table-responsive)):not(:has(table)) {
  padding: var(--scims-s-5) !important;
}

/* ---------- 10. Badges ---------- */
.badge {
  font-size: 0.6875rem !important;
  font-weight: 600 !important;
  padding: 0.3rem 0.55rem !important;
  border-radius: var(--scims-r-sm) !important;
  letter-spacing: 0.02em;
  text-transform: capitalize;
  border: 1px solid transparent;
}

.badge.bg-primary { background: var(--scims-primary-soft) !important; color: var(--scims-primary) !important; }
.badge.bg-success { background: var(--scims-success-soft) !important; color: var(--scims-success) !important; }
.badge.bg-warning { background: var(--scims-warning-soft) !important; color: #92400e !important; }
.badge.bg-danger  { background: var(--scims-danger-soft)  !important; color: var(--scims-danger)  !important; }
.badge.bg-info    { background: var(--scims-info-soft)    !important; color: #0e7490 !important; }
.badge.bg-secondary { background: var(--scims-surface-2) !important; color: var(--scims-text-secondary) !important; }
.badge.bg-light { background: var(--scims-surface-2) !important; color: var(--scims-text-secondary) !important; }
.badge.bg-dark { background: var(--scims-text) !important; color: #fff !important; }

[data-bs-theme="dark"] .badge.bg-primary { background: rgba(129, 140, 248, 0.15) !important; color: var(--scims-primary) !important; }
[data-bs-theme="dark"] .badge.bg-success { background: rgba(52, 211, 153, 0.15) !important; color: var(--scims-success) !important; }
[data-bs-theme="dark"] .badge.bg-warning { background: rgba(251, 191, 36, 0.15) !important; color: var(--scims-warning) !important; }
[data-bs-theme="dark"] .badge.bg-danger  { background: rgba(248, 113, 113, 0.15) !important; color: var(--scims-danger)  !important; }
[data-bs-theme="dark"] .badge.bg-info    { background: rgba(34, 211, 238, 0.15) !important; color: var(--scims-info)    !important; }

/* ---------- 11. Alerts ---------- */
.alert {
  border-radius: var(--scims-r-md) !important;
  border: 1px solid transparent !important;
  padding: 0.875rem 1rem !important;
  font-size: 0.875rem !important;
  box-shadow: var(--scims-shadow-xs);
}

.alert-primary { background: var(--scims-primary-soft) !important; color: var(--scims-primary-ink) !important; border-color: rgba(79, 70, 229, 0.2) !important; }
.alert-success { background: var(--scims-success-soft) !important; color: #065f46 !important; border-color: rgba(16, 185, 129, 0.25) !important; }
.alert-warning { background: var(--scims-warning-soft) !important; color: #92400e !important; border-color: rgba(245, 158, 11, 0.25) !important; }
.alert-danger  { background: var(--scims-danger-soft)  !important; color: #991b1b !important; border-color: rgba(239, 68, 68, 0.25) !important; }
.alert-info    { background: var(--scims-info-soft)    !important; color: #0e7490 !important; border-color: rgba(6, 182, 212, 0.25) !important; }

[data-bs-theme="dark"] .alert-primary { color: #c7d2fe !important; }
[data-bs-theme="dark"] .alert-success { color: #6ee7b7 !important; }
[data-bs-theme="dark"] .alert-warning { color: #fcd34d !important; }
[data-bs-theme="dark"] .alert-danger  { color: #fca5a5 !important; }
[data-bs-theme="dark"] .alert-info    { color: #67e8f9 !important; }

/* ---------- 12. Dropdowns ---------- */
.dropdown-menu,
[data-bs-theme="light"] .dropdown-menu {
  background: var(--scims-surface) !important;
  border: 1px solid var(--scims-border) !important;
  border-radius: var(--scims-r-md) !important;
  box-shadow: var(--scims-shadow-lg) !important;
  padding: 0.375rem !important;
  min-width: 220px;
  font-size: 0.875rem;
  color: var(--scims-text) !important;
}

.dropdown-item,
[data-bs-theme="light"] .dropdown-item {
  border-radius: var(--scims-r-sm) !important;
  padding: 0.5rem 0.75rem !important;
  color: var(--scims-text-secondary) !important;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all .12s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dropdown-item:hover,
.dropdown-item:focus,
[data-bs-theme="light"] .dropdown-item:hover {
  background: var(--scims-surface-2) !important;
  color: var(--scims-text) !important;
}

.dropdown-item.text-danger { color: var(--scims-danger) !important; }
.dropdown-item.text-danger:hover { background: var(--scims-danger-soft) !important; color: var(--scims-danger) !important; }

.dropdown-divider {
  border-top: 1px solid var(--scims-border) !important;
  margin: 0.375rem 0 !important;
}

.dropdown-header {
  color: var(--scims-text-muted) !important;
  font-size: 0.6875rem !important;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.5rem 0.75rem 0.25rem !important;
}

/* ---------- 13. Modals ---------- */
.modal-content {
  background: var(--scims-surface) !important;
  border: 1px solid var(--scims-border) !important;
  border-radius: var(--scims-r-lg) !important;
  box-shadow: var(--scims-shadow-lg) !important;
}
.modal-header {
  border-bottom: 1px solid var(--scims-border) !important;
  padding: var(--scims-s-4) var(--scims-s-5) !important;
}
.modal-body { padding: var(--scims-s-5) !important; }
.modal-footer {
  border-top: 1px solid var(--scims-border) !important;
  padding: var(--scims-s-3) var(--scims-s-5) !important;
}

/* ---------- 14. Tabs ---------- */
.nav-tabs { border-bottom: 1px solid var(--scims-border) !important; gap: 0.25rem; }
.nav-tabs .nav-link,
[data-bs-theme="light"] .nav-tabs .nav-link {
  color: var(--scims-text-secondary) !important;
  border: 0 !important;
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.625rem 0.875rem !important;
  border-radius: 0 !important;
  border-bottom: 2px solid transparent !important;
  background: transparent !important;
  transition: all .15s ease;
}
.nav-tabs .nav-link:hover {
  color: var(--scims-text) !important;
  background: var(--scims-surface-2) !important;
}
.nav-tabs .nav-link.active,
[data-bs-theme="light"] .nav-tabs .nav-link.active {
  color: var(--scims-primary) !important;
  border-bottom-color: var(--scims-primary) !important;
  background: transparent !important;
}

/* ---------- 15. List groups ---------- */
.list-group { border-radius: var(--scims-r-md); overflow: hidden; }
.list-group-item,
[data-bs-theme="light"] .list-group-item {
  background: var(--scims-surface) !important;
  border-color: var(--scims-border) !important;
  color: var(--scims-text) !important;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
}

/* ---------- 16. Pagination ---------- */
.pagination { gap: 2px; }
.page-link {
  border: 1px solid var(--scims-border) !important;
  color: var(--scims-text-secondary) !important;
  background: var(--scims-surface) !important;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem !important;
  border-radius: var(--scims-r-sm) !important;
}
.page-link:hover {
  background: var(--scims-surface-2) !important;
  color: var(--scims-text) !important;
  border-color: var(--scims-border-strong) !important;
}
.page-item.active .page-link {
  background: var(--scims-primary) !important;
  border-color: var(--scims-primary) !important;
  color: #fff !important;
}

/* ---------- 17. Page loader ---------- */
#page-loader {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}
.loader-spinner {
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
}

/* ---------- 18. Auth (login/forgot) layout ---------- */
.auth-layout {
  min-height: 100vh;
  background:
    radial-gradient(circle at 0% 0%, rgba(79, 70, 229, 0.10), transparent 40%),
    radial-gradient(circle at 100% 100%, rgba(6, 182, 212, 0.10), transparent 40%),
    var(--scims-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--scims-s-5);
}

.auth-card {
  background: var(--scims-surface);
  border: 1px solid var(--scims-border);
  border-radius: var(--scims-r-xl);
  box-shadow: var(--scims-shadow-lg);
  padding: var(--scims-s-7) var(--scims-s-6);
  width: 100%;
  max-width: 420px;
}

.auth-brand {
  text-align: center;
  margin-bottom: var(--scims-s-6);
}
.auth-brand .auth-logo {
  width: 56px; height: 56px;
  border-radius: var(--scims-r-md);
  background: linear-gradient(135deg, var(--scims-primary), var(--scims-primary-hover));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: var(--scims-s-3);
  box-shadow: var(--scims-shadow-md);
}
.auth-brand h1 {
  font-size: 1.375rem;
  margin-bottom: var(--scims-s-1);
}
.auth-brand p { color: var(--scims-text-muted); font-size: 0.875rem; margin: 0; }

/* ---------- 19. Misc utilities ---------- */
hr { border-color: var(--scims-border) !important; opacity: 1; }

.shadow-sm { box-shadow: var(--scims-shadow-sm) !important; }
.shadow    { box-shadow: var(--scims-shadow-md) !important; }
.shadow-lg { box-shadow: var(--scims-shadow-lg) !important; }

/* Scrollbars (subtle) */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--scims-border-strong);
  border-radius: 8px;
  border: 2px solid var(--scims-bg);
}
*::-webkit-scrollbar-thumb:hover { background: var(--scims-text-muted); }

/* ============================================================
   NAVIGATION v2 — Shell, Sidebar groups, Topbar, Breadcrumbs
   ============================================================ */

/* App shell layout */
.scims-shell { display: flex; min-height: 100vh; width: 100%; }
.scims-shell--guest { display: block; }
.scims-shell--auth .scims-main {
  flex: 1 1 auto;
  min-width: 0;
  margin-left: var(--scims-sidebar-w, 264px);
  transition: margin-left .22s ease;
}
.scims-shell--auth.scims-shell--collapsed .scims-main { margin-left: 72px; }
.scims-content { padding: 1.25rem 1.5rem 2rem; }

/* ── Sidebar container (overrides earlier rule for new geometry) ── */
.sidebar-container {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--scims-sidebar-w, 264px);
  display: flex; flex-direction: column;
  background: var(--scims-surface) !important;
  border-right: 1px solid var(--scims-border) !important;
  box-shadow: var(--scims-shadow-sm);
  z-index: 1040;
  transition: width .22s ease, transform .25s ease;
  overflow: hidden;
}

/* Sidebar header (brand + collapse toggle) */
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1rem 0.875rem;
  border-bottom: 1px solid var(--scims-border);
  flex: 0 0 auto;
  gap: 0.5rem;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 0.625rem;
  text-decoration: none; color: inherit; min-width: 0; flex: 1 1 auto;
}
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand-mark {
  width: 36px; height: 36px; flex: 0 0 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--scims-primary), var(--scims-primary-600));
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.05rem;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.25);
}
.sidebar-brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.1; }
.sidebar-brand-text .sidebar-title {
  font-size: 0.95rem; font-weight: 700; color: var(--scims-text);
  letter-spacing: 0.01em;
}
.sidebar-brand-text .sidebar-subtitle {
  font-size: 0.6875rem; color: var(--scims-text-muted);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}
.sidebar-collapse-toggle {
  flex: 0 0 auto;
  background: transparent; border: 0; color: var(--scims-text-muted);
  width: 30px; height: 30px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background-color .15s ease, color .15s ease, transform .25s ease;
}
.sidebar-collapse-toggle:hover { background: var(--scims-surface-hover); color: var(--scims-text); }
.scims-shell--collapsed .sidebar-collapse-toggle { transform: rotate(180deg); }

/* Search */
.sidebar-search {
  position: relative;
  margin: 0.875rem 0.875rem 0.5rem;
  flex: 0 0 auto;
}
.sidebar-search-icon {
  position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%);
  color: var(--scims-text-muted); font-size: 0.95rem; pointer-events: none;
}
.sidebar-search-input {
  width: 100%;
  background: var(--scims-surface-2);
  border: 1px solid var(--scims-border);
  border-radius: var(--scims-radius-sm);
  padding: 0.5rem 2.25rem 0.5rem 2.25rem;
  font-size: 0.85rem;
  color: var(--scims-text);
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.sidebar-search-input::placeholder { color: var(--scims-text-muted); }
.sidebar-search-input:focus {
  outline: none;
  border-color: var(--scims-primary);
  background: var(--scims-surface);
  box-shadow: 0 0 0 3px var(--scims-primary-soft);
}
.sidebar-search-kbd {
  position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%);
  font-family: var(--scims-font-sans);
  font-size: 0.7rem; font-weight: 600;
  color: var(--scims-text-muted);
  background: var(--scims-surface);
  border: 1px solid var(--scims-border);
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  line-height: 1.2;
  pointer-events: none;
}

/* Scrollable nav region */
.sidebar-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.25rem 0.5rem 1rem;
  scrollbar-gutter: stable;
}

/* Sections */
.sidebar-section { margin: 0.25rem 0; }
.sidebar-section--pinned { margin-bottom: 0.5rem; }
.sidebar-section--favorites { margin-bottom: 0.75rem; }

.sidebar-section-label {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.75rem 0.25rem;
  font-size: 0.6875rem; font-weight: 700;
  color: var(--scims-text-muted);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.sidebar-section-label .bi { font-size: 0.85rem; color: var(--scims-warning); }

.sidebar-section-toggle {
  display: flex; align-items: center; gap: 0.625rem;
  width: 100%;
  background: transparent; border: 0;
  padding: 0.55rem 0.75rem;
  color: var(--scims-text);
  font-size: 0.85rem; font-weight: 600;
  border-radius: var(--scims-radius-sm);
  transition: background-color .15s ease, color .15s ease;
  text-align: left;
  cursor: pointer;
}
.sidebar-section-toggle:hover { background: var(--scims-surface-hover); color: var(--scims-text); }
.sidebar-section-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--scims-primary-soft);
}
.sidebar-section-toggle .sidebar-link-icon {
  font-size: 1rem; color: var(--scims-text-muted); flex: 0 0 18px;
}
.sidebar-section-toggle:hover .sidebar-link-icon { color: var(--scims-primary); }
.sidebar-section-toggle .sidebar-link-text { flex: 1 1 auto; min-width: 0; }
.sidebar-section-chevron {
  font-size: 0.75rem; color: var(--scims-text-muted);
  transition: transform .2s ease;
  flex: 0 0 auto;
}
.sidebar-section-toggle:not(.collapsed) .sidebar-section-chevron { transform: rotate(180deg); }

.sidebar-section-body { padding: 0.125rem 0 0.25rem 0.625rem; }

/* Links */
.sidebar-link {
  position: relative;
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  margin: 0.0625rem 0;
  color: var(--scims-text-muted) !important;
  text-decoration: none !important;
  font-size: 0.8125rem; font-weight: 500;
  border-radius: var(--scims-radius-sm);
  border: 0 !important;
  background: transparent !important;
  transition: background-color .15s ease, color .15s ease;
}
.sidebar-link:hover {
  background: var(--scims-surface-hover) !important;
  color: var(--scims-text) !important;
}
.sidebar-link.active {
  background: var(--scims-primary-soft) !important;
  color: var(--scims-primary) !important;
  font-weight: 600;
}
.sidebar-link.active::before {
  content: '';
  position: absolute; left: -0.625rem; top: 6px; bottom: 6px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--scims-primary);
}
.sidebar-section--pinned .sidebar-link { padding-left: 0.75rem; font-weight: 600; font-size: 0.85rem; color: var(--scims-text) !important; }
.sidebar-section--pinned .sidebar-link.active::before { left: -0.5rem; }

.sidebar-link-icon { font-size: 0.95rem; flex: 0 0 18px; text-align: center; opacity: 0.85; }
.sidebar-link.active .sidebar-link-icon { color: var(--scims-primary); opacity: 1; }
.sidebar-link-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Favorite star button */
.sidebar-fav-btn {
  flex: 0 0 22px;
  width: 22px; height: 22px;
  background: transparent; border: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--scims-text-muted);
  border-radius: 5px;
  opacity: 0;
  transition: opacity .15s ease, background-color .15s ease, color .15s ease;
  font-size: 0.8rem;
  cursor: pointer;
}
.sidebar-link:hover .sidebar-fav-btn,
.sidebar-link.is-favorite .sidebar-fav-btn { opacity: 1; }
.sidebar-fav-btn:hover { background: var(--scims-surface-hover); color: var(--scims-warning); }
.sidebar-link.is-favorite .sidebar-fav-btn { color: var(--scims-warning); }
.sidebar-link.is-favorite .sidebar-fav-btn .bi::before { content: "\F586"; /* bi-star-fill */ }

/* Empty search-results */
.sidebar-no-results {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--scims-text-muted);
}
.sidebar-no-results .bi { font-size: 1.5rem; opacity: 0.5; }
.sidebar-no-results p { margin: 0.5rem 0 0; font-size: 0.85rem; }

/* Footer */
.sidebar-footer {
  flex: 0 0 auto;
  border-top: 1px solid var(--scims-border);
  padding: 0.75rem;
  background: var(--scims-surface);
}
.sidebar-user {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.375rem 0.5rem;
  border-radius: var(--scims-radius-sm);
}
.sidebar-user-avatar {
  width: 34px; height: 34px; flex: 0 0 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--scims-primary), var(--scims-primary-600));
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem;
}
.sidebar-user-meta { flex: 1 1 auto; min-width: 0; line-height: 1.2; }
.sidebar-user-name { font-size: 0.825rem; font-weight: 600; color: var(--scims-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 0.7rem; color: var(--scims-text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.sidebar-logout-btn {
  flex: 0 0 32px;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  color: var(--scims-text-muted);
  background: transparent;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.sidebar-logout-btn:hover {
  background: var(--scims-danger-soft, #fee2e2);
  color: var(--scims-danger);
  border-color: transparent;
}

/* ── Collapsed (icons-only) sidebar ── */
.scims-shell--collapsed .sidebar-container { width: 72px; }
.scims-shell--collapsed .sidebar-container .sidebar-link-text,
.scims-shell--collapsed .sidebar-container .sidebar-section-chevron,
.scims-shell--collapsed .sidebar-container .sidebar-search-kbd,
.scims-shell--collapsed .sidebar-container .sidebar-fav-btn,
.scims-shell--collapsed .sidebar-container .sidebar-brand-text,
.scims-shell--collapsed .sidebar-container .sidebar-user-meta,
.scims-shell--collapsed .sidebar-container .sidebar-section-label,
.scims-shell--collapsed .sidebar-container .sidebar-no-results p {
  display: none;
}
.scims-shell--collapsed .sidebar-container .sidebar-section-toggle,
.scims-shell--collapsed .sidebar-container .sidebar-link {
  justify-content: center;
}
.scims-shell--collapsed .sidebar-container .sidebar-search { padding: 0; margin: 0.5rem 0.625rem; }
.scims-shell--collapsed .sidebar-container .sidebar-search-input {
  padding: 0.5rem;
  text-align: center;
}
.scims-shell--collapsed .sidebar-container .sidebar-search-input::placeholder { color: transparent; }
.scims-shell--collapsed .sidebar-container .sidebar-search-icon { left: 50%; transform: translate(-50%, -50%); }
.scims-shell--collapsed .sidebar-container .sidebar-section-body { padding-left: 0; }
.scims-shell--collapsed .sidebar-container .sidebar-link.active::before { display: none; }
.scims-shell--collapsed .sidebar-container .sidebar-link.active {
  background: var(--scims-primary-soft) !important;
  outline: 1px solid var(--scims-primary);
}
.scims-shell--collapsed .sidebar-container .sidebar-footer { padding: 0.5rem; }
.scims-shell--collapsed .sidebar-container .sidebar-user { justify-content: center; padding: 0; }
.scims-shell--collapsed .sidebar-container .sidebar-logout-btn { display: none; }

/* Hover-expand: when user hovers a collapsed sidebar, restore full width as overlay */
@media (min-width: 992px) {
  .scims-shell--collapsed .sidebar-container:hover {
    width: var(--scims-sidebar-w, 264px);
    box-shadow: var(--scims-shadow-lg);
    z-index: 1050;
  }
  .scims-shell--collapsed .sidebar-container:hover .sidebar-link-text,
  .scims-shell--collapsed .sidebar-container:hover .sidebar-section-chevron,
  .scims-shell--collapsed .sidebar-container:hover .sidebar-search-kbd,
  .scims-shell--collapsed .sidebar-container:hover .sidebar-brand-text,
  .scims-shell--collapsed .sidebar-container:hover .sidebar-user-meta,
  .scims-shell--collapsed .sidebar-container:hover .sidebar-section-label,
  .scims-shell--collapsed .sidebar-container:hover .sidebar-no-results p {
    display: revert;
  }
  .scims-shell--collapsed .sidebar-container:hover .sidebar-link-text,
  .scims-shell--collapsed .sidebar-container:hover .sidebar-section-label {
    display: inline;
  }
  .scims-shell--collapsed .sidebar-container:hover .sidebar-brand-text,
  .scims-shell--collapsed .sidebar-container:hover .sidebar-user-meta {
    display: flex;
  }
  .scims-shell--collapsed .sidebar-container:hover .sidebar-section-toggle,
  .scims-shell--collapsed .sidebar-container:hover .sidebar-link,
  .scims-shell--collapsed .sidebar-container:hover .sidebar-user { justify-content: flex-start; }
  .scims-shell--collapsed .sidebar-container:hover .sidebar-search-input { padding: 0.5rem 2.25rem 0.5rem 2.25rem; text-align: left; }
  .scims-shell--collapsed .sidebar-container:hover .sidebar-search-input::placeholder { color: var(--scims-text-muted); }
  .scims-shell--collapsed .sidebar-container:hover .sidebar-search-icon { left: 0.75rem; transform: translateY(-50%); }
  .scims-shell--collapsed .sidebar-container:hover .sidebar-section-body { padding-left: 0.625rem; }
  .scims-shell--collapsed .sidebar-container:hover .sidebar-logout-btn { display: inline-flex; }
  .scims-shell--collapsed .sidebar-container:hover .sidebar-link.active::before { display: block; }
}

/* ============================================================
   TOPBAR v2
   ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 1030;
  display: flex; align-items: center; gap: 1rem;
  padding: 0.625rem 1.5rem;
  background: var(--scims-surface);
  border-bottom: 1px solid var(--scims-border);
  min-height: 60px;
}
.topbar-left { display: flex; align-items: center; gap: 0.875rem; min-width: 0; flex: 0 1 auto; }
.topbar-right { display: flex; align-items: center; gap: 0.375rem; margin-left: auto; flex: 0 0 auto; }

.topbar-icon-btn {
  position: relative;
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--scims-text-muted);
  border-radius: 9px;
  text-decoration: none;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
  font-size: 1.05rem;
}
.topbar-icon-btn:hover {
  background: var(--scims-surface-hover);
  color: var(--scims-text);
  border-color: var(--scims-border);
}

.topbar-notification-badge {
  position: absolute;
  top: 4px; right: 4px;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  background: var(--scims-danger);
  color: #fff;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--scims-surface);
}
.topbar-notification-badge:empty,
.topbar-notification-badge[style*="display: none"] { display: none !important; }

.topbar-profile {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: transparent; border: 1px solid transparent;
  padding: 0.25rem 0.5rem 0.25rem 0.25rem;
  border-radius: 9px; cursor: pointer;
  color: var(--scims-text);
  transition: background-color .15s ease, border-color .15s ease;
}
.topbar-profile:hover { background: var(--scims-surface-hover); border-color: var(--scims-border); }
.topbar-profile-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--scims-primary), var(--scims-primary-600));
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.75rem;
}
.topbar-profile-meta { display: flex; flex-direction: column; line-height: 1.1; text-align: left; }
.topbar-profile-name { font-size: 0.8rem; font-weight: 600; color: var(--scims-text); }
.topbar-profile-role { font-size: 0.65rem; color: var(--scims-text-muted); text-transform: uppercase; font-weight: 600; letter-spacing: 0.04em; }
.topbar-profile-chev { font-size: 0.7rem; color: var(--scims-text-muted); }

/* Topbar global search */
.topbar-search {
  position: relative;
  max-width: 460px; flex: 1 1 360px;
}
.topbar-search-icon {
  position: absolute; left: 0.85rem; top: 50%; transform: translateY(-50%);
  color: var(--scims-text-muted); pointer-events: none;
}
.topbar-search-input {
  width: 100%;
  background: var(--scims-surface-2);
  border: 1px solid var(--scims-border);
  border-radius: var(--scims-radius-sm);
  padding: 0.45rem 3rem 0.45rem 2.25rem;
  font-size: 0.85rem;
  color: var(--scims-text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.topbar-search-input:focus {
  outline: none;
  border-color: var(--scims-primary);
  box-shadow: 0 0 0 3px var(--scims-primary-soft);
}
.topbar-search-input:disabled { cursor: not-allowed; opacity: 0.85; }
.topbar-search-kbd {
  position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%);
  font-size: 0.7rem; font-weight: 600;
  color: var(--scims-text-muted);
  background: var(--scims-surface);
  border: 1px solid var(--scims-border);
  border-radius: 4px;
  padding: 0.05rem 0.4rem;
  pointer-events: none;
}

/* ============================================================
   BREADCRUMBS
   ============================================================ */
.scims-breadcrumb {
  display: flex; align-items: center;
  gap: 0.4rem;
  font-size: 0.825rem;
  flex-wrap: wrap;
  min-width: 0;
}
.scims-breadcrumb-item {
  display: inline-flex; align-items: center; gap: 0.35rem;
  color: var(--scims-text-muted);
  text-decoration: none;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  transition: background-color .15s ease, color .15s ease;
  white-space: nowrap;
}
.scims-breadcrumb-item:hover { background: var(--scims-surface-hover); color: var(--scims-text); }
.scims-breadcrumb-item .bi { font-size: 0.95rem; }
.scims-breadcrumb-current {
  color: var(--scims-text) !important;
  font-weight: 600;
  background: transparent !important;
  cursor: default;
}
.scims-breadcrumb-sep {
  color: var(--scims-border-strong);
  font-size: 0.7rem;
  display: inline-flex; align-items: center;
}

/* ============================================================
   MOBILE — sidebar drawer + backdrop
   ============================================================ */
.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1035;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.sidebar-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 991.98px) {
  .scims-shell--auth .scims-main { margin-left: 0 !important; }
  .scims-shell--collapsed .scims-main { margin-left: 0 !important; }
  .sidebar-container {
    transform: translateX(-100%);
    box-shadow: var(--scims-shadow-lg);
  }
  .sidebar-container.is-mobile-open { transform: translateX(0); }
  .scims-shell--collapsed .sidebar-container { width: var(--scims-sidebar-w, 264px); }
  .scims-shell--collapsed .sidebar-container .sidebar-link-text,
  .scims-shell--collapsed .sidebar-container .sidebar-section-chevron,
  .scims-shell--collapsed .sidebar-container .sidebar-search-kbd,
  .scims-shell--collapsed .sidebar-container .sidebar-fav-btn,
  .scims-shell--collapsed .sidebar-container .sidebar-brand-text,
  .scims-shell--collapsed .sidebar-container .sidebar-user-meta,
  .scims-shell--collapsed .sidebar-container .sidebar-section-label,
  .scims-shell--collapsed .sidebar-container .sidebar-no-results p {
    display: revert;
  }
  .topbar { padding: 0.5rem 1rem; }
  .scims-content { padding: 1rem; }
  .topbar-search { display: none !important; }
}

/* Reveal scrollbar gutter and limit shifts */
.sidebar-nav::-webkit-scrollbar { width: 6px; }

/* Danger soft swatch (used by logout button hover) */
:root { --scims-danger-soft: #fee2e2; }
[data-bs-theme="dark"] { --scims-danger-soft: rgba(239, 68, 68, 0.15); }

/* =========================================================
   DASHBOARD v2 — Role-based control center
   ========================================================= */

/* Welcome banner */
.dash-welcome {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(168, 85, 247, 0.04));
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 0.75rem;
}
[data-bs-theme="dark"] .dash-welcome {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(168, 85, 247, 0.08));
    border-color: rgba(99, 102, 241, 0.3);
}
.dash-welcome h1 { font-weight: 600; }
.dash-welcome-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: var(--bs-secondary-color);
    white-space: nowrap;
}

/* Quick actions row */
.dash-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.dash-qa {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 1rem;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.625rem;
    color: var(--bs-body-color);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s ease;
}
.dash-qa:hover {
    transform: translateY(-1px);
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.12);
    color: var(--bs-body-color);
}
.dash-qa-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 0.5rem;
    font-size: 1rem;
}
.dash-qa-icon--primary   { background: rgba(99, 102, 241, 0.15); color: rgb(99, 102, 241); }
.dash-qa-icon--success   { background: rgba(34, 197, 94, 0.15);  color: rgb(34, 197, 94); }
.dash-qa-icon--info      { background: rgba(6, 182, 212, 0.15);  color: rgb(6, 182, 212); }
.dash-qa-icon--warning   { background: rgba(245, 158, 11, 0.15); color: rgb(245, 158, 11); }
.dash-qa-icon--danger    { background: rgba(239, 68, 68, 0.15);  color: rgb(239, 68, 68); }
.dash-qa-icon--secondary { background: rgba(168, 85, 247, 0.15); color: rgb(168, 85, 247); }

/* Stat cards */
.dash-stat {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.75rem;
    height: 100%;
    transition: all 0.15s ease;
    position: relative;
    overflow: hidden;
}
.dash-stat::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--dash-stat-accent, var(--bs-primary));
}
.dash-stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
}
.dash-stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 0.625rem;
    font-size: 1.4rem;
    background: var(--dash-stat-bg, rgba(99, 102, 241, 0.12));
    color: var(--dash-stat-accent, rgb(99, 102, 241));
    flex-shrink: 0;
}
.dash-stat-body { flex: 1; min-width: 0; }
.dash-stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--bs-secondary-color);
    font-weight: 600;
    margin-bottom: 0.25rem;
}
.dash-stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--bs-body-color);
}
.dash-stat-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.5rem;
    font-size: 0.8125rem;
    color: var(--bs-secondary-color);
    text-decoration: none;
}
.dash-stat-link:hover { color: var(--dash-stat-accent, var(--bs-primary)); }
.dash-stat-progress {
    margin-top: 0.625rem;
    height: 6px;
    background: var(--bs-tertiary-bg);
}

.dash-stat--primary   { --dash-stat-accent: rgb(99, 102, 241); --dash-stat-bg: rgba(99, 102, 241, 0.12); }
.dash-stat--success   { --dash-stat-accent: rgb(34, 197, 94);  --dash-stat-bg: rgba(34, 197, 94, 0.12); }
.dash-stat--info      { --dash-stat-accent: rgb(6, 182, 212);  --dash-stat-bg: rgba(6, 182, 212, 0.12); }
.dash-stat--warning   { --dash-stat-accent: rgb(245, 158, 11); --dash-stat-bg: rgba(245, 158, 11, 0.12); }
.dash-stat--danger    { --dash-stat-accent: rgb(239, 68, 68);  --dash-stat-bg: rgba(239, 68, 68, 0.12); }
.dash-stat--secondary { --dash-stat-accent: rgb(168, 85, 247); --dash-stat-bg: rgba(168, 85, 247, 0.12); }

/* Panels */
.dash-panel {
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.75rem;
    overflow: hidden;
}
.dash-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--bs-border-color);
}
.dash-panel-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--bs-body-color);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.dash-panel-title i { color: var(--bs-secondary-color); }
.dash-panel-action {
    font-size: 0.8125rem;
    color: var(--bs-secondary-color);
    text-decoration: none;
    white-space: nowrap;
}
.dash-panel-action:hover { color: var(--bs-primary); }
.dash-panel-body { padding: 1.25rem; }
.dash-panel-body.p-0 { padding: 0; }

/* Empty state */
.dash-empty {
    padding: 2rem 1.25rem;
    text-align: center;
    color: var(--bs-secondary-color);
    font-size: 0.9rem;
}
.dash-empty i { display: block; font-size: 2rem; margin-bottom: 0.5rem; opacity: 0.6; }

/* List items inside panels */
.dash-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.dash-list-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--bs-border-color);
    transition: background 0.1s ease;
}
.dash-list-item:last-child { border-bottom: 0; }
.dash-list-item:hover { background: var(--bs-tertiary-bg); }
.dash-list-item.is-unread { background: rgba(99, 102, 241, 0.04); }
.dash-list-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 36px;
    padding: 0 0.625rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
    background: var(--bs-tertiary-bg);
    color: var(--bs-secondary-color);
}
.dash-list-pill--primary { background: rgba(99, 102, 241, 0.15); color: rgb(99, 102, 241); }
.dash-list-pill--success { background: rgba(34, 197, 94, 0.15);  color: rgb(34, 197, 94); }
.dash-list-pill--info    { background: rgba(6, 182, 212, 0.15);  color: rgb(6, 182, 212); }
.dash-list-pill--warning { background: rgba(245, 158, 11, 0.15); color: rgb(245, 158, 11); }
.dash-list-pill--danger  { background: rgba(239, 68, 68, 0.15);  color: rgb(239, 68, 68); }

.dash-list-main { flex: 1; min-width: 0; }
.dash-list-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--bs-body-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dash-list-meta {
    font-size: 0.8rem;
    color: var(--bs-secondary-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dash-list-end {
    flex-shrink: 0;
    text-align: right;
}

/* Schedule items */
.dash-schedule {
    list-style: none;
    margin: 0;
    padding: 0;
}
.dash-schedule-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--bs-border-color);
}
.dash-schedule-item:last-child { border-bottom: 0; }
.dash-schedule-time {
    flex-shrink: 0;
    width: 80px;
    text-align: right;
    border-right: 2px solid var(--bs-border-color);
    padding-right: 1rem;
}
.dash-schedule-start {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--bs-body-color);
}
.dash-schedule-end {
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
}
.dash-schedule-body { flex: 1; min-width: 0; }
.dash-schedule-title {
    font-weight: 600;
    color: var(--bs-body-color);
    margin-bottom: 0.125rem;
}
.dash-schedule-meta {
    font-size: 0.8rem;
    color: var(--bs-secondary-color);
}
.dash-schedule-end-cell { flex-shrink: 0; }

/* Timeline (recent activity) */
.dash-timeline {
    list-style: none;
    margin: 0;
    padding: 0.75rem 0;
}
.dash-timeline li {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    padding: 0.625rem 1.25rem;
    position: relative;
}
.dash-timeline-dot {
    flex-shrink: 0;
    width: 10px;
    height: 10px;
    margin-top: 6px;
    border-radius: 50%;
    background: rgb(99, 102, 241);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.dash-timeline-body { flex: 1; min-width: 0; font-size: 0.875rem; }
.dash-timeline-meta {
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
    margin-top: 0.125rem;
}

/* Mobile: stack welcome banner */
@media (max-width: 575.98px) {
    .dash-welcome { padding: 1rem; }
    .dash-welcome-meta { font-size: 0.8rem; padding: 0.375rem 0.625rem; }
    .dash-stat { padding: 1rem; }
    .dash-stat-value { font-size: 1.35rem; }
    .dash-schedule-time { width: 64px; padding-right: 0.625rem; }
}

/* =========================================================
   GLOBAL SEARCH PANEL
   ========================================================= */
.topbar-search { position: relative; }
.topbar-search.is-open .topbar-search-input { background: var(--bs-body-bg); }
.topbar-search.is-loading::after {
    content: '';
    position: absolute;
    right: 48px;
    top: 50%;
    width: 14px;
    height: 14px;
    margin-top: -7px;
    border: 2px solid rgba(99, 102, 241, 0.25);
    border-top-color: rgb(99, 102, 241);
    border-radius: 50%;
    animation: searchSpin 0.6s linear infinite;
}
@keyframes searchSpin { to { transform: rotate(360deg); } }
.topbar-search-input:focus,
.topbar-search.is-open .topbar-search-input {
    border-color: rgba(99, 102, 241, 0.45);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
    outline: none;
}

.search-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    max-height: min(70vh, 560px);
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.75rem;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12), 0 2px 8px rgba(15, 23, 42, 0.04);
    overflow-y: auto;
    z-index: 1050;
    padding: 0.5rem 0;
}
[data-bs-theme="dark"] .search-panel {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.2);
}

.search-panel-section { padding: 0; }
.search-panel-section + .search-panel-section { border-top: 1px solid var(--bs-border-color); }
.search-panel-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem 0.375rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bs-secondary-color);
}
.search-panel-section-head i { color: var(--bs-secondary-color); margin-right: 0.375rem; }
.search-panel-count {
    background: var(--bs-tertiary-bg);
    padding: 0.0625rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    color: var(--bs-secondary-color);
}
.search-panel-clear {
    background: none;
    border: none;
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
    text-transform: none;
    letter-spacing: normal;
    cursor: pointer;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
}
.search-panel-clear:hover { color: var(--bs-primary); background: var(--bs-tertiary-bg); }

.search-panel-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.search-panel-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    cursor: pointer;
    transition: background 0.1s ease;
}
.search-panel-item:hover,
.search-panel-item.is-active {
    background: var(--bs-tertiary-bg);
}
.search-panel-item.is-active {
    background: rgba(99, 102, 241, 0.08);
}
[data-bs-theme="dark"] .search-panel-item.is-active {
    background: rgba(99, 102, 241, 0.18);
}
.search-panel-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    background: rgba(99, 102, 241, 0.12);
    color: rgb(99, 102, 241);
    font-size: 0.95rem;
}
.search-panel-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}
.search-panel-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--bs-body-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.search-panel-meta {
    font-size: 0.78rem;
    color: var(--bs-secondary-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.search-panel-meta-sub { opacity: 0.75; font-size: 0.72rem; }
.search-panel-tag {
    flex-shrink: 0;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    background: var(--bs-tertiary-bg);
    color: var(--bs-secondary-color);
    text-transform: capitalize;
}
.search-panel-tag--active,
.search-panel-tag--paid,
.search-panel-tag--available { background: rgba(34, 197, 94, 0.15); color: rgb(22, 163, 74); }
.search-panel-tag--pending,
.search-panel-tag--partial,
.search-panel-tag--waitlist  { background: rgba(245, 158, 11, 0.15); color: rgb(180, 83, 9); }
.search-panel-tag--inactive,
.search-panel-tag--rejected,
.search-panel-tag--unpaid,
.search-panel-tag--out,
.search-panel-tag--overdue   { background: rgba(239, 68, 68, 0.15); color: rgb(185, 28, 28); }

.search-hl {
    background: rgba(99, 102, 241, 0.18);
    color: inherit;
    font-weight: 600;
    border-radius: 2px;
    padding: 0 1px;
}

.search-panel-empty {
    padding: 2.5rem 1.5rem;
    text-align: center;
    color: var(--bs-secondary-color);
}
.search-panel-empty i { display: block; font-size: 2rem; margin-bottom: 0.5rem; opacity: 0.5; }
.search-panel-empty-title { font-weight: 500; color: var(--bs-body-color); margin-bottom: 0.25rem; }
.search-panel-empty-meta { font-size: 0.85rem; }

.search-panel-foot {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--bs-border-color);
    font-size: 0.72rem;
    color: var(--bs-secondary-color);
    background: var(--bs-tertiary-bg);
}
.search-panel-foot kbd {
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.25rem;
    padding: 0.0625rem 0.375rem;
    font-size: 0.7rem;
    color: var(--bs-body-color);
}

.topbar-search-kbd {
    background: var(--bs-tertiary-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.25rem;
    padding: 0.0625rem 0.375rem;
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
    cursor: help;
}

/* =========================================================================
   SMART TABLE — sticky head, sort, pagination, bulk, column toggle, print
   ========================================================================= */
.smart-table-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: center;
    justify-content: space-between;
    padding: .75rem .25rem 1rem;
    border-bottom: 1px solid var(--scims-border, #e5e7eb);
    margin-bottom: .5rem;
}
.smart-table-toolbar-left,
.smart-table-toolbar-right {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
}
.smart-table-search-wrap { width: 280px; max-width: 100%; }
.smart-table-page-size { width: auto; min-width: 110px; }

.smart-table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--scims-surface, #fff);
    box-shadow: inset 0 -2px 0 var(--scims-border, #e5e7eb);
    white-space: nowrap;
}
[data-bs-theme="dark"] .smart-table thead th {
    background: var(--scims-surface-2, #1e2632);
    color: #f1f5f9;
}
.smart-table-sortable {
    cursor: pointer;
    user-select: none;
    transition: background .15s ease;
}
.smart-table-sortable:hover { background: rgba(13, 110, 253, .08); }
.smart-table-sortable.is-sorted { color: var(--scims-primary, #0d6efd); }
.smart-table-sort-icon { opacity: .55; font-size: .9em; }
.smart-table-sortable.is-sorted .smart-table-sort-icon { opacity: 1; }

.smart-table tbody tr { transition: background-color .12s ease; }
.smart-table tbody tr:hover { background-color: rgba(13, 110, 253, .06); }
[data-bs-theme="dark"] .smart-table tbody tr:hover { background-color: rgba(96, 165, 250, .12); }

.smart-table-filter-row th { background: rgba(0,0,0,.02); padding: .35rem .5rem !important; }
[data-bs-theme="dark"] .smart-table-filter-row th { background: rgba(255,255,255,.04); }
.smart-table-col-filter { min-width: 110px; }

.smart-table-bulk-col { width: 36px; text-align: center; }
.smart-table-bulk-col input { cursor: pointer; }

.smart-table-bulk-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(90deg, rgba(13,110,253,.08), rgba(13,110,253,.02));
    border: 1px solid rgba(13,110,253,.25);
    border-radius: .5rem;
    padding: .5rem .85rem;
    margin-bottom: .75rem;
}
.smart-table-bulk-bar.is-active { display: flex; }
.smart-table-bulk-count { font-weight: 600; color: var(--scims-primary, #0d6efd); }

.smart-table-footer {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: center;
    justify-content: space-between;
    padding: .75rem .25rem;
    border-top: 1px solid var(--scims-border, #e5e7eb);
    margin-top: .5rem;
}

.smart-table-col-menu {
    max-height: 320px;
    overflow-y: auto;
    min-width: 220px;
}
.smart-table-col-toggle { cursor: pointer; user-select: none; margin-bottom: 0; }
.smart-table-col-toggle:hover { background: rgba(13,110,253,.06); }

/* Print mode: hide everything except the printing table */
@media print {
    body.smart-table-print-mode > * { visibility: hidden !important; }
    body.smart-table-print-mode .smart-table-printing,
    body.smart-table-print-mode .smart-table-printing * { visibility: visible !important; }
    body.smart-table-print-mode .smart-table-printing {
        position: absolute !important;
        top: 0; left: 0; width: 100%;
    }
    body.smart-table-print-mode .smart-table-toolbar,
    body.smart-table-print-mode .smart-table-footer,
    body.smart-table-print-mode .smart-table-bulk-bar,
    body.smart-table-print-mode .smart-table-bulk-col,
    body.smart-table-print-mode .smart-table-filter-row,
    body.smart-table-print-mode .smart-table-sort-icon { display: none !important; }
    body.smart-table-print-mode .smart-table thead th { background: #f3f4f6 !important; color: #000 !important; }
    body.smart-table-print-mode .smart-table tr,
    body.smart-table-print-mode .smart-table td,
    body.smart-table-print-mode .smart-table th { color: #000 !important; }
    body.smart-table-print-mode .btn,
    body.smart-table-print-mode .badge { box-shadow: none !important; border: 1px solid #999 !important; }
}

/* =========================================================================
   SMART FORM — multi-step, validation, autosave, toast
   ========================================================================= */
.smart-form-stepper {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--scims-border, #e5e7eb);
}
.smart-form-step-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .9rem;
    cursor: pointer;
    border-radius: .5rem;
    color: var(--scims-text-muted, #6b7280);
    font-size: .92rem;
    transition: all .15s ease;
    flex: 1 1 auto;
    min-width: 130px;
    position: relative;
    /* Reset native button styles when stepper items are <button> */
    border: 0;
    background: transparent;
    text-align: left;
    font-family: inherit;
    line-height: 1.3;
}
.smart-form-step-item:focus-visible {
    outline: 2px solid var(--scims-primary, #0d6efd);
    outline-offset: 2px;
}
.smart-form-step-item + .smart-form-step-item::before {
    content: '';
    position: absolute;
    left: -.5rem;
    top: 50%;
    width: .25rem;
    height: 2px;
    background: var(--scims-border, #e5e7eb);
}
.smart-form-step-item:hover { background: rgba(13,110,253,.05); }
.smart-form-step-item.is-active {
    color: var(--scims-primary, #0d6efd);
    background: rgba(13,110,253,.08);
    font-weight: 600;
}
.smart-form-step-item.is-done { color: #198754; }
.smart-form-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--scims-surface-2, #f1f5f9);
    color: inherit;
    font-size: .9rem;
    flex-shrink: 0;
}
.smart-form-step-item.is-active .smart-form-step-num {
    background: var(--scims-primary, #0d6efd);
    color: #fff;
}
.smart-form-step-item.is-done .smart-form-step-num {
    background: #198754;
    color: #fff;
}
.smart-form-step-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.smart-form-nav {
    display: flex;
    justify-content: space-between;
    gap: .5rem;
    padding-top: 1rem;
    margin-top: 1rem;
    border-top: 1px solid var(--scims-border, #e5e7eb);
}

.smart-form-step { animation: smartFormStepIn .25s ease; }
@keyframes smartFormStepIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

.smart-form-draft-banner {
    margin-bottom: 1rem;
    border-left: 4px solid var(--scims-primary, #0d6efd);
}
.smart-form-autosave-indicator {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    background: rgba(25, 135, 84, .95);
    color: #fff;
    padding: .4rem .9rem;
    border-radius: 999px;
    font-size: .85rem;
    box-shadow: 0 4px 16px rgba(0,0,0,.15);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .2s, transform .2s;
    pointer-events: none;
    z-index: 1080;
}
.smart-form-autosave-indicator.is-visible {
    opacity: 1;
    transform: none;
}

.form-control.is-valid, .form-select.is-valid {
    border-color: #198754;
    background-image: none;
    padding-right: .75rem;
}
.form-control.is-invalid, .form-select.is-invalid {
    background-image: none;
    padding-right: .75rem;
}

/* Toast (used by smart-form + can be triggered by other code) */
.scims-toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1090;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    max-width: 360px;
}
.scims-toast {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: #fff;
    border-radius: .5rem;
    box-shadow: 0 6px 24px rgba(0,0,0,.18);
    padding: .65rem .85rem;
    font-size: .92rem;
    color: #1f2937;
    border-left: 4px solid #6c757d;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity .2s, transform .2s;
}
.scims-toast.is-visible { opacity: 1; transform: none; }
.scims-toast--success { border-left-color: #198754; }
.scims-toast--error   { border-left-color: #dc3545; }
.scims-toast--warning { border-left-color: #f59e0b; }
.scims-toast--info    { border-left-color: #0d6efd; }
.scims-toast .scims-toast-msg { flex: 1; }
.scims-toast-close {
    background: transparent;
    border: 0;
    font-size: 1.25rem;
    line-height: 1;
    color: #9ca3af;
    cursor: pointer;
    padding: 0 .25rem;
}
.scims-toast-close:hover { color: #1f2937; }
[data-bs-theme="dark"] .scims-toast {
    background: #1e2632;
    color: #f1f5f9;
}
[data-bs-theme="dark"] .scims-toast-close { color: #94a3b8; }
[data-bs-theme="dark"] .scims-toast-close:hover { color: #f1f5f9; }

/* Hide submit row by default in multi-step until last step */
.smart-form-step + .smart-form-submit-row { display: none; }

/* =========================================================================
   MOBILE & TOUCH UX HARDENING (final pass)
   - Kills iOS focus-zoom on form inputs
   - Promotes table action icons to 44×44 minimum on touch devices
   - Reflows smart-table toolbar / smart-form stepper on narrow viewports
   - Smooths the sidebar drawer transition
   ========================================================================= */

/* ---- iOS focus-zoom fix (16px on inputs ≤ tablet) ---- */
@media (max-width: 768px) {
    .form-control,
    .form-select,
    [data-bs-theme="light"] .form-control,
    [data-bs-theme="light"] .form-select,
    [data-bs-theme="dark"]  .form-control,
    [data-bs-theme="dark"]  .form-select,
    .smart-table-search,
    .smart-table-col-filter input,
    .smart-table-col-filter select {
        font-size: 16px !important;
    }
    /* Keep dense inputs inside dropdowns/menus visually consistent */
    .smart-table-page-size { font-size: 16px !important; }
}

/* ---- 44×44 touch targets on coarse pointers (phones, tablets) ---- */
@media (hover: none) and (pointer: coarse) {
    .btn-sm,
    .table .btn-sm,
    .smart-table .btn-sm {
        min-height: 44px;
        min-width: 44px;
        padding: 0.5rem 0.75rem !important;
        font-size: 0.9375rem !important;
        line-height: 1.2;
    }
    /* Icon-only action buttons keep their square shape */
    .btn-sm.btn-icon,
    .smart-table td .btn-sm > i.bi:only-child {
        font-size: 1.1rem;
    }
    .dropdown-item {
        padding-top: 0.65rem;
        padding-bottom: 0.65rem;
    }
    /* Sidebar nav link comfort */
    .sidebar-nav-link {
        min-height: 44px;
    }
}

/* ---- Smart-table toolbar reflow on mobile ---- */
@media (max-width: 575.98px) {
    .smart-table-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        padding: 0.5rem 0 0.75rem;
    }
    .smart-table-toolbar-left,
    .smart-table-toolbar-right {
        width: 100%;
        justify-content: flex-start;
    }
    .smart-table-toolbar-right { justify-content: space-between; }
    .smart-table-search-wrap { width: 100% !important; }
    .smart-table-page-size  { flex: 1; min-width: 0; }
    .smart-table-footer {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
        gap: 0.5rem;
    }
    .smart-table-footer .pagination { justify-content: center; }
    /* Tables themselves: never let them break the layout */
    .table-responsive { -webkit-overflow-scrolling: touch; }
}

/* ---- Smart-form stepper: condense to "Step X / N" on mobile ---- */
@media (max-width: 575.98px) {
    .smart-form-stepper {
        position: relative;
        gap: 0;
        padding: 0.75rem 0 1rem;
    }
    .smart-form-stepper::after {
        content: 'Step ' attr(data-current) ' of ' attr(data-total);
        position: absolute;
        right: 0; top: 0.85rem;
        font-size: 0.8125rem;
        font-weight: 600;
        color: var(--scims-text-muted, #6b7280);
    }
    .smart-form-step-item {
        flex: 0 0 auto;
        padding: 0.35rem 0.4rem;
        min-width: 0;
        gap: 0.25rem;
    }
    .smart-form-step-item .smart-form-step-label { display: none; }
    .smart-form-step-item.is-active .smart-form-step-label {
        display: inline;
        max-width: 9rem;
    }
    .smart-form-step-item + .smart-form-step-item::before { display: none; }
    .smart-form-step-num { width: 26px; height: 26px; font-size: 0.8125rem; }
    .smart-form-nav { flex-wrap: wrap; gap: 0.4rem; }
    .smart-form-nav .btn { flex: 1 1 0; min-width: 7rem; }
}

/* ---- Auto-scroll for tables that forgot the .table-responsive wrap ---- */
@media (max-width: 991.98px) {
    .scims-content > .card .table:not(.table-responsive *),
    .scims-content > .card-body .table:not(.table-responsive *) {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
}

/* ---- Sidebar drawer: smoother + safe-area aware on iOS ---- */
@media (max-width: 991.98px) {
    .sidebar-container {
        transition: transform 0.25s ease-in-out, box-shadow 0.25s ease-in-out;
        padding-top: env(safe-area-inset-top, 0);
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
    .sidebar-backdrop {
        transition: opacity 0.2s ease-in-out;
    }
    .scims-content {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0));
    }
}

/* ---- Page loader respects reduced-motion preference ---- */
@media (prefers-reduced-motion: reduce) {
    .loader-spinner,
    .smart-form-step,
    .scims-toast,
    .sidebar-container,
    .sidebar-backdrop {
        animation: none !important;
        transition: none !important;
    }
}

/* ---- Larger native font in modals on mobile ---- */
@media (max-width: 575.98px) {
    .modal-dialog { margin: 0.5rem; }
    .modal-body  { padding: 1rem; }
    .modal-footer { flex-wrap: wrap; gap: 0.5rem; }
    .modal-footer .btn { flex: 1 1 auto; min-width: 8rem; }
}
