@import url('./fonts.css');

:root {
    /* Paleta Ejecutiva Verde / Crema Modernizada (SaaS) */
    --bg-primary: #F4F7EE;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #E7EFE0;
    
    --accent-primary: #6E9460;
    --accent-hover: #5A7D4D;
    --accent-secondary: #3F543B;
    --accent-soft: rgba(110, 148, 96, 0.12);
    
    --text-primary: #1F291E;
    --text-secondary: #526350;
    --text-muted: #768874;
    
    --danger: #dc2626;
    --success: #059669;
    --warning: #d97706;
    --info: #2563eb;
    
    --border-color: #D5E0CE;
    --border-strong: #BFCFBA;
    
    --glass-bg: #FFFFFF;
    --glass-border: #D5E0CE;
    
    --shadow-xs: 0 1px 2px rgba(45, 55, 43, 0.05);
    --shadow-sm: 0 2px 8px -1px rgba(45, 55, 43, 0.07), 0 1px 3px rgba(45, 55, 43, 0.05);
    --shadow-md: 0 10px 24px -4px rgba(45, 55, 43, 0.10), 0 4px 8px -2px rgba(45, 55, 43, 0.05);
    --shadow-lg: 0 20px 38px -8px rgba(45, 55, 43, 0.16), 0 8px 16px -4px rgba(45, 55, 43, 0.08);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-primary);
    background-image: radial-gradient(circle at 100% 0%, rgba(110, 148, 96, 0.07) 0%, transparent 45%),
                      radial-gradient(circle at 0% 100%, rgba(63, 84, 59, 0.05) 0%, transparent 45%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Utilities (Superficies Sólidas SaaS) */
.glass-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.glass-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.22s ease, border-color 0.22s ease;
    box-shadow: var(--shadow-sm);
}

/* Solo elevar tarjetas interactivas o KPIs, evitando saltos molestos en formularios grandes */
.stat-card.glass-card:hover,
.grid-cards > .glass-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
}

/* ==========================================================================
   LOGIN EJECUTIVO
   ========================================================================== */
.login-viewport {
    padding: 1.25rem;
    background: radial-gradient(circle at 50% 20%, rgba(110, 148, 96, 0.14) 0%, transparent 60%);
}

.login-card {
    position: relative;
    width: 100%;
    max-width: 430px;
    padding: 2.5rem 2.25rem 2rem 2.25rem !important;
    text-align: center;
    border-radius: 20px !important;
    box-shadow: var(--shadow-lg) !important;
    overflow: hidden;
}

.login-card-accent {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: linear-gradient(90deg, var(--accent-secondary) 0%, var(--accent-primary) 50%, #90B77D 100%);
}

.login-brand-badge {
    width: 68px;
    height: 68px;
    margin: 0 auto 0.9rem auto;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--accent-secondary) 0%, var(--accent-primary) 100%);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.25rem;
    box-shadow: 0 10px 20px -5px rgba(63, 84, 59, 0.35);
}

.password-toggle-btn {
    position: absolute;
    right: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.15rem;
    transition: background 0.15s ease, color 0.15s ease;
}

.password-toggle-btn:hover {
    background: var(--bg-tertiary);
    color: var(--accent-secondary);
}

.login-submit-btn {
    padding: 0.85rem 1.5rem !important;
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    border-radius: 10px !important;
    letter-spacing: 0.01em;
}

.login-security-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    font-size: 0.76rem;
    color: var(--text-muted);
    font-weight: 500;
}

.login-security-footer i {
    color: var(--accent-primary);
    font-size: 1rem;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Outfit', sans-serif;
    color: var(--accent-secondary);
    font-weight: 700;
    letter-spacing: -0.025em;
    margin-bottom: 0.5rem;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.35rem; }

p {
    color: var(--text-secondary);
    line-height: 1.55;
}

/* Forms and Inputs */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.45rem;
    font-size: 0.84rem;
    color: var(--text-primary);
    font-weight: 600;
}

.form-control {
    width: 100%;
    padding: 0.68rem 0.95rem;
    background-color: #FFFFFF;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    box-shadow: var(--shadow-xs);
}

