/* ============================================================================
   💎 MINIAPP TÀI CHÍNH - ADAPTIVE OCEAN CYAN FINTECH DESIGN SYSTEM
   ============================================================================ */

/* ─── THEME TỐI ĐẶC TRƯNG (MẶC ĐỊNH HOẶC THEO HỆ THỐNG) ─── */
:root {
  --bg-base: #0B1120;
  --bg-surface: #0F172A;
  --bg-card: #1E293B;
  --bg-card2: #334155;
  --bg-glass: rgba(255, 255, 255, 0.04);
  --bg-glass-border: rgba(255, 255, 255, 0.08);

  /* Tone Xanh Cyan FinTech linh hoạt */
  --primary: #06B6D4;
  --primary-light: #67E8F9;
  --primary-dark: #0891B2;
  --primary-alpha: rgba(6, 182, 212, 0.15); /* Nền mờ đồng bộ cho Active và Hover */
  --grad-primary: linear-gradient(135deg, #06B6D4 0%, #3B82F6 100%);

  /* Phân loại tài chính - MÀU TƯƠI RỰC RỠ (Đồng bộ Sáng & Tối) */
  --income-color: #00D26A; /* Xanh lá tươi, trong trẻo */
  --income: #00D26A;
  --income-bg: rgba(0, 210, 106, 0.15);

  --expense-color: #FF4444; /* Đỏ tươi, sắc nét */
  --expense: #FF4444;
  --expense-bg: rgba(255, 68, 68, 0.15);

  --balance-color: #FFB800; /* Vàng rực sáng, không bị xỉn hay ngả cam */
  --balance: #FFB800;

  /* Hệ thống chữ */
  --text-1: #F8FAFC;   
  --text-2: #94A3B8;   
  --text-3: #475569;   
  
  --border: rgba(255, 255, 255, 0.06);
  --border-color: rgba(255, 255, 255, 0.08);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  
  --shadow-glow: 0 0 32px rgba(6, 182, 212, 0.2);
}

/* ─── TỰ ĐỘNG CHUYỂN ĐỔI THEME SÁNG THEO THIẾT BỊ ─── */
@media (prefers-color-scheme: light) {
  :root {
    /* Đổi nền app thành xám xanh cực nhạt, giúp thẻ trắng nổi bật lên */
    --bg-base: #F4F7FA;
    --bg-surface: #FFFFFF;
    /* Dùng Trắng Tinh cho Card để xóa bỏ cảm giác "xỉn/đục" */
    --bg-card: #FFFFFF;
    --bg-card2: #F8FAFC;
    --bg-glass: rgba(0, 0, 0, 0.02);
    --bg-glass-border: rgba(0, 0, 0, 0.04);

    --primary: #0891B2;
    --primary-light: #06B6D4;
    --primary-dark: #155E75;
    --primary-alpha: rgba(6, 182, 212, 0.12);
    
    /* Đổi Gradient thẻ chính sang Xanh Biển Sâu để tạo độ tương phản, giúp chữ Đỏ/Xanh nổi bật hoàn toàn */
    --grad-primary: linear-gradient(135deg, #0284C7 0%, #1E40AF 100%);

    /* Phân loại tài chính - MÀU TƯƠI RỰC RỠ (Đồng bộ 100% với Tối) */
    --income-color: #00D26A; 
    --income: #00D26A;
    --income-bg: rgba(0, 210, 106, 0.12);

    --expense-color: #FF4444; 
    --expense: #FF4444;
    --expense-bg: rgba(255, 68, 68, 0.1);

    --balance-color: #FFB800; 
    --balance: #FFB800;

    --text-1: #0F172A;
    --text-2: #475569;
    --text-3: #94A3B8;
    
    /* Viền mỏng, nhạt và mềm mại hơn */
    --border: rgba(0, 0, 0, 0.06);
    --border-color: rgba(0, 0, 0, 0.06);
    --shadow-glow: 0 8px 24px rgba(0, 114, 255, 0.2);
  }
}

/* ============================================================================
   LAYOUTS CORE & BASE SYSTEM
   ============================================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 15px; scroll-behavior: smooth; }
body { font-family: 'Plus Jakarta Sans', sans-serif; background: var(--bg-base); color: var(--text-1); padding: 0 0 100px 0; min-height: 100vh; overflow-x: hidden; transition: background-color 0.3s ease, color 0.3s ease; }
.content-wrapper { max-width: 600px; margin: 0 auto; animation: fadeIn 0.3s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.tab-content { display: none; padding: 0 16px; animation: tabFadeIn 0.3s ease; }
.tab-content.active { display: block; }
@keyframes tabFadeIn { from { opacity: 0; transform: scale(0.98); } to { opacity: 1; transform: scale(1); } }

.mt-4 { margin-top: 16px !important; }
.mb-3 { margin-bottom: 12px !important; }
.pb-4 { padding-bottom: 16px !important; }
.w-full { width: 100% !important; }
.flex-1 { flex: 1 !important; }
.text-left { text-align: left !important; }

.loading-spinner { text-align: center; margin: 16px 0; }
.loading-spinner i { font-size: 1.5rem; color: var(--primary-light); }

.section-header { display: flex; align-items: center; justify-content: center; margin-top: 20px; margin-bottom: 12px; }
.section-title { font-size: 1.15rem; font-weight: 800; color: var(--text-1); letter-spacing: -0.01em; text-transform: uppercase; text-align: center; }
h1 { font-size: 1.1rem; font-weight: 800; color: var(--primary-light); margin: 1.5rem 0 1rem; text-align: center; text-transform: uppercase; }

/* ============================================================================
   CARD & HERO DASHBOARD STYLE
   ============================================================================ */
.hero-card { background: var(--grad-primary); border-radius: var(--radius-xl); padding: 20px 20px 18px; margin-top: 16px; margin-bottom: 16px; box-shadow: var(--shadow-glow); position: relative; overflow: hidden; }
.hero-card::before { content: ''; position: absolute; width: 200px; height: 200px; border-radius: 50%; background: rgba(255,255,255,0.06); top: -60px; right: -40px; }
.hero-card::after { content: ''; position: absolute; width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,0.04); bottom: -30px; left: 20px; }

/* Các class mới cho Nút chuyển ngày */
.hero-date-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
    position: relative;
    z-index: 1;
}
.hero-date { font-size: 0.78rem; color: rgba(255,255,255,0.55); margin-bottom: 0; }
.date-nav-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
    font-size: 0.6rem;
}
.date-nav-btn:active { transform: scale(0.9); }

