/* =====================================================================
   TOTEM · experiencia en el móvil (≤ 860 px)
   Solo aspecto: no cambia nada de lo que hace cada pantalla.
     · Arriba: barra compacta con el negocio y, debajo, las secciones de la
       pantalla en pastillas con nombre, siempre a la vista.
     · Abajo: barra flotante con los servicios TOTEM, al alcance del pulgar.
     · Números en una tira que se desliza, ventanas que suben desde abajo,
       tablas convertidas en tarjetas y botones cómodos para el dedo.
   Todo va con «html body.totem» delante: gana a los estilos de cada página y
   no toca nunca los paneles a medida (Oñoro y compañía no llevan .totem).
   ===================================================================== */

.tt-mbar, .tt-mas { display: none; }

@media (max-width: 860px) {
  html body.totem { --mtop: 58px; --mbar: 0px; -webkit-tap-highlight-color: transparent; }
  html body.totem:has(.tt-mbar) { --mbar: 84px; }

  /* Campos a 16 px: así el iPhone no hace zoom al tocarlos */
  html body.totem input:not([type=checkbox]):not([type=radio]):not([type=color]),
  html body.totem select, html body.totem textarea { font-size: 16px; }
  html body.totem .tt-btn, html body.totem .btn { min-height: 44px; }
  html body.totem .tt-btn.peq, html body.totem .btn.pequeno { min-height: 38px; }

  /* ------------------------------------------------ barra de arriba */
  html body.totem .tt-app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; align-content: start; }
  html body.totem .tt-app > .tt-side {
    position: sticky; top: 0; z-index: 40; height: auto; min-height: 52px;
    display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px 8px;
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px; overflow: visible; min-width: 0; max-width: 100vw;
    box-shadow: 0 10px 30px -18px rgba(22,21,29,.7);
  }
  html body.totem .tt-app > .tt-side .tt-side-cab { flex: 1 1 auto; min-width: 0; padding: 0; gap: 10px; }
  html body.totem .tt-side .tt-negocio-logo { width: 36px; height: 36px; font-size: 16px; border-radius: 11px; flex: none; }
  html body.totem .tt-side .tt-negocio-txt { min-width: 0; }
  html body.totem .tt-side .tt-negocio-txt b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
  /* con barra inferior, los servicios ya están abajo: arriba solo el negocio */
  html body.totem:has(.tt-mbar) .tt-app > .tt-side > a.tt-side-item,
  html body.totem:has(.tt-mbar) .tt-app > .tt-side > .tt-side-sec { display: none; }
  html body.totem .tt-side-pie { margin: 0 0 0 auto; padding: 0; flex-direction: row; align-items: center; gap: 4px; border: 0; order: 2; }
  html body.totem .tt-side-pie .tt-side-item { width: 40px; height: 40px; padding: 0; justify-content: center; border-radius: 12px; }
  html body.totem .tt-side-pie .tt-side-item span { display: none; }

  /* Wallet con más servicios: sus secciones pasan arriba, en pastillas */
  html body.totem.panel-totem:has(.tt-mbar) .tt-side .tt-sub-nav {
    position: static; order: 3; flex: 1 1 100%; display: flex; flex-direction: row; justify-content: flex-start;
    gap: 6px; margin: 2px -12px 0; padding: 4px 12px 2px; background: none; box-shadow: none;
    overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity;
  }
  html body.totem.panel-totem:has(.tt-mbar) .tt-side .tt-sub-nav::-webkit-scrollbar { display: none; }
  html body.totem.panel-totem:has(.tt-mbar) .tt-side .tt-sub-nav .nav-item {
    flex: none; width: auto; flex-direction: row; gap: 7px; padding: 9px 15px; font-size: 14px; border-radius: 999px;
    background: rgba(255,255,255,.08); color: rgba(255,255,255,.78); border: 0; position: relative; scroll-snap-align: start;
  }
  html body.totem.panel-totem:has(.tt-mbar) .tt-side .tt-sub-nav .nav-item .tt-ico { width: 17px; height: 17px; }
  html body.totem.panel-totem:has(.tt-mbar) .tt-side .tt-sub-nav .nav-item.activa { background: #fff; color: var(--tt-noche); box-shadow: 0 6px 16px -8px rgba(0,0,0,.5); }
  html body.totem.panel-totem:has(.tt-mbar) .tt-side .tt-sub-nav .nav-item .contador { position: static; margin-left: 2px; }

  /* Solo Wallet: su barra de secciones, fija abajo (cuelga de <body>) */
  html body.totem .tt-sub-nav.tt-sub-nav-movil {
    position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 45;
    display: flex; flex-direction: row; justify-content: space-around; gap: 2px; padding: 6px; border-radius: 24px;
    background: rgba(22,21,29,.92); backdrop-filter: blur(18px) saturate(1.5); -webkit-backdrop-filter: blur(18px) saturate(1.5);
    box-shadow: 0 18px 40px -14px rgba(22,21,29,.75); transform: translateZ(0);
  }
  html body.totem .tt-sub-nav.tt-sub-nav-movil .nav-item {
    flex: 1 1 0; min-width: 0; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    border: 0; background: none; color: rgba(255,255,255,.6); font: inherit; font-size: 11px; font-weight: 600; border-radius: 18px; position: relative;
  }
  html body.totem .tt-sub-nav.tt-sub-nav-movil .nav-item .tt-ico { width: 22px; height: 22px; }
  html body.totem .tt-sub-nav.tt-sub-nav-movil .nav-item.activa { color: #fff; background: linear-gradient(180deg, #8E7FF2 0%, #6C55E8 60%, #5640D0 100%); }
  html body.totem .tt-sub-nav.tt-sub-nav-movil .nav-item .contador { position: absolute; top: 4px; right: 18%; }
  html body.totem:has(.tt-sub-nav-movil) { --mbar: 84px; }

  /* Pestañas de Booking, Connect, Flow y Carteles: fijas arriba, con nombre */
  html body.totem .bk-top {
    position: sticky; top: var(--mtop); z-index: 30; display: flex; flex-wrap: nowrap; align-items: center; gap: 8px;
    padding: 10px 12px; margin: 0; background: color-mix(in srgb, var(--tt-crema, #F5F4F0) 88%, transparent);
    backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
    border-bottom: 1px solid var(--tt-linea);
  }
  html body.totem .bk-top .bk-titulo { display: none; }
  html body.totem .bk-pestanas { flex: 1 1 auto; min-width: 0; width: auto; padding: 4px; scroll-snap-type: x proximity; }
  html body.totem .bk-pestanas button, html body.totem .bk-pestanas a { padding: 9px 13px; font-size: 14px; scroll-snap-align: start; flex: none; }
  html body.totem .bk-pestanas button span, html body.totem .bk-pestanas a span { display: inline; }
  html body.totem .bk-qr-accion { flex: none; width: 44px; height: 44px; min-height: 44px; padding: 0; justify-content: center; border-radius: 14px; margin: 0; }
  html body.totem .bk-qr-accion span { display: none; }

  /* ------------------------------------------------ barra de abajo */
  html body.totem .tt-mbar {
    position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 45;
    transform: translateZ(0); will-change: transform;
    display: flex; gap: 2px; padding: 6px; border-radius: 24px;
    background: rgba(22,21,29,.9); backdrop-filter: blur(18px) saturate(1.5); -webkit-backdrop-filter: blur(18px) saturate(1.5);
    box-shadow: 0 18px 40px -14px rgba(22,21,29,.75), inset 0 1px 0 rgba(255,255,255,.1);
    animation: tt-mbar-in .45s cubic-bezier(.2,.9,.3,1) both;
  }
  @keyframes tt-mbar-in { from { transform: translateY(30px); opacity: 0; } }
  html body.totem .tt-mbar > a, html body.totem .tt-mbar > button {
    flex: 1 1 0; min-width: 0; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    border: 0; background: none; color: rgba(255,255,255,.6); text-decoration: none; font: inherit; font-size: 11px; font-weight: 600;
    border-radius: 18px; cursor: pointer; transition: background .25s, color .25s, transform .15s;
  }
  html body.totem .tt-mbar > :active { transform: scale(.94); }
  html body.totem .tt-mbar .tt-ico { width: 23px; height: 23px; }
  html body.totem .tt-mbar span { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  html body.totem .tt-mbar .on { color: #fff; background: linear-gradient(180deg, #8E7FF2 0%, #6C55E8 60%, #5640D0 100%);
    box-shadow: 0 10px 22px -10px rgba(108,85,232,.95), inset 0 1px 0 rgba(255,255,255,.3); }
  html body.totem .tt-mbar .pronto { opacity: .55; }

  html body.totem .tt-mas:popover-open {
    display: flex; flex-direction: column; gap: 4px; position: fixed; inset: auto 10px calc(var(--mbar) + 10px + env(safe-area-inset-bottom)) 10px;
    margin: 0; width: auto; border: 0; border-radius: 22px; padding: 12px; background: var(--tt-noche); color: #fff;
    box-shadow: 0 24px 60px -16px rgba(22,21,29,.8); animation: tt-mbar-in .3s cubic-bezier(.2,.9,.3,1);
  }
  html body.totem .tt-mas::backdrop { background: rgba(22,21,29,.35); }
  html body.totem .tt-mas b { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.55); padding: 4px 8px 6px; }
  html body.totem .tt-mas a { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; color: #fff; text-decoration: none; font-weight: 600; }
  html body.totem .tt-mas a.on { background: rgba(255,255,255,.1); }
  html body.totem .tt-mas em { margin-left: auto; font-style: normal; font-size: 11px; opacity: .6; }

  /* hueco para la barra de abajo y los avisos por encima de ella */
  html body.totem .tt-main, html body.totem.panel-totem main.tt-main { padding-bottom: calc(var(--mbar) + 40px + env(safe-area-inset-bottom)); }
  html body.totem .tt-toasts { bottom: calc(var(--mbar) + 18px + env(safe-area-inset-bottom)); left: 12px; right: 12px; align-items: center; }

  /* ------------------------------------------------ números: tira deslizable */
  html body.totem .tt-kpis, html body.totem.panel-totem .metricas {
    display: flex; grid-template-columns: none; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory;
    margin: 0 -14px 16px; padding: 4px 14px 10px; scrollbar-width: none; scroll-padding: 0 14px;
  }
  html body.totem .tt-kpis::-webkit-scrollbar, html body.totem.panel-totem .metricas::-webkit-scrollbar { display: none; }
  html body.totem .tt-kpis > *, html body.totem.panel-totem .metricas > * {
    flex: 0 0 auto; min-width: 140px; max-width: 46vw; scroll-snap-align: start; margin: 0;
  }
  html body.totem .tt-kpi { padding: 14px 16px; }
  html body.totem .tt-kpi b { font-size: 24px; }
  html body.totem.panel-totem .metricas .metrica { padding: 14px 16px; }
  html body.totem.panel-totem .metricas .valor { font-size: 26px; }

  /* ------------------------------------------------ ventanas: suben desde abajo */
  html body.totem dialog.tt-dialogo {
    width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 26px 26px 0 0; max-height: 92dvh; overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom); animation: tt-hoja .34s cubic-bezier(.2,.9,.3,1);
    overscroll-behavior: contain;
  }
  html body.totem dialog.tt-dialogo > form { padding: 26px 18px 18px; position: relative; }
  html body.totem dialog.tt-dialogo > form::before {
    content: ''; position: absolute; top: 9px; left: 50%; width: 42px; height: 5px; margin-left: -21px;
    border-radius: 9px; background: var(--tt-linea);
  }
  html body.totem .tt-dialogo-pie { position: sticky; bottom: calc(-18px - env(safe-area-inset-bottom)); margin: 16px -18px -18px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
    background: var(--tt-sup); border-top: 1px solid var(--tt-linea); z-index: 2; flex-wrap: wrap; }
  html body.totem .tt-dialogo-pie .tt-btn { flex: 1 1 auto; }
  @keyframes tt-hoja { from { transform: translateY(60px); opacity: .3; } }

  /* ------------------------------------------------ tablas: una tarjeta por fila */
  html body.totem .tt-tabla, html body.totem .tt-tabla tbody { display: block; width: 100%; }
  html body.totem .tt-tabla thead { display: none; }
  html body.totem .tt-tabla tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 14px 10px; border-bottom: 1px solid var(--tt-linea-2, var(--tt-linea)); }
  html body.totem .tt-tabla tr:last-child { border-bottom: 0; }
  html body.totem .tt-tabla td { display: block; padding: 0 !important; border: 0 !important; max-width: 100%; }
  html body.totem .tt-tabla td:first-child { flex: 1 1 100%; }
  html body.totem .tt-tabla td:last-child:has(.tt-switch) { margin-left: auto; }

  /* ------------------------------------------------ Wallet */
  html body.totem.panel-totem .panel-top { padding: 14px 14px 4px; }
  html body.totem.panel-totem .panel-top .tt-h1 { font-size: 24px; }
  html body.totem.panel-totem .panel-top .tt-lead { font-size: 14px; }
  html body.totem.panel-totem .buscador-envoltorio input { min-height: 50px; border-radius: 16px; }
  html body.totem.panel-totem .premio-fila { flex-wrap: wrap; gap: 10px 12px; }
  html body.totem.panel-totem .premio-fila .premio-texto { flex: 1 1 calc(100% - 90px); }
  html body.totem.panel-totem .premio-fila > .btn { flex: 1 1 100%; min-height: 44px; }
  html body.totem.panel-totem .tarjeta { padding: 18px 16px; border-radius: 20px; }
  html body.totem.panel-totem .tt-pase-tarjeta .tt-movil { width: min(220px, 62vw); margin: 0 auto; }
  html body.totem.panel-totem .cab-tarjeta h2 { font-size: 18px; }
  /* lista de clientes: una tarjeta por persona */
  html body.totem.panel-totem #tabla-clientes table, html body.totem.panel-totem #tabla-clientes tbody { display: block; width: 100%; }
  html body.totem.panel-totem #tabla-clientes thead { display: none; }
  html body.totem.panel-totem #tabla-clientes tr { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center;
    padding: 14px 4px; border-bottom: 1px solid var(--tt-linea); }
  html body.totem.panel-totem #tabla-clientes td { display: block; padding: 0; border: 0; }
  html body.totem.panel-totem #tabla-clientes td:nth-child(1) { grid-column: 1; }
  html body.totem.panel-totem #tabla-clientes td:nth-child(5) { grid-column: 2; grid-row: 1 / span 2; }
  html body.totem.panel-totem #tabla-clientes td:nth-child(2) { grid-column: 1; }
  html body.totem.panel-totem #tabla-clientes td:nth-child(3), html body.totem.panel-totem #tabla-clientes td:nth-child(4) { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; }
  html body.totem.panel-totem #tabla-clientes td:nth-child(3) { grid-column: 1; }
  html body.totem.panel-totem #tabla-clientes td:nth-child(3)::before { content: 'Compras:'; color: var(--tt-gris); }
  html body.totem.panel-totem #tabla-clientes td:nth-child(4) { grid-column: 1 / -1; }
  html body.totem.panel-totem #tabla-clientes td:nth-child(4) div { display: inline; }
  html body.totem.panel-totem #tabla-clientes .btn { min-height: 42px; display: inline-flex; align-items: center; }

  /* ------------------------------------------------ Booking */
  html body.totem .bk-main { padding-top: 14px; }
  /* sin transform en el contenedor: si no, el botón flotante no se queda fijo */
  html body.totem .bk-vista { animation: none; transform: none; }
  html body.totem .bk-barra { gap: 10px; }
  html body.totem .bk-dia { width: 100%; }
  html body.totem .bk-acciones [data-nueva-cita] {
    position: fixed; right: 16px; bottom: calc(var(--mbar) + 18px + env(safe-area-inset-bottom)); z-index: 35;
    min-height: 56px; padding: 0 22px; border-radius: 999px; font-size: 15.5px;
    box-shadow: 0 16px 34px -12px rgba(108,85,232,.95), inset 0 1px 0 rgba(255,255,255,.35);
  }
  html body.totem .bk-equipo { grid-template-columns: 1fr; }
  html body.totem .bk-horas { max-height: 210px; }
  html body.totem .bk-horas button { min-width: 68px; min-height: 44px; }

  /* ------------------------------------------------ Connect */
  /* los tres pasos, luego cómo queda en el móvil y por último el botón de enviar */
  html body.totem .cn-rejilla { display: flex; flex-direction: column; gap: 16px; }
  html body.totem .cn-rejilla > .cn-form { display: contents; }
  html body.totem .cn-rejilla > .cn-form > * { order: 1; }
  html body.totem .cn-rejilla > .cn-vista { order: 2; position: static; }
  html body.totem .cn-rejilla > .cn-form > .cn-enviar { order: 3; margin-top: 0; }
  html body.totem .cn-vista .tt-movil { width: min(200px, 56vw); }
  html body.totem .cn-canales { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  html body.totem .cn-canal { flex-direction: column; align-items: center; justify-content: flex-start; text-align: center; padding: 12px 6px; gap: 6px; }
  html body.totem .cn-canal small { display: none; }
  html body.totem .cn-canal b { margin: 0; font-size: 13px; line-height: 1.2; }
  html body.totem .cn-canal em { margin: 0; font-size: 11.5px; }
  html body.totem .cn-paso { padding: 18px 16px; }
  html body.totem .cn-enviar { position: sticky; bottom: calc(var(--mbar) + 12px + env(safe-area-inset-bottom)); z-index: 5; min-height: 54px; }

  /* ------------------------------------------------ Flow */
  html body.totem .fl-hero { padding: 20px 18px; gap: 16px; }
  html body.totem .fl-hero h2 { font-size: 22px; }
  html body.totem .fl-kpis { display: flex; overflow-x: auto; scrollbar-width: none; margin: 0; padding: 2px 0 4px; width: 100%; scroll-snap-type: x mandatory; }
  html body.totem .fl-kpis::-webkit-scrollbar { display: none; }
  html body.totem .fl-kpi { flex: 0 0 auto; min-width: 128px; scroll-snap-align: start; }
  html body.totem .fl-rejilla { grid-template-columns: 1fr; gap: 12px; }
  html body.totem .fl-receta { padding: 16px; }
  html body.totem .fl-r-pie .tt-btn { min-height: 40px; }
  html body.totem .tt-switch { width: 50px; height: 30px; }
  html body.totem .tt-switch::after { width: 24px; height: 24px; }
  html body.totem .tt-switch.on::after { transform: translateX(20px); }

  /* buscadores a todo el ancho */
  html body.totem .tt-cabecera { flex-direction: column; align-items: stretch; gap: 12px; }
  html body.totem .tt-buscar { width: 100%; }
  html body.totem .tt-buscar input { width: 100%; min-height: 48px; }

  /* ------------------------------------------------ superadmin (socios) */
  html body.totem.superadmin .tt-app > .tt-side .tt-marca { flex: 1 1 auto; padding: 0; }
  html body.totem.superadmin .tt-side .menu {
    order: 3; flex: 1 1 100%; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 2px -12px 0; padding: 4px 12px 2px;
  }
  html body.totem.superadmin .tt-side .menu::-webkit-scrollbar { display: none; }
  html body.totem.superadmin .tt-side .menu button { flex: none; width: auto; padding: 9px 15px; border-radius: 999px; font-size: 14px;
    background: rgba(255,255,255,.08); color: rgba(255,255,255,.78); }
  html body.totem.superadmin .tt-side .menu button.activa { background: #fff; color: var(--tt-noche); }
  html body.totem.superadmin .tt-side-pie [data-nuevo-negocio] { width: 40px; height: 40px; min-height: 40px; padding: 0; font-size: 0; gap: 0; justify-content: center; border-radius: 12px; }
  html body.totem.superadmin .tt-side-pie [data-nuevo-negocio] .tt-ico { width: 20px; height: 20px; margin: 0; }

  /* ------------------------------------------------ Inicio y carteles */
  html body.totem .tt-mod-lista { gap: 12px; }
  html body.totem .ct-rejilla { grid-template-columns: 1fr; }
  html body.totem .ct-botones .tt-btn { min-height: 48px; }
}

@media (max-width: 860px) and (prefers-reduced-motion: reduce) {
  html body.totem .tt-mbar, html body.totem dialog.tt-dialogo { animation: none; }
}
@media (max-width: 860px) {
  html[data-tema="oscuro"] body.totem .bk-top { background: color-mix(in srgb, #0C0B11 85%, transparent); }
}

/* =====================================================================
   Dentro de la app de iPhone (la app pone la clase «en-app» en <html>)
   ===================================================================== */
html.en-app, html.en-app body { -webkit-text-size-adjust: 100%; overscroll-behavior-y: none; }
html.en-app body.totem { -webkit-touch-callout: none; }
html.en-app body.totem a, html.en-app body.totem button, html.en-app body.totem .tt-side, html.en-app body.totem .tt-mbar,
html.en-app body.totem .bk-pestanas, html.en-app body.totem .tt-kpi, html.en-app body.totem .metrica, html.en-app body.totem label { -webkit-user-select: none; user-select: none; }
html.en-app body.totem a:active, html.en-app body.totem .tt-card:active { opacity: .92; }
html.en-app body.totem .tt-btn:active, html.en-app body.totem .btn:active { transform: scale(.97); }
/* la app ya trae su propio modo instalado: fuera avisos de «instalar» */
html.en-app [data-instalar], html.en-app .tt-instalar { display: none !important; }
/* login a pantalla completa, con hueco para la cámara y la barra de inicio */
html.en-app body.totem .tt-login-hero, html.en-app body.totem .login-hero { padding-top: calc(24px + env(safe-area-inset-top)); }
html.en-app body.totem { padding-bottom: env(safe-area-inset-bottom); }
