:root {
    --bg-color: #0f172a;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #38bdf8;
    --accent-glow: rgba(56, 189, 248, 0.5);
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --card-hover: rgba(51, 65, 85, 0.8);
    --success: #10b981;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --tooltip-bg: #1e293b;
}

[data-theme="light"] {
    --bg-color: #f1f5f9;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --glass-bg: #ffffff;
    --glass-border: rgba(0, 0, 0, 0.08);
    --card-hover: #ffffff;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    --tooltip-bg: #ffffff;
}

[data-theme="light"] .background-mesh {
    background: radial-gradient(circle at 50% 50%, rgba(56, 189, 248, 0.05), transparent 40%),
                radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.05), transparent 30%);
}

[data-theme="light"] input[type="range"] {
    background: rgba(0, 0, 0, 0.1);
}

/* Light mode: fix all rgba(255,...) backgrounds that become invisible on white */
[data-theme="light"] .overlap-box {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .bench-item {
    background: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .return-box {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] #top-holdings-list li {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .fund-stats {
    border-top-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .clean-list li {
    border-bottom-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .strategy-toggle {
    background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .modal-content {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .modal-overlay {
    background: rgba(15, 23, 42, 0.4);
}

[data-theme="light"] .modal-section h3 {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .modal-allocation-tip {
    background: rgba(16, 185, 129, 0.08);
    color: #065f46;
}

[data-theme="light"] .glass:hover {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .fund-card:hover {
    box-shadow: 0 10px 40px rgba(56, 189, 248, 0.1);
    border-color: rgba(56, 189, 248, 0.3);
}

/* Revamped Modern Institutional Loading Terminal */
#app-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh; /* dynamic viewport height — correctly excludes mobile browser chrome */
    background: #06080e;
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    z-index: 100000 !important;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    overflow: hidden;
    /* Safe-area insets for notched iPhones */
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

[data-theme="light"] #app-loading-overlay {
    background: #f8fafc;
}

#app-loading-overlay.active {
    display: flex !important;
    opacity: 1 !important;
}

/* Modern Technical Grid Background */
.loading-grid-pattern {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 28px 28px;
    z-index: 1;
    pointer-events: none;
}

[data-theme="light"] .loading-grid-pattern {
    background-image: 
        linear-gradient(rgba(0, 0, 0, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.02) 1px, transparent 1px);
}

/* Premium Soft Ambient Glows */
.ambient-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    -webkit-filter: blur(120px);
    opacity: 0.15;
    z-index: 1;
    pointer-events: none;
    animation: floatGlow 20s infinite alternate ease-in-out;
}

[data-theme="light"] .ambient-glow {
    opacity: 0.08;
    filter: blur(100px);
}

.glow-primary {
    width: 400px;
    height: 400px;
    background: #38bdf8;
    top: 15%;
    left: 10%;
}

.glow-secondary {
    width: 500px;
    height: 500px;
    background: #818cf8;
    bottom: 15%;
    right: 10%;
    animation-delay: -5s;
}

@keyframes floatGlow {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(40px, -60px) scale(1.1); }
    100% { transform: translate(-20px, 40px) scale(0.95); }
}

/* Sleek Minimalist Container */
.loader-container {
    background: rgba(15, 23, 42, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 2.2rem 2rem;
    width: 440px;
    max-width: 92%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
    margin: auto; /* ensures centering even in flex column layout */
    flex-shrink: 0;
}

[data-theme="light"] .loader-container {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.08);
}

/* Double-Ring Hologram spinner */
.hologram-wrapper {
    position: relative;
    width: 80px;
    height: 80px;
    margin-bottom: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hologram-ring {
    position: absolute;
    border-radius: 50%;
    border: 1.5px solid transparent;
}

.hologram-ring-outer {
    width: 80px;
    height: 80px;
    border-top-color: #38bdf8;
    border-bottom-color: rgba(56, 189, 248, 0.1);
    animation: spinClockwise 2.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.4));
}

.hologram-ring-inner {
    width: 56px;
    height: 56px;
    border-left-color: #818cf8;
    border-right-color: rgba(129, 140, 248, 0.1);
    animation: spinCounterClockwise 1.6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    filter: drop-shadow(0 0 6px rgba(129, 140, 248, 0.3));
}

.hologram-core {
    width: 10px;
    height: 10px;
    background-color: #10b981;
    border-radius: 50%;
    filter: drop-shadow(0 0 10px #10b981);
    animation: pulseCore 2s infinite alternate ease-in-out;
}

/* Brand Typography & Badge */
.terminal-brand {
    text-align: center;
    margin-bottom: 1.5rem;
    width: 100%;
}

.brand-title {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: 4px;
    color: #ffffff;
    margin-bottom: 6px;
}

[data-theme="light"] .brand-title {
    color: #0f172a;
}

.brand-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: #10b981;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.15);
    padding: 4px 12px;
    border-radius: 20px;
    text-transform: uppercase;
}

/* Premium Dynamic Progress Area */
.progress-section {
    width: 100%;
    margin-bottom: 1.8rem;
}

.progress-track-wrapper {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 2px;
    border-radius: 10px;
    margin-bottom: 8px;
}

[data-theme="light"] .progress-track-wrapper {
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.progress-track {
    width: 100%;
    height: 4px;
    background: transparent;
    border-radius: 8px;
    overflow: hidden;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #38bdf8, #818cf8, #c084fc);
    border-radius: 8px;
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.4);
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 600;
}

#loading-percent {
    color: #38bdf8;
    font-family: monospace;
}

#loading-subtext {
    color: #94a3b8;
    font-weight: 500;
}

