/* Kho Giá Treo */
:root {
  --blue: #0b6bd3; --blue-d: #0956ab; --blue-l: #e8f1fc;
  --green: #18a058; --green-d: #128047; --red: #d93025; --orange: #f08c00; --purple: #7048e8;
  --bg: #f1f3f6; --line: #dfe3e8; --text: #1f2933; --muted: #6b7785;
  --radius: 6px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; font-weight: 600; }
h3 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
input, select, textarea { font: inherit; color: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(11,107,211,.15); }
input[type=checkbox], input[type=radio] { width: auto; }
input[type=file] { border: 0; padding: 0; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
label input, label select, label textarea { margin-top: 4px; color: var(--text); }
label.radio, label.check { display: flex; align-items: center; gap: 6px; color: var(--text); margin: 6px 0; cursor: pointer; }
code { background: #eef1f4; padding: 1px 5px; border-radius: 4px; }

/* --- Top bar --- */
.topbar { background: var(--blue); color: #fff; position: sticky; top: 0; z-index: 50; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.topbar-inner { display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 16px; max-width: 1500px; margin: 0 auto; }
.brand { color: #fff; font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; white-space: nowrap; margin-right: 12px; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: #fff; color: var(--blue); font-weight: 800; }
.mainnav { display: flex; align-items: stretch; height: 100%; }
.nav-item { position: relative; display: flex; align-items: center; }
.nav-link { color: #fff; padding: 0 14px; height: 52px; display: flex; align-items: center; cursor: pointer; white-space: nowrap; }
.nav-link:hover { background: var(--blue-d); text-decoration: none; }
.nav-item.active > .nav-link { background: var(--blue-d); box-shadow: inset 0 -3px 0 #fff; }
.dropdown { display: none; position: absolute; top: 100%; left: 0; min-width: 200px; background: #fff; border-radius: 0 0 var(--radius) var(--radius); box-shadow: 0 6px 20px rgba(0,0,0,.15); padding: 6px 0; }
.dropdown.right { left: auto; right: 0; }
.dropdown a { display: block; padding: 9px 16px; color: var(--text); }
.dropdown a:hover { background: var(--blue-l); text-decoration: none; }
.nav-item:hover .dropdown, .nav-item:focus-within .dropdown { display: block; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.wh-switch select { background: var(--blue-d); color: #fff; border: 1px solid rgba(255,255,255,.3); padding: 6px 8px; width: auto; }
.wh-fixed { padding: 0 10px; white-space: nowrap; }
.btn-sell { background: var(--green); color: #fff; font-weight: 600; padding: 8px 16px; border-radius: var(--radius); white-space: nowrap; }
.btn-sell:hover { background: var(--green-d); text-decoration: none; }
.mobile-only { display: none !important; }
.nav-toggle { display: none; background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; }

/* --- Layout --- */
.container { max-width: 1500px; margin: 0 auto; padding: 18px 16px 40px; }
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: #fff; border-radius: var(--radius); box-shadow: 0 1px 2px rgba(16,24,40,.06); border: 1px solid var(--line); padding: 16px; margin-bottom: 14px; }
.layout-2col { display: grid; grid-template-columns: 240px 1fr; gap: 14px; align-items: start; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.filters summary { display: none; }
.filters .filter-box { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.filters h4 { margin: 0 0 8px; font-size: 13px; font-weight: 600; }
.summary-bar { display: flex; gap: 20px; flex-wrap: wrap; background: #fff; border: 1px solid var(--line); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; padding: 10px 14px; color: var(--muted); }
.summary-bar b { color: var(--text); }
.summary-bar + .table-wrap { border-radius: 0 0 var(--radius) var(--radius); }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.card.table-wrap, .card > .table-wrap { border: 0; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select { width: auto; }
.inline-form .quick a { margin-left: 10px; }
.form-narrow { max-width: 560px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; max-width: 900px; }
.form-grid .span2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.steps { padding-left: 18px; margin-top: 0; } .steps li { margin-bottom: 6px; }

/* --- Buttons --- */
.btn { display: inline-flex; align-items: center; gap: 4px; padding: 7px 14px; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: var(--radius); cursor: pointer; font: inherit; white-space: nowrap; }
.btn:hover { background: #f5f7fa; text-decoration: none; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-d); }
.btn-danger { color: var(--red); border-color: #f1c4c0; }
.btn-danger:hover { background: #fdecea; }
.btn-light { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.35); color: #fff; }
.btn-light:hover { background: rgba(255,255,255,.25); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .6; cursor: wait; }

/* --- Tables --- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { background: var(--blue-l); color: #334155; font-weight: 600; text-align: left; padding: 9px 10px; white-space: nowrap; font-size: 13px; }
.tbl td { padding: 9px 10px; border-top: 1px solid #edf0f3; vertical-align: middle; }
.tbl tbody tr:hover { background: #f8fbff; }
.tbl tfoot td { border-top: 2px solid var(--line); }
.tbl.compact td, .tbl.compact th { padding: 6px 8px; }
.tbl input.num { width: 110px; text-align: right; padding: 5px 8px; }
.tbl .x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 15px; }
.tbl .x:hover { color: var(--red); }
tr.clickable { cursor: pointer; }
tr.muted td { color: #9aa5b1; }
td.r, th.r, .tbl th.r, .tbl td.r { text-align: right; } .nowrap { white-space: nowrap; }
.code { font-family: ui-monospace, Consolas, monospace; color: var(--blue); font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px !important; }
.warn { color: var(--orange); font-weight: 600; }
.pos { color: var(--green); } .neg { color: var(--red); }
.muted { color: var(--muted); } .small { font-size: 12px; }
.kv { width: 100%; border-collapse: collapse; }
.kv th { text-align: left; color: var(--muted); font-weight: 400; padding: 6px 0; width: 40%; }
.kv td { padding: 6px 0; }
.kv tr.total th, .kv tr.total td { border-top: 1px solid var(--line); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 500; }
.badge-ok { background: #e3f6ec; color: var(--green-d); }
.badge-cancel { background: #fdecea; color: var(--red); }
.pager { display: flex; gap: 4px; padding: 12px 0; flex-wrap: wrap; }
.pager a { padding: 5px 11px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.pager a.cur { background: var(--blue); color: #fff; border-color: var(--blue); }
.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; }
.alert-ok { background: #e3f6ec; color: #0e5c34; border: 1px solid #b7e4c9; }
.alert-err { background: #fdecea; color: #8a1c13; border: 1px solid #f5c2bd; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs a { padding: 9px 16px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.cur { color: var(--blue); border-color: var(--blue); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--blue); }

/* --- Dashboard --- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 14px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; gap: 14px; align-items: center; }
.kpi small { color: var(--muted); display: block; }
.kpi b { font-size: 22px; display: block; margin: 2px 0; }
.kpi-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; flex: none; }
.kpi-icon.blue { background: #e8f1fc; } .kpi-icon.green { background: #e3f6ec; } .kpi-icon.orange { background: #fff3e0; } .kpi-icon.purple { background: #efeafd; }
.dash { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
.dash > .card { margin: 0; }
.chart { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--blue); } .chart .bar:hover { fill: var(--blue-d); }
.chart .grid { stroke: #edf0f3; } .chart .axis { fill: var(--muted); font-size: 11px; }
.feed { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow: auto; }
.feed li { padding: 7px 0; border-bottom: 1px solid #f0f2f4; font-size: 13px; }

/* --- Chứng từ --- */
.doc-layout { display: grid; grid-template-columns: 1fr 300px; gap: 14px; align-items: start; }
.doc-side .sum-line { display: flex; justify-content: space-between; padding: 6px 0; }
.doc-side .sum-line.big b { font-size: 18px; color: var(--blue); }
.pick-wrap { margin-bottom: 12px; position: relative; }
.pick-wrap input#pick { max-width: 520px; }
.picker-list { display: none; position: absolute; top: 100%; left: 0; width: 520px; max-width: 95vw; max-height: 360px; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.15); z-index: 60; }
.picker-item { display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px; cursor: pointer; border-bottom: 1px solid #f2f4f6; color: var(--text); }
.picker-item.sel, .picker-item:hover { background: var(--blue-l); }
.picker-empty { padding: 12px; color: var(--muted); }

/* --- POS --- */
.pos-page { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.pos-top { background: var(--blue); display: flex; align-items: center; gap: 10px; padding: 8px 12px; color: #fff; }
.pos-top .brand { margin: 0; }
.pos-search { flex: 1; max-width: 560px; position: relative; }
.pos-search input { border: 0; padding: 9px 12px; color: var(--text); }
.pos-search .picker-list { width: 100%; color: var(--text); }
.pos-info { margin-left: auto; white-space: nowrap; font-size: 13px; }
.pos-body { flex: 1; display: grid; grid-template-columns: 1fr 360px; min-height: 0; }
.pos-cart { overflow: auto; padding: 12px; }
.pos-cart .tbl { background: #fff; border: 1px solid var(--line); }
.pos-side { background: #fff; border-left: 1px solid var(--line); padding: 14px; display: flex; flex-direction: column; gap: 10px; overflow: auto; }
.pos-cust { display: flex; flex-direction: column; gap: 6px; }
.pos-sum > div { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; gap: 10px; }
.pos-sum input, .pos-sum select { width: 160px; text-align: right; }
.pos-sum .big b { font-size: 22px; color: var(--blue); }
.btn-pay { margin-top: auto; background: var(--blue); color: #fff; border: 0; border-radius: var(--radius); padding: 16px; font-size: 17px; font-weight: 700; cursor: pointer; }
.btn-pay:hover { background: var(--blue-d); }
.btn-pay:disabled { opacity: .6; }

/* --- Login --- */
.login-page { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, var(--blue) 0%, #2d8cf0 100%); }
.login-box { background: #fff; width: 360px; max-width: 92vw; padding: 28px; border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.login-brand { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; color: var(--blue); }
.login-brand .brand-mark { background: var(--blue); color: #fff; }

/* --- Mobile --- */
@media (max-width: 960px) {
  .layout-2col, .grid-2, .dash, .doc-layout, .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: auto; }
  .nav-toggle { display: block; }
  .mainnav { display: none; position: absolute; top: 52px; left: 0; right: 0; background: var(--blue); flex-direction: column; height: auto; }
  body.nav-open .mainnav { display: flex; }
  .mainnav .dropdown { position: static; display: block; box-shadow: none; background: var(--blue-d); border-radius: 0; }
  .mainnav .dropdown a { color: #fff; padding-left: 30px; }
  .user-menu .nav-link span, .brand { font-size: 15px; }
  .wh-switch select { max-width: 130px; }
  .topbar-right .user-menu, .brand-text { display: none; }
  .mainnav .mobile-only { display: flex !important; flex-direction: column; align-items: stretch; }
  .mainnav .nav-item { flex-direction: column; align-items: stretch; }
  .topbar-inner { padding: 0 10px; gap: 6px; }
  .btn-sell { padding: 8px 10px; }
  .pos-body { grid-template-columns: 1fr; overflow: auto; }
  .pos-page { height: auto; overflow: visible; }
  .pos-info { display: none; }
}

/* --- Ảnh sản phẩm --- */
.thumb { width: 44px; height: 44px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 6px; flex: none; display: block; }
.thumb.sm { width: 34px; height: 34px; }
.thumb-cell { width: 56px; padding-right: 0 !important; }
.name-img { display: flex; align-items: center; gap: 10px; }
.picker-item { align-items: center; }
.picker-item .grow { flex: 1; min-width: 0; }
.img-edit { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 10px; padding: 12px; background: #f8fafc; border: 1px dashed var(--line); border-radius: var(--radius); }
.img-edit img { width: 140px; height: 140px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); flex: none; }
.img-edit > div { flex: 1; }
.product-photo { text-align: center; }
.product-photo img { width: 100%; max-height: 320px; object-fit: contain; border-radius: var(--radius); background: #fff; }
.price-big { font-size: 24px; font-weight: 700; color: var(--blue); margin-top: 8px; }
.price-big small { font-size: 14px; color: var(--muted); font-weight: 400; }
.view-toggle { margin-left: auto; display: flex; gap: 4px; }
.view-toggle a { padding: 2px 10px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--muted); }
.view-toggle a.cur { background: var(--blue); border-color: var(--blue); color: #fff; }
.view-toggle a:hover { text-decoration: none; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); }
.pcard { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; color: var(--text); background: #fff; transition: box-shadow .15s, border-color .15s; }
.pcard:hover { text-decoration: none; border-color: var(--blue); box-shadow: 0 4px 14px rgba(11,107,211,.15); }
.pcard-img { aspect-ratio: 1 / 1; background: #fff; display: grid; place-items: center; border-bottom: 1px solid #f0f2f4; }
.pcard-img img { width: 100%; height: 100%; object-fit: contain; }
.pcard-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.pcard-name { font-weight: 500; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.7em; }
.pcard-price { font-size: 17px; font-weight: 700; color: var(--blue); margin-top: auto; }
.pcard-stock { font-size: 13px; color: var(--green-d); }
.pcard-stock.low { color: var(--orange); }
.pcard-stock.out { color: var(--red); font-weight: 600; }
@media (max-width: 960px) {
  .pgrid { grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 8px; }
  .filters summary { display: block; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; cursor: pointer; font-weight: 600; }
  .filters details[open] summary { margin-bottom: 10px; }
  .img-edit { flex-direction: column; }
}
