/* Workspace 2026: shell fluido, navegación lateral, tarjetas adaptativas y sistema visual.
   Se carga tras layout.css y mejoras-visuales.css; usa ID + clase para ganar al CSS de módulo
   que el router inyecta dinámicamente después de las hojas estáticas. */

:root {
  --ws-sidebar: clamp(274px, 18vw, 360px);
  --ws-ease: cubic-bezier(.22, 1, .36, 1);
  --ws-sombra: 0 1px 2px rgba(10, 37, 64, .06), 0 10px 24px -16px rgba(10, 37, 64, .35), 0 28px 60px -40px rgba(10, 37, 64, .45);
}

@keyframes wsFadeSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
@keyframes wsNavPulsoX {
  0%, 100% { transform: translateX(-50%) scaleX(.55); opacity: .65; }
  50% { transform: translateX(-50%) scaleX(1); opacity: 1; }
}
@keyframes wsNavPulsoY {
  0%, 100% { transform: translateY(-50%) scaleY(.55); opacity: .65; }
  50% { transform: translateY(-50%) scaleY(1); opacity: 1; }
}
@keyframes wsBackdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes wsPanelPop {
  from { opacity: 0; transform: translate3d(0, 8px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes wsToastIn {
  from { opacity: 0; transform: translateX(18px) scale(.96); }
  to { opacity: 1; transform: none; }
}

/* --------------------------- Sistema visual --------------------------- */
#app-root .card {
  border: 1px solid color-mix(in srgb, var(--borde) 82%, transparent);
  border-radius: 14px;
  box-shadow: var(--ws-sombra);
}

#app-root .btn {
  transition: transform 180ms var(--ws-ease), box-shadow 180ms var(--ws-ease),
    background-color 180ms var(--ws-ease), color 180ms var(--ws-ease),
    border-color 180ms var(--ws-ease);
}
#app-root .btn:not(:disabled):hover { transform: translateY(-1px); }
#app-root .btn:not(:disabled):active { transform: scale(.97); }
#app-root .btn-primario {
  background: linear-gradient(135deg, color-mix(in srgb, var(--color-primario) 82%, #fff), var(--color-primario));
  box-shadow: 0 12px 26px -14px color-mix(in srgb, var(--color-primario) 85%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, .28);
}
#app-root .btn-primario:not(:disabled):hover {
  box-shadow: 0 18px 32px -16px color-mix(in srgb, var(--color-primario) 90%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, .32);
}
#app-root .btn-suave {
  background: color-mix(in srgb, var(--color-primario) 12%, var(--superficie));
  color: var(--color-oscuro);
}
#app-root .btn-oscuro {
  background: linear-gradient(135deg, color-mix(in srgb, var(--color-oscuro) 82%, #33587A), var(--color-oscuro));
  box-shadow: 0 10px 24px -16px rgba(10, 37, 64, .8);
}
#app-root .btn-peligro {
  background: color-mix(in srgb, var(--peligro) 12%, var(--superficie));
  color: var(--peligro);
}
#app-root .btn-peligro:not(:disabled):hover {
  box-shadow: 0 12px 24px -16px color-mix(in srgb, var(--peligro) 70%, transparent);
}

#app-root input:focus, #app-root select:focus,
#app-root textarea:focus {
  border-color: var(--color-primario);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primario) 18%, transparent);
}
#app-root select:not([multiple]) {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.4rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B8198' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .85rem center;
  background-size: 1rem 1rem;
}

#app-root .mono, #app-root .dash-kpi strong, #app-root .caja-metricas strong,
#app-root td.mono { font-variant-numeric: tabular-nums; }

#app-root #app-content .badge {
  background: color-mix(in srgb, var(--color-primario) 12%, transparent);
  color: var(--color-primario);
}
#app-root #app-content .badge-listo, #app-root #app-content .badge-exito {
  background: color-mix(in srgb, var(--exito) 16%, transparent);
  color: var(--exito);
}
#app-root #app-content .badge-pendiente {
  background: color-mix(in srgb, var(--alerta) 18%, transparent);
  color: var(--alerta);
}
#app-root #app-content .badge-proceso, #app-root #app-content .badge-info {
  background: color-mix(in srgb, var(--color-primario) 14%, transparent);
  color: var(--color-primario);
}
#app-root #app-content .badge-peligro {
  background: color-mix(in srgb, var(--peligro) 15%, transparent);
  color: var(--peligro);
}
#app-root #app-content .badge-neutro {
  background: color-mix(in srgb, var(--texto-suave) 12%, transparent);
  color: var(--texto-suave);
}

