/* Focused UX layer for inventory and point-of-sale screens. */
:root {
    --ux-focus: #2563eb;
    --ux-focus-ring: rgba(37, 99, 235, 0.24);
    --ux-surface-muted: #f8fafc;
    --ux-border-soft: #dbe5f1;
}

#view-inventario :is(button, input, select, textarea, a):focus-visible,
#view-ventas :is(button, input, select, textarea, a):focus-visible {
    outline: 3px solid var(--ux-focus-ring);
    outline-offset: 2px;
}

#view-inventario .app-tabs {
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: thin;
}

#view-inventario .app-tab {
    min-height: 44px;
    white-space: nowrap;
}

#view-inventario .inventory-workspace,
#view-inventario .inventory-surface-panel,
#view-inventario .inventory-hero-card {
    min-width: 0;
}

#view-inventario .inventory-toolbar-premium,
#view-inventario .purchase-toolbar-premium {
    position: sticky;
    top: 0;
    z-index: 3;
    background: rgba(255, 255, 255, 0.94);
    background: color-mix(in srgb, var(--app-panel, #fff) 94%, transparent);
    backdrop-filter: blur(10px);
}

#view-inventario .table-wrapper-premium {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
}

#view-inventario .data-table-premium {
    min-width: 760px;
}

#view-inventario .data-table-premium th {
    position: sticky;
    top: 0;
    z-index: 1;
    white-space: nowrap;
}

#view-inventario .inventory-empty-state,
#view-inventario .inventory-empty-state-premium {
    min-height: 240px;
}

#view-inventario .inventory-skeleton-card {
    min-height: 190px;
}

#view-inventario .inventory-error-state {
    display: grid;
    justify-items: center;
    gap: 0.65rem;
    max-width: 32rem;
    margin: 2rem auto;
    padding: 2rem;
    border: 1px solid #ef4444;
    border-radius: 1rem;
    background: #fff;
    color: var(--app-text, #172033);
    text-align: center;
}

#view-inventario .inventory-error-state-icon {
    display: grid;
    width: 2.75rem;
    height: 2.75rem;
    place-items: center;
    border-radius: 50%;
    background: #fff;
    color: #b91c1c;
    border: 1px solid #ef4444;
}

#view-inventario .inventory-error-state h3,
#view-inventario .inventory-error-state p {
    margin: 0;
}

#view-inventario .inventory-error-state p {
    color: var(--app-muted, #64748b);
}

#view-inventario .inventory-toolbar-premium input,
#view-inventario .inventory-toolbar-premium select,
#view-inventario .purchase-toolbar-premium select,
#view-inventario .inventory-hero-search {
    min-height: 44px;
}

#view-ventas .pos-layout {
    grid-template-columns: minmax(320px, 1fr) minmax(420px, 1.25fr);
}

#view-ventas .pos-catalog-panel,
#view-ventas .pos-checkout-panel,
#view-ventas .pos-tab-content,
#view-ventas .pos-product-card {
    min-width: 0;
}

#view-ventas .pos-search-wrapper input {
    min-height: 44px;
}

#view-ventas .pos-product-card {
    min-height: 214px;
    content-visibility: auto;
    contain-intrinsic-size: 214px;
}

#view-ventas .pos-product-card[role="button"] {
    cursor: pointer;
}

#view-ventas .pos-product-actions .btn,
#view-ventas .pos-cat-tab,
#view-ventas .pos-tab-btn,
#view-ventas .pos-manual-actions .btn {
    min-height: 44px;
}

#view-ventas .pos-checkout-tabs-header {
    position: sticky;
    top: 0;
    z-index: 4;
}

#view-ventas .pos-checkout-btn[aria-busy="true"] {
    cursor: progress;
    position: relative;
}

#view-ventas .pos-checkout-btn[aria-busy="true"]::before {
    content: "";
    width: 0.9em;
    height: 0.9em;
    margin-right: 0.5em;
    display: inline-block;
    vertical-align: -0.12em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: inventory-pos-spin 0.7s linear infinite;
}

#view-ventas .pos-cart-item {
    content-visibility: auto;
    contain-intrinsic-size: 180px;
}

#view-ventas .pos-cart-empty-state {
    min-height: 180px;
}

@keyframes inventory-pos-spin {
    to { transform: rotate(360deg); }
}

body[data-theme="dark"] {
    --ux-focus: #93c5fd;
    --ux-focus-ring: rgba(147, 197, 253, 0.35);
    --ux-surface-muted: #101d2e;
    --ux-border-soft: rgba(148, 163, 184, 0.18);
}

body[data-theme="dark"] #view-inventario .inventory-toolbar-premium,
body[data-theme="dark"] #view-inventario .purchase-toolbar-premium {
    background: rgba(15, 27, 45, 0.94);
    background: color-mix(in srgb, var(--app-panel, #0f1b2d) 94%, transparent);
}

body[data-theme="dark"] #view-inventario .inventory-error-state {
    background: #450a0a;
    background: color-mix(in srgb, #450a0a 42%, var(--app-panel, #0f1b2d));
}

body[data-theme="dark"] #view-inventario .inventory-error-state-icon {
    background: #7f1d1d;
    color: #fecaca;
}

@media (max-width: 1100px) {
    #view-ventas .pos-layout {
        grid-template-columns: 1fr;
    }

    #view-ventas .pos-checkout-panel {
        order: 1;
    }

    #view-ventas .pos-catalog-panel {
        order: 2;
    }
}

@media (max-width: 760px) {
    .os-window {
        width: 100%;
    }

    .occ-side-drawer:not(.open) {
        display: none;
    }

    .occ-side-drawer.open {
        right: 0;
        width: min(100vw, 500px);
    }

    #view-inventario .app-tabs {
        display: flex;
        justify-content: flex-start;
        gap: 6px;
        padding: 6px;
        border-radius: 16px;
    }

    #view-inventario .app-tab {
        flex: 0 0 auto;
        padding-inline: 14px;
    }

    #view-inventario .inventory-toolbar-premium,
    #view-inventario .purchase-toolbar-premium {
        position: static;
    }

    #view-inventario .inventory-hero-actions,
    #view-inventario .inventory-toolbar-premium,
    #view-inventario .purchase-toolbar-premium {
        align-items: stretch;
    }

    #view-inventario .inventory-toolbar-premium > *,
    #view-inventario .purchase-toolbar-premium > * {
        flex: 1 1 100%;
        max-width: none;
    }

    #view-ventas .pos-layout {
        gap: 14px;
    }

    #view-ventas .pos-product-card {
        min-height: 0;
    }

    #view-ventas .pos-summary-options {
        grid-template-columns: 1fr 1fr;
    }

    #view-ventas .pos-discount-field {
        grid-column: 1 / -1;
    }

    /* Hallazgos E2E autenticados: conservar la lectura de tablas y evitar
       que KPIs/navegacion empujen el viewport fuera de pantalla. */
    #view-inventario .inventory-kpi,
    #view-inventario .inventory-kpi * {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    #view-cobranzas .cobranzas-main-panel,
    #view-cobranzas .cobranzas-layout {
        min-width: 0;
        max-width: 100%;
    }

    #view-cobranzas .cobranzas-main-panel {
        overflow-x: auto;
        overscroll-behavior-x: contain;
    }

    #view-cobranzas .cobranzas-table {
        min-width: 680px;
    }

    #view-taller .workshop-submodule-tabs {
        display: flex;
        max-width: 100%;
        overflow-x: auto;
        align-items: stretch;
        justify-content: flex-start;
        padding: 6px;
        gap: 8px;
    }

    #view-taller .workshop-submodule-tab {
        flex: 0 0 170px;
        min-height: 60px;
    }

    #view-taller .module-actions,
    #view-taller .section-actions {
        max-width: 100%;
        flex-wrap: wrap;
    }
}

@media (prefers-reduced-motion: reduce) {
    #view-inventario *,
    #view-ventas * {
        scroll-behavior: auto !important;
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

/* -------------------------------------------------------------------------
   POS visual system — scoped strictly to Ventas. The rest of the ERP keeps
   its existing module cards, documents and brand colors.
   ------------------------------------------------------------------------- */
#view-ventas {
    --pos-petroleum: #123b52;
    --pos-petroleum-deep: #0b2638;
    --pos-metal: #2f6f93;
    --pos-metal-light: #e8f2f7;
    --pos-purple: #6d4bd8;
    --pos-purple-soft: #f0ecff;
    --pos-ink: #15283a;
    --pos-muted: #6b7d8d;
    --pos-line: #dce7ee;
    /* Fondo neutro para que el hero no quede visualmente cortado al hacer
       scroll; el color distintivo vive en la cabecera y en los paneles. */
    background: #f3f7f9;
}

#view-ventas .app-header {
    background: linear-gradient(110deg, var(--pos-petroleum-deep), var(--pos-petroleum) 58%, #245d78);
    color: #fff;
    border: 0;
    box-shadow: 0 14px 34px rgba(11, 38, 56, 0.18);
}

#view-ventas .app-header-title h1 {
    color: #fff;
    letter-spacing: -0.025em;
}

#view-ventas .btn-back {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.1);
}

#view-ventas .btn-pos-header {
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
    background: rgba(255, 255, 255, 0.11);
}

#view-ventas .btn-pos-header:hover {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 18px rgba(4, 20, 31, 0.2);
}

#view-ventas .btn-pos-clear {
    background: transparent;
    border-color: #dc2626;
    color: #dc2626;
}

#view-ventas .app-content {
    max-width: 1640px;
}

#view-ventas .pos-layout {
    gap: 18px;
    grid-template-columns: minmax(370px, 0.82fr) minmax(0, 1.68fr);
}

#view-ventas .pos-catalog-panel,
#view-ventas .pos-checkout-panel {
    border: 1px solid rgba(141, 166, 184, 0.42);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: 0 18px 42px rgba(25, 56, 77, 0.1);
    backdrop-filter: blur(12px);
}

#view-ventas .pos-catalog-panel {
    border-top: 4px solid var(--pos-metal);
}

#view-ventas .pos-checkout-panel {
    border-top: 4px solid var(--pos-purple);
}

#view-ventas .pos-catalog-header {
    margin: -24px -24px 20px;
    padding: 22px 24px 16px;
    background:
        radial-gradient(circle at 96% 0%, rgba(47, 111, 147, 0.18), transparent 14rem),
        linear-gradient(145deg, #f9fcfd, #edf4f7);
    border-bottom: 1px solid var(--pos-line);
}

#view-ventas .pos-search-wrapper input {
    height: 48px;
    border: 1px solid #c6d6df;
    border-radius: 14px;
    color: var(--pos-ink);
    background: #fff;
    box-shadow: 0 5px 15px rgba(30, 73, 96, 0.06);
}

#view-ventas .pos-search-wrapper input:focus {
    border-color: var(--pos-metal);
    box-shadow: 0 0 0 4px rgba(47, 111, 147, 0.15), 0 8px 20px rgba(30, 73, 96, 0.1);
}

#view-ventas .pos-search-wrapper .search-icon {
    color: var(--pos-metal);
}

#view-ventas .pos-view-toggle {
    border-color: #cbdbe3;
    background: rgba(255, 255, 255, 0.74);
}

#view-ventas .pos-view-toggle .btn.active {
    background: var(--pos-petroleum);
    box-shadow: 0 5px 12px rgba(18, 59, 82, 0.22);
}

#view-ventas .pos-manual-actions .btn,
#view-ventas .pos-view-toggle .btn {
    min-height: 42px;
    border-radius: 11px;
}

#view-ventas .pos-manual-actions .btn:hover {
    border-color: var(--pos-metal);
    color: var(--pos-petroleum);
    background: var(--pos-metal-light);
}

#view-ventas .pos-category-tabs {
    gap: 5px;
    border: 0;
    padding: 3px;
    border-radius: 13px;
    background: rgba(213, 227, 234, 0.72);
}

#view-ventas .pos-cat-tab {
    flex: 1;
    padding: 10px 14px;
    color: var(--pos-muted);
    border-radius: 10px;
}

#view-ventas .pos-cat-tab:hover {
    color: var(--pos-petroleum);
    background: rgba(255, 255, 255, 0.72);
}

#view-ventas .pos-cat-tab.active {
    color: #fff;
    background: linear-gradient(135deg, var(--pos-petroleum), var(--pos-metal));
    box-shadow: 0 5px 12px rgba(18, 59, 82, 0.2);
}

#view-ventas .pos-product-card {
    border-color: #d7e3e9;
    border-radius: 16px;
    padding: 16px;
    background: linear-gradient(155deg, #fff 0%, #f5f9fb 100%);
    box-shadow: 0 8px 20px rgba(22, 55, 75, 0.07);
}

#view-ventas .pos-product-card:hover,
#view-ventas .pos-product-card:focus-visible {
    border-color: rgba(109, 75, 216, 0.48);
    box-shadow: 0 15px 30px rgba(55, 49, 104, 0.15);
    transform: translateY(-3px);
}

#view-ventas .pos-product-thumb {
    border-color: #c8dbe4;
    background: linear-gradient(145deg, #e5f0f5, #cbdde6);
    color: var(--pos-petroleum);
}

#view-ventas .pos-product-copy strong,
#view-ventas .pos-product-prices strong {
    color: var(--pos-ink);
}

#view-ventas .pos-product-meta span {
    color: var(--pos-petroleum);
    background: var(--pos-metal-light);
    border-color: #c8dfe8;
}

#view-ventas .pos-product-actions .btn.primary,
#view-ventas .pos-checkout-btn {
    background: linear-gradient(135deg, var(--pos-purple), #5135b7);
    border-color: transparent;
    box-shadow: 0 8px 16px rgba(81, 53, 183, 0.22);
}

#view-ventas .pos-product-actions .btn.primary:hover,
#view-ventas .pos-checkout-btn:hover {
    background: linear-gradient(135deg, #7959e5, var(--pos-purple));
    box-shadow: 0 10px 20px rgba(81, 53, 183, 0.3);
}

#view-ventas .pos-checkout-tabs-header {
    margin: -24px -24px 20px;
    padding: 7px;
    gap: 6px;
    background: linear-gradient(180deg, #edf4f7, #e5eef3);
    border-bottom: 1px solid #cbdde5;
    box-shadow: inset 0 -1px 0 rgba(18, 59, 82, 0.08);
}

#view-ventas .pos-tab-btn {
    min-height: 48px;
    border: 0;
    border-radius: 12px;
    color: #6b7d8d;
    background: rgba(255, 255, 255, 0.46);
}

#view-ventas .pos-tab-btn:hover {
    color: var(--pos-petroleum);
    background: rgba(255, 255, 255, 0.84);
}

#view-ventas .pos-tab-btn.active {
    color: #fff;
    border: 0;
    background: linear-gradient(135deg, var(--pos-metal), var(--pos-purple));
    box-shadow: 0 7px 16px rgba(55, 62, 133, 0.22);
}

#view-ventas .pos-tab-count {
    min-width: 22px;
    padding: 2px 7px;
    border-radius: 99px;
    color: var(--pos-petroleum-deep);
    background: #fff;
    font-size: 0.72rem;
}

body.pos-payment-open #pos-content-billing .pos-customer-card,
body.pos-payment-open #pos-content-billing .pos-summary-card {
    border-color: var(--pos-line);
    border-radius: 17px;
    background: linear-gradient(150deg, #fff, #f4f8fa);
    box-shadow: 0 9px 22px rgba(20, 58, 78, 0.06);
}

body.pos-payment-open #pos-content-billing .pos-customer-card {
    padding: 21px 22px;
}

body.pos-payment-open #pos-content-billing .pos-customer-card .form-grid.two {
    column-gap: 18px;
    row-gap: 17px;
}

body.pos-payment-open #pos-content-billing .pos-customer-card {
    position: relative;
    overflow: hidden;
}

body.pos-payment-open #pos-content-billing .pos-customer-card::before {
    content: "DATOS DE LA OPERACIÓN";
    display: block;
    margin-bottom: 15px;
    color: var(--pos-petroleum);
    font-size: 0.69rem;
    font-weight: 900;
    letter-spacing: 0.13em;
}

body.pos-payment-open #pos-content-billing .pos-customer-card label,
body.pos-payment-open #pos-content-billing .pos-summary-card label {
    color: var(--pos-petroleum);
    font-size: 0.74rem;
    font-weight: 800;
}

