/* Reset y configuración base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f7fa;
}

.sales-accounting-summary {
    margin-bottom: 24px;
}

.accounting-card {
    height: 100%;
    padding: 18px 20px;
    border-radius: 16px;
    background: #ffffff;
    border: 1px solid rgba(47, 111, 149, 0.12);
    box-shadow: 0 14px 32px rgba(36, 59, 74, 0.07);
}

.accounting-card span,
.accounting-card small {
    display: block;
    color: #6f8292;
}

.accounting-card span {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.accounting-card strong {
    display: block;
    margin: 8px 0 4px;
    color: #243b4a;
    font-size: 1.5rem;
}

.payment-method-box {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

.payment-method-box label {
    color: #243b4a;
    font-weight: 700;
}

.payment-method-box select {
    min-height: 46px;
    border: 1px solid #d7e2ea;
    border-radius: 10px;
    padding: 10px 12px;
    background: #ffffff;
    color: #243b4a;
}

.payment-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.payment-efectivo {
    background: rgba(45, 143, 111, 0.12);
    color: #246c54;
}

.payment-bizum {
    background: rgba(47, 111, 149, 0.12);
    color: #245a79;
}

/* Variables CSS */
:root {
    --primary-color: #2f6f95;
    --primary-hover: #245a79;
    --secondary-color: #6f8292;
    --success-color: #2d8f6f;
    --warning-color: #c9872f;
    --danger-color: #c65b52;
    --light-gray: #e7eef4;
    --dark-gray: #243b4a;
    --white: #ffffff;
    --shadow: 0 18px 40px rgba(36, 59, 74, 0.08);
    --border-radius: 14px;
    --transition: all 0.3s ease;
}

.dashboard-shell {
    align-items: flex-start;
    background:
        radial-gradient(circle at top right, rgba(63, 167, 214, 0.10), transparent 22%),
        linear-gradient(180deg, #f4f8fb 0%, #edf4f8 100%);
}

.dashboard-mobilebar {
    background: linear-gradient(135deg, #173047, #2b5974);
    box-shadow: 0 8px 24px rgba(17, 39, 55, 0.18);
    z-index: 1040;
}

.dashboard-mobilebar .navbar-brand,
.dashboard-mobilebar-user {
    color: #ffffff;
    font-weight: 600;
}

.dashboard-mobilebar-user {
    font-size: 0.85rem;
    opacity: 0.9;
}

.dashboard-main {
    min-width: 0;
}

.sidebar.offcanvas-lg {
    width: min(320px, 88vw);
    background: linear-gradient(180deg, #173047 0%, #203b52 100%);
    color: #ffffff;
}

.sidebar.offcanvas-lg .offcanvas-body {
    min-height: 100%;
}

.sidebar.offcanvas-lg .offcanvas-header {
    background: rgba(255,255,255,0.04);
    color: #ffffff;
}

@media (min-width: 992px) {
    .sidebar.offcanvas-lg {
        position: relative !important;
        top: auto;
        align-self: stretch;
        height: auto;
        max-height: none;
        display: flex;
        flex-direction: column;
        overflow: visible;
        transform: none !important;
        visibility: visible !important;
        border-right: 1px solid rgba(255,255,255,0.08);
        border-radius: 0;
    }

    .sidebar.offcanvas-lg .offcanvas-body {
        min-height: 100vh;
        overflow: visible;
    }
}

.sidebar-menu.nav {
    --bs-nav-link-padding-x: 0;
    --bs-nav-link-padding-y: 0;
}

.sidebar-menu li {
    list-style: none;
}

.sidebar-menu .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 16px;
    color: rgba(255,255,255,0.82);
    font-weight: 500;
}

.sidebar-menu .nav-link:hover,
.sidebar-menu .nav-link:focus {
    color: #ffffff;
    background: rgba(255,255,255,0.09);
}

.sidebar-menu li.active .nav-link {
    color: #ffffff;
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.9), rgba(35, 118, 173, 0.92));
    box-shadow: 0 10px 24px rgba(20, 88, 131, 0.22);
}

.sidebar-menu .nav-link i {
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    margin: 16px;
    padding: 18px;
    border-radius: 20px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
}

.sidebar-footer .user-info {
    color: rgba(255,255,255,0.88);
}

.sidebar-footer .btn-logout {
    border-radius: 14px;
}

/* ========================================
   RESPONSIVE DESIGN - MOBILE FIRST
======================================== */

/* Botón hamburguesa para móvil */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
}

.mobile-menu-toggle:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.mobile-menu-toggle:active {
    transform: scale(0.95);
}

/* Mostrar botón solo en móvil */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
    }
}

/* Overlay para cerrar menú en móvil */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.mobile-overlay.active {
    display: block;
    opacity: 1;
}

/* ========================================
   TABLET (768px y menos)
======================================== */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
    }

    .dashboard-container {
        grid-template-columns: 1fr !important;
        grid-template-areas: "main" !important;
        position: relative !important;
        overflow-x: hidden !important;
        min-height: 100vh !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 280px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
        background: var(--dark-gray);
        color: var(--white);
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .sidebar.mobile-open {
        left: 0;
    }

    /* Sidebar específicos móvil */
    .sidebar-header {
        padding: 20px 15px;
        background: rgba(0,0,0,0.15);
        border-bottom: 1px solid rgba(255,255,255,0.1);
        flex-shrink: 0;
    }

    .sidebar-header h2 {
        font-size: 1.4rem;
        margin: 0;
        color: var(--white);
    }

    .sidebar-header i {
        color: var(--primary-color);
        font-size: 24px;
    }

    .sidebar-menu {
        padding: 0;
        margin: 0;
        flex: 1;
        overflow-y: auto;
        list-style: none;
        -webkit-overflow-scrolling: touch;
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    .sidebar-menu li {
        list-style: none;
        margin: 0;
        padding: 0;
        display: block;
        width: 100%;
        flex-shrink: 0;
    }

    .sidebar-menu li a {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 15px 20px;
        color: var(--white);
        text-decoration: none;
        font-size: 16px;
        transition: background-color 0.2s ease;
        border: none;
        background: none;
        width: 100%;
        box-sizing: border-box;
        text-align: left;
        cursor: pointer;
        flex-direction: row;
        justify-content: flex-start;
    }

    .sidebar-menu li a:hover,
    .sidebar-menu li a:active {
        background-color: rgba(52, 152, 219, 0.2);
    }

    .sidebar-menu li.active a {
        background-color: var(--primary-color);
        color: var(--white);
    }

    .sidebar-menu li a i {
        width: 20px;
        text-align: center;
        font-size: 16px;
        color: inherit;
        flex-shrink: 0;
    }

    .sidebar-footer {
        padding: 20px 15px;
        border-top: 1px solid rgba(255,255,255,0.1);
        flex-shrink: 0;
    }

    .user-info {
        font-size: 14px;
        margin-bottom: 15px;
        color: var(--white);
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .btn-logout {
        width: 100%;
        background-color: var(--danger-color);
        color: var(--white);
        border: none;
        padding: 12px;
        border-radius: 6px;
        text-decoration: none;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        font-size: 14px;
        transition: background-color 0.2s ease;
    }

    .btn-logout:hover {
        background-color: #c0392b;
    }

    /* Mejoras adicionales para móvil */
    .dashboard-container {
        position: relative;
        overflow-x: hidden;
        min-height: 100vh;
        width: 100%;
    }

    .main-content {
        grid-area: main;
        padding: 70px 10px 10px 10px !important;
        margin: 0 !important;
        width: 100% !important;
        min-width: 0 !important;
        position: relative !important;
        z-index: 1 !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
        left: 0 !important;
        right: 0 !important;
    }

    /* Mejorar container general */
    .container {
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Sections responsive */
    .content-section {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .content-section.active {
        display: block !important;
    }

    /* Headers responsive */
    .section-header {
        padding: 15px 0 !important;
        margin: 0 0 20px 0 !important;
        border-bottom: 2px solid #eee !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .section-header h2 {
        font-size: 1.6rem !important;
        margin: 0 0 5px 0 !important;
        color: var(--dark-gray) !important;
        line-height: 1.3 !important;
        padding: 0 !important;
    }

    .section-header p {
        margin: 0 !important;
        color: #666 !important;
        font-size: 0.95rem !important;
        line-height: 1.4 !important;
        padding: 0 !important;
    }

    .container {
        padding: 10px;
        max-width: 100%;
    }

    /* Stats cards responsivos */
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 15px;
    }

    .stats-card {
        padding: 20px 15px;
        text-align: center;
    }

    .stats-card h3 {
        font-size: 2rem;
        margin-bottom: 5px;
    }

    .stats-card p {
        font-size: 0.9rem;
        margin: 0;
    }

    /* Tablas responsivas con scroll horizontal */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -15px;
        padding: 0 15px;
    }

    table {
        min-width: 700px;
        font-size: 14px;
        white-space: nowrap;
    }

    th, td {
        padding: 12px 8px;
        vertical-align: middle;
    }

    /* Formularios en una columna */
    .form-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .form-row {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }

    .form-group {
        margin-bottom: 15px;
        width: 100%;
    }

    .form-group label {
        font-size: 14px;
        font-weight: 600;
        margin-bottom: 8px;
        display: block;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        width: 100%;
        padding: 14px 12px;
        font-size: 16px; /* Previene zoom en iOS */
        border: 1px solid #ddd;
        border-radius: 8px;
        box-sizing: border-box;
    }

    /* Botones responsive */
    .btn {
        padding: 14px 20px;
        font-size: 16px;
        width: 100%;
        justify-content: center;
        margin-bottom: 10px;
        min-height: 48px;
        box-sizing: border-box;
    }

    .btn-group {
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }

    .btn-group .btn {
        margin-bottom: 0;
    }

    /* Action buttons en tablas */
    .action-buttons {
        display: flex;
        flex-direction: column;
        gap: 8px;
        min-width: 100px;
    }

    .action-buttons .btn {
        margin-bottom: 0;
        padding: 8px 12px;
        font-size: 14px;
        min-height: 40px;
    }

    /* Productos grid responsive */
    .available-products-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 15px;
        padding: 0;
    }

    .product-card {
        padding: 15px;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }

    .product-image {
        height: 140px;
        margin-bottom: 15px;
    }

    .product-image img {
        height: 100%;
        width: 100%;
        object-fit: cover;
        border-radius: 8px;
    }

    .product-info h4 {
        font-size: 1.1rem;
        margin-bottom: 8px;
        line-height: 1.3;
    }

    .product-details {
        margin: 10px 0;
    }

    .product-price {
        font-size: 1.2rem;
        font-weight: bold;
        color: var(--primary-color);
    }

    /* Cart section */
    .cart-section {
        margin-top: 20px;
        max-height: 60vh;
        overflow-y: auto;
        border: 1px solid #eee;
        border-radius: 12px;
        background: white;
        padding: 15px;
    }

    /* Modales responsive */
    .modal-content {
        width: 95%;
        max-width: 95vw;
        margin: 5vh auto;
        max-height: 90vh;
        overflow-y: auto;
        border-radius: 12px;
    }

    .modal-header {
        padding: 20px 15px;
        border-bottom: 1px solid #eee;
    }

    .modal-header h3 {
        font-size: 1.3rem;
        margin: 0;
    }

    .modal-body {
        padding: 20px 15px;
        max-height: 70vh;
        overflow-y: auto;
    }

    /* Section headers */
    .section-header {
        padding: 15px 0;
        margin-bottom: 20px;
        border-bottom: 2px solid #eee;
    }

    .section-header h2 {
        font-size: 1.6rem;
        margin: 0 0 5px 0;
        color: var(--dark-gray);
    }

    .section-header p {
        margin: 0;
        color: #666;
        font-size: 0.95rem;
    }

    /* Search and filters */
    .search-filter-container {
        display: flex;
        flex-direction: column;
        gap: 15px;
        margin-bottom: 20px;
    }

    .search-filter-container input,
    .search-filter-container select {
        width: 100%;
        padding: 12px;
        font-size: 16px;
        border: 1px solid #ddd;
        border-radius: 8px;
    }

    /* Alerts */
    .alert {
        padding: 15px;
        font-size: 14px;
        margin-bottom: 15px;
        border-radius: 8px;
        line-height: 1.4;
    }

    /* Charts responsive */
    .chart-container {
        height: 250px;
        margin-bottom: 25px;
        padding: 15px;
        background: white;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
}

/* ========================================
   MÓVIL (480px y menos)
======================================== */
@media (max-width: 480px) {
    .mobile-menu-toggle {
        top: 10px;
        left: 10px;
        padding: 10px;
        font-size: 16px;
    }

    .main-content {
        padding: 60px 5px 5px 5px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
        margin: 0 !important;
        left: 0 !important;
        right: 0 !important;
        position: relative !important;
    }

    .container {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Asegurar que todos los elementos internos no tengan offset */
    .content-section,
    .section-header,
    .stats-grid,
    .available-products-grid,
    .table-container,
    .form-grid,
    .chart-container {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 5px !important;
        padding-right: 5px !important;
        box-sizing: border-box !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Stats cards en una columna */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stats-card {
        padding: 15px;
        text-align: center;
        border-radius: 10px;
    }

    .stats-card h3 {
        font-size: 1.8rem;
        margin-bottom: 5px;
    }

    .stats-card p {
        font-size: 0.85rem;
        margin: 0;
    }

    /* Tablas muy compactas */
    .table-container {
        margin: 0 -8px;
        padding: 0 8px;
    }

    table {
        font-size: 13px;
        min-width: 600px;
    }

    th, td {
        padding: 8px 4px;
        font-size: 12px;
    }

    /* Formularios ultra compactos */
    .form-group {
        margin-bottom: 12px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 12px 10px;
        font-size: 16px;
        border-radius: 6px;
    }

    /* Productos en una sola columna */
    .available-products-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .product-card {
        padding: 12px;
        border-radius: 10px;
    }

    .product-image {
        height: 120px;
        margin-bottom: 12px;
    }

    .product-info h4 {
        font-size: 1rem;
        margin-bottom: 6px;
        line-height: 1.2;
    }

    .product-price {
        font-size: 1.1rem;
    }

    /* Modales pantalla completa */
    .modal-content {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
        position: fixed;
        top: 0;
        left: 0;
    }

    .modal-header {
        padding: 15px 12px;
        position: sticky;
        top: 0;
        background: white;
        z-index: 10;
    }

    .modal-body {
        padding: 15px 12px;
        height: calc(100vh - 120px);
        overflow-y: auto;
    }

    .modal-footer {
        padding: 12px;
        position: sticky;
        bottom: 0;
        background: white;
        border-top: 1px solid #eee;
    }

    /* Botones más grandes para dedos */
    .btn {
        padding: 16px 20px;
        font-size: 16px;
        min-height: 50px;
        border-radius: 8px;
        font-weight: 600;
    }

    /* Sidebar más compacto */
    .sidebar {
        width: 260px;
        left: -260px;
    }

    .sidebar-header {
        padding: 15px 12px;
    }

    .sidebar-header h2 {
        font-size: 1.3rem;
    }

    .sidebar-menu li a {
        padding: 14px 12px;
        font-size: 15px;
    }

    .sidebar-footer {
        padding: 15px 12px;
    }

    /* Cart responsive */
    .cart-section {
        margin-top: 15px;
        border-radius: 10px;
        padding: 12px;
        max-height: 50vh;
    }

    .cart-item {
        padding: 10px 0;
        border-bottom: 1px solid #eee;
    }

    .cart-item:last-child {
        border-bottom: none;
    }

    /* Section headers compactos */
    .section-header {
        padding: 10px 0;
        margin-bottom: 15px;
    }

    .section-header h2 {
        font-size: 1.4rem;
        margin-bottom: 3px;
    }

    /* Search compacto */
    .search-filter-container {
        gap: 10px;
        margin-bottom: 15px;
    }

    .search-filter-container input,
    .search-filter-container select {
        padding: 12px 10px;
        border-radius: 6px;
    }

    /* Alerts compactos */
    .alert {
        padding: 12px 10px;
        font-size: 13px;
        margin-bottom: 10px;
        border-radius: 6px;
    }

    /* Charts más pequeños */
    .chart-container {
        height: 200px;
        margin-bottom: 15px;
        padding: 10px;
        border-radius: 10px;
    }

    /* Action buttons compactos */
    .action-buttons {
        gap: 6px;
    }

    .action-buttons .btn {
        padding: 8px 10px;
        font-size: 13px;
        min-height: 36px;
    }

    /* Quantity controls mejores para touch */
    .quantity-controls {
        gap: 8px;
        margin: 8px 0;
    }

    .quantity-controls button {
        min-width: 40px;
        min-height: 40px;
        padding: 8px;
        font-size: 16px;
        border-radius: 6px;
    }

    .quantity-controls input {
        width: 70px;
        text-align: center;
        padding: 8px;
        font-size: 16px;
        border-radius: 4px;
    }

    /* Sales layout mejorado */
    .sales-layout {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }

    .products-section {
        order: 1;
    }

    .cart-section {
        order: 2;
        position: sticky;
        bottom: 0;
        background: white;
        border-top: 2px solid #eee;
        margin: 0 -8px;
        padding: 15px 8px;
        z-index: 50;
    }
}

/* ========================================
   MEJORAS DE USABILIDAD MÓVIL
======================================== */

/* Reset básico para móvil */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    scroll-behavior: smooth;
    width: 100%;
    overflow-x: hidden;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    width: 100%;
    margin: 0;
    padding: 0;
    position: relative;
}

/* Scroll suave en contenedores */
.available-products-grid,
.table-container,
.modal-body {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Mejores tap targets para touch devices */
.product-name-clickable,
.btn,
button,
.sidebar-menu a,
.modal-close,
input[type="submit"],
input[type="button"] {
    -webkit-tap-highlight-color: rgba(52, 152, 219, 0.2);
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

/* Estados hover mejorados solo para desktop */
@media (hover: hover) and (pointer: fine) {
    .product-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow);
        border-color: var(--primary-color);
    }

    .btn:hover:not(:disabled) {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    }

    .sidebar-menu a:hover {
        background-color: rgba(52, 152, 219, 0.1);
    }
}

/* Estados touch para dispositivos táctiles */
@media (hover: none) and (pointer: coarse) {
    .product-card:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }

    .btn:active:not(:disabled) {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }

    .sidebar-menu a:active {
        background-color: rgba(52, 152, 219, 0.2);
    }

    /* Remover hover effects en touch devices */
    .product-card:hover {
        transform: none;
        box-shadow: initial;
        border-color: initial;
    }

    .btn:hover {
        transform: none;
        box-shadow: initial;
    }
}

/* Mejoras para inputs en dispositivos móviles */
input, select, textarea {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: var(--border-radius);
    font-family: inherit;
}

/* Fix para selects en iOS */
select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

/* Keyboard navigation improvements */
.btn:focus,
.sidebar-menu a:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.2);
}

