/* ── Table wrap ──────────────────────────────────────────────────────────── */
.tbl-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Toolbar ─────────────────────────────────────────────────────────────── */
.tbl-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
  flex-wrap: wrap;
  min-height: 52px;
}

.tbl-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tbl-total-label {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Search */
.tbl-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 260px;
}

.tbl-search-icon {
  position: absolute;
  left: 9px;
  width: 14px; height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.tbl-search {
  width: 100%;
  padding: 6px 28px 6px 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-app);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.tbl-search:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--brand-light);
  background: var(--bg-card);
}
.tbl-search::placeholder { color: var(--text-muted); }

.tbl-search-clear {
  position: absolute;
  right: 7px;
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: background var(--t-fast), color var(--t-fast);
}
.tbl-search-clear:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Page size */
.tbl-page-size {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-app);
  color: var(--text-secondary);
  font-size: 12.5px;
  cursor: pointer;
  outline: none;
  transition: border-color var(--t-fast);
}
.tbl-page-size:focus { border-color: var(--border-focus); }

/* ── Scroll ──────────────────────────────────────────────────────────────── */
.tbl-scroll { overflow-x: auto; flex: 1; }

/* ── Table ───────────────────────────────────────────────────────────────── */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tbl-head-row { position: sticky; top: 0; z-index: 2; }

.tbl-th {
  padding: 0 14px;
  height: 40px;
  text-align: left;
  background: var(--bg-stripe);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: middle;
  border-top: none;
}

/* Column with filter gets extra bottom space */
.tbl-th:has(.tbl-col-filter) { vertical-align: top; padding-top: 10px; }

.tbl-th-inner {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
}

.tbl-th--sortable { cursor: pointer; }
.tbl-th--sortable:hover { background: var(--bg-hover); color: var(--text-secondary); }
.tbl-th--sorted { color: var(--brand); }
.tbl-th--sorted .tbl-sort-icon { color: var(--brand); }
.tbl-sort-icon { font-size: 11px; color: var(--border); line-height: 1; }

/* Column filter */
.tbl-col-filter {
  display: block;
  width: 100%;
  padding: 3px 7px;
  margin: 4px 0 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-size: 11.5px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-primary);
  outline: none;
  min-width: 70px;
  transition: border-color var(--t-fast);
}
.tbl-col-filter::placeholder { color: var(--text-muted); font-style: italic; }
.tbl-col-filter:focus { border-color: var(--border-focus); }

/* Rows */
.tbl-row { transition: background var(--t-fast); }
.tbl-row:hover { background: var(--brand-subtle); }

.tbl-td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.tbl-null { color: var(--text-muted); }

/* Zebra stripe */
.tbl-row:nth-child(even) { background: var(--bg-stripe); }
.tbl-row:nth-child(even):hover { background: var(--brand-subtle); }

/* States */
.tbl-loading, .tbl-empty, .tbl-error {
  text-align: center;
  padding: 52px 16px;
  color: var(--text-muted);
  font-size: 13.5px;
}
.tbl-error { color: var(--color-danger); }

/* ── Pagination ──────────────────────────────────────────────────────────── */
.tbl-footer {
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-stripe);
}

.tbl-pagination {
  display: flex;
  align-items: center;
  gap: 2px;
}

.tbl-btn-page {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text-muted);
  transition: background var(--t-fast), color var(--t-fast);
}
.tbl-btn-page:hover:not(:disabled) { background: var(--bg-hover); color: var(--brand); }
.tbl-btn-page:disabled { opacity: .3; cursor: not-allowed; }

.tbl-page-info {
  min-width: 64px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-secondary);
  font-weight: 500;
}
