:root {
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --primary: #3b82f6;
    --primary-rgb: 59, 130, 246;
    /* Blue */
    --primary-glow: rgba(59, 130, 246, 0.5);
    --accent: #8b5cf6;
    /* Purple */
    --success: #10b981;
    --danger: #ef4444;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --font-family: 'Outfit', sans-serif;
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 80px;
}

/* Hide Spin Buttons */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
    color: var(--text-main);
    font-family: var(--font-family);
    min-height: 100vh;
    padding: 20px;
    overflow-x: hidden;
    width: 100%;
}

.app-container {
    max-width: 100%;
    margin: 0;
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

#appMain {
    flex-grow: 1;
    min-width: 0; /* Add this to prevent flex child from expanding beyond parent */
    padding: 2rem;
    max-width: none !important;
    width: 98%;
    margin: 0 auto;
    transition: all 0.3s ease;
}

#appMain.sidebar-collapsed {
    padding-left: 1rem;
    padding-right: 1rem;
    max-width: none !important;
}

#appMain.sidebar-collapsed .savings-container,
#appMain.sidebar-collapsed .stock-list-section,
#appMain.sidebar-collapsed .dashboard-grid,
#appMain.sidebar-collapsed .view-section {
    max-width: none !important;
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

@media (max-width: 1024px) {
    body {
        padding: 10px;
    }

    .app-container {
        flex-direction: column;
    }

    #appMain {
        padding: 0.5rem;
        padding-bottom: 90px;
        /* Space for bottom nav */
        width: 100%;
    }

    #ahorroGlobalCalendarWrapper {
        padding: 0.75rem;
    }
}

/* Glassmorphism Utilities */
.glass-header,
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

#ahorroGlobalCalendarWrapper {
    padding: 1.5rem;
}

.digital-timer {
    position: static;
    text-align: center;
    font-family: 'Courier New', Courier, monospace;
    font-size: 1rem;
    padding: 0.35rem 0.9rem;
    color: var(--primary);
    text-shadow: 0 0 15px var(--primary-glow);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    letter-spacing: 1px;
    font-weight: 700;
    white-space: nowrap;
    z-index: 1;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    margin-bottom: 2rem;
    -webkit-app-region: no-drag;
}

header button,
header a {
    -webkit-app-region: no-drag;
    pointer-events: auto;
    position: relative;
    z-index: 1;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    flex-shrink: 0;
    white-space: nowrap;
    color: #ffffff;
    /* Explicitly white for visibility on dark background */
}

.highlight {
    color: var(--primary);
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 0 15px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 25px var(--primary-glow);
}

.btn-primary:active {
    transform: scale(0.95);
}

.btn-privacy {
    padding: 0.5rem;
    font-size: 1.1rem;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-privacy:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.btn-privacy.active {
    color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

.hidden {
    display: none !important;
}

/* Sidebar Navigation */
.wealth-sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: sticky;
    top: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.25rem;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    overflow-x: hidden;
}

.wealth-sidebar.collapsed {
    width: 0;
    padding: 0;
    margin: 0;
    opacity: 0;
    pointer-events: none;
    border-right: none;
    transform: translateX(-100%);
}

.sidebar-desktop-toggle-btn {
    position: fixed;
    top: 32px;
    left: 32px;
    z-index: 1200;
    /* Higher than sidebar */
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.sidebar-desktop-toggle-btn:hover {
    background: var(--bg-card);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
}

.sidebar-desktop-toggle-btn.sidebar-open {
    left: 212px;
    /* Close to the sidebar's edge or inside header area */
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 3rem;
    padding: 0 44px 0 0.5rem;
    /* Space for the fixed toggle button */
    height: 48px;
}

@media (max-width: 1024px) {
    .sidebar-desktop-toggle-btn {
        display: none;
        /* Only desktop */
    }
}

.wealth-sidebar.collapsed .logo-text,
.wealth-sidebar.collapsed .nav-text,
.wealth-sidebar.collapsed .nav-group-title,
.wealth-sidebar.collapsed .sidebar-storage {
    display: none;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: white;
}

.logo-icon {
    font-size: 1.5rem;
    filter: drop-shadow(0 0 10px var(--primary-glow));
}

.logo-text h1 {
    font-size: 1.25rem;
    margin: 0;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 2.5rem;
}

.nav-group-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    padding-left: 1rem;
    opacity: 0.6;
}

.wealth-nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    border-radius: 12px;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    width: 100%;
    text-align: left;
    font-family: inherit;
    font-weight: 500;
}

.wealth-nav-item:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
    transform: translateX(4px);
}

.wealth-nav-item.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(139, 92, 246, 0.15));
    border-color: rgba(59, 130, 246, 0.4);
    color: white;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    transform: translateX(4px);
}

.wealth-nav-item.active .nav-icon {
    transform: scale(1.15) rotate(-5deg);
    filter: drop-shadow(0 0 10px var(--primary-glow));
}

.nav-icon {
    font-size: 1.25rem;
    width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-text {
    font-size: 0.95rem;
}

/* Submenu Styles */
.nav-item-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin-bottom: 2px;
}

.nav-item-header {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.nav-item-chevron {
    position: absolute;
    right: 1rem;
    pointer-events: none;
    font-size: 0.7rem;
    opacity: 0.5;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: white;
    z-index: 5;
}

.wealth-nav-item {
    padding-right: 3rem !important;
    /* Extra space for chevron */
}

.nav-item-container.open .nav-item-chevron {
    transform: rotate(180deg);
}

.sidebar-submenu {
    max-height: 0;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    padding-left: 2.5rem;
    margin-top: 2px;
    opacity: 0;
}

.nav-item-container.open .sidebar-submenu {
    max-height: 500px;
    opacity: 1;
    margin-bottom: 0.5rem;
}

.submenu-item {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: inherit;
}

.submenu-item:hover {
    color: white;
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(4px);
}

.submenu-item.active {
    color: white;
    background: rgba(59, 130, 246, 0.15);
    font-weight: 600;
    transform: translateX(4px);
    border-radius: 6px;
}

.submenu-item span {
    font-size: 1rem;
}

/* Hide old header icons as requested */
#bolsaHeaderActions,
#ahorroHeaderActions,
#nominaHeaderActions {
    display: none !important;
}

