/* ═══ Reset & Base ═══ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Prompt', sans-serif;
    background: #F5F3EE;
    color: #3A3632;
    min-height: 100dvh;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}
input, select, button, textarea { font-family: inherit; font-size: inherit; }
a { color: inherit; text-decoration: none; }

.hidden { display: none !important; }

/* ═══ App Bar ═══ */
.app-bar {
    background: #2D5A3D;
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
.app-bar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    max-width: 600px;
    margin: 0 auto;
}
.app-bar-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
}
.app-bar-actions {
    display: flex;
    gap: 2px;
}
.app-bar-actions button {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
}
.app-bar-actions button:active { background: rgba(255,255,255,0.15); }
#btn-refresh.spinning span {
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ═══ Pages ═══ */
.page {
    display: none;
    padding: 16px;
    max-width: 600px;
    margin: 0 auto;
    padding-bottom: 100px;
}
.page.active { display: block; }
.page-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}
.page-header h2 { flex: 1; font-size: 16px; font-weight: 600; }
.back-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #3A3632;
    padding: 4px;
    border-radius: 8px;
    display: flex;
}
.back-btn:active { background: #E0DBD0; }

/* ═══ Section Label ═══ */
.section-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: #9C988F;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #E0DBD0;
}
.section-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
}
.section-row .section-label { margin-bottom: 0; }

/* ═══ Link Button ═══ */
.link-btn {
    background: none;
    border: none;
    color: #2D5A3D;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
}
.link-btn:active { background: rgba(45,90,61,0.08); }

