@charset "UTF-8";
/* =====================================================================
   app.css — Bộ giao diện dùng chung cho toàn app Personal Finance
   Thay cho ~1.400 dòng CSS bị copy-paste trong 18 trang.

   Nguyên tắc:
   - Mobile-first, co giãn theo mọi màn hình (clamp + grid auto-fit)
   - Hỗ trợ vùng an toàn iPhone (tai thỏ + thanh home): env(safe-area-inset-*)
   - Mọi nút bấm tối thiểu 44x44px theo chuẩn Apple/Google
   - Tự đổi sáng/tối theo hệ thống (dùng data-bs-theme của Bootstrap 5.3)
   - Màu thương hiệu dùng cho hành động; xanh/đỏ CHỈ dùng cho số tiền
   ===================================================================== */

/* ============================ 1. TOKENS ============================ */
:root {
    /* Màu thương hiệu — cam vàng.
       #C2410C đạt tương phản 5.18:1 với chữ trắng (chuẩn cần >= 4.5) nên nút
       chữ trắng vẫn đọc rõ; phần rực rỡ dồn vào dải chuyển màu bên dưới. */
    --brand:            #C2410C;
    --brand-600:        #9A3412;
    --brand-100:        #FFF1E3;
    --brand-contrast:   #FFFFFF;
    --brand-grad:       linear-gradient(135deg, #FBBF24 0%, #F59E0B 38%, #EA580C 100%);

    /* Các mức trong suốt viết sẵn bằng rgba.
       KHONG dung ham tron mau moi cua CSS: Safari duoi iOS 16.2 khong hieu,
       se lam MAT NEN thanh tren va thanh duoi -> noi dung troi xuyen qua. */
    --brand-shadow:     rgba(194, 65, 12, .34);
    --brand-ring:       rgba(194, 65, 12, .22);
    --brand-bd:         rgba(194, 65, 12, .26);
    --surface-blur:     rgba(255, 255, 255, .90);
    --surface-blur-2:   rgba(255, 255, 255, .95);

    /* Màu số tiền (chỉ dùng cho tiền, không dùng cho nút) */
    --money-in:         #15803D;
    --money-in-bg:      #E9F7EF;
    --money-in-bd:      rgba(21, 128, 61, .32);
    --money-out:        #DC2626;
    --money-out-bg:     #FEF0F0;
    --money-out-bd:     rgba(220, 38, 38, .32);
    --warn:             #B45309;
    --warn-bg:          #FFF8E6;
    --warn-bd:          rgba(180, 83, 9, .34);

    /* Nền & chữ */
    --bg:               #F6F6F8;
    --surface:          #FFFFFF;
    --surface-2:        #FAFAFB;
    --border:           #E6E7EB;
    --border-strong:    #D6D8DE;
    --text:             #15161A;
    --text-2:           #5B5F6B;
    --text-3:           #8E93A0;

    /* Bán kính & bóng */
    --r-sm:  10px;
    --r:     14px;
    --r-lg:  18px;
    --r-pill: 999px;
    --sh-1: 0 1px 2px rgba(16,18,24,.05), 0 1px 3px rgba(16,18,24,.04);
    --sh-2: 0 2px 8px rgba(16,18,24,.07);
    --sh-3: 0 8px 24px rgba(16,18,24,.10);

    /* Khoảng cách & chiều cao */
    --gutter:     clamp(14px, 4vw, 24px);
    --topbar-h:   56px;
    --tabbar-h:   58px;
    --tap:        44px;
    --page-max:   680px;

    /* Vùng an toàn iPhone */
    --sa-top:    env(safe-area-inset-top, 0px);
    --sa-bottom: env(safe-area-inset-bottom, 0px);
    --sa-left:   env(safe-area-inset-left, 0px);
    --sa-right:  env(safe-area-inset-right, 0px);
}

/* ============ 1b. LỚP THÍCH ỨNG THEO LOẠI MÀN HÌNH ============
   Toàn bộ giao diện đọc các token dưới đây, nên chỉ cần đổi ở một chỗ là
   mọi trang tự co giãn đúng theo máy. Không trang nào phải viết CSS riêng.

   Nhóm máy:
     <=374px   điện thoại nhỏ   (iPhone SE, mini)
     375-413   điện thoại thường (iPhone 13/14/15, Android phổ thông)
     414-480   điện thoại lớn   (iPhone 14/15/16 Pro Max, Plus)
     481-833   máy tính bảng dọc
     >=834     máy tính bảng ngang & máy tính
   ============================================================ */

/* Mặc định = điện thoại thường */
:root {
    --fs-base:   15.5px;   /* cỡ chữ gốc            */
    --tile-h:    66px;     /* ô nút tắt ở trang chủ */
    --row-pad-y: 9px;      /* độ dày dòng giao dịch */
    --icon-sz:   34px;     /* vòng icon đầu dòng    */
    --hero-pad:  16px;     /* đệm trong thẻ số dư   */
}

/* Điện thoại nhỏ — dồn chặt lại để vẫn đủ chỗ */
@media (max-width: 374px) {
    :root {
        --gutter:    12px;
        --fs-base:   14.5px;
        --topbar-h:  52px;
        --tabbar-h:  54px;
        --tile-h:    60px;
        --row-pad-y: 8px;
        --icon-sz:   30px;
        --hero-pad:  13px;
    }
}

/* Điện thoại lớn (Pro Max / Plus) — thoáng hơn, chữ to hơn một chút */
@media (min-width: 414px) and (max-width: 480px) {
    :root {
        --gutter:    18px;
        --fs-base:   16px;
        --topbar-h:  58px;
        --tabbar-h:  60px;
        --tile-h:    72px;
        --row-pad-y: 11px;
        --icon-sz:   38px;
        --hero-pad:  19px;
    }
}

/* Máy tính bảng dọc */
@media (min-width: 481px) and (max-width: 833px) {
    :root {
        --gutter:    22px;
        --fs-base:   16px;
        --page-max:  640px;
        --tile-h:    78px;
        --row-pad-y: 12px;
        --icon-sz:   40px;
        --hero-pad:  22px;
    }
}

/* Máy tính bảng ngang & máy tính — bỏ thanh tab dưới, dùng chiều ngang */
@media (min-width: 834px) {
    :root {
        --gutter:    24px;
        --fs-base:   16px;
        --page-max:  760px;
        --tile-h:    82px;
        --row-pad-y: 13px;
        --icon-sz:   40px;
        --hero-pad:  24px;
    }
}

/* Điện thoại xoay ngang: màn rất thấp, phải giảm chiều cao thanh và đệm */
@media (max-height: 480px) and (orientation: landscape) {
    :root {
        --topbar-h:  46px;
        --tile-h:    56px;
        --row-pad-y: 7px;
        --hero-pad:  12px;
    }
}

[data-bs-theme="dark"] {
    --brand:            #FB923C;
    --brand-600:        #FDBA74;
    --brand-100:        #3A2110;
    --brand-contrast:   #2A1204;
    --brand-grad:       linear-gradient(135deg, #B45309 0%, #7C2D12 100%);

    --brand-shadow:     rgba(251, 146, 60, .30);
    --brand-ring:       rgba(251, 146, 60, .26);
    --brand-bd:         rgba(251, 146, 60, .30);
    --surface-blur:     rgba(23, 24, 29, .90);
    --surface-blur-2:   rgba(23, 24, 29, .95);

    --money-in:         #4ADE80;
    --money-in-bg:      #11291B;
    --money-in-bd:      rgba(74, 222, 128, .32);
    --money-out:        #FF6B6B;
    --money-out-bg:     #2B1416;
    --money-out-bd:     rgba(255, 107, 107, .32);
    --warn:             #FBBF24;
    --warn-bg:          #2A2008;
    --warn-bd:          rgba(251, 191, 36, .34);

    --bg:               #0C0D10;
    --surface:          #17181D;
    --surface-2:        #1E1F25;
    --border:           #2A2C34;
    --border-strong:    #3A3D47;
    --text:             #F2F3F5;
    --text-2:           #A8ACB8;
    --text-3:           #7C818F;

    --sh-1: 0 1px 2px rgba(0,0,0,.4);
    --sh-2: 0 2px 10px rgba(0,0,0,.45);
    --sh-3: 0 10px 28px rgba(0,0,0,.55);
}

/* ============================ 2. BASE ============================ */
*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;   /* iPhone không tự phóng chữ khi xoay ngang */
    text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: var(--fs-base);
    line-height: 1.5;
    overflow-x: hidden;               /* chặn trôi ngang trên màn hẹp */
    overscroll-behavior-y: contain;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--brand); }
