/* CobroFlow · capa móvil (≤767 px). CSS puro, sin dependencias: se carga después de styles.css y no toca el escritorio. */
@media (max-width: 767px) {
  html { -webkit-text-size-adjust: 100%; }
  button, a, select, input, textarea { touch-action: manipulation; }          /* sin retraso de 300 ms al tocar */
  #mainApp { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }       /* espacio para la barra inferior */

  /* ---- Cabecera compacta: menos de 60 px en vez de ~150 px ---- */
  #mainApp > header .min-h-16 { min-height: 3.25rem; padding-top: 4px; padding-bottom: 4px; }
  #mainApp > header .tracking-wider { display: none; }
  #mainApp > header .w-10.h-10 { width: 2rem; height: 2rem; border-radius: .6rem; }
  #mainApp > header .w-10.h-10 i { font-size: 1rem; }
  #mainApp > header .text-xl { font-size: 1.05rem; }

  /* ---- Navegación inferior (Bottom Navigation Bar), zona del pulgar ---- */
  #mobileNav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; display: flex !important; gap: 0; overflow-x: auto; padding: 0 0 env(safe-area-inset-bottom);
    background: rgba(10, 25, 47, .97); border-top: 1px solid #1e293b; box-shadow: 0 -6px 18px rgba(0, 0, 0, .25); -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  #mobileNav::-webkit-scrollbar { display: none; }
  #mobileNav > button {
    flex: 1 0 72px; min-height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    padding: 6px 4px; border: 0; border-radius: 0; background: transparent; color: #94a3b8; font-size: 10.5px; font-weight: 700; line-height: 1.1; text-align: center; white-space: normal;
  }
  #mobileNav > button i { font-size: 1.25rem; }
  #mobileNav > button.ring-2 { color: #fff; background: rgba(16, 185, 129, .16); box-shadow: inset 0 3px 0 #10b981; --tw-ring-shadow: 0 0 #0000; }

  /* Las ventanas (modales) van POR ENCIMA de la barra inferior: sus botones de abajo nunca quedan tapados */
  .fixed.inset-0[class*="z-50"] { z-index: 90 !important; }

  /* Avisos y mensajes por encima de la barra inferior */
  #toastContainer { top: calc(104px + env(safe-area-inset-top)) !important; bottom: auto !important; pointer-events: none; z-index: 120 !important; }   /* los avisos van ARRIBA: nunca tapan los botones de abajo */

  /* ---- Tablas → tarjetas (cada fila es una tarjeta legible sin hacer zoom ni desplazarse de lado) ---- */
  .overflow-x-auto:has(> table.cf-cards) { overflow: visible; }
  table.cf-cards, table.cf-cards tbody { display: block; width: 100%; }
  table.cf-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }   /* sigue disponible para lectores de pantalla */
  table.cf-cards tr { display: block; margin: 10px 12px; padding: 6px 14px; border: 1px solid #e2e8f0; border-radius: 16px; background: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, .05); content-visibility: auto; contain-intrinsic-size: auto 150px; }
  table.cf-cards td { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0 !important; border: 0; text-align: right !important; background: transparent !important; }
  table.cf-cards td[data-label]::before { content: attr(data-label); flex: 0 0 38%; text-align: left; font-size: 10.5px; font-weight: 800; color: #64748b; text-transform: uppercase; letter-spacing: .03em; }
  table.cf-cards td + td { border-top: 1px dashed #eef2f7; }
  table.cf-cards td[colspan], table.cf-cards td:empty { display: block; text-align: center !important; }
  table.cf-cards td:empty { display: none; }

  /* ---- Cobrador: cada cliente es una tarjeta de una sola mano, con el botón COBRAR grande al final ---- */
  table.cf-propia, table.cf-propia tbody { display: block; width: 100%; }
  table.cf-propia thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .overflow-x-auto:has(> table.cf-propia) { overflow: visible; }
  tr.fila-cobro {
    display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; margin: 10px 12px; padding: 12px 14px; border: 1px solid #e2e8f0; border-radius: 18px; background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .08); content-visibility: auto; contain-intrinsic-size: auto 230px;
    grid-template-areas: "cli cuo" "sem sal" "dir dir" "gps vis" "acc acc";
  }
  tr.fila-cobro > td { display: block; padding: 0 !important; border: 0; text-align: left !important; background: transparent !important; min-width: 0; }
  tr.fila-cobro > td[data-celda="cliente"] { grid-area: cli; }
  tr.fila-cobro > td[data-celda="cuota"] { grid-area: cuo; text-align: right !important; font-size: 1.35rem; line-height: 1.1; }
  tr.fila-cobro > td[data-celda="semaforo"] { grid-area: sem; }
  tr.fila-cobro > td[data-celda="semaforo"] > div { flex-direction: row; flex-wrap: wrap; justify-content: flex-start; }
  tr.fila-cobro > td[data-celda="saldo"] { grid-area: sal; text-align: right !important; font-size: .95rem; align-self: center; }
  tr.fila-cobro > td[data-celda="saldo"]::before { content: 'Saldo '; font-size: 10px; font-weight: 800; color: #94a3b8; text-transform: uppercase; }
  tr.fila-cobro > td[data-celda="direccion"] { grid-area: dir; }
  tr.fila-cobro > td[data-celda="gps"] { grid-area: gps; }
  tr.fila-cobro > td[data-celda="visita"] { grid-area: vis; text-align: right !important; }
  tr.fila-cobro > td[data-celda="accion"] { grid-area: acc; margin-top: 4px; }
  tr.fila-cobro > td[data-celda="gps"] a, tr.fila-cobro > td[data-celda="visita"] select { display: flex; align-items: center; justify-content: center; min-height: 46px; width: 100%; font-size: 13px; border-radius: 14px; }
  tr.fila-cobro > td[data-celda="accion"] button { width: 100%; min-height: 56px; justify-content: center; font-size: 18px; border-radius: 16px; }
  tr.fila-cobro > td[data-celda="accion"] > span { display: block; text-align: center; padding: 10px 0; font-size: 15px; }
  tr.fila-cobro > td[colspan] { grid-column: 1 / -1; grid-area: auto; }

  /* Botones de acción principales con tamaño táctil cómodo (≥ 44 px) en las vistas del cobrador */
  [id^="view-cobrador"] button, [id^="view-cobrador"] select { min-height: 44px; }
  .modal-accion, #modalPago button, #modalPago input, #modalPago select { min-height: 48px; font-size: 16px; }   /* 16 px evita el zoom automático de iOS al enfocar */
  input, select, textarea { font-size: 16px; }

  /* ================= Manager / vistas con muchos datos (v45) ================= */
  /* Contenedores fluidos: nada puede ensanchar la página */
  html, body, #mainApp, #mainApp main { max-width: 100vw; overflow-x: clip; }
  #mainApp * { min-width: 0; }
  #mainApp img, #mainApp svg, #mainApp canvas, #mainApp video, #mainApp pre, #mainApp table { max-width: 100%; }
  #mainApp h1, #mainApp h2, #mainApp h3, #mainApp p, #mainApp b, #mainApp span, #mainApp td, #mainApp li { overflow-wrap: anywhere; }
  #mainApp [class*="rounded-full"] { white-space: normal; max-width: 100%; }                 /* etiquetas largas se parten en vez de salirse */
  #mainApp .whitespace-nowrap { white-space: normal !important; }
  #mainApp main { padding-left: 12px; padding-right: 12px; }

  /* Métricas: 2 por fila en vez de una tarjeta gigante por métrica */
  #mainApp [class*="md:grid-cols-"], #mainApp [class*="sm:grid-cols-"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px !important; }
  #mainApp [class*="md:grid-cols-"] > div[class*="p-"], #mainApp [class*="sm:grid-cols-"] > div[class*="p-"] { padding: 12px !important; border-radius: 14px !important; }
  #mainApp [class*="md:grid-cols-"] .text-3xl, #mainApp [class*="md:grid-cols-"] .text-4xl, #mainApp [class*="sm:grid-cols-"] .text-3xl { font-size: 1.35rem !important; line-height: 1.15 !important; }
  #mainApp [class*="md:grid-cols-"] .text-2xl { font-size: 1.15rem !important; }
  #mainApp [class*="md:grid-cols-"] [class*="uppercase"] { font-size: 10px !important; letter-spacing: .02em; }

  #mainApp [class*="md:grid-cols-3"] > :last-child:nth-child(odd) { grid-column: 1 / -1; }   /* la métrica que queda sola ocupa todo el ancho */
  #mainApp main span[class*="rounded-full"][class*="uppercase"] { display: inline-block; border-radius: 14px; line-height: 1.3; padding: 6px 12px; }

  /* Encabezados de sección (héroes) más compactos */
  #mainApp main > section > div:first-child[class*="rounded-3xl"], #mainApp main > section > div:first-child[class*="rounded-2xl"] { padding: 14px !important; }
  #mainApp main > section h2.text-2xl, #mainApp main > section h2.text-3xl { font-size: 1.2rem !important; line-height: 1.2 !important; }
  #mainApp main { gap: 12px; } #mainApp main > section { gap: 12px; }

  /* Tarjetas de tabla v2: el 1.er dato es el TÍTULO de la tarjeta; los datos largos o con varias piezas se apilan (etiqueta arriba) */
  table.cf-cards td[data-titulo] { display: block; padding: 8px 0 6px !important; margin-bottom: 4px; border-bottom: 2px solid #eef2f7; text-align: left !important; font-size: 15px; font-weight: 800; }
  table.cf-cards td[data-titulo]::before { content: none; }
  table.cf-cards td[data-larga] { display: block; text-align: left !important; }
  table.cf-cards td[data-larga]::before { display: block; margin-bottom: 4px; }
  table.cf-cards td[data-larga] > * { max-width: 100%; }
  table.cf-cards td[data-larga] .flex { flex-wrap: wrap; }
  table.cf-cards td button, table.cf-cards td a.inline-flex { min-height: 44px; }
  table.cf-cards tr[data-oculta] { display: none !important; }
  table.cf-cards tr[data-fuera] { display: none !important; }

  /* Filtros colapsables (búsqueda + filtros por columna) */
  details.cf-filtros { margin: 6px 12px; background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; }
  details.cf-filtros > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: 0 14px; font-weight: 800; font-size: 14px; cursor: pointer; }
  details.cf-filtros > summary::-webkit-details-marker { display: none; }
  details.cf-filtros > summary .cf-n { font-weight: 600; color: #64748b; font-size: 12.5px; }
  details.cf-filtros .cf-fc { display: grid; gap: 8px; padding: 0 14px 14px; }
  details.cf-filtros input, details.cf-filtros select { width: 100%; min-height: 46px; border: 1px solid #cbd5e1; border-radius: 12px; padding: 0 12px; background: #fff; }
  details.cf-filtros label { font-size: 11px; font-weight: 800; color: #64748b; text-transform: uppercase; display: grid; gap: 4px; }
  .cf-mas-filas { display: block; width: calc(100% - 24px); margin: 6px 12px 12px; min-height: 48px; border: 1px solid #cbd5e1; border-radius: 14px; background: #fff; font-weight: 800; }

  /* Navegación inferior con «Más» cuando hay más de 5 secciones */
  #mobileNav.cf-compacta > button.cf-extra { display: none; }
  #mobileNav > button.cf-mas { color: #94a3b8; }
  #mobileNav > button.cf-mas.on { color: #fff; background: rgba(16, 185, 129, .16); box-shadow: inset 0 3px 0 #10b981; }
  #cfMasPanel { position: fixed; left: 8px; right: 8px; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 59; background: #0a192f; border: 1px solid #1e293b; border-radius: 18px; padding: 8px; display: none; gap: 6px; box-shadow: 0 -10px 30px rgba(0, 0, 0, .35); }
  #cfMasPanel.abierto { display: grid; }
  #cfMasPanel button { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 14px; border: 0; border-radius: 12px; background: transparent; color: #cbd5e1; font-weight: 700; font-size: 15px; text-align: left; }
  #cfMasPanel button i { width: 24px; text-align: center; font-size: 1.15rem; }
  #cfMasPanel button.ring-2 { background: rgba(16, 185, 129, .16); color: #fff; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---- v76 · Auditoría móvil / tablet ---- */
html, body { overflow-x: hidden; max-width: 100%; }                         /* cero desplazamiento horizontal en TODA la PWA */
img, svg, video, canvas, table { max-width: 100%; }
[role="alert"]:empty, [role="status"]:empty, .aviso-caja:empty, .alerta:empty { display: none !important; }   /* alertas vacías ocultas */
@media (max-width: 767px) {
  /* Uso a una mano: todo botón de la app (no la calculadora de entrada) mide al menos 48 px (h-12) */
  #mainApp main button, #mainApp section button, .fixed.inset-0 button, #mainApp select, .fixed.inset-0 select, .fixed.inset-0 input:not([type="checkbox"]):not([type="radio"]) { min-height: 48px; }
  /* …sin achicar los que ya eran más grandes */
  :is(#mainApp, .fixed.inset-0) .cr-botones button, :is(#mainApp, .fixed.inset-0) .ob-btn, :is(#mainApp, .fixed.inset-0) tr.fila-cobro > td[data-celda="accion"] button { min-height: 56px; }
  :is(#mainApp, .fixed.inset-0) .cr-emitir { min-height: 64px; }
  :is(#mainApp, .fixed.inset-0) .nav-conf-caja button, :is(#mainApp, .fixed.inset-0) .cfm-salir { min-height: 54px; }
  :is(#mainApp, .fixed.inset-0) .cfm-si, :is(#mainApp, .fixed.inset-0) .cfm-no { min-height: 60px; }
  :is(#mainApp, .fixed.inset-0) .tr-btn { min-height: 52px; }
  :is(#mainApp, .fixed.inset-0) .cr-campo input { min-height: 72px; }
  #modalTraslado select, #modalTraslado input[type=text] { min-height: 50px; }
  #mainApp section .flex.justify-between { flex-wrap: wrap; }
  .fixed.inset-0 > div { max-width: 100%; max-height: calc(100dvh - 24px); overflow-y: auto; }
}
@media (min-width: 768px) and (max-width: 1023px) {
  #mainApp section .grid.md\:grid-cols-2, #mainApp section .grid[class*="md:grid-cols"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }   /* tablet: dos columnas */
  .fixed.inset-0 > div { max-width: min(56rem, 100%); }
}
/* Tablet y portátil pequeño: el menú superior baja a su propia fila (antes quedaba cortado y la campana/salir no se veían) */
@media (min-width: 768px) and (max-width: 1199px) {
  #mainApp > header .min-h-16 { row-gap: 6px; padding: 8px 0; }
  #mainNavBar { order: 3; width: 100%; flex-wrap: wrap; gap: 4px; }
  #mainNavBar > * { margin-left: 0 !important; }
  #mainNavBar > button { min-height: 44px; }
}

/* v76 · Tablet (768-1199 px): las tablas anchas pasan a tarjetas en DOS columnas (antes se cortaban columnas a la derecha) */
@media (min-width: 768px) and (max-width: 1199px) {
  .overflow-x-auto:has(> table.cf-cards) { overflow: visible; }
  table.cf-cards, table.cf-cards tbody { display: block; width: 100%; }
  table.cf-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }   /* sigue disponible para lectores de pantalla */
  table.cf-cards tr { display: block; margin: 10px 12px; padding: 6px 14px; border: 1px solid #e2e8f0; border-radius: 16px; background: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, .05); }
  table.cf-cards td { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0 !important; border: 0; text-align: right !important; background: transparent !important; }
  table.cf-cards td[data-label]::before { content: attr(data-label); flex: 0 0 38%; text-align: left; font-size: 10.5px; font-weight: 800; color: #64748b; text-transform: uppercase; letter-spacing: .03em; }
  table.cf-cards td + td { border-top: 1px dashed #eef2f7; }
  table.cf-cards td[colspan], table.cf-cards td:empty { display: block; text-align: center !important; }
  table.cf-cards td:empty { display: none; }
  table.cf-cards td[data-titulo] { display: block; padding: 8px 0 6px !important; margin-bottom: 4px; border-bottom: 2px solid #eef2f7; text-align: left !important; font-size: 15px; font-weight: 800; }
  table.cf-cards td[data-titulo]::before { content: none; }
  table.cf-cards td[data-larga] { display: block; text-align: left !important; }
  table.cf-cards td[data-larga]::before { display: block; margin-bottom: 4px; }
  table.cf-cards td[data-larga] > * { max-width: 100%; }
  table.cf-cards td[data-larga] .flex { flex-wrap: wrap; }
  table.cf-cards td button, table.cf-cards td a.inline-flex { min-height: 44px; }
  table.cf-cards tbody { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; }
  table.cf-cards tr:has(> td[colspan]) { grid-column: 1 / -1; }
}
