/* ============================================================================
   LUBRICANTES INTERNACIONALES — Layout y componentes (rediseño premium)
   Bootstrap se usa solo como base estructural (grid, utilities, modal,
   dropdown); toda la identidad visual vive aquí, encima del Design System
   definido en theme.css.
   ============================================================================ */

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    transition: background-color .2s ease, color .2s ease;
    margin: 0;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 999px; }
::-webkit-scrollbar-track { background: transparent; }

.text-mono { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* Red de seguridad si el CSS de Bootstrap (CDN externo) no llega a cargar:
   sin su hoja de estilos, .dropdown-menu/.modal (ocultos por defecto vía el
   propio CSS de Bootstrap) se verían como cualquier otro <div>, visibles en
   el flujo normal de la página — rompiendo cualquier pantalla que use estos
   componentes (el bell de notificaciones, el menú de usuario, los modales de
   Preventa...). El JS de Bootstrap agrega/quita la clase .show al abrir y
   cerrar independientemente de si su CSS cargó, así que basta con ocultarlos
   por defecto acá y dejar que .show los revele, igual que ya hace Bootstrap. */
.dropdown-menu:not(.show) { display: none; }
.modal:not(.show) { display: none; }

/* ============================================================================
   LAYOUT SHELL
   ============================================================================ */

.app-shell {
    display: grid;
    /* minmax(0, 1fr) y no un "1fr" pelado: un track "1fr" es en realidad
       minmax(auto, 1fr) implícito, cuyo mínimo "auto" se calcula del
       min-content de lo que caiga en esa columna — si algún módulo tiene
       contenido ancho sin wrap (p. ej. una fila con scroll horizontal
       propio), el track crece para acomodarlo en vez de dejarlo scrollear
       dentro de su propio overflow-x, y termina empujando toda la página.
       minmax(0, 1fr) elimina ese piso de min-content. */
    grid-template-columns: 264px minmax(0, 1fr);
    grid-template-rows: 68px 1fr;
    grid-template-areas:
        "sidebar topbar"
        "sidebar content";
    /* Fija la altura del shell al viewport: con min-height la fila "1fr" del
       grid queda con tamaño indefinido y crece según su contenido, así que
       .content nunca llega a recortar con su propio overflow-y (definido más
       abajo) y termina desplazando sidebar/topbar fuera de vista en vez de
       dejarlos fijos — necesario para que el POS pueda vivir sin scroll de
       página con scroll interno en productos/carrito. */
    /* 100dvh sigue el alto visible real cuando las barras del navegador móvil
       aparecen o desaparecen. Se conserva 100vh como fallback para navegadores
       antiguos. */
    height: 100vh;
    height: 100dvh;
    transition: grid-template-columns .2s ease;
}

html.sidebar-collapsed .app-shell { grid-template-columns: 80px minmax(0, 1fr); }

.content {
    grid-area: content;
    padding: 1.75rem;
    overflow-y: auto;
    overscroll-behavior-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Los ítems de grid tienen min-height:auto/min-width:auto por defecto, lo
       que puede hacer que la pista 1fr crezca con el contenido en vez de
       recortarlo con overflow — min-height:0 fuerza a que el scroll interno
       funcione, y min-width:0 evita que contenido interno sin wrap (p. ej.
       una fila horizontal con scroll propio) empuje todo el ancho de la
       página en vez de quedarse contenido en su propio overflow-x. */
    min-height: 0;
    min-width: 0;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
}

/* ============================================================================
   SIDEBAR — "cockpit" automotriz, siempre en tono grafito
   ============================================================================ */

.sidebar {
    grid-area: sidebar;
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-surface) 100%);
    color: var(--sidebar-text);
    padding: 0;
    overflow-y: auto;
    overflow-x: hidden;
    /* El scroll sigue funcionando (rueda, touch, teclado) — solo se oculta
       la barra visible, que ensuciaba el panel angosto del sidebar. */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* Edge/IE legacy */
    transition: width .2s ease;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--sidebar-border);
}
.sidebar::-webkit-scrollbar { display: none; } /* Chrome/Edge/Safari */

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: 1.35rem 1.25rem;
    color: #fff;
    border-bottom: 1px solid var(--sidebar-border);
    white-space: nowrap;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-brand .brand-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent), #f59e0b);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(217, 119, 6, 0.35);
}
.sidebar-brand .brand-icon i { color: #1a1206; font-size: 1.15rem; }

.sidebar-brand .brand-text { line-height: 1.15; font-weight: 800; font-size: .82rem; letter-spacing: .03em; }
.sidebar-brand .brand-text span { display: block; color: var(--sidebar-text); font-weight: 600; font-size: .68rem; letter-spacing: .06em; }
html.sidebar-collapsed .sidebar-brand .brand-text { display: none; }
html.sidebar-collapsed .sidebar-brand { justify-content: center; padding-left: 0; padding-right: 0; }

.sidebar-scroll {
    flex: 1 1 auto; overflow-y: auto; padding: 1rem 0 .5rem;
    scrollbar-width: none; -ms-overflow-style: none;
}
.sidebar-scroll::-webkit-scrollbar { display: none; }

.sidebar-section-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .1em;
    color: #52607a;
    padding: 1rem 1.35rem .4rem;
    white-space: nowrap;
    cursor: pointer;
}
.sidebar-section-label .section-chevron {
    font-size: .7rem;
    transition: transform .15s ease;
    flex-shrink: 0;
}
.sidebar-section-label.open .section-chevron { transform: rotate(180deg); }
html.sidebar-collapsed .sidebar-section-label { text-align: center; padding: 1rem .5rem .4rem; }
html.sidebar-collapsed .sidebar-section-label .section-chevron { display: none; }

.sidebar-nav {
    list-style: none;
    margin: 0;
    padding: 0 .6rem;
    max-height: 0;
    overflow: hidden;
}
.sidebar-nav.open { max-height: none; }
html.sidebar-collapsed .sidebar-nav { max-height: none; overflow: visible; }

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .62rem .75rem;
    color: var(--sidebar-text);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    overflow: hidden;
    font-weight: 500;
    font-size: .865rem;
    position: relative;
    margin-bottom: 2px;
    transition: background-color .15s ease, color .15s ease;
}

.sidebar-nav .nav-link:hover {
    background: var(--sidebar-active-bg);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: var(--sidebar-active-bg);
    color: #fff;
}

.sidebar-nav .nav-link.active::before {
    content: '';
    position: absolute;
    left: -.6rem;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--accent);
    border-radius: 0 4px 4px 0;
}

.sidebar-nav .nav-link i { width: 20px; text-align: center; font-size: 1.05rem; flex-shrink: 0; }
.sidebar-nav .nav-link.active i { color: var(--accent); }

html.sidebar-collapsed .sidebar-nav .nav-link { justify-content: center; padding-left: .5rem; padding-right: .5rem; }
html.sidebar-collapsed .sidebar-nav .nav-link span { display: none; }

