/* ============================================================
   Khảo sát NCC — giao diện ưu tiên ĐIỆN THOẠI
   Nguyên tắc: nút cao tối thiểu 48px, chữ 17px, một cột.
   ============================================================ */

:root {
  --xanh: #0b6b3a;
  --xanh-nhat: #e6f4ec;
  --do: #c62828;
  --do-nhat: #fdecea;
  --cam: #e07b00;
  --cam-nhat: #fff4e5;
  --xam-1: #f5f6f7;
  --xam-2: #e3e6e8;
  --xam-3: #9aa3a8;
  --chu: #16211c;
  --chu-mo: #5c6b64;
  --nen: #ffffff;
  --vien: #d4d9dc;
  --bong: 0 1px 3px rgba(0, 0, 0, .10);
  --r: 10px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px; line-height: 1.45;
  color: var(--chu); background: var(--xam-1);
  overscroll-behavior-y: contain;
}

/* ---------- Thanh trên ---------- */
.thanh-tren {
  position: sticky; top: 0; z-index: 50;
  background: var(--xanh); color: #fff;
  padding: 10px 14px 0;
  box-shadow: var(--bong);
}
.thanh-tren .ma-ten { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.thanh-tren .ma { font-size: 13px; opacity: .85; font-variant-numeric: tabular-nums; white-space: nowrap; }
.thanh-tren .ten { font-size: 17px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tien-do { display: flex; gap: 4px; margin: 10px 0 0; }
.tien-do button {
  flex: 1; border: 0; background: rgba(255,255,255,.25); color: #fff;
  padding: 7px 2px 9px; font-size: 13px; font-weight: 600; cursor: pointer;
  border-radius: 6px 6px 0 0; font-family: inherit;
}
.tien-do button.dang { background: var(--xam-1); color: var(--xanh); }
.tien-do button .cham { display: block; font-size: 10px; font-weight: 400; opacity: .8; }
.tien-do button.dang .cham { opacity: 1; }

/* ---------- Thân ---------- */
main { padding: 12px 12px 96px; max-width: 900px; margin: 0 auto; }

.muc {
  background: var(--nen); border-radius: var(--r);
  margin-bottom: 14px; padding: 14px; box-shadow: var(--bong);
}
.muc > h2 {
  margin: 0 0 4px; font-size: 16px; color: var(--xanh);
  text-transform: uppercase; letter-spacing: .3px;
}
.muc > .ghi-chu-muc {
  background: var(--cam-nhat); border-left: 3px solid var(--cam);
  padding: 8px 10px; border-radius: 0 6px 6px 0;
  font-size: 14px; color: #7a4a00; margin: 8px 0 4px;
}

/* ---------- Trường ---------- */
.truong { padding: 14px 0; border-top: 1px solid var(--xam-2); }
.muc .truong:first-of-type { border-top: 0; padding-top: 8px; }
.truong.an { display: none; }

.nhan {
  display: block; font-weight: 600; font-size: 15.5px;
  margin-bottom: 8px; color: var(--chu);
}
.nhan .sao { color: var(--do); margin-left: 3px; }
.nhan .co-quan-trong {
  display: inline-block; background: var(--do); color: #fff;
  font-size: 10px; padding: 1px 6px; border-radius: 8px;
  margin-left: 6px; vertical-align: middle; letter-spacing: .4px;
}
.goi-y { font-size: 13.5px; color: var(--chu-mo); margin: -4px 0 8px; }
.nhac {
  font-size: 13.5px; background: var(--cam-nhat); color: #7a4a00;
  padding: 7px 9px; border-radius: 6px; margin: -2px 0 9px;
}

/* ---------- Nút chọn (1 lựa chọn) ---------- */
.nhom-chon { display: flex; flex-direction: column; gap: 7px; }
.nhom-chon.ngang { flex-direction: row; flex-wrap: wrap; }
.nhom-chon.ngang > .nut-chon { flex: 1 1 auto; min-width: 92px; text-align: center; }

.nut-chon {
  display: block; width: 100%; min-height: 48px;
  padding: 11px 13px; font-size: 16px; font-family: inherit; text-align: left;
  background: var(--nen); color: var(--chu);
  border: 1.5px solid var(--vien); border-radius: var(--r);
  cursor: pointer; transition: none;
}
.nut-chon:active { background: var(--xam-1); }
.nut-chon.chon {
  background: var(--xanh); border-color: var(--xanh); color: #fff; font-weight: 600;
}
.nut-chon.chon.xau { background: var(--do); border-color: var(--do); }
.nut-chon.chon.vua { background: var(--cam); border-color: var(--cam); }

/* ---------- Chip (chọn nhiều) ---------- */
.nhom-chip { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 10px 13px; min-height: 44px;
  font-size: 15px; font-family: inherit; line-height: 1.25;
  background: var(--nen); color: var(--chu);
  border: 1.5px solid var(--vien); border-radius: 22px;
  cursor: pointer; text-align: left;
}
.chip.chon { background: var(--xanh); border-color: var(--xanh); color: #fff; font-weight: 600; }
.chip.chon::before { content: "✓ "; }

/* Ô gõ tay hiện ra khi bấm "Khác" */
.o-khac {
  display: flex; gap: 7px; align-items: flex-start;
  margin-top: 8px; padding: 9px;
  background: var(--xam-1);
  border: 1.5px dashed var(--xanh); border-radius: var(--r);
}
.o-khac input { background: var(--nen); }

/* ---------- Ô nhập ---------- */
.o-nhap-boc { display: flex; gap: 7px; align-items: flex-start; }
input[type=text], input[type=number], input[type=date], textarea, select {
  width: 100%; min-height: 48px; padding: 11px 12px;
  font-size: 16px; font-family: inherit; color: var(--chu);
  background: var(--nen); border: 1.5px solid var(--vien); border-radius: var(--r);
}
textarea { min-height: 84px; resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--xanh); outline-offset: -2px; border-color: var(--xanh); }
.don-vi { font-size: 14px; color: var(--chu-mo); align-self: center; white-space: nowrap; padding: 0 2px; }

.nut-phu {
  min-height: 48px; min-width: 52px; padding: 0 12px;
  font-size: 19px; font-family: inherit;
  background: var(--xam-1); border: 1.5px solid var(--vien);
  border-radius: var(--r); cursor: pointer; flex-shrink: 0;
}
.nut-phu.dang-nghe { background: var(--do); border-color: var(--do); color: #fff; animation: nhap-nhay 1s infinite; }
@keyframes nhap-nhay { 50% { opacity: .55; } }

/* ---------- Thang điểm 1–5 ---------- */
.thang-hang { display: flex; gap: 6px; }
.thang-hang button {
  flex: 1; min-height: 56px; font-size: 21px; font-weight: 700; font-family: inherit;
  background: var(--nen); color: var(--chu);
  border: 1.5px solid var(--vien); border-radius: var(--r); cursor: pointer;
}
.thang-hang button.chon { color: #fff; }
.thang-hang button.chon[data-d="5"], .thang-hang button.chon[data-d="4"] { background: var(--xanh); border-color: var(--xanh); }
.thang-hang button.chon[data-d="3"] { background: var(--cam); border-color: var(--cam); }
.thang-hang button.chon[data-d="2"], .thang-hang button.chon[data-d="1"] { background: var(--do); border-color: var(--do); }
.neo-mo-ta {
  margin-top: 8px; padding: 9px 11px; border-radius: 8px;
  background: var(--xam-1); font-size: 14.5px; color: var(--chu-mo); line-height: 1.4;
}
.neo-mo-ta b { color: var(--chu); }
.trong-so-nho { float: right; font-size: 12.5px; color: var(--chu-mo); font-weight: 400; }

/* ---------- Tổng điểm ---------- */
.tong-diem {
  margin-top: 14px; padding: 16px; border-radius: var(--r); text-align: center;
  background: var(--xam-1); border: 2px solid var(--vien);
}
.tong-diem .so { font-size: 42px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.tong-diem .kl { font-size: 15px; margin-top: 6px; font-weight: 600; }
.tong-diem.dat { background: var(--xanh-nhat); border-color: var(--xanh); color: var(--xanh); }
.tong-diem.dk  { background: var(--cam-nhat); border-color: var(--cam); color: #8a4b00; }
.tong-diem.truot { background: var(--do-nhat); border-color: var(--do); color: var(--do); }

/* ---------- Ảnh ---------- */
.o-anh { display: flex; flex-wrap: wrap; gap: 8px; }
.nut-chup {
  min-height: 82px; min-width: 82px; padding: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: var(--xam-1); border: 2px dashed var(--vien); border-radius: var(--r);
  font-size: 12.5px; color: var(--chu-mo); cursor: pointer; font-family: inherit;
}
.nut-chup .bieu-tuong { font-size: 25px; }
.the-anh { position: relative; width: 82px; height: 82px; border-radius: var(--r); overflow: hidden; background: var(--xam-2); }
.the-anh img { width: 100%; height: 100%; object-fit: cover; display: block; }
.the-anh .xoa {
  position: absolute; top: 2px; right: 2px; width: 26px; height: 26px;
  border: 0; border-radius: 50%; background: rgba(0,0,0,.62); color: #fff;
  font-size: 15px; line-height: 1; cursor: pointer; font-family: inherit;
}
.dem-anh { font-size: 13px; color: var(--chu-mo); margin-top: 6px; }

/* ---------- Bảng thiết bị ---------- */
.the-may {
  border: 1.5px solid var(--vien); border-radius: var(--r);
  padding: 12px; margin-bottom: 10px; background: var(--xam-1);
}
.the-may .dau { display: flex; justify-content: space-between; align-items: center; margin-bottom: 9px; }
.the-may .stt { font-weight: 700; color: var(--xanh); font-size: 15px; }
.the-may .xoa-may { border: 0; background: var(--do-nhat); color: var(--do); border-radius: 6px; padding: 7px 12px; font-size: 14px; cursor: pointer; font-family: inherit; min-height: 40px; }
.the-may .o { margin-bottom: 9px; }
.the-may .o > label { display: block; font-size: 13.5px; color: var(--chu-mo); margin-bottom: 4px; font-weight: 600; }
.nut-them {
  width: 100%; min-height: 50px; font-size: 16px; font-weight: 600; font-family: inherit;
  background: var(--xanh-nhat); color: var(--xanh);
  border: 1.5px dashed var(--xanh); border-radius: var(--r); cursor: pointer;
}

/* ---------- Nhóm dòng (trạng thái / hồ sơ / rủi ro / kế hoạch) ---------- */
.dong-nhom { padding: 12px 0; border-bottom: 1px solid var(--xam-2); }
.dong-nhom:last-child { border-bottom: 0; }
.dong-nhom > .ten-dong { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.dong-nhom > .ten-dong .so-tt { color: var(--xanh); margin-right: 5px; }
.dong-nhom .doi { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.dong-nhom .doi > div > label { display: block; font-size: 13px; color: var(--chu-mo); margin-bottom: 4px; font-weight: 600; }

/* ---------- Thanh dưới ---------- */
.thanh-duoi {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; gap: 8px; align-items: center;
  background: var(--nen); border-top: 1px solid var(--vien);
  padding: 9px 12px calc(9px + env(safe-area-inset-bottom));
  box-shadow: 0 -1px 6px rgba(0,0,0,.08);
}
.thanh-duoi button {
  min-height: 48px; padding: 0 16px; font-size: 16px; font-weight: 600; font-family: inherit;
  border-radius: var(--r); border: 1.5px solid var(--vien);
  background: var(--nen); color: var(--chu); cursor: pointer;
}
.thanh-duoi button.chinh { background: var(--xanh); border-color: var(--xanh); color: #fff; flex: 1; }
.thanh-duoi button:disabled { opacity: .4; }
.thanh-duoi .trang-thai-luu { font-size: 12.5px; color: var(--chu-mo); flex: 1; text-align: center; line-height: 1.25; }

/* ---------- Màn hình kiểm tra trước khi gửi ---------- */
.thieu { background: var(--do-nhat); border-left: 3px solid var(--do); padding: 10px 12px; border-radius: 0 6px 6px 0; margin-bottom: 8px; }
.thieu b { display: block; font-size: 14px; }
.thieu a { color: var(--do); font-size: 13.5px; }
.du { background: var(--xanh-nhat); border-left: 3px solid var(--xanh); padding: 12px; border-radius: 0 6px 6px 0; color: var(--xanh); font-weight: 600; }

/* ---------- Trang danh sách (máy tính) ---------- */
.bang-ds { width: 100%; border-collapse: collapse; background: var(--nen); font-size: 14.5px; }
.bang-ds th, .bang-ds td { padding: 9px 10px; border-bottom: 1px solid var(--xam-2); text-align: left; vertical-align: top; }
.bang-ds th { background: var(--xanh); color: #fff; font-size: 13px; text-transform: uppercase; letter-spacing: .3px; position: sticky; top: 0; }
.bang-ds tbody tr:hover { background: var(--xam-1); }
.bang-ds td.so { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.the-diem { display: inline-block; padding: 3px 9px; border-radius: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.the-diem.dat { background: var(--xanh-nhat); color: var(--xanh); }
.the-diem.dk { background: var(--cam-nhat); color: #8a4b00; }
.the-diem.truot { background: var(--do-nhat); color: var(--do); }
.co-do { color: var(--do); font-size: 13px; }

/* ---------- Máy tính bảng / máy tính ---------- */
@media (min-width: 760px) {
  body { font-size: 16px; }
  main { padding: 18px 18px 96px; }
  .nhom-chon { flex-direction: row; flex-wrap: wrap; }
  .nhom-chon > .nut-chon { flex: 1 1 calc(50% - 4px); min-width: 220px; }
  .the-may .luoi { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
}

@media print {
  .thanh-tren, .thanh-duoi, .nut-phu, .nut-them { display: none !important; }
  body { background: #fff; }
}
