/* =========================================
   1. BIẾN MÀU SẮC (PREMIUM PALETTE)
========================================= */
:root {
    --bg-color: #f1f5f9; 
    --card-bg: #ffffff; 
    --text-main: #0f172a; 
    --text-muted: #64748b;
    --primary: #3b82f6;      
    --primary-hover: #2563eb;
    --cash: #10b981;         
    --gold: #f59e0b;         
    --bank: #6366f1;         
    --danger: #ef4444;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
    --radius-lg: 24px;
    --radius-md: 16px;
}

* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
    font-family: 'Plus Jakarta Sans', sans-serif; 
}

/* =========================================
   2. BỐ CỤC CHÍNH & FOOTER BÁM ĐÁY
========================================= */
body { 
    background: var(--bg-color); 
    color: var(--text-main); 
    font-size: 14px; 
    display: flex;              
    flex-direction: column;     
    min-height: 100vh;          
}

.container { 
    max-width: 1240px; 
    margin: 0 auto; 
    padding: 0 15px; 
    width: 100%;
    flex: 1; /* Tự động giãn ra để đẩy footer xuống đáy */
}

/* =========================================
   3. HEADER (FLOATING ISLAND)
========================================= */
.header-wrapper { 
    position: relative; /* Không dính chặt vào viền trên */
    z-index: 100;
    max-width: 1240px; 
    margin: 15px auto 30px auto; 
    padding: 0 15px;
    width: 100%;
}

.header { 
    background: var(--card-bg);
    padding: 15px 24px;
    border-radius: var(--radius-lg); 
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(255,255,255,0.8);
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}

.header-title { font-size: 20px; font-weight: 800; display: flex; align-items: center; gap: 10px; color: var(--text-main);}
.header-title img { width: 26px; height: 26px; } 
.header-title span.hl { color: var(--primary); }