.sidebar-promo {
    margin: .75rem;
    padding: 1.1rem;
    border-radius: var(--radius-md);
    background: linear-gradient(155deg, #101828 0%, #1c2740 55%, #2a1a08 130%);
    border: 1px solid var(--sidebar-border);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}
.sidebar-promo::after {
    content: '';
    position: absolute;
    right: -30px; bottom: -30px;
    width: 120px; height: 120px;
    background: radial-gradient(circle, rgba(217,119,6,.35), transparent 70%);
}
.sidebar-promo .promo-logo-glass {
    width: 76px; height: 76px;
    margin-bottom: .7rem;
    background: rgba(255, 255, 255, .1);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, .24);
    border-radius: 14px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 6px 16px rgba(0, 0, 0, .3);
    overflow: hidden;
    position: relative;
}
.sidebar-promo .promo-logo-glass img {
    width: 100%; height: 100%; object-fit: cover; object-position: 50% 46%; display: block;
}
.sidebar-promo .promo-sub { color: #8a97b3; font-size: .72rem; line-height: 1.4; position: relative; }
html.sidebar-collapsed .sidebar-promo { display: none; }

.sidebar-footer {
    padding: .85rem 1.1rem;
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
html.sidebar-collapsed .sidebar-footer span { display: none; }
html.sidebar-collapsed .sidebar-footer { justify-content: center; }

/* ---- Peek al pasar el mouse: en escritorio, con el sidebar colapsado a
   rail de iconos, mantenerlo encima del contenido como flotante en vez de
   navegar a otra pantalla para expandirlo — no reserva más espacio (la
   columna del grid sigue en 80px) y se repliega solo al salir. ---- */
@media (min-width: 901px) {
    html.sidebar-collapsed .sidebar:hover {
        position: fixed;
        top: 0; bottom: 0; left: 0;
        width: 264px;
        z-index: 1100;
        box-shadow: var(--shadow-lg);
    }
    html.sidebar-collapsed .sidebar:hover .sidebar-brand { justify-content: flex-start; padding-left: 1.25rem; padding-right: 1.25rem; }
    html.sidebar-collapsed .sidebar:hover .sidebar-brand .brand-text { display: block; }
    html.sidebar-collapsed .sidebar:hover .sidebar-section-label { text-align: left; padding: 1rem 1.35rem .4rem; }
    html.sidebar-collapsed .sidebar:hover .sidebar-nav .nav-link { justify-content: flex-start; padding-left: .75rem; padding-right: .75rem; }
    html.sidebar-collapsed .sidebar:hover .sidebar-nav .nav-link span { display: inline; }
    html.sidebar-collapsed .sidebar:hover .sidebar-promo { display: block; }
    html.sidebar-collapsed .sidebar:hover .sidebar-footer { justify-content: space-between; }
    html.sidebar-collapsed .sidebar:hover .sidebar-footer span { display: inline; }
}

.mini-switch {
    width: 38px; height: 20px;
    background: #1e293b;
    border-radius: 999px;
    position: relative;
    cursor: pointer;
    border: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}
.mini-switch .knob {
    position: absolute; top: 1px; left: 1px;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--accent);
    transition: transform .2s ease;
}
:root[data-theme="dark"] .mini-switch .knob { transform: translateX(18px); }

/* ============================================================================
   TOPBAR
   ============================================================================ */

.topbar {
    grid-area: topbar;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 900;
}

.sidebar-toggle-btn {
    border: 1px solid var(--border-color);
    background: var(--bg-subtle);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    width: 38px; height: 38px;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sidebar-toggle-btn:hover { color: var(--accent); border-color: var(--accent); }

.global-search {
    flex: 1 1 auto;
    max-width: 480px;
    position: relative;
}
.global-search input {
    width: 100%;
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    padding: .55rem 3.2rem .55rem 2.6rem;
    font-size: .85rem;
    color: var(--text-primary);
}
.global-search input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); background: var(--bg-surface); }
.global-search i.bi-search {
    position: absolute; left: .95rem; top: 50%; transform: translateY(-50%);
    color: var(--text-tertiary); font-size: .9rem;
}
.global-search .kbd-hint {
    position: absolute; right: .6rem; top: 50%; transform: translateY(-50%);
    font-size: .68rem; color: var(--text-tertiary);
    border: 1px solid var(--border-color); border-radius: 5px; padding: .05rem .35rem;
    background: var(--bg-surface);
}
.global-search-results {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0;
    background: var(--bg-elevated); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
    max-height: 340px; overflow-y: auto; z-index: 1000; padding: .4rem;
}
.global-search-results:empty { display: none; }
.global-search-results .gs-group-label { font-size: .68rem; font-weight: 700; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .05em; padding: .5rem .6rem .2rem; }
.global-search-results .gs-item { display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem; border-radius: var(--radius-sm); color: var(--text-primary); }
.global-search-results .gs-item:hover { background: var(--bg-subtle); }
.global-search-results .gs-item i { color: var(--text-tertiary); }
.global-search-results .gs-empty { padding: .75rem; text-align: center; color: var(--text-tertiary); font-size: .82rem; }

.topbar-actions { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }

.icon-btn {
    border: 1px solid var(--border-color);
    background: var(--bg-subtle);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    width: 38px; height: 38px;
    display: inline-flex; align-items: center; justify-content: center;
    position: relative;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn .dot-badge {
    position: absolute; top: -4px; right: -4px;
    min-width: 16px; height: 16px; border-radius: 999px;
    background: var(--red); color: #fff; font-size: .6rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center; padding: 0 3px;
    border: 2px solid var(--bg-surface);
}

.user-menu-btn {
    display: flex; align-items: center; gap: .6rem;
    border: 1px solid var(--border-color);
    background: var(--bg-subtle);
    border-radius: var(--radius-pill);
    padding: .3rem .9rem .3rem .3rem;
    color: var(--text-primary);
}
.user-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #f59e0b);
    color: #1a1206; font-weight: 800; font-size: .78rem;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; object-fit: cover;
}
.user-menu-btn .user-name { font-weight: 600; font-size: .8rem; line-height: 1.1; }
.user-menu-btn .user-role { font-size: .68rem; color: var(--text-tertiary); }

/* ---- Bell de notificaciones (topbar) ---- */

@keyframes li-notif-bell-alert {
    0%, 100% { transform: rotate(0); }
    18% { transform: rotate(13deg) scale(1.08); }
    36% { transform: rotate(-11deg) scale(1.08); }
    54% { transform: rotate(8deg) scale(1.04); }
    72% { transform: rotate(-5deg); }
}

#pvNotifBell.li-notif-alerting > i {
    color: var(--accent);
    transform-origin: 50% 12%;
    animation: li-notif-bell-alert .72s ease-in-out;
}

