:root {
  --font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  
  /* Modern Clean Light Gray Palette */
  --bg-app: #f1f4f9;               /* Elegant light gray background */
  --bg-surface: #ffffff;           /* Clean crisp white sidebar & topbar */
  --bg-surface-hover: #f8fafc;
  --bg-card: #ffffff;              /* Pure white card backgrounds */
  --border-color: #e2e8f0;         /* Soft subtle border */
  --border-focus: #3b82f6;
  
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  
  --success: #059669;
  --success-light: #ecfdf5;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --purple: #7c3aed;
  --purple-light: #f5f3ff;

  --text-main: #0f172a;            /* Deep slate for high contrast and readability */
  --text-muted: #475569;           /* Secondary slate text */
  --text-dim: #94a3b8;             /* Subtle tertiary gray */

  --sidebar-w: 240px;
  --sidebar-w-collapsed: 72px;
  --header-h: 54px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
  --shadow-card-hover: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  font-size: 13.5px;
  line-height: 1.45;
}

/* Layout */
.app-container {
  display: flex;
  width: 100vw;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  box-shadow: 1px 0 5px rgba(0, 0, 0, 0.02);
  transition: var(--transition);
}

.sidebar-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 1.15rem;
  border-bottom: 1px solid var(--border-color);
  gap: 0.65rem;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #2563eb, #6366f1);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: white;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.2);
}

.brand-text {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #0f172a;
}

.sidebar-nav {
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
  overflow-y: auto;
}

.nav-label {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0.45rem 0.65rem 0.2rem;
  letter-spacing: 0.05em;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  font-weight: 600;
  font-size: 0.85rem;
}

.nav-link svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.9;
  opacity: 0.75;
  transition: var(--transition);
}

.nav-link:hover {
  color: var(--primary);
  background: #f8fafc;
}

.nav-link.active {
  color: var(--primary);
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
}

.nav-link.active svg {
  color: var(--primary);
  opacity: 1;
}

.sidebar-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fafafa;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  font-size: 0.85rem;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: #0f172a;
}

.user-role {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

/* Main Content Area */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: calc(100vw - var(--sidebar-w));
}

/* Header */
.topbar {
  height: var(--header-h);
  min-height: var(--header-h);
  flex-shrink: 0;
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.page-title {
  font-size: 1.12rem;
  font-weight: 800;
  color: #0f172a;
}

/* Mobile brand header - hidden on desktop */
.mobile-brand-header {
  display: none;
  align-items: center;
  gap: 0.35rem;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
}
.mobile-brand-header .brand-bss {
  color: #1e3a8a;
  font-weight: 900;
}
.mobile-brand-header .brand-lms {
  color: #2563eb;
  font-weight: 900;
}
.mobile-brand-header .brand-plus {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  letter-spacing: 0.04em;
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.3);
}