.hero-label, .hero-stat-label { display: flex; align-items: center; }
.hero-label i, .hero-stat-label i { margin-right: 4px; }
.hero-label { font-size: 0.72rem; font-weight: 600; color: rgba(255,255,255,0.65); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; position: relative; z-index: 1; }
.hero-balance { font-size: 2.2rem; font-weight: 900 !important; color: white; letter-spacing: -0.02em; line-height: 1.1; margin-bottom: 4px; position: relative; z-index: 1; display: flex; align-items: center; gap: 2px;}
.hero-balance span { font-size: 1.2rem; font-weight: 700; opacity: 0.8; line-height: 1; }

#heroExpenseCompare { 
  font-size: 0.75rem; 
  margin-bottom: 20px; 
  display: flex; 
  align-items: center; 
  gap: 4px; 
  position: relative; 
  z-index: 1; 
}
#heroExpenseCompare span { 
  background: transparent !important; 
  padding: 0 !important; 
  box-shadow: none !important; 
  text-shadow: none !important;
  letter-spacing: 0.02em;
  font-weight: 800 !important; 
}
#heroExpenseCompare span i { 
  margin-right: 4px; 
}

.hero-sub { display: flex; gap: 20px; margin-top: 18px; position: relative; z-index: 1; }
.hero-stat { flex: 1; }
.hero-stat-label { font-size: 0.7rem; color: rgba(255,255,255,0.6); font-weight: 600; margin-bottom: 3px; }
.hero-stat-val { font-size: 1.05rem; font-weight: 700; color: white; }
.divider-v { width: 1px; background: rgba(255,255,255,0.2); }