/* Bottom Nav Hub for Mobile */
.bottom-nav-hub {
    display: none;
    /* Only mobile */
    position: fixed;
    bottom: 24px;
    left: 20px;
    right: 20px;
    width: auto;
    max-width: 500px;
    margin: 0 auto;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 30px;
    height: 72px;
    z-index: 2000;
    padding: 0 1.25rem;
    padding-top: 8px;
    /* Room for handle */
    display: flex;
    /* Added to view_file was missing displaying correctly */
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(59, 130, 246, 0.05);
    user-select: none;
    touch-action: none;
    /* Crucial for dragging */
    transition: bottom 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28), opacity 0.3s ease;
}

.bottom-nav-hub.is-minimized .bottom-nav-item {
    opacity: 0;
    pointer-events: none;
}

/* Keep FAB visible and clickable even when minimized */
.bottom-nav-hub.is-minimized .floating-action-btn {
    transform: translateY(10px) scale(0.8);
    opacity: 0.8;
}

.bottom-nav-hub.is-minimized {
    background: rgba(15, 23, 42, 0.4);
    /* Extra glass effect when small */
}

.drag-handle {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 32px;
    /* Slightly taller for controls */
    cursor: grab;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    pointer-events: none;
    /* Let clicks pass through to buttons under it */
}

.drag-handle>* {
    pointer-events: auto;
    /* Re-enable for the actual controls */
}

.drag-indicator {
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
}

.nav-control-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.2rem;
    padding: 4px 8px;
    cursor: pointer;
    line-height: 1;
    transition: transform 0.3s ease;
}

.nav-control-btn.rotated {
    transform: rotate(180deg);
}

.move-icon {
    color: rgba(255, 255, 255, 0.4);
    font-size: 1.2rem;
    pointer-events: none;
    /* Let the handle handle the drag */
}

.drag-handle:active {
    cursor: grabbing;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0.5rem;
    position: relative;
    font-family: inherit;
}

.bottom-nav-item.active {
    color: var(--primary);
}

.bottom-nav-item.active::after {
    content: '';
    position: absolute;
    bottom: -5px;
    width: 4px;
    height: 4px;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--primary-glow);
}

.bottom-nav-icon {
    font-size: 1.35rem;
}

.bottom-nav-text {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.floating-action-btn {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(59, 130, 246, 0.4);
    transform: translateY(-20px);
    transition: all 0.3s ease;
    z-index: 50;
    /* Above handle but within hub's context */
}

.floating-action-btn span {
    pointer-events: none;
}

.floating-action-btn:active {
    transform: translateY(-15px) scale(0.9);
}

/* Sidebar Toggle for Mobile Sidebar view */
.sidebar-toggle-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    display: none;
}

@media (max-width: 1024px) {
    .wealth-sidebar {
        position: fixed;
        left: -100%;
        /* Hidden by default */
        top: 0;
        bottom: 0;
        width: 280px !important;
        border-right: 1px solid var(--glass-border);
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
    }

    .wealth-sidebar.mobile-open {
        left: 0;
    }

    .bottom-nav-hub {
        display: flex;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(4px);
        z-index: 999;
        display: none;
    }

    .sidebar-overlay.visible {
        display: block;
    }
}

/* Hide old nav/header elements when using the NEW nav */
.main-nav,
.mobile-action-bar,
.glass-header {
    display: none !important;
}

#appMain {
    margin-top: 0;
    /* No header spacing needed */
}

/* View Sections */
.view-section {
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Drawers Grid */
.savings-container {
    max-width: none !important;
    width: 100%;
    margin: 0 auto;
    padding: 0 1rem;
}

@media (max-width: 1024px) {
    .savings-container {
        padding: 0 0.5rem;
    }
}

.drawers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.5rem 1.5rem;
    /* Reduced row gap from 1.5rem to 0.5rem */
    perspective: 1000px;
}

.drawer-group-title {
    grid-column: 1 / -1;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0.75rem 0 0 0 !important;
    /* Minimal top margin */
    padding: 0.5rem !important;
    border-bottom: 1px solid rgba(59, 130, 246, 0.15);
    display: flex;
    align-items: center;
    gap: 10px;
}

.drawer-group-title::before {
    content: '📁';
    font-size: 1.1rem;
}

.drawer-card {
    cursor: pointer;
    transition: all 0.5s cubic-bezier(0.23, 1, 0.32, 1);
    border: 1px solid var(--glass-border);
    position: relative;
    overflow: hidden;
    padding: 1.5rem;
    transform-style: preserve-3d;
}

.drawer-card:hover {
    transform: translateY(-8px);
    border-color: var(--primary);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 20px rgba(59, 130, 246, 0.1);
}

.drawer-card::after,
.summary-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: -150%;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right,
            transparent,
            rgba(255, 255, 255, 0.05),
            transparent);
    transform: skewX(-25deg);
    transition: 0.75s;
    pointer-events: none;
}

.drawer-card:hover::after,
.summary-card:hover::after {
    left: 150%;
}

.drawer-card.bolsa-drawer {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(30, 41, 59, 0.4) 100%);
    border-color: rgba(59, 130, 246, 0.3);
}

.app-container .drawer-card.income-drawer {
    background: rgba(16, 185, 129, 0.25);
    background-color: #064e3b !important;
    /* Very dark green solid fallback */
    background-image: linear-gradient(135deg, rgba(16, 185, 129, 0.4) 0%, rgba(15, 23, 42, 0.8) 100%) !important;
    border: 2px solid #10b981 !important;
}

.app-container .drawer-card.income-drawer:hover {
    border-color: var(--success) !important;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.35) 0%, rgba(30, 41, 59, 0.7) 100%) !important;
}

.drawer-card.savings-drawer {
    background: rgba(245, 158, 11, 0.15);
    background-color: #451a03 !important;
    background-image: linear-gradient(135deg, rgba(245, 158, 11, 0.25) 0%, rgba(15, 23, 42, 0.8) 100%) !important;
    border: 2px solid #f59e0b !important;
}

.drawer-card.undestined-drawer {
    background: rgba(139, 92, 246, 0.15);
    background-color: #2e1065 !important;
    background-image: linear-gradient(135deg, rgba(139, 92, 246, 0.4) 0%, rgba(15, 23, 42, 0.8) 100%) !important;
    border: 2px solid #8b5cf6 !important;
}

.drawer-card.undestined-drawer:hover {
    border-color: #a78bfa !important;
    background-image: linear-gradient(135deg, rgba(139, 92, 246, 0.5) 0%, rgba(30, 41, 59, 0.7) 100%) !important;
}

/* Premium Glow Styles */
.profit-glow {
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.2), 0 0 30px rgba(59, 130, 246, 0.1);
}

.loss-glow {
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.2), 0 0 30px rgba(239, 68, 68, 0.1);
}

