/* ===================================
   DeividKids - Sistema de Gestión
   Apple Light Glass Design
   =================================== */

/* CSS Variables - Apple Light Mode Design System */
:root {
    /* Backgrounds - Unified Apple System */
    --bg-primary: #f5f5f7;
    --bg-secondary: rgba(255, 255, 255, 0.9);
    --bg-tertiary: rgba(255, 255, 255, 0.7);

    /* Liquid Glass Effects - Intensified */
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-bg-hover: rgba(255, 255, 255, 0.9);
    --glass-bg-active: rgba(255, 255, 255, 1);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-border-hover: rgba(255, 255, 255, 0.8);
    --glass-blur: blur(25px) saturate(180%);

    /* Neon System Colors */
    --neon-blue: #007AFF;
    --neon-purple: #5856D6;
    --neon-pink: #FF2D55;
    --neon-orange: #FF9500;
    --neon-green: #34C759;
    --neon-teal: #5AC8FA;

    /* Apple Palette */
    --apple-blue: var(--neon-blue);
    --apple-purple: var(--neon-purple);
    --apple-pink: var(--neon-pink);
    --apple-orange: var(--neon-orange);
    --apple-green: var(--neon-green);
    --apple-red: #FF3B30;

    /* High-Vibrancy Gradients */
    --gradient-primary: linear-gradient(135deg, #007AFF 0%, #5856D6 50%, #FF2D55 100%);
    --gradient-blue: linear-gradient(135deg, #007AFF 0%, #5AC8FA 100%);
    --gradient-purple: linear-gradient(135deg, #5856D6 0%, #AF52DE 100%);
    --gradient-pink: linear-gradient(135deg, #FF2D55 0%, #FF6482 100%);
    --gradient-success: linear-gradient(135deg, #34C759 0%, #30D158 100%);
    --gradient-warning: linear-gradient(135deg, #FF9500 0%, #FFCC00 100%);
    --gradient-danger: linear-gradient(135deg, #FF3B30 0%, #FF6961 100%);
    --gradient-neon: linear-gradient(45deg, #007AFF, #5856D6, #FF2D55, #FF9500);

    /* Text System */
    --text-primary: #1d1d1f;
    --text-secondary: #424245;
    --text-tertiary: #6e6e73;
    --text-muted: #86868b;

    /* Shadows */
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 40px 100px rgba(0, 0, 0, 0.16);
    --shadow-neon: 0 0 20px rgba(0, 122, 255, 0.3);

    /* Radius & Layout */
    --sidebar-width: 240px;
    --header-height: 72px;
    --border-radius-sm: 14px;
    --border-radius: 24px;
    --border-radius-lg: 32px;
    --border-radius-xl: 44px;

    /* Animation Tokens */
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Dark Mode Overrides */
body.dark-mode {
    --bg-primary: #050507;
    --bg-secondary: rgba(20, 20, 25, 0.95);
    --bg-tertiary: rgba(30, 30, 35, 0.8);
    --glass-bg: rgba(28, 28, 30, 0.55);
    --glass-bg-hover: rgba(44, 44, 46, 0.7);
    --glass-bg-active: rgba(58, 58, 60, 0.85);
    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-border-hover: rgba(255, 255, 255, 0.25);
    --glass-blur: blur(35px) saturate(200%);
    --text-primary: #f5f5f7;
    --text-secondary: rgba(235, 235, 245, 0.8);
    --text-tertiary: rgba(235, 235, 245, 0.6);
    --text-muted: rgba(235, 235, 245, 0.4);
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.8);
    --shadow-neon: 0 0 30px rgba(88, 86, 214, 0.4);
}

body.dark-mode::before {
    background:
        radial-gradient(at 0% 0%, rgba(88, 86, 214, 0.25) 0%, transparent 50%),
        radial-gradient(at 100% 0%, rgba(0, 122, 255, 0.2) 0%, transparent 50%),
        radial-gradient(at 100% 100%, rgba(255, 45, 85, 0.15) 0%, transparent 50%),
        radial-gradient(at 0% 100%, rgba(10, 132, 255, 0.2) 0%, transparent 50%),
        radial-gradient(at 50% 50%, rgba(0, 0, 0, 0.4) 0%, transparent 60%);
    background-color: #050507;

    /* Dark Mode Mesh Colors (Theme 1 Overrides) */
    --mesh-1: rgba(88, 86, 214, 0.25);
    --mesh-2: rgba(0, 122, 255, 0.2);
    --mesh-3: rgba(255, 45, 85, 0.15);
    --mesh-4: rgba(10, 132, 255, 0.2);
}

/* ===================================
   UTILITIES - Apple Premium
   =================================== */
.squircle {
    mask-image: paint(squircle);
    /* Fallback to border-radius */
    border-radius: var(--border-radius-lg);
}

.neon-glow {
    position: relative;
}

.neon-glow::after {
    content: '';
    position: absolute;
    inset: -2px;
    background: var(--gradient-neon);
    filter: blur(15px);
    opacity: 0.3;
    z-index: -1;
    border-radius: inherit;
    animation: neonPulse 4s ease-in-out infinite;
}

@keyframes neonPulse {

    0%,
    100% {
        opacity: 0.3;
        filter: blur(15px);
    }

    50% {
        opacity: 0.5;
        filter: blur(20px);
    }
}

/* Reset & Base */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', 'Inter', sans-serif;
    background: radial-gradient(circle at top, #f0f2f5, #ffffff);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    overflow-x: auto;
    /* Allow horizontal scroll if needed */
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.mobile-only,
.mobile-search-capsule,
.mobile-drawer-footer {
    display: none !important;
}

@media (max-width: 768px) {
    .mobile-only {
        display: flex !important;
    }

    .mobile-search-capsule {
        display: block !important;
    }

    .mobile-drawer-footer {
        display: flex !important;
    }
}


/* Soft Gradient Background - Light Mode */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-primary);
    pointer-events: none;
    z-index: 0;
    /* Optimized for performance */
    opacity: 0.85;
    transition: all 0.8s ease-in-out;
}

@keyframes gradientShift {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    100% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

/* Scrollbar - Apple Light Style */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.45);
    /* More visible */
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.65);
    border: 2px solid transparent;
    background-clip: content-box;
}

/* ===================================
   SIDEBAR - tvOS Dark Glass Style
   =================================== */

.sidebar {
    width: var(--sidebar-width);
    height: calc(100vh - 40px);
    background: var(--glass-bg) !important;
    backdrop-filter: blur(30px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(30px) saturate(180%) !important;
    border: 1px solid var(--glass-border) !important;
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 20px;
    top: 20px;
    z-index: 1000;
    transition: all var(--transition-normal);
    border-radius: 30px !important;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
    /* Allow floating menus (store selector) to pop out without being cut */
    overflow: visible !important;
}

/* Brand Logo styles moved to LOGO PANEL section at bottom of file */

/* Navigation Category Label */
.nav-category {
    font-size: 0.72rem;
    font-weight: 800;
    /* Extra Bold */
    color: var(--text-tertiary);
    /* Solid deep grey */
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 22px 16px 10px 24px;
    margin-top: 10px;
}

.nav-category:first-child {
    margin-top: 0;
}

.nav-menu {
    flex: 1;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

.nav-menu::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

/* --- Sync Indicator --- */
.sync-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
    background: var(--bg-primary);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--apple-blue);
    border: 1px solid var(--glass-border);
    animation: sync-pulse 1.5s infinite ease-in-out;
    transition: opacity 0.3s;
    pointer-events: none;
}

.sync-icon {
    display: inline-block;
    margin-right: 4px;
    animation: rotate 2s linear infinite;
}

@keyframes sync-pulse {

    0%,
    100% {
        opacity: 0.6;
        transform: scale(0.95);
    }

    50% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 600;
    /* Bolder */
    cursor: pointer;
    border-radius: 14px;
    transition: all var(--transition-normal);
    text-align: left;
    position: relative;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.5);
    color: #000000;
    transform: scale(1.02);
}

.nav-item:hover .nav-icon-wrapper {
    transform: scale(1.1);
}

.nav-item.active {
    background: #ffffff;
    color: #1d1d1f;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.nav-item.active .nav-icon-wrapper {
    background: rgba(0, 0, 0, 0.08);
    box-shadow: none;
}

.nav-item.active::before {
    display: none;
}

/* Icon Wrapper for circular icons */
.nav-icon-wrapper {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    line-height: 1;
    /* Reset for Windows Chrome */
    transition: all var(--transition-bounce);
    flex-shrink: 0;
}

/* Icon colors for each nav item */
.nav-item[data-section="dashboard"] .nav-icon-wrapper {
    background: linear-gradient(135deg, #5856D6 0%, #AF52DE 100%);
    box-shadow: 0 4px 12px rgba(88, 86, 214, 0.4);
}

.nav-item[data-section="inventario"] .nav-icon-wrapper {
    background: linear-gradient(135deg, #007AFF 0%, #5AC8FA 100%);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4);
}

.nav-item[data-section="proveedores"] .nav-icon-wrapper {
    background: linear-gradient(135deg, #FF9500 0%, #FFCC00 100%);
    box-shadow: 0 4px 12px rgba(255, 149, 0, 0.4);
}

.nav-item[data-section="ventas"] .nav-icon-wrapper {
    background: linear-gradient(135deg, #34C759 0%, #30D158 100%);
    box-shadow: 0 4px 12px rgba(52, 199, 89, 0.4);
}

.nav-item[data-section="novedades"] .nav-icon-wrapper {
    background: linear-gradient(135deg, #FF2D55 0%, #FF6482 100%);
    box-shadow: 0 4px 12px rgba(255, 45, 85, 0.4);
}

.nav-item[data-section="configuracion"] .nav-icon-wrapper {
    background: linear-gradient(135deg, #8E8E93 0%, #636366 100%);
    box-shadow: 0 4px 12px rgba(142, 142, 147, 0.4);
}

.nav-item[data-section="usuarios"] .nav-icon-wrapper {
    background: linear-gradient(135deg, #00C6FB 0%, #005BEA 100%);
    box-shadow: 0 4px 12px rgba(0, 198, 251, 0.4);
}

/* Active state removes colored background */
.nav-item.active .nav-icon-wrapper {
    background: rgba(0, 0, 0, 0.06) !important;
    box-shadow: none !important;
}

.nav-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.nav-text {
    font-weight: 500;
}

/* User Profile Panel Container - Bottom Left Stack */
.user-panel {
    padding: 10px 15px 15px 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: transparent !important;
    /* border-top removed as requested to avoid limiting view */
    width: 100%;
    position: relative;
    flex-shrink: 0;
    /* Keep it fixed at bottom */
}

/* The actual clickable Pill */
.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.4) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 50px;
    cursor: pointer;
    transition: all var(--transition-normal);
    width: 100%;
    box-sizing: border-box;
}

.user-details {
    flex: 1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.12);
}

/* Store Selector Pop-up Menu */
.store-selector-menu {
    position: absolute;
    bottom: 85px;
    left: 10px;
    width: 320px;
    /* Much wider to fit names without cutting */
    background: var(--glass-bg) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 24px !important;
    padding: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(15px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.store-selector-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.store-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 4px 8px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.store-menu-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.btn-create-store {
    background: var(--apple-blue);
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-create-store:hover {
    background: #006add;
    transform: scale(1.05);
}

.store-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
}

.store-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--glass-bg) !important;
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border: 1px solid var(--glass-border) !important;
    border-radius: 20px !important;
    transition: all var(--transition-fast);
    cursor: pointer;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
}

.store-item:hover {
    background: rgba(255, 255, 255, 0.5);
}

.store-item.active {
    background: rgba(0, 122, 255, 0.1);
    border-color: rgba(0, 122, 255, 0.2);
}

.store-item.active:hover {
    background: rgba(0, 122, 255, 0.15);
}

.store-icon {
    font-size: 1rem;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #34C759 0%, #30D158 100%);
    border-radius: 50%;
    color: white;
    box-shadow: 0 4px 8px rgba(52, 199, 89, 0.3);
}

.store-name {
    flex: 1;
    font-size: 0.82rem;
    /* Reduced slightly to ensure it fits better */
    font-weight: 600;
    color: var(--text-primary);
    white-space: normal;
    word-break: break-word;
    line-height: 1.2;
    min-width: 110px;
}

.store-actions {
    display: flex;
    gap: 6px;
    margin-left: 8px;
    opacity: 1;
    transition: all var(--transition-normal);
}


.store-action-btn {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 1px solid var(--glass-border) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    cursor: pointer;
    background: var(--glass-bg) !important;
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    transition: all var(--transition-bounce);
    color: var(--text-primary);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

.store-action-btn:hover {
    transform: scale(1.2) translateY(-1px);
    color: white;
}

.store-action-btn.edit:hover {
    background: var(--gradient-blue);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4);
}

.store-action-btn.delete:hover {
    background: var(--gradient-danger);
    box-shadow: 0 4px 12px rgba(255, 59, 48, 0.4);
}

/* Generic Table Actions */
.table-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.table-action-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--glass-border) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    cursor: pointer;
    background: var(--glass-bg) !important;
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    transition: all var(--transition-bounce);
    color: var(--text-primary);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

.table-action-btn:hover {
    transform: scale(1.2) translateY(-2px);
    color: white;
}

.table-action-btn.edit:hover {
    background: var(--gradient-blue);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4);
}

.table-action-btn.delete:hover {
    background: var(--gradient-danger);
    box-shadow: 0 4px 12px rgba(255, 59, 48, 0.4);
}

.table-action-btn.pay:hover {
    background: var(--gradient-success);
    box-shadow: 0 4px 12px rgba(52, 199, 89, 0.4);
}

/* Replaced by refined definition above */

.user-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #34C759 0%, #30D158 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    color: white;
    box-shadow: 0 4px 10px rgba(52, 199, 89, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
}


/* Replaced by refined definition above */


.user-role {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Current time display in sidebar */
.sidebar-time {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    margin-left: auto;
    font-weight: 600;
}

/* ===================================
   MAIN CONTENT
   =================================== */

.main-content {
    flex: 1;
    margin-left: calc(var(--sidebar-width) + 40px);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

/* Modular Header Container */
.header-modules {
    position: fixed;
    top: 24px;
    /* Boundary check: Must stay strictly BETWEEN logo and right panel */
    left: calc(var(--sidebar-width) + 60px);
    right: calc(var(--sidebar-width) + 60px);
    display: flex;
    align-items: center;
    justify-content: center;
    /* Center content in the available gap */
    gap: 16px;
    z-index: 500;
    pointer-events: none;
    padding: 0;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
    pointer-events: auto;
}

/* Individual Glass Pill Module */
.header-module {
    background: var(--glass-bg) !important;
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border: 1px solid var(--glass-border) !important;
    border-radius: 50px;
    height: 44px;
    /* Unified compact height */
    display: flex;
    align-items: center;
    padding: 0 16px;
    /* Optimized padding */
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    transition: all var(--transition-normal), opacity 0.3s ease;
    cursor: pointer;
    pointer-events: auto;
}

.header-module:hover {
    background: rgba(255, 255, 255, 0.5);
    transform: scale(1.02);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.08);
}

.header-module.scrolled {
    opacity: 0.6;
    transform: scale(0.95);
    backdrop-filter: blur(10px);
}

.header-module.scrolled:hover {
    opacity: 1;
    transform: scale(1);
    backdrop-filter: blur(25px);
}

/* Specific Alignment */
.search-module {
    width: fit-content;
}

/* Remove scale animation from search module */
.search-module:hover {
    transform: none;
}

.title-module {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: fit-content;
    padding: 0 40px;
    z-index: 100;
    pointer-events: auto;
    /* Transition for opacity changes */
    transition: all var(--transition-normal), opacity 0.2s ease;
}

/* When scrolling, all header modules become more translucent */
.header-module.scrolled {
    opacity: 0.6;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(80px) saturate(160%);
    -webkit-backdrop-filter: blur(80px) saturate(160%);
    border-color: rgba(255, 255, 255, 0.2);
}

.header-module.scrolled:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.35);
}

/* Compact Date Module (placed next to search) */
.date-module {
    position: relative;
    width: fit-content;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Maintain centering ONLY for title-module if it exists, date is now relative */
.title-module:hover {
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.5);
}

.date-module:hover {
    background: rgba(255, 255, 255, 0.45);
    transform: none;
    /* No jumping, it's relative now */
}

/* Clean up internal elements styles */
.search-box input {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 8px 0 8px 30px;
    width: 250px;
}

.header-date {
    background: transparent;
    border: none;
    padding: 0;
}

.search-box {
    position: relative;
    width: 200px;
}

.search-box input {
    width: 100%;
    padding: 10px 16px 10px 36px;
    background: transparent;
    border: none;
    border-radius: 50px;
    color: var(--text-primary);
    font-size: 0.85rem;
    transition: all var(--transition-normal);
    pointer-events: auto;
}

.search-box input:focus {
    outline: none;
    background: transparent;
    box-shadow: none;
}

.search-box input::placeholder {
    color: var(--text-tertiary);
    font-weight: 500;
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    color: var(--text-tertiary);
    pointer-events: none;
}

.header-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 0;
    background: transparent;
    border-radius: 0;
    border: none;
    font-weight: 500;
}

.content-area {
    flex: 1;
    padding: 32px;
    padding-top: 100px;
    /* Reduced to give more air on normal screens */
    overflow-y: auto;
    scrollbar-gutter: stable;
    /* Prevent layout shift on Windows */
}

/* ===================================
   GLASS CARD COMPONENTS - Light Mode
   =================================== */

.glass-card {
    background: var(--glass-bg) !important;
    border: 1px solid var(--glass-border) !important;
    transform: translateZ(0);
    will-change: transform;
    border-radius: var(--border-radius-lg) !important;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
}

.glass-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.8) 50%,
            transparent);
    pointer-events: none;
}

.glass-card:hover {
    border-color: var(--glass-border-hover);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.glass-card-static {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg);
    position: relative;
    box-shadow: var(--shadow-sm);
}

.glass-card-static::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.6) 50%,
            transparent);
    pointer-events: none;
}

