/* Notification Test — giao diện dùng chung cho trang người dùng và trang admin.
 * Ưu tiên điện thoại. Phông hệ thống: PWA phải mở được khi mất mạng, và phông hệ thống có sẵn
 * đủ chữ Việt lẫn chữ Nhật (nội dung thông báo nghỉ phép là tiếng Nhật).
 */
:root {
  --nen: #f3f5f9;
  --the: #ffffff;
  --muc: #121b2e;
  --muc-phu: #5b6478;
  --vien: #dce1ea;
  --vien-nhat: #e9edf3;
  --accent: #254edb;
  --accent-dam: #1a3ab0;
  --accent-nhat: #e8eeff;
  --chu-tren-accent: #ffffff;
  --ok: #16804a;
  --ok-nhat: #e3f4ea;
  --canh: #9a5800;
  --canh-nhat: #fff1dc;
  --loi: #c4302b;
  --loi-nhat: #fde7e6;
  --bong: 0 1px 2px rgba(18, 27, 46, 0.06), 0 6px 20px -14px rgba(18, 27, 46, 0.35);
  --bo: 12px;
  --phong: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic UI', sans-serif;
  --phong-ma: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --nen: #0d121c;
    --the: #151c2a;
    --muc: #e6eaf2;
    --muc-phu: #9aa4b8;
    --vien: #283247;
    --vien-nhat: #1e2738;
    --accent: #6e8fff;
    --accent-dam: #92abff;
    --accent-nhat: #1b2644;
    --chu-tren-accent: #0b1020;
    --ok: #4cc98a;
    --ok-nhat: #10301f;
    --canh: #f0b35a;
    --canh-nhat: #372710;
    --loi: #ff7a73;
    --loi-nhat: #3a1614;
    --bong: 0 1px 2px rgba(0, 0, 0, 0.45), 0 8px 24px -16px rgba(0, 0, 0, 0.9);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--nen);
  color: var(--muc);
  font-family: var(--phong);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  /* chừa tai thỏ / thanh home của iPhone khi chạy toàn màn hình */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}
a {
  color: var(--accent);
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
[hidden] {
  display: none !important;
}

.khung {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.khung--rong {
  max-width: 1120px;
}

/* ---------------- đầu trang */
.dau {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 2px 2px;
}
.dau img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex: none;
}
.dau h1 {
  margin: 0;
  font-size: 1.28rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.dau p {
  margin: 2px 0 0;
  color: var(--muc-phu);
  font-size: 0.82rem;
}
.dau .day {
  margin-left: auto;
  font-size: 0.82rem;
  white-space: nowrap;
}

/* ---------------- thẻ */
.the {
  background: var(--the);
  border: 1px solid var(--vien);
  border-radius: var(--bo);
  box-shadow: var(--bong);
  padding: 14px 16px;
}
.the h2 {
  margin: 0 0 8px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muc-phu);
  font-weight: 700;
}

/* hàng nhãn — giá trị */
.hang {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--vien-nhat);
  min-height: 42px;
}
.hang:first-of-type {
  border-top: 0;
}
.hang > span:first-child {
  color: var(--muc-phu);
  font-size: 0.9rem;
  white-space: nowrap; /* nhãn giữ một dòng, giá trị dài tự xuống dòng */
}
.hang .gt {
  text-align: right;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.ma {
  font-family: var(--phong-ma);
  font-size: 0.82rem;
  font-weight: 500;
}

/* chip trạng thái: màu + chấm — đọc được cả khi mù màu nhờ chữ đi kèm */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px 2px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  background: var(--vien-nhat);
  color: var(--muc-phu);
}
.chip::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.chip.ok {
  background: var(--ok-nhat);
  color: var(--ok);
}
.chip.canh {
  background: var(--canh-nhat);
  color: var(--canh);
}
.chip.loi {
  background: var(--loi-nhat);
  color: var(--loi);
}

.so-badge {
  font-variant-numeric: tabular-nums;
  font-size: 1.1rem;
}
.phu {
  display: block;
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--muc-phu);
}

