/* Shared dense-table UX: scroll containment, sticky key column, column chooser, mobile cards. */

.responsive-table-toolbar {
  align-items: center;
  background: #fafafa;
  border-bottom: 1px solid #eee;
  color: #767676;
  display: flex;
  font-size: 11px;
  gap: 10px;
  justify-content: flex-end;
  min-height: 38px;
  padding: 6px 10px;
}

.table-scroll-hint {
  align-items: center;
  display: none;
  gap: 6px;
  margin-right: auto;
}

.table-scroll-hint.show {
  display: inline-flex;
}

.responsive-table-shell {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  position: relative;
  scrollbar-gutter: stable;
}

.responsive-table-shell:focus-visible {
  box-shadow: inset 0 0 0 2px #448727;
  outline: none;
}

.responsive-data-table th:first-child,
.responsive-data-table td:first-child {
  background: inherit;
  left: 0;
  position: sticky;
  z-index: 2;
}

.responsive-data-table th:first-child {
  background: #fff;
  z-index: 4;
}

.responsive-data-table tr:hover td:first-child {
  background: #fafafa;
}

.responsive-data-table .rt-col-hidden {
  display: none !important;
}

.table-column-picker {
  position: relative;
}

.table-column-picker > summary {
  align-items: center;
  background: #fff;
  border: 1px solid #d5d5d5;
  border-radius: 4px;
  color: #555;
  cursor: pointer;
  display: inline-flex;
  font-size: 11px;
  font-weight: 600;
  gap: 6px;
  list-style: none;
  min-height: 28px;
  padding: 4px 9px;
}

.table-column-picker > summary::-webkit-details-marker {
  display: none;
}

.table-column-picker-menu {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  display: grid;
  gap: 7px;
  max-height: 320px;
  min-width: 210px;
  overflow-y: auto;
  padding: 10px;
  position: absolute;
  right: 0;
  top: calc(100% + 5px);
  z-index: 90;
}

.table-column-picker-menu label {
  align-items: center;
  color: #444;
  cursor: pointer;
  display: flex;
  font-size: 11px;
  gap: 7px;
  text-transform: none;
}

@media (max-width: 760px) {
  .responsive-table-toolbar:has(+ .responsive-table-shell .mobile-card-table),
  .responsive-table-toolbar:has(+ .responsive-table-shell.mobile-card-table) {
    display: none;
  }

  .filter-bar {
    align-items: stretch !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .filter-bar .search-box,
  .filter-bar .typeahead-wrap,
  .filter-bar .date-range,
  .filter-bar .result-count {
    grid-column: 1 / -1;
    margin-left: 0 !important;
    width: 100%;
  }

  .filter-bar select,
  .filter-bar input[type="number"] {
    min-width: 0;
    width: 100%;
  }

  .responsive-table-toolbar {
    position: relative;
  }

  .table-column-picker-menu {
    max-width: calc(100vw - 32px);
    position: fixed;
    right: 16px;
    top: 70px;
  }

  .mobile-card-table {
    min-width: 0 !important;
    width: 100%;
  }

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

  .mobile-card-table tbody,
  .mobile-card-table tr,
  .mobile-card-table td {
    display: block;
    min-width: 0;
    position: static;
    width: 100%;
  }

  .mobile-card-table tr {
    background: #fff;
    border-bottom: 8px solid #f5f5f5;
    padding: 8px 12px;
  }

  .mobile-card-table tr:hover {
    background: #fff;
  }

  .mobile-card-table td {
    align-items: start;
    background: transparent !important;
    border-bottom: 1px solid #f0f0f0;
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(92px, 34%) minmax(0, 1fr);
    padding: 8px 2px !important;
    text-align: left !important;
  }

  .mobile-card-table td::before {
    color: #767676;
    content: attr(data-label);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
  }

  .mobile-card-table td[data-empty="true"] {
    display: none;
  }

  .mobile-card-table td[colspan] {
    display: block;
    padding: 22px 8px !important;
    text-align: center !important;
  }

  .mobile-card-table td[colspan]::before {
    content: none;
  }

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

  .mobile-card-table.responsive-data-table td:first-child {
    position: static;
  }

  .mobile-card-table + * {
    clear: both;
  }

  .mobile-card-table ~ .table-scroll-hint,
  .responsive-table-shell:has(.mobile-card-table) + .table-scroll-hint {
    display: none;
  }
}