body.pos-payment-open #pos-content-billing .pos-customer-card input,
body.pos-payment-open #pos-content-billing .pos-summary-card input,
body.pos-payment-open #pos-content-billing .pos-customer-card select {
    min-height: 44px;
    border-color: #cbdbe3;
    border-radius: 11px;
    color: var(--pos-ink);
    background: #fff;
}

body.pos-payment-open #pos-content-billing .pos-customer-card input::placeholder,
body.pos-payment-open #pos-content-billing .pos-summary-card input::placeholder {
    color: #81909c;
    font-size: 0.84rem;
    opacity: 0.95;
}

body.pos-payment-open #pos-content-billing .pos-customer-card input:focus,
body.pos-payment-open #pos-content-billing .pos-summary-card input:focus,
body.pos-payment-open #pos-content-billing .pos-customer-card select:focus {
    border-color: var(--pos-purple);
    box-shadow: 0 0 0 3px rgba(109, 75, 216, 0.13);
}

body.pos-payment-open #pos-content-billing .pos-select-trigger {
    min-height: 44px;
    border-color: #cbdbe3;
    border-radius: 11px;
    color: var(--pos-ink);
    background: #fff;
}

body.pos-payment-open #pos-content-billing .pos-select-label {
    color: var(--pos-petroleum);
    font-weight: 800;
}

body.pos-payment-open #pos-content-billing .pos-total-row-preview,
body.pos-payment-open #pos-content-billing .pos-total-box {
    border: 0;
    background: linear-gradient(120deg, var(--pos-petroleum-deep), var(--pos-metal) 60%, var(--pos-purple));
    box-shadow: 0 12px 24px rgba(18, 59, 82, 0.22);
}

body.pos-payment-open #pos-content-billing .pos-total-row-preview span,
body.pos-payment-open #pos-content-billing .pos-total-row-preview strong {
    color: #fff;
}

body.pos-payment-open #pos-content-billing .pos-total-row-preview strong {
    font-size: 1.65rem;
    letter-spacing: -0.03em;
}

#view-ventas .pos-cart-toolbar {
    padding: 4px 2px 18px;
    border-bottom: 1px solid var(--pos-line);
}

#view-ventas .pos-cart-heading-icon {
    color: #fff;
    background: linear-gradient(135deg, var(--pos-purple), var(--pos-metal));
    box-shadow: 0 8px 16px rgba(81, 53, 183, 0.22);
}

#view-ventas .pos-cart-heading h2,
#view-ventas .pos-summary-topline span:first-child {
    color: var(--pos-petroleum-deep);
}

#view-ventas .pos-cart-item {
    border-color: #d5e3ea;
    background: #fff;
    box-shadow: 0 7px 16px rgba(20, 58, 78, 0.05);
}

#view-ventas .pos-cart-item:focus-within {
    border-color: rgba(109, 75, 216, 0.48);
    box-shadow: 0 0 0 3px rgba(109, 75, 216, 0.1);
}

#view-ventas .pos-cart-name-input,
#view-ventas .pos-cart-field input {
    border-color: #cbdbe3;
    background: #f9fbfc;
}

/* Three-column vehicle picker for service applications. */
#modal-service-applications-manager .service-application-vehicle-results {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-content: start;
    gap: 10px;
    max-height: 320px;
    margin-top: 10px;
    padding: 10px;
    overflow: auto;
    border: 1px solid var(--ux-border-soft, #dbe4f0);
    border-radius: 14px;
    background: var(--app-panel-soft, #f8fafc);
}

#modal-service-applications-manager .service-application-vehicle-option {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: start;
    gap: 9px;
    min-width: 0;
    min-height: 76px;
    padding: 12px;
    border: 1px solid var(--ux-border-soft, #dbe4f0);
    border-radius: 12px;
    background: var(--app-panel, #fff);
    cursor: pointer;
    transition: border-color .16s ease, background .16s ease, box-shadow .16s ease, transform .16s ease;
}

#modal-service-applications-manager .service-application-vehicle-option:hover {
    border-color: rgba(79, 70, 229, .5);
    box-shadow: 0 6px 16px rgba(79, 70, 229, .09);
    transform: translateY(-1px);
}

#modal-service-applications-manager .service-application-vehicle-option:has(input:checked) {
    border-color: #635bdb;
    background: rgba(99, 91, 219, .07);
    box-shadow: inset 0 0 0 1px rgba(99, 91, 219, .12);
}

#modal-service-applications-manager .service-application-vehicle-option:focus-within {
    outline: 2px solid rgba(99, 91, 219, .35);
    outline-offset: 2px;
}

#modal-service-applications-manager .service-application-vehicle-option input {
    width: 17px;
    height: 17px;
    margin: 2px 0 0;
    accent-color: #5545df;
}

#modal-service-applications-manager .service-application-vehicle-copy {
    display: grid;
    gap: 5px;
    min-width: 0;
}

#modal-service-applications-manager .service-application-vehicle-copy strong {
    overflow-wrap: anywhere;
    color: var(--app-text, #172033);
    font-size: .91rem;
    font-weight: 850;
}

#modal-service-applications-manager .service-application-vehicle-copy > span {
    color: var(--app-muted, #64748b);
    font-size: .78rem;
    line-height: 1.4;
}

#modal-service-applications-manager .service-application-vehicle-limit,
#modal-service-applications-manager .service-application-vehicle-empty {
    grid-column: 1 / -1;
    padding: 12px;
    color: var(--app-muted, #64748b);
    font-size: .84rem;
}

@media (max-width: 760px) {
    #modal-service-applications-manager .service-application-vehicle-results {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    #modal-service-applications-manager .service-application-vehicle-results {
        grid-template-columns: minmax(0, 1fr);
        gap: 8px;
        padding: 8px;
    }

    #modal-service-applications-manager .service-application-vehicle-option {
        min-height: 64px;
    }
}

#view-ventas .pos-cart-field-value {
    display: inline-flex;
    min-height: 36px;
    align-items: center;
    color: var(--pos-petroleum-deep);
    font-size: .9rem;
}

#view-ventas .line-action-edit {
    color: #3158b7;
    border-color: rgba(49, 88, 183, .22);
    background: rgba(49, 88, 183, .06);
}

#modal-pos-item-edit .pos-item-edit-modal {
    width: min(680px, 94vw);
}

#modal-pos-item-edit .pos-item-reference-card {
    margin-top: 18px;
    padding: 14px 16px;
    border: 1px solid #d7e2e9;
    border-radius: 14px;
    background: linear-gradient(145deg, #f8fbfc, #eef5f8);
}

#modal-pos-item-edit .pos-item-reference-heading {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: baseline;
    color: var(--pos-petroleum-deep);
}

#modal-pos-item-edit .pos-item-reference-heading small {
    color: var(--pos-muted);
    font-size: .72rem;
}

#modal-pos-item-edit .pos-item-reference-list {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
}

#modal-pos-item-edit .pos-item-reference-row {
    display: grid;
    gap: 4px;
    padding: 9px 10px;
    border: 1px solid rgba(49, 88, 183, .12);
    border-radius: 10px;
    background: #fff;
}

#modal-pos-item-edit .pos-item-reference-row span {
    color: var(--pos-muted);
    font-size: .72rem;
}

#modal-pos-item-edit .pos-item-reference-row strong {
    color: var(--pos-petroleum-deep);
}

#modal-pos-item-edit .pos-item-reference-empty {
    margin: 0;
    color: var(--pos-muted);
    font-size: .8rem;
}

#modal-pos-item-edit .pos-item-edit-footer {
    justify-content: flex-end;
    padding: 18px 0 0;
}

#view-ventas .pos-summary-topline,
#view-ventas .pos-breakdown-row {
    color: var(--pos-muted);
}

#view-ventas .pos-cart-summary {
    border-color: rgba(109, 75, 216, 0.2);
    background: linear-gradient(145deg, #f8f7ff, #eef5f8);
}

@media (max-width: 760px) {
    #view-ventas .pos-layout { gap: 14px; }
    #view-ventas .pos-catalog-header,
    #view-ventas .pos-checkout-tabs-header { margin-inline: -16px; }
    #view-ventas .pos-category-tabs { overflow-x: auto; }
    #view-ventas .pos-cat-tab { flex: 0 0 auto; }
    #view-ventas .pos-manual-actions { width: 100%; }
    #view-ventas .pos-manual-actions .btn { flex: 1; }
    #modal-pos-item-edit .pos-item-reference-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    #modal-pos-item-edit .pos-item-reference-heading { display: grid; }
}

/* -------------------------------------------------------------------------
   POS final layout corrections
   Keep checkout visible on the left while the catalog gets its own scroll
   surface. These rules intentionally live in the isolated UX layer so the
   shared ERP panels keep their existing behavior.
   ------------------------------------------------------------------------- */
#view-ventas {
    background: #f3f7f9;
    background-repeat: no-repeat;
    background-attachment: initial;
}

#view-ventas .app-content {
    background: transparent;
}

#view-ventas .pos-layout {
    align-items: start;
    grid-template-areas: "checkout catalog";
    grid-template-columns: minmax(390px, 0.92fr) minmax(0, 1.72fr);
}

#view-ventas .pos-checkout-panel {
    grid-area: checkout;
    order: initial;
    position: sticky;
    top: 16px;
    align-self: start;
    overflow: visible;
}

#view-ventas .pos-catalog-panel {
    grid-area: catalog;
    order: initial;
    max-height: calc(100vh - 164px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

#view-ventas .pos-catalog-header {
    position: sticky;
    top: 0;
    z-index: 3;
}

/* The parent panel/card used to clip the menu before its options could be
   read. Keep the open menu above the form without changing the native value
   or the checkout API contract. */
#view-ventas .pos-checkout-panel,
body.pos-payment-open #pos-content-billing,
body.pos-payment-open #pos-content-billing .pos-customer-card {
    overflow: visible;
}

body.pos-payment-open #pos-content-billing .pos-custom-select {
    z-index: 1;
}

body.pos-payment-open #pos-content-billing .pos-custom-select.is-open {
    z-index: 20;
}

body.pos-payment-open #pos-content-billing .pos-select-options {
    max-height: none;
    overflow: visible;
}

/* Keep both checkbox toggles readable without letting them dominate the
   sale summary. The discount field remains the flexible third column. */
#view-ventas .pos-summary-options {
    grid-template-columns: repeat(2, max-content) minmax(108px, 1fr);
    gap: 6px;
}

#view-ventas .pos-summary-options .quote-toggle {
    gap: 5px;
    padding: 5px 8px;
    border-radius: 8px;
    box-shadow: none;
    font-size: 0.74rem;
    line-height: 1.2;
}

#view-ventas .pos-summary-options .quote-toggle input {
    width: 14px;
    height: 14px;
}

@media (max-width: 1100px) {
    #view-ventas .pos-layout {
        grid-template-areas: "checkout" "catalog";
        grid-template-columns: 1fr;
    }

    #view-ventas .pos-checkout-panel {
        position: static;
    }

    #view-ventas .pos-catalog-panel {
        max-height: none;
        overflow: visible;
    }

    #view-ventas .pos-catalog-header {
        position: static;
    }
}

@media (max-width: 760px) {
    #view-ventas .pos-summary-options {
        grid-template-columns: 1fr 1fr;
    }

    #view-ventas .pos-discount-field {
        grid-column: 1 / -1;
    }
}

/* Keep the POS title vertically centered inside the existing 80px header
   without changing its buttons, icons, palette, or overall height. */
#view-ventas .app-header-title {
    min-height: 100%;
    align-items: center;
}

#view-ventas .app-header-title h1 {
    margin: 0;
    line-height: 1.1;
    padding-bottom: 5px;
}

/* Restore the POS to the page's original scroll surface. Keep these final
   overrides scoped to Ventas so shared ERP modules retain their behavior. */
#view-ventas .pos-catalog-panel {
    max-height: none;
    overflow: visible;
    overscroll-behavior: auto;
    scrollbar-gutter: auto;
}

#view-ventas .pos-catalog-header {
    position: static;
}

#view-ventas .app-header {
    background: transparent;
    box-shadow: none;
    color: #0f172a;
}

#view-ventas .app-header-title h1 {
    color: #0f172a;
}

#view-ventas .btn-back,
#view-ventas .btn-pos-header {
    color: #0f172a;
    border-color: rgba(15, 23, 42, 0.28);
    background: rgba(255, 255, 255, 0.72);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.86);
}

#view-ventas .btn-pos-header i {
    color: inherit;
}

#view-ventas .btn-back:hover,
#view-ventas .btn-pos-header:hover {
    color: #0f172a;
    border-color: rgba(15, 23, 42, 0.46);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.16), inset 0 1px 0 #fff;
    transform: translateY(-1px);
}

/* -------------------------------------------------------------------------
   POSVENTAS reference composition
   Keep ORION's existing state and IDs, but present the catalog and the
   customer/cart workspace in the same direction as the reference POS.
   ------------------------------------------------------------------------- */
#view-ventas .pos-layout {
    grid-template-areas: "catalog checkout";
    grid-template-columns: minmax(0, 1fr) minmax(360px, 410px);
    align-items: start;
}

#view-ventas .pos-catalog-panel {
    grid-area: catalog;
    max-height: none;
    overflow: visible;
    overscroll-behavior: auto;
    scrollbar-gutter: auto;
}

#view-ventas .pos-checkout-panel {
    grid-area: checkout;
    position: sticky;
    top: 16px;
    align-self: start;
    overflow: visible;
}

#view-ventas .pos-cart-client {
    display: grid;
    gap: 14px;
    margin: 0 0 16px;
    min-width: 0;
    box-sizing: border-box;
    padding: 16px;
    border: 1px solid var(--pos-line);
    border-radius: 18px;
    background: linear-gradient(150deg, #fff, #f4f8fa);
    box-shadow: 0 9px 22px rgba(20, 58, 78, 0.06);
}

#view-ventas .pos-cart-client-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--pos-petroleum-deep);
}

#view-ventas .pos-cart-client-heading strong,
#view-ventas .pos-cart-client-heading small {
    display: block;
}

#view-ventas .pos-cart-client-heading small {
    margin-top: 2px;
    color: var(--pos-muted);
    font-size: 0.75rem;
}

#view-ventas .pos-cart-client .pos-cart-heading-icon {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    font-size: 0.86rem;
}

#view-ventas .pos-cart-client .form-grid.two {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
}

#view-ventas .pos-cart-client .pos-client-lookup,
#view-ventas .pos-cart-client .form-grid.two {
    width: 100%;
    min-width: 0;
}

#view-ventas .pos-cart-client label {
    min-width: 0;
    color: var(--pos-petroleum);
    font-size: 0.72rem;
    font-weight: 800;
}

#view-ventas .pos-cart-client input {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-height: 42px;
    border-color: #cbdbe3;
    border-radius: 11px;
    background: #fff;
}

#view-ventas .pos-cart-client input:focus {
    border-color: var(--pos-purple);
    box-shadow: 0 0 0 3px rgba(109, 75, 216, 0.13);
}

#view-ventas .pos-checkout-tabs-header {
    margin: 0 0 16px;
    border-radius: 14px;
}

#view-ventas #pos-content-cart {
    min-height: 300px;
}

@media (max-width: 1100px) {
    #view-ventas .pos-layout {
        grid-template-areas: "catalog" "checkout";
        grid-template-columns: 1fr;
    }

    #view-ventas .pos-catalog-panel {
        max-height: none;
        overflow: visible;
    }

    #view-ventas .pos-checkout-panel {
        position: static;
    }
}

@media (max-width: 760px) {
    #view-ventas .pos-cart-client .form-grid.two {
        grid-template-columns: 1fr;
    }

    #view-ventas .pos-cart-client,
    #view-ventas .pos-checkout-panel {
        border-radius: 16px;
    }
}

/* POS polish: make the selected client, summary trigger and payment modal feel like one workflow. */
#view-ventas .pos-client-selected {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 58px;
    padding: 10px 12px;
    border: 1px solid rgba(47, 111, 147, .2);
    border-radius: 14px;
    background: linear-gradient(120deg, #f0f8fb, #f5f3ff);
}

#view-ventas .pos-client-selected.hidden,
#pos-content-billing .pos-payment-selector.hidden {
    display: none !important;
}

#view-ventas .pos-client-selected-main {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 10px;
}