.topbar-date-badge-mobile {
  display: none;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Content Container - Tight edge spacing, full width */
.content-body {
  padding: 0.85rem 1rem;
  flex: 1;
  width: 100%;
  margin: 0;
}

/* Responsive Grid System */
.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 1366px) {
  .grid-stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.35rem;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

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

.stat-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.stat-val {
  font-size: clamp(1.6rem, 1.9vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #0f172a;
}

.stat-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid #cbd5e1;
  background: var(--bg-card);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

/* Seamless Continuous Gradient Across the ENTIRE Header Row */
.data-table thead {
  background: linear-gradient(90deg, #1e40af 0%, #2563eb 50%, #3b82f6 100%);
}

.data-table thead tr {
  background: linear-gradient(90deg, #1e40af 0%, #2563eb 50%, #3b82f6 100%);
}

.data-table th {
  padding: 0.65rem 0.85rem;
  background: transparent;
  color: #ffffff !important;
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid rgba(255, 255, 255, 0.25);
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

/* Horizontal & Vertical Lines for all data cells */
.data-table td {
  padding: 0.45rem 0.65rem;
  border: 1px solid #e2e8f0;
  font-size: 0.78rem;
  vertical-align: middle;
  color: #1e293b;
  white-space: nowrap;
}

.portfolio-compact-table td {
  font-size: 0.77rem;
  padding: 0.4rem 0.6rem;
}

.portfolio-compact-table th {
  font-size: 0.7rem;
  padding: 0.55rem 0.6rem;
}

.data-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.data-table tbody tr:hover {
  background: #eef2ff;
}

/* Colourful Modern Action Buttons */
.btn-icon-edit {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 6px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff !important;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(217, 119, 6, 0.3);
  transition: all 0.2s ease;
  text-decoration: none;
}
.btn-icon-edit:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-icon-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.28rem 0.55rem;
  font-size: 0.75rem;
  border-radius: 6px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #ffffff !important;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.3);
  transition: all 0.2s ease;
  text-decoration: none;
}
.btn-icon-delete:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-icon-loan {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.28rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 6px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff !important;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.3);
  transition: all 0.2s ease;
  text-decoration: none;
}
.btn-icon-loan:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge-success { background: var(--success-light); color: var(--success); border: 1px solid rgba(5, 150, 105, 0.2); }
.badge-warning { background: var(--warning-light); color: var(--warning); border: 1px solid rgba(217, 119, 6, 0.2); }
.badge-danger { background: var(--danger-light); color: var(--danger); border: 1px solid rgba(220, 38, 38, 0.2); }
.badge-primary { background: var(--primary-light); color: var(--primary); border: 1px solid rgba(37, 99, 235, 0.2); }
.badge-purple { background: var(--purple-light); color: var(--purple); border: 1px solid rgba(124, 58, 237, 0.2); }
.badge-secondary { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }

/* Forms & Inputs */
.form-group {
  margin-bottom: 0.65rem;
}

.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: #334155;
  margin-bottom: 0.25rem;
}

.form-control, .form-select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  color: #0f172a;
  font-family: inherit;
  font-size: 0.86rem;
  transition: var(--transition);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background: #ffffff;
  width: 92%;
  max-width: 520px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.35);
  overflow: visible;
  transform: translateY(-16px) scale(0.98);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-box {
  transform: translateY(0) scale(1);
}

/* Colourful Gradient Modal Header */
.modal-header {
  padding: 0.95rem 1.35rem;
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 50%, #3b82f6 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-close {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 1.25rem;
  line-height: 1;
  color: #ffffff;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

.modal-body {
  padding: 1.25rem 1.4rem;
  background: #ffffff;
}

/* Modal Footer with increased button height */
.modal-footer {
  padding: 0.85rem 1.4rem;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  background: #f8fafc;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
}

/* Taller, Colourful Modal Buttons */
.modal-btn-save {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 42px;
  min-width: 120px;
  padding: 0 1.25rem;
  font-size: 0.92rem;
  font-weight: 700;
  border-radius: 8px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  border: none;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.35);
  transition: all 0.2s ease;
}

.modal-btn-save:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(37, 99, 235, 0.45);
}

.modal-btn-cancel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  min-width: 95px;
  padding: 0 1.15rem;
  font-size: 0.92rem;
  font-weight: 700;
  border-radius: 8px;
  background: #e2e8f0;
  color: #475569;
  border: 1px solid #cbd5e1;
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-btn-cancel:hover {
  background: #cbd5e1;
  color: #0f172a;
}

.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-size: 0.88rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.btn-secondary {
  background: #e2e8f0;
  color: #334155;
}
.btn-secondary:hover {
  background: #cbd5e1;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.78rem;
}

/* Alerts */
.alert {
  padding: 0.9rem 1.2rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
}
.alert-danger {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}
.alert-success {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

/* Code badges */
code {
  background: #f1f5f9;
  color: #2563eb;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.85em;
  font-weight: 600;
  border: 1px solid #e2e8f0;
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
    z-index: 1050;
  }
  .sidebar.show {
    transform: translateX(0);
  }
  .main-wrapper {
    margin-left: 0;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }
  .mobile-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 0.35rem;
    border-radius: 6px;
  }
  .sidebar-close-btn {
    display: flex !important;
  }
  /* In mobile version hide desktop page title and display BSS LMS Plus brand header */
  .topbar .page-title,
  .desktop-only-title {
    display: none !important;
  }
  .mobile-brand-header {
    display: flex !important;
  }
  .topbar {
    padding: 0 0.85rem;
    height: 52px;
    min-height: 52px;
    flex-shrink: 0;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  }
  .topbar-left {
    gap: 0.65rem;
    align-items: center;
  }
  .topbar-right .topbar-date-badge {
    font-size: 0.68rem;
    padding: 0.2rem 0.5rem;
    font-weight: 700;
  }
}