[data-theme="light"] #loading-subtext {
    color: #475569;
}

/* Dynamic Boot Sequence Checklist */
.boot-sequence {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 1.5rem;
    padding: 0 4px;
}

.boot-step {
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
}

.step-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.step-label {
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

/* Boot Sequence Statuses */
.boot-step.pending {
    opacity: 0.35;
}

.boot-step.pending .step-indicator {
    background: transparent;
    border: 1.5px solid #64748b;
}

.boot-step.pending .step-label {
    color: #94a3b8;
}

[data-theme="light"] .boot-step.pending .step-label {
    color: #475569;
}

.boot-step.active {
    opacity: 1;
}

.boot-step.active .step-indicator {
    background: #38bdf8;
    border: 1.5px solid #38bdf8;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
    animation: activeStepPulse 1.2s infinite alternate ease-in-out;
}

.boot-step.active .step-label {
    color: #ffffff;
    font-weight: 600;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .boot-step.active .step-label {
    color: #0f172a;
}

.boot-step.completed {
    opacity: 0.85;
}

.boot-step.completed .step-indicator {
    background: #10b981;
    border: 1.5px solid #10b981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}

.boot-step.completed .step-label {
    color: #94a3b8;
    font-weight: 500;
}

[data-theme="light"] .boot-step.completed .step-label {
    color: #475569;
}

@keyframes activeStepPulse {
    0% { transform: scale(0.9); opacity: 0.6; }
    100% { transform: scale(1.15); opacity: 1; box-shadow: 0 0 14px rgba(56, 189, 248, 0.8); }
}

/* Monospace Live Console Feed Removed for ultra-minimalist layout */

/* Animations definition */
@keyframes spinClockwise {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes spinCounterClockwise {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(-360deg); }
}

@keyframes pulseCore {
    0% { transform: scale(0.8); opacity: 0.6; box-shadow: 0 0 8px #10b981; }
    100% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 18px #10b981; }
}

/* Responsive Overrides — Loading Screen */
@media (max-width: 480px) {
    #app-loading-overlay {
        /* Force true full-screen using both inset and dvh for maximum browser compat */
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        height: 100vh;
        height: 100dvh;
        width: 100vw;
        width: 100dvw;
        /* Center content reliably across all mobile browsers */
        display: flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    #app-loading-overlay:not(.active) {
        display: none !important;
    }

    .loader-container {
        padding: 1.8rem 1.4rem;
        border-radius: 16px;
        width: calc(100vw - 32px);
        max-width: 360px;
        margin: auto;
    }
    
    /* Constrain glows so they don't overflow and offset the layout */
    .glow-primary {
        width: 200px;
        height: 200px;
        top: 5%;
        left: -5%;
    }

    .glow-secondary {
        width: 250px;
        height: 250px;
        bottom: 5%;
        right: -5%;
    }

    .brand-title {
        font-size: 1.25rem;
        letter-spacing: 3px;
    }
    
    .boot-sequence {
        gap: 8px;
    }
    
    .boot-step .step-label {
        font-size: 0.8rem;
    }
    
    .live-console {
        height: 84px;
        padding: 10px 12px;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

html, body {
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    transition: background-color 0.3s ease;
    touch-action: manipulation;
}

/* Dynamic background mesh gradient */
.background-mesh {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 50% 50%, rgba(56, 189, 248, 0.15), transparent 40%),
                radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.15), transparent 30%);
    z-index: -1;
    animation: pulse 15s ease-in-out infinite alternate;
    transition: background 0.3s ease;
}

@keyframes pulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.05); }
}

.app-container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 2rem 4rem;
}

header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.8s ease-out;
}

#theme-toggle:hover #toggle-track {
    filter: brightness(1.1);
}

#theme-toggle:hover #toggle-knob {
    transform: scale(1.1);
}

h1 {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 0.5rem;
}

.highlight {
    color: var(--accent);
}

.highlight-text {
    background: linear-gradient(135deg, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.2rem;
    font-weight: 300;
}

/* Glassmorphism utility */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, background 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.glass:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    border-color: rgba(56, 189, 248, 0.4);
}

[data-theme="light"] .glass:hover {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
    border-color: rgba(56, 189, 248, 0.3);
}

.dashboard {
    margin-bottom: 3rem;
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

.info-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: help;
}

.tooltip-content {
    position: absolute;
    bottom: 150%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    width: 300px;
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-muted);
    background: var(--tooltip-bg);
    border: 1px solid var(--glass-border);
    border-left: 3px solid #34d399;
    box-shadow: var(--shadow);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
    pointer-events: none;
}