.profit-glow:hover {
    box-shadow: 0 0 25px rgba(59, 130, 246, 0.4), 0 0 50px rgba(59, 130, 246, 0.2) !important;
}

.loss-glow:hover {
    box-shadow: 0 0 25px rgba(239, 68, 68, 0.4), 0 0 50px rgba(239, 68, 68, 0.2) !important;
}

/* Pulsing Shimmer for Premium Feel */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.shimmer-card {
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.03) 50%,
            rgba(255, 255, 255, 0) 100%);
    background-size: 200% 100%;
    animation: shimmer 3s infinite linear;
}

.drawer-target-icon {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.2rem;
    opacity: 0.4;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}

.drawer-target-icon:hover {
    opacity: 1;
    transform: scale(1.2);
}

.target-info {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Specific rule for the Expense Summary to disable movement */
.summary-drawer {
    cursor: default !important;
}

.summary-drawer:hover {
    transform: none !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
    border-color: var(--danger) !important;
}

.summary-drawer:hover::after {
    display: none !important;
}

.summary-header-toggle {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
    padding: 0.5rem;
    border-radius: 12px;
}

.summary-header-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
}

.collapsible-content {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    margin-top: 0;
}

.collapsible-content:not(.expanded) {
    display: none !important;
    /* Hide completely to remove grid footprints/gaps */
}

.collapsible-content.expanded {
    display: grid !important;
    max-height: none !important;
    opacity: 1;
    margin-top: 0.5rem !important;
    padding-top: 0.25rem;
}

.toggle-arrow {
    transition: transform 0.3s ease;
    display: inline-block;
}

.toggle-arrow.expanded,
.section-toggle-icon.expanded {
    transform: rotate(180deg);
}

.drawer-icon {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    display: block;
}

.drawer-name {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: block;
}

.drawer-amount {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
    border: 1px solid var(--danger);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.3);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
    perspective: 1000px;
}

.summary-card {
    padding: 1.5rem;
    transition: all 0.5s cubic-bezier(0.23, 1, 0.32, 1);
    transform-style: preserve-3d;
    position: relative;
    overflow: hidden;
}

.summary-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 20px rgba(59, 130, 246, 0.1);
    border-color: var(--primary);
}

