/* ============================================================
   TGA POS — Diseño táctil para celular y tablet (≤ 1180 px)
   Referencia: encabezado oscuro con órdenes activas, pestañas tipo píldora,
   catálogo en tarjetas con foto, orden con − / +, botón negro de pago y estadísticas.
   El color de acento es el del negocio (--color-primary-500). El escritorio no cambia.
   ============================================================ */

:root {
  --mv-tinta: #111214;
  --mv-tinta-2: #1d1f23;
  --mv-papel: #ffffff;
  --mv-lienzo: #f2f3f5;
  --mv-pista: #eceef1;
  --mv-texto-suave: #8a8f98;
  --mv-radio: 18px;
  --mv-radio-sm: 12px;
  --mv-sombra: 0 1px 2px rgba(17, 18, 20, 0.04), 0 6px 18px rgba(17, 18, 20, 0.06);
  --mv-acento: var(--color-primary-500);
  --mv-acento-suave: color-mix(in srgb, var(--color-primary-500) 12%, #ffffff);
}

/* Elementos que solo existen en la vista táctil */
.movil-encabezado,
.movil-pestanas,
.mo-cabecera,
.mo-contexto,
.mo-resumen-titulo,
.mo-productos-titulo,
.dish-thumb,
.dish-quitar,
.me-cerrar-busqueda {
  display: none;
}

@media (max-width: 1180px) {
  /* ---------------- Encabezado oscuro con órdenes activas ---------------- */
  body[data-vista="comandero"] .movil-encabezado,
  body[data-vista="mesas"] .movil-encabezado {
    display: block;
    background: var(--mv-tinta);
    background-image:
      radial-gradient(120% 80% at 100% 0%, rgba(255, 255, 255, 0.06), transparent 60%),
      repeating-radial-gradient(circle at 85% -20%, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 14px);
    color: #ffffff;
    padding: 14px 16px 18px;
    flex-shrink: 0;
  }

  body[data-vista="comandero"] .tga-topbar,
  body[data-vista="mesas"] .tga-topbar {
    display: none;
  }

  .me-fila { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

  .me-usuario {
    display: inline-flex; align-items: center; gap: 10px; min-width: 0;
    background: none; border: none; color: inherit; padding: 4px 4px 4px 0; cursor: pointer; font: inherit;
  }

  .me-avatar {
    width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
    display: grid; place-items: center;
    background: var(--mv-acento); color: #ffffff; font-weight: 800; font-size: 0.82rem;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85);
  }

  .me-nombre { font-weight: 700; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .me-acciones { display: flex; gap: 8px; }

  .me-icono {
    width: 32px; height: 32px; border-radius: 50%;
    display: grid; place-items: center;
    background: transparent; color: #ffffff; cursor: pointer;
    border: 1.5px solid rgba(255, 255, 255, 0.55);
  }

  .me-icono svg { width: 15px; height: 15px; }
  .me-icono:hover, .me-icono:focus-visible { background: rgba(255, 255, 255, 0.12); outline: none; }

  .me-titulo-fila { display: flex; justify-content: space-between; align-items: baseline; margin: 18px 0 10px; }
  .me-titulo { margin: 0; font-size: 1rem; font-weight: 700; color: #ffffff; }
  .me-vertodas { background: none; border: none; color: rgba(255, 255, 255, 0.7); font: inherit; font-size: 0.8rem; cursor: pointer; padding: 4px 0; }

  .me-ordenes {
    display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x proximity;
    margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none;
  }

  .me-ordenes::-webkit-scrollbar { display: none; }

  .me-orden {
    flex: 0 0 auto; width: 156px; min-height: 92px;
    display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
    padding: 12px; border-radius: 14px; border: 2px solid transparent;
    background: var(--mv-papel); color: var(--mv-tinta); text-align: left; cursor: pointer;
    scroll-snap-align: start; font: inherit;
  }

  .me-orden.activa { border-color: var(--mv-acento); }
  .me-orden:focus-visible { outline: 2px solid #ffffff; outline-offset: 2px; }
  .me-orden-nombre { font-weight: 700; font-size: 0.92rem; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .me-orden-meta { font-size: 0.7rem; color: var(--mv-texto-suave); }

  .me-estado {
    margin-top: auto; padding: 3px 9px; border-radius: 999px;
    font-size: 0.66rem; font-weight: 700; color: #ffffff; white-space: nowrap;
  }

  .me-estado.lista { background: #0f766e; }
  .me-estado.preparando { background: #d97706; }
  .me-estado.espera { background: #f08a5d; }
  .me-estado.cuenta { background: #2563eb; }
  .me-vacio { margin: 0; font-size: 0.82rem; color: rgba(255, 255, 255, 0.7); }

  /* Búsqueda: la barra superior aparece sola, encima del encabezado */
  body.me-buscando .tga-topbar {
    display: flex !important;
    position: fixed; inset: 0 0 auto 0; z-index: 1150;
    height: 64px; padding: 0 12px; background: var(--mv-papel);
    box-shadow: 0 6px 20px rgba(17, 18, 20, 0.12);
  }

  body.me-buscando .tga-topbar-right,
  body.me-buscando .tga-page-title { display: none !important; }
  body.me-buscando .tga-topbar-left { flex: 1; gap: 8px; }
  body.me-buscando .tga-global-search { display: flex !important; flex: 1; max-width: none; height: 42px; border-radius: 999px; }
  body.me-buscando .me-cerrar-busqueda {
    display: inline-flex; background: none; border: none; font: inherit; font-weight: 700;
    color: var(--mv-acento); padding: 8px 4px; cursor: pointer;
  }

  /* ---------------- Barra de acciones del POS como fichas desplazables ---------------- */
  body[data-vista="comandero"] .pos-context-strip,
  body[data-vista="mesas"] .pos-context-strip {
    padding: 10px 16px 0; border-bottom: none; background: transparent;
  }

  .pos-context-strip .crumb-block { flex-wrap: nowrap; width: 100%; gap: 10px; }
  .pos-context-strip .crumb-block > div:first-child { display: none; }

  .pos-context-strip .foh-quick-actions {
    display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 8px; scrollbar-width: none; width: 100%;
  }

  .pos-context-strip .foh-quick-actions::-webkit-scrollbar { display: none; }

  .pos-context-strip .foh-mini-btn {
    flex: 0 0 auto; height: 34px; padding: 0 12px; border-radius: 999px;
    background: var(--mv-papel); border: 1px solid var(--border-default); white-space: nowrap;
  }

  /* ---------------- Pestañas tipo píldora ---------------- */
  body[data-vista="comandero"] .movil-pestanas:not([hidden]) {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
    margin: 12px 16px 4px; padding: 4px; border-radius: 999px; background: var(--mv-pista);
  }

  .movil-pestanas button {
    height: 40px; border: none; border-radius: 999px; background: transparent;
    font: inherit; font-size: 0.88rem; font-weight: 600; color: var(--mv-texto-suave); cursor: pointer;
  }

  .movil-pestanas button[aria-selected="true"] {
    background: var(--mv-acento, var(--color-primary-500)) !important;
    color: #ffffff !important;
    font-weight: 700;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--color-primary-500) 35%, transparent) !important;
  }

  .movil-pestanas button:focus-visible { outline: 2px solid var(--mv-acento); outline-offset: 1px; }

  body[data-vista="comandero"] .category-pills-bar {
    padding: 8px 16px;
    gap: 8px;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  body[data-vista="comandero"] .category-pills-bar::-webkit-scrollbar { display: none; }

  body[data-vista="comandero"] .category-oval-tab {
    min-height: 38px;
    padding: 8px 16px;
    font-size: 0.84rem;
    font-weight: 600;
    border-radius: 999px;
    border: 1px solid var(--border-default);
    background: var(--mv-papel, #ffffff);
    color: var(--mv-texto-suave, #64748b);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.16s ease;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
  }

  body[data-vista="comandero"] .category-oval-tab:active {
    transform: scale(0.96);
  }

  body[data-vista="comandero"] .category-oval-tab.active {
    background: var(--mv-acento, var(--color-primary-500)) !important;
    border-color: var(--mv-acento, var(--color-primary-500)) !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    box-shadow: 0 3px 10px color-mix(in srgb, var(--color-primary-500) 40%, transparent) !important;
  }

  body[data-vista="comandero"] .category-oval-tab[data-cat-id="populares"].active {
    background: #f59e0b !important;
    border-color: #f59e0b !important;
    color: #ffffff !important;
    box-shadow: 0 3px 10px rgba(245, 158, 11, 0.4) !important;
  }

  /* ---------------- Catálogo: tarjetas con foto ---------------- */
  body[data-vista="comandero"] .marble-floor-section { padding: 8px 16px 96px; background: var(--mv-lienzo); }
  body[data-vista="comandero"] .marble-section-title { font-size: 1rem; font-weight: 700; margin-bottom: 10px; }

  body[data-vista="comandero"] #mesas-plates-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px;
  }

  body[data-vista="comandero"] .product-catalog-card {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "foto foto" "nombre nombre" "desc desc" "stock precio";
    align-items: end; gap: 4px 8px;
    padding: 0 0 12px; border: none; border-radius: var(--mv-radio);
    background: var(--mv-papel); box-shadow: var(--mv-sombra); overflow: hidden; min-height: 0;
  }

  body[data-vista="comandero"] .product-catalog-card .product-card-top-row,
  body[data-vista="comandero"] .product-catalog-card .product-card-bottom,
  body[data-vista="comandero"] .product-catalog-card .plate-footer-row { display: contents; }

  body[data-vista="comandero"] .product-catalog-card .dish-photo-banner {
    grid-area: foto; margin: 0 0 6px; height: auto; aspect-ratio: 4 / 3; border-radius: 0; overflow: hidden;
  }

  body[data-vista="comandero"] .product-catalog-card .dish-photo-banner img { width: 100%; height: 100%; object-fit: cover; display: block; }

  body[data-vista="comandero"] .product-catalog-card .plate-name {
    grid-area: nombre; padding: 0 12px; font-size: 0.9rem !important; font-weight: 700 !important; line-height: 1.25;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }

  body[data-vista="comandero"] .product-catalog-card .plate-meta-text {
    grid-area: desc; padding: 0 12px; font-size: 0.72rem; color: var(--mv-texto-suave);
    white-space: normal !important; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  }

  body[data-vista="comandero"] .product-catalog-card .plate-stock-badge {
    grid-area: stock; margin-left: 12px; justify-self: start; padding: 0 !important;
    background: none !important; border: none !important; color: var(--mv-texto-suave) !important;
    font-size: 0.7rem; font-weight: 600 !important;
  }

  body[data-vista="comandero"] .product-catalog-card .plate-price-tag {
    grid-area: precio; padding: 0 12px 0 0; font-size: 1rem; font-weight: 800; color: var(--mv-acento); white-space: nowrap;
  }

  body[data-vista="comandero"] .product-catalog-card .plate-price-tag small,
  body[data-vista="comandero"] .product-catalog-card .product-area-pill,
  body[data-vista="comandero"] .product-catalog-card .plate-footer-row > span:last-child { display: none; }

  body[data-vista="comandero"] .product-catalog-card:active { transform: scale(0.98); }

  /* La tarjeta recorta con overflow:hidden: el globito de cantidad va dentro de la esquina, no fuera */
  body[data-vista="comandero"] .product-catalog-card .plate-ticket-qty-badge { top: 8px; left: 8px; }

  /* ---------------- Panel de la orden (estilo de la segunda pantalla) ---------------- */
  .navy-comanda-sidebar { background: var(--mv-papel); }
  .navy-comanda-sidebar > * { flex-shrink: 0; }

  .navy-comanda-sidebar .mo-cabecera {
    display: grid; grid-template-columns: 40px 1fr 40px; align-items: center;
    padding: 14px 16px 8px; flex-shrink: 0;
  }

  .mo-volver {
    width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
    border: none; background: var(--mv-pista); color: var(--mv-tinta); cursor: pointer;
  }

  .mo-volver svg { width: 18px; height: 18px; }
  .mo-titulo { margin: 0; text-align: center; font-size: 1.02rem; font-weight: 700; color: var(--mv-tinta); }

  .navy-comanda-sidebar .mo-contexto { display: block; padding: 4px 16px 0; flex-shrink: 0; }

  .mo-segmento:not([hidden]) {
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px;
    border-radius: 999px; background: var(--mv-pista); margin-bottom: 14px;
  }

  .mo-segmento button {
    height: 42px; border: none; border-radius: 999px; background: transparent; cursor: pointer;
    font: inherit; font-size: 0.88rem; font-weight: 600; color: var(--mv-texto-suave);
  }

  .mo-segmento button[aria-pressed="true"] { background: var(--mv-papel); color: var(--mv-tinta); font-weight: 700; box-shadow: var(--mv-sombra); }

  .navy-comanda-sidebar .mo-seccion { display: block; margin: 0 0 8px; font-weight: 700; font-size: 0.92rem; color: var(--mv-tinta); }

  .mo-campo {
    display: flex; align-items: center; justify-content: space-between; width: 100%;
    height: 48px; margin-bottom: 10px; padding: 0 14px; box-sizing: border-box;
    border: 1px solid var(--border-default); border-radius: 14px; background: var(--mv-papel);
    font: inherit; font-size: 0.9rem; color: var(--mv-tinta); text-align: left;
  }

  .mo-campo::placeholder, .mo-mesa:not(.con-valor) span { color: var(--mv-texto-suave); }
  .mo-mesa { cursor: pointer; }
  .mo-mesa[hidden] { display: none; }
  .mo-mesa svg { width: 18px; height: 18px; color: var(--mv-tinta); }
  .mo-campo:focus-visible, .mo-campo:focus { outline: 2px solid var(--mv-acento); outline-offset: 0; border-color: transparent; }

  /* La barra de título original queda solo con comensales */
  .navy-comanda-sidebar .comanda-top-title-bar { padding: 4px 16px 8px; border-bottom: none; }
  .navy-comanda-sidebar .comanda-top-title-bar > div:first-child { display: none; }
  .navy-comanda-sidebar .comanda-top-title-bar > div:last-child { width: 100%; justify-content: space-between; }
  .navy-comanda-sidebar .mobile-drawer-close-btn { display: none !important; }
  .navy-comanda-sidebar .comanda-course-seat-bar { padding: 0 16px 8px; border-bottom: none; }

  /* Líneas de la orden: en táctil se desplaza todo el panel, no solo la lista */
  .navy-comanda-sidebar .mo-productos-titulo { padding: 8px 16px 0; margin-bottom: 0; }
  .navy-comanda-sidebar .comanda-cards-list { padding: 0 16px; gap: 0; flex: none !important; max-height: none !important; overflow: visible !important; }

  .navy-comanda-sidebar .dish-porcelain-item-card {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) auto 40px;
    grid-template-areas: "thumb info info quitar" "thumb total stepper quitar";
    align-items: center; gap: 4px 12px;
    padding: 14px 0; margin: 0; border: none; border-bottom: 1px solid var(--border-subtle);
    border-radius: 0; background: transparent; box-shadow: none;
  }

  .navy-comanda-sidebar .dish-porcelain-item-card.selected-for-mod { background: transparent; box-shadow: none; }

  .navy-comanda-sidebar .dish-thumb {
    display: block; grid-area: thumb; width: 64px; height: 64px; border-radius: 12px; object-fit: cover; background: var(--mv-pista);
  }

  .navy-comanda-sidebar .dish-center-col { grid-area: info; min-width: 0; }
  .navy-comanda-sidebar .dish-title-serif { font-weight: 700; font-size: 0.9rem; }
  .navy-comanda-sidebar .dish-unit-rate { font-size: 0.7rem; color: var(--mv-texto-suave); }
  .navy-comanda-sidebar .dish-total-linea { grid-area: total; color: var(--mv-acento) !important; font-size: 0.98rem !important; }

  .navy-comanda-sidebar .dish-stepper-navy {
    grid-area: stepper; background: transparent; padding: 0; gap: 6px; justify-self: end;
  }

  .navy-comanda-sidebar .dish-stepper-btn {
    width: 32px; height: 32px; border-radius: 50%; font-size: 1.05rem; line-height: 1;
    background: var(--mv-papel); border: 1px solid var(--border-default); color: var(--mv-tinta);
    box-shadow: 0 1px 2px rgba(17, 18, 20, 0.06);
  }

  .navy-comanda-sidebar .dish-stepper-btn[aria-label="Sumar"] { color: var(--mv-acento); border-color: var(--mv-acento-suave); }
  .navy-comanda-sidebar .dish-cant-input { width: 34px; font-size: 0.92rem; }

  .navy-comanda-sidebar .dish-quitar {
    display: grid; place-items: center; grid-area: quitar; align-self: stretch;
    width: 40px; border: none; border-radius: 12px; cursor: pointer;
    background: #fdecec; color: #dc2626;
  }

  .navy-comanda-sidebar .dish-quitar svg { width: 18px; height: 18px; }
  .navy-comanda-sidebar .dish-quitar:focus-visible { outline: 2px solid #dc2626; outline-offset: 1px; }

  /* Resumen y botón de pago */
  .navy-comanda-sidebar .mo-resumen-titulo { padding: 14px 16px 0; margin-bottom: 8px; }

  .navy-comanda-sidebar .comanda-subtotals-box {
    margin: 0 16px; padding: 12px 16px; border-radius: 14px; background: var(--mv-lienzo); border: none;
  }

  .navy-comanda-sidebar .subtotal-row-item { color: var(--mv-texto-suave); font-size: 0.86rem; }
  .navy-comanda-sidebar .subtotal-row-item span:last-child { color: var(--mv-tinta); font-weight: 700; }

  .navy-comanda-sidebar .silver-total-plaque {
    margin: 0; padding: 12px 16px 16px; border: none; border-radius: 0; background: var(--mv-papel); box-shadow: none;
  }

  .navy-comanda-sidebar .plaque-top-label { font-size: 0.72rem; color: var(--mv-texto-suave); letter-spacing: 0; }
  .navy-comanda-sidebar .plaque-gold-digits { color: var(--mv-tinta); }

  .navy-comanda-sidebar .plaque-pill-actions {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px;
  }

  .navy-comanda-sidebar .plaque-pill-actions .action-pill-3d {
    height: 38px; border-radius: 999px; background: var(--mv-papel); border: 1px solid var(--border-default); box-shadow: none;
  }

  .navy-comanda-sidebar .plaque-pill-actions .cobrar-highlight {
    grid-column: 1 / -1; order: 9; height: 54px; border-radius: 999px;
    background: linear-gradient(135deg, #22c55e 0%, #15803d 100%) !important; border-color: transparent !important; color: #ffffff !important;
    box-shadow: 0 6px 16px rgba(22, 163, 74, 0.28) !important;
    font-size: 0.98rem; font-weight: 700;
  }

  .navy-comanda-sidebar .plaque-pill-actions .cobrar-highlight svg { color: #ffffff; }

  /* ---------------- Estadísticas (tercera pantalla) ---------------- */
  .movil-estadisticas:not([hidden]) {
    position: fixed; inset: 0; z-index: 1200; background: rgba(17, 18, 20, 0.35);
    display: flex; justify-content: center; align-items: stretch;
  }

  .mest-hoja {
    width: 100%; max-width: 720px; overflow-y: auto; background: var(--mv-papel);
    padding-bottom: 24px;
  }

  .mest-hoja .mo-cabecera { display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; padding: 14px 16px 8px; }

  .mest-periodos {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 8px 16px 16px; padding: 4px;
    border-radius: 999px; background: var(--mv-pista);
  }

  .mest-periodos button {
    height: 40px; border: none; border-radius: 999px; background: transparent; cursor: pointer;
    font: inherit; font-size: 0.86rem; font-weight: 600; color: var(--mv-texto-suave);
  }

  .mest-periodos button[aria-selected="true"] { background: var(--mv-papel); color: var(--mv-tinta); font-weight: 700; box-shadow: var(--mv-sombra); }

  .mest-total { display: flex; flex-direction: column; gap: 2px; padding: 0 16px 8px; }
  .mest-total span { font-size: 0.78rem; color: var(--mv-texto-suave); }
  .mest-total strong { font-size: 1.6rem; font-weight: 800; color: var(--mv-tinta); letter-spacing: -0.01em; }
  .mest-total small { font-size: 0.74rem; color: var(--mv-texto-suave); }

  .mest-grafico { padding: 0 8px 0 4px; }
  .mest-grafico svg { width: 100%; height: auto; display: block; overflow: visible; }
  .mest-cargando { padding: 48px 16px; text-align: center; color: var(--mv-texto-suave); font-size: 0.86rem; }
  .mest-reja { stroke: var(--border-subtle); stroke-width: 1; }
  .mest-eje { fill: var(--mv-tinta); font-size: 9.5px; }
  .mest-linea { fill: none; stroke: var(--mv-acento); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
  .mest-columna { fill: var(--mv-acento); opacity: 0.12; }
  .mest-punto { fill: var(--mv-acento); stroke: #ffffff; stroke-width: 2; }
  .mest-etiqueta rect { fill: #ffffff; filter: drop-shadow(0 2px 6px rgba(17, 18, 20, 0.12)); }
  .mest-etiqueta text { fill: var(--mv-acento); font-size: 10.5px; font-weight: 700; }

  .mest-tarjetas { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 16px; }

  .mest-tarjeta {
    display: flex; flex-direction: column; gap: 2px; min-height: 132px; padding: 14px;
    border-radius: var(--mv-radio); box-sizing: border-box;
  }

  .mest-tarjeta small { margin-top: auto; font-size: 0.74rem; color: var(--mv-texto-suave); }
  .mest-tarjeta strong { font-size: 1.12rem; font-weight: 800; color: var(--mv-tinta); }
  .mest-tarjeta em { font-style: normal; font-size: 0.68rem; color: var(--mv-texto-suave); }

  .mest-ico { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 18px; }
  .mest-ico svg { width: 19px; height: 19px; }

  .mest-tarjeta.t1 { background: #ecf6f4; } .mest-tarjeta.t1 .mest-ico { background: #cfe7e2; color: #0f766e; }
  .mest-tarjeta.t2 { background: #f6f0fb; } .mest-tarjeta.t2 .mest-ico { background: #e7d8f5; color: #7e22ce; }
  .mest-tarjeta.t3 { background: #fdf3ec; } .mest-tarjeta.t3 .mest-ico { background: #f9dccb; color: #c2410c; }
  .mest-tarjeta.t4 { background: #eff3fd; } .mest-tarjeta.t4 .mest-ico { background: #d8e2fb; color: #1d4ed8; }

  body.mest-abierta { overflow: hidden; }
}

/* ---------------- Tablet: menú y orden lado a lado ---------------- */
@media (min-width: 768px) and (max-width: 1180px) {
  body[data-vista="comandero"] .pos-body-split,
  body[data-vista="mesas"] .pos-body-split {
    grid-template-columns: minmax(0, 1fr) clamp(340px, 42vw, 420px) !important;
  }

  .navy-comanda-sidebar .dish-porcelain-item-card { grid-template-columns: 52px minmax(0, 1fr) auto 36px; gap: 4px 10px; }
  .navy-comanda-sidebar .dish-thumb { width: 52px; height: 52px; }
  .navy-comanda-sidebar .dish-quitar { width: 36px; }
  .navy-comanda-sidebar .dish-stepper-btn { width: 30px; height: 30px; }

  body[data-vista="comandero"] .navy-comanda-sidebar,
  body[data-vista="mesas"] .navy-comanda-sidebar {
    position: static !important; transform: none !important; height: 100% !important;
    border-radius: 0; box-shadow: none; border-left: 1px solid var(--border-subtle);
    overflow-y: auto;
  }

  .navy-comanda-sidebar .mo-volver { visibility: hidden; }
  .mobile-comanda-fab { display: none !important; }
  body[data-vista="comandero"] .marble-floor-section { padding-bottom: 24px; }
  .mest-hoja { border-radius: 20px; margin: 24px 0; box-shadow: 0 24px 60px rgba(17, 18, 20, 0.25); }
}

/* ---------------- Celular: la orden ocupa toda la pantalla ---------------- */
@media (max-width: 767px) {
  .navy-comanda-sidebar {
    position: fixed !important; inset: 0 !important; height: 100dvh !important;
    border-radius: 0 !important; z-index: 950 !important; overflow-y: auto;
    transform: translateY(102%); transition: transform 0.26s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .navy-comanda-sidebar.mobile-open { transform: translateY(0); }

  /* Botón de pago fijo al final de la pantalla de la orden */
  .navy-comanda-sidebar .silver-total-plaque { position: sticky; bottom: 0; box-shadow: 0 -8px 20px rgba(17, 18, 20, 0.06); }

  /* Barra flotante: total, ítems y "Ver orden" */
  body[data-vista="comandero"] .mobile-comanda-fab,
  body[data-vista="mesas"] .mobile-comanda-fab {
    display: flex; position: fixed; left: 16px; right: 16px; bottom: max(16px, env(safe-area-inset-bottom));
    height: 56px; padding: 0 8px 0 18px; border-radius: 999px; border: none;
    background: var(--mv-tinta); color: #ffffff; align-items: center; justify-content: space-between;
    box-shadow: 0 10px 28px rgba(17, 18, 20, 0.3); z-index: 800; cursor: pointer; font: inherit;
  }

  .mobile-comanda-fab.vacia { opacity: 0.9; }

  /* Menú lateral abierto: la barra se encoge hasta un círculo con "₡" (lado izquierdo, fuera del menú) */
  body[data-vista="comandero"] .mobile-comanda-fab,
  body[data-vista="mesas"] .mobile-comanda-fab {
    overflow: hidden;
    transition: right 0.38s cubic-bezier(0.16, 1, 0.3, 1), padding 0.38s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
  }
  .mobile-comanda-fab .fab-izq, .mobile-comanda-fab .fab-der { transition: opacity 0.18s ease, transform 0.3s ease; white-space: nowrap; }
  .mobile-comanda-fab .fab-colon {
    position: absolute; inset: 0; display: grid; place-items: center;
    font-size: 1.45rem; font-weight: 800; line-height: 1; color: #ffffff;
    opacity: 0; transform: scale(0.6); transition: opacity 0.2s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
  }
  body.tga-menu-abierto[data-vista="comandero"] .mobile-comanda-fab,
  body.tga-menu-abierto[data-vista="mesas"] .mobile-comanda-fab {
    right: calc(100% - 72px); padding: 0;
    background: var(--mv-acento);
    box-shadow: 0 8px 22px rgba(17, 18, 20, 0.28);
  }
  body.tga-menu-abierto .mobile-comanda-fab .fab-izq,
  body.tga-menu-abierto .mobile-comanda-fab .fab-der { opacity: 0; transform: translateX(-12px); pointer-events: none; }
  body.tga-menu-abierto .mobile-comanda-fab .fab-colon { opacity: 1; transform: scale(1); transition-delay: 0.12s; }

  .fab-izq { display: inline-flex; align-items: center; gap: 8px; }
  .fab-izq svg { width: 18px; height: 18px; }
  .fab-izq b { font-size: 1rem; font-weight: 800; }
  .fab-izq small { font-size: 0.74rem; color: rgba(255, 255, 255, 0.7); }

  .fab-der {
    height: 42px; padding: 0 18px; border-radius: 999px; display: inline-flex; align-items: center;
    background: var(--mv-acento); color: #ffffff; font-weight: 700; font-size: 0.88rem;
  }

  body[data-vista="comandero"] #mesas-plates-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .mest-tarjeta { min-height: 120px; }
}

@media (prefers-reduced-motion: reduce) {
  .navy-comanda-sidebar { transition: none !important; }
  .mobile-comanda-fab, .mobile-comanda-fab .fab-izq, .mobile-comanda-fab .fab-der, .mobile-comanda-fab .fab-colon { transition: none !important; }
}

/* ============================================================
   Escáner con cámara (js/modules/escaner-camara.js)
   ============================================================ */
.btn-camara-buscador { display: none; }
.fab-colon { display: none; }

@media (max-width: 1180px) {
  .btn-camara-buscador {
    display: inline-grid; place-items: center; flex-shrink: 0;
    width: 34px; height: 34px; margin-right: -4px; padding: 0;
    border: none; border-radius: 999px; background: transparent; color: var(--color-primary-500); cursor: pointer;
  }
  .btn-camara-buscador svg { width: 20px; height: 20px; }
  .btn-camara-buscador:focus-visible { outline: 2px solid var(--color-primary-500); outline-offset: 1px; }
}

.escaner-camara:not([hidden]) {
  position: fixed; inset: 0; z-index: 9995; background: #000; color: #fff;
  display: flex; flex-direction: column; overflow: hidden;
}

.escaner-camara video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.ec-marco {
  position: absolute; left: 10%; right: 10%; top: 50%; height: min(32vh, 220px); transform: translateY(-50%);
  border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.45);
  outline: 3px solid rgba(255, 255, 255, 0.9); outline-offset: -3px; pointer-events: none;
}

.ec-linea {
  position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; border-radius: 2px;
  background: var(--color-primary-500, #10b981); box-shadow: 0 0 12px var(--color-primary-500, #10b981);
}

@media (prefers-reduced-motion: no-preference) {
  .ec-linea { animation: ec-barrido 1.8s ease-in-out infinite alternate; }
  @keyframes ec-barrido { from { top: 18%; } to { top: 82%; } }
}

.ec-arriba {
  position: relative; z-index: 2; display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 8px;
  padding: max(14px, env(safe-area-inset-top)) 16px 10px;
  background: linear-gradient(rgba(0, 0, 0, 0.55), transparent);
}

.ec-arriba h2 { margin: 0; text-align: center; font-size: 1rem; font-weight: 700; color: #fff; }

.ec-boton-circulo {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid rgba(255, 255, 255, 0.6); background: rgba(0, 0, 0, 0.25); color: #fff; cursor: pointer;
}
.ec-boton-circulo[hidden] { visibility: hidden; display: grid; }
.ec-boton-circulo[aria-pressed="true"] { background: #fff; color: #111; }
.ec-boton-circulo svg { width: 18px; height: 18px; }

.ec-listo {
  height: 40px; padding: 0 18px; border-radius: 999px; border: none; cursor: pointer;
  background: #fff; color: #111; font: inherit; font-weight: 700; font-size: 0.9rem;
}

.ec-listo:focus-visible, .ec-boton-circulo:focus-visible { outline: 2px solid var(--color-primary-500, #10b981); outline-offset: 2px; }

.ec-ayuda {
  position: absolute; z-index: 2; left: 0; right: 0; top: calc(50% + min(16vh, 110px) + 14px);
  margin: 0; text-align: center; font-size: 0.86rem; font-weight: 600; color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.ec-pie {
  position: absolute; z-index: 2; left: 16px; right: 16px; bottom: max(16px, env(safe-area-inset-bottom));
  display: flex; justify-content: space-between; gap: 10px; padding: 12px 16px; border-radius: 999px;
  background: rgba(17, 18, 20, 0.85); font-size: 0.84rem; font-weight: 600;
}

.ec-hoja:not([hidden]) {
  position: absolute; z-index: 3; left: 0; right: 0; bottom: 0;
  padding: 18px 16px max(18px, env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0;
  background: #fff; color: #111214; box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.3);
  max-width: 560px; margin: 0 auto;
}

.ec-producto { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.ec-producto strong { display: block; font-size: 1.02rem; font-weight: 700; }
.ec-producto small { display: block; margin-top: 2px; color: #8a8f98; font-size: 0.8rem; }
.ec-subtotal { font-size: 1.1rem; font-weight: 800; color: var(--color-primary-500, #0f766e); white-space: nowrap; }

.ec-cantidad { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 18px 0; }

.ec-paso {
  width: 52px; height: 52px; border-radius: 50%; border: 1px solid #e5e7eb; background: #fff; cursor: pointer;
  font-size: 1.5rem; line-height: 1; color: #111214; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.ec-paso[data-paso="1"] { color: var(--color-primary-500, #0f766e); }

.ec-cant-campo { display: inline-flex; align-items: baseline; gap: 4px; }
.ec-cant-campo input {
  width: 96px; height: 52px; text-align: center; font: inherit; font-size: 1.5rem; font-weight: 800;
  border: 1px solid #e5e7eb; border-radius: 14px; color: #111214;
}
.ec-cant-campo input:focus { outline: 2px solid var(--color-primary-500, #0f766e); border-color: transparent; }
.ec-cant-campo span { font-weight: 700; color: #8a8f98; }

.ec-acciones { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }
.ec-acciones:has(> :only-child) { grid-template-columns: 1fr; }

.ec-omitir, .ec-agregar {
  height: 52px; border-radius: 999px; font: inherit; font-size: 0.95rem; font-weight: 700; cursor: pointer;
}
.ec-omitir { border: 1px solid #e5e7eb; background: #fff; color: #111214; }
.ec-agregar { border: none; background: #111214; color: #fff; }
.ec-agregar:disabled { opacity: 0.6; }
.ec-omitir:focus-visible, .ec-agregar:focus-visible, .ec-paso:focus-visible { outline: 2px solid var(--color-primary-500, #0f766e); outline-offset: 2px; }

.ec-mensaje { margin: 4px 0 14px; font-size: 0.95rem; font-weight: 600; text-align: center; }
.ec-mensaje.error { color: #b91c1c; }
.ec-mensaje.info { color: #4b5563; margin-bottom: 4px; }

body.ec-abierto { overflow: hidden; }

/* ============================================================
   Inventario en pantallas angostas: formularios y filtros sin desbordarse
   ============================================================ */
.inv-form-fila > * { min-width: 0; }

@media (max-width: 900px) {
  .inv-form-fila { grid-template-columns: 1fr 1fr !important; }
  .inv-form-mov > #inv-mov-supply,
  .inv-form-mov > #inv-mov-motivo,
  .inv-form-mov > button,
  .inv-form-receta > #rec-prod-id,
  .inv-form-receta > #rec-sup-id,
  .inv-form-receta > button { grid-column: 1 / -1; }
  .inv-form-fila > button { min-height: 44px; }
  .inv-filtro { width: auto !important; flex: 1 1 160px; min-width: 0; }
}

@media (max-width: 520px) {
  .inv-form-mov > #inv-mov-tipo,
  .inv-form-mov > #inv-mov-cant { grid-column: auto; }
  .inv-filtro { flex-basis: 100%; }
  .inv-form-fila select, .inv-form-fila input { font-size: 16px; } /* evita el zoom automático de iOS */
}

/* ============================================================
   Contenedores en el teléfono: nada más ancho que la pantalla
   ============================================================ */
@media (max-width: 767px) {
  /* Modales: ocupan el ancho disponible y crecen hacia arriba como una hoja */
  .modal-overlay:not(#modal-recuperar-clave):not(#modal-registro-negocio) { padding: 10px; align-items: flex-end; }
  .modal-overlay:not(#modal-recuperar-clave):not(#modal-registro-negocio) .modal-card {
    width: 100% !important; max-width: 100% !important; min-width: 0 !important;
    max-height: calc(100dvh - 20px) !important; border-radius: 18px !important;
  }

  /* Modales centrados de seguridad y bienvenida */
  #modal-recuperar-clave,
  #modal-registro-negocio {
    align-items: center !important;
    justify-content: center !important;
    padding: 14px !important;
  }
  #modal-recuperar-clave .modal-card,
  #modal-registro-negocio .modal-card {
    margin: auto !important;
    align-self: center !important;
    width: 95vw !important;
    max-width: 480px !important;
    border-radius: 20px !important;
  }
  .modal-card .modal-body { flex: 1 1 auto; min-height: 0; max-height: none !important; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
  .modal-card .modal-header { flex-wrap: wrap; gap: 10px !important; padding: 14px 16px; }
  .modal-card .modal-header > div:first-child { flex: 1 1 200px; min-width: 0; }
  .modal-card .modal-header h2, .modal-card .modal-header h3 { font-size: 1.02rem !important; }
  .modal-card .modal-header .admin-btn-secondary,
  .modal-card .modal-header .admin-btn-primary { white-space: nowrap; }
  .modal-card .modal-footer { flex-wrap: wrap; gap: 8px; }
  .modal-card .modal-footer > button { flex: 1 1 auto; justify-content: center; text-align: center; }

  /* Ningún bloque interno se sale de su contenedor */
  .modal-card :where(div, form, section, fieldset, img, video, canvas, input, select, textarea, label),
  #floorplan-container :where(div, form, section, fieldset, img, canvas, input, select, textarea) { max-width: 100%; }
  .modal-card :where(input, select, textarea) { min-width: 0; }
  /* En rejillas, las columnas pueden encogerse (si no, un campo de texto las ensancha) */
  .modal-card [style*="grid-template-columns"] > *, .modal-card .admin-form-grid > *,
  #floorplan-container [style*="grid-template-columns"] > *, #floorplan-container .admin-form-grid > * { min-width: 0; }
  .modal-card [style*="grid-template-columns:1fr 1fr"], .modal-card [style*="grid-template-columns: 1fr 1fr"],
  .modal-card [style*="grid-template-columns: 1fr 1.4fr"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }

  /* Rejillas de dos columnas fijas (caja, reportes): una sola columna que se ajusta */
  .caja-dual-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .caja-dual-grid > *, .kpi-cards-row > * { min-width: 0; }
  /* Rejillas de 4 columnas: 2 en el teléfono. Las de 3 (como el teclado numérico) se mantienen */
  .modal-card [style*="repeat(4, 1fr)"]:not(:has(> .numpad-key)),
  .modal-card [style*="repeat(4,1fr)"]:not(:has(> .numpad-key)) { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .modal-card [style*="repeat(3, 1fr)"], .modal-card [style*="repeat(3,1fr)"] { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }

  /* Pasos del asistente de configuración: se desplazan de lado */
  .wizard-steps-indicator { display: flex !important; overflow-x: auto; gap: 6px; scrollbar-width: none; }
  .wizard-steps-indicator > * { flex: 0 0 auto; }

  /* Tablas: cada fila es una tarjeta (js/modules/tablas-movil.js pone el nombre de cada columna) */
  .table-responsive-wrap:has(> table.tabla-apilable) { overflow-x: visible; border: none; background: transparent; }
  table.tabla-apilable { width: 100% !important; min-width: 0 !important; border-collapse: separate; border-spacing: 0; }
  table.tabla-apilable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  table.tabla-apilable, table.tabla-apilable tbody, table.tabla-apilable tr, table.tabla-apilable td { display: block; }
  table.tabla-apilable tbody tr {
    background: var(--bg-surface, #fff); border: 1px solid var(--border-default, #e2e8f0); border-radius: 14px;
    padding: 6px 12px; margin-bottom: 10px;
  }
  table.tabla-apilable tbody tr:last-child { margin-bottom: 0; }
  table.tabla-apilable td {
    display: grid; grid-template-columns: minmax(84px, 36%) minmax(0, 1fr); gap: 10px; align-items: start;
    padding: 7px 0 !important; border: none !important; border-bottom: 1px solid var(--border-subtle, #f1f5f9) !important;
    max-width: none !important; width: auto !important; text-align: left !important; white-space: normal !important;
    overflow-wrap: anywhere; font-size: 0.84rem;
  }
  table.tabla-apilable td:last-child { border-bottom: none !important; }
  table.tabla-apilable td::before {
    content: attr(data-label); font-size: 0.72rem; font-weight: 700; color: var(--text-muted, #64748b); line-height: 1.35; padding-top: 1px;
  }
  table.tabla-apilable td[data-label=""]::before { content: none; }
  table.tabla-apilable td[data-label=""] { grid-template-columns: minmax(0, 1fr); }
  table.tabla-apilable td.celda-completa { display: block; text-align: center !important; }
  table.tabla-apilable td.celda-completa::before { content: none; }
  /* Botones de acciones: fila completa y fáciles de tocar */
  table.tabla-apilable td > div[style*="display:flex"], table.tabla-apilable td > div[style*="display: flex"] { flex-wrap: wrap; }
  table.tabla-apilable td .admin-btn-secondary, table.tabla-apilable td .admin-btn-primary { min-height: 36px; }
}

/* ============================================================
   Botón Cobrar en verde y encabezado de la orden con el acento
   ============================================================ */
.action-pill-3d.cobrar-highlight {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 55%, #15803d 100%);
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.32);
}
.action-pill-3d.cobrar-highlight:hover { box-shadow: 0 6px 18px rgba(22, 163, 74, 0.42); filter: brightness(1.04); }
.action-pill-3d.cobrar-highlight:focus-visible { outline: 2px solid #15803d; outline-offset: 2px; }

/* Encabezado "Orden Activa" + mesa o canal */
.navy-comanda-sidebar .comanda-top-title-bar {
  background: linear-gradient(135deg, var(--color-primary-500) 0%, color-mix(in srgb, var(--color-primary-500) 82%, #000) 100%);
  border-bottom: none;
  color: #ffffff;
}
.navy-comanda-sidebar .comanda-title-large { color: #ffffff; }
.navy-comanda-sidebar .comanda-table-badge { background: rgba(255, 255, 255, 0.2); color: #ffffff; }
.navy-comanda-sidebar .comanda-top-title-bar .pax-selector-pill { background: rgba(255, 255, 255, 0.16); }
.navy-comanda-sidebar .comanda-top-title-bar .pax-selector-pill > span:first-child,
.navy-comanda-sidebar .comanda-top-title-bar .pax-num { color: #ffffff !important; }
.navy-comanda-sidebar .comanda-top-title-bar .pax-btn { background: rgba(255, 255, 255, 0.92); border-color: transparent; color: var(--text-main); }
.navy-comanda-sidebar .comanda-top-title-bar .mobile-drawer-close-btn { background: rgba(255, 255, 255, 0.18); border-color: transparent; color: #ffffff; }

/* Teléfono: el encabezado con el acento es el de "Orden actual"; la fila de comensales queda neutra */
@media (max-width: 767px) {
  .navy-comanda-sidebar .mo-cabecera {
    background: linear-gradient(135deg, var(--color-primary-500) 0%, color-mix(in srgb, var(--color-primary-500) 82%, #000) 100%);
    padding-bottom: 14px;
  }
  .navy-comanda-sidebar .mo-titulo { color: #ffffff; }
  .navy-comanda-sidebar .mo-volver { background: rgba(255, 255, 255, 0.2); color: #ffffff; }
  .navy-comanda-sidebar .mo-contexto { padding-top: 12px; }
  .navy-comanda-sidebar .comanda-top-title-bar { background: transparent; color: inherit; }
  .navy-comanda-sidebar .comanda-top-title-bar .pax-selector-pill { background: var(--bg-subtle); }
  .navy-comanda-sidebar .comanda-top-title-bar .pax-selector-pill > span:first-child { color: var(--text-secondary) !important; }
  .navy-comanda-sidebar .comanda-top-title-bar .pax-num { color: var(--text-main) !important; }
  .navy-comanda-sidebar .comanda-top-title-bar .pax-btn { background: var(--bg-surface); border-color: var(--border-default); }
}
