/* Rapizza OS · panel v3 — estilos de ROS.tabla (tabla.js).
   Tokens de estilo.css; en un contenedor angosto (móvil, drawer, columna) cada fila es una tarjeta (container query). */
.tb { container: tb / inline-size; display: flex; flex-direction: column; gap: 12px; min-width: 0; --tb-bien: var(--good); --tb-mal: var(--bad); --tb-atencion: var(--warn); --tb-info: var(--info); --tb-neutro: var(--s-otros); }

/* barra de herramientas */
.tb-barra { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tb-busq { flex: 1 1 260px; max-width: 440px; }
.tb-herr { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-left: auto; }
.tb-orden select { height: 32px; font-size: 13px; padding-left: 32px; max-width: 280px; text-overflow: ellipsis; }
.tb-orden .tb-orden-ic { left: 10px; right: auto; }
.tb-bfiltros[aria-expanded="true"] { background: var(--surface-2); border-color: var(--ink-3); }
.tb-bfiltros .badge { min-width: 18px; height: 18px; font-size: 11px; }
.tb-link { appearance: none; border: 0; background: none; padding: 0; font: inherit; font-weight: 600; color: var(--info-tx); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.tb-link:hover { color: var(--ink); }

/* atajos (presets) y chips con conteo */
.tb-presets { gap: 6px; }
.tb-preset {
  appearance: none; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 8px; cursor: pointer;
  border: 1px dashed var(--line-2); background: transparent; color: var(--ink-2); font: 600 12.5px/1 var(--f-texto); white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s;
}
.tb-preset .ic { color: var(--ink-3); }
.tb-preset:hover { border-color: var(--ink-3); color: var(--ink); background: var(--surface); }
.tb-preset[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border: 1px solid transparent; box-shadow: 2px 2px 0 var(--brand-deep); }
.tb-preset[aria-pressed="true"] .ic { color: var(--on-accent); }
.tb-chips { gap: 6px; }
.tb-chip { height: 30px; padding: 0 11px; }
.tb-chip small { font-variant-numeric: tabular-nums; }
.tb-chip-k { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; box-shadow: 0 0 0 2px var(--surface); }
.tb-chip[aria-pressed="true"] .tb-chip-k { box-shadow: 0 0 0 2px var(--bg); }
.tb-chip--cero { opacity: .5; }
@media (pointer: coarse) { .tb-preset, .tb-chip { height: 38px; } }

/* panel de filtros (se despliega en el lugar: nada de popovers que se cierran con el teclado del teléfono) */
.tb-panel { background: var(--surface-2); border-radius: 12px; padding: 14px 16px 12px; border: 1px solid var(--line); animation: tbAbrir .16s ease-out; }
@keyframes tbAbrir { from { opacity: 0; transform: translateY(-4px); } }
.tb-panel-in { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px 22px; align-items: start; }
.tb-panel-pie { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.tb-ctl { border: 0; margin: 0; padding: 0; min-width: 0; }
.tb-ctl-t { display: flex; align-items: center; gap: 6px; font: 600 12.5px/1.3 var(--f-texto); color: var(--ink-2); margin-bottom: 8px; padding: 0; }
.tb-ctl--activo .tb-ctl-t { color: var(--ink); }
.tb-ctl--activo .tb-ctl-t::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }
.tb-ctl-x { font-size: 12px; color: var(--ink-3); margin-top: 6px; line-height: 1.4; }
.tb-mini { display: block; font-size: 11.5px; color: var(--ink-3); margin-bottom: 3px; }
/* multi */
.tb-multi-q { position: relative; display: flex; align-items: center; margin-bottom: 6px; }
.tb-multi-q .ic { position: absolute; left: 9px; color: var(--ink-3); pointer-events: none; }
.tb-multi-q .input { padding-left: 28px; height: 32px; }
.tb-multi-lista { display: flex; flex-direction: column; gap: 1px; max-height: 216px; overflow-y: auto; margin: 0 -6px; padding: 0 6px; overscroll-behavior: contain; }
.tb-multi-op { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; align-items: center; gap: 8px; min-height: 32px; padding: 4px 8px; border-radius: 7px; cursor: pointer; font-size: 13.5px; }
.tb-multi-op:hover { background: var(--surface); }
.tb-multi-op input { margin: 0; width: 16px; height: 16px; accent-color: var(--brand); }
.tb-multi-op span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-multi-op small { color: var(--ink-3); font-variant-numeric: tabular-nums; font-size: 12px; }
.tb-multi-op--cero { opacity: .55; }
.tb-multi-acc { display: flex; gap: 14px; margin-top: 6px; font-size: 12.5px; }
@media (pointer: coarse) { .tb-multi-op { min-height: 40px; } }
/* rango: dos números + deslizador doble */
.tb-rango-in { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px; align-items: center; }
.tb-rango-in .input { font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield; }
.tb-rango-in .input::-webkit-outer-spin-button, .tb-rango-in .input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tb-rango-a { font-size: 12.5px; color: var(--ink-3); }
.tb-slider { position: relative; height: 28px; margin: 6px 2px 0; --a: 0%; --b: 100%; }
.tb-slider-pista { position: absolute; left: 10px; right: 10px; top: 12px; height: 4px; border-radius: 2px; background: var(--line-2); }
.tb-slider-pista i { position: absolute; top: 0; bottom: 0; left: var(--a); right: calc(100% - var(--b)); border-radius: 2px; background: var(--ink); }
.tb-slider input[type="range"] { position: absolute; inset: 0; width: 100%; height: 28px; margin: 0; padding: 0; background: none; pointer-events: none; -webkit-appearance: none; appearance: none; outline: none; }
.tb-slider input[type="range"]::-webkit-slider-runnable-track { height: 28px; background: none; border: 0; }
.tb-slider input[type="range"]::-moz-range-track { height: 28px; background: none; border: 0; }
.tb-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; pointer-events: auto; width: 20px; height: 20px; margin-top: 4px; border-radius: 50%; cursor: grab;
  background: var(--surface); border: 2px solid var(--ink); box-shadow: 0 1px 3px rgba(26, 18, 16, .25);
}
.tb-slider input[type="range"]::-moz-range-thumb { pointer-events: auto; width: 16px; height: 16px; border-radius: 50%; cursor: grab; background: var(--surface); border: 2px solid var(--ink); box-shadow: 0 1px 3px rgba(26, 18, 16, .25); }
.tb-slider input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--foco); outline-offset: 2px; }
.tb-slider input[type="range"]:focus-visible::-moz-range-thumb { outline: 2px solid var(--foco); outline-offset: 2px; }
.tb-slider input[type="range"]:active::-webkit-slider-thumb { cursor: grabbing; }
@media (pointer: coarse) {
  .tb-slider { height: 36px; }
  .tb-slider-pista { top: 16px; left: 13px; right: 13px; }
  .tb-slider input[type="range"], .tb-slider input[type="range"]::-webkit-slider-runnable-track { height: 36px; }
  .tb-slider input[type="range"]::-webkit-slider-thumb { width: 26px; height: 26px; margin-top: 5px; }
}
.tb-rango-ext { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; margin-top: 2px; }
/* fechas */
.tb-rapidos { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tb-rapido { appearance: none; height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); font: 600 12px/1 var(--f-texto); cursor: pointer; white-space: nowrap; }
.tb-rapido:hover { border-color: var(--ink-3); color: var(--ink); }
.tb-rapido[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
@media (pointer: coarse) { .tb-rapido { height: 36px; } }
.tb-fechas-in { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.tb-fechas-in .input { padding: 0 8px; }
/* bandera */
.tb-bandera-op { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 6px 12px; border-radius: 9px; background: var(--surface); border: 1px solid var(--line); cursor: pointer; font-size: 13.5px; font-weight: 500; }
.tb-bandera-op input { margin: 0; width: 16px; height: 16px; accent-color: var(--brand); flex: none; }
.tb-bandera-op small { margin-left: auto; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* lo activo (píldoras) y el estado */
.tb-activos { display: flex; flex-wrap: wrap; gap: 6px; }
.tb-pildora { display: inline-flex; align-items: center; height: 30px; border-radius: 999px; max-width: 100%; background: color-mix(in srgb, var(--info) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--info) 28%, transparent); color: var(--ink); }
.tb-pildora-t { appearance: none; border: 0; background: none; font: 600 12.5px/1 var(--f-texto); color: inherit; padding: 0 4px 0 12px; height: 100%; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tb-pildora-x { appearance: none; border: 0; background: none; color: var(--ink-2); width: 28px; height: 28px; margin-right: 1px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; flex: none; }
.tb-pildora-x:hover { background: color-mix(in srgb, var(--info) 16%, transparent); color: var(--ink); }
@media (pointer: coarse) { .tb-pildora { height: 36px; } .tb-pildora-x { width: 34px; height: 34px; } }
.tb-estado { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; font-size: 13px; color: var(--ink-2); min-height: 18px; }
.tb-estado b { color: var(--ink); font-size: 14px; font-variant-numeric: tabular-nums; }
.tb-estado-f { color: var(--ink-3); }
.tb-selbanda { padding: 9px 12px; border-radius: 10px; font-size: 13.5px; background: color-mix(in srgb, var(--accent) 16%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); }

/* tabla */
.tb-scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.tb-tbl th { vertical-align: bottom; }
.tb-tbl th, .tb-tbl td { padding-left: 8px; padding-right: 8px; }
.tb-tbl .th-ic-on { color: var(--ink); }
.tb-tbl th[aria-sort] { color: var(--ink); }
.tb-th-sel, .tb-td-sel { width: 36px; padding-right: 0 !important; }
.tb-cbx { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; cursor: pointer; margin: -4px 0; }
.tb-cbx:hover { background: var(--surface-2); }
.tb-cbx input { margin: 0; width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }
.tb-f--clic { cursor: pointer; }
.tb-f:focus-visible { outline: 2px solid var(--foco); outline-offset: -2px; }
.tb-tbl tbody tr.tb-f--sel { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.tb-tbl tbody tr.tb-f--sel:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.tb-mark { background: color-mix(in srgb, var(--accent) 60%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.tb-vacio { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.tb-vacio > .vacio { width: 100%; }

/* pie: resumen y "ver más" */
.tb-pie { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; font-size: 13px; color: var(--ink-2); }
.tb-pie:empty { display: none; }
.tb-resumen b { color: var(--ink); font-variant-numeric: tabular-nums; }
.tb-pag { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-left: auto; color: var(--ink-3); }

/* barra de acciones flotante (acompaña a su tabla: sticky dentro de ella) */
.tb-accbar {
  position: sticky; bottom: 16px; z-index: 12; align-self: center; width: fit-content; max-width: 100%;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 8px 8px 16px; border-radius: 14px;
  background: var(--tip-bg); color: var(--tip-ink); box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .5); animation: subir .2s cubic-bezier(.2, .8, .3, 1);
}
.tb-acc-n { font-size: 13.5px; color: var(--tip-ink-2); }
.tb-acc-n b { color: var(--tip-ink); font-size: 16px; font-variant-numeric: tabular-nums; }
.tb-acc-n small { display: block; font-size: 12px; color: var(--tip-ink-2); }
.tb-acc-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.tb-accbar .btn--sec { background: rgba(255, 255, 255, .1); color: var(--tip-ink); border-color: rgba(255, 255, 255, .22); }
.tb-accbar .btn--sec:hover { background: rgba(255, 255, 255, .18); }
.tb-accbar .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.tb-acc-x { color: var(--tip-ink-2); }
.tb-acc-x:hover { background: rgba(255, 255, 255, .12); color: var(--tip-ink); }
.tb-acc-c { display: none; }
/* en el teléfono la barra va pegada arriba (abajo están la barra de secciones y el botón de comentarios) */
@media (max-width: 767.98px) {
  .tb-accbar { order: -1; top: calc(var(--sup-h) + 8px); bottom: auto; align-self: stretch; width: auto; padding: 8px 8px 8px 14px; gap: 8px; }
  .tb-acc-n { flex: 1 1 auto; min-width: 0; }
  .tb-acc-x { order: 2; }
  .tb-acc-btns { order: 3; flex: 1 1 100%; flex-wrap: nowrap; }
  .tb-acc-btns .btn { flex: 1 1 0; min-width: 0; padding: 0 8px; }
  .tb-acc-l { display: none; }
  .tb-acc-c { display: inline; }
}

/* mientras hay una barra de selección a la vista, los avisos (toasts) suben para no taparla */
@media (min-width: 768px) { body:has(.tb-accbar:not([hidden])) .toasts { bottom: 92px; } }

/* menú de columnas */
.pop--tb { padding: 8px; min-width: 220px; }
.tb-cols { display: flex; flex-direction: column; gap: 1px; }
.tb-cols .menu-t { padding: 4px 8px 6px; }
.tb-cols-op { display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 0 8px; border-radius: 7px; font-size: 14px; cursor: pointer; }
.tb-cols-op:hover { background: var(--surface-2); }
.tb-cols-op input { margin: 0; width: 16px; height: 16px; accent-color: var(--brand); }
.tb-cols-op:has(input:disabled) { opacity: .55; cursor: default; }
.tb-cols .tb-link { align-self: flex-start; margin: 8px 8px 2px; font-size: 13px; }

/* ancho mediano: antes que el scroll horizontal, se esconden las columnas de menos prioridad */
@container tb (min-width: 700px) and (max-width: 999px) { .tb-tbl .tb-p3 { display: none; } }
@container tb (min-width: 700px) and (max-width: 819px) { .tb-tbl .tb-p2 { display: none; } }

/* contenedor angosto: cada fila es una tarjeta legible */
@container tb (max-width: 699px) {
  .tb-busq { flex: 1 1 100%; max-width: none; }
  .tb-herr { margin-left: 0; flex: 1 1 100%; flex-wrap: nowrap; min-width: 0; }
  .tb-herr > * { flex: none; }
  .tb-herr .tb-orden { flex: 1 1 0; min-width: 0; display: flex; }
  .tb-orden select { width: 100%; max-width: none; height: 36px; padding-left: 10px; font-size: 12.5px; }
  .tb-orden .tb-orden-ic { display: none; }
  .tb-bcols { display: none; }
  .tb-panel { padding: 12px; }
  .tb-panel-in { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .tb-scroll { overflow: visible; margin: 0; padding: 0; }
  .tb-tbl thead { display: none; }
  .tb-tbl, .tb-tbl tbody { display: block; }
  .tb-tbl tr { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 12px; padding: 12px 14px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
  .tb-tbl tbody tr:hover { background: var(--surface); }
  .tb-tbl tbody tr.tb-f--sel { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
  .tb-tbl td { display: block; padding: 0; border: 0 !important; text-align: left; min-width: 0; }
  .tb-tbl td.num { text-align: left; }
  .tb-tbl td.m-titulo { grid-column: 1 / -1; font-size: 15px; }
  .tb-tbl td.m-sub { grid-column: 1 / -1; margin-top: -2px; }
  .tb-tbl td.m-dato::before { content: attr(data-l); display: block; font-size: 11.5px; font-weight: 500; color: var(--ink-3); margin-bottom: 1px; }
  .tb-tbl td.m-oculta { display: none; }
  .tb-tbl td.tb-td-sel { position: absolute; top: 4px; right: 4px; width: auto; }
  .tb-tbl tr:has(.tb-td-sel) td.m-titulo { padding-right: 36px; }
  .tb-tbl .tb-cbx { width: 40px; height: 40px; margin: 0; }
  .tb-tbl .tb-cbx input { width: 20px; height: 20px; }
  .tb-pag { margin-left: 0; width: 100%; justify-content: space-between; }
}
@media print { .tb-accbar, .tb-barra, .tb-presets, .tb-panel, .tb-pag .btn { display: none !important; } }
