/* 10 named table patterns */

/* Shared base for data tables */
.table-basic,
.table-zebra,
.table-sortable,
.table-sortable-status,
.table-admin-compact,
.table-admin-actions,
.table-invoice-lines,
.table-invoice-ledger {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table-basic th,
.table-basic td,
.table-zebra th,
.table-zebra td,
.table-sortable th,
.table-sortable td,
.table-sortable-status th,
.table-sortable-status td,
.table-admin-compact th,
.table-admin-compact td,
.table-admin-actions th,
.table-admin-actions td,
.table-invoice-lines th,
.table-invoice-lines td,
.table-invoice-ledger th,
.table-invoice-ledger td {
  padding: 0.75rem 1rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

.table-basic th,
.table-zebra th,
.table-sortable th,
.table-sortable-status th,
.table-admin-compact th,
.table-admin-actions th,
.table-invoice-lines th,
.table-invoice-ledger th {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  background: #f7f9fb;
}

.table-basic tbody tr:last-child td,
.table-zebra tbody tr:last-child td,
.table-sortable tbody tr:last-child td,
.table-sortable-status tbody tr:last-child td,
.table-admin-compact tbody tr:last-child td,
.table-admin-actions tbody tr:last-child td {
  border-bottom: 0;
}

/* ========== 1. Basic Data ========== */
.table-basic__wrap {
  background: var(--surface-raised);
}

.table-basic__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
}

.table-basic__toolbar h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
}

.table-basic__toolbar p {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--ink-faint);
}

/* ========== 2. Zebra Basic ========== */
.table-zebra tbody tr:nth-child(even) {
  background: #f7fafb;
}

.table-zebra th:first-child,
.table-zebra td:first-child {
  padding-left: 1.15rem;
}

.table-zebra__caption {
  caption-side: top;
  padding: 0.9rem 1rem;
  text-align: left;
  font-size: 0.95rem;
  font-weight: 800;
  border-bottom: 1px solid var(--border);
}

/* ========== 3. Sortable ========== */
.table-sortable th[aria-sort] button,
.table-sortable-status th[aria-sort] button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  font-weight: inherit;
  cursor: pointer;
}

.table-sortable th[aria-sort] button:hover,
.table-sortable-status th[aria-sort] button:hover {
  color: var(--accent-deep);
}

.table-sortable__indicator,
.table-sortable-status__indicator {
  display: inline-block;
  min-width: 0.85rem;
  font-size: 0.7rem;
  line-height: 1;
  opacity: 0.4;
}

.table-sortable__indicator::before,
.table-sortable-status__indicator::before {
  content: "↕";
}

.table-sortable th[aria-sort="ascending"] .table-sortable__indicator,
.table-sortable-status th[aria-sort="ascending"] .table-sortable-status__indicator,
.table-sortable th[aria-sort="descending"] .table-sortable__indicator,
.table-sortable-status th[aria-sort="descending"] .table-sortable-status__indicator {
  opacity: 1;
  color: var(--accent-deep);
}

.table-sortable th[aria-sort="ascending"] .table-sortable__indicator::before,
.table-sortable-status th[aria-sort="ascending"] .table-sortable-status__indicator::before {
  content: "↑";
}

.table-sortable th[aria-sort="descending"] .table-sortable__indicator::before,
.table-sortable-status th[aria-sort="descending"] .table-sortable-status__indicator::before {
  content: "↓";
}

/* ========== 4. Sortable Status ========== */
.table-sortable-status td .muted {
  color: var(--ink-faint);
  font-size: 0.75rem;
}

.table-sortable-status__person {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.table-sortable-status__person strong {
  font-weight: 700;
}

/* ========== 5. Compact Admin ========== */
.table-admin-compact {
  font-size: 0.8125rem;
}

.table-admin-compact th,
.table-admin-compact td {
  padding: 0.45rem 0.65rem;
}

.table-admin-compact th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef2f6;
  border-bottom: 1px solid var(--border-strong);
}

.table-admin-compact__shell {
  max-height: 16rem;
  overflow: auto;
  background: var(--surface-raised);
}

.table-admin-compact .id {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-faint);
}

/* ========== 6. Admin Actions ========== */
.table-admin-actions {
  font-size: 0.8125rem;
}

.table-admin-actions th,
.table-admin-actions td {
  padding: 0.55rem 0.7rem;
}

.table-admin-actions__check {
  width: 2.25rem;
  text-align: center;
}

.table-admin-actions__check input {
  accent-color: var(--accent);
}

.table-admin-actions__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border);
  background: #f7f9fb;
}

