/* ============================================================
   Datos obligatorios y opcionales (site.js marca las etiquetas de los formularios)
   ============================================================ */
.field-mark { margin-left: .3rem; }
.field-required { color: var(--bs-danger, #DC2626); font-weight: 700; }
.field-optional { color: var(--bs-secondary-color, #64748B); font-size: .78em; font-weight: 400; }
.field-optional::before { content: "("; }
.field-optional::after { content: ")"; }
.required-legend { margin-top: .75rem; font-size: .8rem; color: var(--bs-secondary-color, #64748B); text-align: end; }
.select2-hidden-accessible.is-invalid + .select2-container .select2-selection { border-color: var(--bs-danger, #DC2626) !important; }
#notInCatalog > .flex-grow-1,
#priceMissing > .flex-grow-1 { flex: 1 1 14rem; min-width: 0; }

/* Revisar precios */
.min-w-0 { min-width: 0; }
.price-check-head { display: flex; gap: 1rem; align-items: flex-start; }
.price-check-image { width: 132px; height: 132px; flex: none; object-fit: contain; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-3); }
.price-check-thumb { width: 56px; height: 56px; object-fit: contain; }
.price-check-value { font-size: 2.1rem; font-weight: 800; line-height: 1.1; margin: .35rem 0; letter-spacing: -.01em; }
.price-check-nice { padding: .6rem .75rem; border-radius: 8px; background: var(--bs-tertiary-bg); border: 1px solid var(--line); }
.price-history-item { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: .75rem; padding: .55rem 1rem; border: 0; background: none; text-align: start; color: inherit; }
.price-history-item:hover { background: var(--bs-tertiary-bg); }
@media (max-width: 575.98px) {
    .price-check-image { width: 96px; height: 96px; }
    .price-check-value { font-size: 1.8rem; }
}
.receive-defaults { padding: .6rem .75rem; border: 1px dashed var(--bs-border-color); border-radius: .5rem; background: var(--bs-tertiary-bg); }
/* Entradas: qué hacer con cada pieza (dar de alta, registrar la entrada, imprimir la etiqueta). */
.receive-actions { padding: .6rem .75rem; border: 1px solid rgba(var(--brand-rgb), .25); border-radius: .5rem; background: rgba(var(--brand-rgb), .04); }
.receive-label-options summary { cursor: pointer; color: var(--muted); }

/* =============================================================================
   JoyeriaNice - estilos base
   El color de marca (--brand) lo define cada empresa en Configuración y el
   layout lo inyecta en <html style="--brand:...; --brand-rgb:...">.
   ============================================================================= */
:root {
    --brand: #4F46E5;
    --brand-rgb: 79, 70, 229;
    /* Marca usable como texto: el layout calcula una versión con contraste AA para cada
       tema (--brand-text-light / --brand-text-dark) a partir del color de la empresa. */
    --brand-text: var(--brand-text-light, var(--brand));
    --brand-text-rgb: var(--brand-text-light-rgb, var(--brand-rgb));
    --ink: #0F172A;
    /* #5B6A7F: contraste 5:1 sobre el fondo gris (#64748B no llegaba a 4.5:1). */
    --muted: #5B6A7F;
    --line: #E2E8F0;
    --canvas: #F4F6FA;
    --surface: #FFFFFF;
    --surface-2: #F8FAFC;
    --surface-3: #F1F5F9;
    --topbar-bg: rgba(255, 255, 255, .85);
    --overlay-bg: rgba(248, 250, 252, .92);
    --highlight-bg: #FFFBEB;
    --sidebar: #0B1220;
    --sidebar-ink: #A8B3C7;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .04);
    --bs-primary: var(--brand);
    --bs-primary-rgb: var(--brand-rgb);
    --bs-link-color: var(--brand-text);
    --bs-link-color-rgb: var(--brand-text-rgb);
    --bs-link-hover-color: var(--brand-text);
    --bs-link-hover-color-rgb: var(--brand-text-rgb);
    --bs-body-font-family: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    --bs-body-color: var(--ink);
    --bs-border-color: var(--line);
    --bs-border-radius: 10px;
}

html {
    font-size: 14.5px;
}

body {
    background: var(--canvas);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------- Botones */
.btn-primary {
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: color-mix(in srgb, var(--brand) 88%, black);
    --bs-btn-hover-border-color: color-mix(in srgb, var(--brand) 88%, black);
    --bs-btn-active-bg: color-mix(in srgb, var(--brand) 80%, black);
    --bs-btn-active-border-color: color-mix(in srgb, var(--brand) 80%, black);
    --bs-btn-disabled-bg: var(--brand);
    --bs-btn-disabled-border-color: var(--brand);
}

.btn-outline-primary {
    --bs-btn-color: var(--brand-text);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-active-bg: var(--brand);
    --bs-btn-active-border-color: var(--brand);
}

.btn {
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
}

.btn .material-symbols-outlined {
    font-size: 18px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
}

.btn-icon .material-symbols-outlined {
    font-size: 18px;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus,
.btn:focus-visible {
    border-color: rgba(var(--brand-rgb), .55);
    box-shadow: 0 0 0 .2rem rgba(var(--brand-rgb), .18);
}

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

.form-label {
    font-weight: 500;
    font-size: .9rem;
    margin-bottom: .3rem;
}

.form-text {
    font-size: .8rem;
}

.text-brand {
    color: var(--brand-text) !important;
}

.bg-brand-soft {
    background: rgba(var(--brand-rgb), .08) !important;
}

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

/* offcanvas-lg de Bootstrap fuerza fondo transparente en escritorio: el color va con !important. */
.app-sidebar {
    display: flex;
    flex-direction: column;
    width: 268px;
    flex: none;
    background-color: var(--sidebar) !important;
    color: var(--sidebar-ink);
    --bs-offcanvas-width: 268px;
    --bs-offcanvas-bg: var(--sidebar);
}

@media (min-width: 992px) {
    .app-sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
        overflow: hidden;
        width: 72px;
        transition: width .16s ease;
    }

    .sidebar-expanded .app-sidebar {
        width: 268px;
    }

    .app-sidebar .offcanvas-body {
        padding-left: .55rem;
        padding-right: .55rem;
    }

    .sidebar-expanded .app-sidebar .offcanvas-body {
        padding-left: .9rem;
        padding-right: .9rem;
    }

    .app-sidebar .sidebar-brand,
    .app-sidebar .sidebar-link {
        justify-content: center;
    }

    .sidebar-expanded .app-sidebar .sidebar-brand,
    .sidebar-expanded .app-sidebar .sidebar-link {
        justify-content: flex-start;
    }

    .app-sidebar .sidebar-brand-copy,
    .app-sidebar .sidebar-link-label,
    .app-sidebar .sidebar-section-label,
    .app-sidebar .section-chevron,
    .app-sidebar .sidebar-footer {
        display: none;
    }

    .sidebar-expanded .app-sidebar .sidebar-brand-copy,
    .sidebar-expanded .app-sidebar .sidebar-link-label,
    .sidebar-expanded .app-sidebar .sidebar-section-label,
    .sidebar-expanded .app-sidebar .section-chevron,
    .sidebar-expanded .app-sidebar .sidebar-footer {
        display: block;
    }

    .app-sidebar .sidebar-section {
        justify-content: center;
        padding: .55rem;
        margin: .4rem 0;
        border-left: 3px solid transparent;
    }

    .sidebar-expanded .app-sidebar .sidebar-section {
        justify-content: flex-start;
        padding: .7rem .65rem;
        margin: .3rem 0;
        border-left: 3px solid var(--section-accent);
    }

    .app-sidebar:not(.offcanvas.show) .sidebar-section-items[hidden] { display: none; }

    html:not(.sidebar-expanded) .app-sidebar .sidebar-section-items { display: none; }
}

.app-sidebar .offcanvas-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    padding: 1.1rem .9rem;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .25rem .5rem 1.1rem;
    color: #fff;
    text-decoration: none;
}

.sidebar-brand:hover {
    color: #fff;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 55%, #0EA5E9));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex: none;
    overflow: hidden;
}

.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Con imagen (el logo de la aplicación o el que se sube en Configuración), sin fondo detrás. */
.brand-mark:has(img) {
    background: none;
}

.brand-name {
    font-weight: 700;
    line-height: 1.15;
    font-size: .98rem;
}

.brand-subtitle {
    font-size: .72rem;
    color: var(--sidebar-ink);
    font-weight: 400;
}

.sidebar-section {
    display: flex;
    align-items: center;
    width: 100%;
    gap: .7rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    text-align: left;
    cursor: pointer;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--sidebar-ink);
    padding: .7rem .75rem;
    border-left: 3px solid var(--section-accent, transparent);
    margin: .35rem 0;
}

.sidebar-section:hover,
.sidebar-section[aria-expanded="true"] {
    color: #fff;
    background: rgba(255, 255, 255, .08);
}

.sidebar-section > .material-symbols-outlined:first-child {
    font-size: 20px;
    color: var(--section-accent);
}

.sidebar-section .section-chevron { margin-left: auto; font-size: 18px; }
.sidebar-section[aria-expanded="true"] .section-chevron { transform: rotate(180deg); }
.sidebar-section-items[hidden] { display: none; }
.sidebar-section-items { padding-bottom: .35rem; }

@media (max-width: 991.98px) {
    .sidebar-section { min-height: 44px; }
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .5rem .75rem;
    border-radius: 9px;
    color: var(--sidebar-ink);
    text-decoration: none;
    font-size: .92rem;
    transition: background-color .12s ease, color .12s ease;
}

.sidebar-link .material-symbols-outlined {
    font-size: 20px;
    color: color-mix(in srgb, var(--section-accent, #A8B3C7) 48%, #FFFFFF);
}

.sidebar-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, .06);
}

.sidebar-link.active {
    color: #fff;
    background: var(--section-accent, var(--brand));
    box-shadow: 0 5px 14px rgba(0, 0, 0, .2);
}

.sidebar-link.active .material-symbols-outlined {
    color: #fff;
}

@media (max-width: 991.98px) {
    .app-sidebar .sidebar-link { min-height: 44px; }
    .app-topbar .btn-icon { min-width: 44px; min-height: 44px; }
}

.sidebar-footer {
    margin-top: auto;
    padding: 1rem .75rem 0;
    font-size: .72rem;
    color: #7C8799;
}

.app-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    background: var(--topbar-bg);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 2px solid var(--module-color, var(--line));
}

.app-version {
    flex: none;
    color: var(--muted);
    font-size: .75rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.topbar-search {
    position: relative;
    max-width: 380px;
    width: 100%;
    min-width: 0;
    flex: 1 1 160px;
}

@media (max-width: 575.98px) {
    .topbar-search input { font-size: .82rem; }
}

.topbar-search .material-symbols-outlined {
    position: absolute;
    left: .7rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 20px;
}

.topbar-search input {
    padding-left: 2.3rem;
    background: var(--canvas);
    border-color: transparent;
}

.app-content {
    padding: 1.6rem 1.75rem 2.5rem;
    flex: 1 1 auto;
}

@media (max-width: 575.98px) {
    .app-content {
        padding: 1.1rem .9rem 2rem;
    }
}

/* ---------------------------------------------------------------- Encabezado de página */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.4rem;
}

.page-title {
    font-size: 1.45rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -.01em;
}

.module-context {
    color: color-mix(in srgb, var(--module-color, var(--muted)) 85%, #000);
    font-size: .68rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: .2rem;
    text-transform: uppercase;
}

.page-subtitle {
    color: var(--muted);
    margin: .15rem 0 0;
}

.module-badge {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
}

.module-badge .material-symbols-outlined {
    font-size: 22px;
}

/* Íconos con el color de su módulo: la vista define --tone y aquí se decide cómo se
   ve en cada tema. En claro se oscurece un poco (el ámbar #D97706 no llegaba a 3:1
   sobre su fondo tenue) y en oscuro se aclara. */
.module-badge,
.kpi-icon {
    background: color-mix(in srgb, var(--tone, var(--brand)) 12%, transparent);
    color: color-mix(in srgb, var(--tone, var(--brand)) 85%, #000);
}

.tone-text {
    color: color-mix(in srgb, var(--tone, var(--brand)) 85%, #000);
}

/* ---------------------------------------------------------------- Tarjetas */
.card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--line);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

.section-title {
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    margin-bottom: .9rem;
}

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

/* ---------------------------------------------------------------- Inicio */
.home-hero {
    display: grid;
    gap: 1rem;
    margin-bottom: 1rem;
}

.home-search {
    padding: 1.1rem 1.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background:
        radial-gradient(circle at 100% 0%, rgba(var(--brand-rgb), .10), transparent 55%),
        var(--surface);
    box-shadow: var(--shadow);
}

.home-search-label {
    display: block;
    font-weight: 700;
    font-size: 1.05rem;
    margin-bottom: .6rem;
}

.home-search-box {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.home-search-box > .material-symbols-outlined {
    color: var(--brand);
    font-size: 28px;
    flex: none;
}

.home-search-box .form-control {
    min-width: 0;
    flex: 1;
    height: 48px;
    font-size: 1.05rem;
}

.home-search-box .btn {
    height: 48px;
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}

.home-search-camera {
    border: 1px solid var(--line);
}

.home-actions {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: .75rem;
}

.home-action {
    display: flex;
    flex-direction: column;
    gap: .55rem;
    min-width: 0;
    padding: .95rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--ink);
    text-decoration: none;
    box-shadow: var(--shadow);
    transition: border-color .12s ease, transform .12s ease, box-shadow .12s ease;
}

.home-action:hover,
.home-action:focus-visible {
    border-color: color-mix(in srgb, var(--action-color) 55%, transparent);
    box-shadow: 0 8px 22px color-mix(in srgb, var(--action-color) 16%, transparent);
    transform: translateY(-1px);
    color: var(--ink);
}

.home-action-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--action-color) 13%, transparent);
    color: color-mix(in srgb, var(--action-color) 85%, #000);
}

.home-action-copy strong,
.home-action-copy small {
    display: block;
}

.home-action-copy strong {
    line-height: 1.2;
}

.home-action-copy small {
    color: var(--muted);
    line-height: 1.3;
    margin-top: .2rem;
}

.home-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .75rem;
    margin-bottom: 1rem;
}

.home-kpi {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "icon label" "icon value" "icon note";
    column-gap: .85rem;
    align-items: center;
    padding: 1rem 1.1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: var(--ink);
    text-decoration: none;
}

.home-kpi:hover {
    border-color: color-mix(in srgb, var(--tone) 45%, transparent);
    color: var(--ink);
}

.home-kpi-icon {
    grid-area: icon;
    width: 46px;
    height: 46px;
    border-radius: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--tone) 12%, transparent);
    color: color-mix(in srgb, var(--tone) 85%, #000);
}

.home-kpi-label { grid-area: label; color: var(--muted); font-size: .82rem; }
.home-kpi-value { grid-area: value; font-size: 1.45rem; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.home-kpi-value small { font-size: .78rem; font-weight: 600; color: var(--muted); }
.home-kpi-note { grid-area: note; color: var(--muted); font-size: .75rem; }

.home-movements .list-group-item {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.home-movement-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.home-movement-icon .material-symbols-outlined { font-size: 19px; }
.home-movement-icon.is-in { background: rgba(4, 120, 87, .12); color: #047857; }
.home-movement-icon.is-out { background: rgba(217, 119, 6, .14); color: #B45309; }

.home-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: .85rem;
}

.home-piece {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    min-width: 0;
    color: var(--ink);
    text-decoration: none;
}

.home-piece:hover { color: var(--ink); }
.home-piece:hover .home-piece-photo { border-color: rgba(var(--brand-rgb), .45); }

.home-piece-photo {
    aspect-ratio: 1;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface-3);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: .35rem;
    color: var(--muted);
}

.home-piece-photo img { width: 100%; height: 100%; object-fit: contain; }
.home-piece-photo .material-symbols-outlined { font-size: 36px; }
.home-piece-sku { font-size: .78rem; color: var(--muted); }
.home-piece-name { font-size: .86rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.home-piece-foot { display: flex; flex-direction: column; margin-top: .15rem; }
.home-piece-foot small { font-size: .74rem; }

@media (max-width: 1399.98px) {
    .home-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

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

@media (max-width: 575.98px) {
    .home-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
    .home-action { padding: .8rem; }
    .home-action-copy small { display: none; }
    .home-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
    .home-kpi { grid-template-columns: minmax(0, 1fr); grid-template-areas: "icon" "label" "value" "note"; row-gap: .1rem; padding: .8rem; }
    .home-kpi-icon { width: 34px; height: 34px; border-radius: 10px; margin-bottom: .35rem; }
    .home-kpi-icon .material-symbols-outlined { font-size: 20px; }
    .home-kpi-value { font-size: 1.15rem; }
    .home-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .home-chart .mini-chart { height: 120px; }
    .home-search { padding: .9rem 1rem; }
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
}

.kpi-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.kpi-label {
    color: var(--muted);
    font-size: .85rem;
}

@media (max-width: 575.98px) {
    .kpi { gap: .65rem; }
    .kpi-icon { width: 38px; height: 38px; border-radius: 11px; }
    .kpi-value { font-size: 1.3rem; }
    .kpi-label { font-size: .78rem; line-height: 1.25; }
}

/* Gráfica de barras del tablero, sin librerías externas. */
.mini-chart {
    display: grid;
    grid-template-columns: repeat(14, minmax(0, 1fr));
    align-items: end;
    gap: 6px;
    height: 170px;
}

.mini-chart .bar-group {
    display: flex;
    align-items: end;
    justify-content: center;
    gap: 2px;
    height: 100%;
}

.mini-chart .bar {
    width: 45%;
    min-height: 2px;
    border-radius: 4px 4px 1px 1px;
}

.mini-chart .bar.in {
    background: var(--brand);
}

.mini-chart .bar.out {
    background: #F59E0B;
}

.mini-chart-labels {
    display: grid;
    grid-template-columns: repeat(14, minmax(0, 1fr));
    gap: 6px;
    font-size: .68rem;
    color: var(--muted);
    text-align: center;
    margin-top: .35rem;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    display: inline-block;
}

/* ---------------------------------------------------------------- Estados */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-pill::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.status-Labeled { background: #EEF2FF; color: #4338CA; }
.status-InStock { background: #ECFDF5; color: #047857; }
.status-Shipped { background: #F1F5F9; color: #475569; }
.status-Voided { background: #FEF2F2; color: #B91C1C; }
.status-Sent { background: #ECFDF5; color: #047857; }
.status-Generated { background: #EFF6FF; color: #1D4ED8; }
.status-Failed { background: #FEF2F2; color: #B91C1C; }
.status-active { background: #ECFDF5; color: #047857; }
.status-inactive { background: #F1F5F9; color: #475569; }

.qty-in { color: #047857; font-weight: 600; }
.qty-out { color: #B45309; font-weight: 600; }

.mono {
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: .92em;
}

/* ---------------------------------------------------------------- Escaneo */
.scan-panel {
    border: 2px dashed rgba(var(--brand-rgb), .35);
    background: rgba(var(--brand-rgb), .03);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.scan-input {
    font-size: 1.6rem;
    font-weight: 600;
    letter-spacing: .04em;
    padding: .7rem 1rem .7rem 3.3rem;
    border-radius: 12px;
}

.scan-input-wrapper {
    position: relative;
}

.scan-input-wrapper > .material-symbols-outlined {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 30px;
    color: var(--brand-text);
}

.camera-panel {
    min-width: 0;
}

.camera-panel #qrReader {
    width: 100%;
    max-width: 560px;
    overflow: hidden;
}

.camera-panel #qrReader video {
    max-width: 100%;
}

.pair-qr-reader {
    width: 100%;
    max-width: 560px;
    overflow: hidden;
    border-radius: 12px;
}

.pair-qr-reader video {
    max-width: 100%;
}

/* Etiqueta doble por QR: las dos mitades de la etiqueta. */
.pair-slot {
    height: 100%;
    padding: .6rem;
    border: 2px dashed var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    transition: border-color .12s ease, box-shadow .12s ease;
}

.pair-slot.is-filled {
    border-style: solid;
}

.pair-slot.is-target {
    border-color: var(--brand);
    box-shadow: 0 0 0 .2rem rgba(var(--brand-rgb), .15);
}

.pair-slot-side {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
}

.pair-slot-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .15rem;
    width: 100%;
    min-height: 150px;
    padding: .4rem;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--ink);
    text-align: center;
}

.pair-slot-body:hover {
    background: rgba(var(--brand-rgb), .05);
}

.pair-slot-empty-icon {
    font-size: 40px;
    color: var(--muted);
}

.pair-slot-image {
    width: 64px;
    height: 64px;
    margin-bottom: .2rem;
    border-radius: 10px;
    object-fit: cover;
    background: var(--surface-3);
}

.pair-slot-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.25;
}

.camera-device-select {
    flex: 1 1 180px;
    max-width: 280px;
}

.scan-log {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    max-height: 60vh;
    overflow-y: auto;
}

.scan-log li {
    display: flex;
    gap: .75rem;
    align-items: flex-start;
    padding: .7rem .9rem;
    border-radius: 11px;
    border: 1px solid var(--line);
    background: var(--surface);
    animation: scan-in .25s ease;
}

.scan-log li.ok { border-left: 4px solid #10B981; }
.scan-log li.error { border-left: 4px solid #EF4444; background: #FFFBFB; }
.scan-log li .material-symbols-outlined { font-size: 22px; }
.scan-log li.ok .material-symbols-outlined { color: #10B981; }
.scan-log li.error .material-symbols-outlined { color: #EF4444; }

@keyframes scan-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
}

.flash-ok { animation: flash-ok .6s ease; }
.flash-error { animation: flash-error .6s ease; }

@keyframes flash-ok { 0% { box-shadow: 0 0 0 .35rem rgba(16, 185, 129, .45); } 100% { box-shadow: none; } }
@keyframes flash-error { 0% { box-shadow: 0 0 0 .35rem rgba(239, 68, 68, .5); } 100% { box-shadow: none; } }

/* ---------------------------------------------------------------- Varios */
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--muted);
}

.empty-state .material-symbols-outlined {
    font-size: 44px;
    color: #8491A5;
}

.definition-list dt {
    font-weight: 500;
    color: var(--muted);
    font-size: .82rem;
}

.definition-list dd {
    margin-bottom: .8rem;
    font-weight: 500;
}

.timeline {
    list-style: none;
    padding: 0;
    margin: 0;
    position: relative;
}

.timeline::before {
    content: "";
    position: absolute;
    left: 15px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--line);
}

.timeline li {
    position: relative;
    padding: 0 0 1.1rem 2.75rem;
}

.timeline .dot {
    position: absolute;
    left: 0;
    top: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 2px solid var(--line);
}

.timeline .dot .material-symbols-outlined {
    font-size: 17px;
}

textarea.zpl-editor {
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: .85rem;
    line-height: 1.5;
    min-height: 460px;
    tab-size: 2;
    background: #0B1220;
    color: #E2E8F0;
    border-radius: 12px;
}

textarea.zpl-editor:focus {
    background: #0B1220;
    color: #E2E8F0;
}

.label-preview {
    background: repeating-conic-gradient(#F1F5F9 0% 25%, #fff 0% 50%) 50% / 18px 18px;
    border: 1px dashed var(--line);
    border-radius: 12px;
    min-height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.label-preview img {
    max-width: 100%;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .18);
    background: #fff;
}

.placeholder-chip {
    display: inline-block;
    font-family: ui-monospace, Consolas, monospace;
    font-size: .76rem;
    padding: .15rem .45rem;
    margin: 0 .25rem .35rem 0;
    border-radius: 6px;
    background: var(--surface-3);
    border: 1px solid var(--line);
    cursor: pointer;
}

.placeholder-chip:hover {
    background: rgba(var(--brand-rgb), .1);
    border-color: rgba(var(--brand-rgb), .4);
}

.item-thumb {
    width: 40px;
    height: 40px;
    border-radius: 9px;
    object-fit: cover;
    background: var(--surface-3);
    border: 1px solid var(--line);
}

.item-thumb-lg {
    width: 100%;
    max-width: 220px;
    aspect-ratio: 1;
    border-radius: 14px;
    object-fit: cover;
    background: var(--surface-3);
    border: 1px solid var(--line);
}

/* ---------------------------------------------------------------- Cambios de precio */
.price-delta {
    display: inline-flex;
    align-items: center;
    gap: .2rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.price-delta .material-symbols-outlined {
    font-size: 18px;
}

.price-delta-up { color: #B91C1C; }
.price-delta-down { color: #047857; }
.price-delta-initial,
.price-delta-removed { color: var(--muted); font-weight: 500; }

.price-delta-percent {
    font-weight: 500;
    opacity: .85;
}

.price-row-new > td {
    background: var(--highlight-bg);
}

.price-timeline-item {
    padding: .75rem 1.1rem;
    border-bottom: 1px solid var(--line);
}

.price-timeline-item:last-child {
    border-bottom: 0;
}

.price-bell-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #DC2626;
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--surface);
}

.price-bell-menu {
    width: min(380px, calc(100vw - 24px));
    border-radius: 12px;
    overflow: hidden;
}

.price-bell-list {
    max-height: min(420px, 60vh);
    overflow-y: auto;
}

.price-bell-item {
    display: flex;
    align-items: flex-start;
    gap: .7rem;
    padding: .65rem 1rem;
    color: var(--ink);
    text-decoration: none;
    border-bottom: 1px solid var(--line);
}

.price-bell-item:last-child {
    border-bottom: 0;
}

.price-bell-item:hover {
    background: rgba(var(--brand-rgb), .05);
}

.price-bell-item.is-new {
    background: var(--highlight-bg);
    box-shadow: inset 3px 0 0 #F59E0B;
}

@media (max-width: 575.98px) {
    /* En el celular el menú de la campana ocupa el ancho de la pantalla. */
    .price-bell {
        position: static;
    }

    .price-bell-menu {
        left: 12px !important;
        right: 12px !important;
        width: auto;
        transform: none !important;
        top: 100% !important;
    }

    .app-version {
        display: none;
    }
}

.permission-group {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 1rem 1.1rem;
    height: 100%;
}

/* ---------------------------------------------------------------- Tablas */
.table {
    --bs-table-hover-bg: rgba(var(--brand-rgb), .035);
    margin-bottom: 0;
}

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

.table td {
    vertical-align: middle;
}

div.dt-container .dt-search input,
div.dt-container .dt-length select {
    border-radius: 9px;
}

.card-body,
div.dt-container,
div.dt-container .dt-layout-row,
div.dt-container .dt-layout-cell {
    min-width: 0;
}

div.dt-container,
div.dt-container .dt-scroll {
    max-width: 100%;
}

div.dt-buttons.btn-group {
    flex-wrap: wrap;
    gap: .35rem;
}

div.dt-buttons.btn-group > .btn {
    flex: 0 0 auto;
    border-radius: 8px !important;
}

div.dt-container div.dt-paging .page-item.active .page-link {
    background: var(--brand);
    border-color: var(--brand);
}

/* Sin scroll de DataTables (celular girado): la tabla se desplaza dentro de su tarjeta. */
div.dt-container .dt-layout-table > div {
    overflow-x: auto;
}

/* ---- Celular: barra de búsqueda arriba y cada renglón como tarjeta ---- */
@media (max-width: 767.98px) {
    div.dt-container > .row:not(.dt-layout-table) > div {
        text-align: left;
    }

    div.dt-container > .row:not(.dt-layout-table) > .dt-layout-end {
        order: -1;
    }

    div.dt-container .dt-layout-start {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: .5rem;
    }

    div.dt-container .dt-search,
    div.dt-container .dt-search input {
        width: 100% !important;
        margin-left: 0 !important;
    }

    div.dt-container .dt-search input {
        min-height: 42px;
    }

    div.dt-container .dt-info,
    div.dt-container .dt-paging {
        text-align: center;
    }

    table.dt-cards,
    table.dt-cards > tbody,
    table.dt-cards > tbody > tr,
    table.dt-cards > tbody > tr > td {
        display: block;
        width: 100% !important;
    }

    /* El encabezado queda como fila de "chips" para ordenar. */
    table.dt-cards > thead {
        display: block;
    }

    table.dt-cards > thead > tr {
        display: flex;
        gap: .4rem;
        overflow-x: auto;
        padding-bottom: .6rem;
        scrollbar-width: none;
    }

    table.dt-cards > thead > tr > th {
        flex: 0 0 auto;
        width: auto !important;
        border: 1px solid var(--line);
        border-radius: 999px;
        padding-top: .3rem;
        padding-bottom: .3rem;
        background: var(--surface);
    }

    table.dt-cards > thead > tr > th.dt-orderable-none {
        display: none;
    }

    table.dt-cards > tbody > tr {
        position: relative;
        border: 1px solid var(--line);
        border-radius: 12px;
        padding: .55rem .8rem;
        margin-bottom: .6rem;
        background: var(--surface);
        box-shadow: var(--shadow);
    }

    table.dt-cards > tbody > tr > td {
        position: relative;
        min-height: 1.9rem;
        padding: .3rem 0 .3rem 40%;
        border: 0;
        text-align: right !important;
        white-space: normal;
        overflow-wrap: anywhere;
        box-shadow: none !important;
    }

    table.dt-cards > tbody > tr > td::before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        top: .45rem;
        width: 38%;
        text-align: left;
        font-size: .72rem;
        font-weight: 600;
        letter-spacing: .04em;
        text-transform: uppercase;
        color: var(--muted);
    }

    /* Celdas sin título (imagen, casillas) y la de acciones van sin etiqueta. */
    table.dt-cards > tbody > tr > td[data-label=""],
    table.dt-cards > tbody > tr > td[data-label="Acciones"],
    table.dt-cards > tbody > tr > td.dt-empty {
        padding-left: 0;
        min-height: 0;
    }

    table.dt-cards > tbody > tr > td[data-label=""]::before,
    table.dt-cards > tbody > tr > td[data-label="Acciones"]::before,
    table.dt-cards > tbody > tr > td.dt-empty::before {
        content: none;
    }

    table.dt-cards > tbody > tr > td[data-label=""] {
        text-align: left !important;
    }

    table.dt-cards > tbody > tr > td[data-label="Acciones"] {
        margin-top: .35rem;
        padding-top: .5rem;
        border-top: 1px solid var(--line);
    }

    table.dt-cards > tbody > tr > td.dt-empty {
        text-align: center !important;
        color: var(--muted);
    }
}

/* En pantallas táctiles iOS acerca la página al enfocar un campo con letra menor a
   16px (y no la regresa). Los campos usan 16px ahí; el placeholder puede ser menor. */
@media (pointer: coarse) {
    .form-control,
    .form-select,
    .select2-container .select2-selection,
    .select2-container .select2-search__field,
    div.dt-container .dt-search input,
    div.dt-container .dt-length select {
        font-size: 16px !important;
    }

    .topbar-search input::placeholder {
        font-size: .82rem;
    }
}

.select2-container--bootstrap-5 .select2-selection {
    border-radius: 10px;
    min-height: calc(1.5em + .75rem + 2px);
}

.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: rgba(var(--brand-rgb), .55);
    box-shadow: 0 0 0 .2rem rgba(var(--brand-rgb), .18);
}

.select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option.select2-results__option--highlighted {
    background-color: rgba(var(--brand-rgb), .1);
    color: var(--ink);
}

/* ---------------------------------------------------------------- Autenticación */
.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
}

@media (max-width: 991.98px) {
    .auth-shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .auth-hero {
        display: none !important;
    }
}

.auth-hero {
    background:
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, .14), transparent 45%),
        radial-gradient(circle at 80% 80%, rgba(14, 165, 233, .35), transparent 50%),
        linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 45%, #0B1220));
    color: #fff;
    padding: 3.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.auth-hero h1 {
    font-size: 2.3rem;
    font-weight: 800;
    letter-spacing: -.02em;
    line-height: 1.12;
}

.auth-feature {
    display: flex;
    gap: .8rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.auth-feature .material-symbols-outlined {
    background: rgba(255, 255, 255, .16);
    border-radius: 10px;
    padding: .4rem;
}

.auth-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    padding: 2rem 1rem;
    background: var(--surface);
}

.auth-version {
    color: var(--muted);
    font-size: .75rem;
    font-variant-numeric: tabular-nums;
}

.auth-card {
    width: 100%;
    max-width: 420px;
}

.business-option {
    display: block;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    padding: .85rem 1rem;
    cursor: pointer;
    height: 100%;
    transition: border-color .12s ease, background-color .12s ease;
}

.business-option:hover {
    border-color: rgba(var(--brand-rgb), .5);
}

.btn-check:checked + .business-option {
    border-color: var(--brand);
    background: rgba(var(--brand-rgb), .06);
}

/* ---------------------------------------------------------------- Overlay de carga */
.page-loading {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: var(--overlay-bg);
    z-index: 3000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .15s ease, visibility .15s ease;
}

.page-loading.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.page-loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .9rem;
    color: var(--ink);
    font-weight: 600;
}

/* Indicador de carga: el logo de la aplicación girando despacio. */
.loading-mark {
    width: 72px;
    height: 72px;
    flex: none;
    animation: loading-mark-spin 3.6s linear infinite;
}

.loading-mark-sm {
    width: 1.25rem;
    height: 1.25rem;
}

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

@media (prefers-reduced-motion: reduce) {
    .loading-mark { animation-duration: 12s; }
}

@media print {
    .app-sidebar,
    .app-topbar,
    .page-header .btn,
    .no-print {
        display: none !important;
    }

    .app-content {
        padding: 0;
    }

    .card {
        box-shadow: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}

/* ---------------------------------------------------------------- Foto de perfil */
.user-avatar {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    border-radius: 50%;
    overflow: hidden;
    color: #fff;
    font-weight: 700;
    background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 55%, #0EA5E9));
}

.user-avatar-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
}

.user-avatar.has-photo .user-avatar-photo {
    opacity: 1;
}

.user-avatar.has-photo .user-avatar-initial {
    visibility: hidden;
}

.avatar-editor-canvas {
    width: 100%;
    max-width: 320px;
    aspect-ratio: 1;
    border-radius: 12px;
    background: var(--surface-3);
    cursor: grab;
    touch-action: none;
}

.avatar-editor-canvas:active {
    cursor: grabbing;
}

/* ---------------------------------------------------------------- Selector de tema */
.theme-switch {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .25rem;
    padding: .2rem;
    border-radius: 10px;
    background: var(--surface-3);
}

.theme-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .1rem;
    padding: .35rem .25rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font-size: .74rem;
    font-weight: 600;
}

.theme-option .material-symbols-outlined {
    font-size: 19px;
}

.theme-option:hover {
    color: var(--ink);
}

.theme-option.active {
    background: var(--surface);
    color: var(--brand-text);
    box-shadow: 0 1px 3px rgba(15, 23, 42, .15);
}

/* ================================================================ Tema oscuro
   Todo el color sale de las variables: aquí se redefinen para fondo oscuro y se
   corrigen los componentes de Bootstrap / Select2 / SweetAlert que traen colores
   claros fijos. Cada texto se eligió con contraste de al menos 4.5:1 (WCAG AA)
   sobre las superficies oscuras (--surface #131C2E y --canvas #0B1120).
   ================================================================ */
[data-bs-theme="dark"] {
    --brand-text: var(--brand-text-dark, #A5B4FC);
    --brand-text-rgb: var(--brand-text-dark-rgb, 165, 180, 252);
    --ink: #E5E9F0;
    --muted: #9AA8BC;
    --line: #273449;
    --canvas: #0B1120;
    --surface: #131C2E;
    --surface-2: #182339;
    --surface-3: #1E2A42;
    --topbar-bg: rgba(19, 28, 46, .9);
    --overlay-bg: rgba(11, 17, 32, .9);
    --highlight-bg: rgba(245, 158, 11, .13);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 4px 16px rgba(0, 0, 0, .25);
    --input-bg: #0E1627;
    --input-border: #33415A;
    --bs-body-bg: var(--surface);
    --bs-body-bg-rgb: 19, 28, 46;
    --bs-secondary-bg: var(--surface-2);
    --bs-tertiary-bg: var(--surface-3);
    --bs-emphasis-color: #F8FAFC;
    --bs-secondary-color: rgba(229, 233, 240, .75);
    --bs-tertiary-color: rgba(229, 233, 240, .6);
    --bs-heading-color: var(--ink);
    color-scheme: dark;
}

/* Colores de texto de Bootstrap que no llegan a 4.5:1 sobre fondos gris claro o tintados
   (medido en todas las pantallas): se usan tonos un poco más oscuros. En oscuro, abajo. */
.text-secondary { color: var(--muted) !important; }
.text-danger { color: #B91C1C !important; }
.text-success { color: #047857 !important; }
.btn-outline-secondary { --bs-btn-color: var(--muted); }
:root { --bs-code-color: #B4236E; }
[data-bs-theme="dark"] { --bs-code-color: #F0A5C8; }

[data-bs-theme="dark"] .text-primary { color: var(--brand-text) !important; }
[data-bs-theme="dark"] .text-success { color: #34D399 !important; }
[data-bs-theme="dark"] .text-danger { color: #F87171 !important; }
[data-bs-theme="dark"] .text-warning { color: #FBBF24 !important; }
[data-bs-theme="dark"] .text-dark { color: var(--ink) !important; }
[data-bs-theme="dark"] .bg-light { background-color: var(--surface-2) !important; color: var(--ink); }
[data-bs-theme="dark"] .bg-white { background-color: var(--surface) !important; }
[data-bs-theme="dark"] .text-bg-light { background-color: var(--surface-3) !important; color: var(--ink) !important; }

/* Botones claros y delineados: en Bootstrap tienen colores fijos pensados para fondo blanco. */
[data-bs-theme="dark"] .btn-light {
    --bs-btn-color: var(--ink);
    --bs-btn-bg: var(--surface-2);
    --bs-btn-border-color: var(--surface-2);
    --bs-btn-hover-color: #FFFFFF;
    --bs-btn-hover-bg: var(--surface-3);
    --bs-btn-hover-border-color: var(--surface-3);
    --bs-btn-active-color: #FFFFFF;
    --bs-btn-active-bg: #26344F;
    --bs-btn-active-border-color: #26344F;
    --bs-btn-disabled-color: var(--muted);
    --bs-btn-disabled-bg: var(--surface-2);
    --bs-btn-disabled-border-color: var(--surface-2);
}

[data-bs-theme="dark"] .btn-outline-secondary {
    --bs-btn-color: var(--ink);
    --bs-btn-border-color: #3B4A63;
    --bs-btn-hover-color: #FFFFFF;
    --bs-btn-hover-bg: var(--surface-3);
    --bs-btn-hover-border-color: #4B5B77;
    --bs-btn-active-color: #FFFFFF;
    --bs-btn-active-bg: var(--surface-3);
    --bs-btn-active-border-color: #4B5B77;
    --bs-btn-disabled-color: var(--muted);
    --bs-btn-disabled-border-color: var(--line);
}

[data-bs-theme="dark"] .btn-outline-primary {
    --bs-btn-border-color: var(--brand-text);
}

[data-bs-theme="dark"] .btn-outline-danger {
    --bs-btn-color: #F87171;
    --bs-btn-border-color: #F87171;
}

[data-bs-theme="dark"] .btn-outline-success {
    --bs-btn-color: #34D399;
    --bs-btn-border-color: #34D399;
}

/* Campos de captura: un poco más oscuros que la tarjeta para distinguirlos. */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: var(--input-bg);
    border-color: var(--input-border);
    color: var(--ink);
}

[data-bs-theme="dark"] .form-control::placeholder {
    color: #8392A8;
}

[data-bs-theme="dark"] .form-control:disabled,
[data-bs-theme="dark"] .form-select:disabled {
    background-color: var(--surface-2);
    color: var(--muted);
}

[data-bs-theme="dark"] .form-check-input {
    background-color: var(--input-bg);
    border-color: #4B5B77;
}

[data-bs-theme="dark"] .form-check-input:checked {
    background-color: var(--brand);
    border-color: var(--brand);
}

[data-bs-theme="dark"] .input-group-text {
    background-color: var(--surface-2);
    border-color: var(--input-border);
    color: var(--ink);
}

[data-bs-theme="dark"] .topbar-search input {
    background: var(--canvas);
}

/* Encabezados y módulos: el color de cada sección se aclara sobre fondo oscuro. */
[data-bs-theme="dark"] .module-context {
    color: color-mix(in srgb, var(--module-color, var(--muted)) 50%, #FFFFFF);
}

[data-bs-theme="dark"] .module-badge,
[data-bs-theme="dark"] .kpi-icon {
    background: color-mix(in srgb, var(--tone, var(--brand)) 22%, transparent);
    color: color-mix(in srgb, var(--tone, var(--brand)) 50%, #FFFFFF);
}

[data-bs-theme="dark"] .tone-text {
    color: color-mix(in srgb, var(--tone, var(--brand)) 50%, #FFFFFF);
}

[data-bs-theme="dark"] .home-action-icon,
[data-bs-theme="dark"] .home-kpi-icon {
    background: color-mix(in srgb, var(--action-color, var(--tone)) 22%, transparent);
    color: color-mix(in srgb, var(--action-color, var(--tone)) 55%, #fff);
}

[data-bs-theme="dark"] .home-movement-icon.is-in { background: rgba(52, 211, 153, .16); color: #34D399; }
[data-bs-theme="dark"] .home-movement-icon.is-out { background: rgba(251, 191, 36, .16); color: #FBBF24; }

[data-bs-theme="dark"] .theme-option.active {
    background: var(--surface-2);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
}

/* Estados y cantidades */
[data-bs-theme="dark"] .status-Labeled { background: rgba(99, 102, 241, .2); color: #C7D2FE; }
[data-bs-theme="dark"] .status-InStock,
[data-bs-theme="dark"] .status-Sent,
[data-bs-theme="dark"] .status-active { background: rgba(16, 185, 129, .16); color: #6EE7B7; }
[data-bs-theme="dark"] .status-Shipped,
[data-bs-theme="dark"] .status-inactive { background: rgba(148, 163, 184, .16); color: #CBD5E1; }
[data-bs-theme="dark"] .status-Voided,
[data-bs-theme="dark"] .status-Failed { background: rgba(239, 68, 68, .16); color: #FCA5A5; }
[data-bs-theme="dark"] .status-Generated { background: rgba(59, 130, 246, .18); color: #BFDBFE; }
[data-bs-theme="dark"] .qty-in { color: #34D399; }
[data-bs-theme="dark"] .qty-out { color: #FBBF24; }
[data-bs-theme="dark"] .price-delta-up { color: #F87171; }
[data-bs-theme="dark"] .price-delta-down { color: #34D399; }

[data-bs-theme="dark"] .scan-log li.error { background: rgba(239, 68, 68, .08); }
[data-bs-theme="dark"] .empty-state .material-symbols-outlined { color: #6B7A90; }
[data-bs-theme="dark"] .label-preview {
    background: repeating-conic-gradient(#1E2A42 0% 25%, #172238 0% 50%) 50% / 18px 18px;
}

/* Tablas: Bootstrap usa blanco puro en oscuro; aquí el mismo tono del resto del texto. */
[data-bs-theme="dark"] .table {
    --bs-table-color: var(--ink);
    --bs-table-bg: transparent;
    --bs-table-border-color: var(--line);
    --bs-table-hover-color: var(--ink);
    --bs-table-hover-bg: rgba(255, 255, 255, .035);
}

/* Select2 (buscadores de artículos) trae blanco fijo. */
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection {
    background-color: var(--input-bg);
    border-color: var(--input-border);
    color: var(--ink);
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection--single {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23dee2e6' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    color: var(--ink);
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered .select2-selection__placeholder,
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option.select2-results__message {
    color: #8392A8;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection__clear {
    filter: invert(1) grayscale(100%) brightness(160%);
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown {
    background-color: var(--surface);
    border-color: var(--input-border);
    color: var(--ink);
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown .select2-search .select2-search__field {
    background-color: var(--input-bg);
    border-color: var(--input-border);
    color: var(--ink);
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option {
    color: var(--ink);
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option.select2-results__option--highlighted {
    background-color: rgba(var(--brand-rgb), .3);
    color: #FFFFFF;
}

/* SweetAlert2: su tema oscuro con los mismos colores de la aplicación. */
[data-swal2-theme="dark"][data-swal2-theme] {
    --swal2-dark-theme-black: #131C2E;
    --swal2-dark-theme-white: #E5E9F0;
    --swal2-footer-border-color: #273449;
}

/* Al imprimir siempre en claro: los fondos oscuros gastan tinta y no se leen en papel. */
@media print {
    [data-bs-theme="dark"] {
        --ink: #0F172A;
        --muted: #5B6A7F;
        --line: #E2E8F0;
        --canvas: #FFFFFF;
        --surface: #FFFFFF;
        --surface-2: #F8FAFC;
        --surface-3: #F1F5F9;
        --bs-body-bg: #FFFFFF;
        color-scheme: light;
    }
}
/* ================================================================ Códigos de Nice
   Selector Automático / Manual (_NiceCodeEntry): en Manual se teclean el código del
   lateral (1) y el de arriba (2) de la etiqueta, con una ilustración de dónde está cada uno. */
.nice-codes {
    margin-top: .85rem;
    /* Se acomoda al ancho de su columna (en Etiqueta doble es angosta), no al de la ventana. */
    container-type: inline-size;
}

/* Controles de escaneo ocultos en modo Manual (le gana a .d-flex y .d-none de Bootstrap). */
[data-nice-auto].nice-codes-off {
    display: none !important;
}

.nice-codes-switch {
    display: flex;
    width: 100%;
}

.nice-codes-switch .btn {
    flex: 1 1 0;
    font-size: .85rem;
}

.nice-codes-manual {
    margin-top: .75rem;
    padding: .9rem;
    border: 1px dashed var(--line);
    border-radius: 12px;
    background: var(--surface-2);
}

.nice-codes-grid {
    display: grid;
    gap: 1rem;
    align-items: start;
}

.nice-codes-grid .nice-label-figure svg {
    max-width: 210px;
}

@container (min-width: 470px) {
    .nice-codes-grid {
        grid-template-columns: minmax(0, 200px) minmax(0, 1fr);
    }
}

@container (max-width: 359.98px) {
    .nice-codes-extra {
        display: none;
    }
}

.nice-label-figure {
    margin: 0;
    text-align: center;
}

.nice-label-figure svg {
    width: 100%;
    max-width: 230px;
    height: auto;
}

.nice-code-1 {
    color: #1D4ED8;
}

.nice-code-2 {
    color: #B45309;
}

.nice-code-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-right: .25rem;
    border-radius: 50%;
    color: #FFFFFF;
    font-size: .72rem;
    font-weight: 700;
    vertical-align: text-bottom;
}

.nice-code-badge.is-1 {
    background: #1D4ED8;
}

.nice-code-badge.is-2 {
    background: #B45309;
}

.nice-code-badge.is-sku {
    width: auto;
    padding: 0 .4rem;
    border-radius: 10px;
}

.nice-codes-notice {
    margin-top: .75rem;
    padding: .55rem .75rem;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
}

.nice-codes-notice.is-warning {
    background: var(--highlight-bg);
    border-color: rgba(180, 83, 9, .35);
}

.nice-codes-notice.is-error {
    border-color: rgba(185, 28, 28, .4);
    color: #B91C1C;
}

[data-bs-theme="dark"] .nice-code-1 {
    color: #93C5FD;
}

[data-bs-theme="dark"] .nice-code-2 {
    color: #FBBF24;
}

[data-bs-theme="dark"] .nice-codes-notice.is-error {
    color: #F87171;
}

/* Botón con ojo para ver la contraseña (site.js): mismo borde que el campo junto al que va. */
.password-toggle {
    --bs-btn-border-color: var(--bs-border-color);
    --bs-btn-hover-color: var(--ink);
    --bs-btn-hover-bg: var(--bs-tertiary-bg);
    --bs-btn-hover-border-color: var(--bs-border-color);
    --bs-btn-active-color: var(--ink);
    --bs-btn-active-bg: var(--bs-tertiary-bg);
    --bs-btn-active-border-color: var(--bs-border-color);
    padding-inline: .7rem;
}

.password-toggle .material-symbols-outlined { font-size: 20px; }

[data-bs-theme="dark"] .password-toggle {
    --bs-btn-border-color: var(--input-border);
    --bs-btn-hover-border-color: var(--input-border);
    --bs-btn-active-border-color: var(--input-border);
}