.summary-card h3 {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.summary-card .amount {
    font-size: 2rem;
    font-weight: 700;
}

.amount--simulated {
    font-style: italic;
    opacity: 0.85;
}

@keyframes syncFlash {
    0% {
        background-color: transparent;
    }

    50% {
        background-color: rgba(245, 158, 11, 0.1);
    }

    100% {
        background-color: transparent;
    }
}

.sync-flash {
    animation: syncFlash 0.8s ease-out;
}

.trend {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.trend.positive {
    color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

.trend.negative {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* Stock List */
.stock-list-section {
    padding: 2rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.filter-tabs button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-weight: 500;
    transition: color 0.2s;
}

.filter-tabs button.active {
    color: var(--text-main);
    border-bottom: 2px solid var(--primary);
}

.signal-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    white-space: nowrap;
}

.signal-badge.hammer {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.signal-badge.hammer-inv {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.signal-badge.doji {
    background: rgba(156, 163, 175, 0.15);
    color: #d1d5db;
    border: 1px solid rgba(156, 163, 175, 0.3);
}

.signal-badge.engulfing {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

th {
    text-align: left;
    padding: 1rem;
    color: var(--text-main);
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.25);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    user-select: none;
    position: relative;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.03);
}

th:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

th .sort-icon {
    margin-left: 0.5rem;
    font-size: 0.8rem;
    opacity: 0.5;
    transition: opacity 0.2s;
}

th.active-sort {
    color: var(--primary);
}

th.active-sort .sort-icon {
    opacity: 1;
}

td {
    padding: 0.75rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    white-space: nowrap;
}

tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.current-month-row {
    background: rgba(59, 130, 246, 0.12) !important;
    border-left: 4px solid var(--primary) !important;
}

.insufficient-income-row {
    background: rgba(239, 68, 68, 0.2) !important;
}

/* Composite class for current month with insufficient income */
.current-month-row.insufficient-income-row {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.15) 0%, rgba(239, 68, 68, 0.2) 100%) !important;
}

.profit {
    color: var(--success);
}

.loss {
    color: var(--danger);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none !important;
}

.modal-content {
    width: 100%;
    max-width: 650px;
    /* Increased for charting */
    max-height: 90vh;
    padding: 2.5rem;
    position: relative;
    background: #1e293b;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    line-height: 1;
    transition: color 0.2s;
}

.close-btn:hover {
    color: var(--text-main);
}

.close-modal,
.close-export-modal {
    position: sticky;
    top: 0;
    float: right;
    margin-top: -1.5rem;
    margin-right: -1.5rem;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--text-muted);
    z-index: 10;
    transition: color 0.2s;
}

.close-modal:hover,
.close-export-modal:hover {
    color: var(--text-color);
}

.form-group {
    margin-bottom: 1rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

input,
select {
    width: 100%;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-main);
    font-family: inherit;
}

select option {
    background-color: #1e293b;
    color: var(--text-main);
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
}

.full-width {
    width: 100%;
    margin-top: 1rem;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.empty-state.hidden {
    display: none !important;
}

/* Global Hidden Utility */
.hidden {
    display: none !important;
}

/* Search Suggestions */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #1e293b;
    border: 1px solid var(--glass-border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    z-index: 1001;
    max-height: 200px;
    overflow-y: auto;
}

.search-item {
    padding: 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s;
}

.search-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.search-item .ticker {
    font-weight: 700;
    color: var(--primary);
    margin-right: 0.5rem;
}

.search-item .name {
    color: var(--text-main);
    font-size: 0.9rem;
}

.search-item:last-child {
    border-bottom: none;
}

.form-group {
    position: relative;
    /* For absolute search results */
}

/* Login Overlay Styles */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at top right, #1e293b, #0f172a);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 3rem;
    text-align: left;
    animation: fadeInAuth 0.5s ease-out;
}

.login-card h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

@keyframes fadeInAuth {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.error-text {
    animation: shakeAuth 0.3s ease-in-out;
}

@keyframes shakeAuth {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

/* Live Badge */
.badge-live {
    font-size: 0.65rem;
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid rgba(16, 185, 129, 0.3);
    display: inline-flex;
    align-items: center;
}

.badge-live::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
    margin-right: 4px;
    box-shadow: 0 0 5px var(--success);
    animation: pulse-live 2s infinite;
}

@keyframes pulse-live {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Status Badges */
.status-badge {
    font-size: 0.6rem;
    padding: 1px 5px;
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-left: 4px;
}

.status-badge.open {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.closed {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Source Dots */
.source-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.source-dot.live {
    background-color: var(--success);
    box-shadow: 0 0 6px var(--success);
    animation: pulse-live 2s infinite ease-in-out;
}

.source-dot.simulated {
    background-color: #f59e0b;
    /* Amber */
    box-shadow: 0 0 6px #f59e0b;
    opacity: 0.8;
}

/* Global Status Dot for Dashboard */
.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    transition: all 0.3s ease;
}

.status-dot.live {
    background-color: var(--success);
    box-shadow: 0 0 10px var(--success);
    animation: pulse-live 2s infinite ease-in-out;
}

.status-dot.simulated {
    background-color: #f59e0b;
    box-shadow: 0 0 8px #f59e0b;
}

.status-dot.offline {
    background-color: var(--danger);
    box-shadow: 0 0 10px var(--danger);
}

.sparkline-container {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
    padding: 2px 4px;
}

.sparkline-placeholder {
    font-size: 0.8rem;
    color: var(--text-muted);
    width: 80px;
    text-align: center;
}

/* ── Mobile: ≤600px (Fold cerrado, iPhone, etc.) ─────────────────── */
@media (max-width: 600px) {
    body {
        padding: 0 !important;
        background-attachment: fixed;
    }

    header {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: 60px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: var(--bg-dark) !important;
        backdrop-filter: blur(20px) !important;
        border-bottom: 1px solid var(--glass-border) !important;
        z-index: 10000 !important;
        padding: 0 1rem !important;
        margin: 0 !important;
    }

    header>*:not(.logo) {
        display: none !important;
    }

    .stock-list-section {
        display: block !important;
        padding: 1rem !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
    }

    #bolsaListHeader h2 {
        display: none !important;
    }

    #bolsaMobileTitle {
        font-size: 1rem;
    }

    .app-container {
        height: auto;
        min-height: auto;
        max-width: 100%;
        padding: 0 !important;
        margin-top: 0 !important;
    }

    main {
        height: auto;
        padding: 0 !important;
    }

    #bolsaSection .dashboard-grid {
        height: auto;
        min-height: auto;
        grid-template-rows: auto;
    }

    .app-container {
        padding: 0 !important;
        max-width: 100% !important;
    }

    .main-nav {
        margin-top: 70px !important;
        /* Offset for sticky header */
        margin-bottom: 0.5rem !important;
        gap: 0;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        border: none !important;
        display: flex;
        align-items: stretch;
        background: transparent !important;
        backdrop-filter: none !important;
        box-shadow: none !important;
    }

    .nav-item,
    .nav-icon-btn {
        padding: 0.7rem 0 !important;
        /* Unified vertical padding */
        font-size: 0.75rem !important;
        flex: 1 !important;
        /* All children share space equally */
        text-align: center;
        min-width: 0 !important;
        border-radius: 0 !important;
        /* Square for edge-to-edge */
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none !important;
    }

    .nav-icon-btn {
        font-size: 1.1rem !important;
    }

    .nav-spacer {
        display: none !important;
    }

    .dashboard-grid {
        width: 100%;
        margin: 0;
        grid-template-columns: 1fr;
        gap: 0;
    }

    .summary-card {
        border-radius: 0;
        border: none;
        border-bottom: 1px solid var(--glass-border);
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding: 1rem 1.5rem;
        background: rgba(30, 41, 59, 0.5);
    }

    .summary-card:last-child {
        border-bottom: none;
    }

    .summary-card h3 {
        font-size: 1.1rem;
        letter-spacing: 0.1em;
        text-transform: uppercase;
        margin-bottom: 1rem;
    }

    .summary-card .amount {
        font-size: 2rem;
    }

    .trend {
        font-size: 1rem;
        padding: 0.4rem 0.8rem;
    }

    #fxIndicator,
    #liveStatus {
        font-size: 0.8rem;
        margin-top: 1rem;
    }

    .digital-timer {
        position: fixed;
        bottom: 3.5rem;
        /* above the mobile action bar */
        top: auto;
        left: 0;
        right: 0;
        transform: none;
        z-index: 500;
        font-size: 0.8rem;
        padding: 0.3rem 1rem;
        background: rgba(15, 23, 42, 0.97);
        border-radius: 0;
        border-top: 1px solid var(--glass-border);
        min-width: auto;
        width: 100%;
        letter-spacing: 1px;
    }

    /* .mobile-action-bar:not(.hidden) {
        display: flex !important;
    } */
}

/* ── Foldable / Tablet: 601–900px (Fold 5 abierto, etc.) ────────── */
@media (min-width: 601px) and (max-width: 900px) {

    /* Hide the timer inside the header row to avoid overflow */
    .digital-timer {
        display: none;
    }

    /* Compact header — hide PWA/Reset noise, just keep key buttons */
    #pwaStatusText,
    #pwaManualGuide {
        display: none !important;
    }

    header {
        padding: 0.75rem 1rem;
        margin-bottom: 1rem;
    }

    .logo h1 {
        font-size: 1.1rem;
    }

    #addStockBtn {
        font-size: 0.8rem;
        padding: 0.5rem 0.8rem;
    }

    /* Show the mobile action bar so 💾 📂 ➕ are always reachable */
    /* .mobile-action-bar:not(.hidden) {
        display: flex !important;
    } */
}

/* Mobile Action Bar - hidden by default, shown only on mobile */
.mobile-action-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 600;
    background: rgba(15, 23, 42, 0.97);
    border-top: 1px solid var(--glass-border);
    padding: 0.6rem 1.5rem;
    justify-content: flex-end;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 -3px 20px rgba(0, 0, 0, 0.5);
}

.mobile-action-bar button {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    border-radius: 10px;
    padding: 0.6rem 0.9rem;
    font-size: 1.3rem;
    cursor: pointer;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-action-bar button:active {
    background: rgba(255, 255, 255, 0.18);
}

/* Portfolio Candle Styles */
.candle-container {
    display: flex;
    align-items: center;
    justify-content: space-around;
    gap: 1.5rem;
    margin-top: 0.5rem;
    min-height: 80px;
}

.candle-graphics {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 60px;
    height: 100px;
}

.candle-values {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.val-row {
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.val-row .label {
    color: var(--text-muted);
}

.val-row span:last-child {
    font-family: monospace;
}

/* (Old badges kept for compatibility) */
.badge-live::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
    margin-right: 4px;
    box-shadow: 0 0 5px var(--success);
    animation: pulse-live 2s infinite;
}

.badge-simulated::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    margin-right: 4px;
    box-shadow: 0 0 5px var(--accent);
    animation: pulse-live 2s infinite ease-in-out;
}

/* Company Link */
.company-link {
    color: var(--text-main);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}

.company-link.profit {
    color: var(--success);
    font-weight: 700;
    text-shadow: 0 0 8px rgba(16, 185, 129, 0.3);
}

.company-link.loss {
    color: var(--danger);
}

.company-link.neutral {
    color: var(--text-main);
}

.company-link:hover {
    color: var(--primary);
    text-decoration: underline;
}

/* Financials Grid */
.financials-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    padding: 1rem 0;
}

