/* ============================================================
   Sổ Tiền — hệ thống thiết kế
   Tham chiếu: Copilot Money (bố cục thoáng, thẻ bo tròn lớn,
   giao diện trung tính — màu chỉ dành cho DỮ LIỆU, không dành cho nút).
   ============================================================ */

:root {
  /* --- Nền & bề mặt: trắng ngà ấm, không phải trắng lạnh --- */
  --bg:        #FBFBF9;
  --surface:   #FFFFFF;
  --surface-2: #F5F5F2;
  --surface-3: #EFEFEB;
  --border:    #EAEAE4;
  --hairline:  #F0F0EC;

  /* --- Chữ --- */
  --text:      #16171A;
  --text-2:    #565A61;
  --muted:     #9498A0;

  /* --- Chrome trung tính: nút chính là mực, không phải màu mè --- */
  --ink:       #16171A;
  --ink-text:  #FFFFFF;
  --active-bg: #EFEFEB;

  /* --- Màu ngữ nghĩa: chỉ dùng cho số liệu --- */
  --thu:       #1B7F53;
  --thu-bg:    #E8F4ED;
  --chi:       #16171A;     /* tiền chi = mực, giữ cho màn hình yên tĩnh */
  --canh-bao:  #C0392B;     /* đỏ chỉ dành cho quá hạn / vượt mức */
  --canh-bao-bg:#FBEEEC;
  --luu-y:     #9A6A00;
  --luu-y-bg:  #FBF3E0;

  /* --- Bo góc: lớn và mềm --- */
  --r-sm: 10px;
  --r:    14px;
  --r-lg: 20px;
  --r-xl: 26px;

  --shadow-sm: 0 1px 2px rgba(22,23,26,.04);
  --shadow:    0 8px 24px -8px rgba(22,23,26,.10);
  --shadow-lg: 0 32px 64px -16px rgba(22,23,26,.22);

  --sidebar-w: 244px;

  /* --- Chữ: SF Pro của hệ thống, đúng thứ app Apple dùng --- */
  --ff: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
        "Inter", "Segoe UI", Roboto, sans-serif;
  /* Chữ số: dạng bảng, khoảng cách siết lại — nét đặc trưng của app tài chính */
  --ff-num: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
            "Inter", "Segoe UI", Roboto, sans-serif;
}

html[data-theme="dark"] {
  --bg:        #0A0A0B;
  --surface:   #151517;
  --surface-2: #1C1C1F;
  --surface-3: #232326;
  --border:    #26262A;
  --hairline:  #1E1E21;

  --text:      #F3F3F4;
  --text-2:    #A6AAB1;
  --muted:     #74777D;

  --ink:       #F3F3F4;
  --ink-text:  #0A0A0B;
  --active-bg: #232326;

  --thu:       #3ECF8E;
  --thu-bg:    #0D2B1F;
  --chi:       #F3F3F4;
  --canh-bao:  #FF6B5E;
  --canh-bao-bg:#2C1310;
  --luu-y:     #E8B44C;
  --luu-y-bg:  #2A2011;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.5);
  --shadow:    0 8px 24px -8px rgba(0,0,0,.6);
  --shadow-lg: 0 32px 64px -16px rgba(0,0,0,.75);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--ff);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  letter-spacing: -.008em;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1,h2,h3,h4 { margin: 0; font-weight: 600; letter-spacing: -.022em; }
button, input, select, textarea { font: inherit; color: inherit; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em;
       background: var(--surface-2); padding: 1.5px 5px; border-radius: 5px; }
kbd { font-family: var(--ff); font-size: 10px; padding: 1.5px 5px; border-radius: 4px;
      background: rgba(255,255,255,.16); margin-left: 6px; opacity: .8; }

/* Chữ số kiểu app tài chính: bề rộng đều, tracking siết */
.num, .kpi-value, .hero-value, .networth-value, .tx-amt, .rule-val, .amount-wrap input {
  font-family: var(--ff-num);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "ss01" 1;
}