.sidebar-close-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
}
.sidebar-close-btn:hover {
  background: #f1f5f9;
  color: var(--danger);
}

/* Sidebar Backdrop on Mobile */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  z-index: 1040;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.sidebar-backdrop.show {
  display: block;
  opacity: 1;
}

.mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: #0f172a;
  cursor: pointer;
}

/* Custom Searchable Select Dropdown */
.searchable-select {
  position: relative;
  width: 100%;
}
.searchable-select-trigger {
  width: 100%;
  height: 38px;
  padding: 0.45rem 2rem 0.45rem 0.85rem;
  font-size: 0.875rem;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  color: #0f172a;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  user-select: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}
.searchable-select-trigger:focus,
.searchable-select.is-open .searchable-select-trigger {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.searchable-select-trigger .ss-arrow {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  transition: transform 0.2s ease;
  color: #64748b;
}
.searchable-select.is-open .ss-arrow {
  transform: translateY(-50%) rotate(180deg);
  color: #2563eb;
}
.searchable-select-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 16px 36px -4px rgba(15, 23, 42, 0.25), 0 6px 16px -2px rgba(15, 23, 42, 0.12);
  z-index: 9999;
  display: none;
  overflow: hidden;
  animation: ssFadeIn 0.15s ease-out;
}
@keyframes ssFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.searchable-select.is-open .searchable-select-menu {
  display: block;
}
.searchable-select-search-wrap {
  padding: 8px 10px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  position: relative;
}
.searchable-select-search-wrap input {
  width: 100%;
  padding: 7px 10px 7px 32px;
  font-size: 0.85rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  outline: none;
  color: #0f172a;
}
.searchable-select-search-wrap input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
}
.searchable-select-search-icon {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
  pointer-events: none;
}
.searchable-select-options {
  max-height: 250px;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 6px 0;
}
.searchable-select-options::-webkit-scrollbar {
  width: 6px;
}
.searchable-select-options::-webkit-scrollbar-track {
  background: #f1f5f9;
}
.searchable-select-options::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}
.searchable-select-options::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
.searchable-select-option {
  padding: 9px 14px;
  font-size: 0.88rem;
  color: #0f172a;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.65rem;
  text-align: left;
  border-bottom: 1px solid #f8fafc;
  transition: background 0.12s ease, color 0.12s ease;
}
.searchable-select-option:last-child {
  border-bottom: none;
}
.searchable-select-option:hover,
.searchable-select-option.highlighted {
  background: #eff6ff;
  color: #1d4ed8;
}
.searchable-select-option.selected {
  background: #e0e7ff;
  color: #1e40af;
  font-weight: 700;
}
.searchable-select-empty {
  padding: 14px 12px;
  font-size: 0.85rem;
  color: #64748b;
  text-align: center;
  font-style: italic;
}

/* ----------------------------------------------------
   Responsive Optimizations for 1366x768 & Laptop Screens
   ---------------------------------------------------- */
@media screen and (max-width: 1400px) {
  :root {
    --sidebar-w: 220px;
    --header-h: 50px;
  }
  
  .content-body {
    padding: 0.65rem 0.85rem;
  }
  
  .brand-text {
    font-size: 0.95rem;
  }
  
  .nav-link {
    padding: 0.45rem 0.65rem;
    font-size: 0.82rem;
    gap: 0.6rem;
  }
  
  .nav-link svg {
    width: 16px;
    height: 16px;
  }
  
  .loan-grid-container {
    grid-template-columns: 370px 1fr !important;
    gap: 0.85rem !important;
  }
  
  .data-table th, 
  .data-table td {
    padding: 0.5rem 0.65rem;
    font-size: 0.8rem;
  }
}