#view-ventas .pos-client-selected-icon {
    display: grid;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    place-items: center;
    border-radius: 11px;
    color: #fff;
    background: linear-gradient(135deg, var(--pos-petroleum), var(--pos-purple));
    box-shadow: 0 6px 14px rgba(81, 53, 183, .18);
}

#view-ventas .pos-client-selected-main div {
    display: grid;
    min-width: 0;
    gap: 2px;
}

#view-ventas .pos-client-selected-main strong,
#view-ventas .pos-client-selected-main small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#view-ventas .pos-client-selected-main strong {
    color: var(--pos-petroleum-deep);
    font-size: .84rem;
}

#view-ventas .pos-client-selected-main small {
    color: var(--pos-muted);
    font-size: .72rem;
    font-weight: 700;
}

#view-ventas .pos-client-change-btn {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border: 1px solid rgba(81, 53, 183, .24);
    border-radius: 9px;
    color: var(--pos-purple);
    background: #fff;
    cursor: pointer;
    font-size: .73rem;
    font-weight: 900;
    white-space: nowrap;
}

#view-ventas .pos-client-change-btn:hover {
    color: #fff;
    background: var(--pos-purple);
}

#view-ventas .pos-cart-details-toggle {
    display: inline-flex;
    min-width: 178px;
    min-height: 46px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 11px 7px 12px;
    border: 1px solid rgba(81, 53, 183, .22);
    border-radius: 13px;
    color: var(--pos-petroleum-deep);
    background: linear-gradient(135deg, #fff, #f3f0ff);
    box-shadow: 0 7px 15px rgba(81, 53, 183, .08);
    cursor: pointer;
    text-align: left;
}

#view-ventas .pos-cart-details-toggle:hover:not(:disabled) {
    border-color: var(--pos-purple);
    box-shadow: 0 9px 18px rgba(81, 53, 183, .14);
    transform: translateY(-1px);
}

#view-ventas .pos-cart-details-toggle:disabled {
    cursor: not-allowed;
    opacity: .55;
}

#view-ventas .pos-cart-details-toggle-copy {
    display: grid;
    min-width: 0;
    grid-template-columns: auto 1fr;
    align-items: center;
    column-gap: 7px;
}

#view-ventas .pos-cart-details-toggle-copy > i {
    grid-row: span 2;
    color: var(--pos-purple);
    font-size: .9rem;
}

#view-ventas .pos-cart-details-label {
    color: var(--pos-petroleum-deep);
    font-size: .78rem;
    font-weight: 900;
}

#view-ventas .pos-cart-details-toggle-copy small {
    color: var(--pos-muted);
    font-size: .62rem;
    font-weight: 700;
    white-space: nowrap;
}

#view-ventas .pos-cart-details-chevron {
    color: var(--pos-purple);
    transition: transform 160ms ease;
}

#view-ventas .pos-cart-details-chevron.is-expanded {
    transform: rotate(180deg);
}

body.pos-payment-open #pos-content-billing .pos-payment-modal-head {
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(47, 111, 147, .14);
}

body.pos-payment-open #pos-content-billing .pos-payment-choice-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 18px 0 14px;
}

body.pos-payment-open #pos-content-billing .pos-payment-choice {
    min-height: 86px;
    padding: 13px 8px;
    border-color: rgba(47, 111, 147, .24);
    border-radius: 16px;
    font-size: .77rem;
}

body.pos-payment-open #pos-content-billing .pos-payment-choice i {
    font-size: 1.2rem;
}

body.pos-payment-open #pos-content-billing .pos-customer-card {
    margin-bottom: 10px;
}

body.pos-payment-open #pos-content-billing > .pos-summary-card:not(.pos-cart-summary) {
    margin-top: 0;
    margin-bottom: 0;
}

body.pos-payment-open #pos-content-billing #pos-credit-fields[style*="display: none"] {
    display: none !important;
}

body[data-theme="dark"] #view-ventas .pos-client-selected,
body[data-theme="dark"] #view-ventas .pos-cart-details-toggle {
    border-color: rgba(129, 140, 248, .3);
    color: #e7eefb;
    background: linear-gradient(135deg, rgba(30, 41, 59, .95), rgba(49, 46, 129, .45));
}

body[data-theme="dark"] #view-ventas .pos-client-selected-main strong,
body[data-theme="dark"] #view-ventas .pos-cart-details-label {
    color: #e7eefb;
}

body[data-theme="dark"] #view-ventas .pos-client-change-btn {
    border-color: rgba(129, 140, 248, .36);
    color: #c4b5fd;
    background: rgba(15, 23, 42, .7);
}

@media (max-width: 760px) {
    #view-ventas .pos-cart-details-toggle {
        min-width: 0;
        flex: 1;
    }

    body.pos-payment-open #pos-content-billing .pos-payment-choice-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

body.pos-payment-open {
    overflow: hidden;
}

#view-ventas.pos-payment-modal-open::before {
    display: none;
}

body.pos-payment-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    background: rgba(9, 25, 38, 0.48);
    backdrop-filter: blur(5px);
    pointer-events: auto;
}

#view-ventas.pos-payment-modal-open .pos-checkout-panel {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

body.pos-payment-open #pos-content-billing {
    position: fixed;
    inset: 50% auto auto 50%;
    z-index: 2147483001;
    display: block !important;
    width: min(700px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    overflow-x: hidden;
    overflow-y: auto;
    margin: 0;
    padding: 24px;
    border: 1px solid rgba(148, 177, 194, 0.5);
    border-radius: 24px;
    background: linear-gradient(155deg, #ffffff, #f3f8fa);
    box-shadow: 0 30px 90px rgba(5, 25, 40, 0.32);
    transform: translate(-50%, -50%);
    pointer-events: auto;
}

body.pos-payment-open #pos-content-billing .pos-customer-card,
body.pos-payment-open #pos-content-billing .pos-summary-card {
    margin-inline: 0;
}

body.pos-payment-open #pos-content-billing .pos-payment-modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

body.pos-payment-open #pos-content-billing .pos-payment-modal-kicker {
    color: var(--pos-purple);
    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0.14em;
}

body.pos-payment-open #pos-content-billing .pos-payment-modal-head h2 {
    margin: 3px 0 2px;
    color: var(--pos-petroleum-deep);
    font-size: 1.4rem;
}

body.pos-payment-open #pos-content-billing .pos-payment-modal-head p {
    margin: 0;
    color: var(--pos-muted);
    font-size: 0.82rem;
}

body.pos-payment-open #pos-content-billing .pos-payment-modal-close {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border: 1px solid #cbdbe3;
    border-radius: 50%;
    color: var(--pos-petroleum-deep);
    background: #fff;
    cursor: pointer;
    font-size: 1.45rem;
    line-height: 1;
}

body.pos-payment-open #pos-content-billing .pos-payment-modal-close:hover {
    border-color: var(--pos-purple);
    color: var(--pos-purple);
}

body.pos-payment-open #pos-content-billing .pos-payment-choice-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 18px 0 14px;
}

body.pos-payment-open #pos-content-billing .pos-payment-choice {
    display: grid;
    min-height: 86px;
    place-items: center;
    gap: 6px;
    padding: 13px 8px;
    border: 1px solid #cbdbe3;
    border-radius: 16px;
    color: var(--pos-muted);
    background: #fff;
    cursor: pointer;
    font-size: 0.77rem;
    font-weight: 800;
    transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

body.pos-payment-open #pos-content-billing .pos-payment-choice i {
    color: var(--pos-metal);
    font-size: 1.2rem;
}

body.pos-payment-open #pos-content-billing .pos-payment-choice:hover,
body.pos-payment-open #pos-content-billing .pos-payment-choice.is-selected {
    border-color: var(--pos-purple);
    color: var(--pos-petroleum-deep);
    background: var(--pos-purple-soft);
    box-shadow: 0 7px 16px rgba(81, 53, 183, 0.12);
    transform: translateY(-1px);
}

body.pos-payment-open #pos-content-billing .pos-payment-choice.is-selected i {
    color: var(--pos-purple);
}

@media (max-width: 760px) {
    body.pos-payment-open #pos-content-billing {
        width: calc(100vw - 20px);
        max-height: calc(100vh - 20px);
        padding: 16px;
        border-radius: 18px;
    }

    body.pos-payment-open #pos-content-billing .pos-payment-choice-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Let the product catalog grow with the page instead of becoming a short scroll box. */
#view-ventas .pos-catalog-panel {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
}

#view-ventas .pos-catalog-panel .pos-catalog-header {
    margin: 0 0 22px;
    border: 1px solid var(--pos-line);
    border-radius: 18px;
}

#view-ventas .pos-pagination {
    justify-content: space-between;
    flex-wrap: wrap;
    margin: 24px 0 4px;
    padding: 14px 0 0;
    border-top: 1px solid var(--pos-line);
}

#view-ventas .pos-pagination-summary {
    color: var(--pos-muted);
    font-size: .78rem;
    font-weight: 800;
}

#view-ventas .pos-pagination-controls,
#view-ventas .pos-page-indexes {
    display: flex;
    align-items: center;
    gap: 6px;
}

#view-ventas .pos-pagination-arrow,
#view-ventas .pos-page-index {
    display: grid;
    place-items: center;
    min-width: 34px;
    height: 34px;
    padding: 0 9px;
    border: 1px solid #cbdbe3;
    border-radius: 9px;
    color: var(--pos-petroleum-deep);
    background: #fff;
    cursor: pointer;
    font-weight: 800;
}

#view-ventas .pos-pagination-arrow {
    font-size: 1.25rem;
    line-height: 1;
}

#view-ventas .pos-pagination-arrow:hover:not(:disabled),
#view-ventas .pos-page-index:hover {
    border-color: var(--pos-metal);
    color: var(--pos-petroleum-deep);
    background: var(--pos-metal-light);
}

#view-ventas .pos-page-index.is-current {
    border-color: var(--pos-purple);
    color: #fff;
    background: linear-gradient(135deg, var(--pos-metal), var(--pos-purple));
    box-shadow: 0 6px 14px rgba(81, 53, 183, .2);
}

#view-ventas .pos-pagination-arrow:disabled,
#view-ventas .pos-tab-btn:disabled,
#view-ventas .pos-checkout-btn:disabled {
    cursor: not-allowed;
    opacity: .5;
}

#view-ventas .pos-tab-btn:disabled {
    background: rgba(226, 232, 240, .55);
    box-shadow: none;
}

#view-ventas .pos-checkout-btn:disabled {
    transform: none;
    filter: grayscale(.25);
    box-shadow: none;
}

#view-ventas .pos-pagination-ellipsis {
    min-width: 20px;
    color: var(--pos-muted);
    text-align: center;
    font-weight: 800;
}

@media (max-width: 760px) {
    #view-ventas .pos-pagination {
        align-items: flex-start;
        flex-direction: column;
    }

    #view-ventas .pos-pagination-controls {
        width: 100%;
        justify-content: space-between;
    }

    #view-ventas .pos-page-indexes {
        overflow-x: auto;
    }
}

/* Compact cart workspace: one surface, one row per item, minimal chrome. */
#view-ventas .pos-checkout-panel {
    container-type: inline-size;
    container-name: pos-checkout;
}

#view-ventas .pos-cart-list {
    display: block;
    max-height: none;
    overflow: visible;
    margin-bottom: 14px;
    padding: 0;
    border: 1px solid var(--pos-line);
    border-radius: 17px;
    background: #fff;
    box-shadow: 0 8px 20px rgba(20, 58, 78, .05);
}

#view-ventas .pos-cart-columns,
#view-ventas .pos-cart-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 82px 86px 68px;
    gap: 8px;
    align-items: center;
}

#view-ventas .pos-cart-columns {
    padding: 10px;
    border-bottom: 1px solid var(--pos-line);
    color: var(--pos-muted);
    background: #f7fafb;
    font-size: .65rem;
    font-weight: 900;
    letter-spacing: .09em;
    text-transform: uppercase;
}

#view-ventas .pos-cart-columns span:nth-child(n+2) {
    text-align: right;
}

#view-ventas .pos-cart-item {
    min-width: 0;
    padding: 13px 10px;
    border: 0;
    border-bottom: 1px solid #e5edf1;
    border-radius: 0;
    background: #fff;
    box-shadow: none;
    transition: background-color 160ms ease;
}

#view-ventas .pos-cart-item:last-child {
    border-bottom: 0;
}

#view-ventas .pos-cart-item:hover,
#view-ventas .pos-cart-item:focus-within {
    border-color: #e5edf1;
    background: #f8fbfc;
    box-shadow: none;
}

#view-ventas .pos-cart-item-controls {
    display: contents;
}

#view-ventas .pos-cart-item-main {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    min-width: 0;
}

#view-ventas .pos-cart-item-thumb {
    display: grid;
    width: 42px;
    height: 42px;
    overflow: hidden;
    place-items: center;
    border: 1px solid #a5f3fc;
    border-radius: 11px;
    color: #0e7490;
    background: #ecfeff;
    font-size: .78rem;
}

#view-ventas .pos-cart-item-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#view-ventas .pos-cart-item-thumb.is-placeholder {
    background: linear-gradient(145deg, #ecfeff, #dff5fa);
}

#view-ventas .pos-cart-item-copy strong {
    display: block;
    display: -webkit-box;
    overflow: hidden;
    color: var(--pos-petroleum-deep);
    font-size: .84rem;
    line-height: 1.2;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

#view-ventas .pos-cart-item-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 3px;
    overflow: hidden;
    white-space: nowrap;
}

#view-ventas .pos-cart-item-meta small {
    overflow: hidden;
    color: var(--pos-muted);
    font-size: .68rem;
    text-overflow: ellipsis;
}

#view-ventas .pos-cart-field,
#view-ventas .pos-cart-line-total {
    min-width: 0;
    gap: 4px;
}

#view-ventas .pos-cart-field > span:first-child,
#view-ventas .pos-cart-line-total > span:first-child {
    color: var(--pos-muted);
    font-size: .63rem;
    font-weight: 900;
    letter-spacing: .07em;
    text-align: right;
    text-transform: uppercase;
}

#view-ventas .pos-cart-field,
#view-ventas .pos-cart-line-total {
    text-align: right;
}

#view-ventas .pos-quantity-stepper {
    justify-content: flex-end;
    min-height: 30px;
    border-color: #d5e3e9;
    border-radius: 9px;
    background: #f8fbfc;
}

#view-ventas .pos-quantity-stepper button {
    width: 24px;
    height: 28px;
    color: var(--pos-petroleum);
}

#view-ventas .pos-quantity-stepper input {
    width: 28px;
    min-height: 28px;
    padding: 0;
    border: 0;
    background: transparent;
    font-size: .8rem;
}

#view-ventas .pos-cart-line-total strong {
    color: var(--pos-petroleum-deep);
    font-size: .9rem;
}

#view-ventas .line-item-actions {
    display: inline-flex;
    flex-direction: row;
    justify-content: flex-end;
    gap: 4px;
}

#view-ventas .line-item-actions .line-action {
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 8px;
    font-size: .72rem;
}

#view-ventas .pos-cart-clear-btn {
    width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    border-radius: 9px;
}

#view-ventas .pos-cart-summary {
    margin-top: 0;
    padding: 16px;
    border-color: rgba(47, 111, 147, .2);
    border-radius: 17px;
    background: linear-gradient(145deg, #fff, #f4f8fa);
    box-shadow: 0 9px 22px rgba(20, 58, 78, .06);
}

@media (max-width: 760px) {
    #view-ventas .pos-cart-list {
        overflow: visible;
    }

    #view-ventas .pos-cart-columns {
        display: none;
    }

    #view-ventas .pos-cart-item {
        grid-template-columns: minmax(0, 1fr) auto auto;
        gap: 10px;
    }

    #view-ventas .pos-cart-item-main {
        grid-column: 1 / -1;
    }

    #view-ventas .pos-cart-field,
    #view-ventas .pos-cart-line-total,
    #view-ventas .line-item-actions {
        grid-column: auto;
    }

    #view-ventas .pos-cart-line-total,
    #view-ventas .line-item-actions {
        align-self: end;
    }
}

/* The checkout column can be narrow even on desktop, so respond to its width rather than the viewport. */
@container pos-checkout (max-width: 560px) {
    #view-ventas .pos-cart-columns {
        display: none;
    }

    #view-ventas .pos-cart-item {
        grid-template-columns: 82px minmax(0, 1fr) 68px;
        row-gap: 9px;
    }

    #view-ventas .pos-cart-item-main {
        grid-column: 1 / -1;
        grid-template-columns: 44px minmax(0, 1fr);
    }

    #view-ventas .pos-cart-field {
        grid-column: 1;
    }

    #view-ventas .pos-cart-line-total {
        grid-column: 2;
    }

    #view-ventas .line-item-actions {
        grid-column: 3;
        justify-self: end;
    }
}