.form-control:hover {
    border-color: var(--border-strong);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3.5px rgba(110, 148, 96, 0.18);
    background-color: #FFFFFF;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.68rem 1.25rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.86rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid transparent;
    font-family: 'Inter', sans-serif;
    box-shadow: var(--shadow-xs);
    text-decoration: none;
    line-height: 1.2;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary) 0%, #5B824D 100%);
    color: white;
    border-color: rgba(255, 255, 255, 0.12);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--accent-hover) 0%, var(--accent-secondary) 100%);
    box-shadow: 0 6px 14px -3px rgba(63, 84, 59, 0.28);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #FFFFFF;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--bg-tertiary);
    border-color: var(--accent-primary);
    color: var(--accent-secondary);
    transform: translateY(-1px);
}

.btn-warning {
    background-color: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
}

.btn-warning:hover:not(:disabled) {
    background-color: var(--warning);
    color: #FFFFFF;
    border-color: var(--warning);
}

.btn-danger {
    background-color: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

.btn-danger:hover:not(:disabled) {
    background-color: var(--danger);
    color: white;
}

.btn-sm {
    padding: 0.38rem 0.72rem;
    font-size: 0.78rem;
    border-radius: 8px;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Layout Utilities */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.w-full { width: 100%; }
.h-screen { height: 100vh; }
.text-center { text-align: center; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.ml-2 { margin-left: 0.5rem; }
.mr-2 { margin-right: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }

/* Dashboard Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ==========================================================================
   SIDEBAR EJECUTIVO & COLAPSABLE EN PC
   ========================================================================== */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, #354732 0%, #243122 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    color: white;
    transition: width 0.26s cubic-bezier(0.16, 1, 0.3, 1), padding 0.26s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
    box-shadow: 4px 0 24px rgba(31, 41, 30, 0.12);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    gap: 0.5rem;
}

.sidebar-logo {
    font-family: 'Outfit', sans-serif;
    font-size: 1.35rem;
    font-weight: 800;
    color: white;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar-logo-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent-primary) 0%, #87A87A 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #FFFFFF;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.sidebar-collapse-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-collapse-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #FFFFFF;
}

.sidebar-close-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.12);
    color: white;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.sidebar-close-btn:hover {
    background: rgba(239, 68, 68, 0.4);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 0.85rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-item-logout {
    color: #fca5a5 !important;
}

.nav-item-logout i {
    color: #f87171 !important;
}

.nav-item-logout:hover {
    background: rgba(239, 68, 68, 0.18) !important;
    color: #fecaca !important;
}

.sidebar-user-card {
    display: none;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.sidebar-user-info {
    overflow: hidden;
    flex: 1;
}

.sidebar-user-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: white;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.sidebar-user-role {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.7);
}

.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(18, 28, 17, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.hamburger-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--accent-secondary);
    font-size: 1.4rem;
    cursor: pointer;
    box-shadow: var(--shadow-xs);
    transition: all 0.2s ease;
}

.hamburger-btn:hover {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
}

.header-brand-mobile {
    display: none;
    align-items: center;
    gap: 0.45rem;
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-secondary);
}

.device-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.73rem;
    font-weight: 700;
    color: var(--accent-secondary);
}

/* Botón en móvil para cambiar entre Tarjetas y Tabla */
.mobile-view-toggle-btn {
    display: none;
    align-items: center;
    gap: 0.35rem;
    padding: 0.38rem 0.7rem;
    border-radius: 20px;
    background: var(--accent-soft);
    border: 1px solid var(--accent-primary);
    color: var(--accent-secondary);
    font-size: 0.74rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mobile-view-toggle-btn i {
    font-size: 1rem;
    color: var(--accent-primary);
}

.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--border-color);
    z-index: 999;
    justify-content: space-around;
    align-items: center;
    padding: 0 0.35rem;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -6px 20px rgba(31, 41, 30, 0.08);
}

.mobile-bottom-nav-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.66rem;
    font-weight: 600;
    gap: 3px;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-bottom-nav-item i {
    font-size: 1.35rem;
    transition: transform 0.2s ease, color 0.2s ease;
}

