/*
IMPORTANTE (DOCUMENTACIÓN DIDÁCTICA):
- Este proyecto se usa también como material de aprendizaje.
- Mantener comentarios MUY explicativos: qué hace cada bloque, qué endpoint llama, y con qué archivo se comunica.
- Cuando se agregue código nuevo, documentarlo como si lo fuera a leer un estudiante de 1er semestre.

Archivo: wwwroot/css/xtrak.css
Fecha: 2026-02-04
*/

/* =========================
   XTRAK - THEME BASE
   Mantiene tu look "glass"
   ========================= */
:root {
    /*
      Variables "glass" base.
      IMPORTANTE:
      - No usamos colores fijos (blanco/negro) para que el tema Bootstrap (data-bs-theme)
        pueda alternar claro/oscuro sin romper el diseño.
      - Estas variables se ajustan más abajo para light/dark.
    */
    --glass-bg: color-mix(in srgb, var(--bs-body-bg) 88%, transparent);
    --glass-border: color-mix(in srgb, var(--bs-body-color) 12%, transparent);
    --glass-shadow: 0 10px 30px rgba(0,0,0,.22);
    --muted: color-mix(in srgb, var(--bs-body-color) 65%, transparent);

    /* Fondo "ambient" (se ajusta por tema) */
    --page-bg: var(--bs-body-bg);
}

/* ======= Ajustes por tema (Bootstrap 5.3) =======
   Bootstrap usa el atributo data-bs-theme en <html>.
   Aquí afinamos el look glass para que se vea bien en ambos temas.
*/
html[data-bs-theme="light"] {
    /*
      Glass en tema claro:
      Subimos un poco la opacidad para mejorar legibilidad (sin perder el efecto).
    */
    --glass-bg: rgba(255,255,255,.78);
    --glass-border: rgba(0,0,0,.08);
    --glass-shadow: 0 10px 30px rgba(18, 38, 63, .10);
    --muted: rgba(0,0,0,.55);

    /* Glass “fuerte” para overlays (dropdowns/menús flotantes) */
    --glass-bg-strong: rgba(255,255,255,.92);

    --page-bg: radial-gradient(1200px 600px at 10% 10%, #e9f2ff, transparent), #f6f7fb;
}

html[data-bs-theme="dark"] {
    /*
      Glass en tema oscuro:
      Subimos un poco la opacidad para que el contenido no “se pierda”.
    */
    --glass-bg: rgba(255,255,255,.10);
    --glass-border: rgba(255,255,255,.10);
    --glass-shadow: 0 10px 30px rgba(0,0,0,.25);
    --muted: rgba(255,255,255,.70);

    /* Glass “fuerte” para overlays (dropdowns/menús flotantes) */
    --glass-bg-strong: rgba(15, 23, 42, .88);

    --page-bg: radial-gradient(1200px 600px at 10% 10%, rgba(13,110,253,.18), transparent), #0b1220;
}

html, body {
    height: 100%;
}

/* Evita scroll horizontal en toda la app (típico por row/gutters o links largos) */
body {
    min-height: 100vh;
    overflow-x: hidden;
}

/* Mantiene tu contenedor centrado */
.app-shell {
    max-width: 1200px;
}

/* Tarjetas glass */
.glass {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1rem;
    /*
      Sombra centralizada en variable para que se ajuste por tema.
      (Evita que en tema claro quede “muy pesada”).
    */
    box-shadow: var(--glass-shadow);
}

/* =========================================================
   TOPBAR y MENÚS FLOTANTES
   Objetivo:
   - Garantizar que el TopBar SIEMPRE quede por encima del contenido.
   - Hacer los dropdowns más legibles (menos transparentes) sin perder el glass.
   ========================================================= */

/* Contenedor donde layout.js inyecta el TopBar */
#topbar-container {
    position: sticky;
    top: 0;
    z-index: 2200;
    overflow: visible;
    isolation: isolate;
}

/* Barra superior (la clase .topbar la usamos en el parcial TopBar.html) */
.topbar {
    position: sticky;
    top: 0;
    z-index: 2200;
    overflow: visible;
}

/* Dropdowns del TopBar: glass más “fuerte” y encima de todo */
.topbar .dropdown-menu {
    z-index: 2300;
    margin-top: .5rem;
    background: var(--glass-bg-strong);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Items dentro del menú: mejora contraste */
.topbar .dropdown-menu .dropdown-item {
    color: var(--bs-body-color);
}

.topbar .dropdown-menu .dropdown-item:hover,
.topbar .dropdown-menu .dropdown-item:focus {
    background: color-mix(in srgb, var(--bs-primary) 12%, transparent);
}

.topbar,
.topbar .container-fluid,
.topbar .dropdown,
.topbar-actions,
#topbar-container {
    overflow: visible !important;
}

.topbar-actions {
    flex-wrap: nowrap;
}

.small-muted {
    color: var(--muted);
}

.brand-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.brand-text {
    letter-spacing: .2px;
}

/* =========================
   NAV ITEM (tu "nav-pill")
   ========================= */
.nav-pill {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem .7rem;
    border-radius: 12px;
    text-decoration: none;
    color: rgba(255,255,255,.85);
    background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.06);
    /* IMPORTANTE: evita que textos largos creen scroll horizontal */
    white-space: normal;
    word-break: break-word;
}

    .nav-pill:hover {
        color: #fff;
        background: rgba(255,255,255,.08);
        border-color: rgba(255,255,255,.12);
    }

/* =========================
   SIDEBAR OFFCANVAS
   Objetivo: siempre oculto.
   Se muestra con botón hamburguesa.
   ========================= */

/* el offcanvas en bootstrap tiene ancho propio; aquí lo fijamos */
#sidebar {
    width: 280px;
    max-width: 85vw;
    overflow-x: hidden; /* mata scroll horizontal interno */
}

    /* cuerpo con scroll vertical si el menú crece */
    #sidebar .sidebar-body {
        max-height: calc(100vh - 110px); /* header + padding aprox */
        overflow-y: auto;
        overflow-x: hidden;
    }

/* Ajuste visual para separación del contenido */
.main-pad {
    padding-top: 1rem;
}

/* Fondo general (depende de --page-bg por tema) */
body {
    background: var(--page-bg);
}

/* Utilidades que antes estaban inline en algunas páginas */
.mono { font-variant-numeric: tabular-nums; }

/* Alias para textos secundarios (varios HTML usan .muted) */
.muted { color: var(--muted) !important; }

/* KPI box para pantallas de costos/precio */
.kpi {
    border-radius: 14px;
    border: 1px dashed color-mix(in srgb, var(--bs-body-color) 18%, transparent);
    padding: .85rem;
    background: color-mix(in srgb, var(--bs-body-bg) 84%, transparent);
}

/* Cabecera sticky (para acciones en pantallas largas) */
.sticky-actions {
    position: sticky;
    top: 0;
    z-index: 10;
    background: color-mix(in srgb, var(--bs-body-bg) 86%, transparent);
    backdrop-filter: blur(8px);
}

/* Badge suave (para etiquetas de contexto) */
.badge-soft {
    background: color-mix(in srgb, var(--bs-primary) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--bs-primary) 22%, transparent);
    color: var(--bs-primary);
}

.readonly {
    background: color-mix(in srgb, var(--bs-body-color) 4%, transparent);
}

/* Evita que <thead> rompa el layout por columnas angostas */
.table thead th { white-space: nowrap; }

.list-group-item-action { cursor: pointer; }

/* =====================================================
   Mensajes de estado (hdrMsg)
   =====================================================
   - layout.js garantiza que exista <span id="hdrMsg"> en todas las páginas.
   - Para escribir: window.XtrakUI.setHdrMsg('texto', 'info'|'success'|'warn'|'error')
   - Las clases siguientes mantienen el look "glass" y se adaptan a light/dark.
*/

.xtrak-msg {
    display: inline-block;
    padding: .25rem .5rem;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, var(--bs-body-color) 18%, transparent);
    background: color-mix(in srgb, var(--bs-body-bg) 86%, transparent);
    color: var(--bs-body-color);
}

.xtrak-msg-info {
    border-color: color-mix(in srgb, var(--bs-primary) 35%, transparent);
    background: color-mix(in srgb, var(--bs-primary) 12%, transparent);
}

.xtrak-msg-success {
    border-color: color-mix(in srgb, var(--bs-success) 35%, transparent);
    background: color-mix(in srgb, var(--bs-success) 12%, transparent);
}

.xtrak-msg-warn {
    border-color: color-mix(in srgb, var(--bs-warning) 45%, transparent);
    background: color-mix(in srgb, var(--bs-warning) 14%, transparent);
}

.xtrak-msg-error {
    border-color: color-mix(in srgb, var(--bs-danger) 45%, transparent);
    background: color-mix(in srgb, var(--bs-danger) 14%, transparent);
}



/* =========================
   PRODUCTOS · IMÁGENES (UI)
   - Solo UI por ahora (localStorage).
   - Cuando haya backend, este bloque sigue sirviendo para la estética.
   ========================= */
.product-media .media-main-wrap{
  position: relative;
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
}
.product-media .media-main-img{
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}
.product-media .media-empty{
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: color-mix(in srgb, var(--glass-bg) 88%, transparent);
  backdrop-filter: blur(6px);
}
.product-media .media-thumbs{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.product-media .media-thumb{
  width: 64px;
  height: 64px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  padding: 0;
  cursor: pointer;
}
.product-media .media-thumb img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.product-media .media-thumb.active{
  outline: 2px solid color-mix(in srgb, var(--bs-primary) 75%, transparent);
  outline-offset: 2px;
}


/* =========================
   FORM ALIGNMENT (ORDEN VISUAL)
   Objetivo: que los campos queden en la misma "altura" y no se vean desordenados.
   ========================= */
.field-note{
  line-height: 1.25;
}

/* En pantallas grandes, el selector de estado debe ser legible */
#hdrEstado{
  min-width: 180px;
}


/* =====================================================
   RESPONSIVE-FIRST 2026-03-29
   Regla vigente del proyecto:
   - una sola UI responsive
   - optimizada para celular, tablet y PC
   ===================================================== */
:root {
    --shell-max: 1320px;
    --page-pad-x: clamp(.85rem, 1.6vw, 1.25rem);
    --page-pad-y: clamp(.85rem, 1.6vw, 1.25rem);
    --control-min-h: 42px;
}

.xtrak-page {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.app-shell,
.page-shell {
    max-width: var(--shell-max);
    padding-left: var(--page-pad-x);
    padding-right: var(--page-pad-x);
}

.page-section {
    padding-inline: 0;
}

.page-header,
.page-head-card,
.sticky-actions {
    border-radius: 18px;
}

.page-toolbar,
.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .65rem;
    align-items: center;
}

.page-title-block {
    min-width: 0;
}

.page-title-block h1,
.page-title-block h2,
.page-title-block h3,
.page-title-block h4,
.page-title-block h5,
.page-title-block h6 {
    overflow-wrap: anywhere;
}

.glass,
.card,
.modal-content {
    overflow: hidden;
}

