body {
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

section {
  /* Add a little vertical spacing */
  padding-top: 3rem;
  padding-bottom: 3rem;
}

.card-title {
  color: #212529;
}

footer {
  margin-top: 2rem;
}

/* Custom blue color classes */
.custom-blue {
  background-color: #023469 !important;
}

.custom-blue-btn {
  background-color: #023469 !important;
  border-color: #023469 !important;
  color: white !important;
}

.custom-blue-btn:hover {
  background-color: #022a5a !important;
  border-color: #022a5a !important;
  color: white !important;
}

/* Sidebar styles */
.sidebar {
  min-height: 100vh;
  box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
  background-color: #023469 !important;
}

/* Make the container and row extend to full height so sidebar can match the full page including footer */
.container-fluid {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.container-fluid > .row {
  display: flex !important;
  align-items: stretch !important;
  flex: 1;
  min-height: 100%;
  flex-wrap: nowrap !important; /* Prevent wrapping - keep sidebar and main on same row */
}

/* Ensure both sidebar and main stretch to same height */
.container-fluid > .row > nav.sidebar,
.container-fluid > .row > main {
  align-self: stretch;
}

/* Ensure sidebar extends to full height of row (including footer) */
@media (min-width: 768px) {
  .sidebar {
    display: flex !important;
    flex-direction: column !important;
    align-self: stretch !important;
  }
  
  /* Ensure offcanvas-body fills the sidebar */
  .sidebar .offcanvas-body {
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
  }
  
  /* Make position-sticky div fill available space */
  .sidebar .offcanvas-body > .position-sticky {
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
  }
  
  /* Make sure main content also stretches */
  main {
    display: block !important; /* Change from flex to block to allow normal flow */
    flex: 1;
    align-self: stretch;
  }
  
  /* Ensure sections stack vertically */
  main > section {
    display: block !important;
    width: 100% !important;
  }
  
  /* Ensure container-fluid inside sections takes full width */
  main section .container-fluid {
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  
  /* Ensure rows inside main take full width and stack vertically */
  main section .container-fluid .row,
  main .row {
    display: flex !important;
    flex-wrap: wrap !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-left: calc(var(--bs-gutter-x, 0.75rem) * -.5) !important;
    margin-right: calc(var(--bs-gutter-x, 0.75rem) * -.5) !important;
  }
  
  /* Ensure col-12 inside rows takes full width and forces new line */
  main section .container-fluid .row .col-12,
  main .row .col-12 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    width: 100% !important;
  }
}

/* Limit sidebar width on large screens - prevent it from expanding too wide */
/* Apply to all screen sizes 768px and above */
@media (min-width: 768px) {
  /* Target the nav element with sidebar class - override Bootstrap's flex behavior */
  /* Force sidebar to size based on content, not Bootstrap's percentage grid */
  nav.sidebar,
  nav.col-md-3.sidebar,
  nav.col-lg-2.sidebar,
  #sidebar.sidebar,
  #sidebar.col-md-3,
  #sidebar.col-lg-2,
  nav.col-md-3.d-md-block.sidebar,
  nav.col-lg-2.d-md-block.sidebar,
  nav.col-md-3.col-lg-2.sidebar,
  nav.sidebar[class*="col-"],
  #sidebar[class*="col-"],
  /* Override Bootstrap's grid column width calculation completely */
  nav.col-md-3,
  nav.col-lg-2 {
    width: fit-content !important;
    max-width: 280px !important;
    flex: 0 0 fit-content !important;
    flex-basis: fit-content !important;
    flex-grow: 0 !important;
    flex-shrink: 0 !important;
    min-width: fit-content !important;
  }
  
  /* Sidebar already has flex and align-self: stretch from above, just ensure it works */
  
  /* Ensure the offcanvas-body doesn't expand the sidebar - constrain it to content width */
  .sidebar .offcanvas-body,
  nav.sidebar .offcanvas-body,
  #sidebar .offcanvas-body {
    width: fit-content !important;
    max-width: 100% !important;
    min-width: fit-content !important;
    flex: 0 0 auto !important;
    flex-grow: 0 !important;
    flex-shrink: 0 !important;
  }
  
  /* Ensure position-sticky div inside offcanvas-body doesn't expand */
  .sidebar .offcanvas-body > .position-sticky,
  .sidebar .offcanvas-body > div {
    width: fit-content !important;
    max-width: 100% !important;
  }
  
  /* Prevent the row from forcing expansion */
  .row > nav.sidebar,
  .container-fluid .row > nav.sidebar,
  .row > #sidebar,
  .container-fluid .row > #sidebar {
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
  }
  
  /* Ensure the sidebar content (nav items) determines the width */
  .sidebar .nav,
  .sidebar .offcanvas-body .nav {
    width: fit-content !important;
    max-width: 100% !important;
    white-space: nowrap !important;
    flex: 0 0 auto !important;
  }
  
  /* Add padding to nav items for proper spacing */
  .sidebar .nav-link {
    padding-left: 1.5rem !important;
    padding-right: 1.5rem !important;
  }
  
  /* Ensure navbar-brand inside sidebar doesn't expand */
  .sidebar .navbar-brand {
    width: fit-content !important;
    max-width: 100% !important;
  }
  
  /* Prevent container-fluid from forcing sidebar to expand */
  .container-fluid > .row {
    align-items: flex-start !important;
  }
  
  /* Make main content area take up remaining space after sidebar */
  main.col-md-9,
  main.col-lg-10 {
    flex: 1 !important;
    flex-grow: 1 !important;
    max-width: none !important;
    width: auto !important;
    margin-left: 0 !important;
  }
  
  /* Add small gap between sidebar and main content */
  nav.sidebar + main {
    margin-left: 1rem !important;
  }
  
  /* Ensure main content doesn't wrap below sidebar */
  .container-fluid > .row > main {
    flex: 1;
    min-width: 0; /* Allow flex item to shrink below its content size */
  }
}


