:root {
  --tblr-primary: #1677ff;
  --tblr-primary-rgb: 22, 119, 255;
  --tblr-border-color: #d9d9d9;
  --tblr-card-shadow: 0 6px 18px rgba(5, 5, 5, 0.06);
  --tblr-body-bg: #f5f7f9;
  --tblr-text: rgba(0, 0, 0, 0.88);
  --tblr-text-muted: rgba(0, 0, 0, 0.45);
  --tblr-surface: #ffffff;
  --tblr-surface-subtle: #fafafa;
}

.border-rfc {
  --bs-border-opacity: 1;
  border-color: rgba(217, 217, 217, var(--bs-border-opacity)) !important;
}

body {
  background: var(--tblr-body-bg);
  color: var(--tblr-text);
  padding-top: 70px;
  padding-left: 20px;
  padding-right: 20px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
}

html {
  overflow-x: hidden;
  scroll-behavior: smooth;
  scroll-padding-top: var(--app-scroll-offset, 96px);
}

body > .container-fluid.px-4 {
  padding-left: 10px !important;
  padding-right: 10px !important;
}

.back-to-top-button {
  position: fixed;
  right: 20px;
  bottom: 24px;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 999px;
  background: var(--tblr-primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px rgba(var(--tblr-primary-rgb), 0.22);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease, background-color 0.2s ease;
  z-index: 1060;
  pointer-events: none;
}

.back-to-top-button.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.back-to-top-button:hover,
.back-to-top-button:focus-visible {
  background: #0958d9;
  outline: none;
}

.back-to-top-button span {
  font-size: 1.3rem;
  line-height: 1;
  font-weight: 700;
}

@media (max-width: 767.98px) {
  .back-to-top-button {
    right: 14px;
    bottom: 18px;
    width: 42px;
    height: 42px;
  }
}

body > .container-fluid.px-4 > .card.mb-5.records-card {
  width: 100%;
  max-width: 90vw;
  margin-left: auto;
  margin-right: auto;
}

.records-card .card-header {
  background-color: var(--tblr-surface) !important;
  color: var(--tblr-text) !important;
  border-bottom: 1px solid var(--tblr-border-color);
}

.records-card .table {
  --bs-table-striped-bg: #fafafa;
  --bs-table-striped-color: var(--tblr-text);
  --bs-table-hover-bg: #f0f5ff;
  --bs-table-hover-color: var(--tblr-text);
  --bs-table-border-color: #f0f0f0;
}

.records-card .table thead th {
  background-color: #fafafa !important;
  color: var(--tblr-text);
  border-bottom: 1px solid #f0f0f0;
  letter-spacing: 0.03em;
}

.records-card .table thead th .sort-link {
  color: var(--tblr-text);
}

.records-card .table thead th .sort-link:hover {
  color: var(--tblr-primary);
  text-decoration: none;
}

.records-card .table tbody td {
  border-bottom: 1px solid #f0f0f0;
  vertical-align: top;
  color: var(--tblr-text);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.25;
}

.records-card .table tbody td .cell-value,
.records-card .table tbody td .date-cell-main,
.records-card .table tbody td .weekday-inline {
  display: block;
  width: 100%;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  text-align: left;
}

.records-card .table thead .id-col {
  background-color: #fafafa;
}

.records-card .table tbody tr:nth-of-type(odd) .id-col {
  background-color: #fafafa;
}

.records-card .table tbody tr:nth-of-type(even) .id-col {
  background-color: #ffffff;
}

.records-card .table tbody tr:hover .id-col {
  background-color: #f0f5ff;
}

.card {
  border: 1px solid var(--tblr-border-color);
  border-radius: 16px;
  box-shadow: var(--tblr-card-shadow);
  background-color: var(--tblr-surface);
}

.card-header {
  border-bottom: 1px solid var(--tblr-border-color);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.table-container {
  max-height: 400px;
  overflow-y: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table .id-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
}

.table thead .id-col {
  z-index: 4;
  background: #fafafa;
}

.weekday-inline {
  display: none;
}

.records-card .weekday-inline {
  display: none;
}

.date-cell-main {
  display: block;
}

@media (max-width: 767.98px) {
  .table .mobile-hide-col {
    display: none;
  }

  .table .weekday-col {
    display: none;
  }

  .records-card .weekday-inline {
    display: block;
    margin-top: 2px;
    font-size: 0.78rem;
    line-height: 1.2;
  }
}

.table thead th {
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--tblr-text-muted);
}

#historyViewModal .history-modal-table thead th {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.2;
}