a:hover { color: var(--brand-600); }

/* Mọi thứ bấm được: không delay 300ms, không bị chọn chữ khi bấm giữ */
a, button, .btn, [role="button"], label, summary {
    touch-action: manipulation;
}

img, svg, canvas { max-width: 100%; height: auto; }

/* Chữ dài (mô tả giao dịch) không được làm vỡ layout */
.text-wrap-safe { overflow-wrap: anywhere; word-break: break-word; }

:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
    border-radius: 6px;
}

[data-bs-theme="dark"] :focus-visible { outline-color: var(--brand); }

/* ======================= 3. KHUNG TRANG ======================= */
/* Nội dung mọi trang: tự chừa chỗ cho thanh trên + tab bar dưới + tai thỏ */
.container,
.app-container {
    width: 100%;
    max-width: var(--page-max);
    margin-inline: auto;
    padding-inline: max(var(--gutter), var(--sa-left)) max(var(--gutter), var(--sa-right));
}

/* Trang rộng (thống kê, danh sách ví) cho phép tràn rộng hơn trên desktop */
.container-wide { --page-max: 1100px; }

.app-main {
    padding-top: calc(var(--topbar-h) + var(--sa-top) + 12px);
    padding-bottom: calc(var(--tabbar-h) + var(--sa-bottom) + 24px);
    min-height: 100vh;
    min-height: 100dvh;
}

/* Trang không có tab bar (đăng nhập, đăng ký) */
.app-main--plain { padding-bottom: calc(var(--sa-bottom) + 24px); }

/* ======================= 4. THANH TRÊN ======================= */
.topbar {
    position: fixed;
    will-change: transform;        /* tách lớp riêng, không vẽ lại khi cuộn */
    transform: translateZ(0);
    inset: 0 0 auto 0;
    z-index: 1030;
    height: calc(var(--topbar-h) + var(--sa-top));
    padding-top: var(--sa-top);
    display: flex;
    align-items: center;
    gap: 6px;
    padding-inline: max(10px, var(--sa-left)) max(10px, var(--sa-right));
    /* Nền đặc, KHÔNG dùng hiệu ứng mờ nền.
       Trên iPhone, blur trên thanh cố định buộc trình duyệt vẽ lại mỗi khung hình
       khi cuộn -> giật. Nền đặc vừa mượt vừa chạy được trên mọi đời máy. */
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar__btn {
    flex: 0 0 auto;
    width: var(--tap);
    height: var(--tap);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--text);
    border-radius: var(--r-sm);
    font-size: 1.25rem;
    text-decoration: none;
}
.topbar__btn:active { background: var(--surface-2); color: var(--text); }

.topbar__title {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-size: clamp(1rem, 4.2vw, 1.125rem);
    font-weight: 700;
    color: var(--text);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar__title--left { text-align: left; padding-left: 4px; }

.topbar__actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: var(--tap);
    justify-content: flex-end;
}

/* ======================= 5. TAB BAR DƯỚI ======================= */
.tabbar {
    position: fixed;
    will-change: transform;
    transform: translateZ(0);
    inset: auto 0 0 0;
    z-index: 1030;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: end;
    height: calc(var(--tabbar-h) + var(--sa-bottom));
    padding-bottom: var(--sa-bottom);
    padding-inline: max(0px, var(--sa-left)) max(0px, var(--sa-right));
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.tabbar__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: var(--tabbar-h);
    min-height: var(--tap);
    color: var(--text-3);
    text-decoration: none;
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .1px;
}
.tabbar__item i { font-size: 1.3rem; line-height: 1; }
.tabbar__item.is-active { color: var(--brand); }
.tabbar__item:active { color: var(--brand-600); }

/* Nút + nổi ở giữa tab bar */
.tabbar__fab {
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    width: 54px;
    height: 54px;
    margin-inline: auto;
    margin-bottom: 14px;
    border-radius: var(--r-pill);
    background: var(--brand);
    color: var(--brand-contrast);
    box-shadow: 0 6px 18px var(--brand-shadow);
    font-size: 1.6rem;
    text-decoration: none;
}
.tabbar__fab:active { transform: scale(.94); color: var(--brand-contrast); }
.tabbar__fab i { line-height: 1; }

/* ======================= 6. THẺ / CARD ======================= */
.card,
.filter-card, .expense-list-card, .transfer-list-card, .chart-card,
.cat-card, .s-card, .bank-card, .plan-card, .profile-card, .preview-box,
.saving-card-mobile, .card-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-1);
}

.card { overflow: hidden; }
.card-body { padding: clamp(16px, 4.5vw, 22px); }

.card-header {
    padding: 16px clamp(16px, 4.5vw, 22px);
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    font-weight: 700;
    color: var(--text);
}

/* Card header màu (trang Thêm chi tiêu / Thu nhập / Chuyển khoản) */
.card-header.bg-danger, .card-header.bg-success,
.card-header.bg-primary, .card-header.bg-info {
    border-bottom: 0;
    color: #fff;
}

.filter-card, .chart-card, .cat-card, .preview-box { padding: clamp(14px, 4vw, 20px); }

.section-header, .page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 22px 0 12px;
    font-size: .95rem;
    font-weight: 700;
    color: var(--text);
}
.section-header a, .page-header a { font-size: .85rem; font-weight: 600; }

