:root {
  --nen: #faf6f5; --be-mat: #ffffff; --be-mat-2: #f7efed; --vien: #eadedb; --vien-dam: #d8c6c2;
  --chu: #2a1a17; --chu-phu: #63514d; --chu-mo: #8c7a76;
  --chinh: #c8372a; --chinh-dam: #a82b20; --chinh-nhat: #fce9e6; --chu-tren-chinh: #ffffff;
  --cot: #d5402c; --luoi: #f0e6e4;
  --do: #9b1c12; --do-nhat: #fbe4e1; --vang-nhat: #fff6dc; --vang: #8a6100; --tot: #2e7d32;
  --bong: 0 1px 2px rgba(60, 20, 15, .06), 0 2px 8px rgba(60, 20, 15, .05);
  --bo: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --nen: #171111; --be-mat: #201817; --be-mat-2: #2a201e; --vien: #3a2d2a; --vien-dam: #4a3a36;
    --chu: #f1e8e6; --chu-phu: #bba9a5; --chu-mo: #8f7f7b;
    --chinh: #e2574a; --chinh-dam: #f07a6e; --chinh-nhat: #3a1f1b; --chu-tren-chinh: #ffffff;
    --cot: #e2574a; --luoi: #2f2523;
    --do: #ff8a80; --do-nhat: #3a1d1b; --vang-nhat: #3a3016; --vang: #f0c869; --tot: #81c784;
    --bong: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --nen: #171111; --be-mat: #201817; --be-mat-2: #2a201e; --vien: #3a2d2a; --vien-dam: #4a3a36;
  --chu: #f1e8e6; --chu-phu: #bba9a5; --chu-mo: #8f7f7b;
  --chinh: #e2574a; --chinh-dam: #f07a6e; --chinh-nhat: #3a1f1b; --chu-tren-chinh: #ffffff;
  --cot: #e2574a; --luoi: #2f2523;
  --do: #ff8a80; --do-nhat: #3a1d1b; --vang-nhat: #3a3016; --vang: #f0c869; --tot: #81c784;
  --bong: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--nen); color: var(--chu);
  font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--chinh); }
.so { font-variant-numeric: tabular-nums; }
.phai { text-align: right; }
.mo { color: var(--chu-mo); }
.phu { color: var(--chu-phu); }
.an { display: none !important; }

