html, body {
    height: 100%;
}

.sidebar {
    width: 264px;
    /* Móvil: el offcanvas de Bootstrap es position:fixed y arranca en la
       parte superior real de la pantalla (top:0), tapando el alto de la
       barra de navegación, así que no se resta nada acá. En escritorio
       (ver media query más abajo) sí arranca debajo de la barra fija. */
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    background-color: #fcfdfc;
    transition: width .18s ease;
    /* Sin overflow:hidden acá: el botón de colapsar (.sidebar-toggle) se
       posiciona a propósito medio afuera del borde derecho, y este
       contenedor lo recortaría. El contenido que sí necesita recortarse
       (la lista de navegación) se controla en .offcanvas-body. */
}

.sidebar .offcanvas-body {
    height: 100%;
    max-height: 100%;
    overflow: hidden;
}

.sidebar .nav {
    padding-left: .75rem;
    padding-right: .75rem;
    row-gap: .1rem;
    flex-wrap: nowrap;
}

.sidebar .nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: .85rem .5rem .4rem;
    margin-top: .15rem;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #97a3a8;
    font-weight: 700;
    border-top: 1px solid #eef1f0;
    background: none;
    border-left: none;
    border-right: none;
    border-bottom: none;
}

button.nav-header {
    cursor: pointer;
}

li.nav-group:first-child .nav-header {
    border-top: none;
    margin-top: 0;
}

.nav-header-left {
    display: flex;
    align-items: center;
    gap: .7rem;
    min-width: 0;
}

.nav-header .nav-ico {
    width: 1.5rem;
    height: 1.5rem;
    font-size: .8rem;
}

.nav-header .chevron {
    font-size: .7rem;
    color: #b7c0c3;
    transition: transform .18s ease;
    flex: none;
}

.nav-header[aria-expanded="false"] .chevron {
    transform: rotate(-90deg);
}

.nav-sub {
    list-style: none;
    margin: .1rem 0 .1rem .55rem;
    padding: 0 0 0 .55rem;
    border-left: 1px dashed #dde4e1;
    overflow: hidden;
    transition: max-height .2s ease;
}

.sidebar .nav-link,
button.nav-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    width: 100%;
    color: #43494c;
    font-size: .9rem;
    padding: .48rem .6rem;
    border-radius: .55rem;
    background: none;
    border: none;
    text-align: left;
    font-family: inherit;
    transition: background-color .15s ease, color .15s ease;
}

.sidebar .nav-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 1.85rem;
    height: 1.85rem;
    border-radius: .5rem;
    background-color: #eef2f1;
    color: #3f8f86;
    font-size: .95rem;
    transition: background-color .15s ease, color .15s ease;
}

.sidebar .nav-link:hover,
.sidebar .nav-header:hover {
    color: #115e59;
    background-color: #e0f7f5;
}

.sidebar .nav-link:hover .nav-ico {
    background-color: #c8f4ee;
    color: #0d9488;
}

.sidebar .nav-link.active {
    color: #115e59;
    background-color: #ccfbf1;
    font-weight: 600;
}

.sidebar .nav-link.active .nav-ico {
    background-color: #0d9488;
    color: #fff;
}

.sidebar-footer {
    margin-top: auto;
    padding: .6rem .75rem .85rem;
    border-top: 1px solid #eef1f0;
}

.sidebar-footer .nav-link-salir:hover {
    color: #b02a37;
    background-color: #fbeaec;
}

.sidebar-footer .nav-link-salir:hover .nav-ico {
    background-color: #f6d6da;
    color: #b02a37;
}

.sidebar-toggle {
    position: absolute;
    top: 18px;
    right: -14px;
    z-index: 5;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: #0d9488;
    color: #fff;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,.18);
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    transition: transform .18s ease, background-color .15s ease;
}

.sidebar-toggle:hover {
    background-color: #115e59;
}

.contenido {
    min-height: calc(100vh - 56px);
    background-color: #f6f8f7;
}

@media (min-width: 992px) {
    /* En escritorio, el contenido queda acotado al mismo alto que el
       sidebar (que ya no scrollea, gracias a sticky) y hace su propio
       scroll interno si una tabla es larga, en vez de estirar toda la
       página más allá de donde está "Salir". */
    .contenido {
        height: calc(100vh - 56px);
        height: calc(100dvh - 56px);
        overflow-y: auto;
        padding-bottom: 2rem !important;
    }
}

