/* Phần mềm nội bộ Lý Thành Phát */
:root {
  --ink-navy: #0f1f33; --link: #1e40af;
  --navy: #1d4ed8; --navy-2: #2f6aa3; --gold: #3b82f6; --gold-dark: #94702c;
  --bg: #f5f7fa; --card: #fff; --line: #e5e7eb; --line-2: #eef2f6;
  --text: #1f2937; --muted: #556070; --green: #12784a; --green-bg: #e8f5ee;
  --red: #c62828; --red-bg: #fdecec; --amber: #a15c00; --amber-bg: #fff4dc; --blue-bg: #eaf1ff;
  --radius: 10px; --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
p { margin: 0 0 10px; }
small { font-size: 12.5px; }
kbd { font: 12px/1 "Segoe UI", sans-serif; padding: 3px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: #fff; color: var(--muted); }
.muted { color: var(--muted); }
.r { text-align: right; }
.b { font-weight: 600; }
.neg { color: var(--red); font-weight: 600; }
.neg a { color: inherit; }
.warn { color: var(--amber); font-weight: 600; }
.grow { flex: 1; }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { border: 1px solid #d0d7e2; border-radius: 7px; padding: 8px 10px; background: #fff; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(47, 106, 163, .35); outline-offset: 0; border-color: var(--navy-2); }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--navy); vertical-align: -3px; }
textarea { resize: vertical; width: 100%; }
label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
label > input, label > select, label > textarea, label > .sg { display: block; width: 100%; margin-top: 4px; font-weight: 400; color: var(--text); }
label .sg input { width: 100%; }
.hint { display: block; font-weight: 400; color: var(--muted); margin-top: 3px; min-height: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border: 1px solid #d0d7e2; border-radius: 8px; background: #fff; color: var(--text); font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn:hover { background: #f3f5f8; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #1d1503; }
.btn.gold:hover { background: #d6b470; }
.btn.ghost { background: transparent; border-color: rgba(255, 255, 255, .45); color: #fff; }
.btn.ghost:hover { background: rgba(255, 255, 255, .12); }
.btn.danger { color: var(--red); border-color: #efc1c1; }
.btn.danger:hover { background: var(--red-bg); }
.btn.big { padding: 11px 22px; font-size: 16px; }
.btn.small { padding: 5px 10px; font-size: 13.5px; }
.btn:disabled { opacity: .5; cursor: default; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* Thanh trên */
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 18px; padding: 0 20px; height: 58px; background: var(--navy); color: #fff; border-bottom: 2px solid var(--gold); }
.logo { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none !important; }
.logo img { height: 40px; width: auto; padding: 4px 7px; border-radius: 8px; background: #fff; }
.logo span { font-weight: 700; line-height: 1.15; white-space: nowrap; }
.logo small { display: block; font-weight: 400; font-size: 11.5px; color: #cbd5e1; letter-spacing: .08em; text-transform: uppercase; }
.nav { display: flex; gap: 2px; flex: 1; min-width: 0; }
.nav a { padding: 8px 12px; border-radius: 7px; color: #e6edf5; font-weight: 600; white-space: nowrap; text-decoration: none; }
.nav a:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.nav a.on { background: rgba(255, 255, 255, .16); color: #fff; }
.nav-toggle { display: none; background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.me { position: relative; }
.me summary { list-style: none; cursor: pointer; padding: 5px 10px; border-radius: 7px; font-weight: 600; line-height: 1.15; }
.me summary::-webkit-details-marker { display: none; }
.me summary:hover { background: rgba(255, 255, 255, .1); }
.me summary small { display: block; font-weight: 400; color: #cbd5e1; font-size: 11.5px; }
.me-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 190px; background: #fff; color: var(--text); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(15, 23, 42, .18); padding: 6px; }
.me-menu a, .me-menu button { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; background: none; border-radius: 7px; color: var(--text); cursor: pointer; text-decoration: none; }
.me-menu a:hover, .me-menu button:hover { background: var(--bg); }
.me-menu form { border-top: 1px solid var(--line-2); margin-top: 4px; padding-top: 4px; }

.main { max-width: 1240px; margin: 0 auto; padding: 22px 20px 60px; }
.main.wide { max-width: 1560px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head p { margin: 0; }
.crumb { font-size: 13px; margin: 0 0 2px; color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.card-head a { font-size: 13.5px; }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.empty { text-align: center; padding: 60px 20px; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 600; white-space: pre-line; }
.alert.good { background: var(--green-bg); color: var(--green); }
.alert.bad { background: var(--red-bg); color: var(--red); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; background: #b6bdc9; }
.dot.good { background: var(--green); }

/* Tổng quan */
.hello { margin-bottom: 14px; }
.actions3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 16px; }
.act { position: relative; display: block; padding: 20px 22px; border-radius: 12px; background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--text); text-decoration: none !important; transition: transform .12s, box-shadow .12s; }
.act:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(15, 23, 42, .12); }
.act b { display: block; font-size: 19px; margin-bottom: 4px; }
.act span { color: var(--muted); font-size: 14px; }
.act kbd { position: absolute; top: 14px; right: 14px; }
.act.xuat { background: var(--navy); border-color: var(--navy); color: #fff; }
.act.xuat span { color: #cbd5e1; }
.act.xuat kbd { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .3); color: #fff; }
.act.nhap { border-left: 5px solid var(--green); }
.act.shot { border-left: 5px solid var(--gold); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat { display: block; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--text); text-decoration: none !important; box-shadow: var(--shadow); }
a.stat:hover { border-color: #b8c4d4; }
.stat span { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
.stat b { display: block; font-size: 23px; letter-spacing: -.01em; margin: 2px 0; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); }
.stat.alert { background: var(--amber-bg); border-color: #f0d9a4; margin: 0; white-space: normal; }
.stat.alert b { color: var(--amber); }
.guide { border-left: 5px solid var(--gold); }
.guide ol { margin: 0; padding-left: 22px; }
.guide li { margin: 6px 0; }
.guide li.done { color: var(--muted); text-decoration: line-through; }
.more { margin: 10px 0 0; font-size: 13.5px; }

/* Bảng */
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fff; }
.tbl th.r { text-align: right; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.tbl td small { display: block; color: var(--muted); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl.click tbody tr[data-href] { cursor: pointer; }
.tbl.click tbody tr[data-href]:hover { background: #f6f8fc; }
.tbl td.none { text-align: center; color: var(--muted); padding: 26px 10px; }
.tbl td.code { font-family: Consolas, "Courier New", monospace; font-size: 13.5px; color: #3b4a66; white-space: nowrap; }
.tbl td.in { color: var(--green); }
.tbl td.out { color: #9a3412; }
.tbl td.clip { max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tbl td.acts { white-space: nowrap; text-align: right; }
.tbl td.acts button, .inline-form button { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 3px 9px; font-size: 13px; cursor: pointer; color: var(--muted); }
.tbl td.acts button:hover, .inline-form button:hover { color: var(--text); border-color: #b8c4d4; }
.tbl tr.off td { color: #9aa3b2; }
.tbl tfoot td { padding: 10px; font-weight: 700; border-top: 2px solid var(--line); background: #fafbfc; position: sticky; bottom: 0; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.tag.xuat { background: var(--blue-bg); color: var(--link); }
.tag.nhap { background: var(--green-bg); color: var(--green); }
.bar-cell { width: 28%; min-width: 80px; }
.bar-cell i { display: block; height: 10px; margin-top: 6px; border-radius: 5px; background: linear-gradient(90deg, var(--navy-2), var(--gold)); min-width: 2px; }

/* Bảng kiểu Excel */
.sheet-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; max-height: calc(100vh - 250px); }
.tbl.grid th { position: sticky; top: 0; z-index: 2; background: #f3f5f8; border-bottom: 1px solid #d5dbe3; }
.tbl.grid td, .tbl.grid th { border-right: 1px solid var(--line-2); }
.tbl.grid td:last-child, .tbl.grid th:last-child { border-right: 0; }
.tbl.grid tbody tr:nth-child(even) { background: #fafbfd; }
.tbl.edit td[data-f] { cursor: cell; }
.tbl.edit td[data-f]:hover { box-shadow: inset 0 0 0 1px #9db0d6; background: #f5f8ff; }
.tbl.edit td.editing { padding: 0; box-shadow: inset 0 0 0 2px var(--navy-2); }
.tbl.edit td.editing input, .tbl.edit td.editing select { width: 100%; border: 0; border-radius: 0; padding: 8px 10px; background: #fff; outline: 0; }
.tbl.edit td.saving { opacity: .5; }
.tbl.edit td.saved { background: var(--green-bg) !important; transition: background .3s; }

.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.filters label { display: flex; align-items: center; gap: 6px; font-weight: 400; color: var(--text); font-size: 14px; }
.filters label > input { margin: 0; width: auto; }
.filters input[type=search] { flex: 1 1 240px; max-width: 380px; }
.filters.inline { margin: 0; }
.check { display: flex !important; align-items: center; gap: 7px; font-weight: 400 !important; color: var(--text) !important; font-size: 14px !important; flex-wrap: wrap; }
.check > input { width: 17px !important; margin: 0 !important; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { padding: 4px 12px; border: 1px solid var(--line); border-radius: 20px; background: #fff; font-size: 13.5px; color: var(--text); text-decoration: none !important; }
.chip:hover { border-color: #b8c4d4; }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.tabs-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; align-items: center; }
.tabs-row .filters { margin: 0; }
.tabs { display: inline-flex; background: #e6e9f0; border-radius: 9px; padding: 3px; }
.tab { padding: 6px 14px; border-radius: 7px; color: var(--muted); font-weight: 600; font-size: 14px; text-decoration: none !important; }
.tab.on { background: #fff; color: var(--text); box-shadow: var(--shadow); }
.addrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 14px; }
.addrow b { margin-right: 4px; }
.addrow input[name=name] { flex: 1 1 220px; }
.addrow input[name=ship_address] { flex: 2 1 220px; }
.w-xs { width: 84px; } .w-s { width: 150px; }
section > .addrow { padding: 14px 0 6px; }

/* Biểu mẫu */
.form h2 { margin-top: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 16px; margin-bottom: 18px; }
.form.narrow { max-width: 420px; display: grid; gap: 12px; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; }
.inline-form input { padding: 4px 8px; width: 150px; font-size: 13px; }

/* Lập phiếu */
.vc-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.vc-head p { margin: 0; }
.vc-meta { display: flex; gap: 10px; }
.vc-meta input { width: 150px; font-weight: 600; }
.vc-body { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.vc.has-shot .vc-body { grid-template-columns: minmax(0, 1fr) minmax(340px, 34%); }
.vc-main { margin: 0; }
.vc.xuat .vc-main { border-top: 4px solid var(--navy); }
.vc.nhap .vc-main { border-top: 4px solid var(--green); }
.vc-partner { display: grid; grid-template-columns: 2fr 3fr 1.3fr 1.2fr 1.2fr; gap: 10px 12px; margin-bottom: 14px; }
.vc-partner .hint { min-height: 17px; color: var(--green); }
.lines-wrap { border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; }
.lines { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; min-width: 720px; }
.lines th { background: #f3f5f8; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 8px 8px; text-align: left; border-bottom: 1px solid #d5dbe3; white-space: nowrap; }
.lines th.r { text-align: right; }
.lines td { padding: 4px 4px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.lines tbody tr:last-child td { border-bottom: 0; }
.lines input { width: 100%; border-color: transparent; background: transparent; padding: 7px 8px; }
.lines input:hover { border-color: #d0d7e2; }
.lines input:focus { background: #fff; }
.lines .p-name { font-weight: 600; }
.lines .c-stt { width: 44px; text-align: center; color: var(--muted); padding-top: 12px; }
.lines .c-unit { width: 60px; padding-top: 12px; color: var(--muted); }
.lines .c-qty { width: 96px; } .lines .c-price { width: 126px; } .lines .c-note { width: 16%; }
.lines .c-amt { width: 130px; padding: 12px 10px 0; font-weight: 600; }
.lines .c-x { width: 34px; }
.lines .x { border: 0; background: none; color: #a3acbb; cursor: pointer; padding: 8px 6px; border-radius: 6px; }
.lines .x:hover { color: var(--red); background: var(--red-bg); }
.lines tr.blank .x { visibility: hidden; }
.p-info { display: block; padding: 0 9px 4px; color: var(--muted); font-size: 12.5px; }
.p-info:empty { display: none; }
.p-info.bad { color: var(--red); font-weight: 600; }
.p-info.warn { color: var(--amber); font-weight: 600; }
.lines tr.need { background: var(--amber-bg); }
.lines tr.need .p-name { border-color: #e2b65a; background: #fff; }
.add-line { margin: 10px 0 0; }
.vc-foot { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; margin-top: 16px; align-items: start; }
.sums { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.sums th { text-align: left; font-weight: 400; padding: 5px 0; color: var(--text); white-space: nowrap; }
.sums td { text-align: right; padding: 5px 0; font-weight: 600; }
.sums .mini { width: 56px; padding: 4px 6px; text-align: right; }
.sums .money { width: 150px; padding: 4px 8px; text-align: right; }
.sums .grand th, .sums .grand td { border-top: 2px solid var(--text); padding-top: 9px; font-size: 20px; font-weight: 700; }
.sums .words { text-align: right; font-weight: 400; font-style: italic; color: var(--muted); font-size: 13.5px; }
.vc-actions { position: sticky; bottom: 0; z-index: 10; display: flex; justify-content: flex-end; align-items: center; gap: 8px; flex-wrap: wrap; margin: 16px -20px -60px; padding: 12px 20px; background: rgba(255, 255, 255, .96); border-top: 1px solid var(--line); box-shadow: 0 -4px 14px rgba(15, 23, 42, .06); }
.save-state { margin-right: auto; }
.vc-side { margin: 0; position: sticky; top: 74px; }
.vc-side.drag { outline: 2px dashed var(--navy-2); }
.vc-side.pulse { animation: pulse 1.2s ease 2; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(201, 164, 92, .5); } }
.shot-empty { display: grid; gap: 8px; }
.shot-empty p { margin: 4px 0 0; font-size: 13.5px; }
.shot-view img { display: block; width: 100%; max-height: calc(100vh - 250px); object-fit: contain; object-position: top; border: 1px solid var(--line); border-radius: 8px; background: #f3f5f8; cursor: zoom-in; }
.shot-tools { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.shot-status { margin: 8px 0 0; font-size: 13.5px; }

/* Danh sách gợi ý */
.sg-box { position: fixed; z-index: 100; max-width: min(620px, calc(100vw - 16px)); max-height: 340px; overflow-y: auto; background: #fff; border: 1px solid #b8c4d4; border-radius: 9px; box-shadow: 0 14px 36px rgba(15, 23, 42, .22); padding: 4px; }
.sg-item { display: grid; grid-template-columns: 1fr auto; gap: 0 14px; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.sg-item b { font-weight: 600; }
.sg-item small { grid-column: 1; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sg-stock { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-size: 13px; font-weight: 600; color: var(--green); white-space: nowrap; }
.sg-stock.zero { color: var(--red); }
.sg-item.on, .sg-item:hover { background: var(--blue-bg); }
.sg-new { color: var(--link); font-weight: 600; border-top: 1px solid var(--line-2); border-radius: 0 0 6px 6px; }
/* Ảnh sản phẩm: trong danh sách gợi ý, trong ô tên hàng của phiếu, trong danh mục hàng hóa */
.sg-item:has(.sg-img) { grid-template-columns: 56px 1fr auto; }
.sg-img { grid-column: 1; grid-row: 1 / span 2; width: 56px; height: 42px; object-fit: contain; border-radius: 6px; background: #fff; border: 1px solid var(--line-2); align-self: center; }
.sg-item:has(.sg-img) b, .sg-item:has(.sg-img) small { grid-column: 2; }
.sg-item:has(.sg-img) .sg-stock { grid-column: 3; }
.p-name-wrap { display: flex; align-items: center; gap: 6px; }
.p-name-wrap .p-name { flex: 1; min-width: 0; }
.p-img { flex: none; width: 56px; height: 42px; object-fit: contain; border-radius: 6px; background: #fff; border: 1px solid var(--line-2); cursor: zoom-in; }
.p-img[hidden] { display: none; }
body.no-img .p-img, body.no-img .sg-img { display: none !important; }
body.no-img .sg-item:has(.sg-img) { grid-template-columns: 1fr auto; }
body.no-img .sg-item:has(.sg-img) b, body.no-img .sg-item:has(.sg-img) small { grid-column: 1; }
body.no-img .sg-item:has(.sg-img) .sg-stock { grid-column: 2; }
.tg-img { margin-left: 6px; }
td.pic { position: relative; width: 74px; text-align: center; padding: 3px; }
td.pic .x-photo { position: absolute; top: 0; right: 0; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; font-size: 11px; line-height: 20px; cursor: pointer; opacity: 0; }
td.pic:hover .x-photo, td.pic:focus-within .x-photo { opacity: 1; }
@media (hover: none) { td.pic .x-photo { opacity: 1; } }
td.pic img { display: block; width: 64px; height: 48px; object-fit: contain; margin: 0 auto; border-radius: 6px; background: #fff; border: 1px solid var(--line-2); cursor: pointer; }
td.pic button { font-size: 12px; padding: 4px 6px; white-space: nowrap; }

/* Hộp thoại */
.dlg { border: 0; border-radius: 12px; padding: 20px 22px; width: min(460px, calc(100vw - 24px)); box-shadow: 0 24px 60px rgba(15, 23, 42, .35); }
.dlg::backdrop { background: rgba(29, 78, 216, .45); }
.dlg form { display: grid; gap: 12px; }
.dlg-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dlg-err { color: var(--red); font-weight: 600; margin: 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* Khoanh vùng ảnh chụp màn hình */
.crop { position: fixed; inset: 0; z-index: 200; background: rgba(8, 16, 36, .92); display: flex; flex-direction: column; }
.crop-bar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; color: #fff; }
.crop-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 0 16px 16px; }
.crop-pic { position: relative; max-width: 100%; max-height: 100%; cursor: crosshair; touch-action: none; line-height: 0; }
.crop-img { max-width: calc(100vw - 32px); max-height: calc(100vh - 90px); border-radius: 4px; }
.crop-sel { position: absolute; border: 2px solid var(--gold); box-shadow: 0 0 0 9999px rgba(8, 16, 36, .55); pointer-events: none; }
.crop-pic { overflow: hidden; }

.toast { position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 20px); z-index: 300; max-width: min(560px, calc(100vw - 24px)); padding: 11px 18px; border-radius: 10px; background: #14213d; color: #fff; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; white-space: pre-line; box-shadow: 0 12px 30px rgba(15, 23, 42, .3); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--red); }

/* Đăng nhập */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 50% -10%, #17357a, var(--navy) 60%, #1e40af); }
.login-card { width: min(400px, 100%); background: #fff; border-radius: 16px; padding: 30px 28px; display: grid; gap: 14px; box-shadow: 0 30px 80px rgba(0, 0, 0, .4); border-top: 4px solid var(--gold); }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0; }
.login-brand { display: grid; justify-items: center; gap: 6px; padding-bottom: 16px; border-bottom: 1px solid var(--line); text-align: center; }
.login-brand img { height: 78px; width: auto; }
.login-co small { display: block; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.login-co b { display: block; font-size: 23px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-navy); }
.login-co b::after { content: ""; display: block; width: 46px; height: 3px; margin: 8px auto 0; border-radius: 2px; background: var(--gold); }
.login-title { text-align: center; }
.login-title h1 { font-size: 19px; margin-bottom: 2px; }
.login-back { text-align: center; font-size: 13.5px; color: var(--muted); }

@media (max-width: 1180px) {
  .nav-toggle { display: block; }
  .nav { display: none; position: absolute; top: 58px; left: 0; right: 0; flex-direction: column; background: var(--navy); padding: 8px 14px 14px; border-bottom: 2px solid var(--gold); }
  .nav.open { display: flex; }
  .top { gap: 10px; }
  .top-actions { margin-left: auto; }
  .vc-body, .vc.has-shot .vc-body { grid-template-columns: minmax(0, 1fr); }
  .vc-side { position: static; }
  .vc-partner { grid-template-columns: 1fr 1fr; }
  .vc-partner .f-partner, .vc-partner .f-ship { grid-column: 1 / -1; }
}
@media (max-width: 820px) {
  .actions3, .cols2, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: 1fr 1fr; }
  .vc-foot { grid-template-columns: minmax(0, 1fr); }
  .card { overflow-x: auto; }
  .vc-head { align-items: stretch; }
  .vc-meta input { width: 100%; }
  .vc-meta label { flex: 1; }
  .top { padding: 0 12px; }
  .top-actions .btn.ghost { display: none; }
  .logo span { display: none; }
  .main { padding: 16px 12px 60px; }
  .vc-actions { margin: 16px -12px -60px; padding: 10px 12px; }
  .sheet-wrap { max-height: none; }
}

.shot-status.warn { color: #8a5a00; background: #fffaeb; border: 1px solid #fde7a8; border-radius: 10px; padding: 8px 12px; font-size: 13.5px; }
.shot-status.good { color: #1f6b3a; background: #f0faf3; border: 1px solid #c6ead2; border-radius: 10px; padding: 8px 12px; font-size: 13.5px; }
.unsure input { background: #fff7ed; }
.shot-dup { margin: 10px 0; padding: 10px 12px; border-radius: 10px; background: #fef2f2; border: 1.5px solid #fca5a5; color: #7f1d1d; display: grid; gap: 4px; }
.shot-dup a { font-weight: 600; color: #b91c1c; text-decoration: underline; }
.shot-dup small { color: #7f1d1d; opacity: .85; }

/* Mô-đun công nợ & sổ quỹ */
.tag.thu { background: #e8f5ee; color: #12784a; }
.tag.chi { background: #fdecec; color: #c62828; }
td.debt-in { color: #12784a; }
td.debt-out { color: #c62828; }
.debt-state { font-size: 17px; margin: 6px 0 0; }
.tbl.kv th { width: 34%; text-align: left; font-weight: 600; color: var(--muted); }
.btn.danger { color: #c62828; border-color: #f3b4b4; }
.btn.danger:hover { background: #fdecec; }
details.card.form > summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }

/* Mô-đun hóa đơn điện tử */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 16px; }
.grid2 .span2 { grid-column: 1 / -1; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
fieldset.prov { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 10px 0; }
fieldset.prov legend { font-weight: 700; padding: 0 6px; }

/* Mô-đun nhân sự */
.punch { text-align: center; }
.punch-clock { font-size: 54px; font-weight: 800; margin: 4px 0; color: var(--ink-navy, #0f1f33); font-variant-numeric: tabular-nums; }
.punch-state { font-size: 17px; margin: 0 0 12px; }
.punch .btns { justify-content: center; }
.punch-msg { min-height: 1.4em; }
img.face { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; }
.warn-text { color: #b42318; }
.month-grid td.c, .month-grid th.c { text-align: center; padding: 4px 2px; min-width: 22px; }
.month-grid td.ok { color: #12784a; } .month-grid td.bad { background: #fdecec; color: #b42318; } .month-grid td.lv { color: #1d4ed8; }
.month-grid .wk { background: #f3f6fa; }
.adj { font-size: 12.5px; color: var(--muted); }
form.inline { display: inline-flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.who-staff { display: block; margin-top: 10px; font-size: 14px; }
.cam video { width: 220px; height: 220px; object-fit: cover; border-radius: 50%; border: 4px solid var(--navy-2, #2f6aa3); margin: 6px auto; display: block; }

/* Mô-đun giá thành */
.cost-tbl tr.lo td { background: #fdecec; }
.cost-tbl tr.it td { background: #fff7e6; }

/* Nút "Mở rộng" gom các phần mở thêm trên thanh trên */
.nav-more { position: relative; }
.nav-more > summary { list-style: none; cursor: pointer; padding: 8px 12px; border-radius: 7px; color: #e6edf5; font-weight: 600; white-space: nowrap; }
.nav-more > summary::-webkit-details-marker { display: none; }
.nav-more > summary::after { content: " ▾"; font-size: 11px; opacity: .8; }
.nav-more > summary:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.nav-more > summary.on { background: rgba(255, 255, 255, .16); color: #fff; }
.nav-more-menu { position: absolute; top: calc(100% + 6px); left: 0; min-width: 200px; background: #fff; border-radius: 10px; padding: 6px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, .22); z-index: 60; display: flex; flex-direction: column; }
.nav-more-menu a { color: var(--text, #1f2a44) !important; padding: 9px 12px; border-radius: 7px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.nav-more-menu a:hover, .nav-more-menu a.on { background: #eef3fb; }
@media (max-width: 1180px) {   /* màn hình hẹp: mỗi nhóm là một mục bấm mở ra (accordion) */
  .nav-more > summary { display: block; padding: 10px 12px; color: inherit; }
  .nav-more-menu { position: static; background: none; box-shadow: none; padding: 0 0 4px 14px; min-width: 0; }
  .nav-more-menu a { color: inherit !important; font-weight: 500; }
  .nav-more-menu a:hover, .nav-more-menu a.on { background: rgba(255, 255, 255, .14); }
}

/* Nhập nhiều hóa đơn */
.hang-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.hang-kind { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.hang-sum { margin-left: auto; font-size: 13.5px; }
.hang-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.hang-empty { text-align: center; padding: 30px 0; }
.hang-item { display: grid; grid-template-columns: 84px 1fr auto; gap: 14px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: #fff; }
.hang-item.done { opacity: .7; background: #f6fbf7; }
.hang-img { width: 84px; height: 84px; border-radius: 8px; overflow: hidden; background: #eef2f6; display: block; }
.hang-img img { width: 100%; height: 100%; object-fit: cover; }
.hang-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.hang-body small { color: var(--muted); }
.hang-body .tag { align-self: flex-start; font-size: 12.5px; padding: 3px 9px; border-radius: 999px; background: #eef2f6; }
.hang-body .tag.ok { background: #e8f6ec; color: #1f6b3a; } .hang-body .tag.warn { background: #fff6dc; color: #8a5a00; } .hang-body .tag.bad { background: #fdecea; color: #a3311f; }
.hang-dup { margin: 0; font-size: 12.5px; color: #a3311f; }
.hang-act { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
@media (max-width: 640px) { .hang-item { grid-template-columns: 64px 1fr; } .hang-img { width: 64px; height: 64px; } .hang-act { grid-column: 1 / -1; flex-direction: row; } .hang-act .btn { flex: 1; } .hang-sum { margin-left: 0; width: 100%; } }

/* Giá bán riêng theo khách */
.gr-box { margin-top: 18px; }
.gr-head h2 { margin: 0 0 4px; font-size: 17px; }
.gr-head p { margin: 0 0 12px; font-size: 13.5px; }
.gr-box td input[data-gr-price] { width: 130px; }
.gr-on { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #e7f3e9; color: #2d6a3a; font-size: 12.5px; font-weight: 600; }
.gr-add { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.gr-add [data-gr-name] { flex: 1 1 220px; min-width: 0; }
.gr-add [data-gr-new] { width: 140px; }
@media (max-width: 640px) {
  .gr-add .btn, .gr-add [data-gr-new] { flex: 1; }
  .gr-box .sheet-wrap { overflow: visible; max-height: none; }
  .gr-box table, .gr-box tbody { display: block; width: 100%; }
  .gr-box thead { display: none; }
  .gr-box tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) 118px; gap: 4px 10px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line-2); }
  .gr-box tbody td { display: block !important; border: 0 !important; padding: 0; text-align: left; }
  .gr-box tbody td:first-child { font-weight: 600; grid-column: 1 / -1; white-space: normal; overflow: visible; }
  .gr-box tbody td:nth-child(2) { grid-column: 1; grid-row: 2; }
  .gr-box tbody td:nth-child(2):not(:empty)::before { content: "Lần trước: "; }
  .gr-box tbody td:nth-child(3) { grid-column: 2; grid-row: 2; }
  .gr-box td input[data-gr-price] { width: 100%; }
  .gr-box .sheet-wrap { border: 0; }
  .gr-box tbody td.gr-state { grid-column: 2; grid-row: 1; justify-self: end; display: none !important; }
  .gr-box tbody tr.gr-empty td { grid-column: 1 / -1; }
}
.tbl td.acts button[data-delete-row]:hover { color: #b42318; border-color: #f0b4ad; background: #fdf1ef; }

/* Phiếu đang làm dở được mở lại */
.draft-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; padding: 10px 14px;
  border: 1px solid #f0d58a; background: #fff8e1; color: #6b4e00; border-radius: 10px; font-size: 14px; }
.draft-bar .btn { padding: 5px 12px; font-size: 13px; }

/* Nút xóa phiếu trong Sổ phiếu (giám đốc) */
.tbl td.acts .del-vc { margin-left: 8px; }
.tbl td.acts .del-vc:hover { color: #b42318; border-color: #f0b4ad; background: #fdf1ef; }

/* Phiếu xuất: khách trả trước, còn lại ghi công nợ; khung lịch sử công nợ của khách */
.sums tr.prepaid select { font: inherit; font-size: 12.5px; padding: 2px 4px; border: 1px solid var(--line); border-radius: 6px; margin-left: 4px; }
.sums tr.prepaid input { width: 130px; text-align: right; }
.sums tr.left th small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.sums tr.left td { font-weight: 700; }
.sums tr.left td.warn { color: var(--amber); } .sums tr.left td.in { color: var(--green); } .sums tr.left td.neg { color: var(--red); }
.debt-hist { margin: 0 0 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fffaf0; }
.debt-hist h2 { font-size: 16px; margin: 0; }
.debt-now { margin: 6px 0 8px; font-size: 14px; }
.debt-hist .tbl { table-layout: fixed; }
.debt-hist .tbl td { padding: 5px 4px; font-size: 13px; overflow-wrap: anywhere; }
.debt-hist .tbl td b { display: block; } .debt-hist .tbl td b.in { color: var(--green); }
.debt-hist .tbl td small.in { color: var(--green); }

/* Đơn vị tính sửa được ngay trên phiếu */
.lines .c-unit { width: 78px; }
.lines td.c-unit { padding: 4px 2px 0; }
.lines .p-unit { width: 100%; min-width: 60px; text-align: center; border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 6px 0; text-overflow: clip; font: inherit; color: var(--muted); }
.lines .p-unit:not(:disabled):hover { border-color: var(--line); background: #fff; }
.lines .p-unit:focus { border-color: #1d4ed8; background: #fff; color: var(--text); outline: 0; }

/* Bảng nút chọn nhanh đơn vị */
.lines .p-unit:not(:disabled) { cursor: pointer; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2394a3b8' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 4px center; border-color: var(--line); padding-right: 14px; }
.unit-pick { position: absolute; z-index: 60; display: flex; flex-wrap: wrap; gap: 6px; max-width: 290px; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(15, 40, 80, .18); }
.unit-pick button { min-width: 54px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #f7fafd; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.unit-pick button:hover { border-color: #1d4ed8; background: #e8f2fc; }
.unit-pick button.on { border-color: #1d4ed8; background: #1d4ed8; color: #fff; }
.unit-pick small { flex-basis: 100%; color: var(--muted); font-size: 12px; }
