/* ============================================================
   Quản lý chi tiêu — Mobile-first, tone xanh đá / đen
   Sáng/Tối điều khiển bằng data-theme trên <html>
   ============================================================ */

:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:          #0a0e16;
  --bg-grad:     radial-gradient(900px 480px at 15% -10%, #10202b 0%, transparent 55%),
                 radial-gradient(800px 420px at 110% 0%, #0f2a2a 0%, transparent 50%);
  --surface:     #121926;
  --surface-2:   #1a2433;
  --surface-3:   #212e40;
  --border:      #26344a;
  --text:        #e2e9f2;
  --muted:       #8698ad;
  --primary:     #14b8a6;
  --primary-2:   #0d9488;
  --primary-ink: #04211d;
  --income:      #34d399;
  --expense:     #fb7185;
  --shadow:      0 10px 30px -12px rgba(0,0,0,.6);
  --ring:        rgba(20,184,166,.35);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg:          #eaeef3;
  --bg-grad:     radial-gradient(900px 480px at 15% -10%, #dbe7ec 0%, transparent 55%),
                 radial-gradient(800px 420px at 110% 0%, #d7ecea 0%, transparent 50%);
  --surface:     #ffffff;
  --surface-2:   #f3f6f9;
  --surface-3:   #e9eef4;
  --border:      #d6dee8;
  --text:        #0f1e2e;
  --muted:       #5b6d81;
  --primary:     #0d9488;
  --primary-2:   #0f766e;
  --primary-ink: #ffffff;
  --income:      #059669;
  --expense:     #e11d48;
  --shadow:      0 12px 28px -16px rgba(15,30,46,.35);
  --ring:        rgba(13,148,136,.30);
}

* { box-sizing: border-box; }
html { margin: 0; padding: 0; -webkit-text-size-adjust: 100%; }

/* Hiệu ứng vòng tròn tỏa ra khi đổi sáng/tối (View Transitions) */
::view-transition-old(root),
::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { z-index: 9999; }
::view-transition-old(root) { z-index: 1; }
body {
  margin: 0; padding: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
  overflow-x: hidden;   /* chỉ chặn tràn ngang ở body, KHÔNG đặt trên <html> để tránh khoá cuộn dọc trên iOS */
}
img, svg { max-width: 100%; }

/* ---- Scrollbar mảnh, đồng màu ---- */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ---- Icon ---- */
.ico {
  width: 18px; height: 18px; flex: none; vertical-align: -3px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.ico.lg { width: 22px; height: 22px; }

/* ============================================================
   HEADER
   ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: var(--primary-ink); box-shadow: 0 4px 14px -4px var(--primary);
}
.brand .logo .ico { width: 20px; height: 20px; stroke-width: 2.2; }
.brand h1 { font-size: 16px; margin: 0; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Nút tròn trong header */
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  display: inline-grid; place-items: center; cursor: pointer; padding: 0;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
}
.icon-btn .ico { width: 21px; height: 21px; }
.icon-btn:hover { background: var(--surface-3); filter: none; }
.icon-btn:active { transform: scale(.94); }
/* Nút xoá màu đỏ */
.icon-btn.del { color: var(--expense); border-color: color-mix(in srgb, var(--expense) 35%, var(--border)); }
.icon-btn.del:hover { background: color-mix(in srgb, var(--expense) 15%, transparent); border-color: var(--expense); }
:root[data-theme="light"] [data-theme-toggle] .ico-sun { display: none; }
:root[data-theme="dark"]  [data-theme-toggle] .ico-moon { display: none; }

/* Menu người dùng */
.menu-wrap { position: relative; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60;
  min-width: 200px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow); padding: 8px; display: none;
}
.menu-panel.open { display: block; }
.menu-panel .who { padding: 8px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu-panel .who .name { font-weight: 700; }
.menu-panel .who .role { font-size: 12px; color: var(--muted); }
.menu-panel button {
  width: 100%; justify-content: flex-start; background: transparent; color: var(--text);
  padding: 10px; border-radius: 10px;
}
.menu-panel button:hover { background: var(--surface-2); filter: none; }
.role-tag.admin { color: var(--primary); font-weight: 700; }

/* ============================================================
   NAV (tabs) — trên desktop nằm trên, trên mobile là bottom-nav
   ============================================================ */
.nav {
  display: flex; gap: 4px; z-index: 45;
  background: var(--surface);
}
.nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: transparent; color: var(--muted); border: none; cursor: pointer;
  padding: 8px 4px; font-size: 11px; font-weight: 600; border-radius: 12px;
}
.nav button .ico { width: 22px; height: 22px; }
.nav button.active { color: var(--primary); }
.nav button { position: relative; }
.nav-badge {
  position: absolute; top: 2px; right: 10px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--expense); color: #fff; font-size: 10px; font-weight: 800;
  display: grid; place-items: center; line-height: 1; box-shadow: 0 0 0 2px var(--surface);
}
@media (min-width: 720px) { .nav-badge { top: 4px; right: 8px; } }

@media (max-width: 719px) {
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0;
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(env(safe-area-inset-bottom) + 6px); gap: 2px;
    box-shadow: 0 -8px 24px -12px rgba(0, 0, 0, .35);
  }
  .nav button { font-size: 10px; padding: 7px 2px; white-space: nowrap; }
  .nav button .ico { width: 20px; height: 20px; }
  .nav button.active { background: color-mix(in srgb, var(--primary) 14%, transparent); }
}