@media screen and (max-height: 820px), screen and (max-width: 1400px) and (max-height: 850px) {
  .sidebar-header {
    height: 44px;
    padding: 0 0.85rem;
  }
  
  .sidebar-nav {
    padding: 0.4rem 0.4rem;
    gap: 0.1rem;
  }

  .nav-label {
    padding: 0.3rem 0.5rem 0.1rem;
    font-size: 0.62rem;
  }

  .nav-link {
    padding: 0.38rem 0.65rem;
    font-size: 0.8rem;
    gap: 0.55rem;
  }

  .nav-link svg {
    width: 16px;
    height: 16px;
  }
  
  .sidebar-footer {
    padding: 0.4rem 0.65rem;
  }

  .user-avatar {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
  }

  .user-name {
    font-size: 0.76rem;
  }

  .user-role {
    font-size: 0.62rem;
  }
  
  .topbar {
    height: 52px;
    min-height: 52px;
    flex-shrink: 0;
    padding: 0 0.75rem;
  }

  .mobile-brand-header {
    font-size: 0.92rem;
  }

  .topbar-date-badge {
    display: none !important;
  }

  .topbar-date-badge-mobile {
    display: inline-block !important;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    white-space: nowrap;
  }
  
  .content-body {
    padding: 0.35rem 0.65rem !important;
  }
  
  .searchable-select-options {
    max-height: 260px;
  }

  /* Compact Collection Entry specific styles */
  .col-page-container {
    max-width: 860px !important;
    margin: 0 auto;
  }

  .col-main-card {
    padding: 0.65rem 0.95rem !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03) !important;
  }

  .col-header-row {
    margin-bottom: 0.45rem !important;
  }

  .col-header-title {
    font-size: 1.05rem !important;
  }

  .col-step-box {
    padding: 0.4rem 0.65rem !important;
    margin-bottom: 0.45rem !important;
  }

  .col-step-header {
    margin-bottom: 0.25rem !important;
    font-size: 0.7rem !important;
  }

  .col-form-group {
    margin-bottom: 0.45rem !important;
  }

  .col-form-label {
    font-size: 0.74rem !important;
    margin-bottom: 0.15rem !important;
  }

  .col-kpi-grid {
    gap: 0.35rem !important;
    margin-bottom: 0.35rem !important;
  }

  .col-kpi-item {
    padding: 0.3rem 0.45rem !important;
  }

  .col-kpi-title {
    font-size: 0.6rem !important;
  }

  .col-kpi-val {
    font-size: 0.85rem !important;
    margin-top: 0.05rem !important;
  }

  .col-emi-bar {
    padding: 0.35rem 0.6rem !important;
    font-size: 0.7rem !important;
  }

  .col-input-row {
    gap: 0.5rem !important;
    margin-bottom: 0.45rem !important;
  }

  .col-input-amount {
    height: 36px !important;
    font-size: 1.05rem !important;
  }

  .col-input-select {
    height: 36px !important;
    font-size: 0.82rem !important;
  }

  .col-input-small {
    height: 32px !important;
    font-size: 0.8rem !important;
  }

  .col-submit-btn {
    height: 36px !important;
    font-size: 0.88rem !important;
  }

  .main-wrapper {
    min-height: auto;
    height: 100vh;
    overflow-y: auto;
  }

  .content-body {
    padding: 0.3rem 0.15rem !important;
  }

  .col-page-container {
    max-width: 820px !important;
    margin: 0 auto;
  }

  .col-main-card {
    padding: 0.55rem 0.85rem !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.03) !important;
  }
}


@media screen and (max-width: 1100px) {
  .loan-grid-container {
    grid-template-columns: 1fr !important;
  }
}

/* ----------------------------------------------------
   Responsive Mobile Cards for Areas & Entity Views
   ---------------------------------------------------- */
.mobile-cards-view {
  display: none;
}

.desktop-table-view {
  display: block;
}

.areas-mobile-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.area-mobile-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.9rem 1rem;
  box-shadow: 0 2px 8px -2px rgba(15, 23, 42, 0.06);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.area-mobile-card:hover {
  box-shadow: 0 6px 18px -3px rgba(37, 99, 235, 0.12);
}

.area-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.area-card-icon-box {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  color: #2563eb;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid #bfdbfe;
}

