/* Sổ tiền — giấy vở ô ly, mực tím.
   Một chỗ đậm duy nhất: con số lãi hôm nay viết bằng mực tím trên giấy ô ly.
   Mọi thứ còn lại yên tĩnh: giấy sáng, chữ mực, đường kẻ mảnh. */

:root {
  color-scheme: light dark;
  --paper: #F6F5FB;
  --sheet: #FFFFFF;
  --ink: #1D1A33;
  --ink-2: #534F6E;
  --ink-3: #7C7896;
  --rule: #E8E4F3;
  --rule-2: #D6D0EA;
  --oly: #ECE6FB;
  --oly-2: #D3C6F6;
  --margin: #EBA3B3;
  --tim: #5B3DD6;
  --tim-ink: #4428B9;
  --tim-soft: #EFEBFD;
  --btn: #5B3DD6;
  --btn-press: #4A2EC2;
  --thu: #0B7A45;
  --bad: #C42E2E;
  --bad-soft: #FCEDED;
  --warn: #8A5A00;
  --warn-bar: #FAB219;
  --good: #0B7A45;
  --pos: #5B3DD6;
  --neg: #D03B3B;
  --c0: #A19DB5; --c1: #2A78D6; --c2: #EB6834; --c3: #1BAF7A; --c4: #EDA100;
  --c5: #E87BA4; --c6: #008300; --c7: #6250D6; --c8: #E34948;
  --font: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  --nav-h: 64px;
  --top-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --lift: 0 1px 2px rgba(29, 26, 51, .06), 0 10px 28px -16px rgba(29, 26, 51, .28);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #15132A;
    --sheet: #1D1A35;
    --ink: #EFEBFC;
    --ink-2: #BDB7D9;
    --ink-3: #8E88AF;
    --rule: #2B2749;
    --rule-2: #3A345F;
    --oly: #221E3F;
    --oly-2: #312B5A;
    --margin: #7D3F56;
    --tim: #8A74F2;
    --tim-ink: #B9ACFF;
    --tim-soft: #29234F;
    --btn: #6248E3;
    --btn-press: #553BD6;
    --thu: #4FCB88;
    --bad: #F27878;
    --bad-soft: #3B1E2C;
    --warn: #F2B53A;
    --good: #4FCB88;
    --pos: #8A74F2;
    --neg: #E05555;
    --c0: #6E6990; --c1: #3987E5; --c2: #D95926; --c3: #199E70; --c4: #C98500;
    --c5: #D55181; --c6: #008300; --c7: #9085E9; --c8: #E66767;
    --lift: 0 12px 30px -14px rgba(0, 0, 0, .7);
  }
}

/* ---------- Nền ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 16px/1.5 var(--font);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
h1, h2, h3, p, dl, dd, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
b, strong { font-weight: 600; }
small { font-size: inherit; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2.5px solid var(--tim); outline-offset: 2px; border-radius: 6px; }

.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--ink-3); }
.neg { color: var(--bad) !important; }
.in { color: var(--thu); }
.link { color: var(--tim-ink); font-size: 14.5px; font-weight: 500; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.link .ic { width: 18px; height: 18px; }
.link:active { opacity: .6; }

/* Giấy ô ly: ô lớn 32px, mỗi ô 4 dòng kẻ ngang, kẻ dọc chỉ ở ô lớn — như vở học sinh */
.oly {
  background-color: var(--sheet);
  background-image:
    linear-gradient(to right, var(--oly-2) 1px, transparent 1px),
    linear-gradient(to bottom, var(--oly-2) 1px, transparent 1px),
    linear-gradient(to bottom, var(--oly) 1px, transparent 1px);
  background-size: 32px 32px, 32px 32px, 100% 8px;
  background-position: -1px -1px, -1px -1px, 0 -1px;
}
.oly-soft {
  background-color: var(--sheet);
  background-image:
    linear-gradient(to right, var(--oly) 1px, transparent 1px),
    linear-gradient(to bottom, var(--oly) 1px, transparent 1px);
  background-size: 32px 32px, 32px 32px;
}

/* ---------- Khung app ---------- */

body.shell {
  padding-top: calc(var(--top-h) + var(--safe-t));
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 28px);
}
.top {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  height: calc(var(--top-h) + var(--safe-t));
  padding: var(--safe-t) 16px 0;
  display: flex; align-items: center; justify-content: space-between;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
}
.brand { font-size: 19px; font-weight: 700; letter-spacing: -.01em; text-decoration: none; }
.top-back { display: inline-flex; align-items: center; gap: 2px; margin-left: -8px; padding: 8px; text-decoration: none; color: var(--tim-ink); font-weight: 500; }
.me { padding: 4px; margin-right: -4px; border-radius: 999px; text-decoration: none; }