#app-root #app-content table { width: 100%; max-width: 100%; }

/* ------------------------------- Móvil ------------------------------- */
@media (max-width: 767px) {
  #app-root #app-header {
    background: rgba(255, 255, 255, .98);
  }
  #app-root #app-header .header-inner { padding: 10px 14px; gap: .5rem; }
  #app-root #app-header .header-marca { flex: 1 1 auto; min-width: 0; overflow: visible; }
  #app-root #app-header .header-acciones { flex: 0 0 auto; gap: .3rem; }
  #app-root #app-header .header-texto { overflow: visible; min-width: 0; }
  #app-root #app-header .header-texto h1 { max-width: none; font-size: .95rem; }
  #app-root #app-header .header-subfila { min-width: 0; overflow: visible; }
  #app-root #app-header .icono-btn {
    min-height: 34px;
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    padding: 0;
  }

  #app-root #app-content .btn,
  #app-root #app-content .btn-mini,
  #app-root #app-content input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
  #app-root #app-content select,
  #app-root #app-content .icono-btn,
  #app-root #bottom-nav .nav-btn { min-height: 44px; }

  #app-root #app-content .view {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 1rem;
    min-width: 0;
    max-width: 100%;
  }
  #app-root #app-content .view > * { min-width: 0; max-width: 100%; }
  #app-root #app-content .dash-panel-doble { grid-template-columns: minmax(0, 1fr); }

  #app-root #bottom-nav .nav-btn { position: relative; }
  #app-root #bottom-nav .nav-btn.activo::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 5px;
    width: 20px;
    height: 3px;
    border-radius: 999px;
    background: var(--color-primario);
    box-shadow: 0 0 10px color-mix(in srgb, var(--color-primario) 55%, transparent);
    transform: translateX(-50%);
  }

  #app-root #app-content table.tabla-movil,
  #app-root #app-content table.tabla-movil tbody,
  #app-root #app-content table.tabla-movil tr,
  #app-root #app-content table.tabla-movil td {
    display: block;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
  #app-root #app-content table.tabla-movil {
    margin: 0;
    border: 0;
    background: transparent;
    overflow: visible;
  }
  #app-root #app-content table.tabla-movil thead { display: none; }
  #app-root #app-content table.tabla-movil tr {
    margin: 0 0 .65rem;
    padding: .75rem .85rem;
    border: 1px solid color-mix(in srgb, var(--borde) 85%, transparent);
    border-radius: 14px;
    background: var(--superficie);
    box-shadow: var(--sombra);
  }
  #app-root #app-content table.tabla-movil td {
    border: 0;
    padding: .35rem 0;
    text-align: left;
    overflow-wrap: anywhere;
  }
  #app-root #app-content table.tabla-movil td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: .15rem;
    font-size: .6rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--texto-suave);
  }
  #app-root #app-content table.tabla-movil td:empty::before { content: ''; display: none; }
}