.table td,
.table th {
  padding: 0.85rem 0.95rem;
}

.sort-link {
  text-decoration: none;
  color: var(--tblr-text);
  font-weight: 600;
}

.sort-link:hover {
  text-decoration: underline;
  color: var(--tblr-primary);
}

.history-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  margin-left: 6px;
  vertical-align: middle;
  border-radius: 999px;
  font-size: 0.612rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
  padding: 0 3.4px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.history-indicator.bg-history-green {
  background-color: #52c41a;
  transform: scale(1.02);
}

.history-indicator.bg-history-gray {
  background-color: #bfbfbf;
  opacity: 0.9;
}

.bg-history-green {
  background-color: #52c41a;
  cursor: pointer;
}

.bg-history-gray {
  background-color: #bfbfbf;
}

.custom-navbar {
  background: #ffffff;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  z-index: 1040;
  display: flex;
  align-items: center;
  padding: 0 20px;
  box-shadow: 0 1px 0 rgba(5, 5, 5, 0.08);
}

.custom-navbar .stuff-navbar-search-wrap {
  max-width: 380px;
  width: min(45vw, 380px);
}

.menu-trigger {
  background: none;
  border: none;
  color: var(--tblr-text);
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.custom-navbar .text-white {
  color: var(--tblr-text) !important;
}

.custom-navbar .text-muted {
  color: var(--tblr-text-muted) !important;
}

/* Top-header "AI" server-status badge (templates/site_master.html, left of the
   Sign Out control). The navbar's own `.custom-navbar .text-white` rule would
   force dark text on a `text-white` utility here, so the badge's white text
   comes from its own rule instead. The base `.ai-status-badge` neutral-gray
   background shows from page load until the first ping answers; the JS in
   static/js/ai_status_badge.js then flips the badge to `.ai-status-online`
   (solid green) or `.ai-status-offline` (solid red + pulse). */
.ai-status-badge {
  color: #fff;
  background-color: #6c757d; /* pending */
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1;
  vertical-align: middle;
  white-space: nowrap;
  border-radius: 0.5rem;
  transition: background-color 0.25s ease;
}

.ai-status-badge-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

/* Hover tooltip under the "AI" badge: shows a live countdown to the next ping
   ("Next AI ping in Ns"), swapped for "Pinging AI server..." while a ping is
   in flight and then the ping's outcome for a few seconds afterwards. Hidden
   until the wrapper is hovered/focused; its text is refreshed every 250 ms by
   static/js/ai_status_badge.js, so it is always current when revealed. */
.ai-status-tooltip {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 1080;
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.25;
  color: #fff;
  background-color: #212529;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.ai-status-badge-wrap:hover .ai-status-tooltip,
.ai-status-badge-wrap:focus-within .ai-status-tooltip {
  display: block;
}

.ai-status-badge.ai-status-online {
  background-color: #198754; /* green */
}

.ai-status-badge.ai-status-offline {
  background-color: #dc3545; /* red */
  animation: ai-status-pulse 1.5s ease-in-out infinite;
}

@keyframes ai-status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.25);
  z-index: 1045;
  display: none;
}

.app-sidebar {
  position: fixed;
  top: 0;
  left: -280px;
  width: 280px;
  height: 100vh;
  height: 100dvh;
  box-sizing: border-box;
  background: #f0f2f5;
  z-index: 1050;
  transition: left 0.3s ease;
  padding: 14px;
  /* Reserve 50px of clear space beneath the bottom navigation link. */
  padding-bottom: 50px;
  /* Lay the navigation out as a column of equally-sized rows with one uniform
     gap so every link is evenly spaced down the full window height. */
  display: flex;
  flex-direction: column;
  gap: 2px;
  /* Never scroll or clip the bottom links: the rows shrink to fit instead. */
  overflow: hidden;
  color: var(--tblr-text);
}

.app-sidebar.active {
  left: 0;
}

.sidebar-overlay.active {
  display: block;
}