/* Prevent zoom on inputs en iOS */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    select, textarea, input[type="text"], input[type="password"],
    input[type="datetime"], input[type="datetime-local"],
    input[type="date"], input[type="month"], input[type="time"],
    input[type="week"], input[type="number"], input[type="email"],
    input[type="url"], input[type="search"], input[type="tel"] {
        font-size: 16px !important;
    }
}

/* Mejor contraste para pantallas pequeñas */
@media (max-width: 480px) {
    body {
        font-size: 16px;
        line-height: 1.5;
    }

    .text-muted {
        color: #666 !important;
    }

    /* Mejorar legibilidad */
    h1, h2, h3, h4, h5, h6 {
        line-height: 1.3;
    }

    p, li {
        line-height: 1.5;
    }
}

/* Orientación landscape en móvil */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .sidebar {
        width: 220px;
        left: -220px;
    }

    .sidebar-menu li a {
        padding: 8px 12px;
        font-size: 14px;
    }

    .main-content {
        padding-top: 50px;
    }

    .mobile-menu-toggle {
        top: 5px;
        left: 5px;
        padding: 8px;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }

}

/* Mejoras específicas para PWA */
@media (display-mode: standalone) {
    .main-content {
        padding-top: 80px; /* Más espacio para status bar */
    }
}

/* Dark mode support para dispositivos que lo prefieren */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #1a1a1a;
        --text-color: #ffffff;
        --card-bg: #2d2d2d;
        --border-color: #404040;
    }

    body {
        background-color: var(--bg-color);
        color: var(--text-color);
    }

    .sidebar {
        background-color: var(--card-bg);
        border-right: 1px solid var(--border-color);
    }

    .product-card,
    .stats-card,
    .modal-content {
        background-color: var(--card-bg);
        border-color: var(--border-color);
        color: var(--text-color);
    }
}

/* Mejoras para reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .sidebar {
        transition: none;
    }

    .mobile-overlay {
        transition: none;
    }
}

/* ========================================
   MEJORAS TOUCH Y ACCESIBILIDAD MÓVIL
======================================== */

/* Mejores tap targets para touch devices */
.product-name-clickable,
.btn,
button,
.sidebar-menu a,
.modal-close,
input[type="submit"],
input[type="button"] {
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    touch-action: manipulation;
}

/* Estados hover mejorados para touch */
@media (hover: hover) and (pointer: fine) {
    .product-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow);
        border-color: var(--primary-color);
    }

    .btn:hover {
        transform: translateY(-1px);
    }
}

/* Estados touch para dispositivos táctiles */
@media (hover: none) and (pointer: coarse) {
    .product-card:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }

    .btn:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }

    .sidebar-menu a:active {
        background-color: rgba(52, 152, 219, 0.1);
    }
}

/* Scroll suave en contenedores */
.available-products-grid,
.table-container,
.modal-body {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Mejoras para inputs en dispositivos móviles */
input, select, textarea {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: var(--border-radius);
}

/* Keyboard navigation improvements */
.btn:focus,
.sidebar-menu a:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ========================================
   MEJORAS ESPECÍFICAS MENÚ MÓVIL
======================================== */

/* Asegurar que el sidebar esté por encima de todo */
@media (max-width: 768px) {
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: -100% !important;
        width: 280px !important;
        height: 100vh !important;
        z-index: 1000 !important;
        background: var(--dark-gray) !important;
        transform: translateX(0);
        transition: left 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
        display: flex !important;
        flex-direction: column !important;
    }

    .sidebar.mobile-open {
        left: 0 !important;
    }

    .sidebar.show,
    .sidebar.showing {
        left: 0 !important;
    }

    /* Menú vertical forzado */
    .sidebar-menu {
        display: flex !important;
        flex-direction: column !important;
        list-style: none !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        flex: 1 !important;
        overflow-y: auto !important;
    }

    .sidebar-menu li {
        display: block !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        list-style: none !important;
        flex-shrink: 0 !important;
    }

    .sidebar-menu li a {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 12px !important;
        padding: 16px 20px !important;
        width: 100% !important;
        color: var(--white) !important;
        text-decoration: none !important;
        font-size: 16px !important;
        border: none !important;
        background: none !important;
        box-sizing: border-box !important;
        text-align: left !important;
        cursor: pointer !important;
        transition: background-color 0.2s ease !important;
        white-space: nowrap !important;
    }

    .sidebar-menu li a i {
        width: 20px !important;
        text-align: center !important;
        font-size: 16px !important;
        color: inherit !important;
        flex-shrink: 0 !important;
        margin-right: 0 !important;
    }

    .sidebar-menu li a span {
        flex: 1 !important;
        text-align: left !important;
    }

    .sidebar-menu li a:hover,
    .sidebar-menu li a:active {
        background-color: rgba(52, 152, 219, 0.2) !important;
    }

    .sidebar-menu li.active a {
        background-color: var(--primary-color) !important;
        color: var(--white) !important;
    }

    .mobile-overlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        z-index: 999 !important;
        background: rgba(0, 0, 0, 0.6) !important;
        backdrop-filter: blur(3px);
        -webkit-backdrop-filter: blur(3px);
    }

    .mobile-menu-toggle {
        position: fixed !important;
        top: 15px !important;
        left: 15px !important;
        z-index: 1001 !important;
    }

    /* Prevenir scroll del body cuando menú está abierto */
    body.menu-open {
        overflow: hidden !important;
        position: fixed !important;
        width: 100% !important;
        height: 100% !important;
    }
}

/* Para móviles muy pequeños */
@media (max-width: 480px) {
    .mobile-menu-toggle {
        top: 10px !important;
        left: 10px !important;
        padding: 10px !important;
    }

    .sidebar {
        width: 260px !important;
        left: -260px !important;
    }

    .sidebar.mobile-open {
        left: 0 !important;
    }

    .sidebar.show,
    .sidebar.showing {
        left: 0 !important;
    }

    /* Opciones de menú más compactas pero siempre verticales */
    .sidebar-menu li a {
        padding: 14px 16px !important;
        font-size: 15px !important;
        min-height: 50px !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
    }

    .sidebar-menu li a i {
        width: 18px !important;
        font-size: 15px !important;
        margin-right: 0 !important;
    }

    .sidebar-header {
        padding: 15px 12px !important;
    }

    .sidebar-header h2 {
        font-size: 1.3rem !important;
    }

    .sidebar-footer {
        padding: 15px 12px !important;
    }
}

/* ========================================
   FORZAR MENÚ VERTICAL EN MÓVIL
======================================== */

/* CSS específico para teléfonos - FORZAR VERTICAL */
@media screen and (max-width: 768px) {
    /* Sidebar container */
    .sidebar {
        display: flex !important;
        flex-direction: column !important;
    }

    /* Lista de menú siempre vertical */
    .sidebar-menu {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        list-style: none !important;
        width: 100% !important;
    }

    /* Items del menú en bloques separados */
    .sidebar-menu li {
        display: block !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        border-bottom: 1px solid rgba(255,255,255,0.05) !important;
    }

    .sidebar-menu li:last-child {
        border-bottom: none !important;
    }

    /* Enlaces del menú con contenido horizontal pero opciones verticales */
    .sidebar-menu li a {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-start !important;
        width: 100% !important;
        padding: 16px 20px !important;
        color: rgba(255,255,255,0.9) !important;
        text-decoration: none !important;
        font-size: 16px !important;
        font-weight: 400 !important;
        background: none !important;
        border: none !important;
        box-sizing: border-box !important;
        text-align: left !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
        min-height: 52px !important;
        gap: 12px !important;
    }

    /* Iconos del menú */
    .sidebar-menu li a i {
        display: inline-block !important;
        width: 20px !important;
        height: 20px !important;
        text-align: center !important;
        font-size: 16px !important;
        color: inherit !important;
        flex-shrink: 0 !important;
        line-height: 20px !important;
    }

    /* Texto del menú */
    .sidebar-menu li a span,
    .sidebar-menu li a {
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    /* Estados hover y active */
    .sidebar-menu li a:hover {
        background-color: rgba(52, 152, 219, 0.15) !important;
        color: #ffffff !important;
    }

    .sidebar-menu li a:active,
    .sidebar-menu li a:focus {
        background-color: rgba(52, 152, 219, 0.25) !important;
        color: #ffffff !important;
    }

    .sidebar-menu li.active a {
        background-color: var(--primary-color) !important;
        color: #ffffff !important;
        font-weight: 500 !important;
    }

    /* Badge de alertas */
    .alert-badge {
        margin-left: auto !important;
        flex-shrink: 0 !important;
    }
}

/* Extra pequeño - ajustes finales */
@media screen and (max-width: 480px) {
    .sidebar-menu li a {
        padding: 14px 16px !important;
        font-size: 15px !important;
        min-height: 48px !important;
    }

    .sidebar-menu li a i {
        width: 18px !important;
        font-size: 15px !important;
    }
}

/* ========================================
   ESTILOS EXISTENTES (mantener al final)
======================================== */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--white);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: var(--white);
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.btn-success {
    background-color: var(--success-color);
    color: var(--white);
}

.btn-success:hover {
    background-color: #229954;
}