.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  height: calc(var(--nav-h) + var(--safe-b));
  padding: 0 6px var(--safe-b);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--rule);
}
.tabs .rail-brand, .tabs .tab-settings, .tabs .rail-me { display: none; }
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: 100%; text-decoration: none; color: var(--ink-3); font-size: 11.5px; font-weight: 500;
}
.tab .ic { width: 24px; height: 24px; }
.tab.on { color: var(--tim-ink); font-weight: 600; }
.tab-add .tab-ic {
  width: 52px; height: 52px; border-radius: 18px; display: grid; place-items: center;
  background: var(--btn); color: #fff; box-shadow: var(--lift); transform: translateY(-10px);
}
.tab-add .tab-ic .ic { width: 26px; height: 26px; stroke-width: 2.2; }
.tab-add .tab-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.tab-add:active .tab-ic { background: var(--btn-press); }
.tab-add.on { color: var(--ink-3); }

.page { max-width: 640px; margin: 0 auto; padding: 4px 16px 24px; }

/* ---------- Chữ ---------- */

.page-title { font-size: 28px; line-height: 1.15; font-weight: 700; letter-spacing: -.02em; margin: 6px 0 14px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 4px; }
.page-head .page-title { margin-bottom: 6px; }
.block { margin-top: 30px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 2px 10px; }
.block-head h2 { font-size: 18px; line-height: 1.3; font-weight: 600; letter-spacing: -.01em; }
.block-total { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.lead-note { font-size: 14.5px; line-height: 1.55; color: var(--ink-2); margin: -4px 2px 14px; max-width: 62ch; }
.pad { padding: 2px 2px; font-size: 14.5px; line-height: 1.55; }
.pad-top { margin-top: 16px; }
.foot-link { margin-top: 28px; text-align: center; }
.version { text-align: center; font-size: 12.5px; color: var(--ink-3); margin-top: 18px; }

/* ---------- Hôm nay (điểm nhấn duy nhất) ---------- */

.today {
  position: relative; border-radius: 22px; margin-top: 4px;
  padding: 18px 18px 18px 46px; overflow: hidden;
  border: 1px solid var(--rule);
}
.today::before { /* đường lề đỏ của vở */
  content: ""; position: absolute; top: 0; bottom: 0; left: 31px; width: 1.5px; background: var(--margin);
}
.today-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.today-h { font-size: 16px; font-weight: 600; color: var(--ink); }
.today-date { font-size: 14px; color: var(--ink-2); }
.hero-label { margin-top: 22px; font-size: 14px; color: var(--ink-2); }
.hero-num {
  margin: 2px 0 18px; color: var(--tim-ink);
  font-size: clamp(30px, 9.2vw, 50px); line-height: 1.1; font-weight: 600; letter-spacing: -.025em; white-space: nowrap;
}
.hero-num.neg { color: var(--bad); }
.today-split { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.today-split span { display: block; font-size: 12.5px; color: var(--ink-2); line-height: 1.3; }
.today-split b { display: block; font-size: 17px; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ---------- Thông báo ---------- */

.notice {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 12px; padding: 12px 14px; border-radius: 16px; background: var(--tim-soft);
}
.notice-ic { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--sheet); color: var(--tim-ink); flex: none; }
.notice p { flex: 1 1 180px; font-size: 14.5px; line-height: 1.45; }
.notice .btn { margin-left: auto; }

/* ---------- Bộ số ---------- */

.figures { display: grid; grid-template-columns: 1fr 1fr; column-gap: 20px; }
.figures.three { grid-template-columns: repeat(3, 1fr); }
.fig { padding: 11px 2px 12px; border-top: 1px solid var(--rule); min-width: 0; }
.fig dt { font-size: 13.5px; color: var(--ink-2); line-height: 1.35; }
.fig dd { font-size: 19px; font-weight: 600; margin-top: 2px; letter-spacing: -.01em; }
.fig.lead { grid-column: 1 / -1; }
.fig.lead dd { font-size: 28px; letter-spacing: -.02em; }
.delta { display: block; margin-top: 3px; font-size: 12.5px; color: var(--ink-3); }
.delta.good { color: var(--good); }
.delta.bad { color: var(--bad); }

/* ---------- Tờ, danh sách ---------- */

.sheet { background: var(--sheet); border: 1px solid var(--rule); border-radius: 18px; overflow: hidden; }
.sheet + .sheet { margin-top: 14px; }
.sheet.list > * + * { border-top: 1px solid var(--rule); }

.txn {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 11px 14px; text-decoration: none; color: inherit;
}
.txn:active { background: var(--tim-soft); }
.txn-ic {
  width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center;
  background: var(--paper); font-size: 20px; line-height: 1;
}
.txn-ic.swap { color: var(--ink-2); }
.txn-ic .ic { width: 20px; height: 20px; }
.txn-main { min-width: 0; }
.txn-title { display: block; font-size: 15.5px; font-weight: 500; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.txn-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 10px; margin-top: 2px; font-size: 13px; color: var(--ink-3); line-height: 1.35; min-width: 0; }
.txn-meta .note { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.txn-meta .seg { display: inline-flex; align-items: center; }
.has-receipt .ic { width: 15px; height: 15px; }
.txn-end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.txn-amt { font-size: 15.5px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.txn-amt.in { color: var(--thu); }
.txn-amt.move { color: var(--ink-2); font-weight: 500; }
.txn-amt.bad { color: var(--bad); }
.is-pending .txn-amt { color: var(--ink-2); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px 1px 6px; border-radius: 999px;
  font-size: 12px; font-weight: 500; line-height: 1.6; text-decoration: none; white-space: nowrap;
  border: 1px solid var(--rule-2); color: var(--ink-2); background: var(--sheet);
}
.badge .ic { width: 13px; height: 13px; stroke-width: 2; }
.badge.done { color: var(--good); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.badge.due { color: var(--warn); border-color: color-mix(in srgb, var(--warn-bar) 60%, transparent); background: color-mix(in srgb, var(--warn-bar) 12%, var(--sheet)); }
.badge.later { color: var(--ink-3); }

.dot { --c: var(--c0); display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); margin-right: 6px; flex: none; }

.avatar {
  --c: var(--c7);
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--c); color: #fff; font-size: 13.5px; font-weight: 700; line-height: 1; flex: none;
}
.avatar.c3, .avatar.c4, .avatar.c5 { color: #1D1A33; }
.avatar.sm { width: 28px; height: 28px; font-size: 12.5px; }
.avatar.xs { width: 20px; height: 20px; font-size: 10.5px; }
.c0 { --c: var(--c0); } .c1 { --c: var(--c1); } .c2 { --c: var(--c2); } .c3 { --c: var(--c3); }
.c4 { --c: var(--c4); } .c5 { --c: var(--c5); } .c6 { --c: var(--c6); } .c7 { --c: var(--c7); } .c8 { --c: var(--c8); }

ul.sheet.plain > li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; font-size: 15px;
}
ul.sheet.plain > li + li { border-top: 1px solid var(--rule); }
ul.sheet.plain small { display: block; font-size: 12.5px; color: var(--ink-3); }
ul.sheet.plain b { font-variant-numeric: tabular-nums; white-space: nowrap; }

.wallets li + li { border-top: 1px solid var(--rule); }
.wallets .w-group { padding: 10px 14px 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); background: var(--paper); }
.figures.net { margin-bottom: 10px; }
.figures.net .fig dd { font-size: 17px; }
.entry[data-kind="transfer"] p[data-only="transfer"] { display: block; }
.wallet-row { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; text-decoration: none; font-size: 15px; }
.wallet-row b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.wallet-row:active { background: var(--tim-soft); }

/* ---------- Ngăn ---------- */

.jars { background: var(--sheet); border: 1px solid var(--rule); border-radius: 18px; padding: 2px 14px; }
.jar { padding: 12px 0 11px; }
.jar + .jar { border-top: 1px solid var(--rule); }
.jar-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.jar-name { font-size: 15px; font-weight: 500; }
.jar-num { font-size: 13.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.jar-num b { color: var(--ink); }
.jar-state { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; margin-top: 6px; white-space: nowrap; flex: none; }
.jar-state .ic { width: 15px; height: 15px; stroke-width: 2; }
.jar-state.muted { color: var(--ink-3); }
.jar-state.warn { color: var(--warn); }
.jar-state.bad { color: var(--bad); font-weight: 500; }
.jar-state.good { color: var(--good); }
.jar-foot { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.jar-note { font-size: 12.5px; color: var(--ink-3); text-align: right; }

.meter {
  display: block; height: 8px; margin-top: 8px; border-radius: 999px; overflow: hidden;
  background: color-mix(in srgb, var(--tim) 15%, var(--sheet));
}
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--tim); }
.meter.near { background: color-mix(in srgb, var(--warn-bar) 22%, var(--sheet)); }
.meter.near > span { background: var(--warn-bar); }
.meter.over { background: var(--bad-soft); }
.meter.over > span { background: var(--neg); }

/* ---------- Xếp hạng ---------- */

.rank-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name val" "bar bar" "sub sub";
  gap: 4px 12px; padding: 12px 14px; text-decoration: none; color: inherit;
}
.rank-row + .rank-row { border-top: 1px solid var(--rule); }
.rank-row:active { background: var(--tim-soft); }
.rank-name { grid-area: name; display: inline-flex; align-items: center; font-size: 15px; font-weight: 500; min-width: 0; }
.rank-ic { margin-right: 8px; font-size: 17px; }
.rank-val { grid-area: val; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.hbar { grid-area: bar; display: block; height: 6px; margin: 3px 0 1px; }
.hbar > span { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--tim); }
.hbar.neg > span { background: var(--neg); }
.rank-sub { grid-area: sub; font-size: 12.5px; color: var(--ink-3); }

/* ---------- Biểu đồ ---------- */

.daily { height: 196px; margin: 0 -4px; position: relative; touch-action: pan-y; }
.daily svg { display: block; width: 100%; height: 100%; overflow: visible; }
.daily .grid { stroke: var(--rule); stroke-width: 1; shape-rendering: crispEdges; }
.daily .grid.zero { stroke: var(--rule-2); }
.daily .tick { fill: var(--ink-3); font-size: 11px; font-variant-numeric: tabular-nums; font-family: var(--font); }
.daily .pos { fill: var(--pos); }
.daily .neg { fill: var(--neg); }
.daily .hit { fill: transparent; cursor: pointer; }
.daily.hovering .bar:not(.on) path { opacity: .4; }

.tip {
  position: fixed; z-index: 60; pointer-events: none; transform: translate(-50%, calc(-100% - 10px));
  padding: 7px 10px; border-radius: 10px; background: var(--ink); color: var(--paper);
  font-size: 13px; line-height: 1.35; box-shadow: var(--lift); white-space: nowrap;
}
.tip b { display: block; font-size: 14.5px; font-variant-numeric: tabular-nums; }

.table-view { margin-top: 6px; }
.table-view summary { display: inline-block; cursor: pointer; font-size: 13.5px; color: var(--tim-ink); padding: 6px 2px; }
.num-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 6px; }
.num-table th { text-align: left; font-weight: 500; color: var(--ink-3); font-size: 12.5px; padding: 6px 4px; border-bottom: 1px solid var(--rule); }
.num-table td { padding: 7px 4px; border-bottom: 1px solid var(--rule); }
.num-table th:last-child, .num-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Nút ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 13px; border: 1px solid var(--rule-2);
  background: var(--sheet); color: var(--ink); font-size: 15.5px; font-weight: 600;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn .ic { width: 19px; height: 19px; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--btn); border-color: transparent; color: #fff; }
