/* ==========================================================
   Bodega Palmor - apariencia tipo app
   Base común (PC y celular) + ajustes para celular (<= 820 px)
   y para computador (>= 821 px).
   ========================================================== */

:root {
    --app-grad: #000e21;
    --app-red: #e60023;
    --btn-grad: #e60023;
    --app-red-dark: #e60023;
    --nav-h: 66px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html { -webkit-tap-highlight-color: transparent; overflow-anchor: none; }
body { overflow-anchor: none; }

/* Elementos solo de celular */
.app-nav, .app-sheet, .app-sheet-backdrop, .side-nav { display: none; }

/* ---------- Cabecera (común) ---------- */
.header {
    background: var(--app-grad);
    border-bottom: 0;
}

.logo { background: transparent; padding: 0; border-radius: 0; }
.logo img:not(.logo-app) { display: none; }
.logo .logo-app { display: block; width: 150px; height: auto; }

.header .user-info { color: rgba(255, 255, 255, .8); }
.header .user-info strong { color: #fff; }

.header .avatar {
    width: 36px; height: 36px;
    background: rgba(255, 255, 255, .16);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .28);
    font-size: 15px;
}

.header .header-link {
    background: rgba(255, 255, 255, .14);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 999px;
}
.header .header-link:hover { background: rgba(255, 255, 255, .26); }

.theme-toggle {
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .24);
    color: #fff;
    width: 38px; height: 38px;
    border-radius: 50%;
}
.theme-toggle:hover { background: rgba(255, 255, 255, .24); }

/* ---------- Portada (común) ---------- */
.page-heading .page-eyebrow,
.page-heading h1,
.side-label {
    font-family: "Inter", -apple-system, "SF Pro Display", "Segoe UI Variable Display", system-ui, sans-serif;
}
.page-heading h1 { font-weight: 600; letter-spacing: 1.5px; }
.page-heading .page-eyebrow { font-weight: 800; letter-spacing: 2.5px; }

.page-heading .page-eyebrow { color: rgba(255, 255, 255, .72); }
.page-heading h1 { color: #fff; }
.page-heading h1 span { color: #fff; }
.page-heading p { color: rgba(255, 255, 255, .78); }

/* ---------- Tarjetas y controles (común) ---------- */
.card, .admin-card, .recent-updates {
    border-radius: 22px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .08);
}
.search-card { padding: 22px; }

.search-input {
    height: 54px;
    border-radius: 16px;
    background: var(--bg-subtle);
    border-color: transparent;
    font-size: 16px;
}
.search-input:focus { background: var(--surface); border-color: var(--app-red-dark); }

input[type="text"], input[type="search"], input[type="number"], textarea, select { font-size: 16px; }

.button {
    border-radius: 999px;
    min-height: 46px;
    background: var(--btn-grad);
    box-shadow: none;
}
.button.secondary {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border-input);
    box-shadow: none;
}

/* ---------- Modo búsqueda: los resultados suben ---------- */
body.buscando .page-heading,
body.buscando .avisos-top,
body.buscando .search-title,
body.buscando .search-description,
body.buscando .search-help { display: none !important; }

body.buscando .search-card { padding: 14px; }
body.buscando .container > .search-card:first-of-type { margin-top: 0; }

#resultados { scroll-margin-top: 92px; }

/* Corrige: "Sin stock" heredaba el relleno grande de la tarjeta vacía (.empty) */
.stock.empty { padding: 6px 9px; text-align: center; }

/* ---------- Lista de resultados ---------- */
.lista-resultados { display: flex; flex-direction: column; gap: 10px; }

.lista-titulo {
    display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
    padding: 4px 6px 2px;
    font-size: 14px; font-weight: 800; color: var(--text);
}
.orden-sel { font: inherit; font-size: 11px; font-weight: 700; color: var(--text); background: var(--surface); border: 1px solid var(--border-input);
    border-radius: 99px; padding: 5px 10px; cursor: pointer; }
.lista-titulo span { font-size: 11px; font-weight: 600; color: var(--text-muted); }

.fila-resultado {
    display: flex; align-items: stretch; justify-content: space-between; gap: 12px;
    width: 100%;
    text-align: left;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .06);
    color: var(--text);
    font: inherit;
    cursor: pointer;
}
.fila-resultado:active { transform: scale(.99); }
.fila-resultado:hover { border-color: var(--app-red-dark); }

