/* ==========================================================================
   CatalogStore.UI — base theme
   Variables centralizadas + componentes reutilizables (cards de auth, etc.)
   ========================================================================== */

:root {
    --brand-primary: #2f5d50;
    --brand-primary-dark: #24473d;
    --brand-primary-light: #e8f0ee;
    --brand-accent: #c8a24a;

    --text-color: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --bg-body: #f5f6f8;
    --bg-card: #ffffff;

    --danger: #dc3545;
    --danger-bg: #fdecea;

    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 18px;

    --shadow-card: 0 10px 30px rgba(15, 23, 42, 0.08);
    --shadow-card-hover: 0 14px 38px rgba(15, 23, 42, 0.12);

    --font-base: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

/* ---------- Marca de agua global ---------- */

body {
    background-color: var(--bg-body);
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url('/img/logos/sam_desing-removebg-preview.png');
    background-repeat: no-repeat;
    background-position: center;
    background-size: 480px auto;
    opacity: 0.05;
    pointer-events: none;
    z-index: -1;
}

/* ---------- Navbar / módulos ---------- */

.app-navbar {
    background: linear-gradient(90deg, var(--brand-primary-dark) 0%, var(--brand-primary) 55%, var(--brand-primary-dark) 100%);
    font-family: var(--font-base);
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.18);
    padding-top: 10px;
    padding-bottom: 10px;
    /* Los menús desplegables tienen que quedar encima de la barra sticky del catálogo (.order-bar, 1010).
       Debajo de offcanvas (1045) y modales (1055). */
    position: relative;
    z-index: 1030;
}

.app-navbar-logo {
    height: 34px;
    width: auto;
    object-fit: contain;
}

.app-navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff !important;
}

.app-navbar-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.02em;
}

.app-navbar .navbar-toggler {
    border-color: rgba(255, 255, 255, 0.35);
}

.app-navbar .navbar-toggler-icon {
    filter: invert(1) grayscale(100%) brightness(2);
}

.app-navbar .nav-link {
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85) !important;
    padding: 8px 14px !important;
    border-radius: var(--radius-sm);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.app-navbar .nav-link:hover,
.app-navbar .dropdown-toggle:hover {
    background-color: rgba(255, 255, 255, 0.12);
    color: #fff !important;
}

.app-navbar .nav-link.active {
    background-color: rgba(255, 255, 255, 0.18);
    color: #fff !important;
}

.app-navbar .dropdown-menu {
    border: none;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: 8px;
    margin-top: 8px;
}

.app-navbar .dropdown-item {
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 0.9rem;
    color: var(--text-color);
}

.app-navbar .dropdown-item:hover,
.app-navbar .dropdown-item:focus {
    background-color: var(--brand-primary-light);
    color: var(--brand-primary-dark);
}

/* Submenús anidados (dropend) — posición fija por CSS, no depende de que Popper la calcule bien
   (Popper queda desactivado en estos toggles vía data-bs-display="static"). */
.app-navbar .dropdown-menu li {
    position: relative;
}

.app-navbar .dropend {
    position: relative;
}

.app-navbar .dropend > .dropdown-menu {
    top: 0;
    left: 100%;
    right: auto;
    margin-top: -8px;
    margin-left: 8px;
}

/* ---------- Home ---------- */

.home-hero {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.home-hero-content h1 {
    color: var(--brand-primary-dark);
    font-weight: 700;
}

/* ---------- Página de error / código de estado (404, 403, etc.) ---------- */

.status-page {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.status-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 48px 40px;
    max-width: 420px;
}

.status-code {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--brand-primary);
    line-height: 1;
    margin-bottom: 12px;
}

.status-card h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 8px;
}

.status-card p {
    margin-bottom: 24px;
}


/* ---------- Página de autenticación (login/registro) ---------- */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--brand-primary) 0%, var(--brand-primary-dark) 45%, #1a352c 100%);
    font-family: var(--font-base);
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 40px 36px 32px;
    transition: box-shadow 0.2s ease;
}

.auth-card:hover {
    box-shadow: var(--shadow-card-hover);
}

.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 28px;
}

.auth-brand-mark {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    background: var(--brand-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: 0.02em;
    margin-bottom: 14px;
}

.auth-brand-logo {
    height: 56px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
    margin-bottom: 14px;
}

.auth-brand-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

.auth-brand-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: center;
}

/* ---------- Formulario ---------- */

.auth-form .form-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 6px;
}

.auth-form .form-control {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.95rem;
    background-color: #fafafa;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.auth-form .form-control:focus {
    border-color: var(--brand-primary);
    background-color: #fff;
    box-shadow: 0 0 0 3px var(--brand-primary-light);
    outline: none;
}

.auth-form .form-control.is-invalid {
    border-color: var(--danger);
}

.auth-form .field-validation-error,
.auth-form .text-danger {
    font-size: 0.8rem;
    color: var(--danger);
    display: block;
    margin-top: 4px;
}

.auth-input-group {
    position: relative;
    margin-bottom: 20px;
}

.auth-toggle-password {
    position: absolute;
    right: 12px;
    top: 38px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 4px 6px;
}

.auth-toggle-password:hover {
    color: var(--brand-primary);
}

/* Edge agrega su propio "ojo" en los campos de contraseña y queda encima de "Mostrar": se oculta el del navegador.
   El padding evita que el texto escrito corra por debajo del botón. */
.auth-form input[type="password"]::-ms-reveal,
.auth-form input[type="password"]::-ms-clear {
    display: none;
}