/* ------------------------- Tablet / escritorio ------------------------- */
@media (min-width: 768px) {
  #app-root #app-header .header-inner,
  #app-root #app-content,
  #app-root #bottom-nav .nav-inner,
  #app-root .login-shell #app-content,
  #app-root #app-content.sa-main {
    width: min(100%, 1440px);
    max-width: 1440px;
    margin-inline: auto;
  }
  #app-root #app-header .header-inner {
    padding-inline: clamp(20px, 4vw, 56px);
  }
  #app-root #app-content.shell-contenido {
    padding-top: 96px;
    padding-inline: clamp(20px, 4vw, 56px);
    padding-bottom: 32px;
  }
  #app-root #bottom-nav .nav-inner {
    padding-inline: clamp(20px, 4vw, 56px);
    gap: .5rem;
  }
  #app-root #app-content .view { min-width: 0; max-width: 100%; }

  #app-root #app-content .dash-kpis,
  #app-root #app-content .dash-accesos-grid,
  #app-root #app-content .caja-metricas,
  #app-root #app-content .hel-productos,
  #app-root #app-content [class*="gym-"]:is([class*="grid"], [class*="lista"], [class*="producto"], [class*="metrica"]),
  #app-root #app-content [class*="bar-"]:is([class*="grid"], [class*="lista"], [class*="producto"], [class*="servicio"], [class*="metrica"]) {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: clamp(12px, 1.4vw, 18px);
    align-items: stretch;
  }
  #app-root #app-content .dash-panel-doble {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(14px, 1.6vw, 22px);
    align-items: start;
  }

  #app-root #app-content .vista-pos .pos-layout,
  #app-root #app-content .vista-pos:has(.carrito-detalle) .pos-layout,
  #app-root #app-content .caja-layout,
  #app-root #app-content .bar-caja-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
    gap: clamp(16px, 2vw, 28px);
    align-items: start;
    width: 100%;
  }
  #app-root #app-content .vista-pos .pos-catalogo,
  #app-root #app-content .caja-layout > :first-child,
  #app-root #app-content .bar-caja-layout > :first-child { min-width: 0; }
  #app-root #app-content .vista-pos .pos-orden,
  #app-root #app-content .caja-layout > .pos-orden,
  #app-root #app-content .bar-caja-layout > .pos-orden {
    position: sticky;
    top: 96px;
    align-self: start;
    min-width: 0;
  }

  /* Super Admin: misma amplitud que el resto del workspace. */
  #app-root #app-content.sa-main {
    margin-left: 250px;
    margin-right: 0;
    width: min(calc(100% - 250px), 1440px);
    padding: 96px clamp(20px, 4vw, 56px) 32px;
  }
  #app-root #app-content.sa-main .view { width: 100%; max-width: 100%; }
  #app-root #app-content.sa-main .sa-contenido-ancho,
  #app-root #app-content .sa-contenido-ancho { width: 100%; max-width: none; }
  #app-root #app-content.sa-main .sa-kpis,
  #app-root #app-content.sa-main .sa-metricas {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: clamp(12px, 1.4vw, 18px);
  }
  /* .sa-grid se rige por superadmin.css: 3 columnas máx. en 1920, 2 en 1366, 1 en móvil. */
  #app-root #app-content.sa-main table,
  #app-root #app-content.sa-main .sa-tabla table { width: 100%; max-width: 100%; }

  /* Login: el contenedor es fluido; la tarjeta se centra sin columna diminuta. */
  #app-root .login-shell {
    background: radial-gradient(circle at 18% 12%, color-mix(in srgb, var(--color-primario) 14%, transparent), transparent 42%),
      linear-gradient(155deg, var(--fondo), color-mix(in srgb, var(--color-primario) 8%, var(--superficie)));
  }
  #app-root .login-shell #app-content {
    padding: 96px clamp(20px, 4vw, 56px) 32px;
  }
  #app-root .login-shell .vista-login {
    width: min(100%, 30rem);
    max-width: 30rem;
    margin-inline: auto;
  }
  #app-root .login-shell .login-tarjeta {
    width: 100%;
    max-width: 30rem;
    margin: 1.75rem auto 0;
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 1px 2px rgba(10, 37, 64, .06), 0 18px 40px -28px rgba(10, 37, 64, .5),
      0 48px 90px -60px color-mix(in srgb, var(--color-primario) 70%, transparent);
  }
}

