/* css/estilos.css */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
    --sidebar-width: 248px;
    /* Magenta de acción y de texto: el tono de marca (#ea0b80) queda en 4,32:1
       con texto blanco y por debajo de 4,5:1 sobre los rosados suaves del panel.
       Con #c00a6b el blanco llega a 6,0:1 y el texto rosa a 5,1:1 (WCAG AA). */
    --primary-color: #c00a6b;
    --secondary-color: #7c3aed;
    --accent-color: #c00a6b;
    --success-color: #15803d;
    /* Verde de estado como TEXTO: el tono 600 (#059669) se quedaba en 3,2:1
       sobre los fondos verdes suaves del panel. En oscuro usa el tono claro. */
    --ok-ink: #047857;
    /* Ámbar de aviso como texto: en oscuro el tono 700 no se lee. */
    --warn-ink: #b45309;
    --danger-color: #b91c1c;
    --text-color: #191c21;
    --text-muted: #5b6270;
    --bg-color: #f8f9fa;
    --card-color: #ffffff;
    --card-bg: #ffffff;
    --surface-color: #ffffff;
    --surface-overlay: #f8f9fa;
    --surface-shadow: 0 18px 40px rgba(25, 28, 33, 0.06);
    --border-color: #e2e5eb;
    --sidebar-color: #ffffff;
    --input-bg: #ffffff;
    --input-bg-focus: #ffffff;
    --surface-2: #f4f5f8;
    --surface-3: #eceef3;
    --surface-raised: #ffffff;
    --bg-gradient-1: rgba(234, 11, 128, 0.04);
    --bg-gradient-2: rgba(124, 58, 237, 0.03);
}

/*
 * Páginas solo-admin (data-admin-only="true"):
 * sin clase .role-admin el contenido del main no se muestra.
 * nucleo.js agrega .role-admin solo tras validar rol admin.
 */
body[data-admin-only="true"]:not(.role-admin) .main-content {
    visibility: hidden !important;
    pointer-events: none !important;
}

body[data-admin-only="true"]:not(.role-admin) .main-content * {
    visibility: hidden !important;
}

/* Elementos con data-role-allowed ocultos por JS */
.role-gate-hidden {
    display: none !important;
}

/*
 * Items del menu lateral que el rol no puede abrir (applyRoleNavigation).
 * Va con clase propia y no con style.display inline: applyRoleContentVisibility
 * corre despues y limpia el display de todo lo que data-role-allowed permite,
 * y asi devolvia a la vista items que el nav ya habia prohibido.
 */
.nav-gate-hidden {
    display: none !important;
}

/*
 * El menu esta escrito completo en el HTML de cada pagina, asi que hasta que
 * termine el chequeo de sesion (una ida y vuelta a la red) una vendedora veia
 * Historiales, Auditoria y Plan de Metricas en pantalla. No abre nada -- el
 * guard de pagina y las policies los frenan -- pero le muestra el mapa del
 * panel de administracion. Arrancan ocultos y los revela el gate de rol.
 */
body:not(.session-verified) .sidebar [data-role-allowed] {
    display: none !important;
}

/*
 * Velo de autenticación: hasta que nucleo.js verifica sesión + rol y agrega
 * .session-verified al body, el contenido del panel NO se pinta. Antes solo
 * se ocultaba la sidebar (regla de arriba) y el main quedaba a la vista: con
 * un token vencido, o entrando a una página de rol superior, se veía el
 * esqueleto HTML completo durante el ida-y-vuelta a Supabase; y si nucleo.js
 * no cargaba, quedaba a la vista para siempre. Solo aplica a elementos que
 * existen en páginas del panel (.main-content / #sidebar-root): la tienda,
 * el login, 404, offline y legales no los tienen y no se ven afectadas.
 * pagar.html y calculadora-precios.html (standalone, sin nucleo) tienen su
 * propio velo inline en el <head>.
 */
body:not(.session-verified) .main-content,
body:not(.session-verified) #sidebar-root {
    visibility: hidden !important;
}

/*
 * El atributo nativo [hidden] equivale a `display: none`, pero con la
 * especificidad más baja que existe: cualquier clase que declare
 * `display: flex/grid/block` lo pisa y el elemento se ve igual.
 * Esto ya había obligado a parchear caso por caso en asistencias.css,
 * inventario.css, historial-compartido.css, etc. Con esta regla el
 * atributo vuelve a significar lo que dice en todas las páginas.
 */
[hidden] {
    display: none !important;
}

:root[data-theme='dark'],
[data-theme='dark'],
body[data-theme='dark'] {
    /* Oscuro suavizado: fondo apenas levantado del negro, texto sin blanco
       puro y superficies escalonadas (card → surface-2 → surface-3) para que
       las páginas no mezclen azul marino y violeta sueltos. */
    --bg-color: #111318;
    --card-color: #181b22;
    --card-bg: #181b22;
    --surface-color: #181b22;
    --surface-2: #1f232b;
    --surface-3: #282d37;
    --surface-raised: #1c1f27;
    --surface-overlay: rgba(17, 19, 24, 0.94);
    --surface-shadow: 0 20px 44px rgba(0, 0, 0, 0.5);
    --border-color: #2b303b;
    --sidebar-color: #111318;
    --input-bg: #1c2029;
    --input-bg-focus: #232834;
    --text-color: #e9ebf0;
    --text-muted: #9ca3b0;
    --primary-color: #f0579c;
    --secondary-color: #a78bfa;
    --accent-color: #f0579c;
    --success-color: #34d399;
    --ok-ink: #34d399;
    --warn-ink: #fbbf24;
    --danger-color: #f87171;
    --bg-gradient-1: rgba(244, 63, 142, 0.05);
    --bg-gradient-2: rgba(167, 139, 250, 0.04);
}

/* WhatsApp conserva su oscuro de siempre (se ajustó aparte, imitando al
   original): los tokens nuevos del panel vuelven acá a los valores que tenían
   los colores sueltos que reemplazaron. */
body#page-whatsapp[data-theme='dark'] {
    --bg-color: #0f1115;
    --card-color: #161920;
    --card-bg: #161920;
    --surface-color: #161920;
    --surface-2: #181f35;
    --surface-3: #2d3654;
    --surface-raised: #151b2f;
    --surface-overlay: rgba(15, 17, 21, 0.94);
    --surface-shadow: 0 24px 54px rgba(0, 0, 0, 0.65);
    --border-color: #282d3a;
    --sidebar-color: #0f1115;
    --input-bg: #181d30;
    --input-bg-focus: #1e243c;
    --text-color: #f1f3f7;
    --text-muted: #9199a8;
    --primary-color: #f43f8e;
    --accent-color: #f43f8e;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

html {
    color-scheme: light;
}

body[data-theme='dark'] {
    color-scheme: dark;
}

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background:
        radial-gradient(circle at 10% 8%, var(--bg-gradient-1), transparent 42%),
        radial-gradient(circle at 92% 95%, var(--bg-gradient-2), transparent 46%),
        var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    background-attachment: fixed;
    overflow-x: hidden;
}

/* ─── Loading global (todas las páginas) ─── */
@keyframes cositas-shimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}
@keyframes cositas-spin {
    to { transform: rotate(360deg); }
}

.is-loading-value {
    position: relative;
    display: inline-block;
    min-width: 4.5rem;
    min-height: 1.15em;
    color: transparent !important;
    border-radius: 8px;
    background: linear-gradient(
        90deg,
        rgba(234, 11, 128, 0.08) 0%,
        rgba(234, 11, 128, 0.18) 45%,
        rgba(234, 11, 128, 0.08) 90%
    );
    background-size: 200% 100%;
    animation: cositas-shimmer 1.1s ease-in-out infinite;
    pointer-events: none;
    user-select: none;
}

body[data-theme='dark'] .is-loading-value {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.032) 0%,
        rgba(255, 255, 255, 0.08) 45%,
        rgba(255, 255, 255, 0.032) 90%
    );
    background-size: 200% 100%;
}

.is-loading-block {
    position: relative;
    min-height: 3.5rem;
    pointer-events: none;
}

.is-loading-section {
    position: relative;
}

.cositas-loading,
.dash-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.cositas-loading__spinner,
.dash-loading__spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(234, 11, 128, 0.20);
    border-top-color: var(--primary-color);
    animation: cositas-spin 0.7s linear infinite;
    flex-shrink: 0;
}

.cositas-loading-row td {
    text-align: center !important;
    vertical-align: middle;
    padding: 28px 12px !important;
}

.cositas-loading-row .cositas-loading {
    padding: 8px;
}

.summary-card.is-loading .summary-card__meta p,
.kpi-card.is-loading .kpi-card__value {
    min-width: 5.5rem;
}

body,
.main-content,
.card,
.modal-content,
.summary-card,
.chart-wrapper,
.help-center__panel,
.help-center__toggle,
.global-search-trigger__button,
.global-search-trigger__collapse,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    transition: background-color 0.24s ease, color 0.24s ease, border-color 0.24s ease, box-shadow 0.24s ease;
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: inherit;
    text-decoration: none;
}

ul {
    margin: 0;
    padding: 0;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.page-header__meta h1 {
    margin: 0;
    font-size: 2rem;
}

.page-header__meta p {
    margin: 6px 0 0;
    color: var(--text-muted);
}

.page-header__actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-chip[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-chip--danger {
    border-color: rgba(132, 89, 232, 0.4);
    background: rgba(132, 89, 232, 0.18);
    color: #b61739;
}

.email-manager__status {
    font-size: 0.82rem;
    color: var(--text-muted);
    min-height: 18px;
    transition: color 0.2s ease;
}

.email-manager__status.is-error {
    color: var(--danger-color);
}

.email-manager__status.is-success {
    color: var(--success-color);
}

.email-manager__status.is-info {
    color: var(--primary-color);
}

/* .email-manager__list / __item: la lista de destinatarias ahora reutiliza
   .account-manager__user-list / .account-manager__user (mismo look que
   Gestión de Equipo). El wrapper de cada ítem sigue usando estas clases. */
.email-manager__details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.email-manager__badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.email-manager__badge--inactive {
    background: rgba(132, 89, 232, 0.18);
    color: #b61739;
}

.email-manager__meta {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.email-manager__cta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
}

.email-manager__empty {
    font-size: 0.9rem;
}

.email-manager__hint {
    margin-top: 12px;
    font-size: 0.85rem;
    line-height: 1.5;
}

/* "Destinatarias de reportes" reutiliza .account-manager / __sidebar / __details
   (mismo layout que Gestión de Equipo). La sección de agregar y el workspace
   se apilan verticalmente dentro de .account-manager__details. */

.email-manager__section-label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    margin: 0 0 10px;
}

.email-manager__content {
    flex: none;
    padding-bottom: 4px;
}

.email-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 520px;
}

