:root {
    --app-bg: #05070d;
    --app-bg-soft: #0b1020;
    --surface: #0c1424;
    --surface-soft: #101b30;
    --surface-hover: #16233a;
    --line: rgba(255, 255, 255, 0.1);
    --line-soft: rgba(255, 255, 255, 0.06);
    --text-main: #e6edf7;
    --text-soft: #94a3b8;
    --accent: #4f8cff;
    --accent-soft: rgba(79, 140, 255, 0.25);
    --danger: #ff5f7a;
    --bottom-nav-height: 4.8rem;
    --bottom-nav-offset: 0rem;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100dvh;
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    background:
        radial-gradient(1200px 500px at 50% -20%, rgba(59, 130, 246, 0.18), transparent 60%),
        radial-gradient(900px 420px at 100% 120%, rgba(244, 63, 94, 0.08), transparent 60%),
        linear-gradient(180deg, #04060b 0%, #070b14 55%, #05070d 100%);
}

.app-shell {
    max-width: 64rem;
    margin: 0 auto;
    padding: 1.05rem 1.05rem calc(var(--bottom-nav-safe-height, var(--bottom-nav-height)) + env(safe-area-inset-bottom) + 1rem);
}

#app-view.app-shell {
    padding-bottom: calc(var(--bottom-nav-safe-height, var(--bottom-nav-height)) + env(safe-area-inset-bottom) + 1rem) !important;
}

#app-view header {
    margin-bottom: 0.9rem;
}

#app-view header h1 {
    letter-spacing: -0.02em;
}

.card,
.glass-card {
    background: linear-gradient(180deg, rgba(16, 25, 43, 0.94) 0%, rgba(9, 14, 26, 0.94) 100%);
    border: 1px solid var(--line-soft);
    border-radius: 1.2rem;
    box-shadow: 0 18px 44px -28px rgba(0, 0, 0, 0.9);
}

.card {
    padding: 1.25rem;
}

#app-view main {
    padding: 0.35rem 0.2rem 0;
}

#app-view main > [data-view] {
    padding: 0 0.1rem;
}

.glass-card {
    backdrop-filter: blur(14px);
}

#user-info {
    background: rgba(12, 22, 40, 0.86);
}

#user-menu {
    display: flex;
    justify-content: flex-end;
}

.user-menu-trigger {
    width: 3rem;
    height: 3rem;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #e2e8f0;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.88) 0%, rgba(139, 92, 246, 0.92) 100%);
    border: 1px solid rgba(255, 255, 255, 0.24);
    box-shadow: 0 16px 34px -20px rgba(99, 102, 241, 0.9);
    transition: transform 0.18s ease, filter 0.18s ease, border-color 0.18s ease;
}

.user-menu-trigger:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
}

.user-menu-trigger:focus-visible {
    outline: 2px solid rgba(99, 102, 241, 0.65);
    outline-offset: 2px;
}

#user-info {
    position: absolute;
    right: 0;
    top: calc(100% + 0.6rem);
    width: min(17.5rem, 90vw);
    padding: 0.95rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: 0 26px 52px -32px rgba(0, 0, 0, 0.95);
    z-index: 40;
}

#user-info.hidden {
    display: none;
}

.icon-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.35rem;
    height: 2.35rem;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.14);
}

.btn {
    min-height: 2.7rem;
    border-radius: 0.9rem;
    border: 1px solid transparent;
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
}

