/* ==========================================================================
   REDPOWER — App Quản Lý Thi Công
   Bảng màu lấy ĐÚNG từ logo công ty: đỏ #DE2128 · navy #2B337A · cam #F89720.
   Giao diện dựng cho ĐIỆN THOẠI TRƯỚC (mobile-first).
   ========================================================================== */

/* --- Dòng bắt buộc: thiếu nó thì mọi nút lẽ ra ẩn theo quyền đều hiện ra --- */
[hidden] { display: none !important; }

:root {
  /* Màu thương hiệu — lấy từ file logo gốc */
  --do: #DE2128;
  --do-dam: #B81A20;
  --do-nhan: #EC2F36;
  --do-mo: rgba(222, 33, 40, 0.08);

  --navy: #2B337A;
  --navy-dam: #1E2559;
  --navy-mo: rgba(43, 51, 122, 0.08);

  --cam: #F89720;

  /* Nền và chữ */
  --den: #1E2559;        /* thanh trên dùng navy đậm của logo, không dùng đen */
  --den-thuc: #000000;
  --trang: #FFFFFF;
  --nen: #F4F4F4;
  --nen-the: #FFFFFF;
  --vien: #E9E9E9;
  --chu: #1A1A1A;
  --chu-phu: #666666;
  --chu-nhat: #8A8A8A;

  /* Trạng thái */
  --xanh: #12864B;
  --xanh-mo: rgba(18, 134, 75, 0.10);
  --vang: #B7791F;
  --vang-mo: rgba(183, 121, 31, 0.12);

  /* Kích thước */
  --r: 10px;
  --r-nho: 6px;
  --bong: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --bong-noi: 0 4px 16px rgba(0, 0, 0, 0.10);
  --thanh-duoi: 60px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--nen);
  color: var(--chu);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   MÀN ĐĂNG NHẬP
   ========================================================================== */

#man-dang-nhap,
#man-doi-mk {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(155deg, var(--navy-dam) 0%, #2a2050 45%, var(--do-dam) 100%);
}

/* Màn đổi mật khẩu dài hơn — cho phép cuộn trên máy nhỏ */
#man-doi-mk { align-items: flex-start; padding-top: 24px; padding-bottom: 24px; }
#man-doi-mk .logo-anh { max-width: 160px; margin-bottom: 10px; }

/* --- Bảng luật đặt mật khẩu, tự tick khi đạt --- */
.luat-mk {
  list-style: none;
  margin: 4px 0 16px;
  padding: 12px 14px;
  background: var(--nen);
  border-radius: var(--r-nho);
  font-size: 12.5px;
}

.luat-mk li {
  color: var(--chu-phu);
  padding: 3px 0 3px 22px;
  position: relative;
  transition: color .15s;
}

.luat-mk li::before {
  content: '○';
  position: absolute;
  left: 2px;
  color: var(--chu-nhat);
  font-size: 13px;
}

.luat-mk li.dat {
  color: var(--xanh);
  font-weight: 600;
}

.luat-mk li.dat::before {
  content: '✓';
  color: var(--xanh);
  font-weight: 700;
}

.nut-thoat-nho {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 8px;
  background: none;
  color: var(--chu-phu);
  font-size: 13px;
  font-weight: 500;
  text-decoration: underline;
}

.nut-thoat-nho:hover { color: var(--chu); }

.hop-dang-nhap {
  width: 100%;
  max-width: 380px;
  background: var(--trang);
  border-radius: 14px;
  padding: 30px 26px 32px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.logo {
  text-align: center;
  margin-bottom: 24px;
}

/* Logo đầy đủ (biểu tượng + chữ REDPOWER + Own your energy) */
.logo-anh {
  display: block;
  width: 100%;
  max-width: 210px;
  height: auto;
  margin: 0 auto 14px;
}

.logo-phu {
  font-size: 12.5px;
  color: var(--chu-phu);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  font-weight: 600;
  padding-top: 12px;
  border-top: 1px solid var(--vien);
}

/* ==========================================================================
   Ô NHẬP VÀ NÚT
   ========================================================================== */

.o-nhap { margin-bottom: 15px; }

.o-nhap label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--chu);
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="date"],
select {
  width: 100%;
  padding: 11px 13px;
  font-size: 16px; /* >=16px để iPhone không tự phóng to khi bấm vào ô */
  font-family: inherit;
  color: var(--chu);
  background: var(--trang);
  border: 1.5px solid var(--vien);
  border-radius: var(--r-nho);
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--do);
  box-shadow: 0 0 0 3px var(--do-mo);
}

button {
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  border-radius: var(--r-nho);
  transition: background .15s, opacity .15s;
}

.nut-chinh {
  width: 100%;
  padding: 12px;
  background: var(--do);
  color: var(--trang);
  margin-top: 6px;
}

