/* ═══════════════════════════════════════════════════════════
   MANY — Mobile Responsive Stylesheet
   iOS/iPhone-optimized, fintech-grade UX
   Complements styles.css — loaded after it
   ═══════════════════════════════════════════════════════════ */

/* ─── iOS SAFE AREA VARIABLES ───────────────────────────── */
:root {
    --safe-top:     env(safe-area-inset-top,    0px);
    --safe-bottom:  env(safe-area-inset-bottom, 0px);
    --safe-left:    env(safe-area-inset-left,   0px);
    --safe-right:   env(safe-area-inset-right,  0px);
    --mobile-nav-h: 64px;
}

/* ─── SMOOTH TOUCH SCROLLING ─────────────────────────────── */
.content-area,
.tab-content,
.section-panel,
.modal-container,
.dropdown-content {
    -webkit-overflow-scrolling: touch;
}

/* ═══════════════════════════════════════════════════════════
   PREVENT iOS AUTO-ZOOM ON INPUT FOCUS (font-size < 16px)
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 800px) {
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="search"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   MOBILE TOPBAR — Fintech-grade redesign
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 800px) {

    .mobile-topbar {
        position: sticky;
        top: 0;
        z-index: 150;
        height: calc(54px + var(--safe-top));
        padding: calc(var(--safe-top) + 9px) 14px 9px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        background: rgba(255, 255, 255, 0.9);
        backdrop-filter: saturate(180%) blur(20px);
        -webkit-backdrop-filter: saturate(180%) blur(20px);
        border-bottom: 1px solid var(--color-border);
        box-shadow: 0 1px 8px rgba(0,0,0,0.05);
    }

    [data-theme="dark"] .mobile-topbar,
    body.dark .mobile-topbar {
        background: rgba(30, 41, 59, 0.92);
    }

    /* Left cluster: logo + hamburger */
    .mobile-topbar__left {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-shrink: 0;
    }

    .mobile-topbar__logo {
        display: block;
        flex-shrink: 0;
    }

    .mobile-menu-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
        border-radius: 10px;
        -webkit-tap-highlight-color: transparent;
    }

    /* Right cluster: month nav + user avatar */
    .mobile-topbar__right {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-shrink: 0;
    }

    .mobile-topbar__month-nav {
        display: flex;
        align-items: center;
        gap: 2px;
        background: var(--color-surface-alt);
        border: 1px solid var(--color-border);
        border-radius: 22px;
        padding: 3px 4px;
        flex-shrink: 0;
    }

    .mobile-topbar__month-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 30px;
        height: 30px;
        border: none;
        background: transparent;
        border-radius: 50%;
        cursor: pointer;
        color: var(--color-text-muted);
        transition: background 0.12s, color 0.12s;
        -webkit-tap-highlight-color: transparent;
        flex-shrink: 0;
    }

    .mobile-topbar__month-btn:active {
        background: var(--color-surface-dark);
        color: var(--color-primary);
    }

    .mobile-topbar__month-label {
        font-size: 11.5px;
        font-weight: 800;
        font-family: var(--font-numeric);
        color: var(--color-text);
        min-width: 72px;
        text-align: center;
        letter-spacing: 0.01em;
        white-space: nowrap;
        text-transform: capitalize;
    }

    /* User avatar button */
    .mobile-topbar__user-btn {
        width: 34px;
        height: 34px;
        min-width: 34px;
        border-radius: 50%;
        border: 2px solid var(--color-border);
        background: var(--color-surface-alt);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        color: var(--color-text-muted);
        overflow: hidden;
        -webkit-tap-highlight-color: transparent;
        transition: border-color 0.15s;
    }

    .mobile-topbar__user-btn:active {
        border-color: var(--color-primary);
    }

    .mobile-topbar__user-btn .material-symbols-outlined {
        font-size: 20px;
        line-height: 1;
    }

    /* Lock button — shows only when PIN is enabled */
    .mobile-topbar__lock-btn {
        width: 34px;
        height: 34px;
        min-width: 34px;
        border-radius: 50%;
        border: none;
        background: transparent;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        color: var(--color-text-muted);
        -webkit-tap-highlight-color: transparent;
        transition: background 0.12s, color 0.12s;
    }

    .mobile-topbar__lock-btn:active {
        background: rgba(234, 88, 12, 0.08);
        color: var(--color-primary);
    }

    .mobile-topbar__lock-btn .material-symbols-outlined {
        font-size: 20px;
        line-height: 1;
    }

    /* Search / Command Bar button */
    .mobile-topbar__search-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
        border-radius: 10px;
        border: none;
        background: transparent;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        color: var(--color-text-muted);
        -webkit-tap-highlight-color: transparent;
        transition: background 0.12s, color 0.12s;
    }

    .mobile-topbar__search-btn:active {
        background: var(--color-surface-alt);
        color: var(--color-text);
    }

    .mobile-topbar__search-btn .material-symbols-outlined {
        font-size: 21px;
        line-height: 1;
    }
}

/* ═══════════════════════════════════════════════════════════
   BOTTOM NAVIGATION — Material Design 3 / iOS-grade
   ═══════════════════════════════════════════════════════════ */