.auth-form .auth-input-group:has(.auth-toggle-password) .form-control {
    padding-right: 76px;
}

/* ---------- Botón ---------- */

.btn-brand {
    width: 100%;
    background-color: var(--brand-primary);
    border: none;
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 11px 0;
    border-radius: var(--radius-sm);
    transition: background-color 0.15s ease, transform 0.05s ease;
}

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

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

/* ---------- Alertas ---------- */

.auth-alert {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--danger-bg);
    color: var(--danger);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.85rem;
    margin-bottom: 20px;
}

/* Confirmaciones (contraseña creada, enlace enviado) */
.auth-notice {
    background: var(--brand-primary-light);
    color: var(--brand-primary-dark);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: 16px;
    overflow-wrap: anywhere;
}

.auth-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: -6px 0 20px;
    line-height: 1.5;
}

.auth-link-forgot {
    display: inline-block;
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--brand-primary);
    text-decoration: none;
    font-weight: 600;
}

.auth-link-forgot:hover {
    text-decoration: underline;
}

.auth-btn-link {
    display: block;
    text-align: center;
    text-decoration: none;
}

.auth-btn-link:hover {
    color: #fff;
}

/* ---------- Footer de la card ---------- */

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.auth-footer a {
    color: var(--brand-primary);
    text-decoration: none;
    font-weight: 600;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* ---------- Tablas (.app-table) ---------- */

.app-table {
    font-size: 0.92rem;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.app-table thead th {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 12px 16px;
    border-bottom: 2px solid var(--border-color);
    background: #fafafa;
    white-space: nowrap;
}

.app-table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
}

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

.app-table tbody tr:hover {
    background-color: var(--brand-primary-light);
}

.app-table-clickable tbody tr {
    cursor: pointer;
}

/* Encabezados ordenables (tablesorter) */
.app-table thead th.tablesorter-header {
    cursor: pointer;
    position: relative;
    padding-right: 22px;
}

    .app-table thead th.tablesorter-header:hover {
        color: var(--brand-primary-dark);
    }

    .app-table thead th .tablesorter-header-inner::after {
        content: '\2195';
        position: absolute;
        right: 8px;
        opacity: 0.35;
        font-size: 0.9em;
    }

/* Fila que no matchea el filtro — tablesorter solo le pone la clase, el hide lo hace el CSS */
.app-table tbody tr.filtered {
    display: none;
}

.app-table thead th.tablesorter-headerAsc .tablesorter-header-inner::after {
    content: '\2191';
    opacity: 1;
    color: var(--brand-primary);
}

.app-table thead th.tablesorter-headerDesc .tablesorter-header-inner::after {
    content: '\2193';
    opacity: 1;
    color: var(--brand-primary);
}

.app-table thead th.sorter-false {
    cursor: default;
    padding-right: 16px;
}

/* Buscador único (filter_external) */
.app-table-search-wrap {
    position: relative;
    max-width: 320px;
    margin-bottom: 14px;
}

.app-table-search {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 9px 12px 9px 36px;
    font-size: 0.9rem;
    background-color: #fff;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.app-table-search:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-primary-light);
}

.app-table-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
    pointer-events: none;
}

/* Grupo de botones de acción en tablas — siempre en una sola fila, nunca se apila */
.action-buttons {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.action-sep {
    color: var(--border-color);
    font-size: 0.9rem;
    line-height: 1;
    user-select: none;
}

/* Badges de estado (Activo/Inactivo) y de rol — colores de marca, no el gris/rojo/verde genérico de Bootstrap */
.badge-status-active,
.badge-status-inactive,
.badge-role {
    font-weight: 600;
    font-size: 0.72rem;
    letter-spacing: 0.3px;
    padding: 5px 10px;
    border-radius: 999px;
}

.badge-status-active,
.badge-role {
    background-color: var(--brand-primary-light);
    color: var(--brand-primary-dark);
}

/* Usuario invitado que todavía no creó su contraseña */
.badge-invite-pending {
    background-color: #fff4d6;
    color: #8a6100;
    font-weight: 600;
    font-size: 0.72rem;
    padding: 5px 10px;
    border-radius: 999px;
}

.badge-status-inactive {
    background-color: #c69797;
    color: var(--text-muted);
}

/* Bootstrap no trae un "info oscuro" de fábrica — para distinguir LogOut de LogIn (ambos celeste) */
.text-bg-info-dark {
    background-color: #0e7490 !important;
    color: #fff !important;
}

/* Estado vacío de una tabla — icono + texto, en vez de un párrafo suelto */
.app-table-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 40px 20px;
    color: var(--text-muted);
    text-align: center;
}

