/* =============================================================================
   MOVIMIENTOS DE AZÚCAR EN EL TELÉFONO — etapa 3b del teléfono
   docs/movil/lamina-04-azucar-movimientos.html: ganó la B (06/10/2026), «la
   planilla y lo pendiente». Debajo de 768 px, el umbral con el que
   `mobile-router.js` elige el mundo.

   HOJA APARTE de `mw-ui.css`: esto no agrega nada a la pantalla del escritorio.
   Scope `#mobile-data-container`: la de Polvos (`.ed-ui`, otra hoja) arma su
   propio Movimientos con las mismas clases `.mw-*`.

   QUÉ HACE:
   · La barra de secciones es la píldora de Ventas (el indicador lo pone
     `core/mobile-gestos.js`); la cola («22 por resolver») baja a su renglón.
   · La planilla en cuatro líneas, el mismo molde que Polvos:
         MW00004026  17/09  ↗ SAL                     33.600
         MOYCO SRL
         SUPERIMPERIO SA
         12101 - Azúcar 1kg Azucel  · R 00001-00016449 · FCA …
   · Pendientes y Recepción: el id y la fecha arriba, lo demás debajo, sin la
     columna de la acción (se resuelve en la PC).
   · DE CONSULTA: sin el período (queda «los últimos 50» + «Cargar más
     antiguos»), sin acciones de fila; la ficha del MW sube desde abajo y sin
     los verbos que imprimen o anulan.
   ========================================================================== */