/* Override: show on all mobile sizes (not just ≤480px) */
@media (max-width: 800px) {

    .bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(var(--mobile-nav-h) + var(--safe-bottom));
        padding-bottom: var(--safe-bottom);
        padding-left: var(--safe-left);
        padding-right: var(--safe-right);
        background: rgba(255, 255, 255, 0.88);
        backdrop-filter: saturate(180%) blur(24px);
        -webkit-backdrop-filter: saturate(180%) blur(24px);
        border-top: 1px solid var(--color-border);
        justify-content: space-around;
        align-items: stretch;
        z-index: 1000;
        box-shadow: 0 -2px 20px rgba(0,0,0,0.07);
    }

    [data-theme="dark"] .bottom-nav,
    body.dark .bottom-nav {
        background: rgba(30, 41, 59, 0.9);
    }

    .bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 8px 4px 6px;
        background: transparent;
        border: none;
        color: var(--color-text-muted);
        font-size: 9.5px;
        font-weight: 600;
        font-family: var(--font-display);
        cursor: pointer;
        min-height: 56px;
        text-align: center;
        -webkit-tap-highlight-color: transparent;
        transition: color 0.18s;
        position: relative;
        max-width: 80px;
    }

    .bottom-nav-item__icon {
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 10px;
        transition: background 0.18s, transform 0.15s;
        position: relative;
    }

    .bottom-nav-item__icon .material-symbols-outlined {
        font-size: 22px;
        line-height: 1;
        font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 24;
        transition: font-variation-settings 0.18s;
        display: block;
    }

    .bottom-nav-item__label {
        font-size: 9.5px;
        line-height: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 72px;
    }

    /* Active state */
    .bottom-nav-item.active {
        color: var(--color-primary);
    }

    .bottom-nav-item.active .bottom-nav-item__icon {
        background: rgba(234, 88, 12, 0.12);
    }

    .bottom-nav-item.active .bottom-nav-item__icon .material-symbols-outlined {
        font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
    }

    /* Press feedback */
    .bottom-nav-item:active .bottom-nav-item__icon {
        transform: scale(0.87);
    }

    /* Active pill indicator (top) */
    .bottom-nav-item.active::before {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 24px;
        height: 3px;
        background: var(--color-primary);
        border-radius: 0 0 3px 3px;
    }

    /* Adjust FAB position */
    .fab {
        display: flex;
        bottom: calc(var(--mobile-nav-h) + var(--safe-bottom) + 10px);
    }

    /* Body padding for fixed bottom nav */
    body {
        padding-bottom: calc(var(--mobile-nav-h) + var(--safe-bottom)) !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   CONTENT AREA PADDING
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 800px) {
    .main-wrapper .content-area {
        padding: 18px 16px 24px !important;
    }
}

@media (max-width: 480px) {
    .main-wrapper .content-area {
        padding: 14px 12px 20px !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   TOUCH TARGET ENFORCEMENT (Apple HIG: 44px minimum)
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 800px) {
    .btn,
    .btn-primary,
    .btn-secondary,
    .btn-danger {
        min-height: 44px;
    }

    .btn-danger-sm,
    .btn-edit-sm,
    .btn-success-sm {
        min-height: 40px;
        min-width: 40px;
        padding: 8px 10px;
    }

    /* Checkbox and radio touch areas */
    input[type="checkbox"],
    input[type="radio"] {
        width: 20px;
        height: 20px;
        min-width: 20px;
    }
}

/* ═══════════════════════════════════════════════════════════
   FORM GRIDS — Single column on small screens
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .form-group label {
        font-size: 13px;
    }

    .form-control {
        padding: 10px 12px;
    }
}

/* ═══════════════════════════════════════════════════════════
   SECTION PANELS — Tighter on mobile
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
    .section-panel {
        border-radius: 14px !important;
        padding: 16px !important;
        margin-bottom: 14px !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   PAGE HEADERS (section titles + action buttons)
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
    /* Stack title and action buttons */
    .page-header,
    .section-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }

    .page-header .btn-group,
    .section-header .btn-group,
    .income-actions,
    .section-actions {
        width: 100%;
        justify-content: flex-end;
    }

    /* Large title font reduce */
    .section-panel h2[style*="1.875rem"],
    h2[style*="1.875rem"] {
        font-size: 1.4rem !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   TABLE → CARD CONVERSION on Mobile
   Income, Fixed Expenses, Debts tables become readable cards
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 640px) {

    /* Hide table headers */
    #incomeTableBody ~ * thead,
    table:has(#incomeTableBody) thead,
    table:has(#fxTableBody) thead,
    table:has(#otherDebtsTableBody) thead {
        display: none;
    }

    /* Card-style rows (exclude empty-state rows)
       Layout de 2 filas:
         Fila 1: [nombre (flex:1)]  [acciones]
         Fila 2: [badge categoría]  [monto]
    */
    #incomeTableBody tr:not(.table-row-empty),
    #fxTableBody tr:not(.table-row-empty),
    #otherDebtsTableBody tr:not(.table-row-empty) {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        border: 1px solid var(--color-border);
        border-radius: 12px;
        margin-bottom: 10px;
        padding: 10px 14px;
        gap: 4px 0;
        background: var(--color-surface);
        box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    }

    #incomeTableBody tr:not(.table-row-empty) td,
    #fxTableBody tr:not(.table-row-empty) td,
    #otherDebtsTableBody tr:not(.table-row-empty) td {
        border: none !important;
        padding: 2px 0 !important;
        font-size: 13px;
        display: flex;
        align-items: center;
    }

    /* td:1 — nombre: fila 1 izquierda, crece */
    #incomeTableBody tr:not(.table-row-empty) td:first-child,
    #fxTableBody tr:not(.table-row-empty) td:first-child,
    #otherDebtsTableBody tr:not(.table-row-empty) td:first-child {
        order: 1;
        flex: 1 1 0;
        min-width: 0;
        font-weight: 700;
        font-size: 14px;
        color: var(--color-text);
        padding-right: 8px !important;
    }

    /* td:2 — badge (Salario/Extra): fila 2 derecha, donde estaba el monto */
    #incomeTableBody tr:not(.table-row-empty) td:nth-child(2),
    #fxTableBody tr:not(.table-row-empty) td:nth-child(2),
    #otherDebtsTableBody tr:not(.table-row-empty) td:nth-child(2) {
        order: 4;
        margin-left: auto;
        padding-top: 4px !important;
    }

    /* td:3 — monto: oculto en móvil */
    #incomeTableBody tr:not(.table-row-empty) td:nth-child(3),
    #fxTableBody tr:not(.table-row-empty) td:nth-child(3),
    #otherDebtsTableBody tr:not(.table-row-empty) td:nth-child(3) {
        display: none !important;
    }

    /* td:last — acciones: fila 1 derecha, sin posición absoluta */
    #incomeTableBody tr:not(.table-row-empty) td:last-child,
    #fxTableBody tr:not(.table-row-empty) td:last-child,
    #otherDebtsTableBody tr:not(.table-row-empty) td:last-child {
        order: 2;
        flex-shrink: 0;
    }

    /* Hide table wrapper overflow on mobile */
    [style*="overflow-x:auto"],
    [style*="overflow-x: auto"] {
        overflow-x: visible;
    }
}