/* ============ BỐ CỤC ============ */
.app { display: flex; min-height: 100%; }

.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--bg);
  border-right: 1px solid var(--hairline);
  padding: 22px 12px 18px;
  display: flex; flex-direction: column; gap: 26px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  object-fit: cover; display: block;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15px; font-weight: 600; letter-spacing: -.02em; }
.brand-text span { font-size: 11.5px; color: var(--muted); letter-spacing: 0; }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text-2);
  font-size: 14px; font-weight: 450; text-align: left; cursor: pointer;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.is-active { background: var(--active-bg); color: var(--text); font-weight: 550; }
.nav-ico { width: 17px; text-align: center; font-size: 13px; opacity: .75; }
.nav-item.is-active .nav-ico { opacity: 1; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; }
.hint { font-size: 11px; color: var(--muted); padding: 8px 10px 0; line-height: 1.5; letter-spacing: 0; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 32px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.8) blur(16px);
}
.month-nav { display: flex; align-items: center; gap: 1px; }
.month-label {
  border: 0; background: transparent; cursor: pointer;
  font-size: 17px; font-weight: 600; letter-spacing: -.025em;
  padding: 6px 10px; border-radius: var(--r-sm); color: var(--text);
}
.month-label:hover { background: var(--surface-2); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  border: 0; background: transparent; color: var(--text-2);
  cursor: pointer; font-size: 16px; line-height: 1; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.views { padding: 8px 32px 72px; max-width: 1180px; }
.view { display: none; }
.view.is-active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } }

/* ============ THÀNH PHẦN ============ */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 8.5px 15px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-size: 13.5px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, opacity .12s, transform .06s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn-sm { padding: 6.5px 11px; font-size: 12.5px; border-radius: 9px; }
/* Nút chính là màu mực — màu sắc để dành cho dữ liệu */
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--ink-text); font-weight: 500; }
.btn-primary:hover { background: var(--ink); opacity: .88; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--canh-bao); }
.btn-danger-ghost:hover { background: var(--canh-bao-bg); }

