/* VINASẤY quản trị: giao diện chung. Không font ngoài, không style nội tuyến (CSP). Mobile trước. */
:root {
  --nen: #f4f5f7;
  --the: #ffffff;
  --chu: #14181f;
  --chu-phu: #5a6270;
  --vien: #d9dde3;
  --nhan: #0b57d0;
  --nhan-dam: #0a47aa;
  --nhan-chu: #ffffff;
  --dat: #0a7a2f;
  --vang: #9a6700;
  --do: #b3261e;
  --nen-dat: #e5f4ea;
  --nen-vang: #fdf3d6;
  --nen-do: #fbe9e7;
  --nen-tin: #e6effc;
  --dau-nen: #0b3d5c;
  --dau-chu: #ffffff;
  --bo-goc: 10px;
  --bong: 0 1px 2px rgba(0, 0, 0, 0.06);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --nen: #0f1318;
    --the: #181d24;
    --chu: #e8ebf0;
    --chu-phu: #a0a8b5;
    --vien: #2d343e;
    --nhan: #7aa7ff;
    --nhan-dam: #9bbcff;
    --nhan-chu: #0b1220;
    --dat: #5fd18a;
    --vang: #f2c14e;
    --do: #ff8a80;
    --nen-dat: #12301e;
    --nen-vang: #33290e;
    --nen-do: #3a1a17;
    --nen-tin: #14233d;
    --dau-nen: #0a2536;
    --bong: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--nen);
  color: var(--chu);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