/* ============================================================
   LAYOUT
   ============================================================ */
.container {
  max-width: 1040px; margin: 0 auto;
  padding: 16px 14px calc(env(safe-area-inset-bottom) + 110px);
}
@media (min-width: 720px) {
  .topbar { height: 62px; padding: 0 24px; }
  .nav {
    position: sticky; top: 62px; margin: 0; padding: 8px 24px; gap: 6px;
    border-bottom: 1px solid var(--border); justify-content: center;
  }
  .nav button {
    flex: 0 0 auto; flex-direction: row; gap: 8px; font-size: 14px; padding: 10px 18px; min-width: 132px;
    border: 1px solid transparent;
  }
  .nav button:hover { background: var(--surface-2); }
  .nav button.active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: var(--primary-ink); }
  .nav button.active .ico { stroke: var(--primary-ink); }
  .container { padding: 24px 24px 48px; }
}

/* ---- Cards ---- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card .hint { color: var(--muted); font-size: 13px; margin: -4px 0 12px; }
.section-title { font-size: 13px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .6px; margin: 4px 2px 10px; }

/* ---- Tiles ---- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.tiles .tile.full { grid-column: 1 / -1; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 14px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.tile::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: linear-gradient(var(--primary), var(--primary-2)); }
.tile.income::before { background: linear-gradient(var(--income), var(--income)); }
.tile.expense::before { background: linear-gradient(var(--expense), var(--expense)); }
.tile .label { color: var(--muted); font-size: 12.5px; }
.tile .value { font-size: 21px; font-weight: 800; margin-top: 5px; letter-spacing: -.3px; }
.tile .value.income { color: var(--income); }
.tile .value.expense { color: var(--expense); }
@media (min-width: 560px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .tiles .tile.full { grid-column: auto; }
}
/* Tổng quan admin chỉ có 2 ô -> chia đôi full chiều rộng cho cân */
#dashAdmin .tiles { grid-template-columns: 1fr 1fr; }

/* ---- Form ---- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
@media (min-width: 560px) { .form-grid { grid-template-columns: repeat(2, 1fr); } }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; padding: 12px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }

/* Select tuỳ biến: bỏ mũi tên mặc định, thêm chevron riêng */
select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237c8aa0' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; background-size: 16px;
}
select:hover { border-color: var(--muted); }

/* Date input: canh icon lịch theo màu chủ đạo */
input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .7; }
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 1; }

/* Checkbox tuỳ biến */
input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 22px; height: 22px; padding: 0; border-radius: 7px; flex: none;
  border: 1px solid var(--border); background: var(--surface-2); cursor: pointer;
  display: inline-grid; place-content: center; transition: background .15s, border-color .15s;
}
input[type="checkbox"]:checked {
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); border-color: transparent;
}
input[type="checkbox"]:checked::after {
  content: ""; width: 6px; height: 11px; margin-top: -2px;
  border: solid var(--primary-ink); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
input[type="checkbox"]:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring); }
.amount-preview { font-size: 13px; color: var(--primary); font-weight: 700; margin-top: 6px; min-height: 16px; }
.form-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.switch { display: flex; align-items: center; gap: 10px; }
.switch input { width: auto; flex: none; }