.card {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); padding: 22px;
}
html[data-theme="light"] .card, :root .card { box-shadow: var(--shadow-sm); }
html[data-theme="dark"] .card { box-shadow: none; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.card-title { font-size: 15px; font-weight: 600; letter-spacing: -.02em; }
.card-sub { font-size: 12.5px; color: var(--muted); letter-spacing: 0; line-height: 1.5; }

.grid { display: grid; gap: 14px; }
.grid-kpi { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: 1.2fr .8fr; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.section-gap { margin-top: 14px; }

/* Tiêu đề nhóm giữa các mục — kiểu Copilot */
.group-title {
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  letter-spacing: 0; margin: 26px 2px 10px;
}

/* --- Thẻ chính của màn Hôm nay --- */
.hero { padding: 26px; }
.hero-label { font-size: 13px; color: var(--muted); font-weight: 450; }
.hero-value { font-size: 42px; font-weight: 600; letter-spacing: -.04em; line-height: 1.05; margin-top: 6px; }
.hero-value small { font-size: 21px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.hero-meta { margin-top: 12px; font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.compare { margin-top: 20px; display: flex; flex-direction: column; gap: 9px; }
.compare-row { display: flex; align-items: center; gap: 12px; font-size: 12.5px; }
.compare-name { width: 96px; flex: none; color: var(--muted); }
.compare-track { flex: 1; height: 7px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.compare-fill { height: 100%; border-radius: 99px; transition: width .45s cubic-bezier(.2,.7,.3,1); }
.compare-val { width: 104px; flex: none; text-align: right; font-weight: 550; }

/* KPI nhỏ */
.kpi-label { font-size: 12.5px; font-weight: 450; color: var(--muted); letter-spacing: 0; }
.kpi-value { font-size: 26px; font-weight: 600; letter-spacing: -.033em; margin-top: 7px; line-height: 1.1; }
.kpi-value small { font-size: 15px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.kpi-foot { margin-top: 9px; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 7px; letter-spacing: 0; }
.kpi.thu .kpi-value { color: var(--thu); }
.kpi.chi .kpi-value { color: var(--chi); }

.delta { font-weight: 550; padding: 2px 7px; border-radius: 99px; font-size: 11.5px; letter-spacing: 0; }
.delta.up { color: var(--canh-bao); background: var(--canh-bao-bg); }
.delta.down { color: var(--thu); background: var(--thu-bg); }
.delta.flat { color: var(--muted); background: var(--surface-2); }

/* --- Cần chú ý (kiểu "Needs review" của Copilot) --- */
.alert {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--hairline);
  font-size: 13px; color: var(--text-2); line-height: 1.55; cursor: pointer;
  transition: background .12s;
}
.alert:hover { background: var(--surface-2); }
.alert b { color: var(--text); font-weight: 600; }
.alert-ico {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-size: 14px;
}
.alert.warn .alert-ico { background: var(--canh-bao-bg); }
.alert.note .alert-ico { background: var(--luu-y-bg); }
.alert-go { margin-left: auto; color: var(--muted); font-size: 15px; align-self: center; }

/* --- Quy tắc 10/70/20 --- */
.rule-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--hairline); }
.rule-row:last-child { border-bottom: 0; padding-bottom: 2px; }
.rule-name { width: 136px; flex: none; font-size: 13.5px; font-weight: 500; }
.rule-name small { display: block; font-weight: 400; color: var(--muted); font-size: 11.5px; letter-spacing: 0; }
.rule-bar { flex: 1; height: 7px; border-radius: 99px; background: var(--surface-2); position: relative; overflow: hidden; }
.rule-fill { position: absolute; inset: 0 auto 0 0; border-radius: 99px; transition: width .45s cubic-bezier(.2,.7,.3,1); }
.rule-target { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); opacity: .28; border-radius: 2px; }
.rule-val { width: 128px; flex: none; text-align: right; font-size: 13.5px; font-weight: 600; }
.rule-val small { display: block; font-weight: 400; font-size: 11.5px; color: var(--muted); letter-spacing: 0; }

/* --- Danh mục: biểu tượng tròn màu, kiểu Copilot --- */
.cat-row { display: flex; align-items: center; gap: 13px; padding: 10px 0; }
.cat-ico {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-size: 15px; background: var(--surface-2);
}
.cat-main { flex: 1; min-width: 0; }
.cat-name { font-size: 14px; font-weight: 450; display: flex; justify-content: space-between; gap: 12px; }
.cat-name span:last-child { font-weight: 550; }
.cat-track { height: 5px; border-radius: 99px; background: var(--surface-2); margin-top: 7px; overflow: hidden; }
.cat-fill { height: 100%; border-radius: 99px; transition: width .45s cubic-bezier(.2,.7,.3,1); }
.cat-pct { font-size: 11.5px; color: var(--muted); margin-top: 5px; letter-spacing: 0; }

/* Hàng danh mục có hạn mức */
.budget-row { display: flex; align-items: center; gap: 13px; padding: 12px 0; cursor: pointer; border-radius: var(--r); }
.budget-row:hover { background: var(--surface-2); margin: 0 -12px; padding: 12px; }
.budget-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 11.5px; color: var(--muted); margin-top: 5px; letter-spacing: 0; }
.budget-meta .over { color: var(--canh-bao); font-weight: 550; }

/* --- Giao dịch --- */
.tx-list { display: flex; flex-direction: column; }
.tx-day { padding: 16px 0 6px; font-size: 12.5px; font-weight: 550; color: var(--muted);
          letter-spacing: 0; display: flex; justify-content: space-between; }
.tx {
  display: flex; align-items: center; gap: 13px; padding: 10px 12px; margin: 0 -12px;
  border-radius: var(--r); cursor: pointer; transition: background .1s;
}
.tx:hover { background: var(--surface-2); }
.tx-main { flex: 1; min-width: 0; }
.tx-title { font-size: 14px; font-weight: 450; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0; }
.tx-amt { font-size: 14.5px; font-weight: 550; white-space: nowrap; }
.tx-amt.thu { color: var(--thu); }
.tx-amt.chi { color: var(--chi); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 11px; padding: 3px; gap: 2px; }
.seg-btn {
  border: 0; background: transparent; color: var(--text-2); cursor: pointer;
  padding: 6px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
}
.seg-btn.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 550; }
.seg-lg { display: flex; width: 100%; }
.seg-lg .seg-btn { padding: 10px 0; flex: 1; font-size: 14px; }
.seg-lg .seg-btn[data-type="thu"].is-active,
.seg-lg .seg-btn[data-ben="phai-thu"].is-active { color: var(--thu); }