.fin-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.fin-item label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
    color: var(--text-muted);
    cursor: help;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.2);
    display: inline-block;
}

.fin-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-color);
}

/* Technical Analysis Section Styles */
.tech-section {
    margin-top: 2rem;
}

.tech-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.tech-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 0.75rem;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
}

.tech-item label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.3rem;
    color: var(--text-muted);
}

.tech-value {
    font-size: 1rem;
    font-weight: 600;
}

.tech-extra {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.tech-ma-status {
    background: rgba(59, 130, 246, 0.1);
    padding: 0.5rem;
    border-radius: 8px;
    border-left: 3px solid var(--primary);
}

.tech-patterns {
    background: rgba(139, 92, 246, 0.1);
    padding: 0.5rem;
    border-radius: 8px;
    border-left: 3px solid var(--accent);
}

.badge-trend {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.trend-bullish {
    color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

.trend-bearish {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.trend-neutral {
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.1);
}

/* News Section Styles (Kept for compatibility or future use) */
.news-section {
    margin-top: 2rem;
}

/* Chart Styles */
.chart-section {
    margin-bottom: 2rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid var(--border-color);
}

.timeframe-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.time-tab {
    padding: 0.3rem 0.8rem;
    font-size: 0.8rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.time-tab:hover {
    background: rgba(255, 255, 255, 0.1);
}

.time-tab.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.chart-container {
    width: 100%;
    height: 300px;
    background: #0f172a !important;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    margin-bottom: 1rem;
    position: relative;
}

/* Nomina Improvements: Checkboxes and Totals */
.nomina-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--glass-border);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    vertical-align: middle;
}

.nomina-checkbox:checked {
    background: var(--success);
    border-color: var(--success);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

.nomina-checkbox:checked::after {
    content: '✔';
    color: white;
    font-size: 11px;
    font-weight: 900;
}

.nomina-checkbox:hover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

.movement-item-paid {
    opacity: 0.5;
    text-decoration: line-through;
    transition: all 0.3s ease;
}

.box-total-label {
    font-size: 0.65rem;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.box-total-value {
    font-size: 0.75rem;
    font-weight: 700;
}

/* Nomina & Ahorro Months Selection Grid */
.months-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px 4px;
    background: rgba(255, 255, 255, 0.03);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: 420px) {
    .months-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px 2px;
        padding: 10px 8px;
    }
}

.box-total-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: toastSlideUp 0.3s ease-out;
    pointer-events: auto;
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

.toast.fade-out {
    opacity: 0;
    transform: translate(-50%, 1rem);
    transition: all 0.3s ease-in;
}

@keyframes toastSlideUp {
    from {
        opacity: 0;
        transform: translateY(1rem);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Reset Button Hover/Active */
#pwaResetBtn:hover {
    opacity: 0.8 !important;
    background: rgba(255, 255, 255, 0.1) !important;
}

#pwaResetBtn:active {
    opacity: 0.6 !important;
    transform: scale(0.95);
}

/* Continuous rotation for manual refresh button */
.spin-animation {
    animation: spin 1s linear infinite;
    display: inline-block;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* PWA Update Toast */
.pwa-update-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(30, 41, 59, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--primary);
    border-radius: 16px;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    z-index: 10000;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(59, 130, 246, 0.2);
    transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.4s;
    opacity: 0;
    width: max-content;
    max-width: 90vw;
}

.pwa-update-toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.pwa-toast-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.pwa-toast-icon {
    font-size: 1.5rem;
}

.pwa-toast-text strong {
    display: block;
    color: var(--text-main);
    font-size: 0.95rem;
}

.pwa-toast-text p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0;
}

@media (max-width: 480px) {
    .pwa-update-toast {
        bottom: 5rem;
        /* Up from mobile nav */
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        text-align: center;
    }

    .pwa-toast-content {
        flex-direction: column;
    }
}


/* Analisis View Styles */
.current-month-row {
    background: rgba(59, 130, 246, 0.1) !important;
    border-left: 3px solid var(--primary);
}

/* Specific to ultra-narrow screens for Analisis (Fold 5) */
@media (max-width: 400px) {
    #analisisTableContainer table {
        font-size: 0.65rem !important;
    }

    #analisisTableContainer th,
    #analisisTableContainer td {
        padding: 0.25rem 0.2rem !important;
        white-space: nowrap !important;
        letter-spacing: -0.02em;
    }

    #analisisTableContainer .sort-icon {
        font-size: 0.55rem !important;
    }
}

.insufficient-income-row {
    background: rgba(239, 68, 68, 0.05);
}

.insufficient-income-row td {
    color: var(--danger) !important;
}

.current-month-card {
    border: 1px solid var(--primary) !important;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
}

/* Ahorro List View Styles */
.ahorro-list-header {
    background: rgba(255, 255, 255, 0.08);
    font-weight: bold;
    border-bottom: 1px solid var(--primary);
}

.ahorro-list-header td {
    padding: 0.8rem 1rem;
}

.ahorro-list-header .header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.ahorro-list-header .list-actions {
    display: flex;
    gap: 0.4rem;
}

.ahorro-list-header .balance {
    text-align: right;
    color: var(--primary);
    font-weight: 800;
}

@media (max-width: 600px) {
    header {
        padding: 0.5rem 0.8rem !important;
        gap: 0.5rem;
    }

    .logo {
        font-size: 1.25rem !important;
        /* Slightly larger but controlled */
        gap: 0.5rem !important;
        display: flex !important;
        opacity: 1 !important;
        visibility: visible !important;
        white-space: nowrap !important;
    }

    .logo-icon {
        font-size: 1.25rem;
        display: inline-block !important;
    }
}

.list-section-header {
    background: rgba(var(--primary-rgb), 0.25) !important;
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.08rem;
    border-top: 2px solid rgba(var(--primary-rgb), 0.3) !important;
    border-bottom: 1px solid rgba(var(--primary-rgb), 0.2) !important;
    text-transform: uppercase;
}

