/* =====================================================================================================
   POS-Admin · Design System v2
   Base: Bootstrap 5.3 (se sobreescriben sus variables CSS, no se reemplaza el framework).
   Estructura:
     1. Tokens (paleta, tipografía, radios, sombras) · claro / oscuro
     2. Base y tipografía
     3. Componentes Bootstrap afinados (botones, inputs, cards, tablas, badges, dropdowns, modales…)
     4. Shell: sidebar, navbar, contenido, footer
     5. Patrones de página: page-head, KPIs, filtros, estados vacíos
     6. Módulo POS
     7. Utilidades, Tom Select, responsive, impresión, accesibilidad
   Todas las clases antiguas (.kpi, .badge-stock-*, .pag-bar, .prod-card, .cart-line…) se conservan.
   ===================================================================================================== */

/* ---------------------------------------------------------------- 1. Tokens */
:root {
    /* Marca */
    --pos-primary: #2451d6;           /* Azul corporativo: confianza / tecnología */
    --pos-primary-hover: #1c41b3;
    --pos-primary-soft: #eaf0fd;
    --pos-primary-rgb: 36, 81, 214;
    --pos-secondary: #475569;         /* Pizarra: acciones secundarias */
    --pos-accent: #e11d48;            /* Acento de marca (heredado del rojo corporativo) */

    /* Semánticos */
    --pos-success: #15803d;
    --pos-success-soft: #e7f6ec;
    --pos-warning: #b45309;
    --pos-warning-soft: #fdf3e1;
    --pos-danger: #dc2626;
    --pos-danger-soft: #fdeceb;
    --pos-info: #0369a1;
    --pos-info-soft: #e6f3fb;

    /* Neutros */
    --pos-bg: #f6f7fb;
    --pos-surface: #ffffff;
    --pos-surface-2: #f9fafc;
    --pos-text: #0f172a;
    --pos-text-2: #334155;
    --pos-muted: #64748b;
    --pos-border: #e4e7ef;
    --pos-border-strong: #cfd5e1;
    --pos-hover: #f1f4f9;

    /* Sidebar (oscuro en ambos temas: separa navegación de contenido) */
    --sb-bg: #0f172a;
    --sb-bg-2: #131c33;
    --sb-text: #cbd5e1;
    --sb-text-strong: #ffffff;
    --sb-muted: #7c8aa5;
    --sb-hover: rgba(255, 255, 255, .06);
    --sb-active: rgba(91, 132, 245, .16);
    --sb-active-bar: #6d93ff;

    /* Layout */
    --sidebar-w: 264px;
    --sidebar-rail: 72px;
    --navbar-h: 60px;

    /* Forma */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-md: 0 8px 24px -6px rgba(15, 23, 42, .12), 0 2px 6px rgba(15, 23, 42, .05);
    --shadow-lg: 0 24px 48px -12px rgba(15, 23, 42, .25);
    --focus-ring: 0 0 0 3px rgba(var(--pos-primary-rgb), .25);
    --ease: cubic-bezier(.2, .7, .2, 1);

    /* Alias heredados (otras vistas / scripts los usan) */
    --pos-blue: var(--pos-primary);
    --pos-blue-dark: var(--pos-primary-hover);
    --pos-blue-light: var(--pos-primary-soft);
    --pos-red: var(--pos-danger);
    --pos-red-dark: #b91c1c;
    --pos-white: #ffffff;

    /* Bootstrap */
    --bs-primary: var(--pos-primary);
    --bs-primary-rgb: var(--pos-primary-rgb);
    --bs-secondary: var(--pos-secondary);
    --bs-secondary-rgb: 71, 85, 105;
    --bs-success: var(--pos-success);
    --bs-success-rgb: 21, 128, 61;
    --bs-warning: #d97706;
    --bs-warning-rgb: 217, 119, 6;
    --bs-danger: var(--pos-danger);
    --bs-danger-rgb: 220, 38, 38;
    --bs-info: var(--pos-info);
    --bs-info-rgb: 3, 105, 161;
    --bs-body-bg: var(--pos-bg);
    --bs-body-color: var(--pos-text);
    --bs-secondary-color: var(--pos-muted);
    --bs-border-color: var(--pos-border);
    --bs-border-radius: var(--radius-sm);
    --bs-border-radius-lg: var(--radius);
    --bs-link-color: var(--pos-primary);
    --bs-link-color-rgb: var(--pos-primary-rgb);
    --bs-link-hover-color: var(--pos-primary-hover);
    --bs-font-sans-serif: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

[data-bs-theme="dark"] {
    --pos-primary: #5b84f5;
    --pos-primary-hover: #7a9bf7;
    --pos-primary-soft: rgba(91, 132, 245, .14);
    --pos-primary-rgb: 91, 132, 245;
    --pos-secondary: #94a3b8;
    --pos-success: #34c26c;
    --pos-success-soft: rgba(52, 194, 108, .14);
    --pos-warning: #f0a53a;
    --pos-warning-soft: rgba(240, 165, 58, .14);
    --pos-danger: #f26363;
    --pos-danger-soft: rgba(242, 99, 99, .14);
    --pos-info: #38b2e8;
    --pos-info-soft: rgba(56, 178, 232, .14);

    --pos-bg: #0b0f19;
    --pos-surface: #121826;
    --pos-surface-2: #161d2d;
    --pos-text: #e6e9f0;
    --pos-text-2: #c4cad6;
    --pos-muted: #8d97ab;
    --pos-border: #232b3d;
    --pos-border-strong: #313b52;
    --pos-hover: #1a2234;

    --sb-bg: #0a0e17;
    --sb-bg-2: #0d1220;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .45);
    --shadow-md: 0 8px 24px -6px rgba(0, 0, 0, .6);
    --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, .7);

    --bs-primary-rgb: 91, 132, 245;
    --bs-success-rgb: 52, 194, 108;
    --bs-danger-rgb: 242, 99, 99;
    --bs-warning-rgb: 240, 165, 58;
    --bs-info-rgb: 56, 178, 232;
    --bs-body-bg: var(--pos-bg);
    --bs-body-color: var(--pos-text);
    --bs-border-color: var(--pos-border);
    --bs-secondary-bg: var(--pos-surface-2);
    --bs-tertiary-bg: var(--pos-surface-2);
    --bs-link-color: #86a6f8;
    --bs-link-color-rgb: 134, 166, 248;
    --bs-link-hover-color: #a9c0fa;
}

/* ---------------------------------------------------------------- 2. Base */
html {
    -webkit-text-size-adjust: 100%;
}

body {
    background: var(--pos-bg);
    color: var(--pos-text);
    font-family: var(--bs-font-sans-serif);
    font-size: .875rem;
    line-height: 1.5;
    font-feature-settings: "cv11", "ss01";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
    color: var(--pos-text);
    font-weight: 650;
    letter-spacing: -.01em;
}

a {
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.btn:hover, .dropdown-item:hover, .page-link:hover, .sb-link:hover, .nav-link:hover, .list-group-item:hover,
a.card:hover, a.text-reset:hover, .stretched-link:hover, .text-decoration-none:hover {
    text-decoration: none;
}

.text-muted, .text-body-secondary {
    color: var(--pos-muted) !important;
}

.tabular, .table td.text-end, .kpi .val, .totals, .money {
    font-variant-numeric: tabular-nums;
}

hr {
    border-color: var(--pos-border);
    opacity: 1;
}

::selection {
    background: rgba(var(--pos-primary-rgb), .2);
}

/* Foco visible y consistente (WCAG 2.4.7) */
:focus-visible {
    outline: 2px solid var(--pos-primary);
    outline-offset: 2px;
}

.btn:focus-visible, .form-control:focus, .form-select:focus, .form-check-input:focus, .page-link:focus {
    outline: 0;
    box-shadow: var(--focus-ring);
}

.skip-link {
    position: absolute;
    left: 1rem;
    top: -60px;
    z-index: 3000;
    background: var(--pos-primary);
    color: #fff;
    padding: .55rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    transition: top .15s;
}

.skip-link:focus {
    top: .75rem;
    color: #fff;
}

kbd, .kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4rem;
    height: 1.35rem;
    padding: 0 .35rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .68rem;
    font-weight: 600;
    color: var(--pos-muted);
    background: var(--pos-surface-2);
    border: 1px solid var(--pos-border);
    border-bottom-width: 2px;
    border-radius: 5px;
    line-height: 1;
}