/* --------------------- Navegación lateral en escritorio --------------------- */
@media (min-width: 1024px) {
  #app-root #bottom-nav {
    inset: 0 auto 0 0;
    width: var(--ws-sidebar);
    border-right: 1px solid var(--borde);
    border-top: 0;
    background: rgba(255, 255, 255, .96);
    z-index: 45;
  }
  #app-root #bottom-nav .nav-inner {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    padding: 88px .75rem 1rem;
    gap: .4rem;
  }
  #app-root #bottom-nav .nav-btn {
    flex-direction: row;
    justify-content: flex-start;
    gap: .75rem;
    width: 100%;
    min-height: 48px;
    padding: .8rem 1rem;
    border-radius: 12px;
    font-size: .8rem;
    text-align: left;
  }
  #app-root #bottom-nav .nav-btn i {
    width: 1.25rem;
    flex: 0 0 1.25rem;
    font-size: 1rem;
    text-align: center;
  }
  #app-root #bottom-nav .nav-btn.activo {
    background: color-mix(in srgb, var(--color-primario) 12%, transparent);
    color: var(--color-primario);
  }
  #app-root #bottom-nav .nav-btn.activo::after {
    left: 0;
    right: auto;
    top: 50%;
    bottom: auto;
    width: 3px;
    height: 26px;
    border-radius: 999px;
    transform: translateY(-50%);
  }
  #app-root #app-header { left: var(--ws-sidebar); right: 0; }
  #app-root #app-header .header-inner { max-width: none; width: 100%; padding-inline: 40px; }
  #app-root #app-content.shell-contenido {
    margin-left: var(--ws-sidebar);
    margin-right: 0;
    width: calc(100% - var(--ws-sidebar));
    max-width: none;
    padding-inline: 40px;
  }
  /* El pie se centra en todo escritorio, con la barra lateral como navegación. */
  #app-root #app-content.sa-main {
    margin-left: 250px;
    width: min(calc(100% - 250px), 1440px);
    max-width: 1440px;
  }
}

/* ------------------------------- Animaciones ------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  #app-root #app-content .view { animation: wsFadeSlideUp 220ms var(--ws-ease) both; }
  #app-root #app-content .view > * { animation: wsFadeSlideUp 220ms var(--ws-ease) both; }
  #app-root #app-content .view > :nth-child(2) { animation-delay: 45ms; }
  #app-root #app-content .view > :nth-child(3) { animation-delay: 90ms; }
  #app-root #app-content .view > :nth-child(4) { animation-delay: 135ms; }
  #app-root #app-content .view > :nth-child(n + 5) { animation-delay: 180ms; }

  #app-root #app-content .dash-kpis > *,
  #app-root #app-content .lista > *,
  #app-root #app-content tbody tr { animation: wsFadeSlideUp 220ms var(--ws-ease) both; }
  #app-root #app-content .dash-kpis > :nth-child(2),
  #app-root #app-content .lista > :nth-child(2),
  #app-root #app-content tbody tr:nth-child(2) { animation-delay: 50ms; }
  #app-root #app-content .dash-kpis > :nth-child(3),
  #app-root #app-content .lista > :nth-child(3),
  #app-root #app-content tbody tr:nth-child(3) { animation-delay: 100ms; }
  #app-root #app-content .dash-kpis > :nth-child(4),
  #app-root #app-content .lista > :nth-child(4),
  #app-root #app-content tbody tr:nth-child(4) { animation-delay: 150ms; }
  #app-root #app-content .dash-kpis > :nth-child(n + 5),
  #app-root #app-content .lista > :nth-child(n + 5),
  #app-root #app-content tbody tr:nth-child(n + 5) { animation-delay: 200ms; }

  #bottom-nav .nav-btn.activo::after { animation: wsNavPulsoX 1.8s var(--ws-ease) infinite; }
  .modal-backdrop:not(.oculto) { animation: wsBackdropIn 240ms var(--ease-sa) both; will-change: opacity; }
  .modal-backdrop:not(.oculto) .modal-panel { animation: wsPanelPop 260ms var(--ws-ease) both; will-change: transform, opacity; }
  #toast-container .toast.visible { animation: wsToastIn 260ms var(--ws-ease); }
  #toast-container .toast {
    transition: opacity 240ms var(--ws-ease), transform 240ms var(--ws-ease),
      background-color 240ms var(--ws-ease);
  }
}

@media (min-width: 1024px) and (prefers-reduced-motion: no-preference) {
  #app-root #bottom-nav .nav-btn.activo::after { animation-name: wsNavPulsoY; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  html body * { scroll-behavior: auto; }
  html body .view *, html body .view > *, html body .dash-kpis > *,
  html body .lista > *, html body tbody tr, html body .modal-backdrop,
  html body .modal-panel, html body .toast, html body .nav-btn::after {
    animation: none;
    transition: none;
  }
}

/* Acciones del panel de campana: marcar y vaciar sin destruir los avisos. */
#panel-notificaciones .notificaciones-acciones {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .5rem;
  padding: .25rem .8rem .9rem;
}
#panel-notificaciones .notificaciones-acciones .btn {
  width: 100%;
  min-height: 44px;
  font-size: .72rem;
  padding: .55rem .35rem;
}
@media (max-width: 359px) {
  #panel-notificaciones .notificaciones-acciones { grid-template-columns: 1fr; }
}