/* ================== 7. THẺ TỔNG (số dư / tổng chi) ================== */
.summary-card, .balance-hero {
    position: relative;
    overflow: hidden;
    border: 0;
    border-radius: var(--r-lg);
    padding: var(--hero-pad) calc(var(--hero-pad) + 2px);
    color: #fff;
    background: var(--brand-grad);
    box-shadow: var(--sh-3);
}
.summary-card--out { background: linear-gradient(135deg, #DC2626 0%, #8B1116 100%); }
.summary-card--in  { background: linear-gradient(135deg, #15803D 0%, #0A4A24 100%); }

.summary-card .s-label,
.summary-card [class*="label"] {
    color: rgba(255,255,255,.92);          /* trước bị mờ quá trên nền tím đậm */
    opacity: 1;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .7px;
}

.summary-card .s-value, .balance-hero .amount {
    font-size: clamp(1.5rem, 7.5vw, 2rem);
    font-weight: 800;
    line-height: 1.15;
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.summary-strip, .summary-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
    gap: 10px;
}
.s-card > * { min-width: 0; }

/* Ô thống kê nhỏ */
.s-card { padding: 14px; text-align: center; }
.s-label { font-size: .74rem; color: var(--text-2); font-weight: 600; }
.s-amount, .amount-money, .amount-val, .t-price, .expense-amount, .transfer-amount, .plan-amount {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.s-amount {
    display: block;
    margin-top: 4px;
    font-size: clamp(.78rem, 3.1vw, 1.05rem);
    white-space: nowrap;        /* không tách "25.677.500" và "₫" ra 2 dòng */
}
.s-period { font-size: .7rem; color: var(--text-3); margin-top: 2px; }

/* Tiền vào / ra — xanh đỏ CHỈ ở đây */
.money-in, .net-positive, .balance-positive { color: var(--money-in) !important; }
.money-out, .net-negative, .balance-negative { color: var(--money-out) !important; }

/* Thanh tiến độ chi tiêu tháng */
.progress-line {
    height: 8px;
    border-radius: var(--r-pill);
    background: rgba(255,255,255,.25);
    overflow: hidden;
    margin-top: 12px;
}
.progress-line__fill {
    height: 100%;
    border-radius: var(--r-pill);
    background: #fff;
    transition: width .4s ease;
}

/* ================== 8. DANH SÁCH GIAO DỊCH ================== */
.expense-list-card, .transfer-list-card, .list-group-ios { overflow: hidden; }

.date-group-header, .date-divider {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px clamp(14px, 4vw, 18px);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: .74rem;
    font-weight: 700;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.expense-row, .income-row, .transfer-row, .t-item, .list-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px clamp(14px, 4vw, 18px);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.expense-row:last-child, .income-row:last-child,
.transfer-row:last-child, .t-item:last-child, .list-row:last-child { border-bottom: 0; }

/* Vòng icon đầu dòng */
.expense-icon, .icon-circle, .t-icon-circle, .transfer-icon, .icon-box {
    flex: 0 0 auto;
    width: var(--icon-sz);
    height: var(--icon-sz);
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    background: var(--money-out-bg);
    color: var(--money-out);
}
.icon-circle, .income-row .icon-circle { background: var(--money-in-bg); color: var(--money-in); }
.transfer-icon, .t-icon-circle { background: var(--brand-100); color: var(--brand); }

/* Phần chữ giữa — phải co được, nếu không sẽ đẩy tràn ngang */
.expense-desc, .t-info, .row-main { flex: 1 1 auto; min-width: 0; }
.expense-desc .desc-text, .t-title, .row-title {
    font-size: .95rem;
    font-weight: 600;
    color: var(--text);
    /* Mô tả dài: cho xuống tối đa 2 dòng rồi mới cắt,
       thay vì cắt ngay giữa chừng ở dòng đầu. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}
.expense-desc .desc-meta, .t-date, .row-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 3px;
    font-size: .76rem;
    color: var(--text-3);
}

.bank-badge, .t-bank-tag, .bank-tag, .period-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--brand-100);
    color: var(--brand);
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
}
.bank-tag.from { background: var(--money-out-bg); color: var(--money-out); }
.bank-tag.to   { background: var(--money-in-bg);  color: var(--money-in); }

.expense-amount, .amount-val, .t-price, .transfer-amount {
    flex: 0 0 auto;
    text-align: right;
    font-size: .95rem;
    white-space: nowrap;
}
.expense-amount, .t-price { color: var(--money-out); }
.income-row .amount-val { color: var(--money-in); }

/* ============ 9. NÚT HÀNH ĐỘNG TRONG DÒNG (Sửa / Xóa) ============ */
/* Thay 2 nút 28px sát nhau bằng 1 nút ⋯ mở bảng chọn → hết bấm nhầm Xóa */
.row-menu { flex: 0 0 auto; position: relative; }

.btn-icon,
.btn-action-sm, .action-btn, .btn-edit-sm, .btn-del-sm, .btn-t-action, .btn-action {
    width: var(--tap);
    height: var(--tap);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text-2);
    text-decoration: none;
    font-size: .95rem;
    flex: 0 0 auto;
}
.btn-icon:active,
.btn-action-sm:active, .action-btn:active, .btn-edit-sm:active, .btn-t-action:active {
    background: var(--brand-100);
    border-color: var(--brand);
    color: var(--brand);
}
.btn-icon--danger, .btn-action-sm.del:active, .action-btn.del:active, .btn-del-sm:active {
    background: var(--money-out-bg);
    border-color: var(--money-out);
    color: var(--money-out);
}

/* Nút chỉ có chữ trong dòng (Sửa / Xóa ở dashboard) */
.btn-t-action {
    width: auto;
    min-width: var(--tap);
    min-height: var(--tap);
    padding-inline: 12px;
    font-size: .82rem;
    font-weight: 600;
}

.t-actions, .plan-actions, .actions-section, .action-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ======================= 10. BẢNG CHỌN TRƯỢT LÊN ======================= */
.sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1055;
    background: rgba(0,0,0,.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}
.sheet-backdrop.is-open { opacity: 1; pointer-events: auto; }

.sheet {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 1060;
    transform: translateY(100%);
    transition: transform .26s cubic-bezier(.32,.72,0,1);
    background: var(--surface);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    padding: 10px 14px calc(14px + var(--sa-bottom));
    padding-inline: max(14px, var(--sa-left)) max(14px, var(--sa-right));
    box-shadow: var(--sh-3);
    max-width: var(--page-max);
    margin-inline: auto;
}
.sheet.is-open { transform: translateY(0); }

.sheet__grip {
    width: 40px; height: 4px;
    margin: 4px auto 12px;
    border-radius: var(--r-pill);
    background: var(--border-strong);
}
.sheet__title {
    font-size: .8rem;
    font-weight: 700;
    color: var(--text-3);
    text-align: center;
    margin-bottom: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sheet__item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 52px;
    padding: 12px 14px;
    border: 0;
    border-radius: var(--r);
    background: var(--surface-2);
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
    text-align: left;
    text-decoration: none;
    margin-bottom: 8px;
}
.sheet__item i { font-size: 1.15rem; color: var(--text-2); }
.sheet__item:active { background: var(--brand-100); }
.sheet__item--danger { color: var(--money-out); }
.sheet__item--danger i { color: var(--money-out); }
.sheet__item--danger:active { background: var(--money-out-bg); }
.sheet__item--cancel { justify-content: center; color: var(--text-2); background: transparent; border: 1px solid var(--border); }

/* ======================= 11. ĐIỀU HƯỚNG THÁNG ======================= */
.month-nav {
    display: flex;
    align-items: stretch;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    overflow: hidden;
    box-shadow: var(--sh-1);
}
.month-nav a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--tap);
    min-height: var(--tap);
    color: var(--brand);
    font-size: 1.1rem;
    text-decoration: none;
}
.month-nav a:active { background: var(--brand-100); }
.month-nav .month-label {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 6px;
    border-inline: 1px solid var(--border);
    font-weight: 700;
    font-size: .98rem;
    color: var(--text);
    white-space: nowrap;
}

/* ======================= 12. TAB NGANG ======================= */
.bank-tabs, .custom-tabs, .tab-bar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: 4px max(var(--gutter), var(--sa-left)) 8px;
    margin-inline: calc(-1 * var(--gutter));
    scroll-snap-type: x proximity;
}
.bank-tabs::-webkit-scrollbar, .custom-tabs::-webkit-scrollbar, .tab-bar::-webkit-scrollbar { display: none; }

.bank-tabs .tab-item, .custom-tabs .tab-btn, .tab-bar .tab-btn {
    flex: 0 0 auto;
    scroll-snap-align: start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    background: var(--surface);
    color: var(--text-2);
    font-size: .86rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}
.bank-tabs .tab-item.active, .custom-tabs .tab-btn.active, .tab-bar .tab-btn.active {
    background: var(--brand);
    border-color: var(--brand);
    color: var(--brand-contrast);
}

/* ======================= 13. FORM ======================= */
.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: .9rem;
    font-weight: 600;
    color: var(--text-2);
}

.form-control, .form-select, textarea.form-control {
    width: 100%;
    min-height: var(--tap);
    padding: 11px 14px;
    font-size: 16px;            /* >=16px: iPhone không tự phóng khi focus */
    line-height: 1.4;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    -webkit-appearance: none;      /* iOS bỏ qua bo góc / padding nếu thiếu dòng này */
    appearance: none;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-ring);
    outline: 0;
}
.form-control::placeholder { color: var(--text-3); }
.form-control:disabled, .form-control[readonly] { background: var(--surface-2); color: var(--text-3); }

.form-select {
    padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%238E93A0' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 14px;
}

/* Ô nhập số tiền — to, rõ, dễ đọc khi vừa gõ */
.input-money {
    font-size: clamp(1.25rem, 6vw, 1.5rem) !important;
    font-weight: 800;
    letter-spacing: .3px;
    font-variant-numeric: tabular-nums;
}
.input-money--out { color: var(--money-out); }
.input-money--in  { color: var(--money-in); }

/* Bỏ mũi tên tăng/giảm của input number (nếu còn sót) */
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.form-text, .footnote { font-size: .8rem; color: var(--text-3); margin-top: 5px; }

/* Lưới form: 1 cột trên điện thoại, 2 cột khi đủ rộng */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}
@media (min-width: 560px) {
    .form-grid--2 { grid-template-columns: 1fr 1fr; }
}