.info-tooltip:hover .tooltip-content {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Premium Tooltip System */
.tooltip-container {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: help;
}

.tooltip-content {
    visibility: hidden;
    width: 220px;
    background: rgba(15, 23, 42, 0.95);
    color: #fff;
    text-align: left;
    border-radius: 10px;
    padding: 12px;
    position: absolute;
    z-index: 1000;
    bottom: 140%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.5;
    pointer-events: none;
    border: 1px solid rgba(99, 102, 241, 0.4);
    box-shadow: 0 12px 30px rgba(0,0,0,0.6);
    backdrop-filter: blur(10px);
}

.tooltip-container:hover .tooltip-content {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.tooltip-content::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: rgba(15, 23, 42, 0.95) transparent transparent transparent;
}

[data-theme="light"] .tooltip-content {
    background: rgba(255, 255, 255, 0.98);
    color: #0f172a;
    border-color: rgba(99, 102, 241, 0.2);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

[data-theme="light"] .tooltip-content::after {
    border-color: rgba(255, 255, 255, 0.98) transparent transparent transparent;
}

.ratio-desc {
    margin-top: auto;
}

.insights-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
    align-items: center;
}

.chart-container {
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
}

.commentary-container h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--accent);
}

.commentary-container p {
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.card h3 {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.card .value {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.card.primary {
    border: 1px solid var(--accent);
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.1);
}

.sub-value {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.value-obscured {
    color: transparent !important;
    background: transparent !important;
    -webkit-text-fill-color: transparent !important;
    user-select: none;
    position: relative;
}

.value-obscured::after {
    content: "••••••••";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-main);
    -webkit-text-fill-color: var(--text-main);
    letter-spacing: 4px;
    font-size: 2.8rem;
    font-weight: 800;
    opacity: 0.5;
    pointer-events: none;
}

#toggle-value-btn:hover {
    color: var(--accent) !important;
    transform: scale(1.1);
}

/* Slider styling */
.slider-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    font-size: 1.1rem;
    font-weight: 500;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 10px var(--accent-glow);
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Funds Section */
.funds-section {
    animation: fadeInUp 0.8s ease-out 0.4s both;
}

.funds-section h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.section-desc {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.insights-grid, .dashboard, .xray-grid, .funds-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.5rem;
    align-items: stretch;
}

.fund-card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.fund-name {
    font-weight: 600;
    font-size: 1.1rem;
    line-height: 1.4;
}

.fund-stats {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.stat-group {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-val {
    font-weight: 500;
    font-size: 1.1rem;
}

.sip-val {
    color: var(--accent);
    font-weight: 700;
    font-size: 1.3rem;
}

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

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.loading-dots::after {
    content: ' .';
    animation: loading-dots 1.5s steps(5, end) infinite;
}

@keyframes loading-dots {
    0%, 20% { content: ' .'; }
    40% { content: ' . .'; }
    60% { content: ' . . .'; }
    80%, 100% { content: ''; }
}

/* Responsive */
@media (max-width: 768px) {
    h1 { font-size: 2.2rem; }
    .app-container { padding: 1.5rem; }
    .card .value { font-size: 2rem; }
    .modal-content { width: 95%; margin: 5% auto; }
    .modal-content h2 {
        font-size: 1.35rem !important;
        line-height: 1.4 !important;
        padding-right: 3.2rem !important; /* Ensure breathing room so it wraps and never overlaps with the absolute close button */
    }
    
    .categories-card-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }
    
    #search-btn {
        left: 0 !important;
        top: 54px !important;
    }
    
    /* Ensure 3-column layout persists unless extremely narrow */
    .dashboard, .insights-grid { 
        grid-template-columns: repeat(3, minmax(0, 1fr)); 
        gap: 1rem;
    }
    
    /* Horizontal Swipeable Carousel for Funds */
    .funds-grid {
        display: flex;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        scroll-behavior: smooth;
        gap: 1rem;
        padding-bottom: 1.5rem; /* aesthetic padding */
        -webkit-overflow-scrolling: touch;
        /* Hide scrollbar */
        -ms-overflow-style: none;  
        scrollbar-width: none;  
    }
    
    .funds-grid::-webkit-scrollbar {
        display: none;
    }
    
    .funds-grid .fund-card {
        min-width: 85vw;
        scroll-snap-align: center;
        flex: 0 0 auto;
    }

    /* Horizontal Swipeable Carousel for Portfolio X-Ray */
    .xray-grid {
        display: flex;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        scroll-behavior: smooth;
        gap: 1rem;
        padding-bottom: 1.5rem; /* aesthetic padding */
        -webkit-overflow-scrolling: touch;
        /* Hide scrollbar */
        -ms-overflow-style: none;  
        scrollbar-width: none;  
    }
    
    .xray-grid::-webkit-scrollbar {
        display: none;
    }
    
    .xray-grid .card {
        width: 74vw;
        max-width: 74vw;
        scroll-snap-align: start;
        flex: 0 0 auto;
        padding: 1.1rem !important;
        min-height: 380px !important;
    }
    
    .xray-grid #drawdown-resilience-card,
    .xray-grid #efficiency-profile-card,
    .xray-grid #top-holdings-risk-card {
        min-height: 350px !important;
    }
    
    .xray-grid #true-allocation-insight,
    .xray-grid #sectoral-allocation-insight {
        min-height: auto !important;
        padding-top: 0.5rem !important;
        margin-top: 0.5rem !important;
    }

    .xray-grid .card ul.clean-list li {
        padding: 0.25rem 0px !important;
    }

    .xray-grid .card .split-bar-container {
        margin-top: 0.75rem !important;
    }

    .xray-grid .card h3 {
        font-size: 1.05rem !important;
        margin-bottom: 0.6rem !important;
    }

    .xray-grid .card p {
        font-size: 0.72rem !important;
        margin-bottom: 0.6rem !important;
        line-height: 1.35 !important;
    }

    .xray-grid .card .ratio-desc {
        font-size: 0.72rem !important;
        padding-top: 0.5rem !important;
        margin-top: 0.5rem !important;
    }

    .xray-grid .overlap-box {
        padding: 0.75rem !important;
        margin-bottom: 0.6rem !important;
        gap: 10px !important;
    }

    .xray-grid .overlap-pct-badge {
        width: 40px !important;
        height: 40px !important;
        border-radius: 8px !important;
    }

    .xray-grid .overlap-pct-badge span {
        font-size: 0.95rem !important;
    }

    .xray-grid #efficiency-metrics-list li {
        padding: 0.3rem 0.4rem !important;
    }

    .xray-grid #efficiency-metrics-list li div svg {
        width: 16px !important;
        height: 16px !important;
    }

    .xray-grid #efficiency-metrics-list li div span {
        font-size: 0.85rem !important;
    }

    .xray-grid #efficiency-metrics-list li span[id^="port-"] {
        font-size: 0.95rem !important;
    }

    .xray-grid #top-four-funds-list li {
        padding: 0.35rem 0px !important;
        gap: 4px !important;
    }

    #strategic-reallocation-grid {
        grid-template-columns: 1fr !important;
    }

    /* Carousel Indicators for Mobile */
    .carousel-dots {
        display: flex;
        justify-content: center;
        gap: 8px;
        margin-top: 0.5rem;
        margin-bottom: 1.5rem;
    }
    
    .carousel-dots .dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.2);
        transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        cursor: pointer;
    }
    
    .carousel-dots .dot.active {
        background: var(--accent);
        transform: scale(1.2);
    }
    
    [data-theme="light"] .carousel-dots .dot {
        background: rgba(15, 23, 42, 0.15);
    }
    
    [data-theme="light"] .carousel-dots .dot.active {
        background: var(--accent);
    }
}