.btn-danger {
    background-color: var(--danger-color);
    color: var(--white);
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.btn-logout {
    background-color: var(--danger-color);
    color: var(--white);
    font-size: 12px;
    padding: 8px 12px;
}

/* Alertas */
.alert {
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: var(--border-radius);
    border-left: 4px solid;
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert button {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: inherit;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border-left-color: var(--success-color);
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border-left-color: var(--danger-color);
}

.alert-warning {
    background-color: #fff3cd;
    color: #856404;
    border-left-color: var(--warning-color);
}

/* ========================================
   PÁGINA PRINCIPAL
======================================== */

.welcome-section {
    text-align: center;
    padding: 60px 0;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.logo i {
    font-size: 48px;
    color: var(--primary-color);
}

.logo h1 {
    font-size: 48px;
    color: var(--dark-gray);
    font-weight: 300;
}

.subtitle {
    font-size: 18px;
    color: var(--secondary-color);
    margin-bottom: 50px;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin-bottom: 50px;
}

.feature {
    background: var(--white);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.feature:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.feature i {
    font-size: 32px;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.feature h3 {
    margin-bottom: 10px;
    color: var(--dark-gray);
}

.action-buttons {
    margin-top: 30px;
}

.info-section {
    background: var(--white);
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-top: 40px;
}

.feature-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.feature-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--light-gray);
    border-radius: var(--border-radius);
}

.feature-list i {
    color: var(--success-color);
    font-size: 16px;
}

footer {
    text-align: center;
    padding: 40px 0;
    color: var(--secondary-color);
    background: var(--white);
    margin-top: 40px;
}

/* ========================================
   PÁGINA DE LOGIN
======================================== */

.login-page {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden;
}

.login-header {
    background: var(--dark-gray);
    color: var(--white);
    padding: 30px 20px;
    text-align: center;
}

.login-header i {
    font-size: 32px;
    margin-bottom: 10px;
}

.login-header h1 {
    font-size: 24px;
    margin-bottom: 5px;
}

.login-header p {
    font-size: 14px;
    opacity: 0.8;
}

.login-form {
    padding: 30px 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--dark-gray);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--light-gray);
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.login-footer {
    padding: 20px;
    background: var(--light-gray);
    text-align: center;
}

.default-credentials {
    margin-top: 15px;
}

.default-credentials code {
    background: var(--white);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
}

.small-text {
    font-size: 12px;
    color: var(--secondary-color);
}

/* ========================================
   DASHBOARD
======================================== */

.dashboard-page {
    background: var(--light-gray);
    min-height: 100vh;
}

.dashboard-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    grid-template-areas: "sidebar main";
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    grid-area: sidebar;
    width: 260px;
    background: var(--dark-gray);
    color: var(--white);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    background: rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header i {
    font-size: 24px;
    color: var(--primary-color);
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 300;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.sidebar-menu li {
    margin: 0;
    padding: 0;
    list-style: none;
    display: block;
    width: 100%;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 20px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: all 0.3s ease;
    position: relative;
    border: none;
    background: none;
    width: 100%;
    box-sizing: border-box;
    font-size: 16px;
    cursor: pointer;
    text-align: left;
}

.sidebar-menu a:hover {
    background: rgba(255,255,255,0.1);
    color: var(--white);
}

.sidebar-menu li.active a {
    background: var(--primary-color);
    color: var(--white);
}

.sidebar-menu a i {
    width: 20px;
    text-align: center;
    font-size: 16px;
    color: inherit;
    flex-shrink: 0;
}

.alert-badge {
    background: var(--danger-color);
    color: var(--white);
    font-size: 10px;
    font-weight: bold;
    padding: 0;
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    max-width: 20px;
    max-height: 20px;
    border-radius: 50%;
    aspect-ratio: 1 / 1;
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 15px;
    font-size: 14px;
    color: rgba(255,255,255,0.8);
}

/* Main Content */
.main-content {
    grid-area: main;
    padding: 30px;
    overflow-y: auto;
    min-width: 0; /* Previene overflow en grid */
}

.content-section {
    display: none;
}

.content-section.active {
    display: block;
}

.section-header {
    margin-bottom: 30px;
}

.section-header h1 {
    color: var(--dark-gray);
    margin-bottom: 8px;
}

.section-header p {
    color: var(--secondary-color);
    font-size: 16px;
}

.section-actions {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.section-actions input,
.section-actions select {
    padding: 10px 15px;
    border: 2px solid var(--light-gray);
    border-radius: var(--border-radius);
    font-size: 14px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--white);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.stat-icon {
    width: 60px;
    height: 60px;
    min-width: 60px;
    min-height: 60px;
    max-width: 60px;
    max-height: 60px;
    border-radius: 50%;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: var(--white);
    font-size: 24px;
    flex-shrink: 0;
}

.stat-info h3 {
    font-size: 28px;
    color: var(--dark-gray);
    margin-bottom: 5px;
}

.stat-info p {
    color: var(--secondary-color);
    font-size: 14px;
}

/* Tables */
.table-container {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 30px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--dark-gray);
    color: var(--white);
}

th, td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--light-gray);
}

th {
    font-weight: 500;
    font-size: 14px;
}

tbody tr:hover {
    background: rgba(52, 152, 219, 0.05);
}

.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.status-badge.in-stock {
    background: rgba(39, 174, 96, 0.2);
    color: var(--success-color);
}

.status-badge.low-stock {
    background: rgba(243, 156, 18, 0.2);
    color: var(--warning-color);
}

.status-badge.out-of-stock {
    background: rgba(231, 76, 60, 0.2);
    color: var(--danger-color);
}

.action-buttons {
    display: flex;
    gap: 5px;
}

/* Forms */
.product-form {
    background: var(--white);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.form-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid var(--light-gray);
}

/* Alerts Section */
.product-alert {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    padding: 20px;
}

.alert-content h3 {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-content p {
    margin-bottom: 5px;
}

.alert-actions {
    flex-shrink: 0;
    margin-left: 20px;
}

.whatsapp-alerts-button {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1050;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 54px;
    padding: 14px 18px;
    border: 0;
    border-radius: 999px;
    background: #25d366;
    color: #ffffff;
    font-weight: 800;
    box-shadow: 0 14px 30px rgba(37, 211, 102, 0.28);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.whatsapp-alerts-button i {
    font-size: 1.35rem;
}

.whatsapp-alerts-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 18px 36px rgba(37, 211, 102, 0.34);
}

.whatsapp-alerts-button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    box-shadow: 0 10px 22px rgba(36, 59, 74, 0.12);
}

@media (max-width: 576px) {
    .whatsapp-alerts-button {
        right: 16px;
        bottom: 16px;
        min-width: 54px;
        padding: 14px;
    }

    .whatsapp-alerts-button span {
        display: none;
    }
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1100; /* Aumentado para estar por encima del sidebar móvil */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: var(--white);
    margin: 5% auto;
    padding: 0;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.modal-header {
    background: var(--dark-gray);
    color: var(--white);
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
}

.close {
    color: var(--white);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    opacity: 0.7;
}

/* ========================================
   RESPONSIVE DESIGN
======================================== */

@media (max-width: 768px) {
    .dashboard-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        position: static;
    }

    .sidebar-menu {
        display: flex;
        overflow-x: auto;
        padding: 10px;
    }

    .sidebar-menu li {
        margin-bottom: 0;
        margin-right: 5px;
        flex-shrink: 0;
    }

    .sidebar-footer {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .main-content {
        padding: 20px 15px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .section-actions {
        flex-direction: column;
    }

    .features {
        grid-template-columns: 1fr;
    }

    .feature-list {
        grid-template-columns: 1fr;
    }

    .product-alert {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .alert-actions {
        margin-left: 0;
        width: 100%;
    }

    .form-actions {
        flex-direction: column;
    }

    .action-buttons {
        justify-content: center;
    }

    table {
        font-size: 12px;
    }

    th, td {
        padding: 8px;
    }

    .modal-content {
        width: 95% !important;
        margin: 5px auto !important;
        max-height: 95vh !important;
        border-radius: 8px !important;
    }

    .modal-header {
        padding: 15px 20px !important;
    }

    .modal-header h2, .modal-header h3 {
        font-size: 18px !important;
        margin: 0 !important;
    }

    .close {
        font-size: 24px !important;
        padding: 5px !important;
        line-height: 1 !important;
    }

    /* Modal de imagen de producto específico para móviles */
    #product-image-modal .modal-content {
        width: 98% !important;
        margin: 2px auto !important;
        max-height: 98vh !important;
    }

    #product-image-modal .modal-header {
        padding: 10px 15px !important;
        background: var(--primary-color) !important;
    }

    #product-image-modal .modal-body {
        padding: 15px !important;
    }

    #product-image-modal img {
        width: 100% !important;
        height: auto !important;
        max-height: 60vh !important;
        object-fit: contain !important;
        border-radius: 8px !important;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

    .logo h1 {
        font-size: 36px;
    }

    .logo i {
        font-size: 36px;
    }

    .welcome-section {
        padding: 40px 0;
    }

    .stat-card {
        padding: 15px;
    }

    .stat-icon {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }

    .stat-info h3 {
        font-size: 20px;
    }
}

/* ========================================
   ANIMACIONES
======================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.content-section.active {
    animation: fadeIn 0.3s ease-in-out;
}

.alert {
    animation: fadeIn 0.3s ease-in-out;
}

/* ========================================
   UTILIDADES
======================================== */

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

.p-20 {
    padding: 20px;
}

.hidden {
    display: none;
}

.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ========================================
   ESTILOS DE VENTAS
======================================== */

.sales-container {
    margin-bottom: 30px;
}

.sales-panel-header {
    display: flex;
    position: relative;
    z-index: 2;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--light-gray);
    padding-bottom: 10px;
}

.products-panel .sales-panel-header h3 {
    margin: 0;
    border-bottom: 0;
    padding-bottom: 0;
}

.sales-cart-button {
    position: relative;
    z-index: 3;
    pointer-events: auto;
    white-space: nowrap;
    touch-action: manipulation;
}

.cart-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--primary-color);
    font-size: 12px;
    font-weight: 800;
}

.sales-cart-button.has-items .cart-count-badge {
    background: #ffffff;
    color: var(--success-color);
}

.sales-cart-modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
    width: auto;
    max-width: none;
    margin: 0;
    display: flex;
    align-items: stretch;
    justify-content: flex-end;
    padding: 24px;
    background: rgba(20, 37, 50, 0.48);
}

.sales-cart-modal[hidden] {
    display: none !important;
}

.sales-cart-dialog {
    width: min(540px, 100%);
    max-height: 100%;
    display: flex;
}

.sales-cart-modal .cart-panel {
    width: 100%;
    max-height: 100%;
    overflow-y: auto;
}

.cart-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--light-gray);
    padding-bottom: 10px;
}

.cart-panel .cart-modal-header h3 {
    margin: 0;
    border-bottom: 0;
    padding-bottom: 0;
}

@media (max-width: 768px) {
    .sales-panel-header {
        align-items: stretch;
        flex-direction: column;
    }

    .sales-cart-button {
        justify-content: center;
        width: 100%;
    }

    .sales-cart-modal {
        padding: 0;
    }

    .sales-cart-dialog {
        width: 100%;
    }

    .sales-cart-modal .cart-panel {
        border-radius: 0;
    }
}

.products-panel, .cart-panel {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.products-panel h3, .cart-panel h3 {
    margin-bottom: 15px;
    color: var(--dark-gray);
    border-bottom: 2px solid var(--light-gray);
    padding-bottom: 10px;
}

.available-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.product-card {
    border: 1px solid var(--light-gray);
    border-radius: var(--border-radius);
    padding: 15px;
    background: var(--white);
    transition: var(--transition);
    cursor: pointer;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--primary-color);
}

.product-card h4 {
    color: var(--dark-gray);
    margin-bottom: 8px;
    font-size: 16px;
}

.product-description {
    color: #666;
    font-size: 14px;
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-details {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 15px;
}

.product-category {
    background: var(--light-gray);
    color: var(--dark-gray);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    align-self: flex-start;
}

.product-stock {
    font-size: 14px;
    color: var(--secondary-color);
}

.product-price {
    font-size: 18px;
    font-weight: bold;
    color: var(--success-color);
}

.btn-add-to-cart {
    width: 100%;
    justify-content: center;
}

/* Información del cliente */
.customer-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.customer-info input {
    padding: 10px;
    border: 1px solid var(--light-gray);
    border-radius: var(--border-radius);
    font-size: 14px;
}

.customer-info input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* Carrito */
.cart-items {
    min-height: 200px;
    margin-bottom: 20px;
}

.empty-cart {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--secondary-color);
    text-align: center;
}

.empty-cart i {
    font-size: 48px;
    margin-bottom: 10px;
}

.cart-item {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid var(--light-gray);
}

.cart-item:last-child {
    border-bottom: none;
}

.item-info h4 {
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--dark-gray);
}

.item-price {
    font-size: 12px;
    color: var(--secondary-color);
}

.item-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-quantity {
    width: 28px;
    height: 28px;
    border: 1px solid var(--light-gray);
    border-radius: 4px;
    background: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    transition: var(--transition);
}

.btn-quantity:hover {
    background: var(--light-gray);
}

.quantity {
    min-width: 30px;
    text-align: center;
    font-weight: bold;
}

.item-total {
    font-weight: bold;
    color: var(--success-color);
}

.btn-remove {
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 4px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-remove:hover {
    background: #c0392b;
}

/* Resumen del carrito */
.cart-summary {
    border-top: 2px solid var(--light-gray);
    padding-top: 15px;
    margin-bottom: 20px;
}

.summary-line {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}

.total-line {
    font-size: 18px;
    font-weight: bold;
    color: var(--dark-gray);
    border-top: 1px solid var(--light-gray);
    padding-top: 8px;
    margin-top: 10px;
}

/* Acciones del carrito */
.cart-actions {
    display: flex;
    gap: 10px;
}

.cart-actions .btn {
    flex: 1;
    justify-content: center;
}

/* Historial de ventas */
.sales-history {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.sales-history h3 {
    margin-bottom: 20px;
    color: var(--dark-gray);
    border-bottom: 2px solid var(--light-gray);
    padding-bottom: 10px;
}

/* Modal para detalles de venta */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 0;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--light-gray);
}

.modal-header h3 {
    margin: 0;
    color: var(--dark-gray);
}

.btn-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--secondary-color);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close:hover {
    color: var(--danger-color);
}

.modal-body {
    padding: 20px;
}

.sale-info {
    margin-bottom: 20px;
}

.sale-info p {
    margin-bottom: 8px;
}

.modal-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.modal-table th,
.modal-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid var(--light-gray);
}