/* Chọn mức ưu tiên / nhóm nút chọn */
.priority-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.priority-option { position: absolute; opacity: 0; pointer-events: none; }
.priority-label {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: var(--tap);
    padding: 10px 6px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text-2);
    font-size: .88rem;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
}
.priority-option:checked + .priority-label {
    background: var(--brand);
    border-color: var(--brand);
    color: var(--brand-contrast);
}

/* ======================= 14. NÚT ======================= */
.btn {
    min-height: var(--tap);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    border-radius: var(--r-sm);
    font-size: 1rem;
    font-weight: 600;
    border: 1px solid transparent;
    text-decoration: none;
    cursor: pointer;
}
.btn-lg { min-height: 52px; padding: 14px 20px; font-size: 1.05rem; border-radius: var(--r); }
.btn-sm { min-height: 38px; padding: 8px 14px; font-size: .88rem; }
.btn:active { transform: translateY(1px); }

.btn-primary   { background: var(--brand); border-color: var(--brand); color: var(--brand-contrast); }
.btn-primary:hover, .btn-primary:focus { background: var(--brand-600); border-color: var(--brand-600); color: var(--brand-contrast); }
.btn-secondary { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover { background: var(--border); color: var(--text); }
.btn-outline-secondary { background: transparent; border-color: var(--border-strong); color: var(--text-2); }
.btn-outline-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-light { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-danger  { background: var(--money-out); border-color: var(--money-out); color: #fff; }
.btn-success { background: var(--money-in);  border-color: var(--money-in);  color: #fff; }
.btn-outline-danger { background: transparent; border-color: var(--money-out); color: var(--money-out); }
.btn-outline-light { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-outline-primary { background: transparent; border-color: var(--brand); color: var(--brand); }
.btn-outline-primary:hover { background: var(--brand); color: var(--brand-contrast); }
.btn-warning { background: var(--warn); border-color: var(--warn); color: #fff; }

.btn-block, .d-grid > .btn { width: 100%; }

/* Nút chính nổi bật ở dashboard */
.main-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 56px;
    border-radius: var(--r);
    background: var(--brand);
    color: var(--brand-contrast);
    font-size: 1.05rem;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 6px 18px var(--brand-shadow);
}
.main-add-btn:active { transform: translateY(1px); color: var(--brand-contrast); }

/* Lưới nút tắt ở dashboard — tự giãn theo bề rộng màn hình */
.quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
    gap: 10px;
}
.btn-action {
    width: auto;
    height: auto;
    flex-direction: column;
    gap: 7px;
    padding: 14px 6px;
    min-height: 78px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    color: var(--text-2);
    font-size: .76rem;
    font-weight: 600;
    text-align: center;
    box-shadow: var(--sh-1);
}
.btn-action i { font-size: 1.4rem; color: var(--brand); }
.btn-action:active { background: var(--brand-100); color: var(--brand); }

/* Nút nổi góc phải (các trang danh sách) — nâng lên trên tab bar */
.fab-add, .btn-add-float, .btn-floating {
    position: fixed;
    right: max(18px, var(--sa-right));
    bottom: calc(var(--tabbar-h) + var(--sa-bottom) + 18px);
    z-index: 1025;
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-pill);
    background: var(--brand);
    color: var(--brand-contrast);
    font-size: 1.5rem;
    text-decoration: none;
    border: 0;
    box-shadow: 0 6px 18px var(--brand-shadow);
}
.fab-add:active, .btn-add-float:active { transform: scale(.94); color: var(--brand-contrast); }

/* ======================= 15. THANH TỔNG DƯỚI ======================= */
.bottom-bar {
    position: fixed;
    inset: auto 0 calc(var(--tabbar-h) + var(--sa-bottom)) 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    max-width: var(--page-max);
    margin-inline: auto;
    padding: 10px max(var(--gutter), var(--sa-left)) 10px max(var(--gutter), var(--sa-right));
    background: var(--surface);
    border-top: 1px solid var(--border);
}
.has-bottom-bar { padding-bottom: calc(var(--tabbar-h) + var(--sa-bottom) + 86px); }

/* ======================= 16. BẢNG (desktop) ======================= */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; margin: 0; border-collapse: collapse; color: var(--text); }
.table th, .table td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: left; }
.table thead th {
    background: var(--surface-2);
    font-size: .78rem;
    font-weight: 700;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: .4px;
    white-space: nowrap;
}
.table tfoot td { background: var(--surface-2); font-weight: 700; }
.table .text-end { text-align: right; }

/* Ẩn/hiện theo khổ màn hình */
.desktop-only { display: none; }
@media (min-width: 768px) {
    .desktop-only { display: block; }
    .mobile-only  { display: none !important; }
}

/* ======================= 17. BANNER / THÔNG BÁO ======================= */
.alert {
    padding: 13px 16px;
    border: 1px solid transparent;
    border-radius: var(--r);
    font-size: .92rem;
    margin-bottom: 14px;
}
.alert-success { background: var(--money-in-bg);  border-color: var(--money-in-bd);  color: var(--money-in); }
.alert-danger  { background: var(--money-out-bg); border-color: var(--money-out-bd); color: var(--money-out); }
.alert-warning { background: var(--warn-bg);      border-color: var(--warn-bd);     color: var(--warn); }
.alert-info    { background: var(--brand-100);    border-color: var(--brand-bd);    color: var(--brand); }
.alert-link { color: inherit; font-weight: 700; text-decoration: underline; }

.smart-banner, .info-banner, .reminder-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 15px;
    border-radius: var(--r);
    margin-bottom: 10px;
    text-decoration: none;
    border: 1px solid transparent;
}
.smart-banner .sb-icon, .reminder-item .r-icon { flex: 0 0 auto; font-size: 1.3rem; }
.smart-banner .sb-text, .reminder-item > div { flex: 1 1 auto; min-width: 0; font-size: .88rem; line-height: 1.35; }
.smart-banner .sb-text strong { display: block; font-size: .92rem; }
.smart-banner .sb-text span { font-size: .8rem; opacity: .85; }

