/* Закрепление левых столбцов без наезда/зазоров и фиксация строк
   дат и номеров пар при вертикальной прокрутке журнала.
   Только CSS-переменные, без литералов #hex. */

.journal-container {
  overflow: auto;
  max-height: calc(100dvh - 160px);
  min-height: 320px;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.j-table {
  width: max-content;
}

.j-table .sticky-num {
  position: sticky;
  left: 0;
  width: 34px;
  min-width: 34px;
  max-width: 34px;
  white-space: nowrap;
  z-index: 104;
}

.j-table .sticky-fio {
  position: sticky;
  left: var(--j-left-fio, 34px);
  width: 200px;
  min-width: 200px;
  max-width: 200px;
  z-index: 103;
}

.j-table .sticky-subgroup {
  position: sticky;
  left: var(--j-left-sub, 234px);
  width: 50px;
  min-width: 50px;
  max-width: 50px;
  white-space: nowrap;
  z-index: 102;
}

.j-table .sticky-total {
  position: sticky;
  left: var(--j-left-tot, 284px);
  width: 70px;
  min-width: 70px;
  max-width: 70px;
  white-space: nowrap;
  z-index: 101;
  box-shadow: 1px 0 0 0 var(--border), 3px 0 8px color-mix(in srgb, var(--text) 8%, transparent);
}

.j-table thead tr th.sticky-num,
.j-table thead tr th.sticky-fio,
.j-table thead tr th.sticky-subgroup,
.j-table thead tr th.sticky-total,
.j-table thead tr th.h-date-label {
  background: var(--bg-card2) !important;
}

.j-table tbody tr td.sticky-num,
.j-table tbody tr td.sticky-fio,
.j-table tbody tr td.sticky-subgroup {
  background: var(--bg-card) !important;
}

.j-table tbody tr td.sticky-total {
  background: var(--bg-card2) !important;
}

.j-table thead tr.j-head-dates th {
  position: sticky;
  top: 0;
  z-index: 120;
}

.j-table thead tr.j-head-nums th {
  position: sticky;
  top: var(--j-head-row1-h, 40px);
  z-index: 119;
  box-shadow: 0 2px 6px color-mix(in srgb, var(--text) 8%, transparent);
}

.j-table thead tr.j-head-dates th.sticky-num,
.j-table thead tr.j-head-nums th.sticky-num {
  z-index: 134;
}

.j-table thead tr.j-head-dates th.sticky-fio,
.j-table thead tr.j-head-nums th.sticky-fio {
  z-index: 133;
}

.j-table thead tr.j-head-dates th.sticky-subgroup,
.j-table thead tr.j-head-nums th.sticky-subgroup {
  z-index: 132;
}

.j-table thead tr.j-head-dates th.sticky-total,
.j-table thead tr.j-head-nums th.sticky-total {
  z-index: 131;
}

.j-table thead tr.j-head-nums th.sticky-total {
  box-shadow: 1px 0 0 0 var(--border),
              3px 0 8px color-mix(in srgb, var(--text) 8%, transparent),
              0 2px 6px color-mix(in srgb, var(--text) 8%, transparent);
}

.j-table th.h-num {
  height: 38px;
  padding: 0 !important;
  background: var(--bg-card);
  vertical-align: middle !important;
}

[data-theme="dark"] .j-table th.h-num {
  background: var(--bg-card2);
}

.j-table th.h-num .type-text-wrap {
  height: 38px;
}

.j-table th.h-num-label {
  height: 38px;
  font-size: 0.78rem;
  color: var(--text-muted) !important;
}

.j-table thead tr.j-head-nums th.h-num.is-today:not(.kn-header) {
  background-color: color-mix(in srgb, var(--accent) 18%, var(--bg-card)) !important;
}

[data-theme="dark"] .j-table thead tr.j-head-nums th.h-num.is-today:not(.kn-header) {
  background-color: color-mix(in srgb, var(--accent) 28%, var(--bg-card)) !important;
}

.j-table thead tr.j-head-topics th.h-type {
  height: 70px;
}

.j-table thead tr.j-head-topics .topic-textarea {
  border-top: none;
  height: 70px;
}

.j-table.hide-topics tr.j-head-topics {
  display: none;
}

@media (max-width: 767.98px) {
  .journal-container {
    max-height: calc(100dvh - 195px);
    min-height: 260px;
  }

  .j-table .sticky-num {
    left: 0 !important;
    width: 24px !important;
    min-width: 24px !important;
    max-width: 24px !important;
  }

  .j-table .sticky-fio {
    left: var(--j-left-fio, 24px) !important;
    width: 96px !important;
    min-width: 96px !important;
    max-width: 96px !important;
  }

  .j-table .sticky-total {
    left: var(--j-left-tot, 120px) !important;
    width: 42px !important;
    min-width: 42px !important;
    max-width: 42px !important;
  }

  .j-table .h-num {
    width: 42px !important;
    min-width: 42px !important;
  }
}