.btn kbd {
    background: rgba(255, 255, 255, .18);
    border-color: rgba(255, 255, 255, .3);
    color: inherit;
}

/* ---------------------------------------------------------------- 3. Componentes */

/* Botones ---------------------------------------------------------- */
.btn {
    --bs-btn-font-weight: 550;
    --bs-btn-padding-x: .85rem;
    --bs-btn-padding-y: .45rem;
    --bs-btn-font-size: .875rem;
    --bs-btn-border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s, box-shadow .15s, transform .08s;
}

.btn:active {
    transform: translateY(1px);
}

.btn > i[class*="me-"], .btn > i[class*="ms-"] {
    margin: 0 !important;
}

.btn-sm {
    --bs-btn-padding-x: .6rem;
    --bs-btn-padding-y: .3rem;
    --bs-btn-font-size: .8125rem;
}

.btn-lg {
    --bs-btn-padding-y: .65rem;
    --bs-btn-font-size: 1rem;
    --bs-btn-border-radius: var(--radius);
}

.btn-primary {
    --bs-btn-bg: var(--pos-primary);
    --bs-btn-border-color: var(--pos-primary);
    --bs-btn-hover-bg: var(--pos-primary-hover);
    --bs-btn-hover-border-color: var(--pos-primary-hover);
    --bs-btn-active-bg: var(--pos-primary-hover);
    --bs-btn-active-border-color: var(--pos-primary-hover);
    --bs-btn-disabled-bg: var(--pos-primary);
    --bs-btn-disabled-border-color: var(--pos-primary);
    box-shadow: 0 1px 2px rgba(var(--pos-primary-rgb), .3), inset 0 1px 0 rgba(255, 255, 255, .12);
}

.btn-success {
    --bs-btn-bg: var(--pos-success);
    --bs-btn-border-color: var(--pos-success);
    --bs-btn-hover-bg: #116632;
    --bs-btn-hover-border-color: #116632;
    --bs-btn-active-bg: #116632;
    --bs-btn-disabled-bg: var(--pos-success);
    --bs-btn-disabled-border-color: var(--pos-success);
}

.btn-danger {
    --bs-btn-bg: var(--pos-danger);
    --bs-btn-border-color: var(--pos-danger);
    --bs-btn-hover-bg: var(--pos-red-dark);
    --bs-btn-hover-border-color: var(--pos-red-dark);
    --bs-btn-active-bg: var(--pos-red-dark);
}

.btn-outline-primary {
    --bs-btn-color: var(--pos-primary);
    --bs-btn-border-color: rgba(var(--pos-primary-rgb), .35);
    --bs-btn-hover-color: var(--pos-primary);
    --bs-btn-hover-bg: var(--pos-primary-soft);
    --bs-btn-hover-border-color: var(--pos-primary);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--pos-primary);
    --bs-btn-active-border-color: var(--pos-primary);
}

.btn-outline-secondary, .btn-light {
    --bs-btn-color: var(--pos-text-2);
    --bs-btn-bg: var(--pos-surface);
    --bs-btn-border-color: var(--pos-border-strong);
    --bs-btn-hover-color: var(--pos-text);
    --bs-btn-hover-bg: var(--pos-hover);
    --bs-btn-hover-border-color: var(--pos-border-strong);
    --bs-btn-active-color: var(--pos-text);
    --bs-btn-active-bg: var(--pos-hover);
    --bs-btn-active-border-color: var(--pos-border-strong);
    box-shadow: var(--shadow-xs);
}

.btn-outline-danger {
    --bs-btn-color: var(--pos-danger);
    --bs-btn-border-color: rgba(220, 38, 38, .35);
    --bs-btn-hover-color: var(--pos-danger);
    --bs-btn-hover-bg: var(--pos-danger-soft);
    --bs-btn-hover-border-color: var(--pos-danger);
    --bs-btn-active-bg: var(--pos-danger);
}

.btn-outline-success {
    --bs-btn-color: var(--pos-success);
    --bs-btn-border-color: rgba(21, 128, 61, .35);
    --bs-btn-hover-color: var(--pos-success);
    --bs-btn-hover-bg: var(--pos-success-soft);
    --bs-btn-hover-border-color: var(--pos-success);
}

/* Botón fantasma: acciones terciarias / iconos en tablas */
.btn-ghost {
    --bs-btn-color: var(--pos-muted);
    --bs-btn-bg: transparent;
    --bs-btn-border-color: transparent;
    --bs-btn-hover-color: var(--pos-text);
    --bs-btn-hover-bg: var(--pos-hover);
    --bs-btn-active-bg: var(--pos-hover);
    --bs-btn-active-color: var(--pos-text);
}

.btn-icon {
    width: 2.125rem;
    height: 2.125rem;
    padding: 0;
}

.btn-icon.btn-sm {
    width: 1.875rem;
    height: 1.875rem;
}

/* Estado de carga para formularios (app.js añade .is-loading al enviar) */
.btn.is-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.is-loading::after {
    content: "";
    position: absolute;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-color: rgba(255, 255, 255, .9) rgba(255, 255, 255, .9) transparent transparent;
    border-radius: 50%;
    animation: pos-spin .7s linear infinite;
}

.btn-outline-secondary.is-loading::after, .btn-outline-primary.is-loading::after, .btn-light.is-loading::after {
    border-color: var(--pos-primary) var(--pos-primary) transparent transparent;
}

@keyframes pos-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Inputs / Selects --------------------------------------------------- */
.form-label {
    font-weight: 550;
    font-size: .8125rem;
    color: var(--pos-text-2);
    margin-bottom: .35rem;
}

.form-label.small, label.small {
    font-size: .78rem;
}

.form-control, .form-select {
    border-color: var(--pos-border-strong);
    border-radius: var(--radius-sm);
    background-color: var(--pos-surface);
    color: var(--pos-text);
    font-size: .875rem;
    padding: .5rem .75rem;
    box-shadow: var(--shadow-xs);
    transition: border-color .15s, box-shadow .15s;
}

.form-select {
    padding-right: 2.25rem;
}

.form-control-sm, .form-select-sm {
    font-size: .8125rem;
    padding-top: .3rem;
    padding-bottom: .3rem;
}

.form-select-sm {
    padding-right: 2rem;
}

.form-control-lg, .form-select-lg {
    font-size: 1rem;
    padding-top: .6rem;
    padding-bottom: .6rem;
    border-radius: var(--radius);
}

.form-control:hover:not(:focus):not(:disabled), .form-select:hover:not(:focus):not(:disabled) {
    border-color: #b6bfd0;
}

[data-bs-theme="dark"] .form-control:hover:not(:focus):not(:disabled),
[data-bs-theme="dark"] .form-select:hover:not(:focus):not(:disabled) {
    border-color: #3d4964;
}

.form-control:focus, .form-select:focus {
    border-color: var(--pos-primary);
    background-color: var(--pos-surface);
    color: var(--pos-text);
}

.form-control::placeholder {
    color: #9aa4b6;
}

/* Fechas (input date/month nativo): el ícono del calendario con el color de marca, más grande y visible en tema
   claro y oscuro. Todo el campo abre el calendario (app.js · initFechas). Firefox dibuja su propio ícono. */
input[type="date"], input[type="month"], input[type="datetime-local"] {
    cursor: pointer;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    opacity: 1;
    cursor: pointer;
    width: 1.15rem;
    height: 1.15rem;
    margin-left: .4rem;
    padding: 0;
    background: var(--pos-primary);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 .5a.5.5 0 0 1 1 0V1h6V.5a.5.5 0 0 1 1 0V1h1.5A1.5 1.5 0 0 1 15 2.5v11a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 1 13.5v-11A1.5 1.5 0 0 1 2.5 1H4zM2 5v8.5a.5.5 0 0 0 .5.5h11a.5.5 0 0 0 .5-.5V5z'/%3E%3Cpath d='M4 7h2v2H4zm3 0h2v2H7zm3 0h2v2h-2zM4 10h2v2H4zm3 0h2v2H7z'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 .5a.5.5 0 0 1 1 0V1h6V.5a.5.5 0 0 1 1 0V1h1.5A1.5 1.5 0 0 1 15 2.5v11a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 1 13.5v-11A1.5 1.5 0 0 1 2.5 1H4zM2 5v8.5a.5.5 0 0 0 .5.5h11a.5.5 0 0 0 .5-.5V5z'/%3E%3Cpath d='M4 7h2v2H4zm3 0h2v2H7zm3 0h2v2h-2zM4 10h2v2H4zm3 0h2v2H7z'/%3E%3C/svg%3E") center / contain no-repeat;
    transition: background-color .15s, transform .15s;
}