/* Paginador de tabla (tablesorter pager) */
.app-table-pager {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.app-table-pager .pagedisplay {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0 4px;
    white-space: nowrap;
}

.app-table-pager .pagesize {
    width: auto;
    padding: 4px 28px 4px 10px;
    font-size: 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: #fff;
}

.app-table-pager button.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.app-table-empty i {
    font-size: 1.8rem;
    opacity: 0.5;
}

/* ==========================================================================
   Responsive — target: desktop y tablet primero, celular como piso mínimo.
   Breakpoints alineados a Bootstrap 5: lg = 992px, md = 768px, sm = 576px.
   ========================================================================== */

/* ---------- Tablet (<= 991.98px: portrait de iPad/tablet, y navbar colapsado) ---------- */
@media (max-width: 991.98px) {
    body::before {
        background-size: 360px auto;
    }

    .app-navbar-brand {
        font-size: 1rem;
    }

    .app-navbar .navbar-collapse {
        padding-top: 10px;
    }

    .app-navbar .nav-link {
        padding: 10px 14px !important;
    }

    .app-navbar .dropdown-menu {
        box-shadow: none;
        background: rgba(255, 255, 255, 0.08);
        margin-top: 2px;
    }

    .app-navbar .dropdown-item {
        color: #fff;
    }

    .app-navbar .dropdown-item:hover,
    .app-navbar .dropdown-item:focus {
        background-color: rgba(255, 255, 255, 0.15);
        color: #fff;
    }

    .status-card {
        padding: 36px 28px;
    }

    .auth-card {
        padding: 32px 26px 26px;
    }

    .app-table {
        font-size: 0.88rem;
    }

    .app-table thead th,
    .app-table tbody td {
        padding: 10px 12px;
    }
}

/* ---------- Celular (<= 575.98px) — piso mínimo, no es el target principal ---------- */
@media (max-width: 575.98px) {
    body::before {
        background-size: 260px auto;
    }

    .home-hero {
        min-height: 40vh;
    }

    .auth-page {
        padding: 16px;
    }

    .auth-card {
        padding: 28px 20px 22px;
    }

    .status-card {
        padding: 32px 20px;
        max-width: 100%;
    }

    .status-code {
        font-size: 2.6rem;
    }

    .app-table-search-wrap {
        max-width: 100%;
    }

    /* Encabezado de página (título + botón de acción) — pasa a apilado para que no se aprieten */
    .d-flex.justify-content-between.align-items-center.mb-3 {
        flex-wrap: wrap;
        row-gap: 10px;
    }

    .d-flex.justify-content-between.align-items-center.mb-3 > .btn {
        width: 100%;
    }
}

/* ---------- Tablas anchas: scroll horizontal propio, nunca desborda la página ---------- */
.table-responsive {
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
}

.table-responsive > .app-table {
    box-shadow: none;
    margin-bottom: 0;
}

/* ==========================================================================
   Página de detalle (Client/Details y similares) — tarjeta de información
   ========================================================================== */

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

.detail-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.detail-avatar {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    background: var(--brand-primary-light);
    color: var(--brand-primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.detail-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-color);
    margin: 0 0 4px;
}

.detail-subtitle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.detail-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.info-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 24px 28px;
    margin-bottom: 20px;
}

.info-card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-color);
    margin: 0 0 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.info-card-title i {
    color: var(--brand-primary);
}

.info-field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 32px;
}

.info-field-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.info-field-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
    word-break: break-word;
}

/* Secciones todavía sin módulo propio (Órdenes, Ventas...) — el espacio ya queda reservado */
.info-card-placeholder .info-card-title {
    color: var(--text-muted);
}

.info-card-placeholder .app-table-empty {
    padding: 24px 12px;
}

.info-card-soon {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    background: #f1f1f2;
    padding: 3px 9px;
    border-radius: 999px;
    margin-left: auto;
}

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

/* Carrusel de imágenes en Details (Product y similares) — espacio reservado, aspect-ratio fijo para evitar layout shift */
.product-media-card {
    padding: 0;
    overflow: hidden;
    position: relative;
}

.product-media-manage-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 5;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.product-media-carousel,
.product-media-carousel .carousel-inner,
.product-media-carousel .carousel-item {
    height: 100%;
}

.product-media-carousel {
    aspect-ratio: 1 / 1;
}

.product-media-placeholder {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--bg-muted, #f6f7f9);
    color: var(--text-muted);
    text-align: center;
    padding: 24px;
}

.product-media-placeholder i {
    font-size: 2.5rem;
    color: var(--border-color);
}

.product-media-placeholder span:not(.info-card-soon) {
    font-size: 0.9rem;
    font-weight: 600;
}

/* ==========================================================================
   Catálogo de productos (Product/Catalog) — grid de tarjetas para que el
   vendedor le muestre al cliente
   ========================================================================== */

.catalog-filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.catalog-pill {
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 6px 16px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 150ms ease;
}

.catalog-pill:hover {
    border-color: var(--brand-primary);
    color: var(--brand-primary-dark);
}

.catalog-pill.active {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: #fff;
}

.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 20px;
}

.catalog-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 150ms ease, box-shadow 150ms ease;
}

.catalog-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.catalog-card-media {
    aspect-ratio: 4 / 3;
}

.catalog-media-placeholder i {
    font-size: 2rem;
}

.catalog-card-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.catalog-card-category {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--brand-primary-dark);
}

.catalog-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-color);
    margin: 0;
}

.catalog-card-code {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0 0 8px;
    min-height: 1.1em;
}

.catalog-card-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.catalog-card-price {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-color);
}

.catalog-card-img,
.product-media-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ==========================================================================
   Gestor de imágenes de producto (Details) y miniaturas (tabla admin)
   ========================================================================== */