@media (max-width: 580px) {
    .dashboard, .insights-grid { 
        grid-template-columns: 1fr; 
    }
}

/* General styles for Carousel Dots (Hidden on Desktop) */
.carousel-dots {
    display: none;
}


/* X-Ray Section Override */
.xray-grid .card {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.xray-grid > .card {
    min-height: 460px;
}

.split-bar-container {
    margin-top: 1rem;
}

.split-bar {
    display: flex;
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 0.8rem;
}

.split-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    font-size: 0.85rem;
    font-weight: 500;
}

.overlap-box {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    background: rgba(255,255,255,0.03);
    padding: 0.7rem;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.05);
}

.overlap-stat {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1;
    min-width: 45px;
}

.clean-list {
    list-style: none;
    margin-top: 1rem;
}

.clean-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.6rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 0.95rem;
}

.clean-list li:last-child {
    border-bottom: none;
}

.benchmark-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-top: 1rem;
}

.bench-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.03);
    padding: 0.8rem;
    border-radius: 6px;
    font-size: 0.95rem;
}

.badge {
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge.positive {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.badge.negative {
    background: rgba(248, 113, 113, 0.2);
    color: #f87171;
}

/* Strategy Toggle */
.section-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 2rem;
}

.strategy-toggle {
    display: flex;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    padding: 4px;
}

.strategy-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
}

.strategy-btn.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

/* Clickable Fund Cards */
.fund-card {
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.fund-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 10px 40px rgba(56, 189, 248, 0.15);
    border-color: rgba(56, 189, 248, 0.4);
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-color);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    position: relative;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid var(--glass-border);
}

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

.close-btn {
    position: absolute;
    top: 1.2rem;
    right: 1.2rem;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent);
    color: var(--accent);
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.2);
}

.close-btn:active {
    transform: rotate(90deg) scale(0.95);
}

#modal-fund-name {
    padding-right: 3rem;
    margin-bottom: 2rem;
    font-size: 1.8rem;
    color: var(--accent);
}

.modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.modal-section h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--text-main);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 0.5rem;
}

.returns-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.return-box {
    background: rgba(255,255,255,0.03);
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid rgba(255,255,255,0.05);
}

.return-box .timeframe {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.return-box .return-val {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--success);
}

.ratio-item {
    margin-bottom: 1.5rem;
}

.ratio-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.ratio-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.ratio-val {
    font-family: monospace;
    font-size: 1.2rem;
    color: var(--accent);
    background: rgba(56, 189, 248, 0.1);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
}

.ratio-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.3;
    margin-top: 1rem;
    display: block;
}

.xray-grid .card .ratio-desc {
    margin-top: auto;
    padding-top: 1rem;
}

#true-allocation-insight,
#sectoral-allocation-insight {
    min-height: 190px;
}

#drawdown-resilience-card,
#efficiency-profile-card,
#top-holdings-risk-card {
    min-height: 380px;
}

#top-holdings-list li {
    background: rgba(255,255,255,0.03);
    margin-bottom: 0.5rem;
    padding: 0.8rem 1rem;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    border: 1px solid rgba(255,255,255,0.05);
}

.holding-name {
    font-weight: 500;
}

.holding-weight {
    color: var(--accent);
    font-weight: 600;
}

.modal-allocation-tip {
    margin-top: 2rem;
    padding: 1rem;
    background: rgba(16, 185, 129, 0.1);
    border-left: 4px solid var(--success);
    border-radius: 4px;
    color: #d1fae5;
    font-size: 0.95rem;
    line-height: 1.5;
}
.portfolio-table th {
    border-bottom: 1px solid var(--glass-border);
}