.card,
.modal-content {
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

.card-header {
    background: color-mix(in srgb, var(--bs-body-bg) 92%, transparent);
    border-bottom: 1px solid var(--glass-border);
    font-weight: 600;
}

.form-control,
.form-select,
.btn,
.input-group-text {
    min-height: var(--control-min-h);
}

.form-control,
.form-select {
    border-radius: 12px;
}

.btn {
    border-radius: 12px;
}

.btn-sm,
.form-control-sm,
.form-select-sm,
.input-group-sm > .form-control,
.input-group-sm > .form-select,
.input-group-sm > .btn {
    min-height: 36px;
}

textarea.form-control {
    min-height: 96px;
}

.table-responsive {
    border-radius: 14px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.table {
    vertical-align: middle;
}

.table > :not(caption) > * > * {
    padding: .7rem .75rem;
}

.table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: color-mix(in srgb, var(--bs-body-bg) 96%, transparent);
    backdrop-filter: blur(8px);
}

.sticky-actions {
    top: calc(.4rem + env(safe-area-inset-top, 0px));
    z-index: 1020;
    padding-inline: .25rem;
    border-bottom: 0 !important;
}

.sticky-actions .container-fluid,
.sticky-actions .page-header-inner {
    padding-inline: 0;
}

.topbar {
    margin: .65rem var(--page-pad-x) 0;
    padding-inline: .35rem;
    border-radius: 18px;
}

.topbar .container-fluid {
    gap: .5rem;
}

.topbar .navbar-brand {
    min-width: 0;
    margin-right: auto;
}

.topbar .navbar-brand span {
    white-space: nowrap;
}

.topbar-btn {
    min-width: 38px;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.topbar .dropdown-menu {
    max-width: min(92vw, 360px);
}

#sidebarOffcanvas {
    width: min(86vw, 340px);
    max-width: 340px;
}

#sidebarOffcanvas .accordion-item {
    border-radius: 14px;
}

#sidebarOffcanvas .accordion-button,
#sidebarOffcanvas .nav-link {
    min-height: 44px;
}

#sidebarOffcanvas .nav-link {
    border-radius: 12px;
    color: var(--bs-body-color);
}

#sidebarOffcanvas .nav-link.active,
#sidebarOffcanvas .nav-link:hover,
#sidebarOffcanvas .nav-link:focus {
    background: color-mix(in srgb, var(--bs-primary) 12%, transparent);
    color: var(--bs-body-color);
}

#sidebarOffcanvas .accordion-button:not(.collapsed) {
    background: color-mix(in srgb, var(--bs-primary) 12%, transparent);
    color: var(--bs-body-color);
}

.sidebar-context {
    padding: .95rem;
    border-radius: 14px;
}

.sidebar-context-label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
}

.sidebar-context-value {
    font-weight: 600;
    line-height: 1.25;
    word-break: break-word;
}

#btnLogoutSidebar.nav-link {
    width: 100%;
}

.modal-dialog {
    margin: max(1rem, env(safe-area-inset-top, 0px)) auto;
}

.modal-content {
    background: var(--glass-bg-strong);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.modal-body {
    max-height: min(70vh, 680px);
    overflow: auto;
}

.badge-soft {
    white-space: normal;
    text-align: center;
}

.readonly,
.form-control[readonly] {
    opacity: .92;
}

@media (max-width: 991.98px) {
    .topbar .navbar-brand span,
    #topbar-username {
        max-width: 20vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .sticky-actions {
        position: static;
        padding-inline: 0;
        background: transparent;
        backdrop-filter: none;
    }

    .sticky-actions > .container-fluid,
    .sticky-actions > .page-header-inner {
        background: var(--glass-bg);
        border: 1px solid var(--glass-border);
        border-radius: 16px;
        box-shadow: var(--glass-shadow);
        padding: 1rem;
    }

    .page-shell .glass[style*="position: sticky"],
    .page-shell [style*="position: sticky"] {
        position: static !important;
        top: auto !important;
    }
}

@media (max-width: 767.98px) {
    :root {
        --page-pad-x: .85rem;
        --page-pad-y: .85rem;
    }

    .topbar {
        margin-top: .45rem;
        padding-inline: .15rem;
    }

    .topbar .container-fluid {
        flex-wrap: wrap;
        row-gap: .55rem;
    }

    .topbar .navbar-brand {
        order: 1;
        flex: 1 1 auto;
    }

    .topbar .ms-auto {
        order: 2;
        width: 100%;
        justify-content: flex-end;
        gap: .45rem !important;
    }

    .topbar-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .topbar .dropdown-menu {
        max-width: min(94vw, 320px);
    }

    .page-shell > .row,
    .page-shell .row {
        --bs-gutter-x: 1rem;
        --bs-gutter-y: 1rem;
    }

    .page-toolbar,
    .page-actions,
    .d-flex.gap-2,
    .d-flex.gap-3 {
        row-gap: .55rem;
    }

    .page-toolbar > .btn,
    .page-actions > .btn,
    .page-toolbar > a.btn,
    .page-actions > a.btn,
    .page-shell .header-actions > .btn,
    .page-shell .header-actions > a.btn {
        flex: 1 1 100%;
    }

    .page-shell .d-flex.align-items-center.justify-content-between,
    .page-shell .d-flex.flex-wrap.align-items-center.justify-content-between,
    .page-shell .d-flex.flex-wrap.align-items-start.justify-content-between {
        align-items: stretch !important;
    }

    .page-shell h3,
    .page-shell h4,
    .page-shell h5 {
        line-height: 1.15;
    }

    .page-shell .badge-soft,
    .page-shell .badge {
        max-width: 100%;
    }

    .table {
        font-size: .92rem;
    }

    .table > :not(caption) > * > * {
        padding: .6rem .55rem;
    }

    .glass,
    .card,
    .modal-content {
        border-radius: 14px;
    }

    .page-shell .container,
    .page-shell .container-fluid,
    .page-shell .page-section {
        padding-left: 0;
        padding-right: 0;
    }
}

@media (min-width: 768px) and (max-width: 1199.98px) {
    .app-shell,
    .page-shell {
        max-width: 1040px;
    }

    #sidebarOffcanvas {
        width: min(52vw, 340px);
    }
}


/* =========================
   Ajustes de esta entrega
   ========================= */

.modal-backdrop.show {
    opacity: .72;
}

.cursor-pointer {
    cursor: pointer;
}

.login-shell {
    padding: clamp(1rem, 2vw, 1.5rem);
}

.login-hero {
    justify-content: center;
}

.login-hero-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    background: color-mix(in srgb, var(--bs-body-bg) 76%, transparent);
    box-shadow: var(--glass-shadow);
    width: 92px;
    height: 92px;
    transition: all .2s ease;
}

.login-hero-logo img {
    width: 70%;
    height: 70%;
    object-fit: contain;
}

.login-hero-logo--large {
    width: min(100%, 260px);
    height: 260px;
    margin-inline: auto;
}

.login-hero-logo--compact {
    width: 84px;
    height: 84px;
}

#dvWrap .form-control {
    max-width: 100%;
}

@media (max-width: 767.98px) {
    .login-hero-logo--large {
        width: min(100%, 180px);
        height: 180px;
    }

    .product-media .media-main-wrap {
        min-height: 220px;
    }
}

/* =====================================================
   TERCEROS - layout lateral de ficha + buscador
   Objetivo:
   - En escritorio: ficha a la izquierda y buscador a la derecha.
   - En móvil/tablet: ficha arriba y buscador debajo.
   ===================================================== */

.terceros-layout {
    align-items: flex-start;
}

.terceros-main-col,
.terceros-search-col {
    display: flex;
    flex-direction: column;
}

.terceros-search-panel {
    position: sticky;
    top: calc(6.4rem + env(safe-area-inset-top, 0px));
}

.terceros-search-results {
    max-height: min(62vh, 720px);
}

.terceros-doc-type-col {
    max-width: 320px;
}

.terceros-doc-number-col {
    min-width: 0;
}

.terceros-doc-dv-col {
    max-width: 90px;
}

@media (max-width: 991.98px) {
    .terceros-search-panel {
        position: static;
        top: auto;
    }

    .terceros-search-results {
        max-height: none;
    }
}

.product-page-v3 #modalDuplicarVariante .modal-body .form-check {
    padding-top: .2rem;
}
.product-page-v3 #dupVarianteOrigen {
    max-width: 100%;
    word-break: break-word;
}

/* =========================
   Empresa activa en topbar
   ========================= */
.topbar-company {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    max-width: min(34vw, 380px);
    padding: .4rem .75rem;
    border-radius: 14px;
    border: 1px solid color-mix(in srgb, var(--bs-body-color) 14%, transparent);
    background: color-mix(in srgb, var(--bs-body-bg) 72%, transparent);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}

.topbar-company-label {
    font-size: .68rem;
    line-height: 1;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .08em;
}

#topbar-company-name {
    display: block;
    font-size: .92rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-company.is-empty {
    opacity: .78;
}

@media (max-width: 991.98px) {
    .topbar-company {
        max-width: min(42vw, 300px);
    }
}

@media (max-width: 767.98px) {
    .topbar-company {
        order: 3;
        width: 100%;
        max-width: none;
    }

    .topbar-company-label {
        font-size: .64rem;
    }
}

/* =========================
   CATÁLOGOS · Toolbar ordenado
   ========================= */
.catalog-toolbar {
    padding-top: .15rem;
}

.catalog-toolbar-grid {
    display: grid;
    grid-template-columns: minmax(220px, 270px) minmax(190px, 220px) minmax(260px, 1fr) minmax(240px, 320px);
    gap: 1rem;
    align-items: end;
}

.catalog-toolbar-item {
    min-width: 0;
}

.catalog-toolbar-item .form-label {
    margin-bottom: .45rem;
    font-weight: 500;
}

.catalog-actions-wrap {
    min-height: var(--control-min-h);
    align-items: center;
}

.catalog-actions-wrap .btn {
    min-width: 90px;
}

@media (max-width: 1199.98px) {
    .catalog-toolbar-grid {
        grid-template-columns: repeat(2, minmax(240px, 1fr));
    }
}

@media (max-width: 767.98px) {
    .catalog-toolbar-grid {
        grid-template-columns: 1fr;
        gap: .85rem;
    }

    .catalog-actions-wrap .btn {
        flex: 1 1 calc(50% - .5rem);
    }
}

/* =====================================================
   XTRAK · BRANDING 2026-04-11
   - isotipo en espacios compactos
   - logo horizontal donde hay contexto suficiente
   ===================================================== */
.brand-logo-iso {
    width: 36px;
    height: 36px;
    object-fit: contain;
    display: block;
    background: transparent;
}

.brand-logo-horizontal {
    max-height: 42px;
    width: auto;
    object-fit: contain;
    display: block;
}