.email-form__desc {
    margin: 0 0 2px;
    font-size: 0.88rem;
}

.email-form__row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

.email-form__row .form-group {
    margin-bottom: 0;
}

.email-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    cursor: pointer;
}

.email-checkbox input {
    accent-color: var(--primary-color);
}

.input-password-wrapper {
    position: relative;
    display: flex;
}

.input-password-wrapper input {
    flex: 1;
    padding-right: 40px;
}

.btn-toggle-password {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    opacity: 0.6;
    padding: 4px;
    line-height: 1;
}

.pay-scheme-note {
    margin-top: 8px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px dashed rgba(102, 51, 153, 0.35);
    background: rgba(245, 237, 255, 0.7);
    color: #2f2450;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.pay-scheme-note__title {
    margin: 0 0 6px;
    font-weight: 700;
    font-size: 0.92rem;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.pay-scheme-note__summary {
    margin: 0 0 8px;
    font-size: 0.88rem;
    line-height: 1.4;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.pay-scheme-note__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.pay-scheme-note__block {
    background: #fff;
    border: 1px dashed #d7c7ff;
    border-radius: 8px;
    padding: 8px 10px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.pay-scheme-note__subtitle {
    margin: 0 0 4px;
    font-weight: 600;
    font-size: 0.85rem;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.pay-scheme-note ul {
    margin: 0;
    padding-left: 16px;
    line-height: 1.4;
    font-size: 0.85rem;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.pay-scheme-note__amounts {
    color: var(--primary-color, #ea0b80);
}

.account-pay-scheme-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.account-pay-scheme-form select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    text-overflow: ellipsis;
}

.account-pay-scheme-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
}

.account-pay-scheme-actions .form-status {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.btn-toggle-password:hover {
    opacity: 1;
}

body[data-theme='dark'] .email-manager__meta {
    color: #aeb5d9;
}

body[data-theme='dark'] .email-manager__badge--inactive {
    background: rgba(132, 89, 232, 0.26);
    color: #ffb4c4;
}

@media (max-width: 600px) {
    .email-form__row {
        grid-template-columns: 1fr;
    }
}

.alert-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: rgba(255, 221, 87, 0.16);
    color: #705100;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.08);
}

.alert-card__icon {
    font-size: 1.6rem;
    line-height: 1;
}

.alert-card__body {
    flex: 1;
}

.alert-card__title {
    font-weight: 700;
    margin: 0 0 4px;
    font-size: 1.05rem;
}

.alert-card__message {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.4;
}

.alert-card.alert-warn {
    background: rgba(255, 221, 87, 0.18);
    border-color: rgba(255, 221, 87, 0.4);
    color: #5b4300;
}

.alert-card.alert-danger {
    background: rgba(255, 99, 132, 0.18);
    border-color: rgba(255, 99, 132, 0.45);
    color: #71192c;
}

.alert-card.alert-info {
    background: rgba(97, 218, 251, 0.18);
    border-color: rgba(97, 218, 251, 0.45);
    color: #0f3f54;
}

body[data-theme='dark'] .alert-card.alert-warn {
    background: rgba(255, 221, 87, 0.12);
    border-color: rgba(255, 221, 87, 0.38);
    color: #ffe9a0;
}

body[data-theme='dark'] .alert-card.alert-danger {
    background: rgba(255, 99, 132, 0.12);
    border-color: rgba(255, 99, 132, 0.4);
    color: #ffb4c4;
}

.alert-card.alert-warning {
    border-color: #facc15;
    background: #fffbeb;
    color: #5b4300;
}

body[data-theme='dark'] .alert-card.alert-warning {
    background: rgba(250, 204, 21, 0.16);
    border-color: rgba(250, 204, 21, 0.35);
    color: #ffe58a;
}

body[data-theme='dark'] .alert-card.alert-info {
    background: rgba(97, 218, 251, 0.12);
    border-color: rgba(97, 218, 251, 0.35);
    color: #9ae0ff;
}

/* G4: acciones de alerta (no modifica .alert-card base) */
.alert-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin-top: 10px;
    align-items: center;
}

.alert-card__action {
    font-size: 0.85rem;
    font-weight: 700;
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    opacity: 0.95;
}

.alert-card__action:hover {
    opacity: 1;
}

.alert-card__dismiss {
    font-size: 0.78rem;
    font-weight: 500;
    border: none;
    background: transparent;
    color: inherit;
    opacity: 0.7;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    padding: 0;
    font-family: inherit;
    line-height: 1.3;
}

.alert-card__dismiss:hover {
    opacity: 1;
}

.alert-card__dismiss:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
    border-radius: 2px;
}

.main-content {
    margin-left: var(--sidebar-width);
    padding: 30px;
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    background: var(--surface-overlay);
    border-radius: 14px 0 0 14px;
    box-shadow: var(--surface-shadow);
}

.main-header h1 {
    font-size: 2rem;
}

.main-header p {
    color: var(--text-muted);
    margin-top: 5px;
}

.card,
.modal-content {
    background: linear-gradient(140deg, rgba(234, 11, 128, 0.12), rgba(132, 89, 232, 0.08)), var(--card-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 18px;
    margin-top: 16px;
    box-shadow: 0 8px 20px rgba(17, 15, 38, 0.05);
    color: var(--text-color);
    backdrop-filter: blur(18px);
}

body[data-theme='dark'] .modal-content {
    background: linear-gradient(150deg, rgba(234, 11, 128, 0.24), rgba(132, 89, 232, 0.18)), var(--surface-2);
    border-color: var(--border-color);
}

.summary-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.summary-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.7));
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 18px 22px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 14px 40px #0001;
    position: relative;
    overflow: hidden;
}

/* Workspace de destinataria seleccionada: separado del form con borde superior. */
.email-manager__workspace {
    border-top: 1px solid var(--border-color);
    padding-top: 14px;
    display: grid;
    gap: 14px;
}

.email-workspace__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}

.email-workspace__identity {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.email-workspace__selected {
    font-weight: 600;
    font-size: 0.95rem;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-workspace__status {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0;
}

.email-preferences {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 20px;
}

.email-workspace__selector {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.email-workspace__selector-controls {
    display: flex;
    gap: 6px;
    align-items: center;
}

.email-workspace__selector-controls select {
    min-width: 180px;
    max-width: 260px;
}

body[data-theme='dark'] .summary-card {
    background: linear-gradient(135deg, var(--surface-3), var(--surface-3));
    border-color: rgba(255, 255, 255, 0.06);
}

.summary-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top right, rgba(173, 83, 255, 0.16), transparent 45%);
    pointer-events: none;
}

.summary-card__icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-size: 1.6rem;
    font-weight: 700;
    color: #ffffff;
    flex-shrink: 0;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
}

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

.badge-secondary {
    background: var(--secondary-color);
}