/* ═══════════════════════════════════════════════════════════
   DASHBOARD — Mobile
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    #heroMetric {
        padding: 20px 18px !important;
        border-radius: 18px !important;
    }

    .hero-metric__amount {
        font-size: clamp(1.8rem, 8vw, 2.5rem) !important;
    }

    /* Dashboard stat cards: 2 columns */
    .dashboard-kpi-grid,
    #dashboardKpiCards {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }
}

@media (max-width: 380px) {
    .dashboard-kpi-grid,
    #dashboardKpiCards {
        grid-template-columns: 1fr !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   DISTRIBUTION — Mobile
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    #distCards {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }
}

@media (max-width: 380px) {
    #distCards {
        grid-template-columns: 1fr !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   INVESTMENTS — Mobile
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    .inv-summary-grid,
    #invSummaryCards {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }

    .inv-type-cards,
    #invCardsGrid {
        grid-template-columns: 1fr !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   FIXED EXPENSES SUMMARY CARDS — Mobile
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    #fxSummaryCards {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   DEBTS — Mobile sidebar reset
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 800px) {
    /* Remove the 43px offset that was for desktop alignment */
    #debts .sv-col-sidebar {
        margin-top: 0 !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   CREDIT CARDS (Debts tab) — Full width on mobile
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    #creditCardsContainer .card,
    #creditCardsContainer [class*="card"] {
        border-radius: 14px;
    }
}

/* ═══════════════════════════════════════════════════════════
   EMERGENCY GAUGE — Center on mobile
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    .em-gauge-wrap,
    [id="em-gauge-container"],
    #emGaugeWrap {
        margin: 0 auto;
        max-width: 280px;
    }

    /* History table → cards */
    #emHistoryTable tr,
    #em-history-table tr {
        display: flex;
        flex-wrap: wrap;
        border: 1px solid var(--color-border);
        border-radius: 10px;
        margin-bottom: 8px;
        padding: 10px 12px;
        background: var(--color-surface);
    }

    #emHistoryTable thead,
    #em-history-table thead {
        display: none;
    }

    #emHistoryTable td,
    #em-history-table td {
        border: none !important;
        padding: 2px 0 !important;
        font-size: 13px;
    }
}

/* ═══════════════════════════════════════════════════════════
   SAVINGS GOALS GRID — Mobile
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    .sv-goals-grid,
    #svGoalsContainer {
        grid-template-columns: 1fr !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   HEALTH SCORE CARD — Mobile
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    #healthScore {
        padding: 18px !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   MODAL / WIZARD — Full-screen on mobile
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
    .wizard-container,
    .modal-container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        border-radius: 20px 20px 0 0 !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding-bottom: calc(20px + var(--safe-bottom));
        max-height: 92vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .wizard-overlay,
    .modal-overlay {
        align-items: flex-end !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   SIDEBAR — Safe area for notch
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 800px) {
    .nav-sidebar {
        padding-bottom: calc(var(--mobile-nav-h) + var(--safe-bottom) + 16px);
        width: min(280px, 85vw);
    }
}

/* ═══════════════════════════════════════════════════════════
   CALENDAR — Mobile
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 800px) {
    /* Stack columns: show sidebar (metas ETA) below calendar on mobile */
    #calendar .sv-layout { display: flex; flex-direction: column; }
    #calendar .sv-col-sidebar { order: 1; }
}

@media (max-width: 640px) {
    .calendar-day {
        min-height: 52px !important;
        font-size: 11px !important;
    }
    /* Calendar grid: tighter gaps on mobile */
    .calendar-grid { gap: 4px !important; }
}

/* ═══════════════════════════════════════════════════════════
   TOUR TOOLTIP — Mobile sizing
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    .tour-tooltip {
        width: calc(100vw - 28px) !important;
        max-width: 360px;
        font-size: 13px !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   DROPDOWN MENUS — Full width on small screens
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
    .dropdown-content {
        left: 0 !important;
        right: 0 !important;
        width: auto !important;
        margin: 0 12px !important;
        border-radius: 14px !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   INCOME HEADER — Stack on mobile
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
    .income-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   BUTTON GROUPS — Flexible wrapping
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
    .flex.gap-sm,
    .flex[style*="gap:8px"],
    .flex[style*="gap: 8px"] {
        flex-wrap: wrap;
    }

    /* Prevent single button from overflowing */
    .btn {
        min-width: 0;
        white-space: nowrap;
    }
}

