:root {
    --brand-primary: #00327d;
    --brand-primary-hover: #0a3f93;
    --bs-primary: #00327d;
    --bs-primary-rgb: 0, 50, 125;
}

.quick-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1030;
    width: 72px;
    height: 100vh;
    background: #222e3c;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.2s ease-in-out;
}

.app-topbar {
    --topbar-nav-underline: 2px;
    --topbar-nav-underline-gap: 3px;
    background: #00327d;
}

.app-topbar.navbar {
    align-items: center;
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
}

.app-topbar > .container-fluid {
    align-items: center;
}

.app-topbar .navbar-nav {
    gap: 0.15rem;
    align-items: center;
}

.app-topbar .nav-item {
    position: relative;
    display: flex;
    align-items: center;
    padding-bottom: calc(var(--topbar-nav-underline) + var(--topbar-nav-underline-gap));
}

.app-topbar .navbar-brand,
.app-topbar .nav-link,
.app-topbar .navbar-text {
    color: #f8fafc !important;
}

.app-topbar .navbar-brand {
    padding: 0.25rem 0;
    padding-bottom: calc(0.25rem + var(--topbar-nav-underline) + var(--topbar-nav-underline-gap));
    margin-bottom: 0;
    line-height: 1.25;
}

.app-topbar .nav-link {
    border-radius: 6px;
    padding: 0.25rem 0.65rem;
    line-height: 1.25;
    font-weight: 500;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.app-topbar .nav-link:hover,
.app-topbar .nav-link:focus {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.1);
}

.app-topbar .nav-link.active {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff !important;
    box-shadow: none;
}

.app-topbar .nav-item:has(> .nav-link.active)::after {
    content: "";
    position: absolute;
    left: 0.3rem;
    right: 0.3rem;
    bottom: 0;
    height: var(--topbar-nav-underline);
    background: #ffffff;
    border-radius: 1px;
}

.app-topbar .dropdown-menu {
    border: none;
    border-radius: 0.5rem;
    box-shadow: 0 10px 28px -12px rgba(15, 23, 42, 0.35);
    padding: 0.35rem;
    margin-top: 0.35rem;
}

.app-topbar .dropdown-item {
    border-radius: 0.375rem;
    padding: 0.45rem 0.75rem;
    font-size: 0.9rem;
}

.app-topbar .dropdown-item.active,
.app-topbar .dropdown-item:active {
    background-color: var(--brand-primary);
    color: #fff;
}

.app-topbar .dropdown-item.active i {
    color: inherit;
}

.app-topbar .dropdown-header {
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--bs-secondary-color);
}

.app-topbar .navbar-toggler {
    border-color: rgba(255, 255, 255, 0.35);
}

@media (max-width: 575.98px) {
    .app-topbar .navbar-nav {
        padding-top: 0.35rem;
        padding-bottom: 0.35rem;
    }

    .app-topbar .dropdown-menu {
        border: 1px solid rgba(15, 23, 42, 0.08);
        box-shadow: none;
        background: rgba(255, 255, 255, 0.06);
    }

    .app-topbar .dropdown-item {
        color: #f8fafc;
    }

    .app-topbar .dropdown-item.active,
    .app-topbar .dropdown-item:active {
        background: rgba(255, 255, 255, 0.18);
        color: #fff;
    }
}

.quick-sidebar-header {
    color: #cbd5e1;
    letter-spacing: 0.06em;
    font-size: 10px;
    margin-top: 12px;
}

.quick-sidebar-nav {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quick-link {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    color: #cbd5e1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 18px;
}

.quick-link:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
}

