/* Core Design System: opt in with .core-app and data-core-view.
   Screen-only tokens preserve the existing fiscal/thermal print styles.
   .core-product-grid, .core-sidebar and .core-table are reusable across channels. */
:root {
    --core-bg-canvas: #0f172a;
    --core-bg-surface: #1e293b;
    --core-bg-card: #334155;
    --core-border-subtle: rgba(148, 163, 184, 0.24);
    --core-text-main: #f3f4f6;
    --core-text-muted: #cbd5e1;
    --core-accent: #f59e0b;
    --core-success: #4ade80;
    --core-price-font: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --core-radius: 16px;
    --core-sidebar-width: 250px;
    --core-bottom-height: 88px;
}

.core-camera-scanner {
    position: fixed;
    inset: 0;
    z-index: 10000;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background: #000;
    overflow: hidden;
    isolation: isolate;
}
.core-camera-scanner.hidden { display: none; }
.core-camera-reader, .core-camera-reader > div {
    position: absolute !important;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    padding: 0 !important;
    border: 0 !important;
}
.core-camera-reader {
    inset: auto !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%);
    width: var(--camera-reader-width, 100%) !important;
    height: var(--camera-reader-height, 100%) !important;
}
.core-camera-reader video {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    object-position: center;
}
.core-camera-toolbar {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 16px max(16px, env(safe-area-inset-left));
    background: linear-gradient(#000c, transparent);
    color: white;
}
.core-camera-close {
    min-width: 96px;
    min-height: 48px;
    padding: 12px 16px;
    border-radius: 24px;
    border: 1px solid #fff8;
    background: #000b;
    color: #fff;
    font-weight: bold;
    cursor: pointer;
}
.core-camera-close:focus-visible { outline: 3px solid #22d3ee; outline-offset: 3px; }
.core-camera-controls {
    position: absolute;
    z-index: 3;
    top: calc(env(safe-area-inset-top, 0px) + 88px);
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    color: white;
}
.core-camera-controls button, .core-camera-controls label, .core-camera-controls select {
    min-height: 44px;
    padding: 8px;
    border-radius: 12px;
    background: #111b;
    color: white;
    max-width: 100%;
    min-width: 0;
}
.core-camera-controls button { border: 1px solid #fff8; cursor: pointer; }
.core-camera-controls button[aria-pressed="true"] { background: #047857; }
.core-camera-controls [hidden] { display: none; }
.core-camera-controls p { width: 100%; margin: 0; overflow-wrap: anywhere; }
.core-scan-result {
    padding: 16px;
    margin: 12px 0;
    border: 1px solid #64748b;
    border-radius: 16px;
    background: var(--core-bg-card);
    color: var(--core-text-main);
    max-height: 55dvh;
    overflow: auto;
    overflow-wrap: anywhere;
}
.core-scan-result button, .core-scan-result input { min-height: 44px; margin: 4px; padding: 8px; }
.core-scan-result button { border: 1px solid #64748b; border-radius: 12px; }
.core-scan-result input { width: 100px; background: transparent; color: inherit; border: 1px solid #64748b; }
.core-scan-result[hidden] { display: none; }
.core-camera-launch { min-width: 44px; min-height: 44px; }
.core-camera-target {
    position: absolute;
    z-index: 2;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(72vw, 55vh, 320px);
    width: min(72vw, 55dvh, 320px);
    aspect-ratio: 1;
    border: 2px solid #22d3ee;
    border-radius: 16px;
    box-shadow: 0 0 18px #22d3ee66;
    overflow: hidden;
    pointer-events: none;
}
.core-camera-line {
    position: absolute;
    width: 100%;
    height: 2px;
    background: #34d399;
    box-shadow: 0 0 12px #34d399;
    animation: core-camera-scan 2.4s ease-in-out infinite alternate;
}
.core-camera-help {
    position: absolute;
    z-index: 3;
    bottom: 0;
    width: 100%;
    margin: 0;
    padding: 24px 20px max(24px, env(safe-area-inset-bottom));
    text-align: center;
    color: #fff;
    font-size: 14px;
    background: linear-gradient(transparent, #000d);
}
@keyframes core-camera-scan { from { top: 10%; } to { top: 90%; } }
@media (prefers-reduced-motion: reduce) { .core-camera-line { animation: none; top: 50%; } }

.core-product-thumb {
    width: 100%;
    aspect-ratio: 1/1;
    object-fit: contain;
    background: #090d16;
    border-radius: 10px;
}

@media screen {
    html:has(.core-app) { background: var(--core-bg-canvas); }
    html:not(.dark):has(.core-app) {
        --core-bg-canvas: #f1f5f9;
        --core-bg-surface: #ffffff;
        --core-bg-card: #f1f5f9;
        --core-border-subtle: #e2e8f0;
        --core-text-main: #0f172a;
        --core-text-muted: #475569;
        color-scheme: light;
    }
    body.core-app[data-core-view] {
        background: var(--core-bg-canvas);
        color: var(--core-text-main);
        font-family: var(--core-ui-font, "Plus Jakarta Sans"), ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
        -webkit-font-smoothing: antialiased;
        min-height: 100dvh;
        max-width: 100%;
        overflow-x: clip;
    }
    body.core-app[data-core-view="catalogo"] { height: auto; min-height: 100dvh; }
    .core-app :where(main, section, aside, header, nav, .core-content) { min-width: 0; min-height: 0; }
    .core-app[data-core-view] :is(.bg-slate-950, .dark\:bg-slate-950) { background-color: var(--core-bg-canvas); }
    .core-app[data-core-view] :is(.bg-slate-900, .dark\:bg-slate-900, .core-card) { background-color: var(--core-bg-surface); }
    .core-app[data-core-view] :is(.bg-slate-800, .dark\:bg-slate-800) { background-color: var(--core-bg-card); }
    .core-app[data-core-view] :is(.border-slate-800, .border-slate-700, .dark\:border-slate-800, .core-card) {
        border-color: var(--core-border-subtle);
    }
    .core-app[data-core-view] :is(.text-slate-400, .dark\:text-slate-400) { color: var(--core-text-muted); }
    .core-app .font-mono, .core-price {
        font-family: var(--core-price-font);
        font-variant-numeric: tabular-nums;
        letter-spacing: -0.025em;
    }
    .core-app :where(button, a, input, select, textarea):focus-visible {
        outline: 2px solid var(--core-accent);
        outline-offset: 3px;
    }
    .core-app button { touch-action: manipulation; }
    .core-account-dialog { width: min(94vw, 720px); max-height: 90dvh; padding: 0; border: 1px solid var(--core-border-subtle); border-radius: 16px; background: var(--core-bg-surface); color: var(--core-text-main); }
    .core-account-dialog::backdrop { background: rgba(0, 0, 0, .75); }
    .core-account-header { display: flex; align-items: center; justify-content: space-between; padding: 12px; border-bottom: 1px solid var(--core-border-subtle); }
    .core-account-body { padding: 16px; overflow-y: auto; }
    .core-account-card { padding: 12px; margin-block: 12px; border: 1px solid var(--core-border-subtle); border-radius: 12px; }
    .core-account-action { min-height: 44px; padding: 8px 12px; margin: 4px; border: 1px solid var(--core-accent); border-radius: 10px; color: var(--core-text-main); background: var(--core-bg-card); }
    :is(.core-account-dialog, .core-account-form) label { display: block; margin-block: 8px; }
    :is(.core-account-dialog, .core-account-form) input { display: block; width: 100%; padding: 8px; border: 1px solid var(--core-border-subtle); border-radius: 8px; color: var(--core-text-main); background: var(--core-bg-canvas); }
    .core-account-previews { display: flex; flex-wrap: wrap; gap: 8px; }
    .core-account-previews img { width: 88px; height: 88px; object-fit: contain; }
    .core-account-previews button { display: block; min-height: 44px; }
    .core-account-image { display: block; max-width: 100%; max-height: 72dvh; object-fit: contain; margin: auto; }
    .core-theme-toggle {
        display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
        min-width: 44px; min-height: 44px; border-radius: 12px;
        background: var(--core-bg-card); color: var(--core-text-main); border: 1px solid var(--core-border-subtle);
    }
    .core-topbar-actions { flex-wrap: wrap; }
    html:not(.dark) .core-app :is(.text-white, .text-slate-100, .text-slate-200, .text-slate-300):not(:is(button, a)[class*="bg-"]):not([class*="bg-"]):not(#coreprint-etiqueta-mockup *):not(#corehmr-print-root *) { color: var(--core-text-main); }
    html:not(.dark) .core-app :is(.text-slate-400, .text-slate-500) { color: #475569; }
    html:not(.dark) .core-app :is(input, select, textarea) { color: var(--core-text-main); background-color: var(--core-bg-surface); }
    html:not(.dark) .core-app :is(input, textarea)::placeholder { color: #4b5563; opacity: 1; }
    html:not(.dark) .core-app :is(button, a):is(.bg-slate-700, .bg-slate-800, .bg-slate-900, [class*="bg-slate-800/"]) {
        color: #1f2937 !important;
        background-color: #f1f5f9 !important;
        border-color: #64748b !important;
    }
    html:not(.dark) .core-app :is(button, a):is(.bg-slate-700, .bg-slate-800, .bg-slate-900, [class*="bg-slate-800/"]):hover {
        color: #111827 !important;
        background-color: #e2e8f0 !important;
        border-color: #64748b !important;
    }
    html:not(.dark) .core-app .diag-trigger { color: #1f2937 !important; background: #e2e8f0 !important; border-color: #64748b !important; }
    html:not(.dark) .core-app table { border-color: #cbd5e1; }
    html:not(.dark) .core-app table thead { background: #e2e8f0 !important; color: #374151 !important; }
    html:not(.dark) .core-app table :is(th, td) { border-bottom: 1px solid #cbd5e1; }
    html:not(.dark) .core-app table tbody tr:hover { background: #f8fafc; }
    .core-app .core-printer-settings :is(input, select, textarea) {
        color: var(--core-text-main) !important; background: var(--core-bg-surface) !important;
        border-color: var(--core-border-subtle) !important; color-scheme: inherit;
    }
    .core-app .core-printer-settings option { color: var(--core-text-main); background: var(--core-bg-surface); }
    .core-app .core-printer-settings label { color: var(--core-text-muted); }
    .core-app .core-printer-settings [class*="bg-slate-950/"] { background: var(--core-bg-canvas) !important; }
    .core-app #coreprint-estado-impresora { color: var(--core-text-main) !important; }
    .core-app .core-printer-settings input::placeholder { color: var(--core-text-muted); opacity: 1; }
    .core-grid-sentinel { grid-column: 1 / -1; min-height: 44px; width: 100%; padding: 12px; color: var(--core-accent); }
    .core-grid-sentinel[hidden] { display: none; }
    .core-inventory-controls { position: sticky; top: 0; z-index: 30; flex-shrink: 0; padding-block: 8px; background: var(--core-bg-canvas); border-bottom: 1px solid var(--core-border-subtle); }
    .core-inventory-results { flex: 1 1 0; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch; }
    @media (pointer: coarse) {
        body.core-app[data-core-view="caja"] #core-pos-ticket button,
        body.core-app[data-core-view="caja"] #modal-cobro [data-metodo-rapido] {
            min-width: 44px;
            min-height: 44px;
        }
        body.core-app[data-core-view="caja"] #core-pos-ticket select { min-height: 44px; }
        body.core-app[data-core-view="erp"] #sec-inicio :is(.core-hub-grid, .core-hub-tools) > :is(a, button),
        body.core-app[data-core-view="erp"] #sec-articulos .core-inventory-actions > button,
        body.core-app[data-core-view="erp"] #sec-articulos .core-inventory-view-toggle > button,
        body.core-app[data-core-view="erp"] :is(#sec-autorizaciones, #sec-creditos-clientes, #sec-configuracion, #sec-usuarios, #sec-proveedores, #sec-metodos-pago) :is(button, a):not(table button, table a) {
            min-width: 44px;
            min-height: 44px;
        }
    }
    #sec-articulos .core-inventory-controls { isolation: isolate; }
    #sec-articulos .core-inventory-actions > button { min-height: 44px; }
    .core-inventory-view-toggle { display: none; }
    .core-inventory-name {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        overflow: hidden;
        overflow-wrap: anywhere;
        white-space: normal;
    }
    .core-inventory-category, .core-inventory-prices { min-width: 0; overflow-wrap: anywhere; }
    #tabla-articulos-body { grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr)); }
    @media (max-width: 767px) {
        #sec-articulos .core-inventory-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-bottom: 4px; }
        #sec-articulos .core-inventory-metrics > * { grid-column: auto; padding: 6px; border-radius: 10px; }
        #sec-articulos .core-inventory-metrics .text-xl { font-size: 16px; overflow-wrap: anywhere; }
        #sec-articulos .core-inventory-metrics .tracking-wider { font-size: 9px; letter-spacing: 0; }
        .core-inventory-view-toggle { display: flex; flex-shrink: 0; gap: 2px; }
        .core-inventory-view-toggle button {
            min-width: 44px; min-height: 44px; padding: 4px 6px; border-radius: 10px;
            display: flex; flex-direction: column; align-items: center; justify-content: center;
            gap: 2px; font-size: 10px; color: var(--core-text-muted);
            border: 1px solid var(--core-border-subtle); background: var(--core-bg-surface);
        }
        .core-inventory-view-toggle button[aria-pressed="true"] { color: var(--core-accent); border-color: var(--core-accent); }
        #tabla-articulos-body { gap: 8px; padding: 0; }
        #sec-articulos .core-inventory-results { padding-inline: 0; }
        #tabla-articulos-body .core-inventory-card { padding: 10px; gap: 8px; border-radius: 12px; }
        #tabla-articulos-body .core-inventory-card > * { margin-top: 0; min-width: 0; }
        #tabla-articulos-body .core-inventory-card-heading { flex-direction: column; gap: 8px; }
        #tabla-articulos-body .miniatura-articulo-wrapper { width: 100%; height: 72px; aspect-ratio: auto; }
        #tabla-articulos-body .miniatura-articulo-wrapper img { max-height: 100%; }
        #tabla-articulos-body .core-inventory-card-info { width: 100%; }
        #tabla-articulos-body .core-inventory-card-meta { flex-wrap: wrap; gap: 4px; }
        #tabla-articulos-body .core-inventory-sku { max-width: 100%; }
        #tabla-articulos-body .core-inventory-name { font-size: 12px; line-height: 1.35; }
        #tabla-articulos-body .core-inventory-card-footer { gap: 4px; padding-top: 8px; }
        #tabla-articulos-body .core-inventory-card-footer button { min-width: 44px; min-height: 44px; }
        #tabla-articulos-body[data-inventory-view="list"] { grid-template-columns: minmax(0, 1fr) !important; }
        #tabla-articulos-body[data-inventory-view="list"] .core-inventory-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 112px); align-items: center; }
        #tabla-articulos-body[data-inventory-view="list"] .core-inventory-card-heading { flex-direction: row; align-items: center; }
        #tabla-articulos-body[data-inventory-view="list"] .miniatura-articulo-wrapper { width: 40px; height: 40px; }
        #tabla-articulos-body[data-inventory-view="list"] .core-inventory-card-info { width: auto; }
        #tabla-articulos-body[data-inventory-view="list"] .core-inventory-card-footer { border-top: 0; padding-top: 0; align-items: center; }
        #tabla-articulos-body[data-inventory-view="list"] .core-inventory-prices > .text-base { font-size: 13px; }
        #tabla-articulos-body[data-inventory-view="list"] .core-inventory-category,
        #tabla-articulos-body[data-inventory-view="list"] .core-inventory-cost { display: none; }
    }
    .core-order-add, .core-order-stepper { width: 100%; min-height: 44px; border-radius: 999px; background: var(--core-accent); color: #090d16; font-size: 12px; font-weight: 800; }
    .core-order-stepper { display: flex; align-items: center; justify-content: space-between; background: var(--core-bg-card); color: var(--core-text-main); border: 1px solid var(--core-accent); overflow: hidden; }
    .core-order-stepper button { min-width: 44px; min-height: 44px; flex: 1; color: var(--core-accent); font-size: 20px; }
    .core-order-stepper output { min-width: 28px; text-align: center; font-family: var(--core-price-font); }
    .core-order-control button:disabled { opacity: 0.45; cursor: not-allowed; }
    #grilla-b2b-interactiva button, #grilla-b2b-proveedor button { min-width: 44px; min-height: 44px; }
    .core-app[data-core-view="catalogo"] { padding-bottom: calc(112px + env(safe-area-inset-bottom)); }
    .core-app[data-core-view="catalogo"] #btn-ver-pedido { width: auto; flex-shrink: 0; }
    .core-app[data-core-view="catalogo"] .core-order-add { background: #10b981; color: #052e23; }
    .core-app[data-core-view="catalogo"].core-order-open { position: fixed; width: 100%; overflow: hidden; }
    .core-order-overlay { z-index: 100; }
    .core-order-sheet { height: 90dvh; max-height: 90dvh; background: var(--core-bg-surface); animation: core-sheet-in 180ms ease-out; }
    .core-order-sheet-scroll { overflow-y: auto; overscroll-behavior: contain; flex: 1; min-height: 0; }
    .core-order-sheet-footer { flex-shrink: 0; background: var(--core-bg-canvas); padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
    .core-order-sheet :is(button, input, select, textarea) { min-height: 44px; }
    .core-order-sheet button { min-width: 44px; }
    .core-order-line { min-width: 0; }
    .core-order-line h4 { white-space: normal; overflow-wrap: anywhere; }
    .core-b2b-mobile-bar { display: none; }
    .core-b2b-order-dialog { width: 100%; max-width: 100%; height: 90dvh; max-height: 90dvh; margin: auto auto 0; padding: 12px; border: 1px solid var(--core-border-subtle); border-radius: 24px 24px 0 0; background: var(--core-bg-surface); color: var(--core-text-main); overflow: hidden; }
    .core-b2b-order-dialog[open] { display: flex; flex-direction: column; animation: core-sheet-in 180ms ease-out; }
    .core-b2b-order-dialog::backdrop { background: rgba(0, 0, 0, 0.8); }
    .core-b2b-dialog-header { display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; padding-bottom: 8px; }
    #b2b-order-slot { flex: 1; min-height: 0; display: flex; }
    #b2b-order-slot #panel-col-carrito { display: flex; width: 100%; min-height: 0; }
    #b2b-order-dialog :is(button, input) { min-width: 44px; min-height: 44px; }
    #b2b-order-dialog #panel-col-carrito { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
    .core-b2b-remove { min-width: 44px; min-height: 44px; margin-left: auto; }
    .core-b2b-photo { background: var(--core-bg-canvas); }
    .core-b2b-card { min-width: 0; height: auto; }
    /* Nombre B2B completo: ajusta en varias lineas, nunca se recorta (catalogos con nombres largos). */
    .core-b2b-name { display: block; min-height: 2.6em; line-height: 1.3; white-space: normal; overflow: visible; overflow-wrap: anywhere; word-break: break-word; }
    .core-b2b-pack { overflow-wrap: anywhere; }
    .core-b2b-card-footer { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; margin-top: auto; flex-shrink: 0; padding-top: 8px; gap: 6px; }
    .core-b2b-card-footer > div:last-child { display: contents; }
    .core-b2b-card-footer select { grid-column: 1 / -1; grid-row: 1; width: 100%; max-width: 100%; }
    .core-b2b-card-footer > div:first-child { grid-column: 1; grid-row: 2; min-width: 0; }
    .core-b2b-card-footer button { grid-column: 2; grid-row: 2; }
    #grilla-b2b-interactiva { flex: 1; min-height: 0; align-items: stretch; }
    #grilla-b2b-interactiva, #grilla-b2b-proveedor { grid-auto-rows: max-content; }
    @media (min-width: 768px) {
        .core-b2b-catalog-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(120px, 0.8fr); gap: 8px; align-items: center; }
        .core-b2b-catalog-toolbar > div { min-width: 0; border-bottom: 0; padding-bottom: 0; }
        .core-b2b-catalog-toolbar > div > div:first-child { min-width: 0; }
        .core-b2b-catalog-toolbar .core-b2b-search { padding: 0; }
        .core-b2b-catalog-toolbar output { grid-column: 1 / -1; }
        .core-b2b-card .core-b2b-photo { height: 130px; max-height: 130px; aspect-ratio: 1 / 1; }
        .core-b2b-card .core-b2b-photo img { width: 100%; max-height: 130px; object-fit: contain; }
    }
    #b2b-import-status:empty { display: none; }
    #grilla-b2b-interactiva, #grilla-b2b-proveedor { background: var(--core-bg-canvas); }
    #panel-col-catalogo, #panel-col-carrito { background: var(--core-bg-surface); }
    @keyframes core-sheet-in { from { transform: translateY(100%); } to { transform: translateY(0); } }
    @media (prefers-reduced-motion: reduce) { .core-order-sheet, .core-b2b-order-dialog[open] { animation: none; } }
    @media (max-width: 767px) {
        .core-app[data-core-view="catalogo"] main { width: 100%; max-width: none; margin-inline: 0; box-sizing: border-box; }
        .core-app[data-core-view="catalogo"] #grilla-articulos { width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
        .core-order-overlay { padding: 0; align-items: flex-end; }
        .core-order-sheet { width: 100%; max-width: none; border-radius: 24px 24px 0 0; }
        #barra-pedido-flotante > div > div { min-width: 0; }
        #barra-pedido-flotante > div > div > div { flex-wrap: wrap; }
    }
    .core-category-pills { display: flex; gap: 8px; min-width: 0; max-width: 100%; overflow-x: auto; flex-shrink: 0; padding-block: 4px 8px; scroll-snap-type: x proximity; }
    .core-app[data-core-view="catalogo"] .core-topbar > div { width: 100%; min-width: 0; }
    .core-app .core-category-pill { flex-shrink: 0; white-space: nowrap; min-height: 44px; padding: 8px 14px; border: 1px solid var(--core-border-subtle); border-radius: 999px; color: var(--core-text-muted); background: var(--core-bg-surface); scroll-snap-align: start; font-size: 12px; font-weight: 700; }
    .core-app .core-category-pill[aria-pressed="true"] { background: var(--core-accent); color: #090d16; border-color: var(--core-accent); }
    .core-category-status { align-self: center; flex-shrink: 0; color: #fbbf24; font-size: 11px; }
    .core-category-manager { width: min(440px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 24px; border: 1px solid var(--core-border-subtle); border-radius: 20px; background: var(--core-bg-surface); color: var(--core-text-main); overflow-y: auto; }
    .core-category-manager::backdrop { background: rgba(0, 0, 0, 0.75); backdrop-filter: blur(8px); }
    .core-category-manager form { display: grid; gap: 16px; }
    .core-category-manager :is(input, select, button) { min-height: 44px; border-radius: 10px; padding: 10px; background: var(--core-bg-card); color: var(--core-text-main); border: 1px solid var(--core-border-subtle); }
    .core-category-manager button[type="submit"] { background: var(--core-accent); color: #090d16; font-weight: 700; }
    .core-app input::placeholder, .core-app textarea::placeholder { color: var(--core-text-muted); opacity: 0.75; }
    .core-app :where(input, select, textarea) { max-width: 100%; }
    .core-app ::-webkit-scrollbar { width: 5px; height: 5px; }
    .core-app ::-webkit-scrollbar-thumb { background: #334155; border-radius: 10px; }
    .core-app .core-topbar {
        background: var(--core-bg-surface);
        border-bottom: 1px solid var(--core-border-subtle);
        gap: 12px;
        min-height: 64px;
    }
    .core-app[data-core-view] .core-card, .core-app[data-core-view] .core-kpi {
        border: 1px solid var(--core-border-subtle);
        border-radius: var(--core-radius);
        background: var(--core-bg-surface);
        box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
    }
    .core-app .core-kpi { padding: 18px; position: relative; overflow: hidden; }
    .core-kpi::before {
        content: "";
        position: absolute;
        top: 0;
        left: 18px;
        width: 32px;
        height: 2px;
        background: var(--core-accent);
    }
    .core-product-grid { gap: 12px; }
    .core-product-grid:not(:where(#tabla-articulos-body)) { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    .core-product-grid > * { min-width: 0; }
    .core-product-grid .miniatura-articulo-wrapper { flex-shrink: 0; height: auto; aspect-ratio: 1/1; }
    .core-product-grid img.core-product-thumb { height: auto; object-fit: contain !important; }
    /* POS: vertical touch cards; the catalog grid remains the native scroll root. */
    .core-app[data-core-view="caja"] #grid-catalogo-caja {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
        gap: 12px;
        grid-auto-rows: max-content;
        align-items: stretch;
        scrollbar-gutter: stable;
    }
    .core-pos-product-card {
        display: flex; flex-direction: column; min-width: 0; padding: 0; overflow: hidden;
        border: 1px solid var(--core-border-subtle); border-radius: 16px;
        background: var(--core-bg-surface); color: var(--core-text-main);
        text-align: left; cursor: pointer; touch-action: manipulation;
        transition: transform 100ms ease, border-color 100ms ease;
        content-visibility: auto;
        contain-intrinsic-block-size: auto 320px;
    }
    .core-pos-product-card:hover:not(:disabled) { border-color: var(--core-success); }
    .core-pos-product-card:active:not(:disabled) { transform: scale(0.97); }
    .core-pos-product-card:disabled { opacity: 0.5; cursor: not-allowed; }
    .core-pos-product-image {
        position: relative; display: flex; align-items: center; justify-content: center;
        width: 100%; aspect-ratio: 1 / 1; flex-shrink: 0; background: var(--core-bg-card);
        overflow: hidden;
    }
    .core-pos-product-image img.core-product-thumb {
        width: 100%; height: 100%; object-fit: contain !important;
        padding: 12px; border-radius: 0; background: transparent;
    }
    .core-pos-product-placeholder {
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        gap: 8px; max-width: 100%; padding: 16px; color: var(--core-text-muted);
    }
    .core-pos-product-placeholder svg { width: 48px; height: 48px; }
    .core-pos-product-placeholder > span { max-width: 100%; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .core-pos-product-stock {
        position: absolute; top: 8px; right: 8px; padding: 4px 7px; border-radius: 8px;
        background: var(--core-bg-surface); color: #10b981; border: 1px solid var(--core-border-subtle);
        font: 700 11px var(--core-price-font);
    }
    .core-pos-product-stock.is-low { color: #f59e0b; }
    .core-pos-product-stock.is-empty { color: #f43f5e; }
    .core-pos-product-info { display: flex; flex-direction: column; gap: 5px; padding: 12px 12px 8px; }
    .core-pos-product-name {
        display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
        line-clamp: 2;
        font-size: 13px; font-weight: 700; line-height: 1.4; min-height: 2.8em; overflow-wrap: anywhere;
    }
    .core-pos-product-reference {
        display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
        font: 500 11px var(--core-price-font); color: var(--core-text-muted);
    }
    .core-pos-product-prices { display: flex; flex-direction: column; gap: 4px; margin-top: auto; padding: 8px 12px 12px; }
    .core-pos-product-usd { font: 800 18px var(--core-price-font); color: #10b981; }
    .core-pos-product-bs { font: 600 11px var(--core-price-font); color: var(--core-text-muted); overflow-wrap: anywhere; }
    .core-pos-product-action { margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--core-border-subtle); font-size: 11px; font-weight: 700; color: var(--core-accent); }
    .core-app .miniatura-catalogo { object-fit: contain; }
    .core-app .core-bottom-bar {
        background: rgba(15, 23, 42, 0.9);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-top: 1px solid var(--core-border-subtle);
        color: #f8fafc;
        padding: 12px max(16px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
        box-shadow: 0 -12px 32px rgba(0, 0, 0, 0.2);
        z-index: 30;
    }
    .core-mobile-ticket-bar { display: none; }
    .core-pos-layout { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr) !important; height: auto; min-height: 0; }
    .core-pos-layout > * { grid-column: auto !important; }
    .core-ticket { border: 1px solid var(--core-border-subtle); background: var(--core-bg-surface); border-radius: 20px; }
    .core-app .core-sidebar {
        width: var(--core-sidebar-width);
        flex: 0 0 var(--core-sidebar-width);
        background: var(--core-bg-surface);
        border-right: 1px solid var(--core-border-subtle);
        transition: width 180ms ease, flex-basis 180ms ease, transform 180ms ease;
    }
    .core-sidebar nav :where(button, a) { min-height: 44px; border-radius: 12px; }
    .core-sidebar nav :where(button, a):hover { background-color: var(--core-bg-card); }
    .core-sidebar-toggle { min-width: 44px; min-height: 44px; }
    .core-table-scroll { overflow-x: auto; overscroll-behavior: contain; }
    .core-table {
        width: 100%;
        border-collapse: separate;
        border-spacing: 0;
        color: var(--core-text-main);
        background: var(--core-bg-surface);
    }
    .core-table th {
        color: var(--core-text-muted);
        font-size: 11px;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        background: var(--core-bg-card);
    }
    .core-table :where(th, td) { padding: 12px 14px; border-bottom: 1px solid var(--core-border-subtle); }
    .core-table tbody tr:hover { background: rgba(56, 189, 248, 0.04); }
    .core-row-off-page { display: none !important; }
    .core-table-tools {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
        padding: 12px;
        background: var(--core-bg-surface);
        border: 1px solid var(--core-border-subtle);
        border-radius: 12px;
        margin-block: 8px;
    }
    .core-table-tools input { flex: 1 1 160px; min-width: 0; }
    .core-table-tools :where(input, select, button) {
        background: var(--core-bg-card);
        color: var(--core-text-main);
        border: 1px solid var(--core-border-subtle);
        border-radius: 8px;
        padding: 8px 12px;
    }
    .core-table-tools button:disabled { opacity: 0.4; cursor: not-allowed; }
    .core-table-tools [role="status"] { font-size: 12px; color: var(--core-text-muted); }
    .core-app [id^="modal-"] > :where(div, form, section) {
        max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        overscroll-behavior: contain;
        overflow-y: auto;
    }
    .core-cash-close > div { border-radius: 20px; border-color: var(--core-border-subtle); }
    .core-cash-close .bg-slate-950 { border-radius: 14px; }
    .core-sidebar-backdrop { z-index: 45; }

    @media (min-width: 768px) {
        .core-product-grid:not(:where(#tabla-articulos-body)) { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
        .core-app .core-sidebar {
            position: relative !important;
            inset: auto !important;
            transform: none !important;
            height: 100%;
        }
        .core-sidebar-backdrop { display: none !important; }
        .core-sidebar-collapsed { --core-sidebar-width: 64px; }
    }
    @media (min-width: 768px) and (max-width: 1199px) {
        .core-app { --core-sidebar-width: 64px; }
        .core-app.core-sidebar-expanded { --core-sidebar-width: 250px; }
    }
    @media (min-width: 768px) and (max-width: 1199px) {
        .core-app:not(.core-sidebar-expanded) .core-sidebar { padding: 8px; }
        .core-app:not(.core-sidebar-expanded) .core-sidebar nav { padding-inline: 0; }
        .core-app:not(.core-sidebar-expanded) .core-sidebar > div:last-child { padding: 8px 0; }
        .core-app:not(.core-sidebar-expanded) .core-sidebar :where(nav span, nav > div, .core-sidebar-label, .core-sidebar-brand) { display: none; }
        .core-app:not(.core-sidebar-expanded) .core-sidebar nav :where(button, a) { justify-content: center; padding: 10px 0; }
        .core-app:not(.core-sidebar-expanded) .core-sidebar nav i { margin: 0 !important; font-size: 18px; }
    }
    .core-sidebar-collapsed .core-sidebar { padding: 8px; }
    .core-sidebar-collapsed .core-sidebar nav { padding-inline: 0; }
    .core-sidebar-collapsed .core-sidebar > div:last-child { padding: 8px 0; }
    .core-sidebar > div:last-child button { min-height: 44px; }
    .core-sidebar-collapsed .core-sidebar :where(nav span, nav > div, .core-sidebar-label, .core-sidebar-brand) { display: none; }
    .core-sidebar-collapsed .core-sidebar nav :where(button, a) { justify-content: center; padding: 10px 0; }
    .core-sidebar-collapsed .core-sidebar nav i { margin: 0 !important; font-size: 18px; }

    @media (min-width: 1200px) {
        .core-product-grid:not(:where(#tabla-articulos-body)) { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
    }
    @media (max-width: 1024px) {
        .core-app :where(button, a) { min-height: 44px; }
        .core-app :where(input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]), select, textarea) {
            min-height: 44px;
            font-size: 16px;
        }
        .core-topbar { flex-wrap: wrap; }
    }
    @media (max-width: 1199px) {
        .core-app[data-core-view="vendedor"] .core-vendedor-bottom {
            display: flex !important;
            position: fixed;
            inset: auto 0 0;
        }
        .core-app[data-core-view="vendedor"] .core-vendedor-catalog {
            padding-bottom: calc(112px + env(safe-area-inset-bottom));
        }
        .core-app[data-core-view="vendedor"] #aside-carrito {
            position: fixed !important;
            width: min(100%, 384px);
        }
        .core-app[data-core-view="vendedor"] #aside-carrito.translate-x-full {
            transform: translateX(100%) !important;
        }
        .core-app[data-core-view="vendedor"] #aside-carrito:not(.translate-x-full) {
            transform: translateX(0) !important;
        }
        .core-app[data-core-view="vendedor"] #aside-carrito button[onclick="toggleCarritoMovil()"] {
            display: inline-flex !important;
        }
    }
    @media (max-width: 767px) {
        .core-app { --core-bottom-height: 96px; }
        .core-sidebar { max-width: 90vw; z-index: 50; }
        .core-sidebar-brand { padding: 12px; }
        .core-topbar {
            --header-padding-top: 10px;
            --header-padding-x: 12px;
            padding: calc(env(safe-area-inset-top, 0px) + var(--header-padding-top)) max(var(--header-padding-x), env(safe-area-inset-right, 0px)) 10px max(var(--header-padding-x), env(safe-area-inset-left, 0px));
        }
        .core-app[data-core-view="erp"] .core-topbar { --header-padding-top: 0.75rem; }
        #btn-volver-proveedores, .core-app[data-core-view="erp"] [data-core-sidebar-toggle] { min-width: 44px; min-height: 44px; }
        .core-topbar > div { flex-wrap: wrap; }
        .core-topbar > div:last-child { margin-left: auto; }
        .core-pos-layout { display: flex !important; flex-direction: column; }
        .core-pos-catalog { flex: 1; padding-bottom: calc(var(--core-bottom-height) + env(safe-area-inset-bottom)); }
        .core-pos-layout > .core-ticket { display: none; }
        .core-app[data-core-ticket-open="true"] .core-pos-catalog { display: none; }
        .core-app[data-core-ticket-open="true"] .core-pos-layout > .core-ticket { display: flex; flex: 1; }
        .core-app[data-core-ticket-open="true"] .core-mobile-ticket-bar { display: none; }
        .core-mobile-ticket-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
        .core-mobile-ticket-bar, .core-vendedor-bottom {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
        }
        .core-vendedor-catalog { padding-bottom: calc(var(--core-bottom-height) + env(safe-area-inset-bottom)); }
        .core-ticket-back { display: inline-flex; align-items: center; justify-content: center; }
        .core-app[data-core-view="catalogo"] main { padding-bottom: calc(var(--core-bottom-height) + env(safe-area-inset-bottom)); }
        #tabla-articulos-body > div > div:first-child { flex-direction: column; }
        #tabla-articulos-body .miniatura-articulo-wrapper { width: 100%; height: auto; aspect-ratio: 1/1; }
        .core-cash-close > div { padding: 16px; }
        .core-cash-close .grid-cols-2 { grid-template-columns: minmax(0, 1fr); }
        .core-cash-close :where(label, input) { width: 100%; }
        .core-cash-close .flex { flex-wrap: wrap; gap: 8px; }
    }
    @media (max-width: 1279px) {
        .core-b2b-header { padding-top: max(0.75rem, env(safe-area-inset-top)); }
        .core-b2b-header > div { flex-wrap: wrap; min-width: 0; }
        #contenedor-layout-b2b { display: flex; flex-direction: column; }
        #panel-col-proveedores { flex: 1 1 auto; min-height: 0; }
        #proveedores-grid { padding-bottom: 12px; overscroll-behavior: contain; }
        #panel-col-catalogo { min-height: 0; }
    }
    @media (max-width: 1023px) {
        #contenedor-layout-b2b > #panel-col-carrito { display: none; }
        #sec-proveedores { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
        /* Movil y tablet: lista y catalogo se alternan a pantalla completa. */
        #sec-proveedores:not([data-catalogo-abierto="true"]) #panel-col-catalogo { display: none; }
        #sec-proveedores[data-catalogo-abierto="true"] { padding: 0 0 calc(72px + env(safe-area-inset-bottom)); }
        #sec-proveedores[data-catalogo-abierto="true"] .core-b2b-header { position: sticky; top: 0; z-index: 20; margin: 0; padding: 6px 8px; border-radius: 0; }
        #sec-proveedores[data-catalogo-abierto="true"] [data-b2b-admin],
        #sec-proveedores[data-catalogo-abierto="true"] .core-b2b-header :is(p, h2 > i) { display: none; }
        #sec-proveedores[data-catalogo-abierto="true"] #panel-col-proveedores { display: none; }
        #sec-proveedores[data-catalogo-abierto="true"] #panel-col-catalogo { padding: 4px; border-radius: 0; border: 0; }
        #sec-proveedores[data-catalogo-abierto="true"] #grilla-b2b-interactiva { grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr)); gap: 12px; padding: 0; margin-top: 0; }
        #sec-proveedores[data-catalogo-abierto="true"] .core-b2b-header h2 { font-size: 11px; }
        #sec-proveedores[data-catalogo-abierto="true"] .core-b2b-photo { padding: 6px; }
        #sec-proveedores:not([data-catalogo-abierto="true"]) .core-b2b-mobile-bar { display: none; }
        .core-b2b-mobile-bar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; min-height: 52px; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--core-border-subtle); background: var(--core-bg-surface); font-size: 11px; }
        .core-b2b-mobile-bar button { min-height: 44px; flex-shrink: 0; }
    }
    @media (min-width: 1280px) {
        /* Escritorio ancho: paneles laterales acotados; el catálogo absorbe todo el espacio restante.
           El id prevalece sobre los xl:col-span-* que alterna suppliers.js al abrir/cerrar el catálogo. */
        #contenedor-layout-b2b { grid-template-columns: clamp(220px, 20%, 300px) minmax(0, 1fr) clamp(280px, 26%, 380px); }
        #contenedor-layout-b2b > [id^="panel-col-"] { grid-column: auto; }
        #sec-proveedores[data-catalogo-abierto="true"] #contenedor-layout-b2b { grid-template-columns: minmax(0, 1fr) clamp(280px, 24%, 400px); }
    }
    @media (min-width: 1536px) {
        #modal-comparador-b2b > .core-modal-panel { max-width: min(96vw, 1760px); }
    }
    @media (min-width: 1024px) and (max-width: 1279px) {
        #panel-col-catalogo { flex: 1 0 56%; min-height: 340px; }
        #panel-col-carrito { display: flex; flex: 0 0 320px; min-height: 320px; }
    }
    @media (min-width: 1024px) and (max-height: 820px) {
        .core-b2b-name {
            display: -webkit-box;
            -webkit-line-clamp: 6;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }
    }
    @media (min-width: 1024px) and (max-height: 700px) {
        .core-b2b-card .core-b2b-photo { height: 104px; max-height: 104px; }
        .core-b2b-card .core-b2b-photo img { max-height: 104px; }
        .core-b2b-name { -webkit-line-clamp: 4; }
    }
    @media (min-width: 768px) {
        .core-ticket-back { display: none; }
    }
    .core-section-tabs {
        display: flex;
        gap: 8px;
        max-width: 100%;
        overflow-x: auto;
        padding: 6px;
        border: 1px solid var(--core-border-subtle);
        border-radius: 14px;
        background: var(--core-bg-surface);
        scrollbar-width: thin;
    }
    .core-section-tabs [role="tab"] {
        flex: 1 0 auto;
        min-height: 42px;
        padding: 9px 14px;
        border: 1px solid transparent;
        border-radius: 10px;
        color: var(--core-text-muted);
        background: transparent;
        font-size: 12px;
        font-weight: 800;
        white-space: nowrap;
        cursor: pointer;
    }
    .core-section-tabs [role="tab"]:hover { color: var(--core-text-main); background: var(--core-bg-card); }
    .core-section-tabs [role="tab"][aria-selected="true"] {
        color: #111827;
        background: var(--core-accent);
        border-color: var(--core-accent);
        box-shadow: 0 6px 18px rgba(245, 158, 11, .18);
    }
    [data-core-tab-panel][hidden] { display: none !important; }
    html:not(.dark) .core-app .core-section-tabs { border-color: #cbd5e1; background: #ffffff; }
    html:not(.dark) .core-app .core-section-tabs [role="tab"] { color: #374151; }
    html:not(.dark) .core-app .core-section-tabs [role="tab"]:hover { color: #111827; background: #f1f5f9; }

    @media (prefers-reduced-motion: reduce) {
        .core-app *, .core-app *::before, .core-app *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
    }
}

@media print {
    .core-table-tools, .core-bottom-bar, .core-sidebar-toggle, .core-ticket-back { display: none !important; }
    .core-row-off-page { display: table-row !important; }
}