.topbar-wrap {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.topbar-left {
    min-width: 0;
}

.navbar-brand {
    min-width: 0;
}

.login-brand-panel {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: min(100%, 360px);
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.login-brand-horizontal {
    width: 100%;
    max-height: 180px;
    height: auto;
    object-fit: contain;
    display: block;
}

/* =====================================================
   PRODUCTOS V3 · Rediseño funcional
   ===================================================== */
.product-main-shell {
    padding-bottom: 6rem;
}

.product-page-hero {
    padding: 1.25rem 1.35rem;
}

.product-page-hero__content {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.product-page-hero__actions {
    display: flex;
    gap: .65rem;
    flex-wrap: wrap;
    align-items: center;
}

.product-card {
    padding: 1.1rem 1.15rem;
}

.product-card__header {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
}

.product-search-zone {
    border-top: 1px solid color-mix(in srgb, var(--bs-body-color) 12%, transparent);
    padding-top: .9rem;
}

.smart-search-results {
    max-height: 260px;
    overflow: auto;
    border-radius: 14px;
    border: 1px solid color-mix(in srgb, var(--bs-body-color) 10%, transparent);
    background: color-mix(in srgb, var(--bs-body-bg) 88%, transparent);
}

.smart-search-item {
    background: transparent;
    border-left: 0;
    border-right: 0;
}

.smart-search-item:first-child {
    border-top: 0;
}

.variant-context-chip {
    display: inline-flex;
    align-items: center;
    padding: .55rem .85rem;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--bs-primary) 18%, transparent);
    background: color-mix(in srgb, var(--bs-primary) 10%, transparent);
    color: var(--bs-primary);
    font-size: .9rem;
    line-height: 1.2;
}

.variant-table-wrap {
    border: 1px solid color-mix(in srgb, var(--bs-body-color) 10%, transparent);
    border-radius: 18px;
    overflow: hidden;
}

.variant-table {
    margin-bottom: 0;
}

.variant-table tbody tr.table-active > * {
    background: color-mix(in srgb, var(--bs-primary) 14%, transparent);
}

.variant-cards {
    display: grid;
    gap: .85rem;
}

.variant-card {
    padding: .95rem;
    border-radius: 18px;
    border: 1px solid color-mix(in srgb, var(--bs-body-color) 12%, transparent);
    background: color-mix(in srgb, var(--bs-body-bg) 86%, transparent);
}

.variant-card.is-active {
    border-color: color-mix(in srgb, var(--bs-primary) 34%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bs-primary) 22%, transparent);
}

.variant-card__header,
.variant-card__actions,
.config-toolbar,
.product-context-card__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}

.variant-card__code {
    font-weight: 700;
    letter-spacing: .02em;
}

.variant-card__body {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .85rem;
    margin-top: .85rem;
}

.variant-card__body span,
.product-context-grid .small {
    display: block;
    margin-bottom: .2rem;
}

.product-side-sticky {
    display: grid;
    gap: 1rem;
    align-content: start;
    grid-auto-flow: row;
}

.product-main-grid {
    align-items: start;
}

.product-context-card {
    background: color-mix(in srgb, var(--bs-body-bg) 90%, transparent);
}

.product-context-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.product-context-grid__full {
    grid-column: 1 / -1;
}

.config-card__header {
    align-items: flex-start;
}

.product-main-grid > [class*="col-"] {
    display: flex;
    flex-direction: column;
}

.product-main-grid > [class*="col-"] > .product-card:last-child,
.product-main-grid > [class*="col-"] > .product-side-sticky:last-child {
    margin-bottom: 0;
}

.config-current-variant {
    flex: 1 1 220px;
    padding: .75rem .9rem;
    border-radius: 16px;
    background: color-mix(in srgb, var(--bs-body-bg) 88%, transparent);
    border: 1px solid color-mix(in srgb, var(--bs-body-color) 10%, transparent);
    font-weight: 600;
}

.config-toolbar__actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.config-tabs {
    gap: .5rem;
}

.config-tabs .nav-link {
    border-radius: 999px;
}

.bom-placeholder__box {
    padding: 1rem;
    border-radius: 16px;
    border: 1px dashed color-mix(in srgb, var(--bs-body-color) 18%, transparent);
    background: color-mix(in srgb, var(--bs-body-bg) 90%, transparent);
}

.kpi-stack {
    display: grid;
    gap: .85rem;
}

.kpi-compact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.product-media--compact .media-main-wrap--compact {
    width: 100%;
    min-height: auto;
}

.product-media--compact .media-main-img {
    aspect-ratio: 16 / 9;
    width: 100%;
    max-height: 160px;
    object-fit: cover;
}

.product-media--compact .media-thumb {
    width: 58px;
    height: 58px;
}

.product-media--compact #mediaThumbs {
    gap: .6rem;
}

@media (max-width: 1199.98px) {
    .product-side-sticky {
        position: static;
        top: auto;
    }
}

@media (max-width: 767.98px) {
    .topbar-wrap {
        gap: .75rem;
    }

    .brand-logo-horizontal {
        max-height: 34px;
    }

    .login-brand-panel {
        width: 100%;
    }

    .product-page-hero {
        padding: 1rem;
    }

    .product-page-hero__actions {
        width: 100%;
    }

    .product-page-hero__actions > .btn,
    .product-page-hero__actions > .dropdown {
        flex: 1 1 100%;
    }

    .product-page-hero__actions .dropdown > .btn {
        width: 100%;
    }

    .product-card {
        padding: 1rem;
    }

    .variant-card__body,
    .product-context-grid {
        grid-template-columns: 1fr;
    }

    .config-toolbar__actions {
        width: 100%;
        justify-content: stretch;
    }

    .config-toolbar__actions > .btn {
        flex: 1 1 100%;
    }

    .kpi-compact {
        flex-direction: column;
        align-items: flex-start;
    }
}

.product-media--small .media-main-wrap--small {
    min-height: 140px;
}

.product-media--small .media-main-img {
    aspect-ratio: 16 / 9;
    max-height: 145px;
    object-fit: cover;
}

.product-media--small .media-empty {
    min-height: 140px;
}

@media (max-width: 1199.98px) {
    .product-media--small .media-main-wrap--small,
    .product-media--small .media-empty {
        min-height: 130px;
    }
}

@media (max-width: 767.98px) {
    .product-media--small .media-main-wrap--small,
    .product-media--small .media-empty {
        min-height: 120px;
    }

    .product-media--small .media-main-img {
        max-height: 130px;
    }
}

.product-media--small .media-empty .display-6 { font-size: 2.2rem; }

/* =====================================================
   PRODUCTOS V3 - layout 50 / 30 / 20 + 50 / 50
   ===================================================== */