.sidebar-link {
  display: block;
  color: var(--tblr-text-muted);
  padding: 6px 10px;
  text-decoration: none;
  border-radius: 10px;
  font-weight: 500;
  line-height: 1.15;
  font-size: 0.88rem;
}

.sidebar-link:hover,
.sidebar-link.active {
  background-color: #e6f4ff;
  color: var(--tblr-primary);
}

.sidebar-brand {
  font-size: 20px;
  font-weight: bold;
  color: var(--tblr-text);
  margin-bottom: 10px;
  border-bottom: 1px solid var(--tblr-border-color);
  padding-bottom: 7px;
}

/*
  Even vertical spacing for the navigation menu.
  Every link is a flex child of .app-sidebar, so giving each an equal share of
  the free space (flex: 1 1 0) makes all rows the same height and keeps the gap
  between them uniform. min-height: 0 lets the rows compress on short windows so
  the whole menu still fits the visible height (with the container's 50px bottom
  padding beneath the last link) instead of overflowing. Single-line rows
  (white-space: nowrap) keep the spacing identical on every screen size.
*/
.app-sidebar .sidebar-link {
  flex: 1 1 0;
  min-height: 0;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
}

.linked-options-synonyms-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.28rem;
  padding: 0.12rem 0.48rem;
  border-radius: 999px;
  background: #f6ffed;
  border: 1px solid #b7eb8f;
  color: #389e0d;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  line-height: 1.1;
}

.linked-options-disabled-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.28rem;
  padding: 0.12rem 0.48rem;
  border-radius: 999px;
  background: #fff1f0;
  border: 1px solid #ffccc7;
  color: #cf1322;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  line-height: 1.1;
}

.linked-options-group-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.25rem;
  padding: 0.45rem 0.9rem;
  border-radius: 0.7rem;
  background: #64748b;
  color: #ffffff;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: normal;
  word-break: break-word;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.08);
}

.linked-options-group-badge.is-disabled {
  background: #cf1322;
}

.form-control,
.form-select {
  border: 1px solid #d9d9d9;
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  box-shadow: none;
  background-color: #fff;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--tblr-primary);
  box-shadow: 0 0 0 0.2rem rgba(var(--tblr-primary-rgb), 0.16);
}

.btn {
  border-radius: 999px;
  padding: 0.6rem 1rem;
  min-height: 44px;
}

.btn-primary {
  background-color: var(--tblr-primary);
  border-color: var(--tblr-primary);
  color: #fff;
  box-shadow: 0 2px 0 rgba(5, 145, 255, 0.1);
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: #0958d9;
  border-color: #0958d9;
  color: #fff;
}

.btn-warning {
  background-color: #faad14;
  border-color: #faad14;
  color: rgba(0, 0, 0, 0.88);
  box-shadow: 0 2px 0 rgba(250, 173, 20, 0.1);
}

.btn-warning:hover,
.btn-warning:focus {
  background-color: #d48806;
  border-color: #d48806;
  color: #fff;
}

.btn-secondary {
  box-shadow: none;
  background-color: #fff;
  border-color: #d9d9d9;
  color: var(--tblr-text);
}

.btn-outline-warning {
  color: #d48806;
  border-color: #d48806;
}

.btn-outline-warning:hover,
.btn-outline-warning:focus {
  background-color: #d48806;
  border-color: #d48806;
  color: #fff;
}

.btn-outline-danger {
  color: #cf1322;
  border-color: #cf1322;
}

.btn-outline-danger:hover,
.btn-outline-danger:focus {
  background-color: #cf1322;
  border-color: #cf1322;
  color: #fff;
}

.modal-content {
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid #f0f0f0;
}

.card-header.bg-dark,
.modal-header.bg-dark,
.card-header.bg-primary,
.modal-header.bg-primary {
  background-color: #fafafa !important;
  color: var(--tblr-text) !important;
  border-bottom: 1px solid #f0f0f0;
}

.card-header.bg-warning,
.modal-header.bg-warning {
  background-color: #fffbe6 !important;
  color: #ad6800 !important;
  border-bottom: 1px solid #ffe58f;
}

.table-light,
.table-light > th,
.table-light > td {
  background-color: #fafafa !important;
  color: var(--tblr-text) !important;
}

