:root {
    --bg-color: linear-gradient(180deg, #3f6386 0%, #131314 100%);
    --surface-color: #1e1f20;
    --surface-container: #282a2c;
    --text-primary: #e3e3e3;
    --text-secondary: #c4c7c5;
    --accent-gradient: linear-gradient(90deg, #3b82f6, #60a5fa);
    --sidebar-width: 280px;
    --sidebar-collapsed: 72px;
    --transition-curve: cubic-bezier(0.2, 0, 0, 1);
    --transition: width 0.4s var(--transition-curve), background-color 0.3s ease;
    --border-color: rgba(255, 255, 255, 0.05);

    --glass-bg: rgba(30, 31, 32, 0.65);
    --glass-blur: 24px;
    --glass-saturate: 180%;
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-inner-glow: inset 0 1px 1px rgba(255, 255, 255, 0.05);

    --squircle-radius: 32px;
    --input-radius: 18px;
}

/* Enhanced Light Theme following Google Standard Font Color Guide */
body.light-theme {
    --bg-color: linear-gradient(180deg, #e0f2fe 0%, #ffffff 100%);
    --surface-color: #ffffff;
    --surface-container: #f1f5f9;
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --border-color: rgba(0, 0, 0, 0.08);
    --glass-bg: rgba(241, 245, 249, 0.9);
    --glass-border: rgba(0, 0, 0, 0.1);
    --glass-inner-glow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* Specific overrides for Light Mode text to prevent "grayed out" look */
body.light-theme .opacity-70,
body.light-theme .opacity-60,
body.light-theme h2.opacity-40,
body.light-theme h3.opacity-40 {
    opacity: 1 !important;
    color: #202124 !important;
}

body.light-theme p.opacity-30,
body.light-theme p.opacity-60,
body.light-theme .text-\[10px\].opacity-30,
body.light-theme .text-\[9px\].opacity-30,
body.light-theme .text-\[10px\].opacity-50 {
    opacity: 1 !important;
    color: #5f6368 !important;
}

body.light-theme .text-\[10px\].font-bold.opacity-30,
body.light-theme .text-\[9px\].font-bold.opacity-30 {
    opacity: 1 !important;
    color: #3c4043 !important;
}

@media (max-width: 768px) {
    :root {
        --squircle-radius: 24px;
    }
}

body {
    background: var(--bg-color);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    margin: 0;
    overflow-x: hidden;
    transition: background 0.3s ease;
    min-height: 100vh;
    -webkit-user-select: none;
    user-select: none;
    touch-action: pan-x pan-y;
}

/* Android Specific UI Overrides */
body.is-android .bottom-nav {
    background: #000000 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Enhanced Glass & Squircle Styling for Cards */
.response-card, #results-card-container {
    background: var(--glass-bg) !important;
    backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate)) !important;
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate)) !important;
    border: 1px solid var(--glass-border) !important;
    box-shadow: var(--glass-inner-glow), 0 10px 30px -10px rgba(0,0,0,0.5) !important;
    border-radius: var(--squircle-radius) !important;
    padding: 24px;
    margin-bottom: 12px;
    transition: all 0.5s var(--transition-curve);
}

body.light-theme #results-card-container, body.light-theme .response-card {
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.02) !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
}

/* Refined Dropdown & Input Styling */
select, input[type="number"], input[type="text"], input[type="date"] {
    background-color: rgba(255, 255, 255, 0.07) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: var(--input-radius) !important;
    color: var(--text-primary) !important;
    transition: all 0.3s ease;
}

body.light-theme select, body.light-theme input[type="number"], body.light-theme input[type="text"], body.light-theme input[type="date"] {
    background-color: rgba(255, 255, 255, 0.5) !important;
    border: 1px solid rgba(0, 0, 0, 0.15) !important;
    color: #202124 !important;
}

/* Styling the Dropdown Popover List */
select option {
    background-color: #1e1f20;
    color: #e3e3e3;
    padding: 15px;
}

body.light-theme select option {
    background-color: #ffffff;
    color: #202124;
}

/* Interactive active scale */
button, .sidebar-item, .bottom-nav-item, .share-option, .mobile-result-tab-btn, .mobile-input-tab-btn {
    transition: transform 0.15s cubic-bezier(0.2, 0, 0, 1), opacity 0.2s ease, background-color 0.2s ease;
}
button:active, .sidebar-item:active, .bottom-nav-item:active, .share-option:active {
    transform: scale(0.96);
}

/* Hide all scrollbars specifically in PWA standalone mode */
@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
    *::-webkit-scrollbar {
        display: none !important;
        width: 0 !important;
        height: 0 !important;
    }
    html, body, .main-content, .styled-scroll, div {
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
    }
}

/* Transitions shared between views */
#breakdown-list,
#summary-footer-stats,
#bill-trend-badge,
.cost-chart-container {
    transition: max-height 0.7s var(--transition-curve),
                opacity 0.4s ease,
                margin 0.6s var(--transition-curve),
                padding 0.6s var(--transition-curve);
}

