@media screen {
    html, body { max-width: 100%; overflow-x: hidden; }
    .hotel-app { height: 100vh; height: 100dvh; }
    .hotel-app main, .hotel-app main > div, .hotel-admin-content { min-width: 0; min-height: 0; }
    .hotel-catalog-panel { min-width: 0; }
    .hotel-catalog-panel[hidden] { display: none !important; }
    .hotel-app { padding-top: env(safe-area-inset-top); }
    #grid-pos, #grid-habitaciones-admin { grid-template-columns: minmax(0, 1fr); grid-auto-rows: max-content; }
    [data-room-card] { min-width: 0; overflow-wrap: anywhere; }
    [data-room-card] button { min-height: 44px; }
    [data-room-card] { border-top-width: 4px; }
    [data-room-state="DISPONIBLE"] { border-top-color: #10b981; }
    [data-room-state="OCUPADA"] { border-top-color: #f43f5e; }
    [data-room-state="LIMPIEZA"], [data-room-state="POR_LIMPIAR"],
    [data-room-state="SALIDA_RECIENTE"] { border-top-color: #f59e0b; }
    [data-room-state="RESERVADA"] { border-top-color: #0ea5e9; }
    [data-room-state="MANTENIMIENTO"], [data-room-state="FUERA_SERVICIO"] { border-top-color: #64748b; }
    .hotel-room-action { min-height: 44px; }
    #carrito-lista button { min-width: 44px; min-height: 44px; }
    .hotel-product-image { width: 100%; height: 140px; flex-shrink: 0; }
    [data-product-card], [data-inventory-card] { min-width: 0; overflow-wrap: anywhere; }
    body[data-lobby-mode="tienda"] #grid-pos { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hotel-utilities { z-index: 45; }
    .hb-solo-movil { display: none; }
    @media (max-width: 1023px) { .hb-solo-movil { display: block; } }
    .hb-checklist { margin: 10px 0; font-size: 12px; min-width: 0; }
    .hb-checklist__resumen { font-weight: 800; margin: 0 0 6px; }
    .hb-checklist__lista { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
    .hb-checklist__lista li { display: flex; align-items: flex-start; gap: 8px; min-width: 0; overflow-wrap: anywhere; }
    .hb-checklist__lista li[data-estado="ok"] > span:first-child { color: #065f46; font-weight: 800; }
    .hb-checklist__lista li[data-estado="pendiente"] > span:first-child { color: #78350f; font-weight: 800; }
    .dark .hb-checklist__lista li[data-estado="ok"] > span:first-child { color: #6ee7b7; }
    .dark .hb-checklist__lista li[data-estado="pendiente"] > span:first-child { color: #fcd34d; }
    .hb-checklist__lista li > span:nth-child(2) { flex: 1 1 auto; min-width: 0; }
    .hb-checklist__lista button { flex: 0 0 auto; min-height: 44px; padding: 0 12px; border-radius: 10px; font-weight: 800; background: #f59e0b; color: #020617; }
    .hb-accion-tabla { min-height: 44px; min-width: 44px; }
    @media (max-width: 639px) { .hb-col-costo { display: none; } }
    .hotel-utilities summary::-webkit-details-marker { display: none; }
    .hotel-utilities-panel { z-index: 45; max-height: min(70dvh, 480px); overflow-y: auto; }
    .hotel-utilities-panel button, .hotel-utilities-panel a { min-height: 48px; }
    .hotel-app button:disabled { opacity: .45; cursor: not-allowed; }
    .hotel-app :is(button, a, summary, [role="button"]):focus-visible { outline: 3px solid #0ea5e9; outline-offset: 2px; }
    [data-room-filter][aria-pressed="true"] { outline: 2px solid #f59e0b; outline-offset: 2px; }
    [data-hotel-tab][aria-pressed="true"] { background: #f59e0b; color: #020617; }
    .hotel-ticket-summary { display: none; }
    .hotel-bottom-nav { display: none; }
    .hotel-app [id^="modal-"] { padding: 12px; }
    .hotel-app [id^="modal-"] > div,
    .hotel-app [id^="modal-"] > form {
        max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        overflow-y: auto;
        overscroll-behavior: contain;
        min-width: 0;
    }
    .hotel-app [id^="modal-"] input,
    .hotel-app [id^="modal-"] select { min-width: 0; }
    @media (min-width: 640px) and (max-width: 767px) {
        #grid-pos, #grid-habitaciones-admin { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    }
    @media (min-width: 768px) and (max-width: 1024px) {
        #grid-pos, #grid-habitaciones-admin { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    }
    @media (min-width: 1025px) {
        #grid-pos, #grid-habitaciones-admin { grid-template-columns: repeat(3, minmax(0, 1fr)); }
        body[data-lobby-mode="tienda"] #grid-pos { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    }
    @media (min-width: 1536px) {
        #grid-pos, #grid-habitaciones-admin { grid-template-columns: repeat(4, minmax(0, 1fr)); }
        body[data-lobby-mode="tienda"] #grid-pos { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    }
    @media (max-width: 1023px) {
        .hotel-ticket-summary { display: flex; }
        #lobby-ticket-summary { position: sticky; bottom: 12px; z-index: 20; flex-shrink: 0; box-shadow: 0 8px 24px #02061766; }
        body[data-lobby-view="rack"] #lobby-ticket { display: none; }
        body[data-lobby-view="caja"] #lobby-rack { display: none; }
        #lobby-ticket { min-height: 0; flex: 1 0 auto; }
        #lobby-topbar > div:first-child { flex: 1; min-width: 0; }
        #lobby-header-actions { display: flex; flex-wrap: wrap; width: 100%; order: 3; }
        #lobby-header-actions > :not(#btn-admin-lobby):not(#btn-logout-lobby) { display: none; }
        #lobby-header-actions > :is(#btn-admin-lobby, #btn-logout-lobby) { flex: 1; justify-content: center; }
        #lobby-rack { min-height: 0; overflow: visible; }
    }
    @media (max-width: 1024px) {
        .hotel-app button, .hotel-app a, .hotel-login button, .hotel-login a { min-height: 44px; }
        .hotel-app input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
        .hotel-app select, .hotel-app textarea,
        .hotel-login input, .hotel-login select { min-height: 44px; font-size: 16px; }
        .hotel-app [id^="modal-"] > div,
        .hotel-app [id^="modal-"] > form { padding: 16px; }
        #form-checkin > .grid, #form-nuevo-abono { grid-template-columns: minmax(0, 1fr); }
        #form-nuevo-abono > * { grid-column: 1 / -1; }
        #lobby-topbar { flex-wrap: wrap; gap: 8px; }
        #lobby-header-actions { flex-wrap: wrap; }
        #sidebar-hotel { flex-shrink: 0; }
    }
    @media (max-width: 767px) {
        .hotel-bottom-nav {
            display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
            position: fixed; bottom: 0; left: 0; right: 0; z-index: 25;
            padding: 6px max(12px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
            background: #0f172a; border-top: 1px solid #334155; color: #cbd5e1; gap: 6px;
        }
        .hotel-bottom-nav button { min-height: 48px; border-radius: 12px; font-size: 12px; font-weight: 700; }
        .hotel-bottom-nav button[aria-pressed="true"] { background: #f59e0b; color: #020617; }
        .hotel-app { --hotel-nav-h: calc(61px + env(safe-area-inset-bottom)); }
        .hotel-app main { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
        /* Con el resumen de ticket acoplado sobre la barra, el rack reserva ~pb-36 para que ninguna tarjeta quede tapada */
        body[data-lobby-view="rack"] #lobby-main { padding-bottom: calc(144px + env(safe-area-inset-bottom)); }
        #lobby-header-actions { display: flex; }
        .hotel-catalog-panel { flex: 1 0 auto; min-height: 0; }
        #lobby-topbar { padding: 8px 12px; }
        #lobby-topbar h1 { flex-wrap: wrap; overflow-wrap: anywhere; }
        #lobby-topbar > div { min-width: 0; }
        #hotel-status-bar { gap: 6px; }
        #hotel-status-bar [data-status] { max-width: 100%; }
        #lobby-main { overflow-y: auto; }
        /* backdrop-filter crea un bloque contenedor y dejaría el resumen fixed anclado al final del rack, no a la pantalla */
        body.hb-theme.hotel-app #lobby-rack { -webkit-backdrop-filter: none; backdrop-filter: none; }
        /* Franja acoplada al borde superior de la barra inferior, ya no flota sobre las tarjetas */
        #lobby-ticket-summary {
            position: fixed; left: 0; right: 0; bottom: var(--hotel-nav-h); z-index: 24;
            margin: 0; border-radius: 12px 12px 0 0; min-height: 48px; padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
            box-shadow: 0 -4px 12px #02061740;
        }
        #lobby-rack { flex: 1 0 auto; min-height: 0; }
        #grid-pos { overflow-y: visible; flex: none; }
        #lobby-ticket { min-height: 0; flex: 1 0 auto; }
        #carrito-lista { overflow-y: visible; }
        body[data-lobby-view="rack"] #lobby-ticket { display: none; }
        body[data-lobby-view="caja"] #lobby-rack { display: none; }
        #sidebar-hotel { padding-bottom: calc(72px + env(safe-area-inset-bottom)); max-width: 90vw; }
        #sidebar-hotel nav { max-height: calc(100dvh - 290px); }
        .hotel-admin-content header { gap: 8px; flex-wrap: wrap; }
        #btn-asistente-kamila { bottom: calc(86px + env(safe-area-inset-bottom)); }
        body[data-lobby-view="rack"] #btn-asistente-kamila { bottom: calc(144px + env(safe-area-inset-bottom)); }
        .hotel-login { height: auto; min-height: 100dvh; padding-top: max(16px, env(safe-area-inset-top)); padding-bottom: max(16px, env(safe-area-inset-bottom)); }
        .hotel-login > div { margin-top: auto; margin-bottom: auto; }
    }
}

/* Bot?n flotante de Kami arrastrable (static/js/modules/boton_flotante_arrastrable.js) */
#btn-asistente-kamila[data-arrastrable="true"] { cursor: grab; -webkit-touch-callout: none; }
#btn-asistente-kamila[data-arrastrando="true"] { cursor: grabbing; transition: none; opacity: .92; box-shadow: 0 18px 40px rgba(245, 158, 11, .35); }

#modal-ocr[data-modulo="hotel_tienda"] > div {
    max-height: calc(100dvh - 1.5rem);
    overflow-y: auto;
    min-width: 0;
}

#modal-ocr[data-modulo="hotel_tienda"] table {
    min-width: 900px;
}

#modal-ocr[data-modulo="hotel_tienda"] button:disabled {
    opacity: .6;
    cursor: progress;
}

html:not(.dark) #modal-ocr[data-modulo="hotel_tienda"] .bg-slate-900 {
    background-color: #fff;
}

html:not(.dark) #modal-ocr[data-modulo="hotel_tienda"] :is(.bg-slate-950, .bg-slate-800, #dropzone-ocr) {
    background-color: #f1f5f9;
}

html:not(.dark) #modal-ocr[data-modulo="hotel_tienda"] :is(.text-white, .text-slate-200, .text-slate-300, .text-slate-400) {
    color: #334155;
}

html:not(.dark) #modal-ocr[data-modulo="hotel_tienda"] :is(.text-amber-200, .text-amber-300, .text-amber-400) {
    color: #92400e;
}

html:not(.dark) #modal-ocr[data-modulo="hotel_tienda"] :is(.text-emerald-200, .text-emerald-300, .text-emerald-400) {
    color: #047857;
}

html:not(.dark) #modal-ocr[data-modulo="hotel_tienda"] :is(.border-slate-700, .border-slate-800) {
    border-color: #cbd5e1;
}

html:not(.dark) #modal-ocr[data-modulo="hotel_tienda"] #btn-confirmar-ingreso-ocr {
    color: #fff;
}

/* ---------- Tablas como tarjetas en móvil (las etiquetas data-label las pone tablas_responsive.js) ---------- */
@media screen and (max-width: 639px) {
    .hb-tabla-responsive,
    .hb-tabla-responsive tbody,
    .hb-tabla-responsive tfoot,
    .hb-tabla-responsive tr,
    .hb-tabla-responsive td { display: block; min-width: 0 !important; width: 100%; }
    /* La cabecera sigue disponible para lectores de pantalla, pero sale del flujo visual. */
    .hb-tabla-responsive thead {
        position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
        clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
    }
    .hb-tabla-responsive tbody tr:not([data-mensaje]) {
        margin: 0 0 10px; padding: 8px 12px; border: 1px solid rgba(100, 116, 139, .35); border-radius: 14px;
    }
    .hb-tabla-responsive td[data-label] {
        display: flex; align-items: center; justify-content: space-between; gap: 12px;
        padding: 7px 0 !important; text-align: right !important; white-space: normal !important; overflow-wrap: anywhere;
    }
    .hb-tabla-responsive td[data-label]::before {
        content: attr(data-label); flex: 0 0 38%; max-width: 38%; text-align: left;
        font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; opacity: .85;
    }
    .hb-tabla-responsive td[data-label] > * { min-width: 0; }
    .hb-tabla-responsive td[data-label] select { max-width: 60%; min-height: 44px; }
    .hb-tabla-responsive td[data-label] .flex { justify-content: flex-end; }
    /* Con tarjetas caben todas las columnas: se anula el ocultamiento de columnas secundarias. */
    .hb-tabla-responsive .hb-col-costo { display: flex; }
    .hb-tabla-responsive tfoot tr { padding: 8px 12px; }
}

/* ---------- Áreas táctiles de 44px en pantallas táctiles y móviles ---------- */
@media screen and (max-width: 767px), (pointer: coarse) {
    .hotel-app :is(button, [role="button"], summary, select):not(.hb-sin-minimo) { min-height: 44px; }
    .hotel-app [data-ui-overlay] :is(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea) { min-height: 44px; }
    .hotel-app .hb-cerrar-modal, .hotel-app [data-ui-overlay] button:has(> .fa-xmark:only-child) { min-width: 44px; min-height: 44px; }
    /* Evita el zoom automático de Safari iOS al enfocar un campo (exige 16px o más). */
    .hotel-app :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea) { font-size: max(16px, 1em); }
}