/* ═══ Summary Cards ═══ */
.summary-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 2px 0 10px;
    margin-bottom: 4px;
}
.summary-scroll::-webkit-scrollbar { display: none; }
.scroll-hint-wrap { position: relative; }
.scroll-hint-left, .scroll-hint-right {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 2;
    color: #9C988F;
}
.scroll-hint-left .material-icons-outlined,
.scroll-hint-right .material-icons-outlined { font-size: 18px; }
.scroll-hint-left {
    left: 0;
    background: linear-gradient(to right, #F5F3EE, transparent);
}
.scroll-hint-right {
    right: 0;
    background: linear-gradient(to left, #F5F3EE, transparent);
}
.scroll-hint-left.hidden, .scroll-hint-right.hidden { display: none; }
.summary-card {
    min-width: 115px;
    flex-shrink: 0;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #E0DBD0;
    overflow: hidden;
}
.summary-card-inner {
    border-left: 3px solid var(--accent);
    padding: 10px;
}
.summary-card .label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #9C988F;
}
.summary-card .value {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
    margin-top: 4px;
    white-space: nowrap;
}

/* ═══ Borrows Banner ═══ */
.borrows-banner {
    background: #F5F0FF;
    border: 1px solid #D5C8F0;
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #6B4A8B;
}
.borrows-banner:active { background: #EBE5F5; }
.borrows-banner.hidden { display: none; }

/* ═══ Jar Cards ═══ */
.jar-cards-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 8px 0 12px;
}
.jar-cards-scroll::-webkit-scrollbar { display: none; }
.jar-card {
    min-width: 150px;
    flex-shrink: 0;
    background: #fff;
    border-radius: 14px;
    border: 1px solid #E0DBD0;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s;
}
.jar-card:active { transform: scale(0.97); }
.jar-card-header {
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
}
.jar-card-body { padding: 8px 10px 10px; }
.jar-card .jar-name-en {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.3px;
}
.jar-card .jar-name-th {
    font-size: 10px;
    color: #6B6760;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.jar-card .balance-box {
    margin-top: 8px;
    padding: 5px 6px;
    border-radius: 6px;
}
.jar-card .balance-label { font-size: 9px; color: #9C988F; font-weight: 600; }
.jar-card .balance-value { font-size: 13px; font-weight: 700; margin-top: 2px; }
.jar-card .mini-stats {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}
.jar-card .mini-stat {
    flex: 1;
    padding: 3px 4px;
    border-radius: 5px;
    font-size: 9px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 2px;
    overflow: hidden;
}
.jar-card .mini-stat .amt {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ═══ Filters ═══ */
.filter-row {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}
.filter-row select {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #E0DBD0;
    border-radius: 8px;
    background: #F9F7F3;
    color: #3A3632;
    font-size: 13px;
    appearance: auto;
}
.jar-filter-chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 10px 0;
}
.jar-filter-chips::-webkit-scrollbar { display: none; }
.jar-chip {
    flex-shrink: 0;
    padding: 6px 10px;
    border-radius: 20px;
    border: 1px solid #E0DBD0;
    background: #fff;
    font-size: 11px;
    font-weight: 600;
    color: #9C988F;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
    white-space: nowrap;
}
.jar-chip.active {
    border-width: 1.5px;
}

/* ═══ Entry List ═══ */
.entry-count {
    font-size: 12px;
    color: #9C988F;
    margin-bottom: 8px;
}
.entry-list {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #E0DBD0;
    overflow: hidden;
}
.entry-list:empty {
    border: none;
}
.entry-item {
    display: flex;
    align-items: flex-start;
    padding: 12px 14px;
    gap: 10px;
    border-bottom: 1px solid #E0DBD0;
}
.entry-item:last-child { border-bottom: none; }
.entry-badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 2px;
}
.entry-info { flex: 1; min-width: 0; }
.entry-desc {
    font-size: 14px;
    font-weight: 500;
    word-break: break-word;
}
.entry-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-top: 4px;
}
.entry-date { font-size: 11px; color: #9C988F; }
.entry-jar-tag {
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 700;
}
.entry-amount {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}
.entry-delete {
    background: none;
    border: none;
    color: #9C988F;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    font-size: 18px;
    line-height: 1;
}
.entry-delete:active { background: #F5F3EE; }
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #9C988F;
}

/* ═══ FAB ═══ */
.fab {
    position: fixed;
    bottom: 24px;
    right: 16px;
    background: #2D5A3D;
    color: #fff;
    border: none;
    border-radius: 16px;
    padding: 14px 20px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 16px rgba(45,90,61,0.3);
    z-index: 50;
    transition: all 0.2s;
}
.fab:active { transform: scale(0.95); }
.fab.scrolling {
    opacity: 0.4;
    transform: scale(0.85);
    padding: 12px;
    border-radius: 50%;
    gap: 0;
}
.fab.scrolling .fab-label { display: none; }
@media (max-width: 400px) {
    .fab { padding: 12px 16px; font-size: 14px; bottom: 20px; right: 12px; }
}

/* ═══ Modal ═══ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    align-items: flex-end;
    justify-content: center;
}
.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.2s;
}
.modal-sheet {
    background: #fff;
    border-radius: 20px 20px 0 0;
    padding: 12px 20px 20px;
    width: 100%;
    max-width: 600px;
    max-height: 90dvh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.25s ease-out;
}
.modal-handle {
    width: 36px;
    height: 4px;
    background: #E0DBD0;
    border-radius: 2px;
    margin: 0 auto 16px;
}
.modal-sheet h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}
.close-modal {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    color: #9C988F;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ═══ Form ═══ */
.form-group {
    margin-bottom: 12px;
}
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #6B6760;
    margin-bottom: 4px;
}
.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #E0DBD0;
    border-radius: 8px;
    background: #F9F7F3;
    font-size: 14px;
    color: #3A3632;
}
.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #2D5A3D;
    border-width: 2px;
}
.date-picker-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border: 1px solid #E0DBD0;
    border-radius: 8px;
    background: #F9F7F3;
    cursor: pointer;
    font-size: 14px;
    color: #3A3632;
}
/* The real date input overlays the whole field, transparent but tappable, so tapping
   it opens the native date picker directly on every platform (no showPicker() needed,
   which is unsupported/blocked in many mobile & in-app browsers). */
.date-picker-wrap input[type=date] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    opacity: 0;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}
.field-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #6B6760;
    margin: 8px 0 6px;
}
.balance-hint {
    display: block;
    font-size: 11px;
    font-weight: 600;
    margin-top: 4px;
    color: #6B6760;
}