.portfolio-table td {
    padding: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    font-size: 0.9rem;
    color: var(--text-main);
}

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

.portfolio-table input {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 6px 10px;
    border-radius: 4px;
    width: 120px;
}

.delete-fund {
    color: #ef4444;
    cursor: pointer;
    font-size: 1.2rem;
    background: none;
    border: none;
    opacity: 0.6;
    transition: opacity 0.3s;
}

.delete-fund:hover {
    opacity: 1;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Terminal Footer */
.terminal-footer {
    margin-top: 4rem;
    padding: 4rem 2rem 2rem;
    border-top: 1px solid var(--glass-border);
    background: linear-gradient(to bottom, transparent, rgba(15, 23, 42, 0.5));
}

[data-theme="light"] .terminal-footer {
    background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.02));
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.footer-top {
    display: flex;
    justify-content: space-between;
    gap: 4rem;
    margin-bottom: 3rem;
}

.footer-brand {
    max-width: 300px;
}

.footer-logo {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    display: block;
}

.footer-brand p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
}

.footer-links {
    display: flex;
    gap: 4rem;
}

.link-group h4 {
    color: var(--text-main);
    font-size: 0.9rem;
    margin-bottom: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.link-group a {
    display: block;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    margin-bottom: 0.8rem;
    transition: color 0.3s;
}

.link-group a:hover {
    color: var(--accent);
}

.footer-bottom {
    padding-top: 2rem;
    border-top: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.disclaimer {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.6;
    max-width: 800px;
}

.copyright {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.version-tag {
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

@media (max-width: 768px) {
    .footer-top {
        flex-direction: column;
        gap: 2rem;
    }
    .footer-links {
        gap: 2rem;
    }
}

/* Back to Top */
#back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 40px;
    height: 40px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
    z-index: 100;
}

#back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

#back-to-top:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(56, 189, 248, 0.4);
}

/* Portfolio Architect Theme Support */
:root {
    --accent-rgb: 56, 189, 248;
}

.architect-table-container {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
}

[data-theme="light"] .architect-table-container {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.08);
}

.architect-form-container {
    background: rgba(var(--accent-rgb), 0.05);
    border: 1px solid rgba(var(--accent-rgb), 0.1);
    border-radius: 16px;
}

[data-theme="light"] .architect-form-container {
    background: rgba(var(--accent-rgb), 0.03);
    border-color: rgba(var(--accent-rgb), 0.15);
}

.architect-input {
    background: rgba(0, 0, 0, 0.3) !important;
    border: 1px solid var(--glass-border) !important;
    color: white !important;
}

[data-theme="light"] .architect-input {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.12) !important;
    color: #0f172a !important;
}

.architect-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

[data-theme="light"] .architect-input::placeholder {
    color: rgba(0, 0, 0, 0.3);
}

.close-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

[data-theme="light"] .close-btn {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
    color: #4b5563;
}

[data-theme="light"] .close-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #1f2937;
}

#portfolio-manage-body tr {
    border-bottom: 1px solid var(--glass-border);
}

#portfolio-manage-body tr:last-child {
    border-bottom: none;
}

@keyframes live-pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.6; }
    100% { transform: scale(1); opacity: 1; }
}

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

/* Responsive Portfolio Architect (Smartphone Optimization) */
@media (max-width: 768px) {
    #settings-modal .modal-content {
        padding: 1.5rem !important;
        width: 100% !important;
        height: 100% !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
    }

    #add-fund-form {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    #add-fund-form button {
        width: 100% !important;
        margin-top: 0.5rem;
    }

    .architect-table-container {
        background: transparent !important;
        border: none !important;
    }

    .architect-table-container table, 
    .architect-table-container thead, 
    .architect-table-container tbody, 
    .architect-table-container th, 
    .architect-table-container td, 
    .architect-table-container tr { 
        display: block; 
    }

    .architect-table-container thead tr { 
        position: absolute; 
        top: -9999px; 
        left: -9999px; 
    }

    #portfolio-manage-body tr { 
        border: 1px solid var(--glass-border); 
        margin-bottom: 1.5rem; 
        border-radius: 12px; 
        padding: 1rem;
        background: rgba(255, 255, 255, 0.02);
        box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    }

    #portfolio-manage-body td { 
        border: none; 
        position: relative; 
        padding: 0.8rem 0 0.8rem 45% !important; 
        text-align: right !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    #portfolio-manage-body td:last-child {
        border-bottom: none;
        display: flex;
        justify-content: flex-end;
    }

    #portfolio-manage-body td:before { 
        content: attr(data-label); 
        position: absolute; 
        left: 0; 
        width: 40%; 
        text-align: left; 
        font-weight: 600; 
        color: var(--text-muted); 
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        top: 50%;
        transform: translateY(-50%);
    }

    #portfolio-manage-body td input {
        width: 120px !important;
        text-align: right;
    }

    .architect-form-container {
        padding: 1.2rem !important;
        margin-bottom: 1.5rem !important;
    }

    #settings-modal div[style*="display: flex; justify-content: space-between"] {
        flex-direction: column !important;
        gap: 1rem !important;
    }

    #save-portfolio {
        width: 100% !important;
        padding: 1rem !important;
    }
    
    #reset-portfolio {
        width: 100% !important;
    }

    .architect-scroll-top-btn {
        display: none;
        position: fixed;
        bottom: 2rem;
        right: 2rem;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background-color: var(--accent);
        color: white;
        border: none;
        cursor: pointer;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
        z-index: 10000;
        align-items: center;
        justify-content: center;
        opacity: 0;
        transition: opacity 0.2s, transform 0.2s;
    }

    .architect-scroll-top-btn.visible {
        display: flex;
        opacity: 1;
    }
}