.form-control-sm::-webkit-calendar-picker-indicator {
    width: 1rem;
    height: 1rem;
}

input:hover::-webkit-calendar-picker-indicator {
    background: var(--pos-primary-hover);
    transform: scale(1.08);
}

input:disabled::-webkit-calendar-picker-indicator, input[readonly]::-webkit-calendar-picker-indicator {
    background: var(--pos-muted);
    cursor: not-allowed;
    transform: none;
}

.form-control:disabled, .form-select:disabled, .form-control[readonly] {
    background-color: var(--pos-surface-2);
    color: var(--pos-muted);
}

.form-text {
    color: var(--pos-muted);
    font-size: .76rem;
}

.input-group-text {
    background: var(--pos-surface-2);
    border-color: var(--pos-border-strong);
    color: var(--pos-muted);
    font-size: .875rem;
}

.input-group > .form-control, .input-group > .form-select, .input-group > .input-group-text, .input-group > .btn {
    box-shadow: none;
}

.input-group {
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-xs);
}

/* Input con icono interno (sin input-group) */
.input-icon {
    position: relative;
}

.input-icon > i, .input-icon > .bi {
    position: absolute;
    left: .75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--pos-muted);
    pointer-events: none;
    font-size: .95em;
}

.input-icon > .form-control {
    padding-left: 2.25rem;
}

.input-icon > .form-control-lg {
    padding-left: 2.6rem;
}

.input-icon > .input-kbd {
    position: absolute;
    right: .55rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

.form-check-input {
    border-color: var(--pos-border-strong);
}

.form-check-input:checked {
    background-color: var(--pos-primary);
    border-color: var(--pos-primary);
}

.form-switch .form-check-input {
    width: 2.25em;
}

/* Obligatorio: app.js añade .required a los labels de campos [required] */
.form-label.required::after, label.required::after {
    content: " *";
    color: var(--pos-danger);
    font-weight: 700;
}

/* Validación */
.form-control.is-invalid, .form-select.is-invalid, .was-validated .form-control:invalid {
    border-color: var(--pos-danger);
    background-image: none;
    padding-right: .75rem;
}

.form-control.is-invalid:focus, .form-select.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .18);
}

.form-control.is-valid, .form-select.is-valid {
    border-color: var(--pos-success);
    background-image: none;
    padding-right: .75rem;
}

.invalid-feedback {
    font-size: .76rem;
    color: var(--pos-danger);
    font-weight: 500;
}

.invalid-feedback:not(:empty)::before {
    content: "";
    display: inline-block;
    width: .45rem;
    height: .45rem;
    border-radius: 50%;
    background: currentColor;
    margin-right: .4rem;
    vertical-align: middle;
}

/* Secciones dentro de formularios largos */
.form-section {
    padding: 1.25rem;
    border-bottom: 1px solid var(--pos-border);
}

.form-section:last-child {
    border-bottom: 0;
}

.form-section-head {
    display: flex;
    gap: .75rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.form-section-head .ico {
    width: 2rem;
    height: 2rem;
    flex: none;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--pos-primary-soft);
    color: var(--pos-primary);
}

.form-section-head h2 {
    font-size: .95rem;
    margin: 0;
}

.form-section-head p {
    margin: 0;
    color: var(--pos-muted);
    font-size: .8rem;
}

/* Barra de acciones fija al pie de formularios */
.form-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    padding: .75rem 1rem;
    margin: 1rem -.25rem 0;
    background: color-mix(in srgb, var(--pos-surface) 92%, transparent);
    backdrop-filter: blur(8px);
    border: 1px solid var(--pos-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}

/* Zona de carga de imagen */
.dropzone {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border: 1.5px dashed var(--pos-border-strong);
    border-radius: var(--radius);
    background: var(--pos-surface-2);
    transition: border-color .15s, background .15s;
    cursor: pointer;
}

.dropzone:hover, .dropzone.is-dragover {
    border-color: var(--pos-primary);
    background: var(--pos-primary-soft);
}

.dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.dropzone .dz-preview {
    width: 72px;
    height: 72px;
    flex: none;
    border-radius: var(--radius-sm);
    background: var(--pos-surface) center/cover no-repeat;
    border: 1px solid var(--pos-border);
    display: grid;
    place-items: center;
    color: var(--pos-muted);
    font-size: 1.5rem;
}

/* Cards ------------------------------------------------------------ */
.card {
    --bs-card-bg: var(--pos-surface);
    --bs-card-border-color: var(--pos-border);
    --bs-card-border-radius: var(--radius-lg);
    --bs-card-inner-border-radius: calc(var(--radius-lg) - 1px);
    --bs-card-cap-bg: transparent;
    --bs-card-cap-padding-y: .85rem;
    --bs-card-cap-padding-x: 1.15rem;
    --bs-card-spacer-x: 1.15rem;
    background: var(--pos-surface);
    border: 1px solid var(--pos-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    color: var(--pos-text);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--pos-border);
    font-weight: 600;
    font-size: .875rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    min-height: 3.1rem;
}

.card-header.d-block {
    display: block !important;
}

.card-header .card-title, .card-title {
    font-size: .9rem;
    font-weight: 650;
    margin: 0;
}

.card-header .card-sub {
    color: var(--pos-muted);
    font-size: .76rem;
    font-weight: 400;
}

.card-footer {
    background: var(--pos-surface-2);
    border-top: 1px solid var(--pos-border);
}

.card-link-more {
    font-size: .78rem;
    font-weight: 550;
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: .25rem;
}

a.card-hover, .card-hover {
    transition: border-color .15s, box-shadow .2s var(--ease), transform .2s var(--ease);
}

a.card-hover:hover, .card-hover:hover {
    border-color: rgba(var(--pos-primary-rgb), .35);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* Tablas ------------------------------------------------------------ */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--pos-text);
    --bs-table-border-color: var(--pos-border);
    --bs-table-hover-bg: var(--pos-hover);
    --bs-table-hover-color: var(--pos-text);
    --bs-table-striped-bg: var(--pos-surface-2);
    margin-bottom: 0;
    font-size: .8125rem;
}

.table > :not(caption) > * > * {
    background: transparent;
    color: var(--pos-text);
    border-color: var(--pos-border);
    padding: .7rem .85rem;
}

.table-sm > :not(caption) > * > * {
    padding: .5rem .75rem;
}

.table thead th {
    background: var(--pos-surface-2);
    color: var(--pos-muted);
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    white-space: nowrap;
    border-bottom: 1px solid var(--pos-border);
    vertical-align: middle;
}

[data-bs-theme="dark"] .table thead th {
    color: var(--pos-muted);
}

.table tbody tr:last-child > * {
    border-bottom: 0;
}

.table-hover tbody tr {
    transition: background-color .1s;
}

.table-hover tbody tr:hover > * {
    background: var(--pos-hover);
}

.table a:not(.btn):not(.dropdown-item) {
    color: var(--pos-text);
    font-weight: 550;
}

.table a:not(.btn):not(.dropdown-item):hover {
    color: var(--pos-primary);
}

/* Contenedor con scroll y cabecera fija (sticky header) */
.table-responsive {
    border-radius: inherit;
}

.table-sticky {
    max-height: min(68vh, 760px);
    overflow: auto;
}

.table-sticky thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    box-shadow: inset 0 -1px 0 var(--pos-border);
}

/* Las tablas que viven dentro de un card llegan a los bordes */
.card > .table-responsive, .card > .table-sticky {
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}

/* Solo cuando el card-body conserva su padding; con .p-0 el margen negativo saca la tabla del recuadro */
.card-body:not(.p-0) > .table-responsive:first-child:last-child {
    margin: -1rem -1.15rem;
    width: auto;
}

/* Cabeceras ordenables */
.table thead th .th-sort {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    border-radius: 4px;
}

.table thead th .th-sort:hover {
    color: var(--pos-text);
}

.table thead th .th-sort i {
    opacity: .4;
    font-size: .85em;
}

.table thead th .th-sort:hover i, .table thead th[aria-sort="ascending"] .th-sort i, .table thead th[aria-sort="descending"] .th-sort i {
    opacity: 1;
}

.table thead th[aria-sort="ascending"], .table thead th[aria-sort="descending"] {
    color: var(--pos-primary);
}