.product-page-v3 .product-page-hero .muted { display: none; }
.product-page-v3 .product-page-hero { padding: 1.15rem 1.25rem; }
.product-page-v3 .product-page-hero__actions .btn,
.product-page-v3 .product-page-hero__actions .dropdown > .btn {
    min-width: 0;
}
.product-page-v3 .btn-icon-only {
    width: 2.45rem;
    height: 2.45rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.product-page-v3 .product-card__header--tight {
    align-items: center;
}
.product-page-v3 .product-switch-inline .form-check-input {
    margin-top: 0;
}
.product-workspace {
    display: grid;
    gap: 1rem;
}
.product-top-grid {
    display: grid;
    grid-template-columns: 5fr 3fr 2fr;
    gap: 1rem;
    align-items: stretch;
}
.product-bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: start;
}
.product-top-grid > .product-card,
.product-bottom-grid > .product-card {
    margin-bottom: 0;
    height: 100%;
}
.product-page-v3 .card-head .product-search-zone {
    min-height: 0;
}
.product-page-v3 .smart-search-results {
    max-height: 220px;
}
.product-page-v3 .card-image .media-main-wrap {
    width: 100%;
}
.product-page-v3 .card-image .media-main-img {
    aspect-ratio: 4 / 5;
    max-height: 320px;
    object-fit: contain;
    width: 100%;
}
.product-page-v3 .card-image .media-empty {
    min-height: 220px;
}
.product-page-v3 .card-image #mediaThumbs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(46px, 1fr));
    gap: .5rem;
}
.product-page-v3 .card-image .media-thumb {
    width: 100%;
    height: 52px;
}
.product-page-v3 .card-variants {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.product-page-v3 .variant-listbox {
    display: grid;
    gap: .7rem;
    flex: 1 1 auto;
    min-height: 0;
    max-height: clamp(300px, 44vh, 560px);
    overflow-y: auto;
    padding-right: .2rem;
}
.product-page-v3 .variant-list-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: .75rem;
    align-items: center;
    padding: .8rem .9rem;
    border-radius: 16px;
    border: 1px solid color-mix(in srgb, var(--bs-body-color) 10%, transparent);
    background: color-mix(in srgb, var(--bs-body-bg) 88%, transparent);
    cursor: pointer;
    transition: border-color .18s ease, transform .18s ease, background .18s ease;
}
.product-page-v3 .variant-list-item:hover {
    border-color: color-mix(in srgb, var(--bs-primary) 24%, transparent);
}
.product-page-v3 .variant-list-item.is-active {
    border-color: color-mix(in srgb, var(--bs-primary) 34%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bs-primary) 20%, transparent);
    background: color-mix(in srgb, var(--bs-primary) 10%, transparent);
}
.product-page-v3 .variant-list-item.is-inactive {
    color: color-mix(in srgb, var(--bs-body-color) 48%, transparent);
}
.product-page-v3 .variant-list-item.is-inactive .variant-list-item__meta,
.product-page-v3 .variant-list-item.is-inactive .variant-list-item__line2 {
    color: color-mix(in srgb, var(--bs-body-color) 44%, transparent);
}
.product-page-v3 .variant-list-item__main {
    min-width: 0;
}
.product-page-v3 .variant-list-item__line1 {
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: .2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.product-page-v3 .variant-list-item__line2,
.product-page-v3 .variant-list-item__meta {
    font-size: .88rem;
    color: color-mix(in srgb, var(--bs-body-color) 66%, transparent);
}
.product-page-v3 .variant-list-item__actions {
    display: flex;
    align-items: center;
    gap: .4rem;
}
.product-page-v3 .variant-context-chip {
    padding: .45rem .7rem;
    font-size: .83rem;
}
.product-page-v3 .config-toolbar {
    align-items: flex-start;
}
.product-page-v3 .config-current-variant {
    min-height: 48px;
}
.product-page-v3 .config-tabs .nav-link {
    padding: .55rem .95rem;
}
.product-page-v3 .price-card .tab-pane .row > [class*="col-"] {
    display: flex;
    flex-direction: column;
}
.product-page-v3 .ficha-card .bom-placeholder__box,
.product-page-v3 .price-card .bom-placeholder__box {
    min-height: 160px;
}
@media (max-width: 1399.98px) {
    .product-top-grid {
        grid-template-columns: 1.65fr 1fr .85fr;
    }
}
@media (max-width: 1199.98px) {
    .product-top-grid {
        grid-template-columns: 1fr;
    }
    .product-top-grid .card-head {
        order: 1;
    }
    .product-top-grid .card-variants {
        order: 2;
    }
    .product-top-grid .card-image {
        order: 3;
    }
    .product-bottom-grid {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 767.98px) {
    .product-page-v3 .product-page-hero__actions {
        width: auto;
        flex-wrap: nowrap;
    }
    .product-page-v3 .product-page-hero__actions > .btn,
    .product-page-v3 .product-page-hero__actions > .dropdown {
        flex: 0 0 auto;
    }
    .product-top-grid {
        grid-template-columns: 3fr 2fr;
    }
    .product-top-grid .card-head {
        grid-column: 1 / -1;
    }
    .product-top-grid .card-variants {
        grid-column: 1 / 2;
        order: 2;
    }
    .product-top-grid .card-image {
        grid-column: 2 / 3;
        order: 3;
    }
    .product-page-v3 .card-image .media-main-img {
        aspect-ratio: 1 / 1.2;
        max-height: 220px;
    }
    .product-page-v3 .card-image .media-empty {
        min-height: 160px;
    }
    .product-page-v3 .config-toolbar__actions {
        width: 100%;
    }
    .product-page-v3 .config-toolbar__actions > .btn {
        flex: 1 1 calc(50% - .5rem);
    }
}
@media (max-width: 479.98px) {
    .product-page-v3 .product-page-hero__actions {
        gap: .45rem;
    }
}


/* ==== PRODUCTOS V3 · compactación adicional 2026-04-16 ==== */
.product-page-v3 .product-head-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .8rem .9rem;
}
.product-page-v3 .field-span-4 {
    grid-column: 1 / -1;
}
.product-page-v3 .product-head-grid .form-label {
    margin-bottom: .35rem;
}
.product-page-v3 .product-head-grid .form-control,
.product-page-v3 .product-head-grid .form-select {
    min-width: 0;
}
.product-page-v3 .field-state #hdrEstado {
    min-width: 0;
    width: 100%;
    max-width: 10rem;
}
.product-page-v3 .variant-listbox {
    gap: .55rem;
    max-height: clamp(240px, 36vh, 420px);
}
.product-page-v3 .variant-list-item {
    grid-template-columns: 1fr auto;
    gap: .6rem;
    padding: .72rem .8rem;
}
.product-page-v3 .variant-list-item__line1,
.product-page-v3 .variant-list-item__line2 {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .8rem;
}
.product-page-v3 .variant-list-item__title,
.product-page-v3 .variant-list-item__code {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.product-page-v3 .variant-list-item__line1 {
    margin-bottom: .18rem;
}
.product-page-v3 .variant-list-item__line2 {
    font-size: .86rem;
    color: color-mix(in srgb, var(--bs-body-color) 66%, transparent);
}
.product-page-v3 .variant-list-item__qty,
.product-page-v3 .variant-list-item__unit {
    flex: 0 0 auto;
    font-size: .82rem;
    color: color-mix(in srgb, var(--bs-body-color) 64%, transparent);
}
.product-page-v3 .variant-list-item__actions {
    align-self: center;
}
.product-page-v3 .variant-list-item.is-inactive .variant-list-item__qty,
.product-page-v3 .variant-list-item.is-inactive .variant-list-item__unit {
    color: color-mix(in srgb, var(--bs-body-color) 44%, transparent);
}
.product-page-v3 .config-header-compact {
    gap: .75rem;
    align-items: flex-start;
}
.product-page-v3 .config-toolbar__actions--header {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    justify-content: flex-end;
}
.product-page-v3 .config-variant-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .8rem;
    align-items: center;
}
.product-page-v3 .config-current-variant {
    min-height: 0;
    padding: .72rem .9rem;
    font-weight: 600;
    border-radius: 14px;
}
.product-page-v3 .config-tabs {
    margin: 0;
    gap: .45rem;
    justify-content: flex-end;
}
.product-page-v3 .config-tabs .nav-link {
    padding: .48rem .82rem;
    font-size: .95rem;
}
.product-page-v3 .tab-content.pt-3 {
    padding-top: .85rem !important;
}
.product-page-v3 .price-card .tab-pane .row {
    row-gap: .8rem !important;
}
.product-page-v3 .price-card .form-label {
    margin-bottom: .28rem;
}
.product-page-v3 .price-card .form-control,
.product-page-v3 .price-card .form-select {
    padding-top: .5rem;
    padding-bottom: .5rem;
}
.product-page-v3 .card-image .media-main-img {
    max-height: 250px;
}
.product-page-v3 .card-image .media-empty {
    min-height: 180px;
}
@media (max-width: 991.98px) {
    .product-page-v3 .product-head-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: .7rem;
    }
    .product-page-v3 .product-head-grid .form-label {
        font-size: .83rem;
    }
    .product-page-v3 .product-head-grid .form-control,
    .product-page-v3 .product-head-grid .form-select {
        font-size: .92rem;
        padding: .48rem .7rem;
    }
    .product-page-v3 .field-state #hdrEstado {
        max-width: 100%;
    }
    .product-page-v3 .config-header-compact {
        flex-direction: column;
        align-items: stretch;
    }
    .product-page-v3 .config-toolbar__actions--header {
        justify-content: flex-start;
    }
    .product-page-v3 .config-variant-row {
        grid-template-columns: 1fr;
    }
    .product-page-v3 .config-tabs {
        justify-content: flex-start;
    }
}
@media (max-width: 767.98px) {
    .product-page-v3 .product-head-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: .6rem;
    }
    .product-page-v3 .product-head-grid .form-label {
        font-size: .78rem;
    }
    .product-page-v3 .product-head-grid .form-control,
    .product-page-v3 .product-head-grid .form-select {
        font-size: .84rem;
        padding: .42rem .58rem;
    }
    .product-page-v3 .product-top-grid {
        grid-template-columns: 3fr 2fr;
        align-items: start;
    }
    .product-page-v3 .product-top-grid .card-head {
        grid-column: 1 / -1;
    }
    .product-page-v3 .product-top-grid .card-variants {
        grid-column: 1 / 2;
    }
    .product-page-v3 .product-top-grid .card-image {
        grid-column: 2 / 3;
    }
    .product-page-v3 .card-image .media-main-img {
        aspect-ratio: 1 / 1.18;
        max-height: 180px;
    }
    .product-page-v3 .card-image .media-empty {
        min-height: 140px;
    }
    .product-page-v3 .price-card .tab-pane .row > [class*="col-"] {
        flex: 0 0 33.3333%;
        max-width: 33.3333%;
    }
    .product-page-v3 .price-card .tab-pane .row {
        display: flex;
        flex-wrap: wrap;
    }
}
@media (max-width: 419.98px) {
    .product-page-v3 .product-head-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .product-page-v3 .field-span-4 {
        grid-column: 1 / -1;
    }
    .product-page-v3 .product-page-hero__actions .btn,
    .product-page-v3 .product-page-hero__actions .dropdown > .btn {
        width: 2.5rem;
        height: 2.5rem;
        padding: 0;
    }
    .product-page-v3 .config-toolbar__actions--header > .btn {
        flex: 1 1 calc(50% - .25rem);
    }
    .product-page-v3 .config-tabs .nav-link {
        font-size: .88rem;
        padding-inline: .7rem;
    }
}


/* ==== PRODUCTOS V3 · ronda compactación 03 ==== */
.product-page-v3 .product-page-hero {
    position: relative;
    z-index: 30;
    overflow: visible;
}
.product-page-v3 .product-page-hero .dropdown-menu {
    z-index: 2400;
    background: var(--glass-bg-strong);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.product-page-v3 .product-workspace {
    position: relative;
    z-index: 1;
}
.product-page-v3 .field-state {
    max-width: 9rem;
}
.product-page-v3 .field-state #hdrEstado {
    max-width: 8.4rem;
}
.product-page-v3 .card-variants .product-card__header,
.product-page-v3 .card-image .product-card__header,
.product-page-v3 .price-card .product-card__header,
.product-page-v3 .ficha-card .product-card__header {
    margin-bottom: .2rem;
}
.product-page-v3 .variant-list-item {
    padding: .62rem .72rem;
}
.product-page-v3 .variant-list-item__line1,
.product-page-v3 .variant-list-item__line2 {
    margin-bottom: .08rem;
}
.product-page-v3 .variant-list-item__title {
    padding-right: .4rem;
}
.product-page-v3 .variant-list-item__qty,
.product-page-v3 .variant-list-item__unit,
.product-page-v3 .variant-list-item__code {
    font-size: .81rem;
}
.product-page-v3 .variant-list-item__actions .btn {
    width: 2.35rem;
    height: 2.35rem;
}
.product-page-v3 .config-header-compact {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .65rem;
    align-items: center;
}
.product-page-v3 .config-toolbar__actions--header {
    flex-wrap: nowrap;
    gap: .4rem;
}
.product-page-v3 .config-toolbar__actions--header > .btn {
    white-space: nowrap;
}
.product-page-v3 .config-variant-row {
    gap: .65rem;
    align-items: center;
}
.product-page-v3 .config-current-variant {
    min-height: 0;
    padding: .62rem .82rem;
    font-size: .95rem;
    line-height: 1.2;
}
.product-page-v3 #precioMsg {
    min-height: 0;
    margin-top: 0 !important;
}
.product-page-v3 .tab-content.pt-3 {
    padding-top: .55rem !important;
}
.product-page-v3 .price-card .form-label {
    margin-bottom: .18rem;
    font-size: .94rem;
}
.product-page-v3 .price-card .form-control,
.product-page-v3 .price-card .form-select {
    padding-top: .42rem;
    padding-bottom: .42rem;
}
.product-page-v3 .price-card .tab-pane .row {
    row-gap: .62rem !important;
}
.product-page-v3 .price-card .nav-pills {
    row-gap: .35rem;
}
@media (max-width: 991.98px) {
    .product-page-v3 .config-header-compact {
        grid-template-columns: minmax(0, 1fr) auto;
    }
    .product-page-v3 .config-toolbar__actions--header > .btn {
        min-width: 2.4rem;
        width: 2.4rem;
        height: 2.4rem;
        padding: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .product-page-v3 .config-variant-row {
        grid-template-columns: 1fr;
        gap: .55rem;
    }
    .product-page-v3 .config-tabs {
        justify-content: flex-start;
    }
}
@media (max-width: 767.98px) {
    .product-page-v3 .variant-list-item {
        padding: .56rem .6rem;
    }
    .product-page-v3 .variant-list-item__title {
        font-size: .9rem;
    }
    .product-page-v3 .variant-list-item__qty,
    .product-page-v3 .variant-list-item__unit,
    .product-page-v3 .variant-list-item__code {
        font-size: .74rem;
    }
    .product-page-v3 .config-header-compact {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: .45rem;
    }
    .product-page-v3 .config-toolbar__actions--header {
        gap: .3rem;
    }
    .product-page-v3 .config-toolbar__actions--header > .btn {
        width: 2.28rem;
        height: 2.28rem;
    }
    .product-page-v3 .price-card .form-label {
        font-size: .86rem;
    }
    .product-page-v3 .price-card .form-control,
    .product-page-v3 .price-card .form-select,
    .product-page-v3 .config-current-variant {
        font-size: .88rem;
    }
}


/* =====================================================
   PRODUCTOS V3 - cierre visual de productos
   ===================================================== */
.product-page-v3 .smart-search-results {
    position: relative;
    z-index: 35;
    max-height: 12.5rem;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
}
.product-page-v3 .smart-search-item {
    display: grid;
    gap: .3rem;
    padding-block: .65rem;
}
.product-page-v3 .smart-search-item__title {
    font-size: .82rem;
    font-weight: 600;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.product-page-v3 .smart-search-item__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    font-size: .72rem;
    color: var(--muted);
}
.product-page-v3 .product-page-hero,
.product-page-v3 .product-page-hero .dropdown,
.product-page-v3 .product-page-hero .dropdown-menu {
    position: relative;
    z-index: 60;
}
.product-page-v3 .config-header-compact {
    gap: .7rem;
    flex-wrap: nowrap;
}
.product-page-v3 .config-header-compact > h4 {
    font-size: 1.05rem;
    white-space: nowrap;
    flex: 0 0 auto;
}
.product-page-v3 .config-toolbar__actions--header {
    flex: 1 1 auto;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: .45rem;
}
.product-page-v3 .config-toolbar__actions--header > .btn {
    display: inline-flex;
    align-items: center;
    gap: .38rem;
    min-width: 0;
    font-size: .82rem;
    padding: .38rem .62rem;
    white-space: nowrap;
}
.product-page-v3 .config-toolbar__actions--header > .btn i {
    font-size: .86rem;
    line-height: 1;
}
.product-page-v3 .config-toolbar__actions--header > .btn .btn-label {
    display: inline;
}
.product-page-v3 .config-variant-row {
    gap: .6rem;
}
.product-page-v3 .config-current-variant {
    padding: .6rem .8rem;
    font-size: .95rem;
    line-height: 1.2;
}
.product-page-v3 .tab-content.pt-3 {
    padding-top: .75rem !important;
}
.product-page-v3 .price-card .tab-pane .row {
    --bs-gutter-x: .75rem;
    --bs-gutter-y: .65rem;
}
.product-page-v3 .price-card .form-label {
    margin-bottom: .3rem;
    font-size: .88rem;
}
.product-page-v3 .price-card .form-control,
.product-page-v3 .price-card .form-select {
    min-height: 2.5rem;
    padding-top: .42rem;
    padding-bottom: .42rem;
}
.product-page-v3 #precioMsg {
    display: none !important;
}
@media (max-width: 1399.98px) {
    .product-page-v3 .config-header-compact > h4 {
        font-size: .96rem;
    }
    .product-page-v3 .config-toolbar__actions--header > .btn {
        font-size: .74rem;
        padding-inline: .54rem;
    }
}
@media (max-width: 991.98px) {
    .product-page-v3 .config-header-compact {
        align-items: center;
    }
    .product-page-v3 .config-toolbar__actions--header > .btn .btn-label {
        display: none;
    }
    .product-page-v3 .config-toolbar__actions--header > .btn {
        width: 2.35rem;
        height: 2.35rem;
        padding: 0;
        justify-content: center;
        border-radius: .8rem;
    }
}
@media (max-width: 767.98px) {
    .product-page-v3 .variant-list-item__title {
        font-size: .92rem;
    }
    .product-page-v3 .variant-list-item__qty,
    .product-page-v3 .variant-list-item__unit,
    .product-page-v3 .variant-list-item__code {
        font-size: .74rem;
    }
    .product-page-v3 .smart-search-item__title {
        font-size: .76rem;
    }
}