.product-image-upload-form {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.product-image-upload-form input[type="file"] {
    flex: 1;
    min-width: 200px;
}

.product-image-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.product-image-thumb-wrap {
    position: relative;
    width: 90px;
    height: 90px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.product-image-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.product-image-thumb-wrap .btn-delete-image {
    position: absolute;
    bottom: 4px;
    right: 4px;
    padding: 2px 6px;
    line-height: 1;
}

table.app-table .product-image-thumb {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    object-fit: cover;
}

/* ==========================================================================
   Órdenes desde el catálogo — barra de orden activa, botón "+", panel lateral
   y selector de cliente (Product/Catalog + order-catalog.js)
   ========================================================================== */

.btn-brand-auto {
    width: auto;
    padding: 6px 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Junto a botones btn-sm (cabeceras de detalle) mantiene la misma altura */
.btn-sm.btn-brand-auto {
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    gap: 6px;
}

.btn-outline-brand {
    border: 1px solid var(--brand-primary);
    color: var(--brand-primary-dark);
    background: var(--bg-card);
    font-weight: 600;
}

.btn-outline-brand:hover,
.btn-outline-brand:focus-visible {
    background: var(--brand-primary-light);
    color: var(--brand-primary-dark);
    border-color: var(--brand-primary-dark);
}

/* Barra sticky: sigue visible mientras se recorre el catálogo */
.order-bar {
    position: sticky;
    top: 12px;
    z-index: 1010;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: 12px 16px;
    margin-bottom: 16px;
    min-height: 64px;
}

.order-bar.has-order {
    border-left-color: var(--brand-primary);
}

.order-bar-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.order-bar-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--brand-primary-light);
    color: var(--brand-primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.order-bar:not(.has-order) .order-bar-icon {
    background: #f1f1f2;
    color: var(--text-muted);
}

.order-bar-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.order-bar-title {
    font-weight: 700;
    color: var(--text-color);
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.order-bar-cc {
    font-weight: 500;
    color: var(--text-muted);
}

.order-bar-meta {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.order-bar-meta strong {
    color: var(--text-color);
}

.order-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.order-bar-actions .btn {
    min-height: 40px;
}

.order-bar-count {
    background: rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 0.75rem;
}

.order-bar-release {
    width: 40px;
    padding: 0;
}

.order-bar.pulse {
    animation: order-bar-pulse 600ms ease-out;
}

@keyframes order-bar-pulse {
    0% { box-shadow: 0 0 0 0 rgba(47, 93, 80, 0.45); }
    100% { box-shadow: 0 0 0 12px rgba(47, 93, 80, 0); }
}

/* Botón "+" sobre la imagen de cada tarjeta */
.catalog-card-media-wrap {
    position: relative;
}

.catalog-add-btn {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 3; /* por encima de los controles del carrusel */
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--brand-primary);
    color: #fff;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.25);
    transition: background-color 150ms ease, transform 150ms ease;
}

.catalog-add-btn:hover {
    background: var(--brand-primary-dark);
    transform: scale(1.06);
}

.catalog-add-btn:focus-visible {
    outline: 3px solid var(--brand-accent);
    outline-offset: 2px;
}

.catalog-add-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.catalog-add-btn.is-loading:disabled {
    background: var(--brand-primary);
    cursor: progress;
}

.catalog-card-qty {
    position: absolute;
    left: 12px;
    top: 12px;
    z-index: 3;
    background: var(--brand-accent);
    color: #1f2937;
    font-weight: 700;
    font-size: 0.8rem;
    border-radius: 999px;
    padding: 3px 10px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
}

.catalog-card.in-order {
    outline: 2px solid var(--brand-primary-light);
}

/* Panel lateral de la orden */
.order-panel {
    --bs-offcanvas-width: 440px;
    font-family: var(--font-base);
}

.order-panel-header {
    border-bottom: 1px solid var(--border-color);
    align-items: flex-start;
}

.order-panel-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 4px;
    color: var(--text-color);
}

.order-panel-sub {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.order-panel.is-busy .order-panel-body,
.order-panel.is-busy .order-panel-footer {
    opacity: 0.6;
    pointer-events: none;
}

.order-panel-empty {
    padding: 32px 12px;
}

.order-lines {
    list-style: none;
    margin: 0;
    padding: 0;
}

.order-line {
    padding: 14px 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.order-line:last-child {
    border-bottom: none;
}

.order-line-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.order-line-name {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.92rem;
}

.order-line-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.order-line-discount {
    color: var(--brand-primary-dark);
    font-weight: 600;
}

.order-line-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.order-line-total {
    margin-left: auto;
    font-weight: 700;
    color: var(--text-color);
    font-variant-numeric: tabular-nums;
}

.qty-stepper {
    display: inline-flex;
    align-items: stretch;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.qty-stepper button {
    width: 40px;
    min-height: 40px;
    border: none;
    background: #f6f7f9;
    color: var(--text-color);
    font-size: 0.8rem;
}

.qty-stepper button:hover:not(:disabled) {
    background: var(--brand-primary-light);
    color: var(--brand-primary-dark);
}

.qty-stepper button:disabled {
    color: #c4c7cc;
    cursor: not-allowed;
}

.qty-stepper input {
    width: 56px;
    border: none;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    text-align: center;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    -moz-appearance: textfield;
}

.qty-stepper input::-webkit-outer-spin-button,
.qty-stepper input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.qty-stepper input:focus-visible,
.qty-stepper button:focus-visible,
.order-line-remove:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: -2px;
}

.order-line-remove {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
}

.order-line-remove:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.order-panel-footer {
    border-top: 1px solid var(--border-color);
    padding: 16px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fafbfc;
}

.order-panel-footer:empty {
    display: none;
}

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

.order-totals {
    margin: 0;
}

/* Descuento a toda la orden: botón del panel del catálogo y textos del diálogo (order-discount.js) */
.order-panel-discount {
    align-self: flex-start;
    width: auto;
}

.order-discount-intro {
    font-size: 0.92rem;
    margin-bottom: 8px;
}

.order-discount-cap {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.order-discount-list {
    text-align: left;
    font-size: 0.9rem;
    margin: 8px auto 0;
    padding-left: 20px;
    max-width: 340px;
}

.order-totals > div {
    display: flex;
    justify-content: space-between;
    font-size: 0.88rem;
    color: var(--text-muted);
    padding: 2px 0;
}

.order-totals dt {
    font-weight: 500;
}

.order-totals dd {
    margin: 0;
    font-variant-numeric: tabular-nums;
}

.order-totals .order-totals-total {
    color: var(--text-color);
    font-size: 1.05rem;
    font-weight: 700;
    border-top: 1px solid var(--border-color);
    margin-top: 4px;
    padding-top: 8px;
}

.order-totals .order-totals-total dt {
    font-weight: 700;
}

.order-panel-footer .btn-brand:disabled {
    background: #9ca3af;
}

.order-panel-release {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-decoration: none;
}

.order-panel-release:hover {
    color: var(--text-color);
}

/* Selector de cliente */
.order-client-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.order-client-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.order-client-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    width: 100%;
    min-height: 48px;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    transition: border-color 150ms ease, background-color 150ms ease;
}

.order-client-item:hover,
.order-client-item:focus-visible {
    border-color: var(--brand-primary);
    background: var(--brand-primary-light);
    outline: none;
}

.order-client-name {
    font-weight: 600;
    color: var(--text-color);
}

.order-client-cc {
    font-weight: 500;
    color: var(--text-muted);
}

.order-client-id {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.order-client-empty {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 12px 4px;
}

@media (max-width: 575.98px) {
    .order-bar {
        top: 8px;
        padding: 10px 12px;
    }

    .order-bar-actions {
        width: 100%;
    }

    .order-bar-actions .btn-brand {
        flex: 1;
        justify-content: center;
    }
}

.order-panel-links {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

/* ==========================================================================
   Órdenes: listado y detalle (Order/Index, Order/Details, tarjeta del cliente)
   ========================================================================== */

.badge-order {
    font-weight: 600;
    font-size: 0.72rem;
    padding: 5px 10px;
    border-radius: 999px;
    background: #f1f1f2;
    color: var(--text-muted);
}

.badge-order-inprocess {
    background: var(--brand-primary-light);
    color: var(--brand-primary-dark);
}

.badge-order-pending {
    background: #fbf3df;
    color: #7a5a12;
}

.badge-order-completed {
    background: #dcfce7;
    color: #166534;
}

.badge-order-cancelled {
    background: var(--danger-bg);
    color: #9b1c1c;
}

/* Retornada: su venta se anuló (gris violáceo, distinto de cancelada) */
.badge-order-returned {
    background: #ede9fe;
    color: #5b21b6;
}

.badge-order-active {
    background: var(--brand-accent);
    color: #1f2937;
}

.order-list-filter {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.order-list-filter-clear {
    margin-left: 8px;
    color: var(--brand-primary-dark);
    font-weight: 600;
    text-decoration: none;
}

.catalog-filter-pills a.catalog-pill {
    text-decoration: none;
}

.order-number-link {
    font-weight: 700;
    color: var(--brand-primary-dark);
    text-decoration: none;
}

.order-number-link:hover {
    text-decoration: underline;
}

.order-amount {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.order-no-iva {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
}

.detail-avatar .fa-file-invoice {
    font-size: 1.4rem;
}

.order-state-note {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fbf3df;
    color: #7a5a12;
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.order-card-count {
    margin-left: auto;
    background: #f1f1f2;
    color: var(--text-muted);
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 0.75rem;
}

.order-lines-table .order-input {
    width: 90px;
    margin-left: auto;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.order-lines-table td {
    vertical-align: middle;
}

.order-lines-table td:first-child {
    min-width: 170px;
}

.order-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 12px 0 0;
}

.order-client-grid {
    grid-template-columns: 1fr;
    gap: 12px;
}

.order-client-link {
    color: var(--brand-primary-dark);
    text-decoration: none;
}

.order-client-link:hover {
    text-decoration: underline;
}

.order-card-link {
    margin-left: auto;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--brand-primary-dark);
    text-decoration: none;
}

.order-card-link:hover {
    text-decoration: underline;
}

body.order-busy {
    cursor: progress;
}

body.order-busy main {
    pointer-events: none;
    opacity: 0.7;
}

/* Tarjeta "Órdenes" en el detalle del cliente */
.client-order-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.client-order-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    min-height: 48px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: inherit;
    text-decoration: none;
    transition: border-color 150ms ease, background-color 150ms ease;
}

.client-order-item:hover,
.client-order-item:focus-visible {
    border-color: var(--brand-primary);
    background: var(--brand-primary-light);
    color: inherit;
}

.client-order-main,
.client-order-side {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.client-order-side {
    align-items: flex-end;
    gap: 4px;
}

.client-order-number {
    font-weight: 700;
    color: var(--text-color);
}

.client-order-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.client-order-total {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-size: 0.9rem;
}

/* ==========================================================================
   Ventas: indicadores, estados de pago, progreso de cobro y abonos
   (Sales/Index, Sales/Details, tarjeta "Ventas" del cliente, nota en la orden)
   ========================================================================== */

/* Nota verde (orden completada / venta recién creada) — misma forma que .order-state-note */
.order-state-note-done {
    background: #dcfce7;
    color: #166534;
}

.order-state-note-done a {
    color: #14532d;
    font-weight: 700;
}

/* Cuatro indicadores del mismo ancho; en pantallas medianas y en celular, 2x2 */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.kpi-tile {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 118px;
    border-top: 3px solid transparent;
}

.kpi-tile-alert {
    border-top-color: var(--danger);
}

.kpi-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.kpi-value {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-color);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.kpi-value-ok { color: #166534; }
.kpi-value-warn { color: #8a5a00; }
.kpi-value-danger { color: #b42318; }

.kpi-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: auto;
}

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

/* En celular sigue en 2x2 (simétrico y corto), con números más chicos */
@media (max-width: 575.98px) {
    .kpi-grid {
        gap: 10px;
    }

    .kpi-tile {
        min-height: 0;
        padding: 14px;
    }

    .kpi-value {
        font-size: 1.05rem;
    }
}

/* Estado de pago: color + texto (nunca solo color) */
.badge-pay {
    font-weight: 600;
    font-size: 0.72rem;
    padding: 5px 10px;
    border-radius: 999px;
}

.badge-pay-pending {
    background: #fbf3df;
    color: #7a5a12;
}

.badge-pay-partial {
    background: #e0ecff;
    color: #1d4ed8;
}

.badge-pay-paid {
    background: #dcfce7;
    color: #166534;
}

.badge-pay-voided {
    background: #f1f1f2;
    color: var(--text-muted);
}

/* Venta anulada: nota gris con borde rojo (misma forma que .order-state-note) */
.order-state-note-voided {
    background: #f6f6f7;
    color: #374151;
    border-left: 4px solid var(--danger);
}

.order-state-note-voided a {
    color: #111827;
    font-weight: 700;
}

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

/* Filas anuladas del listado: atenuadas, el número tachado */
.sales-row-voided td {
    color: var(--text-muted);
}

.sales-row-voided .order-number-link {
    text-decoration: line-through;
}

/* Movimiento de inventario "Venta" (verde de la marca) */
.badge-tx-sale {
    background: var(--brand-primary);
    color: #fff;
}

/* Movimiento de inventario "Devolución por anulación" */
.badge-tx-return {
    background: #ccfbf1;
    color: #115e59;
}

.badge-overdue {
    background: var(--danger-bg);
    color: #9b1c1c;
    font-weight: 700;
    font-size: 0.72rem;
    padding: 5px 10px;
    border-radius: 999px;
}

/* Barra de cobro */
.pay-progress {
    height: 6px;
    background: #eef0f3;
    border-radius: 999px;
    overflow: hidden;
    min-width: 90px;
}

.pay-progress-lg {
    height: 8px;
    margin: 6px 0 2px;
}

.pay-progress-bar {
    height: 100%;
    background: var(--brand-primary);
    border-radius: 999px;
    transition: width 300ms ease;
}

.pay-progress-bar.is-complete {
    background: #16a34a;
}

.pay-progress-text {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    margin-top: 3px;
}

.sales-table td {
    vertical-align: middle;
}

/* Cliente legible en una o dos líneas; fechas sin cortes */
.sales-table td:nth-child(2) {
    min-width: 190px;
}

.sales-table td:nth-child(3),
.sales-table td:nth-child(8) {
    white-space: nowrap;
}

.sales-table tbody tr.sales-row-overdue td:first-child {
    box-shadow: inset 3px 0 0 var(--danger);
}

/* Lista de abonos */
.payment-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.payment-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-color);
}

.payment-item:last-child {
    border-bottom: none;
}

.payment-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--brand-primary-light);
    color: var(--brand-primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.payment-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.payment-title {
    font-weight: 600;
    color: var(--text-color);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.payment-ref {
    font-weight: 500;
    color: var(--text-muted);
}

.payment-meta {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.payment-void-reason {
    font-size: 0.8rem;
    color: #9b1c1c;
    margin-top: 2px;
}

.payment-amount {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: var(--text-color);
}

.payment-void {
    width: 36px;
    height: 36px;
    padding: 0;
    flex-shrink: 0;
}

.payment-item.is-voided .payment-icon {
    background: #f1f1f2;
    color: var(--text-muted);
}

.payment-item.is-voided .payment-amount {
    text-decoration: line-through;
    color: var(--text-muted);
}

/* Saldo del cliente en su perfil */
.client-debt {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: #f6f7f9;
    margin-bottom: 12px;
}

.client-debt.has-debt {
    background: #fbf3df;
}

.client-debt.has-overdue {
    background: var(--danger-bg);
}

.client-debt-value {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-color);
}

@media (prefers-reduced-motion: reduce) {
    .order-bar.pulse {
        animation: none;
    }

    .catalog-add-btn,
    .catalog-add-btn:hover {
        transition: none;
        transform: none;
    }

    .pay-progress-bar {
        transition: none;
    }
}

/* ---------- Metas del vendedor (.goal-*) ---------- */

.goal-phase-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Selector de mes */
.goal-month-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.goal-month-btn {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--brand-primary);
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.goal-month-btn:hover {
    background: var(--brand-primary-light);
    border-color: var(--brand-primary);
}

.goal-month-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--brand-primary-light);
    border-color: var(--brand-primary);
}

.goal-month-btn.is-disabled {
    opacity: 0.4;
    pointer-events: none;
}

.goal-month-label {
    min-width: 170px;
    text-align: center;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-color);
}

.goal-month-today {
    margin-left: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--brand-primary);
    text-decoration: none;
}

.goal-month-today:hover {
    text-decoration: underline;
}

.goal-note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--brand-primary-light);
    color: var(--brand-primary-dark);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    line-height: 1.45;
}

.goal-note i {
    margin-top: 3px;
}

/* Tarjetas de "Mis metas" */
.goal-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.goal-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 18px 20px;
}

/* Una métrica: valor, estado, barra y lo que falta */
.goal-metric-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.goal-metric-label {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.goal-metric-value {
    margin: 8px 0 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
    overflow-wrap: anywhere;
}

.goal-metric-value strong {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-color);
    margin-right: 4px;
}

.goal-metric-foot {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    margin-top: 10px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.goal-metric-pct {
    font-weight: 700;
    color: var(--text-color);
}

/* Barra: relleno = lo logrado; marca oscura = ritmo esperado a hoy */
.goal-bar {
    position: relative;
    height: 12px;
    border-radius: 999px;
    background: #eceff1;
}

.goal-bar-fill {
    height: 100%;
    border-radius: 999px;
    background: #9ca3af;
    transition: width 0.4s ease;
}

.goal-bar.goal-s-met .goal-bar-fill { background: #2f8f5b; }
.goal-bar.goal-s-ok .goal-bar-fill { background: var(--brand-primary); }
.goal-bar.goal-s-behind .goal-bar-fill { background: #d9a233; }
.goal-bar.goal-s-miss .goal-bar-fill { background: #d4574a; }

.goal-bar-pace {
    position: absolute;
    top: -4px;
    bottom: -4px;
    width: 3px;
    margin-left: -1.5px;
    border-radius: 2px;
    background: var(--text-color);
}

/* Estado en texto (el color nunca es lo único que informa) */
.goal-status {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
}

.goal-status.goal-s-met { background: #dcfce7; color: #166534; }
.goal-status.goal-s-ok { background: var(--brand-primary-light); color: var(--brand-primary-dark); }
.goal-status.goal-s-behind { background: #fff4d6; color: #8a5a00; }
.goal-status.goal-s-miss { background: var(--danger-bg); color: #b42318; }
.goal-status.goal-s-none { background: #f1f2f4; color: #4b5563; }

.goal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    margin: 4px 0 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.goal-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.goal-legend-bar {
    display: inline-block;
    width: 22px;
    height: 8px;
    border-radius: 999px;
    background: var(--brand-primary);
}

.goal-legend-pace {
    display: inline-block;
    width: 3px;
    height: 14px;
    border-radius: 2px;
    background: var(--text-color);
}

.goal-help {
    font-size: 0.8rem;
    color: var(--text-muted);
    max-width: 760px;
    margin-bottom: 28px;
}

.goal-h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 12px;
}

/* Historial */
.goal-history td {
    vertical-align: top;
}

.goal-history-current td {
    background: var(--brand-primary-light);
}

.goal-history-sub {
    margin-top: 3px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.goal-history-none {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* Equipo: una tarjeta por vendedor con sus tres métricas en fila */
.goal-team {
    display: grid;
    gap: 16px;
}

.goal-seller {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 18px 22px 22px;
}

.goal-seller-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.goal-seller-name {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
}

.goal-seller-email {
    font-size: 0.8rem;
    color: var(--text-muted);
    overflow-wrap: anywhere;
}

.goal-seller-body {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 28px;
}

.goal-modal-month {
    font-weight: 700;
    color: var(--brand-primary-dark);
    margin-bottom: 14px;
}

.goal-modal-help {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

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

    .goal-seller-body {
        gap: 20px;
    }
}

@media (max-width: 575.98px) {
    .goal-month-label {
        min-width: 0;
        flex: 1;
    }

    .goal-seller {
        padding: 16px;
    }

    .goal-seller-head {
        flex-direction: column;
    }
}

@media (prefers-reduced-motion: reduce) {
    .goal-bar-fill {
        transition: none;
    }
}

/* Metas dentro del perfil (Account/Details) */
.goal-profile-sep {
    margin: 32px 0 24px;
    border-color: var(--border-color);
    opacity: 1;
}

.goal-profile-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.goal-profile {
    scroll-margin-top: 16px;
}

/* ---------- CABYS de productos (.cabys-*) ---------- */

.cabys-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 560px;
}

.cabys-code {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.3px;
}

/* Selector del catálogo oficial (SweetAlert) */
.cabys-picker-intro {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0 0 8px;
}

.cabys-picker-input {
    width: 100% !important;
    margin: 0 0 12px !important;
    box-sizing: border-box;
}

.cabys-picker-results {
    max-height: 340px;
    overflow-y: auto;
    text-align: left;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.cabys-picker-empty {
    padding: 18px;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.cabys-option {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

.cabys-option:last-child {
    border-bottom: 0;
}

.cabys-option:hover,
.cabys-option:has(input:checked) {
    background: var(--brand-primary-light);
}

.cabys-option input {
    margin-top: 5px;
    accent-color: var(--brand-primary);
}

.cabys-option-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.cabys-option-code {
    font-weight: 700;
    font-size: 0.88rem;
    font-variant-numeric: tabular-nums;
}

.cabys-option-tax {
    margin-left: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    background: #f1f2f4;
    color: #4b5563;
}

.cabys-option-desc {
    font-size: 0.9rem;
    color: var(--text-color);
}

.cabys-option-cat {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.cabys-picker-tax {
    margin-top: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #8a5a00;
    min-height: 1.2em;
}

/* ---------- Facturación electrónica (.invoice-*) ---------- */

.invoice-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.invoice-item {
    padding: 14px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.invoice-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.invoice-title {
    font-weight: 700;
}

.invoice-meta {
    margin-top: 4px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.invoice-clave {
    margin-top: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.75rem;
    color: var(--text-color);
    overflow-wrap: anywhere;
}

.invoice-note {
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--brand-primary-light);
    color: var(--brand-primary-dark);
    font-size: 0.85rem;
    line-height: 1.45;
}

.invoice-note.is-warn {
    background: #fff4d6;
    color: #8a5a00;
}

.invoice-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.invoice-actions .btn {
    width: auto;
}

.invoice-start {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.invoice-hint {
    font-size: 0.82rem;
    color: var(--text-muted);
    flex: 1;
    min-width: 200px;
}

/* Estado del comprobante (texto siempre visible, no solo color) */
.badge-inv {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #f1f2f4;
    color: #4b5563;
}

.badge-inv-ok { background: #dcfce7; color: #166534; }
.badge-inv-wait { background: var(--brand-primary-light); color: var(--brand-primary-dark); }
.badge-inv-warn { background: #fff4d6; color: #8a5a00; }
.badge-inv-bad { background: var(--danger-bg); color: #b42318; }

/* Diálogo de revisión */
.invoice-summary {
    text-align: left;
    margin: 12px 0 8px;
}

.invoice-summary > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.92rem;
}

.invoice-summary dt { font-weight: 600; color: var(--text-muted); }
.invoice-summary dd { margin: 0; text-align: right; }
.invoice-summary .is-total { font-size: 1.05rem; font-weight: 700; }
.invoice-summary .is-total dt { color: var(--text-color); }
.invoice-summary select { min-width: 190px; }

.invoice-errors {
    text-align: left;
    margin: 12px 0 0;
    padding: 10px 12px 10px 30px;
    border-radius: var(--radius-sm);
    background: var(--danger-bg);
    color: #b42318;
    font-size: 0.88rem;
    line-height: 1.5;
}

.invoice-warning {
    margin: 12px 0 0;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: #fff4d6;
    color: #8a5a00;
    font-size: 0.85rem;
    line-height: 1.5;
    text-align: left;
}

/* ---------- Reportes (.report-*) ---------- */

.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.report-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
}

.report-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 6px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.report-title i {
    color: var(--brand-primary);
    width: 20px;
    text-align: center;
}

.report-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 14px;
}

.report-form {
    margin-top: auto;
}

.report-form .form-label {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.report-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}

.report-chip {
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-color);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.report-chip:hover,
.report-chip.is-active {
    background: var(--brand-primary-light);
    border-color: var(--brand-primary);
    color: var(--brand-primary-dark);
}

.report-chip:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--brand-primary-light);
}

.report-btn {
    width: 100%;
}

/* ---------- Catálogo: disponibilidad y cantidad en la tarjeta ---------- */

.catalog-card-stock {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: flex-start;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--brand-primary-light);
    color: var(--brand-primary-dark);
    margin-bottom: 8px;
}

.catalog-card-stock.is-low { background: #fff4d6; color: #8a5a00; }
.catalog-card-stock.is-out { background: var(--danger-bg); color: #b42318; }

.catalog-card-qtyrow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.catalog-card-qtyrow[hidden] { display: none; }

.catalog-card-qtylabel {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* Versión compacta del selector del panel de la orden */
.qty-stepper-sm button {
    width: 32px;
    min-height: 32px;
}

.qty-stepper-sm input {
    width: 54px;
    text-align: center;
    border: 0;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    font-size: 0.9rem;
    font-weight: 600;
    -moz-appearance: textfield;
}

.qty-stepper-sm input:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--brand-primary-light);
}

.qty-stepper-sm input::-webkit-outer-spin-button,
.qty-stepper-sm input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ---------- Orden en revisión: aviso de cancelación automática (.order-expiry) ---------- */
.order-expiry {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
    font-size: 0.78rem;
    color: #6b7280;
    white-space: nowrap;
}

.order-expiry.is-soon {
    color: #9a2b22;
    font-weight: 600;
}


/* ---------- Bloqueo por mora en el perfil del cliente (.credit-alert) ---------- */
.credit-alert {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid transparent;
}

.credit-alert > i {
    font-size: 1.15rem;
}

.credit-alert-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.9rem;
}

.credit-alert.is-blocked {
    background: var(--danger-bg);
    border-color: #f1b5b0;
    color: #9a2b22;
}

.credit-alert.is-override {
    background: #fff6df;
    border-color: #ecd593;
    color: #7a5a0d;
}

.credit-alert.is-notice {
    background: var(--brand-primary-light);
    border-color: #c9dcd6;
    color: var(--brand-primary-dark);
}

@media (max-width: 575.98px) {
    .credit-alert {
        flex-wrap: wrap;
    }
}

/* ---------- Cambios por producto defectuoso en el detalle de la venta (.sale-exchange-*) ---------- */
.sale-exchange-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sale-exchange-list li {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid #eef0f2;
}

.sale-exchange-list li:last-child {
    border-bottom: 0;
}

.sale-exchange-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.sale-exchange-product {
    font-weight: 600;
}

.sale-exchange-reason {
    font-size: 0.88rem;
    color: #6b7280;
    overflow-wrap: anywhere;
}

.sale-exchange-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    font-size: 0.8rem;
    color: #6b7280;
    white-space: nowrap;
}

@media (max-width: 575.98px) {
    .sale-exchange-list li {
        flex-direction: column;
        gap: 4px;
    }

    .sale-exchange-side {
        align-items: flex-start;
        flex-direction: row;
        gap: 10px;
    }
}
