/* Quản Lý Tạp Hóa (trang/tap-hoa.js). Màu chính xanh lá dịu; số tiền to màu cam để nổi bật. */
/* Đầu màn hình cố định 2 dòng: tên (dưới là Mã Game 50) và 3 tab. */
.th-dau { position: sticky; top: 0; z-index: 20; margin: 0 -16px; padding: 6px 16px 6px; background: var(--nen); border-bottom: 1px solid var(--vien); }
.th-ten { display: flex; align-items: center; gap: 8px; }
.th-logo { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; font-size: 20px; background: #d3f9d8; }
.th-ten h1 { flex: 1; min-width: 0; margin: 0; color: #2f9e44; font-size: 19px; font-weight: 900; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.th-ten h1 small { display: block; color: #e8590c; font-size: 12px; font-weight: 700; }
.th-ten .chia-se { flex: none; margin: 0; width: 36px; height: 36px; padding: 0; display: grid; place-items: center; border-radius: 50%; background: var(--nhan); color: #1c7ed6; }
.th-tab { display: grid; grid-template-columns: 1fr 1fr 1fr 44px; gap: 4px; margin-top: 6px; }
.th-tab[hidden] { display: none; }
.th-tab button { margin: 0; padding: 7px 1px; font-size: 13px; border-radius: 10px; background: var(--the); color: var(--mo); border: 1px solid var(--vien); white-space: nowrap; }
.th-tab button.chon { background: #2f9e44; color: #fff; border-color: #2f9e44; }
.th-cong { text-align: center; padding: 24px 0; }
.th-cong p { font-size: 17px; }
#th-dang-nhap[hidden] { display: none; }
/* Dòng nút của tab đang mở (Quét mã, Xong / Hàng mới), nằm trong phần đầu cố định. */
.th-thanh-nut { display: flex; gap: 6px; margin-top: 6px; }
.th-thanh-nut[hidden] { display: none; }
.th-thanh-nut button { flex: 1; margin: 0; padding: 9px 4px; border-radius: 12px; font-size: 15px; line-height: 1.2; white-space: nowrap; }
.th-thanh-nut button small { display: block; font-size: 12px; font-weight: 700; opacity: .95; }
.th-thanh-nut button small:empty { display: none; }
.th-quet { background: #1c7ed6; }
.th-xong, .th-xanh { background: #2f9e44; }
/* Lưới ô hàng 2 cột; hàng có lẻ và sỉ thì 2 ô nằm chung một hàng (.th-cum chiếm cả hàng). */
.th-luoi { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; grid-auto-flow: row dense; }
.th-cum { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.th-o { display: flex; flex-direction: column; gap: 1px; padding: 9px 9px 8px; background: var(--the); border: 2px solid var(--vien); border-radius: 14px; min-width: 0; }
.th-cum .th-o:first-child { border-left: 5px solid #74c0fc; }
.th-cum .th-o:last-child { border-left: 5px solid #ffa94d; }
.th-o.co { border-color: #40c057; background: color-mix(in srgb, #40c057 8%, var(--the)); }
.th-o-ten { font-size: 15px; line-height: 1.25; overflow-wrap: anywhere; }
.th-o-dv { color: var(--mo); font-size: 13px; }
.th-o-gia { color: #e8590c; font-weight: 900; font-size: 17px; }
.th-o-con { color: var(--mo); font-size: 12px; }
.th-o-con.het { color: #e03131; font-weight: 700; }
.th-o-buoc { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.th-tru, .th-cong-nut { flex: none; margin: 0; width: 40px; height: 40px; padding: 0; border-radius: 50%; font-size: 24px; line-height: 1; }
.th-tru { background: #e7f5ff; color: #1971c2; }
.th-tru:disabled { opacity: .35; }
.th-cong-nut { background: #2f9e44; color: #fff; }
.th-o-sl { min-width: 34px; text-align: center; font-size: 22px; font-weight: 900; color: #1c7ed6; }
/* Danh sách tổng mặt hàng */
.th-dem { color: var(--mo); font-size: 14px; margin: 0 0 6px; }
.th-the-hang { padding: 10px 12px; margin: 0 0 8px; background: var(--the); border: 1px solid var(--vien); border-left: 5px solid #40c057; border-radius: 12px; }
.th-the-dau { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 10px; }
.th-the-dau b { font-size: 17px; }
.th-ton { color: #1c7ed6; font-weight: 800; font-size: 14px; }
.th-ton.het { color: #e03131; }
.th-the-dong { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; padding-top: 6px; margin-top: 6px; border-top: 1px dashed var(--vien); font-size: 14px; }
.th-the-loai { color: var(--chu); font-weight: 700; }
.th-the-gia { display: flex; gap: 10px; justify-content: flex-end; }
.th-gn { color: var(--mo); }
.th-gb { color: #e8590c; font-weight: 800; }
.th-the-mv { grid-column: 1 / -1; color: var(--mo); font-family: ui-monospace, monospace; font-size: 12px; }
.nut-lon.th-nut-xanh, .th-nut-xanh { display: block; width: 100%; margin: 12px 0 8px; padding: 13px; border-radius: 12px; font-size: 17px; background: #2f9e44; }
.th-nut-do { background: #fff0f0; color: #e03131; }
/* Màn phụ (Thêm hàng mới, Nhập hàng cũ) */
.th-man[hidden] { display: none; }
#th-sua label, .th-hop label { margin-top: 10px; }
#th-sua input { background: var(--the); }
.th-h2 { margin: 0 0 4px; font-size: 17px; color: #2b8a3e; }
.th-h3 { margin: 14px 0 2px; font-size: 16px !important; color: #2b8a3e !important; text-align: left !important; }
.th-dv { padding: 10px; margin: 12px 0; border: 1px solid var(--vien); border-left: 4px solid #40c057; border-radius: 12px; background: var(--the); }
.th-dv + .th-dv { border-left-color: #ffa94d; }
.th-dv-hang { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.th-dv-hang > span { flex: none; color: var(--mo); font-size: 14px; }
.th-dv-hang > span:first-child { min-width: 68px; }
.th-dv-hang input { flex: 1; min-width: 0; }
.th-dv-nho { min-width: 0 !important; }
.th-nho-nut { flex: none; margin: 0; padding: 8px 12px; }
/* Hộp giữa màn hình (khung .tc-hop của tro-choi.js) */
.th-hop { width: min(420px, 100%); max-height: 90vh; overflow-y: auto; text-align: left; }
.th-hop h2 { color: #2b8a3e; font-size: 21px; text-align: center; overflow-wrap: anywhere; }
.th-hop input { background: #fff; color: #24324a; font-size: 18px; }
.th-hop label { color: #555; }
.th-hop .tc-nut { margin-top: 14px; flex-wrap: wrap; }
.th-hop .tc-nut button { min-width: 0; padding: 0 6px; font-size: 15px; background: linear-gradient(#51cf66, #37b24d); box-shadow: 0 3px 0 #2b8a3e; }
.th-hop .tc-nut button.phu { background: #eceef3; color: #444; box-shadow: 0 3px 0 #c9ccd6; }
.th-hop .th-nho, .th-nho { color: #6b7480; font-size: 14px; margin: 4px 0 8px; }
.th-hop .th-tong, .th-tong { text-align: right; font-size: 20px; font-weight: 900; color: #e8590c; margin: 10px 0 0; }
.th-hop .th-dv-hang > span { color: #555; }
.th-hop .th-dv-hang input { flex: none; width: 110px; text-align: right; }
.th-hop .th-dv-ten { flex: 1 !important; color: #24324a !important; font-size: 15px !important; }
.th-phieu-dong { padding: 8px 0; border-bottom: 1px solid #eee; color: #24324a; }
.th-nut-phu { display: flex; gap: 8px; margin-top: 12px; }
.th-nut-phu button { flex: 1; margin: 0; }
/* Hóa đơn, phiếu nhập (giấy in) */
.th-giay { background: #fff; color: #222; border: 1px dashed #bbb; border-radius: 6px; padding: 12px 10px; text-align: center; font-size: 14px; }
.th-giay-cua-hang { display: block; font-size: 16px; }
.th-giay-tieu-de { display: block; margin-top: 2px; font-size: 15px; letter-spacing: .5px; }
.th-giay-ngay { display: block; color: #666; margin-bottom: 8px; }
.th-giay table { width: 100%; border-collapse: collapse; font-size: 13px; }
.th-giay th, .th-giay td { padding: 4px 2px; border-bottom: 1px dotted #ccc; text-align: right; white-space: normal; }
.th-giay th:first-child, .th-giay td:first-child { text-align: left; }
.th-giay-tong { display: flex; justify-content: space-between; margin: 8px 0 0; font-size: 16px; }
.th-giay-tong b { color: #e8590c; font-size: 22px; }
.th-giay-cam-on { display: block; margin-top: 6px; color: #666; }
/* Cài đặt */
.th-the { margin-bottom: 12px; }
.th-the h2 { margin: 0 0 8px; font-size: 18px; color: #2b8a3e; }
.th-the > button { margin: 6px 6px 0 0; }
.th-ngay { display: flex; align-items: center; gap: 10px; }
.th-ngay b { flex: 1; text-align: center; font-size: 17px; }
.th-ngay button { margin: 0; width: 40px; height: 40px; padding: 0; border-radius: 50%; font-size: 24px; background: var(--nhan); color: var(--chinh-dam); }
.th-ngay button:disabled { opacity: .35; }
.th-so-lieu { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin: 10px 0; text-align: center; }
.th-so-lieu small { display: block; color: var(--mo); font-size: 13px; }
.th-so-lieu b { display: block; font-size: 21px; line-height: 1.2; }
.th-tien { color: #e8590c; font-weight: 900; }
.th-lai { color: #2f9e44; font-weight: 900; }
.th-dem-don { color: #1c7ed6; }
.th-don { display: flex; justify-content: space-between; width: 100%; margin: 0 0 6px; padding: 9px 12px; border-radius: 10px; background: var(--nen); color: var(--chu); border: 1px solid var(--vien); font-weight: 600; }
.th-gia-dong { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 10px; padding: 10px 4px; border-bottom: 1px solid var(--vien); user-select: none; -webkit-user-select: none; cursor: pointer; }
.th-gia-dong > span { display: flex; flex-wrap: wrap; gap: 10px; }
.th-han-chu { font-weight: 700; color: #2b8a3e; }
.th-han-chu.het { color: #e03131; }
.th-zalo { display: block; margin: 4px 0 8px; padding: 12px; border-radius: 12px; background: #0068ff; color: #fff; font-weight: 800; text-align: center; text-decoration: none; }
.th-gia-han label { margin-top: 8px; }
.th-dong { display: flex; align-items: center; justify-content: space-between; margin: 8px 0; }
.th-loa { margin: 0 !important; font-size: 20px; padding: 6px 14px; }
/* Quét mã vạch */
.th-quet-man { position: fixed; inset: 0; z-index: 60; background: #000; }
.th-quet-man video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.th-khung-quet { position: absolute; left: 10%; right: 10%; top: 26%; height: 24%; border: 4px solid #51cf66; border-radius: 16px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); }
.th-quet-chu { position: absolute; left: 12px; right: 12px; top: 12%; margin: 0; text-align: center; color: #fff; font-size: 18px; font-weight: 700; text-shadow: 0 1px 3px #000; }
.th-quet-duoi { position: absolute; left: 12px; right: 12px; bottom: 20px; }
.th-vua-quet { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; padding: 10px 12px; border-radius: 14px; background: #fff; color: #24324a; }
.th-vua-quet[hidden] { display: none; }
.th-vua-quet .th-chu { flex: 1; min-width: 0; }
.th-vua-quet .th-chu b { display: block; color: #2b8a3e; font-size: 16px; }
.th-vua-quet .th-chu small { color: #e8590c; font-weight: 800; }
.th-go { display: flex; gap: 8px; }
.th-go input { flex: 1; min-width: 0; background: #fff; color: #222; }
.th-go button { margin: 0; flex: none; }
/* Thông báo nhỏ dưới màn hình */
.th-bao { position: fixed; left: 16px; right: 16px; bottom: 30px; z-index: 70; padding: 12px 14px; border-radius: 12px; background: #2b8a3e; color: #fff; font-weight: 700; text-align: center;
  opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none; }
.th-bao.hien { opacity: 1; transform: none; }
.th-bao.loi { background: #e03131; }
/* Tem mã vạch */
.th-xem-tem { display: flex; justify-content: center; margin-top: 10px; }
.th-tem { display: inline-flex; flex-direction: column; align-items: center; width: 54mm; padding: 2mm; border: 1px dashed #999; background: #fff; color: #000; text-align: center; break-inside: avoid; }
.th-tem small { font-size: 10px; }
.th-tem b { font-size: 12px; line-height: 1.2; }
.th-tem svg { width: 100%; height: auto; max-height: 22mm; }
.th-tem-gia { font-size: 13px; font-weight: 800; }
#th-in { display: none; }
@media print {
  body > *:not(#th-in) { display: none !important; }
  #th-in { display: block !important; }
  #th-in.in-tem { display: flex !important; flex-wrap: wrap; gap: 2mm; }
  #th-in .th-giay { border: 0; max-width: 80mm; margin: 0 auto; }
  body { background: #fff; }
}
/* Tab Nhập hàng: mỗi món một dòng gọn, mỗi loại có − số + nhỏ. */
.th-nh { display: flex; align-items: center; gap: 6px; padding: 6px 8px; margin: 0 0 4px; background: var(--the); border: 1px solid var(--vien); border-radius: 10px; }
.th-nh-chu { flex: 1; min-width: 0; line-height: 1.25; }
.th-nh-chu b { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.th-nh-chu small { display: block; color: #1c7ed6; font-size: 12px; font-weight: 700; }
.th-nh-chu small.het { color: #e03131; }
.th-nh-nut { flex: none; display: flex; flex-direction: column; gap: 3px; }
.th-nh-buoc { display: flex; align-items: center; justify-content: flex-end; gap: 3px; }
.th-nh-dv { font-size: 12px; color: var(--mo); min-width: 34px; text-align: right; }
.th-nh-buoc .th-tru, .th-nh-buoc .th-cong-nut { width: 30px; height: 30px; font-size: 19px; }
.th-nh-buoc .th-o-sl { min-width: 26px; font-size: 17px; }
.th-nh-buoc.co .th-o-sl { color: #2f9e44; }
/* Hàng mới: một ô duy nhất */
.th-moi .th-dv-hang > span:first-child { min-width: 84px; color: #555; }
.th-moi .th-dv-hang input { flex: 1; min-width: 0; width: auto; text-align: left; }
.th-moi .th-dv-hang[hidden] { display: none; }
/* Cài đặt */
.th-ten-dong { display: flex; gap: 8px; align-items: center; }
.th-ten-dong b { flex: 1; font-size: 20px; color: #2f9e44; overflow-wrap: anywhere; }
.th-ten-dong input { flex: 1; min-width: 0; }
.th-ten-dong button { flex: none; margin: 0 !important; white-space: nowrap; }
.th-tong-thu { text-align: center; margin: 8px 0; color: #e8590c; font-size: 32px; font-weight: 900; line-height: 1.2; }
.th-ban-ngay table { width: 100%; border-collapse: collapse; font-size: 15px; }
.th-ban-ngay th, .th-ban-ngay td { padding: 6px 4px; border-bottom: 1px solid var(--vien); text-align: right; white-space: normal; }
.th-ban-ngay th:first-child, .th-ban-ngay td:first-child { text-align: left; }
.th-ban-ngay th { color: var(--mo); font-size: 13px; }
/* Cài đặt: nút rồi tới tên / ô mã trên cùng một dòng */
.th-dong-ch { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.th-dong-ch:first-child { margin-top: 0; }
.th-dong-ch button { flex: none; width: auto; margin: 0 !important; padding: 10px 14px; font-size: 15px; white-space: nowrap; }
.th-dong-ch input { flex: 1; min-width: 0; }
.th-ten-do { flex: 1; min-width: 0; color: #e03131; font-size: 17px; overflow-wrap: anywhere; }
.th-gia-han > input { width: 100%; margin-top: 8px; }
.th-hop .th-xoa-ten { font-size: 20px; font-weight: 800; color: #e03131; text-align: center; }
/* Cài đặt: 2 tab nhỏ Tổng thu / Đã nhập, ngày gọn */
.th-tab-nho { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.th-tab-nho button { margin: 0; padding: 7px 4px; font-size: 14px; border-radius: 10px; background: var(--the); color: var(--mo); border: 1px solid var(--vien); }
.th-tab-nho button.chon { background: #2f9e44; color: #fff; border-color: #2f9e44; }
#th-so-ngay .th-ngay b { font-size: 15px; }
#th-so-ngay .th-ngay button { width: 32px; height: 32px; font-size: 20px; }
#th-so-ngay .th-tong-thu { font-size: 26px; margin: 4px 0; }
.th-gia-ds { background: var(--the); border: 1px solid var(--vien); border-radius: 14px; padding: 4px 12px; }
/* .chon chung của trang là display:flex, giữ nút tab đang chọn căn giữa như các nút khác */
.th-tab button.chon, .th-tab-nho button.chon { display: flex; justify-content: center; align-items: center; margin: 0; }
/* Đăng nhập bằng số điện thoại */
.th-dn { max-width: 360px; margin: 8px auto 0; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.th-dn[hidden] { display: none; }
.th-dn input { width: 100%; font-size: 18px; }
.th-dn button { margin: 0 !important; width: 100%; }
/* Dòng gợi ý nhỏ trên danh sách Giá cả (Duong 2026-10-26) */
.th-goi-y-nho { margin: 10px 0 2px; padding: 6px 12px; border-radius: 10px; background: #fff3bf; color: #e8590c; font-size: 14px; font-weight: 700; }
.th-hop .th-ten-o input { flex: 1; width: auto; text-align: left; }
/* Bán hàng: sắp hết thì ô vàng cam, hết hàng thì ô xám mờ (Duong 2026-10-26) */
.th-o.sap-het { background: #fff4e6; border-color: #ffa94d; }
.th-o.sap-het .th-o-con { color: #e8590c; font-weight: 700; }
.th-o.het { background: #f1f3f5; border-color: #dee2e6; opacity: .65; }
#th-ban .th-cong-nut:disabled, #th-vua-quet .th-cong-nut:disabled { background: #ced4da; box-shadow: none; opacity: 1; }
/* Không cho bôi chọn chữ, sao chép, tra từ khi ấn lâu (Duong 2026-10-27); ô nhập vẫn gõ và dán được. */
body { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
input, textarea, [contenteditable] { user-select: text; -webkit-user-select: text; -webkit-touch-callout: default; }
.th-sap-dong { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 8px 0; border-bottom: 1px solid var(--vien); }
.th-sap-dong > b { flex: 1 1 100%; font-size: 15px; }
.th-sap-o { display: flex; align-items: center; gap: 4px; color: #555; font-size: 14px; }
.th-hop .th-sap-o input { width: 64px; margin: 0; text-align: right; }