/* ==== FASE 4B · Matriz de variantes + scroll controlado ==== */
.product-page-v3 .card-variants {
    overflow: hidden;
}
.product-page-v3 .variant-listbox {
    scrollbar-width: thin;
}
.product-page-v3 .variant-listbox::-webkit-scrollbar {
    width: 8px;
}
.product-page-v3 .variant-listbox::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--bs-body-color) 22%, transparent);
    border-radius: 999px;
}
.product-page-v3 .matrix-summary {
    display: grid;
    gap: .35rem;
    padding: .8rem .95rem;
    border-radius: 18px;
    background: color-mix(in srgb, var(--bs-primary) 6%, transparent);
    border: 1px solid color-mix(in srgb, var(--bs-primary) 14%, transparent);
}

/* ==== FASE 4C · Matriz avanzada + scroll de variantes ==== */
.product-top-grid {
    align-items: stretch;
}
.product-page-v3 .card-variants {
    max-height: clamp(360px, 64vh, 780px);
    overflow: hidden;
}
.product-page-v3 .card-variants .product-card__header {
    flex: 0 0 auto;
}
.product-page-v3 .variant-listbox {
    flex: 1 1 auto;
    min-height: 180px;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
}
.product-page-v3 .matrix-picker-box {
    display: grid;
    gap: .75rem;
    min-height: 100%;
    padding: .8rem;
    border: 1px solid color-mix(in srgb, var(--bs-body-color) 10%, transparent);
    border-radius: 18px;
    background: color-mix(in srgb, var(--bs-body-bg) 88%, transparent);
}
.product-page-v3 .matrix-picker-box__top {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: .6rem;
    align-items: start;
}
.product-page-v3 .matrix-selected-list {
    display: grid;
    gap: .5rem;
    align-content: start;
    min-height: 108px;
    max-height: 240px;
    overflow-y: auto;
    padding-right: .1rem;
}
.product-page-v3 .matrix-selected-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: .5rem;
    align-items: center;
    padding: .55rem .7rem;
    border-radius: 14px;
    border: 1px solid color-mix(in srgb, var(--bs-body-color) 10%, transparent);
    background: color-mix(in srgb, var(--bs-body-bg) 80%, transparent);
}
.product-page-v3 .matrix-selected-item__label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.product-page-v3 .matrix-selected-empty {
    padding: .8rem;
    border-radius: 14px;
    border: 1px dashed color-mix(in srgb, var(--bs-body-color) 16%, transparent);
    color: var(--bs-secondary-color);
    text-align: center;
}
@media (max-width: 991.98px) {
    .product-page-v3 .card-variants {
        max-height: clamp(320px, 58vh, 700px);
    }
    .product-page-v3 .matrix-picker-box__top {
        grid-template-columns: 1fr;
    }
}


/* ==== FASE 4D · Código corto oficial de color + scroll robusto ==== */
.product-top-grid,
.product-bottom-grid {
    min-height: 0;
}
.product-page-v3 .card-variants,
.product-page-v3 .price-card,
.product-page-v3 .ficha-card {
    min-height: 0;
}
.product-page-v3 .card-variants {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.product-page-v3 .variant-listbox {
    flex: 1 1 auto;
    min-height: 0 !important;
    max-height: clamp(320px, 48vh, 640px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding-right: .2rem;
}
.product-page-v3 .variant-listbox::-webkit-scrollbar,
.product-page-v3 .config-tab-scroll::-webkit-scrollbar,
.product-page-v3 .ficha-card .bom-placeholder::-webkit-scrollbar {
    width: 8px;
}
.product-page-v3 .variant-listbox::-webkit-scrollbar-thumb,
.product-page-v3 .config-tab-scroll::-webkit-scrollbar-thumb,
.product-page-v3 .ficha-card .bom-placeholder::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--bs-body-color) 22%, transparent);
    border-radius: 999px;
}
.product-page-v3 .price-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.product-page-v3 .config-tab-scroll {
    flex: 1 1 auto;
    min-height: 0;
    max-height: clamp(220px, 34vh, 420px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: .1rem;
    overscroll-behavior: contain;
}
.product-page-v3 .ficha-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.product-page-v3 .ficha-card .bom-placeholder {
    flex: 1 1 auto;
    min-height: 0;
    max-height: clamp(220px, 34vh, 420px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: .1rem;
    overscroll-behavior: contain;
}
@media (max-width: 991.98px) {
    .product-page-v3 .variant-listbox {
        max-height: clamp(280px, 42vh, 540px) !important;
    }
    .product-page-v3 .config-tab-scroll,
    .product-page-v3 .ficha-card .bom-placeholder {
        max-height: 360px;
    }
}

/* ==== FASE 4E · Código corto oficial + scroll fino ==== */
.catalog-color-helper {
    padding: .55rem .7rem;
    border-radius: 12px;
    background: color-mix(in srgb, var(--bs-info) 7%, transparent);
    border: 1px dashed color-mix(in srgb, var(--bs-info) 18%, transparent);
}

.product-page-v3 .variant-listbox {
    scrollbar-gutter: stable both-edges;
}

.product-page-v3 .config-tab-scroll,
.product-page-v3 .ficha-card .bom-placeholder {
    scrollbar-gutter: stable both-edges;
}

.product-page-v3 .price-card,
.product-page-v3 .ficha-card {
    min-height: clamp(280px, 34vh, 520px);
}


/* ==== FASE 5A · Catálogos compactos en pantallas pequeñas ==== */
.catalog-workspace {
    display: grid;
    grid-template-columns: minmax(280px, 0.92fr) minmax(360px, 1.08fr);
    gap: 1rem;
    align-items: start;
}

.catalog-form-card,
.catalog-list-card {
    min-width: 0;
    overflow: hidden;
}

.catalog-form-card {
    position: sticky;
    top: calc(72px + 1rem);
}

.catalog-list-card__body {
    padding: 0;
}

.catalog-list-scroll {
    max-height: clamp(420px, calc(100vh - 225px), 760px);
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable both-edges;
}

.catalog-list-table {
    min-width: 520px;
    margin-bottom: 0;
}

.catalog-list-table thead.sticky-top th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--bs-body-bg);
}

.catalog-list-scroll::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.catalog-list-scroll::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--bs-primary) 38%, transparent);
    border-radius: 999px;
}

.catalog-inline-help {
    font-size: .88rem;
    line-height: 1.35;
}

.catalog-color-helper {
    padding: .45rem .6rem;
    font-size: .88rem;
    line-height: 1.3;
}

@media (max-width: 991.98px) {
    .catalog-workspace {
        grid-template-columns: minmax(240px, 0.95fr) minmax(280px, 1.05fr);
        gap: .8rem;
    }

    .catalog-form-card {
        top: calc(68px + .75rem);
    }

    .catalog-list-scroll {
        max-height: clamp(400px, calc(100vh - 205px), 680px);
    }

    .catalog-list-table {
        min-width: 440px;
    }
}

@media (max-width: 767.98px) {
    .catalog-workspace {
        grid-template-columns: minmax(210px, 0.96fr) minmax(250px, 1.04fr);
        gap: .65rem;
    }

    .catalog-form-card .card-header,
    .catalog-list-card .card-header {
        padding: .8rem .9rem;
        font-size: 1rem;
    }

    .catalog-form-card .card-body {
        padding: .9rem;
    }

    .catalog-form-card .btn,
    .catalog-list-card .btn {
        min-height: 42px;
    }

    .catalog-form-card {
        top: calc(64px + .6rem);
    }

    .catalog-list-scroll {
        max-height: clamp(380px, calc(100vh - 175px), 620px);
    }

    .catalog-list-table {
        min-width: 380px;
    }
}


/* ==== FASE 5B · Toolbar catálogos compacto + publicación http/https ==== */
.catalog-toolbar-rows {
    display: grid;
    gap: .9rem;
}

.catalog-toolbar-row {
    display: grid;
    gap: .85rem;
    align-items: end;
}

.catalog-toolbar-row-primary {
    grid-template-columns: minmax(220px, 1fr) auto auto;
}

.catalog-toolbar-row-secondary {
    grid-template-columns: minmax(220px, 1fr) minmax(180px, 240px) auto;
}

.catalog-toolbar-inline-actions {
    display: grid;
    grid-template-columns: repeat(2, auto);
    gap: .6rem;
    align-items: end;
}

.catalog-toolbar-inline-actions .btn {
    min-width: 96px;
}

.catalog-toolbar-inline-visibility {
    display: grid;
    align-items: end;
}

.form-label-compact {
    margin-bottom: .35rem;
}

.catalog-toolbar-inline-visibility .catalog-visibility-switch {
    min-height: var(--control-min-h);
    display: inline-flex;
    align-items: center;
    padding-top: .15rem;
}

.catalog-inline-help {
    font-size: .83rem;
    line-height: 1.25;
    margin-bottom: .65rem !important;
}

.catalog-color-helper {
    min-height: 0;
    padding: .35rem .5rem;
    font-size: .82rem;
    line-height: 1.2;
    background: color-mix(in srgb, var(--bs-info) 5%, transparent);
}

.catalog-color-helper:empty {
    display: none;
}

@media (max-width: 991.98px) {
    .catalog-toolbar-row-primary {
        grid-template-columns: minmax(170px, 1fr) auto auto;
    }

    .catalog-toolbar-row-secondary {
        grid-template-columns: minmax(170px, 1fr) minmax(150px, 210px) auto;
    }

    .catalog-toolbar-inline-actions .btn {
        min-width: 86px;
        padding-inline: .9rem;
    }
}

