:root {
  --navy: #232c5f;
  --navy-2: #2f3a78;
  --orange: #f07d3c;
  --orange-soft: #fde7da;
  --yellow: #f6b938;
  --cream: #fdf6ec;
  --card: #ffffff;
  --ink: #1d2340;
  --muted: #6b7090;
  --line: #ece4d6;
  --green: #23845a;
  --green-soft: #e1f3ea;
  --red: #c93c3c;
  --red-soft: #fbe5e5;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(35, 44, 95, .06), 0 4px 16px rgba(35, 44, 95, .06);
  font-family: "Segoe UI", "Be Vietnam Pro", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--cream); min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Thanh trên ---------- */
.topbar { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: baseline; gap: 10px; color: #fff; text-decoration: none; min-width: 0; }
.logo { font-weight: 800; font-size: 26px; letter-spacing: -.5px; line-height: 1; }
.logo b { color: var(--yellow); }
.brand-sub { font-size: 12px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tabs a {
  color: #fff; text-decoration: none; padding: 8px 14px; border-radius: 999px;
  font-weight: 600; font-size: 14px; opacity: .8; white-space: nowrap;
}
.tabs a:hover { opacity: 1; background: rgba(255,255,255,.08); }
.tabs a.active { background: #fff; color: var(--navy); opacity: 1; }
.me { position: relative; }
.me-btn {
  background: rgba(255,255,255,.12); border: 0; color: #fff; border-radius: 999px;
  padding: 7px 12px; font-size: 13px; font-weight: 600; max-width: 180px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.me-menu {
  position: absolute; right: 0; top: calc(100% + 6px); background: #fff; color: var(--ink);
  border-radius: 12px; box-shadow: var(--shadow); padding: 6px; min-width: 170px;
}
.me-menu button {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  padding: 10px 12px; border-radius: 8px; font-size: 14px;
}
.me-menu button:hover { background: var(--cream); }

.avatar {
  display: none; width: 30px; height: 30px; border-radius: 50%; background: var(--yellow); color: var(--navy);
  font-weight: 800; font-size: 14px; place-items: center;
}
.me-head { display: none; }
.page-title { display: none; }
.bottom-nav { display: none; }
.m-only { display: none; }
.pskus { display: none; }

/* ---------- Bố cục chung ---------- */
main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 120px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: 24px; color: var(--navy); }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.section { margin-top: 26px; }
.section-title { display: flex; align-items: center; gap: 12px; margin: 0 0 12px; flex-wrap: wrap; }
.section-title h2 { margin: 0; font-size: 18px; color: var(--navy); }
.section-title .hint { margin-left: auto; color: var(--muted); font-size: 13px; }
.section-title .hint b { color: var(--orange); }
.pill-orange {
  background: var(--orange); color: #fff; font-weight: 700; font-size: 13px;
  padding: 6px 12px; border-radius: 8px; letter-spacing: .3px;
}
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.panel + .panel { margin-top: 16px; }
.panel h3 { margin: 0 0 4px; font-size: 16px; color: var(--navy); }
.panel .sub { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; font-size: 14px; }

/* ---------- Nút & form ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 12px; padding: 11px 18px; font-weight: 700; font-size: 15px;
  background: var(--navy); color: #fff; text-decoration: none; transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-orange { background: var(--orange); }
.btn-ghost { background: transparent; color: var(--navy); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn-ghost:hover { background: #fff; filter: none; }
.btn-danger { background: var(--red); }
.btn-excel { background: #1d6f42; } /* xanh Excel */
.btn-excel svg { width: 18px; height: 18px; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; color: var(--navy-2); font-weight: 600; padding: 4px 6px; font-size: 13px; border-radius: 6px; }
.link-btn:hover { background: var(--cream); }
.link-btn.danger { color: var(--red); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; border: 1.5px solid var(--line); background: #fff; border-radius: 10px;
  padding: 10px 12px; font-size: 15px; outline: none;
}
.input:focus { border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(47,58,120,.12); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.form-row .field { margin: 0; }
.error-text { color: var(--red); font-size: 13px; min-height: 18px; margin: 4px 0 0; }

/* ---------- Đăng nhập ---------- */
.login-wrap { min-height: calc(100vh - 40px); display: grid; place-items: center; }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; }
.login-head { background: var(--navy); color: #fff; padding: 26px 24px 22px; position: relative; overflow: hidden; }
.login-head::after {
  content: ""; position: absolute; right: -50px; top: -60px; width: 170px; height: 170px;
  border-radius: 50%; background: var(--orange); opacity: .9;
}
.login-head .logo { font-size: 38px; position: relative; z-index: 1; }
.login-head p { margin: 8px 0 0; font-size: 13px; opacity: .8; position: relative; z-index: 1; }
.login-body { padding: 22px 24px 24px; }

/* ---------- Bán hàng ---------- */
.today-strip {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  background: var(--navy); color: #fff; border-radius: var(--radius); padding: 14px 18px;
}
.today-strip .ts-item { display: flex; flex-direction: column; min-width: 110px; }
.today-strip .ts-label { font-size: 12px; opacity: .7; }
.today-strip .ts-value { font-size: 20px; font-weight: 800; }
.today-strip .ts-value.hl { color: var(--yellow); }
.today-strip .ts-sep { width: 1px; align-self: stretch; background: rgba(255,255,255,.15); }

.grid-products { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-products.single { grid-template-columns: 1fr; }
.pcard {
  position: relative; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px; display: flex; flex-direction: column; gap: 10px; cursor: pointer;
  border: 2.5px solid transparent; transition: border-color .15s, box-shadow .15s, transform .1s;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.pcard:hover { box-shadow: 0 2px 4px rgba(35,44,95,.08), 0 10px 24px rgba(35,44,95,.10); }
.pcard.selected { border-color: var(--orange); box-shadow: 0 0 0 4px rgba(240,125,60,.15), var(--shadow); }
.pcard .pimg { border-radius: 12px; overflow: hidden; aspect-ratio: 16 / 10; background: #eef1f6; }
.pphotos { position: absolute; inset: 6% 8% 5%; display: flex; align-items: flex-end; justify-content: center; gap: 4%; }
.pphotos img { display: block; max-width: 44%; object-fit: contain; filter: drop-shadow(0 6px 8px rgba(35,44,95,.12)); }
.pphotos .plus { color: var(--orange); font-weight: 800; font-size: 26px; align-self: center; }
.pphotos .or { color: var(--orange); font-weight: 700; font-size: 12px; align-self: center; }
.pfoot { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.pstock { margin-left: auto; font-size: 12px; color: var(--muted); opacity: .85; white-space: nowrap; }
.pstock b { font-weight: 700; color: var(--muted); }
.pstock .kho-na { font-style: italic; }
b.low, .pstock b.low { color: #c46a12; }
b.out, .pstock b.out { color: var(--red); }
.warn-box { background: #fff4e5; color: #8a4b0b; border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.warn-box ul { margin: 6px 0 0; padding-left: 18px; }
.inv-preview { display: flex; gap: 16px; flex-wrap: wrap; background: var(--cream); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-top: 4px; }
.inv-preview b { color: var(--navy); }
.inv-tbl td { vertical-align: middle; }
.inv-tbl .btn-sm { white-space: nowrap; }
details.collapsible > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; user-select: none;
}
details.collapsible > summary::-webkit-details-marker { display: none; }
details.collapsible > summary > span { flex: 1; display: flex; flex-direction: column; gap: 2px; }
details.collapsible > summary h3 { margin: 0; }
details.collapsible > summary .sub { margin: 0; }
details.collapsible .chev {
  width: 34px; height: 34px; padding: 7px; border-radius: 50%; background: var(--cream); color: var(--navy);
  flex: none; transition: transform .2s;
}
details.collapsible[open] .chev { transform: rotate(180deg); }
details.collapsible[open] > summary { margin-bottom: 10px; }
.inv-set { display: flex; align-items: center; gap: 12px; min-width: 250px; }
.inv-thumb { position: relative; flex: none; width: 120px; aspect-ratio: 16 / 10; border-radius: 10px; overflow: hidden; }
.inv-thumb .pphotos { inset: 8% 6% 6%; gap: 3%; }
.inv-thumb .pphotos .plus { font-size: 13px; }
.inv-thumb .pphotos .or { font-size: 8px; }
.inv-thumb.lg { width: 100%; max-width: 300px; margin: 0 auto 14px; border-radius: 14px; }
.inv-thumb.lg .pphotos .plus { font-size: 22px; }
.inv-thumb.lg .pphotos .or { font-size: 12px; }
.pcode {
  position: absolute; top: 8px; left: 8px; z-index: 1; min-width: 34px; height: 34px; padding: 0 8px;
  border-radius: 999px; background: var(--navy); color: #fff; font-weight: 800; font-size: 15px;
  display: grid; place-items: center; box-shadow: 0 0 0 3px #fff;
}
.set-no {
  display: inline-block; vertical-align: 2px; margin-right: 8px; background: var(--orange); color: #fff;
  font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 5px; letter-spacing: .3px;
}
.psub { margin: -2px 0 0; color: var(--orange); font-weight: 700; font-size: 13px; }
.pcomps { list-style: none; margin: 2px 0 0; padding: 0; }
.pcomps li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 13px; }
.pcomps li span { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pcomps li b { color: var(--navy); font-weight: 600; }
.pcomps li small { color: var(--muted); font-size: 12px; }
.pcomps code { font-family: inherit; font-weight: 800; color: var(--navy); font-size: 13px; white-space: nowrap; }
.pcard.wide { flex-direction: row; align-items: stretch; }
.pcard.wide .pimg { flex: 0 0 min(42%, 340px); aspect-ratio: 16 / 11; }
.pcard.wide .pbody { justify-content: center; padding: 6px 8px; }
.pbody { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.ptitle { display: flex; align-items: flex-start; gap: 8px; }
.ptitle h3 { margin: 0; font-size: 17px; color: var(--navy); line-height: 1.3; }
.badge-x { margin-left: auto; background: var(--orange); color: #fff; font-weight: 800; font-size: 12px; padding: 3px 10px; border-radius: 999px; flex: none; }
.badge-suggest { background: var(--yellow); color: var(--navy); font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; flex: none; margin-top: 2px; }
.pdesc { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.ptag { align-self: flex-start; background: var(--orange-soft); color: #b8531c; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 6px; }
.pprice { font-weight: 800; color: var(--orange); font-size: 15px; }
.check {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 9px;
  background: rgba(255,255,255,.95); border: 2px solid #c9cde0; display: grid; place-items: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.12); transition: background .15s, border-color .15s;
}
.check svg { width: 18px; height: 18px; opacity: 0; transition: opacity .15s; }
.pcard.selected .check { background: var(--orange); border-color: var(--orange); }
.pcard.selected .check svg { opacity: 1; }
.pimg { position: relative; }

.pcontrols { display: none; flex-direction: column; gap: 10px; border-top: 1px dashed var(--line); padding-top: 10px; cursor: default; }
.pcard.selected .pcontrols { display: flex; }
.ctrl-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ctrl-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; margin-left: auto; }
.stepper button { width: 38px; height: 36px; border: 0; background: #fff; font-size: 20px; font-weight: 700; color: var(--navy); }
.stepper button:hover { background: var(--cream); }
.stepper span { min-width: 34px; text-align: center; font-weight: 800; font-size: 16px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px;
  font-size: 13px; font-weight: 600; color: var(--ink);
}
.chip.on { border-color: var(--navy); background: var(--navy); color: #fff; }
.chip.need { border-color: var(--red); animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

.cart-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: #fff; box-shadow: 0 -6px 24px rgba(35,44,95,.14);
  transform: translateY(110%); transition: transform .2s;
}
.cart-bar.show { transform: none; }
.cart-inner { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.cart-sum { display: flex; flex-direction: column; min-width: 0; }
.cart-sum b { font-size: 20px; color: var(--navy); }
.cart-sum span { font-size: 13px; color: var(--muted); }
.cart-actions { margin-left: auto; display: flex; gap: 8px; }

.recent-list { display: flex; flex-direction: column; }
.recent-item { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.recent-item:first-child { border-top: 0; }
.recent-item .ri-main { flex: 1; min-width: 0; font-size: 14px; }
.recent-item .ri-meta { font-size: 12px; color: var(--muted); }
.recent-item .ri-total { font-weight: 800; color: var(--navy); white-space: nowrap; }
.cancelled .ri-main, .cancelled .ri-total, tr.cancelled td { text-decoration: line-through; opacity: .55; }
.status { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.status.ok { background: var(--green-soft); color: var(--green); }
.status.off { background: var(--red-soft); color: var(--red); }

/* ---------- Bộ lọc ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.seg { display: inline-flex; background: #fff; border-radius: 12px; padding: 4px; box-shadow: var(--shadow); flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 7px 12px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--navy); color: #fff; }
.filters .input { width: auto; padding: 7px 10px; font-size: 13px; }
.live { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }

/* ---------- Thống kê ---------- */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.kpi { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.kpi .k-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi .k-value { font-size: 28px; font-weight: 800; color: var(--navy); margin-top: 4px; line-height: 1.1; }
.kpi .k-foot { font-size: 12px; color: var(--muted); margin-top: 6px; }
.kpi.primary { background: var(--navy); }
.kpi.primary .k-label, .kpi.primary .k-foot { color: rgba(255,255,255,.7); }
.kpi.primary .k-value { color: var(--yellow); }

.two-col { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.tbl { width: 100%; min-width: 600px; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 700; padding: 8px 8px; border-bottom: 1.5px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tfoot td { font-weight: 800; color: var(--navy); border-top: 1.5px solid var(--line); border-bottom: 0; }
.tbl .pname { font-weight: 600; color: var(--navy); }
.tbl .vlist { font-size: 12px; color: var(--muted); margin-top: 2px; }
.idx.m-only { display: none; } /* chỉ hiện trên điện thoại (xem phần GIAO DIỆN ĐIỆN THOẠI) */
.idx { display: inline-grid; place-items: center; min-width: 26px; height: 22px; padding: 0 5px; border-radius: 999px; background: var(--navy); color: #fff; font-size: 11px; font-weight: 800; }

.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 290px) minmax(60px, 1fr) auto; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .bl { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 14px; background: #f1ece3; border-radius: 0 4px 4px 0; overflow: hidden; }
.bar-fill { height: 100%; background: var(--orange); border-radius: 0 4px 4px 0; min-width: 2px; transition: width .4s; }
.bar-fill.navy { background: var(--navy-2); }
.bar-fill.teal { background: #2a8c82; }

/* Mục thống kê có nút chuyển Biểu đồ / Bảng */
.panel-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.panel-head > div:first-child { flex: 1; min-width: 200px; }
.seg.seg-sm { box-shadow: none; background: var(--cream); padding: 3px; flex: none; }
.seg.seg-sm button { padding: 6px 12px; font-size: 12px; }
.vt-panel.show-chart .vt-table, .vt-panel.show-table .vt-chart { display: none; }
.bar-row .bv { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-row .bv b { color: var(--navy); }
.bar-row .bv small { color: var(--muted); margin-left: 6px; }
@media (max-width: 520px) {
  .bar-row { grid-template-columns: 1fr auto; }
  .bar-row .bar-track { grid-column: 1 / -1; order: 3; }
  .bar-row .bl { white-space: normal; line-height: 1.3; }
}

/* ---------- Bảng xếp hạng ---------- */
.lb-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.lb-head > div:first-child { flex: 1; min-width: 200px; }
.lb-head .sub { margin-bottom: 0; }
.lb-total { background: var(--navy); color: #fff; border-radius: 12px; padding: 8px 14px; display: flex; flex-direction: column; }
.lb-total span { font-size: 12px; opacity: .7; }
.lb-total b { color: var(--yellow); font-size: 18px; }
.lb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.lb-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 14px;
  background: #faf7f2; border: 1.5px solid transparent;
}
.lb-row.top1 { background: linear-gradient(90deg, #fff5d6, #fffaf0 70%); border-color: #f3d27a; }
.lb-row.top2 { background: linear-gradient(90deg, #eef1f6, #fafbfd 70%); border-color: #cfd5e2; }
.lb-row.top3 { background: linear-gradient(90deg, #fbe9dc, #fff8f3 70%); border-color: #e7b993; }
.lb-row.me { box-shadow: 0 0 0 2px var(--orange); }
.lb-rank { flex: none; width: 48px; display: grid; place-items: center; }
.rank-no { font-size: 18px; font-weight: 800; color: var(--navy); }
.lb-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.lb-name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.lb-link {
  background: none; border: 0; padding: 0; font-weight: 700; font-size: 16px; color: var(--navy);
  text-decoration: underline; text-decoration-color: rgba(47,58,120,.3); text-underline-offset: 3px; text-align: left;
}
.lb-link:hover { color: var(--orange); text-decoration-color: currentColor; }
.lb-plain { font-weight: 700; font-size: 16px; color: var(--navy); }
.you { background: var(--orange); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.lb-bar { height: 8px; background: rgba(35,44,95,.08); border-radius: 0 4px 4px 0; overflow: hidden; }
.lb-bar > div { height: 100%; background: var(--navy-2); border-radius: 0 4px 4px 0; transition: width .4s; }
.lb-row.top1 .lb-bar > div { background: #e0a91b; }
.lb-row.top2 .lb-bar > div { background: #8e98ad; }
.lb-row.top3 .lb-bar > div { background: #c47a45; }
.lb-meta { font-size: 12px; color: var(--muted); }
.lb-rev { flex: none; text-align: right; display: flex; flex-direction: column; }
.lb-rev b { font-size: 17px; color: var(--navy); }
.lb-rev small { font-size: 12px; color: var(--muted); }

/* Huy chương: đĩa tròn + dải ruy băng */
.medal { position: relative; display: inline-grid; place-items: center; width: 38px; height: 38px; margin-top: 10px; }
.medal::before, .medal::after {
  content: ""; position: absolute; top: -12px; width: 11px; height: 18px; z-index: 0;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%);
}
.medal::before { left: 8px; transform: rotate(14deg); background: #2f3a78; }
.medal::after { right: 8px; transform: rotate(-14deg); background: var(--orange); }
.medal > span {
  position: relative; z-index: 1; width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center;
  font-weight: 900; font-size: 16px; color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.25);
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.45), 0 2px 6px rgba(0,0,0,.18);
}
.medal.m1 > span { background: radial-gradient(circle at 35% 30%, #ffe89a, #f2b822 55%, #c98d0a); }
.medal.m2 > span { background: radial-gradient(circle at 35% 30%, #ffffff, #c3cad6 55%, #8b94a6); }
.medal.m3 > span { background: radial-gradient(circle at 35% 30%, #f8c9a0, #cf8650 55%, #9c5a2a); }
.medal.lg { width: 50px; height: 50px; margin-top: 12px; }
.medal.lg > span { font-size: 21px; }
.medal.lg::before, .medal.lg::after { width: 14px; height: 22px; top: -14px; }
.medal.lg::before { left: 11px; }
.medal.lg::after { right: 11px; }

/* Chi tiết nhân viên (hộp thoại) */
dialog.modal.wide { width: min(720px, calc(100vw - 32px)); }
.sd-head { display: flex; align-items: center; gap: 14px; }
.sd-head .rank-no { width: 44px; text-align: center; }
.sd-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.sd-kpis > div { background: var(--cream); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; }
.sd-kpis span { font-size: 12px; color: var(--muted); }
.sd-kpis b { font-size: 17px; color: var(--navy); }
.sd-title { margin: 16px 0 6px; font-size: 14px; color: var(--navy); }
table.tbl.sd-tbl { min-width: 0; }
@media (max-width: 560px) {
  .sd-kpis { grid-template-columns: repeat(2, 1fr); }
  .lb-row { gap: 10px; padding: 10px; }
  .lb-rank { width: 40px; }
  .lb-rev b { font-size: 15px; }
}

.role { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--orange-soft); color: #b8531c; }
.role.admin { background: var(--navy); color: #fff; }

/* ---------- Modal & toast ---------- */
dialog.modal { border: 0; border-radius: 18px; padding: 0; width: min(480px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); color: var(--ink); }
.focus-sink { position: absolute; width: 1px; height: 1px; overflow: hidden; outline: none; }
dialog.modal::backdrop { background: rgba(20, 24, 50, .5); }
.modal-head { padding: 18px 20px 0; }
.modal-head h3 { margin: 0; color: var(--navy); font-size: 18px; }
.modal-body { padding: 14px 20px; max-height: 60vh; overflow: auto; }
.modal-foot { padding: 0 20px 18px; display: flex; gap: 8px; justify-content: flex-end; }
.sum-list { list-style: none; margin: 0 0 12px; padding: 0; }
.sum-list li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.sum-list li span:first-child { flex: 1; }
.sum-total { display: flex; justify-content: space-between; font-weight: 800; font-size: 18px; color: var(--navy); margin-bottom: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: calc(100vw - 32px);
}
.toast.ok { background: var(--green); }
.toast.err { background: var(--red); }

/* =====================================================================
   GIAO DIỆN ĐIỆN THOẠI
   ===================================================================== */
@media (max-width: 760px) {
  :root { --nav-h: 62px; }
  /* Thanh trên gọn: logo + tên trang + ảnh đại diện */
  .topbar-inner { gap: 10px; padding: 8px 14px; padding-top: max(8px, env(safe-area-inset-top)); }
  .brand-sub, .tabs { display: none; }
  .logo { font-size: 23px; }
  .page-title {
    display: block; flex: 1; min-width: 0; font-weight: 700; font-size: 15px; opacity: .9;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 10px;
    border-left: 1px solid rgba(255,255,255,.2);
  }
  .me-btn { padding: 0; background: none; max-width: none; }
  .me-name { display: none; }
  .avatar { display: grid; }
  .me-menu { min-width: 210px; }
  .me-head { display: flex; flex-direction: column; padding: 8px 12px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
  .me-head span { font-size: 12px; color: var(--muted); }

  /* Thanh điều hướng dưới đáy */
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -4px 18px rgba(35,44,95,.08);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav[hidden] { display: none; }
  .bottom-nav a {
    flex: 1; height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600;
    -webkit-tap-highlight-color: transparent; position: relative;
  }
  .bottom-nav svg { width: 24px; height: 24px; }
  .bottom-nav a.active { color: var(--navy); }
  .bottom-nav a.active::before {
    content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--orange);
  }
  .bottom-nav a.active svg { color: var(--orange); }

  main { padding: 14px 12px 24px; }
  body.has-nav main { padding-bottom: calc(var(--nav-h) + 110px + env(safe-area-inset-bottom)); }
  .m-only { display: inline; }
  .idx.m-only { display: inline-grid; margin-right: 4px; }
  div.m-only { display: block; }
  .page-head { margin-bottom: 12px; }
  .page-head h1 { font-size: 20px; }
  .page-head p { font-size: 13px; }
  .panel { padding: 14px; border-radius: 14px; }
  .section { margin-top: 18px; }
  .input, select.input, textarea.input { font-size: 16px; } /* tránh iPhone tự phóng to khi gõ */

  /* Giỏ hàng nằm ngay trên thanh điều hướng */
  .cart-bar { bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding: 10px 12px; border-radius: 16px 16px 0 0; }
  body:not(.has-nav) .cart-bar { bottom: 0; }
  .cart-bar:not(.show) { transform: translateY(calc(100% + var(--nav-h) + 40px)); }
  .cart-sum b { font-size: 18px; }
  .cart-sum span { font-size: 12px; }
  .cart-actions { gap: 6px; flex: none; }
  .cart-actions .btn { padding: 12px 16px; white-space: nowrap; }
  .cart-actions .btn-ghost { padding: 12px 10px; }
  .cart-sum { flex: 1; }
  .d-only { display: none; }
  .toast { bottom: calc(var(--nav-h) + 90px + env(safe-area-inset-bottom)); }

  /* Ô tổng số: 2 cột */
  .kpis { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .kpi { padding: 10px 12px; border-radius: 14px; }
  .kpi .k-label { font-size: 11px; line-height: 1.3; }
  .kpi .k-value { font-size: 19px; }
  .kpi .k-foot { display: none; }
  .kpi.primary { grid-column: 1 / -1; padding: 14px 16px; }
  .kpi.primary .k-value { font-size: 26px; }
  .kpi.primary .k-foot { display: block; font-size: 12px; }

  /* Bộ lọc thời gian: 1 hàng vuốt ngang */
  .filters { gap: 6px; }
  .seg { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .seg::-webkit-scrollbar { display: none; }
  .seg button { white-space: nowrap; flex: none; }
  .filters .live { width: 100%; margin-left: 0; }
  .filters select.input { flex: 1; }
}

@media (max-width: 600px) {
  /* --- Bán hàng --- */
  .today-strip { padding: 12px 14px; gap: 6px; flex-wrap: nowrap; }
  .today-strip .ts-item { min-width: 0; flex: 1; }
  .today-strip .ts-item:first-child { flex: 1.6; }
  .today-strip .ts-label { font-size: 11px; white-space: nowrap; }
  .today-strip .ts-value { font-size: 17px; }
  .section-title { gap: 8px; margin-bottom: 10px; }
  .section-title h2 { font-size: 15px; }
  .pill-orange { font-size: 11px; padding: 4px 8px; }
  .section-title .hint { width: 100%; margin: -4px 0 0; font-size: 12px; }

  .grid-products { grid-template-columns: 1fr 1fr; gap: 10px; }
  .pcard { padding: 8px; gap: 8px; border-radius: 14px; border-width: 2px; }
  .pcard .pimg { aspect-ratio: 1 / 1; border-radius: 10px; }
  .pphotos { inset: 18% 4% 6%; gap: 2%; }
  .pphotos .plus { font-size: 16px; }
  .pphotos .or { font-size: 9px; }
  .pcode { min-width: 26px; height: 26px; font-size: 12px; top: 6px; left: 6px; padding: 0 6px; box-shadow: 0 0 0 2px #fff; }
  .check { width: 26px; height: 26px; top: 6px; right: 6px; border-radius: 8px; }
  .check svg { width: 15px; height: 15px; }
  .pbody { gap: 5px; }
  .ptitle { flex-wrap: wrap; gap: 4px; }
  /* Dòng 1: mã set + tên set; nhãn Gợi ý / x2 nằm dòng dưới */
  .ptitle h3 { font-size: 14px; width: 100%; line-height: 1.3; }
  .set-no { font-size: 10px; padding: 1px 5px; margin-right: 5px; vertical-align: 1px; }
  .badge-x, .badge-suggest { font-size: 10px; padding: 1px 6px; margin: 0; }
  .badge-x { margin-left: 0; }
  .pcomps { display: none; }
  .pskus { display: flex; flex-direction: column; gap: 1px; font-size: 11px; color: var(--muted); line-height: 1.35; }
  .pskus code { font-family: inherit; font-weight: 700; color: var(--navy); }
  .ptag { font-size: 10px; padding: 2px 6px; }
  .pfoot { flex-direction: column; align-items: flex-start; gap: 1px; margin-top: auto; }
  .pprice { font-size: 13px; }
  .pstock { margin-left: 0; font-size: 11px; }
  .pcontrols { padding-top: 8px; gap: 8px; }
  .ctrl-row { gap: 6px; }
  .ctrl-label { display: none; }
  .stepper { margin: 0; width: 100%; justify-content: space-between; }
  .stepper button { width: 44px; height: 38px; }

  /* Lựa chọn 1: thẻ ngang, ảnh bên trái */
  .grid-products.single { grid-template-columns: 1fr; }
  .pcard.wide { flex-direction: row; align-items: stretch; }
  .pcard.wide .pimg { flex: 0 0 44%; aspect-ratio: 1 / 1; }
  .pcard.wide .ptitle h3 { font-size: 15px; }
  .pcard.wide .pbody { padding: 2px 2px 2px 4px; justify-content: flex-start; }

  .recent-item { flex-wrap: wrap; gap: 4px 10px; }
  .recent-item .ri-main { flex-basis: 100%; }
  .recent-item .ri-total { margin-right: auto; }

  /* --- Bảng → thẻ --- */
  .table-wrap { overflow: visible; margin: 0; }
  table.tbl.stack, table.tbl.orders-tbl { min-width: 0; }
  .tbl.stack thead, .tbl.orders-tbl thead { display: none; }
  .tbl.stack, .tbl.stack tbody, .tbl.stack tfoot,
  .tbl.orders-tbl, .tbl.orders-tbl tbody, .tbl.orders-tbl tfoot { display: block; }
  .tbl.stack tr {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(86px, 1fr)); gap: 8px 10px;
    padding: 12px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 12px; background: #fff;
  }
  .tbl.stack td { display: flex; flex-direction: column; gap: 1px; padding: 0; border: 0; text-align: left; white-space: normal; }
  .tbl.stack td::before { content: attr(data-label); font-size: 11px; font-weight: 600; color: var(--muted); }
  .tbl.stack td.st-title { grid-column: 1 / -1; font-size: 15px; display: block; } /* mã + tên trên cùng 1 dòng */
  .tbl.stack td.st-title::before, .tbl.stack td.st-action::before { display: none; }
  .tbl.stack td.st-skip { display: none; }
  .tbl.stack td.st-action { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .tbl.stack td.st-action .btn { width: 100%; }
  .tbl.stack tfoot tr { background: var(--cream); border-color: transparent; }
  .tbl.stack tfoot td { border: 0; }
  .tbl.stack tr:last-child td { border-bottom: 0; }

  /* Đơn hàng dạng thẻ */
  .tbl.orders-tbl tr {
    display: grid; grid-template-columns: auto 1fr auto; gap: 6px 10px; align-items: center;
    grid-template-areas: "id time status" "items items items" "staff staff total" "act act act";
    padding: 12px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 12px; background: #fff;
  }
  .tbl.orders-tbl td { padding: 0; border: 0; }
  .orders-tbl .c-id { grid-area: id; }
  .orders-tbl .c-time { grid-area: time; color: var(--muted); font-size: 13px; }
  .orders-tbl .c-status { grid-area: status; }
  .orders-tbl .c-items { grid-area: items; font-size: 14px; }
  .orders-tbl .c-staff { grid-area: staff; font-size: 13px; color: var(--muted); }
  .orders-tbl .c-total { grid-area: total; font-size: 16px; }
  .orders-tbl .c-act { grid-area: act; }
  .orders-tbl .c-act:empty { display: none; }
  .orders-tbl .c-act { text-align: right; margin-top: -2px; }
  .orders-tbl .c-act .link-btn { padding: 6px 10px; font-size: 13px; }
  .tbl.orders-tbl tr.cancelled td { text-decoration: none; }
  .tbl.orders-tbl tr.cancelled { opacity: .6; }
  .tbl.orders-tbl tfoot tr { display: flex; justify-content: space-between; background: var(--navy); color: #fff; border: 0; }
  .tbl.orders-tbl tfoot td { color: #fff; }
  .tbl.orders-tbl tfoot td:empty { display: none; }

  /* Kho hàng dạng thẻ */
  .inv-set { min-width: 0; gap: 10px; }
  .inv-thumb { width: 84px; }
  .inv-set .pname { font-size: 14px; }

  /* Bảng xếp hạng */
  .lb-head { flex-direction: column; align-items: stretch; }
  .lb-total { flex-direction: row; justify-content: space-between; align-items: center; }
  .lb-link, .lb-plain { font-size: 15px; }

  /* Hộp thoại trượt lên từ đáy màn hình */
  dialog.modal, dialog.modal.wide {
    width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 20px 20px 0 0;
    max-height: 92vh; padding-bottom: env(safe-area-inset-bottom);
    animation: sheet-up .22s ease-out;
  }
  dialog.modal::before {
    content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: #d9d4ca; margin: 8px auto 0;
  }
  .modal-head { padding-top: 10px; }
  .modal-body { max-height: 64vh; }
  .modal-foot .btn { flex: 1; }
  .form-row { grid-template-columns: 1fr 1fr; }
  .form-row .btn { grid-column: 1 / -1; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }

/* Ứng dụng cài lên màn hình chính (iPhone): chừa vùng tai thỏ */
@media (display-mode: standalone) {
  .topbar-inner { padding-top: max(10px, env(safe-area-inset-top)); }
}