/* Las reglas compactas solo aplican en móvil: en PC las etiquetas van completas. */
@media (max-width: 1023px) {
/* Seis entradas en la nav de rubros con módulos propios. */
#app-root #bottom-nav .nav-inner--seis { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 2px; }
#app-root #bottom-nav .nav-inner--seis .nav-btn { padding-inline: 2px; }
#app-root #bottom-nav .nav-inner--seis .nav-btn span { font-size: .58rem; }

/* Siete y ocho entradas mantienen la barra completa sin recortes en 390 px. */
#app-root #bottom-nav .nav-inner--siete,
#app-root #bottom-nav .nav-inner--ocho { gap: 1px; padding-inline: .2rem; }
#app-root #bottom-nav .nav-inner--siete { grid-template-columns: repeat(7, minmax(0, 1fr)); }
#app-root #bottom-nav .nav-inner--ocho { grid-template-columns: repeat(8, minmax(0, 1fr)); }
#app-root #bottom-nav .nav-inner--siete .nav-btn,
#app-root #bottom-nav .nav-inner--ocho .nav-btn { padding-inline: 1px; gap: .1rem; }
#app-root #bottom-nav .nav-inner--siete .nav-btn span,
#app-root #bottom-nav .nav-inner--ocho .nav-btn span {
  font-size: .48rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#app-root #bottom-nav .nav-inner--siete .nav-btn i,
#app-root #bottom-nav .nav-inner--ocho .nav-btn i { font-size: .9rem; }
}

/* Escritorio: riel autoajustable de 274 a 360 px, con etiquetas legibles y sin elipsis. */
@media (min-width: 1024px) {
  #app-root #bottom-nav .nav-inner--seis,
  #app-root #bottom-nav .nav-inner--siete,
  #app-root #bottom-nav .nav-inner--ocho { display: flex; gap: .4rem; padding: 88px .75rem 1rem; }
  #app-root #bottom-nav .nav-btn { padding: .8rem 1rem; gap: .75rem; min-height: 48px; }
  #app-root #bottom-nav .nav-btn span {
    font-size: .8rem; max-width: none; overflow: visible;
    text-overflow: clip; white-space: normal; line-height: 1.25;
  }
  #app-root #bottom-nav .nav-btn i { font-size: 1rem; }
}

/* ---------- Responsive v32: 320–1920 px sin desbordes ni solapes ---------- */
@media (max-width: 1023px) {
  #app-root #app-content,
  #app-root #app-content.sa-main,
  #app-root #app-header .header-inner {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  #app-root #app-content,
  #app-root #app-content.sa-main {
    padding-inline: 12px;
    margin-inline: 0;
  }
  /* El header de negocio es fijo (68 px): el contenido nunca queda recortado
     debajo de él. El login y la reserva no llevan este header y se excluyen. */
  html body #app-root .client-shell > #app-content.shell-contenido {
    padding-top: calc(var(--header-h, 68px) + 16px) !important;
    scroll-margin-top: calc(var(--header-h, 68px) + 16px);
  }
  #app-root #app-content > .view,
  #app-root #app-content > section,
  #app-root #app-content .vista-superadmin {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-inline: 0;
    padding-inline: 12px;
  }
  #app-root #app-content table:not(.tabla-movil):not(.sa-logs-tabla) {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  #app-root :is(.card, [class*="tarjeta"], [class*="panel"], [class*="kpi"], .btn) {
    flex-wrap: wrap;
    min-width: 0;
    max-width: 100%;
    word-break: normal;
    overflow-wrap: break-word;
  }
  #app-root :is(form, .sa-acciones-export, .sa-logs-acciones, [class*="filtros"], [class*="toolbar"]) {
    flex-wrap: wrap;
    min-width: 0;
    max-width: 100%;
  }
  #app-root #app-header .header-inner {
    align-items: center;
    column-gap: .4rem;
  }
  #app-root #app-header .header-acciones {
    min-width: 0;
    flex-wrap: nowrap;
    flex: 0 0 auto;
  }
  #app-root #app-header .header-texto h1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #app-root #app-header .header-nombre-linea,
  #app-root #app-header .header-subfila {
    min-width: 0;
    flex-wrap: nowrap;
  }
  #app-root #app-header .suscripcion-badge { display: none; }
}