.architect-scroll-top-btn {
    display: none;
}

/* Fund modal scroll-to-top button */
.fund-modal-scroll-top-btn {
    position: fixed;
    bottom: 2.5rem;
    right: 2.5rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #a855f7);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.45), 0 0 0 2px rgba(255,255,255,0.08);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease, box-shadow 0.2s ease;
    transform: translateY(8px) scale(0.92);
}

.fund-modal-scroll-top-btn.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.fund-modal-scroll-top-btn:hover {
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.6), 0 0 0 2px rgba(255,255,255,0.12);
    transform: translateY(-2px) scale(1.06);
}

.fund-modal-scroll-top-btn:active {
    transform: scale(0.97);
}


.spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(168, 85, 247, 0.2);
    border-top: 2px solid #a855f7;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.hover-lift:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.15);
    border-color: rgba(168, 85, 247, 0.3) !important;
}

/* Welcome Import Overlay */
#welcome-import-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 14, 23, 0.96);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    z-index: 9998;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    overflow-y: auto;
}

[data-theme="light"] #welcome-import-overlay {
    background: rgba(241, 245, 249, 0.98);
}

#welcome-import-overlay.active {
    display: flex !important;
}

.welcome-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 20px;
    padding: 3.5rem 3rem;
    max-width: 1100px;
    width: 100%;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: relative;
    z-index: 10;
    text-align: center;
}

[data-theme="light"] .welcome-card {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.06);
}

.welcome-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    text-align: left;
}

.welcome-column {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.3s;
}

[data-theme="light"] .welcome-column {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.06);
}

@media (max-width: 950px) {
    .welcome-card {
        padding: 2.2rem 1.2rem;
        border-radius: 16px;
        max-width: 600px;
    }
    
    #welcome-import-overlay {
        padding: 1.5rem 1rem;
    }

    .welcome-grid {
        grid-template-columns: 1fr;
        gap: 1.2rem;
    }

    .welcome-column {
        padding: 1.2rem;
    }
}

#welcome-manual-form input {
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: white !important;
}

#welcome-manual-form input::placeholder {
    color: rgba(255, 255, 255, 0.4) !important;
}

[data-theme="light"] #welcome-manual-form input {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.12) !important;
    color: #0f172a !important;
}

[data-theme="light"] #welcome-manual-form input::placeholder {
    color: rgba(0, 0, 0, 0.4) !important;
}

/* Mobile Bottom Navigation Bar */
.mobile-bottom-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--glass-border);
    z-index: 1000;
    padding-top: 0.6rem;
    padding-bottom: calc(0.6rem + env(safe-area-inset-bottom, 0px));
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.5s ease-in-out;
    transform: translateY(0);
    opacity: 1;
}

.mobile-bottom-bar.scrolling-hidden {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
}

.mobile-bottom-bar ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.mobile-bottom-bar li {
    flex: 1;
    text-align: center;
}

.mobile-bottom-bar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.3s;
}

.mobile-bottom-bar a svg {
    width: 20px;
    height: 20px;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.mobile-bottom-bar a.active-nav {
    color: var(--accent) !important;
}

.mobile-bottom-bar a.active-nav svg {
    opacity: 1 !important;
}

/* Subtle desktop-only hover effects, completely isolated from mobile touch/focus states */
@media (hover: hover) {
    .mobile-bottom-bar a:hover {
        color: var(--accent);
    }
    .mobile-bottom-bar a:hover svg {
        opacity: 0.9;
    }
}

.mobile-bottom-bar.keyboard-hidden {
    display: none !important;
}

[data-theme="light"] .mobile-bottom-bar {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.05);
}

@media (max-width: 768px) {
    .mobile-bottom-bar {
        display: block;
    }
    
    body {
        padding-bottom: 70px;
    }
    
    .app-container {
        padding-bottom: 70px;
    }
    
    #back-to-top {
        display: none !important;
    }
}

/* Biometric Lock Screen Overlay */
.lock-screen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    opacity: 1;
    transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.6s;
}

[data-theme="light"] .lock-screen-overlay {
    background: rgba(255, 255, 255, 0.85);
}

.lock-screen-content {
    background: rgba(255, 255, 255, 0.05);
    padding: 3rem 2rem;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 400px;
}

[data-theme="light"] .lock-screen-content {
    background: rgba(255, 255, 255, 0.7);
}

[data-theme="light"] .lock-screen-content h2 {
    color: #0f172a !important;
}

[data-theme="light"] .lock-screen-content p {
    color: #475569 !important;
}

/* --- Portfolio Architect Slider & Text Input Styles --- */
.edit-fund-value-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    transition: background 0.3s, opacity 0.2s;
    cursor: pointer;
    margin-top: 4px;
}

[data-theme="light"] .edit-fund-value-slider {
    background: rgba(0, 0, 0, 0.08);
}