.modal-table th {
    background: var(--light-gray);
    font-weight: bold;
}

.sale-totals {
    border-top: 2px solid var(--light-gray);
    padding-top: 15px;
}

.sale-totals p {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

/* Responsive para ventas */
@media (max-width: 768px) {
    .available-products-grid {
        grid-template-columns: 1fr;
    }

    .cart-item {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .item-controls {
        justify-content: center;
    }

    .cart-actions {
        flex-direction: column;
    }
}

/* ========================================
   ESTILOS DE ESTADÍSTICAS
======================================== */

/* Resumen de estadísticas */
.stats-summary {
    margin-bottom: 30px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.stat-icon {
    width: 60px;
    height: 60px;
    min-width: 60px;
    min-height: 60px;
    max-width: 60px;
    max-height: 60px;
    border-radius: 50%;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    flex-shrink: 0;
}

.stat-card:nth-child(1) .stat-icon {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
}

.stat-card:nth-child(2) .stat-icon {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

.stat-card:nth-child(3) .stat-icon {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.stat-card:nth-child(4) .stat-icon {
    background: linear-gradient(135deg, #f39c12, #e67e22);
}

.stat-info h3 {
    font-size: 28px;
    font-weight: bold;
    margin: 0 0 5px 0;
    color: var(--dark-gray);
}

.stat-info p {
    margin: 0;
    color: var(--secondary-color);
    font-size: 14px;
}

.main-content {
    grid-area: main;
    padding: 34px;
    overflow-y: auto;
    min-width: 0;
    background:
        radial-gradient(circle at top right, rgba(63, 167, 214, 0.10), transparent 24%),
        radial-gradient(circle at top left, rgba(46, 204, 113, 0.07), transparent 18%),
        linear-gradient(180deg, #f4f8fb 0%, #edf4f8 100%);
}

.overview-section {
    gap: 24px;
}

.overview-section.active {
    display: grid !important;
}

.overview-bootstrap {
    display: grid;
    gap: 0;
}

.overview-summary-banner {
    border-radius: 24px;
    background: linear-gradient(135deg, rgba(255,255,255,0.94), rgba(243,248,252,0.98));
    box-shadow: 0 22px 46px rgba(48, 78, 98, 0.08);
    border: 1px solid rgba(74, 116, 143, 0.10);
}

.overview-bootstrap-badge {
    letter-spacing: 0.04em;
}

.overview-summary-meta {
    justify-content: flex-end;
}

.overview-mini-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 999px;
    background: #ffffff;
    border: 1px solid rgba(64, 126, 162, 0.14);
    color: #29485e;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 8px 18px rgba(48, 78, 98, 0.05);
}

.overview-mini-badge i {
    color: var(--primary-color);
}

.dashboard-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 10px;
    padding: 22px 26px;
    border-radius: 24px;
    background:
        linear-gradient(135deg, rgba(255,255,255,0.92), rgba(244,250,255,0.95)),
        radial-gradient(circle at top left, rgba(52, 152, 219, 0.18), transparent 36%);
    border: 1px solid rgba(92, 145, 176, 0.16);
    box-shadow: 0 28px 60px rgba(48, 78, 98, 0.10);
    backdrop-filter: blur(10px);
}

.dashboard-topbar-label,
.section-kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--primary-color);
}

.dashboard-topbar h1 {
    margin: 0;
    font-size: clamp(1.8rem, 3vw, 2.4rem);
    color: #203447;
    letter-spacing: -0.03em;
}

.dashboard-topbar-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.topbar-badge,
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(52, 152, 219, 0.16);
    color: #264257;
    font-size: 14px;
    font-weight: 600;
}

.topbar-badge i,
.status-pill i {
    color: var(--primary-color);
}

.topbar-badge-live {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.12), rgba(39, 174, 96, 0.12));
}

.overview-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.8fr) minmax(260px, 0.9fr);
    gap: 24px;
    align-items: stretch;
    margin-bottom: 24px;
    padding: 30px;
    border-radius: 28px;
    color: var(--white);
    background:
        radial-gradient(circle at top right, rgba(255,255,255,0.20), transparent 24%),
        radial-gradient(circle at bottom left, rgba(255,255,255,0.10), transparent 20%),
        linear-gradient(140deg, #173047 0%, #244962 45%, #2f6f95 72%, #57bbca 100%);
    box-shadow: 0 28px 70px rgba(22, 46, 66, 0.24);
    position: relative;
    overflow: hidden;
}

.overview-hero-card {
    border-radius: 32px;
    background:
        radial-gradient(circle at top right, rgba(255,255,255,0.18), transparent 24%),
        radial-gradient(circle at bottom left, rgba(255,255,255,0.10), transparent 18%),
        linear-gradient(140deg, #173047 0%, #244962 45%, #2f6f95 72%, #57bbca 100%);
}

.overview-hero-kicker {
    color: #204259 !important;
    letter-spacing: 0.04em;
}

.overview-hero-lead {
    color: rgba(255,255,255,0.78);
    max-width: 40rem;
}

.overview-hero-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    color: #ffffff !important;
    background: rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.12);
}

.overview-hero-actions-grid {
    display: grid;
    gap: 16px;
}

.overview-cta-main,
.overview-cta-secondary {
    border-radius: 24px;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 76px;
    box-shadow: none !important;
}

.overview-cta-main {
    color: #173047 !important;
    background: linear-gradient(135deg, #ffffff, #e9f7fd) !important;
    border: none !important;
}

.overview-cta-main:hover {
    transform: translateY(-2px);
    background: linear-gradient(135deg, #ffffff, #f3fbff) !important;
}

.overview-cta-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: linear-gradient(135deg, #173047, #2f6f95);
    color: #ffffff;
    flex-shrink: 0;
}

.overview-cta-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    text-align: left;
}

.overview-cta-copy small {
    color: #617687;
    font-size: 13px;
}

.overview-cta-arrow {
    margin-left: auto;
    color: #2d5c78;
}

.overview-cta-secondary {
    color: #ffffff !important;
    background: rgba(255,255,255,0.08) !important;
    border: 1px solid rgba(255,255,255,0.14) !important;
}

.overview-cta-secondary:hover {
    transform: translateY(-2px);
    background: rgba(255,255,255,0.14) !important;
}

.overview-cta-secondary i {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: rgba(255,255,255,0.12);
    flex-shrink: 0;
}

.overview-cta-secondary span {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.overview-cta-secondary small {
    color: rgba(255,255,255,0.74);
}

.overview-hero::after {
    content: '';
    position: absolute;
    inset: auto -90px -110px auto;
    width: 240px;
    height: 240px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.18), transparent 70%);
    pointer-events: none;
}

.overview-hero-copy h1 {
    margin: 0 0 12px;
    font-size: clamp(2rem, 3vw, 3rem);
    line-height: 1.08;
    letter-spacing: -0.04em;
}

.overview-hero-copy p {
    max-width: 680px;
    margin: 0;
    font-size: 16px;
    color: rgba(255,255,255,0.82);
}

.overview-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 18px 0 0;
}

.overview-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.14);
    color: rgba(255,255,255,0.92);
    font-size: 13px;
    font-weight: 600;
}

.overview-status-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 22px;
}

.overview-hero .status-pill {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.16);
    color: var(--white);
}

.overview-hero .status-pill i {
    color: #9dd5f0;
}

.overview-hero-actions {
    display: grid;
    gap: 12px;
    align-content: center;
    position: relative;
    z-index: 1;
    padding: 18px;
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.05));
    border: 1px solid rgba(255,255,255,0.12);
    backdrop-filter: blur(8px);
}

.overview-primary-action,
.overview-secondary-action,
.overview-refresh-action {
    border: none;
    cursor: pointer;
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease, background 0.22s ease;
    font: inherit;
}

.overview-primary-action {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 14px;
    align-items: center;
    width: 100%;
    min-height: 78px;
    padding: 16px 18px;
    border-radius: 22px;
    color: #173047;
    background: linear-gradient(135deg, #ffffff, #e9f6fb);
    box-shadow: 0 18px 35px rgba(16, 35, 49, 0.16);
}

.overview-primary-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 22px 40px rgba(16, 35, 49, 0.20);
}

.overview-primary-action-icon,
.overview-secondary-action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 16px;
    flex-shrink: 0;
}

.overview-primary-action-icon {
    background: linear-gradient(135deg, #173047, #2f6f95);
    color: #ffffff;
}

.overview-primary-action-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    text-align: left;
}

.overview-primary-action-copy strong,
.overview-secondary-action strong {
    font-size: 16px;
    line-height: 1.2;
}

.overview-primary-action-copy small,
.overview-secondary-action small {
    color: #5c7384;
    font-size: 13px;
    line-height: 1.45;
}

.overview-primary-action-arrow,
.quick-action-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    color: #244962;
    background: rgba(36, 73, 98, 0.08);
}

.overview-secondary-action {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 14px;
    align-items: center;
    width: 100%;
    min-height: 70px;
    padding: 15px 16px;
    border-radius: 18px;
    text-align: left;
    color: #ffffff;
    background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.06));
    border: 1px solid rgba(255,255,255,0.12);
}

.overview-secondary-action:hover {
    transform: translateY(-2px);
    background: linear-gradient(180deg, rgba(255,255,255,0.18), rgba(255,255,255,0.08));
}

.overview-secondary-action-icon {
    background: rgba(255,255,255,0.14);
    color: #ffffff;
}

.overview-secondary-action span:last-child {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.overview-secondary-action small {
    color: rgba(255,255,255,0.72);
}

.overview-refresh-action {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 10px 16px;
    border-radius: 999px;
    color: #22445b;
    background: rgba(255,255,255,0.72);
    border: 1px solid rgba(64, 126, 162, 0.16);
    box-shadow: 0 10px 24px rgba(48, 78, 98, 0.08);
}

.overview-refresh-action:hover {
    transform: translateY(-1px);
    background: #ffffff;
    box-shadow: 0 14px 28px rgba(48, 78, 98, 0.12);
}

.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

.quick-action-card {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    padding: 18px 20px;
    border: 1px solid rgba(52, 152, 219, 0.14);
    border-radius: 22px;
    background: linear-gradient(180deg, #ffffff, #f8fbfd);
    box-shadow: 0 16px 40px rgba(52, 73, 94, 0.08);
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    text-align: left;
    position: relative;
    overflow: hidden;
}

.quick-action-card:hover {
    transform: translateY(-3px);
    border-color: rgba(52, 152, 219, 0.28);
    box-shadow: 0 20px 45px rgba(52, 73, 94, 0.12);
}

.quick-action-card:focus-visible {
    outline: 3px solid rgba(52, 152, 219, 0.24);
    outline-offset: 2px;
}

.quick-action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.18), rgba(46, 204, 113, 0.14));
    color: #22577a;
    font-size: 18px;
    flex-shrink: 0;
}

.quick-action-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.quick-action-content strong {
    color: #1f3344;
    font-size: 16px;
}

.quick-action-content small {
    color: #627587;
    font-size: 13px;
}

.quick-action-arrow {
    margin-left: auto;
}

.quick-action-card-products {
    background: linear-gradient(180deg, #ffffff, #eef8fd);
}

.quick-action-card-alerts {
    background: linear-gradient(180deg, #ffffff, #fff6ed);
}

.quick-action-card-alerts .quick-action-icon {
    background: linear-gradient(135deg, rgba(243, 156, 18, 0.22), rgba(231, 76, 60, 0.12));
    color: #9a4d11;
}

.quick-action-card-stats {
    background: linear-gradient(180deg, #ffffff, #eef6f3);
}

.quick-action-card-stats .quick-action-icon {
    background: linear-gradient(135deg, rgba(39, 174, 96, 0.18), rgba(52, 152, 219, 0.14));
    color: #1f6b57;
}

.overview-link-card {
    border-radius: 24px;
    transition: transform 0.22s ease, box-shadow 0.22s ease;
    overflow: hidden;
}

.overview-link-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 22px 40px rgba(48, 78, 98, 0.10) !important;
}

.overview-link-card .card-body {
    min-height: 118px;
}

.overview-link-card-products {
    background: linear-gradient(180deg, #ffffff, #eef8fd);
}

.overview-link-card-alerts {
    background: linear-gradient(180deg, #ffffff, #fff7ef);
}

.overview-link-card-stats {
    background: linear-gradient(180deg, #ffffff, #eef7f2);
}

.overview-link-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.18), rgba(46, 204, 113, 0.14));
    color: #255a79;
    font-size: 18px;
    flex-shrink: 0;
}

.overview-link-card-alerts .overview-link-icon {
    background: linear-gradient(135deg, rgba(243, 156, 18, 0.22), rgba(231, 76, 60, 0.12));
    color: #9b4b0d;
}

.overview-link-card-stats .overview-link-icon {
    background: linear-gradient(135deg, rgba(39, 174, 96, 0.20), rgba(52, 152, 219, 0.14));
    color: #1f6b57;
}

.overview-link-copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.overview-link-copy strong {
    color: #1f3445;
    font-size: 16px;
}

.overview-link-copy small {
    color: #667b8d;
    font-size: 13px;
}

.overview-link-arrow {
    margin-left: auto;
    color: #436176;
}

.overview-refresh-btn {
    min-height: 44px;
    border-color: rgba(64, 126, 162, 0.18);
    background: rgba(255,255,255,0.78);
    color: #24465d;
    box-shadow: 0 12px 26px rgba(48, 78, 98, 0.06);
}

.overview-refresh-btn:hover {
    background: #ffffff;
    color: #1c3d53;
}

.overview-kpi-card {
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(247,251,253,0.96));
    border: 1px solid rgba(74, 116, 143, 0.10);
}

.overview-kpi-warning {
    background: linear-gradient(180deg, #fffdf8, #fff7eb);
}

.overview-kpi-success {
    background: linear-gradient(180deg, #fbfffd, #eef8f1);
}

.overview-kpi-info {
    background: linear-gradient(180deg, #fbfcff, #eff5fb);
}

.overview-kpi-label {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(36, 73, 98, 0.06);
    color: #36556b;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.overview-kpi-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.16), rgba(46, 204, 113, 0.14));
    color: #255a79;
}

.overview-kpi-warning .overview-kpi-icon {
    background: linear-gradient(135deg, rgba(243, 156, 18, 0.18), rgba(231, 76, 60, 0.12));
    color: #9b4b0d;
}

.overview-kpi-success .overview-kpi-icon {
    background: linear-gradient(135deg, rgba(39, 174, 96, 0.18), rgba(46, 204, 113, 0.12));
    color: #1f6b57;
}

.overview-table-card {
    border-radius: 24px;
    overflow: hidden;
}

.overview-table-header {
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(247,251,253,0.96));
}

.overview-bootstrap-table thead th {
    background: linear-gradient(135deg, #223b50, #2f5976);
    color: #ffffff;
    border-bottom: none;
    padding-top: 15px;
    padding-bottom: 15px;
    font-weight: 600;
}

.overview-bootstrap-table tbody tr:nth-child(even) {
    background: rgba(47, 89, 118, 0.025);
}

.compact-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.compact-header h2 {
    margin: 0 0 6px;
    color: #1f3344;
}

.compact-header p {
    margin: 0;
}

.overview-stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 18px;
    margin-bottom: 8px;
}

.overview-stat-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
    padding: 22px;
    border: 1px solid rgba(64, 126, 162, 0.12);
    border-radius: 22px;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.98), rgba(247,251,253,0.96));
    box-shadow: 0 20px 42px rgba(48, 78, 98, 0.08);
}

