:root {
  --nen: #f3f6fa; --the: #ffffff; --chu: #1c2733; --mo: #5f6f80; --vien: #dbe3ec;
  --chinh: #0B4FA0; --chinh-nhat: #e6eef8; --trung: #d93025; --trung-nhat: #fde8e6;
  --chong: #8e44ad; --chong-nhat: #f3e8f8; --co: #9fc3ea; --trong: #eef2f6; --ok: #1e8e3e;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--nen); color: var(--chu); font: 14px/1.45 "Segoe UI", Roboto, Arial, sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--vien); background: var(--the); border-radius: 6px; padding: 6px 12px; }
button:hover { border-color: var(--chinh); }
button.chinh { background: var(--chinh); border-color: var(--chinh); color: #fff; }
button.chinh:hover { filter: brightness(1.1); }
button.nguy { color: var(--trung); }
button:disabled { opacity: .55; cursor: default; }
input[type=text], input[type=password], input[type=date], input[type=search], select {
  border: 1px solid var(--vien); border-radius: 6px; padding: 6px 9px; background: #fff; min-width: 0;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--chinh); outline-offset: 1px; }
.tai { padding: 40px; text-align: center; color: var(--mo); }
.an { display: none !important; }

/* đăng nhập */
.khung-dn { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.the-dn { background: var(--the); width: 100%; max-width: 380px; border-radius: 12px; box-shadow: 0 8px 30px rgba(11,79,160,.12); overflow: hidden; }
.the-dn .dau { background: var(--chinh); color: #fff; padding: 20px 24px; }
.the-dn .dau h1 { margin: 0; font-size: 19px; }
.the-dn .dau p { margin: 4px 0 0; opacity: .85; font-size: 13px; }
.the-dn form { padding: 20px 24px 24px; display: flex; flex-direction: column; gap: 12px; }
.the-dn label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--mo); }
.the-dn button.chinh { padding: 9px; margin-top: 4px; }
.loi { color: var(--trung); background: var(--trung-nhat); border-radius: 6px; padding: 7px 10px; font-size: 13px; }
.goiy { color: var(--mo); font-size: 12.5px; margin: 0; }

/* thanh trên */
.thanh { background: var(--chinh); color: #fff; padding: 10px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 5; }
.thanh h1 { margin: 0; font-size: 17px; margin-right: auto; white-space: nowrap; }
.thanh .nhom { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.thanh button { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.35); color: #fff; }
.thanh button:hover { background: rgba(255,255,255,.22); border-color: #fff; }
.thanh select, .thanh input { border-color: transparent; color: var(--chu); background: #fff; }
.thanh select { max-width: 260px; }
.menu { position: relative; }
.menu .ds { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; color: var(--chu); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.15); min-width: 200px; padding: 6px; z-index: 20; }
.menu .ds button { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--chu); padding: 8px 10px; }
.menu .ds button:hover { background: var(--chinh-nhat); }
.menu .ds .ai { padding: 6px 10px 8px; border-bottom: 1px solid var(--vien); margin-bottom: 4px; font-size: 12.5px; color: var(--mo); }

main { padding: 16px; max-width: 1500px; margin: 0 auto; }
.o-so { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 14px; }
.o { background: var(--the); border: 1px solid var(--vien); border-radius: 10px; padding: 10px 14px; }
.o .so { font-size: 24px; font-weight: 600; }
.o .nhan { color: var(--mo); font-size: 12.5px; }
.o.do .so { color: var(--trung); } .o.tim .so { color: var(--chong); }
.cong-cu { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.cong-cu input[type=search] { flex: 1 1 220px; max-width: 360px; }
.cong-cu .phai { margin-left: auto; color: var(--mo); font-size: 12.5px; }
.chu-giai { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--mo); }
.chu-giai i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; }

.bang { background: var(--the); border: 1px solid var(--vien); border-radius: 10px; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--vien); white-space: nowrap; }
th { background: #f7f9fc; font-weight: 600; font-size: 12.5px; color: var(--mo); position: sticky; top: 0; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--chinh-nhat); }
tr.canh td:first-child { box-shadow: inset 3px 0 0 var(--trung); }
td.so { text-align: right; font-variant-numeric: tabular-nums; }
.nv-ten { font-weight: 600; } .nv-phu { color: var(--mo); font-size: 12px; }
.huy { display: inline-block; min-width: 26px; text-align: center; border-radius: 10px; padding: 1px 8px; font-weight: 600; font-size: 12.5px; }
.huy.do { background: var(--trung-nhat); color: var(--trung); } .huy.tim { background: var(--chong-nhat); color: var(--chong); }
.dai { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; min-width: 360px; }
.dai span { height: 18px; border-radius: 2px; background: var(--trong); }
.dai span.g1 { background: var(--co); } .dai span.g2 { background: var(--chong); } .dai span.g3 { background: var(--trung); }
.thuoc { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; min-width: 360px; font-size: 10px; color: var(--mo); font-weight: 400; }
.thuoc span { text-align: center; }
.trong-rong { padding: 30px; text-align: center; color: var(--mo); }

/* ngăn chi tiết */
.man { position: fixed; inset: 0; background: rgba(15,30,50,.35); z-index: 30; }
.ngan { position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 100%); background: var(--nen); z-index: 31; display: flex; flex-direction: column; box-shadow: -8px 0 30px rgba(0,0,0,.18); }
.ngan .dau { background: var(--the); padding: 14px 16px; border-bottom: 1px solid var(--vien); display: flex; gap: 10px; align-items: flex-start; }
.ngan .dau h2 { margin: 0; font-size: 17px; }
.ngan .dau .nv-phu { margin-top: 2px; }
.ngan .dau button { margin-left: auto; }
.ngan .than { overflow-y: auto; padding: 14px 16px 30px; display: flex; flex-direction: column; gap: 10px; }
.truc { background: var(--the); border: 1px solid var(--vien); border-radius: 10px; padding: 10px 12px; }
.truc .khoang { font-size: 12.5px; color: var(--mo); margin-top: 6px; }
.phieu { background: var(--the); border: 1px solid var(--vien); border-radius: 10px; padding: 10px 12px; }
.phieu.trung { border-left: 4px solid var(--trung); } .phieu.chong { border-left: 4px solid var(--chong); }
.phieu .hang { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.phieu .gio { font-weight: 600; font-variant-numeric: tabular-nums; }
.phieu .loai { color: var(--mo); }
.phieu .bn { margin-top: 2px; }
.nhan-nho { font-size: 11.5px; border-radius: 4px; padding: 1px 6px; font-weight: 600; }
.nhan-nho.do { background: var(--trung-nhat); color: var(--trung); }
.nhan-nho.tim { background: var(--chong-nhat); color: var(--chong); }
.nhan-nho.xanh { background: var(--chinh-nhat); color: var(--chinh); }
.voi { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.voi li { margin: 2px 0; }
.phieu a { color: var(--chinh); font-size: 12.5px; }
/* tương tác thuốc */
.huy.vang { background: #fef3e0; color: #b05a00; } .o.vang .so { color: #b05a00; }
.phieu.cn { border-left: 4px solid #e8a33d; }
.tt-nhom { margin-top: 6px; } .tt-nhom b { font-size: 13px; }
.tt-cap { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--nen); }
.tt-cap p { margin: 4px 0 0; font-size: 13.5px; line-height: 1.45; }

/* hộp thoại */
.hop { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 40; padding: 16px; background: rgba(15,30,50,.35); }
.hop form { background: var(--the); border-radius: 12px; width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.hop h2 { margin: 0 0 4px; font-size: 17px; }
.hop label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--mo); }
.hop label.dong { flex-direction: row; align-items: center; gap: 8px; color: var(--chu); }
.hop .nut { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.ds-khoa { border: 1px solid var(--vien); border-radius: 6px; max-height: 220px; overflow-y: auto; padding: 4px 8px; }
.ds-khoa label { flex-direction: row; align-items: center; gap: 8px; color: var(--chu); padding: 3px 0; }

.trang-tk h2 { font-size: 18px; margin: 0; }
.trang-tk .cong-cu { margin: 4px 0 12px; }
td .nut-nho { padding: 3px 9px; font-size: 12.5px; }
.trangthai-tk { font-size: 12px; }

/* tab chức năng */
.tab-chinh { flex-basis: 100%; display: flex; gap: 4px; margin: 2px 0 -10px; overflow-x: auto; }
.thanh .tab-chinh button { border: 0; border-radius: 8px 8px 0 0; background: transparent; color: rgba(255,255,255,.85); padding: 7px 14px; white-space: nowrap; }
.thanh .tab-chinh button:hover { background: rgba(255,255,255,.15); color: #fff; }
.thanh .tab-chinh button.chon { background: var(--nen); color: var(--chinh); font-weight: 600; }
.tab-phu { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.tab-phu button { border-radius: 16px; padding: 5px 14px; }
.tab-phu button.chon { background: var(--chinh); border-color: var(--chinh); color: #fff; }
.o.bam { cursor: pointer; } .o.bam:hover { border-color: var(--chinh); }
.thanh .nhan-gio { display: flex; align-items: center; gap: 4px; font-size: 13px; }
input[type=time] { border: 1px solid var(--vien); border-radius: 6px; padding: 5px 7px; background: #fff; }
.nhan-nho.ok { background: #e6f4ea; color: var(--ok); }
.nhan-nho.vang { background: #fef3e0; color: #b05a00; }
td.xuong { white-space: normal; min-width: 140px; }
td.ghi-chu { max-width: 420px; }
.tom { margin: 0 0 8px; }

/* kết nối CSDL HIS */
.the-dn .nut { display: flex; gap: 8px; justify-content: flex-end; }
.the-csdl { background: var(--the); border: 1px solid var(--vien); border-radius: 10px; max-width: 560px; margin-top: 12px; }
.the-csdl form { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.the-csdl label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--mo); }
.the-csdl .nut { display: flex; justify-content: flex-end; gap: 8px; }
.the-csdl .tom { margin: 0; padding: 7px 10px; border-radius: 6px; background: var(--chinh-nhat); color: var(--chinh); font-size: 13px; }
.the-csdl .tom.canh { background: var(--trung-nhat); color: var(--trung); }
.the-csdl .goiy { font-size: 12px; }
.the-csdl input[type=number] { border: 1px solid var(--vien); border-radius: 6px; padding: 6px 9px; background: #fff; width: 110px; }
.the-csdl label.dong { flex-direction: row; align-items: center; gap: 8px; color: var(--chu); }
.phan-csdl { margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--vien); font-size: 12.5px; font-weight: 600; color: var(--mo); }
.hang-csdl { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-end; }
.kq-csdl { font-size: 13px; color: var(--mo); overflow-wrap: anywhere; }
.kq-csdl.tot { color: var(--ok); }
.kq-csdl.xau { color: var(--trung); }

/* cài đặt hiển thị & y lệnh */
.the-cd { background: var(--the); border: 1px solid var(--vien); border-radius: 10px; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.the-cd .cong-cu { margin: 0; }
.the-cd .goiy { margin: 0; font-size: 12.5px; max-width: 900px; }
.the-cd label.dong { display: flex; align-items: center; gap: 8px; }
.the-cd .bang { max-height: 60vh; overflow: auto; }
.ds-khoa.ds-cao { max-height: 55vh; columns: 2 320px; column-gap: 24px; }
.ds-khoa.ds-cao label { display: flex; break-inside: avoid; font-size: 13.5px; }
.ds-khoa.ds-cao label.an { display: none; }
.ds-khoa.mo { opacity: .6; }
.ds-khoa label.an { display: none; }
tr.mo td { color: var(--mo); background: #f6f7f9; }
input.o-phut { width: 80px; border: 1px solid var(--vien); border-radius: 6px; padding: 4px 7px; background: #fff; }
input.o-phut:disabled { background: #f1f3f6; color: var(--mo); }
input.o-phut.sai { border-color: var(--trung); box-shadow: 0 0 0 1px var(--trung); }
.chan-cd { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; border-top: 1px solid var(--vien); padding-top: 10px; }
.chan-cd .nut { display: flex; gap: 8px; margin-left: auto; }

/* sơ đồ giường */
.so-do { background: var(--the); border: 1px solid var(--vien); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.so-do h3 { margin: 0 0 4px; font-size: 15px; color: var(--chinh); }
.so-do .phong { font-size: 12.5px; color: var(--mo); font-weight: 600; margin: 8px 0 4px; }
.luoi-giuong { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.giuong { border: 1px solid var(--vien); border-radius: 8px; padding: 6px 8px; background: #fff; display: flex; flex-direction: column; gap: 4px; min-height: 64px; }
.giuong[role=button] { cursor: pointer; } .giuong[role=button]:hover { border-color: var(--chinh); box-shadow: 0 2px 8px rgba(11,79,160,.12); }
.giuong.trong { background: var(--trong); }
.giuong.ghep { border-color: var(--chong); box-shadow: inset 0 0 0 1px var(--chong); }
.giuong.ngung { border-style: dashed; opacity: .8; }
.g-dau { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.g-trong { color: var(--mo); font-size: 12.5px; }
.g-bn { border-left: 3px solid var(--vien); padding: 2px 6px; border-radius: 4px; background: #f7f9fc; }
.g-bn.nam { border-left-color: #1a73e8; background: #e8f0fe; }
.g-bn.nu { border-left-color: #d6337a; background: #fde7f0; }
.g-ten { font-weight: 600; font-size: 13px; }
.g-ke { font-size: 11.5px; color: var(--mo); }
.chu-giai i.mau-nam { background: #1a73e8; } .chu-giai i.mau-nu { background: #d6337a; }
.lich-su { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.ls-ngay { font-size: 13px; } .ls-ngay b { margin-right: 6px; }
.ls-ngay .voi { margin-top: 2px; }

@media (max-width: 640px) {
  .thanh h1 { width: 100%; }
  main { padding: 12px; }
  .thanh select { max-width: 100%; flex: 1; }
}