.list-section-header td {
    padding: 0.75rem 0.5rem !important;
}

@media (max-width: 350px) {
    .list-section-header td {
        padding: 0.4rem 0.3rem !important;
        font-size: 0.65rem !important;
    }
}

.ahorro-list-row {
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    cursor: pointer;
    transition: background 0.2s;
}

.ahorro-list-row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.ahorro-list-row td {
    padding: 0.6rem 1rem;
    font-size: 0.8rem;
    vertical-align: top;
}

.ahorro-list-row .date {
    padding-left: 2rem;
    opacity: 0.6;
    font-size: 0.75rem;
}

.ahorro-list-row .concept {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ahorro-list-row .category-tag {
    font-weight: 500;
}

.ahorro-list-row .detail-text {
    font-size: 0.7rem;
    opacity: 0.5;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.ahorro-list-row.expanded .detail-text {
    max-height: 100px;
    margin-top: 4px;
    opacity: 0.8;
}

.ahorro-list-row .amount {
    text-align: right;
    font-weight: 600;
    font-size: 0.85rem;
}

.ahorro-list-row.expanded {
    background: rgba(255, 255, 255, 0.03);
}

.ahorro-list-empty-row td {
    padding: 0.6rem 1rem;
    font-style: italic;
    opacity: 0.4;
    font-size: 0.8rem;
    padding-left: 2rem;
}

/* Specific to VERY narrow screens (like Fold front) */
@media (max-width: 380px) {
    .ahorro-list-header td {
        padding: 0.5rem 0.6rem;
    }

    .ahorro-list-header .header-content {
        gap: 0.5rem;
    }

    .ahorro-list-header .list-actions button {
        padding: 0.2rem 0.3rem !important;
        font-size: 0.6rem !important;
    }

    .ahorro-list-row td {
        padding: 0.4rem 0.5rem;
        font-size: 0.75rem;
    }

    .ahorro-list-row .date {
        padding-left: 0.5rem;
    }

    #ahorroCurrentMonthLabel {
        font-size: 1rem;
        min-width: 120px !important;
    }

    .list-navigation {
        gap: 0.5rem !important;
        padding: 0.5rem !important;
    }
}

/* Ultra-narrow screens (Fold 5 TWA / Small devices) */
@media (max-width: 350px) {

    .ahorro-list-header td,
    .ahorro-list-row td,
    .ahorro-list-empty-row td {
        padding: 0.3rem 0.4rem !important;
        font-size: 0.7rem !important;
    }

    .ahorro-list-header .header-content {
        gap: 0.2rem !important;
    }

    .list-actions {
        gap: 0.2rem !important;
    }

    .list-actions button {
        padding: 0.15rem 0.25rem !important;
        font-size: 0.55rem !important;
        min-width: unset !important;
    }

    .ahorro-list-row .date {
        padding-left: 0.2rem !important;
    }

    .ahorro-list-row .amount {
        font-size: 0.75rem !important;
    }

    .list-navigation {
        gap: 0.3rem !important;
        padding: 0.3rem 0.5rem !important;
    }

    #ahorroCurrentMonthLabel {
        font-size: 0.85rem !important;
        min-width: 100px !important;
    }
}

/* ── Bolsa Lista: compact table for narrow screens ────────────── */
@media (max-width: 600px) {

    #stockTable th,
    #stockTable td {
        padding: 0.4rem 0.4rem;
        font-size: 0.75rem;
    }

    #stockTable .sparkline-canvas {
        display: none;
    }
}

@media (max-width: 380px) {
    #stockTable {
        font-size: 0.65rem;
    }

    #stockTable th,
    #stockTable td {
        padding: 0.25rem 0.3rem;
        white-space: nowrap;
    }

    #stockTable:not(.bolsa-totals-compact) th:nth-child(2),
    #stockTable:not(.bolsa-totals-compact) td:nth-child(2),
    #stockTable:not(.bolsa-totals-compact) th:nth-child(4),
    #stockTable:not(.bolsa-totals-compact) td:nth-child(4),
    #stockTable:not(.bolsa-totals-compact) th:nth-child(9),
    #stockTable:not(.bolsa-totals-compact) td:nth-child(9) {
        display: none;
    }

    #stockTable .add-more-btn,
    #stockTable .details-btn {
        padding: 0.2rem 0.3rem !important;
        font-size: 0.8rem !important;
    }

    #stockTable .company-link {
        font-size: 0.65rem;
    }

    #stockTable .toggle-btn {
        font-size: 0.9rem !important;
    }

    #bolsaTotalesToggle {
        font-size: 0.7rem !important;
        padding: 0.2rem 0.5rem !important;
        margin-left: 5px !important;
    }
}

/* Medium screens: Hide non-essential columns in Bolsa list to avoid horizontal overflow */
@media (max-width: 900px) {
    #stockTable:not(.bolsa-totals-compact) th:nth-child(2),
    #stockTable:not(.bolsa-totals-compact) td:nth-child(2),
    #stockTable:not(.bolsa-totals-compact) th:nth-child(4),
    #stockTable:not(.bolsa-totals-compact) td:nth-child(4),
    #stockTable:not(.bolsa-totals-compact) th:nth-child(9),
    #stockTable:not(.bolsa-totals-compact) td:nth-child(9) {
        display: none;
    }
}
/* ── Unified Totales Toggle Button ─────────────── */
.totales-toggle-btn {
    padding: 0.3rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
}

.totales-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.totales-toggle-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ── Bolsa TOTALES compact table: narrow screens ─────────────── */
/* On very narrow screens hide G/P column — 3 cols fit much better */
@media (max-width: 380px) {

    /* Eliminamos el ocultar btc-gp porque el usuario quiere verlo.
       Para que quepan, reducimos la fuente un poco más. */

    table.bolsa-totals-compact th,
    table.bolsa-totals-compact td {
        font-size: 0.7rem !important;
        padding: 0.3rem 0.4rem !important;
        white-space: nowrap;
    }
}

/* ── Mobile Tooltip System ─────────────── */
.mobile-tooltip {
    position: fixed;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    padding: 8px 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    pointer-events: none;
    z-index: 9999;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    transform: translate(-50%, -100%) scale(0.8);
    opacity: 0;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease;
    white-space: nowrap;
}

.mobile-tooltip.visible {
    transform: translate(-50%, -130%) scale(1);
    opacity: 1;
}