h1 { font-size: 1.4rem; line-height: 1.3; margin: 0.4rem 0 0.8rem; }
h2 { font-size: 1.1rem; margin: 1.2rem 0 0.5rem; }
p { margin: 0.5rem 0; }
a { color: var(--nhan); }
small { color: var(--chu-phu); font-weight: 400; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

.phu { color: var(--chu-phu); font-size: 0.95rem; }

.bo-qua {
  position: absolute; left: -9999px; top: 0;
  background: var(--the); color: var(--chu); padding: 0.6rem 1rem; z-index: 100;
}
.bo-qua:focus { left: 0.5rem; top: 0.5rem; }

:focus-visible { outline: 3px solid var(--nhan); outline-offset: 2px; }

/* ---------- đầu trang và menu */
.dau {
  background: var(--dau-nen); color: var(--dau-chu);
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; flex-wrap: wrap;
  padding: 0.5rem 1rem;
}
.dau-khach { justify-content: center; padding: 1rem; }
.thuong-hieu { color: var(--dau-chu); font-weight: 800; letter-spacing: 0.06em; text-decoration: none; font-size: 1.15rem; }
.thuong-hieu-phu { margin-left: 0.6rem; opacity: 0.8; font-size: 0.95rem; }
.nguoi { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.nguoi form { margin: 0; }
.nguoi-ten { display: flex; flex-direction: column; line-height: 1.2; font-weight: 600; }
.nguoi-ten small { color: var(--dau-chu); opacity: 0.75; }

.menu {
  background: var(--the); border-bottom: 1px solid var(--vien);
  display: flex; gap: 0.25rem; overflow-x: auto; padding: 0 0.5rem; -webkit-overflow-scrolling: touch;
}
.menu a {
  flex: 0 0 auto; display: inline-flex; align-items: center; min-height: 48px; padding: 0 1rem;
  color: var(--chu); text-decoration: none; font-weight: 600; border-bottom: 3px solid transparent;
}
.menu a:hover { background: var(--nen); }
.menu a.dang-o { color: var(--nhan); border-bottom-color: var(--nhan); }

/* ---------- bố cục */
.chinh { max-width: 1200px; margin: 0 auto; padding: 1rem; }
.chinh-hep { max-width: 460px; padding-top: 1.5rem; }

.the {
  background: var(--the); border: 1px solid var(--vien); border-radius: var(--bo-goc);
  box-shadow: var(--bong); padding: 1rem; margin: 0 0 1rem;
}
.the h1:first-child, .the h2:first-child { margin-top: 0; }
.the-dn { padding: 1.25rem; }
.the-ma { border-color: var(--vang); background: var(--nen-vang); }
.ma-lon {
  font: 700 1.6rem/1.3 ui-monospace, "Cascadia Mono", Consolas, monospace;
  letter-spacing: 0.08em; word-break: break-all; margin: 0.4rem 0; user-select: all;
}

/* ---------- thông báo */
.tb { border-radius: var(--bo-goc); padding: 0.75rem 1rem; margin: 0 0 1rem; border: 1px solid var(--vien); font-weight: 500; }
.tb-loi { background: var(--nen-do); border-color: var(--do); color: var(--do); }
.tb-ok { background: var(--nen-dat); border-color: var(--dat); color: var(--dat); }
.tb-tin { background: var(--nen-tin); border-color: var(--nhan); color: var(--chu); }

/* ---------- biểu mẫu */
.truong { display: block; margin: 0 0 0.9rem; }
.truong > span { display: block; font-weight: 600; margin-bottom: 0.3rem; }
input[type="text"], input[type="password"], input[type="date"], input[type="search"],
input:not([type]), select, textarea {
  width: 100%; min-height: 48px; padding: 0.55rem 0.75rem; font: inherit; font-size: 16px;
  color: var(--chu); background: var(--the); border: 1px solid var(--vien); border-radius: 8px;
}
input:focus, select:focus, textarea:focus { border-color: var(--nhan); }
.o-ma { font-size: 1.5rem; letter-spacing: 0.3em; text-align: center; font-variant-numeric: tabular-nums; }

.chon { display: flex; align-items: center; gap: 0.6rem; min-height: 44px; margin: 0 0 0.6rem; cursor: pointer; }
.chon input { width: 22px; height: 22px; flex: 0 0 auto; }
.chon-nho { display: inline-flex; margin: 0 0 0 0.75rem; min-height: 44px; }

.luoi-form { display: grid; gap: 0 1rem; grid-template-columns: 1fr; }
.loc { display: grid; gap: 0 1rem; grid-template-columns: 1fr; align-items: end; }
@media (min-width: 720px) {
  .luoi-form { grid-template-columns: repeat(2, 1fr); }
  .luoi-form .chon, .luoi-form .nut { grid-column: span 1; }
  .loc { grid-template-columns: repeat(4, 1fr) auto; }
}

/* ---------- nút */
.nut {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 48px; padding: 0.5rem 1.1rem; border-radius: 8px; border: 1px solid var(--vien);
  background: var(--the); color: var(--chu); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.nut:hover { border-color: var(--nhan); }
.nut-chinh { background: var(--nhan); border-color: var(--nhan); color: var(--nhan-chu); }
.nut-chinh:hover { background: var(--nhan-dam); border-color: var(--nhan-dam); }
.nut-phu { background: transparent; }
.nut-nguy { background: transparent; border-color: var(--do); color: var(--do); }
.nut-rong { width: 100%; }
.nut-nho { min-height: 44px; padding: 0.3rem 0.8rem; font-size: 0.95rem; }
.dau .nut-phu { color: var(--dau-chu); border-color: rgba(255, 255, 255, 0.45); }
.dau .nut-phu:hover { border-color: #fff; }
.khoi-phu { margin-top: 0.75rem; }
.hang-nut { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.75rem; }
.hang-nut form { margin: 0; }

/* ---------- chip */
.chip {
  display: inline-block; padding: 0.1rem 0.6rem; border-radius: 999px; font-size: 0.85rem; font-weight: 600;
  background: var(--nen-tin); color: var(--chu); border: 1px solid var(--vien); white-space: nowrap;
}
.chip-ok { background: var(--nen-dat); color: var(--dat); border-color: var(--dat); }
.chip-vang { background: var(--nen-vang); color: var(--vang); border-color: var(--vang); }
.chip-tat { background: transparent; color: var(--chu-phu); }

/* ---------- QR và các bước */
.qr-khung { display: flex; justify-content: center; margin: 1rem 0; }
.qr { width: 224px; height: 224px; max-width: 100%; height: auto; border: 1px solid var(--vien); border-radius: 8px; background: #fff; }
.bi-mat { text-align: center; }
.bi-mat code { font-size: 1.1rem; font-weight: 700; word-break: break-all; user-select: all; }
.buoc { padding-left: 1.3rem; }
.buoc li { margin: 0.4rem 0; }

/* ---------- quản lý người dùng */
.thanh-phu { display: flex; gap: 0.4rem; margin: 0 0 0.5rem; overflow-x: auto; }
.thanh-phu a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 1rem; border-radius: 999px;
  border: 1px solid var(--vien); text-decoration: none; color: var(--chu); font-weight: 600; white-space: nowrap; background: var(--the);
}
.thanh-phu a.dang-o { background: var(--nhan); border-color: var(--nhan); color: var(--nhan-chu); }

details.nd { background: var(--the); border: 1px solid var(--vien); border-radius: var(--bo-goc); margin: 0 0 0.6rem; }
details.nd.nd-ngung { opacity: 0.85; }
details.nd > summary {
  list-style: none; cursor: pointer; padding: 0.75rem 1rem; min-height: 48px;
  display: flex; flex-wrap: wrap; gap: 0.4rem 0.5rem; align-items: center;
}
details.nd > summary::-webkit-details-marker { display: none; }
.nd-ten { font-weight: 700; margin-right: 0.3rem; }
.nd-than { padding: 0 1rem 1rem; border-top: 1px solid var(--vien); padding-top: 1rem; }
.truong-cau-hinh { margin-bottom: 0.5rem; }

/* ---------- bảng */
.bang-cuon { overflow-x: auto; border: 1px solid var(--vien); border-radius: var(--bo-goc); background: var(--the); }
.bang { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.bang th, .bang td { text-align: left; padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--vien); vertical-align: top; }
.bang th { background: var(--nen); white-space: nowrap; }
.bang td { word-break: break-word; min-width: 4rem; }
.phan-trang { display: flex; align-items: center; gap: 0.75rem; justify-content: center; margin: 1rem 0; }

@media (min-width: 900px) {
  .dau { padding: 0.6rem 1.5rem; }
  .menu { padding: 0 1rem; }
  .chinh { padding: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/* ---------- điện thoại: đầu trang một hàng, menu vừa khổ 375px */
@media (max-width: 599px) {
  .dau { flex-wrap: nowrap; padding: 0.35rem 0.6rem; gap: 0.4rem; }
  .nguoi { flex-wrap: nowrap; gap: 0.3rem; }
  .nguoi-ten { display: none; }
  .nguoi .nut-nho { min-height: 44px; padding: 0.2rem 0.55rem; font-size: 0.88rem; white-space: nowrap; }
  .thuong-hieu { font-size: 1.05rem; }
  .menu { padding: 0 0.25rem; gap: 0; }
  .menu a { flex: 1 1 auto; justify-content: center; padding: 0 0.55rem; font-size: 0.95rem; white-space: nowrap; }
}

details.nd-them > summary { cursor: pointer; display: flex; align-items: center; min-height: 48px; }
details.nd-them[open] > summary { margin-bottom: 0.6rem; }