.quick-link.active {
    background: rgba(255, 255, 255, 0.22);
    color: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.btn-primary {
    --bs-btn-bg: var(--brand-primary);
    --bs-btn-border-color: var(--brand-primary);
    --bs-btn-hover-bg: var(--brand-primary-hover);
    --bs-btn-hover-border-color: var(--brand-primary-hover);
    --bs-btn-active-bg: var(--brand-primary-hover);
    --bs-btn-active-border-color: var(--brand-primary-hover);
    --bs-btn-focus-shadow-rgb: 0, 50, 125;
    transition: background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out, transform 0.05s ease-in-out;
}

.btn-primary:hover,
.btn-primary:focus-visible {
    box-shadow: 0 6px 18px -8px rgba(0, 50, 125, 0.55);
}

.btn-primary:active {
    transform: translateY(1px);
}

.app-main-shell {
    margin-left: 72px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-main-shell > .container-fluid {
    flex: 1 0 auto;
}

.app-main-shell .footer {
    position: static;
    width: auto;
    line-height: inherit;
    padding: 0.75rem 0;
    margin-top: 2rem;
}

.app-main-shell main {
    padding-bottom: 1.5rem;
}

body.quick-sidebar-collapsed .quick-sidebar {
    transform: translateX(-100%);
}

body.quick-sidebar-collapsed .app-main-shell {
    margin-left: 0;
}

/* Estado colapsado antes del primer paint (script en <head>) */
html.quick-sidebar-collapsed .quick-sidebar {
    transform: translateX(-100%);
    transition: none;
}

html.quick-sidebar-collapsed .app-main-shell {
    margin-left: 0;
}

@media (max-width: 991.98px) {
    .quick-sidebar {
        transform: translateX(-100%);
    }

    .app-main-shell {
        margin-left: 0;
    }

    body.quick-sidebar-open .quick-sidebar {
        transform: translateX(0);
    }
}

/* ==========================================================================
   ERP Form Mode (Create/Edit)
   ========================================================================== */
main.erp-form-mode {
    --erp-form-max-width: 1000px;
}

/* Modo ancho (ej.: pasos 3 y 4 del wizard de rendiciones): amplía el mismo
   contenedor que usa erp-form-mode para aprovechar mejor el espacio. */
main.erp-form-mode.erp-form-wide {
    --erp-form-max-width: min(1440px, calc(100% - 1rem));
}

main.erp-form-mode > .rendicion-wizard-wide {
    max-width: var(--erp-form-max-width);
}

main.erp-form-mode > :where(h1, h2, h3, p, form, .card, hr, table, .table-responsive, .text-muted, #productoFormRoot):not(.alert) {
    max-width: var(--erp-form-max-width);
    margin-left: auto;
    margin-right: auto;
}

main.erp-form-mode > #productoFormRoot {
    width: 100%;
}

main.erp-form-mode > #productoFormRoot > h1,
main.erp-form-mode > #productoFormRoot > h2,
main.erp-form-mode > #productoFormRoot > h3 {
    margin-bottom: 1rem;
}

main.erp-form-mode > p.text-muted,
main.erp-form-mode > p.text-body-secondary {
    font-size: 0.875rem;
}

main.erp-form-mode > form,
main.erp-form-mode > .erp-form {
    background-color: #fff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 0.6rem;
    box-shadow: 0 8px 20px -18px rgba(2, 6, 23, 0.35);
    padding: 1rem 1rem 0.85rem;
}

main.erp-form-mode > form .row,
main.erp-form-mode > .erp-form .row {
    --bs-gutter-x: 1rem;
    --bs-gutter-y: 1rem;
}

main.erp-form-mode .erp-form h5,
main.erp-form-mode .erp-form h6 {
    font-size: 0.98rem;
}

main.erp-form-mode > form .form-check,
main.erp-form-mode > .erp-form .form-check {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.5rem;
    background: var(--bs-tertiary-bg);
}

main.erp-form-mode > form .producto-opciones-bar .form-check-input,
main.erp-form-mode > .erp-form .producto-opciones-bar .form-check-input,
main.erp-form-mode #productoFormRoot form .producto-opciones-bar .form-check-input {
    float: none;
    margin: 0;
    flex-shrink: 0;
    position: static;
}

.producto-opciones-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
}

.producto-opciones-label {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--bs-secondary-color);
    line-height: 1.5;
    margin: 0;
}

.producto-opcion-item {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    margin: 0;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
    cursor: pointer;
    user-select: none;
}

.producto-opcion-item .form-check-input {
    float: none;
    margin: 0;
    flex-shrink: 0;
}