/* ===================================
   KPI CARDS - Floating Light Glass Panels
   =================================== */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.kpi-card {
    padding: 28px;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-bounce);
}

.kpi-card[style*="cursor: pointer"]:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--shadow-xl);
    background: var(--glass-bg-hover);
}

.kpi-card[style*="cursor: pointer"]:hover .kpi-icon {
    transform: scale(1.15) rotate(5deg);
}

.kpi-card[style*="cursor: pointer"]:hover .result-action {
    opacity: 1 !important;
    transform: translateX(5px);
}

.kpi-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-primary);
    opacity: 0.9;
}

.kpi-card.success::after {
    background: var(--gradient-success);
}

.kpi-card.success:hover {
    box-shadow: 0 20px 60px rgba(52, 199, 89, 0.25);
}

.kpi-card.warning::after {
    background: var(--gradient-warning);
}

.kpi-card.warning:hover {
    box-shadow: 0 20px 60px rgba(255, 149, 0, 0.25);
}

.kpi-card.info::after {
    background: var(--gradient-blue);
}

.kpi-card.info:hover {
    box-shadow: 0 20px 60px rgba(0, 122, 255, 0.25);
}

.kpi-card.purple::after {
    background: var(--gradient-purple);
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.kpi-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    background: var(--gradient-primary);
    border-radius: 50%;
    box-shadow: 0 10px 25px rgba(0, 122, 255, 0.25);
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: all var(--transition-normal);
}