.fila-info { min-width: 0; flex: 1; }
.fila-marca { font-size: 10.5px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: var(--text-muted); }
.fila-nombre {
    margin: 3px 0; font-size: 14px; font-weight: 700; line-height: 1.3; color: var(--text);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.fila-sku { font-size: 12px; font-weight: 700; color: #e60023; }

.fila-lado {
    display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between;
    gap: 8px; flex-shrink: 0;
}
.fila-ub {
    font-size: 13px; font-weight: 800; color: var(--text);
    background: var(--bg-subtle); border-radius: 999px; padding: 6px 11px; white-space: nowrap;
}
.fila-mas { margin-left: 6px; color: var(--app-red-dark); }

.btn-volver-lista {
    display: inline-flex; align-items: center;
    margin: 0 0 10px;
    padding: 10px 16px;
    border: 1px solid var(--border-input);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-secondary);
    font: inherit; font-size: 13px; font-weight: 700;
    cursor: pointer;
}


/* ---------- Resumen de bodega (inicio) ---------- */
.aviso-dif {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin-bottom: 12px; padding: 12px 16px; border-radius: 16px; text-decoration: none;
    background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; font-size: 13px;
}
.aviso-dif span { display: flex; flex-direction: column; gap: 2px; }
.aviso-dif em { font-style: normal; font-size: 12px; opacity: .85; }
.aviso-dif b { font-size: 20px; }

.resumen { margin-top: 18px; }
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.kpi {
    background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
    padding: 16px 18px; box-shadow: 0 8px 22px rgba(0,0,0,.06);
}
.kpi-t { font-size: 10.5px; font-weight: 800; letter-spacing: .9px; color: var(--text-muted); }
.kpi-n { margin: 6px 0 4px; font-size: 30px; font-weight: 800; letter-spacing: -.5px; color: var(--text); line-height: 1.1; }
.kpi-s { font-size: 12px; color: var(--text-muted); }
.kpi-vendido { grid-column: 1 / -1; }
.kpi-u { font-size: 14px; font-weight: 700; color: var(--text-muted); }
.kpi-1l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-oscuro { background: var(--app-grad); border: 0; }
.kpi-oscuro .kpi-t { color: rgba(255,255,255,.75); }
.kpi-oscuro .kpi-n { color: #fff; }
.kpi-oscuro .kpi-dl { color: #ff3b57; }
.kpi-oscuro .kpi-s { color: rgba(255,255,255,.8); }

.paneles { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 12px; }
.panel, .resumen, .kpi { min-width: 0; max-width: 100%; box-sizing: border-box; }
.barra, .item { min-width: 0; max-width: 100%; box-sizing: border-box; }
.panel {
    background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
    padding: 14px 16px 10px; box-shadow: 0 8px 22px rgba(0,0,0,.06);
}
.panel-t { display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
    font-size: 14px; font-weight: 800; color: var(--text); margin-bottom: 8px; }
.panel-t span { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.panel-inv { --surface:#000e21; --border:#000e21; --text:#ffffff; --text-muted:#9aa7b8; --bg-hover:rgba(255,255,255,.09); --bg-subtle:rgba(255,255,255,.14); box-shadow:none; }
.panel-inv .pod-m b { color:#ff3b57; }
.panel-inv .pod-row { border-top-color: rgba(255,255,255,.12); }
.pod-hero { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; margin: 2px 0 8px; padding: 12px 14px;
    border: 0; border-radius: 14px; background: #e60023; color: #fff; font: inherit; text-align: left; cursor: pointer; }
.pod-hero:hover { filter: brightness(1.06); }
.pod-hi { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.pod-hi small { font-size: 10px; font-weight: 800; letter-spacing: .06em; opacity: .85; }
.pod-hi em { font-style: normal; font-size: 14px; font-weight: 700; line-height: 1.25; }
.pod-hi b, .pod-m b { font-size: 11px; font-weight: 800; }
.pod-hi b { color: #fff; }
.pod-big { font-size: 38px; font-weight: 800; line-height: 1; }
.pchip { display: inline-block; margin-left: 4px; font-size: 9px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
    padding: 2px 7px; border-radius: 99px; vertical-align: middle; background: rgba(0,0,0,.28); color: #fff; }
.pod-row { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 4px; border: 0; border-top: 1px solid var(--border);
    background: transparent; font: inherit; color: var(--text); text-align: left; cursor: pointer; border-radius: 0; }
.pod-row:hover { background: var(--bg-hover); }
.pod-rk { flex: none; width: 20px; height: 20px; border-radius: 50%; background: var(--bg-subtle); font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.pod-m { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pod-m em { font-style: normal; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pod-m b { color: #e60023; }
.pod-row .pchip { background: var(--bg-subtle); color: var(--text); }
.pod-bar { height: 4px; border-radius: 99px; background: var(--bg-subtle); overflow: hidden; margin-top: 2px; }
.pod-bar i { display: block; height: 100%; border-radius: 99px; background: #e60023; transform-origin: left center;
    animation: barra-in .9s cubic-bezier(.22,.8,.3,1) both, barra-vaiven 3.4s ease-in-out 1s infinite alternate; }
.pod-row:nth-of-type(3) .pod-bar i { animation-delay: .08s, 1.1s; }
.pod-row:nth-of-type(4) .pod-bar i { animation-delay: .16s, 1.2s; }
.pod-row:nth-of-type(5) .pod-bar i { animation-delay: .24s, 1.3s; }
.pod-hero { animation: pod-latido 3.4s ease-in-out 1s infinite alternate; }
@keyframes pod-latido { from { transform: scale(1); } to { transform: scale(.992); } }
.pod-row .barra-v { width: auto; min-width: 26px; }
:root[data-theme="dark"] .panel-inv { --surface:#f3f4f6; --border:#f3f4f6; --text:#171717; --text-muted:#6b7280; --bg-hover:#e5e7eb; --bg-subtle:#dfe2e7; }
:root[data-theme="dark"] .panel-inv .pod-m b { color:#e60023; }
:root[data-theme="dark"] .panel-inv .pod-row { border-top-color: #dfe2e7; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .panel-inv { --surface:#f3f4f6; --border:#f3f4f6; --text:#171717; --text-muted:#6b7280; --bg-hover:#e5e7eb; --bg-subtle:#dfe2e7; }
    :root:not([data-theme="light"]) .panel-inv .pod-m b { color:#e60023; }
    :root:not([data-theme="light"]) .panel-inv .pod-row { border-top-color: #dfe2e7; }
}
.panel-vacio { padding: 14px 4px; font-size: 13px; color: var(--text-muted); }

.barra, .item {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 4px;
    background: transparent; border: 0; border-radius: 10px; font: inherit; color: var(--text);
    text-align: left; cursor: pointer;
}
.barra:hover, .item:hover { background: var(--bg-hover); }
.barra-n { width: 34%; font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barra-pista { flex: 1; height: 8px; border-radius: 99px; background: var(--bg-subtle); overflow: hidden; }
.barra-pista i { display: block; height: 100%; border-radius: 99px; background: var(--app-red); position: relative; overflow: hidden; transform-origin: left center;
    animation: barra-in .9s cubic-bezier(.22,.8,.3,1) both, barra-vaiven 3.4s ease-in-out 1s infinite alternate; }
.barra-pista i::after { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 22px; background: rgba(255,255,255,.35);
    animation: barra-brillo 3.4s ease-in-out 1s infinite alternate; }
.barra:nth-child(2) .barra-pista i, .barra:nth-of-type(2) .barra-pista i { animation-delay: .08s, 1.1s; }
.barra:nth-of-type(3) .barra-pista i { animation-delay: .16s, 1.2s; }
.barra:nth-of-type(4) .barra-pista i { animation-delay: .24s, 1.3s; }
.barra:nth-of-type(5) .barra-pista i { animation-delay: .32s, 1.4s; }
@keyframes barra-in { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes barra-vaiven { from { transform: scaleX(1); } to { transform: scaleX(.965); } }
@keyframes barra-brillo { from { left: -22px; } to { left: 100%; } }
.barra-v { width: 34px; text-align: right; font-size: 13px; font-weight: 800; }
.item-i { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.item-i b { font-size: 12px; color: #e60023; }
.item-i em { font-style: normal; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-v { font-size: 13px; font-weight: 800; background: var(--bg-subtle); border-radius: 99px; padding: 4px 10px; }
.item-f { font-weight: 600; font-size: 11.5px; }

/* ==========================================================
   COMPUTADOR (>= 821 px)
   ========================================================== */
@media (min-width: 821px) {

    .header { padding: 0 32px; }
    .logo .logo-app { width: 160px; }

    /* Portada: banner redondeado con degradado */
    .container { padding-top: 28px; }

    .page-heading {
        background: var(--app-grad);
        border-radius: 28px;
        padding: 40px 32px 62px;
        margin-bottom: 0;
    }
    .page-heading + .card,
    .page-heading + a,
    .page-heading + section {
        margin-top: -34px;
        position: relative;
        z-index: 2;
    }

    .footer { padding-bottom: 30px; }
}

/* ==========================================================
   COMPUTADOR con sesión: menú lateral + panel tipo dashboard
   ========================================================== */
@media (min-width: 821px) {

    body.con-lateral { padding-left: 244px; }
    body.con-lateral > .header { display: none; }

    .side-nav {
        display: flex; flex-direction: column; gap: 4px;
        position: fixed; top: 0; left: 0; bottom: 0; width: 244px;
        padding: 22px 14px 16px;
        background: var(--surface);
        border-right: 1px solid var(--border);
        z-index: 800;
        overflow-y: auto;
    }
    .side-nav a.side-logo {
        display: block; margin: 0 0 18px; padding: 16px 16px;
        border-radius: 18px; background: var(--app-grad);
    }
    .side-logo img { display: block; width: 138px; height: auto; }

    .side-label {
        margin: 12px 12px 4px; font-size: 10.5px; font-weight: 800;
        letter-spacing: 1px; color: var(--text-faint);
    }

    .side-nav a, .side-item-btn {
        display: flex; align-items: center; gap: 12px;
        padding: 11px 14px; border-radius: 14px; border: 0;
        background: transparent; color: var(--text-secondary);
        font: inherit; font-size: 14px; font-weight: 600;
        text-decoration: none; cursor: pointer; text-align: left; width: 100%;
        position: relative;
    }
    .side-nav svg { width: 20px; height: 20px; flex-shrink: 0; }
    .side-nav a:hover, .side-item-btn:hover { background: var(--bg-hover); color: var(--text); }
    .side-nav a.side-logo:hover, .side-nav a.side-logo:focus-visible { background: var(--app-grad); box-shadow: inset 0 0 0 2px #e60023; }

    .side-nav a.activo, .side-nav a.activo:hover {
        background: #000e21; color: #fff; font-weight: 700;
    }
    .side-nav a.activo::before {
        content: ""; position: absolute; left: -14px; top: 10px; bottom: 10px;
        width: 4px; border-radius: 0 4px 4px 0; background: var(--app-red);
    }
    html[data-theme="dark"] .side-nav a.activo { background: #2a1214; }
    @media (prefers-color-scheme: dark) {
        html:not([data-theme="light"]) .side-nav a.activo { background: #2a1214; }
    }

    .side-badge {
        margin-left: auto; font-style: normal; font-size: 11px; font-weight: 800;
        min-width: 22px; padding: 2px 7px; text-align: center;
        border-radius: 999px; background: var(--app-red); color: #fff;
    }

    .side-fondo { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
    .side-user { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
    .side-user .av {
        width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
        display: flex; align-items: center; justify-content: center;
        background: var(--app-red); color: #fff; font-weight: 800;
    }
    .side-user-txt { min-width: 0; display: flex; flex-direction: column; }
    .side-user-txt strong { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .side-user-txt span { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .side-nav a.side-salir:hover { color: var(--app-red-dark); }

    /* Otras páginas internas: más anchas con el menú lateral */
    body.con-lateral .container { max-width: 1180px; padding-top: 28px; }

    /* ---------- Inicio tipo dashboard ---------- */
    body.con-lateral .container:has(#resultados) {
        max-width: none;
        width: calc(100% - 56px);
        display: grid;
        grid-template-columns: minmax(0, 1.35fr) minmax(300px, 1fr);
        column-gap: 22px;
        align-content: start;
        padding: 18px 0 6px;
    }
    body.con-lateral .container:has(#resultados) > * { grid-column: 1; }

    body.con-lateral .container:has(#resultados) > .page-heading {
        grid-column: 1 / -1; grid-row: 1;
        padding: 14px 28px 16px; margin: 0 0 14px; text-align: left;
        border-radius: 22px;
    }
    body.con-lateral .container:has(#resultados) > .page-heading h1 { font-size: 28px; margin: 2px 0 2px; }
    body.con-lateral .container:has(#resultados) > .page-heading p { margin: 0; font-size: 13px; }
    body.con-lateral .container:has(#resultados) > .page-heading + .card,
    body.con-lateral .container:has(#resultados) > .page-heading + a { margin-top: 0; }

    body.con-lateral .container:has(#resultados) > .avisos-top { grid-column: 1 / -1; grid-row: 2; }
    body.con-lateral .container:has(#resultados) > .search-card { grid-row: 3; margin-bottom: 14px; align-self: start; }
    body.con-lateral .container:has(#resultados) > #resultados {
        grid-row: 4; max-height: calc(100vh - 330px);
        overflow-y: auto; margin-bottom: 0 !important; padding-right: 4px;
    }
    body.con-lateral:not(.buscando) .container:has(#resultados) > #resultados { display: none; }

    body.con-lateral .container:has(#resultados) > .admin-grid { display: contents; }
    body.con-lateral .container:has(#resultados) .admin-grid > .admin-card { margin: 0 0 14px !important; padding: 14px 18px; align-self: start; }
    /* sin aviso de incidencias */
    body.con-lateral .container:has(#resultados) .admin-grid > .admin-card:nth-child(1) { grid-column: 2; grid-row: 3; }
    body.con-lateral .container:has(#resultados) .admin-grid > .admin-card:nth-child(2) { grid-column: 2; grid-row: 4; }
    body.con-lateral .container:has(#resultados) .admin-grid > .admin-card:nth-child(3) { grid-column: 1; grid-row: 4; }

    /* tarjetas compactas */
    body.con-lateral .container:has(#resultados) .admin-card h3 { font-size: 15px; margin: 0 0 4px; }
    body.con-lateral .container:has(#resultados) .admin-card p { font-size: 12px; line-height: 1.4; margin: 0 0 8px; }
    body.con-lateral .container:has(#resultados) .admin-card > div:first-child { margin-bottom: 8px !important; }
    body.con-lateral .container:has(#resultados) .admin-card > div:first-child:not(:has(> div)) { width: 34px !important; height: 34px !important; border-radius: 10px !important; }
    body.con-lateral .container:has(#resultados) .admin-card > div:first-child > div { width: 34px !important; height: 34px !important; border-radius: 10px !important; font-size: 11px !important; }
    body.con-lateral .container:has(#resultados) .admin-card .button { min-height: 40px; }

    body.con-lateral .container:has(#resultados) > .resumen { grid-column: 1 / -1; grid-row: 5; margin-top: 4px; }
    body.con-lateral .resumen .kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    body.con-lateral .resumen .kpi-vendido { grid-column: auto; }
    body.con-lateral .resumen .kpi { padding: 12px 18px; }
    body.con-lateral .resumen .kpi-n { font-size: 26px; margin: 3px 0 2px; }
    body.con-lateral .resumen .paneles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    body.con-lateral.buscando .resumen { display: none; }
    body.con-lateral .container:has(#resultados) > .security, body.con-lateral .container:has(#resultados) ~ .footer { display: none; }

    /* Modo búsqueda en escritorio: solo buscador y resultados, centrados y grandes */
    body.con-lateral.buscando .container:has(#resultados) { grid-template-columns: minmax(0, 860px); justify-content: center; }
    body.con-lateral.buscando .container:has(#resultados) > .search-card { grid-row: 1; }
    body.con-lateral.buscando .container:has(#resultados) > #resultados { grid-row: 2; max-height: calc(100vh - 150px); }
    body.con-lateral.buscando .container:has(#resultados) .admin-grid > .admin-card { display: none; }

    /* pantallas bajas: sin descripciones para evitar el scroll */
    @media (max-height: 940px) {
        body.con-lateral .container:has(#resultados) .admin-card p { display: none; }
    }
}


@media (min-width: 821px) and (max-height: 860px) {
    .side-nav { padding: 12px 14px 10px; gap: 2px; }
    .side-nav a.side-logo { margin-bottom: 6px; padding: 10px 14px; }
    .side-logo img { width: 120px; }
    .side-label { margin: 6px 12px 2px; }
    .side-nav a, .side-item-btn { padding: 8px 14px; }
    .side-fondo { padding-top: 6px; gap: 0; }
    .side-user { padding: 4px 10px; }
}

/* ==========================================================
   CELULAR / TABLET (<= 820 px)
   ========================================================== */
@media (max-width: 820px) {

    body {
        padding-bottom: calc(var(--nav-h) + 34px + var(--safe-bottom));
        -webkit-text-size-adjust: 100%;
    }

    .header {
        height: auto;
        min-height: 0;
        padding: calc(12px + var(--safe-top)) 18px 12px;
        gap: 12px;
    }
    .logo .logo-app { width: 138px; }

    .header .user-info,
    .header .header-link,
    .header .header-links-full,
    .header .menu-wrapper,
    .header .menu-button { display: none !important; }
    .header .user-chip { display: flex; }

    .container { width: calc(100% - 28px); padding-top: 22px; }
    /* Portada con degradado: el título sube hasta pegarse a la cabecera */
    .container > .page-heading:first-child { margin-top: -22px; }

    .page-heading {
        background: var(--app-grad);
        margin: 0 -14px 0;
        padding: 6px 24px 48px;
        border-radius: 0 0 30px 30px;
        text-align: left;
        width: calc(100% + 28px);
        box-sizing: border-box;
    }
    .page-heading h1 { font-size: 30px; letter-spacing: 1px; }
    .page-heading p { margin: 10px 0 0; font-size: 13px; }

    .page-heading + .card,
    .page-heading + a,
    .page-heading + section {
        margin-top: -26px;
        position: relative;
        z-index: 2;
    }

    #resultados { scroll-margin-top: calc(80px + var(--safe-top)); }

    /* ---------- Historial: filas como tarjetas (sin cortes) ---------- */
    .tabla-historial { overflow: visible; background: transparent; border: 0; box-shadow: none; }
    .tabla-historial table, .tabla-historial tbody, .tabla-historial tr, .tabla-historial td { display: block; width: 100%; box-sizing: border-box; }
    .tabla-historial thead { display: none; }
    .tabla-historial tr {
        margin-bottom: 12px; padding: 12px 16px;
        background: var(--surface); border: 1px solid var(--border);
        border-radius: 18px; box-shadow: 0 6px 18px rgba(0,0,0,.06);
    }
    .tabla-historial td {
        display: flex; justify-content: space-between; gap: 14px;
        padding: 6px 0 !important; border: 0 !important; text-align: right;
        font-size: 13px; word-break: break-word; overflow-wrap: anywhere;
    }
    .tabla-historial td[data-label]::before {
        content: attr(data-label); flex-shrink: 0; text-align: left;
        font-size: 11px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: var(--text-muted);
    }
    .tabla-historial td[colspan] { justify-content: center; }

    .footer { padding-bottom: 12px; }

    /* ---------- Barra inferior flotante ---------- */
    .app-nav {
        display: flex;
        position: fixed;
        left: 14px; right: 14px;
        bottom: calc(10px + var(--safe-bottom));
        height: var(--nav-h);
        padding: 7px;
        gap: 4px;
        z-index: 900;
        border-radius: 999px;
        background: color-mix(in srgb, var(--surface) 88%, transparent);
        -webkit-backdrop-filter: blur(16px);
        backdrop-filter: blur(16px);
        border: 1px solid var(--border);
        box-shadow: 0 12px 34px rgba(0, 0, 0, .22);
    }

    .app-nav a, .app-nav button {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        border: 0;
        background: transparent;
        color: var(--text-muted);
        text-decoration: none;
        font: inherit;
        font-size: 10.5px;
        font-weight: 700;
        border-radius: 999px;
        cursor: pointer;
        position: relative;
        transition: background .18s ease, color .18s ease;
    }
    .app-nav svg { width: 22px; height: 22px; }

    .app-nav .activo {
        background: var(--btn-grad);
        color: #fff;
        box-shadow: none;
    }

    .app-nav .insignia {
        position: absolute;
        top: 5px; right: calc(50% - 22px);
        min-width: 17px; height: 17px;
        padding: 0 4px;
        border-radius: 999px;
        background: #facc15;
        color: #422006;
        font-size: 10px; line-height: 17px;
        text-align: center;
    }

    /* ---------- Hoja "Más" ---------- */
    .app-sheet-backdrop {
        display: block;
        position: fixed; inset: 0;
        background: rgba(0, 0, 0, .5);
        opacity: 0; pointer-events: none;
        transition: opacity .2s ease;
        z-index: 1500;
    }
    .app-sheet-backdrop.abierto { opacity: 1; pointer-events: auto; }

    .app-sheet {
        display: block;
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 1600;
        background: var(--surface);
        border-radius: 28px 28px 0 0;
        padding: 10px 18px calc(22px + var(--safe-bottom));
        transform: translateY(105%);
        transition: transform .25s ease;
        box-shadow: 0 -12px 40px rgba(0, 0, 0, .3);
    }
    .app-sheet.abierto { transform: translateY(0); }

    .app-sheet .agarre {
        width: 42px; height: 5px; border-radius: 3px;
        background: var(--border-input);
        margin: 0 auto 14px;
    }
    .app-sheet .usuario {
        display: flex; align-items: center; gap: 12px;
        padding: 4px 4px 14px;
        border-bottom: 1px solid var(--border);
        margin-bottom: 8px;
    }
    .app-sheet .usuario .av {
        width: 44px; height: 44px; border-radius: 50%;
        background: var(--app-red); color: #fff;
        display: flex; align-items: center; justify-content: center;
        font-weight: 800; font-size: 18px; text-transform: uppercase;
    }
    .app-sheet .usuario strong { display: block; color: var(--text); font-size: 15px; }
    .app-sheet .usuario span { color: var(--text-muted); font-size: 12px; }

    .app-sheet .fila {
        display: flex; align-items: center; gap: 14px;
        width: 100%;
        padding: 14px 6px;
        border: 0; background: transparent;
        color: var(--text); font: inherit; font-size: 15px; font-weight: 600;
        text-decoration: none; text-align: left;
        border-radius: 14px; cursor: pointer;
    }
    .app-sheet .fila:active { background: var(--bg-subtle); }
    .app-sheet .fila svg { width: 22px; height: 22px; color: var(--text-muted); flex-shrink: 0; }
    .app-sheet .fila.salir, .app-sheet .fila.salir svg { color: #e60023; }

    /* Los modales existentes quedan por encima de la barra */
    #modalIncidencia, #modalRack { z-index: 2000; }
}

@media (min-width: 821px) {
    .card .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.kpi-dl{display:inline-block;margin-top:6px;font-size:11px;font-weight:800;color:#e60023;text-decoration:none;}
.kpi-dl:hover{text-decoration:underline;}

/* Celular: "Buscar por rack" justo debajo de "Buscar producto" */
@media (max-width: 820px) {
    .container:has(#resultados) { display: flex; flex-direction: column; overflow-x: clip; }
    .container:has(#resultados) > .admin-grid { display: contents; }
    .container:has(#resultados) > .avisos-top { order: 1; }
    .container:has(#resultados) > .search-card { order: 2; margin-bottom: 14px !important; }
    .container:has(#resultados) > #resultados { order: 3; }
    .container:has(#resultados) .admin-grid > #rackCard { order: 4; }
    .container:has(#resultados) .admin-grid > .admin-card:not(#rackCard) { order: 5; }
    .container:has(#resultados) > .resumen { order: 6; }
    .container:has(#resultados) > .security { order: 7; }
    #rackInput { min-width: 0; width: 100%; box-sizing: border-box; }
    #rackBoton { flex-shrink: 0; }
    .container:has(#resultados) .admin-grid > .admin-card { margin: 0 0 14px !important; }
    .container:has(#resultados) > #resultados:empty { margin: 0 !important; }
}

/* Título de "Buscar producto": más grande que los demás del inicio */
.search-card .search-title { font-size: 24px; font-weight: 800; letter-spacing: -.3px; line-height: 1.15; margin-bottom: 6px; }
body.buscando .search-card .search-title { font-size: 18px; }
@media (max-width: 820px) { .search-card .search-title { font-size: 22px; } }


/* ---------- Dona animada (más vendidos) ---------- */
.dona { position: relative; width: var(--tam, 150px); height: var(--tam, 150px); flex: none; animation: dona-burbuja 4.2s ease-in-out infinite alternate; }
.dona-svg { width: 100%; height: 100%; display: block; transform: rotate(-90deg); animation: dona-gira 16s linear infinite; }
.dona-seg { animation: dona-crece 1s cubic-bezier(.22,.8,.3,1) both; }
.dona-c { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; pointer-events: none; }
.dona-c strong { font-size: calc(var(--tam, 150px) * .22); font-weight: 800; color: var(--text); }
.dona-c span { font-size: calc(var(--tam, 150px) * .075); font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
@keyframes dona-gira { from { transform: rotate(-90deg); } to { transform: rotate(270deg); } }
@keyframes dona-burbuja { 0% { transform: scale(1); } 100% { transform: scale(.92); } }
@keyframes dona-crece { from { stroke-dasharray: 0 100; } }
.kpi-vendido { position: relative; }

.dona-body { display: flex; align-items: center; gap: 8px; }
.dona-wrap { display: flex; justify-content: center; flex: none; padding: 4px 2px; }
.dona-leg { display: flex; flex-direction: column; flex: 1; min-width: 0; }
@media (max-width: 820px) {
    .dona-body { flex-direction: column; align-items: stretch; gap: 0; }
    .dona-wrap { padding: 6px 0 10px; }
}
.dona-li { display: flex; align-items: center; gap: 8px; width: 100%; padding: 5px 3px; border: 0; border-radius: 10px; background: transparent; font: inherit; color: var(--text); text-align: left; cursor: pointer; }
.dona-li:hover { background: var(--bg-hover); }
.dona-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.dona-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dona-t em { font-style: normal; font-size: 11.5px; font-weight: 600; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dona-t > span { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.dona-t b { font-size: 11px; font-weight: 800; color: #e60023; }
.panel-inv .dona-t b { color: #ff3b57; }
:root[data-theme="dark"] .panel-inv .dona-t b { color: #e60023; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .panel-inv .dona-t b { color: #e60023; } }
.dona-t .pchip { margin-left: 3px; background: var(--bg-subtle); color: var(--text); }
.dona-v { font-size: 14px; font-weight: 800; }


/* ---------- Distribución del stock en plataformas ---------- */
.dist { margin-top: 12px; border: 1px solid var(--border); border-radius: 12px; padding: 11px 12px; background: var(--surface); }
.dist-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); }
.dchip { display: inline-block; font-size: 10.5px; font-weight: 800; padding: 3px 9px; border-radius: 99px; letter-spacing: .02em; text-transform: none; white-space: nowrap; }
.dchip.falta { background: #fee2e2; color: #b91c1c; }
.dchip.favor { background: #fef3c7; color: #92400e; }
.dchip.cuadra { background: #dcfce7; color: #166534; }
.dist-bar { position: relative; display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--bg-subtle); margin: 10px 0 8px; }
.dist-bar i { display: block; height: 100%; }
.d-woo { background: #7f54b3; }
.d-ml { background: #ffe600; }
.d-libre { background: #9ca3af; opacity: .55; }
.dist-tick { position: absolute; top: -2px; bottom: -2px; width: 3px; margin-left: -1px; background: #e60023; border-radius: 2px; }
.dist-leg { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text); }
.dist-leg span { display: inline-flex; align-items: center; gap: 5px; }
.dist-leg u { text-decoration: none; width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.dist-leg b { font-weight: 800; }
.dist-nota { margin-top: 7px; font-size: 11.5px; font-weight: 600; }
.dist-nota.falta { color: #b91c1c; }
.dist-nota.favor { color: #92400e; }
.dist-nota.cuadra { color: var(--text-muted); }
.dchip.sm { font-size: 9.5px; padding: 2px 7px; margin-left: 6px; }


/* ---------- Alerta de diferencias con plataformas (inicio, arriba junto a incidencias) ---------- */
.avisos-top { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px; margin-bottom: 14px; }
.avisos-top > * { margin-bottom: 0 !important; }
.aviso-plat { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 12px; text-decoration: none;
    background: #e60023; color: #fff; box-shadow: 0 6px 18px rgba(230,0,35,.28); animation: aviso-pulso 2.6s ease-in-out infinite; }
.aviso-plat.favor { background: #f59e0b; color: #1f1300; box-shadow: 0 6px 18px rgba(245,158,11,.3); }
.ap-ico { flex: none; width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,.22); display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 800; }
.ap-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ap-txt strong { font-size: 13px; font-weight: 800; line-height: 1.25; }
.ap-txt em { font-style: normal; font-size: 12px; opacity: .95; }
.ap-txt em b { font-weight: 800; }
.ap-go { flex: none; font-size: 20px; font-weight: 800; }
@keyframes aviso-pulso { 0%, 100% { box-shadow: 0 6px 18px rgba(230,0,35,.28); } 50% { box-shadow: 0 6px 26px rgba(230,0,35,.55); } }

/* Descarga del último listado de pedidos (Generador de ubicación) */
.ultimo-ped { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 10px 12px; border-radius: 12px; text-decoration: none;
    background: var(--ped-bg, #f3f4f6); border: 1px solid var(--ped-bd, #e5e7eb); color: inherit; }
.ultimo-ped:hover { border-color: #e60023; }
.up-ico { flex: none; width: 30px; height: 30px; border-radius: 9px; background: #e60023; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; }
.up-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.up-txt strong { font-size: 13px; font-weight: 800; }
.up-txt em { font-style: normal; font-size: 11.5px; opacity: .7; }
:root[data-theme="dark"] .ultimo-ped { --ped-bg: rgba(255,255,255,.05); --ped-bd: rgba(255,255,255,.12); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ultimo-ped { --ped-bg: rgba(255,255,255,.05); --ped-bd: rgba(255,255,255,.12); } }

/* Inicio: bloque "Hoy en bodega" (los KPI y gráficos pasaron a Reportes) */
.aviso-plat.aviso-dif2 { background: #1d4ed8; box-shadow: 0 6px 18px rgba(29,78,216,.28); animation: none; }
.resumen.hoy { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.hoy-card { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border-radius: 18px; text-decoration: none; color: inherit;
    background: var(--surface); border: 1px solid var(--border); }
.hoy-card:hover { border-color: #e60023; }
.hoy-t { font-size: 11px; font-weight: 800; letter-spacing: .06em; color: var(--text-muted); }
.hoy-n { font-size: 28px; font-weight: 800; line-height: 1.15; }
.hoy-n small { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.hoy-bar { height: 9px; border-radius: 9px; background: var(--bg-subtle); overflow: hidden; margin: 4px 0; }
.hoy-bar i { display: block; height: 100%; background: #16a34a; border-radius: 9px; }
.hoy-s { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.hoy-rep .hoy-n { color: var(--text); }
@media (max-width: 820px) { .resumen.hoy { grid-template-columns: 1fr; } }