.overview-stat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.overview-stat-label {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(36, 73, 98, 0.06);
    color: #32536b;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.overview-stat-card .stat-icon {
    width: 54px;
    height: 54px;
    min-width: 54px;
    min-height: 54px;
    max-width: 54px;
    max-height: 54px;
    border-radius: 18px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.28);
}

.overview-stat-card .stat-info h3 {
    margin: 0 0 6px;
    font-size: clamp(2rem, 3vw, 2.4rem);
    line-height: 1;
    letter-spacing: -0.05em;
}

.overview-stat-card .stat-info p {
    margin: 0;
    font-size: 15px;
    color: #355067;
}

.stat-caption {
    display: block;
    margin-top: 8px;
    color: #7a8f9f;
    font-size: 13px;
    line-height: 1.5;
}

.panel-shell {
    padding: 24px;
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(247,251,253,0.96));
    border: 1px solid rgba(64, 126, 162, 0.10);
    box-shadow: 0 20px 50px rgba(48, 78, 98, 0.08);
}

.panel-shell-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.panel-shell-header h2 {
    margin: 0 0 6px;
    color: #1f3344;
}

.panel-shell-header p {
    margin: 0;
    color: #6f8292;
}

.panel-shell .table-container {
    margin-bottom: 0;
    box-shadow: none;
    border: 1px solid rgba(52, 152, 219, 0.10);
    border-radius: 18px;
    overflow: hidden;
}

.overview-table-panel thead {
    background: linear-gradient(135deg, #223b50, #2f5976);
}

.overview-table-panel tbody tr:nth-child(even) {
    background: rgba(47, 89, 118, 0.025);
}

.overview-empty-row td {
    border-bottom: none;
}

.overview-empty-cell {
    display: table-cell;
    padding: 30px 18px;
    text-align: center;
    color: #71889b;
    font-weight: 600;
}

.overview-empty-cell i {
    display: block;
    margin-bottom: 10px;
    font-size: 22px;
    color: #9ab4c6;
}

@media (max-width: 960px) {
    .dashboard-topbar,
    .compact-header,
    .panel-shell-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .dashboard-topbar-meta {
        justify-content: flex-start;
    }

    .overview-hero {
        grid-template-columns: 1fr;
    }

    .overview-hero-actions {
        grid-template-columns: 1fr;
        width: 100%;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 76px 12px 18px 12px !important;
    }

    .dashboard-topbar {
        padding: 18px;
        margin-bottom: 22px;
    }

    .overview-hero {
        padding: 22px;
        border-radius: 20px;
    }

    .overview-hero-copy h1 {
        font-size: 1.9rem;
    }

    .quick-actions-grid {
        grid-template-columns: 1fr;
    }

    .panel-shell {
        padding: 18px;
    }

    .overview-chip-row,
    .overview-status-row {
        gap: 8px;
    }
}

/* Filtros de gráficos */
.chart-filters {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label {
    font-weight: bold;
    color: var(--dark-gray);
    font-size: 14px;
}

.filter-group select {
    padding: 8px 12px;
    border: 1px solid var(--light-gray);
    border-radius: var(--border-radius);
    background: var(--white);
    font-size: 14px;
    min-width: 120px;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* Contenedores de gráficos */
.charts-container {
    margin-bottom: 30px;
}

.chart-card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--light-gray);
}

.chart-header h3 {
    margin: 0;
    color: var(--dark-gray);
    font-size: 18px;
}

.chart-controls {
    display: flex;
    gap: 5px;
}

.chart-controls .btn {
    padding: 5px 10px;
    font-size: 12px;
    border: 1px solid var(--light-gray);
    background: var(--white);
    color: var(--dark-gray);
}

.chart-controls .btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Tabla de productos más vendidos */
.top-products-table {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.top-products-table h3 {
    margin-bottom: 20px;
    color: var(--dark-gray);
    border-bottom: 2px solid var(--light-gray);
    padding-bottom: 10px;
}

.rank-badge {
    background: var(--primary-color);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

.rank-badge.rank-1 {
    background: linear-gradient(135deg, #f1c40f, #f39c12);
}

.rank-badge.rank-2 {
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
}

.rank-badge.rank-3 {
    background: linear-gradient(135deg, #cd7f32, #b8860b);
}

/* Responsive para estadísticas */
@media (max-width: 768px) {
    .chart-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .charts-container {
        margin-bottom: 20px;
    }

    .chart-container {
        height: 250px;
    }

    .chart-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .chart-controls {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .stat-card {
        flex-direction: column;
        text-align: center;
    }

    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    .stat-info h3 {
        font-size: 24px;
    }

    .chart-container {
        height: 200px;
    }
}

/* ========================================
   ESTILOS DE CONFIGURACIÓN
======================================== */

/* Configuración rápida */
.quick-settings {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.setting-card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

.setting-icon {
    width: 50px;
    height: 50px;
    min-width: 50px;
    min-height: 50px;
    max-width: 50px;
    max-height: 50px;
    border-radius: 50%;
    aspect-ratio: 1 / 1;
    background: linear-gradient(135deg, var(--primary-color), #2980b9);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    flex-shrink: 0;
}

.setting-info {
    flex: 1;
}

.setting-info h3 {
    margin: 0 0 5px 0;
    color: var(--dark-gray);
    font-size: 16px;
}

.setting-info p {
    margin: 0 0 15px 0;
    color: var(--secondary-color);
    font-size: 14px;
}

/* Toggle de tema */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
}

.theme-switch {
    position: relative;
    width: 50px;
    height: 24px;
    appearance: none;
    background: #ccc;
    border-radius: 24px;
    outline: none;
    cursor: pointer;
    transition: var(--transition);
}

.theme-switch:checked {
    background: var(--primary-color);
}

.theme-switch::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    transition: var(--transition);
}

.theme-switch:checked::before {
    transform: translateX(26px);
}

.theme-text {
    font-size: 14px;
    color: var(--dark-gray);
}

/* Configuración de notificaciones */
.notification-settings {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--dark-gray);
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
}

/* Tabs de configuración */
.settings-tabs {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.tab-buttons {
    display: flex;
    background: var(--light-gray);
    border-bottom: 1px solid #ddd;
}

.tab-button {
    flex: 1;
    padding: 15px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    color: var(--secondary-color);
    transition: var(--transition);
}

.tab-button:hover {
    background: rgba(52, 152, 219, 0.1);
    color: var(--primary-color);
}

.tab-button.active {
    background: var(--white);
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
}

.tab-content {
    display: none;
    padding: 30px;
}

.tab-content.active {
    display: block;
}

/* Formularios de configuración */
.settings-form h3 {
    margin-bottom: 20px;
    color: var(--dark-gray);
    border-bottom: 2px solid var(--light-gray);
    padding-bottom: 10px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-weight: bold;
    color: var(--dark-gray);
    font-size: 14px;
}

.form-group input {
    padding: 10px;
    border: 1px solid var(--light-gray);
    border-radius: var(--border-radius);
    font-size: 14px;
    background: var(--white);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.form-group input[readonly] {
    background: var(--light-gray);
    color: var(--secondary-color);
}

.form-actions {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
}

/* Medidor de fuerza de contraseña */
.password-strength {
    margin-top: 10px;
}

.strength-bar {
    width: 100%;
    height: 6px;
    background: #eee;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 5px;
}

.strength-fill {
    height: 100%;
    width: 0%;
    transition: width 0.3s ease, background-color 0.3s ease;
    border-radius: 3px;
}

.strength-fill.weak {
    background: #e74c3c;
}

.strength-fill.medium {
    background: #f39c12;
}

.strength-fill.good {
    background: #f1c40f;
}

.strength-fill.strong {
    background: #27ae60;
}

#strength-text {
    font-size: 12px;
    color: var(--secondary-color);
}

/* Información del sistema */
.system-info h3 {
    margin-bottom: 20px;
    color: var(--dark-gray);
    border-bottom: 2px solid var(--light-gray);
    padding-bottom: 10px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    background: var(--light-gray);
    border-radius: var(--border-radius);
}

.info-label {
    font-weight: bold;
    color: var(--dark-gray);
}

.info-value {
    color: var(--secondary-color);
    font-family: monospace;
}

.system-actions {
    display: flex;
    justify-content: center;
}

/* Sección de backup */
.backup-section h3 {
    margin-bottom: 15px;
    color: var(--dark-gray);
    border-bottom: 2px solid var(--light-gray);
    padding-bottom: 10px;
}

.backup-section p {
    margin-bottom: 20px;
    color: var(--secondary-color);
}

.backup-info {
    margin-bottom: 20px;
}

.backup-warning {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: var(--border-radius);
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #856404;
}

.backup-warning i {
    color: #f39c12;
    font-size: 18px;
}

.backup-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
}

.backup-status {
    background: var(--light-gray);
    border-radius: var(--border-radius);
    padding: 20px;
}

.status-message {
    text-align: center;
    margin-bottom: 10px;
    font-weight: bold;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #eee;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
}

/* ========================================
   TEMA OSCURO
======================================== */

.dark-theme {
    --white: #2c3e50;
    --light-gray: #34495e;
    --dark-gray: #ecf0f1;
    --secondary-color: #bdc3c7;
    --primary-color: #3498db;
    --success-color: #2ecc71;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --border-radius: 8px;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    --transition: all 0.3s ease;
}

.dark-theme body {
    background: #1a252f;
    color: #ecf0f1;
}

.dark-theme .sidebar {
    background: #2c3e50;
    border-right: 1px solid #34495e;
}

.dark-theme .main-content {
    background: #1a252f;
}

.dark-theme .content-section {
    background: #2c3e50;
}

.dark-theme .form-group input {
    background: #34495e;
    border-color: #4a5f7a;
    color: #ecf0f1;
}

.dark-theme .form-group input:focus {
    border-color: var(--primary-color);
}

.dark-theme .form-group input[readonly] {
    background: #4a5f7a;
    color: #95a5a6;
}

.dark-theme .info-item {
    background: #34495e;
}

.dark-theme .backup-warning {
    background: #3d3d1f;
    border-color: #6c5d1f;
    color: #f1c40f;
}

.dark-theme .tab-buttons {
    background: #34495e;
    border-bottom-color: #4a5f7a;
}

.dark-theme .tab-button {
    color: #95a5a6;
}

.dark-theme .tab-button.active {
    background: #2c3e50;
    color: var(--primary-color);
}

/* Responsive para configuración */
@media (max-width: 768px) {
    .quick-settings {
        grid-template-columns: 1fr;
    }

    .tab-buttons {
        flex-wrap: wrap;
    }

    .tab-button {
        flex: 1 0 50%;
        min-width: 120px;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .backup-actions {
        flex-direction: column;
        align-items: center;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .setting-card {
        flex-direction: column;
        text-align: center;
    }

    .tab-content {
        padding: 20px 15px;
    }

    .tab-button {
        flex: 1 0 100%;
        font-size: 12px;
        padding: 12px 15px;
    }
}

/* ========================================
   MEJORAS PARA EL SISTEMA DE VENTAS
======================================== */

/* Buscador mejorado */
.search-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.search-input-group {
    position: relative;
    flex: 1;
    min-width: 250px;
}

.search-input-group i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #95a5a6;
    font-size: 14px;
}

.search-input-group input {
    width: 100%;
    padding: 12px 12px 12px 40px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: var(--transition);
}

.search-input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.filter-select {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 14px;
    background: white;
    min-width: 150px;
}

/* Grid de productos mejorado con imágenes */
.available-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    max-height: 500px;
    overflow-y: auto;
    padding: 10px 0;
}

.product-card {
    background: white;
    border: 1px solid #e1e8ed;
    border-radius: var(--border-radius);
    padding: 15px;
    transition: var(--transition);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--primary-color);
}

.product-image {
    width: 100%;
    height: 120px;
    background: #f8f9fa;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 8px;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.product-image.no-image {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: #6c757d;
    font-size: 14px;
    text-align: center;
}

.product-info h4 {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 4px;
    line-height: 1.3;
}

.product-info .category {
    font-size: 12px;
    color: #7f8c8d;
    margin-bottom: 8px;
}

.product-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.product-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-color);
}

.product-stock {
    font-size: 12px;
    color: #7f8c8d;
    text-align: right;
}

.stock-high { color: var(--success-color); }
.stock-low { color: var(--warning-color); }
.stock-critical { color: var(--danger-color); }

/* Opciones de venta */
.sale-options {
    background: #f8f9fa;
    padding: 15px;
    border-radius: var(--border-radius);
    margin-bottom: 15px;
    border: 1px solid #e9ecef;
}

.checkbox-option {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    cursor: pointer;
    font-size: 14px;
}

.checkbox-option:last-child {
    margin-bottom: 0;
}

.checkbox-option input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.checkmark {
    position: relative;
    height: 18px;
    width: 18px;
    background-color: white;
    border: 2px solid #ddd;
    border-radius: 3px;
    transition: var(--transition);
}

.checkbox-option:hover .checkmark {
    border-color: var(--primary-color);
}

.checkbox-option input:checked ~ .checkmark {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-option input:checked ~ .checkmark:after {
    display: block;
}

.customer-info-note {
    display: block;
    font-size: 11px;
    color: #7f8c8d;
    margin-top: 5px;
    font-style: italic;
}

/* Buscador del historial de ventas */
.history-search {
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.search-row {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.date-input {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 14px;
    min-width: 150px;
}

.search-stats {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    font-size: 14px;
    color: #7f8c8d;
    padding-top: 10px;
    border-top: 1px solid #e9ecef;
}

.search-stats span {
    font-weight: 500;
}

/* Responsive mejoras */
@media (max-width: 768px) {
    .search-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .search-input-group {
        min-width: auto;
    }

    .available-products-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }

    .search-row {
        flex-direction: column;
        align-items: stretch;
    }

    .date-input {
        min-width: auto;
    }

    .search-stats {
        flex-direction: column;
        gap: 10px;
    }
}

/* =======================================================================
   Estilos para Modal de Imagen de Producto
   ======================================================================= */

/* Modal para mostrar imagen del producto */
.product-image-modal-content {
    max-width: 600px;
    width: 90%;
}

.product-image-container {
    text-align: center;
    margin-bottom: 20px;
    min-height: 300px;
    position: relative;
    background: #f8f9fa;
    border-radius: var(--border-radius);
    border: 2px dashed #dee2e6;
}

.product-image-container img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: calc(100% - 20px);
    max-height: calc(100% - 20px);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.no-image-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    padding: 40px;
    width: 100%;
    text-align: center;
    z-index: 5;
    visibility: hidden;
}

.no-image-placeholder i {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.no-image-placeholder p {
    font-size: 16px;
    margin: 0;
}

.product-info {
    background: #f8f9fa;
    padding: 20px;
    border-radius: var(--border-radius);
    border-left: 4px solid var(--primary-color);
}

.product-info p {
    margin: 8px 0;
    font-size: 15px;
}

.product-info strong {
    color: var(--text-color);
    font-weight: 600;
}

/* Nombre de producto clicable */
.product-name-clickable {
    cursor: pointer;
    color: var(--primary-color);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 4px;
}

.product-name-clickable:hover {
    background: rgba(74, 144, 226, 0.1);
    transform: translateY(-1px);
}

.product-name-clickable i {
    transition: color 0.2s ease;
}

.product-name-clickable:hover i {
    color: var(--primary-color) !important;
}

/* =======================================================================
   Estilos para Subida de Imagen en Formulario
   ======================================================================= */

.image-upload-container {
    border: 2px dashed #dee2e6;
    border-radius: var(--border-radius);
    padding: 20px;
    text-align: center;
    background: #f8f9fa;
    transition: all 0.3s ease;
    position: relative;
}

.image-upload-container:hover {
    border-color: var(--primary-color);
    background: rgba(74, 144, 226, 0.05);
}

.file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.image-preview {
    margin-bottom: 15px;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.current-image {
    max-width: 150px;
    max-height: 120px;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 10px;
}

.remove-image {
    padding: 5px 10px;
    font-size: 12px;
}

.no-image {
    color: #6c757d;
    font-style: italic;
    margin: 0;
}

.upload-hint {
    color: #6c757d;
    pointer-events: none;
}

.product-thumb-button {
    width: 56px;
    height: 56px;
    padding: 0;
    border: 1px solid rgba(36, 59, 74, 0.12);
    border-radius: 12px;
    background: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
}

.product-thumb-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.product-thumb-placeholder {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: #eef3f7;
    color: #7b8b99;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.upload-hint i {
    font-size: 24px;
    margin-bottom: 8px;
    display: block;
    color: var(--primary-color);
}

.upload-hint p {
    margin: 0;
    font-size: 14px;
}

/* Tema oscuro para elementos de imagen */
.dark-theme .product-image-container,
.dark-theme .image-upload-container {
    background: #34495e;
    border-color: #4a5f7a;
}

.dark-theme .image-upload-container:hover {
    border-color: var(--primary-color);
    background: rgba(74, 144, 226, 0.1);
}

.dark-theme .product-info {
    background: #34495e;
    border-left-color: var(--primary-color);
}

.dark-theme .no-image-placeholder,
.dark-theme .upload-hint {
    color: #95a5a6;
}

.dark-theme .no-image {
    color: #95a5a6;
}

/* Responsive para modal de imagen */
@media (max-width: 768px) {
    .product-image-modal-content {
        width: 95%;
        max-width: none;
    }

    .product-image-container {
        min-height: 250px;
    }

    .product-image-container img {
        max-height: 300px;
    }

    .current-image {
        max-width: 120px;
        max-height: 100px;
    }
}

/* Estilos específicos para móviles muy pequeños */
@media screen and (max-width: 480px) {
    body {
        margin: 0 !important;
        padding: 0 !important;
        overflow-x: hidden !important;
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    * {
        box-sizing: border-box !important;
    }

    .main-content {
        padding: 60px 3px 3px 3px !important;
        width: 100% !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
        transform: none !important;
        left: 0 !important;
        position: relative !important;
    }

    .container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-sizing: border-box !important;
    }

    /* Forzar que todo el contenido interno esté alineado */
    .content-section,
    .section-header,
    .stats-grid,
    .available-products-grid,
    .table-container,
    .form-grid,
    .chart-container,
    .dashboard-container,
    h1, h2, h3, h4, h5, h6,
    p, div, table {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 3px !important;
        padding-right: 3px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        transform: none !important;
        left: 0 !important;
        position: relative !important;
    }

    /* Asegurar que las tablas no se desborden */
    .table-container {
        overflow-x: auto !important;
        overflow-y: visible !important;
        -webkit-overflow-scrolling: touch !important;
        width: 100% !important;
        position: relative !important;
        border-radius: 8px !important;
        touch-action: auto !important; /* Permitir scroll nativo */
        scroll-behavior: auto !important; /* Scroll nativo sin animaciones que puedan interferir */
    }

    /* Scrollbar más visible en móviles */
    .table-container::-webkit-scrollbar {
        height: 6px !important;
        background-color: rgba(0,0,0,0.1) !important;
        border-radius: 3px !important;
    }

    .table-container::-webkit-scrollbar-thumb {
        background-color: var(--primary-color) !important;
        border-radius: 3px !important;
    }

    /* Mejorar apariencia de tablas en móvil */
    table {
        border-collapse: collapse !important;
        font-size: 13px !important;
        line-height: 1.4 !important;
        min-width: 100% !important;
        width: max-content !important; /* Asegurar que la tabla se extienda según su contenido */
        white-space: nowrap !important;
    }

    th, td {
        padding: 8px 12px !important;
        white-space: nowrap !important;
        border: 1px solid var(--light-gray) !important;
        text-align: left !important;
        vertical-align: middle !important;
        min-width: 80px !important; /* Ancho mínimo para asegurar scroll */
    }

    th {
        background-color: var(--primary-color) !important;
        color: white !important;
        font-weight: 600 !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 5 !important;
    }

    /* Botones de acción en tablas más compactos para móvil */
    .action-buttons {
        display: flex !important;
        gap: 4px !important;
        flex-wrap: nowrap !important;
        min-width: 140px !important; /* Asegurar ancho mínimo para que se genere scroll */
    }

    .action-buttons .btn {
        padding: 6px 8px !important;
        font-size: 11px !important;
        min-width: auto !important;
        white-space: nowrap !important;
        border-radius: 4px !important;
    }

    table {
        min-width: 300px !important;
    }

    /* Ajustar grid de productos para móviles pequeños */
    .available-products-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
        padding: 3px !important;
    }

    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
        padding: 3px !important;
    }

    /* Indicador de scroll para tablas */
    @keyframes fadeInOut {
        0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
        20% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
        80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
        100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    }

    .scroll-hint {
        animation: fadeInOut 3s ease-in-out !important;
    }

    .scroll-hint-mobile {
        opacity: 1 !important;
        transition: opacity 0.5s ease !important;
    }
}

/* Estilos para botones de importar/exportar */
.import-export-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}

.import-btn {
    cursor: pointer;
    transition: all 0.3s ease;
}

.import-btn:hover {
    background-color: var(--secondary-color);
    transform: translateY(-2px);
}

#import-file {
    display: none;
}

/* Dropdown para exportar */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    cursor: pointer;
    transition: all 0.3s ease;
}

