/* Be Vietnam Pro (OFL), tự lưu để PWA chạy offline. Chỉ tập con vietnamese + latin. */
@font-face { font-family: 'Be Vietnam Pro'; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/BeVietnamPro-500-vietnamese.woff2) format('woff2'); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: 'Be Vietnam Pro'; font-style: normal; font-weight: 500; font-display: swap; src: url(fonts/BeVietnamPro-500-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Be Vietnam Pro'; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/BeVietnamPro-700-vietnamese.woff2) format('woff2'); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: 'Be Vietnam Pro'; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/BeVietnamPro-700-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Be Vietnam Pro'; font-style: normal; font-weight: 800; font-display: swap; src: url(fonts/BeVietnamPro-800-vietnamese.woff2) format('woff2'); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: 'Be Vietnam Pro'; font-style: normal; font-weight: 800; font-display: swap; src: url(fonts/BeVietnamPro-800-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ============================================================
   Thu Chi Canteen: "Sổ cái quán ăn" — ấm, rõ, tĩnh.
   Người dùng chính: người lớn tuổi, mắt yếu, dùng điện thoại.
   - Cỡ chữ gốc 20px, 3 mức (nút "Chữ"); mọi kích thước dùng rem để chữ, nút, khoảng cách phóng theo.
   - Tương phản cao, nút bấm ≥ 3,2rem, một cột, không tràn ngang từ 320px.
   - Không dùng màu làm dấu hiệu duy nhất: luôn kèm chữ + biểu tượng SVG.
   ============================================================ */
:root {
  --bg: #f6f4ec;
  --card: #ffffff;
  --paper: #fbfaf4;
  --ink: #15201b;
  --muted: #3e4b44;
  --line: #b9b4a3;
  --line-soft: #dcd8c9;
  --edge: #5d6a63;
  --brand: #14573f;
  --brand-ink: #ffffff;
  --brand-soft: #e6f1ec;
  --brand-line: #b6d2c4;
  --thu: #0a5a30;
  --thu-bg: #dff3e7;
  --chi: #8f2614;
  --chi-bg: #fbe4de;
  --warn-bg: #fff1b8;
  --warn-ink: #4a3600;
  --info-bg: #e3eefb;
  --info-ink: #123a73;
  --focus: #1752c8;
  --radius: 0.9rem;
  --tap: 3.2rem;
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
html { font-size: 20px; }
html.fs-2 { font-size: min(24px, 7vw); }
html.fs-3 { font-size: min(28px, 7.6vw); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: var(--font); font-size: 1rem; line-height: 1.5; font-weight: 500;
  -webkit-text-size-adjust: 100%; overflow-wrap: anywhere; font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 0.2rem solid var(--focus); outline-offset: 0.15rem; }
.skip { position: absolute; left: -999px; top: 0; background: #fff; padding: .6rem 1rem; z-index: 100; }
.skip:focus { left: 0; }
[hidden] { display: none !important; }

/* ---------- biểu tượng ---------- */
.ic { width: 1.3em; height: 1.3em; flex: none; vertical-align: -0.25em; }
.ic.lg { width: 1.7rem; height: 1.7rem; }
.ic.xl { width: 2rem; height: 2rem; }

/* ---------- khung trang ---------- */
.shell { max-width: 60rem; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); }
main { flex: 1; padding: 1rem 0.85rem 6.8rem; animation: rise .18s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(0.4rem); } to { opacity: 1; transform: none; } }

.top { background: var(--brand); color: var(--brand-ink); padding: calc(0.7rem + env(safe-area-inset-top)) 0.85rem 0.8rem; }
.brand { display: flex; align-items: center; gap: 0.55rem; font-size: 1.15rem; font-weight: 800; line-height: 1.2; }
.brand .ic { width: 1.7rem; height: 1.7rem; }
.who { margin-top: 0.5rem; display: block; padding: 0.4rem 0.8rem; border-radius: 0.9rem; background: rgba(255,255,255,.16); font-size: 0.9rem; font-weight: 600; line-height: 1.35; }
.who .where { display: block; font-size: 0.85rem; font-weight: 500; opacity: 1; }
.who b { font-weight: 800; }
.tools { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.7rem; }
.tools button {
  flex: 1 1 5rem; overflow-wrap: normal; white-space: nowrap; flex-direction: column; min-height: 3.4rem; border: 0; background: rgba(255,255,255,.14); color: #fff;
  border-radius: 0.7rem; font-weight: 700; font-size: 0.85rem; padding: 0.3rem 0.3rem; line-height: 1.2;
  display: flex; align-items: center; justify-content: center; gap: 0.15rem;
}
.tools button:active { background: rgba(255,255,255,.3); }
.tag { display: inline-block; white-space: nowrap; background: #ffd24d; color: #3b2d00; font-size: 0.7rem; font-weight: 800; padding: 0.05rem 0.4rem; border-radius: 0.4rem; margin-left: 0.2rem; vertical-align: middle; letter-spacing: .02em; }

nav.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; max-width: 60rem; margin: 0 auto; display: flex; gap: 0.25rem;
  background: #fff; border-top: 0.12rem solid var(--line); padding: 0.25rem 0.35rem calc(0.25rem + env(safe-area-inset-bottom));
}
nav.tabs button {
  flex: 1; min-width: 0; border: 0; background: none; padding: 0.35rem 0.2rem 0.3rem; min-height: 4rem; color: var(--muted); border-radius: 0.8rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.15rem; font-weight: 700; font-size: 0.9rem; line-height: 1.2;
}
nav.tabs .ic { width: 1.6rem; height: 1.6rem; }
nav.tabs button.on { color: var(--brand); background: var(--brand-soft); font-weight: 800; box-shadow: inset 0 -0.22rem 0 var(--brand); }

.pagehead { margin: 0.1rem 0.1rem 0.9rem; }
.pagehead h1 { margin: 0; font-size: 1.45rem; font-weight: 800; line-height: 1.25; letter-spacing: -0.01em; }
.pagehead p { margin: 0.1rem 0 0; color: var(--muted); font-weight: 600; font-size: 0.95rem; }

/* ---------- tờ sổ (thẻ), tiêu đề bước ---------- */
.card { container-type: inline-size; background: var(--card); border: 0.1rem solid var(--line-soft); border-radius: var(--radius); padding: 0.95rem; margin-bottom: 0.85rem; }
.card > h2, .step { margin: 0 0 0.7rem; font-size: 1.1rem; font-weight: 800; line-height: 1.3; }
.card > h2 { padding-bottom: 0.55rem; border-bottom: 0.1rem solid var(--line-soft); }
.step { display: flex; gap: 0.6rem; align-items: center; padding-bottom: 0.6rem; border-bottom: 0.1rem solid var(--line-soft); }
.num { flex: none; width: 2rem; height: 2rem; border-radius: 50%; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 1rem; font-weight: 800; }

/* ---------- ô nhập ---------- */
.field { margin-bottom: 0.85rem; }
.lbl { display: block; font-weight: 800; margin-bottom: 0.15rem; font-size: 1rem; }
.hint { color: var(--muted); font-size: 0.85rem; font-weight: 500; margin: 0 0 0.3rem; line-height: 1.35; }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; min-height: var(--tap); padding: 0.55rem 0.8rem; border: 0.13rem solid var(--edge); border-radius: 0.75rem;
  background: #fff; font-size: 1.1rem; font-weight: 600; transition: box-shadow .12s, background-color .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); background: #f4f8ff; box-shadow: 0 0 0 0.22rem rgba(23,82,200,.28); }
textarea { min-height: 5rem; resize: vertical; font-weight: 500; }
input::placeholder, textarea::placeholder { color: #66726b; font-weight: 500; }
.moneybox { position: relative; }
.moneybox input.money { text-align: right; font-size: 1.25rem; font-weight: 800; padding-right: 2.6rem; }
.moneybox .unit { position: absolute; right: 0.9rem; top: 50%; transform: translateY(-50%); font-weight: 800; color: var(--muted); pointer-events: none; }
.bad, .bad:focus { border-color: var(--chi) !important; border-width: 0.18rem !important; background: #fff6f3 !important; }
.err-msg { display: flex; gap: 0.45rem; margin-top: 0.45rem; padding: 0.55rem 0.7rem; background: var(--chi-bg); color: #7a1b0b; border-left: 0.3rem solid var(--chi); border-radius: 0.45rem; font-weight: 700; font-size: 0.9rem; line-height: 1.4; }
.err-msg .ic { margin-top: 0.1rem; }

.banner { border-radius: var(--radius); padding: 0.8rem 0.9rem; margin-bottom: 1rem; font-weight: 700; line-height: 1.45; }
.banner .ic { margin-right: 0.4rem; }
.banner.err { background: var(--chi-bg); color: #7a1b0b; border: 0.15rem solid var(--chi); }
.banner.warn { background: var(--warn-bg); color: var(--warn-ink); border: 0.15rem solid #c79a00; }
.banner.info { background: var(--info-bg); color: var(--info-ink); border: 0.12rem solid #7ba3de; }
.banner ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.banner li { margin: 0.3rem 0; }
.linkbtn { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; font-weight: 800; font-size: inherit; text-align: left; }

/* ---------- nút ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 0.55rem; width: 100%; min-height: 3.4rem; padding: 0.6rem 1rem;
  border: 0.15rem solid var(--brand); background: var(--brand); color: #fff; border-radius: 0.9rem; font-weight: 800; font-size: 1.1rem; line-height: 1.25; text-align: center;
  transition: transform .08s, filter .08s;
}
.btn:active { transform: translateY(0.08rem); filter: brightness(.9); }
.btn.ghost { background: #fff; color: var(--brand); }
.btn.danger { background: var(--chi); border-color: var(--chi); }
.btn.danger.ghost { background: #fff; color: var(--chi); }
.btn.sm { width: auto; min-height: 2.8rem; font-size: 0.95rem; padding: 0.4rem 0.9rem; border-radius: 0.75rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn + .btn { margin-top: 0.6rem; }
.btn-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 10rem; margin: 0; }
.mt { margin-top: 1rem; }

/* ---------- chọn mục, nhóm nút ---------- */
.chips { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(4.8rem, 100%), 1fr)); gap: 0.6rem; }
.chips button { display: flex; align-items: center; justify-content: center; gap: 0.4rem; min-height: 3.4rem; border: 0.15rem solid var(--edge); background: #fff; border-radius: 0.9rem; font-weight: 800; font-size: 1.1rem; padding: 0.4rem; }
.chips button[aria-pressed=true] { background: var(--brand); border-color: var(--brand); color: #fff; }

.seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(5.2rem, 100%), 1fr)); gap: 0.5rem; margin-bottom: 0.9rem; }
.seg button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.2rem; min-height: 4.4rem; padding: 0.5rem 0.3rem; border: 0.15rem solid var(--edge); background: #fff; border-radius: 0.9rem; font-weight: 800; font-size: 0.95rem; line-height: 1.2; text-align: center; }
.seg button .ic { width: 1.7rem; height: 1.7rem; }
.seg button[aria-pressed=true] { background: var(--brand); border-color: var(--brand); color: #fff; }
.seg button[aria-pressed=true]::after {
  content: ""; position: absolute; top: 0.3rem; right: 0.3rem; width: 1.1rem; height: 1.1rem; border-radius: 50%; background: #fff no-repeat center / 70%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2314573f' stroke-width='3.500' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.500 4.500 4.500L19 7.500'/%3E%3C/svg%3E");
}
.seg-desc { margin: -0.3rem 0 1rem; color: var(--muted); font-size: 0.9rem; padding: 0 0.2rem; font-weight: 500; }

/* ---------- dòng hàng đã mua ---------- */
.item { position: relative; border: 0.12rem solid var(--line); border-radius: var(--radius); padding: 0.85rem; margin-bottom: 0.85rem; background: var(--paper); }
.item-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.6rem; }
.item-head .btn.sm { white-space: nowrap; }
.item-head b { font-size: 1.05rem; }
.item .field { margin-bottom: 0.6rem; }
/* nhiều ô trên một hàng: tự xếp theo bề rộng của THẺ chứa (container query, tính theo rem nên chữ to thì tự xuống dòng) */
.irow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 0.7rem; }
.irow > .full, .irow > .span-all { grid-column: 1 / -1; }
.cols2 > .field, .cols3 > .field { min-width: 0; }
.cols2, .cols3 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 0.8rem; }
.krow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 0.7rem; }
.savebar { display: grid; gap: 0.6rem; }
.savebar .total-line { margin: 0; }
.tl-inline { margin: 0; }
.soldbox { min-height: var(--tap); display: flex; align-items: center; padding: 0.4rem 0.8rem; border-radius: 0.75rem; background: var(--brand-soft); border: 0.13rem solid var(--brand-line); }
.soldbox b { font-size: 1.3rem; font-weight: 800; }
.ctlrow { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 0.8rem; margin-top: 0.9rem; }
.ctlrow:empty { display: none; }
.rgrid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 0.7rem; }
@container (min-width: 30rem) { .cols2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .ctlrow { grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); } .rgrid { grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); } }
@container (min-width: 34rem) {
  .irow.item4 { grid-template-columns: minmax(0, 2.3fr) minmax(0, 0.9fr) minmax(0, 1fr) minmax(0, 1.6fr); }
  .irow.item4 > .full { grid-column: auto; }
  .irow.item4 > .span-all { grid-column: 1 / -1; }
  .savebar { grid-template-columns: minmax(0, 1fr) minmax(14rem, 0.8fr); align-items: center; }
  .savebar .btn { margin: 0; }
}
@container (min-width: 36rem) { .cols3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .krow { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.total-line { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; margin: 1.05rem 0 0.9rem; padding: 0.75rem 0.85rem; background: var(--brand-soft); border-radius: var(--radius); border: 0.1rem solid var(--brand-line); font-weight: 700; }
.total-line b { font-size: 1.4rem; font-weight: 800; }

.photo { display: grid; gap: 0.7rem; }
.photo-btns { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.6rem; }
@container (min-width: 36rem) { .photo-btns { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.photo-btns .btn { margin: 0; cursor: pointer; }
.photo-list { display: grid; gap: 0.6rem; }
.btn.disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.photo-prev { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.sr-file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.photo label.pick { display: inline-flex; align-items: center; min-height: 3.2rem; gap: 0.5rem; border: 0.15rem dashed var(--edge); padding: 0.5rem 0.9rem; border-radius: 0.9rem; font-weight: 800; cursor: pointer; background: #fff; }
.photo img { width: 5rem; height: 5rem; object-fit: cover; border-radius: 0.7rem; border: 0.1rem solid var(--line); }
.photo input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }

details.how { margin-bottom: 1rem; background: #fff; border: 0.1rem solid var(--line-soft); border-radius: var(--radius); }
details.how summary { cursor: pointer; padding: 0.8rem 1rem; font-weight: 800; min-height: 3rem; display: flex; align-items: center; gap: 0.55rem; color: var(--brand); }
details.how .how-body { padding: 0 1rem 0.9rem; }
details.how ol, details.how ul, .dlg-body ol, .dlg-body ul { padding-left: 1.3rem; margin: 0.3rem 0; }
details.how li, .dlg-body li { margin: 0.35rem 0; }

/* ---------- tổng kết: "Còn lại" lớn + hai ô nhỏ Thu / Chi ---------- */
.stats { display: grid; gap: 0.6rem; }
.stat { border-radius: var(--radius); padding: 0.85rem 0.95rem; border: 0.13rem solid transparent; min-width: 0; }
.stat small { display: flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; font-weight: 800; }
.stat b, .tx .amt, .rowcard dd, .total-line b, .busy-title { overflow-wrap: break-word; }
.stat b { display: block; font-size: 1.5rem; line-height: 1.25; font-weight: 800; margin-top: 0.1rem; }
.stat .badge { display: inline-flex; align-items: center; gap: 0.35rem; margin-top: 0.3rem; padding: 0.15rem 0.6rem; border-radius: 2rem; font-size: 0.9rem; font-weight: 800; }
.stat.net { background: var(--brand); color: #fff; }
.stat.net b { font-size: 1.8rem; }
.stat.net .badge { background: rgba(255,255,255,.2); }
.stat.net.neg { background: var(--chi-bg); color: #7a1b0b; border-color: var(--chi); }
.stat.net.neg .badge { background: #fff; color: var(--chi); }
.stat-pair { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.6rem; }
@media (min-width: 38rem) { .stat-pair { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.stat.thu { background: var(--thu-bg); color: #08502a; border-color: #8fcba7; }
.stat.chi { background: var(--chi-bg); color: #7a1b0b; border-color: #e1a597; }

.summary { font-size: 1.05rem; line-height: 1.55; margin: 0 0 0.9rem; padding: 0.8rem 0.9rem; background: #fffbe6; border: 0.12rem solid #e0c96a; border-radius: var(--radius); font-weight: 600; }

.rowcard { border: 0.1rem solid var(--line-soft); border-radius: var(--radius); padding: 0.75rem 0.85rem; margin-bottom: 0.65rem; background: var(--paper); }
.rowcard h3 { margin: 0 0 0.35rem; font-size: 1.05rem; font-weight: 800; }
.rowcard dl { margin: 0; display: grid; grid-template-columns: auto 1fr; column-gap: 0.8rem; row-gap: 0.2rem; }
.rowcard dt { font-weight: 600; color: var(--muted); }
.rowcard dd { margin: 0; text-align: right; font-weight: 800; }
.rowcard dd.neg { color: var(--chi); }
.rowcard .note { margin-top: 0.3rem; color: var(--muted); font-size: 0.85rem; }

.bars .row { padding: 0.55rem 0; border-bottom: 0.08rem solid var(--line-soft); }
.bars .row:last-of-type { border-bottom: 0; }
.bars .d { font-weight: 800; margin-bottom: 0.2rem; }
.bars .b { height: 0.75rem; border-radius: 0.4rem; margin: 0.2rem 0; min-width: 0.2rem; }
.bars .b.thu { background: var(--thu); }
.bars .b.chi { background: var(--chi); }
.bars .v { font-size: 0.9rem; color: var(--muted); font-weight: 600; }

/* ---------- phiếu trong ngày (dòng sổ cái) ---------- */
.tx { border: 0.1rem solid var(--line-soft); border-left-width: 0.45rem; border-radius: var(--radius); padding: 0.75rem 0.85rem; margin-bottom: 0.75rem; background: var(--paper); }
.tx.chi { border-left-color: var(--chi); }
.tx.thu { border-left-color: var(--thu); }
.tx .t1 { display: flex; justify-content: space-between; gap: 0.6rem; align-items: baseline; flex-wrap: wrap; }
.tx .t1 b { font-size: 1.05rem; display: inline-flex; align-items: center; gap: 0.4rem; }
.tx .amt { font-weight: 800; font-size: 1.2rem; }
.tx .amt.chi { color: var(--chi); }
.tx .amt.thu { color: var(--thu); }
.tx .t2 { color: var(--muted); font-size: 0.9rem; margin: 0.2rem 0; }
.tx ul { margin: 0.3rem 0 0.5rem; padding-left: 1.2rem; }
.tx .acts { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
.tx a.img { color: var(--brand); font-weight: 800; text-decoration: none; }

.empty { text-align: center; color: var(--muted); padding: 1.3rem 0.5rem; font-weight: 600; }
.empty .ic { display: block; margin: 0 auto 0.4rem; width: 2rem; height: 2rem; opacity: .7; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.toolbar .when { color: var(--muted); font-size: 0.9rem; font-weight: 600; }
.ctx { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
.ctx > *, .field, .card { min-width: 0; }

/* ---------- các khoản chi: mỗi khoản một dòng (nội dung | số tiền) ---------- */
.rowline { padding: 0.65rem 0.8rem 0.2rem; margin-bottom: 0.65rem; }
.rowhead { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-bottom: 0.35rem; }
.rowhead .btn.sm { min-height: 2.6rem; white-space: nowrap; }
.rrow { grid-template-columns: minmax(0, 1fr); }
@container (min-width: 28rem) { .rrow { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); } }

/* ---------- phiếu tổng hợp chi + danh sách đóng/mở ---------- */
.sumslip > h2 { display: flex; align-items: center; gap: 0.5rem; }
.sumline { display: flex; justify-content: space-between; align-items: baseline; gap: 0.8rem; padding: 0.5rem 0; border-bottom: 0.1rem dashed var(--line); }
.sumline b { text-align: right; overflow-wrap: break-word; }
.sumline.total { margin-top: 0.2rem; padding: 0.7rem 0.85rem; border: 0.13rem solid var(--chi); border-radius: var(--radius); background: var(--chi-bg); color: #7a1b0b; font-weight: 800; font-size: 1.1rem; }
.sumline.total b { font-size: 1.4rem; }
.sumline.mini small { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.subh { margin: 1rem 0 0.2rem; font-size: 1rem; font-weight: 800; }
details.dd { margin-bottom: 1rem; background: #fff; border: 0.1rem solid var(--line-soft); border-radius: var(--radius); }
details.dd summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 0.7rem; min-height: 3.6rem; padding: 0.6rem 1rem; border-radius: var(--radius); }
details.dd summary::-webkit-details-marker { display: none; }
details.dd[open] summary { border-bottom: 0.1rem solid var(--line-soft); border-radius: var(--radius) var(--radius) 0 0; background: var(--brand-soft); }
.dd-t { display: flex; flex-direction: column; min-width: 0; }
.dd-t b { font-weight: 800; font-size: 1.05rem; }
.dd-t small { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
details.dd .when-open, details.dd[open] .when-closed { display: none; }
details.dd[open] .when-open { display: inline; }
.dd-ic { width: 2rem; height: 2rem; padding: 0.3rem; border-radius: 50%; background: var(--brand); color: #fff; transition: transform .18s; }
details.dd[open] .dd-ic { transform: rotate(180deg); }
.dd-body { padding: 0.9rem 0.85rem 0.2rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(22rem, 100%), 1fr)); gap: 0 0.8rem; align-items: start; }

/* ---------- đăng nhập ---------- */
.login { padding: 1.6rem 1rem 2rem; max-width: 30rem; margin: 0 auto; }
.login .logo { display: inline-flex; width: 3.6rem; height: 3.6rem; border-radius: 1rem; background: var(--brand); color: #fff; align-items: center; justify-content: center; margin-bottom: 0.7rem; }
.login .logo .ic { width: 2.1rem; height: 2.1rem; }
.login h1 { font-size: 1.7rem; margin: 0 0 0.3rem; font-weight: 800; letter-spacing: -0.01em; }
.login p.lead { margin: 0 0 1.1rem; font-size: 1.05rem; }
.login input#pin { font-size: 1.8rem; letter-spacing: 0.4rem; text-align: center; min-height: 4rem; }
.pinrow { display: flex; gap: 0.5rem; align-items: stretch; }
.pinrow input { flex: 1; min-width: 0; }
.pinrow button { flex: none; display: flex; align-items: center; justify-content: center; gap: 0.35rem; border: 0.15rem solid var(--edge); background: #fff; border-radius: 0.75rem; padding: 0 0.8rem; font-weight: 800; font-size: 0.95rem; min-width: 5.5rem; }

/* ---------- chờ, bộ khung xương, thanh tiến trình ---------- */
#progress { position: fixed; top: 0; left: 0; right: 0; height: 0.3rem; z-index: 90; overflow: hidden; opacity: 0; transition: opacity .2s; pointer-events: none; }
#progress.on { opacity: 1; }
#progress i { position: absolute; top: 0; bottom: 0; width: 40%; background: #ffd24d; animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { 0% { left: -40%; } 100% { left: 100%; } }

#netbar { position: sticky; top: 0; z-index: 80; background: #7a1b0b; color: #fff; padding: 0.7rem 0.9rem; font-weight: 800; text-align: center; display: flex; gap: 0.6rem; align-items: center; justify-content: center; }
#netbar[hidden] { display: none; }

.skel { background: linear-gradient(90deg, #e8e4d6 25%, #f4f1e6 50%, #e8e4d6 75%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; border-radius: var(--radius); height: 5rem; margin-bottom: 0.8rem; }
.skel.s { height: 2.2rem; width: 60%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.loading-note { display: flex; align-items: center; justify-content: center; gap: 0.5rem; text-align: center; color: var(--muted); font-weight: 700; margin: 0.4rem 0 0.9rem; }

.spinner { width: 3.2rem; height: 3.2rem; border-radius: 50%; border: 0.4rem solid #cfe3d9; border-top-color: var(--brand); animation: spin 0.9s linear infinite; margin: 0 auto 0.8rem; }
@keyframes spin { to { transform: rotate(360deg); } }

.busy { position: fixed; inset: 0; z-index: 200; background: rgba(15, 25, 20, .78); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.busy-card { background: #fff; border-radius: 1.1rem; padding: 1.5rem 1.2rem; max-width: 24rem; width: 100%; text-align: center; }
.busy-title { font-size: 1.3rem; font-weight: 800; margin-bottom: 0.4rem; }
.busy-text { margin: 0; }
.busy-slow { margin: 0.8rem 0 0; padding: 0.6rem; background: var(--warn-bg); color: var(--warn-ink); border-radius: 0.7rem; font-weight: 700; }
.btn .spinner { width: 1.4rem; height: 1.4rem; border-width: 0.22rem; margin: 0; border-color: rgba(255,255,255,.4); border-top-color: #fff; }
.btn.ghost .spinner { border-color: #cfe3d9; border-top-color: var(--brand); }

/* ---------- camera trực tiếp ---------- */
.cam { position: fixed; inset: 0; z-index: 140; background: #0e1512; color: #fff; display: flex; flex-direction: column; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.cam-top { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; padding: 0.6rem 0.9rem; font-size: 1.1rem; }
.cam-x, .cam-flip { display: inline-flex; align-items: center; gap: 0.4rem; min-height: 3rem; padding: 0.3rem 0.9rem; border: 0; border-radius: 0.8rem; background: rgba(255,255,255,.16); color: #fff; font-weight: 800; font-size: 0.95rem; }
.cam-view { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; background: #000; overflow: hidden; }
.cam-view video, .cam-view img { width: 100%; height: 100%; object-fit: contain; }
.cam-frame { position: absolute; inset: 8% 6%; border: 0.18rem dashed rgba(255,255,255,.85); border-radius: 0.8rem; pointer-events: none; }
.cam-tip { margin: 0; padding: 0.6rem 1rem; text-align: center; font-weight: 600; font-size: 0.95rem; line-height: 1.4; background: #0e1512; }
.cam-bar { display: flex; align-items: center; justify-content: space-between; gap: 0.7rem; padding: 0.7rem 1rem 1rem; }
.cam-bar .btn { flex: 1 1 0; margin: 0; }
.cam-spacer { width: 7rem; }
.cam-flip { width: 7rem; flex-direction: column; justify-content: center; font-size: 0.8rem; gap: 0.1rem; }
.cam-shutter { flex: none; width: 4.8rem; height: 4.8rem; border-radius: 50%; border: 0.28rem solid #fff; background: transparent; padding: 0.3rem; display: flex; }
.cam-shutter i { flex: 1; border-radius: 50%; background: #fff; transition: transform .08s; }
.cam-shutter:active i { transform: scale(.85); }

/* ---------- hộp thoại: bảng trượt từ đáy ---------- */
.dlg-back { position: fixed; inset: 0; z-index: 150; background: rgba(15, 25, 20, .72); display: flex; align-items: flex-end; justify-content: center; padding: 0; }
@media (min-width: 40rem) { .dlg-back { align-items: center; padding: 1rem; } }
.dlg { position: relative; background: #fff; width: 100%; max-width: 32rem; max-height: 92dvh; overflow: auto; border-radius: 1.2rem 1.2rem 0 0; padding: 1.5rem 1.1rem calc(1.2rem + env(safe-area-inset-bottom)); animation: sheet .2s ease-out; }
.dlg::before { content: ""; position: absolute; top: 0.5rem; left: 50%; width: 2.6rem; height: 0.3rem; margin-left: -1.3rem; border-radius: 0.2rem; background: var(--line); }
@keyframes sheet { from { transform: translateY(2rem); opacity: .4; } to { transform: none; opacity: 1; } }
@media (min-width: 40rem) { .dlg { border-radius: 1.2rem; } .dlg::before { display: none; } }
.dlg-icon { width: 3.6rem; height: 3.6rem; border-radius: 50%; margin: 0 auto 0.6rem; display: flex; align-items: center; justify-content: center; background: var(--brand-soft); color: var(--brand); }
.dlg-icon .ic { width: 2rem; height: 2rem; }
.dlg-icon.tone-ok { background: var(--thu-bg); color: var(--thu); }
.dlg-icon.tone-warn { background: var(--warn-bg); color: var(--warn-ink); }
.dlg-icon.tone-danger { background: var(--chi-bg); color: var(--chi); }
.dlg-icon.tone-ask { background: var(--info-bg); color: var(--info-ink); }
.dlg h2 { margin: 0 0 0.5rem; font-size: 1.3rem; text-align: center; line-height: 1.3; font-weight: 800; }
.dlg-body { font-size: 1.05rem; line-height: 1.55; }
.dlg-body .sum { margin: 0.7rem 0; padding: 0.7rem 0.8rem; background: #f1f4f2; border-radius: 0.8rem; }
.dlg-body .sum div { display: flex; justify-content: space-between; gap: 0.6rem; padding: 0.2rem 0; }
.dlg-body .sum b { text-align: right; }
.dlg .btn { margin-top: 0.7rem; }

#toast { position: fixed; left: 50%; bottom: 5.8rem; transform: translate(-50%, 1rem); background: #15201b; color: #fff; padding: 0.8rem 1.1rem; border-radius: 0.9rem; opacity: 0; transition: .25s; pointer-events: none; max-width: 92vw; font-weight: 700; z-index: 120; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- màn hình lớn ---------- */
@media (min-width: 36rem) {
  main { padding-left: 1.2rem; padding-right: 1.2rem; }
  .ctx { grid-template-columns: 1fr 1fr; gap: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