.text-primary {
  color: #1677ff !important;
}

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

#historyViewModal .history-meta-wrap {
  margin-top: 0.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

#reasonModal [data-testid="reason-progress-wrap"] {
  background: #fff8e1;
  border: 1px solid #e9ecef;
  border-radius: 10px;
  padding: 0.5rem 0.65rem;
}

#historyViewModal .history-meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  background: #f0f0f0;
  border: 1px solid #d9d9d9;
  color: var(--tblr-text);
  max-width: 100%;
}

#historyViewModal .history-meta-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--tblr-text-muted);
  font-weight: 700;
}

#historyViewModal .history-meta-value {
  font-size: 0.73rem;
  line-height: 1.1;
  font-weight: 600;
  overflow-wrap: anywhere;
}

@media (max-width: 575.98px) {
  #historyViewModal .history-meta-badge {
    width: 100%;
    justify-content: space-between;
  }
}

/* Field history indicators style - BEGIN */

/* Cell layout helper to stack value and dots vertically */
.history-cell {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  position: relative;
  width: 100%;
  min-height: 52px;
  padding-bottom: 10px;
}

.history-cell.history-align-left {
  --history-bar-left: 0;
  --history-bar-transform: none;
  --history-bar-justify: flex-start;
}

.history-cell.history-align-center {
  --history-bar-left: 50%;
  --history-bar-transform: translateX(-50%);
  --history-bar-justify: center;
}

/* Dots alignment container */
.history-bars-indicator {
  display: flex;
  justify-content: var(--history-bar-justify, center);
  align-items: center;
  gap: 5px;
  position: absolute;
  left: var(--history-bar-left, 50%);
  bottom: 0;
  transform: var(--history-bar-transform, translateX(-50%));
  min-height: 18px;
  --history-bar-height: 9px;
  cursor: pointer;
  padding: 0 6px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.history-bars-indicator::after {
  content: attr(data-change-count);
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  font-size: calc(var(--history-bar-height) * 1.15);
  line-height: 1;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.72);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  z-index: 2;
}

.history-bars-indicator:hover::after {
  opacity: 1;
}

.history-bars-indicator:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.history-bars-inline {
  position: relative;
  left: auto;
  bottom: auto;
  transform: none;
  margin-left: 4px;
  min-height: var(--history-bar-height);
  flex: 0 0 auto;
}

.history-bars-inline::after {
  opacity: 1;
}

.history-bars-static {
  cursor: default;
}

.history-bars-static:hover {
  background-color: transparent;
}

/* Base structural style for all bars */
.history-bar {
    border-radius: 50%;
    display: inline-block;
    flex: 0 0 auto;
}

/* 1 change = bar_one */
.bar_zero {
  position: relative;
}

.bar_zero .history-bar {
  display: none;
}

.bar_zero::before {
  content: "";
  width: 23px;
  height: var(--history-bar-height);
  border-radius: 999px;
  background-color: #d9dee2;
}

/* 1 change = bar_one */
.bar_one {
  position: relative;
}

.bar_one .history-bar {
  display: none;
}

.bar_one::before {
  content: "";
  width: 23px;
  height: var(--history-bar-height);
  border-radius: 999px;
  background-color: #c7d7e3;
}

/* 2 changes = bar_two */
.bar_two {
  position: relative;
}

.bar_two .history-bar {
  display: none;
}