/* ---- Buttons ---- */
button, .btn {
  font: inherit; font-weight: 600; font-size: 15px; cursor: pointer; border: none; border-radius: 12px;
  padding: 12px 16px; color: var(--primary-ink); line-height: 1;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .08s, filter .15s;
}
button:hover, .btn:hover { filter: brightness(1.07); }
button:active { transform: translateY(1px); }
button.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
button.ghost:hover { background: var(--surface-3); filter: none; }
button.danger { background: linear-gradient(135deg, #f43f5e, #e11d48); color: #fff; }
button.small { padding: 8px 12px; font-size: 13px; }
button.block { width: 100%; }

/* ---- Badges ---- */
.badge { padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.badge.income { background: color-mix(in srgb, var(--income) 18%, transparent); color: var(--income); }
.badge.expense { background: color-mix(in srgb, var(--expense) 18%, transparent); color: var(--expense); }
.badge.method { background: var(--surface-3); color: var(--muted); }
.badge.role { background: var(--surface-3); color: var(--muted); }
.badge.role.admin { background: color-mix(in srgb, var(--primary) 18%, transparent); color: var(--primary); }
.badge.lock { background: color-mix(in srgb, #f59e0b 20%, transparent); color: #f59e0b; margin-left: 6px; vertical-align: middle; }
.badge.lock .ico { width: 12px; height: 12px; }

/* ---- Transaction list (card) ---- */
.tx-list { display: flex; flex-direction: column; gap: 10px; }
.tx-item {
  display: grid; grid-template-columns: 42px 1fr auto; gap: 12px; align-items: center;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 11px 12px;
}
.tx-avatar { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; }
.tx-avatar.income { background: color-mix(in srgb, var(--income) 16%, transparent); color: var(--income); }
.tx-avatar.expense { background: color-mix(in srgb, var(--expense) 16%, transparent); color: var(--expense); }
.tx-main { min-width: 0; }
.tx-cat { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.tx-note { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.tx-amount { font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tx-amount.income { color: var(--income); }
.tx-amount.expense { color: var(--expense); }
.tx-actions { display: flex; gap: 4px; }
.tx-actions .icon-btn { width: 30px; height: 30px; border-radius: 9px; }
.tx-actions .icon-btn .ico { width: 15px; height: 15px; }

/* ---- User list (admin tổng quan) ---- */
.user-list { display: flex; flex-direction: column; gap: 10px; }
.user-row {
  display: grid; grid-template-columns: 44px 1fr auto 20px; gap: 12px; align-items: center;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px;
  cursor: pointer; transition: border-color .12s, transform .08s;
}
.user-row:hover { border-color: var(--primary); }
.user-row:active { transform: scale(.995); }
.u-avatar { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--primary) 15%, transparent); color: var(--primary); }
.u-info { min-width: 0; }
.u-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.u-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.u-bal { text-align: right; }
.u-bal .n { font-weight: 800; font-variant-numeric: tabular-nums; }
.u-bal .n.income { color: var(--income); }
.u-bal .n.expense { color: var(--expense); }
.u-bal .t { font-size: 11px; color: var(--muted); }
.u-chev { color: var(--muted); display: grid; place-items: center; }

/* ---- Table (thống kê) ---- */
.table-wrap { overflow-x: auto; border-radius: 12px; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 11px 8px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
thead th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
tbody tr:last-child td { border-bottom: none; }
td.amount, th.amount { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
td.amount.income { color: var(--income); }
td.amount.expense { color: var(--expense); }

/* Kỳ hiện tại (highlight) */
tbody tr.current td { background: color-mix(in srgb, var(--primary) 14%, transparent); }
tbody tr.current td:first-child { font-weight: 800; color: var(--primary); border-left: 3px solid var(--primary); }

/* ---- Upload ảnh ---- */
.upload-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; margin-top: 10px; }
.up-item { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.up-item img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: pointer; }
.up-del { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 8px; padding: 0; background: rgba(0,0,0,.6); color: #fff; display: grid; place-items: center; }
.up-del .ico { width: 15px; height: 15px; }

/* ---- Modal ảnh ---- */
.modal { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.8); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal.hidden { display: none; }
.modal-inner { position: relative; max-width: 900px; width: 100%; max-height: 90vh; overflow-y: auto; }
.modal-close { position: absolute; top: 6px; right: 6px; z-index: 2; background: rgba(0,0,0,.6); color: #fff; border-color: transparent; }
.modal-body-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.modal-body-grid img { width: 100%; border-radius: 12px; display: block; }

/* ---- Yêu cầu / báo cáo (list rows) ---- */
.list-item { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
.list-item .li-top { display: flex; align-items: center; gap: 8px; justify-content: space-between; flex-wrap: wrap; }
.list-item .li-title { font-weight: 700; }
.list-item .li-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.list-item .li-amount { font-weight: 800; white-space: nowrap; }
.list-item .li-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.badge.pending { background: color-mix(in srgb, #f59e0b 20%, transparent); color: #f59e0b; }
.badge.approved { background: color-mix(in srgb, var(--income) 18%, transparent); color: var(--income); }
.badge.rejected { background: color-mix(in srgb, var(--expense) 18%, transparent); color: var(--expense); }
.btn-approve { background: linear-gradient(135deg, var(--income), #059669); color: #fff; }
.btn-reject { background: linear-gradient(135deg, #f43f5e, #e11d48); color: #fff; }

/* ---- Segmented control ---- */
.segment { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 14px; }
.segment button { background: transparent; color: var(--muted); padding: 8px 16px; border-radius: 9px; font-size: 14px; }
.segment button.active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: var(--primary-ink); }

/* ---- Donut + legend ---- */
.donut-wrap { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.donut { position: relative; flex: none; margin: 0 auto; }
.donut .center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.donut .center .c-label { font-size: 11px; color: var(--muted); }
.donut .center .c-value { font-size: 17px; font-weight: 800; }
.legend { display: flex; flex-direction: column; gap: 9px; flex: 1; min-width: 200px; }
.legend-item { display: flex; align-items: center; gap: 9px; font-size: 13.5px; }
.legend-dot { width: 11px; height: 11px; border-radius: 4px; flex: none; }
.legend-cat { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend-pct { color: var(--muted); font-variant-numeric: tabular-nums; }
.legend-val { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---- Dropdown tuỳ biến ---- */
.dd { position: relative; width: 100%; }
.dd-btn {
  width: 100%; justify-content: space-between; text-align: left;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  padding: 12px 14px; border-radius: 12px; font-weight: 600; font-size: 16px; line-height: 1.5;
}
.dd-btn .dd-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-btn:hover { filter: none; border-color: var(--muted); }
.dd-btn .chev { color: var(--muted); transition: transform .18s; }
.dd.open .dd-btn { border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
.dd.open .dd-btn .chev { transform: rotate(180deg); }
.dd-menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 35;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px; display: none; max-height: 300px; overflow-y: auto;
}
.dd.open .dd-menu { display: block; animation: ddin .12s ease; }
@keyframes ddin { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.dd-item {
  width: 100%; justify-content: space-between; text-align: left;
  background: transparent; color: var(--text); padding: 11px 12px; border-radius: 9px;
  font-weight: 600; font-size: 15px;
}
.dd-item:hover { background: var(--surface-2); filter: none; }
.dd-item.selected { background: color-mix(in srgb, var(--primary) 16%, transparent); color: var(--primary); }
.dd-item .tick { opacity: 0; width: 16px; height: 16px; }
.dd-item.selected .tick { opacity: 1; }

/* ---- Date picker tuỳ biến ---- */
.dp { position: relative; width: 100%; }
.dp-btn {
  width: 100%; justify-content: space-between; text-align: left;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  padding: 12px 14px; border-radius: 12px; font-weight: 600; font-size: 16px; line-height: 1.5;
}
.dp-btn:hover { filter: none; border-color: var(--muted); }
.dp-btn .ico { color: var(--muted); }
.dp-btn .dp-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-btn .dp-label.dp-empty { color: var(--muted); font-weight: 500; }
.dp.open .dp-btn { border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
.dp-pop {
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 40;
  width: 288px; max-width: calc(100vw - 40px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); padding: 12px; display: none;
}
.dp.open .dp-pop { display: block; animation: ddin .12s ease; }
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.dp-title { font-weight: 700; }
.dp-navs { display: flex; gap: 4px; }
.dp-nav { width: 32px; height: 32px; padding: 0; border-radius: 9px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); display: grid; place-items: center; }
.dp-nav:hover { background: var(--surface-3); filter: none; }
.dp-nav .ico { width: 16px; height: 16px; }
.dp-wd { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 4px; }
.dp-wd span { text-align: center; font-size: 11px; color: var(--muted); padding: 4px 0; min-width: 0; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-day { height: 36px; min-width: 0; padding: 0; border-radius: 9px; background: transparent; color: var(--text); border: none; font-size: 14px; font-weight: 500; display: grid; place-items: center; }
.dp-day.empty { background: transparent; pointer-events: none; }
.dp-day:hover { background: var(--surface-2); filter: none; }
.dp-day.today { color: var(--primary); font-weight: 800; }
.dp-day.sel { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: var(--primary-ink); }
.dp-foot { display: flex; justify-content: space-between; margin-top: 10px; }
.dp-foot button { background: transparent; color: var(--primary); padding: 6px 8px; font-size: 13px; }
.dp-foot button:hover { filter: none; text-decoration: underline; }

/* ---- Line chart ---- */
.chart-legend { display: flex; gap: 18px; margin: 4px 0 12px; font-size: 13px; color: var(--muted); }
.cl-item { display: inline-flex; align-items: center; gap: 7px; }
.cl-dot { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.cl-dot.income { background: var(--income); }
.cl-dot.expense { background: var(--expense); }
.linechart { width: 100%; overflow-x: auto; }
.linechart svg { display: block; width: 100%; height: auto; min-width: 340px; }
.linechart svg text { fill: var(--muted); font-family: inherit; }
.lc-grid { stroke: var(--border); stroke-width: 1; }
.lc-line { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.lc-line.lc-in { stroke: var(--income); }
.lc-line.lc-ex { stroke: var(--expense); }
.lc-dot.lc-in { fill: var(--income); }
.lc-dot.lc-ex { fill: var(--expense); }
.lc-hit { cursor: pointer; }
.donut svg .donut-bg { stroke: var(--surface-3); }

/* Tooltip biểu đồ */
.chart-tip {
  position: fixed; z-index: 210; transform: translate(-50%, -100%);
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 5px 10px; border-radius: 9px; font-size: 12px; font-weight: 800;
  white-space: nowrap; box-shadow: var(--shadow); pointer-events: none;
  opacity: 0; transition: opacity .12s; font-variant-numeric: tabular-nums;
}
.chart-tip::after {
  content: ""; position: absolute; left: 50%; bottom: -5px; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--border);
}
.chart-tip.show { opacity: 1; }
.chart-tip .t { font-size: 10px; font-weight: 600; color: var(--muted); display: block; }
.chart-tip.income { border-color: color-mix(in srgb, var(--income) 55%, var(--border)); }
.chart-tip.income .v { color: var(--income); }
.chart-tip.expense { border-color: color-mix(in srgb, var(--expense) 55%, var(--border)); }
.chart-tip.expense .v { color: var(--expense); }

/* ---- Login ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 400px; margin: 0; }
.login-head { text-align: center; margin-bottom: 22px; }
.login-head .logo {
  width: 60px; height: 60px; border-radius: 18px; margin: 0 auto 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: var(--primary-ink);
  box-shadow: 0 8px 24px -8px var(--primary);
}
.login-head .logo .ico { width: 30px; height: 30px; }
.login-head h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: -.3px; }
.login-head p { color: var(--muted); margin: 0; font-size: 14px; }
.field { margin-bottom: 14px; }
.login-card { padding: 26px 24px; border-radius: 22px; position: relative; overflow: hidden; }
.login-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 90px;
  background: radial-gradient(120% 100% at 50% 0, color-mix(in srgb, var(--primary) 22%, transparent), transparent 70%);
  pointer-events: none;
}
.login-features { display: flex; flex-direction: column; gap: 10px; margin: 20px 0 6px; }
.login-feat { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--muted); }
.login-feat .fi { width: 30px; height: 30px; border-radius: 9px; flex: none; display: grid; place-items: center;
  background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
.login-feat .fi .ico { width: 16px; height: 16px; }
.login-credit { text-align: center; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.login-credit b { color: var(--primary); font-weight: 700; }
.login-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.login-topbar .tag { font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; }

/* ---- Misc ---- */
.msg { padding: 11px 14px; border-radius: 12px; margin: 0 0 12px; font-size: 14px; display: none; }
.msg.error { background: color-mix(in srgb, var(--expense) 16%, transparent); color: var(--expense); display: block; }
.msg.ok { background: color-mix(in srgb, var(--income) 16%, transparent); color: var(--income); display: block; }
.empty { text-align: center; color: var(--muted); padding: 26px 12px; }
.hidden { display: none !important; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters > div { flex: 1; min-width: 120px; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 14px; align-items: start; }
@media (min-width: 720px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* Toast thông báo giữa màn hình dưới */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 90px); z-index: 100;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  color: var(--text); padding: 12px 18px; border-radius: 999px; font-size: 14px; font-weight: 600;
  max-width: 90vw; text-align: center; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.error { border-color: var(--expense); color: var(--expense); }
.toast.ok { border-color: var(--income); color: var(--income); }
@media (min-width: 720px) { .toast { bottom: 32px; } }