.table thead th.text-end .th-sort {
    flex-direction: row-reverse;
}

/* Celda de producto con miniatura */
.cell-media {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-width: 220px;
}

.thumb {
    width: 40px;
    height: 40px;
    flex: none;
    border-radius: 8px;
    object-fit: cover;
    background: var(--pos-surface-2);
    border: 1px solid var(--pos-border);
}

.thumb-placeholder {
    display: grid;
    place-items: center;
    color: var(--pos-muted);
    font-size: 1.05rem;
}

.cell-sub {
    font-size: .74rem;
    color: var(--pos-muted);
    font-weight: 400;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .92em;
}

/* Barra de herramientas de tabla */
.table-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    padding: .75rem 1.15rem;
    border-bottom: 1px solid var(--pos-border);
}

/* Fila resaltada por filtro rápido */
tr[data-filtered-out] {
    display: none;
}

mark, .mark {
    background: rgba(250, 204, 21, .35);
    color: inherit;
    padding: 0 .1em;
    border-radius: 3px;
}

/* Badges ------------------------------------------------------------ */
.badge {
    --bs-badge-font-weight: 600;
    --bs-badge-font-size: .7rem;
    --bs-badge-padding-x: .55em;
    --bs-badge-padding-y: .35em;
    --bs-badge-border-radius: 999px;
    letter-spacing: .01em;
}

/* Badge "soft" con punto: estados de negocio */
.badge-soft, .badge-stock-ok, .badge-stock-low, .badge-stock-crit, .badge-stock-none {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .72rem;
    font-weight: 600;
    line-height: 1;
    padding: .32rem .6rem;
    border-radius: 999px;
    white-space: nowrap;
}

.badge-soft::before, .badge-stock-ok::before, .badge-stock-low::before, .badge-stock-crit::before, .badge-stock-none::before {
    content: "";
    width: .4rem;
    height: .4rem;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}

.badge-soft.no-dot::before {
    display: none;
}

.badge-stock-ok, .badge-soft.success {
    background: var(--pos-success-soft);
    color: var(--pos-success);
}

.badge-stock-low, .badge-soft.warning {
    background: var(--pos-warning-soft);
    color: var(--pos-warning);
}

.badge-stock-crit, .badge-soft.danger {
    background: var(--pos-danger-soft);
    color: var(--pos-danger);
}

.badge-stock-none, .badge-soft.neutral {
    background: var(--pos-hover);
    color: var(--pos-muted);
}

.badge-soft.info {
    background: var(--pos-info-soft);
    color: var(--pos-info);
}

.badge-soft.primary {
    background: var(--pos-primary-soft);
    color: var(--pos-primary);
}

/* Bootstrap text-bg-* más sobrios */
.badge.text-bg-success {
    background: var(--pos-success-soft) !important;
    color: var(--pos-success) !important;
}

.badge.text-bg-secondary {
    background: var(--pos-hover) !important;
    color: var(--pos-muted) !important;
}

.badge.text-bg-danger {
    background: var(--pos-danger-soft) !important;
    color: var(--pos-danger) !important;
}

.badge.text-bg-warning {
    background: var(--pos-warning-soft) !important;
    color: var(--pos-warning) !important;
}

.badge.text-bg-info {
    background: var(--pos-info-soft) !important;
    color: var(--pos-info) !important;
}

.badge.text-bg-primary {
    background: var(--pos-primary-soft) !important;
    color: var(--pos-primary) !important;
}

.badge.text-bg-light {
    background: var(--pos-surface-2) !important;
    color: var(--pos-text-2) !important;
}

/* Contador en menú / navbar */
.count-pill {
    display: inline-grid;
    place-items: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 .35rem;
    font-size: .66rem;
    font-weight: 700;
    border-radius: 999px;
    background: var(--pos-danger);
    color: #fff;
    line-height: 1;
}

/* Dropdowns --------------------------------------------------------- */
.dropdown-menu {
    --bs-dropdown-bg: var(--pos-surface);
    --bs-dropdown-border-color: var(--pos-border);
    --bs-dropdown-border-radius: var(--radius);
    --bs-dropdown-link-color: var(--pos-text-2);
    --bs-dropdown-link-hover-bg: var(--pos-hover);
    --bs-dropdown-link-hover-color: var(--pos-text);
    --bs-dropdown-link-active-bg: var(--pos-primary-soft);
    --bs-dropdown-link-active-color: var(--pos-primary);
    --bs-dropdown-font-size: .8125rem;
    --bs-dropdown-item-padding-y: .45rem;
    --bs-dropdown-item-padding-x: .75rem;
    --bs-dropdown-divider-bg: var(--pos-border);
    --bs-dropdown-header-color: var(--pos-muted);
    padding: .35rem;
    box-shadow: var(--shadow-lg);
    animation: pos-pop .14s var(--ease);
}

.dropdown-item {
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: .55rem;
}

.dropdown-item > i:first-child {
    width: 1rem;
    text-align: center;
    color: var(--pos-muted);
    margin: 0 !important;
}

.dropdown-item.text-danger > i:first-child {
    color: inherit;
}

.dropdown-item.text-danger:hover {
    background: var(--pos-danger-soft);
}

.dropdown-header {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 600;
    padding: .5rem .75rem .3rem;
}

@keyframes pos-pop {
    from {
        opacity: 0;
        transform: translateY(-4px) scale(.98);
    }
}

/* Modales ----------------------------------------------------------- */
.modal {
    --bs-modal-bg: var(--pos-surface);
    --bs-modal-border-color: var(--pos-border);
    --bs-modal-border-radius: var(--radius-lg);
    --bs-modal-header-border-color: var(--pos-border);
    --bs-modal-footer-border-color: var(--pos-border);
    --bs-modal-padding: 1.25rem;
    --bs-modal-header-padding: 1rem 1.25rem;
}

.modal-content {
    box-shadow: var(--shadow-lg);
}

.modal-backdrop {
    --bs-backdrop-bg: #0b1222;
    --bs-backdrop-opacity: .55;
}

.modal-backdrop.show {
    backdrop-filter: blur(2px);
}

.modal-title {
    font-weight: 650;
}

.modal-footer {
    background: var(--pos-surface-2);
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}

/* Alertas ----------------------------------------------------------- */
.alert {
    --bs-alert-border-radius: var(--radius);
    --bs-alert-padding-y: .75rem;
    --bs-alert-padding-x: 1rem;
    border-width: 1px;
    font-size: .8125rem;
}

/* Alerta con icono a la izquierda: <div class="alert alert-info alert-icon"><i class="bi …"></i><div>…</div></div> */
.alert-icon {
    display: flex;
    gap: .6rem;
    align-items: flex-start;
}

.alert-icon > i:first-child, .alert-icon > .bi:first-child {
    font-size: 1rem;
    line-height: 1.25rem;
    flex: none;
}

.alert-danger {
    --bs-alert-bg: var(--pos-danger-soft);
    --bs-alert-color: var(--pos-danger);
    --bs-alert-border-color: rgba(220, 38, 38, .2);
}

.alert-success {
    --bs-alert-bg: var(--pos-success-soft);
    --bs-alert-color: var(--pos-success);
    --bs-alert-border-color: rgba(21, 128, 61, .2);
}

.alert-warning {
    --bs-alert-bg: var(--pos-warning-soft);
    --bs-alert-color: var(--pos-warning);
    --bs-alert-border-color: rgba(180, 83, 9, .22);
}

.alert-info {
    --bs-alert-bg: var(--pos-info-soft);
    --bs-alert-color: var(--pos-info);
    --bs-alert-border-color: rgba(3, 105, 161, .2);
}

.alert a, .alert .alert-link {
    color: inherit;
    font-weight: 650;
    text-decoration: underline;
}

/* Toasts ------------------------------------------------------------ */
.toast-container {
    z-index: 2000;
}

.pos-toast {
    --tone: var(--pos-info);
    min-width: 300px;
    max-width: 380px;
    background: var(--pos-surface);
    color: var(--pos-text);
    border: 1px solid var(--pos-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    position: relative;
}

.pos-toast .toast-body {
    display: flex;
    gap: .65rem;
    align-items: flex-start;
    padding: .8rem .9rem;
    font-size: .8125rem;
    font-weight: 500;
}

.pos-toast .toast-ico {
    width: 1.5rem;
    height: 1.5rem;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--tone);
    background: color-mix(in srgb, var(--tone) 14%, transparent);
    font-size: .85rem;
}