.pv-notif-dropdown {
    width: 340px; max-width: calc(100vw - 2rem);
    padding: 0; border: 1px solid var(--border-color); border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg); overflow: hidden;
}
.pv-notif-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: .7rem .9rem; border-bottom: 1px solid var(--border-color);
    font-weight: 700; font-size: .82rem; color: var(--text-primary);
}
.pv-notif-header button { font-size: .72rem; text-decoration: none; }
.pv-notif-list { max-height: 360px; overflow-y: auto; }
.pv-notif-empty { padding: 1.5rem 1rem; text-align: center; color: var(--text-tertiary); font-size: .82rem; }
.pv-notif-item {
    display: block; padding: .7rem .9rem; border-bottom: 1px solid var(--border-color);
    color: var(--text-primary); text-decoration: none;
}
.pv-notif-item:last-child { border-bottom: none; }
.pv-notif-item:hover { background: var(--bg-subtle); }
.pv-notif-item .pv-notif-title { font-weight: 700; font-size: .82rem; }
.pv-notif-item .pv-notif-message { font-size: .78rem; color: var(--text-secondary); margin-top: .1rem; }
.pv-notif-item .pv-notif-time { font-size: .68rem; color: var(--text-tertiary); margin-top: .2rem; }

/* ============================================================================
   CARDS Y COMPONENTES GENERALES
   ============================================================================ */

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: box-shadow .15s ease, border-color .15s ease;
}
.card:hover { box-shadow: var(--shadow-md); }

.section-title { font-weight: 700; font-size: .92rem; letter-spacing: -0.01em; }
.section-eyebrow { font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-tertiary); }

/* ---- KPI cards ---- */

.kpi-card {
    padding: 1.15rem;
    display: flex;
    flex-direction: column;
    gap: .7rem;
    height: 100%;
}
.kpi-icon {
    width: 40px; height: 40px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.kpi-icon.i-blue { background: var(--blue-soft); color: var(--blue); }
.kpi-icon.i-green { background: var(--green-soft); color: var(--green); }
.kpi-icon.i-purple { background: var(--purple-soft); color: var(--purple); }
.kpi-icon.i-orange { background: var(--orange-soft); color: var(--orange); }
.kpi-icon.i-red { background: var(--red-soft); color: var(--red); }
.kpi-icon.i-teal { background: var(--teal-soft); color: var(--teal); }

.kpi-label { font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-tertiary); }
.kpi-value { font-size: 1.55rem; font-weight: 800; letter-spacing: -0.02em; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.kpi-trend { font-size: .74rem; font-weight: 600; display: flex; align-items: center; gap: .25rem; }
.kpi-trend.up { color: var(--green); }
.kpi-trend.down { color: var(--red); }
.kpi-caption { font-size: .74rem; color: var(--text-tertiary); }

/* ---- Ranking list (productos más vendidos) ---- */

.rank-item { display: flex; align-items: center; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--border-color); }
.rank-item:last-child { border-bottom: none; }
.rank-badge {
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--bg-subtle); color: var(--text-secondary);
    font-size: .72rem; font-weight: 800;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.rank-item:nth-child(1) .rank-badge { background: var(--accent-soft); color: var(--accent-hover); }
.rank-info { flex: 1 1 auto; min-width: 0; }
.rank-name { font-weight: 600; font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-bar-track { height: 5px; border-radius: 999px; background: var(--bg-subtle); margin-top: .3rem; overflow: hidden; }
.rank-bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), #f59e0b); }
.rank-units { font-size: .76rem; font-weight: 700; color: var(--text-secondary); flex-shrink: 0; white-space: nowrap; }

/* ---- Panel de cartera (crédito) — card oscura destacada ---- */

