/* ===== Sổ sức khỏe — kiểu dáng dùng chung =====
   Ý tưởng: một trang sổ khám bệnh. Giấy sáng, mực đậm, kẻ dòng, dấu tròn xanh cho việc đã làm.
   Phía người bệnh (body.bn): chữ to, mỗi màn hình một việc. Phía người nhà (body.nha): gọn hơn. */

:root {
  --giay: #fafbf7;
  --trang: #ffffff;
  --muc: #10241c;
  --muc-nhat: #46574f;
  --ke: #c5d3cc;
  --xanh: #0a6650;
  --xanh-dam: #074a3a;
  --xanh-nhat: #ddefe8;
  --tot: #0f6b37;
  --tot-nen: #d9f0df;
  --vang: #7a4a00;
  --vang-nen: #ffedc2;
  --do: #a8231b;
  --do-nen: #fce1dd;
  --cam: #c96a00;
  --bo: 0.75em;
}

* { box-sizing: border-box; }

html {
  font-size: 17px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
/* iPhone: cỡ chữ đi theo mục "Cỡ chữ" đã cài trên máy */
@supports (font: -apple-system-body) {
  html { font: -apple-system-body; }
}

body {
  margin: 0;
  background: var(--giay);
  color: var(--muc);
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
body.bn { font-size: max(1.2rem, 20px); }
body.nha { font-size: max(1rem, 16px); padding-bottom: 5.2em; }

h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.45em; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.1em; font-weight: 700; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--xanh); }
:focus-visible { outline: 3px solid var(--xanh); outline-offset: 2px; }
[hidden] { display: none !important; }
svg.bt { width: 1.35em; height: 1.35em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.man {
  max-width: 34rem;
  margin: 0 auto;
  padding: calc(0.9em + env(safe-area-inset-top, 0px)) 0.9em calc(1.6em + env(safe-area-inset-bottom, 0px));
}
.mo { color: var(--muc-nhat); }
.nho { font-size: 0.85em; }
.cach { margin-top: 1em; }
.cach-lon { margin-top: 1.6em; }
.giua { text-align: center; }

/* ----- Nút ----- */
.nut {
  display: flex; align-items: center; justify-content: center; gap: 0.5em;
  width: 100%; min-height: 3.2em; padding: 0.5em 0.9em;
  border: 2px solid var(--xanh); border-radius: var(--bo);
  background: var(--trang); color: var(--xanh-dam);
  font-weight: 600; text-align: center; text-decoration: none; line-height: 1.25;
}
.nut:active { transform: scale(0.985); }
.nut-chinh { background: var(--xanh); color: #fff; }
.nut-chinh:active { background: var(--xanh-dam); }
.nut-lon { min-height: 3.9em; font-size: 1.1em; }
.nut-do { background: var(--do); border-color: var(--do); color: #fff; }
.nut-xam { border-color: var(--ke); color: var(--muc); }
.nut-chu { border: 0; background: none; width: auto; min-height: 2.4em; padding: 0.3em 0.4em; color: var(--xanh-dam); text-decoration: underline; font-weight: 600; }
.nut[disabled] { border-color: var(--ke); background: #eef1ee; color: var(--muc-nhat); }
.hai-nut { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6em; }

/* ----- Nhãn đánh giá: luôn có chữ đi kèm màu ----- */
.nhan { display: inline-block; padding: 0.1em 0.6em; border-radius: 99em; font-weight: 600; font-size: 0.85em; white-space: nowrap; }
.nhan-tot { background: var(--tot-nen); color: var(--tot); }
.nhan-vang { background: var(--vang-nen); color: var(--vang); }
.nhan-do { background: var(--do-nen); color: var(--do); }
.nhan-xam { background: #e8ede9; color: var(--muc-nhat); }
.chu-tot { color: var(--tot); } .chu-vang { color: var(--vang); } .chu-do { color: var(--do); }

/* ----- Trang chính của người bệnh ----- */
.dau-trang { padding: 0.3em 0 0.9em; border-bottom: 3px solid var(--muc); }
.dau-trang .ngay { font-weight: 600; color: var(--xanh-dam); }
.muc-tieu-de { margin: 1.1em 0 0.2em; font-weight: 700; }

.viec { list-style: none; margin: 0; padding: 0; }
.viec > li { border-bottom: 1.5px solid var(--ke); }
.viec-dong {
  display: grid; grid-template-columns: 2.5em 1fr; gap: 0.7em; align-items: center;
  width: 100%; padding: 0.75em 0.5em; text-align: left;
  background: none; border: 0;
}
.viec-dong .lam { display: block; }
.viec > li > .nut-chu { margin-top: -0.4em; }
.viec-dong .ten { font-weight: 600; }
.viec-dong .them { color: var(--muc-nhat); font-size: 0.88em; }
.dau-tron {
  width: 2.3em; height: 2.3em; border-radius: 50%;
  border: 2.5px solid var(--muc-nhat); display: grid; place-items: center; color: transparent; background: var(--trang);
}
.viec-dong.xong .dau-tron { background: var(--tot); border-color: var(--tot); color: #fff; }
.viec-dong.xong .ten { color: var(--muc-nhat); }
.viec-dong.ke-tiep { background: var(--xanh-nhat); border: 2.5px solid var(--xanh); border-radius: var(--bo); margin: 0.35em 0; }
.viec-dong.ke-tiep .dau-tron { border-color: var(--xanh); }
.viec-dong.ke-tiep .lam { color: var(--xanh-dam); font-weight: 700; }
.nuoc-hang { padding: 0.75em 0.5em; }
.vach { display: flex; gap: 3px; margin-top: 0.4em; }
.vach i { flex: 1; height: 0.55em; border-radius: 2px; background: #dfe6e2; }
.vach i.day { background: var(--xanh); }

.hang-tt {
  display: grid; grid-template-columns: 1fr auto; gap: 0.5em; align-items: center;
  width: 100%; padding: 0.85em 0.9em; text-align: left;
  background: var(--trang); border: 1.5px solid var(--ke); border-radius: var(--bo);
}
.chan-trang { padding-top: 0.9em; border-top: 1.5px solid var(--ke); color: var(--muc-nhat); }

.hop-do { background: var(--do-nen); border: 2.5px solid var(--do); border-radius: var(--bo); padding: 0.9em; color: var(--do); }
.hop-do p { font-weight: 600; margin-bottom: 0.7em; }
.hop-vang { background: var(--vang-nen); border: 1.5px solid #d9b25c; border-radius: var(--bo); padding: 0.7em 0.9em; color: var(--vang); }
.hop-xanh { background: var(--xanh-nhat); border-radius: var(--bo); padding: 0.7em 0.9em; color: var(--xanh-dam); }

/* ----- Thanh dưới cùng: nút "Trang chính" cố định, cùng một chỗ ở mọi màn hình con ----- */
.thanh-duoi {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 4;
  background: var(--giay); border-top: 1.5px solid var(--ke);
  padding: 0.5em 0.9em calc(0.5em + env(safe-area-inset-bottom, 0px));
}
.thanh-duoi .nut { max-width: 32.2rem; margin: 0 auto; min-height: 3em; border-color: var(--muc-nhat); color: var(--muc); }
.man.co-thanh-duoi { padding-bottom: calc(5.4em + env(safe-area-inset-bottom, 0px)); }

/* ----- Thanh trên (không còn dùng ở phía người bệnh) ----- */
.thanh-tren { display: flex; align-items: center; gap: 0.5em; margin-bottom: 0.9em; }
.thanh-tren .nut { width: auto; min-height: 2.9em; padding: 0.4em 0.9em 0.4em 0.6em; border-color: var(--ke); color: var(--muc); }

/* ----- Nhập số bằng bàn phím to ----- */
.so-lon { font-size: 3.1em; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; min-height: 1.15em; }
.o-so { border: 2.5px solid var(--xanh); border-radius: var(--bo); background: var(--trang); padding: 0.4em 0.6em; text-align: center; }
.ban-phim { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.45em; }
.phim { min-height: 2.5em; font-size: 1.5em; font-weight: 600; background: var(--trang); border: 1.5px solid var(--ke); border-radius: var(--bo); font-variant-numeric: tabular-nums; }
.phim:active { background: var(--xanh-nhat); }
.phim.chu { font-size: 1em; }

/* ----- Trò chuyện ----- */
.tin-ds { display: flex; flex-direction: column; gap: 0.7em; }
.tin { max-width: 92%; padding: 0.7em 0.9em; border-radius: var(--bo); white-space: pre-wrap; overflow-wrap: anywhere; }
.tin-troly { align-self: flex-start; background: var(--trang); border: 1.5px solid var(--ke); }
.tin-toi { align-self: flex-end; background: var(--xanh-nhat); color: var(--xanh-dam); }
.tin .duoi { display: flex; gap: 0.4em; margin-top: 0.5em; }
.tin .duoi .nut { width: auto; min-height: 2.5em; padding: 0.2em 0.8em; font-size: 0.88em; border-color: var(--ke); color: var(--muc); }
.ngay-chia { align-self: center; color: var(--muc-nhat); font-size: 0.85em; }
.goi-y { display: grid; gap: 0.5em; }
.goi-y .nut { justify-content: flex-start; text-align: left; font-weight: 500; border-width: 1.5px; }
.khung-gui { position: sticky; bottom: 0; background: var(--giay); padding: 0.6em 0 calc(0.4em + env(safe-area-inset-bottom, 0px)); border-top: 1.5px solid var(--ke); margin-top: 1em; }
.khung-gui textarea { width: 100%; min-height: 3.1em; max-height: 9em; padding: 0.6em 0.7em; border: 2px solid var(--muc-nhat); border-radius: var(--bo); background: var(--trang); resize: none; display: block; }
.khung-gui .o-gui { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.45em; align-items: stretch; }
.khung-gui .o-gui .nut { width: auto; min-width: 4.4em; flex-direction: column; gap: 0.1em; padding: 0.3em 0.6em; font-size: 0.9em; }
.khung-gui .hai-nut { margin-top: 0.5em; grid-template-columns: 1.2fr 1fr; }
.khung-gui .hai-nut .nut, .khung-gui .ba-nut .nut { border-color: var(--muc-nhat); color: var(--muc); }
/* Thanh dưới cùng khi có nút tiếng: ba nút, biểu tượng trên, chữ dưới */
.khung-gui .ba-nut { display: grid; grid-template-columns: 1.2fr 0.9fr 1.1fr; gap: 0.45em; margin-top: 0.5em; }
.khung-gui .ba-nut .nut { flex-direction: column; gap: 0.1em; min-height: 3.5em; padding: 0.35em 0.2em; font-size: 0.9em; }
body.bn .thong-bao { bottom: 11.5em; }
.dang-nghe { background: var(--do) !important; border-color: var(--do) !important; color: #fff !important; }
.cham { display: inline-flex; gap: 0.3em; vertical-align: middle; }
.cham i { width: 0.45em; height: 0.45em; border-radius: 50%; background: var(--xanh); animation: nhay 1.2s infinite ease-in-out; }
.cham i:nth-child(2) { animation-delay: 0.2s; } .cham i:nth-child(3) { animation-delay: 0.4s; }
@keyframes nhay { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .cham i { animation: none; opacity: 0.7; } .nut:active { transform: none; } }

.van-ban p { margin-bottom: 0.8em; }
.ds-phieu { list-style: none; margin: 0; padding: 0; }
.ds-phieu li { padding: 0.7em 0.2em; border-bottom: 1.5px solid var(--ke); display: grid; grid-template-columns: 1fr auto; gap: 0.5em; align-items: center; }
input.to { width: 100%; min-height: 3.2em; padding: 0.4em 0.7em; font-size: 1.5em; text-align: center; letter-spacing: 0.2em; border: 2.5px solid var(--xanh); border-radius: var(--bo); background: var(--trang); }

/* Dòng chỉ số xét nghiệm trên máy người bệnh: con số to hơn, dòng thoáng hơn */
.bn .dong { padding: 0.8em 0.2em; }
.bn .dong .gt { font-size: 1.55em; line-height: 1.25; }
.bn .dong .gt .nhan { font-size: 0.55em; font-weight: 600; }

/* ----- Nhịp uống nước trên trang chính ----- */
.nuoc-hang .nhip { margin-top: 0.45em; font-weight: 600; }

/* ----- Lịch sử hằng ngày ----- */
.luoi-ngay { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.3em; }
.o-ngay {
  display: grid; justify-items: center; align-content: center; gap: 0.05em; min-height: 3.5em; padding: 0.2em 0;
  border: 1.5px solid var(--ke); border-radius: 0.5em; background: var(--trang); color: var(--muc); line-height: 1.15;
}
.o-ngay .thu { font-size: 0.6em; font-weight: 600; }
.o-ngay .so { font-size: 0.95em; font-weight: 700; font-variant-numeric: tabular-nums; }
.o-ngay .ky { font-size: 0.7em; font-weight: 700; }
.o-ngay.tot { background: var(--tot-nen); border-color: var(--tot); color: var(--tot); }
.o-ngay.vang { background: var(--vang-nen); border-color: var(--cam); color: var(--vang); }
.o-ngay.do { background: var(--do-nen); border-color: var(--do); color: var(--do); }
.o-ngay.xam { border-style: dashed; border-color: var(--muc-nhat); }

.the-ngay {
  margin-top: 0.7em; padding: 0.65em 0.8em 0.7em;
  background: var(--trang); border: 1.5px solid var(--ke); border-left: 0.45em solid var(--ke); border-radius: 0.5em;
}
.the-ngay.tot { border-left-color: var(--tot); }
.the-ngay.vang { border-left-color: var(--cam); }
.the-ngay.do { border-left-color: var(--do); }
.the-ngay.xam { border-left-color: var(--muc-nhat); }
.the-ngay.chon { outline: 3px solid var(--xanh); outline-offset: 2px; }
.the-ngay .dau { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.3em 0.6em; margin-bottom: 0.35em; }
.the-ngay .dau h2 { font-size: 1.05em; }
.dong-ls { display: grid; grid-template-columns: 1.45em minmax(0, 1fr); gap: 0.5em; align-items: start; padding: 0.22em 0; }
.dong-ls .ten { font-weight: 600; }
.dong-ls .ky {
  width: 1.35em; height: 1.35em; margin-top: 0.08em; border-radius: 50%;
  display: grid; place-items: center; font-size: 0.8em; font-weight: 700; color: #fff; background: var(--muc-nhat);
}
.dong-ls .ky.tot { background: var(--tot); }
.dong-ls .ky.vang { background: var(--cam); }
.dong-ls .ky.do { background: var(--do); }
.dong-ls .ky.xam { background: #e8ede9; color: var(--muc-nhat); }

/* ===================== Người nhà ===================== */
.nha .man { max-width: 46rem; }
.nha h1 { font-size: 1.35em; }
.dieu-huong {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--trang); border-top: 1.5px solid var(--ke);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.dieu-huong button { border: 0; background: none; padding: 0.55em 0.1em 0.5em; font-size: 0.72em; white-space: nowrap; font-weight: 600; color: var(--muc-nhat); display: grid; justify-items: center; gap: 0.15em; }
.dieu-huong button.chon { color: var(--xanh-dam); box-shadow: inset 0 3px 0 var(--xanh); }

.luoi { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5em, 1fr)); gap: 0.6em; }
.o { text-align: left; background: var(--trang); border: 1.5px solid var(--ke); border-radius: var(--bo); padding: 0.7em 0.8em; display: block; width: 100%; }
.o .ten { font-size: 0.82em; color: var(--muc-nhat); font-weight: 600; }
.o .so { font-size: 1.9em; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.o .ghi { font-size: 0.82em; }
.o.do { border-color: var(--do); background: var(--do-nen); }
.o.vang { border-color: #d9b25c; background: var(--vang-nen); }

.dong { display: grid; grid-template-columns: 1fr auto; gap: 0.6em; align-items: center; padding: 0.7em 0.2em; border-bottom: 1.5px solid var(--ke); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; }
.dong .phu { font-size: 0.85em; color: var(--muc-nhat); }
.dong .gt { font-weight: 700; font-size: 1.15em; font-variant-numeric: tabular-nums; text-align: right; }
.khoi { background: var(--trang); border: 1.5px solid var(--ke); border-radius: var(--bo); padding: 0.8em 0.9em; }
.nha .nut { min-height: 2.8em; }
.nha .nut-nho { width: auto; min-height: 2.3em; padding: 0.2em 0.8em; font-size: 0.9em; }
.hang-nut { display: flex; flex-wrap: wrap; gap: 0.5em; }
.hang-nut .nut { width: auto; flex: 1 1 8em; }

.truong { display: block; margin-top: 0.7em; }
.truong > span { display: block; font-size: 0.85em; font-weight: 600; color: var(--muc-nhat); margin-bottom: 0.2em; }
.truong input, .truong select, .truong textarea, .o-nho {
  width: 100%; min-height: 2.7em; padding: 0.4em 0.6em;
  border: 1.5px solid var(--muc-nhat); border-radius: 0.5em; background: var(--trang);
}
.truong textarea { min-height: 6em; line-height: 1.45; }
.hai-cot { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.7em; }
.bon-cot { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 0.5em; }

.bang-cuon { overflow-x: auto; }
table.bang { border-collapse: collapse; width: 100%; font-size: 0.9em; }
table.bang th { text-align: left; font-size: 0.85em; color: var(--muc-nhat); padding: 0.3em 0.25em; }
table.bang td { padding: 0.2em 0.25em; border-top: 1px solid var(--ke); }
table.bang input { width: 100%; min-width: 3.6em; min-height: 2.3em; padding: 0.2em 0.35em; border: 1.5px solid var(--ke); border-radius: 0.4em; background: var(--trang); }
table.bang td.cao input { border-color: var(--do); background: var(--do-nen); }
table.bang td.thap input { border-color: #d9b25c; background: var(--vang-nen); }

details.muc { border-bottom: 1.5px solid var(--ke); }
details.muc > summary { padding: 0.85em 0.2em; font-weight: 700; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 0.5em; }
details.muc > summary::-webkit-details-marker { display: none; }
details.muc > summary::after { content: "+"; font-weight: 400; color: var(--muc-nhat); }
details.muc[open] > summary::after { content: "–"; }
details.muc > div { padding: 0 0.2em 1em; }
.ma-ghep { font-size: 2.4em; font-weight: 700; letter-spacing: 0.18em; font-variant-numeric: tabular-nums; }
.bieu-do { width: 100%; height: auto; display: block; }
.thong-bao { position: fixed; left: 0; right: 0; margin: 0 auto; width: max-content; max-width: 90vw; bottom: 6em; background: var(--muc); color: #fff; padding: 0.6em 1em; border-radius: 1em; font-weight: 600; z-index: 9; text-align: center; }