.header-right { display: flex; align-items: center; gap: 20px; }
.header-date { background: #f8fafc; padding: 10px 16px; border-radius: 12px; font-weight: 700; color: var(--text-muted); font-size: 13px; border: 1px solid var(--border); display: none; }
.user-profile { display: flex; align-items: center; gap: 12px; padding-right: 20px; border-right: 1px solid var(--border); }
.user-avatar { width: 42px; height: 42px; border-radius: 12px; object-fit: cover; border: 2px solid #e2e8f0; }
.user-info { display: flex; flex-direction: column; }
.user-name { font-weight: 800; color: var(--text-main); font-size: 14.5px; }
.user-role { font-size: 12px; color: var(--primary); font-weight: 700; }

.btn-logout { background: #f8fafc; color: var(--text-muted); padding: 10px 18px; border-radius: 12px; font-weight: 700; font-size: 13px; border: 1px solid var(--border); cursor: pointer; transition: all 0.2s;}
.btn-logout:hover { color: var(--danger); border-color: var(--danger); background: #fef2f2; transform: translateY(-1px);}

/* =========================================
   4. CÁC THÀNH PHẦN GIAO DIỆN (CARDS)
========================================= */
.card { background: var(--card-bg); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow-md); border: 1px solid rgba(255,255,255,0.8); display: flex; flex-direction: column;}
.card-title { font-size: 16px; font-weight: 800; color: var(--text-main); margin-bottom: 24px; display: flex; align-items: center; gap: 10px; letter-spacing: -0.3px;}
.card-title .icon-bg { width: 32px; height: 32px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 14px;}

/* THANH TIẾN ĐỘ MỤC TIÊU */
.goal-banner { background: var(--card-bg); border-radius: var(--radius-lg); padding: 20px 24px; margin-bottom: 24px; box-shadow: var(--shadow-sm); border: 1px solid rgba(255,255,255,0.8); display: flex; align-items: center; gap: 20px; }
.goal-icon { width: 50px; height: 50px; background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%); color: white; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; box-shadow: 0 4px 10px rgba(245, 158, 11, 0.3);}
.goal-info { flex: 1; }
.goal-top { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 10px; }
.goal-title { font-size: 15px; font-weight: 800; color: var(--text-main); }
.goal-title span { color: var(--text-muted); font-weight: 600; font-size: 13px; margin-left: 5px; }
.goal-pct { font-size: 18px; font-weight: 800; color: var(--gold); }
.progress-bg { width: 100%; height: 10px; background: #f1f5f9; border-radius: 10px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #fcd34d 0%, #f59e0b 100%); border-radius: 10px; transition: width 1s ease-in-out; }

/* TỔNG QUAN (4 THẺ) */
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 24px; }
.sum-card { justify-content: space-between; position: relative; overflow: hidden; border-radius: var(--radius-lg);}
.sum-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.sum-header h3 { font-size: 13px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;}
.s-icon { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 18px;}
.c-total .s-icon { background: rgba(59, 130, 246, 0.1); color: var(--primary); }
.c-cash .s-icon { background: rgba(16, 185, 129, 0.1); color: var(--cash); }
.c-bank .s-icon { background: rgba(99, 102, 241, 0.1); color: var(--bank); }
.c-gold .s-icon { background: rgba(245, 158, 11, 0.1); color: var(--gold); }
.sum-body h2 { font-size: 28px; font-weight: 800; color: var(--text-main); margin-bottom: 12px; letter-spacing: -0.5px;}
.c-total .sum-body h2 { color: var(--primary); font-size: 32px;}
.sum-change { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid #f1f5f9; padding-top: 15px;}
.badge-up { color: #059669; font-size: 12px; font-weight: 700; display:flex; align-items:center; gap: 4px; background: #d1fae5; padding: 4px 8px; border-radius: 6px;}
.badge-down { color: var(--danger); font-size: 12px; font-weight: 700; display:flex; align-items:center; gap: 4px; background: #fee2e2; padding: 4px 8px; border-radius: 6px;}
.badge-neutral { color: var(--text-muted); font-size: 12px; font-weight: 600; display:flex; align-items:center; gap: 4px; background: #f1f5f9; padding: 4px 8px; border-radius: 6px;}
.time-label { font-size: 11px; color: #94a3b8; font-weight: 600;}

/* FEATURE GRID (Cập nhật & Biểu đồ) */
.feature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px;}
.flex-row { display: flex; gap: 15px; align-items: flex-start;}

/* INPUTS & NÚT */
.input-group-modern { position: relative; margin-bottom: 15px; flex: 1;}
.input-group-modern i { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: #94a3b8; font-size: 15px;}
.input-group-modern input { width: 100%; padding: 14px 14px 14px 42px; border: 1px solid var(--border); border-radius: 12px; background: #f8fafc; font-size: 14.5px; transition: all 0.2s; outline: none; color: var(--text-main); font-weight: 700;}
.input-group-modern input:focus { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1); }
.input-label { font-size: 13px; color: var(--text-main); font-weight: 700; margin-bottom: 8px; display: block; }
button.btn-save { padding: 14px 20px; border: none; border-radius: 12px; background: var(--primary); color: white; font-weight: 700; font-size: 14px; cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%;}
button.btn-save:hover { background: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 8px 15px rgba(59, 130, 246, 0.25);}

/* BIỂU ĐỒ & CUSTOM LEGEND (NEW MODERN DESIGN) */
.chart-layout { display: flex; align-items: center; justify-content: space-between; height: 100%; gap: 25px;}

/* Biểu đồ có chữ ở giữa */
.chart-container { width: 45%; height: 210px; position: relative; display: flex; align-items: center; justify-content: center;}
.chart-center { position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; text-align: center; }
.chart-center span.lbl { font-size: 11px; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
.chart-center span.val { font-size: 14.5px; font-weight: 800; color: var(--text-main); }

/* Danh sách chú thích bên phải */
.custom-legend { width: 55%; display: flex; flex-direction: column; justify-content: center; gap: 0; }
.legend-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px dashed var(--border); transition: 0.3s ease;}
.legend-item:last-child { border-bottom: none; padding-bottom: 0;}
.legend-item:first-child { padding-top: 0;}
.legend-item:hover { transform: translateX(5px); } /* Hiệu ứng đẩy nhẹ sang phải khi di chuột */

.legend-left { display: flex; align-items: center; gap: 15px;}
.icon-shape { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0;}
.legend-info { display: flex; flex-direction: column; gap: 5px; }

.l-title { font-size: 12.5px; color: var(--text-muted); font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; line-height: 1;}
.l-val { font-weight: 800; font-size: 15px; color: var(--text-main); line-height: 1; white-space: nowrap;}

.legend-pct { font-size: 13px; font-weight: 800; padding: 6px 10px; border-radius: 8px; min-width: 60px; text-align: center;}

/* BANK SECTION */
.bank-section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;}
.btn-add-bank { background: #fff; color: var(--primary); border: 2px dashed var(--primary); font-weight: 700; padding: 8px 16px; border-radius: 10px; cursor: pointer; transition: 0.2s; display: flex; gap: 8px; align-items: center;}
.btn-add-bank:hover { background: rgba(59,130,246,0.05); transform: translateY(-2px);}
.bank-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; margin-bottom: 24px;}
.bank-card-premium { background: #fff; border: 1px solid var(--border); border-radius: 20px; padding: 24px; display: flex; flex-direction: column; gap: 24px; transition: all 0.3s ease; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.02);}
.bank-card-premium:hover { transform: translateY(-5px); box-shadow: var(--shadow-md); border-color: #cbd5e1;}
.bank-top { display: flex; justify-content: space-between; align-items: flex-start;}
.bank-logo { width: 50px; height: 50px; border-radius: 50%; object-fit: contain; background: #fff; border: 1px solid var(--border); padding: 5px; box-shadow: var(--shadow-sm);}
.bank-actions { display: flex; gap: 6px;}
.btn-action { background: #f1f5f9; border: none; cursor: pointer; width: 34px; height: 34px; border-radius: 10px; transition: 0.2s; color: var(--text-muted); display: inline-flex; align-items: center; justify-content: center; font-size: 13px;}
.btn-action:hover { background: #e2e8f0; color: var(--text-main); }
.btn-action.del:hover { background: #fee2e2; color: var(--danger); }
.bank-bottom h4 { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; margin-bottom: 6px; letter-spacing: 0.5px;}
.bank-bottom span { font-size: 24px; font-weight: 800; color: var(--text-main); display: block; letter-spacing: -0.5px;}

/* BẢNG BIẾN ĐỘNG */
.table-responsive { width: 100%; max-height: 400px; overflow-y: auto; overflow-x: auto; border-radius: 16px; background: #fff;}
.table-responsive::-webkit-scrollbar { width: 6px; height: 6px; }
.table-responsive::-webkit-scrollbar-thumb { background-color: #cbd5e1; border-radius: 6px; }
.data-table { width: 100%; border-collapse: collapse; min-width: 800px; }
.data-table th { position: sticky; top: 0; z-index: 10; background: #f8fafc; padding: 18px 20px; font-size: 12px; color: var(--text-muted); font-weight: 800; text-transform: uppercase; text-align: right; white-space: nowrap; box-shadow: 0 1px 0 var(--border); letter-spacing: 0.5px;}
.data-table th:first-child { text-align: left; }
.data-table th:last-child { text-align: center; }
.data-table td { padding: 18px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; text-align: right;}
.data-table td:first-child { text-align: left; }
.data-table td:last-child { text-align: center; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr:last-child td { border-bottom: none; }
.val-main { font-weight: 800; color: var(--text-main); font-size: 15px; display: block; margin-bottom: 6px;}
.val-delta { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; border-radius: 6px; background: #f1f5f9;}
.val-delta.up { color: #059669; background: #d1fae5; font-size: 12px; font-weight: 700; }
.val-delta.down { color: #dc2626; background: #fee2e2; font-size: 12px; font-weight: 700; }
.val-delta.neutral { color: var(--text-muted); font-size: 12px; font-weight: 700; }
.td-date { font-weight: 700; color: var(--text-main); font-size: 14.5px; display: flex; align-items: center; gap: 10px;}
.td-date i { color: var(--primary); font-size: 16px; background: rgba(59,130,246,0.1); padding: 8px; border-radius: 8px;}

/* =========================================
   5. FOOTER (CẬP NHẬT GIAO DIỆN MỚI)
========================================= */
.footer-wrapper { 
    max-width: 1240px; 
    margin: 20px auto 20px auto; 
    padding: 0 15px; 
    width: 100%;
}

.footer-content { 
    background: var(--card-bg);
    padding: 35px;
    border-radius: var(--radius-lg); 
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(255,255,255,0.8);
}

.footer-grid { display: grid; grid-template-columns: 2fr 1.2fr 1.5fr; gap: 40px; margin-bottom: 25px; padding-bottom: 25px; border-bottom: 1px dashed var(--border); }
.footer-col h4 { font-size: 13px; font-weight: 800; color: var(--text-muted); margin-bottom: 20px; text-transform: uppercase; letter-spacing: 1px; }

/* Cột 2: Tech Stack */
.tech-list { display: flex; flex-direction: column; gap: 12px; }
.tech-item { display: flex; align-items: center; gap: 12px; font-size: 13.5px; color: var(--text-main); font-weight: 600;}
.tech-icon { width: 34px; height: 34px; background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 15px; transition: 0.3s;}
.tech-item:hover .tech-icon { background: var(--primary); color: #fff; border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);}

/* Cột 3: Quản trị dữ liệu */
.data-badge { background: #f8fafc; border: 1px solid var(--border); padding: 16px; border-radius: 14px; margin-bottom: 12px; display: flex; gap: 15px; align-items: flex-start; transition: 0.3s; }
.data-badge:hover { background: #fff; box-shadow: var(--shadow-sm); border-color: #cbd5e1; transform: translateX(3px);}
.data-icon { color: var(--primary); font-size: 20px; margin-top: 2px;}
.data-badge.local .data-icon { color: var(--cash); }
.data-info strong { display: block; font-size: 14px; color: var(--text-main); font-weight: 800; margin-bottom: 4px;}
.data-info span { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; display: block;}

.footer-bottom { display: flex; justify-content: space-between; align-items: center; }
.footer-copy { color: var(--text-muted); font-size: 13px; font-weight: 600; }
.footer-quote { font-style: italic; color: var(--text-main); font-weight: 700; font-size: 13px; background: #f1f5f9; padding: 10px 18px; border-radius: 10px; display: inline-block;}

/* =========================================
   6. MODALS
========================================= */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(5px); z-index: 1000; display: flex; justify-content: center; align-items: center; opacity: 0; visibility: hidden; transition: 0.2s; }
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal-box { background: #fff; border-radius: 24px; width: 90%; max-width: 400px; padding: 30px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); transform: translateY(20px) scale(0.95); transition: 0.3s cubic-bezier(0.16, 1, 0.3, 1); text-align: center;}
.modal-overlay.open .modal-box { transform: translateY(0) scale(1); }
.modal-title { font-size: 18px; font-weight: 800; color: var(--text-main); margin-bottom: 12px; display:flex; align-items:center; justify-content:center; gap:8px;}
.modal-text { font-size: 14.5px; color: var(--text-muted); line-height: 1.5; margin-bottom: 25px;}
.modal-actions { display: flex; gap: 12px; justify-content: flex-end;}
.btn-modal { padding: 12px 20px; border-radius: 12px; font-size: 14px; font-weight: 700; cursor: pointer; border: none; transition: 0.2s; flex: 1;}
.btn-modal-cancel { background: #f1f5f9; color: var(--text-main); }
.btn-modal-cancel:hover { background: #e2e8f0; }
.btn-modal-danger { background: var(--danger); color: white; box-shadow: 0 4px 10px rgba(239, 68, 68, 0.2);}
.btn-modal-danger:hover { background: #dc2626; transform: translateY(-1px);}
.btn-modal-primary { background: var(--primary); color: white; box-shadow: 0 4px 10px rgba(59, 130, 246, 0.2);}
.btn-modal-primary:hover { background: var(--primary-hover); transform: translateY(-1px);}

/* =========================================
   7. RESPONSIVE DESIGN (Tối ưu thiết bị)
========================================= */
@media (min-width: 768px) { 
    .header-date { display: flex; align-items: center; gap: 8px; } 
}

@media (max-width: 1100px) {
    .summary-grid { grid-template-columns: repeat(2, 1fr); }
    .feature-grid { grid-template-columns: 1fr; }
    .chart-layout { flex-direction: column; height: auto;}
    .chart-container { width: 100%; margin-bottom: 20px;}
    .custom-legend { width: 100%; flex-direction: row; flex-wrap: wrap;}
    .legend-item { flex: 1; min-width: 200px;}
}

@media (max-width: 850px) {
    .footer-grid { grid-template-columns: 1fr; gap: 30px; text-align: center; }
    .footer-links li a { justify-content: center; }
    .security-badge { justify-content: center; text-align: left; }
    .footer-bottom { flex-direction: column; gap: 15px; text-align: center; }
    .user-profile { padding-right: 0; border-right: none; }
    .user-info { display: none; }
}

@media (max-width: 600px) {
    .summary-grid { grid-template-columns: 1fr; gap: 15px;}
    .flex-row { flex-direction: column; gap: 0;}
    .card { padding: 20px; }
    .bank-grid { grid-template-columns: 1fr; }
    .custom-legend { flex-direction: column;}
    .goal-banner { flex-direction: column; align-items: flex-start; gap: 15px; }
}

/* =========================================
   8. HIỆU ỨNG THẺ NGÂN HÀNG GRADIENT
========================================= */
.bank-card-premium.bank-card-gradient {
    border: none;
    color: #ffffff;
}

/* Đổi màu chữ bên trong thẻ sang trắng */
.bank-card-gradient .bank-bottom h4 {
    color: rgba(255, 255, 255, 0.8);
}
.bank-card-gradient .bank-bottom span {
    color: #ffffff;
}

/* Làm trong suốt các nút bấm (Sửa/Xóa) */
.bank-card-gradient .btn-action {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}
.bank-card-gradient .btn-action:hover {
    background: rgba(255, 255, 255, 0.3);
    color: #ffffff;
}
.bank-card-gradient .btn-action.del:hover {
    background: rgba(239, 68, 68, 0.9);
}

/* Làm viền logo nổi bật hơn trên nền màu */
.bank-card-gradient .bank-logo {
    border-color: rgba(255, 255, 255, 0.3);
    background: #ffffff;
}

/* =========================================
   9. GIAO DIỆN TRANG LOGIN (ĐỒNG BỘ)
========================================= */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 0;
    min-height: 60vh; /* Đảm bảo form nằm giữa vùng container */
}

.login-card-modern {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255,255,255,0.8);
    text-align: center;
}

.login-header {
    margin-bottom: 30px;
}

.login-avatar {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    object-fit: cover;
    margin-bottom: 15px;
    border: 3px solid var(--primary);
    padding: 3px;
    box-shadow: 0 5px 15px rgba(59, 130, 246, 0.2);
}

.login-card-modern h2 {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 8px;
}

.login-card-modern p.sub-text {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
}

.error-box {
    background: #fef2f2;
    color: var(--danger);
    padding: 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 20px;
    border: 1px solid #fee2e2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.login-form .input-group-modern {
    margin-bottom: 20px;
}

.login-form button.btn-login {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    background: var(--primary);
    color: white;
    font-weight: 800;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.login-form button.btn-login:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.4);
}