/* Chứng từ đơn (27/09/2026) — mục trong chi tiết hóa đơn + nhãn danh sách + khối "Của tôi". Tiền tố ctd-.
   Một bề mặt (không thẻ lồng thẻ), bo tối đa 8px, token theme (7 theme), nút ≥ 44px, focus rõ, có reduced motion.
   Chọn lọc ".ctd .ctd-…" để thắng luật chung ".backend-mode button / label / input" của màn chi tiết hóa đơn. */
.ctd { margin: 14px 0; padding: 14px 16px 16px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-card); color: var(--text-main); overflow-wrap: anywhere; }
.ctd .ctd-ic { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; }
.ctd .ctd-dau { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-bottom: 8px; }
.ctd .ctd-dau h3 { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 16px; font-weight: 650; }
/* 17/10: số thứ tự phần (1 hóa đơn mới · 2 máy thu khách) khi HĐ có thu máy. */
.ctd .ctd-so { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; font-size: 13px; font-weight: 700; color: #fff; background: var(--theme-accent-strong, #0071e3); }
.ctd .ctd-ghi-phan { margin-top: 8px; }
.ctd .ctd-han { flex-basis: 100%; margin: 0; font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.ctd .ctd-han strong { color: var(--text-main); font-weight: 600; }
/* Trạng thái: chữ + màu + icon (không chỉ màu). */
.ctd-tt, .ctd-nhan { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap; }
.ctd-tt .ctd-ic, .ctd-nhan .ctd-ic { width: 14px; height: 14px; stroke: currentColor; fill: none; flex: none; }
.ctd-tt.is-ok, .ctd-nhan.is-ok { background: color-mix(in srgb, var(--txt-ok, #1d7a3a) 14%, transparent); color: var(--txt-ok, #1d7a3a); }
.ctd-tt.is-warn, .ctd-nhan.is-warn { background: color-mix(in srgb, var(--txt-warn, #9a5200) 14%, transparent); color: var(--txt-warn, #9a5200); }
.ctd-tt.is-bad, .ctd-nhan.is-bad { background: color-mix(in srgb, var(--txt-bad, #c0262d) 12%, transparent); color: var(--txt-bad, #c0262d); }
.ctd-tt.is-idle { background: var(--bg-card-hover, rgba(0,0,0,.05)); color: var(--text-muted); }
.ctd-nhan { white-space: normal; }
.ctd .ctd-khoa, .ctd .ctd-goi-y { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 10px; padding: 8px 10px; border-radius: 8px; font-size: 13px; line-height: 1.45; }
.ctd .ctd-khoa { border-left: 3px solid var(--txt-warn, #9a5200); background: var(--bg-card-hover, rgba(0,0,0,.04)); }
.ctd .ctd-khoa .ctd-ic { width: 16px; height: 16px; margin-top: 2px; color: var(--txt-warn, #9a5200); }
.ctd .ctd-goi-y { padding: 0; color: var(--text-muted); }
.ctd .ctd-bao { margin: 0 0 8px; font-size: 13px; color: var(--txt-ok, #1d7a3a); font-weight: 600; }
.ctd .ctd-loi { margin: 4px 0 8px; font-size: 13px; color: var(--txt-bad, #c0262d); }
.ctd .ctd-muc { padding: 12px 0 4px; border-top: 1px solid var(--border-color); }
.ctd .ctd-muc h4 { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; font-size: 13px; font-weight: 650; color: var(--text-muted); }
.ctd .ctd-muc h4 label { display: inline; font: inherit; color: inherit; }
.ctd .ctd-dem { min-width: 20px; padding: 0 6px; border-radius: 6px; background: var(--bg-card-hover, rgba(0,0,0,.05)); color: var(--text-main); font-size: 12px; text-align: center; font-variant-numeric: tabular-nums; }
.ctd .ctd-trong-nho { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; font-size: 13px; color: var(--text-muted); }
.ctd .ctd-trong { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 8px 0 0; font-size: 14px; color: var(--text-muted); }
.ctd .ctd-trong.is-loi { color: var(--txt-bad, #c0262d); }
.ctd .ctd-trong p { margin: 0; }
.ctd .ctd-quay { width: 16px; height: 16px; border: 2px solid var(--border-color); border-top-color: var(--theme-accent-strong, #0071e3); border-radius: 50%; animation: ctd-quay .8s linear infinite; }
@keyframes ctd-quay { to { transform: rotate(360deg); } }
.ctd .ctd-o-m { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.ctd .ctd-luoi .ctd-o-m { font-size: 11.5px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctd .ctd-sau { display: inline-block; margin-top: 2px; font-size: 12px; font-weight: 600; color: var(--txt-warn, #9a5200); }
/* Lưới ảnh: ô 104px (điện thoại 3 cột co giãn). */
.ctd .ctd-luoi { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; margin: 0 0 10px; padding: 0; }
.ctd .ctd-o { position: relative; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ctd .ctd-o-xem { display: block; width: 100%; min-height: 0; padding: 0; border: 0; background: none; border-radius: 8px; cursor: zoom-in; }
.ctd .ctd-anh { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-card-hover, rgba(0,0,0,.04)); }
.ctd .ctd-anh-f { display: grid; place-items: center; color: var(--text-muted); text-align: center; }
.ctd .ctd-anh-f.is-cho { opacity: .7; }
.ctd .ctd-o-t { font-size: 12px; font-weight: 600; line-height: 1.3; }
/* Vùng chạm xóa giữ nguyên 44×44px (chuẩn cảm ứng), phần hộp hiển thị gọn 26×26px ở góc phải trên để không che khuất 1/4 ảnh缩略. */
.ctd .ctd-btn.ctd-o-xoa { position: absolute; top: 0; right: 0; padding: 4px; border-color: transparent; background: transparent; align-items: flex-start; justify-content: flex-end; }
.ctd .ctd-btn.ctd-o-xoa:hover { border-color: transparent; }
.ctd .ctd-btn.ctd-o-xoa .ctd-ic { width: 26px; height: 26px; padding: 5px; box-sizing: border-box; border-radius: 6px; border: 1px solid var(--border-color); background: color-mix(in srgb, var(--bg-card) 92%, transparent); color: var(--text-main); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.ctd .ctd-btn.ctd-o-xoa:hover .ctd-ic { border-color: var(--txt-bad, #c0262d); color: var(--txt-bad, #c0262d); }
.ctd .ctd-o.is-tai .ctd-anh { opacity: .6; }
.ctd .ctd-o.is-loi .ctd-anh { opacity: .45; }
.ctd .ctd-o-loi { font-size: 12px; color: var(--txt-bad, #c0262d); line-height: 1.3; }
.ctd .ctd-o-nut { display: flex; gap: 4px; }
.ctd .ctd-tien { display: block; height: 6px; margin-top: 4px; border-radius: 3px; background: var(--bg-card-hover, rgba(0,0,0,.08)); overflow: hidden; }
.ctd .ctd-tien i { display: block; height: 100%; background: var(--theme-accent-strong, #0071e3); transition: opacity .2s linear; }
/* Danh sách file */
.ctd .ctd-dsf { list-style: none; margin: 0 0 10px; padding: 0; }
.ctd .ctd-dsf > li + li { border-top: 1px solid var(--border-color); }
.ctd .ctd-f { display: flex; align-items: center; gap: 10px; padding: 6px 0; min-width: 0; }
.ctd .ctd-dsf .ctd-o.is-tai { display: grid; grid-template-columns: 44px 1fr; align-items: center; column-gap: 10px; padding: 6px 0; }
.ctd .ctd-dsf .ctd-o.is-tai .ctd-anh { width: 44px; aspect-ratio: 1; grid-row: span 3; }
.ctd .ctd-f-ic { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 8px; background: var(--bg-card-hover, rgba(0,0,0,.04)); color: var(--text-muted); flex: none; }
.ctd .ctd-f-b { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.ctd .ctd-f-t { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Nút + chọn file (input ẩn, nhãn là nút 44px). */
.ctd .ctd-them { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 4px 0 6px; }
.ctd .ctd-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; min-width: 44px; margin: 0; padding: 0 16px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-card); color: var(--text-main); font: inherit; font-size: 14px; font-weight: 600; line-height: 1.2; cursor: pointer; white-space: nowrap; flex: 0 0 auto; }
.ctd .ctd-btn:hover { border-color: var(--theme-accent-strong, #0071e3); }
.ctd .ctd-btn:disabled { opacity: .5; cursor: not-allowed; }
.ctd .ctd-btn.ctd-chinh { background: var(--theme-accent-strong, #0071e3); border-color: var(--theme-accent-strong, #0071e3); color: #fff; }
html[data-itn-theme="graphite"] .ctd .ctd-btn.ctd-chinh, html[data-itn-theme="gold-noir"] .ctd .ctd-btn.ctd-chinh { color: var(--bg-app); }
.ctd .ctd-btn.ctd-nguy { background: var(--theme-danger, #c0262d); border-color: var(--theme-danger, #c0262d); color: #fff; }
.ctd .ctd-btn.ctd-sm { padding: 0 12px; font-size: 13px; }
.ctd .ctd-btn.ctd-icon { padding: 0; width: 44px; }
.ctd .ctd-an { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip: rect(0 0 0 0); pointer-events: none; }
.ctd .ctd-btn:focus-within, .ctd :focus-visible { outline: 2px solid var(--theme-accent-strong, #0071e3); outline-offset: 2px; }
.ctd label.ctd-btn { display: inline-flex; flex: 0 0 auto; }
.ctd .ctd-chon { display: flex; flex-direction: column; gap: 4px; flex: 0 1 240px; min-width: 0; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.ctd .ctd-chon select { min-height: 44px; width: 100%; padding: 0 10px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-input, var(--bg-card)); color: var(--text-main); font: inherit; font-size: 14px; }
/* Ghi chú */
.ctd textarea { display: block; width: 100%; box-sizing: border-box; min-height: 88px; padding: 10px 12px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-input, var(--bg-card)); color: var(--text-main); font: inherit; font-size: 15px; line-height: 1.45; resize: vertical; }
.ctd textarea[aria-invalid="true"] { border-color: var(--txt-bad, #c0262d); }
.ctd .ctd-gc-chan { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0 4px; }
.ctd .ctd-gc-doc { margin: 0 0 6px; font-size: 14px; line-height: 1.5; }
/* Lịch sử */
.ctd .ctd-ls { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border-color); font-size: 13px; }
.ctd .ctd-ls summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; font-weight: 600; color: var(--text-muted); }
.ctd .ctd-ls ol { margin: 0; padding: 0 0 0 18px; }
.ctd .ctd-ls li { padding: 4px 0; }
.ctd .ctd-ls-ct { display: block; color: var(--text-muted); white-space: pre-line; }
/* Hộp xác nhận xoá + xem ảnh lớn (nền mờ, giữa màn; điện thoại tấm đáy). */
.ctd.ctd-hop { margin: 0; padding: 0; border: 0; background: none; }
.ctd-hoi-bg { position: fixed; inset: 0; z-index: 130; background: rgba(0,0,0,.45); }
.ctd .ctd-hoi, .ctd .ctd-lon { position: fixed; z-index: 131; left: 50%; top: 12vh; transform: translateX(-50%); width: min(440px, calc(100vw - 32px)); max-height: 76vh; overflow: auto; padding: 18px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-main); box-shadow: 0 12px 32px rgba(0,0,0,.2); }
.ctd .ctd-hoi h2 { margin: 0 0 8px; font-size: 17px; }
.ctd .ctd-hoi p { margin: 0 0 12px; font-size: 14px; line-height: 1.45; }
.ctd .ctd-hang-nut { display: flex; justify-content: flex-end; gap: 8px; }
.ctd .ctd-lon { width: min(760px, calc(100vw - 32px)); top: 6vh; max-height: 88vh; padding: 12px; }
.ctd .ctd-lon header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.ctd .ctd-lon header strong { flex: 1; font-size: 15px; }
.ctd .ctd-lon img { display: block; max-width: 100%; max-height: 72vh; margin: 0 auto; border-radius: 8px; }
/* Khối "Của tôi" */
.ctd.ctd-toi { margin: 0 0 16px; }
.ctd .ctd-toi-ds { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border-color); }
.ctd .ctd-toi-ds > li + li { border-top: 1px solid var(--border-color); }
.ctd .ctd-toi-dong { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 52px; padding: 6px 2px; color: var(--text-main); text-decoration: none; }
.ctd .ctd-toi-dong:hover { background: var(--bg-card-hover, rgba(0,0,0,.03)); }
.ctd .ctd-toi-b { display: flex; flex-direction: column; min-width: 0; }
.ctd .ctd-toi-b strong { font-size: 14px; font-weight: 600; }
/* Nhãn trong danh sách hóa đơn (app.js) */
.kv-hd-dong .ctd-nhan, .inv-ct-khung .ctd-nhan { margin-top: 2px; }
@media (max-width: 760px) {
  .ctd { padding: 12px; }
  .ctd .ctd-luoi { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .ctd .ctd-them .ctd-chon { flex: 1 1 100%; }
  .ctd .ctd-them label.ctd-btn { flex: 0 0 auto; }
  .ctd .ctd-them > .ctd-o-m { flex: 1 1 180px; line-height: 1.4; }
  .ctd .ctd-hoi { top: auto; bottom: 0; left: 0; transform: none; width: 100%; border-radius: 8px 8px 0 0; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .ctd .ctd-lon { top: 0; left: 0; transform: none; width: 100%; height: 100%; max-height: none; border-radius: 0; padding-top: calc(12px + env(safe-area-inset-top, 0px)); padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); box-sizing: border-box; }
  .ctd .ctd-lon img { max-height: calc(100vh - 90px); }
}
/* 18/10/2026 — Xem ảnh chứng từ: toàn màn nền tối, chừa vùng an toàn, X + Tải về luôn thấy, ảnh vừa khung, phóng / kéo / vuốt. */
.ctd .ctd-xem { position: fixed; inset: 0; z-index: 131; display: flex; flex-direction: column; background: #0b0b0c; color: #fff; }
.ctd .ctd-xem-dau { flex: none; display: flex; align-items: center; gap: 8px; padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left)); background: rgba(20,20,22,.96); border-bottom: 1px solid rgba(255,255,255,.08); }
.ctd .ctd-xem-ten { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ctd .ctd-xem-ten strong { font-size: 15px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctd .ctd-xem-ten span { font-size: 12px; color: rgba(255,255,255,.65); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctd .ctd-xem-nut { flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 44px; min-height: 44px; padding: 0 12px; border: 1px solid rgba(255,255,255,.22); border-radius: 8px; background: rgba(255,255,255,.08); color: #fff; font: 600 14px/1 inherit; cursor: pointer; }
.ctd .ctd-xem-dong { padding: 0; width: 44px; background: rgba(255,255,255,.16); }
.ctd .ctd-xem-nut:focus-visible, .ctd .ctd-xem-zoom button:focus-visible, .ctd .ctd-xem-chuyen:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.ctd .ctd-xem-than { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; padding: 8px; touch-action: none; -webkit-user-select: none; user-select: none; }
.ctd .ctd-xem-hinh { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; transform-origin: 50% 50%; transition: transform .14s ease-out; cursor: zoom-in; -webkit-user-drag: none; -webkit-touch-callout: none; }
.ctd .ctd-xem-than.is-phong .ctd-xem-hinh { cursor: grab; }
.ctd .ctd-xem-than.is-keo .ctd-xem-hinh { transition: none; cursor: grabbing; }
.ctd .ctd-xem-cho { display: flex; align-items: center; gap: 8px; color: rgba(255,255,255,.75); font-size: 14px; }
.ctd .ctd-xem-chuyen { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 64px; border: 0; border-radius: 8px; background: rgba(0,0,0,.45); color: #fff; font-size: 34px; line-height: 1; cursor: pointer; }
.ctd .ctd-xem-chuyen.is-truoc { left: max(8px, env(safe-area-inset-left)); }
.ctd .ctd-xem-chuyen.is-sau { right: max(8px, env(safe-area-inset-right)); }
.ctd .ctd-xem-zoom { position: absolute; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 2px; padding: 4px; border: 1px solid rgba(255,255,255,.25); border-radius: 8px; background: rgba(32,32,32,.88); box-shadow: 0 6px 18px rgba(0,0,0,.45); }
.ctd .ctd-xem-zoom button { min-width: 44px; min-height: 44px; border: 0; border-radius: 8px; background: transparent; color: #fff; font: 600 20px/1 inherit; cursor: pointer; }
.ctd .ctd-xem-zoom [data-ctd-ty] { font-size: 13px; font-variant-numeric: tabular-nums; padding: 0 6px; }
.ctd .ctd-xem-zoom button:disabled { opacity: .4; cursor: default; }
@media (max-width: 760px) { .ctd .ctd-xem-nut span { display: none; } .ctd .ctd-xem-nut { padding: 0; width: 44px; } .ctd .ctd-xem-chuyen { width: 38px; height: 56px; font-size: 28px; } }
@media (prefers-reduced-motion: reduce) {
  .ctd .ctd-quay { animation: none; }
  .ctd .ctd-tien i { transition: none; }
}