body[data-theme="dark"] #view-ventas .pos-cart-item-thumb {
    border-color: rgba(96, 165, 250, .25);
    color: #93c5fd;
    background: rgba(30, 64, 175, .22);
}

/* Keep the payment total readable over the summary card's light background. */
body.pos-payment-open #pos-content-billing .pos-summary-card .pos-total-row-preview,
body.pos-payment-open #pos-content-billing .pos-summary-card .pos-total-box {
    border: 0 !important;
    color: #fff !important;
    background: linear-gradient(120deg, #123f55 0%, #2f6f93 56%, #5b44d6 100%) !important;
    box-shadow: 0 12px 24px rgba(18, 59, 82, .24) !important;
}

body.pos-payment-open #pos-content-billing .pos-summary-card .pos-total-row-preview span,
body.pos-payment-open #pos-content-billing .pos-summary-card .pos-total-row-preview strong,
body.pos-payment-open #pos-content-billing .pos-summary-card .pos-total-box span,
body.pos-payment-open #pos-content-billing .pos-summary-card .pos-total-box strong {
    color: #fff !important;
}

#view-ventas .pos-total-breakdown-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 4px;
    padding-top: 9px;
    border-top: 1px solid rgba(47, 111, 147, .2);
    color: var(--pos-petroleum-deep);
    font-size: .86rem;
    font-weight: 900;
}

#view-ventas .pos-total-breakdown-row strong {
    color: var(--pos-purple);
    font-size: 1rem;
}

body[data-theme="dark"] #view-ventas .pos-total-breakdown-row {
    border-top-color: rgba(129, 140, 248, .26);
    color: #e7eefb;
}

body[data-theme="dark"] #view-ventas .pos-total-breakdown-row strong {
    color: #c4b5fd;
}

/* System confirmations must sit above the payment modal and its backdrop. */
body.pos-payment-open #modal-system-dialog {
    z-index: 2147483002 !important;
}

/* Compra masiva is the primary replenishment workflow; manual entry remains
   available as a quiet secondary action. */
.purchase-bulk-btn {
    transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}

.purchase-bulk-btn:hover,
.purchase-bulk-btn:focus-visible {
    transform: translateY(-1px);
    filter: saturate(1.08) brightness(1.03);
    box-shadow: 0 11px 24px rgba(79, 70, 229, .36) !important;
}

.purchase-manual-btn {
    transition: color .18s ease, border-color .18s ease, background .18s ease;
}

.purchase-manual-btn:hover,
.purchase-manual-btn:focus-visible {
    color: #4338ca !important;
    border-color: #a5b4fc !important;
    background: #f8faff !important;
}

/* Revisión de ítems de Compra masiva: tarjetas legibles, sin scroll lateral. */
.pdf-items-table-wrapper {
    overflow: visible !important;
    border: 0 !important;
    background: transparent !important;
}

.pdf-items-inner-table {
    display: block;
    width: 100%;
    border-spacing: 0;
}

.pdf-items-inner-table thead {
    display: none;
}

.pdf-items-inner-table tbody {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pdf-items-inner-table tr.pdf-item-row {
    display: grid;
    grid-template-columns: 42px minmax(145px, 1.15fr) 78px 82px minmax(120px, .85fr) minmax(130px, .95fr) minmax(120px, .85fr) minmax(128px, .9fr) 34px;
    grid-template-areas:
        "num code unit qty punit pventa marca total actions"
        "desc desc desc desc desc desc desc desc actions"
        "link link link link link link link link actions";
    gap: 9px 10px;
    padding: 14px;
    border: 1px solid var(--app-border, #dbe3ef);
    border-radius: 14px;
    background: var(--app-panel, #fff);
    box-shadow: 0 4px 12px rgba(15, 23, 42, .045);
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.pdf-items-inner-table tr.pdf-item-row:hover {
    border-color: #a5b4fc;
    box-shadow: 0 8px 20px rgba(79, 70, 229, .10);
    transform: translateY(-1px);
}

.pdf-items-inner-table tr.pdf-item-row > td {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
    vertical-align: initial;
}

.pdf-items-inner-table tr.pdf-item-row > td:nth-child(1) { grid-area: num; }
.pdf-items-inner-table tr.pdf-item-row > td:nth-child(2) { grid-area: code; }
.pdf-items-inner-table tr.pdf-item-row > td:nth-child(3) { grid-area: unit; }
.pdf-items-inner-table tr.pdf-item-row > td:nth-child(4) { grid-area: qty; }
.pdf-items-inner-table tr.pdf-item-row > td:nth-child(5) { grid-area: desc; }
.pdf-items-inner-table tr.pdf-item-row > td:nth-child(6) { grid-area: link; }
.pdf-items-inner-table tr.pdf-item-row > td:nth-child(7) { grid-area: punit; }
.pdf-items-inner-table tr.pdf-item-row > td:nth-child(8) { grid-area: pventa; }
.pdf-items-inner-table tr.pdf-item-row > td:nth-child(9) { grid-area: marca; }
.pdf-items-inner-table tr.pdf-item-row > td:nth-child(10) { grid-area: total; }
.pdf-items-inner-table tr.pdf-item-row > td:nth-child(11) {
    grid-area: actions;
    align-self: start;
    justify-self: end;
}

.pdf-items-inner-table tr.pdf-item-row > td:nth-child(1)::before,
.pdf-items-inner-table tr.pdf-item-row > td:nth-child(2)::before,
.pdf-items-inner-table tr.pdf-item-row > td:nth-child(3)::before,
.pdf-items-inner-table tr.pdf-item-row > td:nth-child(4)::before,
.pdf-items-inner-table tr.pdf-item-row > td:nth-child(5)::before,
.pdf-items-inner-table tr.pdf-item-row > td:nth-child(7)::before,
.pdf-items-inner-table tr.pdf-item-row > td:nth-child(8)::before,
.pdf-items-inner-table tr.pdf-item-row > td:nth-child(9)::before {
    display: block;
    margin: 0 0 4px;
    color: var(--app-muted, #64748b);
    font-size: .66rem;
    font-weight: 800;
    letter-spacing: .04em;
    line-height: 1.1;
    text-transform: uppercase;
}

.pdf-items-inner-table tr.pdf-item-row > td:nth-child(1)::before { content: 'Ítem'; }
.pdf-items-inner-table tr.pdf-item-row > td:nth-child(2)::before { content: 'Código factura'; }
.pdf-items-inner-table tr.pdf-item-row > td:nth-child(3)::before { content: 'Unidad'; }
.pdf-items-inner-table tr.pdf-item-row > td:nth-child(4)::before { content: 'Cantidad'; }
.pdf-items-inner-table tr.pdf-item-row > td:nth-child(5)::before { content: 'Descripción'; }
.pdf-items-inner-table tr.pdf-item-row > td:nth-child(7)::before { content: 'Precio compra'; }
.pdf-items-inner-table tr.pdf-item-row > td:nth-child(8)::before { content: 'Precio venta'; }
.pdf-items-inner-table tr.pdf-item-row > td:nth-child(9)::before { content: 'Marca'; }

.pdf-items-inner-table .pdf-item-num {
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    border-radius: 9px;
    color: #4338ca;
    background: #eef2ff;
    font-size: .82rem;
    font-weight: 850;
}

.pdf-items-inner-table .pdf-item-desc {
    max-width: none;
}

.pdf-items-inner-table .pdf-input {
    box-sizing: border-box;
    max-width: 100%;
}

.pdf-items-inner-table .pdf-item-code,
.pdf-items-inner-table .pdf-item-unit,
.pdf-items-inner-table .pdf-item-cant,
.pdf-items-inner-table .pdf-item-punit,
.pdf-items-inner-table .pdf-item-pventa,
.pdf-items-inner-table .pdf-item-marca {
    width: 100% !important;
}

.pdf-items-inner-table .pdf-item-total {
    display: flex;
    min-height: 32px;
    align-items: center;
    justify-content: flex-end;
    color: var(--app-text, #172033);
    font-size: .88rem;
    font-weight: 850;
}

.pdf-items-inner-table .pdf-item-total::before {
    content: 'Total línea';
    margin-right: auto;
    color: var(--app-muted, #64748b);
    font-size: .66rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.pdf-items-inner-table .pdf-link-container {
    display: inline-flex;
    width: auto !important;
    min-width: 0;
}

.pdf-items-inner-table .pdf-link-container::before {
    display: none;
}

.pdf-items-inner-table .pdf-link-container > div:first-of-type {
    min-width: 0;
}

.pdf-items-inner-table .pdf-link-container > div:first-of-type > div:first-child {
    min-width: 0;
}

.pdf-items-inner-table .pdf-link-head {
    display: flex !important;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex-wrap: wrap;
}

.pdf-items-inner-table .pdf-link-mode-switch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.pdf-items-inner-table .pdf-link-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 6px 11px;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #fff;
    color: #475569;
    cursor: pointer;
    font: inherit;
    font-size: .75rem;
    font-weight: 800;
    line-height: 1.1;
    transition: color .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease;
}

.pdf-items-inner-table .pdf-link-pill:hover,
.pdf-items-inner-table .pdf-link-pill:focus-visible {
    border-color: #818cf8;
    color: #3730a3;
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .12);
}

.pdf-items-inner-table .pdf-link-pill.is-selected.is-new {
    border-color: #a5b4fc;
    background: #eef2ff;
    color: #4338ca;
}

.pdf-items-inner-table .pdf-link-pill.is-selected.is-link {
    border-color: #86efac;
    background: #ecfdf5;
    color: #047857;
}

.pdf-items-inner-table .pdf-link-action {
    flex: 0 0 auto;
    min-height: 32px;
    padding: 5px 9px !important;
    white-space: nowrap;
}

.pdf-items-inner-table .pdf-link-container .pdf-new-item-inputs {
    grid-template-columns: minmax(160px, 260px) !important;
}

.pdf-items-inner-table .pdf-link-container .pdf-new-item-inputs input:first-child {
    display: none;
}

.pdf-match-status {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    min-height: 22px;
    margin-top: 2px;
    padding: 3px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    color: #475569;
    background: #f8fafc;
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .02em;
}

.pdf-match-status.is-new {
    color: #4338ca;
    border-color: #c7d2fe;
    background: #eef2ff;
}

.pdf-match-status.is-linked {
    color: #047857;
    border-color: #a7f3d0;
    background: #ecfdf5;
}

.pdf-match-status.is-conflict {
    color: #b91c1c;
    border-color: #ef4444;
    background: #fff;
}

.pdf-match-status.is-general {
    color: #0369a1;
    border-color: #bae6fd;
    background: #f0f9ff;
}

body[data-theme="dark"] .pdf-items-inner-table tr.pdf-item-row {
    background: var(--app-panel, #0f172a);
    border-color: #334155;
}

body[data-theme="dark"] .pdf-items-inner-table .pdf-item-num {
    color: #c4b5fd;
    background: rgba(99, 102, 241, .20);
}

body[data-theme="dark"] .pdf-items-inner-table .pdf-link-container {
    border-top-color: #334155;
}

@media (max-width: 900px) {
    .pdf-items-inner-table tr.pdf-item-row {
        grid-template-columns: 42px minmax(0, 1fr) 78px 34px;
        grid-template-areas:
            "num code qty actions"
            "unit unit punit punit"
            "pventa pventa marca marca"
            "desc desc desc desc"
            "total total total actions"
            "link link link actions";
    }

    .pdf-items-inner-table tr.pdf-item-row > td:nth-child(3)::before {
        content: 'Unidad de medida';
    }

}

@media (max-width: 520px) {
    .pdf-items-inner-table tr.pdf-item-row {
        grid-template-columns: 40px minmax(0, 1fr) 34px;
        grid-template-areas:
            "num code actions"
            "unit qty qty"
            "punit pventa pventa"
            "marca marca marca"
            "desc desc desc"
            "total total actions"
            "link link actions";
        gap: 8px;
        padding: 12px;
    }

    .pdf-items-inner-table tr.pdf-item-row > td:nth-child(3)::before {
        content: 'Unidad';
    }

    .pdf-items-inner-table .pdf-item-total {
        justify-content: flex-start;
    }

    .pdf-items-inner-table .pdf-item-total::before {
        margin-right: 8px;
    }

    .pdf-items-inner-table .pdf-link-mode-switch { flex-wrap: wrap; }
}

@media (max-width: 680px) {
    .purchase-bulk-btn,
    .purchase-manual-btn {
        flex: 1 1 100%;
        justify-content: center;
    }

    .bulk-import-intro {
        align-items: flex-start !important;
        flex-wrap: wrap;
    }

    .bulk-import-intro > div:last-child {
        width: 100%;
        justify-content: flex-start !important;
    }
}

/* Voucher: ventana compacta, imagen legible y controles visibles sobre cabecera oscura. */
#modal-compra-voucher .compra-voucher-modal {
    width: min(720px, calc(100vw - 28px));
    max-width: calc(100vw - 28px);
    max-height: min(850px, calc(100vh - 28px));
    border-radius: 20px;
}

#modal-compra-voucher .compra-voucher-header {
    min-height: 76px;
    padding: 16px 20px;
}

#modal-compra-voucher .compra-voucher-header .modal-window-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

#modal-compra-voucher .compra-voucher-header .modal-close,
#modal-compra-voucher .compra-voucher-header .modal-minimize {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, .2) !important;
    border-radius: 11px;
    color: #fff !important;
    background: rgba(255, 255, 255, .12) !important;
    box-shadow: none;
}

#modal-compra-voucher .compra-voucher-header .modal-close:hover,
#modal-compra-voucher .compra-voucher-header .modal-minimize:hover,
#modal-compra-voucher .compra-voucher-header .modal-close:focus-visible,
#modal-compra-voucher .compra-voucher-header .modal-minimize:focus-visible {
    border-color: rgba(255, 255, 255, .52) !important;
    color: #fff !important;
    background: rgba(255, 255, 255, .22) !important;
    transform: none;
}

#modal-compra-voucher .compra-voucher-body {
    min-height: 0;
    max-height: min(670px, calc(100vh - 170px));
    padding: 14px;
}

#modal-compra-voucher .compra-voucher-viewer {
    min-height: 0;
    max-height: min(610px, calc(100vh - 230px));
    padding: 14px;
    background: #eef3f9;
}

#modal-compra-voucher .compra-voucher-viewer.is-image {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
    background: #e7edf5;
}

#modal-compra-voucher .compra-voucher-image {
    width: auto;
    max-width: 100%;
    max-height: min(570px, calc(100vh - 260px));
    border: 1px solid rgba(148, 163, 184, .25);
    border-radius: 9px;
    background: #fff;
    object-fit: contain;
}

#modal-compra-voucher .compra-voucher-pdf {
    min-height: min(570px, calc(100vh - 260px));
}

#modal-compra-voucher .compra-voucher-file-meta {
    font-weight: 500;
}

@media (max-width: 600px) {
    #modal-compra-voucher .compra-voucher-modal {
        width: min(560px, calc(100vw - 20px));
        max-width: calc(100vw - 20px);
    }

    #modal-compra-voucher .compra-voucher-body {
        max-height: calc(100vh - 155px);
        padding: 10px;
    }

    #modal-compra-voucher .compra-voucher-viewer {
        max-height: calc(100vh - 245px);
    }

    #modal-compra-voucher .compra-voucher-image {
        max-height: calc(100vh - 275px);
    }
}

/* Payment status in the Compras list: actionable only while a balance exists. */
#view-inventario .purchase-payment-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 32px;
    padding: 6px 10px;
    border: 1px solid var(--ux-border-soft);
    border-radius: 999px;
    background: var(--app-panel, #fff);
    color: var(--app-text, #1e293b);
    font-size: .78rem;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
}

#view-inventario button.purchase-payment-status {
    cursor: pointer;
    transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

#view-inventario button.purchase-payment-status:hover,
#view-inventario button.purchase-payment-status:focus-visible {
    transform: translateY(-1px);
    border-color: #818cf8;
    box-shadow: 0 4px 12px rgba(79, 70, 229, .14);
}