.banner-urgent, .reminder-item.today { background: var(--money-out-bg); border-color: var(--money-out-bd); color: var(--money-out); }
.banner-warning, .reminder-item.soon { background: var(--warn-bg); border-color: var(--warn-bd); color: var(--warn); }
.banner-info { background: var(--brand-100); border-color: var(--brand-bd); color: var(--brand); }
.banner-ok { background: var(--money-in-bg); border-color: var(--money-in-bd); color: var(--money-in); }

.empty-state {
    padding: 44px 18px;
    text-align: center;
    color: var(--text-3);
    font-size: .92rem;
}
.empty-state i { display: block; font-size: 2.4rem; margin-bottom: 10px; opacity: .45; }

.badge { font-weight: 600; border-radius: 6px; }

/* ======================= 18. TRANG DỰ ĐỊNH ======================= */
.plan-card { padding: 14px; margin-bottom: 10px; }
.plan-card.overdue { border-left: 3px solid var(--money-out); }
.plan-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.plan-name { flex: 1 1 auto; min-width: 0; font-size: 1rem; font-weight: 700; color: var(--text); overflow-wrap: anywhere; }
.plan-amount { font-size: 1.05rem; color: var(--money-out); margin-top: 6px; }
.plan-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 8px; font-size: .78rem; color: var(--text-3); }
.plan-actions { margin-top: 12px; }
.plan-actions .btn-complete { flex: 1 1 auto; }

.deadline-chip {
    flex: 0 0 auto;
    width: 58px;
    padding: 6px 4px;
    border-radius: var(--r-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    text-align: center;
    line-height: 1.1;
}
.deadline-chip .dc-month { font-size: .62rem; font-weight: 700; color: var(--text-3); text-transform: uppercase; }
.deadline-chip .dc-day   { font-size: 1.25rem; font-weight: 800; color: var(--text); }
.deadline-chip .dc-year  { font-size: .62rem; color: var(--text-3); }
.deadline-chip.overdue { background: var(--money-out-bg); border-color: var(--money-out-bd); }
.deadline-chip.overdue .dc-day, .deadline-chip.overdue .dc-month { color: var(--money-out); }
.deadline-chip.today { background: var(--warn-bg); border-color: var(--warn-bd); }
.deadline-chip.today .dc-day, .deadline-chip.today .dc-month { color: var(--warn); }
.deadline-chip.soon .dc-day { color: var(--warn); }

/* ======================= 19. THỐNG KÊ ======================= */
.cat-row { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; }
.cat-name { flex: 0 0 31%; font-size: .85rem; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-bar-wrap { flex: 1 1 auto; height: 9px; background: var(--surface-2); border-radius: var(--r-pill); overflow: hidden; }
.cat-bar { height: 100%; border-radius: var(--r-pill); background: linear-gradient(90deg, var(--brand), var(--brand-600)); }
.cat-amount { flex: 0 0 auto; font-size: .82rem; font-weight: 700; color: var(--money-out); font-variant-numeric: tabular-nums; }

.chart-card { margin-top: 14px; }
.chart-card canvas { width: 100% !important; height: auto !important; }

.transfer-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 15px;
    border-radius: var(--r);
    background: var(--brand-100);
    border: 1px solid var(--brand-bd);
    color: var(--brand);
    text-decoration: none;
    margin-top: 14px;
}
.transfer-card .t-amount { font-size: 1.1rem; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ======================= 20. VÍ / NGÂN HÀNG ======================= */
.card-grid, .mobile-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}
.bank-card { padding: 16px; }
.bank-card .fs-4, .bank-card .fs-5 { overflow-wrap: anywhere; }
.info-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; font-size: .85rem; }
.info-label { color: var(--text-3); }

/* ======================= 21. HỒ SƠ ======================= */
.profile-header {
    padding: clamp(22px, 7vw, 32px) var(--gutter);
    text-align: center;
    color: #fff;
    background: var(--brand-grad);
    border-radius: var(--r-lg);
}
.avatar, .avatar-wrapper img {
    width: 84px;
    height: 84px;
    border-radius: var(--r-pill);
    object-fit: cover;
    border: 3px solid rgba(255,255,255,.5);
}
.user-name { font-weight: 700; }
.welcome-text { color: var(--text-2); font-size: .85rem; }

/* ======================= 22. XEM TRƯỚC SỐ DƯ ======================= */
/* Các khối này chỉ hiện sau khi JS tính xong (mặc định phải ẩn,
   nếu không sẽ thấy "Số dư hiện tại: →" trống và cảnh báo âm ngay khi mở trang) */