.area-card-title-wrap {
  flex: 1;
  min-width: 0;
}

.area-card-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.25;
  margin-bottom: 0.2rem;
}

.area-card-city {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.76rem;
  color: #64748b;
  font-weight: 600;
}

.area-card-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #f1f5f9;
  margin-bottom: 0.75rem;
}

.area-stat-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.area-stat-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.area-stat-info {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.area-stat-label {
  font-size: 0.68rem;
  color: #64748b;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.area-stat-val {
  font-size: 0.88rem;
  font-weight: 800;
  color: #0f172a;
}

.area-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid #f1f5f9;
  padding-top: 0.65rem;
}

/* Desktop default for mobile filter toggle button */
.mobile-filter-toggle-btn {
  display: none;
}

@media screen and (max-width: 768px) {
  .desktop-table-view {
    display: none !important;
  }
  
  .mobile-cards-view {
    display: block !important;
  }

  /* ---------------------------------------------
     1. Collapsible Filter Bar for Mobile
     --------------------------------------------- */
  .mobile-filter-wrapper {
    margin-bottom: 0.65rem;
  }

  .mobile-filter-toggle-btn {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.55rem 0.85rem;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    color: #1e293b;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: all 0.2s ease;
  }

  .mobile-filter-toggle-btn:active {
    background: #f1f5f9;
  }

  .mobile-filter-toggle-btn .mft-left {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: #1e40af;
  }

  .mobile-filter-toggle-btn .mft-right {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
  }

  .mobile-filter-toggle-btn .mft-badge {
    font-size: 0.68rem;
    font-weight: 700;
    background: #eff6ff;
    color: #2563eb;
    padding: 0.12rem 0.45rem;
    border-radius: 9999px;
    border: 1px solid #bfdbfe;
    letter-spacing: 0.02em;
  }

  .mobile-filter-toggle-btn .mft-chevron {
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    color: #64748b;
  }

  /* When NOT expanded, hide the filter controls automatically on mobile */
  .mobile-filter-wrapper:not(.filter-expanded) .area-filter-bar {
    display: none !important;
  }

  /* When expanded, show with smooth entrance */
  .mobile-filter-wrapper.filter-expanded .area-filter-bar {
    display: grid !important;
    animation: fadeInFilter 0.22s ease-out;
    margin-top: 0.4rem;
    margin-bottom: 0 !important;
  }

  .mobile-filter-wrapper.filter-expanded .mobile-filter-toggle-btn .mft-chevron {
    transform: rotate(180deg);
  }

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

  .area-filter-bar {
    grid-template-columns: 1fr !important;
    gap: 0.4rem !important;
    padding: 0.55rem !important;
  }

  /* ---------------------------------------------
     2. Compact Cards Font Size & Layout for All Pages
     --------------------------------------------- */
  .card {
    padding: 0.45rem 0.25rem !important;
    border-radius: 10px !important;
  }

  .stat-card {
    gap: 0.45rem !important;
  }

  .stat-title {
    font-size: 0.7rem !important;
  }

  .stat-icon {
    width: 32px !important;
    height: 32px !important;
    font-size: 0.95rem !important;
  }

  .stat-val {
    font-size: 1.15rem !important;
  }

  .areas-mobile-grid {
    gap: 0.5rem !important;
  }

  .area-mobile-card {
    padding: 0.65rem 0.75rem !important;
    border-radius: 10px !important;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04) !important;
  }

  .area-card-header {
    margin-bottom: 0.45rem !important;
    gap: 0.45rem !important;
  }

  .area-card-icon-box {
    width: 32px !important;
    height: 32px !important;
    border-radius: 8px !important;
  }

  .area-card-icon-box svg {
    width: 16px !important;
    height: 16px !important;
  }

  .area-card-title {
    font-size: 0.85rem !important;
    margin-bottom: 0.12rem !important;
    line-height: 1.2 !important;
  }

  .area-card-city {
    font-size: 0.68rem !important;
    line-height: 1.15 !important;
  }

  .area-card-stats {
    padding: 0.4rem 0.55rem !important;
    gap: 0.35rem !important;
    margin-bottom: 0.45rem !important;
    border-radius: 6px !important;
  }

  .area-stat-icon {
    width: 24px !important;
    height: 24px !important;
    border-radius: 5px !important;
  }

  .area-stat-icon svg {
    width: 12px !important;
    height: 12px !important;
  }

  .area-stat-label {
    font-size: 0.6rem !important;
  }

  .area-stat-val {
    font-size: 0.78rem !important;
  }

  .area-card-actions {
    padding-top: 0.45rem !important;
  }

  .area-card-actions .badge {
    font-size: 0.68rem !important;
    padding: 0.18rem 0.5rem !important;
  }

  .area-card-actions .btn-icon-edit {
    padding: 0.3rem 0.45rem !important;
    font-size: 0 !important;
    gap: 0 !important;
    border-radius: 6px !important;
  }

  .area-card-actions .btn-icon-edit svg {
    width: 12px !important;
    height: 12px !important;
    margin: 0 !important;
  }

  .area-card-actions .btn-icon-delete {
    padding: 0.3rem 0.45rem !important;
    border-radius: 6px !important;
  }

  .area-card-actions .btn-icon-delete svg {
    width: 12px !important;
    height: 12px !important;
  }

  /* ---------------------------------------------
     3. Professional, Sleek Mobile Modals (Bottom/Center Sheet)
     --------------------------------------------- */
  .modal-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
    background: rgba(15, 23, 42, 0.72) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
  }

  .modal-box {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 88vh !important;
    border-radius: 20px 20px 0 0 !important;
    border: none !important;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3) !important;
    display: flex !important;
    flex-direction: column !important;
    transform: translateY(100%) !important;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1) !important;
    overflow: hidden !important;
  }

  .modal-overlay.active .modal-box {
    transform: translateY(0) !important;
  }

  .modal-box form {
    display: flex !important;
    flex-direction: column !important;
    max-height: calc(88vh - 54px) !important;
    overflow: hidden !important;
  }

  .modal-header {
    padding: 0.75rem 1rem !important;
    border-radius: 20px 20px 0 0 !important;
    flex-shrink: 0 !important;
  }

  .modal-title {
    font-size: 0.92rem !important;
    font-weight: 700 !important;
  }

  .modal-close {
    width: 28px !important;
    height: 28px !important;
    font-size: 1.15rem !important;
  }

  .modal-body {
    padding: 0.85rem 1rem !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    flex: 1 !important;
  }

  /* In mobile modal, convert 2-column input grids to clean stacked or tight responsive layout */
  .modal-body div[style*="grid-template-columns"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem !important;
  }

  @media screen and (max-width: 440px) {
    .modal-body div[style*="grid-template-columns"] {
      grid-template-columns: 1fr !important;
      gap: 0.45rem !important;
    }
  }

  .modal-body .form-group {
    margin-bottom: 0.55rem !important;
  }

  .modal-body .form-label {
    font-size: 0.72rem !important;
    font-weight: 600 !important;
    color: #475569 !important;
    margin-bottom: 0.22rem !important;
  }

  .modal-body .form-control,
  .modal-body .form-select,
  .modal-body .searchable-select-trigger {
    height: 38px !important;
    font-size: 0.82rem !important;
    padding: 0.45rem 0.65rem !important;
    border-radius: 8px !important;
  }

  .modal-footer {
    padding: 0.65rem 1rem !important;
    border-radius: 0 !important;
    background: #f8fafc !important;
    border-top: 1px solid #e2e8f0 !important;
    gap: 0.5rem !important;
    flex-shrink: 0 !important;
  }

  .modal-btn-save {
    height: 38px !important;
    min-width: 105px !important;
    font-size: 0.84rem !important;
    padding: 0 1rem !important;
    border-radius: 8px !important;
  }

  .modal-btn-cancel {
    height: 38px !important;
    min-width: 80px !important;
    font-size: 0.84rem !important;
    padding: 0 0.85rem !important;
    border-radius: 8px !important;
  }

  /* Make sure searchable-select in mobile modals scrolls and displays menu cleanly */
  .modal-body .searchable-select-menu {
    position: static !important;
    margin-top: 6px !important;
    max-height: 220px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
  }
  .modal-body .searchable-select-options {
    max-height: 170px !important;
  }
}