.fila-stock-bajo {
    background-color: #fff3cd !important;
}

.fila-stock-agotado {
    background-color: #f8d7da !important;
}

table.tabla-detalle input[type="number"] {
    max-width: 110px;
}

@media (min-width: 992px) {
    /* Una sola regla para .sidebar: "position" no puede quedar repetido en
       dos selectores distintos que matchean el mismo elemento (.offcanvas-lg
       y .sidebar), porque el que aparece después en el archivo gana y pisa
       al otro. Acá ya quedó unificado para que "sticky" nunca se pierda:
       eso es lo que mantiene la barra lateral (y el botón Salir) siempre
       visible mientras se hace scroll en una tabla larga. */
    .sidebar {
        position: sticky;
        top: 56px;
        height: calc(100vh - 56px);
        height: calc(100dvh - 56px);
        max-height: calc(100vh - 56px);
        max-height: calc(100dvh - 56px);
    }

    /* El modo "solo iconos" es una preferencia de escritorio (el botón que
       lo activa está oculto en pantallas chicas); se acota a este media
       query para que un estado guardado en localStorage nunca lo dispare
       accidentalmente en el menú móvil (offcanvas). */
    .sidebar.collapsed {
        width: 84px;
    }

    .sidebar.collapsed .sidebar-toggle i {
        transform: rotate(180deg);
    }

    .sidebar.collapsed .nav-texto {
        display: none;
    }

    /* El header ya no se oculta del todo: queda su icono como marcador
       visual del modulo por encima de los iconos de sus items (el texto
       y el chevron sí se ocultan, y el click se desactiva porque en modo
       icono las secciones siempre se muestran abiertas). */
    .sidebar.collapsed .nav-header {
        justify-content: center;
        padding: .5rem .4rem .3rem;
        margin-top: 0;
        border-top: none;
        cursor: default;
        pointer-events: none;
    }

    .sidebar.collapsed .nav-header .chevron {
        display: none;
    }

    .sidebar.collapsed li.nav-group {
        margin-top: .55rem;
        padding-top: .55rem;
        border-top: 1px solid #eef1f0;
    }

    .sidebar.collapsed li.nav-group:first-child {
        margin-top: 0;
        padding-top: 0;
        border-top: none;
    }

    .sidebar.collapsed .nav-link {
        justify-content: center;
        padding-left: .4rem;
        padding-right: .4rem;
    }

    .sidebar.collapsed .nav-sub {
        margin-left: 0;
        padding-left: 0;
        border-left: none;
    }
}

/* ---------------------------------------------------------------------
   Encabezados de página y tarjetas contenedoras
--------------------------------------------------------------------- */
.contenido h2 {
    font-weight: 700;
    color: #1c2b23;
    letter-spacing: -.01em;
}

.contenido .card {
    border-radius: .85rem;
}

.contenido .card.shadow-sm {
    box-shadow: 0 1px 2px rgba(23, 35, 27, .04), 0 6px 20px -10px rgba(23, 35, 27, .12) !important;
}

/* ---------------------------------------------------------------------
   Barra de búsqueda/filtros
--------------------------------------------------------------------- */
.contenido form.row.g-2 .form-control,
.contenido form.row.g-2 .form-select {
    border-color: #dbe3df;
}

.contenido form.row.g-2 .form-control:focus,
.contenido form.row.g-2 .form-select:focus {
    border-color: #5eead4;
    box-shadow: 0 0 0 .2rem rgba(13, 148, 136, .12);
}

/* ---------------------------------------------------------------------
   Tablas
--------------------------------------------------------------------- */
.contenido table thead.table-light th {
    background-color: #f1f5f2;
    color: #5c6b62;
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 700;
    border-bottom: none;
    padding-top: .75rem;
    padding-bottom: .75rem;
}

.contenido table td {
    padding-top: .65rem;
    padding-bottom: .65rem;
    color: #2c3733;
}

.contenido table.table-hover tbody tr:hover {
    background-color: #f4faf6;
}

/* ---------------------------------------------------------------------
   Badges de estado — versión "pill" suave, en vez del bootstrap sólido
--------------------------------------------------------------------- */
.contenido .badge {
    font-weight: 600;
    font-size: .72rem;
    letter-spacing: .02em;
    padding: .38em .75em;
    border-radius: 50rem;
}