/* Thao tác nhanh Dashboard */
.quick-actions { display: flex; gap: 10px; margin-bottom: 8px; }
.qa-btn { flex: 1; background: transparent; border: none; padding: 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; transition: 0.2s; }
.qa-btn-relative { position: relative; }
.qa-icon { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.15rem; }
.qa-icon.filter { background: rgba(255, 184, 0, 0.12); color: var(--balance); }
.qa-icon.add { background: rgba(0, 210, 106, 0.12); color: var(--income); }
.qa-icon.search { background: var(--primary-alpha); color: var(--primary-light); }
.qa-label { font-size: 0.75rem; font-weight: 600; color: var(--text-1); }
.hidden-picker { position: absolute; top:0; left:0; width:100%; height:100%; opacity:0; cursor:pointer; }

/* ============================================================================
   TRANSACTION LISTS & CARDS
   ============================================================================ */
.tx-list { display: flex; flex-direction: column; gap: 10px; }
.tx-card { position: relative; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px 16px; display: flex; align-items: center; gap: 14px; transition: 0.2s; overflow: hidden; }
.tx-card:hover { background: var(--bg-card2); }
.tx-icon-wrap { width: 42px; height: 42px; border-radius: 13px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.tx-icon-wrap.income { background: var(--income-bg); color: var(--income); }
.tx-icon-wrap.expense { background: var(--expense-bg); color: var(--expense); }
.tx-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tx-title { font-size: 0.95rem; font-weight: 700; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px; }
.tx-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;}
.tx-date { font-size: 0.72rem; color: var(--text-2); font-weight: 600; }
.tx-badge { font-size: 0.65rem; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.tx-badge.income { background: var(--income-bg); color: var(--income); }
.tx-badge.expense { background: var(--expense-bg); color: var(--expense); }
.tx-amount { font-size: 1.1rem; font-weight: 900 !important; flex-shrink: 0; letter-spacing: -0.02em; display: flex; align-items: center; gap: 2px;}
.tx-amount.income { color: var(--income) !important; }
.tx-amount.expense { color: var(--expense) !important; }
.tx-actions { display: flex; gap: 6px; }
.tx-btn { background: var(--bg-glass); border: 1px solid var(--border); border-radius: 6px; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: 0.2s; }
.tx-btn.edit-btn { color: var(--primary-light); }
.tx-btn.delete-btn { color: var(--expense); }

/* ============================================================================
   REPORT COMPONENT & CHARTS SYSTEM
   ============================================================================ */
.period-pills { display: flex; gap: 10px; padding: 4px 0; overflow-x: auto; scrollbar-width: none; margin-bottom: 12px; }
.period-pills::-webkit-scrollbar { display: none; }
.period-pill { flex: 1; text-align: center; padding: 10px 12px; border-radius: 24px; font-size: 0.8rem; font-weight: 700; cursor: pointer; white-space: nowrap; border: none; background: var(--bg-card2); color: var(--text-2); transition: all 0.3s ease; }
.period-pill.active { background: var(--grad-primary); color: white; box-shadow: 0 4px 12px var(--primary-alpha); }

.time-nav-container { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; background: var(--bg-card); padding: 8px; border-radius: var(--radius-md); border: 1px solid var(--border); }
.nav-arrow-btn { background: transparent; border: none; color: var(--text-2); padding: 8px 12px; cursor: pointer; }
.time-nav-center { position: relative; flex: 1; text-align: center; }
#currentPeriodLabel { font-weight: 700; color: var(--text-1); font-size: 0.9rem; }

.filter-controls { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; background: var(--bg-card); padding: 8px; border-radius: var(--radius-md); border: 1px solid var(--border); }
.filter-separator { font-size: 0.8rem; font-weight: 600; color: var(--text-2); }
.btn-filter { width: 42px !important; flex: 0 0 42px !important; height: 42px !important; padding: 0 !important; display: flex; align-items: center; justify-content: center; border-radius: 50% !important; }

/* Grid Thống kê báo cáo (Thiết kế Clean UI - Căn trái) */
.stat-grid { 
    display: grid; 
    grid-template-columns: repeat(3, 1fr); 
    gap: 8px; 
    margin-bottom: 16px; 
}

.stat-card { 
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md); 
    padding: 14px 10px; 
    display: flex; 
    flex-direction: column; 
    align-items: flex-start; 
    gap: 10px; 
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.stat-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-header i { font-size: 0.85rem; }

.stat-tag { 
    font-size: 0.65rem; 
    font-weight: 700; 
    text-transform: uppercase; 
    letter-spacing: 0.02em;
}

.stat-header.card-income i, .stat-header.card-income .stat-tag { color: var(--income); }
.stat-header.card-expense i, .stat-header.card-expense .stat-tag { color: var(--expense); }
.stat-header.card-balance i, .stat-header.card-balance .stat-tag { color: var(--balance); }

.stat-num { 
    font-size: clamp(0.85rem, 4vw, 1.05rem); 
    font-weight: 800; 
    letter-spacing: -0.02em; 
    white-space: nowrap; 
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.1;
    width: 100%;
}
.stat-num.income { color: var(--income); }
.stat-num.expense { color: var(--expense); }
.stat-num.balance { color: var(--balance); }

.stat-compare { 
    font-size: 0.6rem; 
    text-align: left;
    line-height: 1.4; 
    width: 100%;
}

.stat-compare span { 
    background: transparent !important; 
    padding: 0 !important; 
}

/* Đồ thị & Vùng chứa Chart.js */
.chart-placeholder { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; margin-bottom: 16px; position: relative; display: flex; justify-content: center; align-items: center; min-height: 250px; }
.chart-title { font-size: 0.9rem; font-weight: 800; color: var(--primary-light); margin-bottom: 12px; letter-spacing: -0.01em; text-transform: uppercase; }

/* Tiến trình Chi tiêu theo danh mục */
.category-detail { padding-bottom: 20px; will-change: transform, opacity; }
.detail-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; margin-top: 20px; }
#categoryDetailTitle { margin: 0; text-align: left; font-size: 1.1rem; color: var(--text-1); }

