body {
  background-color: #f8f9fa;
  font-size: 0.95rem;
  min-width: 0;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.bg-orange {
  background-color: #fd7e14 !important;
}

.btn-orange {
  background-color: #fd7e14;
  color: #fff;
}
.btn-orange:hover {
  background-color: #e0660e;
  color: #fff;
}

.card {
  border-radius: 0.5rem;
}

.sidebar .nav-link {
  color: #ccc;
}
.sidebar .nav-link.active,
.sidebar .nav-link:hover {
  background-color: #333;
  color: #fff;
}

/* Shared application shell */
body > .d-flex {
  width: 100%;
  min-width: 0;
  flex: 1 0 auto;
}

body > .navbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  flex: 0 0 auto;
}

body > footer {
  flex: 0 0 auto;
  width: 100%;
  margin-top: auto;
}

#sidebarOffcanvas {
  --bs-offcanvas-width: min(86vw, 280px);
  flex: 0 0 260px;
  width: 260px;
  min-width: 0;
}

#sidebarOffcanvas .offcanvas-body {
  height: calc(100dvh - 64px) !important;
  overflow-y: auto;
  overscroll-behavior: contain;
}

#sidebarOffcanvas .nav-link {
  padding: 0.7rem 0.75rem;
  border-radius: 0.375rem;
}

#sidebarOffcanvas + :is(.container, .container-fluid, .main-content, main, .d-flex),
.main-content,
main.flex-grow-1,
.d-flex.flex-column.flex-fill {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
}

/* Several legacy pages offset content even though the sidebar is in the flex flow. */
.main-content[style*="padding-left"] {
  padding-left: 1.5rem !important;
}

.navbar {
  min-height: 64px;
  flex-wrap: nowrap;
}

.navbar-brand {
  min-width: 0;
  margin-right: 0.5rem;
  white-space: nowrap;
}

.navbar-brand img {
  flex: 0 0 auto;
  max-width: 54px;
  object-fit: contain;
}

.brand-title,
.brand-subtitle {
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-subtitle {
  font-size: 0.8rem;
  font-weight: 400;
  opacity: 0.9;
}

.logout-button {
  min-width: 42px;
  min-height: 38px;
}

.table-responsive {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-responsive > .table {
  margin-bottom: 0;
}

img,
svg,
video {
  max-width: 100%;
}

canvas {
  max-width: 100% !important;
}

.card,
.modal-content {
  max-width: 100%;
}

.btn-group,
.card-header,
.card-footer {
  flex-wrap: wrap;
}

@media (min-width: 992px) {
  #sidebarOffcanvas {
    position: sticky;
    top: 64px;
    align-self: flex-start;
    height: calc(100dvh - 64px);
  }
}

@media (max-width: 991.98px) {
  #sidebarOffcanvas {
    width: var(--bs-offcanvas-width);
    flex-basis: auto;
  }

  .main-content[style*="padding-left"] {
    padding-left: 1rem !important;
  }
}

@media (max-width: 767.98px) {
  body {
    font-size: 0.9rem;
  }

  .navbar {
    padding: 0.45rem 0.65rem !important;
  }

  .navbar-brand {
    font-size: 1rem;
    gap: 0.4rem !important;
  }

  .navbar-brand img {
    width: 42px;
    height: 38px;
  }

  .main-content,
  main.flex-grow-1,
  #sidebarOffcanvas + .container,
  #sidebarOffcanvas + .container-fluid,
  #sidebarOffcanvas + .d-flex {
    padding: 1rem !important;
  }

  .container,
  .container-fluid {
    --bs-gutter-x: 1.25rem;
  }

  .card.p-4,
  .card-body {
    padding: 1rem !important;
  }

  .table-responsive {
    margin-inline: 0;
    padding: 0;
    border-radius: 0.5rem;
  }

  /* Convert ordinary wide tables into labelled record cards on phones. */
  .mobile-card-table-wrap {
    overflow: visible;
    background: transparent;
    box-shadow: none;
  }

  .mobile-card-table,
  .mobile-card-table tbody {
    display: block;
    width: 100%;
  }

  .mobile-card-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .mobile-card-table tbody {
    display: grid;
    gap: 0.85rem;
  }

  .mobile-card-table tbody tr {
    display: block;
    overflow: hidden;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.65rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  }

  .mobile-card-table tbody td {
    display: grid;
    grid-template-columns: minmax(7.5rem, 42%) minmax(0, 1fr);
    gap: 0.75rem;
    align-items: center;
    width: 100%;
    min-height: 42px;
    text-align: right !important;
    white-space: normal;
    overflow-wrap: anywhere;
    border-width: 0 0 1px;
  }

  .mobile-card-table tbody td:last-child {
    border-bottom: 0;
  }

  .mobile-card-table tbody td::before {
    content: attr(data-label);
    color: #5f6368;
    font-weight: 700;
    text-align: left;
  }

  .mobile-card-table tbody td[colspan] {
    display: block;
    padding: 1rem;
    text-align: center !important;
  }

  .mobile-card-table tbody td[colspan]::before,
  .mobile-card-table tbody td[data-label=""]::before {
    content: none;
  }

  .mobile-card-table tbody td img {
    justify-self: end;
  }

  .mobile-card-table tbody td .btn,
  .mobile-card-table tbody td .btn-group,
  .mobile-card-table tbody td form {
    justify-self: end;
    max-width: 100%;
  }

  .table {
    font-size: 0.82rem;
  }

  .table > :not(caption) > * > * {
    padding: 0.55rem 0.6rem;
  }

  h1 { font-size: 1.65rem; }
  h2 { font-size: 1.45rem; }
  h3 { font-size: 1.3rem; }
  h4 { font-size: 1.15rem; }

  .form-control,
  .form-select,
  .btn {
    min-height: 42px;
  }

  .btn-sm {
    min-height: 36px;
  }

  footer {
    padding-inline: 1rem;
    font-size: 0.8rem;
  }
}

@media (max-width: 419.98px) {
  .brand-title {
    max-width: 145px;
  }

  .navbar-toggler {
    padding-inline: 0.35rem;
    margin-right: 0.25rem !important;
  }

  .modal-dialog {
    margin: 0.5rem;
  }
}