#view-inventario .purchase-payment-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #64748b;
    flex: 0 0 auto;
}

#view-inventario .purchase-payment-status.is-paid {
    border-color: rgba(16, 185, 129, .3);
    color: #047857;
    background: rgba(16, 185, 129, .07);
}

#view-inventario .purchase-payment-status.is-paid .purchase-payment-status-dot {
    background: #10b981;
}

#view-inventario .purchase-payment-status.is-action.pending {
    border-color: rgba(99, 102, 241, .32);
    color: #4338ca;
    background: rgba(99, 102, 241, .07);
}

#view-inventario .purchase-payment-status.is-action.pending .purchase-payment-status-dot {
    background: #6366f1;
}

#view-inventario .purchase-payment-status.is-action.partial {
    border-color: rgba(14, 116, 144, .28);
    color: #0e7490;
    background: rgba(14, 116, 144, .07);
}

#view-inventario .purchase-payment-status.is-action.partial .purchase-payment-status-dot {
    background: #0891b2;
}

#view-inventario .purchase-payment-status-arrow {
    font-size: .95rem;
    line-height: .7;
    opacity: .65;
}

/* Modal de pago: panel compacto, táctil y con jerarquía tipo Apple. */
#modal-compra-pago .compra-payment-modal {
    width: min(640px, calc(100vw - 24px));
    max-width: 620px;
    max-height: min(760px, calc(100dvh - 24px));
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(15, 23, 42, .09);
    border-radius: 22px;
    background: var(--app-panel, #fff);
    box-shadow: 0 24px 72px rgba(15, 23, 42, .24), 0 2px 8px rgba(15, 23, 42, .08);
    overflow: hidden;
}

#modal-compra-pago .compra-payment-header {
    align-items: flex-start;
    gap: 16px;
    padding: 22px 26px 18px;
    background: var(--app-panel, #fff);
    border-bottom: 1px solid var(--ux-border-soft);
    flex: 0 0 auto;
}

#modal-compra-pago .compra-payment-header h3 {
    margin: 3px 0 0;
    color: var(--app-text, #172033);
    font-size: 1.28rem;
    letter-spacing: -.025em;
}

#modal-compra-pago .compra-payment-header p {
    margin: 5px 0 0;
    color: var(--app-muted, #64748b);
    font-size: .82rem;
}

#modal-compra-pago .compra-payment-eyebrow {
    color: #2563eb;
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

#modal-compra-pago .compra-payment-form {
    display: grid;
    gap: 14px;
    padding: 20px 26px 0;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    flex: 1 1 auto;
}

#modal-compra-pago .compra-payment-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    border: 1px solid rgba(37, 99, 235, .14);
    border-radius: 16px;
    background: linear-gradient(135deg, #f4f8ff, #fbfdff);
}

#modal-compra-pago .compra-payment-summary-label {
    display: block;
    color: var(--app-muted, #64748b);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

#modal-compra-pago .compra-payment-summary strong {
    display: block;
    margin-top: 3px;
    color: var(--app-text, #172033);
    font-variant-numeric: tabular-nums;
    font-size: 1.52rem;
    letter-spacing: -.035em;
}

#modal-compra-pago .compra-payment-summary-meta {
    display: grid;
    gap: 4px;
    max-width: 55%;
    color: var(--app-muted, #64748b);
    font-size: .76rem;
    text-align: right;
}

#modal-compra-pago .compra-payment-summary-meta span:first-child {
    color: var(--app-text, #334155);
    font-variant-numeric: tabular-nums;
    font-weight: 800;
}

#modal-compra-pago .compra-payment-fields label,
#modal-compra-pago .compra-payment-note {
    display: grid;
    gap: 6px;
    color: var(--app-text, #334155);
    font-size: .76rem;
    font-weight: 800;
}

#modal-compra-pago .compra-payment-fields input,
#modal-compra-pago .compra-payment-fields select,
#modal-compra-pago .compra-payment-note textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--ux-border-soft);
    border-radius: 12px;
    background: var(--app-panel, #fff);
    background: color-mix(in srgb, var(--app-panel, #fff) 94%, #f1f5f9);
    color: var(--app-text, #172033);
    font-size: .84rem;
}

#modal-compra-pago .compra-payment-note textarea {
    min-height: 72px;
    resize: vertical;
}

#modal-compra-pago .compra-payment-note span {
    color: var(--app-muted, #64748b);
    font-weight: 600;
}

#modal-compra-pago .compra-payment-loading {
    padding: 9px 12px;
    border-radius: 9px;
    background: rgba(99, 102, 241, .07);
    color: #4338ca;
    font-size: .76rem;
    font-weight: 700;
}

#modal-compra-pago .compra-payment-proof {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 72px;
    padding: 13px 14px;
    border: 1px dashed #cbd5e1;
    border-radius: 14px;
    background: #f8fafc;
    transition: border-color .18s ease, background .18s ease;
}

#modal-compra-pago .compra-payment-proof.has-file {
    border-color: #86efac;
    background: #f0fdf4;
}

#modal-compra-pago .compra-payment-proof-copy { display: grid; gap: 3px; min-width: 0; }
#modal-compra-pago .compra-payment-proof-copy strong { color: var(--app-text, #172033); font-size: .8rem; }
#modal-compra-pago .compra-payment-proof-copy span { color: var(--app-muted, #64748b); font-size: .7rem; }
#modal-compra-pago .compra-payment-proof input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; pointer-events: none; }
#modal-compra-pago .compra-payment-proof-action {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    max-width: 52%;
    min-height: 36px;
    padding: 0 11px;
    border: 1px solid #dbe3ef;
    border-radius: 10px;
    background: #fff;
    color: #1d4ed8;
    cursor: pointer;
    font-size: .75rem;
    font-weight: 750;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#modal-compra-pago .compra-payment-proof-action span { overflow: hidden; text-overflow: ellipsis; }

#modal-compra-pago .compra-payment-history {
    display: grid;
    gap: 7px;
    padding-top: 2px;
}

#modal-compra-pago .compra-payment-history-title {
    color: var(--app-muted, #64748b);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

#modal-compra-pago .compra-payment-history-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 9px;
    border-bottom: 1px solid var(--ux-border-soft);
    color: var(--app-muted, #64748b);
    font-size: .74rem;
}

#modal-compra-pago .compra-payment-history-row strong {
    color: var(--app-text, #334155);
    font-family: 'JetBrains Mono', monospace;
}

#modal-compra-pago .compra-payment-footer {
    position: sticky;
    bottom: 0;
    margin: 0 -26px;
    padding: 15px 26px 18px;
    border-top: 1px solid var(--ux-border-soft);
    background: var(--app-panel, #fff);
    background: color-mix(in srgb, var(--app-panel, #fff) 94%, transparent);
    backdrop-filter: blur(14px);
}

#modal-compra-pago #compra-pago-submit[aria-busy="true"] {
    cursor: progress;
    opacity: .78;
}

/* Ficha de proveedor: una vista amplia y tranquila, no un modal de reporte. */
.inventory-provider-profile { display: grid; gap: 18px; max-width: 1320px; margin: 0 auto; }
.provider-profile-header { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: start; padding: 24px 26px; border: 1px solid var(--ux-border-soft, #e2e8f0); border-radius: 22px; background: linear-gradient(145deg, var(--app-panel, #fff), color-mix(in srgb, var(--app-panel, #fff) 88%, #eef2ff)); box-shadow: 0 18px 46px rgba(15, 23, 42, .07); }
.provider-profile-title h2 { margin: 3px 0 2px; color: var(--app-text, #172033); font-size: clamp(1.38rem, 2.4vw, 2rem); letter-spacing: -.035em; }
.provider-profile-title p { margin: 0; color: var(--app-muted, #64748b); font-weight: 650; font-size: .82rem; }
.provider-profile-name-row { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.provider-profile-status { display: inline-flex; align-items: center; padding: 4px 9px; border-radius: 999px; font-size: .7rem; font-weight: 800; }
.provider-profile-status.is-active { color: #15803d; background: #dcfce7; }.provider-profile-status.is-inactive { color: #b45309; background: #fef3c7; }
.provider-profile-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }.provider-profile-actions .btn { white-space: nowrap; }
.provider-profile-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); overflow: hidden; border: 1px solid var(--ux-border-soft, #e2e8f0); border-radius: 18px; background: var(--app-panel, #fff); }
.provider-profile-stats > div { min-width: 0; padding: 16px 20px; border-right: 1px solid var(--ux-border-soft, #e2e8f0); }.provider-profile-stats > div:last-child { border-right: 0; }
.provider-profile-stats span, .provider-profile-stats small { display: block; color: var(--app-muted, #64748b); font-size: .72rem; font-weight: 750; }.provider-profile-stats strong { display: block; overflow: hidden; color: var(--app-text, #172033); font-size: 1.1rem; text-overflow: ellipsis; white-space: nowrap; }
.provider-profile-grid { display: grid; grid-template-columns: minmax(260px, .8fr) minmax(0, 1.2fr); gap: 18px; }.provider-profile-card { min-width: 0; padding: 20px; border: 1px solid var(--ux-border-soft, #e2e8f0); border-radius: 18px; background: var(--app-panel, #fff); }
.provider-profile-card-title { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin-bottom: 15px; color: var(--app-text, #172033); font-size: .92rem; font-weight: 850; }.provider-profile-card-title small { color: var(--app-muted, #64748b); font-size: .72rem; font-weight: 700; }
.provider-profile-data { display: grid; gap: 12px; margin: 0; }.provider-profile-data div { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 10px; }.provider-profile-data dt { color: var(--app-muted, #64748b); font-size: .74rem; font-weight: 750; }.provider-profile-data dd { overflow-wrap: anywhere; margin: 0; color: var(--app-text, #172033); font-size: .82rem; font-weight: 650; }.provider-profile-notes { margin-top: 17px; padding-top: 14px; border-top: 1px solid var(--ux-border-soft, #e2e8f0); }.provider-profile-notes span { color: var(--app-muted, #64748b); font-size: .7rem; font-weight: 800; text-transform: uppercase; }.provider-profile-notes p { margin: 5px 0 0; color: var(--app-text, #172033); font-size: .8rem; line-height: 1.5; }
.provider-profile-documents { display: grid; gap: 8px; max-height: 330px; overflow: auto; padding-right: 3px; }.provider-profile-loading { padding: 18px 0; color: var(--app-muted, #64748b); font-size: .8rem; }.provider-profile-document-group { padding: 8px 2px 2px; color: var(--app-muted, #64748b); font-size: .68rem; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }.provider-profile-document-row { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 9px; align-items: center; padding: 10px; border: 1px solid var(--ux-border-soft, #e2e8f0); border-radius: 12px; }.provider-profile-document-row > i { color: #6366f1; }.provider-profile-document-row strong, .provider-profile-document-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.provider-profile-document-row strong { color: var(--app-text, #172033); font-size: .78rem; }.provider-profile-document-row small { margin-top: 2px; color: var(--app-muted, #64748b); font-size: .69rem; }.provider-profile-empty { display: flex; min-height: 86px; align-items: center; justify-content: center; gap: 9px; padding: 14px; border: 1px dashed var(--ux-border-soft, #cbd5e1); border-radius: 12px; color: var(--app-muted, #64748b); font-size: .78rem; text-align: center; }.provider-profile-empty.is-error { color: #b45309; }
.provider-profile-purchase-list { display: grid; }.provider-profile-purchase-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; width: 100%; padding: 13px 4px; border: 0; border-bottom: 1px solid var(--ux-border-soft, #e2e8f0); background: transparent; color: inherit; cursor: pointer; text-align: left; }.provider-profile-purchase-row:last-child { border-bottom: 0; }.provider-profile-purchase-row:hover { background: color-mix(in srgb, #6366f1 5%, transparent); }.provider-profile-purchase-main strong, .provider-profile-purchase-main small { display: block; }.provider-profile-purchase-main strong { color: var(--app-text, #172033); font-size: .84rem; }.provider-profile-purchase-main small { margin-top: 3px; color: var(--app-muted, #64748b); font-size: .72rem; }.provider-profile-purchase-total { display: flex; align-items: center; gap: 9px; color: var(--app-text, #172033); font-size: .82rem; white-space: nowrap; }.provider-profile-purchase-total > i { color: var(--app-muted, #94a3b8); font-size: .7rem; }.provider-profile-payment { padding: 3px 6px; border-radius: 999px; font-size: .63rem; font-weight: 850; }.provider-profile-payment.is-paid { color: #15803d; background: #dcfce7; }.provider-profile-payment.is-pending { color: #a16207; background: #fef3c7; }.provider-profile-payment.is-overdue { color: #b91c1c; background: #fff; border: 1px solid #ef4444; }

@media (max-width: 600px) {
    #modal-compra-pago .compra-payment-form {
        padding: 18px 18px 0;
    }

    #modal-compra-pago .compra-payment-header {
        padding: 18px;
    }

    #modal-compra-pago .compra-payment-fields {
        grid-template-columns: 1fr;
    }

    #modal-compra-pago .compra-payment-summary {
        align-items: flex-start;
        flex-direction: column;
    }

    #modal-compra-pago .compra-payment-summary-meta {
        max-width: 100%;
        text-align: left;
    }

    #modal-compra-pago .compra-payment-footer {
        margin: 0 -18px;
        padding: 14px 18px 18px;
    }

    #modal-compra-pago .compra-payment-proof { align-items: flex-start; flex-direction: column; }
    #modal-compra-pago .compra-payment-proof-action { max-width: 100%; }
}

/* Pago de compra: lectura rápida, peso tipográfico moderado y adjunto por drop/paste. */
#modal-compra-pago .compra-payment-modal {
    width: min(680px, calc(100vw - 32px));
    max-width: 680px;
    max-height: min(780px, calc(100dvh - 32px));
    border-radius: 20px;
    background: var(--app-panel, #fff);
}

#modal-compra-pago .compra-payment-header {
    gap: 18px;
    padding: 20px 24px 17px;
}

#modal-compra-pago .compra-payment-eyebrow {
    color: #4f46e5;
    font-size: .64rem;
    font-weight: 650;
    letter-spacing: .08em;
}

#modal-compra-pago .compra-payment-header h3 {
    margin-top: 5px;
    color: var(--app-text, #172033);
    font-size: 1.18rem;
    font-weight: 650;
    letter-spacing: -.025em;
}

#modal-compra-pago .compra-payment-header p {
    margin-top: 4px;
    color: var(--app-muted, #64748b);
    font-size: .78rem;
    font-weight: 450;
}

#modal-compra-pago .compra-payment-form {
    gap: 16px;
    padding: 18px 24px 0;
}

#modal-compra-pago .compra-payment-summary {
    gap: 18px;
    padding: 14px 16px;
    border-color: rgba(79, 70, 229, .15);
    border-radius: 15px;
    background: linear-gradient(135deg, #f7f8ff 0%, #fbfdff 100%);
}

#modal-compra-pago .compra-payment-summary-label,
#modal-compra-pago .compra-payment-section-heading > span {
    font-size: .66rem;
    font-weight: 650;
    letter-spacing: .07em;
}

#modal-compra-pago .compra-payment-summary strong {
    margin-top: 4px;
    font-size: 1.42rem;
    font-weight: 700;
}

#modal-compra-pago .compra-payment-summary-meta {
    gap: 3px;
    max-width: 58%;
    font-size: .72rem;
    font-weight: 450;
}

#modal-compra-pago .compra-payment-summary-meta span:first-child {
    font-weight: 600;
}

#modal-compra-pago .compra-payment-section {
    display: grid;
    gap: 12px;
}

#modal-compra-pago .compra-payment-section + .compra-payment-section {
    padding-top: 4px;
}

#modal-compra-pago .compra-payment-section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 2px;
}

#modal-compra-pago .compra-payment-section-heading > span {
    color: var(--app-text, #334155);
    text-transform: uppercase;
}

#modal-compra-pago .compra-payment-section-heading small,
#modal-compra-pago .compra-payment-section-heading span small {
    color: var(--app-muted, #64748b);
    font-size: .68rem;
    font-weight: 450;
    letter-spacing: 0;
    text-transform: none;
}

#modal-compra-pago .compra-payment-fields {
    gap: 12px;
}

#modal-compra-pago .compra-payment-fields label,
#modal-compra-pago .compra-payment-single-field,
#modal-compra-pago .compra-payment-note {
    display: grid;
    gap: 6px;
    color: var(--app-text, #475569);
    font-size: .74rem;
    font-weight: 500;
}

#modal-compra-pago .compra-payment-fields label em {
    color: #4f46e5;
    font-style: normal;
}

#modal-compra-pago .compra-payment-fields label span,
#modal-compra-pago .compra-payment-single-field span,
#modal-compra-pago .compra-payment-note span {
    color: var(--app-muted, #64748b);
    font-weight: 450;
}

#modal-compra-pago .compra-payment-fields input,
#modal-compra-pago .compra-payment-fields select,
#modal-compra-pago .compra-payment-single-field input,
#modal-compra-pago .compra-payment-note textarea {
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid color-mix(in srgb, var(--ux-border-soft, #e2e8f0) 92%, #94a3b8);
    border-radius: 11px;
    background: var(--app-panel, #fff);
    color: var(--app-text, #172033);
    font-size: .82rem;
    font-weight: 450;
    transition: border-color .16s ease, box-shadow .16s ease;
}

#modal-compra-pago .compra-payment-fields input:focus,
#modal-compra-pago .compra-payment-fields select:focus,
#modal-compra-pago .compra-payment-single-field input:focus,
#modal-compra-pago .compra-payment-note textarea:focus {
    border-color: #818cf8;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .12);
    outline: none;
}

#modal-compra-pago .compra-payment-note textarea {
    min-height: 62px;
    resize: vertical;
}

#modal-compra-pago .compra-payment-proof {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    min-height: 86px;
    padding: 13px 14px;
    border: 1px dashed #b8c4d6;
    border-radius: 14px;
    background: #fbfcfe;
    cursor: pointer;
    transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}

#modal-compra-pago .compra-payment-proof:hover,
#modal-compra-pago .compra-payment-proof:focus-visible,
#modal-compra-pago .compra-payment-proof.is-dragover {
    border-color: #6366f1;
    background: #f6f7ff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .09);
    outline: none;
}

#modal-compra-pago .compra-payment-proof.has-file {
    border-color: #86b99a;
    background: #f5fbf7;
}

#modal-compra-pago .compra-payment-proof-icon {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border-radius: 11px;
    color: #4f46e5;
    background: #eef2ff;
    font-size: .96rem;
}

#modal-compra-pago .compra-payment-proof-copy {
    display: grid;
    gap: 3px;
    min-width: 0;
}