.edit-fund-value-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
    cursor: pointer;
    transition: transform 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.edit-fund-value-slider::-webkit-slider-thumb:hover {
    transform: scale(1.35);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.8);
}

.edit-fund-value-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
    cursor: pointer;
    transition: transform 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.edit-fund-value-slider::-moz-range-thumb:hover {
    transform: scale(1.35);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.8);
}

/* Aesthetic units text input */
.edit-fund-units.architect-input {
    background: rgba(0, 0, 0, 0.25) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 8px !important;
    color: white !important;
    padding: 0.5rem 0.8rem !important;
    font-family: monospace !important;
    font-size: 0.9rem !important;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.edit-fund-units.architect-input:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.15), inset 0 2px 4px rgba(0,0,0,0.1);
    outline: none;
}

[data-theme="light"] .edit-fund-units.architect-input {
    background: #ffffff !important;
    border-color: rgba(0, 0, 0, 0.12) !important;
    color: #0f172a !important;
}

[data-theme="light"] .edit-fund-units.architect-input:focus {
    border-color: var(--accent) !important;
}

/* --- CSV Ingestion Hub Modal Styles --- */
.csv-templates-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
    margin-top: 1.5rem;
}

.csv-template-card {
    background: rgba(255, 255, 255, 0.02);
    border: 2px solid var(--glass-border);
    border-radius: 12px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

[data-theme="light"] .csv-template-card {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.08);
}

.csv-template-card:hover {
    transform: translateY(-4px);
    border-color: rgba(56, 189, 248, 0.3);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.csv-template-card.active {
    border-color: var(--accent) !important;
    background: rgba(56, 189, 248, 0.04);
    box-shadow: 0 8px 32px rgba(56, 189, 248, 0.15);
}

[data-theme="light"] .csv-template-card.active {
    background: rgba(56, 189, 248, 0.05);
}

.sample-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(56, 189, 248, 0.08);
    color: var(--accent);
    border: 1px solid rgba(56, 189, 248, 0.25);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    text-decoration: none;
    margin-top: 1rem;
    transition: all 0.2s ease;
    align-self: flex-start;
}

.sample-download-btn:hover {
    background: var(--accent);
    color: white;
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.25);
    transform: translateY(-1px);
}

.csv-upload-dropzone {
    border: 2px dashed var(--glass-border);
    border-radius: 12px;
    padding: 2.2rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.01);
    transition: all 0.3s ease;
    cursor: pointer;
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

[data-theme="light"] .csv-upload-dropzone {
    background: rgba(0, 0, 0, 0.005);
}

.csv-upload-dropzone:hover {
    border-color: var(--accent);
    background: rgba(56, 189, 248, 0.02);
}

.csv-upload-dropzone p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-main);
}

.csv-upload-dropzone span {
    font-size: 0.78rem;
    color: var(--text-muted);
}

@media (max-width: 640px) {
    .csv-templates-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

#csv-template-modal {
    z-index: 9999 !important;
}

/* ==========================================================================
   Mutual Fund Search & Category Explorer Premium Styles
   ========================================================================== */

#search-btn:hover {
    background: rgba(255,255,255,0.1) !important;
    border-color: rgba(56, 189, 248, 0.4) !important;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
    transform: scale(1.05);
}

#search-btn:active {
    transform: scale(0.95);
}

.search-input-wrapper input:focus {
    background: rgba(255, 255, 255, 0.06) !important;
    border-color: var(--accent) !important;
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.2) !important;
}

[data-theme="light"] .search-input-wrapper input {
    background: rgba(0, 0, 0, 0.02) !important;
    color: var(--text-main) !important;
}

[data-theme="light"] .search-input-wrapper input:focus {
    background: #ffffff !important;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.15) !important;
}

/* Sleek Compact Category Grid Layout */
.categories-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 8px;
    margin-bottom: 1.2rem;
}

.category-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    cursor: pointer;
    display: grid;
    grid-template-areas: 
        "icon title"
        "icon subtitle";
    grid-template-columns: auto 1fr;
    align-items: center;
    column-gap: 12px;
    row-gap: 2px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.category-card:hover {
    background: rgba(56, 189, 248, 0.03);
    border-color: var(--accent);
    transform: translateY(-1.5px);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.08);
}

.category-card .icon-wrapper {
    grid-area: icon;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    transition: all 0.3s ease;
}

.category-card .icon-wrapper svg {
    width: 18px;
    height: 18px;
}

.category-card:hover .icon-wrapper {
    background: rgba(56, 189, 248, 0.1);
    border-color: var(--accent);
    transform: scale(1.05);
}

.category-card .card-title {
    grid-area: title;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.2;
}

.category-card .card-subtitle {
    grid-area: subtitle;
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.1;
}

[data-theme="light"] .category-card {
    background: rgba(0, 0, 0, 0.015);
    border-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .category-card:hover {
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04);
    border-color: var(--accent);
}

[data-theme="light"] .category-card .icon-wrapper {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.06);
}

/* Back navigation button */
.search-back-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: 30px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
    font-family: inherit;
    outline: none;
    margin-bottom: 1rem;
}

.search-back-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateX(-2px);
}

[data-theme="light"] .search-back-btn {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.06);
    color: var(--text-muted);
}

[data-theme="light"] .search-back-btn:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-main);
}

.searched-fund-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 1.5rem;
    min-height: 75px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden; /* Prevent layout twitch when loading starts */
}

