﻿:where(.c-table, .table, .control-table) {
  --table-column-control-min-width: 160px;
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  background: var(--panel);
  font-size: 14px;
  table-layout: auto;
}

:where(table:not([data-table-runtime-ignore])) {
  --table-column-control-min-width: 160px;
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  background: var(--panel);
  font-size: 14px;
  table-layout: auto;
}

:where(.table-scroll, .c-table-scroll, .control-table-scroll, .table-responsive, .table-wrap, .table-container) {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: visible;
  overscroll-behavior-inline: contain;
  scrollbar-gutter: auto;
  -webkit-overflow-scrolling: touch;
}

:where(.table-scroll .table, .c-table-scroll .c-table, .control-table-scroll .control-table) {
  border-radius: 0;
}

:where(table, .table, .c-table, .control-table, .audit-table) {
  max-width: 100%;
}

/* Runtime tables must fill their scroll surface even when an older table
   setting left a pixel width/max-width equal to the sum of its columns. */
:where(table[data-table-runtime-enhanced="true"]) {
  width: 100% !important;
  max-width: none !important;
}

:where(.c-table, .table, .control-table) th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 40px;
  background: color-mix(in srgb, var(--bg) 44%, var(--panel));
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.25;
  overflow: visible;
  text-transform: none;
}

:where(.c-table, .table, .control-table) th,
:where(.c-table, .table, .control-table) td {
  min-width: 0;
  max-width: none;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 86%, transparent);
  padding: 7px 8px;
  text-align: center;
  vertical-align: middle;
  box-sizing: border-box;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: none;
}

:where(.c-table, .table, .control-table) td {
  height: 44px;
  color: color-mix(in srgb, var(--text) 94%, var(--muted));
  font-size: 14px;
  font-weight: 620;
  line-height: 1.36;
  letter-spacing: 0;
}

:where(.c-table, .table, .control-table) th > *,
:where(.c-table, .table, .control-table) td > * {
  max-width: 100%;
  min-width: 0;
  margin-left: auto;
  margin-right: auto;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: none;
}

:where(.c-table, .table, .control-table) td :where(strong, .table-link strong) {
  color: var(--text);
  font-weight: 780;
  line-height: 1.25;
}

:where(.c-table, .table, .control-table) td :where(small, em) {
  color: var(--muted);
  font-size: 0.92em;
  font-style: normal;
  line-height: 1.24;
}

:where(.c-table, .table, .control-table) td > :where(.c-badge, .badge, .state-pill, .decision-badge),
:where(.c-table, .table, .control-table) td :where(.c-badge, .badge, .state-pill, .decision-badge) {
  margin-left: auto;
  margin-right: auto;
  max-width: 100%;
  line-height: 1.15;
  overflow-wrap: normal;
  white-space: normal;
  text-wrap: balance;
}

:where(.c-table, .table, .control-table) td > :where(.status-stack, .control-status-stack) {
  width: 100%;
  justify-content: center;
  justify-items: center;
  text-align: center;
}

table [data-table-secondary-placeholder="true"] {
  display: none !important;
}

:where(.c-table, .table, .control-table) td :where(.status-stack, .control-status-stack) > span {
  justify-content: center;
  justify-items: center;
}

:where(.c-table, .table, .control-table) thead tr {
  height: auto;
}

:where(.c-table, .table, .control-table) tr {
  position: relative;
}

:where(.c-table, .table, .control-table) tbody tr {
  transition: background 0.12s ease, box-shadow 0.12s ease;
}

:where(.c-table, .table, .control-table) tbody tr > td {
  transition: background-color 0.12s ease, box-shadow 0.12s ease;
}

:where(
  .table tbody tr:has([data-position-info]),
  .table tbody tr:has([data-event-info]),
  .table tbody tr:has([data-stats-info]),
  .table tbody tr:has([data-logistics-info]),
  .table tbody tr:has([data-vehicle-info]),
  .table tbody tr:has([data-crew-info]),
  .table tbody tr:has([data-user-info]),
  .table tbody tr:has([data-unit-info]),
  .table tbody tr:has([data-settlement-info]),
  .table tbody tr:has([data-report-deadline-info]),
  .table tbody tr:has([data-dictionary-info]),
  .table tbody tr:has([data-comment-request]),
  .table tbody tr[data-event-row],
  .table tbody tr[data-control-position],
  .table tbody tr[data-logistics-row],
  .table tbody tr[data-position-row],
  .table tbody tr[data-vehicle-row],
  .table tbody tr[data-crew-row],
  .table tbody tr[data-person-row],
  .table tbody tr[data-unit-row],
  .table tbody tr[data-settlement-row],
  .table tbody tr[data-report-deadline-row],
  .table tbody tr[data-report-row],
  .table tbody tr[data-dictionary-row],
  .table tbody tr[data-request-row],
  .table tbody tr[data-access-template-row],
  .table tbody tr[data-unit-person-row],
  .table tbody tr[data-unit-person-request-row],
  .table tbody tr[data-unit-group-row],
  .table tbody tr[data-unit-vehicle-row],
  .table tbody tr[data-unit-stats-info],
  .table tbody tr[data-user-row],
  .table tbody tr[data-stats-info]
) {
  cursor: pointer;
}

