:root {
  --bg: #f4f6f8; --card: #fff; --text: #1d2733; --muted: #6b7785; --line: #e1e6eb;
  --primary: #0b7a5b; --primary-2: #e6f4ef; --danger: #c0392b; --warn: #b9770e; --blue: #1f6fb2;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.grow { flex: 1; }
.err { color: var(--danger); min-height: 1.2em; }
.right { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.red { color: var(--danger); } .green { color: var(--primary); } .warn { color: var(--warn); }
a { color: var(--blue); cursor: pointer; text-decoration: none; }
h2 { margin: 0 0 12px; font-size: 20px; }
h3 { margin: 16px 0 8px; font-size: 16px; }

input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: inherit; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); border-color: transparent; }
label { display: block; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
label input, label select, label textarea { margin-top: 4px; color: var(--text); font-size: 15px; }
.btn { font: inherit; border: 1px solid var(--line); background: #fff; padding: 8px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; color: var(--text); }
.btn:hover { background: #f0f2f4; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: #f0c8c3; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.big { padding: 12px 18px; font-size: 17px; width: 100%; }
.btn.on { background: var(--primary-2); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 14px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 360px; }
.login h1 { margin: 0 0 16px; text-align: center; color: var(--primary); }

.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 14px; background: var(--primary); color: #fff; }
.top .btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.top .muted { color: rgba(255,255,255,.8); }
.menuBtn { display: none; background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; }
#shell { display: grid; grid-template-columns: 190px 1fr; grid-template-rows: 52px 1fr; min-height: 100vh; }
#shell .top { grid-column: 1 / 3; }
nav { background: #fff; border-right: 1px solid var(--line); padding: 8px 0; position: sticky; top: 52px; height: calc(100vh - 52px); overflow: auto; }
nav a { display: block; padding: 10px 18px; color: var(--text); }
nav a.on { background: var(--primary-2); color: var(--primary); font-weight: 600; border-right: 3px solid var(--primary); }
nav a:hover { background: #f4f6f8; }
main { padding: 16px; min-width: 0; }

table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 13px; color: var(--muted); font-weight: 600; background: #fafbfc; }
tr.click { cursor: pointer; } tr.click:hover td { background: #f7faf9; }
.tableWrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.tableWrap table { border: 0; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #eef1f4; color: var(--muted); }
.tag.green { background: var(--primary-2); color: var(--primary); }
.tag.red { background: #fbe9e7; color: var(--danger); }
.tag.warn { background: #fdf2e0; color: var(--warn); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.stat .k { font-size: 13px; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 12px; color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
.bars div { min-width: 0; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: 11px; color: var(--muted); }
.bars i { display: block; width: 100%; max-width: 42px; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; }

/* Bán hàng */
.pos { display: grid; grid-template-columns: 1fr 340px; gap: 14px; align-items: start; }
.searchBox { position: relative; }
.searchBox input { font-size: 17px; padding: 12px 14px; }
.drop { position: absolute; left: 0; right: 0; top: 100%; z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 60vh; overflow: auto; margin-top: 4px; }
.drop div { padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; gap: 10px; }
.drop div.sel, .drop div:hover { background: var(--primary-2); }
.drop .n { flex: 1; }
.cart td input { padding: 6px 8px; }
.cart .qty { width: 72px; text-align: right; }
.cart .price { width: 100px; text-align: right; }
.pay .line { display: flex; justify-content: space-between; padding: 6px 0; }
.pay .total { font-size: 24px; font-weight: 700; color: var(--primary); }
.pay input.money { text-align: right; font-size: 17px; }
.methods { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin: 8px 0; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

.modal { position: fixed; inset: 0; background: rgba(20,30,40,.45); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modalBox { background: #fff; border-radius: 14px; padding: 18px; width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; }
.modalBox.wide { max-width: 900px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #22303c; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 60; max-width: 90vw; }
.toast.bad { background: var(--danger); }
.print { display: none; }

@media (max-width: 900px) {
  .pos { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  #shell { grid-template-columns: 1fr; }
  #shell .top { grid-column: 1; }
  .menuBtn { display: block; }
  #userName { display: none; }
  nav { position: fixed; top: 52px; left: 0; bottom: 0; width: 220px; z-index: 40; height: auto; transform: translateX(-100%); transition: transform .2s; box-shadow: 4px 0 20px rgba(0,0,0,.15); }
  nav.open { transform: none; }
  main { padding: 12px; }
  .grid2 { grid-template-columns: 1fr; }
  .hideM { display: none; }
  .cart .price { width: 84px; }
}

@media print {
  body * { visibility: hidden; }
  .print, .print * { visibility: visible; }
  .print { display: block; position: absolute; left: 0; top: 0; width: 72mm; font: 12px/1.35 Arial, sans-serif; color: #000; }
  .print table { background: none; }
  .print td, .print th { padding: 2px 0; border: 0; background: none; color: #000; font-size: 12px; }
  .print .c { text-align: center; }
  .print hr { border: 0; border-top: 1px dashed #000; }
  @page { margin: 3mm; }
}

/* Ảnh sản phẩm */
.thumb { display: inline-block; flex: none; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #fff; vertical-align: middle; }
img.thumb { cursor: zoom-in; }
.thumb.ph { display: inline-grid; place-items: center; background: #f0f4f2; color: #9bb5aa; }
.zoom { position: fixed; inset: 0; z-index: 70; background: rgba(10,20,30,.8); display: grid; place-items: center; padding: 16px; cursor: zoom-out; }
.zoom img { max-width: 100%; max-height: 92vh; border-radius: 10px; background: #fff; }