/* ---------------- ô nhập */
.o {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.o > span {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muc-phu);
}
.o input,
.o textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--vien);
  border-radius: 10px;
  background: var(--nen);
}
.o textarea {
  min-height: 84px;
  resize: vertical;
}
.o input:focus,
.o textarea:focus {
  border-color: var(--accent);
  background: var(--the);
  outline: none;
}
.o small {
  color: var(--muc-phu);
  font-size: 0.76rem;
}

/* ---------------- nút */
.nut-cot {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.nut-doi {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.nut {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--vien);
  background: var(--the);
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, transform 0.05s;
  -webkit-tap-highlight-color: transparent;
}
.nut:active {
  transform: scale(0.99);
}
.nut:hover {
  border-color: var(--accent);
}
.nut.chinh {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--chu-tren-accent);
}
.nut.chinh:hover {
  background: var(--accent-dam);
  border-color: var(--accent-dam);
}
.nut.nguy {
  color: var(--loi);
}
.nut.nguy:hover {
  border-color: var(--loi);
}
.nut:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
.nut .so-thu-tu {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 0.74rem;
  background: rgba(255, 255, 255, 0.22);
}
.nut:not(.chinh) .so-thu-tu {
  background: var(--accent-nhat);
  color: var(--accent);
}

/* ---------------- lời nhắn */
.nhan {
  border-radius: var(--bo);
  padding: 12px 14px;
  font-size: 0.9rem;
  border: 1px solid transparent;
}
.nhan b {
  display: block;
  margin-bottom: 4px;
}
.nhan ol {
  margin: 6px 0 0;
  padding-left: 1.2em;
}
.nhan.canh {
  background: var(--canh-nhat);
  border-color: color-mix(in srgb, var(--canh) 30%, transparent);
}
.nhan.loi {
  background: var(--loi-nhat);
  border-color: color-mix(in srgb, var(--loi) 30%, transparent);
}
.nhan.ok {
  background: var(--ok-nhat);
  border-color: color-mix(in srgb, var(--ok) 30%, transparent);
}
.nhan.tin {
  background: var(--accent-nhat);
  border-color: color-mix(in srgb, var(--accent) 25%, transparent);
}

/* dòng trạng thái thao tác (aria-live) */
.dong-tin {
  margin: 0;
  min-height: 1.4em;
  font-size: 0.86rem;
  color: var(--muc-phu);
  text-align: center;
}
.dong-tin.loi {
  color: var(--loi);
  font-weight: 600;
}
.dong-tin.ok {
  color: var(--ok);
  font-weight: 600;
}

/* ---------------- danh sách thông báo gần đây */
.ds-tin {
  list-style: none;
  margin: 0;
  padding: 0;
}
.ds-tin li {
  padding: 10px 0;
  border-top: 1px solid var(--vien-nhat);
}
.ds-tin li:first-child {
  border-top: 0;
}
.ds-tin .tieu-de {
  font-weight: 700;
}
.ds-tin .noi-dung {
  color: var(--muc-phu);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}
.ds-tin time {
  font-size: 0.74rem;
  color: var(--muc-phu);
  font-variant-numeric: tabular-nums;
}
.trong {
  color: var(--muc-phu);
  font-size: 0.88rem;
  text-align: center;
  padding: 12px 0;
}

