/* Sticky-заголовок: светло-голубой непрозрачный фон, без рамок */
.cx-table thead th,
.cx-table[data-sticky-header] thead th,
.cx-table thead .mantine-Table-th {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: #e7f5ff !important;
  background-image: none !important;
  border: none !important;
  box-shadow: none !important;
}

.cx-table thead {
  position: relative;
  z-index: 10;
}

.cx-table thead th,
.cx-table thead .mantine-Table-th,
.cx-table[data-with-table-border] thead th,
.cx-table[data-with-row-borders] thead th {
  border: none !important;
  outline: none !important;
}

/*
 * Двухуровневый thead — без границ.
 * Лёгкая заливка цветом шапки сверху — только чтобы не просвечивал скролл.
 */
.cx-table-grouped-head {
  --cx-h1: 30px;
  --cx-head-bg: #e7f5ff;
  --cx-head-line: #ced4da;
}

.cx-table-grouped-head thead tr:nth-child(1) > th,
.cx-table-grouped-head thead tr:nth-child(1) > .mantine-Table-th {
  position: sticky !important;
  top: 0 !important;
  z-index: 12 !important;
  box-sizing: border-box;
  padding-top: 4px !important;
  padding-bottom: 4px !important;
  vertical-align: middle;
  background-color: var(--cx-head-bg) !important;
  border: none !important;
  box-shadow: 0 -2px 0 0 var(--cx-head-bg) !important;
}

.cx-table-grouped-head thead tr:nth-child(1) > th.cx-th-group,
.cx-table-grouped-head thead tr:nth-child(1) > .mantine-Table-th.cx-th-group {
  box-shadow: 0 -2px 0 0 var(--cx-head-bg) !important;
}

.cx-table-grouped-head thead tr:nth-child(2) > th,
.cx-table-grouped-head thead tr:nth-child(2) > .mantine-Table-th {
  position: sticky !important;
  top: var(--cx-h1) !important;
  z-index: 11 !important;
  box-sizing: border-box;
  padding-top: 4px !important;
  padding-bottom: 4px !important;
  vertical-align: middle;
  background-color: var(--cx-head-bg) !important;
  border: none !important;
  box-shadow: 0 -1px 0 0 var(--cx-head-bg) !important;
}

/* Sticky-footer итогов */
.cx-table tfoot td,
.cx-table tfoot .mantine-Table-td {
  position: sticky;
  bottom: 0;
  z-index: 9;
  background-color: #e7f5ff !important;
  background-image: none !important;
  border-top: none !important;
  border-bottom: none !important;
  box-shadow:
    0 -1px 0 0 #ced4da,
    0 2px 0 0 #e7f5ff;
}

.cx-table tfoot {
  position: relative;
  z-index: 9;
}

/* Выбранная строка (Admin / row_payload) */
.cx-table tbody tr.cx-kbd-row-selected td {
  background-color: rgba(34, 139, 230, 0.12) !important;
}

/* Фокус ячейки в Mantine Table (.cx-kbd-table) */
.cx-kbd-table td.cx-kbd-cell {
  cursor: default;
  outline: none;
  scroll-margin-top: 40px;
}

.cx-kbd-table td.cx-kbd-cell:focus,
.cx-kbd-table td.cx-kbd-cell.cx-kbd-focus {
  outline: 2px solid #228be6;
  outline-offset: -2px;
  background-color: rgba(34, 139, 230, 0.08);
}

/* Широкие таблицы: без переноса; длинный текст обрезается (ellipsis),
 * без полосы прокрутки внутри ячейки. */
.cx-table-nowrap {
  width: 100%;
  min-width: 100%;
  table-layout: auto;
}