.input, select.input {
  padding: 8.5px 12px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface); font-size: 13.5px; min-width: 0;
}
.input:focus { outline: 2px solid color-mix(in srgb, var(--ink) 22%, transparent);
               outline-offset: 1px; border-color: var(--text-2); }
.search { flex: 1; min-width: 170px; }

/* --- Trạng thái trống --- */
.empty { text-align: center; padding: 52px 20px; color: var(--muted); }
.empty-emoji { font-size: 32px; margin-bottom: 12px; opacity: .8; }
.empty h3 { font-size: 15.5px; color: var(--text); margin-bottom: 7px; }
.empty p { margin: 0 auto 18px; max-width: 400px; font-size: 13.5px; line-height: 1.65; letter-spacing: 0; }

/* --- Nhận xét --- */
.insights { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: 12px; }
.insight {
  display: flex; gap: 11px; align-items: flex-start; padding: 14px 16px;
  border: 1px solid var(--hairline); border-radius: var(--r); background: var(--surface);
  font-size: 13px; color: var(--text-2); line-height: 1.55; letter-spacing: 0;
}
.insight b { color: var(--text); font-weight: 600; }
.insight-ico { font-size: 15px; line-height: 1.2; }

/* --- Thẻ dẫn sang màn khác (dùng trên điện thoại) --- */
.link-card {
  display: flex; align-items: center; gap: 13px; width: 100%; text-align: left;
  padding: 16px 18px; border-radius: var(--r-lg);
  border: 1px solid var(--hairline); background: var(--surface); cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--text);
}
.link-card:hover { background: var(--surface-2); }
.link-card small { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; letter-spacing: 0; }
.link-card .arrow { margin-left: auto; color: var(--muted); }

/* --- Cài đặt --- */
.set-row { display: flex; align-items: center; gap: 16px; padding: 15px 0; border-bottom: 1px solid var(--hairline); }
.set-row:last-child { border-bottom: 0; padding-bottom: 2px; }
.set-main { flex: 1; }
.set-title { font-size: 14px; font-weight: 500; }
.set-desc { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.55; letter-spacing: 0; }
.chip-list { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px;
  border: 1px solid var(--border); border-radius: 99px; background: var(--surface);
  font-size: 13px; cursor: pointer;
}
.chip:hover { background: var(--surface-2); }
.tag { font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 6px;
       background: var(--surface-2); color: var(--muted); letter-spacing: 0; }
.tag-warn { background: var(--canh-bao-bg); color: var(--canh-bao); margin-left: 7px; }

/* --- Giá trị ròng --- */
.networth { padding: 26px; }
.networth-value { font-size: 42px; font-weight: 600; letter-spacing: -.04em; line-height: 1.05; margin-top: 6px; }
.networth-value small { font-size: 21px; font-weight: 500; color: var(--muted); }
.networth-parts { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 16px; font-size: 13px; color: var(--text-2); letter-spacing: 0; }
.networth-parts span { display: inline-flex; align-items: center; gap: 7px; }
.networth-parts i { width: 8px; height: 8px; border-radius: 50%; }

