:root {
  --nen: #f4f6f7;
  --the: #ffffff;
  --chu: #1c2528;
  --phu: #66757b;
  --vien: #dde3e5;
  --chinh: #0f766e;
  --chinh-dam: #0b5a54;
  --chinh-nhat: #e3f4f2;
  --do: #c0392b;
  --do-nhat: #fdecea;
  --cam: #b7791f;
  --cam-nhat: #fff4dc;
  --xanh: #1f8a4c;
  --ban-kinh: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 16px/1.45 system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--nen);
  color: var(--chu);
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; }
h2.tieu-de { font-size: 1.4rem; margin: 0; }
h2.tieu-de-lon { font-size: 2.2rem; font-weight: 800; letter-spacing: .3px; color: var(--chinh-dam); }
h3 { font-size: 1.05rem; }
h4 { font-size: .95rem; margin-top: 1.2em; color: var(--phu); }
a { color: var(--chinh); }
b { font-weight: 650; }
small, .phu { color: var(--phu); font-size: .88rem; }
.do { color: var(--do); }
.xanh { color: var(--xanh); }

/* ---------- Khung ---------- */
#vo { display: flex; min-height: 100vh; }
#thanh-ben {
  width: 220px; background: #12302d; color: #d6ebe8; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; flex-shrink: 0;
}
.thuong-hieu { padding: 18px 16px; font-weight: 700; font-size: 1.1rem; color: #fff; border-bottom: 1px solid #ffffff22; }
#thanh-ben nav { flex: 1; padding: 8px; overflow-y: auto; }
#thanh-ben a, #thanh-duoi a, #menu-them a {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 8px; color: inherit; text-decoration: none; font-weight: 500;
}
#thanh-ben a:hover { background: #ffffff14; }
#thanh-ben a.noi-bat { font-size: 1.3rem; font-weight: 800; letter-spacing: .3px; padding: 15px 12px; margin-bottom: 6px; background: #ffffff1f; border-left: 5px solid #5eead4; }
#thanh-ben a.noi-bat .bt { font-size: 1.5rem; }
#thanh-ben a.noi-bat.on { background: var(--chinh); border-left-color: #fff; }
#thanh-ben a.on { background: var(--chinh); color: #fff; }
.nguoi-dung { padding: 12px; border-top: 1px solid #ffffff22; display: flex; flex-direction: column; gap: 8px; font-size: .9rem; }
#noi-dung { flex: 1; min-width: 0; padding: 20px 24px 40px; }
#thanh-duoi, #menu-them { display: none; }

/* ---------- Nút & ô nhập ---------- */
button, .nut-lon, .nut-phu, .nut-do { font: inherit; cursor: pointer; }
.nut-lon, .nut-phu, .nut-do {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 8px; padding: 10px 16px;
  border: 1px solid transparent; text-decoration: none; font-weight: 600; min-height: 44px; text-align: center;
}
.nut-lon { background: var(--chinh); color: #fff; }
.nut-lon:hover { background: var(--chinh-dam); }
.nut-phu { background: var(--the); color: var(--chu); border-color: var(--vien); }
.nut-phu:hover { background: #eef2f3; }
.nut-do { background: var(--do-nhat); color: var(--do); border-color: #f1c4be; }
button:disabled { opacity: .5; cursor: not-allowed; }
.rong-het { width: 100%; }
input, select, textarea {
  font: inherit; color: inherit; background: #fff; border: 1px solid #c8d1d4; border-radius: 8px; padding: 9px 11px; min-height: 42px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--chinh); outline-offset: -1px; border-color: var(--chinh); }
input[type=radio], input[type=checkbox] { width: auto; min-height: 0; }
input:disabled { background: #f0f2f3; }
.dn-quen { margin: 14px 0 0; text-align: center; font-size: .95rem; }
.ma-khoi-phuc { font: 700 1.5rem/1.3 ui-monospace, Consolas, monospace; letter-spacing: 2px; text-align: center; background: var(--chinh-nhat); color: var(--chinh-dam); border: 2px dashed var(--chinh); border-radius: var(--ban-kinh); padding: 16px 10px; margin: 12px 0; user-select: all; word-break: break-all; }
.o-mk { position: relative; }
.o-mk input { padding-right: 48px; }
.nut-mat { position: absolute; top: 0; bottom: 0; right: 2px; width: 44px; display: flex; align-items: center; justify-content: center; background: none; border: 0; border-radius: 8px; color: var(--phu); }
.nut-mat:hover { color: var(--chinh); }
.nut-mat svg { width: 22px; height: 22px; }
.truong { margin-bottom: 12px; }
.truong label, .giam-hang label, #p-tm > label { display: block; font-size: .88rem; color: var(--phu); margin-bottom: 4px; font-weight: 600; }
.nhom { display: flex; gap: 8px; }
.nhom select { width: 80px; flex-shrink: 0; }
.o-loc { margin: 10px 0 14px; }
.hang-nut { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.thanh-tren { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }

.card { background: var(--the); border: 1px solid var(--vien); border-radius: var(--ban-kinh); padding: 16px; margin-bottom: 16px; }
.luoi-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.luoi-2 > .card { margin-bottom: 0; }
.luoi-2 + .card, .luoi-2 + .hang-nut { margin-top: 16px; }
.trong { text-align: center; padding: 30px 12px; color: var(--phu); }
.khung { background: #f7f9f9; border: 1px solid var(--vien); border-radius: 8px; padding: 12px; margin: 12px 0; }
.ok-khung { margin-top: 14px; padding: 12px; background: var(--chinh-nhat); border-radius: 8px; }

/* ---------- Chip, badge ---------- */
.chip-hang { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--vien); background: #fff; border-radius: 999px; padding: 7px 14px; font-weight: 600; color: var(--phu); min-height: 38px; }
.chip.on { background: var(--chinh); border-color: var(--chinh); color: #fff; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 650; background: #e8ecee; color: #44525a; white-space: nowrap; }
.tt-nhap { background: #e8ecee; }
.tt-da_len_don { background: #dbeafe; color: #1d4ed8; }
.tt-dang_giao { background: var(--cam-nhat); color: var(--cam); }
.tt-da_giao { background: #dcf5e6; color: var(--xanh); }
.tt-hoan { background: var(--do-nhat); color: var(--do); }
.tt-huy { background: #eee; color: #888; }

/* ---------- Bảng ---------- */
.cuon { overflow-x: auto; }
.bang { width: 100%; border-collapse: collapse; background: #fff; }
.bang th, .bang td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--vien); vertical-align: middle; }
.bang th { font-size: .82rem; color: var(--phu); font-weight: 650; background: #f7f9f9; white-space: nowrap; }
.bang .so, th.so { text-align: right; white-space: nowrap; }
.bang.bam tbody tr { cursor: pointer; }
.bang.bam tbody tr:hover { background: var(--chinh-nhat); }
.bang tr.huy td { color: #999; text-decoration: line-through; }
.bang.sua input { min-height: 36px; padding: 5px 8px; }
.nut-dong { white-space: nowrap; }
.nut-dong button { min-height: 36px; padding: 5px 10px; margin-left: 4px; }

/* ---------- Danh sách dạng thẻ ---------- */
.ds-the { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.the-don { display: block; width: 100%; text-align: left; background: #fff; border: 1px solid var(--vien); border-radius: var(--ban-kinh); padding: 12px 14px; color: inherit; text-decoration: none; }
.the-don:hover { border-color: var(--chinh); }
.td-1, .td-3 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.td-2 { color: var(--phu); font-size: .9rem; margin: 3px 0; }
.td-3 { font-size: .88rem; color: var(--phu); }
.td-3 b { color: var(--chu); font-size: 1rem; }

/* ---------- Tổng quan ---------- */
.the-so { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 14px 0; }
.so-the { background: #fff; border: 1px solid var(--vien); border-radius: var(--ban-kinh); padding: 14px; display: flex; flex-direction: column; gap: 2px; color: inherit; text-decoration: none; }
.so-the span { color: var(--phu); font-size: .85rem; font-weight: 600; }
.so-the b { font-size: 1.5rem; }
.so-the small { color: var(--phu); }
.so-the.canh { border-color: #e6a23c; background: var(--cam-nhat); }
a.so-the:hover { border-color: var(--chinh); }
.chon-ngay { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
.chon-ngay label { font-weight: 600; font-size: .9rem; display: flex; align-items: center; gap: 6px; }
.chon-ngay input { width: auto; }

/* ---------- Tìm hàng ---------- */
.o-tim { position: relative; margin-bottom: 12px; }
.tim-input { font-size: 1.1rem; padding: 12px 14px; border: 2px solid var(--chinh); }
.tim-kq { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; background: #fff; border: 1px solid var(--vien); border-radius: 8px; box-shadow: 0 8px 24px #0002; max-height: 340px; overflow-y: auto; margin-top: 4px; }
.tim-dong { display: flex; flex-direction: column; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--vien); padding: 10px 12px; }
.tim-dong:hover, .tim-dong:focus { background: var(--chinh-nhat); outline: none; }
.tim-dong.het .tim-ten { color: var(--do); }
.tim-ten { font-weight: 600; }
.tim-phu { font-size: .85rem; color: var(--phu); }
.tim-trong { padding: 14px; color: var(--phu); }

/* ---------- Giỏ hàng ---------- */
.gio-trong { padding: 28px 12px; text-align: center; color: var(--phu); border: 2px dashed var(--vien); border-radius: 8px; }
.gio { container: gio / inline-size; }
.g-dau, .g-dong { display: grid; grid-template-columns: minmax(0, 1fr) 128px 130px 110px 36px; gap: 8px; align-items: center; }
.g-dau.g-nhap, .g-dong.g-nhap { grid-template-columns: minmax(0, 1fr) 128px 120px 120px 110px 36px; }
.g-dau { font-size: .8rem; color: var(--phu); font-weight: 650; padding: 4px 4px 6px; }
.g-dong { padding: 8px 4px; border-top: 1px solid var(--vien); }
.g-dong.qua-ton { background: var(--do-nhat); }
.g-dong.qua-ton .g-ton { color: var(--do); font-weight: 650; }
.g-ten { display: flex; flex-direction: row; gap: 10px; align-items: center; min-width: 0; }
.g-ten-txt { display: flex; flex-direction: column; min-width: 0; }
.g-ten small { overflow: hidden; text-overflow: ellipsis; }
.g-sl { display: flex; }
.g-sl button { width: 36px; min-height: 42px; border: 1px solid #c8d1d4; background: #f0f3f4; font-size: 1.2rem; }
.g-sl button:first-child { border-radius: 8px 0 0 8px; }
.g-sl button:last-child { border-radius: 0 8px 8px 0; }
.g-sl input { border-radius: 0; text-align: center; width: 52px; padding: 4px; -moz-appearance: textfield; }
.g-sl input::-webkit-outer-spin-button, .g-sl input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.g-o input { text-align: right; }
.g-tt { text-align: right; font-weight: 650; }
.g-xoa { background: none; border: 0; color: var(--phu); font-size: 1.1rem; min-height: 40px; }
.g-xoa:hover { color: var(--do); }

/* ---------- Bán hàng ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; margin-top: 12px; }
.pos .card { margin-bottom: 0; }
.pos-phai { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 10px; }
.pos-trai .gio { min-height: 220px; }
.tong-dong { display: flex; justify-content: space-between; padding: 4px 0; }
.tong-lon { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 0; border-top: 2px solid var(--chu); margin-top: 6px; font-weight: 700; }
.tong-lon b { font-size: 1.7rem; color: var(--chinh); }
.chon-pt { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chon-pt label { display: block; }
.chon-pt input { position: absolute; opacity: 0; pointer-events: none; }
.chon-pt span { display: block; text-align: center; padding: 11px 6px; border: 2px solid var(--vien); border-radius: 8px; font-weight: 650; cursor: pointer; }
.chon-pt input:checked + span { border-color: var(--chinh); background: var(--chinh-nhat); color: var(--chinh-dam); }
.goi-y { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.goi-y button { border: 1px solid var(--vien); background: #fff; border-radius: 6px; padding: 6px 10px; font-weight: 600; }
#p-tt { font-size: 1.15rem; min-height: 54px; }
.tu-in { display: flex; gap: 8px; align-items: center; font-size: .9rem; color: var(--phu); }

.bill-xong { text-align: center; }
.bill-xong .so-lon { font-size: 2.2rem; font-weight: 800; color: var(--chinh); }
.bill-xong .thoi { font-size: 1.3rem; margin: 10px 0; }
.bill-xong .hang-nut { justify-content: center; }

/* ---------- Ma trận tồn kho ---------- */
.mt-sp { padding: 12px 14px; }
.mt-dau { display: flex; justify-content: space-between; margin-bottom: 8px; }
table.mt { border-collapse: collapse; }
table.mt th, table.mt td { border: 1px solid var(--vien); padding: 8px 14px; text-align: center; min-width: 54px; }
table.mt thead th { background: #f7f9f9; font-size: .85rem; }
table.mt tbody th { text-align: left; background: #f7f9f9; font-weight: 600; white-space: nowrap; }
td.o-ton { cursor: pointer; font-weight: 650; font-size: 1.05rem; }
td.o-ton:hover { outline: 2px solid var(--chinh); outline-offset: -2px; }
td.o-ton.sap { background: var(--cam-nhat); color: var(--cam); }
td.o-ton.het { background: var(--do-nhat); color: var(--do); }
td.rong { color: #bbb; }
td.tong-c { background: #f7f9f9; font-weight: 700; }
.the-ma { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 8px; }
.the-ma > div { display: flex; flex-direction: column; }
.the-ma .so-lon { font-size: 2rem; }

/* ---------- Ô mã vạch nổi bật ---------- */
.ma-vach-o { display: inline-block; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-weight: 700; font-size: .95em; letter-spacing: .3px; color: var(--chinh-dam); background: #f0fbf9; border: 2px solid var(--chinh); border-radius: 8px; padding: 2px 9px; cursor: copy; white-space: nowrap; }
.ma-vach-o:hover { background: var(--chinh); color: #fff; }

/* ---------- Danh sách mẫu gộp, mở ra các phiên bản ---------- */
.ds-mau { display: flex; flex-direction: column; gap: 8px; }
.mau-hang { background: #fff; border: 1px solid var(--vien); border-radius: var(--ban-kinh); overflow: hidden; }
.mau-hang.mo { border-color: var(--chinh); }
.mau-dong { display: flex; align-items: center; gap: 12px; padding: 10px 12px; cursor: pointer; }
.mau-dong:hover { background: #f4fbfa; }
.mau-mui { width: 18px; color: var(--chinh); font-weight: 700; flex-shrink: 0; }
.mau-ten { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mau-vach, .mau-ton, .mau-ngay { white-space: nowrap; }
.mau-ct { padding: 4px 12px 12px 42px; border-top: 1px dashed var(--vien); background: #fbfdfd; }
@media (max-width: 760px) {
  .mau-dong { flex-wrap: wrap; }
  .mau-ten { flex-basis: calc(100% - 100px); }
  .mau-ct { padding-left: 12px; }
}

/* ---------- Bảng theo mã vạch, kiểm kê nhanh ---------- */
.bang-vach .in-tt { width: 90px; text-align: right; font-weight: 700; border: 2px solid var(--chinh); padding: 6px 8px; min-height: 38px; }
.bang-vach tr.da-sua td { background: #fffbeb; }
.bang-vach td { padding-top: 6px; padding-bottom: 6px; }
.thanh-luu.trang { position: sticky; bottom: 0; margin: 12px -4px 0; padding: 12px 8px; box-shadow: 0 -6px 16px #0001; border-radius: 10px 10px 0 0; }
@media (max-width: 900px) { .thanh-luu.trang { bottom: 60px; } }

/* ---------- Màn sửa sản phẩm ---------- */
.sua-dau { display: flex; gap: 16px; align-items: flex-start; }
.sua-truong { flex: 1; min-width: 0; }
.sua-dau .anh-khung { flex-direction: column; align-items: stretch; width: 120px; margin: 0; gap: 6px; flex-shrink: 0; }
.sua-dau .anh-khung .thumb { width: 110px !important; height: 110px !important; }
.sua-dau .anh-khung label, .sua-dau .anh-khung button { min-height: 36px; padding: 6px 8px; font-size: .85rem; }
.bang.sua .r-tt { border-color: var(--chinh); font-weight: 700; }
@media (max-width: 640px) { .sua-dau { flex-direction: column; } }

/* ---------- Sản phẩm: tìm kiếm gọn, bộ lọc ẩn, nút ＋ nổi (như Sapo) ---------- */
.sp-tim { display: flex; gap: 8px; align-items: stretch; }
.sp-tim input { flex: 1; min-width: 0; font-size: 1.05rem; padding: 11px 14px; border-radius: 999px; background: #eef2f3; border-color: transparent; }
.sp-tim input:focus { background: #fff; }
.nut-loc { display: inline-flex; align-items: center; gap: 6px; position: relative; border: 1px solid var(--vien); background: #fff; color: var(--chu); border-radius: 999px; padding: 0 16px; font-weight: 600; min-height: 44px; }
.nut-loc svg { width: 20px; height: 20px; }
.nut-loc.on { border-color: var(--chinh); color: var(--chinh-dam); background: var(--chinh-nhat); }
.nut-loc i { font-style: normal; min-width: 20px; height: 20px; border-radius: 10px; background: var(--chinh); color: #fff; font-size: .78rem; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; }
.nut-loc i[hidden] { display: none; }
.sp-loc { background: #fff; border: 1px solid var(--vien); border-radius: var(--ban-kinh); padding: 4px 14px 8px; margin: 10px 0; }
.sp-loc[hidden] { display: none; }
#sp-che { margin-bottom: 8px; }
.sp-gach { color: var(--vien); margin: 0 4px; }
.fab { display: none; }
@media (max-width: 900px) {
  .sp-them-pc { display: none; }
  .fab { display: flex; position: fixed; right: 16px; bottom: 78px; z-index: 25; width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--chinh); color: #fff; font-size: 2rem; line-height: 1; align-items: center; justify-content: center; box-shadow: 0 6px 18px #0004; }
  .the-sp { padding: 10px 12px; }
}

/* Màn chi tiết: gọn, ít phải vuốt. Mỗi mã (size/màu) là một thẻ: tên + giá, rồi Tồn máy / Tồn thực tế / Lệch; chi tiết gấp lại */
.bang.sua td.c-tt, .tieu-ma small { display: none; }
.sua-truong .giu-2 { grid-template-columns: 1fr 1fr; gap: 0 10px; }
.sua-truong .truong { margin-bottom: 8px; }
details.gop { border: 1px solid var(--vien); border-radius: 10px; margin: 10px 0; background: #fff; }
details.gop > summary { cursor: pointer; padding: 11px 14px; font-weight: 600; min-height: 44px; display: flex; align-items: center; gap: 6px; }
details.gop[open] > summary { border-bottom: 1px solid var(--vien); }
details.gop > :not(summary) { margin: 10px 14px 12px; }
@media (max-width: 640px) {
  .sua-dau { flex-direction: row; gap: 12px; }
  .sua-dau .anh-khung { width: 88px; flex-direction: column; align-items: stretch; gap: 6px; }
  .sua-dau .anh-khung .thumb { width: 88px !important; height: 88px !important; }
  .sua-dau .anh-khung small { display: none; }
  .tieu-ma small { display: inline; }
  .bang.sua, .bang.sua tbody { display: block; }
  .bang.sua thead { display: none; }
  .bang.sua tr[data-id] { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 10px; padding: 10px 12px; margin-bottom: 8px; background: #fff; border: 1px solid var(--vien); border-radius: 10px; }
  .bang.sua tr[data-id].da-sua { background: #fffbeb; }
  .bang.sua tr[data-id] td { display: block; padding: 0; border: 0; background: none !important; text-align: left; order: 2; }
  .bang.sua tr[data-id] td::before { content: attr(data-l); display: block; font-size: .78rem; color: var(--phu); font-weight: 600; margin-bottom: 2px; }
  .bang.sua tr[data-id] td.c-tt { display: block; grid-column: 1 / -1; order: 0; }
  .bang.sua tr[data-id] td.c-tt::before { content: none; }
  .bang.sua tr[data-id] td.so { order: 1; }
  .bang.sua tr[data-id] td.so b { font-size: 1.15rem; line-height: 40px; }
  .bang.sua tr[data-id] td.r-cl { line-height: 40px; font-size: 1.15rem; }
  .bang.sua tr[data-id] td.so::before { line-height: 1.45; }
  .bang.sua tr[data-id] td.c-sua { display: none; }
  .bang.sua tr[data-id].mo td.c-sua { display: block; }
  .bang.sua tr[data-id] td.c-bc, .bang.sua tr[data-id] td.nut-dong { grid-column: 1 / -1; }
  .bang.sua tr[data-id] td.nut-dong::before { content: none; }
  .bang.sua tr[data-id] td input { width: 100% !important; text-align: left !important; }
  .bang.sua tr[data-id] td.so input { text-align: center !important; }
  .bang.sua tr[data-id] td.nut-dong .nut-do { width: 100%; min-height: 40px; }
  .vt-1 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 1.05rem; }
  .vt-2 { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--phu); font-size: .85rem; }
  .vt-sua { min-height: 32px; padding: 3px 12px; font-size: .85rem; }
  .thanh-luu { gap: 6px 8px; padding: 8px 0; }
  .thanh-luu .phu { flex-basis: 100%; font-size: .85rem; margin: 0; }
  .thanh-luu #e-lydo { flex: 1 1 100%; max-width: none; min-width: 0; }
  .thanh-luu button { flex: 1; min-height: 42px; }
}

/* ---------- Mã sau tên, thanh lưu ---------- */
.ma-tag { display: inline-block; background: var(--chinh-nhat); color: var(--chinh-dam); font-weight: 700; font-size: .85em; border-radius: 6px; padding: 0 7px; margin-left: 4px; white-space: nowrap; vertical-align: baseline; }
.thanh-luu { position: sticky; bottom: -16px; background: #fff; border-top: 1px solid var(--vien); padding: 12px 0; margin-top: 14px; display: flex; gap: 10px; justify-content: flex-end; align-items: center; flex-wrap: wrap; z-index: 3; }
.thanh-luu .phu { margin-right: auto; }
.thanh-luu .co-doi { color: var(--cam); font-weight: 700; }
.bang.sua th, .bang.sua td { padding: 6px 5px; }
.bang.sua input { padding: 5px 7px; }
.bang.sua tr.da-sua td { background: #fffbeb; }
.khoa-chu { background: var(--cam-nhat); border: 1px solid #f0d9a4; color: #7c4a03; border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }

/* ---------- Bộ lọc ---------- */
.bo-loc { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-bottom: 10px; }
.bo-loc label { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: .9rem; }
.bo-loc input[type=date], .bo-loc select { width: auto; }

/* ---------- Ảnh mẫu hàng ---------- */
.thumb { border-radius: 8px; object-fit: cover; flex-shrink: 0; background: #eef2f3; }
.trong-anh { display: inline-flex; align-items: center; justify-content: center; color: #9aa7ac; font-weight: 700; }
.the-sp { display: flex; gap: 12px; align-items: center; }
.the-sp .td-1, .the-sp .td-2, .the-sp .td-3 { margin: 0; }
.the-sp > div { flex: 1; min-width: 0; }
.tim-dong { flex-direction: row !important; align-items: center; gap: 10px; }
.tim-dong > span:last-child, .tim-dong > div { min-width: 0; }
.tim-chu { display: flex; flex-direction: column; min-width: 0; }
.g-ten-hang { display: flex; gap: 10px; align-items: center; min-width: 0; }
.mt-dau .ten-sp { display: flex; align-items: center; gap: 10px; }
.anh-lon { width: 160px; height: 160px; border-radius: 12px; object-fit: cover; background: #eef2f3; }
.anh-khung { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 6px 0 14px; }
.anh-khung .nut-xoa-anh { margin-left: 4px; }

/* ---------- Cân bằng kho, báo cáo ---------- */
.can-bang { border-radius: var(--ban-kinh); padding: 12px 14px; margin: 12px 0; display: flex; flex-direction: column; gap: 4px; }
.can-bang.khop { background: var(--chinh-nhat); border: 1px solid #b6e0da; color: var(--chinh-dam); }
.can-bang.lech { background: var(--do-nhat); border: 1px solid #f1c4be; color: var(--do); }
.can-bang ul { margin: 4px 0; padding-left: 20px; }
.bang tr.tong-hang td { background: #f7f9f9; border-top: 2px solid var(--chu); }

/* ---------- Hộp thoại ---------- */
dialog.hop { border: 0; border-radius: 12px; padding: 0; width: min(560px, 94vw); max-height: 92vh; box-shadow: 0 20px 60px #0005; color: inherit; background: #fff; }
dialog.hop.rong { width: min(960px, 96vw); }
dialog.hop::backdrop { background: #0006; }
.hop-dau { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--vien); position: sticky; top: 0; background: #fff; z-index: 2; }
.hop-dau h3 { margin: 0; }
.nut-x { border: 0; background: #eef2f3; border-radius: 8px; width: 38px; height: 38px; font-size: 1rem; }
.hop-than { padding: 16px; overflow-y: auto; max-height: calc(92vh - 70px); }
.them-ma input, .them-ma button { flex: 1; min-width: 0; }

/* ---------- Đăng nhập ---------- */
.dn { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.dn-hop { width: min(400px, 100%); }
#goc-dn { min-height: 100vh; }

/* ---------- Thông báo ---------- */
#thong-bao { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 9999; width: min(520px, 94vw); pointer-events: none; }
.tb { padding: 12px 16px; border-radius: 10px; background: #1c2528; color: #fff; box-shadow: 0 6px 20px #0004; font-weight: 600; }
.tb.loi { background: var(--do); }

/* ---------- Bill in 80mm ---------- */
#in-an { display: none; }
@media print {
  @page { size: 80mm auto; margin: 0; }
  body.dang-in > *:not(#in-an) { display: none !important; }
  body.dang-in { background: #fff; }
  body.dang-in #in-an { display: block; }
  .bill { width: 72mm; margin: 0 auto; padding: 3mm 0; font: 12px/1.35 "Segoe UI", Arial, sans-serif; color: #000; }
  .b-giua { text-align: center; }
  .b-lon { font-size: 16px; font-weight: 700; }
  .b-lon2 { font-size: 15px; }
  .b-dam { font-weight: 700; }
  .b-gach { border-top: 1px dashed #000; margin: 4px 0; }
  .b-dong { display: flex; justify-content: space-between; gap: 6px; }
  .b-ten { margin-top: 3px; }
}

/* ---------- Điện thoại ---------- */
@media (max-width: 900px) {
  #thanh-ben { display: none; }
  #noi-dung { padding: 14px 12px 90px; }
  #thanh-duoi {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    background: #12302d; padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  }
  #thanh-duoi a { flex-direction: column; gap: 2px; font-size: .72rem; padding: 6px 2px; color: #cfe5e1; text-align: center; }
  #thanh-duoi a.on { background: var(--chinh); color: #fff; }
  #thanh-duoi .bt { font-size: 1.3rem; line-height: 1; }
  #menu-them { position: fixed; right: 8px; bottom: 74px; z-index: 40; background: #12302d; border-radius: 12px; padding: 6px; min-width: 200px; box-shadow: 0 8px 30px #0006; }
  #menu-them:not([hidden]) { display: block; }
  #menu-them a { color: #fff; }
  #menu-them a.on { background: var(--chinh); }
  .pos { grid-template-columns: 1fr; }
  .pos-phai { position: static; }
  .luoi-2 { grid-template-columns: 1fr; }
  .ds-the { grid-template-columns: 1fr; }
  #thong-bao { bottom: 90px; }
}
@container gio (max-width: 620px) {
  .g-dau { display: none; }
  .g-dong, .g-dong.g-nhap { grid-template-columns: 1fr 36px; grid-template-areas: "ten xoa" "sl sl" "gia gia" "tt tt"; row-gap: 6px; }
  .g-dong.g-nhap { grid-template-areas: "ten xoa" "sl sl" "gia gia" "gb gb" "tt tt"; }
  .g-ten { grid-area: ten; }
  .g-xoa { grid-area: xoa; }
  .g-sl { grid-area: sl; }
  .g-sl input { flex: 1; width: auto; }
  .g-o1 { grid-area: gia; }
  .g-o2 { grid-area: gb; }
  .g-tt { grid-area: tt; }
  .g-tt::before { content: "Thành tiền: "; color: var(--phu); font-weight: 400; }
}
@media (max-width: 640px) {
  dialog.hop { width: 100vw; max-width: 100vw; max-height: 100vh; height: 100vh; border-radius: 0; }
  .hop-than { max-height: calc(100vh - 66px); }
  table.mt th, table.mt td { padding: 8px 9px; }
}