#balance-preview { display: none; }
#balance-preview, .preview-box {
    margin-top: 8px;
    font-size: .86rem;
    color: var(--text-2);
}
#balance-preview .bal-val { font-weight: 700; color: var(--text); }
#balance-preview .bal-after { font-weight: 700; }
#balance-preview .bal-after.negative { color: var(--money-out); }
#balance-preview .bal-after.positive { color: var(--money-in); }
#warn-low, #warn-same {
    display: none;
    margin-top: 8px;
    padding: 9px 12px;
    border-radius: var(--r-sm);
    background: var(--money-out-bg);
    color: var(--money-out);
    font-size: .84rem;
    font-weight: 600;
}

.transfer-flow {
    display: none;              /* JS bật lên khi đã chọn đủ 2 tài khoản */
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 12px;
    padding: 14px;
    border-radius: var(--r);
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: .82rem;
}
.transfer-flow > div { min-width: 0; overflow-wrap: anywhere; }
.swap-btn {
    width: var(--tap);
    height: var(--tap);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-pill);
    background: var(--surface);
    color: var(--brand);
    font-size: 1.1rem;
    cursor: pointer;
}

/* ======================= 23. MÀN HÌNH LỚN ======================= */
@media (min-width: 768px) {
    :root { --tabbar-h: 0px; }       /* desktop: bỏ tab bar dưới, dùng menu trên */
    .tabbar { display: none; }
    .app-main { padding-bottom: 40px; }
    .has-bottom-bar { padding-bottom: 110px; }
    .fab-add, .btn-add-float, .btn-floating { bottom: 28px; right: 28px; }
    .bottom-bar { bottom: 0; }
    .topbar__title { text-align: left; padding-left: 6px; }
}

@media (min-width: 992px) {
    .container-wide { --page-max: 1140px; }
}

/* Màn hình rất hẹp (iPhone SE 320–375px) */
@media (max-width: 360px) {
    .btn-action { font-size: .7rem; padding: 11px 4px; }
    .btn-action i { font-size: 1.2rem; }
    .quick-grid { grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 8px; }
    .deadline-chip { width: 52px; }
    .cat-name { flex-basis: 28%; }
}

/* Xoay ngang điện thoại */
@media (max-height: 460px) and (orientation: landscape) {
    .tabbar { position: static; }
    .app-main { padding-bottom: 24px; }
}

/* ======================= 24. IN & GIẢM CHUYỂN ĐỘNG ======================= */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
    .topbar, .tabbar, .fab-add, .btn-add-float, .bottom-bar, .sheet, .sheet-backdrop { display: none !important; }
    .app-main { padding: 0; }
    body { background: #fff; }
}

/* ======= 25. VÙNG BẤM TRÊN THIẾT BỊ CẢM ỨNG =======
   Màn hình cảm ứng: mọi nút phải đạt tối thiểu 44px theo chuẩn Apple/Google.
   Trên máy có chuột thì giữ nút gọn như cũ. */
.btn-sm { min-height: 40px; }
.bank-tabs .tab-item, .custom-tabs .tab-btn, .tab-bar .tab-btn { min-height: 42px; }

@media (pointer: coarse) {
    .btn, .btn-sm, .page-link,
    .bank-tabs .tab-item, .custom-tabs .tab-btn, .tab-bar .tab-btn {
        min-height: var(--tap);
    }
    /* Nút chỉ có icon trong bảng/thẻ: vuông đủ 44px */
    .table .btn, .saving-card-mobile .btn, .bank-card .btn, .actions-section .btn {
        min-width: var(--tap);
    }
    /* Link chữ trong tiêu đề mục ("Tất cả", "Thêm ngay") cũng phải đủ cao */
    .section-header a, .page-header a, .empty-state a {
        display: inline-flex;
        align-items: center;
        min-height: var(--tap);
        padding-inline: 6px;
    }
}

/* Cụm nút trong bảng tiết kiệm: xếp hàng, cách nhau rõ, không dính nhau */
.table .actions-section, .table td > .d-flex { gap: 8px; }
.table td .btn + .btn { margin-left: 6px; }

/* Chuyển khoản nội bộ không phải khoản chi thật nên không tô đỏ như chi tiêu,
   tránh hiểu nhầm khi số này không được cộng vào tổng */
.expense-row.is-transfer .expense-amount,
.income-row.is-transfer .amount-val,
.t-item.is-transfer .t-price { color: var(--text-3); }

/* ======= 26. SỬA NỐT VÀI CHỖ DÙNG CHUNG =======
   .bg-primary của Bootstrap là xanh dương; đổi sang màu thương hiệu
   để các form (Chuyển khoản, Thêm ví, Đổi mật khẩu...) đồng bộ. */
.bg-primary { background-color: var(--brand) !important; }
.text-primary { color: var(--brand) !important; }

/* Trang Tiết kiệm có 2 cách hiển thị: bảng cho máy lớn, thẻ cho điện thoại.
   Trước đây CSS này nằm trong trang nên khi gom file bị mất → hiện CẢ HAI,
   dữ liệu bị lặp 2 lần trên điện thoại. */
.mobile-cards { display: block; }
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 767.98px) {
    .table-responsive { display: none; }
}
@media (min-width: 768px) {
    .mobile-cards { display: none; }
}

/* Thẻ tiết kiệm trên điện thoại */
.saving-card-mobile { padding: 16px; margin-bottom: 12px; }
/* 4 thông số của khoản tiết kiệm: luôn 2 cột -> 2 hàng cân nhau.
   Trước dùng auto-fit nên ra 3+1, ô lẻ bị kéo rộng và nhãn gãy chữ. */
.saving-card-mobile .card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0 14px;
    margin-top: 10px;
}
@media (min-width: 560px) {
    .saving-card-mobile .card-grid { grid-template-columns: repeat(4, 1fr); }
}
.card-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
    font-size: .84rem;
}
.card-item strong {
    flex: 0 0 auto;
    color: var(--text-3);
    font-weight: 600;
    white-space: nowrap;      /* "Ngày tạo" không bị tách làm 2 dòng */
}
.card-item span {
    min-width: 0;
    text-align: right;
    overflow-wrap: anywhere;
    font-variant-numeric: tabular-nums;
}

/* ======= 27. TRANG CÔNG KHAI (đăng nhập / đăng ký / trang giới thiệu) =======
   CSS cũ của 3 trang này nằm inline trong từng trang, gom về đây để
   dùng chung bộ màu và tự theo chế độ sáng/tối. */
.login-container, .hero-section {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: calc(100vh - 40px);
    min-height: calc(100dvh - var(--sa-top) - var(--sa-bottom) - 40px);
    padding-block: 28px;
}

.login-card { width: 100%; max-width: 420px; margin-inline: auto; }

.logo-icon {
    display: block;
    font-size: clamp(2.6rem, 11vw, 3.4rem);
    color: var(--brand);
    margin-bottom: 10px;
}

.btn-login, .btn-register, .btn-hero { width: 100%; }
.btn-login { margin-top: 6px; }