/* --- Ghi nhận thanh toán --- */
.pay-box { border: 1px solid var(--border); border-radius: var(--r); padding: 14px 16px; background: var(--surface-2); }
.pay-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }
.pay-head b { font-size: 15.5px; }
.pay-body { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 11px; }
.pay-body input {
  padding: 9.5px 12px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface); font-size: 14px; width: 100%; min-width: 0;
  font-variant-numeric: tabular-nums;
}
.pay-note { font-size: 11.5px; color: var(--muted); margin-top: 10px; line-height: 1.55; letter-spacing: 0; }

.banner {
  display: flex; gap: 11px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r);
  background: var(--luu-y-bg); color: var(--text); font-size: 13px; line-height: 1.6;
  letter-spacing: 0; margin-bottom: 14px;
}

/* ============ CỬA SỔ ============ */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10,10,12,.4); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 24px;
  animation: fade .15s ease;
}
.sheet {
  width: 100%; max-width: 470px; max-height: 92vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
  animation: pop .2s cubic-bezier(.2,.8,.3,1);
}
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.985); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between;
              padding: 20px 22px 14px; }
.sheet-head h2 { font-size: 17px; font-weight: 600; }
.sheet-body { padding: 4px 22px 22px; display: flex; flex-direction: column; gap: 16px; }
.sheet-foot { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.spacer { flex: 1; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-label { font-size: 12.5px; font-weight: 500; color: var(--text-2); letter-spacing: 0; }
.field-hint { font-size: 11.5px; color: var(--muted); letter-spacing: 0; }
.field input[type="text"], .field input[type="date"], .field input[type="number"] {
  padding: 10px 12px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface-2); font-size: 14.5px; width: 100%;
}
.field input:focus { outline: 2px solid color-mix(in srgb, var(--ink) 22%, transparent);
                     outline-offset: 1px; border-color: var(--text-2); background: var(--surface); }
.amount-wrap { position: relative; }
.amount-wrap input {
  font-size: 28px !important; font-weight: 600; letter-spacing: -.035em;
  padding: 13px 42px 13px 14px !important;
}
.amount-cur { position: absolute; right: 15px; top: 50%; transform: translateY(-50%);
              color: var(--muted); font-size: 18px; font-weight: 500; }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px,1fr)); gap: 7px; }
.cat-pick {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 11px 5px; border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface-2); cursor: pointer; font-size: 11.5px; text-align: center;
  color: var(--text-2); line-height: 1.3; transition: border-color .12s, background .12s;
}
.cat-pick i { font-style: normal; font-size: 18px; }
.cat-pick:hover { background: var(--surface); border-color: var(--text-2); }
.cat-pick.is-active { border-color: var(--ink); background: var(--surface); color: var(--text); font-weight: 550; }
.cat-pick.is-new { border-style: dashed; background: transparent; }

.cat-new { grid-column: 1 / -1; display: grid; grid-template-columns: 62px 1fr auto auto; gap: 7px; align-items: center; }
.cat-new input {
  padding: 10px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface-2); font-size: 14px; width: 100%; min-width: 0;
}
.cat-new input:first-child { text-align: center; }
.cat-new input:focus { outline: 2px solid color-mix(in srgb, var(--ink) 22%, transparent);
                       outline-offset: 1px; border-color: var(--text-2); background: var(--surface); }

.cat-empty {
  font-size: 13px; color: var(--muted); line-height: 1.65; text-align: center;
  padding: 18px 20px; border: 1px dashed var(--border); border-radius: var(--r);
  letter-spacing: 0;
}

/* ============ THANH TAB TRÊN ĐIỆN THOẠI ============ */
.tabbar { display: none; }

/* ============ THÔNG BÁO NGẮN ============ */
.toast-wrap { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
              z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--ink); color: var(--ink-text); padding: 10px 18px; border-radius: 99px;
  font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-lg);
  animation: toastIn .22s cubic-bezier(.2,.8,.3,1);
}
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } }

/* ============ BIỂU ĐỒ ============ */
.chart { width: 100%; display: block; overflow: visible; }
.legend { display: flex; flex-direction: column; gap: 1px; }
.legend-row { display: flex; align-items: center; gap: 10px; font-size: 13px; padding: 4px 0; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.legend-name { flex: 1; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend-val { font-weight: 550; }

/* ============ MÀN HÌNH NHỎ ============ */
/* Trên máy tính đã có Cài đặt ở thanh bên — bỏ nút bánh răng cho gọn */
@media (min-width: 781px) { #btn-settings { display: none; } }

@media (max-width: 980px) {
  .grid-kpi { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
  body { font-size: 15px; }
  .sidebar { display: none; }
  .topbar { padding: 12px 18px; }
  .views { padding: 4px 18px 104px; }
  .hero, .networth { padding: 22px; }
  .hero-value, .networth-value { font-size: 36px; }
  .field-row { grid-template-columns: 1fr; }
  .overlay { padding: 0; align-items: flex-end; }
  .sheet { max-width: 100%; max-height: 94vh; border-radius: var(--r-xl) var(--r-xl) 0 0; }
  .rule-name { width: 120px; }
  .rule-val { width: 110px; }
  /* Thanh dưới đã có nút ＋ — bỏ nút ở thanh trên để tháng không bị xuống dòng */
  #btn-add { display: none; }
  .compare-name { width: 74px; }
  .compare-val { width: 96px; font-size: 12px; }
  .month-label { font-size: 16px; }

  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(1.8) blur(18px);
    border-top: 1px solid var(--hairline);
    padding: 7px 6px calc(7px + env(safe-area-inset-bottom));
  }
  .tab {
    flex: 1; min-width: 0; border: 0; background: transparent; color: var(--muted); cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    font-size: 10.5px; font-weight: 500; padding: 5px 1px; border-radius: 10px;
    white-space: nowrap; letter-spacing: 0;
  }
  .tab span { font-size: 16px; }
  .tab.is-active { color: var(--text); font-weight: 600; }
  .tab-add {
    flex: 0 0 50px; height: 42px; margin: 0 5px; align-self: center;
    background: var(--ink); color: var(--ink-text); font-size: 21px; border-radius: 13px;
    justify-content: center; box-shadow: var(--shadow);
  }
  .toast-wrap { bottom: 92px; }
}

@media print {
  .sidebar, .topbar, .tabbar, .toast-wrap { display: none !important; }
  .views { padding: 0; }
  .card { break-inside: avoid; box-shadow: none; }
}

/* ============ ẢNH HOÁ ĐƠN ============ */
.anh-them {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  padding: 18px; border: 1px dashed var(--border); border-radius: var(--r);
  background: var(--surface-2); cursor: pointer; color: var(--text-2);
  font-size: 13.5px; transition: border-color .12s, background .12s;
}
.anh-them:hover { border-color: var(--text-2); background: var(--surface); }
.anh-them-ico { font-size: 17px; }

.anh-xem { display: flex; gap: 13px; align-items: center; }
.anh-xem img {
  width: 78px; height: 78px; flex: none; object-fit: cover;
  border-radius: var(--r); border: 1px solid var(--border); cursor: zoom-in;
  background: var(--surface-2);
}
.anh-thongtin { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 9px; }
.anh-thongtin > span { font-size: 12.5px; color: var(--muted); letter-spacing: 0; }
.anh-nut { display: flex; gap: 7px; flex-wrap: wrap; }

/* Dấu cho biết giao dịch có ảnh kèm theo */
.tx-kep { color: var(--muted); font-size: 11px; margin-left: 7px; vertical-align: 1px; }

/* Lớp xem ảnh to — phải nằm trên cửa sổ ghi giao dịch (z-index 100) */
.anh-overlay { background: #08080A; padding: 0; z-index: 150; backdrop-filter: none; }
.anh-overlay img {
  max-width: 100%; max-height: 100vh; object-fit: contain; display: block;
}
.anh-dong {
  position: fixed; top: calc(14px + env(safe-area-inset-top)); right: 14px; z-index: 2;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,.14); color: #fff; backdrop-filter: blur(8px);
}
.anh-dong:hover { background: rgba(255,255,255,.24); color: #fff; }