.searched-fund-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
    z-index: 2;
}

.searched-fund-card.loading {
    pointer-events: none;
    opacity: 0.7;
    background: rgba(255, 255, 255, 0.04);
    /* Retain hovered transform & shadow styles to prevent card from snapping smaller during fetch load */
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
    border-color: rgba(56, 189, 248, 0.4);
}

.searched-fund-card.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(56, 189, 248, 0.1), transparent);
    animation: shimmer 1.5s infinite;
}

[data-theme="light"] .searched-fund-card {
    background: rgba(0, 0, 0, 0.015);
    border-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .searched-fund-card:hover {
    background: #ffffff;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.04);
    border-color: var(--accent);
    z-index: 2;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

#search-results-list::-webkit-scrollbar {
    width: 6px;
}

#search-results-list::-webkit-scrollbar-track {
    background: transparent;
}

#search-results-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}

#search-results-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.16);
}

[data-theme="light"] #search-results-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] #search-results-list::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.16);
}

@media (max-width: 768px) {
    #search-modal .modal-content {
        padding: 1.5rem !important;
        width: 95vw !important;
        max-height: 85vh !important;
    }
    .categories-pill-grid {
        max-height: 120px;
        overflow-y: auto;
        padding-bottom: 5px;
    }
    .searched-fund-card {
        padding: 1.1rem 1.4rem !important;
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
    }
    .searched-fund-card .fund-right-meta {
        align-self: flex-end;
        text-align: right;
    }
}

/* Add to Portfolio panel in detail modal */
.modal-add-portfolio-panel {
    display: none;
    margin-top: -1rem;
    margin-bottom: 2rem;
    padding: 1.2rem;
    background: rgba(16, 185, 129, 0.05);
    border: 1px solid rgba(16, 185, 129, 0.15);
    border-left: 4px solid var(--success);
    border-radius: 10px;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

[data-theme="light"] .modal-add-portfolio-panel {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.25);
}

.modal-add-portfolio-info {
    flex: 1;
    min-width: 200px;
}

.modal-add-portfolio-info h4 {
    margin: 0 0 4px 0;
    color: var(--success);
    font-weight: 600;
    font-size: 0.95rem;
}

.modal-add-portfolio-info p {
    margin: 0;
    font-size: 0.76rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.modal-add-portfolio-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.modal-add-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.modal-add-input-wrapper span {
    position: absolute;
    left: 10px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.modal-add-input-wrapper input {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 0.4rem 0.6rem 0.4rem 1.6rem;
    color: var(--text-main);
    font-size: 0.8rem;
    width: 120px;
    outline: none;
    font-family: inherit;
    transition: all 0.2s ease;
}

[data-theme="light"] .modal-add-input-wrapper input {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: var(--text-main);
}

.modal-add-input-wrapper input:focus {
    border-color: var(--success);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.15);
}

#modal-add-to-portfolio-btn {
    background: var(--success);
    color: white;
    border: none;
    padding: 0.45rem 1rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}

#modal-add-to-portfolio-btn:hover {
    background: #059669;
    transform: translateY(-1px);
}

@media (max-width: 768px) {
    .modal-add-portfolio-panel {
        flex-direction: column;
        align-items: stretch !important;
        gap: 15px;
        padding: 1rem;
    }
    .modal-add-portfolio-actions {
        width: 100%;
        justify-content: space-between;
    }
    .modal-add-input-wrapper {
        flex: 1;
    }
    .modal-add-input-wrapper input {
        width: 100%;
        font-size: 16px !important; /* Prevents auto-zoom on input focus in iOS */
    }
    #modal-add-to-portfolio-btn {
        flex: 1;
        justify-content: center;
    }
    input, select, textarea {
        font-size: 16px !important; /* Global safety override to prevent iOS Safari auto-zoom on form element focus */
    }
}

#current-value { transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); }

/* Sleek Top Loading Progress Bar */
#top-loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3.5px;
    background: linear-gradient(90deg, #38bdf8, #818cf8, #38bdf8);
    background-size: 200% 100%;
    box-shadow: 0 1px 10px rgba(56, 189, 248, 0.5), 0 0 5px rgba(129, 140, 248, 0.5);
    z-index: 200000;
    opacity: 0;
    pointer-events: none;
    transition: width 0.4s cubic-bezier(0.1, 0.8, 0.3, 1), opacity 0.4s ease, background 0.3s ease;
    animation: loadingShimmer 2s linear infinite;
}

/* Floating Loading Status Toast */
#loading-status-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 10px 18px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    z-index: 200000;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

[data-theme="light"] #loading-status-toast {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
}

#loading-status-toast.active {
    opacity: 1;
    transform: translateY(0);
}

.toast-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--accent);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: flex;
    align-items: center;
    justify-content: center;
}

#toast-text {
    font-size: 0.82rem;
    color: var(--text-main);
    font-weight: 600;
}

#toast-percent {
    font-size: 0.74rem;
    color: var(--accent);
    font-weight: 700;
    font-family: monospace;
    background: rgba(56, 189, 248, 0.15);
    padding: 2px 7px;
    border-radius: 6px;
    transition: all 0.3s ease;
}

[data-theme="light"] #toast-percent {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent);
}

@keyframes loadingShimmer {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

/* Stock Modal Stats Grid */
.stock-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 520px) {
    .stock-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
