:root {
    --primary:      #4f46e5;
    --primary-dk:   #3730a3;
    --success:      #059669;
    --danger:       #dc2626;
    --warning:      #d97706;
    --bg:           #f1f5f9;
    --card:         #ffffff;
    --text:         #1e293b;
    --muted:        #64748b;
    --border:       #e2e8f0;
    --nav-grad:     linear-gradient(135deg, #1e1b4b 0%, #4338ca 100%);
    --radius:       12px;
    --shadow:       0 1px 3px rgba(0,0,0,.08), 0 4px 14px rgba(0,0,0,.05);
    --shadow-lg:    0 12px 40px rgba(0,0,0,.18);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ── Navbar ── */
.navbar {
    background: var(--nav-grad);
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: 0 2px 16px rgba(0,0,0,.3);
}

.nav-brand {
    color: #fff;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -.4px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    width: 34px;
    height: 34px;
    background: rgba(255,255,255,.15);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 9px;
    color: rgba(255,255,255,.85);
    font-size: .875rem;
}

.nav-avatar {
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .82rem;
    color: #fff;
}

.nav-logout {
    color: rgba(255,255,255,.7);
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,.22);
    font-size: .8rem;
    font-weight: 500;
    transition: all .15s;
}
.nav-logout:hover { background: rgba(255,255,255,.12); color: #fff; }

.nav-history-link {
    color: rgba(255,255,255,.75);
    text-decoration: none;
    font-size: .875rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 6px;
    transition: background .15s, color .15s;
}
.nav-history-link:hover { background: rgba(255,255,255,.12); color: #fff; }

.nav-premium-badge {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: #c7d2fe;
    border: 1px solid rgba(199,210,254,.35);
    border-radius: 4px;
    padding: 2px 7px;
    line-height: 1;
    align-self: center;
}

/* ── Income Tabs (premium) ── */
.income-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 18px;
}
.income-tab {
    padding: 5px 16px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: transparent;
    color: var(--muted);
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
}
.income-tab:hover  { border-color: var(--primary); color: var(--primary); }
.income-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); cursor: default; display: inline-flex; align-items: center; }
.income-tab-input {
    background: transparent;
    border: none;
    border-bottom: 1.5px solid transparent;
    outline: none;
    color: #fff;
    font-size: .8rem;
    font-weight: 600;
    width: 90px;
    text-align: center;
    cursor: text;
    transition: border-color .15s;
}
.income-tab-input:focus { border-bottom-color: rgba(255,255,255,.6); }
.income-tab-input::placeholder { color: rgba(255,255,255,.55); }
.income-tab-edit-icon {
    font-size: .7rem;
    opacity: .6;
    margin-left: 4px;
    pointer-events: none;
    line-height: 1;
}
.income-tab-add {
    padding: 5px 14px;
    border-radius: 20px;
    border: 1.5px dashed var(--border);
    background: transparent;
    color: var(--muted);
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
}
.income-tab-add:hover { border-color: var(--primary); color: var(--primary); }
.btn-remove-income {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    border-radius: 6px;
    padding: 7px 14px;
    font-size: .8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
}
.btn-remove-income:hover     { background: var(--danger); color: #fff; }
.btn-remove-income:disabled  { opacity: .35; cursor: not-allowed; }

/* ── Upgrade Banner ── */
.upgrade-banner {
    background: #1a1740;
    border-bottom: 1px solid rgba(99,102,241,.25);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 9px 28px;
    font-size: .85rem;
    color: rgba(199,210,254,.75);
}
.upgrade-banner strong { color: #c7d2fe; font-weight: 600; }
.upgrade-banner-btn {
    background: transparent;
    color: #c7d2fe;
    border: 1px solid rgba(199,210,254,.4);
    border-radius: 6px;
    padding: 5px 14px;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    flex-shrink: 0;
}
.upgrade-banner-btn:hover    { background: rgba(199,210,254,.1); color: #e0e7ff; border-color: rgba(199,210,254,.65); }
.upgrade-banner-btn:disabled { opacity: .55; cursor: not-allowed; }

/* ── Main Layout ── */
.main {
    max-width: 1080px;
    margin: 0 auto;
    padding: 32px 24px 80px;
}

/* ── Page Header ── */
.page-header { margin-bottom: 28px; }
.page-title  { font-size: 1.55rem; font-weight: 800; }
.page-subtitle { color: var(--muted); font-size: .9rem; margin-top: 4px; }

/* ── Over-Budget Alert ── */
.alert-overbudget {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 4px solid var(--danger);
    border-radius: var(--radius);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    color: #991b1b;
    font-size: .9rem;
    animation: shake .4s ease;
}
.alert-overbudget.hidden { display: none; }

@keyframes shake {
    0%,100% { transform: translateX(0); }
    20%,60%  { transform: translateX(-4px); }
    40%,80%  { transform: translateX(4px); }
}

/* ── Summary Cards ── */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.summary-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px 22px 20px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    transition: transform .2s;
}
.summary-card:hover { transform: translateY(-2px); }

.summary-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    border-radius: var(--radius) var(--radius) 0 0;
}
.summary-card.income::before    { background: var(--primary); }
.summary-card.setasides::before { background: var(--warning); }
.summary-card.disposable::before { background: var(--success); }
.summary-card.disposable.over-budget::before { background: var(--danger); }

.card-label {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    margin-bottom: 10px;
}

.card-amount {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    transition: color .3s;
}
.summary-card.disposable .card-amount         { color: var(--success); }
.summary-card.disposable.over-budget .card-amount { color: var(--danger); }

.card-meta { font-size: .78rem; color: var(--muted); margin-top: 6px; }

.card-icon {
    position: absolute;
    right: 18px; top: 50%;
    transform: translateY(-50%);
    font-size: 2.4rem;
    opacity: .07;
    pointer-events: none;
}

.budget-progress {
    height: 5px;
    background: #e2e8f0;
    border-radius: 99px;
    overflow: hidden;
    margin-top: 12px;
}
.budget-progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 99px;
    transition: width .5s ease, background .3s;
}
.budget-progress-bar.warn   { background: var(--warning); }
.budget-progress-bar.danger { background: var(--danger); }

