/* Listas en tarjeta en el celular (≤680px), compartidas por Operación comercial y Gestión.
   Antes vivían en comercial-arena.css solo para Operación; el 20-nov-2026 se movieron aquí sin cambiar ninguna regla, solo el
   alcance (body[data-core] en vez de body[data-core="comercial"]), para que «Ventas y pagos» y la ficha de producto de Gestión usen
   la misma tarjeta que Operación en vez de una copia. Se activa con tbody.cm-rows; las tablas sin esa clase no cambian.
   Se carga justo después de comercial-arena.css (index.html), en el mismo lugar donde estaban. */

/* ===========================================================
   Listas comerciales en celular: la misma tarjeta de Estudiantes
   (.client-rows en asistida-movil.css), con las celdas marcadas así:
     .cm-title  nombre (línea 1, izquierda)   .cm-amount  cifra (línea 1, derecha)
     .cm-status estado (bajo el nombre)       .cm-info    franja de datos
     .actions-cell botones al final, por partes iguales
   tbody.cm-rows activa la tarjeta; .cm-2col pone la franja en dos columnas.
   =========================================================== */
@media (max-width: 680px) {
  body[data-core] .cm-rows tr {
    --tint: #f3eee8; --tline: var(--as-border-default, #eae2d8);
    display: flex !important; flex-wrap: wrap; align-items: flex-start; column-gap: 8px; row-gap: 0;
    margin: 0 0 10px; padding: 12px;
    border: 0 !important; border-radius: 22px;
    background: var(--gestion-glass-bg, linear-gradient(135deg, var(--tint), var(--as-surface, #fff) 58%)) !important;
    box-shadow: 0 0 0 1px var(--tline), 0 14px 28px -22px rgba(28, 22, 18, .45);
    -webkit-tap-highlight-color: transparent;
  }
  body[data-core] .cm-rows tr:has(.cm-status .status.expired) { --tint: #fdecea; --tline: #f3d6d1; }
  body[data-core] .cm-rows tr:has(.cm-status .status.pending) { --tint: #fdf3e2; --tline: #f1e2c6; }
  body[data-core] .cm-rows tr:has(.cm-status .status.active) { --tint: #eaf5ef; --tline: #d5e9dd; }
  body[data-core] .cm-rows tr:last-child { margin-bottom: 0; }
  /* Filas ocultas (p. ej. el detalle de productos de un crédito, que se abre con "Ver N productos") siguen ocultas. */
  body[data-core] .cm-rows tr[hidden] { display: none !important; }
  /* Detalle de productos abierto: se ve como parte de la tarjeta de arriba. */
  body[data-core] .cm-rows tr.credit-products-detail-row { margin-top: -18px; padding-top: 18px; border-radius: 0 0 22px 22px; box-shadow: 0 0 0 1px var(--tline); }
  body[data-core] .cm-rows tr.credit-products-detail-row td { flex: 1 1 100%; }
  body[data-core] .cm-rows tr td, body[data-core] .cm-rows tr:hover td { background: transparent !important; }
  /* Saltos de línea: antes de la franja y antes de los botones. */
  body[data-core] .cm-rows tr::before { content: ""; display: block !important; order: 4; flex-basis: 100%; height: 0; }
  body[data-core] .cm-rows tr::after { content: ""; order: 8; flex-basis: 100%; height: 0; }
  body[data-core] .cm-rows td {
    display: block !important; box-sizing: border-box; min-width: 0;
    padding: 0 !important; border: 0 !important; text-align: left !important;
  }
  body[data-core] .cm-rows td[data-label]::before { display: none !important; }

  /* Línea 1: nombre ......... cifra */
  body[data-core] .cm-rows .cm-title { order: 1; flex: 1 1 0; padding-top: 2px !important; }
  body[data-core] .cm-rows .cm-title strong {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
    font: 600 16px/20px var(--as-font-sans, inherit); color: var(--as-text-primary, #1c1612); overflow-wrap: anywhere;
  }
  body[data-core] .cm-rows .cm-title small { display: block; margin-top: 2px; font: 500 12.5px/16px var(--as-font-sans, inherit); color: var(--as-text-muted, #6f655b); }
  body[data-core] .cm-rows .cm-amount {
    order: 2; flex: none; max-width: 55%; text-align: right !important;
    font: 700 20px/24px var(--as-font-display, inherit); letter-spacing: -.02em; white-space: nowrap; color: var(--as-text-primary, #1c1612);
  }
  body[data-core] .cm-rows .cm-amount strong { display: block; font: inherit; letter-spacing: inherit; white-space: nowrap; }
  body[data-core] .cm-rows .cm-amount strong:not(.mora):not(.credit-amount) { color: var(--as-text-primary, #1c1612); }
  body[data-core] .cm-rows .cm-amount small { display: block; font-size: 11.5px; color: var(--as-text-muted, #6f655b); }
  /* Estado bajo el nombre: texto de color, sin pastilla (como en Estudiantes). */
  body[data-core] .cm-rows .cm-status { order: 3; flex: 0 0 100%; margin-top: 4px; }
  body[data-core] .cm-rows .cm-status .status {
    height: auto; padding: 0; background: none !important; box-shadow: none !important;
    font: 600 12.5px/18px var(--as-font-sans, inherit); white-space: nowrap;
  }
  body[data-core] .cm-rows .cm-status .status::before { display: none; }

  /* Franja de datos: casillas con su etiqueta arriba (como Plan | Vence | Mora). */
  body[data-core] .cm-rows td.cm-info {
    order: 5; flex: 1 1 calc(33.333% - 6px); margin-top: 8px; padding: 6px 10px !important;
    background: rgba(255, 255, 255, .72) !important; border: 1px solid rgba(28, 22, 18, .07) !important; border-radius: 12px;
    font: 600 13.5px/17px var(--as-font-sans, inherit); color: var(--as-text-primary, #1c1612);
    overflow-wrap: anywhere;
  }
  body[data-core] .cm-rows.cm-2col td.cm-info { flex-basis: calc(50% - 4px); }
  body[data-core] .cm-rows td.cm-info.cm-wide { flex-basis: 100%; }
  body[data-core] .cm-rows td.cm-info[data-label]::before {
    content: attr(data-label) !important; display: block !important; margin: 0 0 1px !important;
    font: 500 10px/13px var(--as-font-sans, inherit) !important; letter-spacing: .08em !important; text-transform: uppercase !important;
    color: var(--as-text-muted, #6f655b) !important;
  }
  body[data-core] .cm-rows td.cm-info strong { font-weight: 600; }
  body[data-core] .cm-rows td.cm-info small { display: block; font: 500 11.5px/15px var(--as-font-sans, inherit); color: var(--as-text-muted, #6f655b); }

  /* Botones: una fila, partes iguales (como Abonar | Ver ficha). */
  body[data-core] .cm-rows td.actions-cell { order: 9; flex: 1 1 100%; width: auto; margin-top: 10px; }
  body[data-core] .cm-rows td.actions-cell:empty { display: none !important; }
  body[data-core] .cm-rows .row-actions { display: flex; flex-wrap: nowrap; gap: 8px; width: 100%; }
  body[data-core] .cm-rows .row-actions > * { flex: 1 1 0; min-width: 0; }
  body[data-core] .cm-rows td.actions-cell > .as-btn { width: 100%; }
  body[data-core] .cm-rows td.actions-cell .as-btn {
    height: 38px; min-height: 38px; border-radius: 13px; font: 600 14px var(--as-font-sans, inherit); justify-content: center;
  }
  body[data-core] .cm-rows .row-actions .as-btn--soft {
    background: linear-gradient(180deg, #fb8a3c, var(--as-brand-600, #ea580c)) !important; color: #fff !important; border: 0 !important;
    box-shadow: 0 8px 18px -10px rgba(234, 88, 12, .9), inset 0 1px 0 rgba(255, 255, 255, .3) !important;
  }
  body[data-core] .cm-rows td.actions-cell .as-btn--secondary { background: var(--as-surface, #fff) !important; }
  body[data-core] .cm-rows .row-actions .debts-whatsapp { flex: 0 0 38px; width: 38px; height: 38px; border-radius: 13px; }
  /* Tarjetas directamente sobre el fondo (sin tarjeta dentro de tarjeta), como Estudiantes. */
  body[data-core] .panel:has(> .table-wrap .cm-rows, > .history-date-group .cm-rows, > div .cm-rows) {
    padding: 0 !important; background: transparent !important; border: 0 !important; box-shadow: none !important; border-radius: 0 !important;
  }
}
