/* Índice de registros compartido (`module-record-index.js`).
   Una hoja para todos los índices del ERP: Facturación, Gastos, Recurrentes,
   Catálogo, Proveedores, Flota y Personal. Si una vista necesita otro aspecto,
   se ajusta aquí y cambia en todas, que es justamente el objetivo. */

.ac-record-index { display: grid; gap: 8px; }
.ac-record-index-fill { min-height: 0; height: 100%; grid-template-rows: minmax(0, 1fr) auto; gap: 0; }
.ac-record-index-fill .ac-record-index-scroll { max-height: none; min-height: 0; border: 0; border-radius: 0; }
.ac-record-index-fill .ac-record-index-progress { min-height: 42px; padding: 6px 12px; border-top: 1px solid var(--line-soft); background: var(--surface); }
.ac-index-table-host { min-width: 0; min-height: 0; display: block; overflow: hidden; }
.ac-index-table-host .ac-record-index-table { width: 100%; min-width: 850px; table-layout: fixed; }
.ac-index-table-host .ac-record-index-table th,
.ac-index-table-host .ac-record-index-table td { overflow: hidden; text-overflow: ellipsis; }

.ac-record-index-trays { display: flex; flex-wrap: wrap; gap: 6px; }
.ac-record-index-trays .btn.active { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.ac-record-index-trays .btn span {
  margin-left: 6px; padding: 0 6px; border-radius: 999px;
  background: var(--surface-2); font-variant-numeric: tabular-nums;
}

.ac-record-index-scroll {
  max-height: 620px; overflow: auto;
  border: 1px solid var(--line-soft); border-radius: 10px; background: var(--bg);
}

.ac-record-index-table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: var(--font-base); }

.ac-record-index-table th,
.ac-record-index-table td {
  padding: 0 10px; height: var(--row-h);
  border-bottom: 1px solid var(--line-soft); white-space: nowrap;
}
.ac-record-index-cell strong,
.ac-record-index-cell small { display: block; overflow: hidden; text-overflow: ellipsis; }
.ac-record-index-cell small { color: var(--ink-muted); font-size: var(--font-xs); }

.ac-record-index-table thead th {
  position: sticky; top: 0; z-index: 2; padding: 0;
  /* Misma corrección que en .crm-table th: la cabecera se leía lavada. */
  background: var(--surface); color: var(--ink); font-weight: 600;
  font-size: var(--font-xs); text-transform: uppercase; text-align: left;
}
.ac-record-index-table thead th button {
  width: 100%; height: var(--row-h); padding: 0 10px;
  border: 0; background: none; color: inherit;
  font: inherit; text-transform: inherit; text-align: inherit; cursor: pointer;
}
.ac-record-index-table thead th button:hover { color: var(--ink); }

/* Importes y cantidades alineados a la derecha y con cifras de ancho fijo:
   una columna de totales sólo se compara de un vistazo si los dígitos cuadran. */
.ac-record-index-col-end, .ac-record-index-cell-end { text-align: right; }
.ac-record-index-cell-end { font-variant-numeric: tabular-nums; }
.ac-record-index-col-center, .ac-record-index-cell-center { text-align: center; }

.ac-record-index-row { cursor: pointer; }
.ac-record-index-row:hover td { background: var(--surface-2); }
.ac-record-index-row.active td { background: color-mix(in srgb, var(--accent) 10%, var(--bg)); }
.ac-record-index-row:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }

.ac-record-index-progress {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  color: var(--muted); font-size: var(--font-xs);
}
.ac-record-index-pages { display: inline-flex; align-items: center; gap: 8px; }
.ac-record-index-pages .btn { min-width: 32px; padding: 2px 8px; }

/* Contador + «Mostrar más» de directorios que aún no son record-index
   (Explotaciones, Clientes). Misma copia que `syncProgressiveReveal`. */
.ac-directory-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 28px;
  padding: 4px 10px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
  color: var(--ink-muted);
  font-size: var(--font-xs);
}
.ac-directory-progress .btn { height: var(--row-h-sm, 28px); padding: 0 8px; font-size: var(--font-xs); }

/* En pantalla estrecha las columnas marcadas `hideOn: ["narrow"]` se retiran:
   §4 dice no quitar capacidades para reducir altura, pero una tabla que
   desborda en horizontal tampoco se lee. Las filas siguen abriendo la ficha. */
@media (max-width: 720px) {
  .ac-record-index-table th.is-narrow-hidden,
  .ac-record-index-table td.is-narrow-hidden { display: none; }
}

/* Acciones de fila: sólo lo que no es «abrir». Se mantienen discretas para que
   la fila siga siendo el destino evidente. */
.ac-record-index-actions { text-align: right; white-space: nowrap; }
.ac-record-index-actions .btn { padding: 0 8px; height: var(--row-h-sm, 28px); font-size: var(--font-xs); }


/* Menú único de acciones de fila (list foundation): sustituye N botones PDF/etc. */
.ac-record-index-action-menu {
  position: relative;
  display: inline-block;
  text-align: left;
}
.ac-record-index-action-menu > summary {
  list-style: none;
  min-width: 28px;
  cursor: pointer;
}
.ac-record-index-action-menu > summary::-webkit-details-marker { display: none; }
.ac-record-index-action-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 5;
  display: grid;
  gap: 2px;
  min-width: 220px;
  padding: 6px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 10px 28px color-mix(in srgb, var(--ink) 16%, transparent);
}
.ac-record-index-action-menu-panel .btn {
  justify-content: flex-start;
  width: 100%;
  height: auto;
  min-height: var(--row-h-sm, 28px);
  padding: 6px 10px;
  white-space: normal;
  text-align: left;
}