.pos-toast .toast-msg {
    flex: 1;
    padding-top: .1rem;
}

.pos-toast .btn-close {
    font-size: .65rem;
    margin-top: .25rem;
}

.pos-toast .toast-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    background: var(--tone);
    animation: pos-toast-progress linear forwards;
}

.pos-toast.success {
    --tone: var(--pos-success);
}

.pos-toast.danger {
    --tone: var(--pos-danger);
}

.pos-toast.warning {
    --tone: var(--pos-warning);
}

.pos-toast.info {
    --tone: var(--pos-info);
}

@keyframes pos-toast-progress {
    from {
        width: 100%;
    }
    to {
        width: 0;
    }
}

/* Breadcrumbs ------------------------------------------------------- */
.breadcrumb {
    --bs-breadcrumb-divider: "›";
    --bs-breadcrumb-divider-color: var(--pos-border-strong);
    --bs-breadcrumb-item-active-color: var(--pos-muted);
    --bs-breadcrumb-item-padding-x: .45rem;
    margin: 0;
    font-size: .78rem;
}

.breadcrumb a {
    color: var(--pos-muted);
}

.breadcrumb a:hover {
    color: var(--pos-primary);
}

/* Paginación -------------------------------------------------------- */
.pagination {
    --bs-pagination-color: var(--pos-text-2);
    --bs-pagination-bg: var(--pos-surface);
    --bs-pagination-border-color: var(--pos-border);
    --bs-pagination-hover-color: var(--pos-text);
    --bs-pagination-hover-bg: var(--pos-hover);
    --bs-pagination-hover-border-color: var(--pos-border);
    --bs-pagination-focus-box-shadow: var(--focus-ring);
    --bs-pagination-active-bg: var(--pos-primary);
    --bs-pagination-active-border-color: var(--pos-primary);
    --bs-pagination-disabled-bg: var(--pos-surface);
    --bs-pagination-disabled-color: #a6aec0;
    --bs-pagination-disabled-border-color: var(--pos-border);
    --bs-pagination-border-radius: var(--radius-sm);
    gap: .25rem;
}

.pagination .page-link {
    border-radius: var(--radius-sm) !important;
    min-width: 2rem;
    text-align: center;
    font-weight: 550;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.pagination-sm .page-link {
    padding: .3rem .55rem;
}

.page-item:not(:first-child) .page-link {
    margin-left: 0;
}

.pag-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    margin-top: 1rem;
}

.card > .pag-bar, .card-footer.pag-bar {
    margin: 0;
    padding: .75rem 1.15rem;
}

/* Nav pills / tabs ---------------------------------------------------- */
.nav-pills {
    --bs-nav-pills-link-active-bg: var(--pos-primary);
    --bs-nav-pills-border-radius: var(--radius-sm);
    gap: .35rem;
}

.nav-pills .nav-link {
    color: var(--pos-text-2);
    font-weight: 550;
    border: 1px solid var(--pos-border);
    background: var(--pos-surface);
}

.nav-pills .nav-link.active {
    border-color: var(--pos-primary);
}

.nav-tabs {
    --bs-nav-tabs-border-color: var(--pos-border);
    --bs-nav-tabs-link-active-color: var(--pos-primary);
    --bs-nav-tabs-link-active-bg: transparent;
    --bs-nav-tabs-link-active-border-color: transparent transparent var(--pos-primary);
}

.nav-tabs .nav-link {
    border: 0;
    border-bottom: 2px solid transparent;
    color: var(--pos-muted);
    font-weight: 550;
}

/* Segmented control (selector de comprobante, etc.) */
.segmented {
    display: inline-flex;
    width: 100%;
    padding: 3px;
    gap: 3px;
    background: var(--pos-hover);
    border-radius: var(--radius);
    border: 1px solid var(--pos-border);
}

.segmented .btn-check + .btn {
    flex: 1;
    border: 0;
    --bs-btn-color: var(--pos-muted);
    --bs-btn-hover-color: var(--pos-text);
    --bs-btn-padding-y: .35rem;
    --bs-btn-font-size: .8rem;
    border-radius: calc(var(--radius) - 3px);
    box-shadow: none;
}

.segmented .btn-check:checked + .btn {
    background: var(--pos-surface);
    color: var(--pos-primary);
    box-shadow: var(--shadow-sm);
}

/* List group ---------------------------------------------------------- */
.list-group {
    --bs-list-group-bg: var(--pos-surface);
    --bs-list-group-border-color: var(--pos-border);
    --bs-list-group-action-hover-bg: var(--pos-hover);
    --bs-list-group-action-active-bg: var(--pos-primary-soft);
    --bs-list-group-active-bg: var(--pos-primary);
    --bs-list-group-active-border-color: var(--pos-primary);
    --bs-list-group-color: var(--pos-text);
}

/* ---------------------------------------------------------------- 4. Shell */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-main {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-width: 0;
    display: flex;
    flex-direction: column;
    transition: margin .22s var(--ease);
}

.app-content {
    flex: 1;
    width: 100%;
    max-width: 1680px;
    margin: 0 auto;
    padding: 1.5rem 1.75rem 2rem;
}

/* Sidebar ------------------------------------------------------------ */
.app-sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--sb-bg) 0%, var(--sb-bg-2) 100%);
    color: var(--sb-text);
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, .04);
    transition: width .22s var(--ease), transform .22s var(--ease), box-shadow .22s;
}

.sb-brand {
    height: var(--navbar-h);
    flex: none;
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: 0 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
    color: var(--sb-text-strong);
    overflow: hidden;
}

.sb-brand:hover {
    color: var(--sb-text-strong);
}

.sb-logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #5b84f5 0%, #2451d6 60%, #1a3aa3 100%);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 1.05rem;
    font-weight: 800;
    flex: none;
    box-shadow: 0 4px 12px rgba(36, 81, 214, .45), inset 0 1px 0 rgba(255, 255, 255, .25);
}

.sb-brand-text {
    min-width: 0;
    line-height: 1.2;
}

.sb-brand-text h6, .sb-brand h6 {
    margin: 0;
    font-size: .875rem;
    font-weight: 700;
    color: var(--sb-text-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sb-brand-text small {
    color: var(--sb-muted);
    font-size: .7rem;
    white-space: nowrap;
}

.sb-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: .75rem .65rem 1rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .14) transparent;
}

.sb-scroll::-webkit-scrollbar {
    width: 6px;
}

.sb-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .14);
    border-radius: 3px;
}

.sb-title {
    font-size: .66rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--sb-muted);
    padding: 1rem .75rem .4rem;
    white-space: nowrap;
}

.sb-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: .7rem;
    min-height: 2.25rem;
    color: var(--sb-text);
    text-decoration: none;
    padding: .45rem .7rem;
    border-radius: 8px;
    font-size: .8375rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color .12s, color .12s;
}

.sb-link .ico {
    width: 1.25rem;
    flex: none;
    text-align: center;
    font-size: 1.05rem;
    color: var(--sb-muted);
    transition: color .12s;
}

.sb-link .lbl {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sb-link:hover {
    background: var(--sb-hover);
    color: var(--sb-text-strong);
}

.sb-link:hover .ico {
    color: var(--sb-text-strong);
}

.sb-link:focus-visible {
    outline: 2px solid var(--sb-active-bar);
    outline-offset: -2px;
}

/* Módulo activo: fondo tintado + barra lateral (estado visible sin depender sólo del color) */
.sb-link.active {
    background: var(--sb-active);
    color: var(--sb-text-strong);
    font-weight: 600;
    box-shadow: none;
}

.sb-link.active .ico {
    color: var(--sb-active-bar);
}

.sb-link.active::before {
    content: "";
    position: absolute;
    left: -.65rem;
    top: .45rem;
    bottom: .45rem;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--sb-active-bar);
}

.sb-link .chev {
    margin-left: auto;
    font-size: .7rem;
    color: var(--sb-muted);
    transition: transform .2s var(--ease);
}

.sb-link[aria-expanded="true"] .chev {
    transform: rotate(90deg);
}

/* Indicadores de módulo: "Nuevo", contador, punto de alerta */
.sb-badge {
    margin-left: auto;
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .03em;
    padding: .18rem .45rem;
    border-radius: 999px;
    background: rgba(91, 132, 245, .2);
    color: #a9c0fa;
    text-transform: uppercase;
}

.sb-badge.hot {
    background: rgba(52, 194, 108, .18);
    color: #6ee39d;
}