.badge-success {
    background: linear-gradient(130deg, #4cc4a3, #36ac8a);
}

.summary-card__meta h3 {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.summary-card__meta p {
    margin: 0;
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary-color);
}

.summary-card__hint {
    display: inline-block;
    margin-top: 6px;
    font-size: 0.82rem;
    color: var(--text-muted);
    background: rgba(173, 83, 255, 0.12);
    padding: 4px 10px;
    border-radius: 999px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    background: rgba(234, 11, 128, 0.16);
    color: var(--primary-color);
    transition: background 0.2s ease, color 0.2s ease;
}

.chip strong {
    font-weight: 700;
}

.chip--accent {
    background: rgba(234, 11, 128, 0.18);
    color: var(--primary-color);
}

.chip--success {
    background: rgba(76, 207, 116, 0.18);
    color: #176b45;
}

.chip--danger {
    background: rgba(132, 89, 232, 0.18);
    color: #b61739;
}

.chip--info {
    background: rgba(112, 153, 255, 0.18);
    color: #3656c9;
}

.chip--warning {
    background: rgba(245, 158, 11, 0.18);
    color: var(--warn-ink);
}

body[data-theme='dark'] .chip--warning {
    background: rgba(245, 158, 11, 0.28);
    color: #fcd34d;
}

.chip--muted {
    background: rgba(23, 22, 34, 0.08);
    color: var(--text-muted);
}

body[data-theme='dark'] .chip {
    background: rgba(234, 11, 128, 0.24);
    color: #d6c8ff;
}

body[data-theme='dark'] .chip--success {
    background: rgba(76, 207, 116, 0.28);
    color: #8ff5c0;
}

body[data-theme='dark'] .chip--danger {
    background: rgba(132, 89, 232, 0.34);
    color: #ffabc8;
}

body[data-theme='dark'] .chip--info {
    background: rgba(112, 153, 255, 0.3);
    color: #b7c8ff;
}

body[data-theme='dark'] .chip--muted {
    background: rgba(255, 255, 255, 0.08);
    color: #aeb5d9;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    background: rgba(128, 128, 128, 0.12);
    color: var(--text-muted);
}

.status--success { background: rgba(34, 197, 94, 0.12); color: #16a34a; }
.status--info { background: rgba(59, 130, 246, 0.12); color: #2563eb; }
.status--muted { background: rgba(128, 128, 128, 0.12); color: var(--text-muted); }

body[data-theme='dark'] .status--success { color: #4ade80; }
body[data-theme='dark'] .status--info { color: #60a5fa; }

.card--split {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.card-panel {
    background: var(--card-color);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 8px 20px #0001;
}

.card-panel__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.card-panel__header .muted {
    margin: 4px 0 0;
    font-size: 0.82rem;
}

.card-panel h3,
.card-panel h2 {
    margin-bottom: 4px;
    font-size: 1rem;
}

.card-panel .muted {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 10px;
}

.caja-history {
    margin-top: 24px;
    padding: 20px;
    border-radius: 18px;
    border: 1px solid rgba(234, 11, 128, 0.18);
    background: linear-gradient(135deg, rgba(234, 11, 128, 0.16), rgba(132, 89, 232, 0.1));
    box-shadow: 0 18px 38px rgba(17, 15, 38, 0.12);
    font-size: 0.88rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.caja-history:hover {
    transform: translateY(-2px);
    box-shadow: 0 24px 48px rgba(17, 15, 38, 0.16);
}

body[data-theme='dark'] .caja-history {
    background: linear-gradient(135deg, rgba(234, 11, 128, 0.26), rgba(132, 89, 232, 0.22));
    border-color: var(--border-color);
    box-shadow: 0 30px 46px rgba(0, 0, 0, 0.38);
}

.sales-summary {
    margin: 12px 0 10px;
    padding: 12px 14px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(234, 11, 128, 0.12), rgba(132, 89, 232, 0.06));
    border: 1px solid rgba(234, 11, 128, 0.14);
    box-shadow: 0 8px 18px rgba(17, 15, 38, 0.08);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

body[data-theme='dark'] .sales-summary {
    background: linear-gradient(135deg, rgba(234, 11, 128, 0.26), rgba(132, 89, 232, 0.2));
    border-color: var(--border-color);
    box-shadow: 0 34px 56px rgba(0, 0, 0, 0.48);
}

.sales-summary__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.sales-summary__chips .chip {
    margin: 0;
}

.sales-summary__chips .chip strong {
    font-weight: 700;
}

@media (max-width: 768px) {
    .sales-summary {
        padding: 10px;
        border-radius: 12px;
    }
}

.link-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: var(--primary-color);
    margin-top: 12px;
    text-decoration: none;
}

button.link-inline {
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    font: inherit;
}

button.link-inline:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.link-inline:hover {
    text-decoration: underline;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

/* display:flex le gana al atributo hidden (p. ej. la contraseña inicial del
   alta de personal, que se oculta cuando se manda invitación). */
.form-group[hidden] {
    display: none;
}

.form-group label {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text-muted);
    letter-spacing: 0.03em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid rgba(234, 11, 128, 0.24);
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(234, 11, 128, 0.12), rgba(132, 89, 232, 0.08));
    color: var(--text-color);
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

textarea {
    min-height: 120px;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(234, 11, 128, 0.55);
    box-shadow: 0 8px 20px rgba(234, 11, 128, 0.18);
    transform: translateY(-1px);
}

input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.form-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
}

.checkbox-inline input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

body[data-theme='dark'] input[type="text"],
body[data-theme='dark'] input[type="email"],
body[data-theme='dark'] input[type="password"],
body[data-theme='dark'] input[type="number"],
body[data-theme='dark'] input[type="date"],
body[data-theme='dark'] select,
body[data-theme='dark'] textarea {
    background: linear-gradient(135deg, var(--surface-3), rgba(43, 48, 72, 0.72));
    border-color: rgba(199, 146, 255, 0.38);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

body[data-theme='dark'] input:focus,
body[data-theme='dark'] select:focus,
body[data-theme='dark'] textarea:focus {
    box-shadow: 0 10px 24px rgba(234, 11, 128, 0.32);
}

.inventory-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 18px;
    background: rgba(255, 255, 255, 0.78);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 12px 26px rgba(17, 15, 38, 0.08);
}

.inventory-table thead {
    background: linear-gradient(135deg, rgba(234, 11, 128, 0.12), rgba(132, 89, 232, 0.08));
}

.inventory-table th,
.inventory-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    font-size: 0.92rem;
}

.inventory-table th {
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.inventory-actions-col,
.inventory-actions-cell {
    text-align: right;
    white-space: nowrap;
}

.inventory-actions-cell .btn {
    min-width: 92px;
}

.inventory-table tbody tr:last-child td {
    border-bottom: none;
}

.inventory-table tbody tr:nth-child(even) {
    background: rgba(234, 11, 128, 0.04);
}

.inventory-table.compact {
    margin-top: 0;
    box-shadow: none;
    background: transparent;
    border-radius: 0;
}

.inventory-table.compact thead {
    background: transparent;
}

.inventory-table.compact th,
.inventory-table.compact td {
    padding: 8px 10px;
}

.inventory-table.compact tbody tr:nth-child(even) {
    background: transparent;
}

.stock-zero {
    background: rgba(220, 38, 38, 0.08);
}
.stock-zero td[data-label="Stock"] {
    color: #b91c1c;
    font-weight: 700;
}
.stock-low {
    background: rgba(132, 89, 232, 0.14) !important;
    color: #b61739;
}

.stock-zero {
    background: rgba(220, 38, 38, 0.10) !important;
}
.stock-zero td[data-label="Stock"],
.stock-zero .stock-low {
    color: #b91c1c;
    font-weight: 700;
}

.text-center {
    text-align: center;
}

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

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.petty-cash-history {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.petty-cash-history__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.petty-cash-history__metrics {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.petty-cash-history__totals {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px 0 12px;
}

.petty-cash-history__totals .chip {
    font-size: 0.85rem;
}

.petty-cash-history__table {
    margin-top: 8px;
}

.petty-cash-history__empty {
    margin-top: 12px;
}

.petty-cash-history__amount {
    font-weight: 600;
}

.petty-cash-history__row[data-sign="out"] .petty-cash-history__amount {
    color: var(--danger-color);
}

.petty-cash-history__row[data-sign="in"] .petty-cash-history__amount {
    color: var(--success-color);
}

.petty-cash-history__reference {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.petty-cash-history__metrics .chip {
    font-size: 0.85rem;
}

@media (max-width: 768px) {
    .petty-cash-history__header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .petty-cash-history__metrics {
        justify-content: flex-start;
    }
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
}

.filter-bar .form-group {
    min-width: 200px;
    flex: 1 1 200px;
}

.filter-bar__actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.filter-bar__actions .btn {
    min-height: 46px;
}

.filter-bar__export {
    flex: 1 1 100%;
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.charts-grid {
    margin-top: 24px;
    display: grid;
    gap: 24px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.card-panel--flush {
    padding: 0;
    box-shadow: none;
    border: none;
    background: transparent;
}

.table-section-title {
    padding: 24px 24px 0 24px;
    margin: 0;
}

.table-wrapper {
    overflow-x: auto;
    padding: 0 24px 24px 24px;
}

.metric-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.metric-list__item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(234, 11, 128, 0.08);
    border: 1px solid rgba(234, 11, 128, 0.12);
    gap: 12px;
}

.metric-list__item--danger {
    background: rgba(132, 89, 232, 0.12);
    border-color: rgba(132, 89, 232, 0.22);
}

.metric-list__main {
    font-weight: 600;
    color: var(--text-color);
}

.metric-list__meta {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.metric-list__value {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 0.95rem;
    text-align: right;
}

.metric-list__value small {
    display: block;
    font-size: 0.74rem;
    color: var(--text-muted);
    font-weight: 500;
}

.metric-list__empty {
    color: var(--text-muted);
    font-size: 0.92rem;
    padding: 12px 0;
}

.metric-list__hint {
    margin: -6px 0 0;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.card-export-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: 12px;
}

.trend-status {
    font-size: 0.82rem;
    color: var(--text-muted);
    align-self: flex-start;
    font-weight: 600;
}

.trend-metric {
    background: rgba(234, 11, 128, 0.08);
    border: 1px solid rgba(234, 11, 128, 0.16);
    border-radius: 14px;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 12px 28px rgba(234, 11, 128, 0.12);
}

.trend-metric__label {
    font-size: 0.76rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
}

.trend-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    background: rgba(23, 22, 34, 0.08);
    color: var(--text-muted);
}

.trend-pill--up {
    background: rgba(76, 207, 116, 0.18);
    color: #176b45;
}

.trend-pill--down {
    background: rgba(132, 89, 232, 0.18);
    color: #b61739;
}

.trend-pill--flat {
    background: rgba(23, 22, 34, 0.08);
    color: var(--text-muted);
}

.trend-insight {
    margin-top: 12px;
    font-size: 0.88rem;
}

body[data-theme='dark'] .trend-metric {
    background: var(--surface-2);
    border-color: var(--border-color);
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.46);
}

body[data-theme='dark'] .trend-pill--flat {
    background: rgba(255, 255, 255, 0.08);
    color: #aeb5d9;
}

body[data-theme='dark'] .trend-pill--up {
    background: rgba(76, 207, 116, 0.28);
    color: #8ff5c0;
}

body[data-theme='dark'] .trend-pill--down {
    background: rgba(132, 89, 232, 0.34);
    color: #ffabc8;
}

body[data-theme='dark'] .trend-status {
    color: #aeb5d9;
}

@media (max-width: 768px) {
    .table-wrapper {
        padding: 0;
    }

    .inventory-table[data-mobile-cards="true"] {
        background: transparent;
        box-shadow: none;
        border-radius: 0;
        overflow: visible;
    }

    .inventory-table[data-mobile-cards="true"] thead {
        display: none;
    }

    .inventory-table[data-mobile-cards="true"] tbody tr {
        display: flex;
        flex-direction: column;
        margin-bottom: 16px;
        border: 1px solid rgba(23, 22, 34, 0.12);
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.94);
        box-shadow: 0 12px 28px rgba(17, 15, 38, 0.08);
        overflow: hidden;
    }

    .inventory-table[data-mobile-cards="true"] tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 16px;
        border: none;
        gap: 12px;
        font-size: 0.98rem;
    }

    .inventory-table[data-mobile-cards="true"] tbody td+td {
        border-top: 1px solid rgba(23, 22, 34, 0.08);
    }

    .inventory-table[data-mobile-cards="true"] tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.78rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--text-muted);
        flex: 0 0 auto;
    }

    .inventory-table[data-mobile-cards="true"] tbody td[data-label="Acciones"] {
        justify-content: flex-start;
    }

    .inventory-table[data-mobile-cards="true"] tbody td[data-label="Acciones"]::before {
        margin-right: 12px;
    }
}

@media (max-width: 768px) {
    body[data-theme='dark'] .inventory-table[data-mobile-cards="true"] tbody tr,
    [data-theme='dark'] .inventory-table[data-mobile-cards="true"] tbody tr {
        background: var(--surface-raised) !important;
        border-color: var(--border-color) !important;
        box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4);
        color: var(--text-color) !important;
    }

    body[data-theme='dark'] .inventory-table[data-mobile-cards="true"] tbody td+td,
    [data-theme='dark'] .inventory-table[data-mobile-cards="true"] tbody td+td {
        border-top-color: var(--border-color) !important;
    }
}

body[data-theme='dark'] .card,
body[data-theme='dark'] .modal-content {
    background: var(--card-color);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: var(--surface-shadow);
}

body[data-theme='dark'] .summary-card__meta p {
    color: #f2f4ff;
}

body[data-theme='dark'] .summary-card__hint {
    background: rgba(255, 255, 255, 0.08);
    color: #eadbff;
}

body[data-theme='dark'] .inventory-table th {
    color: #cdd5f5;
}

body[data-theme='dark'] .inventory-table td {
    color: #f1f5ff;
}

body[data-theme='dark'] .metric-list__item {
    background: rgba(234, 11, 128, 0.18);
    border-color: rgba(234, 11, 128, 0.32);
}

body[data-theme='dark'] .metric-list__item--danger {
    background: rgba(132, 89, 232, 0.24);
    border-color: rgba(132, 89, 232, 0.34);
}

body[data-theme='dark'] .metric-list__value {
    color: #eadbff;
}

body[data-theme='dark'] .metric-list__value small {
    color: #c0c7ef;
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.25s ease;
}

.btn:hover {
    opacity: 0.92;
    transform: translateY(-1px);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.8rem;
}

.btn-icon {
    font-size: 1em;
    line-height: 1;
}

.btn-block {
    width: 100%;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid rgba(23, 22, 34, 0.12);
    padding: 8px 14px;
    font-size: 0.85rem;
}

body[data-theme='dark'] .btn-ghost {
    border-color: rgba(255, 255, 255, 0.12);
    color: var(--text-muted);
}

.btn-ghost:hover {
    background: rgba(23, 22, 34, 0.04);
    color: var(--text-color);
}

.btn-accent {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: #fff;
    box-shadow: 0 14px 32px rgba(234, 11, 128, 0.22);
}

.btn-contrast {
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    color: #fff;
    box-shadow: 0 16px 36px rgba(234, 11, 128, 0.26);
}

.btn-accent:hover,
.btn-contrast:hover {
    box-shadow: 0 18px 40px rgba(234, 11, 128, 0.28);
}

.filter-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.filter-btn {
    background: linear-gradient(135deg, rgba(173, 83, 255, 0.08), rgba(173, 83, 255, 0.18));
    color: var(--text-muted);
    border: 1px solid rgba(173, 83, 255, 0.25);
    border-radius: 999px;
    padding: 10px 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    transform: translateY(-1px);
}

.filter-btn.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: #fff;
    border-color: transparent;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    padding: 16px 18px;
    border-radius: 14px;
    width: min(92vw, 800px);
    max-width: 800px;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    position: relative;
    box-sizing: border-box;
}

body[data-theme='dark'] .modal-content,
[data-theme='dark'] .modal-content {
    background-color: var(--surface-raised) !important;
    border-color: var(--border-color) !important;
    color: var(--text-color) !important;
    color-scheme: dark !important;
}

body[data-theme='dark'] .modal-content input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="reset"]),
body[data-theme='dark'] .modal-content textarea,
body[data-theme='dark'] .modal-content select,
[data-theme='dark'] .modal-content input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="reset"]),
[data-theme='dark'] .modal-content textarea,
[data-theme='dark'] .modal-content select {
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    color-scheme: dark !important;
}

