@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: #f8fafc;
    color: #0f172a;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 40px;
    min-height: 100vh;
    padding-top: env(safe-area-inset-top);
    padding-bottom: calc(env(safe-area-inset-bottom) + 40px);
}

/* Mobile: extra bottom padding so content doesn’t sit under browser URL/nav bar */
@media (max-width: 1023px) {
    body {
        padding-bottom: calc(env(safe-area-inset-bottom) + 88px);
    }
    #main-content {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Themes */
body.theme-dark {
    background-color: #0f172a;
    color: #e2e8f0;
}
body.theme-dark .nav-header {
    border-bottom-color: #1f2937;
}
body.theme-dark .home-header {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.95) 0%, rgba(30, 41, 59, 0.98) 100%);
    border-bottom-color: rgba(51, 65, 85, 0.8);
    box-shadow: 0 4px 24px -4px rgba(0, 0, 0, 0.3);
}
body.theme-dark .home-header-label { color: #94a3b8; }
body.theme-dark .home-header-amount { color: #f1f5f9; }
body.theme-dark .home-header-amount:hover { color: #a5b4fc; text-decoration-color: #6366f1; }
body.theme-dark .home-header-info-btn { border-color: #475569; color: #94a3b8; }
body.theme-dark .home-header-info-btn:hover { background: #334155; color: #cbd5e1; }
body.theme-dark .home-header-icon-btn { background: rgba(51, 65, 85, 0.8); color: #94a3b8; }
body.theme-dark .home-header-icon-btn:hover { background: #475569; color: #e2e8f0; }
body.theme-dark .home-header-surplus-panel {
    background: linear-gradient(135deg, rgba(6, 78, 59, 0.2) 0%, rgba(20, 83, 45, 0.15) 100%);
    border-color: rgba(52, 211, 153, 0.25);
}
body.theme-dark .home-header-surplus-input {
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(52, 211, 153, 0.35);
    color: #e2e8f0;
}
body.theme-dark .nav-pill { background: #1f2937; }
body.theme-dark .tab-inactive { color: #cbd5f5; }
body.theme-dark .tab-active { background: #f8fafc; color: #0f172a; }
body.theme-dark .premium-card {
    background-color: #111827;
    border-color: #1f2937;
    box-shadow: none;
}
body.theme-dark .modal-content { background: #111827; }
body.theme-dark #app-alert-modal .modal-content #app-alert-title,
body.theme-dark #app-alert-modal .modal-content #app-alert-message { color: #e2e8f0; }
body.theme-dark #app-alert-modal .modal-content #app-alert-icon { background: rgba(99, 102, 241, 0.2); color: #818cf8; }
body.theme-dark #app-alert-modal .modal-content #app-alert-cancel { background: #1e293b; color: #94a3b8; }
body.theme-dark #app-alert-modal .modal-content #app-alert-cancel:hover { background: #334155; }

#app-alert-modal.app-confirm-compact .modal-content { padding-top: 1rem; }
#app-alert-modal.app-confirm-compact #app-alert-message { margin-bottom: 1rem; }
#app-alert-modal.app-confirm-compact #app-alert-ok,
#app-alert-modal.app-confirm-compact #app-alert-cancel { padding-top: 0.5rem; padding-bottom: 0.5rem; }
body.theme-dark #bank-balance-info { color: #94a3b8; }
body.theme-dark #bank-balance-info-btn { border-color: #64748b; color: #94a3b8; }
body.theme-dark #bank-balance-info-btn:hover { background: #334155; }

/* Bank Balance card (above Weekly Allowance) */
.bank-balance-card {
    /* Allow small dropdowns/tooltips to extend without clipping */
    overflow: visible;
}
.bank-balance-card .bank-balance-bar-wrap {
    min-height: 2rem;
    display: flex;
    flex-wrap: nowrap;
    min-width: 0;
    overflow: hidden;
}
.bank-balance-segment {
    min-width: 4px;
    flex-shrink: 0;
    border-radius: 0;
}
.bank-balance-segment:first-of-type { border-radius: 6px 0 0 6px; }
.bank-balance-segment:last-of-type { border-radius: 0 6px 6px 0; }
.bank-balance-segment:only-child { border-radius: 6px; }

/* Legend: single line only, scroll horizontally if needed — never wrap to second row */
.bank-balance-legend {
    display: flex;
    flex-wrap: nowrap;
    min-width: 0;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.bank-balance-legend::-webkit-scrollbar { display: none; }
.bank-balance-legend > span {
    white-space: nowrap;
    flex-shrink: 0;
}

.bank-balance-legend [data-bb-group] {
    cursor: default;
}

/* Custom segment tooltip (replaces native title) */
.bank-balance-tooltip {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    padding: 8px 12px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.06);
    pointer-events: none;
    white-space: nowrap;
    max-width: 90vw;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.15s ease;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.bank-balance-tooltip-label {
    font-size: 12px;
    font-weight: 700;
    color: #0f172a;
}
.bank-balance-tooltip-amount {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
}
body.theme-dark .bank-balance-tooltip {
    background: #1e293b;
    box-shadow: 0 4px 14px rgba(0,0,0,0.4), 0 0 0 1px rgba(51,65,85,0.8);
}
body.theme-dark .bank-balance-tooltip-label { color: #f1f5f9; }
body.theme-dark .bank-balance-tooltip-amount { color: #94a3b8; }
.bank-balance-tooltip.hidden {
    visibility: hidden;
    pointer-events: none;
}

body.theme-dark .bank-balance-card {
    background-color: #111827;
    border-color: #1f2937;
}
body.theme-dark #bank-balance-total { color: #f1f5f9; }
body.theme-dark .bank-balance-bar-wrap { background: #1e293b; }
body.theme-dark .bank-balance-info-btn { border-color: #475569; color: #94a3b8; }
body.theme-dark .bank-balance-info-btn:hover { background: #334155; color: #e2e8f0; }

/* Bucket list containers: no horizontal scroll, content wraps */
#savings-buckets-list,
#payables-buckets-list {
    overflow-x: hidden;
    overflow-y: auto;
    min-width: 0;
}

/* Savings/Payables bucket rows — no horizontal scroll: line1 = name + balance, line2 = input + +/- + ⋯ */
.bucket-row-card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    padding: 0.625rem 0.875rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    margin-bottom: 0.5rem;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}
.bucket-row-card:last-child { margin-bottom: 0; }
.bucket-row-label-wrap {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    cursor: pointer;
    padding: 2px 0;
    -webkit-tap-highlight-color: transparent;
}
.bucket-row-label-wrap:hover .bucket-row-label { color: #0f172a; }
.bucket-row-label {
    display: block;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #334155;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bucket-row-label-line {
    display: block;
    height: 2px;
    width: 100%;
    max-width: 3rem;
    margin-top: 4px;
    background: #e2e8f0;
    border-radius: 1px;
}
.bucket-row-name-edit {
    display: none;
    width: 100%;
    max-width: 100%;
    padding: 2px 4px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #0f172a;
    background: #fff;
    border: 1px solid #6366f1;
    border-radius: 6px;
    outline: none;
    box-sizing: border-box;
}
.bucket-row-name-edit:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}
.bucket-row-label-wrap.editing .bucket-row-label,
.bucket-row-label-wrap.editing .bucket-row-label-line {
    display: none !important;
}
.bucket-row-label-wrap.editing .bucket-row-name-edit {
    display: block !important;
}
.bucket-row-balance {
    font-size: 1rem;
    font-weight: 800;
    color: #0f172a;
    flex-shrink: 0;
    min-width: 0;
    text-align: right;
}
/* Second row: input + stepper + more — always full width so ⋯ never falls out */
.bucket-row-controls {
    flex: 1 1 100%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    min-width: 0;
}
.bucket-amount-input {
    width: 3.25rem;
    padding: 0.35rem 0.4rem;
    font-size: 0.8125rem;
    font-weight: 700;
    text-align: center;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    outline: none;
    flex-shrink: 0;
}
.bucket-amount-input:focus {
    border-color: #94a3b8;
    box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.2);
}
.bucket-stepper {
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    flex-shrink: 0;
}
.bucket-stepper button {
    width: 2rem;
    height: 1.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9375rem;
    font-weight: 700;
    color: #64748b;
    background: #f8fafc;
    border: none;
    border-bottom: 1px solid #e2e8f0;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.bucket-stepper button:last-child { border-bottom: none; }
.bucket-stepper button:hover {
    background: #e2e8f0;
    color: #0f172a;
}
.bucket-more-btn {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    font-weight: 600;
    color: #64748b;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
}
.bucket-more-btn:hover {
    background: #e2e8f0;
    color: #475569;
}
.bucket-more-wrap {
    position: relative;
    flex-shrink: 0;
}
.bucket-dropdown {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    min-width: 120px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 50;
    display: none;
    flex-direction: column;
    overflow: hidden;
}
.bucket-dropdown.open { display: flex; }
.bucket-dropdown button {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 11px;
    font-weight: 700;
    text-align: left;
    background: none;
    border: none;
    color: #475569;
    cursor: pointer;
}
.bucket-dropdown button:hover {
    background: #f1f5f9;
}
.bucket-dropdown button[data-action="delete"]:hover {
    background: #fef2f2;
    color: #dc2626;
}
body.theme-dark .bucket-row-card {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
body.theme-dark .bucket-row-label { color: #94a3b8; }
body.theme-dark .bucket-row-label-line { background: #475569; }
body.theme-dark .bucket-row-name-edit {
    background: #0f172a;
    border-color: #6366f1;
    color: #e2e8f0;
}
body.theme-dark .bucket-row-balance { color: #f1f5f9; }
body.theme-dark .bucket-amount-input {
    background: #0f172a;
    border-color: #475569;
    color: #e2e8f0;
}
body.theme-dark .bucket-stepper {
    background: #1e293b;
    border-color: #475569;
}
body.theme-dark .bucket-stepper button {
    background: #1e293b;
    color: #94a3b8;
    border-color: #334155;
}
body.theme-dark .bucket-stepper button:hover {
    background: #334155;
    color: #e2e8f0;
}
body.theme-dark .bucket-more-btn {
    background: #334155;
    border-color: #475569;
    color: #94a3b8;
}
body.theme-dark .bucket-more-btn:hover {
    background: #475569;
    color: #e2e8f0;
}
body.theme-dark .bucket-dropdown {
    background: #1e293b;
    border-color: #475569;
}
body.theme-dark .bucket-dropdown button {
    color: #94a3b8;
}
body.theme-dark .bucket-dropdown button:hover {
    background: #334155;
}

body.theme-dark .food-calendar-buffer {
    border-top-color: #059669;
    background: linear-gradient(to bottom, rgba(16, 185, 129, 0.12), transparent);
}
body.theme-dark .food-buffer-row .w-12 { color: #34d399; }

/* Compact mode */
body.compact .nav-header { padding: 0.5rem 0; }
body.compact .home-header-inner { padding: 0.6rem 0.5rem 0.75rem; }
body.compact .home-header-amount { font-size: 1.1rem; }
body.compact .home-header-extra-amount { font-size: 1rem; }
body.compact .home-header-icon-btn { width: 36px; height: 36px; }
body.compact .tab-btn { padding: 6px; font-size: 10px; }
body.compact .premium-card { border-radius: 16px; }

/* Touch optimization */
button,
a,
input,
select,
textarea,
[role="button"],
[onclick] {
    touch-action: manipulation;
}

@media (max-width: 768px) {
    body {
        min-height: 100dvh;
    }

    button,
    input,
    select,
    textarea {
        -webkit-appearance: none;
        appearance: none;
    }

    .premium-card {
        overflow: hidden;
    }

    .premium-card .flex {
        flex-wrap: wrap;
    }

    /* Bank balance: keep header, bar, and legend on one row — do not wrap to second row */
    .bank-balance-card > .flex:first-of-type,
    .bank-balance-card .bank-balance-bar-wrap,
    .bank-balance-card .bank-balance-legend {
        flex-wrap: nowrap;
    }

    .premium-card .flex > button,
    .premium-card .flex > input,
    .premium-card .flex > select {
        max-width: 100%;
    }

    .weekly-hero {
        overflow: hidden;
    }
    
    /* Better spacing for weekly hero on mobile/iOS */
    @media (max-width: 1023px) {
        .weekly-hero {
            padding: 2rem 1.5rem !important;
        }
        
        .weekly-hero > div:first-child {
            margin-bottom: 1.5rem !important;
        }
        
        #weekly-allowance-explanation {
            margin-top: 1.5rem !important;
            line-height: 1.6 !important;
        }
        
        .weekly-inline-controls {
            margin-top: 1.75rem !important;
            padding: 0.75rem !important;
            gap: 0.75rem !important;
        }
        
        .weekly-inline-controls button {
            padding: 0.75rem 1rem !important;
            min-height: 44px; /* iOS touch target */
        }
    }
    
    #bal-weekly {
        line-height: 1.1;
    }

    .weekly-inline-controls {
        /* Let inner rows control their own layout; keep mobile tweaks minimal */
        gap: 0.5rem;
    }
}

/* --- DESKTOP LAYOUT (lg: 1024px+) --- */
@media (min-width: 1024px) {
    body {
        padding-bottom: 1.5rem;
        min-height: 100vh;
    }

    #app-shell {
        align-items: stretch;
    }

    /* Override .hidden so sidebar shows (our .hidden uses !important) */
    #desktop-sidebar {
        display: flex !important;
        position: sticky;
        top: 0;
        height: 100vh;
        max-height: 100vh;
    }

    .desktop-sidebar .tab-btn.tab-active,
    .desktop-sidebar .desktop-nav-item.tab-active {
        background: transparent;
        color: #0f172a;
        border-left: 3px solid #6366f1;
        padding-left: calc(0.75rem - 3px);
    }

    .nav-header {
        border-radius: 0;
        margin-bottom: 0;
    }

    .nav-header .mb-5 {
        margin-bottom: 0;
    }

    .nav-header {
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }

    /* Constrain width; ensure main area scrolls and content is visible */
    #app-main {
        max-width: 42rem;
        min-height: 0;
        overflow: hidden;
    }

    #main-content {
        margin-top: 0.75rem;
        flex: 1;
        min-height: 0;
        overflow-y: auto;
    }

    /* Ledger top: single column, compact gap */
    .ledger-top-grid {
        gap: 0.75rem;
    }

    /* Weekly hero: compact bar on desktop */
    #page-ledger .weekly-hero {
        padding: 1rem 1.25rem;
    }

    /* Food cycle + buffer card: tighter padding on desktop */
    #page-ledger .premium-card.p-6:not(.weekly-hero) {
        padding: 1.25rem;
    }

    /* Ledger categories: single column on desktop for consistent spacing (like mobile) */
    .ledger-categories-grid {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

}

body.theme-dark .desktop-sidebar {
    background-color: rgba(17, 24, 39, 0.98);
    border-right-color: #1f2937;
}

body.theme-dark .desktop-sidebar .tab-btn.tab-active,
body.theme-dark .desktop-nav-item.tab-active {
    background: transparent;
    color: #f8fafc;
    border-left-color: #818cf8;
}

body.theme-dark .desktop-nav-item:hover {
    background: #1e293b;
}

/* Sidebar nav: simple list, no big boxes */
.desktop-sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.desktop-sidebar .desktop-nav-item,
.desktop-sidebar nav a,
.desktop-sidebar nav .tab-btn {
    text-transform: none;
}
.desktop-sidebar .tab-btn.tab-active {
    background: transparent;
    border-left: 3px solid #6366f1;
    padding-left: calc(0.75rem - 3px);
}

/* Side menu panel: above header on iOS, respect safe area */
.side-menu-panel {
    padding-top: env(safe-area-inset-top);
    z-index: 1;
}

/* When Budget Plan is visible: main-content doesn’t scroll; budget page fills and only body scrolls so header stays fixed (desktop + iOS) */
#main-content.main-content--budget {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#main-content.main-content--budget #page-budget-plan {
    flex: 1 1 0;
    min-height: 0;
}

/* iOS / mobile: ensure Budget Plan has visible height when viewport is short */
@media (max-width: 1023px) {
    #app-shell {
        min-height: 100vh;
        min-height: 100dvh;
    }
    #main-content.main-content--budget {
        min-height: 50vh;
        min-height: 50dvh;
    }
}

/* Budget Plan page: total box stays at top; only body scrolls */
.page-budget-plan .budget-plan-page-header {
    flex-shrink: 0;
    z-index: 20;
    background: white;
}
.page-budget-plan .budget-plan-page-body {
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

/* --- STABLE STYLING --- */
.premium-card {
    background-color: white;
    border-radius: 24px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transition: all 0.2s;
}

/* Nav — sticky header (Home page only; app-header is hidden on other pages) */
.nav-header {
    position: sticky;
    top: 0;
    z-index: 40;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* Home header: sleek glass-style bar, only visible on Home (ledger) */
.home-header {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 250, 252, 0.98) 100%);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 0 0 20px 20px;
    box-shadow: 0 4px 24px -4px rgba(0, 0, 0, 0.06), 0 2px 8px -2px rgba(0, 0, 0, 0.04);
    padding: 0;
    padding-top: max(0.75rem, env(safe-area-inset-top));
    overflow-x: hidden;
}
.home-header-inner {
    padding: 1rem 0.75rem 1.25rem;
    overflow-x: hidden;
}
.home-header-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #94a3b8;
}
@media (max-width: 640px) {
    .home-header-inner { padding: 0.5rem 0.5rem 0.75rem; }
    .home-header-row { gap: 0.5rem; }
    .home-header-icon-btn { width: 32px; height: 32px; border-radius: 8px; }
    .home-header-extra { display: flex; align-items: baseline; gap: 0.25rem; }
    .home-header-extra-amount { font-size: 0.8125rem; }
    .home-header-label { display: inline; }
    #header-extra-label { display: none; }
}
.home-header-balance {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
}
.home-header-amount {
    font-size: 1.25rem;
    font-weight: 800;
    color: #0f172a;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: rgba(15, 23, 42, 0.25);
    transition: text-decoration-color 0.2s, color 0.2s;
}
.home-header-amount:hover {
    text-decoration-color: #6366f1;
    color: #4338ca;
}
.home-header-info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid #cbd5e1;
    color: #64748b;
    font-size: 10px;
    font-weight: 700;
    background: transparent;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.home-header-info-btn:hover {
    background: #f1f5f9;
    color: #475569;
    border-color: #94a3b8;
}
.home-header-extra-amount {
    font-size: 1.125rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}
.home-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}
.home-header-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(241, 245, 249, 0.9);
    color: #475569;
    border: none;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.home-header-icon-btn:hover {
    background: #e2e8f0;
    color: #334155;
}
.home-nav-pill {
    padding: 0.5rem 1rem;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    cursor: pointer;
}
.home-header-resolve-btn {
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: #ef4444;
    color: white;
    border: none;
    cursor: pointer;
    animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}
@keyframes pulseSubtle {
    0%, 100% { opacity: 1; box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.05); }
    50% { opacity: 0.98; box-shadow: 0 2px 8px -2px rgb(0 0 0 / 0.08); }
}
.animate-pulse-subtle {
    animation: pulseSubtle 2.5s ease-in-out infinite;
}
.home-header-surplus-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    padding: 1rem 0.75rem 1.25rem;
    margin: 0.5rem 0.75rem 1rem;
    background: linear-gradient(135deg, rgba(236, 253, 245, 0.9) 0%, rgba(209, 250, 229, 0.5) 100%);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: 16px;
}
.home-header-surplus-input {
    flex: 1;
    min-width: 120px;
    padding: 0.6rem 0.75rem;
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.8);
    outline: none;
}
.home-header-surplus-input:focus {
    border-color: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}
.home-header-surplus-btn {
    padding: 0.5rem 0.875rem;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: none;
    cursor: pointer;
    transition: filter 0.2s, transform 0.05s;
}
.home-header-surplus-btn:active {
    transform: scale(0.98);
}
.home-header-surplus-add {
    background: #10b981;
    color: white;
}
.home-header-surplus-add:hover { filter: brightness(1.08); }
.home-header-surplus-deduct {
    background: #f87171;
    color: white;
}
.home-header-surplus-deduct:hover { filter: brightness(1.08); }
.home-header-surplus-transfer {
    background: #6366f1;
    color: white;
}
.home-header-surplus-transfer:hover { filter: brightness(1.08); }
.nav-pill {
    display: flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 12px;
    max-width: 380px;
    margin: 0 auto;
}
.tab-btn {
    flex: 1;
    padding: 8px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}
.tab-active {
    background: #0f172a;
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.tab-inactive { color: #64748b; }
.tab-inactive:hover { background: #e2e8f0; }

/* Dots */
.dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid;
}
.dot-done {
    background: #e2e8f0;
    border-color: #e2e8f0;
    opacity: 0.5;
}
.dot-today {
    background: #4f46e5;
    border-color: #4f46e5;
    transform: scale(1.1);
    box-shadow: 0 0 0 2px #c7d2fe;
}
.dot-locked { background: #10b981; border-color: #10b981; }
.dot-future { background: white; border-color: #e2e8f0; }

/* Food cycle week grid */
.food-day-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.food-day-box {
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}
.food-day-box:active {
    transform: scale(0.98);
}

.food-overview-cell {
    user-select: none;
}
.food-overview-cell:active {
    transform: scale(0.96);
}

.food-overview-cell-wrapper {
    position: relative;
    min-height: 2rem;
}
.food-day-hover-actions {
    background: rgba(71, 85, 105, 0.92);
    gap: 0;
}
.food-day-consume-panel {
    background: rgba(5, 150, 105, 0.95);
    transition: filter 0.15s;
}
.food-day-consume-panel:hover {
    filter: brightness(1.12);
}
.food-day-transfer-panel {
    background: rgba(71, 85, 105, 0.95);
    transition: filter 0.15s;
}
.food-day-transfer-panel:hover {
    filter: brightness(1.15);
}
.food-day-action-btn {
    transition: background-color 0.15s, color 0.15s;
}
.food-day-transfer-popover.fixed {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}
.food-day-transfer-popover .food-day-transfer-target-btn {
    border: none;
    background: none;
    cursor: pointer;
}

/* Budget calendar: 28-day core vs buffer section */
.food-calendar-core {
    /* Standard 4-week salary cycle */
}
.food-calendar-buffer {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 2px dashed #10b981;
    background: linear-gradient(to bottom, rgba(16, 185, 129, 0.06), transparent);
    border-radius: 0 0 0.5rem 0.5rem;
}
.food-buffer-row .w-12 {
    color: #059669;
}

.food-row-current {
    border-left: 3px solid #4f46e5;
}

/* Major funds: compact on mobile */
.major-fund-bar {
    min-height: 44px;
}
.major-fund-bar button {
    touch-action: manipulation;
}

/* Ledger horizontal bars */
.ledger-bar {
    outline: none;
}
.ledger-bar:focus-visible {
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.4);
}
.ledger-bar-fill {
    background: linear-gradient(90deg, #94a3b8 0%, #64748b 100%);
}
.ledger-bar:hover .ledger-bar-fill {
    background: linear-gradient(90deg, #64748b 0%, #475569 100%);
}

.food-week-tab:focus {
    outline: none;
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    transition: all 0.3s ease;
    opacity: 1;
}
.modal-content {
    background: white;
    width: 100%;
    max-width: 24rem;
    border-radius: 24px;
    padding: 1.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
    transform: translateY(0);
}

.modal-open .modal-content { transform: translateY(0); }
.modal-closed .modal-content { transform: translateY(100%); }

/* Force Hide */
.hidden { display: none !important; }

/* Dragging */
.draggable-row { cursor: grab; user-select: none; }
.draggable-row:active { cursor: grabbing; background: #f8fafc; }
.draggable-card { cursor: grab; }
.draggable-card:active { cursor: grabbing; }
.dragging { opacity: 0.5; border: 2px dashed #cbd5e1; }
.no-drag { cursor: default; pointer-events: auto; }

/* Inputs */
.input-pill {
    background: #f1f5f9;
    border: none;
    border-radius: 8px;
    padding: 4px 8px;
    text-align: right;
    font-weight: 700;
    width: 80px;
    font-size: 12px;
    outline: none;
}
.input-pill:focus {
    box-shadow: 0 0 0 2px #6366f1;
    background: white;
}
.input-pill:read-only {
    background: #e2e8f0;
    color: #64748b;
    cursor: not-allowed;
}

/* Onboarding tips overlay + tip card */
#onboarding-budget-tips-overlay {
    pointer-events: auto;
}

#onboarding-tip-card {
    pointer-events: auto;
}

#home-tour-overlay {
    pointer-events: auto;
}

#home-tour-card {
    pointer-events: auto;
}

/* Soft highlight for tips & home tour (works on desktop + mobile) */
.onboarding-tip-highlight,
.home-tour-highlight {
    position: relative;
    z-index: 30;
    box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.9),
                0 18px 40px rgba(15, 23, 42, 0.35);
    border-radius: 16px;
    background-color: rgba(255, 255, 255, 0.98);
}