.sb-badge + .chev {
    margin-left: .4rem;
}

.sb-sub {
    list-style: none;
    margin: .1rem 0 .3rem;
    padding: 0 0 0 1.35rem;
    position: relative;
}

.sb-sub::before {
    content: "";
    position: absolute;
    left: 1.3rem;
    top: .2rem;
    bottom: .2rem;
    width: 1px;
    background: rgba(255, 255, 255, .08);
}

.sb-sub .sb-link {
    font-size: .8rem;
    min-height: 2rem;
    padding: .35rem .7rem .35rem 1.05rem;
    color: #a3afc4;
}

.sb-sub .sb-link i {
    width: 1rem;
    text-align: center;
    font-size: .8rem;
    opacity: .8;
}

.sb-sub .sb-link.current {
    color: var(--sb-text-strong);
    background: var(--sb-hover);
    font-weight: 600;
}

.sb-sub .sb-link.current::after {
    content: "";
    position: absolute;
    left: -.08rem;
    top: 50%;
    width: 5px;
    height: 5px;
    margin-top: -2.5px;
    border-radius: 50%;
    background: var(--sb-active-bar);
    box-shadow: 0 0 0 3px rgba(109, 147, 255, .2);
}

.sb-footer {
    flex: none;
    padding: .65rem;
    border-top: 1px solid rgba(255, 255, 255, .06);
}

.sb-user {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .5rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, .04);
    font-size: .78rem;
    overflow: hidden;
}

.sb-user .who {
    min-width: 0;
    line-height: 1.25;
}

.sb-user .who > div {
    color: var(--sb-text-strong);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sb-role {
    display: inline-block;
    margin-top: .15rem;
    background: rgba(91, 132, 245, .2);
    color: #a9c0fa;
    font-weight: 700;
    font-size: .62rem;
    letter-spacing: .04em;
    padding: .12rem .45rem;
    border-radius: 999px;
}

.sb-collapse-btn {
    margin-left: auto;
    flex: none;
    width: 1.9rem;
    height: 1.9rem;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 7px;
    color: var(--sb-muted);
    background: transparent;
}

.sb-collapse-btn:hover {
    background: var(--sb-hover);
    color: var(--sb-text-strong);
}

/* Rail (colapsado en escritorio). Al pasar el mouse se despliega encima del contenido. */
@media (min-width: 992px) {
    body.sidebar-collapsed .app-main {
        margin-left: var(--sidebar-rail);
    }

    body.sidebar-collapsed .app-sidebar:not(:hover):not(:focus-within) {
        width: var(--sidebar-rail);
    }

    body.sidebar-collapsed .app-sidebar:hover, body.sidebar-collapsed .app-sidebar:focus-within {
        box-shadow: var(--shadow-lg);
    }

    body.sidebar-collapsed .app-sidebar:not(:hover):not(:focus-within) .lbl,
    body.sidebar-collapsed .app-sidebar:not(:hover):not(:focus-within) .chev,
    body.sidebar-collapsed .app-sidebar:not(:hover):not(:focus-within) .sb-badge,
    body.sidebar-collapsed .app-sidebar:not(:hover):not(:focus-within) .sb-brand-text,
    body.sidebar-collapsed .app-sidebar:not(:hover):not(:focus-within) .sb-user .who,
    body.sidebar-collapsed .app-sidebar:not(:hover):not(:focus-within) .sb-collapse-btn,
    body.sidebar-collapsed .app-sidebar:not(:hover):not(:focus-within) .sb-sub {
        display: none !important;
    }

    body.sidebar-collapsed .app-sidebar:not(:hover):not(:focus-within) .sb-title {
        font-size: 0;
        padding: .6rem 0 .3rem;
        margin: 0 .9rem;
        border-top: 1px solid rgba(255, 255, 255, .07);
    }

    body.sidebar-collapsed .app-sidebar:not(:hover):not(:focus-within) .sb-link {
        justify-content: center;
        padding-left: 0;
        padding-right: 0;
    }

    body.sidebar-collapsed .app-sidebar:not(:hover):not(:focus-within) .sb-brand {
        justify-content: center;
        padding: 0;
    }

    body.sidebar-collapsed .app-sidebar:not(:hover):not(:focus-within) .sb-user {
        justify-content: center;
        background: transparent;
    }
}

/* Navbar ------------------------------------------------------------ */
.app-navbar {
    height: var(--navbar-h);
    background: color-mix(in srgb, var(--pos-surface) 88%, transparent);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--pos-border);
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.app-navbar .search {
    position: relative;
    max-width: 460px;
}

.global-search .form-control {
    background: var(--pos-surface-2);
    border-color: var(--pos-border);
    box-shadow: none;
    height: 2.25rem;
    padding-right: 3.5rem;
}

.global-search .form-control:focus {
    background: var(--pos-surface);
}

.search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 1060;
    padding: .35rem;
    background: var(--pos-surface);
    border: 1px solid var(--pos-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 420px;
    overflow-y: auto;
    animation: pos-pop .12s var(--ease);
}

.search-results .sr-head {
    font-size: .66rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--pos-muted);
    padding: .45rem .6rem .25rem;
}

.search-results .sr-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem .6rem;
    border-radius: var(--radius-sm);
    color: var(--pos-text);
    font-size: .8125rem;
}

.search-results .sr-item:hover, .search-results .sr-item.is-active {
    background: var(--pos-primary-soft);
    color: var(--pos-text);
    text-decoration: none;
}

.search-results .sr-item .sr-ico {
    width: 1.75rem;
    height: 1.75rem;
    flex: none;
    border-radius: 6px;
    display: grid;
    place-items: center;
    background: var(--pos-hover);
    color: var(--pos-muted);
}

.search-results .sr-item .sr-meta {
    margin-left: auto;
    font-size: .72rem;
    color: var(--pos-muted);
}

.search-results .sr-empty {
    padding: 1rem;
    text-align: center;
    color: var(--pos-muted);
    font-size: .8rem;
}

/* Punto de venta: acceso principal del sistema (reemplaza al enlace del sidebar). Bloque azul de marca con el icono
   sobre una pastilla blanca y la caja del usuario debajo; borde inferior más oscuro para que se lea como "tecla". */
.nav-pos {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    height: 2.75rem;
    padding: 0 .9rem 0 .3rem;
    border-radius: var(--radius);
    background: var(--pos-primary);
    border-bottom: 3px solid var(--pos-primary-hover);
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
    flex: none;
    box-shadow: 0 8px 18px -8px rgba(var(--pos-primary-rgb), .9);
    transition: transform .12s var(--ease), filter .12s, box-shadow .12s;
}

.nav-pos:hover {
    color: #fff;
    transform: translateY(-1px);
    filter: brightness(1.06);
    box-shadow: 0 12px 22px -8px rgba(var(--pos-primary-rgb), .95);
}

.nav-pos:active {
    transform: translateY(1px);
    border-bottom-width: 2px;
}

.nav-pos:focus-visible {
    outline: 3px solid rgba(var(--pos-primary-rgb), .45);
    outline-offset: 2px;
}

.nav-pos.active {                      /* dentro del POS: queda marcado */
    outline: 3px solid rgba(var(--pos-primary-rgb), .3);
    outline-offset: 2px;
}

.nav-pos-ico {
    width: 2.1rem;
    height: 2.1rem;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #fff;
    color: var(--pos-primary-hover);
    font-size: 1.15rem;
}

[data-bs-theme="dark"] .nav-pos-ico {
    color: #1c41b3;
}

.nav-pos-txt {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    min-width: 0;
}

.nav-pos-txt b {
    font-size: .86rem;
    font-weight: 800;
    letter-spacing: .01em;
}