/* ── Monthly Outlook ── */
.outlook-card {
    background: var(--nav-grad);
    border-radius: var(--radius);
    padding: 24px 26px;
    margin-bottom: 20px;
    color: #fff;
    box-shadow: var(--shadow-lg);
}

.outlook-title {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255,255,255,.55);
    margin-bottom: 16px;
}

.outlook-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.outlook-item {
    background: rgba(255,255,255,.08);
    border-radius: 10px;
    padding: 16px 18px;
    border: 1px solid rgba(255,255,255,.1);
    transition: background .2s;
}
.outlook-item:hover { background: rgba(255,255,255,.12); }

.outlook-label {
    font-size: .78rem;
    color: rgba(255,255,255,.6);
    margin-bottom: 6px;
}

.outlook-value {
    font-size: 1.55rem;
    font-weight: 800;
}

.outlook-item.bonus .outlook-label::after { content: ' 🎉'; }

/* ── Divider ── */
.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 28px 0 18px;
    color: var(--muted);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
}
.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ── Profile Card ── */
.profile-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 22px 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.profile-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    align-items: end;
}

/* ── Section Header ── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.section-title { font-size: 1rem; font-weight: 700; }
.section-count { color: var(--muted); font-size: .875rem; margin-left: 6px; }

.btn-add {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 18px;
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background .15s, transform .1s;
}
.btn-add:hover { background: var(--primary-dk); transform: translateY(-1px); }

/* ── Items List ── */
.items-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.item-card {
    background: var(--card);
    border-radius: 10px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow);
    transition: transform .15s, box-shadow .15s;
    animation: slideIn .22s ease;
}
.item-card:hover { transform: translateY(-1px); box-shadow: 0 4px 18px rgba(0,0,0,.1); }

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