.bar_two::before {
  content: "";
  width: 32.3px;
  height: var(--history-bar-height);
  border-radius: 999px;
  background: linear-gradient(90deg, #c7d7e3 0%, #a5bdc4 50%, #818380 100%);
}

/* 3+ changes = bar_threeplus */
.bar_threeplus {
  position: relative;
}

.bar_threeplus .history-bar {
  display: none;
}

.bar_threeplus::before {
  content: "";
  width: 44px;
  height: var(--history-bar-height);
  border-radius: 999px;
  background: linear-gradient(90deg, #b3c2cc 0%, #a3bbc2 45%, #6a5d73 100%);
}

/* Field history indicators style - END */

/* Searchable lookup dropdowns */
.lookup-select-group {
  flex-wrap: nowrap;
  align-items: stretch;
}

.lookup-select-group > .select2-container {
  flex: 1 1 auto;
  min-width: 0;
  width: auto !important;
  max-width: calc(100% - 2.7rem);
}

.lookup-select-group > .form-select {
  flex: 1 1 auto;
  min-width: 0;
  max-width: calc(100% - 2.7rem);
}

.lookup-select-group > .btn[data-add-lookup-option] {
  flex: 0 0 auto;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left: 0;
  font-weight: 700;
  min-width: 2.7rem;
}

.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
  border: 1px solid #d9d9d9;
  border-radius: 10px;
  min-height: 42px;
}

.select2-container--default .select2-selection--single {
  padding: 0.45rem 0.75rem;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 1.4;
  padding-left: 0;
  color: var(--tblr-text);
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 100%;
}

.select2-container--default .select2-selection--multiple {
  padding: 0.2rem 0.45rem;
}

.select2-dropdown {
  border-color: #d9d9d9;
  border-radius: 10px;
  box-shadow: 0 8px 22px rgba(5, 5, 5, 0.12);
}

.select2-search--dropdown .select2-search__field {
  border: 1px solid #d9d9d9;
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
}

.stuff-header-search-wrap {
  width: min(100%, 440px);
}

.stuff-global-search {
  position: relative;
  width: 100%;
}

.stuff-global-search-input-wrap {
  display: flex;
  align-items: stretch;
}

.stuff-global-search-input-wrap .form-control {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  min-height: 38px;
}

.stuff-global-search-input-wrap .btn {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left: 0;
  min-width: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.stuff-global-search-icon {
  width: 1rem;
  height: 1rem;
}

.stuff-global-search-results {
  position: absolute;
  top: calc(100% + 0.3rem);
  left: 0;
  width: 100%;
  max-height: 22rem;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #d9dee3;
  border-radius: 0.65rem;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.2);
  z-index: 1060;
}

.stuff-global-search-result {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.65rem;
  color: #1f2937;
  text-decoration: none;
  border-bottom: 1px solid #eef2f6;
}

.stuff-global-search-result:last-child {
  border-bottom: 0;
}

.stuff-global-search-result:hover,
.stuff-global-search-result:focus {
  background: #f6f9fc;
  color: #0f172a;
}

.stuff-global-search-thumb {
  width: 38px;
  height: 38px;
  border-radius: 0.4rem;
  border: 1px solid #d9dee3;
  object-fit: cover;
  flex: 0 0 38px;
  background: #fff;
}

.stuff-global-search-thumb-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  font-size: 0.75rem;
  font-weight: 700;
  background: #f8fafc;
}

.stuff-global-search-text {
  min-width: 0;
}

.stuff-global-search-title {
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stuff-global-search-meta {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 0.1rem;
  line-height: 1.2;
}

.stuff-global-search-empty {
  padding: 0.65rem;
  color: #64748b;
  font-size: 0.8rem;
}

.dual-list-container .form-select[multiple] {
  min-height: 220px;
}

.dual-list-container .dual-list-grid .btn {
  min-width: 64px;
}

.field-char-counter {
  margin-top: 0.25rem;
  line-height: 1.1;
}

#reasonModal .modal-body {
  max-height: min(60vh, 480px);
  overflow-y: scroll;
  scrollbar-gutter: stable;
  scrollbar-width: auto;
}

#reasonModal .modal-body::-webkit-scrollbar {
  width: 14px;
}

#reasonModal .modal-body::-webkit-scrollbar-track {
  background: #f1f3f5;
}

#reasonModal .modal-body::-webkit-scrollbar-thumb {
  background-color: #adb5bd;
  border-radius: 10px;
  border: 3px solid #f1f3f5;
}