.contenido .badge.bg-success {
    background-color: #ccfbf1 !important;
    color: #115e59;
}

.contenido .badge.bg-danger {
    background-color: #fbe4e6 !important;
    color: #8a2432;
}

.contenido .badge.bg-warning {
    background-color: #fff1cc !important;
    color: #8a5a00;
}

.contenido .badge.bg-secondary {
    background-color: #eceff1 !important;
    color: #4a555c;
}

/* ---------------------------------------------------------------------
   Paginación
--------------------------------------------------------------------- */
.contenido .pagination .page-link {
    color: #115e59;
    border-color: #e1e8e4;
    margin: 0 .15rem;
    border-radius: .5rem;
}

.contenido .pagination .page-item.active .page-link {
    background-color: #0d9488;
    border-color: #0d9488;
}

.contenido .pagination .page-link:hover {
    background-color: #e0f7f5;
    color: #115e59;
}

.contenido .pagination .page-item.disabled .page-link {
    color: #adb5bd;
}

/* ---------------------------------------------------------------------
   Formularios (Crear/Editar)
--------------------------------------------------------------------- */
.contenido .form-label {
    font-weight: 600;
    font-size: .85rem;
    color: #3d4a44;
    margin-bottom: .3rem;
}

.contenido .form-control,
.contenido .form-select {
    border-color: #dbe3df;
    padding-top: .5rem;
    padding-bottom: .5rem;
}

.form-control:focus,
.form-select:focus {
    border-color: #5eead4;
    box-shadow: 0 0 0 .2rem rgba(13, 148, 136, .12);
}

.contenido .btn {
    border-radius: .55rem;
    font-weight: 600;
}

/* ---------------------------------------------------------------------
   Tema turquesa — reemplaza el "success" verde de Bootstrap en toda la
   app (navbar, botones, alertas, badges) sin tener que tocar cada vista.
--------------------------------------------------------------------- */
.btn-success {
    background-color: #0d9488;
    border-color: #0d9488;
}

.btn-success:hover,
.btn-success:focus,
.btn-success:active {
    background-color: #115e59 !important;
    border-color: #115e59 !important;
}

.btn-outline-success {
    color: #0d9488;
    border-color: #0d9488;
}

.btn-outline-success:hover,
.btn-outline-success:focus,
.btn-outline-success:active {
    background-color: #0d9488 !important;
    border-color: #0d9488 !important;
    color: #fff !important;
}

.bg-success {
    background-color: #0d9488 !important;
}

.text-success {
    color: #0d9488 !important;
}

.border-success {
    border-color: #0d9488 !important;
}

.alert-success {
    background-color: #ccfbf1;
    border-color: #99f6e4;
    color: #115e59;
}

/* ---------------------------------------------------------------------
   Tarjetas de estadísticas (Inicio)
--------------------------------------------------------------------- */
.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.15rem 1.25rem;
}

.stat-card .stat-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 3rem;
    height: 3rem;
    border-radius: .8rem;
    font-size: 1.35rem;
}

.stat-card .stat-label {
    font-size: .78rem;
    color: #6b7a72;
    font-weight: 600;
    margin-bottom: .15rem;
}

.stat-card .stat-valor {
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1.1;
    color: #1c2b23;
}