/* 2 nút ở trang giới thiệu: 1 nút chính, 1 nút viền */
.hero-section .btn-login {
    background: var(--brand);
    border-color: var(--brand);
    color: var(--brand-contrast);
}
.hero-section .btn-register {
    background: transparent;
    border: 1.5px solid var(--brand);
    color: var(--brand);
}
.link-register { font-weight: 700; }

.lockout-bar {
    padding: 11px 14px;
    margin-bottom: 14px;
    border-radius: var(--r-sm);
    background: var(--warn-bg);
    border: 1px solid var(--warn-bd);
    color: var(--warn);
    font-size: .88rem;
    font-weight: 600;
}

/* Trang giới thiệu */
.hero-section { text-align: center; }
.hero-section h1 {
    font-size: clamp(1.7rem, 8vw, 2.4rem);
    font-weight: 800;
    color: var(--text);
    margin-bottom: 8px;
}
.hero-section > p, .hero-section .lead {
    color: var(--text-2);
    font-size: clamp(.95rem, 4vw, 1.05rem);
    max-width: 44ch;
    margin: 0 auto 22px;
}
.hero-section .d-grid, .hero-section .d-flex { max-width: 340px; margin-inline: auto; }

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    margin-top: 34px;
    text-align: center;
}
.features > div, .features .col { padding: 0; }
.feature-icon {
    display: block;
    font-size: 1.9rem;
    margin-bottom: 8px;
    color: var(--brand);
}
.features h5 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}
.features p { font-size: .87rem; color: var(--text-2); margin: 0; }

/* Nhóm nút dọc ở cuối các form (Lưu / Hủy) */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
}
.action-buttons > * { width: 100%; }
@media (min-width: 560px) {
    .action-buttons { flex-direction: row; }
    .action-buttons > * { flex: 1 1 0; }
}

/* Vài phần nhỏ còn sót từ CSS cũ */
.plan-reminders { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.reminder-item .r-text { flex: 1 1 auto; min-width: 0; }
.reminder-item .r-arrow { flex: 0 0 auto; opacity: .55; }
.t-list { display: block; }
.color-preview {
    display: inline-block;
    width: 30px; height: 30px;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    vertical-align: middle;
}
.balance-header { margin-bottom: 14px; }
.transfer-body { flex: 1 1 auto; min-width: 0; }
.transfer-route { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.transfer-meta { font-size: .76rem; color: var(--text-3); margin-top: 3px; }
.arrow-mini { color: var(--text-3); font-size: .8rem; }
.flow-side { min-width: 0; text-align: center; }
.bank-name { font-weight: 700; color: var(--text); overflow-wrap: anywhere; }
.header-title { font-size: 1.1rem; font-weight: 700; margin: 0; }
.done-badge { font-size: .72rem; font-weight: 700; color: var(--money-in); }

/* ======= 28. GỌN LẠI CHIỀU DỌC (bản 2) =======
   Phản hồi thực tế: trang chủ phải cuộn 60% màn hình mới tới giao dịch đầu tiên,
   và lưới nút tắt bị lẻ 1 ô rơi xuống hàng dưới. */

/* Lưới nút tắt: luôn chia đều 3 cột → 6 ô thành 2 hàng cân, không lẻ ô nào */
.quick-grid { grid-template-columns: repeat(3, 1fr); gap: 9px; }
@media (min-width: 620px) { .quick-grid { grid-template-columns: repeat(6, 1fr); } }

.btn-action {
    min-height: var(--tile-h);
    padding: 11px 5px;
    gap: 5px;
    font-size: .74rem;
}
.btn-action i { font-size: 1.25rem; }
.btn-action.is-primary {        /* ô Chi tiêu — việc làm nhiều nhất trong ngày */
    background: var(--brand);
    border-color: var(--brand);
    color: var(--brand-contrast);
}
.btn-action.is-primary i { color: var(--brand-contrast); }

/* Thẻ số dư gọn hơn */
.summary-card, .balance-hero { padding: var(--hero-pad) calc(var(--hero-pad) + 3px); }
.summary-card .s-value, .balance-hero .amount { font-size: clamp(1.45rem, 6.8vw, 1.85rem); }
.progress-line { height: 6px; margin-top: 10px; }

/* Tiêu đề mục sát hơn */
.section-header, .page-header { margin: 16px 0 9px; }

/* Dòng giao dịch: thấp hơn, chữ và số tiền không chen nhau */
.expense-row, .income-row, .transfer-row, .t-item, .list-row {
    padding: var(--row-pad-y) clamp(12px, 3.5vw, 16px);
    gap: 10px;
}
.expense-icon, .icon-circle, .t-icon-circle, .transfer-icon, .icon-box {
    width: var(--icon-sz); height: var(--icon-sz); border-radius: 10px; font-size: .92rem;
}
.expense-desc .desc-text, .t-title, .row-title { font-size: .92rem; }
.expense-amount, .amount-val, .t-price, .transfer-amount { font-size: .92rem; }

/* Nút ⋯ trong danh sách: bỏ viền cho nhẹ mắt (trước trông như ô nhập trống),
   vùng bấm vẫn giữ nguyên 44px */
.t-item .btn-icon, .expense-row .btn-icon, .income-row .btn-icon,
.transfer-row .btn-icon, .plan-card .btn-icon {
    border-color: transparent;
    background: transparent;
    color: var(--text-3);
    width: 34px;
    margin-right: -6px;
}
.t-item .btn-icon::after, .expense-row .btn-icon::after, .income-row .btn-icon::after,
.transfer-row .btn-icon::after, .plan-card .btn-icon::after {
    content: "";                /* vùng bấm ẩn, đủ 44x44 theo chuẩn */
    position: absolute;
    inset: 50% auto auto 50%;
    width: var(--tap); height: var(--tap);
    transform: translate(-50%, -50%);
}
.t-item .btn-icon, .expense-row .btn-icon, .income-row .btn-icon,
.transfer-row .btn-icon, .plan-card .btn-icon { position: relative; }
.t-item .btn-icon:active, .expense-row .btn-icon:active,
.income-row .btn-icon:active, .transfer-row .btn-icon:active {
    background: var(--brand-100); color: var(--brand);
}

/* Thanh tiến độ trên thẻ tím: tách khỏi con số cho dễ đọc */
.summary-card .progress-line { background: rgba(255,255,255,.22); margin-top: 12px; }

/* Trang có thanh tổng cố định ở dưới: nâng nút + lên trên thanh đó,
   nếu không nút sẽ đè lên dòng "Tổng thu" */
.has-bottom-bar .fab-add,
.has-bottom-bar .btn-add-float,
.has-bottom-bar .btn-floating {
    bottom: calc(var(--tabbar-h) + var(--sa-bottom) + 76px);
}
@media (min-width: 768px) {
    .has-bottom-bar .fab-add,
    .has-bottom-bar .btn-add-float,
    .has-bottom-bar .btn-floating { bottom: 86px; }
}

/* Dải chip chọn ví: cho thụt vào bằng lề trang, cuộn ngang vẫn mượt */
.bank-tabs, .custom-tabs { padding-left: 2px; padding-right: 2px; margin-inline: 0; }
.bank-tabs { margin-bottom: 4px; }

/* ======= 29. DỌN NỐT =======
   Cụm nút trong thẻ (Sửa / Rút): trước dùng w-50 + gap nên tổng > 100%
   và bị rớt xuống 2 hàng. Cho chia đều phần còn lại là vừa khít. */
.actions-section > .btn,
.actions-section > a.btn,
.actions-section > button.btn { flex: 1 1 0; width: auto; min-width: 0; }

/* Thẻ "Tổng tiền đang tiết kiệm": trước là chữ trôi nổi trên nền trang */
.balance-header {
    padding: var(--hero-pad) calc(var(--hero-pad) + 3px);
    border-radius: var(--r-lg);
    background: var(--brand-grad);
    color: #fff;
    box-shadow: var(--sh-3);
    text-align: center;
}
.balance-header .amount {
    font-size: clamp(1.45rem, 6.6vw, 1.9rem);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
}
.balance-header .small { color: rgba(255,255,255,.92); }

/* Hàng Đầu kỳ / Thu / Chi trong thẻ ví: 3 cột hẹp, số tiền dài bị tràn.
   Cho phép co chữ và xuống dòng thay vì cắt mất chữ số. */
.bank-card .row.text-center > .col { min-width: 0; padding-inline: 4px; }
.bank-card .row.text-center .fw-semibold {
    font-size: clamp(.72rem, 3vw, .84rem);
    overflow-wrap: anywhere;
    line-height: 1.25;
    font-variant-numeric: tabular-nums;
}
.bank-card .period-badge {
    display: block;
    margin: 2px auto 0;
    width: -webkit-fit-content;
    width: fit-content;
    font-size: .6rem;
    padding: 1px 5px;
}

/* Hiện nội dung ngay cả khi font icon chưa tải xong */
@font-face { font-family: "bootstrap-icons"; font-display: swap; src: local("bootstrap-icons"); }

/* ======= 30. NÚT ĐỔI GIAO DIỆN SÁNG / TỐI ======= */
.js-theme-toggle .theme-ico-light { display: none; }
[data-bs-theme="dark"] .js-theme-toggle .theme-ico-dark  { display: none; }
[data-bs-theme="dark"] .js-theme-toggle .theme-ico-light { display: inline-block; color: var(--brand); }

/* Bộ chọn 3 chế độ ở trang Hồ sơ */
.theme-picker {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 10px;
}
.theme-picker button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 68px;
    padding: 10px 6px;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text-2);
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
}
.theme-picker button i { font-size: 1.25rem; }
.theme-picker button[aria-pressed="true"] {
    border-color: var(--brand);
    background: var(--brand-100);
    color: var(--brand);
}