.cx-table-nowrap th,
.cx-table-nowrap td {
  white-space: nowrap !important;
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cx-table-nowrap .mantine-Text-root,
.cx-table-nowrap td > div {
  white-space: nowrap !important;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ---- Sticky первая колонка (тело/итоги; в thead — без вертикальной черты) ---- */

.cx-table-sticky-first tbody td:first-child,
.cx-table-sticky-first tbody .mantine-Table-td:first-child,
.cx-table-sticky-first tfoot td:first-child,
.cx-table-sticky-first tfoot .mantine-Table-td:first-child {
  position: sticky !important;
  left: 0 !important;
  box-shadow: 2px 0 0 #ced4da;
}

.cx-table-sticky-first thead th:first-child,
.cx-table-sticky-first thead .mantine-Table-th:first-child {
  position: sticky !important;
  left: 0 !important;
  z-index: 14;
  background-color: #e7f5ff !important;
  /* без вертикальной границы после первой колонки в шапке */
  box-shadow: none;
}

/*
 * Угол: две ячейки + абсолютная подпись на 2 строки.
 * Без вертикальной линии справа от «Месяц»/«Ресторан».
 */
.cx-table-grouped-head thead th.cx-th-corner-top,
.cx-table-grouped-head thead .mantine-Table-th.cx-th-corner-top {
  overflow: visible !important;
  border: none !important;
  padding-top: 4px !important;
  padding-bottom: 4px !important;
  vertical-align: middle !important;
}

.cx-table-grouped-head thead th.cx-th-corner-bottom,
.cx-table-grouped-head thead .mantine-Table-th.cx-th-corner-bottom {
  border: none !important;
}

.cx-table-sticky-first.cx-table-grouped-head thead th.cx-th-corner-top,
.cx-table-sticky-first.cx-table-grouped-head thead .mantine-Table-th.cx-th-corner-top {
  top: 0 !important;
  left: 0 !important;
  z-index: 22 !important;
  background-color: var(--cx-head-bg) !important;
  border: none !important;
  box-shadow: 0 -2px 0 0 var(--cx-head-bg) !important;
}

.cx-table-sticky-first.cx-table-grouped-head thead th.cx-th-corner-bottom,
.cx-table-sticky-first.cx-table-grouped-head thead .mantine-Table-th.cx-th-corner-bottom {
  top: var(--cx-h1) !important;
  left: 0 !important;
  z-index: 21 !important;
  background-color: var(--cx-head-bg) !important;
  color: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.cx-table-grouped-head .cx-th-corner-label {
  position: absolute !important;
  left: 0;
  top: 0;
  right: 0;
  height: calc(var(--cx-h1) * 2) !important;
  display: flex !important;
  align-items: center !important;
  box-sizing: border-box !important;
  padding-left: 8px;
  padding-right: 8px;
  margin: 0 !important;
  background-color: var(--cx-head-bg) !important;
  background-image: none !important;
  border: none !important;
  box-shadow: none !important;
  z-index: 2;
}


.cx-table-grouped-head .cx-th-corner-stub {
  visibility: hidden;
  pointer-events: none;
}

.cx-table-sticky-first tbody td:first-child,
.cx-table-sticky-first tbody .mantine-Table-td:first-child {
  z-index: 8;
}

/* Полосатость первой колонки (Mantine striped=odd) */
.cx-table-sticky-first tbody > tr:nth-child(odd) > td:first-child,
.cx-table-sticky-first tbody > tr:nth-child(odd) > .mantine-Table-td:first-child {
  background-color: var(
    --table-striped-color,
    var(--mantine-color-gray-0, #f8f9fa)
  ) !important;
}

.cx-table-sticky-first tbody > tr:nth-child(even) > td:first-child,
.cx-table-sticky-first tbody > tr:nth-child(even) > .mantine-Table-td:first-child {
  background-color: var(--mantine-color-body, #ffffff) !important;
}

.cx-table-sticky-first tbody tr:hover > td:first-child,
.cx-table-sticky-first tbody tr:hover > .mantine-Table-td:first-child {
  background-color: var(
    --table-highlight-on-hover-color,
    var(--mantine-color-gray-1, #f1f3f5)
  ) !important;
}

.cx-sort-hdr {
  cursor: pointer;
  user-select: none;
}
.cx-sort-caret {
  display: inline-block;
  width: 14px;
  font-size: 12px;
  line-height: 1;
  color: #868e96;
  flex-shrink: 0;
}
.cx-sort-caret::before {
  content: "⇅";
}
.cx-sort-hdr.cx-sort-asc .cx-sort-caret,
.cx-sort-hdr.cx-sort-desc .cx-sort-caret {
  color: #228be6;
  font-weight: 700;
}
.cx-sort-hdr.cx-sort-asc .cx-sort-caret::before {
  content: "↑";
}
.cx-sort-hdr.cx-sort-desc .cx-sort-caret::before {
  content: "↓";
}