.stat-card.acento-verde .stat-ico { background-color: #ccfbf1; color: #0d9488; }
.stat-card.acento-azul .stat-ico { background-color: #dbe8fb; color: #2f6fe4; }
.stat-card.acento-celeste .stat-ico { background-color: #d8f0f4; color: #0e8a9f; }
.stat-card.acento-ambar .stat-ico { background-color: #fdecc8; color: #b3760a; }

/* ---------------------------------------------------------------------
   Pantalla de login
--------------------------------------------------------------------- */
.pantalla-login {
    min-height: 100vh;
    background:
        radial-gradient(circle at 15% 20%, rgba(255,255,255,.08) 0, transparent 45%),
        radial-gradient(circle at 85% 85%, rgba(255,255,255,.06) 0, transparent 45%),
        linear-gradient(150deg, #134e4a 0%, #0f766e 45%, #0d9488 100%);
}

.card-login {
    max-width: 410px;
    width: 100%;
    border-radius: 1rem;
    overflow: hidden;
}

.card-login .login-marca {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3.4rem;
    height: 3.4rem;
    margin: 0 auto .9rem;
    border-radius: .9rem;
    background-color: #ccfbf1;
    color: #0d9488;
    font-size: 1.6rem;
    overflow: hidden;
}

.card-login .login-marca img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.logo-navbar {
    width: 1.8rem;
    height: 1.8rem;
    border-radius: .4rem;
    object-fit: cover;
}

.card-login .btn-success {
    padding-top: .6rem;
    padding-bottom: .6rem;
}

/* ---------------------------------------------------------------------
   Imágenes de producto
--------------------------------------------------------------------- */
.miniatura-producto {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: .5rem;
    object-fit: cover;
    background-color: #f1f5f2;
}

.miniatura-vacia {
    color: #a9b4ae;
    font-size: 1.1rem;
    border: 1px dashed #dbe3df;
}

.miniatura-grande {
    width: 7rem;
    height: 7rem;
    border-radius: .75rem;
}

.imagen-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1 / 1;
    max-width: 9rem;
    border-radius: .75rem;
    background-color: #f1f5f2;
    border: 1px dashed #dbe3df;
    overflow: hidden;
}

.imagen-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.imagen-preview i {
    font-size: 2.2rem;
}

/* ---------------------------------------------------------------------
   Select2 (selects buscables) — que combine con los .form-select de Bootstrap
--------------------------------------------------------------------- */
.select2-container .select2-selection--single {
    height: calc(1.5em + .75rem + 2px);
    padding: .375rem .25rem;
    border: 1px solid #dbe3df;
    border-radius: .375rem;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 1.5;
    padding-left: .5rem;
    color: #212529;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: calc(1.5em + .75rem);
}

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: #5eead4;
    box-shadow: 0 0 0 .2rem rgba(13, 148, 136, .12);
}

.select2-dropdown {
    border-color: #dbe3df;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #0d9488;
}

/* ---------------------------------------------------------------------
   Recibo de venta (ticket imprimible)
--------------------------------------------------------------------- */
.fondo-recibo {
    background-color: #eceff1;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 1.5rem 1rem;
    font-family: 'Courier New', Courier, monospace;
}

.barra-recibo {
    width: 100%;
    max-width: 320px;
    display: flex;
    justify-content: space-between;
    margin-bottom: .75rem;
}

.ticket {
    width: 100%;
    max-width: 320px;
    background-color: #fff;
    padding: 1.5rem 1.25rem;
    border-radius: .35rem;
    box-shadow: 0 1px 2px rgba(23, 35, 27, .06), 0 10px 28px -14px rgba(23, 35, 27, .28);
    color: #1c2b23;
    font-size: .85rem;
}

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

.ticket-negocio {
    font-size: 1.05rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    margin-bottom: .2rem;
}

.ticket-separador {
    border-top: 1px dashed #a9b4ae;
    margin: .85rem 0;
}

.ticket-separador-doble {
    border-top-style: double;
    border-top-width: 3px;
}

.ticket-meta div {
    display: flex;
    justify-content: space-between;
    gap: .75rem;
    padding: .1rem 0;
}

.ticket-meta span:first-child {
    color: #5c6b62;
}

.ticket-meta span:last-child {
    text-align: right;
    word-break: break-word;
}

.ticket-detalle {
    width: 100%;
    border-collapse: collapse;
}

.ticket-detalle th {
    text-align: left;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #5c6b62;
    padding-bottom: .4rem;
    border-bottom: 1px dashed #a9b4ae;
}

.ticket-detalle td {
    padding: .4rem 0;
    vertical-align: top;
    border-bottom: 1px dotted #dbe3df;
}

.ticket-detalle small {
    color: #6b7a72;
}

.ticket-total {
    display: flex;
    justify-content: space-between;
    font-size: 1.15rem;
    font-weight: 700;
}

.ticket-pie {
    text-align: center;
    font-size: .85rem;
}

.ticket-anulado {
    margin-top: .6rem;
    font-weight: 700;
    letter-spacing: .05em;
    color: #b02a37;
    border: 2px solid #b02a37;
    border-radius: .35rem;
    padding: .3rem .5rem;
    display: inline-block;
    transform: rotate(-4deg);
}

@media print {
    .no-imprimir {
        display: none !important;
    }

    .fondo-recibo {
        background-color: #fff;
        padding: 0;
    }

    .ticket {
        box-shadow: none;
        max-width: 100%;
    }
}