.dropdown-toggle:hover {
    background-color: var(--secondary-color);
    transform: translateY(-2px);
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: white;
    min-width: 160px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    border-radius: 8px;
    z-index: 1000;
    border: 1px solid #ddd;
    overflow: hidden;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 12px 16px;
    clear: both;
    font-weight: 400;
    color: #333;
    text-align: left;
    background-color: transparent;
    border: none;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.dropdown-item:hover {
    background-color: #f8f9fa;
    color: var(--primary-color);
}

.dropdown-item i {
    margin-right: 8px;
    width: 16px;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-secondary:hover {
    background-color: #5a6c7d;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.btn-secondary i {
    font-size: 14px;
}

/* Modal para progreso de importación */
.import-progress-modal {
    display: none;
    position: fixed;
    z-index: 1200;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.import-progress-content {
    background-color: white;
    margin: 15% auto;
    padding: 30px;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background-color: var(--light-gray);
    border-radius: 10px;
    margin: 20px 0;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 10px;
}

.import-status {
    margin: 15px 0;
    font-size: 14px;
    color: var(--text-muted);
}

.import-results {
    margin-top: 20px;
    padding: 15px;
    background-color: var(--light-gray);
    border-radius: var(--border-radius);
    text-align: left;
}

.import-results h4 {
    margin: 0 0 10px 0;
    color: var(--primary-color);
}

.import-results ul {
    margin: 0;
    padding-left: 20px;
}

.import-results li {
    margin: 5px 0;
    font-size: 13px;
}

.success-text {
    color: #28a745;
}

.error-text {
    color: #dc3545;
}

.warning-text {
    color: #ffc107;
}

/* Responsive para móviles */
@media (max-width: 768px) {
    .import-export-buttons {
        flex-direction: column;
        gap: 8px;
        margin-top: 10px;
    }

    .section-actions {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .import-progress-content {
        margin: 10% auto;
        padding: 20px;
        width: 95%;
    }
}

@media (max-width: 480px) {
    .import-export-buttons {
        width: 100%;
    }

    .btn-secondary {
        justify-content: center;
        width: 100%;
        padding: 12px;
    }
}

/* Estilos específicos para modal en pantallas muy pequeñas */
@media screen and (max-width: 480px), screen and (max-height: 600px) {
    .modal {
        z-index: 1200 !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        margin: 0 !important;
        padding: 0 !important;
        background-color: rgba(0,0,0,0.8) !important;
    }

    .modal-content {
        position: relative !important;
        width: 100vw !important;
        height: 100vh !important;
        max-width: none !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 0 !important;
        background-color: var(--white) !important;
        overflow-y: auto !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .modal-header {
        flex-shrink: 0 !important;
        padding: 15px 20px !important;
        background: var(--primary-color) !important;
        border-radius: 0 !important;
    }

    .modal-header h2, .modal-header h3 {
        font-size: 16px !important;
        margin: 0 !important;
        color: white !important;
    }

    .modal-body {
        flex: 1 !important;
        padding: 15px !important;
        overflow-y: auto !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
    }

    .product-image-container {
        flex-shrink: 0 !important;
        text-align: center !important;
        position: relative !important;
        min-height: 250px !important;
        margin-bottom: 15px !important;
    }

    .product-image-container img {
        position: absolute !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: auto !important;
        height: auto !important;
        max-width: calc(100% - 20px) !important;
        max-height: calc(100% - 20px) !important;
        object-fit: contain !important;
        border-radius: 8px !important;
        z-index: 10 !important;
    }

    .no-image-placeholder {
        position: absolute !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        display: none !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        width: 100% !important;
        height: 100% !important;
        color: var(--text-muted) !important;
        padding: 20px !important;
        text-align: center !important;
        z-index: 5 !important;
        visibility: hidden !important;
    }

    .no-image-placeholder i {
        font-size: 48px !important;
        margin-bottom: 10px !important;
    }

    .product-info {
        flex-shrink: 0 !important;
        background: var(--light-gray) !important;
        padding: 15px !important;
        border-radius: 8px !important;
    }

    .product-info p {
        margin: 8px 0 !important;
        font-size: 14px !important;
        line-height: 1.4 !important;
    }

    .close {
        font-size: 24px !important;
    }
}

/* ========================================
   REFUERZO PARA ICONOS CIRCULARES EN MÓVILES
======================================== */
@media (max-width: 768px) {
    /* Reforzar que los iconos mantengan su forma circular */
    .stat-icon {
        width: 50px !important;
        height: 50px !important;
        min-width: 50px !important;
        min-height: 50px !important;
        max-width: 50px !important;
        max-height: 50px !important;
        border-radius: 50% !important;
        aspect-ratio: 1 / 1 !important;
        flex-shrink: 0 !important;
        font-size: 20px !important;
    }

    .setting-icon {
        width: 45px !important;
        height: 45px !important;
        min-width: 45px !important;
        min-height: 45px !important;
        max-width: 45px !important;
        max-height: 45px !important;
        border-radius: 50% !important;
        aspect-ratio: 1 / 1 !important;
        flex-shrink: 0 !important;
        font-size: 18px !important;
    }

    /* Badge de alertas circular */
    .alert-badge {
        width: 18px !important;
        height: 18px !important;
        min-width: 18px !important;
        min-height: 18px !important;
        max-width: 18px !important;
        max-height: 18px !important;
        border-radius: 50% !important;
        aspect-ratio: 1 / 1 !important;
        flex-shrink: 0 !important;
        font-size: 9px !important;
        font-weight: bold !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        line-height: 1 !important;
    }

    /* Asegurar que elementos circulares mantengan proporción */
    .theme-switch::before {
        width: 18px !important;
        height: 18px !important;
        border-radius: 50% !important;
        aspect-ratio: 1 / 1 !important;
    }
}

/* ========================================
   CATÁLOGO EXTERNO
======================================== */
.external-products-container {
    background: white;
    border-radius: var(--border-radius);
    padding: 25px;
    box-shadow: var(--shadow);
}

.external-filters {
    display: flex;
    gap: 20px;
    align-items: end;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.external-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.external-results-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 20px;
    background: #f8fbff;
    border: 1px solid #d9e8f6;
    border-radius: 8px;
    color: var(--secondary-color);
    font-size: 14px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label {
    font-weight: 600;
    color: var(--dark-gray);
    font-size: 14px;
}

.filter-group input,
.filter-group select {
    padding: 10px;
    border: 2px solid #e1e8ed;
    border-radius: 6px;
    font-size: 14px;
    transition: var(--transition);
    min-width: 200px;
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.loading-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--secondary-color);
}

.loading-state i {
    font-size: 48px;
    margin-bottom: 15px;
}

.loading-state p {
    font-size: 16px;
    margin: 0;
}

.external-sync-progress {
    max-width: 540px;
    margin: 20px auto 0;
    text-align: left;
}

.external-sync-progress-bar {
    width: 100%;
    height: 12px;
    border-radius: 999px;
    overflow: hidden;
    background: #e6eef5;
    box-shadow: inset 0 1px 2px rgba(36, 59, 74, 0.08);
}

.external-sync-progress-fill {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #2f6f95 0%, #49a4d8 100%);
    transition: width 0.35s ease;
}

.external-sync-progress-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--dark-gray);
}

.external-sync-progress-detail {
    display: block;
    margin-top: 6px;
    color: var(--secondary-color);
    line-height: 1.5;
}

.external-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.external-product-card {
    background: white;
    border: 2px solid #f8f9fa;
    border-radius: 12px;
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
}

.external-product-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.external-product-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: #f8f9fa;
}

.external-product-info {
    padding: 20px;
}

.external-product-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--dark-gray);
    margin-bottom: 10px;
    line-height: 1.4;
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.external-product-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.external-product-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.external-product-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #eef5fb;
    color: #3c5e7c;
    font-size: 12px;
    font-weight: 600;
}