.cat-progress-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px; margin-bottom: 10px; cursor: pointer; transition: 0.2s; }
.cat-progress-card:hover { background: var(--bg-card2); }
.cat-progress-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.cat-progress-info { display: flex; align-items: center; gap: 10px; }
.cat-progress-icon { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 0.95rem; }
.cat-progress-title { font-size: 0.88rem; font-weight: 600; color: var(--text-1); }
.cat-progress-amt { font-size: 0.95rem; font-weight: 800; }
.cat-progress-bar-bg { height: 5px; background: var(--bg-card2); border-radius: 3px; width: 100%; overflow: hidden; }
.cat-progress-bar-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }

/* ============================================================================
   MODALS SHEET UI SYSTEM & INPUT FIELDS
   ============================================================================ */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(3px); z-index: 1500; display: none; }
.overlay.show { display: flex !important; }
.modal-sheet { position: fixed; bottom: 0; left: 0; right: 0; background: var(--bg-surface); border-radius: 28px 28px 0 0; padding: 20px 20px 40px; border-top: 1px solid var(--border); box-shadow: none; z-index: 2000; transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease; max-height: 90vh; overflow-y: auto; width: 100%; max-width: 600px; margin: 0 auto; }
.modal-sheet.show { transform: translateY(0); box-shadow: 0 -8px 40px rgba(0,0,0,0.6); }
.modal-handle { width: 40px; height: 5px; background: var(--text-2); opacity: 0.4; border-radius: 3px; margin: 0 auto 20px; }
.modal-title { font-size: 1.15rem; font-weight: 800; color: var(--text-1); margin-bottom: 24px; letter-spacing: -0.02em; }

