/* Canonical CSS owner: tables. Historical layers consolidated 2026-08-02. */
.data-table th[data-sort] {
  cursor: pointer;

  user-select: none;
}

.data-table th[data-sort]:hover {
  background: var(--surface-hover);

  color: var(--blue-dark);
}

.data-table th.sort-asc::after {
  content: " ↑";

  color: var(--accent);
}

.data-table th.sort-desc::after {
  content: " ↓";

  color: var(--accent);
}

.data-table tbody tr td {
  transition: background-color var(--motion-fast) ease, color var(--motion-fast) ease;
}

.data-table tbody tr.row-enter {
  animation-delay: var(--row-delay, 0ms);
}

.data-table tbody tr.row-pending {
  opacity: 0;

  transform: translateY(4px);
}

.data-table .number {
  text-align: right;

  font-variant-numeric: tabular-nums;
}

.data-table .row-number {
  width: 38px;

  color: var(--text-muted);

  text-align: left;
}

.table-action {
  padding: 3px 7px;

  border: 0px;

  background: transparent;

  color: var(--blue);

  cursor: pointer;
}

.table-muted {
  color: var(--text-muted);

  font-size: 12px;
}

.data-table:not(#limitTable) th[data-auto-sort] {
  cursor: pointer;

  user-select: none;
}

.data-table:not(#limitTable) th[data-auto-sort]:hover {
  background: var(--surface-hover);

  color: var(--action-hover);
}

.data-table th[data-auto-sort].sort-asc::after {
  content: " ↑";

  color: var(--action);
}

.data-table th[data-auto-sort].sort-desc::after {
  content: " ↓";

  color: var(--action);
}

@media (prefers-reduced-motion: reduce) {
  .data-table tbody tr.row-pending {
    opacity: 1;

    transform: none;
  }
}

@media (max-width: 860px) {
  .table-frame {
    max-height: 520px;

    border-right: 0px;
  }
}

.data-table td {
  background: transparent;

  text-align: left;

  height: 40px;

  padding: 0 12px;

  border-right: 0px;

  border-bottom: 1px solid var(--border-subtle);

  line-height: 1.4;
}

.data-table th {
  text-align: left;

  position: sticky;

  top: 0px;

  z-index: 2;

  padding: 8px 11px;

  border-right: 0px;

  border-bottom: 1px solid var(--border);

  line-height: 1.4;

  height: 38px;

  background: var(--table-header);

  color: var(--text-secondary);

  font-size: var(--font-size-label);

  font-weight: var(--font-weight-semibold);
}

.data-table tbody tr.selected td {
  background: var(--table-selected);
}

@media (max-width: 767px) {
  .data-table {
    font-size: 12.5px;
  }

  .data-table td {
    height: 44px;

    padding: 8px 10px;
  }

  .data-table th {
    height: 44px;

    padding: 8px 10px;

    font-size: 11.5px;
  }

  .main-grid > .table-frame {
    min-height: 460px;

    border-right: 0px;
  }
}

.data-table {
  border-spacing: 0px;

  white-space: nowrap;

  color: var(--text-primary);

  width: 100%;

  border-collapse: collapse;

  font-size: var(--font-size-table);
}

.data-table tbody tr:last-child td {
  border-bottom: 0px;
}

.data-table tbody tr {
  cursor: pointer;

  transition: background var(--duration-fast);
}

.data-table tbody tr:hover td {
  background: var(--table-hover);
}

.data-table .stock-name {
  color: var(--text-primary);

  font-size: var(--fs-table);

  font-weight: 600;
}

.main-grid > .table-frame {
  border-right: 1px solid var(--border);

  border-radius: var(--card-radius);
}

.table-frame {
  position: relative;

  min-width: 0px;

  max-height: calc(-285px + 100vh);

  border: 1px solid var(--card-border);

  background: var(--card-bg);

  box-shadow: var(--card-shadow);

  overflow: hidden;

  border-radius: var(--card-radius);
}

.data-table thead th {
  padding: 0 12px;

  border-bottom: 1px solid var(--border);

  background: var(--table-header);

  color: var(--text-secondary);

  font-weight: var(--font-weight-semibold);

  white-space: nowrap;

  height: 36px;

  font-size: var(--font-size-caption);
}