.btn.primary:active { background: var(--btn-press); }
.btn.ghost { background: transparent; color: var(--tim-ink); }
.btn.danger-ghost { background: transparent; color: var(--bad); }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 14.5px; border-radius: 11px; }
.btn.full { display: flex; width: 100%; }
.btn[disabled] { opacity: .6; pointer-events: none; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: var(--ink-2); text-decoration: none; }
.icon-btn:active { background: var(--tim-soft); }
.icon-btn.off { opacity: .28; }

/* ---------- Ô nhập ---------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; min-width: 0; }
.field-label, .group-label { font-size: 13.5px; font-weight: 500; color: var(--ink-2); }
.field-hint { font-size: 12.5px; color: var(--ink-3); line-height: 1.45; }
.field-err { font-size: 13px; color: var(--bad); margin-top: 6px; }
.field.narrow { max-width: 150px; }
:where(input:not([type=checkbox]):not([type=radio]):not([type=file])), select, textarea {
  width: 100%; height: 48px; padding: 0 14px; border: 1px solid var(--rule-2); border-radius: 13px;
  background: var(--sheet); font-size: 16px; -webkit-appearance: none; appearance: none;
}
input::placeholder { color: var(--ink-3); opacity: .8; }
input:focus, select:focus { outline: none; border-color: var(--tim); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tim) 22%, transparent); }
select {
  padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 19px) 52%, calc(100% - 14px) 52%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
input[type=date] { display: flex; align-items: center; }
input[type=date]::-webkit-date-and-time-value { text-align: left; }
.money-input { position: relative; display: block; }
.money-input input { padding-right: 34px; font-variant-numeric: tabular-nums; }
.money-input > span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search { flex-direction: row; align-items: center; position: relative; margin-top: 0; }
.search .ic { position: absolute; left: 12px; color: var(--ink-3); width: 19px; height: 19px; }
.search input { padding-left: 40px; }
.check { display: flex; align-items: flex-start; gap: 10px; margin-top: 14px; font-size: 14.5px; line-height: 1.4; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--tim); flex: none; }
.form-err {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 13px;
  background: var(--bad-soft); color: var(--bad); font-size: 14.5px; line-height: 1.45;
}
.form-err .ic { width: 20px; height: 20px; margin-top: 1px; }
.form-err p + p { margin-top: 4px; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 12px; }
.two > .field { margin-top: 16px; }
.icon-name { grid-template-columns: 96px minmax(0, 1fr); }

/* ---------- Ghi khoản ---------- */