@media (max-width: 575.98px) {
    .catalog-toolbar-row {
        gap: .6rem;
    }

    .catalog-toolbar-row-primary {
        grid-template-columns: minmax(128px, 1fr) auto auto;
    }

    .catalog-toolbar-row-secondary {
        grid-template-columns: minmax(140px, 1fr) auto;
    }

    .catalog-toolbar-item-subcat {
        grid-column: 1 / -1;
        order: 3;
    }

    .catalog-toolbar-inline-actions .btn {
        min-width: 74px;
        min-height: 40px;
        padding-inline: .7rem;
        font-size: .92rem;
    }

    .catalog-toolbar-inline-visibility {
        justify-self: end;
    }

    .catalog-toolbar-inline-visibility .catalog-visibility-switch .form-check-label {
        font-size: .92rem;
    }
}


/* ==== FASE 5B.1 · Ajuste fino catálogo móvil ==== */
.page-head-card-compact {
    padding: .85rem 1rem;
}
.page-head-card-compact .page-title-block h3 {
    font-size: 1.15rem;
}
.page-head-card-compact .small-muted {
    font-size: .92rem;
}
.catalog-quick-actions .btn {
    min-height: 38px;
    padding-inline: .9rem;
}
.catalog-toolbar-row-primary {
    grid-template-columns: minmax(190px, 1fr) auto auto;
}
.catalog-toolbar-inline-actions-compact {
    align-self: end;
    display: flex;
    gap: .55rem;
    flex-wrap: nowrap;
}
.catalog-toolbar-inline-actions-compact .btn {
    min-width: 94px;
    min-height: 42px;
    white-space: nowrap;
}
.catalog-toolbar-row-secondary {
    grid-template-columns: minmax(220px, 1fr) auto minmax(160px, 220px);
}
.catalog-toolbar-inline-visibility {
    align-self: end;
}
.catalog-inline-help {
    font-size: .78rem;
    line-height: 1.15;
    color: var(--muted);
}
.catalog-color-helper {
    padding: .3rem .45rem;
    font-size: .78rem;
    line-height: 1.15;
}
@media (max-width: 767.98px) {
    .page-head-card-compact {
        padding: .75rem .85rem;
    }
    .catalog-quick-actions {
        width: 100%;
    }
    .catalog-quick-actions .btn {
        flex: 1 1 auto;
        min-width: 0;
    }
    .catalog-toolbar-row-primary {
        grid-template-columns: minmax(0, 1fr) auto auto;
        gap: .5rem;
    }
    .catalog-toolbar-row-secondary {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: .55rem;
    }
    .catalog-toolbar-item-subcat {
        grid-column: 1 / -1;
    }
    .catalog-toolbar-inline-actions-compact .btn {
        min-width: 0;
        padding-inline: .75rem;
        font-size: .9rem;
    }
    .catalog-toolbar-inline-actions-compact .btn .bi {
        margin-right: .25rem !important;
    }
    .catalog-form-card .card-body,
    .catalog-list-card .card-body {
        padding: .8rem;
    }
    .catalog-list-scroll {
        max-height: clamp(360px, calc(100vh - 210px), 600px);
    }
}
@media (max-width: 420px) {
    .catalog-toolbar-row-primary {
        grid-template-columns: minmax(0, 1fr) auto auto;
    }
    .catalog-toolbar-inline-actions-compact {
        gap: .4rem;
    }
    .catalog-toolbar-inline-actions-compact .btn {
        min-height: 40px;
        padding-inline: .6rem;
        font-size: .86rem;
    }
}


/* ==== PRECIOS · Listas de precio y bloque venta ==== */
.price-list-grid-wrap {
    border-top: 1px solid color-mix(in srgb, var(--bs-body-color) 12%, transparent);
    padding-top: 1rem;
}
.price-list-grid-scroll {
    max-height: 320px;
    overflow: auto;
    scrollbar-gutter: stable both-edges;
}
.price-list-grid-table {
    min-width: 760px;
    margin-bottom: 0;
}
.price-list-input {
    min-width: 120px;
}
.listas-precio-workspace {
    grid-template-columns: minmax(320px, .95fr) minmax(420px, 1.05fr);
}
.listas-toolbar-row {
    display: grid;
    grid-template-columns: minmax(200px, 1fr) auto;
    gap: .85rem;
    align-items: end;
}
@media (max-width: 991.98px) {
    .listas-precio-workspace {
        grid-template-columns: minmax(260px, .95fr) minmax(340px, 1.05fr);
    }
}
@media (max-width: 767.98px) {
    .listas-precio-workspace {
        grid-template-columns: minmax(220px, .92fr) minmax(300px, 1.08fr);
        gap: .7rem;
    }
    .listas-toolbar-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }
    .price-list-grid-scroll {
        max-height: 280px;
    }
}

/* =====================================================
   ETAPA 02C · Mayor opacidad en navegación y resumen crédito
   ===================================================== */
html[data-bs-theme="dark"] .topbar,
html[data-bs-theme="dark"] #sidebarOffcanvas,
html[data-bs-theme="dark"] #sidebarOffcanvas .sidebar-context,
html[data-bs-theme="dark"] #sidebarOffcanvas .accordion-item {
    background: rgba(15, 23, 42, .96) !important;
    border-color: rgba(255,255,255,.16) !important;
    box-shadow: 0 14px 40px rgba(0,0,0,.34) !important;
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
}

html[data-bs-theme="light"] .topbar,
html[data-bs-theme="light"] #sidebarOffcanvas,
html[data-bs-theme="light"] #sidebarOffcanvas .sidebar-context,
html[data-bs-theme="light"] #sidebarOffcanvas .accordion-item {
    background: rgba(255,255,255,.96) !important;
    border-color: rgba(0,0,0,.10) !important;
    box-shadow: 0 14px 36px rgba(18,38,63,.12) !important;
    backdrop-filter: blur(16px) saturate(130%);
    -webkit-backdrop-filter: blur(16px) saturate(130%);
}

html[data-bs-theme="dark"] .sticky-actions > .container-fluid,
html[data-bs-theme="dark"] .sticky-actions > .page-header-inner {
    background: rgba(15, 23, 42, .92) !important;
}

html[data-bs-theme="light"] .sticky-actions > .container-fluid,
html[data-bs-theme="light"] .sticky-actions > .page-header-inner {
    background: rgba(255,255,255,.94) !important;
}

.credit-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .75rem;
}

.credit-summary-card {
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: .75rem .85rem;
    background: color-mix(in srgb, var(--bs-body-bg) 82%, transparent);
}

.credit-summary-card span {
    display: block;
    color: var(--muted);
    font-size: .78rem;
    line-height: 1.1;
}

.credit-summary-card strong {
    display: block;
    margin-top: .25rem;
    font-size: .95rem;
}

@media (max-width: 991.98px) {
    .credit-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 575.98px) {
    .credit-summary-grid {
        grid-template-columns: 1fr;
    }
}

/* =========================================================
   ETAPA 02F - Terceros compacto
   - Reduce altura del formulario.
   - Mantiene roles base y roles configurables en una sola zona.
   - Hace más legibles las secciones tributarias y de crédito.
   ========================================================= */
.tercero-form-grid .form-label {
    margin-bottom: .25rem;
}

.tercero-form-grid .form-control,
.tercero-form-grid .form-select {
    min-height: 42px;
}

.tercero-section-head {
    min-height: 30px;
}

.roles-inline-card,
.tercero-tax-card {
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    background: color-mix(in srgb, var(--bs-body-bg) 78%, transparent);
    padding: .75rem;
}

.roles-base-line,
.roles-add-line,
.tax-switch-line {
    display: flex;
    flex-wrap: wrap;
    gap: .65rem .9rem;
    align-items: center;
}

.roles-add-line {
    margin-top: .65rem;
}

.roles-add-line .form-select {
    flex: 1 1 260px;
    min-width: 220px;
}

.roles-assigned-line {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-top: .55rem;
    min-height: 24px;
}

.tercero-tax-title {
    font-weight: 600;
    margin-bottom: .45rem;
    color: var(--bs-body-color);
}

.terceros-layout .glass {
    background: color-mix(in srgb, var(--bs-body-bg) 86%, transparent);
}

@media (min-width: 992px) {
    .terceros-layout .terceros-main-col section.glass {
        padding-top: 1rem !important;
    }
}

/* =========================================================
   ETAPA 02G - Ajuste móvil progresivo
   - Mejora el comportamiento de campos en pantallas pequeñas.
   - Evita zoom en iOS con inputs menores a 16px.
   - Compacta terceros, catálogos y toolbars sin cambiar diseño base.
   ========================================================= */
