/* Tabla: los colores y bordes llegan como variables CSS desde las opciones del bloque. */
.cms-table { container-type: inline-size; color: var(--t-row-fg); }
.cms-table:not(.t-full) table { width: auto; }
.cms-t-caption { font-size: 1.25rem; font-weight: 800; margin-bottom: .75rem; }
.cms-t-tools { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: .75rem; }
.cms-t-tools label { display: block; font-size: .75rem; font-weight: 600; color: #475569; margin-bottom: .25rem; }
.cms-t-search { flex: 1 1 16rem; }
.cms-t-q, .cms-t-f { width: 100%; padding: .6rem .8rem; border: 1px solid #cbd5e1; border-radius: .6rem; background: #fff; color: #0f172a; font-size: .95rem; }
.cms-t-q:focus, .cms-t-f:focus { outline: none; border-color: #059669; box-shadow: 0 0 0 3px rgba(16,185,129,.2); }
.cms-t-filter { min-width: 10rem; }
.cms-t-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cms-t-scroll:focus-visible { outline: 3px solid #10b981; outline-offset: 2px; }
.t-sticky .cms-t-scroll { max-height: 70vh; overflow-y: auto; }
.t-sticky thead th { position: sticky; top: 0; z-index: 2; }
.cms-table table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--t-row-bg); }
.t-rounded .cms-t-scroll { border-radius: .9rem; }
.t-rounded table { border-radius: .9rem; overflow: hidden; }
.cms-table th { background: var(--t-head-bg); color: var(--t-head-fg); font-weight: 500; vertical-align: bottom; }
.t-hb th { font-weight: 700; }
.t-ha-left th { text-align: left; } .t-ha-center th { text-align: center; } .t-ha-right th { text-align: right; }
.cms-table th, .cms-table td { padding: .7rem .9rem; }
.t-sp-compact th, .t-sp-compact td { padding: .35rem .6rem; }
.t-sp-wide th, .t-sp-wide td { padding: 1rem 1.25rem; }
.t-fs-sm table { font-size: .82rem; } .t-fs-md table { font-size: .95rem; } .t-fs-lg table { font-size: 1.08rem; }
.t-nowrap td { white-space: nowrap; }
.cms-table td { background: var(--t-row-bg); vertical-align: top; }
.cms-table tbody tr:nth-child(even of :not([hidden])) td { background: var(--t-row-alt); }
.cms-table tbody tr:hover td { background: var(--t-row-hover); }
.cms-table .tal-left { text-align: left; } .cms-table .tal-center { text-align: center; } .cms-table .tal-right { text-align: right; }
.cms-table th.tal-center .cms-t-sort { justify-content: center; } .cms-table th.tal-right .cms-t-sort { justify-content: flex-end; }
/* Bordes */
.t-b-all th, .t-b-all td { border-right: var(--t-bw) var(--t-bs) var(--t-bc); border-bottom: var(--t-bw) var(--t-bs) var(--t-bc); }
.t-b-all table { border-top: var(--t-bw) var(--t-bs) var(--t-bc); border-left: var(--t-bw) var(--t-bs) var(--t-bc); }
.t-b-horizontal td { border-bottom: var(--t-bw) var(--t-bs) var(--t-bc); }
.t-b-outer table { border: var(--t-bw) var(--t-bs) var(--t-bc); }
.t-b-none td, .t-b-none th { border: 0; }
/* Encabezados que ordenan */
.cms-t-sort { all: unset; cursor: pointer; display: flex; align-items: center; gap: .35rem; width: 100%; }
.cms-t-sort:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; border-radius: 4px; }
.cms-t-arrow::after { content: '↕'; opacity: .45; font-size: .8em; }
th[aria-sort="ascending"] .cms-t-arrow::after { content: '▲'; opacity: 1; }
th[aria-sort="descending"] .cms-t-arrow::after { content: '▼'; opacity: 1; }
/* Estados y documentos */
.cms-badge { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.cms-st-green { background: #dcfce7; color: #166534; } .cms-st-red { background: #fee2e2; color: #991b1b; }
.cms-st-amber { background: #fef3c7; color: #92400e; } .cms-st-blue { background: #dbeafe; color: #1e40af; }
.cms-st-slate { background: #e2e8f0; color: #334155; } .cms-st-purple { background: #ede9fe; color: #5b21b6; }
.cms-t-doc { display: inline-flex; flex-wrap: wrap; gap: .35rem; }
.cms-t-btn { display: inline-flex; align-items: center; gap: .25rem; padding: .35rem .65rem; border: 1px solid #cbd5e1; border-radius: .5rem; background: #fff; color: #0f172a; font-size: .8rem; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.cms-t-btn:hover { border-color: #059669; color: #047857; }
.cms-t-btn-primary { background: #047857; border-color: #047857; color: #fff; } .cms-t-btn-primary:hover { background: #065f46; color: #fff; }
.cms-t-btn:disabled { opacity: .4; cursor: default; }
.cms-t-empty { padding: 1.5rem; text-align: center; color: #64748b; background: #fff; }
.cms-t-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-top: .75rem; font-size: .85rem; color: #475569; }
.cms-t-pager { display: flex; align-items: center; gap: .5rem; }
.cms-t-size { display: flex; align-items: center; gap: .35rem; }
.cms-t-ps { padding: .3rem .4rem; border: 1px solid #cbd5e1; border-radius: .45rem; background: #fff; color: #0f172a; }
.cms-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

/* Pantallas o espacios angostos: cada fila se ve como una tarjeta «etiqueta: valor». */
@container (max-width: 640px) {
  .cms-table table, .cms-table tbody, .cms-table tr, .cms-table td { display: block; width: 100%; }
  .cms-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
  .cms-table table { background: transparent; border: 0 !important; }
  .cms-table tbody tr { margin-bottom: .75rem; border: var(--t-bw) solid var(--t-bc); border-radius: .9rem; overflow: hidden; background: var(--t-row-bg); }
  .cms-table td { display: grid; grid-template-columns: minmax(6.5rem, 38%) 1fr; gap: .75rem; text-align: left !important; border-right: 0 !important; border-left: 0 !important; }
  .cms-table td::before { content: attr(data-label); font-weight: 700; color: inherit; opacity: .7; font-size: .82em; }
  .cms-table td > * { justify-self: start; }
  .cms-table td:not(:last-child) { border-bottom: 1px solid var(--t-bc); }
  .cms-table td:empty::after { content: '—'; color: #94a3b8; }
  .cms-table .t-nowrap td, .t-nowrap td { white-space: normal; }
  .cms-table .cms-t-scroll { overflow: visible; max-height: none; }
}
/* Filas ocultas por el filtro o la paginación: el atributo hidden debe ganar también en la vista de tarjetas */
.cms-table tr[hidden] { display: none !important; }