.kind-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 15px; background: var(--rule); }
.kind-opt { position: relative; }
.kind-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.kind-opt span {
  display: block; text-align: center; padding: 9px 4px; border-radius: 11px;
  font-size: 15px; font-weight: 600; color: var(--ink-2); cursor: pointer;
}
.kind-opt input:checked + span { background: var(--sheet); color: var(--ink); box-shadow: 0 1px 2px rgba(29, 26, 51, .1); }
.kind-opt input:focus-visible + span { outline: 2.5px solid var(--tim); outline-offset: 1px; }

.amount {
  display: flex; align-items: center; gap: 6px; margin-top: 16px;
  padding: 10px 12px 10px 18px; border-radius: 18px; border: 1px solid var(--rule);
  background-color: var(--sheet);
  background-image:
    linear-gradient(to right, var(--oly-2) 1px, transparent 1px),
    linear-gradient(to bottom, var(--oly-2) 1px, transparent 1px),
    linear-gradient(to bottom, var(--oly) 1px, transparent 1px);
  background-size: 32px 32px, 32px 32px, 100% 8px;
  background-position: -1px -1px, -1px -1px, 0 -1px;
}
.amount:focus-within { border-color: var(--tim); }
.amount.has-err { border-color: var(--bad); }
.amount input {
  flex: 1; min-width: 0; height: 64px; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none;
  font-size: clamp(32px, 10vw, 44px); font-weight: 600; letter-spacing: -.02em; color: var(--tim-ink); font-variant-numeric: tabular-nums;
}
.amount input:focus { box-shadow: none; }
.amount-unit { font-size: 26px; font-weight: 500; color: var(--ink-3); }
.zeros {
  flex: none; height: 38px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--rule-2);
  background: var(--sheet); font-size: 15px; font-weight: 600; color: var(--ink-2); cursor: pointer;
}
.zeros:active { background: var(--tim-soft); }
.amount-read { min-height: 21px; margin: 6px 4px 0; font-size: 14px; color: var(--ink-2); }