@media (max-width: 767.98px) {
    html,
    body {
        overflow-x: hidden;
    }

    .container.app-shell,
    .container.page-shell {
        max-width: 100%;
        padding-left: .75rem;
        padding-right: .75rem;
    }

    .main-pad {
        padding-top: .55rem;
    }

    .page-section {
        margin-top: .85rem !important;
        margin-bottom: .85rem !important;
    }

    .glass,
    .catalog-form-card .card-body,
    .catalog-list-card .card-body,
    .terceros-layout .glass {
        padding: .85rem !important;
        border-radius: 16px;
    }

    .page-toolbar,
    .header-actions {
        gap: .5rem !important;
    }

    .page-title-block .muted,
    .page-title-block .small,
    .small-muted {
        line-height: 1.2;
    }

    .sticky-actions {
        z-index: 20;
    }

    .sticky-actions .container-fluid {
        padding-top: .55rem !important;
        padding-bottom: .55rem !important;
    }

    .sticky-actions .btn,
    .header-actions .btn {
        min-height: 40px;
        padding-inline: .8rem;
    }

    .form-control,
    .form-select,
    .btn {
        font-size: 16px;
    }

    .form-label,
    .tercero-form-grid .form-label {
        font-size: .88rem;
        margin-bottom: .2rem;
    }

    .tercero-form-grid,
    .catalog-form-grid {
        --bs-gutter-x: .65rem;
        --bs-gutter-y: .55rem;
    }

    .tercero-form-grid .form-control,
    .tercero-form-grid .form-select,
    .catalog-form-grid .form-control,
    .catalog-form-grid .form-select {
        min-height: 40px;
        padding-top: .45rem;
        padding-bottom: .45rem;
    }

    .tercero-section-head {
        min-height: 0;
        margin-bottom: .55rem !important;
    }

    .tercero-section-head h5,
    .terceros-search-panel h5,
    .catalog-form-card h5,
    .catalog-list-card h5 {
        font-size: 1rem;
    }

    .roles-inline-card,
    .tercero-tax-card {
        padding: .65rem;
        border-radius: 14px;
    }

    .roles-base-line {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .45rem .7rem;
        align-items: center;
    }

    .roles-base-line > .form-label,
    .roles-base-line > span.form-label {
        grid-column: 1 / -1;
    }

    .roles-base-line .form-check,
    .tax-switch-line .form-check {
        min-height: 30px;
        display: flex;
        align-items: center;
        margin-bottom: 0;
    }

    .roles-add-line {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: .5rem;
        margin-top: .55rem;
    }

    .roles-add-line label {
        grid-column: 1 / -1;
    }

    .roles-add-line .form-select {
        min-width: 0;
        width: 100%;
    }

    .roles-add-line .btn,
    .roles-add-line a.btn {
        min-height: 40px;
        white-space: nowrap;
    }

    .roles-add-line a.btn {
        grid-column: 1 / -1;
        justify-self: start;
        padding-left: 0 !important;
    }

    .roles-assigned-line {
        min-height: 18px;
        margin-top: .4rem;
    }

    .tax-switch-line {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .35rem .7rem;
    }

    .credit-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .5rem;
    }

    .credit-summary-card {
        padding: .55rem .6rem;
    }

    .credit-summary-card span {
        font-size: .72rem;
    }

    .credit-summary-card strong {
        font-size: .86rem;
    }

    .terceros-search-panel {
        position: static;
    }

    .terceros-search-results {
        max-height: 420px;
    }

    .table-responsive,
    .catalog-list-scroll,
    .terceros-search-results {
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 575.98px) {
    .page-toolbar {
        align-items: stretch !important;
    }

    .page-title-block,
    .header-actions {
        width: 100%;
    }

    .header-actions {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .header-actions .btn {
        width: 100%;
    }

    .terceros-doc-number-col {
        flex: 0 0 75%;
        max-width: 75%;
    }

    .terceros-doc-dv-col:not(.d-none) {
        flex: 0 0 25%;
        max-width: 25%;
    }

    .tax-switch-line {
        grid-template-columns: 1fr;
    }

    .credit-summary-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 420px) {
    .container.app-shell,
    .container.page-shell {
        padding-left: .55rem;
        padding-right: .55rem;
    }

    .roles-base-line,
    .credit-summary-grid {
        grid-template-columns: 1fr;
    }

    .roles-add-line {
        grid-template-columns: 1fr;
    }

    .roles-add-line .btn {
        width: 100%;
    }
}

/* 1.0.15: versión de FRONTEND/BACKEND auditada en todas las pantallas */
.topbar-version { flex-shrink:0; font-size:.72rem; font-weight:600; line-height:1.3; color:#bbd3ef;
  border:1px solid rgba(150,180,220,.22); border-radius:.5rem; padding:.2rem .45rem;
  background:rgba(30,48,80,.45); white-space:nowrap; }
.topbar-version--mismatch { color:#ffd46a; border-color:rgba(255,203,74,.6); }
@media(max-width:620px){.topbar-version{font-size:.62rem;padding:.17rem .28rem;max-width:124px;overflow:hidden;text-overflow:ellipsis}}

/* ===============================================================
   FICHA TÉCNICA DE COSTOS – DISEÑO COMPACTO 30/70
   Estilos limitados al módulo original; NO cambiar otras pantallas.
   =============================================================== */

    .sam-real .sam-results { max-height: 320px; overflow: auto; }
    .sam-real .sam-picked { border: 1px solid rgba(148,163,184,.26); border-radius: 12px; padding: .5rem .65rem; background: rgba(15,23,42,.35); }
    .sam-real .sam-line-table { min-width: 1040px; }
    .sam-real .sam-line-table th, .sam-real .sam-line-table td { padding: .42rem .55rem; vertical-align: middle; }
    .sam-real .sam-line-main { font-weight: 650; line-height: 1.15; }
    .sam-real .sam-line-sub { color: rgba(226,232,240,.62); font-size: .74rem; line-height: 1.15; margin-top: .15rem; }
    .sam-real .sam-line-compact .sam-badge { font-size: .68rem; padding: .08rem .36rem; }
    .sam-real .sam-modal-results { max-height: 260px; overflow:auto; }
    .sam-real .sam-modal-selected { border: 1px solid rgba(148,163,184,.26); border-radius: 12px; padding: .55rem .65rem; background: rgba(15,23,42,.32); min-height: 54px; }
    .sam-real .sam-modal-grid { max-height: 190px; overflow: auto; border: 1px solid rgba(148,163,184,.22); border-radius: 12px; }
    .sam-real .sam-summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: .55rem; }
    .sam-real .sam-summary-card { border: 1px solid rgba(148,163,184,.24); border-radius: 12px; padding: .55rem .65rem; background: rgba(15,23,42,.32); min-height: 70px; }
    .sam-real .sam-summary-card .label { color: rgba(226,232,240,.72); font-size: .76rem; line-height: 1.15; }
    .sam-real .sam-summary-card .value { font-weight: 700; font-size: 1rem; }
    .sam-real .sam-photo-box { border: 1px dashed rgba(148,163,184,.38); border-radius: 16px; min-height: 212px; display: flex; align-items: center; justify-content: center; background: rgba(15,23,42,.28); color: rgba(226,232,240,.66); }
    .sam-real .sam-group-row td { background: rgba(148,163,184,.13); color: rgba(226,232,240,.96); font-weight: 700; position: sticky; top: 0; z-index: 1; }
    .sam-real .sam-badge { display: inline-flex; gap: .25rem; align-items: center; border: 1px solid rgba(148,163,184,.25); border-radius: 999px; padding: .12rem .45rem; font-size: .72rem; color: rgba(226,232,240,.82); }
    .sam-real .sam-alerts .alert { padding: .45rem .65rem; margin-bottom: .4rem; }
    .sam-real .sam-provisional { border-left: 3px solid rgba(245,158,11,.85); }
    .sam-real .sam-search-panel { position: relative; }
    .sam-real .sam-search-dropdown { position: absolute; left: 0; right: 0; top: calc(100% + .35rem); z-index: 30; border: 1px solid rgba(148,163,184,.28); border-radius: 14px; background: rgba(15,23,42,.98); box-shadow: 0 16px 42px rgba(0,0,0,.36); padding: .6rem; }
    .sam-real .sam-compact-label { font-size: .76rem; color: rgba(226,232,240,.72); margin-bottom: .18rem; }
    .sam-real .sam-mini-card { border: 1px solid rgba(148,163,184,.22); border-radius: 16px; background: rgba(15,23,42,.18); }
    .sam-real .sam-cost-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
    .sam-real .sam-cost-result { border: 1px solid rgba(148,163,184,.22); border-radius: 12px; padding: .55rem .65rem; background: rgba(15,23,42,.25); min-height: 58px; }
    .sam-real .sam-cost-result .label { color: rgba(226,232,240,.68); font-size: .75rem; line-height: 1.1; }
    .sam-real .sam-cost-result .value { font-weight: 800; font-size: 1rem; line-height: 1.25; margin-top: .12rem; }
    .sam-real .sam-cost-result.primary { border-color: rgba(59,130,246,.42); background: rgba(37,99,235,.14); }
    .sam-real .sam-cost-result.warning { border-color: rgba(245,158,11,.42); background: rgba(245,158,11,.1); }
    .sam-real .sam-cost-detail-toggle { border-top: 1px solid rgba(148,163,184,.18); margin-top: .7rem; padding-top: .55rem; }
    .sam-real .sam-cost-detail-table th, .sam-real .sam-cost-detail-table td { padding: .34rem .45rem; vertical-align: middle; }
    .sam-real .sam-cost-detail-table .form-control, .sam-real .sam-cost-detail-table .form-select { min-height: 32px; padding-top: .2rem; padding-bottom: .2rem; }
    .sam-real .sam-group-toggle { width: 100%; display:flex; align-items:center; justify-content:space-between; gap:.75rem; border: 0; color: inherit; background: transparent; font-weight: 800; text-align:left; padding: .2rem 0; }
    .sam-real .sam-group-meta { display:flex; flex-wrap:wrap; gap:.4rem; align-items:center; justify-content:flex-end; font-weight:600; color: rgba(226,232,240,.78); font-size:.82rem; }
    @media (max-width: 991.98px) { .sam-cost-summary { grid-template-columns: 1fr; } }
    .sam-real .sam-detail-toolbar { position: sticky; top: 0; z-index: 4; background: rgba(30,41,59,.94); border-radius: 12px; padding: .5rem; }
    .sam-real .sam-field-note { font-size: .72rem; color: rgba(226,232,240,.58); }
    .sam-real .sam-modal-compact .modal-header { padding: .65rem .9rem; }
    .sam-real .sam-modal-compact .modal-body { padding: .75rem .9rem; }
    .sam-real .sam-modal-compact .modal-footer { padding: .65rem .9rem; }
    .sam-real .sam-modal-compact .modal-title { font-size: 1rem; }
    .sam-real .sam-modal-compact .form-label { font-size: .8rem; margin-bottom: .18rem; color: rgba(226,232,240,.84); }
    .sam-modal-compact .form-control,
    .sam-modal-compact .form-select,
    .sam-modal-compact .input-group-text,
    .sam-real .sam-modal-compact .btn { min-height: 34px; padding-top: .28rem; padding-bottom: .28rem; }
    .sam-real .sam-modal-compact .input-group > .btn { padding-left: .65rem; padding-right: .65rem; }
    .sam-real .sam-modal-compact .sam-modal-selected { min-height: 42px; padding: .4rem .55rem; }
    .sam-real .sam-modal-compact .sam-modal-grid { max-height: 154px; }
    .sam-real .sam-modal-compact .sam-picked { padding: .34rem .5rem; border-radius: 10px; }
    .sam-real .sam-modal-compact textarea.form-control { min-height: 38px; }
    .sam-real .sam-modal-compact .compact-status { min-height: 34px; display:flex; align-items:center; }
    .sam-real .sam-modal-compact .compact-line { line-height: 1.15; }
    @media (max-width: 991.98px) {
      .sam-real .sam-search-dropdown { position: static; margin-top: .5rem; }
      .sam-real .sam-photo-box { min-height: 160px; }
    }
  

/* Real: capa visual de la ficha (aislada en esta carpeta; hereda /css/xtrak.css). */
.sam-real .app-shell.sam-workspace { max-width: 1720px; padding-top: .65rem; }
.sam-real .sam-workspace .glass { padding: 0; }
.sam-real .sam-heading { margin: 0 0 .24rem; min-height: 26px; }
.sam-real .sam-title { font-size: 1.13rem; line-height: 1.28; font-weight: 700; }
.sam-real .sam-state { padding: .12rem .48rem; border: 1px solid var(--bs-border-color); border-radius: .35rem; font-size: .76rem; color: var(--bs-secondary-color); }
.sam-real .sam-inactive { font-size: .74rem; color: var(--bs-warning); }
.sam-real .sam-message:empty { display:none; }
.sam-real .sam-message:not(:empty) { margin: .2rem 0 .35rem; }
.sam-real .sam-small-warning { color: var(--bs-warning); font-size: .74rem; }
.sam-real .sam-header { display:flex; padding: .53rem .65rem !important; gap: .5rem; align-items: end; margin-bottom: .6rem; }
.sam-real .sam-header-fields { flex: 1 1 auto; min-width: 0; display:flex; align-items:end; gap: .45rem; overflow-x: auto; scrollbar-width: thin; padding-bottom: .05rem; }
.sam-real .sam-head-field { min-width:0; flex-shrink:0; }
.sam-real .sam-head-field label, .sam-real .sam-extra-item>label { display:block; font-size:.72rem; margin-bottom:.15rem; color:var(--bs-secondary-color); }
.sam-real .sam-head-field input,.sam-real .sam-head-field select { height:34px; min-height:34px; font-size:.85rem; padding:.25rem .43rem; }
.sam-real .sam-head-field input[type="search"] { appearance:auto; }
.sam-real .sam-head-ref { width: 185px; }.sam-real .sam-head-name { flex:1 0 185px; }.sam-real .sam-head-qty { width:73px; }.sam-real .sam-head-unit { width:106px; }.sam-real .sam-head-code { width:112px; }.sam-real .sam-head-ver { width:60px; }
.sam-real .sam-header-actions { display:flex; gap:.28rem; align-items:center; flex:0 0 auto; }
.sam-real .sam-header-actions .btn { min-width:36px; height:36px; display:inline-flex; justify-content:center; align-items:center; padding:0 .55rem; }
.sam-real .sam-header-actions .btn i { font-size: 1rem; }
.sam-real .sam-layout { display:grid; grid-template-columns: minmax(290px,30fr) minmax(0,70fr); gap:.65rem; align-items:start; }
.sam-real .sam-cost-panel,.sam-real .sam-detail-panel { min-width:0; padding:.65rem !important; }
.sam-real .sam-cost-panel { position:sticky; top:.5rem; }
.sam-real .sam-panel-head { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:.4rem; margin-bottom:.48rem; }
.sam-real .sam-panel-head h2 { margin:0; font-size:.93rem; font-weight:700; }
.sam-real .sam-panel-head .btn { font-size:.73rem; }
.sam-real .sam-switch-row { display:flex; gap:.3rem; align-items:center; flex-wrap:wrap; }
.sam-real .sam-switch-row .btn { white-space:nowrap; }
.sam-real .sam-summary-block { border:1px solid var(--bs-border-color); border-radius:.42rem; overflow:hidden; margin-bottom:.3rem; }
.sam-real .sam-summary-heading { width:100%; text-align:left; border:0; border-bottom:1px solid var(--bs-border-color); background:color-mix(in srgb,var(--bs-secondary-bg) 80%,transparent); color:var(--bs-body-color); padding:.36rem .48rem; font-size:.8rem; display:flex; align-items:center; justify-content:space-between; gap:.3rem; }
.sam-real .sam-summary-heading b { font-size:.82rem; font-variant-numeric:tabular-nums; white-space:nowrap; }
.sam-real .sam-summary-block.is-collapsed .sam-summary-rows { display:none; }
.sam-real .sam-summary-block.is-collapsed .sam-summary-heading { border-bottom:0; }
.sam-real .sam-summary-line { display:flex; justify-content:space-between; gap:.55rem; padding:.18rem .52rem; font-size:.81rem; border-bottom:1px solid color-mix(in srgb,var(--bs-border-color) 38%,transparent); }
.sam-real .sam-summary-line:last-child { border:0; }
.sam-real .sam-summary-line span { min-width:0; overflow-wrap:anywhere; }
.sam-real .sam-summary-line b { font-variant-numeric:tabular-nums; white-space:nowrap; }
.sam-real .sam-summary-line small { color:var(--bs-secondary-color); font-size:.66rem; }
.sam-real .sam-summary-totals { margin-top:.38rem; border:1px solid var(--bs-border-color); border-radius:.4rem; overflow:hidden; }
.sam-real .sam-summary-totals .sam-summary-line { padding:.3rem .52rem; }
.sam-real .sam-summary-line.sam-grand { font-weight:700; background: color-mix(in srgb, var(--bs-primary) 19%,transparent); border-top:1px solid var(--bs-primary); font-size:.99rem; }
.sam-real .sam-summary-footer { display:flex; justify-content:space-between; flex-wrap:wrap; gap:.35rem; margin-top:.38rem; color:var(--bs-secondary-color); font-size:.73rem; }
.sam-real .sam-detail-tools { margin-bottom:.43rem; display:flex; flex-wrap:wrap; gap:.35rem; align-items:center; }
.sam-real .sam-filter-wrap { position:relative; flex:1 1 190px; }
.sam-real .sam-filter-wrap i { position:absolute; top:.4rem; left:.6rem; pointer-events:none; color:var(--bs-secondary-color); }
.sam-real .sam-filter-wrap input { padding-left:1.8rem; min-height:32px; font-size:.8rem; }
.sam-real .sam-tool-buttons { display:flex; flex-wrap:wrap; gap:.24rem; }
.sam-real .sam-tool-buttons .btn { white-space:nowrap; }
.sam-real .sam-lines-scroller { max-height: min(64vh, 700px); overflow:auto; border: 1px solid var(--bs-border-color); border-radius:.4rem; }
.sam-real .sam-line-table { min-width: 940px; }
.sam-real .sam-line-table th,.sam-real .sam-line-table td { padding:.35rem .42rem; }
.sam-real .sam-line-table th { position:sticky; top:0; z-index:3; background:var(--bs-secondary-bg); white-space:nowrap; font-size:.74rem; }
.sam-real .sam-group-row td { position:static; }
.sam-real .sam-group-toggle { padding:.15rem 0; }
.sam-real .sam-options { border-top:1px solid var(--bs-border-color); padding-top:.43rem; }
.sam-real .sam-options-content { padding:.65rem .25rem .15rem; display:flex; flex-direction:column; gap:.55rem; }
.sam-real .sam-extra-grid { display:grid; grid-template-columns: 1fr 1fr; gap:.65rem; }
.sam-real .sam-extra-item label { font-size:.76rem; margin-bottom:.18rem; color:var(--bs-secondary-color); }
.sam-real .sam-extra-item h3 { font-size:.85rem; font-weight:600; }
.sam-real .sam-checks { display:flex; gap:.75rem; align-items:center; flex-wrap:wrap; }
.sam-real .sam-options-content .form-control,.sam-real .sam-options-content .form-select { min-height:34px; padding:.26rem .5rem; font-size:.82rem; }
.sam-real .sam-audit { display:grid; grid-template-columns: repeat(auto-fit,minmax(170px,1fr)); gap:.3rem; padding:.4rem; border:1px solid var(--bs-border-color); border-radius:.45rem; }
.sam-real .sam-audit div { display:flex; gap:.3rem; justify-content:space-between; align-items:center; padding:.15rem; }
.sam-real .sam-audit span { color:var(--bs-secondary-color); font-size:.74rem; }
.sam-real .sam-audit b { font-size:.82rem; }
.sam-real .sam-audit small { font-size:.7rem; color:var(--bs-secondary-color); }
.sam-real .sam-photo-image { max-height:70vh; max-width:100%; object-fit:contain; }
.sam-real .sam-search-panel { position:relative; }
.sam-real .sam-search-dropdown { z-index:40; }
@media(max-width:1100px){.sam-real .sam-layout {grid-template-columns:minmax(255px,34fr) minmax(0,66fr);} .sam-real .sam-panel-head.sam-detail-title{align-items:flex-start;} }
@media(max-width:850px){.sam-real .sam-layout {display:flex;flex-direction:column;} .sam-real .sam-cost-panel {position:static;} .sam-real .sam-cost-panel,.sam-real .sam-detail-panel{width:100%;} .sam-real .sam-header {align-items:end;} .sam-real .sam-header-fields{max-width:calc(100vw - 160px);} .sam-real .sam-lines-scroller {max-height:none;} }
@media(max-width:520px){.sam-real .sam-workspace {padding-left:.42rem;padding-right:.42rem;} .sam-real .sam-header{padding:.42rem !important; flex-wrap:wrap;} .sam-real .sam-header-fields {max-width:100%;width:100%;} .sam-real .sam-header-actions {width:100%;justify-content:flex-end;} .sam-real .sam-cost-panel,.sam-real .sam-detail-panel {padding:.45rem !important;} .sam-real .sam-panel-head h2{font-size:.86rem;} .sam-real .sam-switch-row{width:100%;} .sam-real .sam-switch-row .btn {font-size:.78rem;} .sam-real .sam-summary-line {font-size:.79rem;} .sam-real .sam-detail-tools {gap:.26rem;} .sam-real .sam-extra-grid {grid-template-columns:1fr;} .sam-real .sam-tool-buttons{gap:.18rem;} .sam-real .sam-tool-buttons .btn{font-size:.78rem;} }

.sam-real .sam-head-name input { text-overflow:ellipsis; }
.sam-real .sam-head-field.sam-search-panel { position:relative; }
.sam-real .sam-search-dropdown [data-pick-ficha], .sam-real .sam-search-dropdown [data-pick-producto] { display:block; }
.sam-real .sam-summary-line.sam-grand b {font-weight:800;}
.sam-real .sam-search-dropdown {max-height:min(70vh,360px);overflow:auto;}
.sam-real .sam-group-toggle:focus-visible,.sam-real .sam-summary-heading:focus-visible{outline:2px solid var(--bs-primary);outline-offset:2px;}

/* Lista compartida por las búsquedas de referencia y nombre del producto.
   Se mueve a <body> para que no quede recortada por el encabezado compacto. */
body > #resultPrincipal.sam-search-dropdown {
    border: 1px solid var(--bs-border-color);
    border-radius: 12px;
    background: var(--bs-secondary-bg);
    color: var(--bs-body-color);
    box-shadow: 0 16px 42px rgba(0,0,0,.36);
    padding: .55rem;
}
body > #resultPrincipal .sam-picked {
    padding: .5rem;
}


