* { box-sizing: border-box; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
body { background-color: #f0f4f8; margin: 0; padding: 30px; display: flex; justify-content: center; }
.dashboard { background-color: white; padding: 40px; border-radius: 15px; box-shadow: 0 10px 25px rgba(0,0,0,0.05); max-width: 1000px; width: 100%; }
h1 { text-align: center; color: #2c3e50; margin-bottom: 20px; font-size: 28px; }

.app-tools { background: #f0faf4; border: 1px solid #b9dfc7; border-radius: 10px; padding: 14px 16px; margin-bottom: 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.app-tools strong { color: #126b35; }
.app-tools p { margin: 4px 0 0; color: #52635a; font-size: 13px; }
.app-tools-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.app-tools-actions button { border: 0; border-radius: 7px; padding: 9px 12px; background: #14803c; color: #fff; cursor: pointer; font-weight: 700; white-space: nowrap; }
.app-tools-actions button:hover { background: #0f672f; }

.month-selector-panel { background: #eef2f7; padding: 15px; border-radius: 10px; margin-bottom: 25px; display: flex; justify-content: center; align-items: center; gap: 15px; }
.month-selector-panel label { font-size: 15px; color: #2c3e50; font-weight: bold; }
.month-selector-panel select { padding: 8px 15px; font-size: 15px; font-weight: bold; border-radius: 6px; border: 1px solid #ccc; cursor: pointer; }

.control-panel { background-color: #f8fbf9; border: 1px solid #e0e0e0; border-radius: 10px; padding: 20px; margin-bottom: 40px; display: flex; flex-direction: column; align-items: center; gap: 15px; }
.input-group, .rules-group { display: flex; flex-direction: column; align-items: center; width: 100%; }
label { font-weight: bold; color: #333; margin-bottom: 8px; font-size: 14px; }
#total-income { width: 300px; padding: 10px; font-size: 16px; border: 2px solid #14803c; border-radius: 8px; text-align: center; }
.rules-inputs { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.rules-inputs input { width: 55px; padding: 8px; text-align: center; border: 1px solid #ccc; border-radius: 5px; font-weight: bold; }

.jars-container { display: flex; justify-content: space-around; flex-wrap: wrap; gap: 15px; }
.jar-item { display: flex; flex-direction: column; align-items: center; width: 140px; }
.jar-graphic { position: relative; width: 100px; display: flex; flex-direction: column; align-items: center; margin-bottom: 15px; }
.jar-lid { width: 68px; height: 14px; border: 4px solid #14803c; border-bottom: none; border-radius: 6px 6px 0 0; position: relative; z-index: 2; }
.jar-lid::after { content: ''; position: absolute; bottom: 0; left: -10px; width: 80px; height: 8px; background-color: #14803c; border-radius: 4px; }
.jar-glass { width: 100%; height: 120px; border: 5px solid #14803c; border-radius: 15px 15px 25px 25px; position: relative; overflow: hidden; background-color: #ffffff; }
.jar-content { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 2; }
.percent { font-size: 28px; font-weight: 900; color: #14803c; margin-top: 5px; line-height: 1; }
.icon { font-size: 32px; margin-top: 6px; }
.fill { position: absolute; bottom: 0; left: 0; width: 100%; transition: height 0.5s ease; z-index: 1; }
.fill-essential { background-color: rgba(76, 175, 80, 0.25); } 
.fill-invest { background-color: rgba(33, 150, 243, 0.25); } 
.fill-save { background-color: rgba(156, 39, 176, 0.25); } 
.fill-edu { background-color: rgba(255, 152, 0, 0.25); } 
.fill-play { background-color: rgba(244, 67, 54, 0.25); } 
.fill-protect { background-color: rgba(0, 150, 136, 0.25); } 
.jar-item h2 { font-size: 15px; margin: 0 0 8px 0; color: #333; text-align: center; }
.balance-input { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 6px; text-align: center; font-size: 13px; font-weight: bold; color: #333; outline: none; background-color: #f9f9f9; }

/* --- KHU VỰC DANH MỤC CHI TIÊU --- */
.subcategory-panel { background-color: #ffffff; border: 1px solid #e0e0e0; border-radius: 10px; padding: 25px; margin-top: 40px; box-shadow: 0 4px 10px rgba(0,0,0,0.03); }
.subcategory-panel h2 { margin-top: 0; color: #8e44ad; font-size: 20px; border-bottom: 2px solid #f0f4f8; padding-bottom: 10px; }
.create-sub-form { display: flex; gap: 10px; margin-bottom: 15px; flex-wrap: wrap; }
.create-sub-form select, .create-sub-form input { padding: 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; }
.btn-create-sub { background-color: #8e44ad; margin-top: 0; color: white; border: none; padding: 10px 20px; border-radius: 6px; font-weight: bold; cursor: pointer; }
.sub-tags-container { display: flex; flex-direction: column; gap: 10px; margin-top: 15px; }

.sub-tag-group { background: #fdfbfd; border: 1px solid #e8dff5; padding: 15px; border-radius: 10px; }
.sub-tag-header { font-weight: bold; color: #8e44ad; margin-bottom: 10px; font-size: 16px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px dashed #e8dff5; padding-bottom: 6px; }

.sub-item-row { display: flex; flex-direction: column; gap: 4px; background: #fff; border: 1px solid #e0e0e0; padding: 10px; border-radius: 8px; margin-bottom: 8px; }
.sub-item-info { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.sub-progress-bg { background-color: #f0f0f0; height: 8px; border-radius: 4px; overflow: hidden; width: 100%; border: 1px solid #ddd; }
.sub-progress-fill { background-color: #8e44ad; height: 100%; transition: width 0.3s ease; }

.sub-actions { display: inline-flex; gap: 5px; }
.btn-action { background: none; border: none; cursor: pointer; font-size: 12px; padding: 2px 5px; border-radius: 4px; }
.btn-edit { color: #2980b9; }
.btn-delete { color: #e74c3c; }

/* --- KHU VỰC RƯƠNG & HEO BẢO MẬT --- */
.vaults-panel { background-color: #ffffff; border: 1px solid #e0e0e0; border-radius: 10px; padding: 25px; margin-top: 40px; box-shadow: 0 4px 10px rgba(0,0,0,0.03); }
.vaults-panel h2 { margin-top: 0; color: #d35400; font-size: 20px; border-bottom: 2px solid #f0f4f8; padding-bottom: 10px; }

.vault-lock-container { text-align: center; padding: 25px; background: #fffaf0; border: 1px dashed #d35400; border-radius: 12px; margin-top: 15px; }
.locked-chest-img { width: 120px; height: 120px; object-fit: cover; border-radius: 12px; border: 3px solid #ffd700; margin-bottom: 15px; box-shadow: 0 5px 15px rgba(0,0,0,0.15); }
.vault-lock-container p { color: #555; margin-bottom: 15px; font-size: 14px; }
.pin-group { display: flex; justify-content: center; gap: 10px; }
.pin-group input { padding: 9px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 15px; text-align: center; width: 200px; }
.btn-unlock { background-color: #d35400; color: white; border: none; padding: 9px 20px; border-radius: 6px; font-weight: bold; cursor: pointer; }

.create-vault-form { display: flex; gap: 8px; margin-bottom: 25px; justify-content: center; flex-wrap: wrap; margin-top: 15px; }
.create-vault-form input { padding: 9px; border: 1px solid #ccc; border-radius: 6px; font-size: 13px; width: 180px; }
.btn-create-vault { margin-top: 0; background-color: #d35400; color: white; border: none; padding: 9px 12px; border-radius: 6px; font-weight: bold; cursor: pointer; font-size: 13px; }
.btn-lock-pin { margin-top: 0; background-color: #7f8c8d; color: white; border: none; padding: 9px 12px; border-radius: 6px; font-weight: bold; cursor: pointer; font-size: 13px; }
.btn-lock-out { margin-top: 0; background-color: #c0392b; color: white; border: none; padding: 9px 12px; border-radius: 6px; font-weight: bold; cursor: pointer; font-size: 13px; }

.waiting-pot-box { background: #fff8f0; border: 1px solid #f39c12; padding: 15px; border-radius: 8px; text-align: center; margin-bottom: 15px; }
.waiting-pot-box h3 { margin: 0 0 10px 0; font-size: 16px; color: #d35400; }

.vault-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
.chest-card { background: linear-gradient(135deg, #8b5a2b, #5c3a21); border: 3px solid #ffd700; border-radius: 12px; padding: 15px; color: white; box-shadow: 0 5px 15px rgba(0,0,0,0.2); position: relative; }
.piggy-card { background: linear-gradient(135deg, #d35400, #e67e22) !important; border: 3px solid #f1c40f !important; }
.chest-content-wrapper { display: flex; align-items: center; gap: 15px; margin-bottom: 10px; }
.chest-img { width: 55px; height: 55px; object-fit: cover; border-radius: 8px; border: 2px solid #ffd700; background-color: #3e2714; }
.chest-info { flex: 1; }
.chest-title { font-size: 16px; font-weight: bold; margin: 0 0 5px 0; display: flex; align-items: center; gap: 8px; }
.chest-balance { font-size: 16px; font-weight: bold; color: #ffd700; margin: 0;}
.chest-meta { font-size: 13px; color: #f0d5a3; margin-top: 4px; }

/* --- KHU VỰC NHẬP CHI TIÊU --- */
.transaction-panel { background-color: #ffffff; border: 1px solid #e0e0e0; border-radius: 10px; padding: 25px; margin-top: 40px; box-shadow: 0 4px 10px rgba(0,0,0,0.03); }
.transaction-panel h2 { margin-top: 0; color: #2c3e50; font-size: 20px; border-bottom: 2px solid #f0f4f8; padding-bottom: 10px; }
.transaction-form { display: flex; justify-content: space-between; align-items: flex-end; gap: 15px; margin-top: 20px; flex-wrap: wrap; }
.form-group { display: flex; flex-direction: column; flex: 1; min-width: 150px; }
.form-group label { font-size: 14px; font-weight: bold; margin-bottom: 5px; color: #555; }
.form-group input, .form-group select { padding: 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 15px; }
.desc-group { flex: 2; min-width: 200px; }
.btn-expense { background-color: #e74c3c; color: white; border: none; padding: 11px 20px; font-weight: bold; border-radius: 6px; cursor: pointer; height: 42px; min-width: 120px; }
.btn-expense:hover { background-color: #c0392b; }

/* --- KHU VỰC LỊCH SỬ & BÁO CÁO --- */
.history-panel { background-color: #ffffff; border: 1px solid #e0e0e0; border-radius: 10px; padding: 25px; margin-top: 40px; box-shadow: 0 4px 10px rgba(0,0,0,0.03); }
.history-panel h2 { margin-top: 0; color: #2c3e50; font-size: 20px; border-bottom: 2px solid #f0f4f8; padding-bottom: 10px; }
.table-responsive { overflow-x: auto; }
.history-table { width: 100%; border-collapse: collapse; margin-top: 15px; font-size: 15px; }
.history-table th, .history-table td { padding: 15px; text-align: left; border-bottom: 1px solid #eeeeee; }
.history-table th { background-color: #f8fbf9; color: #333; font-weight: bold; }
.history-table tr:hover { background-color: #fcfcfc; }
.history-table td { color: #555; }
.amount-expense { color: #e74c3c !important; font-weight: bold; }
.amount-transfer { color: #14803c !important; font-weight: bold; }

.btn-report { background-color: #8e44ad; color: white; border: none; padding: 14px 30px; font-size: 16px; font-weight: bold; border-radius: 8px; cursor: pointer; }
.btn-report:hover { background-color: #732d91; }

.report-panel { background-color: #ffffff; border: 1px solid #e0e0e0; border-radius: 10px; padding: 25px; margin-top: 40px; box-shadow: 0 4px 10px rgba(0,0,0,0.03); }
.report-panel h2 { color: #8e44ad; border-bottom: 2px solid #f0f4f8; padding-bottom: 10px; margin-top: 0; }
.report-card { background: #fdfbfd; border: 1px solid #e8dff5; padding: 15px; border-radius: 8px; margin-top: 15px; }

/* Nút nạp trực tiếp vào quỹ và rương */
.btn-direct-fund { background: #27ae60; color: white; border: none; padding: 5px 10px; border-radius: 4px; font-size: 12px; cursor: pointer; font-weight: bold; width: 100%; margin-top: 5px; }
.btn-direct-fund:hover { background: #219653; }

@media (max-width: 700px) {
    body { padding: 10px; }
    .dashboard { padding: 18px 12px; border-radius: 10px; }
    h1 { font-size: 22px; }
    .app-tools, .month-selector-panel { flex-direction: column; align-items: stretch; }
    .app-tools-actions { justify-content: stretch; }
    .app-tools-actions button { flex: 1 1 140px; }
    #save-status { margin-left: 0 !important; text-align: center; }
    #total-income { width: 100%; max-width: 300px; }
    .dashboard-grid { grid-template-columns: 1fr !important; }
    .dashboard-grid .report-card { grid-column: span 1 !important; }
}
