/* El contenido nunca puede ser más ancho que la pantalla (los chips y las tablas scrollean por dentro) */
[hidden] { display: none !important; }
.contenido { grid-template-columns: minmax(0, 1fr); }
.contenido > * { min-width: 0; }

/* Carrito en el encabezado (todas las pantallas) */
.cart-top { position: relative; display: inline-grid; place-items: center; width: 46px; height: 46px; border-radius: 12px;
  border: 1px solid var(--azul); margin-left: 8px; }
.top .lema + .cart-top, .top .buscador-top + .cart-top { margin-left: 0; }
.cart-top svg { width: 26px; height: 26px; fill: var(--azul); }
.cart-badge { position: absolute; top: -7px; right: -7px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px;
  background: var(--azul2); color: #fff; font-size: .75rem; font-style: normal; font-weight: 600; display: grid; place-items: center; }
.cart-badge[hidden] { display: none; }
.buscador-top { flex: 1; max-width: 520px; margin-left: auto; }
.buscador-top input { width: 100%; height: 42px; border-radius: 99px; padding: 0 18px; }
.buscador-top + .cart-top { margin-left: 8px; }

/* Barra inferior del cliente (solo celular) */
.nav-inferior { display: none; }
.acciones-inicio { display: flex; gap: 12px; flex-wrap: wrap; }
.acciones-inicio a { margin: 0; }

@media (max-width: 768px) {
  /* Encabezado compacto */
  .top { padding: 8px 12px; gap: 10px; box-shadow: 0 2px 14px rgba(0,140,255,.35); }
  .top img { height: 40px; }
  .usuario span { display: none; }
  body.cliente .usuario { display: none; }
  body.cliente .cart-top { display: none; }          /* el cliente usa la barra inferior */
  .buscador-top { margin-left: 0; max-width: none; }

  /* Contenido */
  .contenido { padding: 14px 12px; gap: 16px; }
  body.cliente .contenido { padding-bottom: 92px; }
  h1 { font-size: 1.35rem; }
  input, select, textarea { font-size: 16px; }       /* evita el zoom automático en iPhone */
  body.cliente .lateral { display: none; }

  /* Tienda: dos columnas, estilo marketplace */
  .barra { gap: 10px; margin: 0 -12px 12px; padding: 10px 12px; }
  .barra input[type=search] { min-width: 100%; height: 44px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .chips::-webkit-scrollbar { display: none; }
  .chip-f { flex: 0 0 auto; white-space: nowrap; }
  .grilla { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .prod { border-radius: 14px; }
  .prod:hover { transform: none; }
  .foto { flex-basis: 128px; height: 128px; }
  .info { padding: 10px 12px 4px; }
  .precio { font-size: 1.2rem; }
  .info h3 { font-size: .9rem; margin: 4px 0; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .stk { font-size: .78rem; }
  .prod .agregar { margin: 8px 10px 12px; height: 38px; font-size: .85rem; }
  .medalla { font-size: .68rem; padding: 3px 9px; top: 8px; left: 8px; }
  #toast { bottom: 84px; max-width: 92vw; text-align: center; }

  /* Inicio del cliente */
  .acciones-inicio a { flex: 1 1 100%; }
  body.cliente .acciones-inicio { display: none; }

  /* Carrito */
  .item { grid-template-columns: 76px 1fr; padding: 12px; }
  .foto-i { width: 76px; height: 76px; }
  .sub-i { grid-column: 2; justify-self: end; margin-top: -4px; }
  .resumen-carrito { position: sticky; bottom: 76px; z-index: 5; border-radius: 16px; box-shadow: 0 -8px 24px rgba(0,0,0,.45); padding: 16px; gap: 10px; }
  .resumen-carrito h2, .resumen-carrito .enlace-seguir { display: none; }
  .resumen-carrito #comprar { height: 50px; }

  /* Pago a pantalla completa */
  #dlg-compra { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; border: 0; padding: 20px 16px;
    overflow-y: auto; }
  #dlg-compra .form-grid { grid-template-columns: 1fr; }
  #dlg-compra .btn-pri, #dlg-compra .btn-sec { height: 52px; width: 100%; }
  #dlg-editar { padding: 20px 16px; }
  .lema { display: none; }

  /* Barra inferior */
  body.cliente .nav-inferior { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: rgba(2,10,24,.96); backdrop-filter: blur(8px); border-top: 1px solid var(--azul2);
    padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 20px rgba(0,140,255,.3); }
  .nav-inferior a { position: relative; display: grid; justify-items: center; gap: 2px; padding: 9px 4px 8px; color: var(--suave);
    text-decoration: none; font-size: .68rem; white-space: nowrap; }
  .nav-inferior svg { width: 25px; height: 25px; fill: currentColor; }
  .nav-inferior a.activo { color: var(--azul); }
  .nav-inferior .cart-badge { top: 3px; right: calc(50% - 26px); }
  .t-pc { display: none; }
}
@media (min-width: 769px) { .t-movil { display: none; } }

/* ===== Administradores y empleados en el celular ===== */
@media (max-width: 768px) {
  body:not(.cliente) .cart-top { display: none; }
  body:not(.cliente) .usuario a { padding: 10px 6px; font-weight: 600; }
  body:not(.cliente) .top { position: sticky; top: 0; z-index: 25; }

  /* Menú: franja con iconos que se desliza al costado, siempre a mano */
  body:not(.cliente) .lateral { display: flex; flex-wrap: nowrap; gap: 4px; overflow-x: auto; padding: 6px 8px;
    position: sticky; top: 57px; z-index: 24; background: rgba(2,10,24,.97); border-bottom: 1px solid var(--borde);
    scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  body:not(.cliente) .lateral::-webkit-scrollbar { display: none; }
  body:not(.cliente) .lateral a { flex: 0 0 auto; flex-direction: column; gap: 3px; min-width: 72px; padding: 8px 10px;
    border-radius: 12px; font-size: .72rem; line-height: 1.15; text-align: center; white-space: nowrap; }
  body:not(.cliente) .lateral a:hover { padding: 8px 10px; }
  body:not(.cliente) .lateral svg { width: 24px; height: 24px; }

  /* Todo en una columna y sin cortes por el costado */
  body:not(.cliente) .contenido { padding: 14px 12px 28px; gap: 16px; }
  body:not(.cliente) .caja { padding: 16px; border-radius: 14px; }
  body:not(.cliente) .form-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  body:not(.cliente) .form-grid > * { min-width: 0; }
  body:not(.cliente) input, body:not(.cliente) select { width: 100%; max-width: 100%; }
  body:not(.cliente) .btn-pri, body:not(.cliente) .btn-sec { min-height: 46px; }
  body:not(.cliente) .filtros > * { flex: 1 1 100%; min-width: 0 !important; }
  body:not(.cliente) .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
  body:not(.cliente) .tabs::-webkit-scrollbar { display: none; }
  body:not(.cliente) .tabs a, body:not(.cliente) .tabs button { flex: 0 0 auto; white-space: nowrap; }
  body:not(.cliente) .tabs .btn-pri { margin-left: 0; }
  body:not(.cliente) .grafico, body:not(.cliente) .grafico-inicio { height: 260px; }
  body:not(.cliente) .pie { justify-content: center; text-align: center; }
  body:not(.cliente) .paginas { flex-wrap: wrap; justify-content: center; }
  body:not(.cliente) dialog { width: 100vw; max-width: 100vw; max-height: 100dvh; margin: 0; border-radius: 0; overflow-y: auto; padding: 20px 16px; }
  body:not(.cliente) #dlg-editar { width: 100vw; padding: 20px 16px; max-height: 100dvh; }
  body:not(.cliente) .notif-pila { top: 8px; bottom: auto; right: 8px; width: calc(100vw - 16px); }
  body:not(.cliente) #toast-stock { bottom: 20px; max-width: 92vw; text-align: center; }

  /* Tablas -> una tarjeta por fila (los rótulos los pone panel_movil.js) */
  body:not(.cliente) .tabla-wrap { overflow: visible; }
  body:not(.cliente) .tabla-wrap table, body:not(.cliente) .tabla-wrap tbody { display: block; width: 100%; }
  body:not(.cliente) .tabla-wrap thead { display: none; }
  body:not(.cliente) .tabla-wrap tr { display: block; margin-bottom: 12px; padding: 6px 14px; background: rgba(4,15,32,.6);
    border: 1px solid var(--borde); border-radius: 14px; }
  body:not(.cliente) .tabla-wrap td { display: flex; justify-content: space-between; align-items: center; gap: 14px;
    padding: 9px 0; border-top: 1px dashed #12335b; text-align: right; overflow-wrap: anywhere; }
  body:not(.cliente) .tabla-wrap td:first-child { border-top: 0; }
  body:not(.cliente) .tabla-wrap td[data-label]::before { content: attr(data-label); flex: 0 0 auto; color: var(--suave);
    font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; text-align: left; }
  body:not(.cliente) .tabla-wrap td.acciones { justify-content: flex-end; flex-wrap: wrap; }
  body:not(.cliente) .tabla-wrap td.acciones::before { display: none; }
  body:not(.cliente) .tabla-wrap td.vacio { display: block; text-align: center; }
  body:not(.cliente) .tabla-wrap td select { width: auto; max-width: 60vw; }
  body:not(.cliente) .tabla-wrap .thumb { margin-right: 8px; }
  body:not(.cliente) .ico { min-width: 44px; height: 42px; }
}
