/* The sidebar is off-canvas below 992px (lg), so switch the wide clients table to cards there too — otherwise a
   17-column table scrolls sideways under the opened sidebar and its left columns (incl. the checkbox) hide behind it.
   Each row becomes a card, cells show their column name from data-label. */
@media (max-width: 991.98px) {
  .table-cards thead { display: none; }
  .table-cards caption { display: block; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { border-bottom: var(--table-border-width, 1px) solid var(--border-color); padding: .5rem 0; }
  .table-cards td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .25rem 1rem; text-align: right; }
  .table-cards td::before { content: attr(data-label); font-weight: 600; text-align: left; }

  /* clients: name, ROI, trading, deposits on top; the rest after a tap */
  .table-cards tr.client-row { display: flex; flex-direction: column; }
  .table-cards tr.client-row.open { border-bottom: 0; }
  .table-cards .td-main { order: -1; }
  .table-cards .td-name { order: -4; }
  .table-cards .td-roi { order: -3; }
  .table-cards .td-trade { order: -2; }
  .table-cards tr.client-row:not(.open) td:not(.td-main) { display: none; }
  .table-cards td.td-name::before { content: none; }
  .table-cards tr.row-detail[hidden] { display: none; }
  .table-cards tr.row-detail td { display: block; text-align: left; }
  /* payout + «в архив?» button: the button takes its own line */
  .table-cards td.td-payout { flex-wrap: wrap; }
  .table-cards td.td-payout form { margin-left: auto; }
  /* the open card edits notes right below, no need to show them twice */
  .table-cards tr.client-row.open td.td-notes { display: none; }
  .table-clients td { overflow-wrap: anywhere; }
}

.td-text { white-space: pre-line; }

@media (min-width: 992px) {
  .table-clients { --table-cell-padding-x: .5rem; --table-cell-padding-y: .375rem; font-size: .8125rem; }
  .table-clients td { white-space: nowrap; }
  .table-clients td.td-name, .table-clients td.td-wrap { white-space: normal; min-width: 7rem; }
  .table-clients td.td-text { white-space: pre-line; max-width: 18rem; }

  /* Desktop: the table scrolls sideways inside .table-responsive; keep the identity columns
     (checkbox, Логин, Имя) frozen on the left so you never lose which client a row is. */
  .table-clients .fz { position: sticky; background: #fff; z-index: 1; }
  .table-clients thead .fz { z-index: 2; }
  .table-clients .fz-1 { left: 0; width: 2.75rem; min-width: 2.75rem; }
  .table-clients .fz-2 { left: 2.75rem; width: 6rem; min-width: 6rem; }
  .table-clients .fz-3 { left: 8.75rem; box-shadow: inset -1px 0 0 var(--border-color); }
}

/* Ticking a row highlights it (and its frozen cells), so the checkbox visibly does something — both layouts. */
.table-clients tr.client-row:has(.row-check:checked) > td { background-color: #fff3cd; }

/* The Limitless .content-inner scrolls (overflow-y:auto forces overflow-x:auto too). Without min-width:0 the flex
   child .content won't shrink below the wide table's width, so .content-inner scrolls sideways and drags the whole
   page under the sidebar. min-width:0 lets .table-responsive clip the table instead. */
.content-inner, .content { min-width: 0; }
.content-inner { overflow-x: hidden; }

/* desktop: the per-row «Ответственный» select must be wide enough to read the name */
@media (min-width: 992px) {
  .table-clients td .form-select-sm { min-width: 7rem; }
}