.external-product-description {
    font-size: 14px;
    color: var(--secondary-color);
    line-height: 1.5;
    display: -webkit-box;
    line-clamp: 3;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 15px;
}

.external-product-actions {
    display: flex;
    gap: 10px;
}

.btn-import {
    background: var(--success-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    flex: 1;
}

.btn-import:hover {
    background: #229954;
    transform: translateY(-1px);
}

.btn-import:disabled,
.btn-view:disabled,
.pagination-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-view {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    flex: 1;
}

.btn-view:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 30px;
}

.pagination-btn {
    background: white;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-info {
    font-size: 14px;
    color: var(--secondary-color);
    font-weight: 600;
}

/* Responsive para catálogo externo */
@media (max-width: 768px) {
    .external-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .external-actions {
        width: 100%;
    }

    .external-actions > * {
        width: 100%;
    }

    .external-results-summary {
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-group input,
    .filter-group select {
        min-width: 100%;
    }

    .external-products-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .external-product-card {
        border-radius: 8px;
    }

    .external-product-info {
        padding: 15px;
    }

    .pagination-container {
        flex-direction: column;
        gap: 10px;
    }

    .pagination-btn {
        padding: 12px 24px;
        font-size: 16px;
    }
}

.content-section {
    width: 100%;
}

.section-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
}

.section-actions,
.external-filters,
.chart-filters,
.search-row,
.search-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.section-actions input,
.section-actions select,
.external-filters input,
.external-filters select,
.chart-filters select,
.search-row input,
.search-row select,
.search-filters input,
.search-filters select,
.customer-info input,
.form-group input,
.form-group textarea,
.form-group select,
.date-input {
    min-height: 44px;
    border-radius: 14px;
}

.table-container {
    background: rgba(255,255,255,0.98);
    border: 1px solid rgba(74, 116, 143, 0.10);
    border-radius: 22px;
    box-shadow: 0 16px 36px rgba(48, 78, 98, 0.06);
    overflow: auto;
}

.table-container table.table {
    --bs-table-bg: transparent;
    --bs-table-striped-bg: rgba(47, 89, 118, 0.03);
    margin-bottom: 0;
}

.table-container thead th {
    white-space: nowrap;
}

.products-panel,
.cart-panel,
.sales-history,
.chart-card,
.top-products-table,
.setting-card,
.settings-tabs,
.system-info,
.backup-section,
.external-products-container,
.recent-products {
    background: rgba(255,255,255,0.98);
    border: 1px solid rgba(74, 116, 143, 0.10);
    border-radius: 24px;
    box-shadow: 0 16px 36px rgba(48, 78, 98, 0.06);
}

.products-panel,
.cart-panel,
.sales-history,
.top-products-table,
.setting-card,
.system-info,
.backup-section,
.external-products-container {
    padding: 24px;
}

.chart-card {
    padding: 0;
    overflow: hidden;
}

.chart-card > * {
    padding: 24px;
}

.setting-card,
.stat-card,
.chart-card {
    height: 100%;
}

.sales-container.row,
.charts-container.row,
.quick-settings.row,
.stats-summary.row {
    --bs-gutter-x: 1.5rem;
    --bs-gutter-y: 1.5rem;
}

@media (max-width: 991.98px) {
    .main-content {
        padding-top: 24px !important;
    }

    .dashboard-topbar {
        margin-top: 8px;
    }
}

@media (max-width: 767.98px) {
    .main-content {
        padding: 20px 12px 24px !important;
    }

    .section-header,
    .section-actions,
    .external-filters,
    .chart-filters,
    .search-row,
    .search-filters {
        align-items: stretch;
    }

    .section-actions > *,
    .external-filters > *,
    .chart-filters > *,
    .search-row > *,
    .search-filters > * {
        width: 100%;
    }
}

/* ========================================
   DASHBOARD VISUAL TUNING
======================================== */

.dashboard-shell {
    background:
        radial-gradient(circle at top right, rgba(47, 111, 149, 0.10), transparent 22%),
        radial-gradient(circle at bottom left, rgba(45, 143, 111, 0.08), transparent 18%),
        linear-gradient(180deg, #f5f8fb 0%, #edf3f7 100%);
}

.dashboard-mobilebar,
.sidebar.offcanvas-lg {
    background: linear-gradient(180deg, #1b3241 0%, #23465a 100%);
}

.sidebar-header,
.sidebar.offcanvas-lg .offcanvas-header {
    background: rgba(255,255,255,0.04);
}

.sidebar-menu .nav-link {
    border: 1px solid transparent;
}

.sidebar-menu .nav-link:hover,
.sidebar-menu .nav-link:focus {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.06);
}

.sidebar-menu li.active .nav-link {
    background: linear-gradient(135deg, #3b84b1, #2b688d);
    box-shadow: 0 12px 28px rgba(21, 73, 108, 0.26);
}

.dashboard-topbar,
.overview-summary-banner,
.overview-kpi-card,
.overview-table-card,
.products-panel,
.cart-panel,
.sales-history,
.chart-card,
.top-products-table,
.setting-card,
.settings-tabs,
.system-info,
.backup-section,
.external-products-container,
.table-container {
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,251,253,0.98));
    border-color: rgba(80, 117, 141, 0.10);
    box-shadow: 0 18px 42px rgba(36, 59, 74, 0.07);
}

.section-header h1,
.section-header h2,
.panel-shell-header h2,
.chart-header h3,
.sales-history h3,
.top-products-table h3,
.settings-form h3,
.system-info h3,
.backup-section h3 {
    color: #1f3342;
    letter-spacing: -0.02em;
}

.section-header p,
.panel-shell-header p,
.chart-header p,
.setting-info p,
.backup-section p,
.external-results-summary,
.search-stats,
.customer-info-note {
    color: #667b8d;
}

.overview-kpi-label,
.overview-stat-label,
.overview-bootstrap-badge,
.overview-hero-kicker,
.status-badge,
.alert-badge {
    letter-spacing: 0.06em;
}

.stat-card,
.overview-link-card,
.setting-card,
.chart-card,
.products-panel,
.cart-panel,
.sales-history,
.top-products-table,
.external-products-container {
    border-radius: 24px;
}

.overview-link-card:hover,
.stat-card:hover,
.chart-card:hover,
.setting-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 22px 44px rgba(36, 59, 74, 0.10);
}

.overview-kpi-icon,
.overview-link-icon,
.quick-action-icon,
.stat-icon {
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.30);
}