.group { margin: 20px 0 0; padding: 0; border: 0; min-width: 0; }
.group-label { display: block; margin-bottom: 8px; padding: 0; }
.group-hint { font-size: 12.5px; color: var(--ink-3); margin-top: 8px; line-height: 1.45; }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: 8px; }
.cat {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 76px; padding: 10px 6px 8px; border-radius: 15px; border: 1px solid var(--rule);
  background: var(--sheet); text-align: center; cursor: pointer;
}
.cat input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.cat-ic { font-size: 23px; line-height: 1; }
.cat-name { font-size: 12.5px; line-height: 1.25; color: var(--ink-2); }
.cat:has(input:checked) { border-color: var(--tim); background: var(--tim-soft); }
.cat:has(input:checked) .cat-name { color: var(--tim-ink); font-weight: 600; }
.cat:has(input:focus-visible) { outline: 2.5px solid var(--tim); outline-offset: 2px; }
.cat.is-on { border-color: var(--tim); background: var(--tim-soft); }

.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { position: relative; }
.pill input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.pill span {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 13px; border-radius: 999px;
  border: 1px solid var(--rule-2); background: var(--sheet); font-size: 14.5px; cursor: pointer; white-space: nowrap;
}
.pill span .ic { width: 16px; height: 16px; stroke-width: 2; }
.pill input:checked + span { border-color: var(--tim); background: var(--tim-soft); color: var(--tim-ink); font-weight: 600; }
.pill input:focus-visible + span { outline: 2.5px solid var(--tim); outline-offset: 2px; }

/* Ẩn hiện theo loại khoản — data-kind do máy chủ đặt sẵn, JS cập nhật khi đổi */
.entry [data-only] { display: none; }
.entry[data-kind="income"] [data-only="income"] { display: block; }
.entry[data-kind="transfer"] [data-only="transfer"] { display: flex; }
.entry[data-kind="transfer"] [data-hide="transfer"] { display: none; }
.entry[data-kind="expense"] .cat[data-kind="income"],
.entry[data-kind="income"] .cat[data-kind="expense"] { display: none; }

.entry:not([data-kind="transfer"]) .wallet-two { grid-template-columns: minmax(0, 1fr); }
.date-row { display: flex; gap: 8px; align-items: center; }
.date-row input { flex: 1; min-width: 0; }
.pill-btn {
  flex: none; height: 48px; padding: 0 13px; border-radius: 13px; border: 1px solid var(--rule-2);
  background: var(--sheet); font-size: 14.5px; font-weight: 500; cursor: pointer;
}
.pill-btn.on { border-color: var(--tim); background: var(--tim-soft); color: var(--tim-ink); font-weight: 600; }

.file-btn {
  position: relative; display: inline-flex; align-items: center; gap: 10px; align-self: flex-start;
  padding: 12px 16px; border-radius: 13px; border: 1px dashed var(--rule-2); color: var(--ink-2); cursor: pointer; font-size: 15px;
}
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-btn:focus-within { outline: 2.5px solid var(--tim); outline-offset: 2px; }
.receipt-preview, .receipt-now img { max-width: 180px; max-height: 240px; object-fit: cover; border-radius: 12px; border: 1px solid var(--rule); margin-top: 10px; }
.receipt-now { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }

.entry-actions > :only-child { grid-column: 1 / -1; }
.entry-actions .btn.ghost { background: var(--sheet); border-color: var(--rule-2); }
.entry-actions {
  position: sticky; bottom: calc(var(--nav-h) + var(--safe-b) + 6px); z-index: 5;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 26px; padding-top: 14px;
  background: linear-gradient(to bottom, transparent, var(--paper) 22px);
}

