:root {
  --bg: #f4f1ec; --card: #fff; --text: #26221e; --muted: #7a726a; --line: #e6e0d8;
  --accent: #b5521b; --accent-2: #8f3f13; --accent-soft: #fbeee5;
  --ok: #2e7d4f; --ok-soft: #e7f4ec; --warn: #c0392b; --warn-soft: #fdecea; --wait: #c98a10; --wait-soft: #fff6e0;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: 15px;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }

/* ===== Thanh menu trên cùng ===== */
header.nav { position: sticky; top: 0; z-index: 10; background: var(--accent); color: #fff;
  display: flex; align-items: center; gap: 4px; padding: 0 16px; min-height: 56px; flex-wrap: wrap; box-shadow: 0 2px 6px rgba(0,0,0,.12); }
header.nav .brand { font-weight: 800; font-size: 18px; margin-right: 14px; color: #fff; text-decoration: none; white-space: nowrap; }
header.nav a.muc { color: #fff; text-decoration: none; padding: 8px 12px; border-radius: 8px; opacity: .85; white-space: nowrap; }
header.nav a.muc:hover { background: rgba(255,255,255,.12); opacity: 1; }
header.nav a.muc.on { background: rgba(255,255,255,.22); opacity: 1; font-weight: 600; }
header.nav .ngay { margin-left: auto; font-size: 13px; opacity: .85; text-transform: capitalize; }

main { padding: 20px 16px 40px; max-width: 1240px; margin: 0 auto; }
h1.tieu-de { font-size: 22px; margin: 4px 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 16px 0 8px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-4 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card, .grid + .card, .card + .grid, .grid-4 + .card, .grid-4 + .grid { margin-top: 16px; }
.card h2 .phu { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 6px; }
.full { grid-column: 1 / -1; }

/* Thẻ số liệu */
.chi-so { padding: 14px 16px; }
.chi-so .nhan { color: var(--muted); font-size: 13px; }
.chi-so .so { font-size: 24px; font-weight: 700; margin-top: 4px; }
.chi-so.do .so { color: var(--warn); } .chi-so.xanh .so { color: var(--ok); }

/* Nút & ô nhập */
button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 8px; padding: 8px 14px; transition: background .15s, border-color .15s; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
button.primary:hover { background: var(--accent-2); }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); }
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label { font-size: 14px; }

/* Bảng */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .02em; background: #faf8f5; }
tbody tr:hover { background: #fcfaf7; }
th.num, td.num { text-align: right; white-space: nowrap; }
tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
.khung-bang { overflow: auto; max-height: 560px; border: 1px solid var(--line); border-radius: 10px; }
.khung-bang th { position: sticky; top: 0; z-index: 1; }
tr.dong-loi td { background: var(--warn-soft); }

.muted { color: var(--muted); font-size: 13px; }
.low { color: var(--warn); font-weight: 600; }
.tot { color: var(--ok); font-weight: 600; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.space { justify-content: space-between; }
.canh-bao-nen { background: var(--wait-soft); border: 1px solid #f1d9a6; border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; font-size: 14px; }
details > summary { cursor: pointer; font-weight: 600; padding: 4px 0; }

/* Vùng kéo thả file / ảnh */
.vung-file { border: 2px dashed var(--line); border-radius: 12px; padding: 22px 12px; text-align: center; cursor: pointer; background: #fcfbf9; }
.vung-file:hover, .vung-file.keo { border-color: var(--accent); background: var(--accent-soft); }
.vung-file .icon { font-size: 28px; display: block; margin-bottom: 4px; }

/* Thông báo góc màn hình */
#hopThongBao { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.thong-bao { position: relative; padding: 12px 36px 12px 14px; border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.15); font-size: 14px; background: #fff; border-left: 5px solid var(--ok); }
.thong-bao.loi { border-left-color: var(--warn); }
.thong-bao.canh-bao { border-left-color: var(--wait); background: var(--wait-soft); }
.thong-bao .dong { position: absolute; top: 6px; right: 6px; border: none; background: none; font-size: 18px; padding: 2px 8px; }

/* Trang chọn vai trò */
.roles { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-top: 20px; }
.role { display: block; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 26px 20px; text-align: center; transition: transform .12s, border-color .12s; box-shadow: var(--shadow); }
.role:hover { transform: translateY(-3px); border-color: var(--accent); }
.role .icon { font-size: 44px; } .role h2 { margin: 10px 0 6px; font-size: 20px; }

@media (max-width: 640px) {
  header.nav { padding: 6px 10px; } header.nav .ngay { display: none; }
  header.nav a.muc { padding: 6px 8px; font-size: 14px; }
  main { padding: 14px 10px 30px; }
  .card { padding: 14px; }
}
@media print {
  header.nav, .khong-in, #hopThongBao { display: none !important; }
  body { background: #fff; } .card { box-shadow: none; border: none; padding: 0; }
  .khung-bang { max-height: none; overflow: visible; border: none; }
}

/* Hộp hỏi thông tin / khoá PIN */
.hop-nen { position: fixed; inset: 0; z-index: 200; background: rgba(30,25,20,.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.hop { background: #fff; border-radius: 14px; padding: 22px; width: min(420px, 100%); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.hop .truong { display: block; margin-top: 10px; }
.hop .truong input { display: block; width: 100%; margin-top: 4px; }
.man-khoa { position: fixed; inset: 0; z-index: 300; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 16px; }
.man-khoa .hop { text-align: center; }
.man-khoa .o-pin { font-size: 28px; letter-spacing: 10px; text-align: center; width: 220px; margin: 12px auto; display: block; }
header.nav .nut-khoa { background: rgba(255,255,255,.15); color: #fff; border-color: transparent; padding: 6px 10px; margin-left: 8px; }
.an-gia .gia { display: none !important; }
/* Dòng đọc từ ảnh bill chưa chắc — nhân viên kiểm tra lại */
tr.dong-can-kiem td { background: var(--wait-soft); }
.ghi-can-kiem { font-size: 12px; color: #9a5b00; margin-top: 3px; }
.anh-bill-xem { max-width: 100%; max-height: 360px; border-radius: 10px; border: 1px solid var(--line); margin-top: 10px; }