/* Premium Smooth Summary Expansion for all Mobile Screens */
@media (max-width: 768px) {
    #breakdown-list,
    #summary-footer-stats,
    #bill-trend-badge,
    .cost-chart-container {
        max-height: 0;
        opacity: 0;
        overflow: hidden;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        pointer-events: none;
    }

    /* Expanded states with cubic-bezier grow effect */
    #results-card-container.is-expanded #breakdown-list {
        max-height: 500px;
        opacity: 1;
        margin-top: 1rem !important;
        pointer-events: auto;
    }

    #results-card-container.is-expanded #bill-trend-badge {
        max-height: 40px;
        opacity: 1;
        pointer-events: auto;
    }

    #results-card-container.is-expanded #summary-footer-stats {
        max-height: 150px;
        opacity: 1;
        margin-top: 1rem !important;
        padding-top: 1rem !important;
        pointer-events: auto;
    }

    #results-card-container.is-expanded .cost-chart-container {
        max-height: 400px;
        opacity: 1;
        margin-top: 1.5rem !important;
        padding-top: 1.5rem !important;
        pointer-events: auto;
    }

    #results-card-container {
        padding-bottom: 12px !important;
    }
    #results-card-container.is-expanded {
        padding-bottom: 20px !important;
    }
    #toggle-expansion-btn {
        display: flex !important;
    }
}

#toggle-expansion-btn {
    display: none;
    transition: all 0.2s ease;
}

.app-container { display: flex; height: 100vh; width: 100vw; }

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--glass-bg);
    backdrop-filter: blur(32px);
    -webkit-backdrop-filter: blur(32px);
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 12px;
    transition: var(--transition);
    z-index: 100;
    overflow-x: hidden;
    border-right: 1px solid var(--glass-border);
    will-change: width;
}

@media (max-width: 768px) {
    .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); width: 280px; box-shadow: none; transition: transform 0.4s var(--transition-curve); padding-top: calc(12px + env(safe-area-inset-top)); border-right: none; }
    .sidebar.mobile-active { transform: translateX(0); }
    .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(8px); z-index: 90; }
    .sidebar-overlay.active { display: block; }
    .main-content {
        padding-top: env(safe-area-inset-top);
        padding-bottom: calc(56px + env(safe-area-inset-bottom));
    }
}

.sidebar.collapsed { width: var(--sidebar-collapsed); padding: 12px 10px; }
.sidebar-header { display: flex; align-items: center; gap: 12px; padding: 16px 12px; margin-bottom: 24px; transition: var(--transition); }
.sidebar-item { display: flex; align-items: center; padding: 12px; margin-bottom: 4px; border-radius: 100px; cursor: pointer; color: var(--text-secondary); transition: background-color 0.2s ease, color 0.2s ease; white-space: nowrap; overflow: hidden; font-weight: 500; border: none; background: none; width: 100%; text-align: left; }
.sidebar-item:hover { background-color: rgba(255,255,255,0.05); color: var(--text-primary); }
.sidebar-item.active { background-color: rgba(255,255,255,0.08); color: var(--text-primary); }
.sidebar-icon { min-width: 24px; width: 24px; height: 24px; margin-right: 16px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sidebar.collapsed .sidebar-icon { margin-right: 0; width: 100%; }
.sidebar-text { transition: opacity 0.3s var(--transition-curve); opacity: 1; }
.sidebar.collapsed .sidebar-text { opacity: 0; pointer-events: none; width: 0; }

.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--glass-bg);
    backdrop-filter: blur(32px);
    -webkit-backdrop-filter: blur(32px);
    border-top: 1px solid var(--glass-border);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -8px 30px rgba(0,0,0,0.2);
}

@media (max-width: 768px) {
    .bottom-nav { display: block; }
}

.bottom-nav-inner {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 56px;
    max-width: 500px;
    margin: 0 auto;
    gap: 8px;
    padding: 0 8px;
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-secondary);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: all 0.3s var(--transition-curve);
    position: relative;
    min-width: 32px;
    min-height: 48px;
}

.bottom-nav-item .icon-wrapper {
    padding: 2px 16px;
    border-radius: 20px;
    transition: all 0.3s var(--transition-curve);
}

.bottom-nav-item.active {
    color: #3b82f6;
}

.bottom-nav-item.active .icon-wrapper {
    background-color: rgba(59, 130, 246, 0.12);
    color: #3b82f6;
}