@media (max-width: 639px) {
  /* Las tarjetas se apilan; las rejillas de KPIs se gestionan como grid de 2 columnas más abajo. */
  #app-root #app-content :is(.card, [class*="tarjeta"], [class*="panel"]) {
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  #app-root #app-content :is(.sa-paneles-resumen, .sa-grid) {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
  #app-root #app-content :is(.sa-paneles-resumen, .sa-grid) > * {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
}

/* Listas y tarjetas repetitivas: el navegador omite pintado fuera del viewport. */
#app-root .lista > *,
#app-root .notificacion-item,
#app-root .item-ticket,
#app-root .dash-kpis > *,
#app-root .dash-kpi,
#app-root .hel-producto,
#app-root .inv-fila,
#app-root .pista-lista > *,
#app-root .sa-metrica,
#app-root .sa-avisos-lista > *,
#app-root .sa-notif-item,
#app-root .sa-auditoria-fila,
#app-root .sa-panel,
#app-root .card {
  content-visibility: auto;
  contain-intrinsic-size: auto 72px;
}

/* Accesos rápidos (Avisos / Soporte / Ayuda) siempre arriba del drawer móvil.
   Estructura esperada: <button><span class="acceso-icono">…</span>
   <span class="acceso-etiqueta">…</span><span class="badge-drawer">…</span></button>. */
.nav-accesos-movil, .sa-accesos-movil { display: none; }
@media (max-width: 1023px) {
  .nav-accesos-movil, .sa-accesos-movil {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px !important; min-width: 0; max-width: 100%;
    padding: .6rem !important;
    border-bottom: 1px solid var(--borde, #DCE6F0);
  }
  /* Icono arriba, etiqueta completa abajo y badge en la esquina: sin elipsis. */
  html body #app-root :is(.nav-accesos-movil, .sa-accesos-movil) button {
    position: relative; box-sizing: border-box;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; width: 100%; min-width: 0; min-height: 58px;
    padding: 7px 4px !important;
    border: 1px solid var(--borde, #DCE6F0); border-radius: 12px;
    background: var(--superficie, #fff); color: var(--texto, #0E1B2A);
    font-size: 11px; font-weight: 800; line-height: 1.15; text-align: center;
    cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
    transition: transform 180ms var(--ws-ease), opacity 180ms var(--ws-ease),
      background-color 180ms var(--ws-ease);
  }
  html body #app-root :is(.nav-accesos-movil, .sa-accesos-movil) button:active:not(:disabled) {
    transform: translate3d(0, 1px, 0); opacity: .88;
  }
  html body #app-root :is(.nav-accesos-movil, .sa-accesos-movil) button > :is(.acceso-icono, i) {
    display: grid; place-items: center;
    width: 22px; height: 22px; flex: 0 0 22px;
    font-size: .95rem; line-height: 1;
  }
  html body #app-root :is(.nav-accesos-movil, .sa-accesos-movil) button > span.acceso-etiqueta,
  html body #app-root :is(.nav-accesos-movil, .sa-accesos-movil)
    button > span:not(.badge-drawer):not(.acceso-icono) {
    display: block !important;
    -webkit-line-clamp: unset !important;
    -webkit-box-orient: horizontal !important;
    max-width: 100%; overflow: visible; text-overflow: clip;
    white-space: nowrap; font-size: 11px; letter-spacing: -.01em;
  }
  /* El botón de ayuda hereda estilos propios: se alinea al mismo patrón. */
  html body #app-root :is(.nav-accesos-movil, .sa-accesos-movil) button.ayuda-shell-btn {
    gap: 4px; width: 100%; font-size: 11px; padding: 7px 4px !important;
  }
  .badge-drawer {
    position: absolute; top: 4px; right: 5px; z-index: 1; pointer-events: none;
    min-width: 18px; height: 18px; padding: 0 4px;
    display: grid; place-items: center; border-radius: 999px;
    background: #D92D20; color: #fff; font-size: .62rem; font-weight: 900; line-height: 1;
    box-shadow: 0 0 0 2px var(--superficie, #fff);
  }
  #app-header .header-inner { min-height: 56px; max-height: 56px; align-items: center; flex-wrap: nowrap; }
  #app-header .header-subfila { display: none; }
  #app-header .header-nombre-linea h1 { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sa-topbar { height: 56px; min-height: 56px; max-height: 56px; }
  .sa-topbar-inner { flex-wrap: nowrap; min-height: 56px; align-items: center; }
  .sa-topbar-inner > strong { font-size: .82rem; }
}