/* Ensure buttons don't show default touch highlight during long press */
button,
.nav-item,
.btn-icon,
[title] {
    -webkit-tap-highlight-color: transparent;
}

.stock-web-link {
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.2);
    position: relative;
    z-index: 5;
}

.card-main-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.stock-web-link:hover {
    color: #3b82f6 !important;
    border-bottom-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 4px;
}

.card-web-view {
    position: absolute;
    inset: 0;
    background: #0f172a;
    z-index: 50 !important;
    border-radius: inherit;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
    color: white !important;
}

.bolsa-drawer.web-view-active {
    min-height: 420px !important;
    padding: 0 !important;
}

.card-web-view iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
    border-radius: 0 0 12px 12px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(59, 130, 246, 0.2);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Bolsa Highlights Animated Summary */
.highlights-container {
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 0.8rem 1.2rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.3);
}

.highlights-badge {
    background: linear-gradient(135deg, var(--primary) 0%, #1e40af 100%);
    color: white;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 0.3rem 0.8rem;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
    z-index: 2;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.highlights-ticker {
    display: flex;
    gap: 40px;
    animation: ticker-slide 30s linear infinite;
    width: max-content;
}

@keyframes ticker-slide {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-20%);
    }
}

.ticker-item {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
}

.ticker-label {
    opacity: 0.6;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.ticker-value {
    font-weight: 800;
}

.ticker-value.profit {
    color: var(--success);
}

.ticker-value.loss {
    color: var(--danger);
}

/* Animation for the container itself when appearing */
#bolsaHighlights:not(.hidden) {
    animation: slideDownIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDownIn {
    0% {
        opacity: 0;
        transform: translateY(-10px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fix for long names in drawers */
.bolsa-drawer .drawer-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

/* Breakdown Detail Styles */
.breakdown-row {
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.breakdown-row:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: var(--glass-border);
    transform: translateX(4px);
}

.breakdown-row:active {
    transform: scale(0.98);
}

#breakdownDetailList::-webkit-scrollbar {
    width: 6px;
}

#breakdownDetailList::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

#breakdownDetailList::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

#breakdownDetailList::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.navigation-arrows {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.btn-nav-arrow {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    line-height: 1;
    transition: all 0.2s;
}

.btn-nav-arrow:hover {
    background: var(--primary);
    border-color: var(--primary);
}

/* Nextcloud Sync Toggle */
.nc-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 18px;
}

.nc-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.nc-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.nc-slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

.nc-switch input:checked+.nc-slider {
    background-color: var(--success);
}

.nc-switch input:checked+.nc-slider:before {
    transform: translateX(18px);
}

.day-short {
    display: none;
}

@media (max-width: 480px) {
    .day-full {
        display: none;
    }

    .day-short {
        display: inline;
    }
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
    background: rgba(255, 255, 255, 0.02);
    padding: 10px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.calendar-day-head {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 700;
    opacity: 0.5;
    padding: 10px 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.calendar-cell {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 6px;
    justify-content: space-between;
    font-size: 0.7rem;
    position: relative;
    border: 1px solid transparent;
    transition: all 0.2s;
    min-height: 50px;
}

.calendar-cell.other-month {
    opacity: 0.2;
}

.calendar-cell.today {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

.calendar-cell-date {
    font-weight: 700;
    opacity: 0.8;
}

.calendar-cell-amount {
    font-weight: 800;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.1;
    width: 100%;
}

.calendar-cell-amount.income {
    color: var(--success);
}

.calendar-cell-amount.expense {
    color: var(--danger);
}

@media (max-width: 480px) {
    #ahorroGlobalCalendarGrid.calendar-grid {
        padding: 4px;
        gap: 2px;
    }

    #ahorroGlobalCalendarGrid .calendar-cell {
        padding: 3px;
        min-height: 80px !important;
        font-size: 0.6rem;
    }

    #ahorroGlobalCalendarGrid .calendar-cell-date {
        font-size: 0.65rem;
    }

    #ahorroGlobalCalendarGrid .calendar-cell-amount {
        font-size: 0.6rem !important;
    }

    #ahorroGlobalCalendarGrid .calendar-day-head {
        font-size: 0.55rem;
        padding: 5px 0;
    }
}

@media (max-width: 380px) {
    body {
        padding: 6px;
    }

    #appMain {
        padding: 4px;
    }

    .savings-container {
        padding: 0 2px;
    }

    #ahorroGlobalCalendarGrid.calendar-grid {
        padding: 0;
        gap: 1px;
    }

    #ahorroGlobalCalendarGrid .calendar-cell {
        padding: 1px;
        min-height: 60px !important;
    }

    #ahorroGlobalCalendarGrid .calendar-cell-amount {
        font-size: 0.5rem !important;
    }

    #ahorroGlobalCalendarGrid .calendar-day-head {
        font-size: 0.5rem;
        padding: 4px 0;
    }
}

@media (max-width: 480px) {

    #savingsCalendarModal .modal-content,
    #bolsaCalendarModal .modal-content {
        padding: 1.25rem 0.5rem;
        width: 100%;
        max-width: 100%;
    }

    .calendar-grid {
        gap: 1px;
        padding: 2px;
    }

    .calendar-day-head {
        font-size: 0.55rem;
        padding: 4px 0;
    }

    .calendar-cell {
        aspect-ratio: auto;
        padding: 2px;
        min-height: 38px;
        border-radius: 4px;
    }

    .calendar-cell-amount {
        font-size: 0.45rem;
    }

    .calendar-cell-date {
        font-size: 0.6rem;
    }
}

/* Ultra-narrow mobile fixes */
@media (max-width: 360px) {

    #savingsCalendarModal .modal-content,
    #bolsaCalendarModal .modal-content {
        padding: 0.75rem 0.4rem;
        width: 100%;
    }

    .calendar-cell {
        min-height: 32px;
        padding: 2px;
    }

    .calendar-cell-amount {
        font-size: 0.45rem;
    }

    .calendar-cell-date {
        font-size: 0.6rem;
    }
}


/* ── Tabla de Actividad Global ── */
#activityTable th {
    padding: 0.5rem 1rem !important;
}

#activityTable td {
    padding: 0.25rem 1rem !important;
    line-height: 1.4;
    vertical-align: middle;
}

#activityTable .activity-category-cell {
    padding: 0.2rem 1rem !important;
}

#activityTable .activity-category-cell .category-badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    display: inline-block;
    line-height: 1.4;
}

#activityTable .activity-category-cell .drawer-label {
    font-size: 0.7rem;
    opacity: 0.55;
    margin-top: 1px;
    padding-left: 2px;
    line-height: 1.2;
}