.priority-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.priority-dot.essential    { background: var(--danger); }
.priority-dot.discretionary { background: #60a5fa; }

.item-info { flex: 1; min-width: 0; }

.item-name {
    font-weight: 600;
    font-size: .95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-meta {
    font-size: .76rem;
    color: var(--muted);
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.badge {
    font-size: .66rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.badge-essential    { background: #fef2f2; color: #dc2626; }
.badge-discretionary { background: #eff6ff; color: #2563eb; }

.item-cost { text-align: right; flex-shrink: 0; }
.item-total  { font-size: .76rem; color: var(--muted); }
.item-ppc    { font-size: 1.08rem; font-weight: 800; color: var(--text); }
.item-ppc-sub { font-size: .68rem; color: var(--muted); }

.item-actions { display: flex; gap: 6px; flex-shrink: 0; }

.btn-icon {
    width: 32px; height: 32px;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    transition: all .15s;
}
.btn-edit   { background: #eff6ff; color: #3b82f6; }
.btn-edit:hover   { background: #dbeafe; }
.btn-delete { background: #fef2f2; color: #ef4444; }
.btn-delete:hover { background: #fee2e2; }

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 64px 20px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.empty-icon  { font-size: 3rem; margin-bottom: 12px; }
.empty-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 6px; }
.empty-text  { color: var(--muted); font-size: .875rem; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-size: .75rem;
    font-weight: 700;
    color: #374151;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: .95rem;
    color: var(--text);
    background: #f8fafc;
    outline: none;
    transition: border-color .15s, box-shadow .15s, background .15s;
    -webkit-appearance: none;
    appearance: none;
}

.form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath fill='%236b7280' d='M6 7L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 38px;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(79,70,229,.13);
}

.form-group input:disabled {
    background: #e2e8f0;
    color: var(--muted);
    cursor: not-allowed;
    border-color: var(--border);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s, visibility .2s;
    backdrop-filter: blur(4px);
}
.modal-overlay.open { opacity: 1; visibility: visible; }

.modal {
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px) scale(.97);
    transition: transform .22s cubic-bezier(.34,1.56,.64,1);
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.modal-title { font-size: 1.15rem; font-weight: 800; }

.btn-close {
    background: #f1f5f9;
    border: none;
    width: 30px; height: 30px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}
.btn-close:hover { background: #e2e8f0; color: var(--text); }

.modal-actions { display: flex; gap: 10px; margin-top: 8px; }

.btn-primary {
    flex: 1;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 12px;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.btn-primary:hover { background: var(--primary-dk); }

.btn-cancel {
    flex: 1;
    background: transparent;
    color: var(--muted);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
}
.btn-cancel:hover { background: #f8fafc; color: var(--text); }

.btn-danger {
    flex: 1;
    background: var(--danger);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 12px;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.btn-danger:hover { background: #b91c1c; }

/* ── Profile Save Button ── */
.btn-save {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: background .15s;
}
.btn-save:hover { background: var(--primary-dk); }

/* ── Setup Wizard ── */
.setup-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 64px);
    padding: 24px;
}

.setup-card {
    background: var(--card);
    border-radius: 20px;
    padding: 52px 44px;
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.setup-emoji  { font-size: 3.2rem; margin-bottom: 14px; }
.setup-title  { font-size: 1.7rem; font-weight: 800; margin-bottom: 8px; }
.setup-sub    { color: var(--muted); font-size: .9rem; margin-bottom: 36px; line-height: 1.6; }
.setup-form   { text-align: left; }

.btn-setup {
    width: 100%;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 15px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 10px;
    transition: background .15s, transform .1s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-setup:hover { background: var(--primary-dk); transform: translateY(-1px); }

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 28px;
    right: 28px;
    background: #1e293b;
    color: #fff;
    padding: 13px 20px;
    border-radius: 10px;
    font-size: .875rem;
    font-weight: 500;
    box-shadow: 0 8px 28px rgba(0,0,0,.28);
    transform: translateY(80px);
    opacity: 0;
    transition: all .32s cubic-bezier(.34,1.56,.64,1);
    z-index: 9999;
    max-width: 320px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }

/* ── Next Pay Countdown ── */
.next-pay-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
    padding: 6px 14px;
    border-radius: 99px;
    font-size: .8rem;
    font-weight: 600;
    margin-top: 16px;
}

/* ── Guest Banner ── */
.guest-banner {
    background: #fffbeb;
    border-bottom: 1px solid #fde68a;
    padding: 11px 28px;
    font-size: .85rem;
    color: #92400e;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.guest-banner-cta { color: #78350f; }

.guest-banner-link {
    color: #b45309;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.guest-banner-link:hover { color: #92400e; }

/* ── Register button in guest navbar ── */
.nav-register {
    background: rgba(255,255,255,.18);
    color: #fff;
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,.4);
    font-size: .8rem;
    font-weight: 600;
    transition: all .15s;
}
.nav-register:hover { background: rgba(255,255,255,.28); }

/* ── Guest mode: main section visibility toggled by localStorage check ── */
.guest-hidden { display: none; }
.guest-has-profile .guest-hidden { display: block; }

/* ── Responsive ── */
@media (max-width: 800px) {
    .summary-grid   { grid-template-columns: 1fr; }
    .outlook-grid   { grid-template-columns: 1fr; }
    .profile-grid   { grid-template-columns: 1fr; }
    .main           { padding: 20px 16px 60px; }
    .navbar         { padding: 0 16px; }
    .card-amount    { font-size: 1.7rem; }
}

@media (max-width: 520px) {
    .setup-card     { padding: 36px 24px; }
    .form-row       { grid-template-columns: 1fr; }
    .item-card      { flex-wrap: wrap; }
    .item-actions   { width: 100%; justify-content: flex-end; }
    .modal          { padding: 24px; }
    .nav-brand span { display: none; }
}

/* ── Page Header Row (title + budget switcher) ── */
.page-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

/* ── Budget Switcher ── */
.budget-switcher {
    position: relative;
    flex-shrink: 0;
}

.budget-switcher-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 9px 16px;
    font-size: .875rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    transition: border-color .15s, color .15s, box-shadow .15s;
    white-space: nowrap;
    box-shadow: var(--shadow);
}
.budget-switcher-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.budget-switcher-caret {
    color: var(--muted);
    font-size: .7rem;
    transition: transform .2s;
    margin-left: 2px;
}
.budget-switcher.open .budget-switcher-caret {
    transform: rotate(180deg);
}

.budget-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 210px;
    z-index: 300;
    overflow: hidden;
}
.budget-switcher.open .budget-menu { display: block; }

.budget-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: .875rem;
    cursor: pointer;
    color: var(--text);
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    transition: background .1s;
}
.budget-menu-item:last-child  { border-bottom: none; }
.budget-menu-item:hover       { background: var(--bg); }
.budget-menu-item.active      { font-weight: 700; color: var(--primary); }

.budget-check {
    width: 18px;
    text-align: center;
    font-size: .85rem;
    color: var(--primary);
    flex-shrink: 0;
}

.budget-menu-divider {
    height: 1px;
    background: var(--border);
}

.budget-menu-add   { color: var(--primary); font-weight: 600; }
.budget-menu-danger { color: var(--danger); }

/* ── Drag handle ── */
.drag-handle {
    color: var(--border);
    font-size: 1.1rem;
    cursor: grab;
    padding: 0 4px;
    flex-shrink: 0;
    line-height: 1;
    transition: color .15s;
}
.item-card:hover .drag-handle,
.category-row:hover .drag-handle { color: #9ca3af; }
.drag-handle:active { cursor: grabbing; }

/* ── Category header row ── */
.category-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg);
    border-radius: 8px;
    border-left: 3px solid var(--primary);
    margin-top: 6px;
}
.category-toggle   { display: flex; align-items: center; gap: 7px; flex: 1; cursor: pointer; }
.category-toggle:hover .category-name { color: var(--primary); }
.category-arrow    { font-size: .65rem; color: var(--primary); flex-shrink: 0; }
.category-name     { font-weight: 700; font-size: .9rem; }
.category-subtotal { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.category-collapsed { opacity: .8; }

/* ── Indented item ── */
.item-indented { margin-left: 20px; }

/* ── Drag states ── */
.dragging   { opacity: .4; }
.drag-over  { outline: 2px dashed var(--primary); outline-offset: 2px; border-radius: 10px; }

/* ── Collapse / expand all ── */
.btn-collapse-all {
    background: none;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.15rem;
    line-height: 1;
    padding: 4px 8px;
    transition: color .15s, border-color .15s;
}
.btn-collapse-all:hover { border-color: var(--primary); color: var(--primary); }

/* ── Category button variant ── */
.btn-add-category {
    background: none;
    color: var(--primary);
    border: 1.5px solid var(--primary);
}
.btn-add-category:hover { background: var(--primary); color: #fff; transform: translateY(-1px); }

/* ── Savings goal progress bar on item cards ── */
.goal-bar-wrap   { margin-top: 8px; }
.goal-bar-track  { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; margin-bottom: 4px; }
.goal-bar-fill   { height: 100%; background: var(--primary); border-radius: 99px; transition: width .4s ease; }
.goal-bar-fill.goal-done { background: #16a34a; }
.goal-bar-sub    { font-size: .75rem; color: var(--muted); }

/* ── Coming Up section ── */
.upcoming-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}
.upcoming-title {
    font-size: .875rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.upcoming-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}
.upcoming-item:last-child { border-bottom: none; }
.upcoming-item-name  { font-size: .9rem; font-weight: 600; }
.upcoming-item-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.upcoming-amount     { font-size: .9rem; font-weight: 700; }
.upcoming-label      { font-size: .75rem; font-weight: 600; border-radius: 4px; padding: 2px 7px; }
.due-today    { background: #fef2f2; color: #dc2626; }
.due-soon     { background: #fff7ed; color: #c2410c; }
.due-upcoming { background: #eff6ff; color: #1d4ed8; }

/* ── Due day badge on item cards ── */
.badge-due { background: #eff6ff; color: #1d4ed8; }

/* ── Empty state template button ── */
.btn-use-template {
    margin-top: 14px;
    background: none;
    color: var(--primary);
    border: 1.5px solid var(--primary);
    border-radius: 8px;
    padding: 9px 20px;
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.btn-use-template:hover { background: var(--primary); color: #fff; }

/* ── Item type selector tabs ── */
.item-type-selector {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
    background: var(--bg);
    border-radius: 8px;
    padding: 4px;
}
.item-type-btn {
    flex: 1;
    padding: 7px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.item-type-btn.active { background: var(--card); color: var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.item-type-btn:hover:not(.active):not(.premium-locked) { background: var(--card); color: var(--text); }
.item-type-btn.premium-locked { opacity: .5; cursor: not-allowed; }
.item-type-btn.premium-locked::after { content: ' 🔒'; font-size: .7em; }

/* ── Actual amount — inline on cards ── */
.actual-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 7px;
    flex-wrap: wrap;
}
.actual-label   { font-size: .75rem; color: var(--muted); }
.actual-value   { font-size: .75rem; font-weight: 700; color: var(--text); }
.actual-variance { font-size: .72rem; font-weight: 600; }
.variance-good  { color: #16a34a; }
.variance-bad   { color: #dc2626; }
.btn-actual-edit, .btn-actual-save, .btn-actual-cancel {
    background: none; border: none; cursor: pointer; font-size: .75rem; padding: 1px 3px; line-height: 1;
}
.btn-actual-save   { color: #16a34a; font-size: .9rem; }
.btn-actual-cancel { color: var(--muted); font-size: .9rem; }
.btn-actual-add {
    background: none;
    border: 1px dashed var(--border);
    border-radius: 4px;
    color: var(--muted);
    cursor: pointer;
    font-size: .72rem;
    padding: 2px 8px;
    transition: border-color .15s, color .15s;
}
.btn-actual-add:hover { border-color: var(--primary); color: var(--primary); }
.actual-input {
    width: 90px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: .8rem;
    padding: 3px 6px;
    outline: none;
}
.actual-input:focus { border-color: var(--primary); }

/* ── Actual summary row on set-asides card ── */
.actual-summary-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: .75rem;
}
.actual-summary-label  { color: var(--muted); }
.actual-summary-amount { font-weight: 700; color: var(--text); }
.actual-summary-variance { font-weight: 600; }

/* ── 3-month spending average ── */
.avg-row {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 5px;
    flex-wrap: wrap;
}
.avg-label  { font-size: .72rem; color: var(--muted); }
.avg-amount { font-size: .72rem; font-weight: 600; color: var(--muted); }
.avg-diff   { font-size: .72rem; font-weight: 700; }
.avg-over   { color: #dc2626; }
.avg-under  { color: #16a34a; }

/* ── Debt badge ── */
.badge-debt { background: #fef2f2; color: #b91c1c; }

/* ── Debt progress bar on item cards ── */
.debt-bar-wrap      { margin-top: 8px; }
.debt-bar-track     { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; margin-bottom: 4px; }
.debt-bar-fill      { height: 100%; background: #ef4444; border-radius: 99px; transition: width .4s ease; }
.debt-bar-fill.debt-done { background: #16a34a; }
.debt-bar-sub       { font-size: .75rem; color: var(--muted); }
.debt-savings-line  { font-size: .75rem; color: #16a34a; font-weight: 600; margin-top: 2px; }

/* ── Debt Overview panel ── */
.debt-overview-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}
.debt-overview-title {
    font-size: .875rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 14px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.debt-overview-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 14px;
}
.debt-stat { flex: 1; }
.debt-stat-label { font-size: .75rem; color: var(--muted); margin-bottom: 2px; }
.debt-stat-value { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.debt-overview-savings {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: .82rem;
    color: #15803d;
    margin-bottom: 14px;
}
.debt-overview-list { display: flex; flex-direction: column; gap: 10px; }
.debt-overview-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.debt-overview-item:last-child { border-bottom: none; }
.debt-overview-item-left { flex: 1; min-width: 0; }
.debt-overview-name { font-size: .875rem; font-weight: 600; margin-bottom: 5px; }
.debt-overview-bar-track { height: 4px; background: var(--border); border-radius: 99px; overflow: hidden; }
.debt-overview-bar-fill  { height: 100%; background: #ef4444; border-radius: 99px; transition: width .4s ease; }
.debt-overview-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; white-space: nowrap; }
.debt-overview-balance { font-size: .875rem; font-weight: 700; }
.debt-overview-payoff  { font-size: .75rem; color: var(--muted); }

/* ── Clear All button ── */
.btn-clear-all {
    background: none;
    color: var(--muted);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 9px 14px;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
    white-space: nowrap;
}
.btn-clear-all:hover { border-color: var(--danger); color: var(--danger); background: #fef2f2; }

/* ── Template selector modal ── */
.template-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    width: 100%;
    background: var(--card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    cursor: pointer;
    text-align: left;
    transition: border-color .15s, box-shadow .15s, background .12s;
}
.template-card:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.08);
    background: #faf9ff;
}
.template-card-emoji { font-size: 1.6rem; line-height: 1; flex-shrink: 0; margin-top: 2px; }
.template-card-name  { font-weight: 700; font-size: .95rem; margin-bottom: 4px; color: var(--text); }
.template-card-desc  { font-size: .83rem; color: var(--muted); line-height: 1.45; margin-bottom: 6px; }
.template-card-count { font-size: .78rem; color: var(--primary); font-weight: 600; }
