/* MINH CHÂU SALES — giao diện theo bộ màu Minh Châu. Đổi màu thương hiệu: sửa các biến trong :root. */
:root {
  --bg: #E8F5EE;
  --primary: #087F5B;
  --primary-h: #066649;
  --primary-soft: #D3EEE1;
  --card: #FFFFFF;
  --text: #1F2937;
  --muted: #64748B;
  --border: #DCE7E1;
  --line: #EEF3F0;
  --warn: #B45309;
  --warn-bg: #FFF7E6;
  --err: #B42318;
  --err-bg: #FEF3F2;
  --ok: #067647;
  --ok-bg: #E7F6EE;
  --info: #175CD3;
  --info-bg: #EFF6FF;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 40, 30, .06), 0 1px 3px rgba(16, 40, 30, .05);
  --side-w: 224px;
  --top-h: 56px;
  --ctl-h: 44px;
  --font: "Be Vietnam Pro", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; line-height: 1.3; margin: 0 0 14px; font-weight: 700; }
h2 { font-size: 17px; margin: 0 0 12px; font-weight: 700; }
h3 { font-size: 15px; margin: 16px 0 8px; font-weight: 700; }
p { margin: 0 0 10px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: Consolas, "SFMono-Regular", Menlo, monospace; font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
.req { color: var(--err); }
.strong { font-weight: 700; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.ic { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.ic-sm { width: 16px; height: 16px; }

/* ---------- Khung ứng dụng ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--side-w); flex: none; background: var(--card); border-right: 1px solid var(--border); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; padding: 14px 16px; height: var(--top-h); border-bottom: 1px solid var(--line); }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 15px; letter-spacing: .5px; flex: none; }
.brand-name { font-weight: 800; font-size: 15px; line-height: 1.15; color: var(--primary); }
.brand-sub { font-size: 11px; font-weight: 600; letter-spacing: 2.5px; color: var(--muted); }
.nav { flex: 1; padding: 10px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.nav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: var(--radius-sm); color: var(--text); font-weight: 600; }
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.active { background: var(--primary); color: #fff; }
.nav a .nav-badge { margin-left: auto; background: var(--err); color: #fff; font-size: 12px; border-radius: 999px; padding: 0 7px; line-height: 20px; }
.nav a.active .nav-badge { background: #fff; color: var(--err); }
.side-user { border-top: 1px solid var(--line); padding: 12px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; flex: none; }
.side-user .who { min-width: 0; flex: 1; }
.side-user .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.side-user .who span { font-size: 12px; color: var(--muted); }
.side-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 25; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; min-height: var(--top-h); background: var(--card); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 8px 20px; flex-wrap: wrap; }
.topbar .t-title { font-size: 18px; font-weight: 700; margin: 0; white-space: nowrap; }
.topbar .t-menu { display: none; }
.topbar .t-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-left: auto; justify-content: flex-end; }
.topbar .t-company { font-size: 13px; color: var(--muted); max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .t-company b { color: var(--text); }
.topbar select.t-wh { width: auto; min-width: 150px; max-width: 220px; }
.t-updated { font-size: 12px; color: var(--muted); white-space: nowrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip-ok { background: var(--ok-bg); color: var(--ok); border-color: #B7E2CB; }
.chip-warn { background: var(--warn-bg); color: var(--warn); border-color: #F5D9A8; }
.chip-err { background: var(--err-bg); color: var(--err); border-color: #F7C6C1; }
.chip-mock { background: var(--warn-bg); color: var(--warn); border-color: #F5D9A8; border-style: dashed; }
.net-banner { background: var(--err-bg); color: var(--err); padding: 10px 20px; font-weight: 600; border-bottom: 1px solid #F7C6C1; }
.lic-bar { background: var(--warn-bg); color: #93370D; padding: 8px 20px; font-size: 14px; border-bottom: 1px solid #F5D9A8; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.lic-bar.lic-err { background: var(--err-bg); color: #912018; border-bottom-color: #F7C6C1; font-weight: 600; }
.lic-bar a { color: inherit; text-decoration: underline; }
.lic-key { width: 100%; min-height: 96px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; }
.lic-machine { font-family: ui-monospace, Consolas, monospace; font-size: 15px; letter-spacing: .5px; }
.main { padding: 16px; flex: 1; min-width: 0; }

/* ---------- Thành phần chung ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
label { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 6px; }
input, select, textarea { font: inherit; font-size: 15px; color: var(--text); width: 100%; min-height: var(--ctl-h); padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
textarea { min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(8, 127, 91, .15); }
input[readonly] { background: #F6F9F7; color: var(--muted); }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; min-height: 0; padding: 0; accent-color: var(--primary); vertical-align: middle; }
input[type=file] { padding: 8px; }
.chk { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; margin: 10px 0; cursor: pointer; }
.chk input { margin-top: 2px; flex: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--ctl-h); padding: 0 18px; font: inherit; font-weight: 600; font-size: 15px;
  border-radius: var(--radius-sm); border: 1px solid var(--primary); background: var(--primary); color: #fff; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--primary-h); border-color: var(--primary-h); text-decoration: none; }
.btn:focus-visible, .nav a:focus-visible, .chipbtn:focus-visible { outline: 3px solid rgba(8, 127, 91, .35); outline-offset: 2px; }
.btn:disabled, .btn[aria-disabled=true] { opacity: .45; cursor: not-allowed; }
.btn-light { background: #fff; color: var(--primary); border-color: var(--border); }
.btn-light:hover { background: var(--bg); border-color: var(--primary); }
.btn-ghost { background: transparent; color: var(--muted); border-color: transparent; }
.btn-ghost:hover { background: var(--bg); color: var(--text); border-color: transparent; }
.btn-danger { background: #fff; color: var(--err); border-color: #F2B8B2; }
.btn-danger:hover { background: var(--err-bg); border-color: var(--err); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn-lg { min-height: 52px; font-size: 16px; padding: 0 22px; }
.btn-block { width: 100%; }
.btn-icon { width: var(--ctl-h); padding: 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; align-items: center; }
.inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline input, .inline select { width: auto; }
.grid { display: grid; gap: 0 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cards { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #EEF2F0; color: #475467; white-space: nowrap; line-height: 1.6; }
.b-ok { background: var(--ok-bg); color: var(--ok); }
.b-warn { background: var(--warn-bg); color: var(--warn); }
.b-err { background: var(--err-bg); color: var(--err); }
.b-info { background: var(--info-bg); color: var(--info); }
.b-mock { background: var(--warn-bg); color: var(--warn); border: 1px dashed #E8B867; }
.alert { padding: 12px 14px; border-radius: var(--radius-sm); margin: 0 0 14px; border: 1px solid transparent; font-size: 14px; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }
.alert b:first-child { font-weight: 700; }
.a-ok { background: var(--ok-bg); color: #05603A; border-color: #B7E2CB; }
.a-warn { background: var(--warn-bg); color: #93370D; border-color: #F5D9A8; }
.a-err { background: var(--err-bg); color: #912018; border-color: #F7C6C1; }
.a-info { background: var(--info-bg); color: #1849A9; border-color: #C9DCF8; }
.a-mock { background: var(--warn-bg); color: #93370D; border: 1px dashed #E8B867; }
.alert .btn { margin-top: 8px; }
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); padding: 10px; border-bottom: 1px solid var(--border); background: #F7FBF9; white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #F5FAF7; }
tr.row-off td { color: var(--muted); }
tr.row-head td { background: var(--warn-bg); font-weight: 600; }
.kv { display: grid; grid-template-columns: minmax(140px, 38%) 1fr; gap: 8px 14px; font-size: 14px; }
.kv > div:nth-child(odd) { color: var(--muted); }
.timeline { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.timeline li { padding: 8px 0; border-bottom: 1px dashed var(--line); }
details { margin: 10px 0; }
details > summary { cursor: pointer; font-weight: 600; color: var(--primary); min-height: 36px; display: flex; align-items: center; }
.state { text-align: center; padding: 36px 16px; color: var(--muted); }
.state .ic { width: 40px; height: 40px; color: #9DB7AA; margin-bottom: 8px; }
.state b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }
.state .actions { justify-content: center; }
.inline input.w-num { width: 80px; }
.inline select { min-width: 100px; }
select.inline-sel { width: auto; min-height: 36px; padding: 4px 8px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { margin: 0; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters > div { min-width: 150px; flex: 1; }
.filters label { margin-top: 0; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chipbtn { min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: #fff; color: var(--text); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.chipbtn:hover { border-color: var(--primary); }
.chipbtn.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: thin; }
.tabs a { padding: 0 14px; min-height: 44px; display: flex; align-items: center; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--primary); border-bottom-color: var(--primary); }
.stat { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat a { display: block; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; color: var(--text); box-shadow: var(--shadow); }
.stat a:hover { border-color: var(--primary); text-decoration: none; }
.stat .n { font-size: 26px; font-weight: 800; line-height: 1.2; }
.stat .warn .n { color: var(--warn); }
.stat .err .n { color: var(--err); }
.stat .ok .n { color: var(--ok); }

/* ---------- Bán hàng (POS) ---------- */
/* Giỏ hàng rộng theo màn hình: 420px ở màn 1280, tới ~620px ở màn Full HD */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) clamp(420px, 34vw, 640px); gap: 14px; align-items: start; }
.pos-tabs { display: none; }
.pane { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.pane-pick { padding: 16px; }
.search-box { position: relative; }
.search-box .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-box input { padding-left: 44px; min-height: 52px; font-size: 16px; }
.search-box kbd { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font: 600 12px var(--font); color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; background: #F7FBF9; }
.pick-tools { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 0 8px; }
.stock-src { font-size: 12px; color: var(--muted); }
select.group-sel { width: auto; min-width: 180px; max-width: 280px; }
.lines-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.price-mode { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.price-mode .pay-seg { grid-template-columns: repeat(2, auto); }
.price-mode .pay-seg button { min-height: 30px; padding: 0 10px; font-size: 13px; }
.sum .sumg .r { text-align: right; }
@container cart (min-width: 560px) { .pane-cart .cart-actions { grid-template-columns: 2fr 1fr 1fr; } .pane-cart .cart-actions .btn-primary { grid-column: auto; } }
@media (max-height: 820px) { .cart-head { padding: 10px 16px; } .cart-foot .sum .grand { font-size: 17px; margin-top: 2px; padding-top: 4px; } .cart-actions { margin-top: 8px; } }
/* Báo cáo */
.rep-filter { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.rep-filter > div { min-width: 150px; }
.rep-filter .rep-actions { display: flex; gap: 8px; margin-left: auto; }
.rep-tbl tfoot th { border-top: 2px solid var(--border); background: var(--bg, #F6F8F7); }
.rep-bar-wrap { display: flex; flex-direction: column; gap: 4px; min-width: 160px; }
.rep-bar { display: block; height: 6px; border-radius: 3px; background: var(--primary-soft, #D3EEE1); width: 0; }
.neg { color: var(--err); }
@media (max-width: 900px) { .stat { grid-template-columns: repeat(2, minmax(0, 1fr)); } .rep-filter .rep-actions { margin-left: 0; } }
.mock-strip { background: var(--warn-bg); color: #93370D; border: 1px dashed #E8B867; border-radius: var(--radius-sm); padding: 8px 12px; font-size: 13px; font-weight: 600; margin-bottom: 12px; }
.ilist { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.irow { display: grid; grid-template-columns: 110px minmax(0, 1fr) 64px 100px minmax(230px, 300px) 44px; gap: 10px; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--line); min-height: 50px; }
.irow:last-child { border-bottom: 0; }
.irow.ihead { background: #F7FBF9; font-size: 12px; font-weight: 600; color: var(--muted); min-height: 40px; }
.irow:not(.ihead) { cursor: pointer; }
.irow:not(.ihead):hover { background: #F5FAF7; }
.irow.out { cursor: default; }
.irow.out:hover { background: transparent; }
.irow.out .i-name, .irow.out .i-code { color: var(--muted); }
.i-code { font-weight: 700; font-size: 14px; word-break: break-all; }
.i-name { font-size: 14px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.i-unit { font-size: 14px; color: var(--muted); }
.i-stock, .i-price { text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; }
.i-stock b { font-size: 15px; }
.i-stock .sub, .i-price .sub { display: block; font-size: 12px; color: var(--muted); }
.noprice { color: var(--warn); font-size: 13px; font-weight: 600; }
.addbtn { width: 40px; height: 40px; min-height: 0; padding: 0; border-radius: 10px; }
.list-more { padding: 10px; text-align: center; font-size: 13px; color: var(--muted); }

.pane-cart { display: flex; flex-direction: column; position: sticky; top: calc(var(--top-h) + 20px); height: calc(100vh - var(--top-h) - 40px); min-height: 520px; }
.ilist { max-height: calc(100vh - var(--top-h) - 236px); min-height: 280px; overflow-y: auto; }
.ilist .ihead { position: sticky; top: 0; z-index: 1; }
.cust-box .dropdown { position: static; box-shadow: none; margin-top: 6px; max-height: 240px; }
.cart-head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; justify-content: space-between; flex-wrap: wrap; }
.cart-head h2 { margin: 0; font-size: 17px; }
.cart-body { padding: 4px 16px 12px; overflow-y: auto; flex: 1; min-height: 120px; }
.cart-foot { border-top: 1px solid var(--line); padding: 12px 16px 16px; background: #FBFDFC; border-radius: 0 0 var(--radius) var(--radius); }
.cust-box { position: relative; }
.cust-row { display: flex; gap: 8px; align-items: flex-start; }
.input-group { display: flex; gap: 6px; }
.input-group input { flex: 1; min-width: 0; }
.input-group .btn { flex: none; padding: 0 12px; }
.lookup-res { margin: 12px 0 0; }
.price-in { width: 120px; min-height: 38px; padding: 6px 10px; text-align: right; font-variant-numeric: tabular-nums; }
.price-in.saving { border-color: var(--primary); background: #F0F8F4; }
/* Ô giá + ô thuế cạnh nhau, giá vốn / lãi gộp gom 1 dòng nhỏ bên dưới → dòng hàng thấp, thấy nhiều hàng hơn */
.irow:not(.ihead) .i-price { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 2px 6px; }
.i-price .i-sub { flex-basis: 100%; text-align: right; font-size: 12px; color: var(--muted); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.i-price .i-sub:empty { display: none; }
.i-price .i-sub .sub { display: inline; }
.i-price .i-sub .sub:not(:empty) ~ .sub:not(:empty)::before { content: ' · '; }
.i-price .pick-price { width: 112px; min-height: 32px; padding: 4px 8px; font-size: 14px; }
.i-price .pick-tax { width: 96px; min-height: 32px; padding: 2px 6px; font-size: 12px; color: var(--muted); }
.i-price .pick-tax:focus { color: var(--text); }
@media (max-width: 899px) { .price-in { width: 140px; } }
.ei-box { margin-top: 12px; }
.ei-box .kv { font-size: 13px; }
.ei-box .actions { margin-top: 10px; }
.ei-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ei-note { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.ei-note.warn { color: var(--warn); font-weight: 600; }
.lookup-res .actions { margin-top: 8px; }
.cust-row .cust-box { flex: 1; min-width: 0; }
.pay-seg.seg2 { grid-template-columns: repeat(2, 1fr); margin-bottom: 4px; }
.pay-seg .seg-opt { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; margin: 0; padding: 0 8px; border-right: 1px solid var(--border); cursor: pointer; font-size: 14px; font-weight: 600; text-align: center; }
.pay-seg .seg-opt:last-child { border-right: 0; }
.pay-seg .seg-opt.on { background: var(--primary); color: #fff; }
.pay-seg .seg-opt input { accent-color: #fff; }
.dup-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 8px 0; border-top: 1px dashed #F5D9A8; }
.dup-row:first-of-type { border-top: 0; }
.cust-sel { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; background: #F7FBF9; }
.cust-sel .who { flex: 1; min-width: 0; font-size: 14px; }
.dropdown { position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(16, 40, 30, .12); max-height: 300px; overflow-y: auto; z-index: 15; }
.dd-item { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 14px; }
.dd-item:last-child { border-bottom: 0; }
.dd-item:hover, .dd-item.on { background: #F0F8F4; }
.dd-item.disabled { cursor: not-allowed; color: var(--muted); }
/* Giỏ hàng đủ rộng (≥ 500px): mỗi dòng hàng thành 1 hàng ngang (SL · ĐVT · Đơn giá · Thuế) → thấy nhiều dòng hơn */
.pane-cart { container-type: inline-size; container-name: cart; }
@container cart (min-width: 450px) {
  .pane-cart .cline { padding: 8px 0; }
  .pane-cart .cl-name b { display: inline; margin-right: 8px; }
  .pane-cart .cl-grid { grid-template-columns: 118px minmax(64px, 0.9fr) minmax(100px, 1.2fr) minmax(90px, 1fr); grid-template-areas: "lq lu lp lt" "q u p t"; gap: 2px 8px; margin-top: 4px; }
  .pane-cart .cl-grid > :nth-child(1) { grid-area: lq; } .pane-cart .cl-grid > :nth-child(2) { grid-area: lu; } .pane-cart .cl-grid > :nth-child(3) { grid-area: q; } .pane-cart .cl-grid > :nth-child(4) { grid-area: u; }
  .pane-cart .cl-grid > :nth-child(5) { grid-area: lp; } .pane-cart .cl-grid > :nth-child(6) { grid-area: lt; } .pane-cart .cl-grid > :nth-child(7) { grid-area: p; } .pane-cart .cl-grid > :nth-child(8) { grid-area: t; }
  .pane-cart .cl-grid select, .pane-cart .cl-grid input { min-height: 36px; padding: 4px 8px; }
  .pane-cart .cline .stepper button { width: 32px; min-height: 36px; }
  .pane-cart .cline .inline.mt { margin-top: 4px; }
  .pane-cart .cline + .cline .cl-grid .lbl { display: none; } /* nhãn cột chỉ hiện ở dòng đầu */
  .pane-cart .cart-foot { padding: 10px 16px 12px; }
}
.kbd { display: inline-block; margin-left: 6px; padding: 0 5px; border: 1px solid currentColor; border-radius: 4px; font-size: 11px; font-weight: 600; line-height: 16px; opacity: .75; }
/* Thu gọn / mở rộng menu trái (màn ≥ 1280px; màn nhỏ hơn đã tự thu gọn) */
.side-toggle .ic { transition: transform .15s; }
@media (max-width: 1439px) { .side-toggle { display: none !important; } }
@media (min-width: 1440px) {
  .app.side-mini { --side-w: 76px; }
  .app.side-mini .brand { justify-content: center; padding: 12px 8px; }
  .app.side-mini .brand .brand-text { display: none; }
  .app.side-mini .nav a { flex-direction: column; justify-content: center; gap: 2px; padding: 8px 4px; min-height: 58px; font-size: 11px; text-align: center; line-height: 1.2; }
  .app.side-mini .nav a .nav-badge { position: absolute; margin: -34px 0 0 30px; font-size: 11px; padding: 0 5px; line-height: 17px; }
  .app.side-mini .side-user { flex-direction: column; padding: 10px 6px; gap: 6px; }
  .app.side-mini .side-user .who { display: none; }
  .app.side-mini .side-toggle .ic { transform: rotate(180deg); }
}
.cline { border-bottom: 1px solid var(--line); padding: 12px 0; }
.cline:last-child { border-bottom: 0; }
.cl-top { display: flex; gap: 8px; align-items: flex-start; }
.cl-name { flex: 1; min-width: 0; font-size: 14px; }
.cl-name b { display: block; }
.cl-grid { display: grid; grid-template-columns: 128px 1fr; gap: 8px 10px; margin-top: 8px; align-items: center; }
.cl-grid .lbl { font-size: 12px; color: var(--muted); font-weight: 600; }
.cl-grid select, .cl-grid input { min-height: 40px; padding: 6px 10px; font-size: 14px; }
.stepper { display: flex; align-items: stretch; }
.stepper button { width: 40px; min-height: 40px; border: 1px solid var(--border); background: #fff; font-size: 18px; font-weight: 700; color: var(--primary); cursor: pointer; }
.stepper button:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.stepper button:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.stepper button:hover { background: var(--bg); }
.stepper input { border-radius: 0; border-left: 0; border-right: 0; text-align: center; width: 100%; min-width: 0; }
.cl-amt { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.cl-warn { margin-top: 6px; font-size: 13px; color: var(--warn); font-weight: 600; }
.cl-err { margin-top: 6px; font-size: 13px; color: var(--err); font-weight: 600; }
.pay-seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.pay-seg button { min-height: 40px; border: 0; border-right: 1px solid var(--border); background: #fff; font: inherit; font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer; padding: 0 6px; }
.pay-seg button:last-child { border-right: 0; }
.pay-seg button.on { background: var(--primary); color: #fff; }
.sum { margin: 0; font-size: 14px; }
.sum div { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
.sum .sumg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 0; }
.sum .sumg2 { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 6px; }
.sum .sumg > div { display: block; padding: 0; min-width: 0; }
.sum .sumg span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.sum .sumg b { display: block; font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sum .sumg2 > div:last-child { text-align: right; }
.sum .sumg b span.prov { display: inline; font-size: 14px; color: var(--warn); text-align: left; }
.blockers1 { font-size: 13px; color: var(--warn); font-weight: 600; margin: 8px 0 0; }
.blockers-d { margin: 8px 0 0; font-size: 13px; color: var(--warn); }
.blockers-d > summary { color: var(--warn); font-weight: 600; min-height: 0; display: block; }
.cart-foot .sum .grand { font-size: 18px; margin-top: 4px; padding-top: 6px; }
.cart-foot .alert { margin: 8px 0 0; }
.sum div span:last-child { font-variant-numeric: tabular-nums; text-align: right; }
.sum .grand { font-size: 19px; font-weight: 800; color: var(--primary); border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; }
.sum .due { font-weight: 700; }
.sum .prov { color: var(--warn); font-weight: 600; }
.blockers { font-size: 13px; color: var(--warn); margin: 8px 0 0; padding-left: 18px; }
.cart-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.cart-actions .btn-primary { grid-column: 1 / -1; }
.cart-body.result { padding-top: 12px; }
.result .sum { margin-top: 4px; }
.result .big { font-size: 18px; font-weight: 700; margin: 6px 0; }
.spin { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: sp .8s linear infinite; vertical-align: -3px; }
@keyframes sp { to { transform: rotate(360deg); } }
.bottom-bar { display: none; }

/* ---------- Hộp thoại, thông báo ---------- */
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 100; overflow-y: auto; }
.modal-box { background: #fff; border-radius: 12px; padding: 20px; width: 100%; max-width: 560px; box-shadow: 0 20px 50px rgba(0, 0, 0, .2); }
.modal-box.modal-wide { max-width: 960px; }
.toast { position: fixed; right: 20px; bottom: 20px; max-width: min(460px, calc(100vw - 32px)); background: #0F3D2E; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); z-index: 200; font-size: 14px; }
.toast.err { background: var(--err); }

/* ---------- Đăng nhập ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-box { width: 100%; max-width: 420px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; justify-content: center; }
.auth-brand .brand-mark { width: 48px; height: 48px; font-size: 18px; }
.auth-brand .brand-name { font-size: 20px; }

/* ---------- In phiếu ---------- */
.print-slip { background: #fff; max-width: 800px; margin: 0 auto; padding: 24px; border: 1px solid var(--border); border-radius: var(--radius); }
.slip-company { line-height: 1.4; }
.slip-company b { font-size: 15px; text-transform: uppercase; }
.slip-title { font-size: 20px; font-weight: 800; text-align: center; margin-top: 8px; }
.slip-warn { text-align: center; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.print-mock { text-align: center; font-weight: 800; color: var(--err); border: 2px dashed var(--err); padding: 6px; margin: 8px 0; }
.slip-sign { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; margin: 28px 0 60px; }
.totals { margin-left: auto; max-width: 340px; font-size: 14px; }
.totals div { display: flex; justify-content: space-between; padding: 3px 0; gap: 12px; }
.totals .grand { font-weight: 800; font-size: 17px; border-top: 1px solid var(--border); padding-top: 6px; margin-top: 4px; }
@media print {
  .sidebar, .topbar, .no-print, .toast, .net-banner, .lic-bar, .bottom-bar { display: none !important; }
  body { background: #fff; }
  .main { padding: 0; }
  .print-slip { border: 0; padding: 0; }
}

/* ---------- Màn hình vừa (≤ 1439px, vd. laptop 1366): thu gọn menu thành biểu tượng, gộp cột ĐVT vào tên hàng ---------- */
@media (max-width: 1439px) {
  :root { --side-w: 76px; }
  .brand { justify-content: center; padding: 12px 8px; }
  .brand .brand-text { display: none; }
  .nav a { flex-direction: column; justify-content: center; gap: 2px; padding: 8px 4px; min-height: 58px; font-size: 11px; text-align: center; line-height: 1.2; }
  .nav a .nav-badge { position: absolute; margin: -34px 0 0 30px; font-size: 11px; padding: 0 5px; line-height: 17px; }
  .side-user { flex-direction: column; padding: 10px 6px; gap: 6px; }
  .side-user .who { display: none; }
  .irow { grid-template-columns: 92px minmax(120px, 1fr) 84px minmax(196px, 240px) 44px; gap: 8px; }
  .irow .i-unit { display: none; }
  .irow .i-unit-inline { display: inline; }
  .topbar .t-company { max-width: 150px; }
  .t-updated { display: none; }
}
@media (max-width: 1100px) {
  .irow { grid-template-columns: 84px minmax(100px, 1fr) 76px 150px 44px; }
  .i-price .pick-price, .i-price .pick-tax { width: 100%; }
  .irow .i-unit { display: none; }
  .irow .i-unit-inline { display: inline; }
}
.i-unit-inline { display: none; color: var(--muted); font-size: 12px; }
/* ≤ 1023px: dòng hàng dạng gọn 2 dòng (mã + có thể bán / tên + giá), không đủ chỗ cho 5 cột */
@media (max-width: 1023px) {
  .pos { grid-template-columns: minmax(0, 1fr) 340px; }
  .irow { grid-template-columns: minmax(0, 1fr) auto 44px; grid-template-areas: "code stock add" "name price add"; gap: 2px 10px; padding: 10px; }
  .irow.ihead { display: none; }
  .irow .i-code { grid-area: code; }
  .irow .i-name { grid-area: name; }
  .irow .i-stock { grid-area: stock; }
  .irow .i-price { grid-area: price; }
  .irow .i-add { grid-area: add; align-self: center; }
  .irow .i-unit { display: none; }
  .irow .i-unit-inline { display: inline; }
  .irow .i-stock .sub { display: inline; margin-left: 4px; }
  .ilist { max-height: calc(100vh - var(--top-h) - 250px); }
  .irow .i-code { word-break: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .irow:not(.ihead) .i-price { max-width: 210px; }
  .i-price .pick-price { width: 104px; }
  .i-price .pick-tax { width: 92px; }
  .i-price .i-sub { white-space: normal; }
}

/* ---------- Máy tính bảng dọc & điện thoại (≤ 899px) ---------- */
@media (max-width: 899px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; transform: translateX(-100%); visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s; }
  .app.menu-open .sidebar { transform: none; visibility: visible; transition: transform .2s ease; box-shadow: 0 10px 40px rgba(0, 0, 0, .2); }
  .brand { justify-content: flex-start; padding: 14px 16px; }
  .brand .brand-text { display: block; }
  .nav a { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 12px; min-height: 48px; font-size: 15px; text-align: left; }
  .nav a .nav-badge { position: static; margin: 0 0 0 auto; }
  .side-user { flex-direction: row; padding: 12px; }
  .side-user .who { display: block; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar .t-menu { display: inline-flex; }
  .topbar .t-title { font-size: 17px; flex: 1; }
  .topbar .t-meta { width: 100%; margin-left: 0; justify-content: flex-start; gap: 8px; }
  .topbar select.t-wh { flex: 1; min-width: 0; max-width: none; }
  .t-updated { display: none; }
  .main { padding: 12px; }
  .grid-2, .grid-3, .grid-cards { grid-template-columns: 1fr; }
  .stat { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pos { display: block; }
  .pos-tabs { display: grid; grid-template-columns: 1fr 1fr; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 12px; }
  .pos-tabs button { min-height: 46px; border: 0; background: #fff; font: inherit; font-weight: 700; color: var(--muted); cursor: pointer; }
  .pos-tabs button.on { background: var(--primary); color: #fff; }
  .pos[data-tab=pick] .pane-cart { display: none; }
  .pos[data-tab=cart] .pane-pick { display: none; }
  .pane-pick { padding: 12px; }
  .pane-cart { position: static; height: auto; min-height: 0; }
  .ilist { max-height: none; min-height: 0; overflow: visible; }
  .cart-body { overflow: visible; }
  .pos[data-tab=pick] { padding-bottom: 76px; }
  .bottom-bar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 18; background: #fff; border-top: 1px solid var(--border); padding: 10px 12px; gap: 10px; align-items: center; box-shadow: 0 -4px 16px rgba(16, 40, 30, .08); }
  .bottom-bar .bb-info { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); }
  .bottom-bar .bb-info b { display: block; font-size: 17px; color: var(--text); }
  table.resp thead { display: none; }
  table.resp, table.resp tbody, table.resp tr, table.resp td { display: block; width: 100%; }
  table.resp tr { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px; padding: 6px 10px; background: #fff; }
  table.resp td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.resp td::before { content: attr(data-l); color: var(--muted); font-family: var(--font); font-size: 13px; font-weight: 600; text-align: left; flex: none; }
  table.resp td.num { white-space: normal; }
  table.resp td[data-l=""]::before { content: none; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv > div:nth-child(even) { margin-bottom: 8px; }
  .filters > div { min-width: calc(50% - 5px); }
  .modal { padding: 12px; }
  .modal-box { padding: 16px; }
  .print-slip { padding: 12px; }
}
@media (max-width: 480px) {
  .topbar .lbl-txt { display: none; }
  .topbar #btnRefresh { width: 40px; padding: 0; }
  .topbar select.t-wh { min-width: 120px; }
  .topbar .t-company { display: none; }
}
@media (max-width: 420px) {
  .cl-grid { grid-template-columns: 1fr 1fr; }
  .topbar .chip { height: 30px; padding: 0 10px; font-size: 12px; }
  .filters > div { min-width: 100%; }
}
/* Điện thoại: tên hàng một dòng riêng, ô giá + thuế xuống dòng dưới (không ép cột mã/tên) */
@media (max-width: 600px) {
  .irow { grid-template-columns: minmax(0, 1fr) auto 44px; grid-template-areas: "code stock add" "name name add" "price price price"; gap: 4px 10px; }
  .irow:not(.ihead) .i-price { max-width: none; justify-content: flex-start; }
  .i-price .i-sub { text-align: left; }
  .irow .i-name { -webkit-line-clamp: 2; }
}