/* Responsive UX: sticky section navigation + touch-friendly controls + table cards on phones. */
.page-section-nav {
  position: relative;
  top: 0;
  z-index: 1020;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(6px);
  border: 1px solid #e5e7eb;
  border-radius: 0.85rem;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.page-section-layout {
  position: relative;
}

.page-section-content-pane {
  position: relative;
}

.page-section-layout .page-section-nav {
  max-height: calc(100vh - var(--app-sticky-top, 66px) - 10px);
  overflow-y: auto;
}

.page-section-nav .nav-link {
  color: #334155;
  border-radius: 999px;
  font-size: 0.89rem;
  font-weight: 600;
  line-height: 1.2;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 0.9rem;
  white-space: nowrap;
}

.page-section-nav .nav-link.active {
  background: #e6f4ff;
  color: #0c4a6e;
}

.menu-trigger,
.sidebar-link,
.pagination .page-link,
.table .btn {
  min-height: 44px;
  min-width: 44px;
}

.form-check {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.table .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 991.98px) {
  body {
    padding-left: 10px;
    padding-right: 10px;
  }

  .custom-navbar {
    padding: 0 12px;
  }

  .custom-navbar .stuff-navbar-search-wrap {
    width: min(52vw, 280px);
  }

  .sidebar-link {
    font-size: 0.95rem;
    padding: 0.65rem 0.8rem;
  }

  .table-container {
    max-height: none;
  }
}

@media (max-width: 767.98px) {
  :root {
    --mobile-scrollspy-rail-width: 52px;
    --mobile-scrollspy-rail-gap: 8px;
    --mobile-scrollspy-form-gap: 5px;
  }

  .form-control,
  .form-select,
  textarea,
  input,
  select {
    min-height: 44px;
    font-size: 16px !important;
  }

  .input-group > .btn,
  .btn {
    min-height: 44px;
  }

  .records-card .card-header,
  .card-header {
    padding: 0.8rem 0.9rem;
  }

  .custom-navbar .stuff-navbar-search-wrap {
    width: min(58vw, 230px);
  }

  .stuff-header-search-wrap {
    width: 100%;
  }

  .page-section-layout {
    padding-right: calc((var(--mobile-scrollspy-rail-width) + var(--mobile-scrollspy-rail-gap) + var(--mobile-scrollspy-form-gap)) * 0.4);
    margin-right: 0;
    --bs-gutter-x: 0.5rem;
  }

  .page-section-content-pane {
    padding-right: 0;
  }

  .page-section-content-pane .row.g-3 {
    --bs-gutter-x: 0.5rem;
  }

  .page-section-aside {
    position: static;
    width: 0;
    padding: 0;
    margin: 0;
  }

  .page-section-nav {
    position: fixed;
    right: var(--mobile-scrollspy-rail-gap);
    top: var(--mobile-scrollspy-top, calc(var(--app-sticky-top, 62px) + 8px));
    z-index: 1035;
    width: var(--mobile-scrollspy-rail-width);
    max-height: calc(100vh - var(--app-sticky-top, 62px) - 16px);
    padding: 0.35rem !important;
    gap: 0.35rem !important;
    overflow-x: hidden;
  }

  .page-section-nav .nav-link {
    width: 100%;
    min-width: 100%;
    min-height: 42px;
    padding: 0.45rem;
    justify-content: center;
  }

  .page-section-nav .scrollspy-label {
    width: 100%;
    justify-content: center;
  }

  .page-section-nav .scrollspy-label-icon {
    width: 1.05rem;
    height: 1.05rem;
    flex: 0 0 1.05rem;
  }

  .page-section-nav .nav-link.active {
    background: #1677ff;
    color: #ffffff;
    box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.24);
  }

  .page-section-nav .nav-link.active .scrollspy-label-icon {
    filter: brightness(0) invert(1);
  }

  .page-section-nav .scrollspy-label-text {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

@media (min-width: 992px) {
  body.stuff-pane-scroll-lock {
    overflow-y: hidden;
    height: 100vh;
  }

  body.stuff-pane-scroll-lock > .container-fluid.px-4[data-page-path="/"] {
    height: calc(100vh - 70px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  body.stuff-pane-scroll-lock > .container-fluid.px-4[data-page-path="/"] > h2 {
    flex: 0 0 auto;
  }

  body.stuff-pane-scroll-lock [data-testid="stuff-form-card"] {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  body.stuff-pane-scroll-lock [data-testid="stuff-form-card"] > .card-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
  }

  body.stuff-pane-scroll-lock #stuffihadItemsForm {
    height: 100%;
  }

  body.stuff-pane-scroll-lock #stuffihadItemsForm > .page-section-layout {
    height: 100%;
    min-height: 0;
  }

  .page-section-aside {
    position: sticky;
    /* top: var(--app-sticky-top, 64px); */
    align-self: flex-start;
    width: auto;
    flex: 0 0 auto;
    max-height: calc(100vh - var(--app-sticky-top, 64px) - 10px);
  }

  .page-section-content-pane {
    max-height: calc(100vh - var(--app-sticky-top, 64px) - 10px);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
    padding-right: 0.25rem;
  }

  body.stuff-pane-scroll-lock .page-section-aside {
    max-height: 100%;
  }

  body.stuff-pane-scroll-lock .page-section-content-pane {
    height: 100%;
    max-height: 100%;
  }

  .page-section-nav {
    width: max-content;
    max-height: 100%;
  }

  .page-section-nav .nav-link {
    width: auto;
    justify-content: flex-start;
    text-align: left;
  }

  .scrollspy-pane-bottom-spacer {
    min-height: 240px;
    height: 44vh;
  }
}

@media (max-width: 991.98px) {
  .scrollspy-pane-bottom-spacer {
    min-height: 0;
    height: 0;
  }
}

@media (min-width: 768px) and (max-width: 991.98px) {
  .page-section-aside {
    position: sticky;
    /* top: 6px !important; */
    margin-top: 2px;
    align-self: flex-start;
    width: auto;
    flex: 0 0 auto;
    max-height: calc(100vh - var(--tablet-scrollspy-top, var(--app-sticky-top, 64px)) - 10px);
    transform: none !important;
    z-index: 1024;
  }

  .page-section-nav {
    position: sticky;
    top: 0;
    z-index: 1025;
    width: max-content;
    max-height: 100%;
    overflow-y: auto;
    background: var(--bs-body-bg, #fff);
  }

  .page-section-nav .nav-link {
    width: auto;
    justify-content: flex-start;
    text-align: left;
  }

  .page-section-content-pane {
    padding-right: 0;
  }
}

@media (max-width: 767.98px) {
  .scrollspy-pane-bottom-spacer {
    min-height: 240px;
    height: 52vh;
  }
}

@media (max-width: 575.98px) {
  .mobile-sort-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
  }

  .mobile-sort-links .mobile-sort-link {
    min-height: 44px;
    padding: 0.55rem 0.8rem;
    font-size: 0.78rem;
  }

  .responsive-stack-table {
    border-collapse: separate;
    border-spacing: 0;
  }

  .responsive-stack-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
  }

  .responsive-stack-table,
  .responsive-stack-table tbody,
  .responsive-stack-table tr,
  .responsive-stack-table td {
    display: block;
    width: 100%;
  }

  .responsive-stack-table tbody tr {
    margin: 0.8rem 0.65rem;
    border: 1px solid #dbe3eb;
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
    padding: 0.35rem 0.55rem;
  }

  .responsive-stack-table tbody td {
    position: relative;
    border: 0 !important;
    border-bottom: 1px dashed #edf2f7 !important;
    padding: 0.65rem 0.55rem 0.7rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    min-height: 44px;
  }

  .responsive-stack-table tbody td:last-child {
    border-bottom: 0 !important;
  }

  .responsive-stack-table tbody td::before {
    content: attr(data-label);
    display: inline-block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    font-weight: 700;
  }

  .responsive-stack-table tbody td.id-col {
    background: transparent !important;
  }

  .responsive-stack-table tbody td.id-col .cell-value {
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
  }

  .responsive-stack-table .text-center {
    text-align: left !important;
  }

  .responsive-stack-table td .d-inline-flex,
  .responsive-stack-table td .d-flex {
    width: 100%;
    justify-content: flex-start !important;
    flex-wrap: wrap;
    gap: 0.45rem;
  }

  .responsive-stack-table td .btn,
  .responsive-stack-table td .form-control,
  .responsive-stack-table td .form-select {
    width: 100%;
    max-width: 100%;
  }

  .responsive-stack-table td input[type='checkbox'].form-check-input {
    width: 1.2rem;
    min-width: 1.2rem;
    min-height: 1.2rem;
    margin-top: 0.2rem;
  }

  .responsive-stack-table td .history-cell {
    min-height: 0;
    padding-bottom: 0.35rem;
  }

  .responsive-stack-table td .history-bars-indicator {
    position: relative;
    left: auto;
    bottom: auto;
    transform: none;
    margin-top: 0.25rem;
  }
}