.kpi-card.success .kpi-icon {
    background: var(--apple-green);
    background: linear-gradient(135deg, #34C759 0%, #30D158 100%);
    box-shadow: 0 10px 25px rgba(52, 199, 89, 0.3);
}

.kpi-card.info .kpi-icon {
    background: var(--apple-blue);
    background: linear-gradient(135deg, #007AFF 0%, #00BFFF 100%);
    box-shadow: 0 10px 25px rgba(0, 122, 255, 0.3);
}

.kpi-card.warning .kpi-icon {
    background: var(--apple-orange);
    background: linear-gradient(135deg, #FF9500 0%, #FFCC00 100%);
    box-shadow: 0 10px 25px rgba(255, 149, 0, 0.3);
}

.kpi-card.purple .kpi-icon {
    background: var(--apple-purple);
    background: linear-gradient(135deg, #5856D6 0%, #AF52DE 100%);
    box-shadow: 0 10px 25px rgba(88, 86, 214, 0.3);
}

.kpi-trend {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 20px;
    background: rgba(52, 199, 89, 0.12);
    color: var(--success);
}

.kpi-trend.down {
    background: rgba(255, 59, 48, 0.12);
    color: var(--danger);
}

.kpi-value {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.1;
}

.kpi-label {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===================================
   CHARTS SECTION
   =================================== */

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.chart-card {
    padding: 28px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.chart-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.chart-container {
    position: relative;
    height: 280px;
}

/* ===================================
   DATA TABLES - Light Apple Style
   =================================== */

.table-card {
    padding: 24px;
    overflow: hidden;
    border-radius: var(--border-radius-lg);
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.table-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.table-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: var(--border-radius-sm);
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 16px 18px;
    text-align: left;
}

.data-table th {
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.8px;
    background: rgba(0, 0, 0, 0.02);
    border-bottom: 1px solid var(--glass-border);
}

.data-table th:first-child {
    border-radius: var(--border-radius-sm) 0 0 0;
}

.data-table th:last-child {
    border-radius: 0 var(--border-radius-sm) 0 0;
}

.data-table tbody tr {
    transition: all var(--transition-fast);
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.data-table tbody tr:hover {
    background: rgba(0, 0, 0, 0.02);
}

.data-table td {
    color: var(--text-primary);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ===================================
   BUTTONS - iOS/tvOS Light Style
   =================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: 0.3s;
    text-decoration: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg,
            rgba(255, 255, 255, 0.2) 0%,
            transparent 50%);
    pointer-events: none;
}

.btn-primary {
    background: var(--gradient-blue);
    color: white;
    box-shadow: 0 4px 16px rgba(0, 122, 255, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-primary:hover {
    background: var(--gradient-blue);
    filter: brightness(1.1);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 24px rgba(0, 122, 255, 0.45);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: rgba(0, 0, 0, 0.08);
    border-color: var(--glass-border-hover);
}

.btn-success {
    background: var(--gradient-success);
    color: white;
    box-shadow: 0 4px 16px rgba(52, 199, 89, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-success:hover {
    filter: brightness(1.1);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 24px rgba(52, 199, 89, 0.45);
}

.btn-danger {
    background: var(--gradient-danger);
    color: white;
    box-shadow: 0 4px 16px rgba(255, 59, 48, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-danger:hover {
    filter: brightness(1.1);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 24px rgba(255, 59, 48, 0.45);
}

.btn-icon {
    padding: 10px;
    min-width: 44px;
    height: 44px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.8rem;
    border-radius: 10px;
}

/* ===================================
   FORM ELEMENTS - Apple Light Style
   =================================== */

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 14px 18px;
    background: white;
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    transition: all var(--transition-normal);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    background: white;
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-tertiary);
    font-weight: 500;
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 44px;
}

.form-select option {
    background: white;
    color: var(--text-primary);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* --- Custom Searchable Select (Apple Premium) --- */
.custom-select-wrapper {
    position: relative;
    user-select: none;
}

.custom-select-trigger {
    width: 100%;
    padding: 14px 18px;
    background: white;
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all var(--transition-normal);
}

.custom-select-trigger::after {
    content: "▼";
    font-size: 0.7rem;
    color: var(--text-tertiary);
    transition: transform var(--transition-normal);
}

.custom-select-wrapper.active .custom-select-trigger {
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.custom-select-wrapper.active .custom-select-trigger::after {
    transform: rotate(180deg);
}

.custom-select-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 2500;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-bounce);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.custom-select-wrapper.active .custom-select-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-select-search-area {
    padding: 12px;
    border-bottom: 1px solid var(--glass-border);
}

.custom-select-options {
    max-height: 250px;
    overflow-y: auto;
    padding: 6px;
}

.custom-select-option {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.custom-select-option:hover {
    background: rgba(0, 122, 255, 0.1);
    color: var(--apple-blue);
}

.custom-select-option.selected {
    background: var(--apple-blue);
    color: white;
}

.custom-select-option.hidden {
    display: none;
}

/* ===================================
   BADGES & STATUS - Light Mode
   =================================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-success {
    background: rgba(52, 199, 89, 0.25);
    color: #1e7d34;
    /* Darker Green */
    border: 1px solid rgba(52, 199, 89, 0.4);
    font-weight: 700;
}

.badge-warning {
    background: rgba(255, 149, 0, 0.25);
    color: #c67100;
    /* Darker Orange */
    border: 1px solid rgba(255, 149, 0, 0.4);
    font-weight: 700;
}

.badge-danger {
    background: rgba(255, 59, 48, 0.25);
    color: #b91d1d;
    /* Darker Red */
    border: 1px solid rgba(255, 59, 48, 0.4);
    font-weight: 700;
}

.badge-info {
    background: rgba(0, 122, 255, 0.25);
    color: #0056b3;
    /* Darker Blue */
    border: 1px solid rgba(0, 122, 255, 0.4);
    font-weight: 700;
}

/* HISTORICAL MODE */
.historical-badge {
    background: linear-gradient(135deg, rgba(88, 86, 214, 0.15), rgba(0, 122, 255, 0.15));
    color: #5856d6;
    border: 1px solid rgba(88, 86, 214, 0.2);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    animation: pulse-historical 2s infinite ease-in-out;
}

@keyframes pulse-historical {
    0% {
        transform: scale(1);
        opacity: 0.9;
    }

    50% {
        transform: scale(1.02);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 0.9;
    }
}

.historical-container {
    border: 2px dashed rgba(88, 86, 214, 0.2) !important;
    background: rgba(88, 86, 214, 0.02) !important;
}

.badge-closed {
    background: rgba(52, 199, 89, 0.15);
    color: #248a3d;
    border: 1px solid rgba(52, 199, 89, 0.2);
}

.historical-header-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: 10px;
}


/* ===================================
   ALERTS SECTION
   =================================== */

.alerts-card {
    padding: 24px;
}

.alert-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 320px;
    overflow-y: auto;
}

.alert-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: rgba(255, 59, 48, 0.06);
    border-radius: var(--border-radius-sm);
    border-left: 4px solid var(--danger);
    transition: all var(--transition-fast);
}

.alert-item:hover {
    background: rgba(255, 59, 48, 0.1);
    transform: translateX(4px);
}

.alert-item.warning {
    background: rgba(255, 149, 0, 0.06);
    border-left-color: var(--warning);
}

.alert-item.warning:hover {
    background: rgba(255, 149, 0, 0.1);
}

.alert-icon {
    font-size: 1.4rem;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--text-primary);
}

.alert-subtitle {
    font-size: 0.85rem;
    color: var(--text-tertiary);
}

.alert-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--danger);
}

.alert-item.warning .alert-value {
    color: var(--warning);
}

/* ===================================
   MODAL - Floating Light Glass Panel
   =================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

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

.modal {
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent container scroll, let body scroll */
    background: rgba(255, 255, 255, 0.95) !important;
    /* Thick Premium Glass */
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.4) !important;
    border-radius: 28px !important;
    /* Smoother corners */
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    transform: scale(0.95) translateY(20px);
    transition: all var(--transition-normal);
}

/* Stability lock: Keep the same thick glass background on hover */
.modal.glass-card:hover {
    background: rgba(255, 255, 255, 0.95) !important;
    transform: scale(1) translateY(0) !important;
}

body.dark-mode .modal.glass-card:hover {
    background: rgba(28, 28, 30, 0.98) !important;
    transform: scale(1) translateY(0) !important;
}

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

.modal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.8) 50%,
            transparent);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 28px;
    border-bottom: 1px solid var(--glass-border);
    flex-shrink: 0;
    /* Keep header fixed size */
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--apple-red);
    border-color: var(--apple-red);
    color: white;
    transform: scale(1.1);
}