:where(.c-table, .table, .control-table) thead th {
  height: auto;
  padding: 7px 7px;
  overflow: visible;
}

:where(.c-table, .table, .control-table) th:first-child {
  border-top-left-radius: var(--radius);
}

:where(.c-table, .table, .control-table) th:last-child {
  border-top-right-radius: var(--radius);
}

.table-customizable th[data-table-column],
.table-customizable th[data-control-column] {
  min-width: var(--table-column-control-min-width, 160px);
}

.table-customizable th.table-column-customizable {
  z-index: 2;
}

:where(.c-table, .table, .control-table) tr:hover td {
  background: var(--row-hover);
}

:where(.c-table, .table, .control-table) tr:focus-within td {
  background: var(--row-hover);
}

:where(.c-table, .table, .control-table) tbody tr.is-row-highlighted td {
  background: color-mix(in srgb, var(--accent) 14%, var(--row-hover));
}

:where(.c-table, .table, .control-table) tbody tr.is-row-highlighted td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

:where(.c-table, .table, .control-table) tbody tr.is-selected td {
  background: color-mix(in srgb, var(--accent) 12%, var(--row-hover));
}

:where(.c-table, .table, .control-table) tbody tr.is-selected td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

/* Keep row feedback visible above route-specific cell backgrounds. */
.layout.app-shell table[data-table-runtime-enhanced="true"] tbody > tr:hover > td {
  background: color-mix(in srgb, var(--accent) 10%, var(--row-hover)) !important;
}

.layout.app-shell table[data-table-runtime-enhanced="true"] tbody > tr:active > td,
.layout.app-shell table[data-table-runtime-enhanced="true"] tbody > tr.is-row-highlighted > td {
  background: color-mix(in srgb, var(--accent) 22%, var(--row-hover)) !important;
}

.layout.app-shell table[data-table-runtime-enhanced="true"] tbody > tr.is-row-highlighted > td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

:where(.table-link) {
  min-height: auto;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--text);
  text-align: center;
  font-weight: inherit;
}

:where(.table-link:hover) {
  color: var(--accent);
}

:where(.table-column-head) {
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 5px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  position: relative;
  text-align: center;
}

:where(.table-customizable th[data-table-column]) {
  position: sticky;
  touch-action: pan-y;
}

:where(.table-customizable .table-column-head) {
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  column-gap: 0;
}

:where(table[data-table-runtime-header-style="compact"] .table-column-head) {
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  justify-items: stretch;
  gap: 0;
  min-height: 32px;
  text-align: center;
}

:where(table[data-table-runtime-header-style="compact"] .table-column-title) {
  grid-row: 1;
  grid-column: 1;
  min-width: 0;
  min-height: 32px;
  padding-inline: 32px;
  text-align: center;
}

:where(table[data-table-runtime-header-style="compact"] .column-filter-menu) {
  z-index: 6;
  grid-row: 1;
  grid-column: 1;
  justify-self: end;
  width: 32px;
  min-width: 32px;
}