.nut-chinh:hover { background: var(--do-dam); }
.nut-chinh:disabled { opacity: .55; cursor: not-allowed; }

.nut-phu {
  padding: 8px 14px;
  background: var(--trang);
  color: var(--chu);
  border: 1.5px solid var(--vien);
}

.nut-phu:hover { border-color: var(--chu-nhat); }

.nut-nho {
  padding: 6px 11px;
  font-size: 13px;
  background: var(--do-mo);
  color: var(--do-dam);
}

/* ==========================================================================
   BÁO LỖI / BÁO THÀNH CÔNG
   ========================================================================== */

.bao {
  padding: 10px 13px;
  border-radius: var(--r-nho);
  font-size: 13.5px;
  margin-bottom: 14px;
  line-height: 1.45;
}

.bao-loi {
  background: var(--do-mo);
  color: var(--do-dam);
  border-left: 3px solid var(--do);
}

.bao-ok {
  background: var(--xanh-mo);
  color: var(--xanh);
  border-left: 3px solid var(--xanh);
}

.bao-nhac {
  background: var(--vang-mo);
  color: var(--vang);
  border-left: 3px solid var(--vang);
}

/* ==========================================================================
   KHUNG APP CHÍNH
   ========================================================================== */

#man-app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.thanh-tren {
  background: var(--den);
  color: var(--trang);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.thanh-tren .ten-app {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

/* Biểu tượng tròn của logo — bản gọn cho thanh ngang */
.thanh-tren .bieu-tuong {
  height: 30px;
  width: auto;
  flex-shrink: 0;
  background: var(--trang);
  border-radius: 6px;
  padding: 3px;
}

.thanh-tren .chu-app {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.2px;
  white-space: nowrap;
}

.thanh-tren .chu-app span { color: var(--do-nhan); }

.thanh-tren .phu-app {
  font-size: 10.5px;
  font-weight: 600;
  opacity: .62;
  text-transform: uppercase;
  letter-spacing: .7px;
  display: block;
  margin-top: 1px;
}

.khoi-nguoi-dung {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
}

.ten-nguoi {
  color: var(--trang);
  opacity: .9;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nut-thoat {
  padding: 5px 11px;
  font-size: 12.5px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--trang);
}

.nut-thoat:hover { background: rgba(255, 255, 255, 0.22); }

/* --- Thân trang --- */

.than {
  flex: 1;
  padding: 16px;
  padding-bottom: calc(var(--thanh-duoi) + 20px); /* chừa chỗ cho thanh dưới */
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

.tieu-de-trang {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.tieu-de-trang h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.dem {
  font-size: 13px;
  color: var(--chu-phu);
  font-weight: 500;
}

/* --- Ô tìm kiếm --- */

.hang-tim {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.hang-tim input { flex: 1; min-width: 0; }

.nut-hep { width: auto; padding: 11px 15px; margin-top: 0; white-space: nowrap; }

/* ==========================================================================
   HỘP LỌC — các ô tick phòng ban / trạng thái
   ========================================================================== */

.hop-loc {
  background: var(--nen-the);
  border: 1px solid var(--vien);
  border-radius: var(--r);
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: var(--bong);
}

.nhom-loc { margin-bottom: 13px; }

.ten-nhom {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--chu-phu);
  margin-bottom: 8px;
}

.cac-o-tick {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

/* Ô tick trông như cái nhãn bấm được, dễ trúng trên điện thoại */
.o-tick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1.5px solid var(--vien);
  border-radius: 20px;
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
  transition: border-color .12s, background .12s, color .12s;
  background: var(--trang);
}

.o-tick input { display: none; }

.o-tick .dau {
  width: 15px;
  height: 15px;
  border: 1.5px solid var(--chu-nhat);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: transparent;
  flex-shrink: 0;
}

.o-tick.chon {
  border-color: var(--do);
  background: var(--do-mo);
  color: var(--do-dam);
  font-weight: 600;
}

.o-tick.chon .dau {
  background: var(--do);
  border-color: var(--do);
  color: var(--trang);
}

.hang-nut-loc {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 11px;
  border-top: 1px solid var(--vien);
}

/* --- Thẻ nhân viên bấm được --- */

.the-nv[role="button"], tbody tr[role="button"] { cursor: pointer; }

.the-nv[role="button"]:active { background: var(--nen); }

.the-nv .xem-them {
  font-size: 12px;
  color: var(--do);
  font-weight: 600;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--vien);
}

/* ==========================================================================
   KHUNG CHI TIẾT / SỬA
   ========================================================================== */

#lop-phu {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 30, 0.55);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.khung {
  background: var(--nen-the);
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  max-height: 92dvh;
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -6px 30px rgba(0, 0, 0, 0.3);
}

.khung-dau {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--vien);
  background: var(--den);
  color: var(--trang);
  border-radius: 16px 16px 0 0;
}