.field-group { margin-bottom: 16px; }
.field-label { font-size: 0.72rem; font-weight: 700; color: var(--text-2); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.05em; }
.field-input { width: 100% !important; max-width: 100% !important; background: var(--bg-card) !important; border: 1px solid var(--border) !important; border-radius: var(--radius-sm); padding: 12px 14px; color: var(--text-1) !important; font-size: 0.95rem; outline: none; font-family: inherit; transition: 0.2s; box-sizing: border-box !important; display: block !important; -webkit-appearance: none; appearance: none; }
.field-input:focus { border-color: var(--primary) !important; background: var(--bg-card2) !important; }
.date-input { width: 100%; display: block; box-sizing: border-box; -webkit-appearance: none; }

.type-row { display: flex; gap: 10px; }
.type-pill { flex: 1; padding: 14px; border-radius: var(--radius-sm); border: 1px solid var(--bg-card); background: var(--bg-card); color: var(--text-2); font-size: 0.95rem; font-weight: 600; cursor: pointer; text-align: center; transition: 0.2s; }
.type-pill.expense-active { background: var(--expense-bg); color: var(--expense); border-color: rgba(255, 68, 68, 0.3); }
.type-pill.income-active { background: var(--income-bg); color: var(--income); border-color: rgba(0, 210, 106, 0.3); }

/* ============================================================================
   BUTTONS UX INTERACTION DESIGN
   ============================================================================ */
.modal-actions { display: flex; gap: 12px; margin-top: 24px; align-items: center;}
.btn-cancel, .btn-save, .btn-full { flex: 1; width: 100%; padding: 14px; border-radius: var(--radius-md); font-weight: 800; cursor: pointer; transition: 0.2s; text-align: center; display: flex; align-items: center; justify-content: center; gap: 6px; }
.btn-full { margin-top: 8px; }
.btn-cancel { background: var(--bg-card); border: 1px solid var(--border); color: var(--text-2); }
.btn-save { background: var(--grad-primary); border: none; color: white; box-shadow: none; }
.btn-back { padding: 8px 14px; background: var(--bg-card); color: var(--text-1); border: 1px solid var(--border); border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 6px;}

.btn-soft { flex: 1; width: 100%; padding: 14px; background: var(--bg-card); border: 1px solid var(--border); color: var(--text-1); border-radius: var(--radius-md); font-weight: 800; cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 0; }
.btn-soft:hover { background: var(--bg-card2); border-color: var(--primary-light); }

.btn-danger-outline { padding: 14px; background: rgba(255, 68, 68, 0.1); color: var(--expense); border: none; border-radius: var(--radius-md); font-weight: 800; cursor: pointer; transition: 0.2s; text-align: center; display: flex; align-items: center; justify-content: center; gap: 6px;}
.btn-edit-kw { background: var(--balance) !important; color: white !important; }

.empty-text { text-align: center; font-size: 0.85rem; color: var(--text-3); font-style: italic; margin: 16px 0; width: 100%; }

/* ============================================================================
   NOTIFICATION, TOASTS & PAGINATION
   ============================================================================ */
.toast { position: fixed; top: 20px; left: 16px; right: 16px; background: var(--bg-card2); border: 1px solid var(--border-color); padding: 14px 18px; border-radius: var(--radius-md); box-shadow: 0 8px 30px rgba(0,0,0,0.5); z-index: 4000; transform: translateY(-50px); opacity: 0; transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1); font-weight: 600; text-align: left; font-size: 0.9rem; max-width: 568px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-left: 4px solid var(--income); }
.toast.error { border-left: 4px solid var(--expense); }
.toast.warning { border-left: 4px solid var(--balance); }