@media (max-width: 767px) {
    /* ── La píldora ─────────────────────────────────────────────────────── */
    #mobile-data-container .mw-ui .mw-shell { padding-top: 4px; }
    /* La píldora gris es un `::before` del primer renglón: la cola va debajo,
       sobre el fondo de la pantalla, no adentro del gris. */
    #mobile-data-container .mw-ui #mw-secnav {
        position: relative; isolation: isolate; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0;
        margin: 4px 4px 0; padding: 3px; border: 0; border-radius: 11px;
        background: none; box-shadow: none; overflow: visible;
    }
    #mobile-data-container .mw-ui #mw-secnav::before {
        content: ''; position: absolute; z-index: -1; top: 0; left: 0; right: 0; height: 44px;
        border-radius: 11px; background: #e3e7ef;
    }
    #mobile-data-container .mw-ui #mw-secnav > button {
        position: relative; z-index: 1; justify-content: center; gap: 5px;
        min-height: 38px; padding: 0 4px; border-radius: 8px; background: none;
        font-size: 13px; white-space: nowrap; color: var(--muted); transition: color .24s ease;
    }
    #mobile-data-container .mw-ui #mw-secnav > button[aria-current="true"] { color: var(--navy); }
    #mobile-data-container .mw-ui #mw-secnav > button::after,
    #mobile-data-container .mw-ui #mw-secnav > button > .material-symbols-outlined { display: none; }
    #mobile-data-container .mw-ui #mw-secnav:not(.mv-con-ind) > button[aria-current="true"] { background: #fff; box-shadow: var(--e1); }
    /* La cola: debajo de la píldora, a lo ancho, sobre el fondo de la pantalla. */
    #mobile-data-container .mw-ui #mw-cola {
        grid-column: 1 / -1; margin: 8px 0 0; padding: 0; border: 0; background: none;
        display: flex; flex-wrap: wrap; gap: 6px;
    }
    #mobile-data-container .mw-ui #mw-cola:empty { display: none; }

    /* ── La barra de la planilla: buscador y segmentos, sin el período ──── */
    #mobile-data-container #mw-btn-historico,
    #mobile-data-container #mw-rango { display: none; }
    #mobile-data-container .mw-ui #mw-seg { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
    #mobile-data-container .mw-ui #mw-seg > button { flex: 0 0 auto; white-space: nowrap; }
    #mobile-data-container .mw-ui .mw-caja-h { flex-wrap: wrap; row-gap: 4px; }

    /* ── Las tablas: cada renglón se apila ──────────────────────────────── */
    #mobile-data-container .mw-ui table.mw-g,
    #mobile-data-container .mw-ui table.mw-g tbody { display: block; width: 100%; min-width: 0; table-layout: auto; }
    #mobile-data-container .mw-ui table.mw-g thead,
    #mobile-data-container .mw-ui table.mw-g colgroup { display: none; }
    #mobile-data-container .mw-ui table.mw-g tbody tr { display: block; border-bottom: 1px solid var(--hair); border-left: 3px solid transparent; }
    #mobile-data-container .mw-ui table.mw-g tbody tr:last-child { border-bottom: 0; }
    #mobile-data-container .mw-ui table.mw-g tbody td {
        display: block; padding: 0; border: 0; min-width: 0; height: auto;
        white-space: normal; text-align: left; background: none;
    }
    #mobile-data-container .mw-ui table.mw-g tbody td.vacia { padding: 28px 16px; text-align: center; }
    #mobile-data-container .mw-ui table.mw-g tr.st-ok  { border-left-color: var(--ok-hair); }
    #mobile-data-container .mw-ui table.mw-g tr.st-wrn { border-left-color: var(--warn); }
    #mobile-data-container .mw-ui table.mw-g tr.st-crit { border-left-color: var(--crit); }
    #mobile-data-container .mw-ui table.mw-g tr.st-neg { border-left-color: var(--crit); }
    #mobile-data-container .mw-ui .mw-scroll { overflow: visible; max-height: none; }

    /* La planilla: cuatro líneas (más la de los papeles, si los hay). */
    #mobile-data-container #mw-grilla table.mw-g tbody tr[data-id] {
        display: grid; grid-template-columns: auto auto auto minmax(0, 1fr) auto;
        column-gap: 8px; row-gap: 2px; align-items: baseline; padding: 9px 12px 9px 9px; cursor: pointer;
    }
    #mobile-data-container #mw-grilla tr[data-id] td:nth-child(1) { grid-area: 1 / 1; }
    #mobile-data-container #mw-grilla tr[data-id] td:nth-child(2) { grid-area: 1 / 2; font-size: 11.5px; }
    #mobile-data-container #mw-grilla tr[data-id] td:nth-child(3) { grid-area: 1 / 3; font-size: 11.5px; }
    #mobile-data-container #mw-grilla tr[data-id] td:nth-child(7) { grid-area: 1 / 5 / 3 / 6; text-align: right; font-weight: 700; font-size: 13.5px; }
    #mobile-data-container #mw-grilla tr[data-id] td:nth-child(7):has(.tnum)::after { content: ' kg'; font-size: 11.5px; font-weight: 500; color: var(--muted); }
    #mobile-data-container #mw-grilla tr[data-id] td:nth-child(4) { grid-area: 2 / 1 / 3 / 5; font-size: 12px; color: var(--muted); }
    #mobile-data-container #mw-grilla tr[data-id] td:nth-child(5) { grid-area: 3 / 1 / 4 / 6; font-weight: 600; }
    #mobile-data-container #mw-grilla tr[data-id] td:nth-child(6) { grid-area: 4 / 1 / 5 / 6; font-size: 12px; color: var(--muted); }
    #mobile-data-container #mw-grilla tr[data-id] td:nth-child(8) { grid-area: 5 / 1 / 6 / 6; }
    #mobile-data-container #mw-grilla tr[data-id] td:nth-child(8):empty { display: none; }
    #mobile-data-container #mw-grilla tr[data-id] td:nth-child(9) { display: none; }

    /* Pendientes y Recepción: id y fecha arriba, lo demás debajo; sin la
       columna de la acción, que se resuelve en la PC. */
    #mobile-data-container #mw-sec-pendientes table.mw-g tbody tr:not(:has(td.vacia)),
    #mobile-data-container #mw-sec-recepcion table.mw-g tbody tr:not(:has(td.vacia)) {
        display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 8px; row-gap: 3px;
        align-items: baseline; padding: 9px 12px 9px 9px;
    }
    #mobile-data-container #mw-sec-pendientes table.mw-g tbody tr[data-id] { cursor: pointer; }
    #mobile-data-container #mw-sec-pendientes table.mw-g tbody tr td:nth-child(n+3),
    #mobile-data-container #mw-sec-recepcion table.mw-g tbody tr td:nth-child(n+3) { grid-column: 1 / -1; font-size: 12.5px; }
    #mobile-data-container #mw-sec-pendientes table.mw-g tbody tr td:nth-child(2),
    #mobile-data-container #mw-sec-recepcion table.mw-g tbody tr td:nth-child(2) { font-size: 11.5px; color: var(--muted); }
    #mobile-data-container #mw-sec-pendientes table.mw-g tbody tr:not(:has(td.vacia)) td:last-child,
    #mobile-data-container #mw-sec-recepcion table.mw-g tbody tr:not(:has(td.vacia)) td:last-child { display: none; }
    #mobile-data-container #mw-sec-pendientes table.mw-g tbody td.n > * { display: inline; margin-left: 3px; }
    #mobile-data-container #mw-sec-pendientes .mw-ph p,
    #mobile-data-container #mw-sec-recepcion .mw-ph p { font-size: 12.5px; }

    /* ── La ficha del MW: una hoja que sube desde abajo, para leer ──────── */
    #mw-detalle.mw-ui.mw-velo { align-items: flex-end; padding: 0; backdrop-filter: none; }
    #mw-detalle .mw-modal {
        max-width: none; max-height: 92vh; border-radius: 20px 20px 0 0;
        animation: mvHojaSube .28s cubic-bezier(.2, .8, .2, 1); will-change: transform;
    }
    #mw-detalle .mw-modal::before {
        content: ''; flex: none; align-self: center; width: 40px; height: 5px;
        margin: 8px 0 0; border-radius: 9px; background: var(--hair-strong);
    }
    #mw-detalle .mw-modal.mv-arrastra { animation: none; transition: none; }
    #mw-detalle .mw-modal.mv-baja { transition: transform .22s ease-in; transform: translateY(105%) !important; }
    #mw-detalle .mw-modal.mv-vuelve { transition: transform .2s ease; }
    /* Lo que imprime, reemplaza o marca: de la PC. Ver el lote, el COA y el
       historial de cambios se quedan (son lectura). */
    #mw-detalle [onclick*="remitoReimprimirMW"],
    #mw-detalle [onclick*="remitoAbrirReemplazo"],
    #mw-detalle [onclick*="mwdF3000"],
    #mw-detalle #mwd-ok { display: none; }
}