.data-table tbody td {
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  height: 40px;
}

.data-table thead tr:last-child th:first-child,
.data-table tbody td:first-child,
.tbl thead tr:last-child th:first-child,
.tbl tbody td:first-child {
  text-align: left;
}

.tbl .row-number {
  text-align: left;
}

.main-grid .data-table thead th {
  height: 36px;

  padding: 0 12px;
}

.main-grid .data-table tbody td {
  height: 40px;

  padding: 5px 10px;
}

:is(#limitTable, #brokenTable, #downTable, #yesterdayTable) tbody tr {
  transition: background-color 150ms;
}

.tbl-wrap {
  overflow: auto;
}

.tbl thead th {
  position: sticky;

  top: 0px;

  background: var(--table-header);

  color: var(--sub);

  font-weight: 600;

  font-size: var(--font-size-caption);

  text-align: left;

  padding: 0 12px;

  border-bottom: 1px solid var(--line);

  white-space: nowrap;

  z-index: 2;
}

.tbl thead th.sortable {
  cursor: pointer;

  user-select: none;
}

.tbl thead th.sortable:hover {
  color: var(--blue);
}

.tbl thead th .arr {
  font-size: 9px;

  color: var(--faint);

  margin-left: 3px;
}

.tbl thead th.sorted,
.data-table thead th.sorted,
.data-table thead th.sort-asc,
.data-table thead th.sort-desc {
  color: var(--accent);
}

.tbl thead th.sorted .arr,
.data-table thead th.sorted .arr {
  color: var(--accent);
}

.tbl tbody td {
  padding: 0 12px;

  border-bottom: 1px solid var(--line-soft);

  white-space: nowrap;

  vertical-align: middle;

  height: 40px;

  font-size: var(--font-size-table);
}

.tbl tbody tr:hover {
  background: var(--table-hover);
}

.tbl.compact tbody td {
  padding: 5px 12px;
}

.tbl thead th.num {
  text-align: right;
}

.tbl-tools {
  display: flex;

  align-items: center;

  gap: 10px;

  padding: 9px 14px;

  border-bottom: 1px solid var(--line-soft);

  flex-wrap: wrap;
}

.tbl-tools .right {
  margin-left: auto;

  display: flex;

  align-items: center;

  gap: 8px;
}

:is(#limitTable, #brokenTable, #downTable, #yesterdayTable) th {
  width: auto;
}

:is(#limitTable, #brokenTable, #downTable, #yesterdayTable) th.row-number {
  width: var(--col-rank);
}

:is(#limitTable, #brokenTable, #downTable, #yesterdayTable) th:nth-child(2) {
  width: var(--col-stock);
}

:is(#limitTable, #brokenTable, #downTable, #yesterdayTable) th.number {
  width: var(--col-number);
}

:is(#limitTable, #brokenTable, #downTable, #yesterdayTable) thead th.num {
  text-align: right;

  font-variant-numeric: tabular-nums;
}

:root[data-theme="dark"] :is(table, .data-table, .tbl) {
  color: var(--text-primary);
}

:root[data-theme="dark"] :is(table thead th, .data-table thead th, .tbl thead th) {
  border-color: var(--border);

  background: var(--surface-muted);

  color: var(--text-secondary);
}

:root[data-theme="dark"] :is(
  .tbl thead th.sorted,
  .data-table thead th.sorted,
  .data-table thead th.sort-asc,
  .data-table thead th.sort-desc
) {
  color: var(--accent);
}

:root[data-theme="dark"] :is(.tbl thead th.sorted .arr, .data-table thead th.sorted .arr) {
  color: var(--accent);
}

:root[data-theme="dark"] :is(table tbody td, .data-table tbody td, .tbl tbody td) {
  border-color: var(--line-soft);

  background-color: transparent;
}

:root[data-theme="dark"] :is(table tbody tr:hover td, .data-table tbody tr:hover td, .tbl tbody tr:hover td) {
  background: var(--action-soft);
}