#modal-compra-pago .compra-payment-proof-copy strong {
    color: var(--app-text, #334155);
    font-size: .78rem;
    font-weight: 600;
}

#modal-compra-pago .compra-payment-proof-copy span {
    overflow: hidden;
    color: var(--app-muted, #64748b);
    font-size: .68rem;
    font-weight: 450;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#modal-compra-pago .compra-payment-proof-copy .compra-payment-proof-file {
    color: #15803d;
    font-weight: 600;
}

#modal-compra-pago .compra-payment-proof-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 36px;
    max-width: none;
    padding: 0 12px;
    border: 1px solid #d7dfeb;
    border-radius: 10px;
    background: var(--app-panel, #fff);
    color: #4338ca;
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
}

#modal-compra-pago .compra-payment-proof input {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    opacity: 0;
    pointer-events: none;
}

#modal-compra-pago .compra-payment-loading {
    padding: 8px 11px;
    border-radius: 9px;
    font-size: .72rem;
    font-weight: 500;
}

#modal-compra-pago .compra-payment-history {
    gap: 6px;
}

#modal-compra-pago .compra-payment-history-title {
    font-size: .64rem;
    font-weight: 650;
}

#modal-compra-pago .compra-payment-history-row {
    padding: 7px 8px;
    font-size: .72rem;
    font-weight: 450;
}

#modal-compra-pago .compra-payment-history-row strong {
    font-weight: 600;
}

#modal-compra-pago .compra-payment-footer {
    margin: 0 -24px;
    padding: 14px 24px 17px;
    gap: 10px;
}

#modal-compra-pago .compra-payment-footer .btn {
    min-height: 40px;
    padding: 0 16px;
    border-radius: 10px;
    font-size: .76rem;
    font-weight: 600 !important;
}

#modal-compra-pago .compra-payment-footer #compra-pago-submit {
    box-shadow: 0 7px 16px rgba(79, 70, 229, .18);
}

@media (max-width: 600px) {
    #modal-compra-pago .compra-payment-form {
        padding: 16px 18px 0;
    }

    #modal-compra-pago .compra-payment-header {
        padding: 18px;
    }

    #modal-compra-pago .compra-payment-summary {
        align-items: flex-start;
        flex-direction: column;
    }

    #modal-compra-pago .compra-payment-summary-meta {
        max-width: 100%;
        text-align: left;
    }

    #modal-compra-pago .compra-payment-proof {
        grid-template-columns: 40px minmax(0, 1fr);
    }

    #modal-compra-pago .compra-payment-proof-action {
        grid-column: 1 / -1;
        justify-self: start;
    }

    #modal-compra-pago .compra-payment-footer {
        margin: 0 -18px;
        padding: 13px 18px 16px;
    }
}

[data-theme="dark"] #modal-compra-pago .compra-payment-summary {
    background: linear-gradient(135deg, rgba(49, 46, 129, .24), rgba(15, 23, 42, .18));
}

[data-theme="dark"] #modal-compra-pago .compra-payment-proof {
    border-color: #475569;
    background: rgba(15, 23, 42, .26);
}

[data-theme="dark"] #modal-compra-pago .compra-payment-proof:hover,
[data-theme="dark"] #modal-compra-pago .compra-payment-proof:focus-visible,
[data-theme="dark"] #modal-compra-pago .compra-payment-proof.is-dragover {
    background: rgba(49, 46, 129, .24);
}

[data-theme="dark"] #modal-compra-pago .compra-payment-proof.has-file {
    border-color: #4ade80;
    background: rgba(20, 83, 45, .2);
}

/* Compras: ficha de factura y accesos documentales. */
#modal-report-detail.purchase-detail-modal .modal-content {
    width: min(1040px, calc(100vw - 24px)) !important;
    max-width: calc(100vw - 24px) !important;
    border: 1px solid rgba(148, 163, 184, .2);
    border-radius: 24px !important;
}

#modal-report-detail.purchase-detail-modal .modal-body {
    max-height: min(72vh, 760px) !important;
    padding: 24px !important;
    background: #f3f6fb !important;
}

#modal-report-detail.purchase-detail-modal .modal-header {
    background: linear-gradient(135deg, #172554, #312e81) !important;
}

#modal-report-detail.purchase-detail-modal .modal-body > #report-detail-body {
    gap: 0 !important;
}

