:root {
  --navy: #0D2B69;
  --red: #BB2723;
  --bg: #F4F6FA;
  --card: #FFFFFF;
  --text: #14213D;
  --muted: #4A5672;
  --line: #DCE2EE;
  --line2: #E6EAF2;
  --input: #9AA6BF;
  --soft: #EAF0FA;
  --ok-bg: #E3F4EA; --ok: #155C33;
  --warn-bg: #FFF1D6; --warn: #6B4300; --warn-line: #C98A1A;
  --bh-bg: #FBE4E3; --bh: #8E1D1A;
  --gray-bg: #EEF1F6; --gray: #5B6680;
  --note-bg: #FFF4E5; --note-line: #E8B467; --note: #5C3B00;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px; line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--navy); }
a:hover { color: var(--red); }
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 3px solid #5B8DEF; outline-offset: 2px; }
.an { display: none !important; }

/* ---------- Thanh trên ---------- */
.thanh {
  background: var(--navy); color: #fff; padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 20;
}
.logo { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.logo img { height: 38px; width: auto; display: block; }
.logo .chu1 { font-size: 16px; font-weight: 700; letter-spacing: 1px; line-height: 1.1; }
.logo .chu2 { font-size: 10px; letter-spacing: 2.5px; opacity: .9; }
.dieu-huong { display: flex; flex-wrap: wrap; gap: 4px; flex: 1 1 auto; }
.dieu-huong a {
  color: #fff; text-decoration: none; padding: 8px 12px; border-radius: 8px; font-size: 15px; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 7px;
}
.dieu-huong a .ic { opacity: .85; }
.dieu-huong .ten-ngan { display: none; }
.nut-toi { display: inline-flex; align-items: center; }
.dieu-huong a.chon { background: rgba(255,255,255,.16); font-weight: 600; }
.dieu-huong a .so { background: var(--red); border-radius: 999px; padding: 0 7px; font-size: 12px; margin-left: 4px; }
.nut-toi {
  min-height: 44px; border: 1px solid rgba(255,255,255,.5); border-radius: 10px; background: transparent; color: #fff;
  font-size: 13px; text-align: right; line-height: 1.35; padding: 4px 10px; margin-left: auto; max-width: 52vw;
}
.nut-toi .mo { color: #fff; opacity: .85; display: inline-block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.trang.dt .ma-don.lon, .ma-don.lon { font-size: 28px; }

/* ---------- Bố cục ---------- */
.trang { max-width: 1376px; margin: 0 auto; padding: 20px 24px 48px; display: flex; flex-direction: column; gap: 18px; }
.trang.dt { max-width: 560px; padding: 18px 16px 40px; gap: 14px; }
h1 { margin: 0; font-size: 26px; color: var(--navy); font-family: 'Lora', Georgia, serif; font-weight: 700; letter-spacing: .2px; }
h2 { margin: 0; font-size: 20px; color: var(--navy); font-family: 'Lora', Georgia, serif; font-weight: 600; }
h1 .phu, h2 .phu { font-family: 'Be Vietnam Pro', system-ui, sans-serif; }

/* ---------- Biểu tượng ---------- */
.ic { width: 20px; height: 20px; flex: 0 0 auto; vertical-align: -4px; }
.ic.nho { width: 14px; height: 14px; vertical-align: -2px; margin-right: 3px; }
.nut .ic, .nut-toi .ic { margin-right: 6px; }
.nut { display: inline-flex; align-items: center; justify-content: center; }
.nhan-roi .ic { width: 22px; height: 22px; }

/* ---------- Màn đăng nhập ---------- */
.man-dau { position: relative; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; padding: 0 16px 24px; background: var(--bg); }
.man-dau::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 290px; background: var(--navy); }
.man-dau > * { position: relative; }
.dau-thuong-hieu { color: #fff; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: max(44px, env(safe-area-inset-top)) 0 26px; text-align: center; }
.dau-thuong-hieu img { height: 62px; width: auto; }
.chu-thuong-hieu .c1 { font-size: 24px; font-weight: 700; letter-spacing: 5px; line-height: 1.1; }
.chu-thuong-hieu .c2 { font-size: 11px; letter-spacing: 6px; opacity: .9; margin-top: 2px; }
.gach-do { width: 36px; height: 2px; background: var(--red); border-radius: 2px; margin: 6px 0 2px; }
.khau-hieu { font-size: 13px; opacity: .8; letter-spacing: .3px; }
.the-dau { width: 100%; max-width: 420px; background: #fff; border-radius: 18px; padding: 26px 22px; box-shadow: 0 12px 32px rgba(13,43,105,.12), 0 1px 3px rgba(13,43,105,.08); }
.the-dau h1 { font-size: 24px; }
.cot-form { display: flex; flex-direction: column; gap: 14px; }
h2 .phu, h1 .phu { font-size: 14px; font-weight: 500; color: var(--muted); }
.hang { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.nhom { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.mo { color: var(--muted); font-size: 13px; }
.the { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.ghi-chu { background: var(--note-bg); border: 1px solid var(--note-line); border-radius: 12px; padding: 12px 14px; color: var(--note); font-size: 14px; }
.loi { background: var(--bh-bg); color: var(--bh); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.thanh-cong { background: var(--ok-bg); color: var(--ok); border-radius: 10px; padding: 10px 12px; font-size: 14px; }

/* ---------- Nút, ô nhập ---------- */
.nut {
  min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--input); background: #fff; font-size: 15px;
}
.nut.chinh { border: 0; background: var(--navy); color: #fff; font-weight: 600; }
.nut.vien { border-color: var(--navy); color: var(--navy); font-weight: 600; }
.nut.do { border-color: var(--red); color: var(--red); font-weight: 600; }
.nut.to { min-height: 58px; font-size: 18px; border-radius: 12px; width: 100%; }
.nut.nho { min-height: 36px; padding: 0 10px; font-size: 14px; border-radius: 8px; }
.chip { min-height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid var(--input); background: #fff; font-size: 14px; }
.chip.chon { border: 0; background: var(--navy); color: #fff; font-weight: 600; }
label.o { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
input.nhap, select.nhap {
  height: 48px; border: 1.5px solid var(--input); border-radius: 12px; padding: 0 14px; background: #fff; font-size: 17px;
}
input.nhap.lon { height: 56px; font-size: 20px; }
input.tim-ma {
  height: 56px; border: 2px solid var(--navy); border-radius: 12px; padding: 0 16px; font-size: 22px; font-weight: 700;
  letter-spacing: 1px; text-align: center; color: var(--navy); width: 100%;
}
label.tich { display: flex; align-items: center; gap: 10px; min-height: 44px; }
label.tich input { width: 22px; height: 22px; accent-color: var(--navy); }

/* ---------- KTV ---------- */
.dong-cho {
  min-height: 64px; width: 100%; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 10px 14px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: left;
}
.dong-cho .ma { font-size: 18px; font-weight: 700; color: var(--navy); display: block; }
.dong-cho .mt { font-size: 14px; display: block; }
.dong-cho .khau { font-size: 12px; color: var(--muted); display: block; }
.tra { font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tra.tre, .tra.sapTre { color: var(--red); font-weight: 700; }
.the-dong { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.the-dong .ten { font-size: 17px; font-weight: 600; }
.buoc { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.vien-tron { padding: 6px 10px; border-radius: 999px; font-size: 13px; font-weight: 500; white-space: nowrap; display: inline-block; }
.cot-ten { min-width: 180px; }
.cot-ten .vien-tron { margin-top: 4px; }
.tt-xong { background: var(--ok-bg); color: var(--ok); }
.tt-dang { background: var(--navy); color: #fff; }
.tt-cho { background: var(--gray-bg); color: var(--gray); }
.tt-chuaGhiNhan { background: var(--warn-bg); color: var(--warn); border: 1px dashed var(--warn-line); }
.tt-boQua { background: transparent; color: #8C95A8; text-decoration: line-through; }
.tt-ngoai { background: #fff; color: var(--navy); border: 1px solid #B8C3DA; }
.tt-tre { background: var(--bh-bg); color: var(--red); font-weight: 600; }
.vien-tron.nho { padding: 3px 8px; font-size: 12px; margin-top: 4px; }
.chu-thich { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chu-thich .vien-tron { font-size: 12px; padding: 3px 9px; }

/* ---------- Thẻ: bóng rất nhẹ, thống nhất ---------- */
.the, .the-dong, .dong-cho, .bang-khung, .kpi .the {
  box-shadow: 0 1px 2px rgba(13,43,105,.05), 0 2px 8px rgba(13,43,105,.04);
}
.dong-cho:hover { border-color: #B8C3DA; }
.kpi .so, .ma-don.lon { font-family: 'Lora', Georgia, serif; }
.nhan-roi { min-height: 52px; border-radius: 12px; background: var(--ok-bg); color: var(--ok); font-size: 16px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 6px 10px; flex-wrap: wrap; }
.nhan-gui { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 8px 12px; font-size: 14px; font-weight: 600; }
.nhan-bh { background: var(--bh-bg); color: var(--bh); border-radius: 999px; padding: 3px 9px; font-size: 12px; font-weight: 600; }

/* ---------- Bảng ---------- */
.bang-khung { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; }
table.bang { width: 100%; border-collapse: collapse; font-size: 15px; }
table.bang th { background: var(--soft); color: var(--navy); text-align: left; padding: 11px 12px; font-weight: 600; white-space: nowrap; }
table.bang td { padding: 10px 12px; border-top: 1px solid var(--line2); vertical-align: middle; }
table.bang .g { text-align: center; }
table.bang .bh-cot { background: var(--bh-bg); color: var(--bh); }
table.bang tr.bam { cursor: pointer; }
table.bang tr.bam:hover td { background: #F7F9FD; }
table.bang tr.tre td:first-child { box-shadow: inset 4px 0 0 var(--red); }
table.bang tr.sapTre td:first-child { box-shadow: inset 4px 0 0 var(--warn-line); }
.ma-don { font-weight: 600; color: var(--navy); }
.so-0 { color: #A0A8B8; }

/* ---------- KPI ---------- */
.kpi { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.kpi .the { padding: 14px 16px; }
.kpi .so { font-size: 28px; font-weight: 700; color: var(--navy); }
.kpi .so.do { color: var(--red); }
@media (max-width: 900px) { .kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Hộp thoại ---------- */
.man-che { position: fixed; inset: 0; background: rgba(13,43,105,.35); display: flex; align-items: flex-end; justify-content: center; z-index: 50; padding: 12px; }
@media (min-width: 700px) { .man-che { align-items: center; } }
.hop { background: #fff; border-radius: 16px; padding: 18px; width: 100%; max-width: 640px; max-height: 88vh; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.hop h3 { margin: 0; color: var(--navy); font-size: 19px; }

.luoi-tich { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 4px 12px; }
.dang-tai { color: var(--muted); padding: 24px 0; text-align: center; }
.chan { color: var(--muted); font-size: 12px; text-align: center; padding: 8px 0 24px; }
/* ---------- Điện thoại: bảng thành thẻ ---------- */
@media (max-width: 700px) {
  .bang-khung { background: transparent; border: 0; overflow: visible; }
  table.co-the thead { display: none; }
  table.co-the, table.co-the tbody, table.co-the tr, table.co-the td { display: block; width: 100%; }
  table.co-the tr { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 10px; }
  table.co-the td { border: 0; padding: 5px 0; display: flex; gap: 12px; justify-content: space-between; align-items: center; text-align: right; }
  table.co-the td::before { content: attr(data-nhan); color: var(--muted); font-size: 13px; text-align: left; flex: 0 0 38%; }
  table.co-the td:not([data-nhan])::before { content: none; }
  table.co-the td:first-child { font-size: 17px; border-bottom: 1px solid var(--line2); padding-bottom: 8px; margin-bottom: 2px; }
  table.co-the td.so-0 { display: none; }
  table.co-the td.bh-cot { background: transparent; }
  table.co-the tr.tre { border-left: 5px solid var(--red); }
  table.co-the tr.sapTre { border-left: 5px solid var(--warn-line); }
  table.co-the tr.tre td:first-child, table.co-the tr.sapTre td:first-child { box-shadow: none; }
  table.co-the .nhom { justify-content: flex-end; }
  .hang h1 { font-size: 21px; }
  .kpi { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .kpi .the { padding: 8px 10px; }
  .kpi .so { font-size: 22px; }
  .kpi .mo { font-size: 12px; line-height: 1.3; }
  .cuon-ngang { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; padding-bottom: 2px; }
  .cuon-ngang > * { flex: 0 0 auto; }
  input.nhap[type=search] { width: 100% !important; max-width: none !important; }
}
@media (max-width: 600px) {
  .trang { padding: 16px 12px 40px; }
  .thanh { padding-left: 12px; padding-right: 12px; }
}
/* ---------- Điện thoại: menu dưới cùng, bấm 1 tay ---------- */
@media (max-width: 700px) {
  .dieu-huong {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: #fff; border-top: 1px solid var(--line);
    box-shadow: 0 -2px 10px rgba(13,43,105,.06); padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 0;
  }
  .dieu-huong a { flex: 1 0 64px; flex-direction: column; gap: 2px; color: var(--muted); font-size: 11px; padding: 6px 4px; border-radius: 10px; }
  .dieu-huong a .ic { width: 22px; height: 22px; opacity: 1; }
  .dieu-huong a.chon { background: var(--soft); color: var(--navy); font-weight: 600; }
  .dieu-huong .ten-dai { display: none; }
  .dieu-huong .ten-ngan { display: inline; }
  body.co-menu-duoi .trang { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
}