.received { position: relative; border-radius: 20px; padding: 16px 16px 18px; margin-bottom: 22px; border: 1px solid var(--rule); }
.received h2 { font-size: 18px; font-weight: 600; }
.received p { font-size: 14.5px; color: var(--ink-2); margin-top: 6px; line-height: 1.5; background: color-mix(in srgb, var(--sheet) 80%, transparent); }
.received-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 12px; }
.received-form .btn { grid-column: 1 / -1; margin-top: 16px; }

.meta-block { margin-top: 30px; padding-top: 14px; border-top: 1px solid var(--rule); font-size: 13.5px; color: var(--ink-3); line-height: 1.6; }
.meta-block form { margin-top: 12px; }

/* ---------- Sổ ---------- */

.month-nav { display: inline-flex; align-items: center; gap: 2px; margin-right: -8px; }
.month-now { min-width: 116px; text-align: center; font-size: 15px; font-weight: 600; }
.seg-tabs {
  display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 4px; scrollbar-width: none;
}
.seg-tabs::-webkit-scrollbar { display: none; }
.seg-tabs a {
  flex: none; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--rule-2);
  font-size: 14.5px; font-weight: 500; color: var(--ink-2); text-decoration: none; white-space: nowrap;
}
.seg-tabs a.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.more-filter { margin-top: 10px; }
.more-filter > summary {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 2px; cursor: pointer; list-style: none;
  font-size: 14.5px; font-weight: 500; color: var(--tim-ink);
}
.more-filter > summary::-webkit-details-marker { display: none; }
.more-filter > summary .ic { width: 18px; height: 18px; }
.more-filter .count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--tim); color: #fff; font-size: 12px; }
.filter-form { margin-top: 8px; padding: 14px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 18px; }
.filter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 10px; }
.filter-actions { display: flex; gap: 8px; margin-top: 14px; }
.sum-line { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 16px 2px 0; font-size: 14px; color: var(--ink-2); }
.sum-line b { color: var(--ink); font-variant-numeric: tabular-nums; }
.sum-line b.in { color: var(--thu); }
.day { margin-top: 18px; }
.day-h { display: flex; justify-content: space-between; gap: 12px; margin: 0 4px 8px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.day-net { font-variant-numeric: tabular-nums; }

.empty { margin-top: 16px; padding: 30px 20px; border-radius: 20px; text-align: center; border: 1px solid var(--rule); }
.empty p { font-size: 15px; color: var(--ink-2); max-width: 34ch; margin: 0 auto; background: color-mix(in srgb, var(--sheet) 70%, transparent); }
.empty .btn { margin-top: 16px; }

/* ---------- Doanh số ---------- */

.h2 { font-size: 18px; line-height: 1.3; font-weight: 600; letter-spacing: -.01em; margin: 0 2px; }
.batches { margin-top: 18px; }
.batches .lead-note { margin-top: 4px; }
.batches .h2.pad-top { margin-top: 24px; }
.sales-entry .date-row a.pill-btn { display: inline-flex; align-items: center; text-decoration: none; color: inherit; }
.sales-entry > .field:first-of-type { margin-top: 4px; }
.calc { margin: 12px 0 18px; border-radius: 16px; background: var(--sheet); border: 1px solid var(--rule); padding: 4px 14px; }
.calc > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 0; font-size: 14.5px; }
.calc > div + div { border-top: 1px solid var(--rule); }
.calc dt { color: var(--ink-2); }
.calc dd { font-weight: 600; font-variant-numeric: tabular-nums; }
.calc .calc-main dt { color: var(--ink); font-weight: 500; }
.calc .calc-main dd { color: var(--tim-ink); font-size: 17px; }
.calc .calc-main dd.neg { color: var(--bad); }
.calc dt small { display: block; font-size: 12.5px; font-weight: 400; color: var(--ink-3); }
.sales-label { display: block; margin-top: 16px; }
.sales-label + .amount { margin-top: 6px; }
.costs .field { margin-top: 12px; }
.day-lai { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; min-width: 62px; text-align: right; }
.day-lai.neg { color: var(--bad); }
.st { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; }
.st .ic { width: 15px; height: 15px; stroke-width: 2.2; }
.st.done { color: var(--good); background: color-mix(in srgb, var(--good) 12%, var(--sheet)); }
.st.wait { color: var(--ink-3); background: var(--paper); }
.days li { padding: 0 !important; }
.days a { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; padding: 11px 14px; text-decoration: none; }
.days a:active { background: var(--tim-soft); }
.day-name { font-size: 14.5px; }
.missing .day-name { color: var(--ink-3); }
.day-sales { display: inline-flex; align-items: center; gap: 10px; }
.day-sales b { font-variant-numeric: tabular-nums; }
.settings-box > summary { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; font-size: 15px; font-weight: 500; color: var(--tim-ink); padding: 6px 2px; }
.settings-box > summary::-webkit-details-marker { display: none; }
.settings-box[open] { background: var(--sheet); border: 1px solid var(--rule); border-radius: 18px; }
.settings-box[open] > summary { padding: 14px 16px 0; }
.api-box { border-top: 1px solid var(--rule); padding-top: 14px; }
.api-kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 12px; margin: 12px 0 4px; font-size: 13.5px; }
.api-kv dt { color: var(--ink-3); }
.api-kv code { font-size: 12.5px; word-break: break-all; background: var(--paper); padding: 2px 6px; border-radius: 6px; }
.shortcut {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; align-items: center; margin-top: 14px;
  padding: 12px 14px; border-radius: 15px; background: var(--tim-soft); color: var(--ink); text-decoration: none; font-size: 14.5px; line-height: 1.4;
}
.shortcut .ic:first-child { color: var(--tim-ink); }
.entry[data-kind="income"] .shortcut[data-only="income"] { display: grid; }