.table-admin-actions__toolbar h3 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 800;
}

.table-admin-actions__tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.table-admin-actions__row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}

.table-admin-actions tbody tr:hover {
  background: var(--accent-soft);
}

.table-admin-actions td.actions {
  text-align: right;
  white-space: nowrap;
}

/* ========== 7. Compare Plans ========== */
.table-compare-plans {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
  background: var(--surface-raised);
}

.table-compare-plans th,
.table-compare-plans td {
  padding: 0.85rem 1rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table-compare-plans th:first-child,
.table-compare-plans td:first-child {
  text-align: left;
  font-weight: 600;
  color: var(--ink-muted);
  background: #f7f9fb;
  position: sticky;
  left: 0;
  z-index: 1;
}

.table-compare-plans thead th {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--ink);
  background: #fff;
  border-bottom: 1px solid var(--border-strong);
}

.table-compare-plans thead th:first-child {
  background: #f7f9fb;
}

.table-compare-plans__price {
  display: block;
  margin-top: 0.25rem;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent-deep);
}

.table-compare-plans__price small {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-faint);
}

.table-compare-plans__featured {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.table-compare-plans thead th.table-compare-plans__featured {
  background: var(--accent-soft);
}

.table-compare-plans__yes {
  color: var(--success);
  font-weight: 800;
}

.table-compare-plans__no {
  color: var(--ink-faint);
}

.table-compare-plans tfoot td {
  border-bottom: 0;
  padding-top: 1rem;
  padding-bottom: 1.1rem;
}

/* ========== 8. Compare Specs ========== */
.table-compare-specs {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table-compare-specs caption {
  caption-side: top;
  padding: 0.9rem 1rem;
  text-align: left;
  font-size: 0.95rem;
  font-weight: 800;
  border-bottom: 1px solid var(--border);
}

.table-compare-specs th,
.table-compare-specs td {
  padding: 0.7rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table-compare-specs thead th {
  background: #f7f9fb;
  font-size: 0.8rem;
  font-weight: 800;
}

.table-compare-specs tbody th {
  width: 28%;
  font-weight: 700;
  color: var(--ink-muted);
  background: #fafbfc;
}

.table-compare-specs tbody tr:last-child th,
.table-compare-specs tbody tr:last-child td {
  border-bottom: 0;
}

.table-compare-specs__best {
  background: var(--accent-soft);
  font-weight: 700;
  color: var(--accent-deep);
}

/* ========== 9. Invoice Lines ========== */
.table-invoice-lines__sheet {
  padding: 1.15rem 1.15rem 1.25rem;
  background: var(--surface-raised);
}

.table-invoice-lines__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.table-invoice-lines__head h3 {
  margin: 0 0 0.2rem;
  font-size: 1.05rem;
  font-weight: 800;
}

.table-invoice-lines__head p {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--ink-muted);
}

.table-invoice-lines__meta {
  text-align: right;
  font-size: 0.8125rem;
  color: var(--ink-muted);
}

.table-invoice-lines__meta strong {
  display: block;
  color: var(--ink);
  font-weight: 800;
}

.table-invoice-lines .num {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.table-invoice-lines th.num,
.table-invoice-lines td.num {
  text-align: right;
}

/* ========== 10. Invoice Ledger ========== */
.table-invoice-ledger__sheet {
  padding: 1.15rem;
  background: var(--surface-raised);
}

.table-invoice-ledger__title {
  margin: 0 0 0.85rem;
  font-size: 1.05rem;
  font-weight: 800;
}

.table-invoice-ledger .num {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.table-invoice-ledger th.num,
.table-invoice-ledger td.num {
  text-align: right;
}

.table-invoice-ledger tfoot th,
.table-invoice-ledger tfoot td {
  border-bottom: 0;
  background: #f7f9fb;
  font-weight: 700;
}

.table-invoice-ledger tfoot tr:first-child th,
.table-invoice-ledger tfoot tr:first-child td {
  border-top: 1px solid var(--border-strong);
}

.table-invoice-ledger__total th,
.table-invoice-ledger__total td {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--accent-deep);
  background: var(--accent-soft);
}

.table-invoice-ledger__note {
  margin: 0.85rem 0 0;
  font-size: 0.75rem;
  color: var(--ink-faint);
}

/* ========== 11. Master Detail ========== */
.table-master-detail {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(14rem, 0.85fr);
  min-height: 20rem;
  background: var(--surface-raised);
}

.table-master-detail__list {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.table-master-detail__list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.table-master-detail__list-head h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
}

.table-master-detail__list-head p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--ink-faint);
}

.table-master-detail table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table-master-detail th,
.table-master-detail td {
  padding: 0.7rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table-master-detail thead th {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  background: #f7f9fb;
}

.table-master-detail tbody tr {
  cursor: pointer;
}

.table-master-detail tbody tr:hover {
  background: #f3f7f8;
}

.table-master-detail tbody tr[aria-selected="true"] {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.table-master-detail tbody tr:last-child td {
  border-bottom: 0;
}

.table-master-detail__detail {
  padding: 1.15rem 1.1rem;
  background: #f7f9fb;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.table-master-detail__detail-label {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.table-master-detail__detail h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
}

.table-master-detail__detail dl {
  margin: 0;
  display: grid;
  gap: 0.65rem;
}

.table-master-detail__detail dt {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.table-master-detail__detail dd {
  margin: 0.15rem 0 0;
  font-size: 0.9rem;
  color: var(--ink);
}

.table-master-detail__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: auto;
  padding-top: 0.5rem;
}

@media (max-width: 48rem) {
  .table-master-detail {
    grid-template-columns: 1fr;
  }

  .table-master-detail__list {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
}

/* ========== 12. Expandable Rows ========== */
.table-expandable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table-expandable th,
.table-expandable td {
  padding: 0.7rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table-expandable thead th {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  background: #f7f9fb;
}

.table-expandable__toggle {
  display: inline-grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--ink-muted);
  font-size: 0.85rem;
  line-height: 1;
}

.table-expandable__toggle:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
  background: var(--accent-soft);
}

.table-expandable tr[aria-expanded="true"] .table-expandable__toggle {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-deep);
}

.table-expandable__detail td {
  padding: 0;
  background: #f7f9fb;
  border-bottom: 1px solid var(--border);
}

.table-expandable__detail[hidden] {
  display: none;
}

.table-expandable__panel {
  padding: 0.85rem 1rem 1rem 3.5rem;
  font-size: 0.8125rem;
  color: var(--ink-muted);
}

.table-expandable__panel strong {
  color: var(--ink);
}

.table-expandable__panel p {
  margin: 0 0 0.45rem;
}

.table-expandable__panel p:last-child {
  margin-bottom: 0;
}

/* ========== 13. Grouped Rows ========== */
.table-grouped {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table-grouped th,
.table-grouped td {
  padding: 0.65rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table-grouped thead th {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  background: #f7f9fb;
}

.table-grouped__group td {
  padding: 0.55rem 1rem;
  background: #eef2f6;
  border-bottom: 1px solid var(--border-strong);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
}

.table-grouped__group-meta {
  float: right;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-faint);
}

.table-grouped tbody tr:not(.table-grouped__group):hover {
  background: #f8fbfb;
}

.table-grouped .num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ========== 14. Paginated ========== */
.table-paginated__shell {
  background: var(--surface-raised);
}

.table-paginated {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table-paginated th,
.table-paginated td {
  padding: 0.7rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table-paginated thead th {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  background: #f7f9fb;
}

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

.table-paginated__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: #f7f9fb;
  font-size: 0.8125rem;
  color: var(--ink-muted);
}

.table-paginated__footer p {
  margin: 0;
}

.table-paginated__pager {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.table-paginated__pager button[aria-current="page"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

/* ========== 15. Sticky Columns ========== */
.table-sticky-cols__shell {
  max-width: 100%;
}

.table-sticky-cols {
  width: max(100%, 44rem);
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
}

.table-sticky-cols th,
.table-sticky-cols td {
  padding: 0.7rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  background: #fff;
  white-space: nowrap;
}

.table-sticky-cols thead th {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  background: #f7f9fb;
}

.table-sticky-cols th:first-child,
.table-sticky-cols td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  box-shadow: 1px 0 0 var(--border);
}

.table-sticky-cols thead th:first-child {
  z-index: 3;
  background: #eef2f6;
}

.table-sticky-cols tbody td:first-child {
  font-weight: 700;
  background: #fafbfc;
}

.table-sticky-cols th:last-child,
.table-sticky-cols td:last-child {
  position: sticky;
  right: 0;
  z-index: 2;
  text-align: right;
  box-shadow: -1px 0 0 var(--border);
  background: #fff;
}

.table-sticky-cols thead th:last-child {
  z-index: 3;
  background: #eef2f6;
}

.table-sticky-cols tbody tr:hover td {
  background: var(--accent-soft);
}

.table-sticky-cols tbody tr:hover td:first-child,
.table-sticky-cols tbody tr:hover td:last-child {
  background: #d9ebe8;
}