/* ═══ Type Toggle ═══ */
.type-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}
.type-btn {
    flex: 1;
    padding: 10px;
    border: 1px solid #E0DBD0;
    border-radius: 8px;
    background: #F9F7F3;
    font-size: 14px;
    font-weight: 600;
    color: #9C988F;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
}
.type-btn.active.income,
.type-btn.active[style*="income"] { background: rgba(26,107,69,0.1); border-color: #1A6B45; color: #1A6B45; border-width: 2px; }
.type-btn.active.expense { background: rgba(139,32,32,0.1); border-color: #8B2020; color: #8B2020; border-width: 2px; }
.type-btn.active.carry { background: rgba(107,74,26,0.1); border-color: #6B4A1A; color: #6B4A1A; border-width: 2px; }
.type-btn.active { background: rgba(45,90,61,0.1); border-color: #2D5A3D; color: #2D5A3D; border-width: 2px; }

/* ═══ Jar Picker ═══ */
/* ═══ FFA Asset Checkbox ═══ */
.asset-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid #E0DBD0;
    border-radius: 8px;
    background: #F9F7F3;
    cursor: pointer;
    margin-top: 8px;
    margin-bottom: 10px;
    transition: all 0.15s;
}
.asset-checkbox.active {
    background: rgba(26,58,107,0.08);
    border-color: #1A3A6B;
    border-width: 2px;
}
.asset-checkbox-text {
    flex: 1;
}

.jar-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}
.jar-pick {
    padding: 6px 10px;
    border: 1px solid #E0DBD0;
    border-radius: 8px;
    background: #F9F7F3;
    font-size: 12px;
    font-weight: 600;
    color: #9C988F;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
}
.jar-pick.active { border-width: 2px; }
.jar-pick.disabled { opacity: 0.4; pointer-events: none; }
/* Carry-forward: jar already carried in for the selected month */
.jar-pick.cf-done::after {
    content: '🔒';
    font-size: 10px;
    margin-left: 2px;
}

/* ═══ Mode Buttons ═══ */
.mode-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
.mode-btn-sm {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #E0DBD0;
    border-radius: 8px;
    background: #F9F7F3;
    font-size: 12px;
    font-weight: 700;
    color: #6B6760;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
}
.mode-btn-sm.active { border-width: 2px; }
.mode-btn-sm small { display: block; font-size: 10px; font-weight: 400; color: #9C988F; }

/* ═══ Split Preview ═══ */
.split-preview {
    background: #F9F7F3;
    border: 1px solid #E0DBD0;
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 10px;
}
.split-row {
    display: flex;
    align-items: center;
    padding: 3px 0;
    font-size: 12px;
}
.split-row .jar-icon { font-size: 14px; margin-right: 6px; }
.split-row .jar-label { flex: 1; font-weight: 600; }
.split-row .jar-pct { color: #9C988F; font-size: 11px; margin-right: 8px; }
.split-row .jar-amt { font-weight: 700; }

/* ═══ Buttons ═══ */
.primary-btn {
    background: #2D5A3D;
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 14px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.primary-btn:active { transform: scale(0.98); }
.primary-btn:disabled { background: #E0DBD0; color: #9C988F; }
.primary-btn.purple { background: #6B4A8B; }
.primary-btn.purple:active { background: #5a3d78; }
.secondary-btn {
    background: #F9F7F3;
    color: #6B6760;
    border: 1px solid #E0DBD0;
    border-radius: 10px;
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.full-width { width: 100%; margin-top: 12px; }

/* ═══ Transfer Preview ═══ */
.transfer-preview {
    padding: 10px 14px;
    background: #F5F0FF;
    border: 1px solid #D5C8F0;
    border-radius: 10px;
    margin: 8px 0;
    font-size: 12px;
    font-weight: 700;
    color: #6B4A8B;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.transfer-preview.hidden { display: none; }

/* ═══ Duration Chips ═══ */
.duration-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
}
.duration-chip {
    padding: 6px 10px;
    border: 1px solid #E0DBD0;
    border-radius: 8px;
    background: #F9F7F3;
    font-size: 12px;
    font-weight: 700;
    color: #9C988F;
    cursor: pointer;
    transition: all 0.15s;
}
.duration-chip.num {
    width: 42px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 14px;
}
.duration-chip.active {
    background: rgba(107,74,139,0.12);
    border-color: #6B4A8B;
    color: #6B4A8B;
    border-width: 2px;
}
.duration-hint {
    font-size: 11px;
    color: #9C988F;
    font-style: italic;
    margin-bottom: 12px;
    min-height: 16px;
}

/* ═══ Rate Type Toggle ═══ */
.rate-type-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
.rate-type-btn {
    padding: 8px 14px;
    border: 1px solid #E0DBD0;
    border-radius: 8px;
    background: #F9F7F3;
    font-size: 13px;
    font-weight: 700;
    color: #9C988F;
    cursor: pointer;
    transition: all 0.15s;
}
.rate-type-btn.active {
    background: rgba(107,74,139,0.12);
    border-color: #6B4A8B;
    color: #6B4A8B;
    border-width: 2px;
}

/* ═══ FFA Source Toggle ═══ */
.ffa-source-toggle {
    display: flex;
    gap: 8px;
    margin: 8px 0 4px;
}
.ffa-source-btn {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #E0DBD0;
    border-radius: 8px;
    background: #F9F7F3;
    cursor: pointer;
    transition: all 0.15s;
}
.ffa-source-btn-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 700;
    color: #9C988F;
}
.ffa-source-btn-amt {
    font-size: 13px;
    font-weight: 700;
    color: #6B6760;
    margin-top: 2px;
}
.ffa-source-btn.active {
    background: rgba(26,58,107,0.10);
    border-color: #1A3A6B;
    border-width: 2px;
}
.ffa-source-btn.active .ffa-source-btn-label,
.ffa-source-btn.active .ffa-source-btn-amt {
    color: #1A3A6B;
}

/* ═══ Interest ═══ */
.interest-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}
.interest-chip {
    padding: 8px 14px;
    border: 1px solid #E0DBD0;
    border-radius: 8px;
    background: #F9F7F3;
    font-size: 13px;
    font-weight: 700;
    color: #9C988F;
    cursor: pointer;
    transition: all 0.15s;
}
.interest-chip.active {
    background: rgba(107,74,139,0.12);
    border-color: #6B4A8B;
    color: #6B4A8B;
    border-width: 2px;
}

/* ═══ Borrow Summary Box ═══ */
.borrow-summary-box {
    padding: 12px;
    background: #F5F0FF;
    border: 1px solid #D5C8F0;
    border-radius: 10px;
    margin-bottom: 10px;
}
.borrow-summary-box.hidden { display: none; }
.borrow-summary-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #6B4A8B;
    margin-bottom: 8px;
}
.borrow-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #6B6760;
    margin-bottom: 2px;
}
.borrow-summary-row.bold {
    font-weight: 700;
    color: #3A3632;
}
.borrow-summary-divider {
    border-top: 1px solid #D5C8F0;
    margin: 6px 0;
}
.borrow-schedule-title {
    font-size: 11px;
    font-weight: 700;
    color: #6B6760;
    margin-top: 10px;
    margin-bottom: 6px;
}
.borrow-schedule-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 3px;
}
.schedule-num {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(107,74,139,0.08);
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    color: #6B4A8B;
}
.schedule-date {
    flex: 1;
    font-size: 11px;
    color: #6B6760;
}
.schedule-amt {
    font-size: 11px;
    font-weight: 700;
    color: #3A3632;
}

/* ═══ Borrow Reason Chips ═══ */
.reason-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}
.reason-chip {
    padding: 6px 12px;
    border: 1px solid #E0DBD0;
    border-radius: 8px;
    background: #F9F7F3;
    font-size: 12px;
    font-weight: 600;
    color: #9C988F;
    cursor: pointer;
    transition: all 0.15s;
}
.reason-chip.active {
    background: rgba(107,74,139,0.12);
    border-color: #6B4A8B;
    color: #6B4A8B;
    border-width: 2px;
}

/* ═══ Borrows List ═══ */
.borrow-item {
    padding: 12px 0;
    border-bottom: 1px solid #E0DBD0;
}
.borrow-item:last-child { border-bottom: none; }
.borrow-header {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 700;
    flex-wrap: wrap;
}
.borrow-details {
    font-size: 12px;
    color: #6B6760;
    margin-top: 4px;
}
.borrow-interest {
    font-size: 11px;
    color: #E65100;
    font-weight: 600;
}
.borrow-repaid {
    font-size: 11px;
    color: #6B4A8B;
    font-weight: 600;
}
.borrow-repay-btn {
    background: none;
    border: none;
    color: #6B4A8B;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    padding: 4px 8px;
}

/* ═══ Repay Options ═══ */
.repay-option-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: #F5F0FF;
    border: 1px solid #6B4A8B;
    border-radius: 10px;
    cursor: pointer;
    margin-bottom: 8px;
    transition: background 0.15s;
}
.repay-option-btn:active { background: #EBE5F5; }

/* ═══ Chart Page ═══ */
.chart-mode-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.mode-btn {
    flex: 1;
    padding: 10px;
    border: 1px solid #E0DBD0;
    border-radius: 8px;
    background: #fff;
    font-size: 13px;
    font-weight: 600;
    color: #9C988F;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
}
.mode-btn.active { background: #2D5A3D; color: #fff; border-color: #2D5A3D; }
#chart-period {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #E0DBD0;
    border-radius: 8px;
    background: #F9F7F3;
    font-size: 13px;
    margin-bottom: 16px;
}
.chart-summary {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.chart-container {
    background: #fff;
    border: 1px solid #E0DBD0;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 16px;
}
.pie-wrapper {
    position: relative;
}
#pie-center-text {
    position: absolute;
    pointer-events: none;
    text-align: center;
    transform: translate(-50%, -50%);
    line-height: 1.3;
}
.empty-chart {
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9C988F;
    font-size: 13px;
}
.jar-detail-card {
    background: #fff;
    border: 1px solid #E0DBD0;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
}
.jar-detail-header {
    display: flex;
    align-items: center;
    gap: 10px;
}
.jar-detail-icon {
    padding: 7px;
    border-radius: 8px;
    display: flex;
}
.jar-detail-names { flex: 1; }
.jar-detail-names .en { font-size: 13px; font-weight: 700; }
.jar-detail-names .th { font-size: 11px; color: #9C988F; }
.jar-detail-balance { text-align: right; }
.jar-detail-balance .lbl { font-size: 10px; color: #9C988F; }
.jar-detail-balance .val { font-size: 15px; font-weight: 700; }
.jar-detail-stats {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}
.jar-stat-box {
    flex: 1;
    padding: 7px 10px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 600;
}
.jar-stat-box .val { font-size: 12px; font-weight: 700; }
.jar-accum-box {
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
}
.jar-accum-box .val { margin-left: auto; font-size: 13px; font-weight: 700; }
.jar-progress {
    margin-top: 8px;
}
.jar-progress-bar {
    height: 6px;
    border-radius: 4px;
    overflow: hidden;
}
.jar-progress-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }
.jar-progress-text { font-size: 10px; color: #9C988F; margin-top: 4px; }

/* ═══ Settings ═══ */
.settings-section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #9C988F;
    margin: 24px 0 12px;
}
.settings-section-header:first-child { margin-top: 0; }
.total-bar {
    background: #fff;
    border: 1px solid #E0DBD0;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
}
.total-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.total-bar-header .label { font-size: 13px; font-weight: 600; }
.total-bar-header .pct { font-size: 18px; font-weight: 700; }
.total-bar-progress {
    height: 8px;
    border-radius: 4px;
    background: #E0DBD0;
    overflow: hidden;
}
.total-bar-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }
.total-bar-msg { font-size: 11px; margin-top: 6px; }
.jar-slider-card {
    background: #fff;
    border: 1px solid #E0DBD0;
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 10px;
}
.jar-slider-header {
    display: flex;
    align-items: center;
    gap: 10px;
}
.jar-slider-icon {
    padding: 6px;
    border-radius: 8px;
    display: flex;
}
.jar-slider-names { flex: 1; }
.jar-slider-names .en { font-size: 13px; font-weight: 700; }
.jar-slider-names .th { font-size: 11px; color: #9C988F; }
.jar-slider-input {
    width: 56px;
    text-align: center;
    padding: 6px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 700;
}
.jar-slider-desc {
    font-size: 10px;
    color: #9C988F;
    margin-top: 4px;
}
.jar-slider-range {
    width: 100%;
    margin-top: 4px;
    accent-color: var(--color);
}
.ext-balance-row {
    background: #fff;
    border: 1px solid #E0DBD0;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.ext-balance-row label { flex: 1; font-size: 13px; font-weight: 600; }
.ext-balance-row input {
    width: 120px;
    text-align: right;
    padding: 8px 10px;
    border: 1px solid #E0DBD0;
    border-radius: 8px;
    background: #F9F7F3;
    font-size: 14px;
    font-weight: 700;
}
.ext-balance-row span { font-weight: 700; color: #6B6760; }
.data-actions {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #E0DBD0;
    border-radius: 12px;
    overflow: hidden;
}
.data-action-tile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    cursor: pointer;
    border-bottom: 1px solid #E0DBD0;
    transition: background 0.15s;
}
.data-action-tile:last-child { border-bottom: none; }
.data-action-tile:active { background: #F9F7F3; }
.data-action-tile .material-icons-outlined { font-size: 22px; }
.data-action-tile div { flex: 1; }
.data-action-tile strong { font-size: 14px; display: block; }
.data-action-tile small { font-size: 11px; color: #9C988F; }
.export-range-panel {
    background: #fff;
    border: 1px solid #E0DBD0;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.export-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #E0DBD0;
    border-radius: 8px;
    background: #F9F7F3;
    font-size: 14px;
    font-weight: 600;
    color: #3A362F;
    font-family: inherit;
}
.export-months-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.export-months-row .export-select { flex: 1; }
.export-range-sep { font-size: 13px; font-weight: 600; color: #6B6760; }

/* ═══ Toast ═══ */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: #2D5A3D;
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    z-index: 300;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    animation: fadeIn 0.2s;
    max-width: 90%;
    text-align: center;
}
.toast.error { background: #8B2020; }
.toast.hidden { display: none; }

/* ═══ Loading Spinner ═══ */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══ Splash Screen ═══ */
.splash-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #1A3D2A 0%, #2D5A3D 50%, #3A7050 100%);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    transition: opacity 0.4s;
}
.splash-screen.fade-out { opacity: 0; }
.splash-circles {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
.splash-circles-g1, .splash-circles-g2 {
    transition: opacity 1s ease-in;
}
.splash-circles-g1.show, .splash-circles-g2.show { opacity: 0.6; }
.splash-content {
    text-align: center;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.splash-logo {
    width: 100px;
    height: 100px;
    background: rgba(255,255,255,0.15);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    opacity: 0;
    transform: scale(0.3);
}
.splash-logo.show {
    animation: splashElastic 1.2s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}
.splash-logo .material-icons-outlined {
    font-size: 48px;
    color: #fff;
}
.splash-title {
    color: #fff;
    font-size: 36px;
    font-weight: 700;
    letter-spacing: 2px;
    margin-top: 28px;
    opacity: 0;
    transform: translateY(12px);
}
.splash-title.show {
    animation: splashSlideUp 0.8s ease-out forwards;
}
.splash-subtitle {
    color: rgba(255,255,255,0.8);
    font-size: 15px;
    font-weight: 400;
    letter-spacing: 1.5px;
    margin-top: 8px;
    opacity: 0;
}
.splash-subtitle.show {
    animation: splashFadeIn 0.8s 0.3s ease-in forwards;
}
.splash-jars {
    display: flex;
    gap: 12px;
    margin-top: 48px;
    opacity: 0;
}
.splash-jars.show {
    animation: splashFadeIn 1s ease-in forwards;
}
.splash-jar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.splash-jar .material-icons-outlined {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--jc);
    background: color-mix(in srgb, var(--jc) 20%, transparent);
    border: 1px solid color-mix(in srgb, var(--jc) 40%, transparent);
    border-radius: 12px;
}
.splash-jar small {
    font-size: 9px;
    font-weight: 600;
    color: var(--jc);
}
.splash-bottom {
    position: absolute;
    bottom: 50px;
    text-align: center;
    z-index: 1;
    opacity: 0;
}
.splash-bottom.show {
    animation: splashFadeIn 1s ease-in forwards;
}
.splash-bottom div:first-child {
    font-size: 12px;
    color: rgba(255,255,255,0.6);
    letter-spacing: 0.5px;
}
.splash-ver {
    font-size: 11px;
    color: rgba(255,255,255,0.4);
    margin-top: 4px;
}
@keyframes splashElastic {
    0% { opacity: 0; transform: scale(0.3); }
    50% { opacity: 1; }
    70% { transform: scale(1.1); }
    85% { transform: scale(0.95); }
    100% { opacity: 1; transform: scale(1); }
}
@keyframes splashSlideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes splashFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ═══ Auth Screen ═══ */
.auth-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(160deg, #2D5A3D 0%, #1A3A28 100%);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.auth-card {
    background: #fff;
    border-radius: 20px;
    padding: 32px 24px;
    width: 100%;
    max-width: 360px;
    text-align: center;
    box-shadow: 0 8px 40px rgba(0,0,0,0.15);
    animation: slideUp 0.3s ease-out;
}
.auth-icon {
    width: 72px;
    height: 72px;
    border-radius: 18px;
    margin-bottom: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.auth-card h2 {
    font-size: 20px;
    font-weight: 700;
    color: #2D5A3D;
    margin-bottom: 4px;
}
.auth-desc {
    font-size: 13px;
    color: #9C988F;
    margin-bottom: 20px;
}
.auth-error {
    background: #FDF0F0;
    border: 1px solid #F5C6C6;
    color: #8B2020;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 16px;
    text-align: left;
}
.auth-field {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #F9F7F3;
    border: 1px solid #E0DBD0;
    border-radius: 10px;
    padding: 0 14px;
    margin-bottom: 12px;
    transition: border-color 0.15s;
}
.auth-field:focus-within {
    border-color: #2D5A3D;
    border-width: 2px;
    padding: 0 13px;
}
.auth-field .material-icons-outlined {
    font-size: 20px;
    color: #9C988F;
}
.auth-field input {
    flex: 1;
    border: none;
    background: none;
    padding: 14px 0;
    font-size: 15px;
    color: #3A3632;
    outline: none;
}
.auth-btn {
    width: 100%;
    background: #2D5A3D;
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 14px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 4px;
    transition: all 0.15s;
}
.auth-btn:active { transform: scale(0.98); }
.auth-btn:disabled { background: #E0DBD0; color: #9C988F; }

/* ═══ Responsive ═══ */
@media (max-width: 360px) {
    .summary-card { min-width: 100px; }
    .jar-card { min-width: 135px; }
    .app-bar-title span:last-child { font-size: 14px; }
}

/* ═══ Scan Slip ═══ */
.scan-pick-row {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}
.scan-pick-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px;
    background: #EAF5EE;
    border: 1px solid #A8D8BC;
    border-radius: 10px;
    color: #2D5A3D;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.scan-pick-btn:active { background: #D4EAD9; }
.scan-pick-btn .material-icons-outlined { font-size: 24px; }
.scan-preview {
    position: relative;
    margin-bottom: 12px;
    border-radius: 10px;
    overflow: hidden;
    background: #F9F7F3;
    text-align: center;
}
.scan-preview.hidden { display: none; }
.scan-preview img {
    max-height: 200px;
    max-width: 100%;
    object-fit: contain;
}
.scan-rescan-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.scan-rescan-overlay.hidden { display: none; }
.scan-rescan-overlay .material-icons-outlined { font-size: 20px; }
.scan-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    color: #6B6760;
    font-size: 13px;
}
.scan-status.hidden { display: none; }
.scan-error {
    padding: 10px 14px;
    background: #FDF0F0;
    border: 1px solid #E8B4B4;
    border-radius: 8px;
    color: #8B2020;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 10px;
}
.scan-error.hidden { display: none; }
.scan-dupe-warn {
    padding: 10px 14px;
    background: #FFF3E0;
    border: 1px solid #FFB74D;
    border-radius: 8px;
    color: #E65100;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 10px;
}
.scan-dupe-warn.hidden { display: none; }
.scan-success-msg {
    padding: 10px 14px;
    background: #EAF5EE;
    border: 1px solid #A8D8BC;
    border-radius: 8px;
    color: #1A6B45;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 10px;
}
.scan-success-msg.hidden { display: none; }

/* ═══ Font Settings ═══ */
.font-setting-card {
    background: #fff;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
}
.font-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.font-grid-item {
    padding: 10px 6px;
    text-align: center;
    border: 2px solid #E0DBD0;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    color: #6B6760;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1.3;
}
.font-grid-item.active {
    border-color: #2D5A3D;
    background: rgba(45,90,61,0.08);
    color: #2D5A3D;
}
.font-size-range {
    width: 100%;
    accent-color: #2D5A3D;
    margin: 6px 0 2px;
}
.font-size-marks {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #9C988F;
    padding: 0 2px;
}
.font-preview {
    margin-top: 14px;
    padding: 14px;
    background: #F5F3EE;
    border-radius: 10px;
    text-align: center;
}
.font-preview-title {
    font-size: 11px;
    font-weight: 600;
    color: #9C988F;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