.credit-panel {
    background: linear-gradient(155deg, var(--secondary-color), #182842);
    color: #fff;
    border-radius: var(--radius-md);
    padding: 1.25rem;
    height: 100%;
    display: flex;
    flex-direction: column;
}
.credit-panel .cp-label { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #93a4c2; }
.credit-panel .cp-total { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; margin: .2rem 0 1rem; }
.credit-panel .cp-row { display: flex; justify-content: space-between; padding: .5rem 0; border-top: 1px solid rgba(255,255,255,.08); font-size: .82rem; }
.credit-panel .cp-row span:first-child { color: #93a4c2; }
.credit-panel .cp-row span:last-child { font-weight: 700; }

/* ---- Badges de estado ---- */

.badge-status {
    display: inline-block;
    padding: .28rem .65rem;
    border-radius: var(--radius-pill);
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.badge-pendiente { background: var(--accent-soft); color: #92400e; }
.badge-parcial   { background: var(--blue-soft); color: #1e40af; }
.badge-vencida   { background: var(--red-soft); color: #991b1b; }
.badge-liquidada { background: var(--green-soft); color: #166534; }
.badge-cancelada { background: var(--bg-subtle); color: var(--text-secondary); }
.badge-aprobada  { background: var(--green-soft); color: #166534; }
.badge-rechazada { background: var(--red-soft); color: #991b1b; }
.badge-convertida_a_venta { background: var(--blue-soft); color: #1e40af; }

/* ---- Botones ---- */

.btn-brand {
    background: linear-gradient(135deg, var(--accent), #b45309);
    border: none;
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.28);
}
.btn-brand:hover { filter: brightness(1.08); color: #fff; box-shadow: 0 6px 16px rgba(217, 119, 6, 0.36); }
.btn-brand:active { transform: translateY(1px); }
.btn-brand:disabled { opacity: .6; }

/* ---- Auth ---- */

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 15% 15%, rgba(217,119,6,.18), transparent 45%),
        radial-gradient(circle at 85% 85%, rgba(37,99,235,.16), transparent 45%),
        linear-gradient(160deg, var(--secondary-color), #060a12);
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.25rem;
}

@media (max-width: 900px) {
    /* html.sidebar-collapsed (riel de iconos, ej. Dashboard vía
       $sidebarCollapsedByDefault, o preferencia guardada por el usuario)
       tiene mayor especificidad que .app-shell sola y, sin este selector
       repetido aquí, ganaba sobre esta media query — dejaba el riel de 80px
       fijo en vez del sidebar off-canvas, angostando todo el contenido en
       teléfono/tablet chica. */
    .app-shell,
    html.sidebar-collapsed .app-shell {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "topbar"
            "content";
    }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: 264px;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform .2s ease;
    }
    .app-shell.sidebar-open .sidebar { transform: translateX(0); }
    .global-search { display: none; }

    /* El riel de iconos (html.sidebar-collapsed) es una preferencia de
       escritorio (o el default forzado del Dashboard, ver
       DashboardController::index). En el drawer off-canvas de teléfono/
       tablet no debe heredarse: aquí el sidebar no compite por ancho con el
       contenido, así que ocultar las etiquetas de texto solo deja iconos
       sin nombre — y el truco de "peek" al pasar el mouse (arriba) no existe
       en touch, así que no habría ninguna forma de recuperarlas. */
    html.sidebar-collapsed .sidebar-brand .brand-text { display: block; }
    html.sidebar-collapsed .sidebar-brand { justify-content: flex-start; padding-left: 1.25rem; padding-right: 1.25rem; }
    html.sidebar-collapsed .sidebar-section-label { text-align: left; padding: 1rem 1.35rem .4rem; }
    html.sidebar-collapsed .sidebar-section-label .section-chevron { display: block; }
    html.sidebar-collapsed .sidebar-nav .nav-link { justify-content: flex-start; padding-left: .75rem; padding-right: .75rem; }
    html.sidebar-collapsed .sidebar-nav .nav-link span { display: inline; }
    html.sidebar-collapsed .sidebar-promo { display: block; }
    html.sidebar-collapsed .sidebar-footer { justify-content: space-between; }
    html.sidebar-collapsed .sidebar-footer span { display: inline; }
}

.status-chip {
    display: inline-flex; align-items: center; gap: .4rem;
    font-size: .72rem; font-weight: 700; color: var(--green);
    background: var(--green-soft); padding: .3rem .7rem; border-radius: var(--radius-pill);
}
.status-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }

#ecClientResults:empty { display: none; }
#ecClientResults { max-height: 220px; overflow-y: auto; background: var(--bg-elevated); border: 1px solid var(--border-color); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); }

/* ============================================================================
   POS — AUTOMOTIVE SALES TERMINAL (rediseño visual completo)
   La captura anterior se usó solo como referencia FUNCIONAL (qué controles y
   datos existen); la estructura visual se reconstruyó por completo: el POS
   ahora ocupa el viewport como una aplicación (sin scroll de página), con el
   área de productos como protagonista y un panel de operación (vendedor +
   cliente + tipo de venta + carrito) unificado a la derecha, con scroll
   independiente para productos y para el carrito.
   ============================================================================ */

.content--pos {
    display: flex;
    flex-direction: column;
    padding: 1.1rem 1.5rem 1.35rem;
    overflow: hidden;
    min-height: 0;
    max-width: none;
    margin: 0;
}

.pos-app { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: .85rem; }

/* ---- Sidebar inteligente en el POS: ocupa toda la pantalla, sin la
   columna del menú lateral (igual que el diseño de referencia), y solo se
   asoma bajo demanda con la pestaña angosta que inyecta pos.js. Solo en
   escritorio: en móvil el sidebar ya vive fuera de pantalla por defecto. ---- */
@media (min-width: 901px) {
    .app-shell.pos-fullscreen,
    html.sidebar-collapsed .app-shell.pos-fullscreen {
        grid-template-columns: 0 minmax(0, 1fr);
    }
    .app-shell.pos-fullscreen .sidebar { border-right: none; }
    .app-shell.pos-fullscreen .sidebar-toggle-btn { display: none; }

    .pos-sidebar-reveal {
        position: fixed;
        left: 0; top: 50%;
        transform: translateY(-50%);
        width: 16px; height: 60px;
        border: none; border-radius: 0 8px 8px 0;
        background: var(--sidebar-bg);
        color: var(--sidebar-text);
        opacity: .5;
        z-index: 1000;
        display: flex; align-items: center; justify-content: center;
        transition: opacity .15s ease, width .15s ease;
    }
    .pos-sidebar-reveal:hover { opacity: 1; width: 20px; }

    .app-shell.pos-fullscreen.pos-sidebar-open .sidebar {
        position: fixed;
        top: 0; bottom: 0; left: 0;
        width: 264px;
        z-index: 1150;
        box-shadow: var(--shadow-lg);
    }
}
@media (max-width: 900px) {
    .pos-sidebar-reveal { display: none; }
}

/* ---- Header de operación ---- */

.pos-header {
    flex: 0 0 auto;
    position: relative;
    overflow: hidden;
    background: linear-gradient(120deg, var(--secondary-color) 0%, #16233a 55%, #1c2740 100%);
    color: #fff;
    border-radius: var(--radius-md);
    padding: .85rem 1.35rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem;
    box-shadow: var(--shadow-md);
}
.pos-header::before {
    content: '';
    position: absolute; inset: 0;
    background: repeating-linear-gradient(115deg, rgba(255,255,255,.035) 0 2px, transparent 2px 46px);
    pointer-events: none;
}
.pos-header-left { display: flex; align-items: center; gap: .75rem; position: relative; z-index: 1; }
.pos-header-icon {
    width: 42px; height: 42px; border-radius: var(--radius-sm); flex-shrink: 0;
    background: linear-gradient(135deg, var(--accent), #f59e0b);
    display: flex; align-items: center; justify-content: center;
    color: #1a1206; font-size: 1.15rem;
    box-shadow: 0 4px 14px rgba(217,119,6,.35);
}
.pos-header .pos-title { font-weight: 800; font-size: 1.02rem; line-height: 1.2; }
.pos-header .pos-title small { display: block; color: #93a4c2; font-weight: 500; font-size: .74rem; margin-top: .1rem; }

.pos-steps { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; position: relative; z-index: 1; }
.pos-step { display: flex; align-items: center; gap: .45rem; font-size: .74rem; color: #6b7fa0; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
.pos-step .step-dot {
    width: 22px; height: 22px; border-radius: 50%;
    border: 2px solid #3a4a68; display: flex; align-items: center; justify-content: center;
    font-size: .66rem; font-weight: 800; color: #6b7fa0; flex-shrink: 0;
    transition: all .2s ease;
}
.pos-step.done .step-dot { background: var(--green); border-color: var(--green); color: #fff; }
.pos-step.active { color: #fff; }
.pos-step.active .step-dot { border-color: var(--accent); background: var(--accent); color: #fff; }
.pos-step-sep { width: 26px; height: 1px; background: #2c3a54; }
.pos-header-actions { position: relative; z-index: 1; display: flex; align-items: center; gap: .5rem; }
.pos-pending-btn { position: relative; }
.pos-pending-btn .dot-badge {
    position: absolute; top: -6px; right: -6px;
    min-width: 16px; height: 16px; border-radius: 999px;
    background: var(--red); color: #fff; font-size: .6rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center; padding: 0 3px;
    border: 2px solid var(--bg-surface);
}

/* ---- Columna de búsqueda + categorías (primera columna del POS) ---- */

.pos-category-sidebar {
    flex: 0 0 208px;
    min-width: 188px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: .75rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 1rem .85rem;
    overflow-y: auto;
}

.pos-search-wrap { position: relative; flex: 0 0 auto; }
.pos-search-wrap input {
    width: 100%;
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: .6rem .7rem .6rem 2.3rem;
    font-size: .8rem;
    font-weight: 500;
    color: var(--text-primary);
}
.pos-search-wrap input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); background: var(--bg-surface); }
.pos-search-wrap i.bi-search { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); font-size: .85rem; }

.pos-categories { display: flex; flex-direction: column; gap: .3rem; }
.pos-category-pill {
    width: 100%;
    text-align: left;
    border: 1px solid transparent;
    background: none;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    padding: .5rem .7rem;
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all .15s ease;
}
.pos-category-pill:hover { background: var(--bg-subtle); color: var(--accent); }
.pos-category-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 3px 10px rgba(217,119,6,.3); }

/* ---- Área principal: productos + panel de operación ---- */

.pos-main { flex: 1 1 auto; min-height: 0; display: flex; gap: .85rem; }

.pos-products-panel {
    flex: 1.6 1 0;
    min-width: 320px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: .75rem;
}

.pos-product-grid {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
    gap: .55rem;
    align-content: start;
    padding: .1rem .1rem .3rem;
}
.pos-empty-msg { grid-column: 1 / -1; text-align: center; color: var(--text-tertiary); padding: 3rem 1rem; }
.pos-empty-msg i { font-size: 2rem; display: block; margin-bottom: .5rem; opacity: .5; }

.pos-product-card {
    position: relative;
    cursor: pointer;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    transition: box-shadow .18s ease, transform .12s ease, border-color .18s ease;
}
.pos-product-card:hover { box-shadow: var(--shadow-md); border-color: var(--accent); transform: translateY(-2px); }
.pos-product-card:active { transform: translateY(0) scale(.99); }

.pos-product-thumb {
    position: relative;
    height: 64px;
    flex-shrink: 0;
    border-radius: calc(var(--radius-sm) - 1px) calc(var(--radius-sm) - 1px) 0 0;
    background: radial-gradient(circle at 30% 20%, rgba(217,119,6,.14), transparent 60%), var(--bg-subtle);
    display: flex; align-items: center; justify-content: center;
    color: var(--accent);
    font-size: 1.3rem;
    border-bottom: 1px solid var(--border-color);
    transition: transform .2s ease;
}
.pos-product-card:hover .pos-product-thumb { transform: scale(1.04); }

.pos-product-body { padding: .5rem .55rem .55rem; display: flex; flex-direction: column; gap: .15rem; flex: 1 1 auto; }
.pos-product-name {
    font-weight: 700; font-size: .72rem; line-height: 1.2; color: var(--text-primary);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pos-product-meta { color: var(--text-tertiary); font-size: .6rem; font-weight: 600; letter-spacing: .01em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pos-product-price { font-weight: 800; color: var(--text-primary); font-size: .88rem; letter-spacing: -.01em; margin-top: .05rem; font-variant-numeric: tabular-nums; }

.pos-product-stock-row { display: flex; align-items: center; gap: .3rem; font-size: .62rem; font-weight: 600; color: var(--text-secondary); }
.pos-stock-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.pos-product-stock-row.stock-low .pos-stock-dot { background: var(--warning-color); }
.pos-product-stock-row.stock-critical .pos-stock-dot { background: var(--danger-color); }
.pos-product-stock-row.stock-out .pos-stock-dot { background: var(--text-tertiary); }
.pos-product-stock-row.stock-out { color: var(--text-tertiary); }

.pos-add-btn {
    position: absolute;
    top: -8px; right: -8px;
    width: 26px; height: 26px;
    border: 2px solid var(--bg-surface);
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: .68rem;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 3px 8px rgba(217,119,6,.4);
    transition: transform .15s ease, filter .15s ease;
}
.pos-add-btn:hover { filter: brightness(1.1); transform: scale(1.08); }
.pos-add-btn:disabled { background: var(--text-tertiary); box-shadow: none; cursor: not-allowed; }

/* ---- Skeleton loader ---- */

.pos-skeleton-card { border-radius: var(--radius-sm); border: 1px solid var(--border-color); overflow: hidden; background: var(--bg-elevated); }
.pos-skeleton-card .sk-thumb, .pos-skeleton-card .sk-line {
    background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--border-color) 37%, var(--bg-subtle) 63%);
    background-size: 400% 100%;
    animation: sk-shimmer 1.4s ease infinite;
}
.pos-skeleton-card .sk-thumb { height: 64px; }
.pos-skeleton-card .sk-body { padding: .55rem; display: flex; flex-direction: column; gap: .4rem; }
.pos-skeleton-card .sk-line { height: 8px; border-radius: 4px; }
.pos-skeleton-card .sk-line.w-60 { width: 60%; }
.pos-skeleton-card .sk-line.w-40 { width: 40%; }
.pos-skeleton-card .sk-line.w-80 { width: 80%; }
@keyframes sk-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ---- Tercera columna: datos de la operación (vendedor + cliente + tipo) ----
   Columna angosta e independiente, separada del carrito, para que el
   carrito pueda ocupar un ancho real (antes el panel de operación se
   comía el espacio del carrito al compartir la misma caja). */

.pos-op-panel {
    flex: 0 0 248px;
    max-width: 280px;
    min-width: 220px;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: .75rem;
    padding-bottom: .1rem;
}
.pos-op-card {
    flex-shrink: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 1rem 1.1rem;
}
.pos-op-heading { font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--text-tertiary); margin-bottom: .7rem; }

/* ---- Estado del sistema: indicador decorativo, igual que los pasos del
   header — confirma de un vistazo que el POS está operando con normalidad. ---- */
.pos-status-card {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: .7rem;
    background: linear-gradient(120deg, var(--secondary-color) 0%, #16233a 100%);
    border-radius: var(--radius-md);
    padding: .9rem 1.1rem;
    box-shadow: var(--shadow-sm);
}
.pos-status-dot {
    width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
    background: var(--green);
    box-shadow: 0 0 0 4px rgba(22,163,74,.2);
    animation: pos-status-pulse 2s ease-in-out infinite;
}
@keyframes pos-status-pulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(22,163,74,.2); }
    50% { box-shadow: 0 0 0 7px rgba(22,163,74,.08); }
}
.pos-status-title { color: #fff; font-weight: 800; font-size: .78rem; letter-spacing: .01em; }
.pos-status-sub { color: #93a4c2; font-size: .68rem; line-height: 1.4; margin-top: .1rem; }

.pos-select, .pos-input {
    width: 100%;
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: .5rem .7rem;
    font-size: .82rem;
    color: var(--text-primary);
}
.pos-select:focus, .pos-input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); background: var(--bg-surface); }

.pos-client-search-wrap { position: relative; }
.pos-client-search-wrap i { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); font-size: .85rem; }
.pos-client-search-wrap input { padding-left: 2.1rem; }
#posClientResults { position: absolute; z-index: 1000; width: 100%; margin-top: .3rem; max-height: 220px; overflow-y: auto; background: var(--bg-elevated); border: 1px solid var(--border-color); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); }
#posClientResults:empty { display: none; border: none; box-shadow: none; }
.pos-client-option { display: block; width: 100%; text-align: left; border: none; background: none; padding: .55rem .75rem; font-size: .8rem; color: var(--text-primary); border-bottom: 1px solid var(--border-color); }
.pos-client-option:last-child { border-bottom: none; }
.pos-client-option:hover { background: var(--bg-subtle); }

.pos-selected-entity {
    display: flex; flex-direction: column; gap: .65rem;
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: .65rem .7rem;
    margin-top: .55rem;
}
.pos-selected-entity .entity-row-top { display: flex; align-items: center; gap: .65rem; }
.pos-selected-entity .avatar-chip {
    width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: .78rem; color: #fff;
    background: linear-gradient(135deg, var(--blue), #1e40af);
}
.pos-selected-entity .entity-name-wrap { min-width: 0; }
.pos-selected-entity .entity-name { font-weight: 700; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pos-selected-entity .entity-meta, .pos-selected-entity .entity-code { font-size: .71rem; color: var(--text-tertiary); }
.pos-selected-entity .entity-clear { margin-left: auto; color: var(--text-tertiary); cursor: pointer; padding: .2rem; flex-shrink: 0; }
.pos-selected-entity .entity-clear:hover { color: var(--danger-color); }

.pos-selected-entity .entity-stats { display: flex; flex-direction: column; gap: .35rem; padding-top: .6rem; border-top: 1px dashed var(--border-color); }
.pos-selected-entity .entity-stat { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.pos-selected-entity .stat-label { font-size: .69rem; color: var(--text-tertiary); font-weight: 600; }
.pos-selected-entity .stat-value { font-size: .78rem; font-weight: 800; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.pos-selected-entity .stat-value.positive { color: var(--green); }
.pos-selected-entity .stat-value.warn { color: var(--warning-color); }

/* ---- Preventas pendientes (modal, tomadas desde el módulo Preventa) ---- */

.pos-pending-row {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: .85rem 0; border-bottom: 1px solid var(--border-color);
}
.pos-pending-row:last-child { border-bottom: none; }
.pos-pending-info { min-width: 0; }
.pos-pending-folio { font-weight: 800; color: var(--text-primary); font-size: .88rem; }
.pos-pending-client { font-size: .84rem; color: var(--text-secondary); margin-top: .1rem; }
.pos-pending-meta { font-size: .72rem; color: var(--text-tertiary); margin-top: .15rem; }
.pos-pending-trailing { display: flex; flex-direction: column; align-items: flex-end; gap: .4rem; flex-shrink: 0; }
.pos-pending-total { font-weight: 800; color: var(--text-primary); font-size: .92rem; }
.pos-pending-issues { margin-top: .35rem; font-size: .72rem; font-weight: 700; color: #d97706; overflow-wrap: anywhere; }
.pos-pending-actions { display: flex; align-items: center; gap: .35rem; }
@media (max-width: 575px) {
    .pos-pending-row { flex-direction: column; align-items: stretch; }
    .pos-pending-trailing { flex-direction: row; align-items: center; justify-content: space-between; }
}

/* Diálogo "Devolver al vendedor" (SweetAlert) */
.pos-return-intro { margin: 0 0 .6rem; font-size: .88rem; color: var(--text-secondary); text-align: left; }
.pos-return-warn { margin: 0 0 .6rem; padding: .5rem .7rem; border-radius: 8px; background: rgba(245, 158, 11, .14); color: #b45309; font-size: .8rem; text-align: left; }

.pos-type-toggle { display: flex; gap: .5rem; }
.pos-type-toggle label {
    flex: 1 1 0; display: flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .55rem .5rem; border-radius: var(--radius-sm);
    border: 1px solid var(--border-color); background: var(--bg-subtle);
    font-size: .78rem; font-weight: 700; color: var(--text-secondary);
    cursor: pointer; transition: all .15s ease;
}
.pos-type-toggle .btn-check:checked + label { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 3px 10px rgba(217,119,6,.3); }
.pos-type-toggle .btn-check:focus-visible + label { box-shadow: var(--focus-ring); }

.pos-term-row { margin-top: .75rem; }
.pos-term-label { font-size: .66rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-tertiary); margin-bottom: .4rem; }
.pos-term-pills { display: flex; flex-wrap: wrap; gap: .4rem; }
.pos-term-pill { border: 1px solid var(--border-color); background: var(--bg-subtle); color: var(--text-secondary); border-radius: var(--radius-pill); padding: .32rem .75rem; font-size: .72rem; font-weight: 700; }
.pos-term-pill:hover { border-color: var(--accent); color: var(--accent); }
.pos-term-pill.active { background: var(--secondary-color); border-color: var(--secondary-color); color: #fff; }

/* Tarjeta 2: carrito — su propia caja, con más peso visual que antes
   (header + lista con scroll propio + totales/botón fijos abajo, todo
   dentro de esta misma tarjeta) para que se perciba de inmediato cuando
   cambia. */
.pos-cart-card {
    flex: 1 1 0;
    min-width: 300px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow .2s ease;
}
.pos-cart-card.flash-add { animation: pos-cart-flash .6s ease; }
@keyframes pos-cart-flash {
    0% { box-shadow: 0 0 0 3px rgba(217,119,6,.45); border-color: var(--accent); }
    100% { box-shadow: var(--shadow-sm); border-color: var(--border-color); }
}

.pos-cart-header {
    display: flex; align-items: center; justify-content: space-between; flex: 0 0 auto;
    padding: .9rem 1.1rem; border-bottom: 1px solid var(--border-color);
    background: var(--bg-subtle);
}
.pos-cart-header-actions { display: flex; align-items: center; gap: .5rem; }
.pos-cart-count { min-width: 24px; height: 24px; padding: 0 .4rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent-hover); font-weight: 800; font-size: .76rem; display: flex; align-items: center; justify-content: center; transition: transform .2s ease; }
.pos-cart-count.bump { transform: scale(1.35); }

/* ---- Producto promo (costo $0) ----
   Ver pos.js sección "producto promo": arma promoMode y el próximo clic (o
   drop) sobre la grilla agrega ese producto con precio $0. */
.pos-promo-btn {
    display: inline-flex; align-items: center; gap: .35rem;
    border: 1px solid var(--border-color); background: var(--bg-surface); color: var(--text-secondary);
    border-radius: 999px; padding: .3rem .65rem; font-size: .72rem; font-weight: 700;
    transition: all .15s ease;
}
.pos-promo-btn i { font-size: .8rem; }
.pos-promo-btn:hover { border-color: var(--accent); color: var(--accent); }
.pos-promo-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.pos-promo-banner {
    display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
    background: var(--accent-soft); border: 1px dashed var(--accent); color: var(--accent-hover);
    border-radius: var(--radius-md); padding: .6rem .9rem; margin-bottom: .7rem;
    font-size: .82rem; font-weight: 600;
}
.pos-promo-banner i { font-size: 1rem; }
.pos-promo-banner button {
    margin-left: auto; border: none; background: none; color: inherit; font-weight: 700;
    font-size: .76rem; text-decoration: underline; padding: 0;
}
.pos-product-grid.pos-promo-picking { outline: 2px dashed var(--accent); outline-offset: 6px; border-radius: var(--radius-md); }

.pos-promo-badge {
    display: inline-flex; align-items: center; gap: .2rem;
    background: var(--accent-soft); color: var(--accent-hover);
    border-radius: 999px; padding: .05rem .4rem; font-size: .62rem; font-weight: 800;
    text-transform: uppercase; letter-spacing: .03em; margin-left: .35rem; vertical-align: middle;
}
.pos-promo-badge i { font-size: .68rem; }
.pos-cart-item-promo { background: var(--accent-soft); }

.pos-cart-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: .3rem 1.1rem 0; }

.pos-cart-empty {
    height: 100%; min-height: 200px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: var(--text-tertiary); text-align: center; gap: .3rem; padding: 1rem;
}
.pos-cart-empty i { font-size: 2.1rem; margin-bottom: .3rem; opacity: .55; }
.pos-cart-empty p { font-weight: 700; color: var(--text-secondary); margin: 0; }
.pos-cart-empty small { font-size: .75rem; }

.pos-cart-item { display: flex; align-items: flex-start; gap: .5rem; padding: .7rem 0; border-bottom: 1px solid var(--border-color); background: var(--bg-surface); }
.pos-cart-item:last-child { border-bottom: none; }
.pos-cart-thumb {
    width: 36px; height: 36px; border-radius: var(--radius-sm);
    background: var(--bg-subtle); color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; font-size: .95rem; margin-top: .1rem;
}
.pos-cart-info { flex: 1 1 auto; min-width: 0; }
.pos-cart-name { font-weight: 700; font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pos-cart-meta { font-size: .68rem; color: var(--text-tertiary); margin-top: .1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pos-qty-stepper { display: flex; align-items: center; gap: .4rem; margin-top: .35rem; }
.pos-qty-stepper button {
    width: 22px; height: 22px; border-radius: 6px;
    border: 1px solid var(--border-color); background: var(--bg-subtle);
    display: flex; align-items: center; justify-content: center;
    font-size: .8rem; line-height: 1; color: var(--text-secondary); font-weight: 700;
}
.pos-qty-stepper button:hover { border-color: var(--accent); color: var(--accent); }
.pos-qty-stepper span { font-size: .8rem; font-weight: 800; min-width: 18px; text-align: center; }

/* Precio 100% editable — reemplaza al antiguo input de descuento (ver
   pos.js: setPrice()). "Lista" solo aparece cuando el precio de venta ya no
   coincide con el precio de catálogo, a modo de referencia. */
.pos-price-row { display: flex; align-items: center; gap: .4rem; margin-top: .4rem; flex-wrap: wrap; }
.pos-price-row label { font-size: .68rem; color: var(--text-tertiary); font-weight: 600; }
.pos-price-edit {
    display: flex; align-items: center; gap: .15rem;
    border: 1px solid var(--border-color); background: var(--bg-subtle); border-radius: 6px;
    padding: 0 .35rem; transition: border-color .15s ease;
}
.pos-price-edit:focus-within { border-color: var(--accent); }
.pos-price-edit span { font-size: .76rem; color: var(--text-tertiary); font-weight: 700; }
.pos-price-edit input {
    width: 74px; border: none; background: none; padding: .28rem .1rem;
    font-size: .78rem; font-weight: 700; color: var(--text-primary);
}
.pos-price-edit input:focus { outline: none; }
.pos-price-list { font-size: .66rem; color: var(--text-tertiary); text-decoration: line-through; }

/* Precio habitual del cliente (informativo, sección 26 del prompt de
   precios por cliente): mismo formato que .pos-promo-badge, otro color. */
.pos-client-price-badge {
    display: inline-flex; align-items: center; gap: .2rem;
    background: var(--success-soft, rgba(34, 197, 94, .14)); color: var(--success-color, #16a34a);
    border-radius: 999px; padding: .05rem .4rem; font-size: .62rem; font-weight: 800;
    text-transform: uppercase; letter-spacing: .03em; vertical-align: middle;
}
.pos-client-price-badge i { font-size: .68rem; }

.pos-cart-subtotal { font-weight: 800; font-size: .85rem; white-space: nowrap; color: var(--text-primary); }
.pos-cart-remove { color: var(--text-tertiary); background: none; border: none; padding: 0; }
.pos-cart-remove:hover { color: var(--danger-color); }

/* ---- Reordenar el carrito: handle de arrastre + subir/bajar ----
   Ver pos.js sección "arrastrar para reordenar". El handle usa Pointer
   Events (mouse, touch y pen con el mismo código) en vez del Drag & Drop
   nativo del navegador, que no dispara en touch — por eso NO es un atributo
   draggable, es un botón con su propio manejo de pointerdown/move/up. */
.pos-drag-handle {
    display: flex; align-items: center; justify-content: center;
    width: 20px; align-self: stretch; flex-shrink: 0;
    border: none; background: none; padding: 0; margin-top: .1rem;
    color: var(--text-tertiary); border-radius: 6px;
    cursor: grab; touch-action: none;
    transition: color .15s ease, background-color .15s ease;
}
.pos-drag-handle:hover { color: var(--accent); background: var(--bg-subtle); }
.pos-drag-handle:active { cursor: grabbing; }
.pos-drag-handle i { font-size: .95rem; pointer-events: none; }

.pos-cart-trailing { display: flex; flex-direction: column; align-items: flex-end; gap: .35rem; flex-shrink: 0; }
.pos-cart-order-actions { display: flex; align-items: center; gap: .1rem; }
.pos-order-btn {
    width: 20px; height: 20px; padding: 0; border: none; background: none;
    color: var(--text-tertiary); border-radius: 5px;
    display: flex; align-items: center; justify-content: center;
    transition: color .15s ease, background-color .15s ease;
}
.pos-order-btn i { font-size: .74rem; pointer-events: none; }
.pos-order-btn:hover:not(:disabled) { color: var(--accent); background: var(--bg-subtle); }
.pos-order-btn:disabled { opacity: .3; cursor: not-allowed; }

/* Tarjeta que el usuario está arrastrando: se saca del flujo (position:fixed
   en pos.js) para poder seguir libremente al puntero; aquí solo el aspecto
   visual — sombra elevada + leve escala, sin cambiar sus dimensiones. */
.pos-cart-item.pos-dragging {
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    transform: scale(1.015);
    cursor: grabbing;
}
.pos-cart-placeholder {
    border: 2px dashed var(--accent);
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    margin: 2px 0;
    box-sizing: border-box;
}

body.pos-dragging-active { cursor: grabbing; }
body.pos-dragging-active * { user-select: none !important; -webkit-user-select: none !important; }

/* Zona de soltado: una franja compacta con feedback claro (check + nombre
   del producto), NO un overlay que tape el carrito — la lista y el total
   quedan visibles y en su lugar todo el tiempo. Se anima por max-height
   para aparecer/desaparecer sin saltos ni mover el resto del layout. */
.pos-drop-hint {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    margin: 0 1.1rem;
    border: 2px dashed transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    transition: max-height .22s ease, opacity .18s ease, margin .22s ease,
                border-color .22s ease, background-color .22s ease;
}
.pos-drop-hint-inner {
    display: flex; align-items: center; gap: .6rem;
    padding: 0 .9rem; color: var(--green);
}
.pos-drop-hint-inner i { font-size: 1.3rem; flex-shrink: 0; }
.pos-drop-hint-copy { display: flex; flex-direction: column; text-align: left; line-height: 1.25; overflow: hidden; }
.pos-drop-hint-copy strong { font-size: .82rem; font-weight: 800; }
.pos-drop-hint-copy span {
    display: block; font-size: .74rem; font-weight: 600; color: var(--text-secondary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pos-cart-card.pos-dropzone-active .pos-drop-hint {
    max-height: 64px;
    opacity: 1;
    margin: .75rem 1.1rem 0;
    border-color: var(--green);
    background: var(--green-soft);
}
.pos-cart-card.pos-dropzone-active .pos-drop-hint .pos-drop-hint-inner { padding: .7rem .9rem; }

/* Tarjeta de origen mientras se arrastra: se atenúa en la grilla para dejar
   claro que "se está moviendo", sin animaciones bruscas de layout. */
.pos-product-card.pos-card-dragging { opacity: .45; transition: opacity .15s ease; }

.pos-op-footer { flex: 0 0 auto; padding: .85rem 1.1rem 1.05rem; border-top: 1px solid var(--border-color); background: var(--bg-subtle); }
.pos-totals-row { display: flex; justify-content: space-between; align-items: center; padding: .2rem 0; font-size: .82rem; color: var(--text-secondary); }
.pos-total-final { display: flex; justify-content: space-between; align-items: baseline; padding-top: .5rem; margin-top: .3rem; border-top: 1px dashed var(--border-color); }
.pos-total-final .label { font-weight: 800; text-transform: uppercase; font-size: .72rem; letter-spacing: .05em; color: var(--text-tertiary); }
.pos-total-final .value { font-size: 1.7rem; font-weight: 800; color: var(--text-primary); font-variant-numeric: tabular-nums; }

.pos-submit-btn {
    width: 100%; margin-top: .8rem; padding: .9rem; border-radius: var(--radius-md);
    font-size: .92rem; font-weight: 700; border: none; color: #fff;
    background: linear-gradient(135deg, var(--accent), #b45309);
    box-shadow: 0 4px 14px rgba(217,119,6,.32);
    display: flex; align-items: center; justify-content: center; gap: .5rem;
    transition: filter .15s ease, transform .1s ease;
}
.pos-submit-btn:hover:not(:disabled) { filter: brightness(1.08); }
.pos-submit-btn:active:not(:disabled) { transform: translateY(1px); }
.pos-submit-btn:disabled { opacity: .65; }

/* ---- Toasts ---- */

#posToastHost { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 1200; display: flex; flex-direction: column; gap: .5rem; align-items: flex-end; pointer-events: none; }
.pos-toast {
    display: flex; align-items: center; gap: .55rem;
    background: var(--bg-elevated); color: var(--text-primary);
    border: 1px solid var(--border-color); border-left: 3px solid var(--green);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
    padding: .65rem .9rem; font-size: .82rem; font-weight: 600;
    animation: pos-toast-in .2s ease;
}
.pos-toast.warn { border-left-color: var(--warning-color); }
.pos-toast i { color: var(--green); }
.pos-toast.warn i { color: var(--warning-color); }
.pos-toast.fade-out { animation: pos-toast-out .2s ease forwards; }
@keyframes pos-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pos-toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ---- FAB de carrito (mobile) ---- */

.pos-mobile-cart-fab {
    display: none; position: fixed; right: 1.1rem; bottom: 1.1rem; z-index: 1100;
    align-items: center; gap: .5rem; border: none; border-radius: 999px;
    background: linear-gradient(135deg, var(--accent), #b45309); color: #fff;
    padding: .8rem 1.2rem; font-weight: 800; font-size: .85rem;
    box-shadow: 0 8px 22px rgba(217,119,6,.4);
}
.pos-mobile-cart-fab .fab-count { background: rgba(255,255,255,.25); border-radius: 999px; padding: .05rem .5rem; font-size: .78rem; }

/* ---- Reskin SweetAlert2 (confirmaciones y alertas del POS) ---- */

.swal2-popup { border-radius: var(--radius-lg) !important; background: var(--bg-elevated) !important; color: var(--text-primary) !important; font-family: 'Inter', 'Segoe UI', system-ui, sans-serif; }
.swal2-title { font-size: 1.05rem !important; font-weight: 800 !important; color: var(--text-primary) !important; }
.swal2-html-container { font-size: .88rem !important; color: var(--text-secondary) !important; }
.swal2-confirm { background: linear-gradient(135deg, var(--accent), #b45309) !important; border-radius: var(--radius-sm) !important; font-weight: 700 !important; box-shadow: none !important; }
.swal2-cancel { background: var(--bg-subtle) !important; color: var(--text-secondary) !important; border-radius: var(--radius-sm) !important; font-weight: 700 !important; }
.swal2-styled:focus { box-shadow: var(--focus-ring) !important; }
.swal2-select, .swal2-input { background: var(--bg-subtle) !important; color: var(--text-primary) !important; border: 1px solid var(--border-color) !important; box-shadow: none !important; }

/* ---- Responsive ---- */

@media (max-width: 1500px) {
    .pos-op-panel { flex-basis: 224px; min-width: 210px; }
    .pos-category-sidebar { flex-basis: 184px; min-width: 168px; }
}

@media (max-width: 1300px) {
    .pos-op-panel { flex-basis: 210px; min-width: 190px; padding: .85rem .9rem .2rem; }
    .pos-category-sidebar { flex-basis: 168px; min-width: 156px; padding: .85rem .7rem; }
    .pos-cart-card { min-width: 260px; }
    .pos-products-panel { min-width: 240px; }
    .pos-product-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
}

@media (max-width: 1050px) {
    .pos-main { flex-wrap: wrap; }
    .pos-category-sidebar { flex: 1 1 100%; flex-direction: row; align-items: center; overflow-x: auto; overflow-y: visible; }
    .pos-category-sidebar .pos-search-wrap { flex: 0 0 220px; }
    .pos-categories { flex-direction: row; }
    .pos-category-pill { width: auto; white-space: nowrap; }
    .pos-products-panel, .pos-cart-card { flex: 1 1 320px; }
    .pos-products-panel { min-height: 46vh; }
    .pos-cart-card { min-height: 380px; }
    .pos-op-panel { flex-basis: auto; max-width: none; min-width: 0; overflow-y: visible; width: 100%; }
}

@media (max-width: 900px) {
    .content--pos { padding: .9rem 1rem 1rem; overflow-y: auto; }
    .pos-header { padding: .75rem 1rem; }
    .pos-steps { display: none; }
}

@media (max-width: 560px) {
    .pos-mobile-cart-fab { display: flex; }
    .pos-product-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}