.btn.bg-indigo-600 {
    background: linear-gradient(135deg, #4e54ff 0%, #7b61ff 100%);
    box-shadow: 0 14px 28px -20px rgba(91, 95, 255, 0.85);
}

.btn.bg-green-600 {
    background: linear-gradient(135deg, #1ecf7f 0%, #0ea5e9 100%);
}

.btn.bg-cyan-600 {
    background: linear-gradient(135deg, #12b9d6 0%, #3b82f6 100%);
}

.btn.bg-red-600 {
    background: linear-gradient(135deg, #ff4d5a 0%, #ff7f2a 100%);
}

.btn.bg-rose-600 {
    background: linear-gradient(135deg, #ff5f7a 0%, #f43f8d 100%);
}

.btn.bg-gray-600 {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--line);
    color: #f8fafc;
}

.input-field {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    color: #f8fbff;
    padding: 0.82rem 0.95rem;
    border-radius: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

select.input-field {
    color-scheme: dark;
}

select.input-field option {
    color: #f8fafc !important;
    background-color: #0f172a !important;
}

select.input-field option:checked {
    color: #ffffff !important;
    background-color: #2563eb !important;
}

.input-field::placeholder {
    color: #7e8ba0;
}

.input-field:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.7);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.item-row {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.03) 100%);
    border: 1px solid var(--line);
    border-radius: 1rem;
    padding: 0.9rem;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.item-row:hover {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.04) 100%);
    border-color: rgba(255, 255, 255, 0.2);
}

.drag-handle {
    cursor: grab;
    touch-action: none;
    border-radius: 0.6rem;
    padding: 0.2rem;
}

.drag-handle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sortable-ghost {
    opacity: 0.45;
    background-color: #3d4a62;
}

.btn-remove {
    background-color: rgba(255, 95, 122, 0.2);
    color: #ffd6de;
    border-radius: 9999px;
    width: 1.95rem;
    height: 1.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    border: 1px solid rgba(255, 95, 122, 0.35);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-remove:hover {
    background-color: rgba(255, 95, 122, 0.35);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.section-title + .space-y-3 {
    margin-top: 0.85rem;
}

.summary-card {
    background: linear-gradient(180deg, rgba(33, 43, 73, 0.38) 0%, rgba(18, 26, 47, 0.4) 100%);
    border: 1px solid var(--line);
    border-radius: 1.25rem;
    padding: 1.2rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.card.grid > div {
    background: transparent;
}

#saved-budgets-list {
    grid-template-columns: 1fr;
}

#saved-budgets-list .card {
    background: linear-gradient(180deg, rgba(21, 31, 53, 0.94) 0%, rgba(11, 17, 30, 0.94) 100%);
    border-color: var(--line);
}

[data-view] {
    display: none;
}

[data-view].view-active {
    display: block;
}

/* Navegacion inferior estilo app social */
#main-nav-tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 70;
    width: 100%;
    max-width: none;
    transform: none;
    margin: 0;
    padding: 0.5rem 0.55rem calc(0.5rem + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.45rem;
    border-radius: 0;
    background: rgba(5, 9, 16, 0.98);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(12px);
    box-shadow: 0 -12px 25px rgba(0, 0, 0, 0.45);
}

#main-nav-tabs .nav-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.24rem;
    min-height: 3.4rem;
    padding: 0.4rem 0.3rem 0.5rem;
    border-radius: 0.9rem;
    border: 1px solid var(--line-soft);
    background: rgba(14, 22, 38, 0.82);
    color: rgba(241, 245, 249, 0.88);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.08;
    text-align: center;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

#main-nav-tabs .nav-tab:hover {
    transform: translateY(-1px);
    background: rgba(22, 35, 58, 0.95);
    border-color: rgba(255, 255, 255, 0.15);
}

#main-nav-tabs .nav-tab svg {
    margin-right: 0 !important;
    width: 1.12rem;
    height: 1.12rem;
    stroke-width: 2;
}

#main-nav-tabs .nav-tab.active {
    color: #ffffff;
    background: linear-gradient(180deg, rgba(33, 41, 79, 0.92) 0%, rgba(25, 33, 62, 0.92) 100%);
    border-color: rgba(124, 141, 255, 0.4);
    box-shadow: inset 0 0 0 1px rgba(124, 141, 255, 0.2);
}

/* Hide number input spinners */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    -moz-appearance: textfield;
}

@media (min-width: 768px) {
    .card {
        padding: 1.45rem;
    }

    .app-shell {
        padding: 1.4rem 1.45rem calc(var(--bottom-nav-safe-height, var(--bottom-nav-height)) + 1.2rem);
    }

    #app-view.app-shell {
        padding-bottom: calc(var(--bottom-nav-safe-height, var(--bottom-nav-height)) + 1.2rem) !important;
    }

    #saved-budgets-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #app-view main {
        padding: 0.45rem 0.35rem 0;
    }
}

@media (min-width: 1024px) {
    #saved-budgets-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