/* Thanh trên */
.thanh-tren {
  position: sticky; top: 0; z-index: 20; background: #c8372a; border-bottom: 3px solid #a82b20;
  display: flex; align-items: center; gap: 12px; padding: 0 16px; height: 56px;
}
.logo { font-weight: 800; color: #fff; white-space: nowrap; display: flex; align-items: center; gap: 8px; letter-spacing: .5px; }
.logo img { flex: none; width: 38px; height: 38px; border-radius: 50%; box-shadow: 0 0 0 2px #fff; background: #fff; }
.man-dn .logo { color: var(--chinh); flex-direction: column; gap: 10px; font-size: 22px; }
.man-dn .logo img { width: 110px; height: 110px; box-shadow: none; }
.tab-chinh { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.tab-chinh::-webkit-scrollbar { display: none; }
.tab-chinh button {
  border: 0; background: none; padding: 8px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; color: rgba(255, 255, 255, .88);
}
.tab-chinh button:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.tab-chinh button.dang { background: #fff; color: #c8372a; font-weight: 700; }
.nguoi { position: relative; }
.nguoi > button { border: 1px solid rgba(255, 255, 255, .6); background: transparent; color: #fff; border-radius: 999px; padding: 5px 12px; cursor: pointer; white-space: nowrap; }
.menu-nguoi {
  position: absolute; right: 0; top: 42px; background: var(--be-mat); border: 1px solid var(--vien); border-radius: var(--bo);
  box-shadow: var(--bong); min-width: 200px; padding: 6px; z-index: 30;
}
.menu-nguoi button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.menu-nguoi button:hover { background: var(--be-mat-2); }

main { padding: 16px; max-width: 1400px; margin: 0 auto; }
h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 0 0 10px; }

/* Thẻ, nút, ô nhập */
.the { background: var(--be-mat); border: 1px solid var(--vien); border-radius: var(--bo); padding: 14px; box-shadow: var(--bong); }
.nut {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--vien-dam);
  background: var(--be-mat); border-radius: 8px; padding: 7px 14px; cursor: pointer; white-space: nowrap; min-height: 38px;
}
.nut:hover { background: var(--be-mat-2); }
.nut.chinh { background: var(--chinh); border-color: var(--chinh); color: var(--chu-tren-chinh); font-weight: 600; }
.nut.chinh:hover { background: var(--chinh-dam); border-color: var(--chinh-dam); }
.nut.nguy { color: var(--do); border-color: var(--do); }
.nut.nho { min-height: 30px; padding: 3px 10px; font-size: 14px; }
.nut.lon { min-height: 48px; font-size: 17px; }
.nut:disabled { opacity: .5; cursor: default; }
.o, select.o, textarea.o {
  border: 1px solid var(--vien-dam); background: var(--be-mat); border-radius: 8px; padding: 7px 10px; min-height: 38px; width: 100%;
}
.o:focus { outline: 2px solid var(--chinh); outline-offset: -1px; border-color: transparent; }
label.nhan { display: block; font-size: 13px; color: var(--chu-phu); margin-bottom: 4px; }
.hang-loc { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 12px; }
.hang-loc > * { flex: 0 0 auto; }
.hang-loc .o { width: auto; }
.luoi-o { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--be-mat-2); color: var(--chu-phu); border: 1px solid var(--vien); }
.chip.xanh { background: var(--chinh-nhat); color: var(--chinh-dam); border-color: transparent; }
.chip.do { background: var(--do-nhat); color: var(--do); border-color: transparent; }

/* Bảng */
.bang-boc { overflow-x: auto; }
table.bang { width: 100%; border-collapse: collapse; }
.bang th, .bang td { padding: 8px 10px; border-bottom: 1px solid var(--vien); text-align: left; vertical-align: middle; }
.bang th { font-size: 13px; color: var(--chu-phu); font-weight: 600; background: var(--be-mat-2); position: sticky; top: 0; }
.bang tr.bam { cursor: pointer; }
.bang tr.bam:hover td { background: var(--be-mat-2); }
.bang tr.huy td { color: var(--chu-mo); text-decoration: line-through; }
.bang tfoot td { font-weight: 700; background: var(--be-mat-2); }

/* Bán hàng */
.ban-hang { display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: 16px; align-items: start; }
.ds-hang { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-height: calc(100vh - 210px); overflow-y: auto; padding: 2px; }
.o-hang {
  text-align: left; border: 1px solid var(--vien); background: var(--be-mat); border-radius: 8px; padding: 9px 10px; cursor: pointer;
  display: flex; flex-direction: column; gap: 3px; min-height: 72px;
}
.o-hang:hover { border-color: var(--chinh); }
.o-hang .ten { font-weight: 600; font-size: 14px; line-height: 1.3; }
.o-hang { padding-top: 6px; }
.anh-o { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; display: block; margin-bottom: 4px; background: var(--be-mat-2); }
.anh-nho { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; display: block; }
.anh-lon { width: 110px; height: 110px; object-fit: cover; border-radius: 10px; display: block; border: 1px solid var(--vien); }
span.anh-trong { display: flex; align-items: center; justify-content: center; background: var(--chinh-nhat); color: var(--chinh-dam); font-weight: 700; font-size: 18px; }
span.anh-o.anh-trong { aspect-ratio: 4 / 3; border-radius: 6px; margin-bottom: 4px; font-size: 28px; }
mark.hl { background: #ffd9d3; color: #b3261e; font-weight: 700; border-radius: 3px; padding: 0 1px; }
:root[data-theme="dark"] mark.hl { background: #5a211b; color: #ffb4a9; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) mark.hl { background: #5a211b; color: #ffb4a9; } }
.o-hang .gia { color: var(--chinh-dam); font-weight: 600; margin-top: auto; }
.o-hang .gia.thieu { color: var(--vang); font-weight: 400; font-size: 13px; }
.nhom-tieu-de { grid-column: 1 / -1; font-size: 13px; color: var(--chu-mo); font-weight: 600; margin: 6px 0 0; }
.gio { position: sticky; top: 72px; }
.dong-gio { display: grid; grid-template-columns: minmax(0, 1fr) 74px 96px 28px; gap: 6px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--vien); }
.dong-gio .ten { font-size: 14px; }
.dong-gio .tt { font-size: 13px; color: var(--chu-phu); }
.dong-gio .o { min-height: 34px; padding: 4px 6px; text-align: right; }
.xoa-dong { border: 0; background: none; cursor: pointer; color: var(--chu-mo); font-size: 18px; line-height: 1; }
.xoa-dong:hover { color: var(--do); }
.tong-gio { display: flex; justify-content: space-between; align-items: baseline; font-size: 22px; font-weight: 700; margin: 10px 0; }
.ds-dong { max-height: 38vh; overflow-y: auto; }
.trong { padding: 24px 8px; text-align: center; color: var(--chu-mo); }
.goi-y { position: relative; }
.goi-y-ds {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 15; background: var(--be-mat); border: 1px solid var(--vien-dam);
  border-radius: 8px; box-shadow: var(--bong); max-height: 260px; overflow-y: auto; margin-top: 2px;
}
.goi-y-ds button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; cursor: pointer; border-bottom: 1px solid var(--vien); }
.goi-y-ds button:hover, .goi-y-ds button.chon { background: var(--chinh-nhat); }
.bang-sua { background: var(--vang-nhat); color: var(--vang); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* Báo cáo */
.the-so { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.the-so.the-so-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.the-so.the-so-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.the-so-6 .gia-tri { font-size: 21px; }
.ba-cot { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.the-so .nhan { font-size: 13px; color: var(--chu-phu); }
.the-so .gia-tri { font-size: 24px; font-weight: 700; margin: 4px 0 2px; }
.the-so .so-sanh { font-size: 13px; color: var(--chu-phu); }
.tang { color: var(--tot); font-weight: 600; }
.giam { color: var(--do); font-weight: 600; }
.bieu-do { position: relative; }
.bieu-do svg { display: block; width: 100%; height: 280px; }
.goi-y-bd {
  position: absolute; pointer-events: none; background: var(--be-mat); border: 1px solid var(--vien-dam); border-radius: 8px;
  padding: 6px 10px; box-shadow: var(--bong); font-size: 13px; white-space: nowrap; transform: translate(-50%, -100%); z-index: 5;
}
.hai-cot { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Hộp thoại */
.phu-mo { position: fixed; inset: 0; background: rgba(10, 20, 14, .45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.hop { background: var(--be-mat); border-radius: 14px; width: 100%; max-width: 560px; padding: 18px; box-shadow: 0 10px 40px rgba(0, 0, 0, .25); }
.hop.rong { max-width: 900px; }
.hop-dau { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; }
.hop-dau h2 { margin: 0; }
.hop-cuoi { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.dong-o { margin-bottom: 10px; }

/* Thông báo */
#thong-bao { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.tb { background: var(--chu); color: var(--nen); padding: 10px 16px; border-radius: 8px; box-shadow: var(--bong); max-width: 90vw; }
.tb.loi { background: var(--do); color: #fff; }

/* Đăng nhập */
.man-dn { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.man-dn .the { width: 100%; max-width: 380px; padding: 24px; }

@media (max-width: 1000px) {
  .ban-hang { grid-template-columns: 1fr; }
  .gio { position: static; }
  .ds-hang { max-height: 46vh; }
  .the-so, .the-so.the-so-5, .the-so.the-so-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ba-cot { grid-template-columns: 1fr; }
  .hai-cot { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .logo span { display: none; }
  .thanh-tren { gap: 6px; padding: 0 10px; }
  .logo img { width: 32px; height: 32px; }
  .the-so .gia-tri { font-size: 19px; }
  .dong-gio { grid-template-columns: minmax(0, 1fr) 64px 84px 24px; }
  .hang-loc .o { width: 100%; }
  .ds-hang { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 40vh; }
  .o-hang { min-height: 64px; padding: 7px 8px; }
}

/* Ô mật khẩu có nút con mắt (04/10/2026) */
.o-mk { position: relative; }
.o-mk .o { padding-right: 46px; }
.nut-mat { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); width: 40px; height: 34px; border: 0; background: transparent; color: var(--chu-phu); cursor: pointer; display: grid; place-items: center; border-radius: 6px; }
.nut-mat:hover { color: var(--chinh); background: var(--do-nhat); }
.loi-mk { margin: 0 0 8px; color: var(--do); font-weight: 600; font-size: 14px; }

/* Duyệt máy đăng nhập (04/10/2026) */
.cho-quay { width: 38px; height: 38px; margin: 14px auto 6px; border-radius: 50%; border: 4px solid var(--vien); border-top-color: var(--chinh); animation: quay 1s linear infinite; }
@keyframes quay { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .cho-quay { animation: none; } }
.cuon-ngang { overflow-x: auto; }
