:root {
  --nen: #f3f5f8;
  --the: #ffffff;
  --chu: #14202b;
  --mo: #5b6b7a;
  --vien: #dde3ea;
  --chinh: #0f5c8c;
  --chinh-dam: #0b4468;
  --chinh-nhat: #e3f0f8;
  --xanh: #11805a;
  --xanh-nhat: #e2f5ec;
  --cam: #b86200;
  --cam-nhat: #fff1dc;
  --do: #c0342b;
  --do-nhat: #fde8e6;
  --xam-nhat: #eef1f4;
  --bo: 12px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--nen);
  color: var(--chu);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--chinh); }

/* ---------- nút ---------- */
.nut {
  appearance: none;
  border: 1px solid var(--vien);
  background: var(--the);
  border-radius: 9px;
  padding: 8px 13px;
  min-height: 40px;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}
.nut:hover { border-color: #b9c4cf; }
.nut:disabled { opacity: .55; cursor: default; }
.nut.chinh { background: var(--chinh); border-color: var(--chinh); color: #fff; }
.nut.chinh:hover { background: var(--chinh-dam); }
.nut.nhe { background: transparent; border-color: rgba(255,255,255,.35); color: #fff; min-height: 34px; padding: 5px 11px; }
.nut.do { color: var(--do); }
.nut.do-dac { background: var(--do); border-color: var(--do); color: #fff; }
.nut.to { width: 100%; min-height: 46px; font-size: 16px; }
.nut.nho { min-height: 32px; padding: 4px 10px; font-size: 13.5px; }

/* ---------- đăng nhập ---------- */
.man-dang-nhap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(160deg, #0f3d5c, #0f5c8c 60%, #1b7bb3);
}
.hop-dang-nhap {
  width: 100%;
  max-width: 360px;
  background: var(--the);
  border-radius: 16px;
  padding: 26px 22px 20px;
  box-shadow: 0 18px 50px rgba(0,0,0,.25);
}
.hop-dang-nhap h1 { font-size: 20px; margin: 12px 0 2px; }
.hop-dang-nhap .mo { margin: 0 0 18px; color: var(--mo); }
.hop-dang-nhap label { display: block; font-weight: 600; margin-bottom: 6px; }
.hop-dang-nhap input { width: 100%; margin-bottom: 14px; }
.logo {
  width: 44px; height: 44px; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--chinh); color: #fff; font-weight: 800; letter-spacing: .5px;
}
.logo.nho { width: 30px; height: 30px; border-radius: 8px; font-size: 13px; background: #fff; color: var(--chinh); }
.loi-chu { color: var(--do); min-height: 1.4em; margin: 10px 0 0; }

input[type=text], input[type=password], input[type=search], input[type=tel], input[type=number], input[type=date], textarea, select {
  border: 1px solid var(--vien);
  border-radius: 9px;
  padding: 9px 11px;
  min-height: 42px;
  background: #fff;
  width: 100%;
}
input:focus, textarea:focus, select:focus, .nut:focus-visible { outline: 2px solid #7fb6da; outline-offset: 1px; }

/* ---------- khung chính ---------- */
.dau {
  background: #0f3d5c;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 5;
  padding-top: env(safe-area-inset-top);
}
.dau-trong {
  max-width: 980px;
  margin: 0 auto;
  padding: 9px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.dau .ten { display: flex; align-items: center; gap: 9px; font-size: 15.5px; min-width: 0; }
.dau .ten b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.than { max-width: 980px; margin: 0 auto; padding: 14px 14px 60px; }

.thong-ke { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.o-so {
  background: var(--the);
  border: 1px solid var(--vien);
  border-radius: var(--bo);
  padding: 9px 11px;
  text-align: left;
  cursor: pointer;
}
.o-so b { display: block; font-size: 21px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.o-so span { color: var(--mo); font-size: 12.5px; }
.o-so.cam b { color: var(--cam); }
.o-so.do b { color: var(--do); }
.o-so.xanh b { color: var(--xanh); }

.thanh-cong-cu { display: flex; gap: 8px; margin-bottom: 9px; }
.thanh-cong-cu input { flex: 1; min-width: 0; }
.loc { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 8px; scrollbar-width: none; }
.loc::-webkit-scrollbar { display: none; }
.loc button {
  border: 1px solid var(--vien);
  background: var(--the);
  border-radius: 999px;
  padding: 5px 12px;
  white-space: nowrap;
  cursor: pointer;
  font-size: 13.5px;
}
.loc button.dang-chon { background: var(--chinh); border-color: var(--chinh); color: #fff; }

/* ---------- thẻ mã ---------- */
.ds { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .ds { grid-template-columns: 1fr 1fr; } }
.trong { color: var(--mo); text-align: center; padding: 30px 10px; grid-column: 1 / -1; }

.the-ma {
  background: var(--the);
  border: 1px solid var(--vien);
  border-left: 4px solid var(--xanh);
  border-radius: var(--bo);
  padding: 11px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}
.the-ma.sap { border-left-color: var(--cam); }
.the-ma.het { border-left-color: var(--do); }
.the-ma.khoa { border-left-color: #6b7785; background: #fafbfc; }

.dong1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ma-chu {
  font: 600 15.5px/1.2 ui-monospace, "Cascadia Mono", Consolas, "Roboto Mono", monospace;
  letter-spacing: .3px;
  background: var(--xam-nhat);
  border: 0;
  border-radius: 7px;
  padding: 5px 8px;
  cursor: pointer;
  white-space: nowrap;
}
.nhan {
  font-size: 12.5px;
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
  background: var(--xanh-nhat);
  color: var(--xanh);
}
.nhan.sap { background: var(--cam-nhat); color: var(--cam); }
.nhan.het { background: var(--do-nhat); color: var(--do); }
.nhan.khoa { background: #e6e9ed; color: #45505c; }

.khach { font-size: 15px; overflow-wrap: anywhere; }
.khach a { text-decoration: none; font-weight: 600; white-space: nowrap; }
.thong-so { color: var(--mo); font-size: 13.5px; display: flex; flex-wrap: wrap; gap: 3px 14px; }
.thong-so b { color: var(--chu); }
.ghi-chu { font-size: 13.5px; background: #fffbea; border-radius: 7px; padding: 5px 8px; overflow-wrap: anywhere; }

.may { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.may li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--xam-nhat);
  border-radius: 8px;
  padding: 6px 6px 6px 9px;
}
.may li div { min-width: 0; }
.may li b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.may li small { color: var(--mo); font-size: 12.5px; }
.may .chua { color: var(--mo); font-size: 13px; background: none; padding: 0; }

.nhom-nut { display: flex; flex-wrap: wrap; gap: 6px; }
.nhom-nut .gia-han { flex: 1 1 0; min-width: 0; padding-left: 6px; padding-right: 6px; }
.nhom-nut.phu .nut { flex: 1 1 auto; }

/* ---------- dùng thử ---------- */
.dung-thu { margin-top: 18px; background: var(--the); border: 1px solid var(--vien); border-radius: var(--bo); padding: 10px 12px; }
.dung-thu summary { cursor: pointer; font-weight: 600; }
.dung-thu table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13.5px; }
.dung-thu td, .dung-thu th { text-align: left; padding: 6px 4px; border-top: 1px solid var(--vien); }
.bang-cuon { overflow-x: auto; }

/* ---------- hộp thoại ---------- */
.hop {
  border: 0;
  border-radius: 14px;
  padding: 0;
  width: min(460px, calc(100vw - 24px));
  max-height: calc(100vh - 40px);
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.hop:focus, .hop:focus-visible { outline: none; }
.hop::backdrop { background: rgba(12, 22, 32, .45); }
.hop-dau { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 13px 16px 0; }
.hop-dau h2 { font-size: 17px; margin: 0; }
.hop-than { padding: 12px 16px 16px; display: grid; gap: 11px; }
.hop-than label { display: grid; gap: 5px; font-weight: 600; font-size: 14px; }
.hop-than label small { font-weight: 400; color: var(--mo); }
.hai-cot { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chon-nhanh { display: flex; gap: 6px; flex-wrap: wrap; }
.chon-nhanh button { flex: 1 1 0; }
.chon-nhanh button.dang-chon { background: var(--chinh-nhat); border-color: var(--chinh); color: var(--chinh-dam); }
.hop-nut { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.hop-nut .nut { min-width: 96px; }
.xem-truoc { background: var(--chinh-nhat); border-radius: 9px; padding: 9px 11px; font-size: 14px; }
.ma-lon {
  font: 700 22px/1.2 ui-monospace, "Cascadia Mono", Consolas, "Roboto Mono", monospace;
  text-align: center;
  letter-spacing: .5px;
  background: var(--xam-nhat);
  border-radius: 10px;
  padding: 14px 8px;
  user-select: all;
  overflow-wrap: anywhere;
}
.tin-nhan { width: 100%; min-height: 170px; resize: vertical; font-size: 14px; }
.lich-su { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 60vh; overflow: auto; }
.lich-su li { border-bottom: 1px solid var(--vien); padding-bottom: 6px; font-size: 14px; }
.lich-su time { color: var(--mo); font-size: 12.5px; display: block; }

/* ---------- thông báo ---------- */
.thong-bao {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: grid;
  gap: 6px;
  z-index: 50;
  width: min(420px, calc(100vw - 24px));
}
.thong-bao div {
  background: #14202b;
  color: #fff;
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.thong-bao div.loi { background: var(--do); }

@media (max-width: 420px) {
  .thong-ke { grid-template-columns: repeat(2, 1fr); }
  .o-so b { font-size: 19px; }
  .ma-chu { font-size: 14.5px; }
}