:where(.table-column-direct-control, .column-filter-menu > summary) {
  min-height: 36px;
  border-color: var(--line);
  background: color-mix(in srgb, var(--bg) 52%, var(--panel));
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

:where(.c-table, .table, .control-table) .action-menu summary {
  min-height: 30px;
  padding: 6px 10px;
  border-radius: var(--radius);
  font-weight: 650;
}

:where(.crew-table) {
  min-width: 900px;
  table-layout: auto;
}

:where(.crew-table th, .crew-table td) {
  max-width: none;
}

:where(.crew-table th, .crew-table td, .crew-table .table-link, .crew-table .stack > div) {
  overflow-wrap: normal;
  word-break: normal;
}

:where(.crew-table th:first-child, .crew-table td:first-child) {
  width: 42px;
}

:where(.crew-table th:last-child, .crew-table td:last-child) {
  width: 70px;
}

:where(.table-column-filter) {
  display: grid;
  gap: 5px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  position: relative;
}

:where(.table-filter-row th) {
  height: 42px;
  padding: 4px 10px;
  background: color-mix(in srgb, var(--panel) 90%, var(--soft-panel));
  vertical-align: middle;
}

:where(.table-filter-row .table-filter-cell:empty)::before {
  content: "";
  display: block;
  min-height: 32px;
}

:where(.table-filter-row input, .table-filter-row select) {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 32px !important;
  min-height: 32px !important;
  padding-block: 0 !important;
  padding-inline: 10px;
  font-size: 12px;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

:where(.table-filter-row .table-search-wrap) {
  width: 100%;
  min-width: 0;
}

:where(.table-filter-row input[type="date"]) {
  padding-inline: 8px;
}

:where(.table-filter-row th:has(.table-filter-stack)) {
  height: auto;
  padding-block: 6px;
}

:where(.table-filter-stack) {
  display: grid;
  gap: 6px;
  width: 100%;
  min-width: 0;
}

:where(.table-pagination) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: var(--gap-sm);
  min-width: 0;
  padding: 10px 4px 4px;
}

:where(.table-pagination-status) {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

:where(.table-pagination-pages) {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}

:where(.table-pagination-pages[hidden]) {
  display: none;
}

:where(.table-pagination-gap) {
  min-width: 20px;
  color: var(--muted);
  text-align: center;
}

:where(.table-pagination-pages button) {
  min-width: 34px;
  min-height: 34px;
  padding: 0 9px;
}

:where(.table-pagination-pages button.is-active) {
  border-color: color-mix(in srgb, var(--accent) 64%, var(--line));
  background: color-mix(in srgb, var(--accent) 16%, var(--panel));
  color: var(--accent);
}

:where(.table-page-size) {
  justify-self: end;
  margin: 0;
}

:where(.table-pagination .sr-only) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:where(.table-page-size select) {
  min-width: 144px;
}

@media (max-width: 640px) {
  :where(.table-pagination) {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  :where(.table-pagination-pages) {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

:where(.table-column-head.has-column-filter, .table-column-head:has(> .table-column-filter)) {
  align-content: stretch;
  gap: 0;
  height: 100%;
  justify-items: stretch;
}

:where(
  .table-column-head.has-column-filter > .table-column-title,
  .table-column-head:has(> .table-column-filter) > .table-column-title
) {
  display: none;
}

.table-column-head.has-column-filter > .table-column-title[hidden],
.table-column-head:has(> .table-column-filter) > .table-column-title[hidden] {
  display: none !important;
}

.table-column-head.has-column-filter > :not(.table-column-filter),
.table-column-head:has(> .table-column-filter) > :not(.table-column-filter) {
  display: none !important;
}

:where(
  .table-column-head.has-column-filter .table-column-filter,
  .table-column-head:has(> .table-column-filter) .table-column-filter
) {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 100%;
  overflow: hidden;
}

:where(.table-customizable .table-column-filter) {
  grid-column: 1 / -1;
}

:where(.table-column-title) {
  cursor: grab;
}

:where(.table-column-title-label) {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: none;
}

:where(.table-column-drag-source:active) {
  cursor: grabbing;
}

:where(.table-column-resize-handle) {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 20;
  display: block;
  width: 12px;
  height: 100%;
  cursor: col-resize;
  pointer-events: auto;
  touch-action: none;
  transform: translateX(50%);
}

:where(.table-column-resize-handle)::after {
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 50%;
  width: 1px;
  background: transparent;
  content: "";
  transform: translateX(-50%);
}

:where(.table-column-resize-handle:hover)::after,
:where(.is-resizing-table-column .table-column-resize-handle)::after {
  background: var(--accent);
}

:where(.table-column-resize-guide) {
  position: fixed;
  top: 0;
  bottom: 0;
  z-index: 5000;
  width: 2px;
  pointer-events: none;
  background: var(--accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

:where(th.is-column-dragging) {
  opacity: 0.64;
}

:where(.table-column-drop-indicator) {
  position: fixed;
  z-index: 5001;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 10%, transparent);
  pointer-events: none;
  transform: translateX(-50%);
}

:where(body.is-resizing-table-column) {
  cursor: col-resize;
  user-select: none;
}

:where(.table-excel th, .table-excel td) {
  border-right: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
}

:where(.table-excel th:last-child, .table-excel td:last-child) {
  border-right: 0;
}

@media (max-width: 1100px) and (min-width: 961px) {
  :where(.panel > .table, .panel > .table-scroll > .table) {
    min-width: 100%;
    table-layout: auto;
  }

  :where(.panel > .table:has(thead th:nth-child(6)), .panel > .table-scroll > .table:has(thead th:nth-child(6))) {
    min-width: 820px;
  }

  :where(.panel > .table:has(thead th:nth-child(8)), .panel > .table-scroll > .table:has(thead th:nth-child(8))) {
    min-width: 980px;
  }

  :where(.panel > .crew-table, .panel > .table-scroll > .crew-table) {
    min-width: 900px;
    table-layout: auto;
  }
}

@media (max-width: 960px) {
  .table-scroll {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .table {
    display: block;
    border-collapse: separate;
    border-spacing: 0 8px;
    min-width: 0;
  }

  .table thead {
    display: none;
  }

  .table tbody,
  .table tr,
  .table th,
  .table td {
    display: block;
  }

  .table tr {
    position: relative;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 0;
    padding: 7px;
    background: var(--panel);
    box-shadow: var(--shadow-sm);
  }

  .table td {
    display: grid;
    grid-template-columns: minmax(82px, 36%) minmax(0, 1fr);
    align-items: start;
    gap: 8px;
    height: auto;
    min-height: 0;
    width: 100%;
    max-width: none;
    border-bottom: 0;
    padding: 5px 2px;
    line-height: 1.3;
    overflow: visible;
    white-space: normal;
    word-break: normal;
    overflow-wrap: anywhere;
  }

  .table td > * {
    min-width: 0;
    max-width: 100%;
  }

  .table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    line-height: 1.25;
    text-transform: uppercase;
    overflow-wrap: break-word;
  }

  .table td[data-label=""] {
    grid-template-columns: 1fr;
  }

  .table td[data-label=""]::before {
    display: none;
  }

  .table td:first-child {
    padding-right: 2px;
  }

  .table td.mobile-select-cell {
    display: none;
  }

  .table tbody tr.mobile-selectable-row {
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
  }

  .table tbody tr.mobile-selected {
    border-color: color-mix(in srgb, var(--accent) 72%, var(--line));
    background: color-mix(in srgb, var(--accent) 10%, var(--panel));
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 24%, transparent);
  }

  .table tbody tr.mobile-selected::after {
    content: "\2713";
    position: absolute;
    top: 8px;
    right: 8px;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-pill);
    background: var(--accent);
    color: var(--on-accent);
    font-size: 14px;
    font-weight: 900;
    line-height: 1;
  }

  .table.mobile-selection-active tbody tr.mobile-selectable-row:not(.mobile-selected) {
    border-color: color-mix(in srgb, var(--line) 70%, var(--accent));
  }

  .badge,
  .decision-badge,
  .state-pill {
    justify-self: start;
    white-space: normal;
    max-width: 100%;
  }

  .table-toolbar {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .table-filter-reset {
    width: 100%;
  }

  .control-table .control-group-list,
  .control-table .control-compact-list,
  .control-table .control-status-stack {
    gap: 6px;
  }

  .control-table .control-group-item,
  .control-table .control-compact-list > span,
  .control-table .control-status-stack > span {
    min-height: 0;
    align-content: start;
  }

  .control-table .control-group-label,
  .control-table .control-compact-list > span,
  .control-table .control-status-stack > span {
    gap: 1px;
  }
}

@media (max-width: 760px) {
  .table td {
    grid-template-columns: minmax(92px, 38%) minmax(0, 1fr);
  }

}

@media (max-width: 520px) {
  .table tbody tr {
    padding: 9px;
  }

  .table td {
    grid-template-columns: minmax(98px, 40%) minmax(0, 1fr);
    gap: 2px;
    text-align: left;
  }

  .table td[data-label] {
    text-align: left;
  }

  .table td::before {
    margin-bottom: 1px;
  }

  .badge,
  .decision-badge,
  .state-pill {
    max-width: 100%;
    white-space: normal;
  }

  .table td > *,
  .table td :where(.badge, .state-pill, .decision-badge) {
    margin-left: 0;
    margin-right: 0;
    justify-self: start;
    text-align: left;
  }

}

@media (max-width: 360px) {
  .table td {
    grid-template-columns: minmax(0, 1fr);
  }
}