.sidebar .nav-link {
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8) !important;
  padding: 0.75rem 1rem;
  transition: all 0.3s ease;
}

.sidebar .nav-link:hover {
  color: #fff !important;
  background-color: rgba(255, 255, 255, 0.1);
}

.sidebar .nav-link.active {
  color: #fff !important;
  background-color: rgba(255, 255, 255, 0.2);
}

.sidebar .nav-link i {
  margin-right: 0.5rem;
}

/* Main content area */
main {
  min-height: 100vh;
}

/* Mobile navigation adjustments */
@media (max-width: 767.98px) {
  .sidebar {
    min-height: auto;
  }
  
  .offcanvas-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  }
  
  .offcanvas-title {
    font-size: 1.1rem;
  }
  
  /* Ensure proper spacing on mobile */
  .offcanvas-body {
    padding-top: 0;
  }
}

/* Custom table striping - alternating white and light blue */
.table.table-striped > tbody > tr:nth-of-type(odd) {
  background-color: #ffffff !important;
}

.table.table-striped > tbody > tr:nth-of-type(even) {
  background-color: #e3f2fd !important;
}

/* Ensure hover effects work with custom colors */
.table.table-striped > tbody > tr:hover {
  background-color: #f8f9fa !important;
}

/* Enhanced responsive table styles */
.table-responsive {
  border-radius: 0.375rem;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  max-width: 100%;
}

/* Responsive table improvements for different screen sizes */
@media (max-width: 767.98px) {
  .table-responsive {
    font-size: 0.875rem;
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  .table-responsive .table {
    min-width: 600px; /* Ensure minimum width for readability */
    width: 100%;
  }
  
  .table-responsive th,
  .table-responsive td {
    padding: 0.5rem 0.75rem;
    white-space: nowrap;
  }
  
  /* Add horizontal scroll indicator */
  .table-responsive::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.8));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  
  .table-responsive:hover::after {
    opacity: 1;
  }
  
  /* Ensure card body doesn't add extra padding on mobile */
  .card-body .table-responsive {
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
  }
  
  /* Add gap between tables for landscape smartphone orientation */
  .table-responsive {
    margin-bottom: 1rem !important;
  }
  
  .table-responsive:last-child {
    margin-bottom: 0 !important;
  }
  
  /* Add gap between cards for landscape smartphone orientation */
  .row .col-12 {
    margin-bottom: 1rem !important;
  }
  
  .row .col-12:last-child {
    margin-bottom: 0 !important;
  }
  
  /* Add visual separation between cards for landscape smartphone orientation */
  .card {
    margin-bottom: 1rem !important;
  }
  
  .card:last-child {
    margin-bottom: 0 !important;
  }
}