#activityTable .activity-actions-cell {
    padding: 0.15rem 0.5rem !important;
    text-align: center;
}

#activityTable .activity-actions-cell .actions-wrap {
    display: flex;
    gap: 3px;
    justify-content: center;
}

#activityTable tr:hover td {
    background: rgba(255, 255, 255, 0.025);
}

/* ── Botón ⋮ (menú móvil) ── */
.activity-menu-btn {
    display: none;
    /* oculto en desktop */
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    border-radius: 6px;
    padding: 2px 9px;
    cursor: pointer;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 1px;
    line-height: 1.4;
    transition: background 0.15s;
}

.activity-menu-btn:hover {
    background: rgba(255, 255, 255, 0.14);
}

/* ── Action Sheet flotante ── */
.activity-action-sheet {
    position: fixed;
    z-index: 9999;
    display: none;
    flex-direction: column;
    min-width: 178px;
    background: rgba(15, 23, 42, 0.97);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    padding: 0.4rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.04);
    transform-origin: top right;
    animation: sheetIn 0.14s ease-out;
}

.activity-action-sheet.visible {
    display: flex;
}

@keyframes sheetIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-4px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.sheet-header {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    padding: 0.4rem 0.85rem 0.3rem;
    opacity: 0.6;
}

.sheet-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 0.25rem 0.5rem;
}

.activity-sheet-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.85rem;
    border-radius: 9px;
    border: none;
    background: transparent;
    color: var(--text-main);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: left;
    width: 100%;
    transition: background 0.12s;
}

.activity-sheet-item:hover {
    background: rgba(255, 255, 255, 0.07);
}

.activity-sheet-item.danger {
    color: var(--danger);
}

.activity-sheet-item.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Compactar filas en móvil */
@media (max-width: 768px) {

    /* El contenedor no scrollea horizontalmente — la tabla se adapta */
    #activityTableContainer {
        overflow-x: hidden !important;
    }

    #activityTable {
        table-layout: fixed;
        width: 100%;
    }

    /* Sobrescribir anchos del colgroup para móvil */
    #activityTable col:nth-child(1) {
        width: 18% !important;
    }

    /* Fecha */
    #activityTable col:nth-child(2) {
        width: 28% !important;
    }

    /* Concepto */
    #activityTable col:nth-child(3) {
        width: 22% !important;
    }

    /* Categoría */
    #activityTable col:nth-child(4) {
        width: 22% !important;
    }

    /* Importe */
    #activityTable col:nth-child(5) {
        width: 10% !important;
    }

    /* Acción */

    #activityTable td,
    #activityTable th {
        padding: 0.2rem 0.4rem !important;
        font-size: 0.78rem !important;
        white-space: nowrap;
        overflow: hidden;
    }

    /* Truncar concepto con "..." */
    #activityTable .concept-cell {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 0;
        /* necesario junto con table-layout: fixed */
    }

    /* Ocultar el nombre de la cuenta en la celda de categoría */
    #activityTable .activity-category-cell .drawer-label {
        display: none;
    }

    /* Badge de categoría más compacto */
    #activityTable .activity-category-cell .category-badge {
        padding: 1px 5px;
        font-size: 0.72rem;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        display: inline-block;
        white-space: nowrap;
    }

    /* ── Columna Acción: ocultar botones, mostrar ⋮ ── */
    #activityTable .activity-actions-cell {
        padding: 0.1rem 0.3rem !important;
        text-align: center;
    }

    /* Ocultar los 3 botones individuales */
    #activityTable .activity-actions-cell .actions-wrap {
        display: none !important;
    }

    /* Mostrar el botón ⋮ */
    .activity-menu-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Fecha en formato corto */
    #activityTable td:nth-child(1) {
        font-size: 0.72rem !important;
    }

    /* Importe alineado a la derecha y compacto */
    #activityTable td:nth-child(4) {
        font-size: 0.8rem !important;
        text-align: right;
    }
}

/* Mobile refinement: Hide concepts in global calendar for small screens */
@media (max-width: 480px) {
    .calendar-cell-concepts {
        display: none !important;
    }

    #ahorroGlobalCalendarWrapper {
        padding: 0 !important;
        background: none !important;
        border: none !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
    }
}

/* Desktop refinement: Larger fonts and spacing for global calendar */
@media (min-width: 1025px) {
    .calendar-cell {
        font-size: 0.85rem;
        padding: 8px;
    }

    .calendar-cell-amount {
        font-size: 0.95rem !important;
        margin-bottom: 4px;
    }

    .calendar-cell-concepts {
        font-size: 0.65rem !important;
        gap: 5px !important;
        margin-top: 2px;
    }

    .calendar-cell-date {
        font-size: 0.9rem;
    }
}

/* --- Secure Delete All Button --- */
.submenu-item.locked {
    filter: grayscale(1);
    opacity: 0.4;
    cursor: not-allowed !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.submenu-item.locked:active {
    background: rgba(239, 68, 68, 0.1) !important;
}

.submenu-item.locked::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: var(--danger);
    width: var(--long-press-progress, 0%);
    transition: width 0.1s linear;
}

.submenu-item.activated {
    filter: none !important;
    opacity: 1 !important;
    cursor: pointer !important;
    background: rgba(239, 68, 68, 0.2) !important;
    border: 1px solid var(--danger) !important;
    animation: pulse-danger 1.5s infinite;
}

@keyframes pulse-danger {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* Estado Table Mobile Optimization */
@media (max-width: 600px) {
    .estado-table th,
    .estado-table td {
        padding: 0.5rem 0.4rem !important;
        font-size: 0.8rem !important;
    }
    
    #ahorroEstadoSection .dashboard-grid {
        gap: 0.75rem;
    }
    
    #ahorroEstadoSection .summary-card {
        padding: 1rem;
    }
    
    #ahorroEstadoSection .amount {
        font-size: 1.25rem;
    }
}
/* Welcome Overlay */
.welcome-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: radial-gradient(circle at center, rgba(30, 41, 59, 0.9) 0%, #0f172a 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.welcome-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(1.05);
}

.welcome-card {
    width: 100%;
    max-width: 440px;
    padding: 3.5rem 2.5rem;
    text-align: center;
    animation: welcomeFadeIn 1s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
}

@keyframes welcomeFadeIn {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

#welcomeGreeting {
    margin: 0;
    line-height: 1.2;
}

.welcome-info-item {
    transition: all 0.3s ease;
}

.welcome-info-item:hover {
    transform: translateY(-3px);
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.15);
}