/* ---------- Pulido móvil v36 · 320–480 px, extensible a 768/1023 ---------- */
@media (max-width: 640px) {
  /* Jerarquía: el título de la vista crece, el del header se mantiene en una línea. */
  #app-root #app-content :is(h1, .bat-titulo, .g2-titulo, .sa-titulo,
    .unas-hero-titulo, .pista-hero h1, .caja-saludo h2, .hel-titulo) {
    font-size: clamp(1.25rem, 5vw, 1.55rem);
    line-height: 1.2;
  }
  #app-root #app-content :is(.sa-subtitulo, .g2-subtitulo, .bat-copy, .bar-hero p,
    .ag-ayuda, .unas-hero-copy, .hel-copy) {
    font-size: .85rem;
    line-height: 1.45;
  }
  /* Valores KPI: cifras tabulares y salto de línea controlado. */
  #app-root #app-content :is(.dash-kpi strong, .caja-metricas strong, .sa-metrica-valor,
    .sa-seg-kpi-valor, .g2-kpi-valor, .bat-kpi strong, .metrica strong,
    .pista-kpis strong, .hist-totales strong, .rep-kpi strong, .unas-kpi strong,
    .ag-dato strong) {
    font-size: clamp(1.25rem, 5.5vw, 1.6rem);
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
  }
  #app-root #app-content :is(.dash-kpi strong, .sa-metrica-valor, .sa-seg-kpi-valor,
    .metrica strong, .pista-kpis strong) {
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Tarjetas: mismo ritmo en las siete plantillas y en la plataforma. */
  #app-root #app-content :is(.card, .dash-kpi, .sa-metrica, .sa-seg-kpi, .sa-panel,
    .sa-tenant, .sa-aviso, .sa-seg-card, .g2-card, .g2-kpi, .bat-kpi,
    .ag-card, .metrica, .rep-kpi, .unas-kpi, .hist-resumen, .tasa-card,
    .pos-orden, .caja-form-card, .tarjeta-pista, .inv-fila, .hel-producto,
    .ag-item, .g2-tarjeta) {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 14px;
    gap: 10px;
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(10, 37, 64, .06), 0 10px 24px -18px rgba(10, 37, 64, .32);
  }

  /* KPIs cortos en dos columnas; bloques anchos a una sola columna. */
  #app-root #app-content :is(.dash-kpis, .sa-metricas, .sa-seg-kpis, .pista-kpis,
    .caja-metricas, .g2-kpis, .bat-dash-kpis, .bat-rep-kpis, .rep-cuadre-valores,
    .unas-kpis, .hist-totales, .bat-metodos-resumen) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
    max-width: 100%;
  }
  #app-root #app-content :is(.dash-panel-doble, .sa-grid, .sa-paneles-resumen,
    .sa-catalogo, .sa-seg-lista, .bat-dash-grid, .bat-dash-encargos,
    .g2-rejilla, .g2-rejilla--amplia, .rest-comandas, .ag-config-grid,
    .ag-wa-layout, .pos-layout) {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 100%;
  }
  #app-root #app-content :is(.dash-kpis, .sa-metricas, .sa-seg-kpis, .pista-kpis,
    .caja-metricas, .g2-kpis, .bat-dash-kpis, .bat-rep-kpis, .rep-cuadre-valores,
    .unas-kpis, .hist-totales, .sa-grid, .sa-paneles-resumen, .dash-panel-doble) > * {
    min-width: 0;
    max-width: 100%;
  }

  /* Botones principales y campos: objetivos táctiles y sin zoom en iOS. */
  #app-root #app-content :is(.btn-primario, .btn-oscuro, .btn-suave,
    .btn-cobrar-pos, .caja-registrar, .orden-cobrar, .avanzar, .tasa-guardar,
    .g2-btn-mini--principal, .bat-accion-principal, .sa-seg-acciones .btn),
  #modales-root :is(.modal-acciones .btn, .confirm-acciones .btn) {
    box-sizing: border-box;
    min-height: 44px;
    padding: 10px 14px;
    border-radius: 12px;
    font-weight: 800;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  #app-root :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]), select, textarea),
  #modales-root :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]), select, textarea) {
    box-sizing: border-box;
    max-width: 100%;
    font-size: 16px;
  }
  #app-root input[type="time"], #modales-root input[type="time"] {
    width: 100%;
    min-width: 128px;
    max-width: 100%;
    min-height: 44px;
    font-size: 16px;
  }
}