#confirmDeleteModal { align-items: center; justify-content: center; z-index: 3000; }
.confirm-dialog { position: relative; border-radius: 20px; padding: 24px; transform: none; top: auto; bottom: auto; margin: 20px; width: 90%; max-width: 400px; }
.confirm-title { font-size: 1.1rem; font-weight: 800; color: var(--text-1); margin-bottom: 12px; text-align: center; }
.confirm-desc { font-size: 0.85rem; color: var(--text-2); margin-bottom: 24px; text-align: center; line-height: 1.5; }
.confirm-actions { margin-top: 0; }
.btn-danger { background: var(--expense); color: white; border: none; padding: 14px; border-radius: var(--radius-md); font-weight: 800; flex: 1; cursor: pointer; }

.pagination-container { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 16px; }
.pagination-btn { padding: 10px 18px; background: var(--bg-card); border: 1px solid var(--border); color: var(--text-1); border-radius: var(--radius-sm); font-weight: 700; cursor: pointer;}
.pagination-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination-info { font-size: 0.8rem; font-weight: 600; color: var(--text-2); }

/* ============================================================================
   TAB 5: APP INFO CARD & KHỐI QR CODE TỐI ƯU
   ============================================================================ */
.info-card { margin-bottom: 16px; background: var(--bg-card); border: 1px solid var(--border); padding: 20px; border-radius: var(--radius-lg); }
.info-card .chart-title { margin-bottom: 8px; }
.info-text { font-size: 0.85rem; color: var(--text-2); line-height: 1.5; margin-bottom: 12px; }
.info-list { font-size: 0.85rem; display: flex; flex-direction: column; gap: 6px; }
.info-list i { color: var(--primary-light); width: 20px; }
.info-list strong { color: var(--text-1); }

/* Khối QR Code cải tiến - To, cân đối và sắc nét */
.qr-container { text-align: center; padding: 20px 16px; margin-bottom: 20px; }
.qr-box { background: white; padding: 20px; display: inline-block; border-radius: var(--radius-xl); box-shadow: 0 10px 30px rgba(0,0,0,0.15); width: 100%; max-width: 280px; box-sizing: border-box; }
.qr-image { width: 100%; height: auto; max-width: 240px; border-radius: 12px; display: block; margin: 0 auto; aspect-ratio: 1/1; object-fit: contain; }

select.field-input { background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") !important; background-repeat: no-repeat !important; background-position: right 14px center !important; background-size: 16px !important; padding-right: 36px !important; cursor: pointer; }
.app-branding { text-align: center; font-size: 0.85rem; font-weight: 800; color: var(--text-2); padding-top: 8px; margin-bottom: -12px; letter-spacing: 0.02em; }

/* ============================================================================
   BOTTOM NAVIGATION BAR SYSTEM
   ============================================================================ */
.bottom-nav { 
  position: fixed; 
  bottom: 20px; 
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px); 
  max-width: 450px; 
  height: 64px; 
  background: var(--bg-surface) !important; 
  border-radius: 32px !important; 
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12) !important; 
  border: 1px solid var(--border) !important;
  display: flex; 
  justify-content: space-around; 
  align-items: center;
  padding: 0 12px; 
  z-index: 1000; 
}
.bottom-nav::before, .bottom-nav::after { display: none !important; }

.nav-btn { 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  justify-content: center; 
  gap: 2px; 
  background: transparent; 
  border: none; 
  cursor: pointer; 
  min-width: 60px;
  height: 54px;
  border-radius: 27px; 
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1); 
}

.nav-icon-wrap { 
  width: 32px; 
  height: 32px; 
  min-width: 32px;      
  min-height: 32px;     
  flex-shrink: 0;       
  border-radius: 50%;   
  display: flex; 
  align-items: center; 
  justify-content: center; 
  font-size: 1.1rem; 
  color: var(--text-2); 
  background: transparent; 
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
}
.nav-label { font-size: 0.65rem; font-weight: 700; color: var(--text-2); transition: all 0.3s ease; }