.mobile-bottom-nav-item.active {
    color: var(--accent-secondary);
    font-weight: 700;
}

.mobile-bottom-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    width: 32px;
    height: 3px;
    border-radius: 0 0 4px 4px;
    background: var(--accent-primary);
}

.mobile-bottom-nav-item.active i {
    color: var(--accent-primary);
    transform: translateY(-1px);
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.22rem;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 2px;
}

.nav-menu::-webkit-scrollbar {
    width: 4px;
}

.nav-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.nav-category-header {
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.46);
    padding: 0.7rem 0.65rem 0.22rem 0.65rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    user-select: none;
    white-space: nowrap;
}

.nav-category-header:not(:first-child) {
    margin-top: 0.4rem;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.nav-category-header span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    padding: 0.6rem 0.85rem;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.82);
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    font-weight: 500;
    font-size: 0.88rem;
    gap: 0.75rem;
    cursor: pointer;
    border: 1px solid transparent;
    white-space: nowrap;
}

.nav-item i {
    font-size: 1.2rem;
    min-width: 1.2rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.75);
    transition: transform 0.2s ease, color 0.2s ease;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateX(2px);
}

.nav-item:hover i {
    color: white;
    transform: scale(1.08);
}

.nav-item.active {
    background: linear-gradient(90deg, var(--accent-primary) 0%, #5B824D 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.18);
    font-weight: 600;
}

.nav-item.active i {
    color: white;
}

/* ==========================================================================
   MODO SIDEBAR COLAPSADO EN PC (>= 1024px)
   ========================================================================== */
@media (min-width: 1024px) {
    body.sidebar-collapsed .sidebar {
        width: 78px;
        padding: 1.25rem 0.65rem;
    }

    body.sidebar-collapsed .sidebar-header {
        flex-direction: column;
        justify-content: center;
        gap: 0.65rem;
        padding-bottom: 0.75rem;
    }

    body.sidebar-collapsed .sidebar-logo-text,
    body.sidebar-collapsed .nav-category-header,
    body.sidebar-collapsed .nav-item span {
        display: none !important;
    }

    body.sidebar-collapsed .nav-menu {
        overflow: visible;
    }

    body.sidebar-collapsed .nav-item {
        justify-content: center;
        padding: 0.7rem 0;
        transform: none !important;
    }

    body.sidebar-collapsed .nav-item i {
        font-size: 1.35rem;
        margin: 0;
    }

    /* Tooltip flotante al pasar el mouse en modo colapsado */
    body.sidebar-collapsed .nav-item[data-tooltip]:hover::after {
        content: attr(data-tooltip);
        position: absolute;
        left: calc(100% + 12px);
        top: 50%;
        transform: translateY(-50%);
        background: #1F291E;
        color: #FFFFFF;
        padding: 0.4rem 0.75rem;
        border-radius: 8px;
        font-size: 0.78rem;
        font-weight: 600;
        white-space: nowrap;
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
        z-index: 2000;
        pointer-events: none;
    }

    body.sidebar-collapsed .main-content {
        margin-left: 78px;
        max-width: calc(100vw - 78px);
    }
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 1.5rem 2.25rem 2.5rem 2.25rem;
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: calc(100vw - 260px);
    transition: margin-left 0.26s cubic-bezier(0.16, 1, 0.3, 1), max-width 0.26s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Header superior tipo barra ejecutiva */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 0.85rem 1.35rem;
    box-shadow: var(--shadow-xs);
}

.header-titles h2 {
    font-size: 1.45rem;
    margin-bottom: 0.1rem;
    line-height: 1.2;
}

.header-titles p {
    font-size: 0.82rem;
    margin-bottom: 0;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-primary);
    padding: 0.38rem 0.85rem 0.38rem 0.45rem;
    border-radius: 50px;
    border: 1px solid var(--border-color);
    transition: border-color 0.2s ease, background 0.2s ease;
}

.user-profile:hover {
    border-color: var(--accent-primary);
    background: var(--bg-tertiary);
}

.avatar-circle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-secondary) 0%, var(--accent-primary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: white;
    box-shadow: 0 2px 6px rgba(63, 84, 59, 0.25);
}