.main-content { flex: 1; display: flex; flex-direction: column; overflow-y: auto; position: relative; min-width: 0; background: transparent; }
.accent-gradient-text { background: var(--accent-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; font-weight: 700; }
.pill-button { background: var(--accent-gradient); color: white; padding: 10px 24px; border-radius: 100px; font-weight: 600; border: none; cursor: pointer; transition: opacity 0.2s; }

/* Premium Transitions */
.page-content { display: none; }
.page-content.active { display: block; animation: pageSlideIn 0.5s var(--transition-curve); }

@keyframes pageSlideIn {
    from { opacity: 0; transform: translateY(12px) scale(0.99); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); display: none; align-items: center; justify-content: center; z-index: 10000; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.modal-overlay.active { display: flex; }

.breakdown-row { padding: 8px 12px; border-radius: 12px; margin-bottom: 2px; transition: transform 0.2s ease; }
.breakdown-row.highlighted { outline: 2px solid #3b82f6; transform: scale(1.02); z-index: 5; }

input[type=range] { -webkit-appearance: none; width: 100%; background: transparent; }
input[type=range]::-webkit-slider-runnable-track { width: 100%; height: 6px; background: rgba(255,255,255,0.05); border-radius: 3px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; height: 20px; width: 20px; border-radius: 50%; background: #3b82f6; cursor: pointer; margin-top: -7px; box-shadow: 0 0 10px rgba(59, 130, 246, 0.4); }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }

.styled-scroll { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.1) transparent; }
.styled-scroll::-webkit-scrollbar { width: 5px; height: 5px; }
.styled-scroll::-webkit-scrollbar-thumb { background-color: rgba(255,255,255,0.1); border-radius: 20px; }
.styled-scroll::-webkit-scrollbar-thumb:hover { background-color: #3b82f6; }

/* Modern Insight Card with Grow Animation */
.insight-card {
    background: rgba(37, 99, 235, 0.08);
    border: 1px dashed rgba(37, 99, 235, 0.3);
    border-radius: 16px;
    padding: 0 16px;
    margin-top: 0;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: all 0.6s var(--transition-curve);
    display: flex;
    align-items: flex-start;
    pointer-events: none;
}

.insight-card.active {
    max-height: 200px;
    opacity: 1;
    margin-top: 12px;
    padding: 16px;
    pointer-events: auto;
}

.info-trigger { display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; border-radius: 50%; background: rgba(255,255,255,0.08); color: var(--text-secondary); font-size: 9px; font-weight: bold; cursor: help; margin-left: 4px; vertical-align: middle; transition: background 0.2s; }
.info-trigger:hover { background: #3b82f6; color: white; }

.toggle-pill { display: flex; background: rgba(255,255,255,0.05); border-radius: 100px; padding: 4px; }
.toggle-pill button { padding: 4px 12px; border-radius: 100px; font-size: 10px; font-weight: 600; transition: all 0.2s; }
.toggle-pill button.active { background: #3b82f6; color: white; }

.skeleton { background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.05) 75%); background-size: 200% 100%; animation: skeleton-loading 1.5s infinite; border-radius: 8px; }
@keyframes skeleton-loading { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.is-loading .hide-on-load { display: none !important; }
.is-loading .show-on-load { display: block !important; }
.show-on-load { display: none; }

.share-option { background: rgba(255,255,255,0.05); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; transition: all 0.2s; cursor: pointer; border: 1px solid transparent; }
.share-option:hover { background: rgba(59, 130, 246, 0.1); border-color: rgba(59, 130, 246, 0.3); transform: translateY(-2px); }

.mobile-input-tab-btn, .mobile-result-tab-btn, .mobile-history-tab-btn { color: rgba(255, 255, 255, 0.4); }
.light-theme .mobile-input-tab-btn, .light-theme .mobile-result-tab-btn, .light-theme .mobile-history-tab-btn { color: rgba(0, 0, 0, 0.4); }
.mobile-input-tab-btn.active, .mobile-result-tab-btn.active, .mobile-history-tab-btn.active { background: #3b82f6; color: white; box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3); }

.step-pill { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: #3b82f6; color: white; font-size: 10px; font-weight: bold; margin-right: 12px; flex-shrink: 0; margin-top: 1px; }

#pwa-splash {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: linear-gradient(180deg, #3f6386 0%, #131314 100%);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.6s;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

@media (max-width: 768px) {
    #pwa-splash.light-theme-splash {
        background: linear-gradient(180deg, #e0f2fe 0%, #ffffff 100%);
    }
}

@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
    #pwa-splash { display: flex; }
    body.is-loading #pwa-splash { opacity: 1; visibility: visible; pointer-events: auto; }
}

.splash-logo {
    width: 120px;
    height: 120px;
    border-radius: var(--squircle-radius);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    margin-bottom: 24px;
    animation: splash-pop 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes splash-pop {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Premium Input Focus States */
input:focus, select:focus {
    background-color: rgba(59, 130, 246, 0.03) !important;
    border-color: rgba(59, 130, 246, 0.4) !important;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.08);
}

#toast {
    position: fixed;
    bottom: calc(80px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #3b82f6;
    color: white !important;
    padding: 14px 32px;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 700;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10000;
    box-shadow: 0 20px 40px -10px rgba(59, 130, 246, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    letter-spacing: 0.02em;
}
#toast.visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}