.modal-body {
    padding: 28px;
    overflow-y: auto;
    /* Enable scroll ONLY here */
    flex: 1;
    /* Take up remaining space */
}

.modal-footer {
    display: flex;
    justify-content: center;
    /* Center buttons as requested */
    gap: 16px;
    /* Slightly larger gap for centered look */
    padding: 24px 28px;
    /* Slightly more breathing room */
    border-top: 1px solid var(--glass-border);
    flex-shrink: 0;
    background: inherit;
}

/* ===================================
   TOAST NOTIFICATIONS
   =================================== */

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 2000;
}

.toast {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    animation: toastSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    min-width: 300px;
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

.toast.warning {
    border-left: 4px solid var(--warning);
}

.toast-icon {
    font-size: 1.3rem;
}

.toast-message {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
    transition: color var(--transition-fast);
}

.toast-close:hover {
    color: var(--text-primary);
}

@keyframes toastSlideIn {
    from {
        transform: translateX(100%) scale(0.8);
        opacity: 0;
    }

    to {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

/* ===================================
   EMPTY STATE
   =================================== */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.6;
}

.empty-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-text {
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* ===================================
   SECTION HEADERS
   =================================== */

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

.title-capsule {
    background: rgba(255, 255, 255, 0.22);
    backdrop-filter: blur(40px) saturate(140%);
    -webkit-backdrop-filter: blur(40px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.35);
    padding: 12px 32px;
    border-radius: 100px;
    display: inline-flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05),
        inset 0 0 0 1px rgba(255, 255, 255, 0.2);
    transition: all var(--transition-bounce);
}

.title-capsule:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.08);
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
    color: var(--text-primary);
}

.title-capsule .text-muted {
    margin: 0;
    font-size: 0.9rem;
    padding-left: 16px;
    border-left: 1px solid rgba(0, 0, 0, 0.1);
    font-weight: 500;
}

body.dark-mode .title-capsule .text-muted {
    border-left-color: rgba(255, 255, 255, 0.2);
}

/* ===================================
   TABS - iOS Segmented Control Style
   =================================== */

.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: rgba(0, 0, 0, 0.04);
    padding: 4px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--glass-border);
    width: fit-content;
}