/* ═══════════════════════════════════════════════════════════
   CHART CONTAINERS — Constrained height on mobile
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    canvas {
        max-height: 260px;
    }
}

/* ═══════════════════════════════════════════════════════════
   SWIPE INDICATOR — iOS-friendly pill
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 800px) {
    .swipe-indicator {
        bottom: calc(var(--mobile-nav-h) + var(--safe-bottom) + 12px);
        background: rgba(0,0,0,0.75);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        font-size: 12px;
        padding: 8px 16px;
    }
}

/* ═══════════════════════════════════════════════════════════
   PRIVACY OVERLAY — Mobile safe area
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 800px) {
    body.privacy-active::before {
        bottom: calc(var(--mobile-nav-h) + var(--safe-bottom));
    }
}

/* ═══════════════════════════════════════════════════════════
   PROGRESS PANEL — Mobile
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 800px) {
    .progress-panel {
        left: 0 !important;
        right: 0 !important;
        bottom: calc(var(--mobile-nav-h) + var(--safe-bottom) + 8px) !important;
        top: auto !important;
        max-width: 100%;
        margin: 0 12px;
        border-radius: 16px;
    }
}

/* ═══════════════════════════════════════════════════════════
   MOBILE CONTENT HIERARCHY — Hide decorative / low-priority
   elements that clutter the mobile experience
   ═══════════════════════════════════════════════════════════ */

/* ─── Tip/info cards: educational, not needed during daily use ─── */
@media (max-width: 800px) {
    .dist-tip-card,
    .em-tip-card { display: none !important; }
}

/* ─── Long descriptive subtexts inside panels ─── */
@media (max-width: 600px) {
    /* Cierre de Mes intro paragraph */
    .dist-panel-header + div > p:first-child { display: none; }

    /* Emergency form panel description */
    .em-panel-desc { display: none; }
}

/* ═══════════════════════════════════════════════════════════
   DISTRIBUTION — Mobile priority layout
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 800px) {
    /* Bring Cierre de Mes sidebar to top so it's immediately visible */
    #distribution .sv-layout { display: flex; flex-direction: column; }
    #distribution .sv-col-sidebar { order: -1; }

    /* Hide breakdown detail panel — alloc cards already show the numbers */
    #distribution .sv-col-main .section-panel:nth-child(2) { display: none; }

    /* Page header: stack on mobile */
    .dist-page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .dist-btn-save {
        width: 100%;
        justify-content: center;
    }

    /* Allocation cards: tighter on mobile */
    .dist-alloc-grid > div {
        border-radius: 14px !important;
    }

    /* Panel header ghost buttons: compact */
    .dist-ghost-btn { padding: 6px 10px; font-size: 11px; }
}

@media (max-width: 480px) {
    /* Config rows: tighter */
    #distConfigGrid > div {
        padding: 10px 12px !important;
        border-radius: 10px !important;
    }
    /* Percentage input: slightly smaller */
    .dist-input { width: 56px !important; }
}

@media (max-width: 380px) {
    /* Hide S/ amount in config rows — too cramped; alloc cards above show totals */
    #distConfigGrid > div > div:nth-child(2) > div:first-child > span:last-child {
        display: none;
    }
    /* Icon: reduce to 36px to give more room to label */
    #distConfigGrid > div > div:first-child {
        width: 36px !important;
        height: 36px !important;
        border-radius: 9px !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   EMERGENCY — Mobile refinements
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 800px) {
    /* Scenario analysis: hide on mobile — useful on desktop only */
    #emergency .sv-col-main { display: none; }

    /* History sidebar becomes full width */
    #emergency .sv-col-sidebar { width: 100%; }
    #emergency .sv-layout { display: block; }

    /* Limit history scroll area */
    #em-history-list { max-height: 280px; }

    /* Page header compact */
    .em-page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .em-header-actions {
        display: flex;
        gap: 8px;
        width: 100%;
    }
    .em-btn-primary { flex: 1; justify-content: center; }
    .em-btn-ghost   { flex: 1; justify-content: center; }
}

@media (max-width: 640px) {
    /* Hero card: compact gauge, stack layout */
    .em-hero-card { padding: 20px 16px; border-radius: 16px; }
    .em-hero-inner { gap: 16px; }
    .em-gauge-wrap { width: 136px; height: 136px; }
    .em-gauge-pct  { font-size: 28px !important; }

    /* KPI row: 3 small cards side by side */
    .em-kpi-row { gap: 8px; }
    .em-kpi-card {
        padding: 12px 10px;
        gap: 8px;
        border-radius: 12px;
    }
    .em-kpi-icon { width: 34px; height: 34px; border-radius: 10px; }
    .em-kpi-value { font-size: 16px !important; }
    .em-kpi-label { font-size: 10px; }
}

/* ═══════════════════════════════════════════════════════════
   SAVINGS — Mobile refinements
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 800px) {
    /* Goals grid: single column */
    .sv-goals-grid,
    #svGoalsContainer { grid-template-columns: 1fr !important; }
}