@media (max-width: 575.98px) {
  .table-responsive {
    font-size: 0.8rem;
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  
  .table-responsive th,
  .table-responsive td {
    padding: 0.375rem 0.5rem;
  }
  
  /* Stack table headers on very small screens */
  .table-responsive .table {
    min-width: 500px;
  }
  
  /* Ensure card body doesn't add extra padding on very small screens */
  .card-body .table-responsive {
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
  }
  
  /* Force all table-responsive containers to full width on very small screens */
  .card .card-body .table-responsive,
  .table-responsive {
    width: 100vw !important;
    max-width: 100vw !important;
    margin-left: calc(-50vw + 50%) !important;
    margin-right: calc(-50vw + 50%) !important;
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
  }
  
  /* Ensure all tables inside table-responsive are full width */
  .table-responsive .table,
  .card .card-body .table-responsive .table {
    width: 100% !important;
    min-width: 500px !important;
  }
  
  /* Override any Bootstrap container constraints */
  .container-fluid,
  .container-fluid .row,
  .container-fluid .col-12 {
    max-width: none !important;
    width: 100% !important;
  }
  
  /* Ensure section doesn't add padding */
  section {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  
  /* Override any Bootstrap grid system constraints */
  .col-md-9,
  .col-lg-10 {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  
  /* Make card headers full width on very small screens */
  .card {
    width: 100vw !important;
    max-width: 100vw !important;
    margin-left: calc(-50vw + 50%) !important;
    margin-right: calc(-50vw + 50%) !important;
    border-radius: 0 !important;
  }
  
  .card-header {
    width: 100vw !important;
    max-width: 100vw !important;
    margin-left: calc(-50vw + 50%) !important;
    margin-right: calc(-50vw + 50%) !important;
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
    border-radius: 0 !important;
  }
  
  /* Ensure card content area is also full width */
  .card-body {
    width: 100vw !important;
    max-width: 100vw !important;
    margin-left: calc(-50vw + 50%) !important;
    margin-right: calc(-50vw + 50%) !important;
  }
  
  /* Add gap between cards on mobile */
  .row .col-12 {
    margin-bottom: 1rem !important;
  }
  
  .row .col-12:last-child {
    margin-bottom: 0 !important;
  }
  
  /* Add visual separation between cards */
  .card {
    margin-bottom: 1rem !important;
  }
  
  .card:last-child {
    margin-bottom: 0 !important;
  }
  
  /* Add gap between tables within cards on mobile */
  .table-responsive {
    margin-bottom: 1rem !important;
  }
  
  .table-responsive:last-child {
    margin-bottom: 0 !important;
  }
}

/* Improve table readability on larger screens */
@media (min-width: 768px) {
  .table-responsive {
    border: 1px solid #dee2e6;
    width: 100%;
  }
  
  .table-responsive .table {
    margin-bottom: 0;
    width: 100%;
  }
  
  /* Add gap between tables on larger screens */
  .table-responsive {
    margin-bottom: 1.5rem !important;
  }
  
  .table-responsive:last-child {
    margin-bottom: 0 !important;
  }
  
  /* Add gap between cards on larger screens */
  .row .col-12 {
    margin-bottom: 2rem !important;
  }
  
  .row .col-12:last-child {
    margin-bottom: 0 !important;
  }
  
  /* Add visual separation between cards */
  .card {
    margin-bottom: 2rem !important;
  }
  
  .card:last-child {
    margin-bottom: 0 !important;
  }
}

/* Add smooth scrolling for table navigation */
.table-responsive {
  scroll-behavior: smooth;
}

/* Improve table header styling for better responsiveness */
.table-responsive .table thead th {
  position: sticky;
  top: 0;
  background-color: #f8f9fa;
  z-index: 1;
  border-bottom: 2px solid #dee2e6;
}

/* Add visual feedback for scrollable tables */
.table-responsive:not(:hover) {
  box-shadow: inset 0 0 0 1px #dee2e6;
}

.table-responsive:hover {
  box-shadow: inset 0 0 0 1px #0d6efd;
}

/* Ensure tables take full width on all screen sizes */
.table {
  width: 100%;
  max-width: 100%;
}

/* Mobile-specific table optimizations */
@media (max-width: 767.98px) {
  .card-body {
    padding: 0;
  }
  
  .table-responsive {
    border-radius: 0;
  }
  
  /* Remove card padding on mobile for full-width tables */
  .card .card-body {
    padding: 0;
  }
  
  /* Ensure main content area doesn't add padding on mobile */
  main {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  
  /* Ensure container-fluid doesn't add padding on mobile */
  .container-fluid {
    padding-left: 0;
    padding-right: 0;
  }
  
  /* Ensure row doesn't add margins on mobile */
  .row {
    margin-left: 0;
    margin-right: 0;
  }
  
  /* Ensure col-12 doesn't add padding on mobile */
  .col-12 {
    padding-left: 0;
    padding-right: 0;
  }
  
  /* Force all table-responsive containers to full width */
  .card .card-body .table-responsive,
  .table-responsive {
    width: 100vw !important;
    max-width: 100vw !important;
    margin-left: calc(-50vw + 50%) !important;
    margin-right: calc(-50vw + 50%) !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
  
  /* Ensure all tables inside table-responsive are full width */
  .table-responsive .table,
  .card .card-body .table-responsive .table {
    width: 100% !important;
    min-width: 600px !important;
  }
  
  /* Override any Bootstrap container constraints */
  .container-fluid,
  .container-fluid .row,
  .container-fluid .col-12 {
    max-width: none !important;
    width: 100% !important;
  }
  
  /* Ensure section doesn't add padding */
  section {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  
  /* Override any Bootstrap grid system constraints */
  .col-md-9,
  .col-lg-10 {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  
  /* Make card headers full width on mobile */
  .card {
    width: 100vw !important;
    max-width: 100vw !important;
    margin-left: calc(-50vw + 50%) !important;
    margin-right: calc(-50vw + 50%) !important;
    border-radius: 0 !important;
  }
  
  .card-header {
    width: 100vw !important;
    max-width: 100vw !important;
    margin-left: calc(-50vw + 50%) !important;
    margin-right: calc(-50vw + 50%) !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    border-radius: 0 !important;
  }
  
  /* Ensure card content area is also full width */
  .card-body {
    width: 100vw !important;
    max-width: 100vw !important;
    margin-left: calc(-50vw + 50%) !important;
    margin-right: calc(-50vw + 50%) !important;
  }
}

/* Make filter options section more compact */
.filter-options .row {
  --bs-gutter-y: 0.25rem !important; /* Reduce vertical gutter */
  --bs-gutter-x: 0.5rem !important;  /* Optional: reduce horizontal gutter */
}
.filter-options .form-label {
  margin-bottom: 0.2rem !important;
  font-size: 0.95em;
}
.filter-options .form-control {
  padding-top: 0.2rem !important;
  padding-bottom: 0.2rem !important;
  font-size: 0.95em;
}
.filter-options .card-body {
  padding-top: 0.5rem !important;
  padding-bottom: 0.5rem !important;
}
.filter-options .card-header {
  padding-top: 0.4rem !important;
  padding-bottom: 0.4rem !important;
}

/* Table scroll indicator and no-wrap styles */
.table-scroll-indicator {
  position: sticky;
  top: 0;
  z-index: 10;
}

.table-responsive table td,
.table-responsive table th {
  white-space: nowrap !important;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-responsive table td {
  max-width: 200px;
  padding: 0.5rem 0.75rem !important;
}

.table-responsive table th {
  padding: 0.75rem 0.75rem !important;
  background-color: #f8f9fa !important;
  border-bottom: 2px solid #dee2e6 !important;
  position: sticky;
  top: 0;
  z-index: 5;
}

/* Make table header sticky */
.table-responsive .table thead th {
  position: sticky;
  top: 0; /* Stick to the very top when scrolling vertically */
  background-color: #f8f9fa !important;
  z-index: 10;
  border-bottom: 2px solid #dee2e6 !important;
}

/* Ensure proper stacking context */
.table-responsive {
  position: relative;
  overflow-y: auto; /* Enable vertical scrolling */
  max-height: 70vh; /* Limit height to enable scrolling */
}