/* ---------- Ngăn và ví ---------- */

.recon + .recon { border-top: 1px solid var(--rule); }
.recon > summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 14px;
  cursor: pointer; list-style: none; font-size: 15px;
}
.recon > summary::-webkit-details-marker { display: none; }
.recon-name small { display: block; font-size: 12.5px; color: var(--ink-3); }
.recon > summary b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.recon[open] > summary { background: var(--tim-soft); }
.recon-form { padding: 2px 14px 16px; }
.recon-form .btn { margin-top: 16px; }
.recon-diff { min-height: 20px; margin-top: 6px; font-size: 14px; color: var(--ink-2); }
.recon-diff.bad { color: var(--bad); font-weight: 500; }
.recon-diff.good { color: var(--good); font-weight: 500; }
.rc-name span { margin-right: 8px; }
.rc-end { display: inline-flex; align-items: center; gap: 10px; }

/* ---------- Cài đặt ---------- */

.menu li + li { border-top: 1px solid var(--rule); }
.menu a { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; text-decoration: none; }
.menu a:active { background: var(--tim-soft); }
.menu-ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--paper); color: var(--tim-ink); }
.menu-ic .ic { width: 20px; height: 20px; }
.menu-t { font-size: 15.5px; font-weight: 500; }
.menu-t small { display: block; font-size: 13px; font-weight: 400; color: var(--ink-3); }
.chev { width: 18px; height: 18px; color: var(--ink-3); transition: transform .15s; }