.stat-card:nth-child(1) .stat-icon {
    background: linear-gradient(135deg, #2f6f95, #3b84b1);
}

.stat-card:nth-child(2) .stat-icon {
    background: linear-gradient(135deg, #c9872f, #d8a14c);
}

.stat-card:nth-child(3) .stat-icon {
    background: linear-gradient(135deg, #2d8f6f, #41a684);
}

.stat-card:nth-child(4) .stat-icon {
    background: linear-gradient(135deg, #7f6cc6, #9987d8);
}

.tab-buttons {
    padding: 8px;
    border-radius: 20px;
    background: rgba(231, 238, 244, 0.72);
    gap: 8px;
}

.tab-button {
    border-radius: 14px;
    color: #526879;
    background: transparent;
    border: 1px solid transparent;
}

.tab-button:hover {
    color: #27485f;
    background: rgba(255,255,255,0.7);
}

.tab-button.active {
    color: #ffffff;
    background: linear-gradient(135deg, #2f6f95, #3b84b1);
    box-shadow: 0 10px 24px rgba(47, 111, 149, 0.22);
}

.search-input-group,
.history-search,
.chart-filters,
.external-filters,
.search-filters,
.cart-summary,
.backup-warning,
.system-actions,
.sale-options {
    border-radius: 18px;
    background: rgba(245, 248, 251, 0.92);
    border: 1px solid rgba(80, 117, 141, 0.09);
}

.search-input-group,
.history-search,
.chart-filters,
.external-filters,
.search-filters {
    padding: 14px;
}

.search-input-group input,
.search-input-group select,
.history-search input,
.chart-filters select,
.external-filters input,
.external-filters select,
.section-actions input,
.section-actions select,
.customer-info input,
.form-group input,
.form-group textarea,
.form-group select,
.date-input {
    background: #ffffff;
    border: 1px solid rgba(97, 122, 140, 0.18);
    color: #243b4a;
}

.search-input-group input:focus,
.history-search input:focus,
.chart-filters select:focus,
.external-filters input:focus,
.external-filters select:focus,
.section-actions input:focus,
.section-actions select:focus,
.customer-info input:focus,
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus,
.date-input:focus {
    border-color: rgba(47, 111, 149, 0.45);
    box-shadow: 0 0 0 0.2rem rgba(47, 111, 149, 0.12);
    outline: none;
}

.btn-primary,
.overview-refresh-btn,
#refresh-external,
#refresh-charts,
#process-sale,
#create-backup {
    background: linear-gradient(135deg, #2f6f95, #3b84b1);
    border-color: #2f6f95;
    color: #ffffff;
}

.btn-primary:hover,
.overview-refresh-btn:hover,
#refresh-external:hover,
#refresh-charts:hover,
#process-sale:hover,
#create-backup:hover {
    background: linear-gradient(135deg, #245a79, #2f6f95);
    border-color: #245a79;
}

.btn-secondary,
.btn-outline-secondary,
#clear-cart,
#clear-search,
#clear-sales-search {
    background: rgba(255,255,255,0.92);
    border-color: rgba(97, 122, 140, 0.16);
    color: #29485e;
}

.btn-secondary:hover,
.btn-outline-secondary:hover,
#clear-cart:hover,
#clear-search:hover,
#clear-sales-search:hover {
    background: #ffffff;
    color: #1f3c51;
}

.table-container thead,
.overview-bootstrap-table thead {
    background: linear-gradient(135deg, #213a4c, #2d5873);
}

.table-container thead th,
.overview-bootstrap-table thead th,
.table thead th {
    color: #ffffff;
    border-bottom: none;
}

.table tbody tr:hover {
    background: rgba(47, 111, 149, 0.045);
}

.external-results-summary,
.loading-state {
    border-radius: 18px;
    background: rgba(245, 248, 251, 0.94);
    border: 1px solid rgba(80, 117, 141, 0.10);
}

.loading-state i {
    color: var(--primary-color);
}

@media (max-width: 767.98px) {
    .dashboard-topbar,
    .overview-summary-banner,
    .products-panel,
    .cart-panel,
    .sales-history,
    .chart-card,
    .top-products-table,
    .setting-card,
    .settings-tabs,
    .system-info,
    .backup-section,
    .external-products-container,
    .table-container {
        border-radius: 18px;
    }
}

body {
    color: #243b4a;
    background: #eff4f8;
}

.product-form,
.modal-content,
.product-image-modal-content,
.import-progress-content {
    background: linear-gradient(180deg, rgba(255,255,255,0.99), rgba(248,251,253,0.98));
    border: 1px solid rgba(80, 117, 141, 0.10);
    box-shadow: 0 24px 48px rgba(36, 59, 74, 0.12);
}

.modal-header,
.modal-body,
.modal-content .modal-body {
    color: #243b4a;
}

.alert {
    border-radius: 18px;
    border-left-width: 5px;
    box-shadow: 0 12px 26px rgba(36, 59, 74, 0.08);
}

.alert-success {
    background: linear-gradient(180deg, rgba(45, 143, 111, 0.10), rgba(255,255,255,0.95));
    color: #276a54;
    border-left-color: #2d8f6f;
}

.alert-error {
    background: linear-gradient(180deg, rgba(198, 91, 82, 0.10), rgba(255,255,255,0.95));
    color: #8d453f;
    border-left-color: #c65b52;
}

.alert-warning {
    background: linear-gradient(180deg, rgba(201, 135, 47, 0.12), rgba(255,255,255,0.95));
    color: #8a632a;
    border-left-color: #c9872f;
}

.status-badge {
    padding: 6px 10px;
    border-radius: 999px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.status-badge.in-stock {
    background: rgba(45, 143, 111, 0.14);
    color: #246c54;
}

.status-badge.low-stock {
    background: rgba(201, 135, 47, 0.16);
    color: #8a632a;
}

.status-badge.out-of-stock {
    background: rgba(198, 91, 82, 0.14);
    color: #8d453f;
}

.product-card,
.external-product-card {
    background: linear-gradient(180deg, rgba(255,255,255,0.99), rgba(248,251,253,0.98));
    border-color: rgba(80, 117, 141, 0.12);
    border-radius: 20px;
    box-shadow: 0 14px 34px rgba(36, 59, 74, 0.06);
}

.product-card:hover,
.external-product-card:hover {
    border-color: rgba(47, 111, 149, 0.28);
    box-shadow: 0 20px 40px rgba(36, 59, 74, 0.10);
}

.product-card h4,
.external-product-title,
.product-name-clickable {
    color: #213746;
}

.product-description,
.external-product-info,
.external-product-meta,
.product-details {
    color: #697f90;
}

.external-product-price,
.product-price,
.summary-line.total-line span:last-child,
#cart-total {
    color: #245f81;
}

.external-product-image,
.product-image-container,
#modal-product-image {
    background: #f3f7fa;
}

.alert-badge {
    background: linear-gradient(135deg, #c65b52, #d77a72);
    box-shadow: 0 8px 18px rgba(198, 91, 82, 0.22);
}

.checkbox-option,
.checkbox-label {
    color: #365062;
}

.empty-cart,
.loading-state,
.no-image-placeholder {
    color: #6e8394;
}

/* ========================================
   ANTI-WHITE PASS
======================================== */

.dashboard-shell {
    background:
        radial-gradient(circle at top right, rgba(59, 132, 177, 0.16), transparent 20%),
        radial-gradient(circle at bottom left, rgba(45, 143, 111, 0.12), transparent 18%),
        linear-gradient(180deg, #eef4f8 0%, #e5edf3 100%);
}

.dashboard-topbar {
    background:
        linear-gradient(135deg, rgba(232, 241, 248, 0.96), rgba(221, 234, 243, 0.96)),
        radial-gradient(circle at top left, rgba(59, 132, 177, 0.16), transparent 32%);
    border-color: rgba(59, 102, 128, 0.14);
}

.overview-summary-banner {
    background: linear-gradient(135deg, #eef5fa, #ddebf4);
}

.overview-mini-badge {
    background: rgba(248, 251, 253, 0.92);
}

.overview-table-header,
.products-panel,
.cart-panel,
.sales-history,
.chart-card,
.top-products-table,
.setting-card,
.settings-tabs,
.system-info,
.backup-section,
.external-products-container,
.table-container,
.product-form,
.modal-content,
.product-image-modal-content,
.import-progress-content {
    background: linear-gradient(180deg, #f8fbfd, #edf4f8);
}

.overview-kpi-card {
    background: linear-gradient(180deg, #f8fbfd, #e9f1f6);
}

.overview-kpi-warning {
    background: linear-gradient(180deg, #fff7ec, #f8ead5);
}

.overview-kpi-success {
    background: linear-gradient(180deg, #eff8f4, #e0f0e8);
}

.overview-kpi-info {
    background: linear-gradient(180deg, #f1f4fb, #e4e9f6);
}

.overview-link-card-products {
    background: linear-gradient(180deg, #eff7fc, #deebf5);
}

.overview-link-card-alerts {
    background: linear-gradient(180deg, #fff7ee, #f7e8d8);
}

.overview-link-card-stats {
    background: linear-gradient(180deg, #eff8f4, #deeee7);
}

.search-input-group,
.history-search,
.chart-filters,
.external-filters,
.search-filters,
.cart-summary,
.backup-warning,
.system-actions,
.sale-options {
    background: linear-gradient(180deg, #f3f7fa, #eaf1f5);
}

.btn-secondary,
.btn-outline-secondary,
#clear-cart,
#clear-search,
#clear-sales-search {
    background: linear-gradient(180deg, #f2f6f9, #e6edf2);
    color: #23465a;
}

.btn-secondary:hover,
.btn-outline-secondary:hover,
#clear-cart:hover,
#clear-search:hover,
#clear-sales-search:hover {
    background: linear-gradient(180deg, #ffffff, #eef4f8);
}

.btn-outline-primary {
    background: linear-gradient(180deg, #eff7fc, #e1edf5);
    border-color: rgba(47, 111, 149, 0.24);
    color: #245a79;
}

.btn-outline-primary:hover {
    background: linear-gradient(180deg, #2f6f95, #3b84b1);
    color: #ffffff;
}

.table-container thead,
.overview-bootstrap-table thead {
    background: linear-gradient(135deg, #234257, #336682);
}

.product-card,
.external-product-card {
    background: linear-gradient(180deg, #f8fbfd, #edf4f8);
}

.alert-success {
    background: linear-gradient(180deg, rgba(45, 143, 111, 0.16), rgba(236, 246, 242, 0.98));
}

.alert-error {
    background: linear-gradient(180deg, rgba(198, 91, 82, 0.16), rgba(249, 239, 238, 0.98));
}

.alert-warning {
    background: linear-gradient(180deg, rgba(201, 135, 47, 0.18), rgba(251, 244, 234, 0.98));
}

@media (min-width: 992px) {
    html,
    body.dashboard-page {
        height: 100%;
    }

    body.dashboard-page {
        overflow: hidden;
    }

    .dashboard-shell {
        min-height: 100vh;
        height: 100vh;
        align-items: stretch;
        overflow: hidden;
    }

    .sidebar.offcanvas-lg {
        position: relative !important;
        top: 0;
        flex: 0 0 min(320px, 88vw);
        width: min(320px, 88vw);
        height: 100vh;
        max-height: 100vh;
        align-self: stretch;
        overflow: hidden;
        border-radius: 0;
    }

    .sidebar.offcanvas-lg .offcanvas-body {
        min-height: 100vh;
        max-height: 100vh;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .dashboard-main {
        flex: 1 1 auto;
        min-width: 0;
        min-height: 100vh;
        height: 100vh;
        overflow: hidden;
    }

    .dashboard-main .main-content {
        height: 100vh;
        max-height: 100vh;
        overflow-y: auto !important;
        overflow-x: hidden;
        overscroll-behavior: contain;
    }
}

/* Sales cart modal: keep it usable when opened from mobile layouts. */
body.sales-cart-open {
    overflow: hidden;
}

.sales-cart-modal {
    box-sizing: border-box;
    position: fixed !important;
    inset: 0 !important;
    display: flex;
    align-items: stretch;
    justify-content: flex-end;
    width: 100vw !important;
    max-width: none !important;
    height: 100vh;
    height: 100dvh;
    margin: 0 !important;
    padding: 24px;
    background: rgba(20, 37, 50, 0.48);
    overflow: hidden;
    overscroll-behavior: contain;
    touch-action: auto;
    z-index: 1300 !important;
}

.sales-cart-modal[hidden] {
    display: none !important;
}

.sales-cart-modal.is-open {
    position: fixed !important;
    inset: 0 !important;
    display: flex !important;
}

.sales-cart-dialog {
    width: min(540px, 100%);
    height: 100%;
    min-height: 0;
    max-height: 100%;
    display: flex;
}

.sales-cart-modal .cart-panel {
    height: 100%;
    max-height: none;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

@media (max-width: 768px) {
    .sales-cart-modal {
        align-items: stretch;
        justify-content: stretch;
        width: 100vw;
        padding: 0;
    }

    .sales-cart-dialog {
        width: 100%;
        max-height: none;
    }

    .sales-cart-modal .cart-panel {
        border-radius: 0 !important;
        padding: 16px;
    }

    .sales-cart-modal .cart-modal-header {
        position: sticky;
        top: 0;
        z-index: 2;
        margin: -16px -16px 16px;
        padding: 14px 16px;
        background: inherit;
    }

    .sales-cart-modal .cart-actions {
        position: sticky;
        bottom: 0;
        z-index: 2;
        margin: 0 -16px -16px;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
        background: inherit;
        border-top: 1px solid rgba(80, 117, 141, 0.16);
    }
}

/* Estadisticas completas */
.statistics-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.statistics-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.statistics-toolbar .form-select {
    width: auto;
    min-width: 132px;
}

.statistics-status {
    margin: 0 0 14px;
    padding: 10px 14px;
    border: 1px solid rgba(47, 111, 149, 0.16);
    border-radius: 8px;
    background: rgba(238, 246, 250, 0.9);
    color: #2f6f95;
    font-weight: 700;
}

.statistics-status.is-error {
    border-color: rgba(198, 91, 82, 0.24);
    background: rgba(255, 242, 240, 0.94);
    color: #8d453f;
}

.stats-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.stats-kpi-card,
.stats-chart-card,
.stats-table-card {
    background: #ffffff;
    border: 1px solid rgba(80, 117, 141, 0.12);
    border-radius: 8px;
    box-shadow: 0 14px 34px rgba(36, 59, 74, 0.08);
}

.stats-kpi-card {
    padding: 18px 20px;
}

.stats-kpi-card span,
.stats-kpi-card small {
    display: block;
    color: #6f8292;
}

.stats-kpi-card span {
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stats-kpi-card strong {
    display: block;
    margin: 8px 0 4px;
    color: #243b4a;
    font-size: 1.55rem;
    line-height: 1.15;
}

.stats-chart-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
    gap: 18px;
    margin-bottom: 20px;
}

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

.stats-chart-card,
.stats-table-card {
    overflow: hidden;
}

.stats-chart-card > .chart-header,
.stats-table-card > .chart-header {
    padding: 18px 20px 0;
}

.stats-chart-card > .chart-container,
.stats-table-card > .table-container {
    padding: 18px 20px 20px;
}

.stats-chart-container {
    min-height: 320px;
}

.stats-chart-card .form-select-sm {
    width: auto;
    min-width: 132px;
}

.stats-table-card .table-container {
    margin: 0;
}

.stats-table-card table th {
    white-space: nowrap;
}

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 28px;
    padding: 0 8px;
    border-radius: 999px;
    background: rgba(47, 111, 149, 0.12);
    color: #2f6f95;
    font-weight: 800;
}

.rank-badge.rank-1 {
    background: rgba(201, 135, 47, 0.18);
    color: #8a632a;
}

.rank-badge.rank-2 {
    background: rgba(45, 143, 111, 0.16);
    color: #246c54;
}

.rank-badge.rank-3 {
    background: rgba(127, 108, 198, 0.16);
    color: #6655a8;
}

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

    .stats-chart-grid,
    .stats-table-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 767.98px) {
    .statistics-header {
        display: block;
    }

    .statistics-toolbar {
        justify-content: stretch;
        margin-top: 14px;
    }

    .statistics-toolbar .form-select,
    .statistics-toolbar .btn,
    .stats-chart-card .form-select-sm {
        width: 100%;
    }

    .stats-dashboard-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stats-chart-container {
        min-height: 260px;
    }

    .stats-chart-card > .chart-header,
    .stats-table-card > .chart-header,
    .stats-chart-card > .chart-container,
    .stats-table-card > .table-container {
        padding-left: 14px;
        padding-right: 14px;
    }
}

/* Codigos de barras */
.barcode-sale-panel {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) auto auto;
    align-items: center;
    gap: 10px;
    margin: 14px 0 18px;
    padding: 12px;
    border: 1px solid rgba(47, 111, 149, 0.16);
    border-radius: 8px;
    background: #f7fbfd;
}

.barcode-sale-input,
.barcode-lookup {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    border: 1px solid rgba(80, 117, 141, 0.18);
    border-radius: 8px;
    background: #ffffff;
    padding: 0 12px;
}

.barcode-sale-input i,
.barcode-lookup i,
.sales-product-barcode i {
    color: #2f6f95;
}

.barcode-sale-input input,
.barcode-lookup input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    padding: 10px 0;
    color: #243b4a;
}

.barcode-sale-status,
.barcode-status {
    min-height: 18px;
    color: #5f7281;
    font-weight: 700;
}

.barcode-sale-status.is-error,
.barcode-status.is-error {
    color: #a34840;
}

.barcode-sale-status.is-success,
.barcode-status.is-success {
    color: #2d8f6f;
}

.barcode-camera-box {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(240px, 420px) auto;
    align-items: end;
    gap: 12px;
    padding-top: 4px;
}

.barcode-camera-box[hidden] {
    display: none;
}

.barcode-camera-box video {
    width: 100%;
    max-height: 280px;
    border-radius: 8px;
    background: #0d1720;
    object-fit: cover;
}

.sales-product-barcode {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    color: #506a7a;
    font-size: 0.82rem;
    font-weight: 800;
}

.barcode-section-header {
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.barcode-actions,
.barcode-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.barcode-tools {
    display: grid;
    grid-template-columns: minmax(260px, 520px) 1fr;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.barcode-lookup {
    padding-right: 8px;
}

.barcode-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.barcode-label-card,
.barcode-empty,
.barcode-table-card {
    border: 1px solid rgba(80, 117, 141, 0.12);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 14px 34px rgba(36, 59, 74, 0.08);
}

.barcode-label-card {
    min-height: 136px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
}

.barcode-label-card strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #243b4a;
    font-size: 0.9rem;
}

.barcode-label-card img {
    width: 100%;
    height: 54px;
    object-fit: contain;
}

.barcode-label-card span {
    color: #5f7281;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.05em;
}

.barcode-empty {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px;
    color: #6f8292;
    font-weight: 800;
}

.barcode-table-card {
    overflow: hidden;
}

#barcodes-table td strong,
#barcodes-table td small {
    display: block;
}

#barcodes-table td small {
    margin-top: 3px;
    color: #6f8292;
}

.barcode-preview {
    width: 150px;
    height: 42px;
    object-fit: contain;
}

.barcode-missing {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 9px;
    border-radius: 999px;
    background: rgba(201, 135, 47, 0.14);
    color: #8a632a;
    font-weight: 800;
}

#barcodes-table tr.is-highlighted {
    animation: barcode-highlight 1.8s ease;
}

@keyframes barcode-highlight {
    0% { background: rgba(45, 143, 111, 0.22); }
    100% { background: transparent; }
}

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

@media (max-width: 767.98px) {
    .barcode-sale-panel,
    .barcode-tools {
        grid-template-columns: 1fr;
    }

    .barcode-sale-panel .btn,
    .barcode-actions .btn,
    .barcode-lookup .btn {
        width: 100%;
        justify-content: center;
    }

    .barcode-camera-box {
        grid-template-columns: 1fr;
    }

    .barcode-section-header {
        display: block;
    }

    .barcode-actions {
        margin-top: 12px;
    }

    .barcode-grid {
        grid-template-columns: 1fr;
    }

    .barcode-preview {
        width: 120px;
    }
}