.purchase-invoice-detail {
    display: grid;
    gap: 16px;
    color: var(--app-text, #172033);
}

.purchase-invoice-hero {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    padding: 24px;
    border: 1px solid #dbe4f0;
    border-radius: 20px;
    background: linear-gradient(135deg, #eef2ff 0%, #f8fbff 58%, #ffffff 100%);
    box-shadow: 0 14px 30px rgba(30, 41, 59, .07);
}

.purchase-invoice-hero-main,
.purchase-invoice-hero-total {
    min-width: 0;
}

.purchase-invoice-eyebrow,
.purchase-invoice-hero-main p,
.purchase-invoice-hero-main small,
.purchase-invoice-hero-total small,
.purchase-invoice-hero-total > span:last-child {
    display: block;
}

.purchase-invoice-eyebrow {
    color: #4f46e5;
    font-size: .68rem;
    font-weight: 850;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.purchase-invoice-eyebrow i {
    margin-right: 6px;
}

.purchase-invoice-hero-main h2 {
    margin: 8px 0 6px;
    color: #18223a;
    font-size: clamp(1.4rem, 3vw, 2rem);
    letter-spacing: -.04em;
    overflow-wrap: anywhere;
}

.purchase-invoice-hero-main p {
    margin: 0;
    color: #334155;
    font-size: .9rem;
    font-weight: 750;
    overflow-wrap: anywhere;
}

.purchase-invoice-hero-main p i {
    margin-right: 6px;
    color: #6366f1;
}

.purchase-invoice-hero-main small,
.purchase-invoice-hero-total small,
.purchase-invoice-hero-total > span:last-child {
    margin-top: 8px;
    color: #64748b;
    font-size: .73rem;
    font-weight: 650;
}

.purchase-invoice-hero-total {
    display: flex;
    min-width: 180px;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    text-align: right;
}

.purchase-invoice-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 11px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 850;
    white-space: nowrap;
}

.purchase-invoice-status > span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.purchase-invoice-status.status-payment-pagada { color: #047857; background: #dcfce7; }
.purchase-invoice-status.status-payment-parcial { color: #b45309; background: #fef3c7; }
.purchase-invoice-status.status-payment-pendiente { color: #4338ca; background: #e0e7ff; }
.purchase-invoice-status.status-payment-vencida { color: #b91c1c; background: #fff; border: 1px solid #ef4444; }
.purchase-invoice-status.status-payment-anulada { color: #475569; background: #e2e8f0; }

.purchase-invoice-hero-total strong {
    margin-top: 4px;
    color: #312e81;
    font-size: clamp(1.45rem, 3vw, 2rem);
    letter-spacing: -.04em;
    white-space: nowrap;
}

.purchase-invoice-info-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.purchase-invoice-info-card {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    align-items: center;
    column-gap: 9px;
    min-width: 0;
    min-height: 64px;
    padding: 12px 13px;
    border: 1px solid var(--ux-border-soft, #dbe4f0);
    border-radius: 14px;
    background: var(--app-panel, #fff);
}

.purchase-invoice-info-card > i {
    grid-row: span 2;
    color: #6366f1;
    font-size: .9rem;
    text-align: center;
}

.purchase-invoice-info-card span,
.purchase-invoice-info-card strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.purchase-invoice-info-card span {
    color: var(--app-muted, #64748b);
    font-size: .66rem;
    font-weight: 800;
    letter-spacing: .035em;
    text-transform: uppercase;
}

.purchase-invoice-info-card strong {
    margin-top: 3px;
    color: var(--app-text, #172033);
    font-size: .79rem;
    font-weight: 800;
}

.purchase-invoice-items-section,
.purchase-invoice-documents-section {
    overflow: hidden;
    border: 1px solid var(--ux-border-soft, #dbe4f0);
    border-radius: 18px;
    background: var(--app-panel, #fff);
}

.purchase-invoice-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 17px 18px 14px;
    border-bottom: 1px solid var(--ux-border-soft, #e5eaf2);
}

.purchase-invoice-section-heading span {
    display: block;
    color: #6366f1;
    font-size: .64rem;
    font-weight: 850;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.purchase-invoice-section-heading h3 {
    margin: 4px 0 0;
    color: var(--app-text, #172033);
    font-size: .94rem;
    letter-spacing: -.015em;
}

.purchase-invoice-section-heading > strong {
    flex: 0 0 auto;
    color: var(--app-muted, #64748b);
    font-size: .7rem;
    font-weight: 800;
}

.purchase-invoice-section-heading > i {
    color: #6366f1;
    font-size: 1rem;
}

.purchase-invoice-items-table {
    overflow-x: auto;
}

.purchase-invoice-items-header,
.purchase-invoice-item-row {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 72px 112px 120px;
    gap: 12px;
    min-width: 600px;
    align-items: center;
    padding: 12px 18px;
}

.purchase-invoice-items-header {
    color: var(--app-muted, #64748b);
    background: color-mix(in srgb, var(--app-panel, #fff) 90%, #eef2ff);
    font-size: .64rem;
    font-weight: 850;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.purchase-invoice-items-header > :nth-child(n+2),
.purchase-invoice-item-row > :nth-child(n+2) {
    text-align: right;
}

.purchase-invoice-item-row {
    border-top: 1px solid var(--ux-border-soft, #edf1f7);
    color: var(--app-text, #334155);
    font-size: .78rem;
}

.purchase-invoice-item-row > div {
    min-width: 0;
}

.purchase-invoice-item-row strong,
.purchase-invoice-item-row small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.purchase-invoice-item-row strong {
    color: var(--app-text, #172033);
    font-weight: 750;
}

.purchase-invoice-item-row small {
    margin-top: 3px;
    color: var(--app-muted, #64748b);
    font-size: .68rem;
}

.purchase-invoice-item-row > strong {
    font-weight: 850;
}

.purchase-invoice-empty-items {
    min-width: 600px;
    margin: 0;
    padding: 24px 18px;
    color: var(--app-muted, #64748b);
    font-size: .8rem;
    text-align: center;
}

.purchase-invoice-document-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px 18px 18px;
}

.purchase-document-action {
    display: inline-flex !important;
    align-items: center;
    gap: 7px;
    min-height: 38px;
    white-space: nowrap;
}

.purchase-proof-btn {
    border-color: #c7d2fe !important;
    background: #f5f7ff !important;
    color: #4338ca !important;
}

.purchase-proof-btn:hover,
.purchase-proof-btn:focus-visible {
    border-color: #818cf8 !important;
    background: #eef2ff !important;
    box-shadow: 0 5px 14px rgba(79, 70, 229, .14);
    transform: translateY(-1px);
}

.purchase-row-actions {
    display: flex;
    min-width: 180px;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.purchase-row-actions .btn {
    white-space: nowrap;
}

.purchase-invoice-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 4px 2px 0;
}

.purchase-invoice-footer > div {
    display: grid;
    gap: 2px;
}

.purchase-invoice-footer span,
.purchase-invoice-footer small {
    color: var(--app-muted, #64748b);
    font-size: .7rem;
}

.purchase-invoice-footer span {
    font-weight: 800;
    text-transform: uppercase;
}

.purchase-invoice-footer strong {
    color: var(--app-text, #172033);
    font-size: .84rem;
}

@media (max-width: 760px) {
    #modal-report-detail.purchase-detail-modal .modal-body {
        padding: 16px !important;
    }

    .purchase-invoice-hero {
        flex-direction: column;
        gap: 18px;
        padding: 19px;
    }

    .purchase-invoice-hero-total {
        align-items: flex-start;
        text-align: left;
    }

    .purchase-invoice-info-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .purchase-invoice-footer {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .purchase-invoice-info-grid {
        grid-template-columns: 1fr;
    }

    .purchase-invoice-section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .purchase-invoice-document-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .purchase-document-action {
        justify-content: center;
    }
}

body[data-theme="dark"] #modal-report-detail.purchase-detail-modal .modal-body {
    background: #0b1220 !important;
}

body[data-theme="dark"] .purchase-invoice-hero {
    border-color: #334155;
    background: linear-gradient(135deg, #172554, #1e293b 72%, #111827);
}

body[data-theme="dark"] .purchase-invoice-hero-main h2,
body[data-theme="dark"] .purchase-invoice-hero-main p,
body[data-theme="dark"] .purchase-invoice-hero-total strong,
body[data-theme="dark"] .purchase-invoice-info-card strong,
body[data-theme="dark"] .purchase-invoice-item-row strong,
body[data-theme="dark"] .purchase-invoice-footer strong {
    color: #f8fafc;
}

body[data-theme="dark"] .purchase-invoice-hero-main small,
body[data-theme="dark"] .purchase-invoice-hero-total small,
body[data-theme="dark"] .purchase-invoice-hero-total > span:last-child {
    color: #cbd5e1;
}

body[data-theme="dark"] .purchase-invoice-info-card,
body[data-theme="dark"] .purchase-invoice-items-section,
body[data-theme="dark"] .purchase-invoice-documents-section {
    border-color: #334155;
    background: #111c2d;
}

body[data-theme="dark"] .purchase-invoice-items-header {
    background: #16243a;
}

body[data-theme="dark"] .purchase-proof-btn {
    border-color: #6366f1 !important;
    background: rgba(79, 70, 229, .2) !important;
    color: #c7d2fe !important;
}

/* Voucher de pago: vista previa interna, sin sacar al usuario del módulo. */
#modal-compra-voucher .compra-voucher-modal {
    width: min(960px, calc(100vw - 24px));
    max-width: 960px;
    max-height: min(860px, calc(100dvh - 24px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, .22);
    border-radius: 24px;
    background: var(--app-panel, #fff);
    box-shadow: 0 28px 80px rgba(15, 23, 42, .3);
}

#modal-compra-voucher .compra-voucher-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 22px;
    background: linear-gradient(135deg, #172554, #312e81);
    border-bottom: 0;
    flex: 0 0 auto;
}

#modal-compra-voucher .compra-voucher-header .modal-title-row {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 12px;
}

#modal-compra-voucher .compra-voucher-header h3 {
    margin: 0;
    color: #fff;
    font-size: 1.1rem;
    letter-spacing: -.02em;
}

#modal-compra-voucher .compra-voucher-header p {
    max-width: min(62vw, 580px);
    margin: 4px 0 0;
    overflow: hidden;
    color: #c7d2fe;
    font-size: .73rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compra-voucher-header-icon {
    display: grid;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 12px;
    background: rgba(255, 255, 255, .12);
    color: #fff;
}

#modal-compra-voucher .compra-voucher-body {
    display: flex;
    min-height: min(560px, 68vh);
    flex-direction: column;
    gap: 12px;
    padding: 18px;
    overflow: auto;
    background: #eef3f9;
}

.compra-voucher-viewer {
    display: grid;
    min-height: 380px;
    flex: 1 1 auto;
    place-items: center;
    overflow: hidden;
    border: 1px solid #dbe4ef;
    border-radius: 16px;
    background: #dfe7f1;
}

.compra-voucher-viewer.is-image {
    padding: 16px;
    background: repeating-conic-gradient(#e8eef6 0% 25%, #f6f9fc 0% 50%) 50% / 22px 22px;
}

.compra-voucher-image {
    display: block;
    max-width: 100%;
    max-height: min(60vh, 620px);
    border-radius: 10px;
    box-shadow: 0 14px 30px rgba(15, 23, 42, .18);
    object-fit: contain;
}

.compra-voucher-pdf {
    width: 100%;
    min-height: min(66vh, 680px);
    align-self: stretch;
    border: 0;
    background: #fff;
}

.compra-voucher-no-preview,
.compra-voucher-loading,
.compra-voucher-error {
    display: grid;
    max-width: 420px;
    justify-items: center;
    gap: 8px;
    padding: 40px 24px;
    color: var(--app-muted, #64748b);
    text-align: center;
}

.compra-voucher-no-preview > i,
.compra-voucher-loading > i,
.compra-voucher-error > i {
    margin-bottom: 4px;
    color: #6366f1;
    font-size: 2rem;
}

.compra-voucher-no-preview strong,
.compra-voucher-error strong {
    color: var(--app-text, #172033);
    font-size: .92rem;
}

.compra-voucher-no-preview span,
.compra-voucher-error span {
    font-size: .76rem;
    line-height: 1.45;
}

.compra-voucher-error > i {
    color: #d97706;
}

.compra-voucher-loading {
    margin: auto;
}

.compra-voucher-file-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 13px;
    border: 1px solid #dbe4ef;
    border-radius: 12px;
    background: var(--app-panel, #fff);
    color: var(--app-muted, #64748b);
    font-size: .72rem;
    font-weight: 700;
}

.compra-voucher-file-meta > span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compra-voucher-file-meta > span i {
    color: #10b981;
}

#modal-compra-voucher .compra-voucher-footer {
    padding: 13px 22px 16px;
    border-top: 1px solid var(--ux-border-soft, #e5eaf2);
    background: var(--app-panel, #fff);
}

body[data-theme="dark"] #modal-compra-voucher .compra-voucher-body {
    background: #0b1220;
}

body[data-theme="dark"] #modal-compra-voucher .compra-voucher-viewer,
body[data-theme="dark"] #modal-compra-voucher .compra-voucher-file-meta {
    border-color: #334155;
    background-color: #111c2d;
}

body[data-theme="dark"] #modal-compra-voucher .compra-voucher-viewer.is-image {
    background: repeating-conic-gradient(#16243a 0% 25%, #1b2b43 0% 50%) 50% / 22px 22px;
}

body[data-theme="dark"] #modal-compra-voucher .compra-voucher-no-preview strong,
body[data-theme="dark"] #modal-compra-voucher .compra-voucher-error strong {
    color: #f8fafc;
}

@media (max-width: 600px) {
    #modal-compra-voucher .compra-voucher-header {
        padding: 16px 18px;
    }

    #modal-compra-voucher .compra-voucher-body {
        min-height: min(480px, 62vh);
        padding: 12px;
    }

    .compra-voucher-viewer {
        min-height: 300px;
    }

    .compra-voucher-file-meta {
        align-items: flex-start;
        flex-direction: column;
    }

    #modal-compra-voucher .compra-voucher-footer {
        padding: 11px 18px 14px;
    }
}

/* Compras: jerarquía más ligera y resumen de pago accionable. */
.purchase-invoice-eyebrow,
.purchase-invoice-status,
.purchase-invoice-info-card span,
.purchase-invoice-section-heading span,
.purchase-invoice-items-header,
.purchase-invoice-section-heading > strong,
.purchase-invoice-footer span {
    font-weight: 600;
}

.purchase-invoice-hero-main h2,
.purchase-invoice-hero-total strong,
.purchase-invoice-info-card strong,
.purchase-invoice-section-heading h3,
.purchase-invoice-item-row > strong,
.purchase-invoice-item-row strong {
    font-weight: 650;
}

.purchase-invoice-hero-main p {
    font-weight: 550;
}

.purchase-invoice-footer {
    align-items: stretch;
    padding: 0;
}

.purchase-payment-summary {
    display: grid !important;
    min-width: 0;
    flex: 1 1 auto;
    gap: 16px !important;
    padding: 17px 18px 16px;
    border: 1px solid #dbe4f0;
    border-radius: 18px;
    background: linear-gradient(135deg, #ffffff, #f7f9ff);
}

.purchase-payment-summary-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.purchase-payment-summary-heading > div {
    display: grid;
    gap: 4px;
}

.purchase-payment-summary-kicker {
    display: inline-flex !important;
    align-items: center;
    gap: 7px;
    color: #4f46e5 !important;
    font-size: .74rem !important;
    letter-spacing: .01em !important;
    text-transform: none !important;
}

.purchase-payment-summary-kicker i {
    color: #6366f1;
}

.purchase-payment-summary-heading small {
    color: var(--app-muted, #64748b);
    font-size: .72rem;
}

.purchase-payment-summary-values {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px !important;
}

.purchase-payment-summary-values > div {
    display: grid;
    gap: 4px;
    padding: 10px 12px;
    border: 1px solid #e4eaf3;
    border-radius: 12px;
    background: rgba(255, 255, 255, .72);
}

.purchase-payment-summary-values span {
    color: var(--app-muted, #64748b) !important;
    font-size: .68rem !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
}

.purchase-payment-summary-values strong {
    color: var(--app-text, #172033);
    font-size: .88rem;
    font-weight: 600;
}

.purchase-payment-actions {
    display: grid !important;
    gap: 8px !important;
    padding-top: 2px;
}

.purchase-payment-loading,
.purchase-payment-empty,
.purchase-payment-list-title {
    color: var(--app-muted, #64748b);
    font-size: .72rem;
    font-weight: 500;
}

.purchase-payment-list-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 3px;
    border-bottom: 1px solid #e8edf5;
}

.purchase-payment-list-title strong {
    color: var(--app-text, #334155);
    font-weight: 600;
}

.purchase-payment-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 8px 0 0;
}

.purchase-payment-row-main {
    display: grid;
    min-width: 0;
    gap: 3px;
}

.purchase-payment-row-main span,
.purchase-payment-row-main small {
    overflow: hidden;
    color: var(--app-muted, #64748b);
    font-size: .71rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.purchase-payment-row-main span {
    color: var(--app-text, #334155);
    font-weight: 550;
}

.purchase-payment-row > strong {
    color: var(--app-text, #172033);
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
}

.purchase-payment-edit-btn,
.purchase-payment-proof-delete {
    min-height: 30px;
    padding: 5px 9px;
    border: 1px solid #d6def0;
    border-radius: 8px;
    background: #fff;
    color: #4f46e5;
    cursor: pointer;
    font: inherit;
    font-size: .69rem;
    font-weight: 550;
}

.purchase-payment-edit-btn:hover,
.purchase-payment-edit-btn:focus-visible {
    border-color: #a5b4fc;
    background: #f5f7ff;
}

.purchase-payment-proof-delete {
    border-color: #ef4444;
    color: #b91c1c;
}

.purchase-payment-proof-delete:hover,
.purchase-payment-proof-delete:focus-visible {
    background: #fff;
    border-color: #b91c1c;
}

.purchase-invoice-footer-actions {
    display: flex;
    align-items: flex-end;
    flex: 0 0 auto;
}

#modal-compra-pago-edit .compra-payment-edit-modal {
    width: min(640px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    overflow: hidden;
    border: 1px solid #dbe4f0;
    border-radius: 20px;
}

.compra-payment-edit-modal .modal-header {
    background: linear-gradient(135deg, #172554, #312e81);
}

.compra-payment-edit-modal .modal-title-row {
    align-items: center;
}

.compra-payment-edit-modal .modal-title-row h3 {
    font-weight: 650;
}

.compra-payment-edit-body {
    display: grid;
    gap: 18px;
    max-height: 70vh;
    padding: 22px;
    overflow-y: auto;
    background: #f7f9fc;
}

.compra-payment-edit-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.compra-payment-edit-field {
    display: grid;
    gap: 6px;
}

.compra-payment-edit-field.is-full {
    grid-column: 1 / -1;
}

.compra-payment-edit-field label,
.compra-payment-edit-proof-title {
    color: #52627a;
    font-size: .72rem;
    font-weight: 600;
}

.compra-payment-edit-field input,
.compra-payment-edit-field select,
.compra-payment-edit-field textarea {
    width: 100%;
    border: 1px solid #d8e1ee;
    border-radius: 10px;
    background: #fff;
    color: #1e293b;
    font: inherit;
    font-size: .82rem;
}

.compra-payment-edit-field input,
.compra-payment-edit-field select {
    min-height: 40px;
    padding: 0 11px;
}

.compra-payment-edit-field textarea {
    min-height: 76px;
    padding: 10px 11px;
    resize: vertical;
}

.compra-payment-edit-field input:focus,
.compra-payment-edit-field select:focus,
.compra-payment-edit-field textarea:focus {
    border-color: #818cf8;
    outline: 3px solid rgba(129, 140, 248, .15);
}

.compra-payment-edit-proof {
    display: grid;
    gap: 9px;
    padding: 14px;
    border: 1px solid #e0e7f0;
    border-radius: 13px;
    background: #fff;
}

.compra-payment-edit-proof-list {
    display: grid;
    gap: 7px;
}

.compra-payment-proof-file {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 0;
    border-top: 1px solid #edf1f6;
}

.compra-payment-proof-file:first-child {
    border-top: 0;
}

.compra-payment-proof-file-name {
    min-width: 0;
    overflow: hidden;
    color: #475569;
    font-size: .75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body[data-theme="dark"] .purchase-payment-summary,
body[data-theme="dark"] .purchase-payment-summary-values > div,
body[data-theme="dark"] .compra-payment-edit-body,
body[data-theme="dark"] .compra-payment-edit-field input,
body[data-theme="dark"] .compra-payment-edit-field select,
body[data-theme="dark"] .compra-payment-edit-field textarea,
body[data-theme="dark"] .compra-payment-edit-proof,
body[data-theme="dark"] .purchase-payment-edit-btn {
    border-color: #334155;
    background: #111c2d;
    color: #e2e8f0;
}

body[data-theme="dark"] .purchase-payment-summary-values strong,
body[data-theme="dark"] .purchase-payment-list-title strong,
body[data-theme="dark"] .purchase-payment-row-main span,
body[data-theme="dark"] .purchase-payment-row > strong,
body[data-theme="dark"] .compra-payment-edit-field input,
body[data-theme="dark"] .compra-payment-edit-field select,
body[data-theme="dark"] .compra-payment-edit-field textarea {
    color: #f8fafc;
}

/* Cabeceras oscuras: el texto y los botones siempre deben tener contraste. */
.compra-payment-edit-modal .modal-header,
#modal-compra-document .compra-document-header {
    color: #fff;
    background: linear-gradient(135deg, #172554, #312e81);
}

.compra-payment-edit-modal .modal-header h3,
.compra-payment-edit-modal .modal-header p,
#modal-compra-document .compra-document-header h3,
#modal-compra-document .compra-document-header p {
    color: #fff !important;
}

.compra-payment-edit-modal .modal-header p,
#modal-compra-document .compra-document-header p {
    margin: 4px 0 0;
    color: #c7d2fe !important;
    font-size: .76rem;
    font-weight: 500;
}

.compra-payment-edit-modal .modal-window-actions,
#modal-compra-document .modal-window-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.compra-payment-edit-modal .modal-close,
.compra-payment-edit-modal .modal-minimize,
#modal-compra-document .modal-close,
#modal-compra-document .modal-minimize {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, .2) !important;
    border-radius: 11px;
    color: #fff !important;
    background: rgba(255, 255, 255, .12) !important;
    box-shadow: none;
}

.compra-payment-edit-modal .modal-close:hover,
.compra-payment-edit-modal .modal-minimize:hover,
#modal-compra-document .modal-close:hover,
#modal-compra-document .modal-minimize:hover,
.compra-payment-edit-modal .modal-close:focus-visible,
.compra-payment-edit-modal .modal-minimize:focus-visible,
#modal-compra-document .modal-close:focus-visible,
#modal-compra-document .modal-minimize:focus-visible {
    border-color: rgba(255, 255, 255, .52) !important;
    color: #fff !important;
    background: rgba(255, 255, 255, .22) !important;
    transform: none;
}

.compra-payment-edit-observation {
    padding-top: 2px;
}

#modal-compra-document .compra-document-modal {
    display: flex;
    width: min(820px, calc(100vw - 28px));
    max-width: calc(100vw - 28px);
    max-height: min(850px, calc(100vh - 28px));
    flex-direction: column;
    overflow: hidden;
    border-radius: 20px;
}

#modal-compra-document .compra-document-body {
    display: flex;
    min-height: 0;
    max-height: min(680px, calc(100vh - 160px));
    flex: 1 1 auto;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    overflow: auto;
    background: #eef3f9;
}

.compra-document-viewer {
    display: grid;
    min-height: 0;
    overflow: hidden;
    border: 1px solid #dbe4ef;
    border-radius: 14px;
    background: #dfe7f1;
    place-items: center;
}

.compra-document-viewer.is-pdf {
    min-height: min(610px, calc(100vh - 230px));
    background: #fff;
}

.compra-document-viewer iframe {
    display: block;
    width: 100%;
    height: min(610px, calc(100vh - 230px));
    border: 0;
    background: #fff;
}

.compra-document-viewer img {
    display: block;
    max-width: 100%;
    max-height: min(610px, calc(100vh - 230px));
    object-fit: contain;
}

#modal-compra-document .compra-document-footer {
    padding: 13px 20px 15px;
    border-top: 1px solid #e5eaf2;
    background: #fff;
}

body[data-theme="dark"] #modal-compra-document .compra-document-body,
body[data-theme="dark"] #modal-compra-document .compra-document-viewer {
    border-color: #334155;
    background: #111c2d;
}

body[data-theme="dark"] #modal-compra-document .compra-document-footer {
    border-top-color: #334155;
    background: #0f172a;
}

@media (max-width: 600px) {
    #modal-compra-document .compra-document-modal {
        width: min(620px, calc(100vw - 20px));
        max-width: calc(100vw - 20px);
    }

    #modal-compra-document .compra-document-body {
        max-height: calc(100vh - 145px);
        padding: 10px;
    }

    .compra-document-viewer.is-pdf,
    .compra-document-viewer iframe {
        height: calc(100vh - 235px);
        min-height: 420px;
    }
}

@media (max-width: 760px) {
    .purchase-invoice-footer {
        flex-direction: column;
    }

    .purchase-invoice-footer-actions {
        justify-content: flex-end;
    }

    .compra-payment-edit-grid {
        grid-template-columns: 1fr;
    }

    .compra-payment-edit-field.is-full {
        grid-column: auto;
    }
}

@media (max-width: 520px) {
    .purchase-payment-summary-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .purchase-payment-summary-values {
        grid-template-columns: 1fr;
    }

    .purchase-payment-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .purchase-payment-row > strong {
        grid-column: 2;
        grid-row: 1;
    }

    .purchase-payment-edit-btn {
        grid-column: 1 / -1;
        justify-self: start;
    }

    .compra-payment-proof-file {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* Provider profile: stronger identity, separate summary tiles, and readable empty states. */
.inventory-provider-profile {
    --provider-profile-accent: #4f46e5;
    --provider-profile-border: #dce5f1;
    display: grid;
    gap: 14px;
    max-width: 1400px;
    margin: 0 auto;
}

.provider-profile-header {
    position: relative;
    isolation: isolate;
    display: grid;
    grid-template-columns: 44px 62px minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    min-height: 154px;
    overflow: hidden;
    padding: 23px 26px;
    border: 1px solid rgba(148, 163, 184, .25);
    border-radius: 23px;
    background: linear-gradient(112deg, #111b31 0%, #1d3154 57%, #31539a 100%);
    box-shadow: 0 16px 36px rgba(26, 45, 82, .18);
}

.provider-profile-header::after {
    position: absolute;
    z-index: -1;
    inset: 0;
    background: radial-gradient(circle at 88% 8%, rgba(103, 232, 249, .19), transparent 28%);
    content: "";
    pointer-events: none;
}

.provider-profile-back {
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .34);
    border-radius: 14px;
    background: rgba(255, 255, 255, .1);
    color: #fff;
    box-shadow: none;
}

.provider-profile-back:hover {
    border-color: rgba(255, 255, 255, .65);
    background: rgba(255, 255, 255, .18);
    color: #fff;
}

.provider-profile-mark {
    display: grid;
    width: 62px;
    height: 62px;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .26);
    border-radius: 19px;
    background: rgba(255, 255, 255, .12);
    color: #b9f4ff;
    font-size: 1.55rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12);
}

.provider-profile-title {
    display: grid;
    gap: 7px;
    min-width: 0;
}

.provider-profile-title .inventory-hero-kicker {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    width: fit-content;
    max-width: 100%;
    margin: 0;
    color: #b9d5ff;
    font-size: .67rem;
    letter-spacing: .11em;
}

.provider-profile-title h2 {
    margin: 0;
    color: #fff;
    font-size: clamp(1.45rem, 2.4vw, 2.05rem);
    font-weight: 800;
    letter-spacing: -.035em;
    line-height: 1.12;
    overflow-wrap: anywhere;
}

.provider-profile-name-row {
    gap: 10px;
}

.provider-profile-status {
    align-items: center;
    gap: 6px;
    min-height: 26px;
    padding: 4px 10px;
    font-size: .69rem;
}

.provider-profile-status.is-active {
    border: 1px solid rgba(134, 239, 172, .5);
    background: rgba(34, 197, 94, .17);
    color: #c5f7d4;
}

.provider-profile-status.is-inactive {
    border: 1px solid rgba(253, 186, 116, .5);
    background: rgba(234, 88, 12, .18);
    color: #ffdfbd;
}

.provider-profile-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.provider-profile-meta > span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 27px;
    padding: 4px 9px;
    border: 1px solid rgba(219, 234, 254, .2);
    border-radius: 9px;
    background: rgba(15, 23, 42, .16);
    color: #e0ebff;
    font-size: .73rem;
    font-weight: 650;
}

.provider-profile-meta > span i {
    color: #9bd6f7;
}

.provider-profile-actions {
    align-items: center;
    gap: 9px;
}

.provider-profile-actions .btn {
    min-height: 43px;
    padding: 0 15px;
    border-radius: 12px;
    font-size: .8rem;
    font-weight: 750;
}

.provider-profile-actions .btn.secondary {
    border-color: rgba(255, 255, 255, .58);
    background: rgba(255, 255, 255, .96);
    color: #1e2c43;
}

.provider-profile-actions .btn.primary {
    border-color: #818cf8;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    box-shadow: 0 8px 20px rgba(12, 18, 52, .24);
}

.provider-profile-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.provider-profile-stat {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: center;
    gap: 13px;
    min-width: 0;
    min-height: 98px;
    padding: 16px 18px;
    border: 1px solid var(--provider-profile-border);
    border-radius: 18px;
    background: linear-gradient(145deg, #fff, #f8faff);
    box-shadow: 0 8px 22px rgba(27, 43, 76, .045);
}

.provider-profile-stat-icon {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border: 1px solid #dbeafe;
    border-radius: 14px;
    background: #eff6ff;
    color: #4169d8;
    font-size: 1rem;
}

.provider-profile-stats .provider-profile-stat-icon {
    display: grid;
}

.provider-profile-stat.is-amount .provider-profile-stat-icon {
    border-color: #c7f0e4;
    background: #ecfdf5;
    color: #0f8b70;
}

.provider-profile-stat.is-last .provider-profile-stat-icon {
    border-color: #e5ddff;
    background: #f4f0ff;
    color: #7450c8;
}

.provider-profile-stat > div {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.provider-profile-stat > div > span {
    color: #687995;
    font-size: .7rem;
    font-weight: 750;
}

.provider-profile-stat > div > strong {
    overflow: hidden;
    color: #152544;
    font-size: 1.14rem;
    font-weight: 800;
    line-height: 1.18;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.provider-profile-stat.is-last > div > strong {
    font-size: .97rem;
}

.provider-profile-stat > div > small {
    color: #8592a8;
    font-size: .66rem;
    line-height: 1.35;
}

.provider-profile-grid {
    grid-template-columns: minmax(320px, .92fr) minmax(0, 1.08fr);
    align-items: stretch;
    gap: 14px;
}

.provider-profile-card {
    padding: 20px;
    border-color: var(--provider-profile-border);
    border-radius: 20px;
    background: linear-gradient(155deg, #fff, #fcfdff 72%, #f7f9ff);
    box-shadow: 0 9px 24px rgba(27, 43, 76, .045);
}

.provider-profile-card-title {
    justify-content: flex-start;
    align-items: center;
    gap: 11px;
    margin-bottom: 17px;
    font-size: .93rem;
}

.provider-profile-card-title > div {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.provider-profile-card-title > div > span {
    color: #182947;
    font-size: .93rem;
    font-weight: 800;
}

.provider-profile-card-title > div > small {
    color: #8190a7;
    font-size: .69rem;
    font-weight: 600;
}

.provider-profile-card-icon {
    display: grid;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    place-items: center;
    border: 1px solid #dce7ff;
    border-radius: 13px;
    background: #f0f5ff;
    color: #4f63ce;
    font-size: .94rem;
}

.provider-profile-card-icon.is-documents {
    border-color: #d9eafe;
    background: #eef8ff;
    color: #2c86bd;
}

.provider-profile-card-icon.is-purchases {
    border-color: #d0efe7;
    background: #effbf6;
    color: #21836d;
}

.provider-profile-data {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
}

.provider-profile-data div {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    gap: 7px;
    min-width: 0;
    min-height: 70px;
    padding: 11px 12px;
    border: 1px solid #e6ebf4;
    border-radius: 14px;
    background: rgba(248, 250, 255, .88);
}

.provider-profile-data div:last-child {
    grid-column: 1 / -1;
}

.provider-profile-data dt {
    display: flex;
    align-items: center;
    gap: 7px;
    color: #71819b;
    font-size: .68rem;
    font-weight: 750;
}

.provider-profile-data dt i {
    width: 14px;
    color: #596ed4;
    text-align: center;
}

.provider-profile-data dd {
    color: #1c2b47;
    font-size: .79rem;
    font-weight: 720;
    line-height: 1.35;
}

.provider-profile-notes {
    margin-top: 11px;
    padding: 12px 13px;
    border: 1px solid #e7eaf5;
    border-radius: 14px;
    background: #fafaff;
}

.provider-profile-documents {
    min-height: 150px;
    max-height: 360px;
    padding: 0 2px 2px 0;
}

.provider-profile-loading {
    display: flex;
    min-height: 148px;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 18px;
    border: 1px dashed #d8e2f1;
    border-radius: 16px;
    background: #f8faff;
    color: #7787a1;
}

.provider-profile-empty {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    justify-content: initial;
    align-items: center;
    gap: 13px;
    min-height: 148px;
    padding: 18px;
    border: 1px dashed #cedaf0;
    border-radius: 16px;
    background: linear-gradient(145deg, #f8faff, #f3f7ff);
    color: #73819a;
    font-size: .78rem;
    text-align: left;
}

.provider-profile-empty-icon {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border: 1px solid #dce6fb;
    border-radius: 14px;
    background: #fff;
    color: #6276d9;
    font-size: 1rem;
}

.provider-profile-empty > div {
    display: grid;
    gap: 5px;
    min-width: 0;
}

.provider-profile-empty > div > strong {
    color: #243654;
    font-size: .83rem;
    font-weight: 800;
}

.provider-profile-empty > div > span {
    color: #7988a1;
    line-height: 1.45;
}

.provider-profile-empty.is-documents-empty > .btn {
    grid-column: 2;
    justify-self: start;
    min-height: 35px;
    border-radius: 10px;
}

.provider-profile-empty.is-error {
    border-color: #fed7aa;
    background: #fffaf3;
    color: #a95619;
}

.provider-profile-empty.is-error .provider-profile-empty-icon {
    border-color: #fed7aa;
    background: #fff7ed;
    color: #c15a19;
}

.provider-profile-empty.is-error > div > strong {
    color: #a95619;
}

.provider-profile-purchases-card {
    padding-bottom: 17px;
}

.provider-profile-purchases-card > .provider-profile-card-title {
    margin-bottom: 12px;
}

.provider-profile-record-count {
    margin-left: auto;
    padding: 6px 10px;
    border: 1px solid #e0e7f2;
    border-radius: 999px;
    background: #f7f9fd;
    color: #687995;
    font-size: .67rem;
    font-weight: 750;
    white-space: nowrap;
}

.provider-profile-purchase-list {
    gap: 8px;
}

.provider-profile-purchase-row {
    min-height: 64px;
    padding: 12px 14px;
    border: 1px solid #e5eaf3;
    border-radius: 14px;
    background: #fff;
    transition: background .16s ease, border-color .16s ease, transform .16s ease;
}

.provider-profile-purchase-row:hover {
    transform: translateY(-1px);
    border-color: #cbd7fb;
    background: #f8faff;
}

.provider-profile-purchase-main strong {
    color: #1b2c49;
    font-size: .83rem;
}

.provider-profile-purchase-main small {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #7a89a0;
}

.provider-profile-purchase-total {
    color: #1b2c49;
}

body[data-theme="dark"] .provider-profile-header {
    border-color: rgba(148, 163, 184, .18);
    background: linear-gradient(112deg, #0d1628 0%, #142644 57%, #263d77 100%);
}

body[data-theme="dark"] .provider-profile-stat,
body[data-theme="dark"] .provider-profile-card {
    border-color: rgba(148, 163, 184, .16);
    background: linear-gradient(150deg, #121d2d, #101a2b 72%, #142038);
}

body[data-theme="dark"] .provider-profile-stat > div > strong,
body[data-theme="dark"] .provider-profile-card-title > div > span,
body[data-theme="dark"] .provider-profile-data dd,
body[data-theme="dark"] .provider-profile-empty > div > strong,
body[data-theme="dark"] .provider-profile-purchase-main strong,
body[data-theme="dark"] .provider-profile-purchase-total {
    color: #e6edf8;
}

body[data-theme="dark"] .provider-profile-stat > div > span,
body[data-theme="dark"] .provider-profile-stat > div > small,
body[data-theme="dark"] .provider-profile-card-title > div > small,
body[data-theme="dark"] .provider-profile-data dt,
body[data-theme="dark"] .provider-profile-empty > div > span,
body[data-theme="dark"] .provider-profile-purchase-main small {
    color: #9cacc4;
}

body[data-theme="dark"] .provider-profile-data div,
body[data-theme="dark"] .provider-profile-notes,
body[data-theme="dark"] .provider-profile-purchase-row,
body[data-theme="dark"] .provider-profile-record-count {
    border-color: rgba(148, 163, 184, .15);
    background: rgba(255, 255, 255, .035);
}

body[data-theme="dark"] .provider-profile-purchase-row:hover {
    border-color: rgba(129, 140, 248, .4);
    background: rgba(99, 102, 241, .1);
}

body[data-theme="dark"] .provider-profile-empty,
body[data-theme="dark"] .provider-profile-loading {
    border-color: rgba(148, 163, 184, .24);
    background: rgba(255, 255, 255, .035);
}

body[data-theme="dark"] .provider-profile-empty-icon {
    border-color: rgba(148, 163, 184, .18);
    background: #17243a;
}

body[data-theme="dark"] .provider-profile-empty.is-error {
    border-color: rgba(251, 146, 60, .3);
    background: rgba(124, 45, 18, .13);
}

@media (max-width: 900px) {
    .provider-profile-header {
        grid-template-columns: 42px 56px minmax(0, 1fr);
    }

    .provider-profile-mark {
        width: 56px;
        height: 56px;
    }

    .provider-profile-actions {
        grid-column: 3;
        justify-content: flex-start;
        margin-top: 2px;
    }

    .provider-profile-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 620px) {
    .inventory-provider-profile {
        gap: 11px;
    }

    .provider-profile-header {
        grid-template-columns: 40px minmax(0, 1fr);
        gap: 12px;
        min-height: 0;
        padding: 18px;
        border-radius: 19px;
    }

    .provider-profile-mark {
        display: none;
    }

    .provider-profile-title {
        grid-column: 2;
    }

    .provider-profile-title h2 {
        font-size: 1.38rem;
    }

    .provider-profile-actions {
        grid-column: 2;
        flex-wrap: wrap;
        margin-top: 1px;
    }

    .provider-profile-actions .btn {
        flex: 1 1 auto;
        justify-content: center;
        padding: 0 11px;
        font-size: .73rem;
    }

    .provider-profile-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 9px;
    }

    .provider-profile-stat {
        grid-template-columns: 36px minmax(0, 1fr);
        gap: 9px;
        min-height: 86px;
        padding: 12px;
        border-radius: 15px;
    }

    .provider-profile-stat-icon {
        width: 36px;
        height: 36px;
        border-radius: 11px;
        font-size: .85rem;
    }

    .provider-profile-stat.is-last {
        grid-column: 1 / -1;
    }

    .provider-profile-card {
        padding: 16px;
        border-radius: 17px;
    }

    .provider-profile-data {
        grid-template-columns: 1fr;
    }

    .provider-profile-data div:last-child {
        grid-column: auto;
    }

    .provider-profile-purchase-row {
        grid-template-columns: minmax(0, 1fr);
        gap: 9px;
    }

    .provider-profile-purchase-total {
        justify-content: space-between;
    }

    .provider-profile-empty {
        grid-template-columns: 38px minmax(0, 1fr);
        gap: 10px;
        min-height: 125px;
        padding: 14px;
    }

    .provider-profile-empty-icon {
        width: 38px;
        height: 38px;
    }

    .provider-profile-empty.is-documents-empty > .btn {
        grid-column: 2;
    }

    .provider-profile-record-count {
        align-self: start;
        margin-left: auto;
    }
}

#view-inventario #inventario-body.inventory-search-updating :is(
    .table-wrapper-premium,
    .inventory-products-grid,
    .inventory-purchase-grid,
    .inventory-provider-grid,
    .inventory-services-no-results,
    .inventory-empty-state,
    .inventory-empty-state-premium
) {
    animation: inventorySearchResultsIn 360ms cubic-bezier(.2, .72, .25, 1) both;
}

@keyframes inventorySearchResultsIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(.99);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

#view-inventario .inventory-services-no-results {
    display: flex;
    min-height: 84px;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin: 10px;
    padding: 16px 18px;
    border: 1px solid var(--app-border, #dbe5f1);
    border-radius: 14px;
    background: var(--app-panel, #fff);
    color: var(--app-text, #172033);
}

#view-inventario .inventory-services-no-results > div {
    display: grid;
    gap: 5px;
}

#view-inventario .inventory-services-no-results strong {
    font-weight: 750;
}

#view-inventario .inventory-services-no-results span {
    color: var(--app-text-muted, #64748b);
    font-size: .9rem;
}

#view-inventario .inventory-services-no-results .btn {
    flex: 0 0 auto;
}

@media (max-width: 600px) {
    #view-inventario .inventory-services-no-results {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (prefers-reduced-motion: reduce) {
    #view-inventario #inventario-body.inventory-search-updating :is(
        .table-wrapper-premium,
        .inventory-products-grid,
        .inventory-purchase-grid,
        .inventory-provider-grid,
        .inventory-services-no-results,
        .inventory-empty-state,
        .inventory-empty-state-premium
    ) {
        animation: none !important;
    }
}
