*{box-sizing:border-box}
body{margin:0;background:#f4f6f8;color:#172033;font-family:Arial,Helvetica,sans-serif;font-size:14px}
.container{max-width:1540px;margin:0 auto;padding:30px 20px}
.topbar{display:flex;align-items:center;justify-content:space-between;margin-bottom:18px}
.topbar h1{font-size:26px;font-weight:500;margin:0}
.money-icon{color:#1479e8}
.actions{display:flex;gap:8px}
.btn{border:1px solid #d4d8dd;background:#fff;border-radius:6px;padding:9px 14px;cursor:pointer;font-size:14px}
.btn:hover{filter:brightness(.97)}
.btn.primary{background:#1677df;color:#fff;border-color:#1677df}
.btn b{background:#dc2626;color:#fff;border-radius:50%;font-size:11px;padding:2px 6px;margin-left:4px}

.summary{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin-bottom:16px}
/* =========================
   SUMMARY CARDS
========================= */

.summary-card{
    position:relative;
    overflow:hidden;
    background:#fff;
    border:1px solid #e5e7eb;
    border-radius:12px;
    padding:18px 20px;
    min-height:92px;
    box-shadow:0 2px 8px rgba(15,23,42,.06);
    transition:
        transform .2s ease,
        box-shadow .2s ease;
}

.summary-card:hover{
    transform:translateY(-2px);
    box-shadow:0 6px 18px rgba(15,23,42,.10);
}

/* vạch màu bên trái */

.summary-card::before{
    content:"";
    position:absolute;
    left:0;
    top:0;
    bottom:0;
    width:5px;
    border-radius:12px 0 0 12px;
}

/* Tiêu đề */

.summary-card small{
    display:block;
    font-size:11px;
    font-weight:700;
    letter-spacing:.5px;
    margin-bottom:8px;
}

/* Số tiền */

.summary-card strong{
    display:block;
    font-size:30px;
    line-height:1.2;
    font-weight:700;
}

/* =========================
   TỔNG NGÂN SÁCH
========================= */

.summary-card:nth-child(1){
    background:linear-gradient(
        135deg,
        #f5f9ff 0%,
        #ffffff 75%
    );

    border-color:#dbeafe;
}

.summary-card:nth-child(1)::before{
    background:#2563eb;
}

.summary-card:nth-child(1) small{
    color:#64748b;
}

.summary-card:nth-child(1) strong{
    color:#2563eb;
}

/* =========================
   TỔNG CHI TIÊU
========================= */

.summary-card:nth-child(2){
    background:linear-gradient(
        135deg,
        #fff5f5 0%,
        #ffffff 75%
    );

    border-color:#fecaca;
}

.summary-card:nth-child(2)::before{
    background:#dc2626;
}

.summary-card:nth-child(2) small,
.summary-card:nth-child(2) strong{
    color:#dc2626;
}

/* =========================
   CÒN DƯ
========================= */

.summary-card:nth-child(3){
    background:linear-gradient(
        135deg,
        #f1fcf6 0%,
        #ffffff 75%
    );

    border-color:#bbf7d0;
}

.summary-card:nth-child(3)::before{
    background:#16a34a;
}

.summary-card:nth-child(3) small{
    color:#64748b;
}

.summary-card:nth-child(3) strong{
    color:#16a34a;
}

/* Khi số dư âm */



.select-card{background:#fff;border:1px solid #e3e5e8;border-radius:8px;padding:10px 14px;margin-bottom:16px;display:flex;align-items:center;gap:10px}
.select-card label{white-space:nowrap;color:#536277}
.select-card select{width:100%;height:34px;border:1px solid #ccd2d9;border-radius:5px;background:#fff;padding:0 10px;color:#26364a}

.panel{background:#fff;border:1px solid #e1e4e8;border-radius:8px;overflow:hidden}
.panel-head{min-height:54px;padding:10px 14px 10px 20px;border-bottom:1px solid #e5e7eb;display:flex;align-items:center;justify-content:space-between}
.panel-head h2{font-size:16px;margin:0}
.category-stats{display:flex;align-items:center;gap:12px;color:#637086}
.category-stats .money-input{display:flex;border:1px solid #d1d5db;border-radius:5px;height:30px}
.category-stats input{width:105px;border:0;text-align:right;padding:5px;outline:0}
.category-stats .money-input span{padding:6px 7px 0 0;color:#555}

.red{color:#d92d27!important}
.green{color:#159447!important}

.table-wrap{overflow-x:auto}
table{width:100%;border-collapse:collapse;table-layout:fixed}
th,td{border-bottom:1px solid #e8eaed;padding:10px;text-align:left;vertical-align:middle}
th{background:#fafafa;color:#526074;font-size:12px;font-weight:600;text-align:center}
th:nth-child(1){width:48px}
th:nth-child(2){width:145px}
th:nth-child(3){width:25%}
th:nth-child(4){width:23%}
th:nth-child(5){width:125px;text-align:right}
th:nth-child(6){width:130px;text-align:right}
th:nth-child(7){width:100px;text-align:center}
th:nth-child(8){width:90px;text-align:center}

td:nth-child(1){text-align:center;color:#50647c}
td:nth-child(6){text-align:right;font-weight:500}
.date-cell{white-space:nowrap}
.calendar{margin-left:7px;color:#54708f}
.note-cell{color:#6d7787}
.editable{cursor:pointer}
.fund-cell{text-align:right}
.amount-cell{text-align:right}
.receipt-cell{text-align:center}
.receipt{width:48px;height:48px;object-fit:cover;border:1px solid #ddd;border-radius:3px;cursor:pointer}

.actions-cell{text-align:center;white-space:nowrap}
.row-btn{border:0;background:transparent;cursor:pointer;font-size:16px;padding:5px 7px}
.row-btn.edit{color:#1677df}
.row-btn.delete{color:#dc2626}
.row-btn.save{background:#1677df;color:#fff;border-radius:5px}
.row-btn.cancel{background:#fff;border:1px solid #d6dae0;border-radius:5px;margin-left:4px}

.inline-input{width:100%;height:34px;border:1px solid #ccd2d9;border-radius:5px;padding:6px 8px;font:inherit;outline:none;background:#fff}
.inline-input:focus{border-color:#3389e8;box-shadow:0 0 0 2px #3389e81a}
.inline-date{min-width:125px}
.inline-money{text-align:right}
.editing td{background:#fcfdff}

tfoot td{background:#fff;padding:9px 10px}
.plus-cell{text-align:center!important;color:#1677df;font-size:18px}
tfoot input{width:100%;height:34px;border:1px solid #ccd2d9;border-radius:5px;padding:6px 8px;font:inherit;outline:none}
tfoot input:focus{border-color:#3389e8}
.new-money{text-align:right}
.upload-cell{text-align:center}
.upload-box{width:48px;height:48px;border:1px dashed #c8ced6;border-radius:5px;display:inline-flex;align-items:center;justify-content:center;cursor:pointer;color:#657386;font-size:20px}
.upload-box input{display:none}
.add-btn{padding:8px 13px}

.table-help{padding:12px 16px;background:#f8fafc;border-top:1px solid #e5e7eb;border-bottom:1px solid #e5e7eb;color:#536277;line-height:1.8;font-size:13px}
.totals{padding:0 0px 8px 0;background:#fff}
.totals>div{display:flex;justify-content:flex-end;gap:120px;padding:8px 24px;border-bottom:1px solid #edf0f2}
.totals>div span{min-width:130px;text-align:right}
.totals>div b{min-width:150px;text-align:right}

.empty{padding:25px;text-align:center;color:#7a8595}

.modal{display:none;position:fixed;inset:0;background:#0006;z-index:50;align-items:center;justify-content:center;padding:20px}
.modal.show{display:flex}
.modal-box{width:min(500px,100%);background:#fff;border-radius:10px;padding:22px;position:relative;box-shadow:0 20px 60px #0003}
.modal-box.wide{width:min(900px,100%)}
.close{position:absolute;right:14px;top:10px;border:0;background:transparent;font-size:28px;color:#667085;cursor:pointer}
.modal h3{margin:0 0 20px;font-size:19px}
.modal label{display:block;margin:12px 0 6px;color:#455468}
.modal input,.modal textarea{width:100%;border:1px solid #cfd5dc;border-radius:6px;padding:9px;font:inherit;outline:none}
.modal input:focus,.modal textarea:focus{border-color:#3389e8}
.full{width:100%;margin-top:18px}
.trash-item{display:grid;grid-template-columns:1fr auto;gap:12px;padding:12px 0;border-bottom:1px solid #eee;align-items:center}
.trash-item small{color:#777}
.trash-actions{display:flex;gap:5px}
.trash-btn{border:1px solid #d6dae0;background:#fff;padding:7px 10px;border-radius:5px;cursor:pointer}

@media(max-width:1000px){
  .summary{grid-template-columns:1fr}
  .topbar{align-items:flex-start;gap:12px;flex-direction:column}
  .category-stats{flex-wrap:wrap}
  .panel-head{align-items:flex-start;gap:8px;flex-direction:column}
  th:nth-child(3){width:260px}
  th:nth-child(4){width:220px}
}

@media print{
  body{background:#fff}
  .actions,.select-card,.category-stats .money-input,.row-btn,.table-help,#newExpenseRow{display:none!important}
  .container{padding:0}
  .panel{border:0}
  .summary-card{box-shadow:none}
  .modal{display:none!important}
}

/* Chứng từ: kéo thả + thay ảnh khi chỉnh sửa */
.receipt-edit-cell{padding:7px 8px!important}
.receipt-edit-box{display:flex;align-items:center;justify-content:center;gap:7px;flex-wrap:wrap;min-width:150px}
.edit-receipt-wrap{display:flex;flex-direction:column;align-items:center;gap:2px}
.edit-receipt-wrap small{font-size:10px;color:#6b7280}
.edit-receipt-empty{font-size:11px;color:#9aa3af}
.receipt-edit-box .receipt{width:44px;height:44px}
.receipt-dropzone{position:relative;transition:.15s ease}
.receipt-dropzone.dragover{border-color:#1677df!important;background:#eef6ff!important;transform:scale(1.03)}
.receipt-dropzone .drop-icon{font-size:18px}
.receipt-dropzone .drop-text{font-size:11px;line-height:1.35;text-align:center;color:#536277}
.receipt-dropzone .drop-text small{font-size:10px;color:#8a94a3}
.receipt-file-input{display:none!important}
.selected-file-name{max-width:130px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:10px;color:#1677df;text-align:center}
.receipt-new-box{display:flex;flex-direction:column;align-items:center;gap:2px}
.receipt-new-box .upload-box{height:48px;width:70px;flex-direction:column;font-size:18px}
.receipt-new-box .upload-box:after{content:'Kéo thả / chọn';font-size:9px;color:#657386;margin-top:1px}

.category-title-wrap{display:flex;align-items:center;gap:5px}.category-edit-btn,
.category-share-btn{border:0;background:transparent;cursor:pointer;padding:3px 5px;font-size:14px;opacity:.7}
.category-edit-btn:hover,.category-share-btn:hover{opacity:1}
.category-name-input{width:min(360px,50vw);height:32px;border:1px solid #3389e8;border-radius:5px;padding:5px 9px;font:inherit;outline:0}
.readonly-money{}.readonly-money input{cursor:not-allowed;color:#172033}
.share-banner{margin-bottom:16px;padding:10px 14px;background:#eef6ff;border:1px solid #cfe4ff;border-radius:7px;color:#235b91}
.share-error{max-width:600px;margin:100px auto;padding:30px;background:#fff;border:1px solid #e3e5e8;border-radius:10px;text-align:center}
.receipt-modal{display:none;position:fixed;inset:0;z-index:9999;background:#000c;align-items:center;justify-content:center;padding:30px}
.receipt-modal.show{display:flex}.receipt-modal-content{max-width:95vw;max-height:92vh;display:flex;align-items:center;justify-content:center}
.receipt-modal-content img{max-width:95vw;max-height:90vh;width:auto;height:auto;object-fit:contain;background:#fff;border-radius:5px;box-shadow:0 20px 70px #0008}
.receipt-modal-close{position:fixed;top:14px;right:20px;width:44px;height:44px;border:0;border-radius:50%;background:#ffffff22;color:#fff;font-size:31px;cursor:pointer;z-index:10000}.receipt-modal-close:hover{background:#ffffff44}body.receipt-popup-open{overflow:hidden}.share-mode .actions .btn.light{display:inline-block}@media(max-width:700px){.category-name-input{width:220px}.share-banner{font-size:13px}}

/* ===== Cài đặt ===== */
.settings-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10050;
    background: rgba(0,0,0,.45);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.settings-overlay.show {
    display: flex;
}

.settings-modal {
    position: relative;
    width: min(460px, 100%);
    background: #fff;
    border-radius: 12px;
    padding: 26px;
    box-shadow: 0 18px 60px rgba(0,0,0,.22);
}

.settings-modal h2 {
    margin: 0 0 20px;
}

.settings-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 34px;
    height: 34px;
    border: 0;
    background: transparent;
    font-size: 25px;
    cursor: pointer;
}

.settings-menu {
    margin-bottom: 18px;
}

.settings-menu-item {
    width: 100%;
    text-align: left;
    border: 1px solid #ddd;
    background: #f7f8fa;
    border-radius: 7px;
    padding: 10px 12px;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.settings-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-weight: 600;
}

.settings-form input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 11px;
    border: 1px solid #cfd5dc;
    border-radius: 6px;
    font: inherit;
}

.settings-form input:focus {
    outline: none;
    border-color: #3389e8;
    box-shadow: 0 0 0 2px rgba(51,137,232,.12);
}

.settings-message {
    min-height: 20px;
    font-size: 14px;
}

.settings-save-btn {
    border: 0;
    border-radius: 6px;
    padding: 11px 15px;
    background: #1677df;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

.settings-save-btn:hover {
    background: #0f68c8;
}