/* Grid System */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.15rem;
    margin-bottom: 1.75rem;
}

/* Stat Card */
.stat-card {
    display: flex;
    align-items: center;
    gap: 1.15rem;
    border-left: 5px solid var(--accent-primary);
    padding: 1.2rem 1.35rem;
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.22s ease, border-color 0.22s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 12px;
    background: var(--bg-tertiary);
    color: var(--accent-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.45rem;
}

.stat-info h4 {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.2rem;
}

.stat-info .value {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--accent-secondary);
    line-height: 1.15;
}

/* ==========================================================================
   TABLAS ERP DE ALTA DENSIDAD (PC & TABLET)
   ========================================================================== */
.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background-color: var(--bg-secondary);
    border-radius: 14px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    position: relative;
    max-height: 74vh;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th, td {
    padding: 0.85rem 1.15rem;
    text-align: left;
    border-bottom: 1px solid #E6EDE1;
}

th {
    background-color: #EBF1E6;
    font-weight: 700;
    color: var(--accent-secondary);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 2px solid var(--border-color);
}

tbody tr:nth-child(even) td {
    background-color: rgba(244, 247, 238, 0.45);
}

tbody tr:hover td {
    background-color: rgba(110, 148, 96, 0.10) !important;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.68rem;
    border-radius: 50px;
    font-size: 0.73rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.badge-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.badge-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.badge-danger { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.badge-info, .badge-blue { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* Notifications */
#notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 92vw;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-left: 5px solid var(--accent-primary);
    padding: 0.9rem 1.25rem;
    border-radius: 10px;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.88rem;
    box-shadow: var(--shadow-md);
    animation: slideIn 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ==========================================================================
   MODAL BASE & MOBILE BOTTOM SHEET
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(24, 34, 23, 0.62);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.26s ease;
    padding: 1rem;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--bg-secondary);
    border-radius: 20px;
    width: fit-content;
    min-width: 420px;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(24, 34, 23, 0.35);
    border: 1px solid var(--border-color);
    transform: translateY(16px) scale(0.98);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
}

.modal-drag-handle {
    display: none;
    width: 46px;
    height: 5px;
    border-radius: 999px;
    background: #C5D1BE;
    margin: 0 auto 0.85rem auto;
    cursor: pointer;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.close-btn {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 1.15rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: #fee2e2;
    border-color: #fecaca;
    color: var(--danger);
}

.hidden { display: none !important; }

/* Touch scroll indicator cue */
.table-scroll-hint {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.72rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    font-weight: 500;
}

/* ==========================================================================
   TABLET & MOBILE DRAWER NAVIGATION (< 1024px)
   ========================================================================== */
@media (max-width: 1023px) {
    .hamburger-btn {
        display: flex !important;
    }

    .header-brand-mobile {
        display: flex !important;
    }

    .sidebar-close-btn {
        display: flex !important;
    }

    .sidebar-collapse-btn {
        display: none !important;
    }

    .sidebar-user-card {
        display: flex !important;
    }

    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 300px !important;
        max-width: 84vw !important;
        height: 100vh !important;
        z-index: 1100 !important;
        transform: translateX(-100%) !important;
        transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1) !important;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.45) !important;
        overflow-y: auto !important;
        padding: 1.25rem 1rem !important;
    }

    .sidebar.open {
        transform: translateX(0) !important;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        padding: 1.25rem 1.25rem 2rem 1.25rem !important;
    }

    .header {
        margin-bottom: 1.25rem;
        padding: 0.75rem 1rem;
    }
}

/* ==========================================================================
   SMARTPHONE MÓVIL (< 768px): VISTA TARJETAS HÍBRIDA & BOTTOM SHEET MODALS
   ========================================================================== */