.nav-pos-txt small {
    font-size: .68rem;
    font-weight: 500;
    opacity: .85;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-pos-kbd {
    font: 600 .62rem/1 var(--bs-font-sans-serif);
    background: rgba(255, 255, 255, .2);
    border-color: rgba(255, 255, 255, .3);
    color: #fff;
    border-radius: 4px;
    padding: .2rem .35rem;
    box-shadow: none;
}

@media (max-width: 575.98px) {         /* celular: solo el icono, sin perder el tamaño táctil */
    .nav-pos {
        padding: 0 .3rem;
        gap: 0;
    }

    .nav-pos-txt {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .nav-pos, .nav-pos:hover, .nav-pos:active {
        transition: none;
        transform: none;
    }
}

.nav-icon-btn {
    position: relative;
    display: inline-grid;
    place-items: center;
    background: transparent;
    border: 0;
    color: var(--pos-muted);
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 8px;
    font-size: 1.05rem;
    flex: none;
    transition: background-color .12s, color .12s;
}

.nav-icon-btn:hover, .nav-icon-btn[aria-expanded="true"] {
    background: var(--pos-hover);
    color: var(--pos-text);
}

.nav-icon-btn .dot {
    position: absolute;
    top: 3px;
    right: 2px;
    background: var(--pos-danger);
    color: #fff;
    font-size: .6rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    border: 2px solid var(--pos-surface);
    box-sizing: content-box;
}

.nav-divider {
    width: 1px;
    height: 1.5rem;
    background: var(--pos-border);
    margin: 0 .25rem;
}

.nav-user-btn {
    display: flex;
    align-items: center;
    gap: .55rem;
    border: 0;
    background: transparent;
    padding: .2rem .45rem .2rem .2rem;
    border-radius: 999px;
    color: var(--pos-text);
}

.nav-user-btn:hover, .nav-user-btn[aria-expanded="true"] {
    background: var(--pos-hover);
}

.avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #5b84f5, #2451d6);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: .78rem;
    flex: none;
}

.avatar-lg {
    width: 2.5rem;
    height: 2.5rem;
    font-size: .95rem;
}

.notif-menu {
    width: 340px;
    padding: 0;
}

.notif-menu .notif-head {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--pos-border);
    font-weight: 650;
    display: flex;
    align-items: center;
}

.notif-item {
    display: flex;
    gap: .7rem;
    padding: .7rem 1rem;
    border-radius: 0 !important;
    white-space: normal;
    align-items: flex-start;
}

.notif-item .n-ico {
    width: 2rem;
    height: 2rem;
    border-radius: 8px;
    display: grid;
    place-items: center;
    flex: none;
    font-size: .95rem;
}

.notif-item .n-title {
    font-weight: 600;
    color: var(--pos-text);
}

.notif-item .n-desc {
    font-size: .75rem;
    color: var(--pos-muted);
}

.quick-menu {
    width: 300px;
}

.quick-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .25rem;
}

.quick-grid a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .35rem;
    padding: .7rem .25rem;
    border-radius: var(--radius-sm);
    color: var(--pos-text-2);
    font-size: .72rem;
    font-weight: 550;
    text-align: center;
}

.quick-grid a i {
    width: 2.25rem;
    height: 2.25rem;
    display: grid;
    place-items: center;
    border-radius: 9px;
    font-size: 1.05rem;
    background: var(--pos-primary-soft);
    color: var(--pos-primary);
}

.quick-grid a:hover {
    background: var(--pos-hover);
    color: var(--pos-text);
    text-decoration: none;
}

/* Footer ------------------------------------------------------------ */
.footer-app {
    padding: .9rem 1.75rem;
    border-top: 1px solid var(--pos-border);
    color: var(--pos-muted);
    font-size: .75rem;
}

/* ---------------------------------------------------------------- 5. Patrones de página */
.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: .75rem 1rem;
    margin-bottom: 1.25rem;
}

.page-head h1 {
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -.02em;
    margin: 0;
    line-height: 1.25;
}

.page-head .breadcrumb {
    margin-bottom: .3rem;
}

.page-head .page-sub {
    color: var(--pos-muted);
    font-size: .8125rem;
    margin: .2rem 0 0;
}

.page-head > div:first-child {
    display: flex;
    flex-direction: column;
}

/* breadcrumb sobre el título aunque el HTML lo tenga después */
.page-head > div:first-child > nav[aria-label="breadcrumb"] {
    order: -1;
}

/* KPIs -------------------------------------------------------------- */
.kpi {
    position: relative;
    overflow: hidden;
    padding: 1.05rem 1.15rem;
    display: flex;
    flex-direction: column;
    gap: .3rem;
}

.kpi::before {
    display: none;
}

.kpi .lbl {
    color: var(--pos-muted);
    font-size: .76rem;
    font-weight: 550;
    display: flex;
    align-items: center;
    gap: .4rem;
}

.kpi .val {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -.02em;
    color: var(--pos-text);
}

.kpi .val small {
    font-size: .55em;
    font-weight: 600;
    color: var(--pos-muted);
    margin-right: .15rem;
}

.kpi .ico {
    position: absolute;
    right: 1rem;
    top: 1rem;
    width: 2.25rem;
    height: 2.25rem;
    display: grid;
    place-items: center;
    border-radius: 9px;
    font-size: 1.05rem;
    background: var(--pos-primary-soft);
    color: var(--pos-primary);
    opacity: 1;
}

.kpi .meta {
    font-size: .74rem;
    color: var(--pos-muted);
    display: flex;
    align-items: center;
    gap: .3rem;
}

.kpi.kpi-red .ico, .kpi.tone-danger .ico {
    background: var(--pos-danger-soft);
    color: var(--pos-danger);
}

.kpi.tone-warning .ico {
    background: var(--pos-warning-soft);
    color: var(--pos-warning);
}

.kpi.tone-success .ico {
    background: var(--pos-success-soft);
    color: var(--pos-success);
}

.kpi.tone-neutral .ico {
    background: var(--pos-hover);
    color: var(--pos-muted);
}

.kpi.tone-danger .val {
    color: var(--pos-danger);
}

/* KPI destacado (valor principal del dashboard) */
.kpi-hero {
    background: linear-gradient(135deg, #1a3aa3 0%, #2451d6 55%, #4b74ee 100%);
    color: #fff;
    border: 0;
}

.kpi-hero .lbl, .kpi-hero .meta {
    color: rgba(255, 255, 255, .78);
}

.kpi-hero .val {
    color: #fff;
}

.kpi-hero .val small {
    color: rgba(255, 255, 255, .75);
}

.kpi-hero .ico {
    background: rgba(255, 255, 255, .16);
    color: #fff;
}

.trend-up {
    color: var(--pos-success);
}

.trend-down {
    color: var(--pos-danger);
}

/* Barra de salud de inventario (proporciones) */
.health-bar {
    display: flex;
    height: .55rem;
    border-radius: 999px;
    overflow: hidden;
    background: var(--pos-hover);
    gap: 2px;
}

.health-bar > span {
    display: block;
    min-width: 0;
    transition: width .5s var(--ease);
}

.legend-dot {
    display: inline-block;
    width: .55rem;
    height: .55rem;
    border-radius: 3px;
    margin-right: .4rem;
    vertical-align: middle;
}

/* Lista de alertas (feed) */
.feed {
    list-style: none;
    margin: 0;
    padding: 0;
}

.feed li {
    display: flex;
    gap: .75rem;
    align-items: center;
    padding: .7rem 1.15rem;
    border-bottom: 1px solid var(--pos-border);
}

.feed li:last-child {
    border-bottom: 0;
}

.feed .f-ico {
    width: 2rem;
    height: 2rem;
    border-radius: 8px;
    flex: none;
    display: grid;
    place-items: center;
    font-size: .9rem;
}

.feed .f-body {
    flex: 1;
    min-width: 0;
}

.feed .f-title {
    font-weight: 600;
    font-size: .8125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.feed .f-sub {
    font-size: .74rem;
    color: var(--pos-muted);
}

.tone-bg-danger {
    background: var(--pos-danger-soft);
    color: var(--pos-danger);
}

.tone-bg-warning {
    background: var(--pos-warning-soft);
    color: var(--pos-warning);
}

.tone-bg-success {
    background: var(--pos-success-soft);
    color: var(--pos-success);
}

.tone-bg-info {
    background: var(--pos-info-soft);
    color: var(--pos-info);
}

.tone-bg-primary {
    background: var(--pos-primary-soft);
    color: var(--pos-primary);
}

.tone-bg-neutral {
    background: var(--pos-hover);
    color: var(--pos-muted);
}

/* Contenedor de gráfica con altura fija (Chart.js con maintainAspectRatio:false) */
.chart-box {
    position: relative;
    height: 240px;
}

.chart-box.lg {
    height: 300px;
}

/* Filtros ------------------------------------------------------------ */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
}

.filter-bar .grow {
    flex: 1 1 260px;
    min-width: 220px;
}

.filter-panel {
    padding: 1rem 1.15rem;
    background: var(--pos-surface-2);
    border-bottom: 1px solid var(--pos-border);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .25rem .4rem .25rem .65rem;
    font-size: .74rem;
    font-weight: 550;
    border-radius: 999px;
    background: var(--pos-primary-soft);
    color: var(--pos-primary);
    border: 1px solid rgba(var(--pos-primary-rgb), .2);
}

.chip a, .chip button {
    display: grid;
    place-items: center;
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 50%;
    color: inherit;
    border: 0;
    background: transparent;
    padding: 0;
}

.chip a:hover, .chip button:hover {
    background: rgba(var(--pos-primary-rgb), .15);
}

/* Estado vacío -------------------------------------------------------- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--pos-muted);
}

.empty-state .es-ico {
    width: 3.5rem;
    height: 3.5rem;
    margin: 0 auto .9rem;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-size: 1.5rem;
    background: var(--pos-hover);
    color: var(--pos-muted);
}

.empty-state h3 {
    font-size: .95rem;
    margin-bottom: .25rem;
}

.empty-state p {
    font-size: .8rem;
    margin: 0 auto .9rem;
    max-width: 360px;
}

/* Skeleton loader */
.skeleton {
    background: linear-gradient(90deg, var(--pos-hover) 25%, var(--pos-surface-2) 37%, var(--pos-hover) 63%);
    background-size: 400% 100%;
    animation: pos-shimmer 1.3s ease infinite;
    border-radius: var(--radius-sm);
}

@keyframes pos-shimmer {
    0% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0 50%;
    }
}