/* Trạng thái Active tự động đồng bộ theo Cyan Alpha của hệ thống biến */
.nav-btn.active { background: transparent !important; }
.nav-btn.active .nav-icon-wrap { background: var(--primary-alpha) !important; color: var(--primary-light) !important; transform: translateY(-2px); }
.nav-btn.active .nav-label { color: var(--primary-light) !important; font-weight: 800; }

/* ============================================================================
   INTERACTIVE PHYSICAL ANIMATIONS (HOVER & SOFT PRESS)
   ============================================================================ */
.btn-save:hover, 
.btn-cancel:hover, 
.btn-soft:hover, 
.btn-back:hover,
.qa-btn:hover,
.pagination-btn:hover,
.tx-btn:hover,
.period-pill:hover {
  opacity: 0.85; 
  transition: opacity 0.2s ease;
}

.btn-save:active, 
.btn-cancel:active, 
.btn-danger:active, 
.btn-danger-outline:active, 
.btn-soft:active,
.btn-back:active,
.qa-btn:active, 
.period-pill:active,
.tx-card:active,
.pagination-btn:active,
.nav-btn:active { 
  transform: scale(0.96) !important; 
  transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1); 
}

/* ============================================================================
   PAGE TRANSITION ANIMATIONS (SLIDE & FADE) - OPTIMIZED FOR FINTECH APP
   ============================================================================ */
.slide-in-right {
    animation: slideInRight 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.slide-out-right {
    animation: slideOutRight 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.fade-in-view {
    animation: fadeInView 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(40px);
    }
}

@keyframes fadeInView {
    from { 
        opacity: 0; 
        transform: scale(0.98); 
    }
    to { 
        opacity: 1; 
        transform: scale(1); 
    }
}

/* ============================================================================
   BỐ CỤC BIỂU ĐỒ TRÒN MỚI (TRÁI - PHẢI)
   ============================================================================ */
.pie-layout-wrapper {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    gap: 16px;
}

.pie-layout-wrapper .pie-chart-inner {
    flex: 0 0 140px; /* Thu nhỏ biểu đồ lại để nhường chỗ cho text */
    height: 140px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* Thu gọn thanh cuộn cho tinh tế VÀ HIỂN THỊ ĐỒNG BỘ MỌI THIẾT BỊ */
.compact-legend {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 150px; 
    overflow-y: auto; 
    padding-right: 8px; /* Đẩy chữ cách xa thanh cuộn ra 1 chút cho thoáng */
    min-width: 0;
    -webkit-overflow-scrolling: touch;
    
    /* Ép hiển thị thanh cuộn trên Firefox */
    scrollbar-width: thin;
    scrollbar-color: var(--text-3) transparent;
}

/* Tùy chỉnh thanh cuộn cho Webkit (Chrome, Safari, Mobile iOS/Android) */
.compact-legend::-webkit-scrollbar { 
    width: 4px; /* Thu nhỏ bề ngang thanh cuộn lại */
    -webkit-appearance: none;
}

/* XÓA lớp viền/đường ray thừa ở dưới */
.compact-legend::-webkit-scrollbar-track { 
    background: transparent; 
}

/* Chỉ giữ lại con lăn màu xám đậm */
.compact-legend::-webkit-scrollbar-thumb { 
    background-color: var(--text-3); 
    border-radius: 10px; /* Bo tròn 2 đầu con lăn */
}

/* Style cho từng mục chú thích */
.legend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: 0.2s;
}
.legend-item:hover { opacity: 0.8; }

.legend-item-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0; 
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.legend-value-col {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
}

.legend-pct {
    font-size: 0.75rem;
    font-weight: 800;
}

.legend-amt {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-3);
}