body[data-theme='dark'] .modal-content input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="reset"]):focus,
body[data-theme='dark'] .modal-content textarea:focus,
body[data-theme='dark'] .modal-content select:focus,
[data-theme='dark'] .modal-content input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="reset"]):focus,
[data-theme='dark'] .modal-content textarea:focus,
[data-theme='dark'] .modal-content select:focus {
    background-color: var(--input-bg-focus);
    border-color: rgba(199, 146, 255, 0.55);
    color: #ffffff;
    box-shadow: 0 0 0 3px rgba(234, 11, 128, 0.2);
}

body[data-theme='dark'] .modal-content input::placeholder,
body[data-theme='dark'] .modal-content textarea::placeholder,
[data-theme='dark'] .modal-content input::placeholder,
[data-theme='dark'] .modal-content textarea::placeholder {
    color: #7e8ba7;
}

.modal-content--xl {
    width: min(80%, 95vw);
    max-width: 1000px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0;
}

.modal-content--xl .modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

/*
 * `.modal-content--xl` monta el patrón "cabecera fija + cuerpo que scrollea":
 * es `display:flex; flex-direction:column` con `overflow:hidden`. Pero al cuerpo
 * nunca se le dio scroll propio, así que todo lo que pasaba del alto máximo
 * quedaba recortado y era imposible llegar (en Eliminar datos se perdían ~700px
 * apenas aparecían resultados).
 *
 * `min-height: 0` es imprescindible: sin eso un hijo de un flex en columna no
 * puede achicarse por debajo de su contenido y el scroll nunca se activa.
 */
.modal-content--xl > .modal-body,
.modal-content--xl > .dd-panel,
.modal-content--xl > form {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* El pie de acciones, si existe, queda siempre visible. */
.modal-content--xl > .modal-actions {
    flex-shrink: 0;
}

/* El tamaño del modal y el layout interno de "Destinatarias de reportes"
   ahora los resuelve el mismo sistema que #account-manager-modal (ver
   panel-inicio.css / movil-optimizado.css / ajustes-responsive.css),
   extendido para incluir también #email-manager-modal. */

#modal-cargar {
    z-index: 1100;
}

#calculator-modal .modal-content--calculator {
    width: min(90vw, 1100px);
    max-width: 95vw;
    min-width: 0;
    resize: horizontal;
    overflow: auto;
}

#calculator-modal .modal-content--calculator::-webkit-resizer {
    background: transparent;
}

#calculator-import-hint {
    margin: 0 0 12px;
    font-size: 0.92rem;
}

/*
 * Cabecera de modal: el bloque de título es un flex item con `min-width: auto`,
 * así que no baja de su ancho mínimo y empuja al botón de cerrar fuera de la
 * caja (se veía como scroll horizontal dentro del modal en pantallas chicas).
 */
.modal-header > *:not(.modal-close):not(.close-modal) {
    min-width: 0;
}

.modal-header .modal-close,
.modal-header .close-modal {
    flex: 0 0 auto;
}

.close-modal {
    color: #aaa;
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

#calendar-weekdays {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.calendar-month {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--text-color);
    width: 200px;
    text-align: center;
}

.cal-nav {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.cal-nav:hover {
    background-color: var(--primary-color);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
    margin-top: 1.5rem;
}

.calendar-day-header {
    text-align: center;
    font-weight: 500;
    color: var(--text-muted);
    padding-bottom: 10px;
}

.calendar-cell {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    min-height: 80px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    font-weight: 500;
}

.calendar-cell.empty {
    background: transparent;
    border-color: transparent;
    cursor: default;
}

.calendar-cell:not(.empty):hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
}

.calendar-cell.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* En tema oscuro el magenta claro de marca deja el blanco en 3,53:1: el día
   seleccionado usa el tono de acción, que sí pasa AA con texto blanco. */
body[data-theme='dark'] .calendar-cell.active {
    background-color: #d40f75;
    border-color: #d40f75;
    color: #fff;
}

.calendar-cell span {
    font-size: 0.8rem;
    display: block;
    margin-top: 5px;
    color: var(--success-color);
}

.caja-history-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    margin-bottom: 12px;
    border-radius: 16px;
    background: rgba(234, 11, 128, 0.12);
    font-size: 0.86rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.caja-history-row:last-child {
    margin-bottom: 0;
}

.caja-history-row:hover {
    transform: translateX(4px);
    box-shadow: 0 12px 28px rgba(234, 11, 128, 0.16);
}

.caja-history-dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(234, 11, 128, 0.24);
}

.caja-history-meta {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.caja-history-meta strong {
    color: var(--text-color);
    font-size: 0.95rem;
}

.caja-history-meta small {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.caja-history-row .nota {
    color: var(--text-muted);
    font-style: italic;
}

.caja-sucursal-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(234, 11, 128, 0.1);
    color: var(--primary-color);
    white-space: nowrap;
}

.caja-sucursal-tag::before {
    content: ''; display: inline-block; width: 1em; height: 1em;
    background-color: currentColor; vertical-align: -0.12em;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M2 7 4.41 2.59A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8M2 7h20'/></svg>") no-repeat center / contain;
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M2 7 4.41 2.59A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8M2 7h20'/></svg>") no-repeat center / contain;
    font-size: 0.65rem;
}

body[data-theme='dark'] .caja-sucursal-tag {
    background: rgba(255, 255, 255, 0.08);
    color: #cbb6ff;
}

.caja-por-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(16, 185, 129, 0.1);
    color: var(--ok-ink);
    white-space: nowrap;
}

.caja-por-tag::before {
    content: ''; display: inline-block; width: 1em; height: 1em;
    background-color: currentColor; vertical-align: -0.12em;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2M12 3a4 4 0 1 0 0 8 4 4 0 0 0 0-8'/></svg>") no-repeat center / contain;
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2M12 3a4 4 0 1 0 0 8 4 4 0 0 0 0-8'/></svg>") no-repeat center / contain;
    font-size: 0.65rem;
}

body[data-theme='dark'] .caja-por-tag {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.caja-history-amount {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 0.95rem;
}

.caja-history-row[data-sign='out'] {
    background: rgba(132, 89, 232, 0.14);
}

.caja-history-row[data-sign='out'] .caja-history-dot {
    background: #ff5c9a;
    box-shadow: 0 0 0 4px rgba(132, 89, 232, 0.24);
}

.caja-history-row[data-sign='out'] .caja-history-amount {
    color: #c63d6b;
}

body[data-theme='dark'] .caja-history-row {
    background: rgba(234, 11, 128, 0.24);
    box-shadow: none;
}

body[data-theme='dark'] .caja-history-row:hover {
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4);
}

body[data-theme='dark'] .caja-history-dot {
    box-shadow: 0 0 0 4px rgba(234, 11, 128, 0.28);
}

body[data-theme='dark'] .caja-history-row[data-sign='out'] {
    background: rgba(132, 89, 232, 0.26);
}

body[data-theme='dark'] .caja-history-row[data-sign='out'] .caja-history-dot {
    box-shadow: 0 0 0 4px rgba(132, 89, 232, 0.32);
}

body[data-theme='dark'] .caja-history-amount {
    color: #cbb6ff;
}

body[data-theme='dark'] .caja-history-row[data-sign='out'] .caja-history-amount {
    color: #ff9fbf;
}

.caja-history-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.caja-history-tags .chip {
    font-size: 0.74rem;
    padding: 3px 8px;
}

.ventas-recientes-empty {
    text-align: center;
    padding: 12px 0;
}