@media (max-width: 767px) {
    .main-content {
        padding: 0.75rem 0.75rem 84px 0.75rem !important;
    }

    .mobile-bottom-nav {
        display: flex !important;
    }

    .mobile-view-toggle-btn {
        display: inline-flex !important;
    }

    .header {
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        margin-bottom: 1rem !important;
        padding: 0.6rem 0.75rem !important;
        gap: 0.5rem !important;
        border-radius: 12px !important;
    }

    .header-titles {
        display: none !important;
    }

    .header-brand-mobile {
        display: flex !important;
        font-size: 1.15rem !important;
    }

    .user-profile {
        padding: 0.25rem !important;
        gap: 0 !important;
    }

    .user-profile-details {
        display: none !important;
    }

    /* KPI / Stat Cards: 2-column mobile layout */
    .grid-cards {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.6rem !important;
    }

    .grid-2 {
        grid-template-columns: 1fr !important;
    }

    .stat-card {
        padding: 0.75rem 0.8rem !important;
        gap: 0.6rem !important;
        border-radius: 12px !important;
    }

    .stat-icon {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
        font-size: 1.15rem !important;
        border-radius: 9px !important;
    }

    .stat-info .value,
    .stat-value {
        font-size: 1.3rem !important;
    }

    .stat-info h4,
    .stat-label {
        font-size: 0.68rem !important;
    }

    /* ----------------------------------------------------------------------
       MODALES ESTILO APP NATIVA (BOTTOM SHEET) EN MÓVIL
       ---------------------------------------------------------------------- */
    .modal-overlay {
        align-items: flex-end !important;
        padding: 0 !important;
    }

    .modal-content {
        width: 100vw !important;
        max-width: 100vw !important;
        min-width: 0 !important;
        max-height: 91vh !important;
        overflow-y: auto !important;
        padding: 0.65rem 1.1rem calc(1.35rem + env(safe-area-inset-bottom, 0px)) 1.1rem !important;
        border-radius: 22px 22px 0 0 !important;
        border-bottom: none !important;
        transform: translateY(100%) !important;
        transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1) !important;
    }

    .modal-overlay.active .modal-content {
        transform: translateY(0) !important;
    }

    .modal-drag-handle {
        display: block !important;
    }

    .modal-header {
        position: sticky;
        top: 0;
        background: var(--bg-secondary);
        z-index: 20;
        padding-top: 0.25rem;
        padding-bottom: 0.65rem;
        margin-bottom: 1rem;
    }

    .modal-header h3 {
        font-size: 1.1rem !important;
    }

    /* Controles táctiles cómodos (44px min-height) */
    .form-control {
        font-size: 16px !important; /* Evita auto-zoom en iOS Safari */
        min-height: 44px;
        padding: 0.65rem 0.85rem !important;
    }

    .btn {
        min-height: 42px;
        padding: 0.55rem 0.95rem !important;
        font-size: 0.84rem !important;
    }

    .btn-sm {
        min-height: 36px;
        padding: 0.4rem 0.68rem !important;
        font-size: 0.76rem !important;
    }

    .glass-card {
        padding: 1rem !important;
        border-radius: 12px !important;
    }

    h1 { font-size: 1.55rem !important; }
    h2 { font-size: 1.3rem !important; }
    h3 { font-size: 1.12rem !important; }

    #login-view .login-card {
        width: 95vw !important;
        padding: 2rem 1.35rem 1.5rem 1.35rem !important;
    }

    /* ----------------------------------------------------------------------
       VISTA HÍBRIDA DE TABLAS A TARJETAS EN MÓVIL (Activa por defecto)
       Si el usuario pulsa el botón "Tabla", se agrega body.mobile-table-mode
       ---------------------------------------------------------------------- */
    body:not(.mobile-table-mode) .table-container {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        max-height: none !important;
        overflow: visible !important;
    }

    body:not(.mobile-table-mode) .table-scroll-hint {
        display: none !important;
    }

    body:not(.mobile-table-mode) .table-container table,
    body:not(.mobile-table-mode) table.table-inventario,
    body:not(.mobile-table-mode) table.mobile-card-ready {
        min-width: 0 !important;
        width: 100% !important;
        display: block !important;
    }

    body:not(.mobile-table-mode) .table-container thead,
    body:not(.mobile-table-mode) table.table-inventario thead,
    body:not(.mobile-table-mode) table.mobile-card-ready thead {
        display: none !important;
    }

    body:not(.mobile-table-mode) .table-container tbody,
    body:not(.mobile-table-mode) table.table-inventario tbody,
    body:not(.mobile-table-mode) table.mobile-card-ready tbody {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.75rem !important;
        width: 100% !important;
    }

    body:not(.mobile-table-mode) .table-container tbody tr,
    body:not(.mobile-table-mode) table.table-inventario tbody tr,
    body:not(.mobile-table-mode) table.mobile-card-ready tbody tr {
        display: flex !important;
        flex-direction: column !important;
        background: #FFFFFF !important;
        border: 1px solid var(--border-color) !important;
        border-left: 4px solid var(--accent-primary) !important;
        border-radius: 14px !important;
        padding: 0.75rem 0.95rem !important;
        box-shadow: 0 3px 10px rgba(31, 41, 30, 0.06) !important;
        width: 100% !important;
    }

    body:not(.mobile-table-mode) .table-container tbody td,
    body:not(.mobile-table-mode) table.table-inventario tbody td,
    body:not(.mobile-table-mode) table.mobile-card-ready tbody td {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        gap: 0.75rem !important;
        padding: 0.42rem 0 !important;
        border-bottom: 1px dashed #E2EAE0 !important;
        text-align: right !important;
        font-size: 0.83rem !important;
        background: transparent !important;
        width: 100% !important;
        min-height: 30px;
    }

    body:not(.mobile-table-mode) .table-container tbody td:last-child,
    body:not(.mobile-table-mode) table.table-inventario tbody td:last-child,
    body:not(.mobile-table-mode) table.mobile-card-ready tbody td:last-child {
        border-bottom: none !important;
        padding-bottom: 0.15rem !important;
    }

    body:not(.mobile-table-mode) .table-container tbody td[data-label]::before,
    body:not(.mobile-table-mode) table.table-inventario tbody td[data-label]::before,
    body:not(.mobile-table-mode) table.mobile-card-ready tbody td[data-label]::before {
        content: attr(data-label);
        font-family: 'Outfit', sans-serif;
        font-size: 0.71rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        color: var(--text-secondary);
        text-align: left;
        flex-shrink: 0;
        max-width: 46%;
    }

    /* Celdas de acciones o ancho completo en tarjetas móviles */
    body:not(.mobile-table-mode) .table-container tbody td[data-cell-type="actions"],
    body:not(.mobile-table-mode) table.table-inventario tbody td[data-cell-type="actions"],
    body:not(.mobile-table-mode) table.mobile-card-ready tbody td[data-cell-type="actions"] {
        justify-content: flex-end !important;
        flex-wrap: wrap !important;
        padding-top: 0.6rem !important;
        margin-top: 0.2rem !important;
        border-top: 1px solid var(--border-color) !important;
        border-bottom: none !important;
    }

    body:not(.mobile-table-mode) .table-container tbody td[data-cell-type="actions"]::before,
    body:not(.mobile-table-mode) table.table-inventario tbody td[data-cell-type="actions"]::before,
    body:not(.mobile-table-mode) table.mobile-card-ready tbody td[data-cell-type="actions"]::before {
        margin-right: auto;
    }

    body:not(.mobile-table-mode) .table-container tbody td[colspan],
    body:not(.mobile-table-mode) table.table-inventario tbody td[colspan],
    body:not(.mobile-table-mode) table.mobile-card-ready tbody td[colspan] {
        justify-content: center !important;
        text-align: center !important;
        border-bottom: none !important;
        padding: 1.25rem 0.5rem !important;
    }

    body:not(.mobile-table-mode) .table-container tbody td[colspan]::before {
        display: none !important;
    }

    /* Si el usuario activa modo Tabla en móvil */
    body.mobile-table-mode .table-scroll-hint {
        display: flex !important;
    }
}