/* ═══════════════════════════════════════════════════════════
   INVESTMENTS — Mobile refinements
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 800px) {
    /* Summary cards: 2×2 */
    .inv-summary-grid { grid-template-columns: 1fr 1fr !important; }
}

/* ═══════════════════════════════════════════════════════════
   GLOBAL PANEL POLISH — Tighter headers on mobile
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
    /* Compact panel headers */
    .dist-panel-header,
    .em-scenarios-header,
    .em-history-header {
        padding: 11px 14px;
    }

    /* Section panels: remove top padding when panel-header is first child */
    .section-panel[style*="padding:0"] {
        border-radius: 14px !important;
    }

    /* Reduce form group label size */
    .em-form-panel .form-group label,
    .dist-confirm-panel .form-group label {
        font-size: 12px;
    }
}

/* ═══════════════════════════════════════════════════════════
   TOUR — Mobile bottom sheet overrides
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 800px) {
    /* Slightly larger touch targets for tour buttons */
    .tour-tooltip--mobile .tour-btn-next,
    .tour-tooltip--mobile .tour-btn-exit {
        min-height: 44px;
    }
}

/* ═══════════════════════════════════════════════════════════
   LOGIN SCREEN — Full responsive (mobile-first)
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* Switch from 2-column to single column */
    .login-screen-modern {
        grid-template-columns: 1fr !important;
    }

    /* Hide decorative branding panel — form is all that matters */
    .login-panel-left { display: none !important; }

    /* Right panel fills full screen */
    .login-panel-right {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 100vh;
        padding: 32px 24px;
        background: linear-gradient(160deg, #f8fafc 0%, #f1f5f9 100%);
    }

    [data-theme="dark"] .login-panel-right,
    body.dark .login-panel-right {
        background: linear-gradient(160deg, #0f172a 0%, #1e293b 100%);
    }

    .login-form-container {
        width: 100%;
        max-width: 400px;
        padding: 0;
    }

    /* Compact welcome header */
    .login-welcome { margin-bottom: 24px; text-align: center; }
    .login-welcome-title { font-size: 1.5rem; }

    /* Mobile brand logo */
    .login-mobile-brand {
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-bottom: 28px;
        gap: 6px;
    }
    .login-mobile-brand svg {
        filter: drop-shadow(0 4px 12px rgba(245,158,11,.25));
    }
    .login-mobile-appname {
        font-family: 'Space Grotesk', 'Outfit', sans-serif;
        font-size: 1.6rem;
        font-weight: 700;
        letter-spacing: 3px;
        color: var(--color-text, #1e293b);
        line-height: 1;
    }
    .login-mobile-tagline {
        font-size: 0.68rem;
        font-weight: 500;
        letter-spacing: 2px;
        text-transform: uppercase;
        color: var(--color-text-muted, #64748b);
    }

    /* Full-width Google button */
    .btn-google-modern { width: 100%; justify-content: center; }

    /* Compact info cards */
    .login-info-cards { gap: 8px; }
    .login-info-card  { padding: 10px 12px; font-size: 12px; }

    /* Hide help text on very small screens */
    .login-help { text-align: center; font-size: 12px; }
}

@media (max-width: 400px) {
    .login-panel-right { padding: 24px 16px; }
    .login-welcome-title { font-size: 1.3rem; }
}

/* ═══════════════════════════════════════════════════════════
   MOBILE DASHBOARD
   ═══════════════════════════════════════════════════════════ */

/* Hidden on desktop — shown only on mobile */
.mdb-wrap      { display: none; }
.db-desktop-only { display: block; }

@media (max-width: 800px) {
    .db-desktop-only { display: none !important; }

    .mdb-wrap {
        display: flex;
        flex-direction: column;
        gap: 18px;
        padding-bottom: 28px;
    }

    /* ── Hero card ── */
    .mdb-hero {
        background: var(--color-primary);
        border-radius: 24px;
        padding: 22px 22px 20px;
        color: #fff;
        position: relative;
        overflow: hidden;
        box-shadow: 0 8px 28px rgba(234,88,12,.32);
    }
    .mdb-hero__blob {
        position: absolute;
        border-radius: 50%;
        pointer-events: none;
    }
    .mdb-hero__blob--1 {
        width: 160px; height: 160px;
        background: rgba(255,255,255,.1);
        filter: blur(28px);
        right: -40px; top: -40px;
    }
    .mdb-hero__blob--2 {
        width: 120px; height: 120px;
        background: rgba(0,0,0,.08);
        filter: blur(20px);
        left: -30px; bottom: -30px;
    }
    .mdb-hero__top {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 6px;
        position: relative;
    }
    .mdb-hero__label {
        font-size: 13px;
        font-weight: 600;
        color: rgba(255,255,255,.72);
        margin: 0;
    }
    .mdb-hero__privacy {
        width: 30px; height: 30px;
        border-radius: 50%;
        border: none;
        background: rgba(255,255,255,.18);
        color: #fff;
        display: flex; align-items: center; justify-content: center;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        flex-shrink: 0;
    }
    .mdb-hero__privacy .material-symbols-outlined { font-size: 17px; }
    .mdb-hero__amount {
        display: flex;
        align-items: baseline;
        gap: 5px;
        margin: 4px 0 20px;
        position: relative;
        line-height: 1;
    }
    .mdb-hero__currency {
        font-size: 1.5rem;
        font-weight: 700;
        opacity: .8;
        font-family: var(--font-numeric);
    }
    #m-heroAmount {
        font-size: 2.6rem;
        font-weight: 800;
        font-family: var(--font-numeric);
        letter-spacing: -.03em;
    }
    .mdb-hero__actions {
        display: flex;
        gap: 10px;
        position: relative;
    }
    .mdb-hero__btn {
        flex: 1;
        padding: 10px 8px;
        border-radius: 14px;
        border: none;
        background: rgba(255,255,255,.2);
        color: #fff;
        font-size: 13px;
        font-weight: 600;
        display: flex; align-items: center; justify-content: center;
        gap: 5px;
        cursor: pointer;
        font-family: var(--font-primary);
        -webkit-tap-highlight-color: transparent;
        transition: background .14s;
    }
    .mdb-hero__btn .material-symbols-outlined { font-size: 15px; }
    .mdb-hero__btn:active { background: rgba(255,255,255,.32); transform: scale(.97); }

    /* ── Horizontal metrics ── */
    .mdb-metrics {
        display: flex;
        gap: 8px;
        overflow-x: visible;
    }
    .mdb-metrics::-webkit-scrollbar { display: none; }
    .mdb-metric {
        flex: 1 1 0;
        min-width: 0;
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: 16px;
        padding: 11px 10px;
    }
    .mdb-metric__icon {
        width: 28px; height: 28px;
        border-radius: 50%;
        display: flex; align-items: center; justify-content: center;
        margin-bottom: 7px;
    }
    .mdb-metric__icon .material-symbols-outlined { font-size: 14px; }
    .mdb-metric__icon--green  { background: rgba(16,185,129,.12); color: #10b981; }
    .mdb-metric__icon--red    { background: rgba(239,68,68,.1);   color: #ef4444; }
    .mdb-metric__icon--purple { background: rgba(124,58,237,.1);  color: #7c3aed; }
    .mdb-metric__label {
        font-size: 9.5px;
        font-weight: 600;
        color: var(--color-text-muted);
        margin: 0 0 2px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .mdb-metric__value {
        font-size: 0.82rem;
        font-weight: 800;
        color: var(--color-text);
        margin: 0;
        font-family: var(--font-numeric);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* ── Section wrapper ── */
    .mdb-section__hdr {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 12px;
    }
    .mdb-section__title {
        font-size: .95rem;
        font-weight: 700;
        color: var(--color-text);
        margin: 0;
    }
    .mdb-section__link {
        font-size: 13px;
        font-weight: 600;
        color: var(--color-primary);
        border: none;
        background: none;
        cursor: pointer;
        padding: 0;
        font-family: var(--font-primary);
    }

    /* ── Donut chart card ── */
    .mdb-chart-card {
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: 20px;
        padding: 20px;
        display: flex;
        flex-direction: column;
        gap: 18px;
    }
    .mdb-donut-wrap {
        position: relative;
        width: 160px;
        height: 160px;
        margin: 0 auto;
    }
    .mdb-donut-wrap canvas {
        position: absolute;
        top: 0; left: 0;
    }
    .mdb-donut-center {
        position: absolute;
        inset: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        pointer-events: none;
    }
    .mdb-donut-center__lbl {
        font-size: 11px;
        color: var(--color-text-muted);
        font-weight: 500;
    }
    .mdb-donut-center__val {
        font-size: 14px;
        font-weight: 700;
        color: var(--color-text);
        font-family: var(--font-numeric);
    }
    .mdb-legend {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    .mdb-legend-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    .mdb-legend-row__l {
        display: flex;
        align-items: center;
        gap: 8px;
    }
    .mdb-legend-dot {
        width: 10px; height: 10px;
        border-radius: 50%;
        flex-shrink: 0;
    }
    .mdb-legend-lbl {
        font-size: 13px;
        font-weight: 500;
        color: var(--color-text-secondary);
    }
    .mdb-legend-pct {
        font-size: 13px;
        font-weight: 700;
        color: var(--color-text);
        font-family: var(--font-numeric);
    }

    /* ── Health score card ── */
    .mdb-health {
        background: var(--color-surface-alt);
        border: 1px solid var(--color-border);
        border-radius: 20px;
        padding: 20px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
    }
    .mdb-health__lbl {
        font-size: 12px;
        font-weight: 500;
        color: var(--color-text-muted);
        margin: 0 0 3px;
    }
    .mdb-health__title {
        font-size: 1.15rem;
        font-weight: 700;
        color: var(--color-text);
        margin: 0 0 3px;
    }
    .mdb-health__sub {
        font-size: 11px;
        font-weight: 600;
        color: #10b981;
        margin: 0;
    }
    .mdb-health__ring {
        position: relative;
        width: 64px; height: 64px;
        flex-shrink: 0;
    }
    .mdb-health__score {
        position: absolute;
        inset: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
        font-weight: 800;
        color: var(--color-text);
        font-family: var(--font-numeric);
    }
}

/* ═══════════════════════════════════════════════════════════
   MOBILE FIXED EXPENSES  (.mfe-*)
   ═══════════════════════════════════════════════════════════ */
.mfe-wrap { display: none; }
.fe-desktop-only { display: block; }

@media (max-width: 800px) {
    .fe-desktop-only { display: none !important; }

    .mfe-wrap {
        display: flex;
        flex-direction: column;
        gap: 16px;
        padding: 16px 16px calc(24px + var(--safe-bottom, 0px));
    }

    /* ── Hero ── */
    .mfe-hero {
        background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
        border-radius: 22px;
        padding: 24px 20px 20px;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 8px;
        position: relative;
        overflow: hidden;
    }
    .mfe-hero::before {
        content: '';
        position: absolute;
        top: -30px; right: -30px;
        width: 120px; height: 120px;
        border-radius: 50%;
        background: rgba(255,255,255,.08);
    }
    .mfe-hero__label {
        font-size: 12px;
        font-weight: 600;
        color: rgba(255,255,255,.75);
        letter-spacing: .04em;
        text-transform: uppercase;
    }
    .mfe-hero__amount {
        font-size: 2.4rem;
        font-weight: 900;
        color: #fff;
        font-family: var(--font-numeric);
        letter-spacing: -.03em;
        line-height: 1;
    }
    .mfe-hero__badge {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        background: rgba(255,255,255,.18);
        border: 1px solid rgba(255,255,255,.25);
        border-radius: 999px;
        padding: 4px 12px;
        font-size: 12px;
        font-weight: 700;
        color: #fff;
    }

    /* ── Metrics ── */
    .mfe-metrics {
        display: flex;
        gap: 8px;
    }
    .mfe-metric {
        flex: 1 1 0;
        min-width: 0;
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: 16px;
        padding: 11px 10px;
        display: flex;
        flex-direction: column;
        gap: 5px;
    }
    .mfe-metric__icon {
        width: 28px; height: 28px;
        border-radius: 50%;
        display: flex; align-items: center; justify-content: center;
        margin-bottom: 2px;
    }
    .mfe-metric__icon .material-symbols-outlined { font-size: 14px; }
    .mfe-icon--green  { background: rgba(16,185,129,.12);  color: #10b981; }
    .mfe-icon--red    { background: rgba(239,68,68,.10);   color: #ef4444; }
    .mfe-icon--purple { background: rgba(99,102,241,.12);  color: #6366f1; }
    .mfe-metric__label {
        font-size: 9.5px;
        font-weight: 600;
        color: var(--color-text-muted);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .mfe-metric__value {
        font-size: 0.82rem;
        font-weight: 800;
        color: var(--color-text);
        font-family: var(--font-numeric);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* ── Sections ── */
    .mfe-section {
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: 20px;
        padding: 18px 16px;
    }
    .mfe-section__hdr {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 16px;
    }
    .mfe-section__title {
        font-size: 15px;
        font-weight: 700;
        color: var(--color-text);
    }
    .mfe-section__sub {
        font-size: 11px;
        font-weight: 500;
        color: var(--color-text-muted);
        background: var(--color-bg, #f3f4f6);
        padding: 3px 8px;
        border-radius: 6px;
    }
    .mfe-see-all {
        display: inline-flex;
        align-items: center;
        gap: 3px;
        font-size: 12px;
        font-weight: 700;
        color: #6366f1;
        background: rgba(99,102,241,.08);
        border: none;
        border-radius: 8px;
        padding: 5px 10px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    /* ── Bar chart ── */
    .mfe-chart {
        display: flex;
        align-items: flex-end;
        justify-content: space-between;
        gap: 6px;
        height: 100px;
    }
    .mfe-bar-col {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 6px;
        flex: 1;
    }
    .mfe-bar-track {
        width: 100%;
        height: 80px;
        background: var(--color-bg, #f3f4f6);
        border-radius: 6px 6px 0 0;
        position: relative;
        overflow: hidden;
    }
    .mfe-bar-fill {
        position: absolute;
        bottom: 0;
        width: 100%;
        border-radius: 6px 6px 0 0;
        background: #c7d2fe;
        transition: height .5s cubic-bezier(.4,0,.2,1);
    }
    .mfe-bar-fill--current { background: #6366f1; box-shadow: 0 0 10px rgba(99,102,241,.4); }
    .mfe-bar-label {
        font-size: 10px;
        font-weight: 700;
        color: var(--color-text-muted);
        text-transform: uppercase;
    }
    .mfe-bar-label--current { color: var(--color-text); }

    /* ── List ── */
    .mfe-list {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    .mfe-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px;
        background: var(--color-bg, #f9fafb);
        border-radius: 14px;
        border: 1px solid var(--color-border);
        -webkit-tap-highlight-color: transparent;
        cursor: pointer;
        transition: background .15s;
    }
    .mfe-item:active { background: var(--color-surface-alt, #f0f0f5); }
    .mfe-item__icon {
        width: 40px; height: 40px;
        border-radius: 12px;
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        display: flex; align-items: center; justify-content: center;
        font-size: 18px;
        flex-shrink: 0;
    }
    .mfe-item__info {
        flex: 1;
        min-width: 0;
    }
    .mfe-item__name {
        font-size: 14px;
        font-weight: 700;
        color: var(--color-text);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .mfe-item__cat {
        font-size: 11px;
        color: var(--color-text-muted);
        font-weight: 500;
    }
    .mfe-item__right {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 4px;
        flex-shrink: 0;
    }
    .mfe-item__amount {
        font-size: 14px;
        font-weight: 800;
        color: #ef4444;
        font-family: var(--font-numeric);
    }
    .mfe-item__badge {
        font-size: 10px;
        font-weight: 700;
        border-radius: 999px;
        padding: 2px 8px;
    }
    .mfe-item__badge--paid    { background: rgba(16,185,129,.12); color: #10b981; }
    .mfe-item__badge--pending { background: rgba(239,68,68,.10);  color: #ef4444; }

    .mfe-empty {
        text-align: center;
        padding: 24px 0;
        color: var(--color-text-muted);
        font-size: 13px;
    }
}

/* ═══════════════════════════════════════════════════════════
   FX FORM / DELETE PANELS — Bottom Sheet on Mobile
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 800px) {
    /* Backdrop overlay when open */
    .fx-shared-panel.fx-panel--open {
        position: fixed !important;
        inset: 0 !important;
        z-index: 9990 !important;
        background: rgba(0,0,0,.45) !important;
        backdrop-filter: blur(3px) !important;
        -webkit-backdrop-filter: blur(3px) !important;
        border-radius: 0 !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
        display: flex !important;
        align-items: flex-end !important;
    }

    .fx-panel-handle {
        width: 40px;
        height: 4px;
        background: var(--color-border);
        border-radius: 99px;
        margin: 0 auto 16px;
    }

    .fx-panel-inner {
        width: 100%;
        background: var(--color-surface);
        border-radius: 24px 24px 0 0;
        padding: 14px 20px calc(20px + env(safe-area-inset-bottom, 0px));
        max-height: 90vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        animation: fxSheetUp .28s cubic-bezier(.4,0,.2,1);
    }

    @keyframes fxSheetUp {
        from { transform: translateY(100%); }
        to   { transform: translateY(0); }
    }
}

/* ═══════════════════════════════════════════════════════════
   QUICK EXPENSE — Bottom Sheet
   ═══════════════════════════════════════════════════════════ */

/* Backdrop */
.qe-sheet {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 9999;
    display: flex;
    align-items: flex-end;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

/* Card */
.qe-card {
    width: 100%;
    max-height: 88vh;
    background: var(--color-surface);
    border-radius: 24px 24px 0 0;
    padding: 12px 20px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transform: translateY(100%);
    transition: transform .32s cubic-bezier(.4,0,.2,1);
    box-shadow: 0 -12px 48px rgba(0,0,0,.22);
    overflow: hidden;
}
.qe-card--open  { transform: translateY(0); }
.qe-card--closing { transform: translateY(100%); }

/* Scrollable inner body (everything except save btn) */
.qe-body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.qe-body::-webkit-scrollbar { display: none; }

/* Sticky save footer */
.qe-footer {
    padding: 10px 0 calc(16px + env(safe-area-inset-bottom, 0px));
    flex-shrink: 0;
}

/* Handle bar */
.qe-handle-bar {
    width: 40px; height: 4px;
    background: var(--color-border);
    border-radius: 99px;
    margin: 0 auto -4px;
    flex-shrink: 0;
}

/* Header */
.qe-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.qe-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-text);
    font-family: var(--font-display);
}
.qe-close {
    width: 32px; height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}
.qe-close .material-symbols-outlined { font-size: 18px; }

/* Amount display */
.qe-amount-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--color-surface-alt);
    border: 2px solid var(--color-border);
    border-radius: 16px;
    padding: 10px 18px;
    transition: border-color .18s;
}
.qe-amount-wrap:focus-within {
    border-color: var(--color-primary);
    background: var(--color-primary-bg, rgba(234,88,12,.06));
}
.qe-currency {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--color-primary);
    font-family: var(--font-numeric);
    flex-shrink: 0;
}
.qe-amount-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 2rem;
    font-weight: 800;
    color: var(--color-text);
    font-family: var(--font-numeric);
    outline: none;
    width: 100%;
    min-width: 0;
}
.qe-amount-input::placeholder { color: var(--color-text-muted); opacity: .5; }
.qe-amount-input::-webkit-inner-spin-button,
.qe-amount-input::-webkit-outer-spin-button { -webkit-appearance: none; }

/* Quick amount chips */
.qe-quick-row {
    display: flex;
    gap: 8px;
}
.qe-quick-chip {
    flex: 1;
    padding: 7px 4px;
    border-radius: 10px;
    border: 1.5px solid var(--color-border);
    background: var(--color-surface-alt);
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-numeric);
    transition: background .14s, border-color .14s, color .14s;
    -webkit-tap-highlight-color: transparent;
}
.qe-quick-chip:active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
    transform: scale(.96);
}

/* Section label */
.qe-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--color-text-muted);
    margin: 0;
}

/* Category chips */
.qe-categories {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.qe-cat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 6px;
    border-radius: 12px;
    border: 1.5px solid var(--color-border);
    background: var(--color-surface-alt);
    cursor: pointer;
    font-size: 20px;
    transition: background .14s, border-color .14s, transform .1s;
    -webkit-tap-highlight-color: transparent;
}
.qe-cat span {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--color-text-secondary);
    font-family: var(--font-primary);
}
.qe-cat.active {
    background: var(--color-primary-bg, rgba(234,88,12,.1));
    border-color: var(--color-primary);
}
.qe-cat.active span { color: var(--color-primary); }
.qe-cat:active { transform: scale(.94); }

/* Description input */
.qe-desc {
    width: 100%;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1.5px solid var(--color-border);
    background: var(--color-surface-alt);
    font-size: 14px;
    color: var(--color-text);
    font-family: var(--font-primary);
    outline: none;
    box-sizing: border-box;
    transition: border-color .18s;
}
.qe-desc:focus { border-color: var(--color-primary); }
.qe-desc::placeholder { color: var(--color-text-muted); }

/* Save button */
.qe-save {
    width: 100%;
    padding: 15px;
    border-radius: 14px;
    border: none;
    background: var(--color-primary);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-primary);
    box-shadow: 0 4px 18px rgba(234,88,12,.35);
    transition: opacity .14s, transform .1s;
    -webkit-tap-highlight-color: transparent;
}
.qe-save .material-symbols-outlined { font-size: 20px; }
.qe-save:active { opacity: .88; transform: scale(.98); }