.theme-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    display: grid;
    place-items: center;
    font-size: 1.3rem;
    box-shadow: 0 12px 22px rgba(0, 0, 0, 0.25);
    z-index: 2000;
    cursor: pointer;
}

body.has-help-center .theme-toggle {
    bottom: 82px;
}

.theme-toggle span {
    pointer-events: none;
}

/* El índigo anterior era el único azul del panel: el botón pasa a la
   superficie elevada, con el borde y la tinta del tema. */
body[data-theme='dark'] .theme-toggle {
    background: var(--surface-3);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.45);
}

.global-search-trigger {
    position: fixed;
    bottom: 76px;
    right: 24px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 2100;
    flex-direction: row-reverse;
}

body.has-help-center .global-search-trigger {
    bottom: 134px;
}

.global-search-trigger__button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.96);
    color: var(--text-color);
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.global-search-trigger__button:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.2);
}

.global-search-trigger__icon {
    font-size: 1rem;
}

.global-search-trigger__hint {
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 6px;
    border-radius: 6px;
}

.global-search-trigger__collapse {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.96);
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.global-search-trigger__button:focus-visible,
.global-search-trigger__collapse:focus-visible {
    outline: 3px solid rgba(234, 11, 128, 0.35);
    outline-offset: 2px;
}

.global-search-trigger__collapse:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 28px rgba(0, 0, 0, 0.18);
}

.global-search-trigger__collapse-text {
    pointer-events: none;
}

.global-search-trigger.is-collapsed .global-search-trigger__button {
    padding: 10px;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    gap: 0;
}

.global-search-trigger.is-collapsed .global-search-trigger__label,
.global-search-trigger.is-collapsed .global-search-trigger__hint {
    display: none;
}

body[data-theme='dark'] .global-search-trigger__button {
    background: var(--surface-3);
    border-color: rgba(255, 255, 255, 0.1);
    color: #f2f4ff;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55);
}

body[data-theme='dark'] .global-search-trigger__collapse {
    background: var(--surface-3);
    border-color: rgba(255, 255, 255, 0.1);
    color: #f2f4ff;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55);
}

body[data-theme='dark'] .global-search-trigger__hint {
    background: rgba(255, 255, 255, 0.12);
}

.global-search-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 80px 20px;
    background: rgba(10, 12, 24, 0.58);
    backdrop-filter: blur(6px);
    z-index: 3000;
}

.global-search-overlay.is-active {
    display: flex;
}

.global-search-backdrop {
    position: absolute;
    inset: 0;
}

.global-search-dialog {
    position: relative;
    width: min(720px, 100%);
    background: var(--card-bg, #fff);
    border-radius: 18px;
    box-shadow: 0 26px 60px rgba(0, 0, 0, 0.3);
    padding: 24px 26px 28px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    z-index: 1;
}

body[data-theme='dark'] .global-search-dialog {
    background: var(--surface-2);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6);
}

.global-search-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.global-search-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.global-search-close {
    background: transparent;
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    color: inherit;
    padding: 4px;
}

.global-search-field {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.94);
}

body[data-theme='dark'] .global-search-field {
    background: rgba(38, 41, 60, 0.92);
    border-color: rgba(255, 255, 255, 0.1);
}

.global-search-field__icon {
    font-size: 1.1rem;
}

.global-search-field__hint {
    margin-left: auto;
    font-size: 0.75rem;
    opacity: 0.7;
    display: flex;
    gap: 4px;
    align-items: center;
}