main.erp-form-mode > form .form-check-input,
main.erp-form-mode > .erp-form .form-check-input {
    margin-top: 0;
}

main.erp-form-mode > form .form-check-label,
main.erp-form-mode > .erp-form .form-check-label {
    margin-bottom: 0;
    font-weight: 500;
}

main.erp-form-mode > form .form-text,
main.erp-form-mode > .erp-form .form-text {
    color: var(--bs-secondary-color);
    font-size: 0.8rem;
}

main.erp-form-mode > form .btn,
main.erp-form-mode > .erp-form .btn {
    margin-top: 0.25rem;
}

main.erp-form-mode > form > .btn,
main.erp-form-mode > form > a.btn,
main.erp-form-mode > form > button.btn,
main.erp-form-mode > .erp-form > .btn,
main.erp-form-mode > .erp-form > a.btn,
main.erp-form-mode > .erp-form > button.btn {
    margin-bottom: 0.5rem;
}

main.erp-form-mode .erp-form .d-flex.justify-content-end.gap-2.mt-4 .btn {
    min-width: 7.25rem;
}

.producto-lista-precios-table-wrap {
    width: fit-content;
    max-width: 100%;
    overflow-x: auto;
}

.producto-lista-precios-table {
    width: auto;
    table-layout: auto;
}

.producto-lista-precios-table th,
.producto-lista-precios-table td {
    vertical-align: middle;
}

.producto-lista-precios-table td:first-child {
    white-space: nowrap;
    padding-right: 0.75rem;
}

.producto-lista-precios-table td:last-child {
    width: 1%;
    white-space: nowrap;
    padding-left: 0;
}

.producto-lista-precios-input {
    width: 9rem;
    min-width: 9rem;
    max-width: 100%;
}

.producto-comp-cantidad-group {
    width: 13rem;
    max-width: 100%;
    flex-wrap: nowrap;
}

.producto-comp-cantidad-group > .form-control {
    flex: 1 1 auto;
    min-width: 3.25rem;
}

.producto-comp-cantidad-group > .input-group-text.comp-unidad-desc {
    flex: 0 0 5.25rem;
    max-width: 5.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Paginación de listados (partial _PaginacionListado) */
.erp-paginacion-footer {
    background: #fff;
    border-top: 1px solid var(--bs-border-color, #dee2e6);
}

.erp-paginacion {
    width: auto;
    flex-wrap: nowrap;
}

.erp-paginacion > .btn,
.erp-paginacion > .input-group-text,
.erp-paginacion > .form-select,
.erp-paginacion > .form-control {
    border-color: var(--bs-border-color, #ced4da);
}

.erp-paginacion > .btn {
    white-space: nowrap;
    font-weight: 500;
}

.erp-paginacion > .btn:not(.disabled):hover {
    background-color: rgba(var(--bs-primary-rgb, 0, 50, 125), 0.06);
    border-color: var(--brand-primary, #00327d);
    color: var(--brand-primary, #00327d);
}

.erp-paginacion-label {
    background: #f8f9fa;
    color: #6c757d;
    font-size: 0.8125rem;
    white-space: nowrap;
    padding-left: 0.65rem;
    padding-right: 0.65rem;
}

.erp-paginacion-select {
    width: auto;
    min-width: 3.25rem;
    max-width: 4.5rem;
    text-align: center;
    font-weight: 600;
    padding-left: 0.5rem;
    padding-right: 1.75rem;
    cursor: pointer;
}

.erp-paginacion-pagina-static {
    width: auto;
    min-width: 3.25rem;
    max-width: 4.5rem;
    background: #fff;
    pointer-events: none;
}

.erp-paginacion > .btn.disabled,
.erp-paginacion > span.btn.disabled {
    opacity: 0.55;
    pointer-events: none;
}

@media (max-width: 575.98px) {
    .erp-paginacion-footer {
        flex-direction: column;
        align-items: stretch !important;
        text-align: center;
    }

    .erp-paginacion-footer nav {
        display: flex;
        justify-content: center;
    }
}