.tab-btn {
    padding: 10px 24px;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    background: white;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

/* ===================================
   VARIANT ITEMS
   =================================== */

.variant-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.variant-item {
    padding: 14px;
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.variant-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.variant-input {
    width: 100%;
    padding: 10px;
    background: white;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
}

.variant-input:focus {
    outline: none;
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

/* ===================================
   STATS MINI CARDS
   =================================== */

.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-mini {
    padding: 20px;
    text-align: center;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.stat-mini-value {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.stat-mini-label {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

/* ===================================
   RESPONSIVE DESIGN
   =================================== */

@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }

    .main-content {
        margin-left: 0;
    }



    .top-header {
        padding: 0 20px;
    }

    .search-box {
        display: none;
    }

    .content-area {
        padding: 20px;
    }

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

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

    .chart-container {
        height: 220px;
    }

    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 12px;
    }

    /* Title capsule should be full width */
    .section-header .title-capsule {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .section-header .title-capsule h2 {
        font-size: 1.3rem;
    }

    /* Controls row stacks vertically on mobile */
    .section-header>div:last-child {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
        width: 100%;
    }

    /* Local search takes full width */
    .local-search-container {
        width: 100% !important;
    }

    .local-search-container input {
        width: 100% !important;
        font-size: 16px !important;
        /* Prevents iOS zoom */
    }

    /* Glass capsule (Valor Total) */
    .section-header .glass-capsule {
        justify-content: center !important;
        padding: 10px 16px !important;
    }

    /* Buttons take full width */
    .section-header .btn {
        width: 100%;
        justify-content: center;
    }

    /* Historical indicator pills */
    .historical-pill {
        font-size: 0.75rem !important;
        padding: 4px 10px !important;
    }

    .table-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .stats-row {
        grid-template-columns: 1fr 1fr;
    }

    /* Table wrapper allows horizontal scroll */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table {
        min-width: 700px;
        font-size: 0.85rem;
    }

    .data-table th,
    .data-table td {
        padding: 8px 10px;
        white-space: nowrap;
    }
}

@media (max-width: 480px) {

    /* 1. Transform Sidebar into iOS Bottom Dock */
    .sidebar {
        position: fixed;
        bottom: 20px;
        /* Floating slightly above bottom */
        left: 10px;
        right: 10px;
        top: auto;
        transform: translateY(0);
        width: auto;
        height: 70px;
        min-height: auto;
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        background: rgba(255, 255, 255, 0.85) !important;
        /* Lighter glass */
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        border: 1px solid rgba(255, 255, 255, 0.4) !important;
        border-radius: 24px !important;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
        padding: 0 10px;
        z-index: 9999;
        overflow: hidden;
    }

    /* Dark Mode Dock */
    body.dark-mode .sidebar {
        background: rgba(30, 30, 30, 0.85) !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
    }

    /* Hide Desktop-only elements in dock */
    .nav-category,
    .sidebar-header,
    .sidebar-footer {
        display: none !important;
    }

    /* Icons larger, text smaller */
    .nav-item {
        flex-direction: column;
        justify-content: center;
        padding: 8px;
        margin: 0;
        background: transparent !important;
        box-shadow: none !important;
        border: none !important;
        gap: 4px;
        border-radius: 12px;
    }

    .nav-item.active {
        background: rgba(0, 122, 255, 0.1) !important;
    }

    .nav-text {
        font-size: 0.6rem;
        display: block !important;
        /* Force show labels if needed, or hide for cleaner look */
        opacity: 0.8;
    }

    .nav-icon {
        font-size: 1.4rem;
    }

    /* 2. Header Cleanup & Branding */
    .top-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: rgba(255, 255, 255, 0.85) !important;
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
        z-index: 2000;
        /* Higher than content */
        padding: 0 15px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    }

    body.dark-mode .top-header {
        background: rgba(20, 20, 25, 0.85) !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    /* New Mobile Logo */
    .top-header::before {
        content: '👶 DeividKids';
        font-weight: 800;
        font-size: 1.1rem;
        color: var(--text-primary);
        position: absolute;
        left: 20px;
        letter-spacing: -0.5px;
    }

    .right-pill-panel {
        display: none !important;
    }

    /* Hide redundant desktop toggles */
    .menu-toggle,
    .search-box {
        display: none !important;
    }

    /* 3. Content Area Breathability & Overflow Fix */
    .main-content {
        width: 100vw;
        max-width: 100%;
        overflow-x: hidden;
        margin: 0;
        padding: 0;
    }

    .content-area {
        padding: 85px 15px 100px 15px;
        /* Top padding for Header + Gap, Bottom for Dock */
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
    }

    /* 4. Card & Title Fixes */
    .title-capsule {
        background: transparent;
        border: none;
        box-shadow: none;
        padding: 0;
    }

    .section-title {
        font-size: 1.5rem;
        margin-bottom: 5px;
    }

    .kpi-grid {
        grid-template-columns: 1fr 1fr;
        /* 2 cols for small widgets */
        gap: 12px;
    }

    .kpi-card {
        padding: 16px;
    }

    .kpi-value {
        font-size: 1.6rem;
    }

    /* Table Horizontal Scroll */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 16px;
    }
}

/* ===================================
   UTILITY CLASSES
   =================================== */

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

.text-right {
    text-align: right;
}

.text-success {
    color: var(--success);
}

.text-warning {
    color: var(--warning);
}

.text-danger {
    color: var(--danger);
}

.text-muted {
    color: var(--text-muted);
}

.font-bold {
    font-weight: 700;
}

.mb-0 {
    margin-bottom: 0;
}

.mb-1 {
    margin-bottom: 8px;
}

.mb-2 {
    margin-bottom: 16px;
}

.mb-3 {
    margin-bottom: 24px;
}

.mt-1 {
    margin-top: 8px;
}

.mt-2 {
    margin-top: 16px;
}

.mt-3 {
    margin-top: 24px;
}

.hidden {
    display: none !important;
}

/* ===================================
   SPECIAL EFFECTS
   =================================== */

/* Shimmer effect for loading states */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.shimmer {
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(255, 255, 255, 0.4) 50%,
            transparent 100%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

/* Pulse animation for important elements */
@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* Glow effect on hover - lighter for light mode */
.glow-blue:hover {
    box-shadow: var(--shadow-glow-blue);
}

.glow-purple:hover {
    box-shadow: var(--shadow-glow-purple);
}

.glow-pink:hover {
    box-shadow: var(--shadow-glow-pink);
}

/* Theme Toggle Button - Fixed Bottom Right */
.theme-toggle-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    transition: all var(--transition-bounce);
    font-size: 1.8rem;
    box-shadow: var(--shadow-lg);
}

.theme-toggle-btn:hover {
    transform: rotate(20deg) scale(1.15);
    background: var(--glass-bg-hover);
    box-shadow: var(--shadow-xl);
}

/* Loading Overlay */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loader-overlay.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loader-visual {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.premium-loader-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.loader-base {
    fill: none;
    stroke: var(--glass-border);
    stroke-width: 4px;
}

.loader-progress {
    fill: none;
    stroke: var(--apple-blue);
    stroke-width: 6px;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 283;
    animation: progressAnimate 2.5s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

.loader-brand {
    position: absolute;
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -2px;
    color: var(--apple-blue);
    animation: brandPulse 1.5s ease-in-out infinite;
}

@keyframes progressAnimate {
    0% {
        stroke-dashoffset: 283;
    }

    50% {
        stroke-dashoffset: 70;
        transform: rotate(0);
    }

    100% {
        stroke-dashoffset: 283;
        transform: rotate(360deg);
    }
}

@keyframes brandPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.1);
        opacity: 1;
    }
}

.loader-text {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-secondary);
    margin-top: 10px;
    background: var(--gradient-primary);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    opacity: 0.8;
}

.loader-bar-container {
    width: 200px;
    height: 4px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

body.dark-mode .loader-bar-container {
    background: rgba(255, 255, 255, 0.1);
}

.loader-bar {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--gradient-primary);
    animation: loaderProgress 2s infinite cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes loaderProgress {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

.loader-text {
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Report Section Specifics */
.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-top: 24px;
}

.wide-card {
    grid-column: 1 / -1;
}

.nav-item[data-section="reportes"] .nav-icon-wrapper {
    background: linear-gradient(135deg, #FF2D55 0%, #AF52DE 100%);
    box-shadow: 0 4px 12px rgba(255, 45, 85, 0.3);
}

body.dark-mode .nav-item.active {
    background: rgba(255, 255, 255, 0.1);
}

body.dark-mode .glass-card {
    background: rgba(30, 30, 35, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode .glass-card:hover {
    background: rgba(45, 45, 52, 0.85);
}

body.dark-mode .glass-card-static {
    background: rgba(25, 25, 30, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

body.dark-mode .kpi-label {
    color: rgba(255, 255, 255, 0.65);
}

body.dark-mode .kpi-value {
    color: #ffffff;
}

body.dark-mode .chart-title {
    color: #ffffff;
}

body.dark-mode .sidebar {
    background: rgba(15, 15, 20, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

body.dark-mode .nav-item .nav-text {
    color: var(--text-secondary);
}

body.dark-mode .nav-item.active {
    background: rgba(255, 255, 255, 0.05);
    border-left: 3px solid var(--apple-blue);
    box-shadow: inset 5px 0 15px rgba(0, 122, 255, 0.1);
}

body.dark-mode .nav-item.active .nav-text {
    color: #ffffff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

body.dark-mode .nav-item:hover .nav-text {
    color: #ffffff;
}

body.dark-mode .brand-logo {
    background: rgba(15, 15, 20, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

body.dark-mode .logo-text {
    color: #ffffff;
}

body.dark-mode .user-info {
    background: rgba(25, 25, 30, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

body.dark-mode .user-name {
    color: #ffffff;
}

body.dark-mode .user-role {
    color: #ffffff;
}

body.dark-mode .user-avatar {
    background: var(--gradient-success);
    color: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3), 0 0 15px rgba(52, 199, 89, 0.3);
}

body.dark-mode .store-selector-menu {
    background: rgba(15, 15, 20, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
}

body.dark-mode .store-menu-title {
    color: rgba(255, 255, 255, 0.5);
}

body.dark-mode .store-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

body.dark-mode .store-name {
    color: #ffffff;
}

body.dark-mode .nav-category {
    color: rgba(255, 255, 255, 0.4);
}

body.dark-mode .data-table th {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-tertiary);
}

body.dark-mode .data-table tbody tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

body.dark-mode .data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

body.dark-mode .modal {
    background: rgba(28, 28, 30, 0.98) !important;
    backdrop-filter: blur(40px) saturate(150%);
    -webkit-backdrop-filter: blur(40px) saturate(150%);
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
}

body.dark-mode .modal-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode .modal-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode .form-input,
body.dark-mode .form-select,
body.dark-mode .form-textarea {
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #ffffff;
}

body.dark-mode .form-input:focus,
body.dark-mode .form-select:focus,
body.dark-mode .form-textarea:focus {
    border-color: var(--apple-blue);
    background: #000000;
}

body.dark-mode .form-select option {
    background: #1a1a1c;
    color: #ffffff;
}

body.dark-mode .tabs {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode .tab-btn.active {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

body.dark-mode .tab-btn {
    color: rgba(255, 255, 255, 0.6);
}

body.dark-mode .tab-btn:hover {
    color: #ffffff;
}

body.dark-mode .stat-mini {
    background: rgba(30, 30, 35, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

body.dark-mode .variant-item {
    background: rgba(255, 255, 255, 0.03);
}

body.dark-mode .variant-input {
    background: #000000;
    border-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

body.dark-mode .btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

body.dark-mode .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
}

body.dark-mode .toast {
    background: #1a1a1c;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

body.dark-mode .alert-item {
    background: rgba(255, 59, 48, 0.1);
}

body.dark-mode .alert-item.warning {
    background: rgba(255, 149, 0, 0.1);
}

body.dark-mode .search-box input {
    color: #ffffff;
}

body.dark-mode .search-box input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* Header Modules Dark Mode Optimization */
body.dark-mode .header-module {
    background: rgba(30, 30, 35, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

body.dark-mode .header-module:hover {
    background: rgba(45, 45, 52, 0.9);
}

body.dark-mode .page-title {
    color: #ffffff;
}

body.dark-mode .header-date {
    color: rgba(255, 255, 255, 0.85);
}

body.dark-mode .search-icon {
    color: rgba(255, 255, 255, 0.6);
}

/* Icon Backgrounds in Dark Mode - Only for buttons that were dark (grey/black) */
body.dark-mode .table-action-btn,
body.dark-mode .store-action-btn {
    background: #ffffff !important;
    background-image: none !important;
    color: #1a1a1c !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
}

body.dark-mode .table-action-btn:hover,
body.dark-mode .store-action-btn:hover {
    background: #f0f0f5 !important;
    transform: scale(1.1) translateY(-2px);
}

/* General Search Results Styles */
.search-results-container {
    display: flex;
    flex-direction: column;
    gap: 32px;
    margin-top: 20px;
    animation: fadeIn var(--transition-normal);
}

/* Global Search Results */
.search-results-container {
    display: flex;
    flex-direction: column;
    gap: 32px;
    margin-top: 24px;
    animation: fadeIn 0.5s ease-out;
}

.search-category-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.search-category-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    padding-left: 12px;
    border-left: 4px solid var(--apple-blue);
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.result-pill {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    cursor: pointer;
    background: var(--bg-secondary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--border-radius);
    border: 1px solid var(--glass-border);
    transition: all var(--transition-bounce);
}

.result-pill:hover {
    transform: translateY(-4px) scale(1.02);
    background: var(--glass-bg-hover);
    border-color: var(--apple-blue);
    box-shadow: var(--shadow-md);
}

.result-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.result-info {
    flex: 1;
}

.result-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.result-meta {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.result-date {
    font-size: 0.75rem;
    color: var(--apple-blue);
    font-weight: 600;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Range Selector Pill - Modern Apple Style */
.range-pill {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 6px 20px 6px 6px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    cursor: pointer;
    transition: all var(--transition-bounce);
    box-shadow: var(--shadow-sm);
    margin: 10px auto;
}

.range-pill:hover {
    transform: translateY(-2px) scale(1.02);
    background: var(--glass-bg-hover);
    box-shadow: var(--shadow-md);
}

.range-icon-circle {
    width: 36px;
    height: 36px;
    background: var(--gradient-blue);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: white;
    box-shadow: 0 4px 10px rgba(0, 122, 255, 0.3);
}

.range-pill-text {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.92rem;
    font-weight: 500;
}

.range-pill-label {
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.range-pill-divider {
    color: var(--text-muted);
    font-weight: 300;
    font-size: 1.2rem;
    opacity: 0.5;
}

.range-pill-value {
    color: var(--text-secondary);
}

.chart-header.centered {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding-bottom: 20px;
}

.result-action {
    color: var(--apple-blue);
    font-size: 1.2rem;
    opacity: 0.4;
    transition: all var(--transition-fast);
}

.result-pill:hover .result-action {
    opacity: 1;
    transform: translateX(4px);
}

/* Dark Mode Overrides for Search */
body.dark-mode .result-pill {
    background: rgba(255, 255, 255, 0.05);
}

body.dark-mode .result-pill:hover {
    background: rgba(255, 255, 255, 0.12);
}

body.dark-mode .result-icon {
    background: #ffffff !important;
    color: #1a1a1c !important;
}

body.dark-mode .search-category-title {
    color: white;
}

/* ===================================
   LOCAL MODULE SEARCH
   =================================== */
.local-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    padding: 6px 12px;
    width: 250px;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
    margin-right: 12px;
    /* Espacio antes del botón */
}

.local-search-wrapper:hover,
.local-search-wrapper:focus-within {
    background: rgba(255, 255, 255, 0.6);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
    width: 280px;
}

.local-search-icon {
    font-size: 0.9rem;
    opacity: 0.5;
    margin-right: 8px;
    pointer-events: none;
}

.local-search-input {
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-primary);
    width: 100%;
    outline: none;
}

.local-search-input::placeholder {
    color: var(--text-tertiary);
}

/* Dark Mode for Local Search */
body.dark-mode .local-search-wrapper {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
}

body.dark-mode .local-search-wrapper:hover,
body.dark-mode .local-search-wrapper:focus-within {
    background: rgba(255, 255, 255, 0.15);
}

body.dark-mode .local-search-input {
    color: white;
}

/* Text Utility Classes */
.text-primary {
    color: var(--text-primary);
}

.text-secondary {
    color: var(--text-secondary);
}

.text-tertiary {
    color: var(--text-tertiary);
}

.text-muted {
    color: var(--text-muted);
}

.text-danger {
    color: var(--apple-red);
}

.text-success {
    color: var(--apple-green);
}

.text-info {
    color: var(--apple-blue);
}

/* ===================================
   LOGIN & REGISTRATION
   =================================== */

.auth-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    background: transparent;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 40px;
    text-align: center;
    animation: fadeInScale 0.6s var(--transition-bounce);
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.auth-logo {
    font-size: 2.5rem;
    margin-bottom: 30px;
    display: inline-block;
}

.auth-header {
    margin-bottom: 30px;
}

.auth-title {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 8px;
    letter-spacing: -0.03em;
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-pill {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 14px 20px;
    border-radius: 16px;
    font-size: 1rem;
    transition: all 0.3s ease;
    width: 100%;
    color: var(--text-primary);
}

body.dark-mode .input-pill {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.input-pill:focus {
    outline: none;
    border-color: var(--apple-blue);
    background: rgba(0, 122, 255, 0.05);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
}

.auth-btn {
    padding: 14px;
    font-size: 1rem;
    font-weight: 600;
}

.auth-footer {
    margin-top: 30px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.auth-link {
    color: var(--apple-blue);
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.auth-link:hover {
    text-decoration: underline;
}

.login-hint {
    margin-top: 15px;
    padding: 12px;
    background: rgba(255, 149, 0, 0.1);
    border-radius: 12px;
    color: #df9000;
    font-size: 0.85rem;
    display: none;
}

body.dark-mode .login-hint {
    background: rgba(255, 149, 0, 0.15);
    color: #ffcc00;
}

/* Register Capsule Style */
.register-capsule {
    margin-top: 24px;
    padding: 24px;
    border-top: 1px solid var(--glass-border);
}

.register-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Auth Mode Overrides */
body.auth-mode .sidebar,
body.auth-mode .user-panel,
body.auth-mode .main-content,
body.auth-mode .brand-logo,
body.auth-mode .theme-toggle-btn {
    display: none !important;
}

body:not(.auth-mode) #authContainer {
    display: none !important;
}

/* ===================================
   LOGO PANEL (matches user-panel pattern)
   =================================== */

.logo-panel {
    padding: 0 15px 15px 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* The clickable Logo Pill */
.brand-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 8px;
    background: transparent;
    border: none;
    transition: all var(--transition-normal);
    cursor: pointer;
    width: 100%;
}

.brand-logo:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.12);
}

.brand-logo .logo-icon {
    width: 40px;
    height: 40px;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #34C759 0%, #30D158 100%);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(52, 199, 89, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
}

.logo-text {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #1d1d1f;
}

/* Logo Selector Menu (appears below logo) */
.logo-selector-menu {
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    width: 200px;
    background: var(--glass-bg) !important;
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border: 1px solid var(--glass-border) !important;
    border-radius: 20px !important;
    padding: 12px;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.logo-selector-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.logo-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 4px 8px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.logo-menu-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.logo-menu-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.3);
}

.logo-user-avatar {
    font-size: 1.2rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #007AFF 0%, #5AC8FA 100%);
    border-radius: 50%;
    box-shadow: 0 4px 8px rgba(0, 122, 255, 0.3);
}

.logo-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.logo-menu-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
    margin: 4px 0;
}

.logo-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

.logo-menu-item:hover {
    background: rgba(255, 255, 255, 0.5);
}

.logo-menu-item.logout {
    color: #ff3b30;
}

.logo-menu-item.logout:hover {
    background: rgba(255, 59, 48, 0.1);
}

/* ===================================
   RIGHT PILL PANEL (Top Right Mirror)
   =================================== */

.right-pill-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 600;
    display: none;
    /* Hidden by default, shown via JS on login */
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    pointer-events: none;
    width: var(--sidebar-width);
}

.interaction-pill {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 8px 16px;
    /* Maintain original interaction pill prominence */
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(60px) saturate(140%);
    -webkit-backdrop-filter: blur(60px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 50px;
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.1),
        0 8px 24px rgba(0, 0, 0, 0.05),
        inset 0 0 0 1px rgba(255, 255, 255, 0.3);
    transition: all var(--transition-normal);
    cursor: pointer;
    pointer-events: auto;
    width: var(--sidebar-width);
    box-sizing: border-box;
}

.interaction-pill:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.12);
}

.user-pill-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    overflow: hidden;
}

.pill-avatar {
    width: 40px;
    /* Restored original size */
    height: 40px;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-blue);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3), 0 0 15px rgba(0, 122, 255, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.15);
    color: white;
    flex-shrink: 0;
}

.pill-user-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: #1d1d1f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-align: right;
}

.pill-user-status {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--apple-green);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pill-dropdown-menu {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 200px;
    background: var(--glass-bg) !important;
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border: 1px solid var(--glass-border) !important;
    border-radius: 20px !important;
    padding: 8px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.pill-dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.menu-header {
    padding: 8px 12px;
}

.menu-title {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.menu-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.05);
    margin: 4px 0;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: transparent;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.menu-item:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-primary);
}

.menu-item.logout {
    color: var(--apple-red);
}

.menu-item.logout:hover {
    background: rgba(255, 59, 48, 0.08);
}

.logo-menu-item.save {
    color: #007AFF;
}

.logo-menu-item.save:hover {
    background: rgba(0, 122, 255, 0.1);
}

/* Dark mode adjustments */
body.dark-mode .logo-panel .brand-logo,
body.dark-mode .logo-selector-menu {
    background: rgba(30, 30, 35, 0.8);
    border-color: rgba(255, 255, 255, 0.12);
}

body.dark-mode .logo-text {
    color: #ffffff;
}

body.dark-mode .logo-menu-user {
    background: rgba(255, 255, 255, 0.1);
}

body.dark-mode .floating-username {
    color: #ffffff;
}

body.dark-mode .user-panel .store-name,
body.dark-mode .store-selector-menu .store-name {
    color: #ffffff;
}

/* Mini Module Navigation (Admin Inspection) */
.mini-module-nav {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 12px;
    margin-bottom: 25px;
    border-radius: 20px;
    overflow-x: auto;
    scrollbar-width: none;
    background: rgba(255, 255, 255, 0.4);
}

.mini-module-nav::-webkit-scrollbar {
    display: none;
}

.mini-module-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 85px;
    color: var(--text-primary);
}

.mini-module-btn:hover {
    background: rgba(255, 255, 255, 0.8);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.mini-module-btn.active {
    background: linear-gradient(135deg, #007AFF 0%, #5856D6 100%);
    box-shadow: 0 8px 20px rgba(0, 122, 255, 0.3);
    transform: scale(1.05);
}

.mini-module-icon {
    font-size: 1.5rem;
}

.mini-module-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.mini-module-btn.active .mini-module-label {
    color: #ffffff;
}

.mini-module-btn:not(.active) .mini-module-label {
    color: var(--text-secondary);
}

/* Dark Mode for Mini Nav */
body.dark-mode .mini-module-nav {
    background: rgba(30, 30, 35, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode .mini-module-btn:not(.active) {
    background: rgba(255, 255, 255, 0.05);
}

body.dark-mode .mini-module-btn:not(.active):hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ===================================
   ADMIN USERS SECTION
   =================================== */

/* Admin nav item special style */
.nav-item[data-section="usuarios"] .nav-icon-wrapper {
    background: linear-gradient(135deg, #FF9500 0%, #FF2D55 100%);
    box-shadow: 0 4px 12px rgba(255, 149, 0, 0.4);
}

/* Users Grid */
.users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

/* User Card */
.user-card {
    background: var(--glass-bg);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 24px;
    transition: all 0.3s ease;
}

.user-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--glass-border-hover);
}

.user-card-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.user-card-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.user-card-avatar.role-admin {
    background: linear-gradient(135deg, #FF9500 0%, #FF2D55 100%);
    box-shadow: 0 4px 12px rgba(255, 149, 0, 0.4);
}

.user-card-avatar.role-user {
    background: linear-gradient(135deg, #007AFF 0%, #5AC8FA 100%);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4);
}

.user-card-info {
    flex: 1;
}

.user-card-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.user-card-role {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    display: inline-block;
}

.user-card-role.admin {
    background: rgba(255, 149, 0, 0.15);
    color: #FF9500;
}

.user-card-role.user {
    background: rgba(0, 122, 255, 0.15);
    color: #007AFF;
}

.user-card-hint {
    margin: 16px 0;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.user-card-hint strong {
    color: var(--text-primary);
}

.user-card-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.user-card-actions .btn {
    flex: 1;
    padding: 10px 16px;
    font-size: 0.85rem;
}

.btn-change-password {
    background: rgba(0, 122, 255, 0.15);
    color: #007AFF;
    border: 1px solid rgba(0, 122, 255, 0.3);
}

.btn-change-password:hover {
    background: rgba(0, 122, 255, 0.25);
}

.btn-delete-user {
    background: rgba(255, 59, 48, 0.15);
    color: #FF3B30;
    border: 1px solid rgba(255, 59, 48, 0.3);
}

.btn-delete-user:hover {
    background: rgba(255, 59, 48, 0.25);
}

/* Users Stats */
.users-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 24px;
}

.users-stat-card {
    flex: 1;
    background: var(--glass-bg);
    backdrop-filter: blur(40px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
}

.users-stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.users-stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Floating Username - Located in empty space between sidebar and user panel */
.floating-username {
    position: fixed;
    bottom: 95px;
    /* Altura suficiente para estar sobre el panel */
    left: 20px;
    width: var(--sidebar-width);
    text-align: center;

    font-size: 0.95rem;
    font-weight: 700;
    color: #000000;
    /* Color negro fuerte */
    text-transform: uppercase;
    letter-spacing: 0.05em;

    pointer-events: none;
    opacity: 0.8;
    z-index: 500;

    /* Sin fondo para que parezca una etiqueta en el espacio vacío */
    background: transparent;
    padding: 0;
    backdrop-filter: none;
    text-shadow: none;
    transition: opacity 0.3s ease;
    /* Smooth transition */
}

/* Hide username when menu is open */
.user-panel:has(.store-selector-menu.active) .floating-username {
    opacity: 0;
    pointer-events: none;
}

/* ===================================
   RESPONSIVE & LAYOUT FIXES
   =================================== */

/* Tablet & Smaller Desktop Adjustments */
@media (max-width: 1200px) {
    :root {
        --sidebar-width: 220px;
    }

    .main-content {
        margin-left: calc(var(--sidebar-width) + 40px);
    }

    /* Small height adjustments for Windows Chrome / Low Res Screens */
    @media (max-height: 800px) {
        .logo-panel {
            padding: 15px 20px 10px !important;
        }

        .brand-logo {
            gap: 10px !important;
        }

        .logo-text {
            font-size: 1.1rem !important;
        }

        .nav-item {
            padding: 8px 12px !important;
            font-size: 0.82rem !important;
            gap: 10px !important;
        }

        .nav-icon-wrapper {
            width: 28px !important;
            height: 28px !important;
            font-size: 0.9rem !important;
        }

        .user-panel {
            padding: 8px 15px 12px !important;
            gap: 8px !important;
        }
    }
}

/* Vertical Screen Height Fixes (Prevent Sidebar Overlapping User Panel) */
@media (max-height: 850px) {
    .sidebar {
        top: 20px;
        transform: none;
        /* Remove center centering */
        bottom: 100px;
        /* Leave space for User Panel at bottom */
        height: auto;
        overflow-y: auto;
        /* Allow scrolling inside sidebar if menu is long */
    }

    .user-panel {
        bottom: 15px;
        /* Ensure it stays pinned at bottom */
    }
}

/* Mobile / Small Tablet (Vertical Layout) */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
    }

    body {
        display: flex !important;
        flex-direction: column !important;
        overflow-x: hidden;
        max-width: 100vw;
        background: #f5f5f7 !important;
        margin: 0 !important;
        width: 100% !important;
    }

    /* Total cleanup for mobile performance and space */
    /* Total cleanup for mobile performance and space */
    .floating-username,
    .logo-panel:not(.has-alert),
    #logoPanel:not(.has-alert),
    .brand-logo,
    #brandLogo,
    .date-module {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
        width: 0 !important;
        height: 0 !important;
        position: absolute !important;
        z-index: -1 !important;
    }

    #logoPanel.has-alert {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: fixed !important;
        top: 10px !important;
        left: 10px !important;
        z-index: 9999 !important;
        width: calc(100% - 20px) !important;
        height: auto !important;
        pointer-events: auto !important;
    }

    #logoPanel.has-alert .brand-logo {
        display: none !important;
        /* Keep logo hidden on mobile, only show alert */
    }

    #logoPanel.has-alert .membership-alert-pill {
        margin-top: 5px !important;
        width: 100% !important;
        background: rgba(255, 149, 0, 0.9) !important;
        /* More solid on mobile */
        color: white !important;
    }

    .user-panel {
        display: none !important;
        /* Hidden by default */
        /* Will be overriden by .active class logic below if needed, 
           but actually we will use a specific mobile selector for it */
    }

    .user-panel.mobile-active {
        display: flex !important;
        position: fixed;
        bottom: 70px;
        /* Above nav bar */
        left: 10px;
        right: 10px;
        width: auto;
        z-index: 2000;
        animation: slideUpPanel 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }

    @keyframes slideUpPanel {
        from {
            transform: translateY(20px);
            opacity: 0;
        }

        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    #mainContent {
        background: #ffffff !important;
        margin: 0 !important;
        width: 100% !important;
    }

    /* Sidebar Drawer Transformation */
    .sidebar {
        width: 280px !important;
        /* Drawer width */
        height: 100vh !important;
        position: fixed !important;
        top: 0 !important;
        left: -300px !important;
        /* Start hidden off-screen */
        bottom: auto !important;
        display: flex !important;
        flex-direction: column !important;
        background: rgba(255, 255, 255, 0.98) !important;
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        z-index: 10000 !important;
        box-shadow: 5px 0 25px rgba(0, 0, 0, 0.15) !important;
        border-right: 1px solid rgba(0, 0, 0, 0.1) !important;
        border-top: none !important;
        padding-top: calc(env(safe-area-inset-top) + 20px) !important;
        padding-bottom: env(safe-area-inset-bottom);
        transition: left 0.35s cubic-bezier(0.16, 1, 0.3, 1) !important;
    }

    .sidebar.drawer-open {
        left: 0 !important;
    }

    .nav-menu {
        flex-direction: column !important;
        width: 100%;
        height: auto;
        padding: 20px;
        justify-content: flex-start;
        align-items: flex-start;
        gap: 15px;
    }

    .nav-item {
        flex-direction: row !important;
        gap: 16px !important;
        padding: 12px 16px !important;
        width: 100% !important;
        justify-content: flex-start !important;
        border-radius: 14px !important;
        min-height: 50px;
    }

    .nav-item.active {
        background: rgba(0, 122, 255, 0.1) !important;
        color: var(--apple-blue);
    }

    .nav-icon-wrapper {
        font-size: 1.4rem !important;
        /* Larger icons for drawer */
        margin-bottom: 0;
    }

    .nav-text {
        font-size: 1rem !important;
        font-weight: 600 !important;
        display: block !important;
        /* Ensure text is visible */
        opacity: 1 !important;
    }

    .nav-category {
        display: block !important;
        font-size: 0.75rem;
        font-weight: 700;
        text-transform: uppercase;
        color: var(--text-tertiary);
        margin: 20px 0 10px 16px;
        letter-spacing: 0.05em;
    }

    /* Hide "Menu" button inside drawer, we only need it to trigger toggle */
    #navMobileMore {
        display: none !important;
    }

    /* Header adjustments to show Hamburger */
    .header-modules {
        justify-content: space-between !important;
        /* Allow toggle on left, title center/right */
        padding-left: 20px !important;
    }
}

/* ===================================
   USERS MANAGEMENT SPECIFIC STYLES
   =================================== */

.role-badge {
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
}

.role-superadmin {
    background: rgba(88, 86, 214, 0.4);
    color: #403eba;
    /* Much deeper */
    border-color: rgba(88, 86, 214, 0.6);
}

.role-admin {
    background: rgba(0, 122, 255, 0.45);
    color: #006ce6;
    /* Much deeper */
    border-color: rgba(0, 122, 255, 0.65);
}

.role-user {
    background: rgba(255, 45, 85, 0.4);
    color: #e60039;
    /* Much deeper */
    border-color: rgba(255, 45, 85, 0.6);
}

.user-password-code {
    font-family: 'SF Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    background: rgba(0, 122, 255, 0.1);
    /* Subtle Blue background */
    padding: 5px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #121213;
    /* Deep black */
    border: 1px solid rgba(0, 122, 255, 0.3);
    /* Defined border */
    transition: all var(--transition-fast);
    font-weight: 700;
}

.user-password-code:hover {
    background: rgba(0, 0, 255, 0.03);
    border-color: rgba(0, 122, 255, 0.2);
}

.user-table-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.9rem;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 2px solid white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.avatar-blue {
    background: linear-gradient(135deg, #007AFF 0%, #00BFFF 100%);
}

.avatar-purple {
    background: linear-gradient(135deg, #5856D6 0%, #AF52DE 100%);
}

.avatar-pink {
    background: linear-gradient(135deg, #FF2D55 0%, #FF6482 100%);
}

.avatar-green {
    background: linear-gradient(135deg, #34C759 0%, #30D158 100%);
}

.avatar-orange {
    background: linear-gradient(135deg, #FF9500 0%, #FFCC00 100%);
}

.usuarios-section .data-table tr:hover {
    background: rgba(0, 122, 255, 0.03);
    transform: scale(1.002);
}

.usuarios-section .section-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 600;
    /* Mas fuerte */
}

/* Configuration Modal - List Items */
.config-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: var(--border-radius-sm);
    border-left: 4px solid var(--apple-blue);
    margin-bottom: 8px;
    transition: all var(--transition-fast);
}

.config-list-item:hover {
    background: rgba(0, 122, 255, 0.08);
    /* Light Blue Tint */
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.config-list-item .item-text {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
}

body.dark-mode .config-list-item {
    background: rgba(255, 255, 255, 0.05);
    border-left-color: var(--apple-blue-dark);
}

body.dark-mode .config-list-item:hover {
    background: rgba(0, 122, 255, 0.15);
}

body.dark-mode .config-list-item .item-text {
    color: #ffffff;
}

/* Section Persistence Styles */
.section-container {
    display: none;
    width: 100%;
    animation: fadeInSection 0.4s ease-out;
}

.section-container.active {
    display: block;
}

@keyframes fadeInSection {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Notification Badges */
.nav-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--apple-red);
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--glass-bg);
    animation: badgePop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10;
}

.nav-badge.dot {
    width: 10px;
    height: 10px;
    min-width: 10px;
    top: 0;
    right: 0;
}

@keyframes badgePop {
    0% {
        transform: scale(0);
    }

    100% {
        transform: scale(1);
    }
}

/* Real-time Pulse for Live Cards */
.live-pulse {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #34C759;
    border-radius: 50%;
    margin-right: 8px;
    box-shadow: 0 0 0 rgba(52, 199, 89, 0.4);
    animation: livePulseAni 2s infinite;
}

@keyframes livePulseAni {
    0% {
        box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(52, 199, 89, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(52, 199, 89, 0);
    }
}

/* Dashboard Insights Cards */
.insight-card {
    border-left: 4px solid var(--apple-blue);
    background: linear-gradient(to right, rgba(0, 122, 255, 0.05), transparent);
}

.insight-card.warning {
    border-left-color: var(--apple-orange);
    background: linear-gradient(to right, rgba(255, 149, 0, 0.05), transparent);
}

.insight-velocity {
    font-weight: 800;
    color: var(--apple-blue);
    margin: 5px 0;
}

/* Estilos para el pie de página de autenticación */
.auth-footer {
    position: fixed;
    bottom: 30px;
    width: 100%;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0.8;
    z-index: 10;
    letter-spacing: 0.5px;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    pointer-events: none;
    /* Allows clicking through if needed */
}

/* Dark mode adjustment if necessary */
body.dark-mode .auth-footer {
    color: rgba(255, 255, 255, 0.4);
}

/* Mobile Search Capsule in Drawer */
.mobile-search-capsule {
    width: 100%;
    padding: 10px 16px;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.search-box-mobile {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 12px;
    padding: 10px 14px;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.search-box-mobile:focus-within {
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: var(--apple-blue);
    transform: translateY(-1px);
}

.search-box-mobile .search-icon {
    position: static !important;
    transform: none !important;
    font-size: 1rem;
    opacity: 0.5;
    margin-right: 10px;
    flex-shrink: 0;
}

.search-box-mobile input {
    border: none;
    background: transparent;
    width: 100%;
    font-size: 16px;
    /* Prevents iOS zoom */
    color: var(--text-primary);
    outline: none;
    font-family: inherit;
}

.search-box-mobile input::placeholder {
    color: var(--text-tertiary);
}

/* Hide global search on mobile strictly */
@media (max-width: 768px) {

    .search-module,
    .search-module * {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    /* Ensure the search-icon from header doesn't escape */
    .header-left .search-icon,
    .search-box .search-icon {
        display: none !important;
    }
}

/* Mobile Drawer Theme Button Styles */
.theme-toggle-drawer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.04);
    border: none;
    padding: 12px 24px;
    border-radius: 50px;
    width: 80%;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.theme-toggle-drawer:active {
    transform: scale(0.96);
    background: rgba(0, 0, 0, 0.08);
}

body.dark-mode .theme-toggle-drawer {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* Mobile Footer Buttons (icon-only circular) */
.mobile-footer-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.06);
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.mobile-footer-btn .btn-icon {
    font-size: 1.4rem;
}

.mobile-footer-btn:active {
    transform: scale(0.92);
    background: rgba(0, 0, 0, 0.1);
}

/* User Avatar Button in Mobile Footer */
.mobile-user-avatar {
    background: linear-gradient(135deg, #007AFF, #5856D6);
    color: #fff;
    font-weight: 700;
}

.mobile-user-avatar .btn-icon {
    font-size: 1.2rem;
    font-family: inherit;
}

/* Dark Mode Styles */
body.dark-mode .mobile-footer-btn {
    background: rgba(255, 255, 255, 0.12);
}

body.dark-mode .mobile-footer-btn:active {
    background: rgba(255, 255, 255, 0.2);
}

body.dark-mode .mobile-user-avatar {
    background: linear-gradient(135deg, #0A84FF, #8B5CF6);
}

/* Mobile Footer Buttons Container */
.mobile-footer-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
}

/* Mobile Logout Button */
.mobile-logout-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 16px;
    transition: all 0.2s ease;
}

.mobile-logout-btn:active {
    color: #FF3B30;
    transform: scale(0.96);
}

body.dark-mode .mobile-logout-btn {
    color: rgba(255, 255, 255, 0.6);
}

body.dark-mode .mobile-logout-btn:active {
    color: #FF453A;
}

/* Hide original floating button on mobile */
@media (max-width: 768px) {
    .theme-toggle-btn {
        display: none !important;
    }

    /* Solid Ivory Background for Mobile - High Visibility */
    body::before {
        content: "";
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: -1;
        background: #FFFFF0 !important;
        pointer-events: none;
    }

    body {
        background: #FFFFF0 !important;
    }

    body.dark-mode::before {
        background: #0a0a0c !important;
    }

    body.dark-mode {
        background: #0a0a0c !important;
    }

    /* Let transparency pass through cards to show the gradient */
    .glass-card,
    .chart-card,
    .table-card {
        background: rgba(255, 255, 255, 0.4) !important;
        backdrop-filter: blur(25px) saturate(180%) !important;
        -webkit-backdrop-filter: blur(25px) saturate(180%) !important;
        border: 1px solid rgba(255, 255, 255, 0.5) !important;
    }

    body.dark-mode .glass-card,
    body.dark-mode .chart-card,
    body.dark-mode .table-card {
        background: rgba(30, 30, 35, 0.6) !important;
    }

    /* Header transparency */
    .top-header {
        background: rgba(255, 255, 255, 0.6) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.2) !important;
    }

    body.dark-mode .top-header {
        background: rgba(10, 10, 12, 0.6) !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
    }

    /* Dock transparency (for small phones) */
    .sidebar {
        background: rgba(255, 255, 255, 0.7) !important;
        backdrop-filter: blur(30px) !important;
        -webkit-backdrop-filter: blur(30px) !important;
    }

    body.dark-mode .sidebar {
        background: rgba(20, 20, 25, 0.8) !important;
    }
}

/* Payroll Section Styles */
.nomina-layout {
    animation: fadeIn 0.5s ease-out;
}

@media (max-width: 1100px) {
    .nomina-layout {
        grid-template-columns: 1fr !important;
    }
}

.payroll-item {
    transition: all var(--transition-bounce);
}

.payroll-item:hover {
    transform: scale(1.02) translateX(5px);
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: var(--apple-blue) !important;
}

.btn-delete-small:hover {
    text-decoration: underline;
    opacity: 1 !important;
}

.kpi-card.purple {
    background: linear-gradient(135deg, rgba(175, 82, 222, 0.1) 0%, rgba(175, 82, 222, 0.2) 100%);
    border-left: 4px solid var(--apple-purple);
}

.live-pulse {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--apple-green);
    border-radius: 50%;
    margin-left: 10px;
    box-shadow: 0 0 0 rgba(52, 199, 89, 0.4);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(52, 199, 89, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(52, 199, 89, 0);
    }
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }

    100% {
        transform: translateY(0px);
    }
}

/* ===================================
   MEMBERSHIP & TOGGLE STYLES
   =================================== */

.membership-alert-pill {
    margin-top: 15px;
    background: rgba(255, 149, 0, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 149, 0, 0.3);
    border-radius: 12px;
    padding: 10px 15px;
    animation: slideInLeft 0.5s cubic-bezier(0.16, 1, 0.3, 1), pulse-border 2s infinite;
    max-width: 100%;
}

.membership-alert-pill.expired {
    background: rgba(255, 59, 48, 0.15);
    border-color: rgba(255, 59, 48, 0.3);
}

.alert-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-icon {
    font-size: 1.2rem;
}

.alert-text {
    display: flex;
    flex-direction: column;
}

.alert-text strong {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--apple-orange);
}

.membership-alert-pill.expired .alert-text strong {
    color: var(--apple-red);
}

.alert-text span {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse-border {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 149, 0, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(255, 149, 0, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(255, 149, 0, 0);
    }
}

/* Switch Toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.1);
    transition: .4s;
    border: 1px solid var(--glass-border);
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    box-shadow: var(--shadow-sm);
}

input:checked+.slider {
    background-color: var(--apple-green);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--apple-green);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}