@media (max-width: 1023px) {
  /* Drawer: la lista se desplaza suave y el pie queda siempre visible. */
  #app-root #bottom-nav .nav-inner,
  #app-root #nav-superadmin .sa-nav,
  #app-root .sa-sidebar .sa-nav {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    min-width: 0;
  }
  #app-root #bottom-nav .nav-pie,
  #app-root .sa-sidebar .sa-sidebar-pie {
    position: sticky;
    bottom: 0;
    z-index: 2;
    flex: 0 0 auto;
    box-shadow: 0 -10px 24px -20px rgba(4, 18, 32, .8);
  }
  #app-root #bottom-nav .nav-btn,
  #app-root .sa-sidebar .sa-nav-btn,
  #app-root #app-content :is(button, a[role="button"], [role="button"]) {
    touch-action: manipulation;
  }
  #app-root #app-content :is(.view, form, [class*="layout"], [class*="grid"],
    [class*="lista"], [class*="toolbar"], [class*="filtros"]) {
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
  }
}

/* ---------- Cierre de Caja (Hoy) + tasa 1 USD = … Bs ---------- */
/* PC: la tasa y el botón comparten la misma fila, alineados a la derecha. */
@media (min-width: 641px) {
  #app-root #app-content :is(.hel-hero-lado, .bat-hero-lado, .bar-hero-lado,
    .dash-cabecera-acciones) {
    display: flex; flex-direction: row; align-items: center; justify-content: flex-end;
    gap: 8px; flex-wrap: nowrap; min-width: 0; max-width: 100%;
  }
  #app-root #app-content :is(.hel-tasa, .bat-tasa, .bar-tasa, .dash-reloj,
    .g2-hora--tasa) { white-space: nowrap; }
  #app-root #app-content :is([data-accion="cierre-caja"], .btn-cierre-pos,
    .dash-btn-cierre) { flex: 0 0 auto; white-space: nowrap; }
}

/* Móvil: el contenedor reparte todo el ancho disponible, sin botones sueltos. */
@media (max-width: 640px) {
  #app-root #app-content :is(.hel-hero, .bat-hero, .dash-cabecera) { flex-wrap: wrap; }
  #app-root #app-content :is(.hel-hero-lado, .bat-hero-lado, .bar-hero-lado,
    .dash-cabecera-acciones) {
    display: flex; flex-direction: row; align-items: center; justify-content: space-between;
    gap: 8px; width: 100%; min-width: 0; max-width: 100%; box-sizing: border-box;
    flex-wrap: nowrap;
  }
  #app-root #app-content :is(.hel-hero-lado, .bat-hero-lado, .bar-hero-lado,
    .dash-cabecera-acciones) :is([data-accion="cierre-caja"], .btn, .dash-cierre) {
    position: static; float: none; margin-left: 0; flex: 0 1 auto; min-width: 0;
  }
  #app-root #app-content :is(.hel-tasa, .bat-tasa, .bar-tasa, .dash-reloj,
    .g2-hora--tasa) { white-space: nowrap; }
}