/* Thẻ tiết kiệm gọn hơn: tên + số tiền trên cùng một hàng */
.saving-card-mobile { padding: 14px; margin-bottom: 10px; }
.saving-card-mobile h6 { margin-bottom: 2px !important; font-size: .95rem; }
.saving-card-mobile .fs-5 { font-size: 1.15rem !important; }
.saving-card-mobile .actions-section { margin-top: 12px !important; }
.saving-card-mobile .btn { min-height: 42px; font-size: .9rem; }

/* ======= 31. KHOẢNG CÁCH GIỮA CÁC Ô =======
   Mọi khối nội dung phải có khe hở; không ô nào được dính sát ô kế bên.
   Chỉ áp khi trong HTML chưa tự đặt lề (mb-*, my-*), để không cộng dồn. */
.app-main .card:not([class*="mb-"]):not([class*="my-"]),
.app-main .filter-card:not([class*="mb-"]):not([class*="my-"]),
.app-main .summary-card:not([class*="mb-"]):not([class*="my-"]),
.app-main .balance-hero:not([class*="mb-"]):not([class*="my-"]),
.app-main .balance-header:not([class*="mb-"]):not([class*="my-"]),
.app-main .chart-card:not([class*="mb-"]):not([class*="my-"]),
.app-main .cat-card:not([class*="mb-"]):not([class*="my-"]),
.app-main .transfer-card:not([class*="mb-"]):not([class*="my-"]),
.app-main .summary-row:not([class*="mb-"]):not([class*="my-"]),
.app-main .month-nav:not([class*="mb-"]):not([class*="my-"]),
.app-main .bank-card:not([class*="mb-"]):not([class*="my-"]),
.app-main .expense-list-card:not([class*="mb-"]):not([class*="my-"]),
.app-main .transfer-list-card:not([class*="mb-"]):not([class*="my-"]) {
    margin-bottom: 12px;
}

/* Hai nút cạnh nhau trong bảng / trong ô: luôn có khe */
.table td .btn + .btn,
.table td a.btn + a.btn,
.table td a.btn + button.btn,
.table td button.btn + a.btn { margin-left: 8px; }
.table td .d-flex, .table td .actions-section { gap: 8px; }

/* Nhóm nút nằm ngang bất kỳ: ép có khe, tránh dính nhau khi đổi khổ màn */
.d-flex.gap-0 > .btn + .btn { margin-left: 8px; }

/* Ô chứa nút thao tác trong bảng: giữ các nút trên cùng một hàng.
   Trước đó ô quá hẹp nên nút thứ hai rớt xuống và chồng lên nút thứ nhất. */
.table td.td-actions { white-space: nowrap; width: 1%; }
.table td.td-actions .btn { vertical-align: middle; }

/* ======= 32. SAO KÊ TỪNG TÀI KHOẢN ======= */
.stmt-line {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 0;
    font-size: .9rem;
    color: var(--text-2);
    border-bottom: 1px solid var(--border);
}
.stmt-line:last-child { border-bottom: 0; }
.stmt-line strong { color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stmt-line--total { border-top: 2px solid var(--border-strong); margin-top: 4px; padding-top: 10px; }
.stmt-line--total span, .stmt-line--total strong { font-weight: 800; color: var(--text); font-size: .98rem; }

/* Số dư luỹ kế hiển thị dưới mỗi dòng giao dịch */
.stmt-bal {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-3);
    font-size: .7rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Thẻ tài khoản bấm được */
.bank-card.is-tappable { cursor: pointer; transition: box-shadow .15s ease, transform .15s ease; }
.bank-card.is-tappable:active { transform: scale(.995); box-shadow: var(--sh-2); }
.bank-name-link { color: inherit; text-decoration: none; }
.bank-name-link:hover { color: var(--brand); }

.bank-card__go {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    color: var(--brand);
    font-size: .85rem;
    font-weight: 600;
}

/* Thanh phân trang của sao kê */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pager__btn {
    display: inline-flex; align-items: center; gap: 6px;
    min-height: var(--tap); padding: 10px 14px;
    border: 1px solid var(--border-strong); border-radius: var(--r-sm);
    background: var(--surface); color: var(--brand);
    font-size: .88rem; font-weight: 600; text-decoration: none;
}
.pager__btn.is-off { opacity: .4; pointer-events: none; color: var(--text-3); }
.pager__info { font-size: .85rem; font-weight: 600; color: var(--text-2); white-space: nowrap; }