.edit-row + .edit-row { border-top: 1px solid var(--rule); }
.edit-row > summary {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 12px 14px; cursor: pointer; list-style: none;
}
.edit-row > summary::-webkit-details-marker { display: none; }
.edit-row[open] > summary { background: var(--tim-soft); }
.edit-row[open] .chev { transform: rotate(90deg); }
.edit-row.add > summary { color: var(--tim-ink); font-weight: 500; }
.edit-row.off .er-name { color: var(--ink-3); }
.er-ic { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--paper); font-size: 19px; color: var(--tim-ink); }
.er-ic .ic { width: 19px; height: 19px; }
.er-ic .dot { width: 14px; height: 14px; margin: 0; }
.er-name { font-size: 15.5px; min-width: 0; }
.er-name small { display: block; font-size: 12.5px; color: var(--ink-3); }
.er-val { font-variant-numeric: tabular-nums; font-size: 15px; white-space: nowrap; }
.edit-form { padding: 0 14px 16px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.hidden-title { margin: 20px 4px 8px; font-size: 13.5px; font-weight: 600; color: var(--ink-3); }
.pad-form { padding: 2px 16px 18px; }
.pad-form .btn { margin-top: 18px; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { position: relative; display: inline-grid; place-items: center; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.swatch .dot { width: 26px; height: 26px; margin: 0; }
.swatch input:checked + .dot, .swatch input:checked + .avatar { outline: 2.5px solid var(--ink); outline-offset: 2px; }
.swatch input:focus-visible + * { outline: 2.5px solid var(--tim); outline-offset: 3px; }

.who { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.who .muted { font-size: 13px; }
.people a { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; text-decoration: none; }
.who-num { font-size: 13.5px; color: var(--ink-2); text-align: right; }
.who-num b { color: var(--ink); margin: 0 6px 0 2px; font-variant-numeric: tabular-nums; }

.history .h-day { padding: 14px 14px 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.history .h-row { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 10px 14px; border-top: 1px solid var(--rule); }
.h-text { font-size: 14.5px; line-height: 1.45; }
.h-time { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; padding-top: 2px; }

/* ---------- Đăng nhập ---------- */

body.bare { display: flex; justify-content: center; padding: calc(24px + var(--safe-t)) 18px calc(24px + var(--safe-b)); }
.auth { width: 100%; max-width: 420px; }
.auth-cover { position: relative; border-radius: 24px; padding: 44px 22px 26px 52px; border: 1px solid var(--rule); }
.auth-cover::before { content: ""; position: absolute; top: 0; bottom: 0; left: 35px; width: 1.5px; background: var(--margin); }
.auth-name { font-size: 40px; line-height: 1.05; font-weight: 700; letter-spacing: -.03em; color: var(--tim-ink); }
.auth-sub { margin-top: 10px; font-size: 15px; color: var(--ink-2); }
.auth-form { margin-top: 18px; }
.auth-form .btn { margin-top: 22px; }
.auth-form .muted { margin-top: 12px; font-size: 14.5px; line-height: 1.55; }
.person { border: 0; padding: 0; margin: 24px 0 0; }
.person legend { font-size: 16px; font-weight: 600; padding: 0; }

/* ---------- Toast ---------- */

.toast {
  position: fixed; z-index: 50; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + var(--safe-b) + 14px);
  width: max-content; max-width: min(92vw, 520px);
  display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 14px; border-radius: 15px;
  background: var(--ink); color: var(--paper); box-shadow: var(--lift); font-size: 14.5px; line-height: 1.4;
  animation: toast-in .22s ease-out;
}
body.bare .toast { bottom: calc(20px + var(--safe-b)); }
.toast-ic { display: grid; place-items: center; }
.toast.ok .toast-ic { color: color-mix(in srgb, var(--thu) 70%, var(--paper)); }
.toast.err .toast-ic { color: color-mix(in srgb, var(--bad) 70%, var(--paper)); }
.toast-act { border: 0; background: transparent; color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; padding: 6px 6px; cursor: pointer; }
.toast-x { border: 0; background: transparent; color: inherit; opacity: .7; padding: 6px; cursor: pointer; display: grid; place-items: center; }
.toast-x .ic { width: 18px; height: 18px; }
.toast.hide { opacity: 0; transform: translate(-50%, 8px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (prefers-color-scheme: dark) {
  .avatar.c7, .avatar.c1 { color: #15132A; }
  .kind-switch { background: var(--sheet); border: 1px solid var(--rule); }
  .kind-opt input:checked + span { background: var(--tim-soft); color: var(--tim-ink); box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
  .toast.hide, .chev { transition: none; }
}

/* ---------- Màn hình nhỏ ---------- */

@media (max-width: 360px) {
  .page { padding-left: 12px; padding-right: 12px; }
  .two, .filter-grid, .received-form { grid-template-columns: minmax(0, 1fr); }
  .today { padding-left: 40px; }
  .today::before { left: 26px; }
  .cat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- Máy tính: thanh điều hướng bên trái ---------- */

@media (min-width: 1000px) {
  body.shell { padding: 0 0 0 248px; }
  .top { position: sticky; inset: auto; height: 64px; padding: 0 40px; background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .top .brand, .top .me { display: none; }
  .tabs {
    inset: 0 auto 0 0; width: 248px; height: auto; padding: 26px 16px 20px;
    display: flex; flex-direction: column; align-items: stretch; gap: 2px;
    border-top: 0; border-right: 1px solid var(--rule); background: var(--paper);
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .tabs .rail-brand { display: block; font-size: 22px; font-weight: 700; letter-spacing: -.02em; text-decoration: none; color: var(--tim-ink); padding: 0 12px 22px; }
  .tab { flex-direction: row; justify-content: flex-start; gap: 12px; height: 44px; padding: 0 12px; border-radius: 12px; font-size: 15px; color: var(--ink-2); }
  .tab .ic { width: 21px; height: 21px; }
  .tab:hover { background: var(--tim-soft); }
  .tab.on { background: var(--tim-soft); color: var(--tim-ink); }
  .tab-add { order: -1; margin-bottom: 14px; background: var(--btn); color: #fff; }
  .tab-add:hover, .tab-add.on { background: var(--btn-press); color: #fff; }
  .tab-add .tab-ic { width: auto; height: auto; background: none; box-shadow: none; transform: none; border-radius: 0; }
  .tab-add .tab-ic .ic { width: 21px; height: 21px; }
  .tab-add .tab-label { position: static; width: auto; height: auto; clip: auto; overflow: visible; }
  .rail-brand { order: -2; }
  .tabs .tab-settings { display: flex; margin-top: 8px; }
  .tabs .rail-me { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 12px; font-size: 14.5px; color: var(--ink-2); }
  .page { max-width: 1120px; padding: 0 40px 56px; }
  .page:has(.entry), .page:has(.menu), .page:has(.edit-list), .page:has(.pad-form) { max-width: 720px; margin-left: 0; }
  .home { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 0 44px; align-items: start; }
  .home-side > .block:first-child { margin-top: 4px; }
  .toast { bottom: 28px; margin-left: 124px; }
  .entry-actions { bottom: 16px; }
  .seg-tabs { margin: 0; padding-left: 0; padding-right: 0; }
  .cat-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
}

@media (hover: hover) {
  .txn:hover, .rank-row:hover, .wallet-row:hover, .menu a:hover, .edit-row > summary:hover, .recon > summary:hover { background: color-mix(in srgb, var(--tim-soft) 60%, transparent); }
  .btn.primary:hover { background: var(--btn-press); }
  .cat:hover, .pill span:hover, .pill-btn:hover { border-color: var(--tim); }
}
