*{box-sizing:border-box}
html,body{margin:0;height:100%;background:#0d3b45}
body{font-family:system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;color:#10323b;overflow:hidden}
.stage{position:absolute;inset:0;width:100vw;height:100vh;display:flex;flex-direction:column;background:linear-gradient(180deg,#e9fbff,#f8fdff);font-size:min(1.02vw,1.81vh)}
/* màn hình rộng hơn 16:9 (máy tính, TV siêu rộng): trải hết bề ngang, chữ theo chiều cao */
@media(min-aspect-ratio:16/9){.stage{font-size:min(1.02vw,1.9vh)}}
.tv-head{display:flex;align-items:center;gap:1.5em;padding:.7em 1.4em;background:linear-gradient(90deg,#0b7285,#15aabf);color:#fff}
.brand{display:flex;align-items:center;gap:.8em;flex:1}
.mark{display:grid;place-items:center;width:2.6em;height:2.6em;border-radius:.7em;background:#fff;color:#0b7285;font-weight:900;font-size:1.3em}
.brand strong{display:block;font-size:1.9em;letter-spacing:.03em}
.brand small{display:block;font-size:1.15em;opacity:.9}
.legend{display:flex;gap:.8em;align-items:center;font-size:1.05em;font-weight:700}
.lg{padding:.3em .8em;border-radius:99em;background:#fff}
.lg.near{color:#d9480f;border:.18em solid #fd7e14}
.lg.late{color:#fff;background:#fa2e2e;animation:blinkop 1s steps(2,start) infinite}
@keyframes blinkop{50%{opacity:.35}}
.pageinfo{opacity:.9}
.clock{text-align:right}
.clock b{display:block;font-size:3em;line-height:1;font-variant-numeric:tabular-nums}
.clock small{font-size:1.1em;opacity:.9}
.tv-grid{flex:1;min-height:0;overflow:hidden;padding:1em 1.2em;display:grid;gap:1em;align-content:start}
.tv-card{background:#fff;border-radius:1em;padding:.7em .8em;box-shadow:0 .2em .8em rgba(11,114,133,.15);border:.25em solid #99e9f2;min-width:0;overflow:hidden;display:flex;flex-direction:column}
.tv-card.near{border-color:#fd7e14;background:#fff4e6}
.tv-card.late{border-color:#e03131;background:#fff5f5;animation:blinkcard 1s steps(2,start) infinite}
.tv-card header{display:flex;gap:.7em;align-items:flex-start;margin-bottom:.4em}
.rm{flex:none;display:grid;place-items:center;min-width:2.6em;height:2.6em;padding:0 .3em;border-radius:.6em;background:#0b7285;color:#fff;font-weight:900;font-size:1.45em}
.tv-card h2{margin:0;font-size:1.55em;line-height:1.15}
.ag{font-weight:600;color:#5c7a83;font-size:.8em}
.dx{margin:.15em 0 0;font-size:1.1em;color:#37626d;font-weight:600}
.tv-sec{margin-top:.45em}
.tv-sec h4{margin:0 0 .2em;font-size:.95em;text-transform:uppercase;letter-spacing:.05em}
.tv-sec.mon h4{color:#1971c2}.tv-sec.doc h4{color:#6741d9}.tv-sec.nur h4{color:#2b8a3e}
.tv-sec ul{list-style:none;margin:0;padding:0}
.tv-sec li{display:flex;gap:.5em;align-items:baseline;font-size:1.2em;line-height:1.3;padding:.18em .4em;border-radius:.4em;margin-bottom:.15em}
.tv-sec li .tm{flex:none;font-variant-numeric:tabular-nums;color:#0b7285}
.tv-sec li small{color:#6b8790;font-size:.8em}
.tv-sec li.near{background:#ffd8a8;color:#7a2a00}
.tv-sec li.near .tm{color:#d9480f}
.tv-sec li.late{background:#e03131;color:#fff;font-weight:700;animation:blinkred 1s steps(2,start) infinite}
.tv-sec li.late .tm,.tv-sec li.late small{color:#fff}
.tv-sec li.seen{text-decoration:line-through;opacity:.5}
.tv-sec li.nd{color:#868e96;font-size:1em}
.none{color:#2b8a3e;font-weight:700;font-size:1.15em;margin:.4em 0 0}
.tv-msg{grid-column:1/-1;text-align:center;font-size:2.2em;color:#0b7285;padding:3em 1em;font-weight:700}
.tv-msg a{color:#0b7285}
.tv-msg.warn{font-size:1.2em;padding:.4em;background:#fff3bf;color:#7a5b00;border-radius:.6em}
.fs{position:absolute;right:.6em;bottom:.6em;border:0;background:rgba(11,114,133,.15);color:#0b7285;border-radius:.5em;font-size:1.4em;width:2em;height:2em;cursor:pointer;opacity:.4}
.fs:hover{opacity:1}
@keyframes blinkred{50%{background:#ff8787}}
@keyframes blinkcard{50%{border-color:#ff8787}}
.rm.long{font-size:.95em;line-height:1.05;text-align:center;min-width:3.4em}

/* ô vuông */
.tv-card header{margin-bottom:.35em}
.tv-card .who{min-width:0}
.tv-card h2{font-size:1.4em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tv-card .dx{font-size:1em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tv-lines{list-style:none;margin:0;padding:0;flex:1;min-height:0;overflow:hidden}
.tv-lines li{display:flex;gap:.4em;align-items:baseline;font-size:1.08em;line-height:1.25;padding:.16em .35em;border-radius:.4em;margin-bottom:.12em}
.tv-lines li span{min-width:0;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
.tv-lines .tm{flex:none;font-variant-numeric:tabular-nums;color:#0b7285}
.tv-lines .tg{flex:none;font-style:normal;font-size:.62em;font-weight:900;border-radius:.35em;padding:.15em .35em;color:#fff;align-self:center}
.tg.mon{background:#1971c2}.tg.doc{background:#6741d9}.tg.nur{background:#2b8a3e}
.tv-lines li.near{background:#ffd8a8;color:#7a2a00}.tv-lines li.near .tm{color:#d9480f}
.tv-lines li.late{background:#e03131;color:#fff;font-weight:700;animation:blinkred 1s steps(2,start) infinite}
.tv-lines li.late .tm{color:#fff}
.tv-lines li.seen{text-decoration:line-through;opacity:.5}
.tv-lines li.nd{color:#868e96;font-size:.95em}
.more{flex:none;text-align:right;font-weight:800;color:#0b7285;font-size:.95em;margin-top:.15em}
.legend .lgt{display:flex;gap:.35em;align-items:center;font-size:.95em}
.legend .tg{font-style:normal;font-size:.8em;font-weight:900;border-radius:.35em;padding:.15em .4em;color:#fff;margin-left:.4em}

/* cả ô đổi màu: cam khi còn ≤ 10 phút, đỏ nhấp nháy khi quá giờ */
.tv-card.near{background:#ffe8cc;border-color:#fd7e14;box-shadow:0 0 0 .2em rgba(253,126,20,.35)}
.tv-card.near header .rm{background:#e8590c}
.tv-card.late{background:#ffe3e3;border-color:#e03131;box-shadow:0 0 0 .2em rgba(224,49,49,.35);animation:tilelate 1s steps(2,start) infinite}
.tv-card.late header .rm{background:#c92a2a}
@keyframes tilelate{50%{background:#ffa8a8;border-color:#ff8787}}

/* hiển thị đầy đủ chẩn đoán */
.tv-card .dx{white-space:normal;overflow:visible;text-overflow:clip;font-size:.98em;line-height:1.25;margin-top:.15em}
.tv-card .dx.kem{font-weight:600;color:#4b3a9a;font-size:.9em}
.tv-card .dx.kem b{color:#6741d9}
.tv-card header{flex:none}
.tv-card h2{white-space:normal}
.tv-card .dx.note{font-style:italic;font-weight:600;color:#37626d;font-size:.9em}

/* dòng bàn giao ghi đầy đủ, mỗi loại một màu: BS tím · ĐD xanh lá · Theo dõi xanh dương */
.tv-lines li{font-size:1.12em;line-height:1.28;padding:.22em .45em;border-left:.32em solid transparent;margin-bottom:.2em}
.tv-lines li span{display:block;-webkit-line-clamp:unset;overflow:visible}
.tv-lines li.doc{background:#f0ebff;border-left-color:#7048e8;color:#2b1d6b}
.tv-lines li.nur{background:#e6f8ea;border-left-color:#2f9e44;color:#12421e}
.tv-lines li.mon{background:#e3f1fd;border-left-color:#1c7ed6;color:#0b3a66}
.tv-lines li small{color:inherit;opacity:.75}
/* mức độ gấp: giữ màu loại, nhấn bằng giờ + viền */
.tv-lines li.near{border-left-color:#fd7e14;font-weight:700}
.tv-lines li.near .tm{background:#fd7e14;color:#fff;border-radius:.3em;padding:0 .25em}
.tv-lines li.late{font-weight:800;animation:none;border-left-color:#e03131}
.tv-lines li.late.doc{background:#f0ebff;color:#2b1d6b}.tv-lines li.late.nur{background:#e6f8ea;color:#12421e}.tv-lines li.late.mon{background:#e3f1fd;color:#0b3a66}
.tv-lines li.late .tm{background:#e03131;color:#fff;border-radius:.3em;padding:0 .25em;animation:tmblink 1s steps(2,start) infinite}
@keyframes tmblink{50%{background:#fff;color:#e03131}}
.tv-lines li.nd{background:#f1f3f5;border-left-color:#adb5bd;color:#6c757d}
.tv-lines .tm{color:#0b3a66}
.tv-lines li.doc .tm{color:#5f3dc4}.tv-lines li.nur .tm{color:#2b8a3e}
.tv-card h2{font-size:1.55em}
.tv-card .dx{font-size:1.05em}

/* thân: ô bệnh nhân + cột tiêm insulin riêng */
.tv-body{flex:1;min-height:0;display:flex}
.tv-body .tv-grid{flex:1;min-width:0}
.ins-panel{flex:none;width:26%;margin:1em 1.2em 1em 0;background:#fff;border-radius:1em;border:.25em solid #f59f00;box-shadow:0 .2em .8em rgba(245,159,0,.2);display:flex;flex-direction:column;overflow:hidden}
.ins-panel[hidden]{display:none}
.ins-panel h3{margin:0;padding:.45em .7em;background:linear-gradient(90deg,#f08c00,#fab005);color:#fff;font-size:1.3em;display:flex;justify-content:space-between;align-items:center;letter-spacing:.02em}
.ins-panel h3 span{font-size:.7em;background:rgba(255,255,255,.25);border-radius:99em;padding:.15em .6em}
.ins-list{list-style:none;margin:0;padding:.5em;flex:1;min-height:0;overflow:hidden}
.ins-list li{background:#fff9db;border-left:.35em solid #f59f00;border-radius:.5em;padding:.4em .55em;margin-bottom:.45em}
.ins-top{display:flex;align-items:center;gap:.45em}
.ins-time{font-size:1.35em;font-variant-numeric:tabular-nums;color:#a05a00;padding:0 .2em;border-radius:.3em}
.rm-s{background:#0b7285;color:#fff;font-weight:900;border-radius:.35em;padding:.05em .4em;font-size:.95em}
.ins-name{font-weight:800;font-size:1.1em;min-width:0}
.ins-name small{font-weight:600;color:#5c7a83}
.ins-drug{font-size:1.1em;margin-top:.15em;color:#3d2c00}
.ins-dose{color:#c92a2a;font-size:1.1em}
.ins-drug small{color:#6b5a2e}
.ins-glu{margin-top:.2em;font-weight:800;color:#c92a2a;font-size:1em}
.ins-state{margin-top:.2em;font-size:.95em;color:#495057}
.ins-list li.near{background:#ffe8cc;border-left-color:#fd7e14}
.ins-list li.near .ins-time{background:#fd7e14;color:#fff}
.ins-list li.late{background:#ffe8cc;border-left-color:#fd7e14}
.ins-list li.late .ins-time{background:#fd7e14;color:#fff;animation:none}
.ins-list li.done{background:#ebfbee;border-left-color:#2f9e44;opacity:.75}
.ins-list li.nd{background:#f1f3f5;border-left-color:#adb5bd;opacity:.8}
.ins-more{flex:none;text-align:right;font-weight:800;color:#a05a00;padding:0 .8em .5em}
/* chuyển màn hình TV */
.tv-switch{display:flex;background:rgba(255,255,255,.18);border-radius:.7em;padding:.25em;gap:.25em;flex:none}
.tv-switch a{color:#fff;text-decoration:none;font-weight:800;font-size:1.05em;padding:.35em .8em;border-radius:.5em;white-space:nowrap;opacity:.85}
.tv-switch a.on{background:#fff;color:#0b7285;opacity:1}
.tvgb .tv-switch a.on{color:#5f3dc4}
.tv-logout{position:absolute;right:3.2em;bottom:.6em;border:0;background:rgba(11,114,133,.15);color:#0b7285;border-radius:.5em;font-size:1.4em;width:2em;height:2em;cursor:pointer;opacity:.35}
.tv-logout:hover{opacity:1}
.brand strong{white-space:nowrap}
.mark{overflow:hidden;background:none!important;padding:0}.mark img{width:100%;height:100%;display:block}

/* 3 màn hình TV: thu gọn nút chuyển để đồng hồ không bị tràn */
.tv-head{min-width:0}
.tv-head .brand{min-width:0}
.tv-switch a{font-size:.95em;padding:.3em .6em}
.ico{width:1em;height:1em;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;vertical-align:-.15em}
.tv-switch a .ico{width:1.15em;height:1.15em;margin-right:.15em}
/* nút về màn hình chính */
.tv-switch .tv-home{display:flex;align-items:center;justify-content:center;padding:.35em .6em;opacity:1;background:rgba(255,255,255,.22)}
.tv-switch .tv-home:hover{background:#fff;color:#0b7285}
.tvgb .tv-switch .tv-home:hover{color:#5f3dc4}
.tv-switch .tv-home .ico{width:1.3em;height:1.3em;margin:0}

/* Ô ngày dd/mm/yyyy trên màn hình TV */
.dmy-wrap{position:relative;display:flex;gap:.3em;align-items:center;min-width:0}
.dmy-wrap>.dmy-txt{flex:1;min-width:0;width:9em}
.dmy-wrap>.dmy-real{position:absolute!important;left:0;bottom:0;width:100%!important;height:1px!important;opacity:0;pointer-events:none;border:0!important;padding:0!important;margin:0!important}
.dmy-pick{flex:none;border:0;background:rgba(255,255,255,.2);border-radius:.4em;padding:.2em .4em;cursor:pointer;font-size:1em}
.dmy-txt.dmy-bad{outline:2px solid #ff8a5b}
.ss-wrap{display:block;position:relative}.ss-native{display:none!important}
.ss-list{position:fixed;z-index:9999;overflow-y:auto;background:#fff;border:1.5px solid #1098ad;border-radius:12px;box-shadow:0 10px 28px rgba(0,0,0,.18);padding:4px}
.ss-list[hidden]{display:none}.ss-list button{display:block;width:100%;text-align:left;border:0;background:none;padding:9px 10px;border-radius:8px;font:inherit;cursor:pointer}
.ss-list button.on{background:#e3f4f7}.ss-list button.sel{font-weight:700}.ss-none{margin:0;padding:10px;color:#5b7176}
/* nút Home to hơn cho TV */
.tv-switch .tv-home{padding:.3em 1em;border-radius:.6em;background:rgba(255,255,255,.35)}
.tv-switch .tv-home .ico{width:1.9em;height:1.9em}
.tv-switch a{font-size:1.05em;padding:.35em .7em}
.tv-switch{gap:.3em}
@media(max-width:1500px){.tv-switch a{font-size:.95em;padding:.3em .55em}.tv-switch .tv-home .ico{width:1.6em;height:1.6em}.legend{display:none}}
.tv-switch a{font-size:1em;padding:.32em .6em}
.tv-switch .tv-home .ico{width:1.75em;height:1.75em}
.tv-switch .tv-home{padding:.25em .8em}
.tv-switch .tv-home .ico{width:2.3em;height:2.3em}
.tv-switch .tv-home{padding:.2em 1em}
@media(max-width:1500px){.tv-switch .tv-home .ico{width:1.9em;height:1.9em}}
/* tên bệnh nhân to hơn */
.tv-card h2,.tv-card h2{font-size:1.95em}
.tv-card h2 .ag{font-size:.6em}
.ins-name{font-size:1.45em;font-weight:900}
.ins-name small{font-size:.6em}