/* Sidebar Configuración: grupos internos compactos, mismo sistema visual de Xtrak. */
#sidebarOffcanvas .sidebar-home-link {
    display: block;
    color: var(--bs-body-color);
    border-radius: 12px;
    text-decoration: none;
    min-height: 44px;
}
#sidebarOffcanvas .sidebar-home-link:hover,
#sidebarOffcanvas .sidebar-home-link.active {
    background: color-mix(in srgb, var(--bs-primary) 12%, transparent);
}
#sidebarOffcanvas .sidebar-submenu-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    background: transparent;
    border: 0;
    color: var(--bs-body-color);
    min-height: 44px;
}
#sidebarOffcanvas .sidebar-submenu-chevron { font-size: .75rem; transition: transform .15s ease; }
#sidebarOffcanvas .sidebar-submenu-toggle[aria-expanded="true"] .sidebar-submenu-chevron { transform: rotate(180deg); }
#sidebarOffcanvas .sidebar-submenu-group { margin: 0 .2rem 0 1.15rem; padding-left: .45rem; border-left: 1px solid var(--bs-border-color); }
#sidebarOffcanvas .sidebar-submenu-group .nav-link { font-size: .92rem; min-height: 38px; }
#sidebarOffcanvas .sidebar-nav-pending { cursor: not-allowed; opacity: .55; }
#sidebarOffcanvas .sidebar-nav-pending small { font-size: .7rem; }

/* Xtrak 1.0.50 — Configuración anidada, conservando navegación operativa compacta. */
#sidebarOffcanvas .sidebar-settings-groups { margin-top: .3rem; border-top: 1px solid var(--bs-border-color); padding-top: .3rem; }
#sidebarOffcanvas .sidebar-submenu-toggle { border-radius: 12px; font-size: .95rem; text-decoration: none; }
#sidebarOffcanvas .sidebar-submenu-toggle:hover,
#sidebarOffcanvas .sidebar-submenu-toggle:focus-visible,
#sidebarOffcanvas .sidebar-submenu-toggle[aria-expanded="true"] { background: color-mix(in srgb, var(--bs-primary) 12%, transparent); }
#sidebarOffcanvas .sidebar-submenu-group .nav-link { min-height: 34px; padding-top: .35rem !important; padding-bottom: .35rem !important; }
#sidebarOffcanvas .sidebar-nav-pending { white-space: normal; font-size: .83rem; }
#sidebarOffcanvas .sidebar-nav-pending small { margin-left: .1rem; }