.global-search-field__hint kbd {
    background: rgba(0, 0, 0, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-family: inherit;
}

body[data-theme='dark'] .global-search-field__hint kbd {
    background: rgba(255, 255, 255, 0.1);
}

.global-search-input {
    flex: 1 1 auto;
    border: none;
    background: transparent;
    font-size: 1.05rem;
    outline: none;
    color: inherit;
}

.global-search-status {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.global-search-results {
    display: flex;
    flex-direction: column;
    gap: 18px;
    max-height: min(420px, 50vh);
    overflow-y: auto;
    padding-right: 4px;
}

.global-search-section__title {
    margin: 0 0 8px;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.global-search-section__items {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.global-search-result {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    gap: 4px 12px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    background: rgba(255, 255, 255, 0.92);
    cursor: pointer;
    text-align: left;
}

.global-search-result:hover {
    border-color: var(--primary-color);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

body[data-theme='dark'] .global-search-result {
    background: rgba(40, 44, 66, 0.94);
    border-color: rgba(255, 255, 255, 0.08);
}

.global-search-result__title {
    font-weight: 600;
    grid-column: 1 / 2;
}

.global-search-result__meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    grid-column: 1 / 2;
}

.global-search-result__tag {
    align-self: flex-end;
    background: rgba(234, 11, 128, 0.12);
    color: var(--primary-color);
    font-size: 0.82rem;
    padding: 2px 8px;
    border-radius: 999px;
}

.global-search-result__tag--warn {
    background: rgba(132, 89, 232, 0.16);
    color: #ff4f90;
}

.global-search-result--static {
    border: 1px solid rgba(0, 0, 0, 0.05);
    background: rgba(255, 255, 255, 0.86);
    border-radius: 12px;
    padding: 12px 14px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 12px;
}

body[data-theme='dark'] .global-search-result--static {
    background: rgba(40, 44, 66, 0.9);
    border-color: rgba(255, 255, 255, 0.08);
}

.global-search-empty {
    text-align: center;
    padding: 32px 0;
    color: var(--text-muted);
}

@media (max-width: 960px) {
    .global-search-trigger {
        top: auto;
        bottom: 90px;
        right: 24px;
    }

    .global-search-field__hint {
        display: none;
    }
}

/* ==========================================================================
   CENTRO DE CONSULTA — Enhanced Global Search (Inventory Page)
   Chips, Master Cards, Detail Tables
   ========================================================================== */

/* ---- Smart Chips ---- */
.inv-lookup__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 4px;
}

.inv-lookup__chip {
    padding: 5px 14px;
    font-size: 0.78rem;
    font-weight: 600;
    border: 1.5px solid var(--border-color, #e0daf5);
    border-radius: 999px;
    background: var(--card-bg, #fff);
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.inv-lookup__chip:hover {
    border-color: var(--border-color);
    background: var(--surface-color);
}

.inv-lookup__chip.is-active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

body[data-theme='dark'] .inv-lookup__chip {
    background: #1e1e2e;
    border-color: rgba(234, 11, 128, 0.30);
    color: #9ca3af;
}

body[data-theme='dark'] .inv-lookup__chip:hover {
    background: rgba(234, 11, 128, 0.1);
}

body[data-theme='dark'] .inv-lookup__chip.is-active {
    background: #7c3aed;
    border-color: #7c3aed;
    color: #fff;
}

/* ---- Summary bar inside overlay ---- */
.inv-lookup__summary {
    padding: 6px 0;
    font-size: 0.78rem;
    font-weight: 600;
    color: #6b7280;
}

body[data-theme='dark'] .inv-lookup__summary {
    color: #9ca3af;
}

/* ---- MASTER CARD (Level 1) ---- */
.inv-card {
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: 12px;
    margin-bottom: 10px;
    overflow: hidden;
    background: var(--card-bg, #fff);
    transition: box-shadow 0.2s;
}

.inv-card:hover {
    box-shadow: 0 4px 16px rgba(100, 60, 200, 0.08);
}

body[data-theme='dark'] .inv-card {
    background: var(--surface-3);
    border-color: rgba(255, 255, 255, 0.08);
}

body[data-theme='dark'] .inv-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.inv-card__master {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    cursor: pointer;
    transition: background 0.12s;
    user-select: none;
}

.inv-card__master:hover {
    background: #faf9fe;
}

body[data-theme='dark'] .inv-card__master:hover {
    background: rgba(234, 11, 128, 0.05);
}

.inv-card__thumb {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: var(--surface-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
    color: var(--primary-color);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.inv-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.inv-card__thumb img:hover {
    transform: scale(1.08);
}

body[data-theme='dark'] .inv-card__thumb {
    background: rgba(234, 11, 128, 0.12);
    border-color: rgba(234, 11, 128, 0.2);
}

.inv-card__info {
    flex: 1;
    min-width: 0;
}

.inv-card__name {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-color, #1f2937);
    line-height: 1.35;
    white-space: normal !important;
    word-break: break-word;
}

.inv-card__codes {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 2px;
}

.inv-card__codes strong {
    color: var(--primary-color);
    font-weight: 700;
}

.inv-card__badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    padding: 6px 14px;
    border-radius: 10px;
    background: rgba(5, 150, 105, 0.06);
    border: 1px solid rgba(5, 150, 105, 0.15);
}

.inv-card__badge-number {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--ok-ink);
    line-height: 1;
}

.inv-card__badge-label {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--ok-ink);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.inv-card__toggle-icon {
    font-size: 0.8rem;
    color: #ea0b80;
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.inv-card.is-open .inv-card__toggle-icon {
    transform: rotate(180deg);
}

/* ---- DETAIL PANEL (Level 2) ---- */
.inv-card__detail {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    background: #faf9fe;
    border-top: 0 solid transparent;
}

.inv-card.is-open>.inv-card__detail {
    max-height: 3000px;
    border-top: 1px solid #f0ecf8;
}

body[data-theme='dark'] .inv-card__detail {
    background: rgba(234, 11, 128, 0.03);
}

body[data-theme='dark'] .inv-card.is-open>.inv-card__detail {
    border-top-color: rgba(234, 11, 128, 0.1);
}

/* ---- Diseño / lote (carpeta de variantes del mismo producto) ---- */
.inv-detail__design-folder {
    margin: 0 0 10px;
    border: 1px solid #e8e2f8;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.55);
}

body[data-theme='dark'] .inv-detail__design-folder {
    border-color: rgba(234, 11, 128, 0.22);
    background: rgba(20, 16, 35, 0.35);
}

.inv-detail__design-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: linear-gradient(90deg, #ede9fe 0%, #f8f5ff 55%, transparent 100%);
    border-bottom: 1px solid #e0daf5;
}

body[data-theme='dark'] .inv-detail__design-header {
    background: linear-gradient(90deg, rgba(234, 11, 128, 0.16) 0%, rgba(234, 11, 128, 0.04) 60%, transparent 100%);
    border-color: rgba(234, 11, 128, 0.18);
}

.inv-detail__design-thumb {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 3px rgba(91, 61, 184, 0.12);
}

body[data-theme='dark'] .inv-detail__design-thumb {
    background: rgba(255, 255, 255, 0.06);
}

.inv-detail__design-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.inv-detail__design-info {
    min-width: 0;
    flex: 1;
}

.inv-detail__design-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #4c1d95;
    line-height: 1.25;
}

body[data-theme='dark'] .inv-detail__design-label {
    color: #ddd6fe;
}

.inv-detail__design-meta {
    margin-top: 2px;
    font-size: 0.72rem;
    color: #6b7280;
    font-weight: 500;
}

body[data-theme='dark'] .inv-detail__design-meta {
    color: #9ca3af;
}

.product-thumb--xs {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px;
    min-height: 32px;
    border-radius: 6px;
    object-fit: cover;
}

/* ---- Lote Group Header (ubicación dentro del diseño) ---- */
.inv-detail__lote-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 0.78rem;
    font-weight: 700;
    color: #5b3db8;
    background: linear-gradient(90deg, #f3f0ff 0%, transparent 100%);
    border-bottom: 1px solid #e8e2f8;
}

body[data-theme='dark'] .inv-detail__lote-header {
    color: #c4b5fd;
    background: linear-gradient(90deg, rgba(234, 11, 128, 0.08) 0%, transparent 100%);
    border-color: rgba(234, 11, 128, 0.12);
}

/* ---- Detail Table ---- */
.inv-detail__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.inv-detail__table th {
    padding: 8px 12px;
    text-align: left;
    font-weight: 700;
    color: #6b7280;
    background: #f3f0ff;
    border-bottom: 1px solid #e0daf5;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

body[data-theme='dark'] .inv-detail__table th {
    background: rgba(234, 11, 128, 0.06);
    color: #9ca3af;
    border-color: rgba(234, 11, 128, 0.12);
}

.inv-detail__table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0ecf8;
    vertical-align: top;
    color: var(--text-color, #374151);
}

body[data-theme='dark'] .inv-detail__table td {
    border-color: rgba(255, 255, 255, 0.04);
}

.inv-detail__table tbody tr {
    transition: background 0.12s;
    position: relative;
}

.inv-detail__table tbody tr:hover {
    background: #ede8fb;
}

body[data-theme='dark'] .inv-detail__table tbody tr:hover {
    background: rgba(234, 11, 128, 0.08);
}

.inv-detail__table tbody tr:last-child td {
    border-bottom: none;
}

.inv-detail__variant-cell {
    font-weight: 600;
    white-space: normal !important;
    word-break: break-word;
}

.inv-detail__stock-cell {
    font-weight: 800;
    font-size: 0.85rem;
}

.inv-detail__stock-cell--zero {
    color: #dc2626;
}

.inv-detail__stock-cell--low {
    color: #f59e0b;
}

/* ---- Micro-Location emphasis ---- */
.inv-detail__location {
    line-height: 1.45;
}

.inv-detail__location-branch {
    font-size: 0.72rem;
    color: #6b7280;
}

.inv-detail__location-micro {
    font-weight: 700;
    color: var(--text-color, #1f2937);
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.inv-detail__location-micro .pin-icon {
    color: #dc2626;
}

.inv-detail__location--missing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 6px;
    background: #fef3c7;
    color: #92400e;
    font-weight: 700;
    font-size: 0.72rem;
}

body[data-theme='dark'] .inv-detail__location--missing {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}

/* ---- Text highlight ---- */
.inv-highlight {
    background: #fef08a;
    color: #1f2937;
    border-radius: 2px;
    padding: 0 2px;
}

body[data-theme='dark'] .inv-highlight {
    background: rgba(250, 204, 21, 0.3);
    color: #fef08a;
}

/* ---- Acciones de variante (siempre visibles, usables en touch) ---- */
.inv-detail__actions-cell {
    min-width: 160px;
    vertical-align: middle !important;
}

.inv-detail__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    opacity: 1;
    pointer-events: auto;
    position: static;
    transform: none;
}

.inv-detail__action-btn {
    padding: 5px 8px;
    font-size: 0.72rem;
    font-weight: 650;
    border: 1px solid var(--border-color, #e0daf5);
    border-radius: 8px;
    background: var(--card-bg, #fff);
    color: #5b3db8;
    cursor: pointer;
    transition: all 0.12s;
    white-space: nowrap;
    min-height: 30px;
    line-height: 1.1;
}

.inv-detail__action-btn:hover,
.inv-detail__action-btn:focus-visible {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
    outline: none;
}

body[data-theme='dark'] .inv-detail__action-btn {
    background: #2a2a3e;
    border-color: rgba(234, 11, 128, 0.30);
    color: var(--primary-color);
}

body[data-theme='dark'] .inv-detail__action-btn:hover,
body[data-theme='dark'] .inv-detail__action-btn:focus-visible {
    background: #7c3aed;
    color: #fff;
}

/* Historial inline del producto */
.inv-detail__history {
    margin: 0;
    padding: 10px 12px 12px;
    border-top: 1px dashed rgba(234, 11, 128, 0.28);
    background: rgba(234, 11, 128, 0.05);
}

body[data-theme='dark'] .inv-detail__history {
    background: rgba(234, 11, 128, 0.1);
    border-top-color: var(--border-color);
}

.inv-detail__history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.inv-detail__history-head strong {
    font-size: 0.85rem;
}

.inv-detail__history-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 220px;
    overflow-y: auto;
}

.inv-detail__history-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(234, 11, 128, 0.12);
    font-size: 0.82rem;
}

body[data-theme='dark'] .inv-detail__history-item {
    background: var(--surface-2);
    border-color: var(--border-color);
}

.inv-detail__history-meta {
    display: block;
    margin-top: 2px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.inv-detail__history-amount {
    font-weight: 750;
    white-space: nowrap;
}

.inv-detail__history-amount.is-pos { color: #109862; }
.inv-detail__history-amount.is-neg { color: #b61739; }

.inv-detail__margin {
    display: inline-block;
    margin-left: 4px;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(234, 11, 128, 0.1);
}
.inv-detail__margin.is-pos { color: #109862; background: rgba(16, 152, 98, 0.12); }
.inv-detail__margin.is-neg { color: #b61739; background: rgba(182, 23, 57, 0.12); }

.inv-detail__compare {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px 10px;
    border-top: 1px solid rgba(234, 11, 128, 0.1);
}
.inv-detail__compare-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    background: rgba(234, 11, 128, 0.08);
    border: 1px solid rgba(234, 11, 128, 0.14);
    color: var(--text-color);
}
.inv-detail__compare-chip.is-low {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.28);
}
.inv-detail__compare-chip.is-zero {
    background: rgba(220, 38, 38, 0.1);
    border-color: rgba(220, 38, 38, 0.22);
}

/* Lightbox imagen centro consulta */
.cc-lightbox {
    position: fixed;
    inset: 0;
    z-index: 4000;
    display: none;
    align-items: center;
    justify-content: center;
}
.cc-lightbox.is-open { display: flex; }
.cc-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 12, 24, 0.72);
    backdrop-filter: blur(4px);
}
.cc-lightbox__panel {
    position: relative;
    z-index: 1;
    max-width: min(92vw, 720px);
    max-height: 90dvh;
    background: var(--card-color, #fff);
    border-radius: 16px;
    padding: 14px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}
.cc-lightbox__img {
    display: block;
    max-width: 100%;
    max-height: min(70dvh, 560px);
    margin: 0 auto;
    border-radius: 10px;
    object-fit: contain;
}
.cc-lightbox__caption {
    margin: 10px 0 0;
    text-align: center;
    font-weight: 650;
}
.cc-lightbox__close {
    position: absolute;
    top: 6px;
    right: 10px;
    border: none;
    background: transparent;
    font-size: 1.6rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    width: 36px;
    height: 36px;
}

@media (max-width: 720px) {
    .inv-detail__table thead { display: none; }
    .inv-detail__table,
    .inv-detail__table tbody,
    .inv-detail__table tr,
    .inv-detail__table td {
        display: block;
        width: 100%;
    }
    .inv-detail__table tr {
        padding: 10px;
        border-bottom: 1px solid rgba(234, 11, 128, 0.12);
    }
    .inv-detail__table td {
        padding: 3px 0;
        border: none;
    }
    .inv-detail__actions-cell {
        min-width: 0;
        margin-top: 6px;
    }
    .inv-detail__actions {
        width: 100%;
    }
    .inv-detail__action-btn {
        flex: 1 1 calc(50% - 4px);
        text-align: center;
        min-height: 36px;
    }
}

/* ==========================================================================
   CENTRO DE CONSULTA — fotos, herramientas, accesos y pantalla de inicio
   ========================================================================== */

/* Con `hidden` y un display propio (flex) el atributo no ocultaba nada. */
.inv-lookup__chips[hidden],
.inv-lookup__tools[hidden],
.inv-lookup__select[hidden] {
    display: none;
}

.inv-lookup__tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    margin-bottom: 4px;
}

.inv-lookup__select {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted, #6b7280);
}

.inv-lookup__select select {
    font: inherit;
    width: auto;
    min-width: 0;
    height: 32px;
    min-height: 0;
    padding: 0 8px;
    border: 1.5px solid var(--border-color, #e0daf5);
    border-radius: 8px;
    background: var(--card-bg, #fff);
    color: var(--text-color, inherit);
    cursor: pointer;
}

body[data-theme='dark'] .inv-lookup__select select {
    background: #1e1e2e;
    border-color: rgba(234, 11, 128, 0.30);
    color: #e5e7eb;
}

.inv-lookup__more {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 9px 12px;
    border: 1.5px dashed var(--border-color, #e0daf5);
    border-radius: 10px;
    background: transparent;
    color: var(--primary-color);
    font-size: 0.82rem;
    font-weight: 650;
    cursor: pointer;
}

.inv-lookup__more:hover,
.inv-lookup__more:focus-visible {
    border-style: solid;
    border-color: var(--primary-color);
    outline: none;
}

.inv-lookup__more span {
    font-weight: 400;
    color: var(--text-muted, #6b7280);
}

/* Tarjeta: cuántas fotos tiene y a qué serie pertenece */
.inv-card__master:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
}

.inv-card__thumb {
    position: relative;
}

.inv-card__thumb[data-cc-do='photos'],
.inv-detail__design-thumb[data-cc-do='photos'] {
    cursor: zoom-in;
}

.inv-card__photo-count {
    position: absolute;
    right: 2px;
    bottom: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: rgba(17, 24, 39, 0.78);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    pointer-events: none;
}

.inv-card__serie {
    margin-top: 2px;
    font-size: 0.74rem;
    color: var(--text-muted, #6b7280);
}

/* Tira de fotos dentro de la tarjeta abierta */
.inv-photos {
    padding: 10px 12px 4px;
}

.inv-photos--empty {
    padding: 8px 12px;
    font-size: 0.78rem;
    color: var(--text-muted, #6b7280);
}

.inv-photos__title {
    display: block;
    margin-bottom: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted, #6b7280);
}

.inv-photos__list {
    display: flex;
    gap: 8px;
    padding-bottom: 6px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.inv-photos__item {
    position: relative;
    flex: 0 0 auto;
    width: 64px;
    height: 64px;
    padding: 0;
    border: 1.5px solid var(--border-color, #e0daf5);
    border-radius: 10px;
    background: var(--surface-overlay, #f8f9fa);
    overflow: hidden;
    cursor: zoom-in;
}

.inv-photos__item:hover,
.inv-photos__item:focus-visible {
    border-color: var(--primary-color);
    outline: none;
}

.inv-photos__item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.inv-photos__tag {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 1px 3px;
    background: rgba(17, 24, 39, 0.72);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Copiar ficha / WhatsApp / estado en la tienda */
.inv-detail__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 6px 12px 8px;
}

.inv-detail__web {
    margin-left: auto;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 650;
}

.inv-detail__web.is-on {
    color: #109862;
    background: rgba(16, 152, 98, 0.12);
}

.inv-detail__web.is-off {
    color: #8a6d00;
    background: rgba(245, 158, 11, 0.14);
}

/* "Ir a…" y pantalla de inicio */
.gs-nav-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.gs-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: 10px;
    background: var(--card-bg, #fff);
    color: inherit;
    font-weight: 600;
    text-decoration: none;
}

.gs-nav:hover,
.gs-nav:focus-visible {
    border-color: var(--primary-color);
    outline: none;
}

.gs-nav__icon {
    display: inline-flex;
    color: var(--primary-color);
}

.gs-nav__section {
    margin-left: auto;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted, #6b7280);
}

body[data-theme='dark'] .gs-nav {
    background: rgba(40, 44, 66, 0.94);
    border-color: rgba(255, 255, 255, 0.08);
}

.gs-idle {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.gs-idle__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.gs-idle__clear {
    margin-left: 8px;
    padding: 0;
    border: none;
    background: none;
    color: var(--primary-color);
    font-size: 0.72rem;
    letter-spacing: 0;
    text-transform: none;
    cursor: pointer;
}

.gs-idle__tip {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-muted, #6b7280);
}

.gs-idle__tip kbd {
    padding: 0 5px;
    border: 1px solid var(--border-color, #e0daf5);
    border-radius: 4px;
    font-size: 0.72rem;
}

@media (max-width: 640px) {
    /* Orden y sucursal lado a lado: apilados se comían media pantalla. */
    .inv-lookup__tools {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .inv-lookup__select {
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
    }

    .inv-lookup__select select {
        width: 100%;
    }

    .inv-detail__toolbar .inv-detail__action-btn {
        flex: 1 1 calc(50% - 6px);
        min-height: 36px;
        text-align: center;
    }

    .inv-detail__web {
        margin-left: 0;
    }

    .inv-photos__item {
        width: 56px;
        height: 56px;
    }
}

/* Wider dialog for Centro de Consulta cards */
.global-search-dialog {
    width: min(900px, 95vw) !important;
}

.global-search-results {
    max-height: min(520px, 60vh) !important;
}

@media (max-width: 640px) {
    .inv-card__master {
        gap: 10px;
        padding: 10px 12px;
    }

    .inv-card__thumb {
        width: 38px;
        height: 38px;
        font-size: 1.1rem;
    }

    .inv-detail__table {
        font-size: 0.72rem;
    }

    .inv-detail__table th,
    .inv-detail__table td {
        padding: 7px 8px;
    }

    .inv-detail__actions {
        position: static;
        transform: none;
        opacity: 1;
        pointer-events: auto;
        padding-top: 6px;
    }
}

body[data-theme='dark'] .theme-toggle {
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
}

body[data-theme='dark'] .inventory-table {
    background: var(--card-color);
    border-radius: 14px;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.42);
}

hr {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 20px 0;
    opacity: 0.7;
}

body[data-theme='dark'] .inventory-table th {
    background: rgba(255, 255, 255, 0.072);
    color: var(--text-color);
}

body[data-theme='dark'] .inventory-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.04);
}

body[data-theme='dark'] .summary-card__icon {
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

body[data-theme='dark'] .summary-card__hint {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-color);
}

.charts-grid {
    margin-top: 20px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.chart-wrapper {
    background: var(--card-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 12px;
    box-shadow: 0 18px 30px rgba(0, 0, 0, 0.08);
}

body[data-theme='dark'] .chart-wrapper {
    background: var(--surface-3);
    border-color: rgba(255, 255, 255, 0.05);
}

.chart-wrapper canvas {
    max-height: 240px;
}

.metric-list__item[data-severity="danger"] .metric-list__main {
    color: var(--danger-color);
}

.metric-list__item[data-severity="warn"] .metric-list__main {
    color: #e1942d;
}

/* Help center */
.help-center__toggle {
    position: fixed;
    bottom: 26px;
    right: 26px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(234, 11, 128, 0.4);
    background: linear-gradient(135deg, rgba(234, 11, 128, 0.16), rgba(132, 89, 232, 0.12)), #fff;
    color: #1f1f1f;
    font-weight: 700;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.14);
    z-index: 3200;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.2s ease;
}

body[data-theme='dark'] .help-center__toggle {
    background: linear-gradient(135deg, rgba(234, 11, 128, 0.22), rgba(132, 89, 232, 0.16)), var(--surface-2);
    color: #f4f6ff;
}

.help-center__toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.18);
}

.help-center__panel {
    position: fixed;
    right: 26px;
    bottom: 86px;
    width: min(360px, 92vw);
    max-height: 70vh;
    background: var(--card-color);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.18);
    padding: 14px 16px;
    z-index: 3200;
    display: none;
    overflow: hidden;
}

body.has-help-center .help-center__panel {
    bottom: 156px;
}

.help-center__panel.is-open {
    display: block;
}

.help-center__header {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 10px;
}

.help-center__header strong {
    font-size: 1rem;
}

.help-center__header span {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.help-center__close {
    position: absolute;
    top: 10px;
    right: 10px;
    border: none;
    background: transparent;
    font-size: 1.2rem;
    cursor: pointer;
}

.help-center__list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    max-height: 48vh;
    padding-right: 6px;
}

.help-center__item {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px 12px;
    background: rgba(234, 11, 128, 0.06);
}

body[data-theme='dark'] .help-center__item {
    background: rgba(234, 11, 128, 0.12);
}

.help-center__item h4 {
    margin: 0 0 6px;
    font-size: 0.98rem;
}

.help-center__item p {
    margin: 0 0 6px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.help-center__link,
.help-center__cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary-color);
    font-weight: 700;
}

.help-center__footer {
    margin-top: 10px;
    border-top: 1px solid var(--border-color);
    padding-top: 10px;
}

/* ========================================
   RESPONSIVE UTILITIES (Global)
   ======================================== */

/* Ocultar en móvil (≤768px) */
@media (max-width: 768px) {

    body {
        font-size: 15px;
    }

    .page-header {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        align-items: flex-start;
    }

    .page-header__meta h1 {
        font-size: 1.35rem;
    }

    .page-header__actions {
        width: auto;
        flex: 1 1 auto;
        flex-wrap: wrap;
        gap: 6px;
        justify-content: flex-end;
    }

    .page-header__actions>* {
        flex: 0 1 auto;
        min-height: 40px;
    }

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

    .card-panel {
        padding: 12px;
    }

    /* 2 columnas en filas de form (no todo apilado) */
    .form-row {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }

    .form-row .form-group {
        flex: 1 1 calc(50% - 8px);
        width: auto;
        min-width: 0;
    }

    .btn,
    .btn-chip {
        padding: 8px 12px;
        font-size: 0.85rem;
        min-height: 40px;
    }

    .main-content {
        padding: 14px 12px 88px;
        border-radius: 0;
    }

    .main-header h1,
    .page-header__meta h1 {
        font-size: 1.35rem;
    }

    /* Métricas en 2 cols para que quepan en pantalla */
    .summary-cards-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .card--split {
        grid-column: 1 / -1;
    }

    .card-panel__header,
    .filter-bar,
    .filter-bar__actions,
    .filter-bar__export,
    .email-workspace__header {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
    }

    .filter-bar .form-group {
        min-width: 0;
        flex: 1 1 calc(50% - 8px);
    }

    .filter-bar__actions .btn,
    .filter-bar__export .btn {
        width: auto;
        flex: 1 1 calc(50% - 8px);
        min-height: 40px;
    }

    .inventory-table th,
    .inventory-table td {
        padding: 10px 12px;
        font-size: 0.86rem;
    }

    .theme-toggle,
    .help-center__toggle {
        right: 14px;
        bottom: calc(14px + env(safe-area-inset-bottom));
    }

    body.has-help-center .theme-toggle {
        bottom: calc(74px + env(safe-area-inset-bottom));
    }

    .global-search-trigger {
        right: 14px;
        bottom: calc(74px + env(safe-area-inset-bottom));
    }

    body.has-help-center .global-search-trigger {
        bottom: calc(130px + env(safe-area-inset-bottom));
    }

    .help-center__panel {
        right: 12px;
        width: min(420px, calc(100vw - 24px));
        bottom: calc(70px + env(safe-area-inset-bottom));
    }

    body.has-help-center .help-center__panel {
        bottom: calc(132px + env(safe-area-inset-bottom));
    }

    .global-search-dialog {
        width: min(100%, calc(100vw - 20px)) !important;
        padding: 18px 16px 20px;
    }
}

@media (max-width: 540px) {
    .main-content {
        padding: 14px 12px 108px;
    }

    .page-header__meta h1,
    .main-header h1 {
        font-size: 1.35rem;
    }

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

    .global-search-result {
        grid-template-columns: 1fr;
        gap: 8px;
    }

}

/* ============================================================
   SISTEMA DE IMÁGENES DE PRODUCTO — Clases globales
   ============================================================ */

/* --- Miniatura de producto (tablas, cards, listas) --- */
.product-thumb {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
    background: linear-gradient(135deg, #f3f0ff 0%, #e8e0fb 100%);
    border: 1px solid #e0daf5;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    flex-shrink: 0;
}

.product-thumb:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(234, 11, 128, 0.18);
}

body[data-theme='dark'] .product-thumb {
    background: rgba(234, 11, 128, 0.12);
    border-color: rgba(234, 11, 128, 0.2);
}

/* Placeholder cuando no hay imagen */
.product-thumb--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: var(--primary-color);
    cursor: default;
}

.product-thumb--placeholder:hover {
    transform: none;
    box-shadow: none;
}

/* Tamaños alternativos */
.product-thumb--sm {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    font-size: 1rem;
}

.product-thumb--lg {
    width: 72px;
    height: 72px;
    border-radius: 12px;
    font-size: 1.8rem;
}

/* --- Lightbox modal universal --- */
.lightbox-modal {
    position: fixed;
    inset: 0;
    z-index: 4500;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    cursor: zoom-out;
}

.lightbox-modal.is-active {
    opacity: 1;
    visibility: visible;
}

.lightbox-modal__img {
    max-width: 90vw;
    max-height: 85vh;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    object-fit: contain;
    animation: lightbox-fadeIn 0.3s ease;
}

.lightbox-modal__close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    font-size: 1.6rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    backdrop-filter: blur(8px);
}

.lightbox-modal__close:hover {
    background: rgba(255, 255, 255, 0.3);
}

@keyframes lightbox-fadeIn {
    from {
        transform: scale(0.92);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* --- Lightbox: alternar entre las fotos del producto ---
   Solo aparece cuando la mercadería tiene más de una foto cargada
   (ver openImageLightbox en js/core/imagenes-producto.js). */
.lightbox-modal__img {
    cursor: default;
}

.lightbox-modal__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 2.2rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: background 0.15s ease;
}

.lightbox-modal__nav:hover {
    background: rgba(255, 255, 255, 0.32);
}

.lightbox-modal__nav--prev {
    left: 20px;
}

.lightbox-modal__nav--next {
    right: 20px;
}

.lightbox-modal__nav[hidden] {
    display: none;
}

.lightbox-modal__counter {
    position: absolute;
    top: 22px;
    left: 50%;
    transform: translateX(-50%);
    padding: 5px 14px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    backdrop-filter: blur(8px);
}

.lightbox-modal__counter[hidden] {
    display: none;
}

.lightbox-modal__thumbs {
    position: absolute;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    max-width: 92vw;
    padding: 8px;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.5);
    overflow-x: auto;
    backdrop-filter: blur(8px);
}

.lightbox-modal__thumbs[hidden] {
    display: none;
}

/* Rótulo de la foto en el visor (diseño / variante), cuando el buscador lo sabe. */
.lightbox-modal__caption {
    position: absolute;
    top: 66px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 86vw;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    backdrop-filter: blur(8px);
}

.lightbox-modal__caption[hidden] {
    display: none;
}

.lightbox-modal__thumb {
    flex: none;
    width: 56px;
    height: 56px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.15s ease, border-color 0.15s ease;
}

.lightbox-modal__thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.lightbox-modal__thumb:hover {
    opacity: 1;
}

.lightbox-modal__thumb.is-active {
    border-color: #fff;
    opacity: 1;
}

@media (max-width: 720px) {
    .lightbox-modal__nav {
        width: 42px;
        height: 42px;
        font-size: 1.7rem;
    }

    .lightbox-modal__nav--prev {
        left: 8px;
    }

    .lightbox-modal__nav--next {
        right: 8px;
    }

    .lightbox-modal__thumb {
        width: 46px;
        height: 46px;
    }

    .lightbox-modal__img {
        max-height: 68vh;
    }
}

/* --- Upload preview de imagen --- */
.image-upload-zone {
    position: relative;
    width: 100%;
    min-height: 120px;
    border: 2px dashed #d1c4f7;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    cursor: pointer;
    background: var(--surface-color);
    transition: border-color 0.2s ease, background 0.2s ease;
    overflow: hidden;
}

.image-upload-zone:hover,
.image-upload-zone.is-dragover {
    border-color: var(--primary-color);
    background: var(--surface-overlay);
}

body[data-theme='dark'] .image-upload-zone {
    background: rgba(234, 11, 128, 0.06);
    border-color: rgba(234, 11, 128, 0.25);
}

body[data-theme='dark'] .image-upload-zone:hover,
body[data-theme='dark'] .image-upload-zone.is-dragover {
    background: rgba(234, 11, 128, 0.12);
    border-color: rgba(234, 11, 128, 0.50);
}

.image-upload-zone__icon {
    font-size: 2rem;
    color: var(--primary-color);
    line-height: 1;
}

.image-upload-zone__text {
    font-size: 0.82rem;
    color: #6b7280;
    text-align: center;
}

.image-upload-zone__input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.image-upload-zone__preview {
    max-width: 100%;
    max-height: 160px;
    border-radius: 8px;
    object-fit: contain;
}

.image-upload-zone__remove {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.55);
    border: none;
    color: #fff;
    font-size: 1.1rem;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.image-upload-zone.has-preview .image-upload-zone__remove {
    display: flex;
}

.image-upload-zone.has-preview .image-upload-zone__icon,
.image-upload-zone.has-preview .image-upload-zone__text {
    display: none;
}

/* --- Foto por variante (tabla de preview de nuevo producto) --- */
.variant-photo-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    line-height: 1;
}

.variant-photo-btn img {
    width: 34px;
    height: 34px;
    max-width: none;
    object-fit: cover;
    border-radius: 6px;
    display: block;
    border: 1px solid rgba(234, 11, 128, 0.35);
}

.variant-photo-btn--has-img {
    padding: 2px;
    background: transparent;
    border: 1px dashed rgba(234, 11, 128, 0.45);
    border-radius: 8px;
    cursor: pointer;
}

.variant-photo-btn--has-img:hover {
    border-color: var(--primary-color);
}

/* ============================================================ */

/* ============================================================
   CONTRASTE DE BOTONES  (WCAG AA = 4.5:1 para texto normal)
   ------------------------------------------------------------
   Los botones principales usan los tonos del logo y los estados conservan
   colores semánticos propios. Las reglas de cada pantalla pueden convertir
   un botón secundario en control neutro, pero nunca deben introducir otra
   familia cromática.
   ============================================================ */
.btn-secondary {
    background-color: var(--secondary-color);
    color: #fff;
}

.btn-secondary:hover {
    background-color: var(--primary-color);
    color: #fff;
}

.btn-danger {
    background-color: #d92b4b;
    color: #fff;
}

.btn-danger:hover {
    background-color: #c31f3d;
}

/* ============================================================
   SUPERFICIES QUE SE QUEDABAN CLARAS EN TEMA OSCURO
   Detectadas midiendo la luminancia del fondo computado con el tema en
   oscuro: quedaban como parches blancos sobre el fondo oscuro.
   ============================================================ */
body[data-theme='dark'] .view-mode-btn.is-active {
    background: rgba(234, 11, 128, 0.32);
    color: #f3e8ff;
}

/* La especificidad lleva el id del body a propósito: estas superficies se
   pintan desde ventas-interfaz.css e inventario.css, que se cargan después
   de esta hoja, así que una regla de sola clase perdía la cascada. */
body[data-theme='dark']#page-inventario .inventory-audit-body,
body[data-theme='dark'] .inventory-audit-body,
body[data-theme='dark']#page-ventas .venta-cart-table,
body[data-theme='dark']#page-ventas #carrito-table-container {
    background: var(--surface-2);
}

/* ============================================================================
   Gestor de correos en pantallas chicas
   ----------------------------------------------------------------------------
   La cabecera del área de trabajo es una fila de dos bloques con gap de 16px.
   En un teléfono angosto el bloque de identidad (correo + estado) pide más de
   200px y empujaba el panel fuera del modal. Se apila.
   ========================================================================== */

@media (max-width: 430px) {

    .email-workspace__header {
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: stretch;
        gap: 8px;
    }

    .email-workspace__identity,
    .email-workspace__selected,
    .account-manager__details {
        min-width: 0;
        overflow-wrap: anywhere;
    }
}

/* =====================================================================
   LEGIBILIDAD EN MODO OSCURO
   ---------------------------------------------------------------------
   Estas reglas fijan un color de texto oscuro y NO declaran fondo, asi
   que heredan el del tema. En claro se leen bien; en oscuro quedan casi
   del mismo valor que el fondo y el texto desaparece.

   La contraparte de abajo conserva el tono (el rojo sigue siendo rojo,
   el verde verde) y solo sube la luminosidad hasta que contrasta. Se
   generaron con el barrido de scripts/, revisando uno por uno que el
   elemento no tuviera un fondo propio del contenedor.
   ===================================================================== */
body[data-theme='dark'] .stock-zero td[data-label="Stock"] { color: #ea9090; }
body[data-theme='dark'] .stock-zero .stock-low { color: #ea9090; }
body[data-theme='dark'] .inv-card__codes { color: #b7bbc2; }
body[data-theme='dark'] .inv-card__toggle-icon { color: #ff4fae; }
body[data-theme='dark'] .inv-detail__stock-cell--zero { color: #e99191; }
body[data-theme='dark'] .inv-detail__location-branch { color: #b7bbc2; }
body[data-theme='dark'] .inv-detail__location-micro .pin-icon { color: #e99191; }
body[data-theme='dark'] .inv-detail__history-amount.is-neg { color: #ec8da2; }
body[data-theme='dark'] .product-thumb--placeholder { color: #ff4fae; }
body[data-theme='dark'] .image-upload-zone__icon { color: #ff4fae; }
body[data-theme='dark'] .image-upload-zone__text { color: #b7bbc2; }

/* =====================================================================
   FOCO VISIBLE — un solo anillo para todo el panel
   ---------------------------------------------------------------------
   Cada componente tenía su propio detalle de foco y varios controles
   quedaban sin señal visible al navegar con teclado. Esta regla global
   usa el mismo token de marca y deja intactas las excepciones puntuales
   (que se declaran más arriba y siguen ganando por especificidad).
   ===================================================================== */
body[data-theme] :is(a, button, input, select, textarea, summary, [role='button'], [role='tab'], [tabindex]):focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Pago mixto (js/core/pago-mixto.js · celdaHtml): el medio y, debajo, el desglose
   («Efectivo 85.000 + Transferencia 15.000») en letra chica. */
.pago-metodo {
    display: block;
}

.pago-detalle {
    display: block;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 0.78em;
    line-height: 1.3;
    white-space: normal;
}