/* ---------------- trang nhân viên (index.html): thẻ chính đổi màu theo tình huống */
.the-chinh {
  --mau: var(--accent);
  --mau-nhat: var(--accent-nhat);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 18px 18px;
  text-align: center;
  border-top: 4px solid var(--mau);
}
.the-chinh[data-kieu='ok'] {
  --mau: var(--ok);
  --mau-nhat: var(--ok-nhat);
}
.the-chinh[data-kieu='canh'] {
  --mau: var(--canh);
  --mau-nhat: var(--canh-nhat);
}
.the-chinh[data-kieu='loi'] {
  --mau: var(--loi);
  --mau-nhat: var(--loi-nhat);
}
.vong-bieu-tuong {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--mau-nhat);
  color: var(--mau);
}
/* .the-chinh đứng trước để thắng quy tắc .the h2 (tiêu đề nhỏ viết hoa của thẻ thường) */
.the-chinh .tieu-de-lon {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.4;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 800;
  color: var(--muc);
}
.the-chinh .dong-tin:empty {
  display: none;
}
/* Tiếng Nhật không viết hoa — text-transform làm「iPhone」thành「IPHONE」 */
html[lang='ja'] .the h2 {
  text-transform: none;
  letter-spacing: 0.02em;
  font-size: 0.86rem;
}
.mo-ta {
  margin: 0;
  max-width: 36em;
  color: var(--muc-phu);
  font-size: 0.92rem;
}
.ma-nv {
  margin: 0;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--nen);
  color: var(--muc-phu);
  font-size: 0.86rem;
}
.ma-nv b {
  margin-left: 6px;
  color: var(--muc);
  font-variant-numeric: tabular-nums;
}
.o-thu {
  width: 100%;
  text-align: left;
}
.nut-lon {
  width: 100%;
  min-height: 54px;
  font-size: 1.05rem;
}
.buoc-so {
  margin: 0;
  padding-left: 1.4em;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.buoc-so li::marker {
  font-weight: 800;
  color: var(--accent);
}
.bieu-tuong-chia-se {
  vertical-align: -3px;
  color: var(--accent);
}
.phu-chu {
  margin: 10px 0 0;
  font-size: 0.82rem;
  color: var(--muc-phu);
}
.ds-tin .mo-tin {
  display: inline-block;
  margin-left: 10px;
  font-size: 0.8rem;
  font-weight: 700;
}
.chan-trang {
  margin: 0;
  text-align: center;
  font-size: 0.74rem;
  color: var(--muc-phu);
}

/* ---------------- admin */
.luoi-admin {
  display: grid;
  gap: 14px;
}
@media (min-width: 900px) {
  .luoi-admin {
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    align-items: start;
  }
}
.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chon-dich {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.chon-dich label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--vien);
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}
.chon-dich input {
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
  margin: 0;
}
.chon-dich label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-nhat);
}
.hang-khoa {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.hang-khoa .o {
  flex: 1 1 240px;
}
.hang-khoa .nut {
  min-height: 44px;
}
.nho-khoa {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muc-phu);
}
p.nho-khoa {
  display: block;
  margin: 0 0 10px;
}
.hang-khoa .o-hep {
  flex: 0 1 110px;
}
.ket-ve {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ket-ve pre {
  margin: 0;
  padding: 10px 12px;
  background: var(--nen);
  border-radius: 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.ket-ve .nut {
  text-decoration: none;
  color: inherit;
}

/* ô kết quả lớn */
.ket-qua {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.ket-qua div {
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--nen);
}
.ket-qua b {
  display: block;
  font-size: 1.6rem;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.ket-qua span {
  font-size: 0.78rem;
  color: var(--muc-phu);
  font-weight: 600;
}
.ket-qua .ok b {
  color: var(--ok);
}
.ket-qua .loi b {
  color: var(--loi);
}

/* bảng */
.cuon {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
/* Căn lề bảng theo quy ước đã chốt: tiêu đề GIỮA, cùng cỡ chữ với nội dung; số PHẢI;
   chữ dài TRÁI; mã / ngày giờ / nhãn / nút GIỮA. */
th,
td {
  text-align: left;
  padding: 8px 8px;
  border-bottom: 1px solid var(--vien-nhat);
  vertical-align: middle;
}
th {
  text-align: center;
  color: var(--muc-phu);
  font-weight: 700;
  white-space: nowrap;
  border-bottom-color: var(--vien);
}
td.so {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
td.giua {
  text-align: center;
  white-space: nowrap;
}
td.giua .phu {
  white-space: normal;
}
tr:last-child td {
  border-bottom: 0;
}
.dau-the {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.dau-the h2 {
  margin: 0;
}
.dau-the .nut {
  margin-left: auto;
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.82rem;
}
details.curl summary {
  cursor: pointer;
  font-size: 0.84rem;
  color: var(--muc-phu);
  font-weight: 600;
}
details.curl pre {
  margin: 8px 0 0;
  padding: 10px 12px;
  background: var(--nen);
  border-radius: 10px;
  font-family: var(--phong-ma);
  font-size: 0.76rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