/* Lista de definición (vistas de detalle) */
.dl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem 1.5rem;
    margin: 0;
}

.dl-grid dt {
    font-size: .72rem;
    font-weight: 550;
    color: var(--pos-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: .15rem;
}

.dl-grid dd {
    margin: 0;
    font-weight: 550;
}

/* ---------------------------------------------------------------- 6. POS */
/* La pantalla de venta (ventas/pos.html) tiene su hoja propia: /css/pos-venta.css. Aquí quedan solo los
   totales, que también usan el detalle de venta y las cotizaciones. */

.totals > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .1rem 0;
    font-size: .8125rem;
    color: var(--pos-text-2);
}

.totals .grand {
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: -.02em;
    color: var(--pos-text);
    border-top: 1px dashed var(--pos-border-strong);
    margin-top: .3rem;
    padding-top: .3rem;
}

.totals .grand > span:first-child {
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .08em;
    color: var(--pos-muted);
}

.totals .grand.bump > span:last-child {
    animation: pos-bump .3s var(--ease);
}

@keyframes pos-bump {
    50% {
        transform: scale(1.06);
        color: var(--pos-primary);
    }
}

#ticket {
    display: none;
}

/* ---------------------------------------------------------------- 7. Tom Select / utilidades */
.ts-wrapper.form-select, .ts-wrapper.form-control {
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    background: none !important;
}

.ts-wrapper .ts-control {
    border-color: var(--pos-border-strong) !important;
    border-radius: var(--radius-sm) !important;
    background-color: var(--pos-surface) !important;
    color: var(--pos-text);
    box-shadow: var(--shadow-xs);
    padding: .5rem 2.25rem .5rem .75rem;
    font-size: .875rem;
}

.ts-wrapper.focus .ts-control {
    border-color: var(--pos-primary) !important;
    box-shadow: var(--focus-ring) !important;
}

.ts-wrapper.form-select-sm .ts-control {
    min-height: calc(1.5em + .6rem + 2px);
    padding: .3rem 2rem .3rem .6rem;
    font-size: .8125rem;
}

.ts-wrapper.is-invalid .ts-control {
    border-color: var(--pos-danger) !important;
}

.ts-wrapper.is-invalid ~ .invalid-feedback {
    display: block;
}

.ts-dropdown {
    z-index: 1060;
    border-color: var(--pos-border) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow-lg) !important;
    background: var(--pos-surface) !important;
    color: var(--pos-text);
    overflow: hidden;
}

.ts-dropdown .option {
    padding: .45rem .75rem;
}

.ts-dropdown .active {
    background: var(--pos-primary-soft) !important;
    color: var(--pos-text) !important;
}

/* Búsqueda escrita en el propio combo: lo tecleado reemplaza visualmente a la opción elegida */
.ts-wrapper.single .ts-control > input {
    color: var(--pos-text);
}

.ts-wrapper.single.ts-buscando .ts-control > .item {
    display: none;
}

[data-bs-theme="dark"] .ts-control,
[data-bs-theme="dark"] .ts-control input,
[data-bs-theme="dark"] .ts-dropdown {
    background-color: var(--pos-surface);
    color: var(--pos-text);
    border-color: var(--pos-border);
}

/* Lista del picker (autocompletado) */
[data-picker-list] {
    border-radius: var(--radius) !important;
    overflow: hidden;
    margin-top: 4px;
    box-shadow: var(--shadow-lg) !important;
}

[data-picker-list] .list-group-item {
    font-size: .8125rem;
}

/* SweetAlert2 en línea con el sistema */
.swal2-popup {
    border-radius: var(--radius-lg) !important;
    background: var(--pos-surface) !important;
    color: var(--pos-text) !important;
    font-family: var(--bs-font-sans-serif) !important;
}

.swal2-title {
    color: var(--pos-text) !important;
    font-size: 1.25rem !important;
}

.swal2-html-container {
    color: var(--pos-text-2) !important;
    font-size: .9rem !important;
}

.swal2-styled {
    border-radius: var(--radius-sm) !important;
    font-weight: 600 !important;
    font-size: .875rem !important;
}

/* DataTables (si alguna vista lo usa) */
.dataTables_wrapper .page-item.active .page-link {
    background: var(--pos-primary);
    border-color: var(--pos-primary);
}

.dt-search input, .dataTables_filter input {
    border-radius: 8px !important;
}

/* Utilidades */
.fw-550 {
    font-weight: 550;
}

.text-primary-soft {
    color: var(--pos-primary);
}

.bg-surface {
    background: var(--pos-surface);
}

.bg-surface-2 {
    background: var(--pos-surface-2);
}

.min-w-0 {
    min-width: 0;
}

.gap-xs {
    gap: .35rem;
}

/* ---------------------------------------------------------------- Responsive */
.sb-backdrop {
    display: none;
}

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
        width: min(var(--sidebar-w), 86vw);
    }

    .app-main {
        margin-left: 0;
    }

    body.sidebar-open .app-sidebar {
        transform: none;
        box-shadow: var(--shadow-lg);
    }

    body.sidebar-open .sb-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(8, 14, 30, .55);
        backdrop-filter: blur(2px);
        z-index: 1035;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    .app-content {
        padding: 1.1rem 1rem 1.5rem;
    }

    .app-navbar {
        padding: 0 .75rem;
        gap: .4rem;
    }

    .sb-collapse-btn {
        display: none;
    }
}

@media (max-width: 767.98px) {
    .page-head h1 {
        font-size: 1.2rem;
    }

    .page-head > div:last-child {
        width: 100%;
    }

    .kpi .val {
        font-size: 1.3rem;
    }

    .kpi .ico {
        width: 1.9rem;
        height: 1.9rem;
        font-size: .9rem;
    }

    .notif-menu, .quick-menu {
        width: calc(100vw - 1.5rem);
    }

    .form-actions {
        margin-left: -.5rem;
        margin-right: -.5rem;
    }

    .form-actions .btn {
        flex: 1;
    }

    /* Tablas en móvil: scroll horizontal con sombra que indica que hay más contenido */
    .table-responsive {
        background: linear-gradient(to right, var(--pos-surface) 30%, transparent),
        linear-gradient(to left, var(--pos-surface) 30%, transparent) 100% 0,
        radial-gradient(farthest-side at 0 50%, rgba(15, 23, 42, .12), transparent),
        radial-gradient(farthest-side at 100% 50%, rgba(15, 23, 42, .12), transparent) 100% 0;
        background-repeat: no-repeat;
        background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
        background-attachment: local, local, scroll, scroll;
    }
}

/* Táctil: objetivos de al menos 40px (Ley de Fitts) */
@media (pointer: coarse) {
    .btn-sm {
        --bs-btn-padding-y: .45rem;
    }

    .sb-link {
        min-height: 2.6rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}

@media print {
    .app-sidebar, .app-navbar, .footer-app, .no-print, .pos-mobile-bar, .form-actions, .toast-container {
        display: none !important;
    }

    .app-main {
        margin: 0 !important;
    }

    .card {
        box-shadow: none;
        border-color: #ccc;
    }

    body {
        background: #fff;
    }
}