.khung-dau h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.nut-dong {
  background: rgba(255, 255, 255, 0.14);
  color: var(--trang);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 15px;
  line-height: 1;
  flex-shrink: 0;
}

.nut-dong:hover { background: rgba(255, 255, 255, 0.26); }

.khung-than {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
}

.khung-chan {
  display: flex;
  gap: 9px;
  justify-content: flex-end;
  padding: 13px 18px;
  border-top: 1px solid var(--vien);
  padding-bottom: calc(13px + env(safe-area-inset-bottom, 0px));
}

/* --- Bảng chi tiết --- */

.bang-chi-tiet {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(96px, auto) 1fr;
  gap: 1px 14px;
}

.bang-chi-tiet dt {
  color: var(--chu-nhat);
  font-size: 13px;
  padding: 9px 0;
  border-bottom: 1px solid var(--vien);
}

.bang-chi-tiet dd {
  margin: 0;
  padding: 9px 0;
  font-size: 14.5px;
  color: var(--chu);
  border-bottom: 1px solid var(--vien);
  word-break: break-word;
}

.bang-chi-tiet dt:last-of-type,
.bang-chi-tiet dd:last-of-type { border-bottom: none; }

.sao { color: var(--do); }

@media (min-width: 700px) {
  #lop-phu { align-items: center; padding: 20px; }
  .khung { border-radius: 16px; max-height: 88vh; }
  .khung-dau { border-radius: 16px 16px 0 0; }
}

/* ==========================================================================
   DANH SÁCH NHÂN VIÊN — thẻ trên điện thoại, bảng trên máy tính
   ========================================================================== */

.the-nv {
  background: var(--nen-the);
  border: 1px solid var(--vien);
  border-radius: var(--r);
  padding: 13px 15px;
  margin-bottom: 10px;
  box-shadow: var(--bong);
}

.the-nv .hang1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.the-nv .ho-ten {
  font-weight: 700;
  font-size: 15.5px;
  color: var(--chu);
}

.the-nv .dong {
  display: flex;
  gap: 7px;
  font-size: 13.5px;
  color: var(--chu-phu);
  margin-top: 3px;
}

.the-nv .nhan-cot {
  color: var(--chu-nhat);
  min-width: 78px;
  flex-shrink: 0;
}

.the-nv .gia-tri { color: var(--chu); }

.ma-nv {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--chu-phu);
  background: var(--nen);
  padding: 2px 7px;
  border-radius: 4px;
}

/* --- Nhãn trạng thái --- */

.trang-thai {
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
}

.tt-lam-viec { background: var(--xanh-mo); color: var(--xanh); }
.tt-nghi     { background: var(--nen);    color: var(--chu-phu); }
.tt-tam-nghi { background: var(--vang-mo); color: var(--vang); }

/* --- Bảng cho màn hình rộng --- */

.bang-nv { display: none; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--nen-the);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--bong);
}

thead th {
  background: var(--den);
  color: var(--trang);
  text-align: left;
  padding: 11px 14px;
  font-size: 12.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
}

tbody td {
  padding: 11px 14px;
  border-top: 1px solid var(--vien);
  font-size: 14px;
}

tbody tr:hover { background: var(--do-mo); }

/* --- Trạng thái rỗng / đang tải --- */

.trong {
  text-align: center;
  padding: 44px 20px;
  color: var(--chu-phu);
  background: var(--nen-the);
  border: 1px dashed var(--vien);
  border-radius: var(--r);
}

.trong .to { font-size: 30px; margin-bottom: 8px; }

.dang-tai {
  text-align: center;
  padding: 36px;
  color: var(--chu-phu);
  font-size: 14px;
}

/* ==========================================================================
   THANH ĐIỀU HƯỚNG
   Điện thoại: nằm dưới đáy màn hình. Máy tính: ẩn, chuyển lên thanh trên.
   ========================================================================== */

.thanh-duoi {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--thanh-duoi);
  background: var(--trang);
  border-top: 1px solid var(--vien);
  display: flex;
  z-index: 30;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.thanh-duoi button {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  color: var(--chu-phu);
  padding: 6px 2px;
}

.thanh-duoi button .to { font-size: 19px; line-height: 1; }
.thanh-duoi button.dang-chon { color: var(--do); }

/* ==========================================================================
   MÁY TÍNH — từ 900px trở lên
   ========================================================================== */

@media (min-width: 900px) {
  body { font-size: 15px; }

  .thanh-duoi { display: none; }

  .than { padding: 24px; padding-bottom: 24px; }

  /* Đổi từ thẻ sang bảng */
  .the-nv { display: none; }
  .bang-nv { display: block; overflow-x: auto; }

  .tieu-de-trang h2 { font-size: 22px; }

  .hang-tim { max-width: 460px; }
}