/* 4. ULTRA-COMPACT PHONES (< 380px) */
@media (max-width: 380px) {
    .grid-cards {
        grid-template-columns: 1fr !important;
    }

    .mobile-bottom-nav-item span {
        font-size: 0.58rem !important;
    }
}

/* DataTables Theme overrides */
.dataTable-wrapper { font-family: 'Inter', sans-serif; }
.dataTable-top, .dataTable-bottom { padding: 1rem; color: var(--text-primary); }
.dataTable-input { background: #FFFFFF !important; color: var(--text-primary) !important; border: 1px solid var(--border-color) !important; border-radius: 8px; padding: 0.5rem 1rem; }
.dataTable-selector { background: #FFFFFF !important; color: var(--text-primary) !important; border: 1px solid var(--border-color) !important; border-radius: 8px; padding: 0.5rem; }
.dataTable-info { color: var(--text-muted); }
.dataTable-pagination a { color: var(--text-primary) !important; background: var(--bg-tertiary); border-radius: 6px; padding: 0.25rem 0.75rem; margin: 0 0.15rem; }
.dataTable-pagination a:hover { background: var(--accent-primary) !important; color: #fff !important; }
.dataTable-pagination .active a, .dataTable-pagination .active a:hover { background: var(--accent-primary) !important; color: #fff !important; font-weight: bold; }
.dataTable-table > tbody > tr > td { padding: 0.85rem 1rem; border-bottom: 1px solid var(--border-color); }
.dataTable-table th a { color: var(--text-primary); text-decoration: none; }

/* Elegant scrollbars */
::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}
::-webkit-scrollbar-track {
    background: rgba(213, 224, 206, 0.25);
}
::-webkit-scrollbar-thumb {
    background: #B8C9B1;
    border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* --- INVENTARIO FÍSICO: MEJORAS VISUALES Y EXPERIENCIA --- */
.filter-chips-bar {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.25rem 0.1rem 0.65rem 0.1rem;
    margin-bottom: 0.75rem;
    scrollbar-width: thin;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.42rem 0.95rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-xs);
}

.filter-chip:hover {
    background: var(--bg-tertiary);
    color: var(--accent-secondary);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}

.filter-chip.active {
    background: var(--accent-secondary);
    color: white;
    border-color: var(--accent-secondary);
    box-shadow: 0 4px 12px rgba(63, 84, 59, 0.25);
    transform: translateY(-1px);
}

.filter-chip .chip-badge {
    background: rgba(0, 0, 0, 0.08);
    padding: 1px 7px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 700;
}

.filter-chip.active .chip-badge {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

.stat-card.kpi-active {
    outline: 2px solid var(--accent-primary) !important;
    outline-offset: -1px;
    box-shadow: 0 8px 24px rgba(110, 148, 96, 0.25) !important;
    transform: translateY(-2px);
    background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(110, 148, 96, 0.1) 100%) !important;
}

/* Tabla de Inventario Global Optimizada */
.table-inventario {
    width: 100%;
    min-width: 1020px;
    border-collapse: separate;
    border-spacing: 0;
}

.table-inventario thead th {
    padding: 0.78rem 0.68rem !important;
    font-size: 0.73rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.04em !important;
    white-space: nowrap !important;
    text-transform: uppercase !important;
    background: #E8F0E3 !important;
    color: var(--accent-secondary) !important;
    border-bottom: 2px solid var(--border-color) !important;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(45, 55, 43, 0.06);
}

.table-inventario tbody td {
    padding: 0.65rem 0.65rem !important;
    font-size: 0.825rem !important;
    vertical-align: middle !important;
    border-bottom: 1px solid #E5ECE0 !important;
    background: transparent;
}

.table-inventario tbody tr:hover td {
    background-color: rgba(110, 148, 96, 0.10) !important;
}

.table-inventario .badge {
    white-space: nowrap;
}

/* Copiado rápido de NIV */
.niv-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--accent-primary);
    font-family: monospace;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 5px;
    transition: background 0.15s ease, color 0.15s ease;
}

.niv-copy-btn:hover {
    background: rgba(110, 148, 96, 0.15);
    color: var(--accent-secondary);
}

.niv-copy-btn i {
    font-size: 0.95rem;
    opacity: 0.75;
}

.niv-copy-btn:hover i {
    opacity: 1;
}

/* --- MODEL STOCK ROW EN SUCURSALES --- */
.model-stock-row {
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.model-stock-row:hover {
    transform: translateX(2px);
}

/* --- MODAL FINANCIERAS: BARRA DE FILTROS --- */
.fin-filter-bar {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    margin-bottom: 1.25rem;
}
