/* =========================================================
   MÀN HÌNH HIỂN THỊ TRUNG TÂM (TV SẢNH) – QMS ĐA ĐIỂM · Bản demo
   Canvas thiết kế: 1920 × 1080 px (TV 65" 16:9, 1 px ≈ 0,75 mm)
   JS tự co giãn canvas cho vừa màn hình. Mọi kích thước tính theo canvas.
   ========================================================= */

:root {
  --cobalt: #0047AB;
  --cobalt-700: #003A8C;
  --cobalt-900: #002A66;
  --cobalt-50: #EAF1FB;
  --cobalt-100: #CFE0F7;
  --gold: #FFCC00;
  --orange: #FF8800;
  --orange-ink: #3D1F00;
  --red: #DA251D;
  --red-50: #FDECEA;
  --green: #1B873F;
  --amber-ink: #7A4B00;
  --red-ink: #B01E17;
  --teal-50: #E1F5EE;
  --teal-ink: #085041;

  --bg: #F5F7FA;
  --line: #DCE3EC;
  --ink: #14213D;
  --ink-2: #4A5568;

  --font: "Be Vietnam Pro", "Roboto", "Inter", "Segoe UI", sans-serif;
  /* Roboto Condensed: các chữ số rộng bằng nhau sẵn (đã kiểm tra), đúng yêu cầu "monospace" của đặc tả */
  --num: "Roboto Condensed", "Arial Narrow", "Roboto", sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.3, 1.35, .5, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font); background: radial-gradient(ellipse at 30% 20%, #16305E 0%, #0A1631 60%, #060D1F 100%); overflow: hidden; color: var(--ink); }
button, select { font: inherit; }
.ic { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.num { font-family: var(--num); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0; }

/* ---------- Sân khấu và khung TV ---------- */
.stage { height: 100vh; display: flex; align-items: center; justify-content: center; gap: 24px; padding: 16px; }
.tv-frame { position: relative; flex: none; border-radius: 10px; box-shadow: 0 0 0 12px #11151F, 0 0 0 14px #2E3648, 0 40px 80px rgba(0, 0, 0, .6); }
body.is-tv .stage { padding: 0; }
body.is-tv .tv-frame { border-radius: 0; box-shadow: none; }
body.is-tv .sim { display: none; }
body.is-tv { cursor: none; }

.tv { position: absolute; top: 0; left: 0; width: 1920px; height: 1080px; transform-origin: 0 0; background: var(--bg); overflow: hidden; border-radius: inherit; user-select: none; }

/* =========================================================
   HEADER (1152 × 120)
   ========================================================= */
.hdr {
  position: absolute; left: 0; top: 0; width: 1152px; height: 120px;
  display: flex; align-items: center; gap: 22px; padding: 0 32px;
  background: linear-gradient(100deg, var(--cobalt-900), var(--cobalt) 70%, #0A5BC9);
  border-bottom: 6px solid var(--gold); color: #fff;
}
.logo { width: 84px; height: 84px; border-radius: 50%; flex: none; background: #fff; color: var(--cobalt); border: 4px solid var(--gold); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 38px; }
.logo span { font-size: 13px; font-weight: 800; letter-spacing: .1em; line-height: 1; margin-top: 2px; }
.org { flex: 1; display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.org strong { font-size: 23px; font-weight: 800; white-space: nowrap; }
.org span { font-size: 23px; font-weight: 700; color: #FFE27A; white-space: nowrap; }
.total { flex: none; display: flex; align-items: center; gap: 10px; height: 68px; padding: 0 20px; border-radius: 34px; background: rgba(255, 255, 255, .12); font-size: 22px; font-weight: 600; white-space: nowrap; }
.total .ic { font-size: 34px; }
.total b { font-family: var(--num); font-size: 40px; font-weight: 700; color: var(--gold); }
.clock { display: flex; flex-direction: column; align-items: flex-end; line-height: 1; }
.clock b { font-family: var(--num); font-size: 64px; font-weight: 700; }
.clock span { font-size: 20px; font-weight: 500; opacity: .85; margin-top: 6px; white-space: nowrap; }

/* =========================================================
   VIDEO (1088 × 612)
   ========================================================= */
.media { position: absolute; left: 32px; top: 136px; width: 1088px; height: 612px; border-radius: 20px; overflow: hidden; background: #0B1530; }
.media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.slides { position: absolute; inset: 0; }
.slide { position: absolute; inset: 0; opacity: 0; transition: opacity 1s ease; display: flex; align-items: center; gap: 56px; padding: 0 72px; color: #fff; }
.slide.is-on { opacity: 1; }
.slide-bg { position: absolute; inset: -6%; z-index: 0; }
.slide.is-on .slide-bg { animation: kenburns 11s ease-out both; }
@keyframes kenburns { from { transform: scale(1.12) translate(2%, 1%); } to { transform: scale(1) translate(0, 0); } }
.slide-bg::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255, 255, 255, .08) 2px, transparent 2px); background-size: 26px 26px; }
.slide-ic { position: relative; z-index: 1; flex: none; width: 240px; height: 240px; border-radius: 50%; display: grid; place-items: center; font-size: 120px; background: rgba(255, 255, 255, .14); border: 4px solid rgba(255, 255, 255, .35); }
.slide.is-on .slide-ic { animation: popIn .9s var(--spring) both .2s; }
.slide-txt { position: relative; z-index: 1; }
.slide-txt small { display: block; font-size: 26px; font-weight: 700; color: #FFE27A; letter-spacing: .06em; text-transform: uppercase; }
.slide-txt h2 { font-size: 56px; font-weight: 800; line-height: 1.2; margin-top: 10px; text-wrap: balance; }
.slide-txt ul { list-style: none; margin-top: 22px; display: flex; flex-direction: column; gap: 10px; }
.slide-txt li { font-size: 30px; line-height: 1.4; padding-left: 36px; position: relative; opacity: .95; }
.slide-txt li::before { content: ""; position: absolute; left: 4px; top: 16px; width: 14px; height: 14px; border-radius: 50%; background: var(--gold); }
.slide.is-on .slide-txt > * { animation: rise .8s var(--ease) both; }
.slide.is-on .slide-txt h2 { animation-delay: .15s; }
.slide.is-on .slide-txt ul { animation-delay: .3s; }
.media-chip { position: absolute; z-index: 2; top: 20px; right: 20px; padding: 8px 16px; border-radius: 12px; background: rgba(0, 0, 0, .35); color: rgba(255, 255, 255, .85); font-size: 18px; font-weight: 600; }
.media-bar { position: absolute; z-index: 2; left: 0; right: 0; bottom: 0; height: 6px; background: rgba(255, 255, 255, .15); }
.media-bar i { display: block; height: 100%; background: var(--gold); transform-origin: left; transform: scaleX(0); }
.media.is-paused .slide-bg, .media.is-paused .slide-ic, .media.is-paused .slide-txt > *, .media.is-paused .media-bar i { animation-play-state: paused !important; }

@keyframes rise { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }

/* =========================================================
   DẢI TÌNH HÌNH HÀNG ĐỢI (1088 × 192)
   ========================================================= */
.strip { position: absolute; left: 32px; top: 764px; width: 1088px; height: 192px; }
.cards { height: 182px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.qcard { position: relative; overflow: hidden; height: 182px; padding: 12px 18px; border-radius: 20px; background: #fff; border: 2px solid var(--line); display: flex; flex-direction: column; justify-content: space-between; box-shadow: 0 14px 28px -20px rgba(0, 40, 100, .45); }
.cards.is-in .qcard { animation: cardIn .6s var(--ease) both; animation-delay: calc(var(--i) * 70ms); }
@keyframes cardIn { from { opacity: 0; transform: translateY(26px); } }
.qc-top { display: flex; align-items: center; gap: 14px; }
.qcard.is-pri { background: #FFF4E5; border-color: #FFC97A; }
.qcard.is-pri .qc-code { background: var(--orange); color: var(--orange-ink); }
.qcard.is-pri .qc-name, .qcard.is-pri .qc-mid b { color: #7A3E00; }
.qc-code { flex: none; width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: var(--cobalt); color: #fff; font-family: var(--num); font-weight: 700; font-size: 34px; }
.qc-name { font-size: 22px; font-weight: 700; line-height: 1.2; color: var(--cobalt-900); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.qc-mid { display: flex; flex-direction: column; }
.qc-mid span { font-size: 16px; font-weight: 700; letter-spacing: .06em; color: var(--ink-2); line-height: 1.2; }
.qc-mid b { font-family: var(--num); font-size: 52px; font-weight: 700; line-height: 1; color: var(--cobalt); white-space: nowrap; }
.qc-bot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 19px; font-weight: 700; white-space: nowrap; }
.qc-bot span { display: inline-flex; align-items: center; gap: 5px; }
.qc-bot .ic { font-size: 22px; }
.qc-eta { color: var(--ink-2); font-weight: 600; }
.lv-low { color: var(--green); } .lv-mid { color: var(--amber-ink); } .lv-high { color: var(--red-ink); }
.bump { animation: bump .7s var(--ease); }
@keyframes bump { 0% { transform: translateY(-12px); opacity: 0; } 100% { transform: none; opacity: 1; } }
.dots { height: 10px; display: flex; align-items: flex-end; justify-content: center; gap: 10px; }
.dots i { width: 10px; height: 10px; border-radius: 5px; background: #B7C1CE; transition: width .4s, background .4s; }
.dots i.on { width: 36px; background: var(--cobalt); }

/* =========================================================
   DANH SÁCH SỐ VỪA GỌI (768 × 972)
   ========================================================= */
.board { position: absolute; left: 1152px; top: 0; width: 768px; height: 972px; background: #fff; border-left: 2px solid var(--line); overflow: hidden; }
.board-head { height: 120px; display: flex; align-items: center; justify-content: space-between; padding: 0 40px; background: var(--cobalt-900); color: #fff; border-bottom: 6px solid var(--gold); position: relative; }
.board-head span { font-size: 36px; font-weight: 800; letter-spacing: .04em; }
.board-head small { position: absolute; left: 0; right: 0; text-align: center; font-size: 22px; font-weight: 500; color: #FFE27A; pointer-events: none; }
.board-body { position: relative; height: 852px; }
.board.is-offline .board-body { filter: grayscale(1); opacity: .45; }

.r { display: flex; align-items: center; padding: 0 40px; position: relative; }
.r .n { font-family: var(--num); font-weight: 700; line-height: 1; white-space: nowrap; }
.r .c { margin-left: auto; font-family: var(--num); font-weight: 700; line-height: 1; min-width: 140px; text-align: right; }
.r .tag { margin-left: 18px; }

.r-top { height: 216px; background: var(--red); color: #fff; }
.r-top .cap { position: absolute; top: 14px; left: 40px; font-size: 22px; font-weight: 700; letter-spacing: .08em; opacity: .9; }
.r-top .n { font-size: 150px; margin-top: 22px; }
.r-top .c { font-size: 150px; margin-top: 22px; min-width: 170px; }
.r-top .arr { font-size: 60px; opacity: .55; margin: 22px 10px 0 auto; }
.r-top .arr + .c { margin-left: 0; }
.r-top.is-new { animation: topIn .7s var(--spring); }
@keyframes topIn { 0% { transform: translateX(100%); } 100% { transform: none; } }

.r-row { height: 120px; color: var(--cobalt-900); border-bottom: 2px solid var(--line); }
.r-row:nth-child(even) { background: var(--cobalt-50); }
.r-row .n { font-size: 112px; }
.r-row .c { font-size: 112px; color: var(--cobalt); }
.board-body.is-shift .r-row { animation: shiftDown .6s var(--ease); }
@keyframes shiftDown { from { transform: translateY(-60px); opacity: .3; } }

.tag { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 10px; font-size: 22px; font-weight: 800; letter-spacing: .03em; white-space: nowrap; }
.tag .ic { font-size: 22px; }
.tag-priority { background: var(--orange); color: var(--orange-ink); }
.tag-booking { background: var(--gold); color: var(--cobalt-900); }
.tag-recall { background: var(--cobalt-100); color: var(--cobalt-900); }
.tag-transfer { background: var(--teal-50); color: var(--teal-ink); }
.r-top .tag-recall, .r-top .tag-transfer { background: #fff; }

.empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 18px; padding: 0 60px; color: var(--ink-2); }
.empty .ic { font-size: 120px; color: var(--cobalt-100); }
.empty b { font-size: 44px; font-weight: 800; color: var(--cobalt-900); }
.empty span { font-size: 30px; line-height: 1.4; }

/* Trạng thái thay thế (nghỉ trưa, ngoài giờ) */
.board-state { position: absolute; top: 120px; left: 0; right: 0; bottom: 0; background: linear-gradient(180deg, #EEF1F5, #E1E6ED); display: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 0 56px; }
.board.has-state .board-state { display: flex; animation: rise .6s var(--ease); }
.bs-ic { width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center; font-size: 80px; background: #fff; color: var(--cobalt); box-shadow: 0 0 0 18px rgba(0, 71, 171, .07); }
.board-state h3 { margin-top: 44px; font-size: 52px; font-weight: 800; line-height: 1.2; color: var(--cobalt-900); }
.board-state p { margin-top: 16px; font-size: 30px; line-height: 1.45; color: var(--ink-2); }
.bs-hours { margin-top: 36px; width: 100%; border-radius: 20px; background: #fff; border: 2px solid var(--line); overflow: hidden; }
.bs-hours > div { display: flex; justify-content: space-between; padding: 20px 30px; font-size: 30px; }
.bs-hours > div + div { border-top: 2px solid var(--line); }
.bs-hours span { color: var(--ink-2); }
.bs-hours b { font-family: var(--num); font-size: 38px; }

/* Banner mất kết nối */
.conn { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; display: none; align-items: center; gap: 20px; padding: 22px 36px; background: var(--gold); color: var(--cobalt-900); }
.board.is-offline .conn { display: flex; animation: rise .4s var(--ease); }
.conn div { display: flex; flex-direction: column; }
.conn b { font-size: 34px; font-weight: 800; }
.conn span:not(.spin) { font-size: 24px; font-weight: 500; line-height: 1.35; }
.spin { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 6px solid rgba(0, 42, 102, .2); border-top-color: var(--cobalt-900); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================
   CHỮ CHẠY (1920 × 108)
   ========================================================= */
.ftr { position: absolute; left: 0; top: 972px; width: 1920px; height: 108px; display: flex; background: var(--cobalt-900); color: #fff; transition: background .4s; }
.ftr-label { flex: none; width: 300px; display: flex; align-items: center; justify-content: center; gap: 14px; background: var(--gold); color: var(--cobalt-900); font-size: 32px; font-weight: 800; letter-spacing: .03em; }
.ftr-label .ic { font-size: 46px; }
.ftr-track { position: relative; flex: 1; overflow: hidden; display: flex; align-items: center; }
.ftr-text { position: absolute; white-space: nowrap; font-size: 48px; font-weight: 600; will-change: transform; animation: marquee var(--dur, 30s) linear infinite; }
.ftr-text em { font-style: normal; color: var(--gold); margin: 0 36px; }
@keyframes marquee { from { transform: translateX(var(--from, 1620px)); } to { transform: translateX(var(--to, -100%)); } }
.ftr.is-urgent { background: var(--red); }
.ftr.is-urgent .ftr-label { background: #fff; color: var(--red); }
.ftr.is-urgent .ftr-label .ic { animation: shake 1s ease-in-out infinite; }
@keyframes shake { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }

/* =========================================================
   KHUNG GỌI SỐ
   ========================================================= */
.call { position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; background: rgba(4, 12, 30, .74); opacity: 0; visibility: hidden; transition: opacity .35s ease, visibility 0s linear .35s; }
.call.is-on { opacity: 1; visibility: visible; transition-delay: 0s; }
.call-card { position: relative; width: 1600px; border-radius: 40px; overflow: hidden; background: #fff; box-shadow: 0 40px 100px rgba(0, 0, 0, .55); transform: scale(.9) translateY(30px); transition: transform .5s var(--spring); }
.call.is-on .call-card { transform: none; }
.call-card.is-swap { animation: swap .55s var(--spring); }
@keyframes swap { 0% { transform: scale(.94); opacity: .4; } 100% { transform: none; opacity: 1; } }

.cc-band { height: 110px; display: flex; align-items: center; justify-content: center; gap: 22px; background: var(--red); color: #fff; font-size: 60px; font-weight: 800; letter-spacing: .04em; }
.cc-band .ic { font-size: 64px; }
.cc-main { display: flex; align-items: flex-start; justify-content: center; gap: 48px; padding: 44px 60px 10px; }
.cc-col { display: flex; flex-direction: column; align-items: center; }
.cc-col .num { font-size: 300px; line-height: .9; }
.cc-col small { margin-top: 14px; font-size: 34px; font-weight: 700; color: var(--ink-2); letter-spacing: .06em; }
.cc-n { color: var(--red); }
.cc-c { color: var(--cobalt); }
.cc-arr { font-size: 140px; color: #9AA6B6; margin-top: 70px; animation: nudge 1.2s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateX(16px); } }
.call.is-on .cc-pulse { animation: pulse 1s ease-in-out 3 .45s; }
@keyframes pulse { 0%, 100% { transform: scale(1); filter: none; } 50% { transform: scale(1.06); filter: brightness(1.15) drop-shadow(0 0 24px rgba(218, 37, 29, .35)); } }
.cc-tags { display: flex; justify-content: center; gap: 16px; padding: 16px 0 30px; min-height: 30px; }
.cc-tags .tag { height: 60px; font-size: 32px; padding: 0 24px; border-radius: 14px; }
.cc-tags .tag .ic { font-size: 34px; }
.cc-next { height: 84px; display: flex; align-items: center; justify-content: center; gap: 16px; background: var(--cobalt-50); color: var(--cobalt-900); font-size: 36px; font-weight: 600; }
.cc-next b { font-family: var(--num); font-size: 48px; }
.cc-next .ic { font-size: 36px; color: var(--cobalt); }
.cc-prog { height: 10px; background: var(--red-50); }
.cc-prog i { display: block; height: 100%; background: var(--red); transform-origin: left; }

/* Gọi dồn (gộp nhiều số) */
.cm-rows { padding: 16px 60px 24px; }
.cm-row { display: grid; grid-template-columns: 1fr 120px auto; align-items: center; height: 186px; padding: 0 40px; border-radius: 24px; transition: background .3s; }
.cm-row + .cm-row { margin-top: 8px; }
.cm-row .num { line-height: 1; }
.cm-row .n { font-size: 164px; color: var(--red); display: flex; align-items: center; gap: 24px; }
.cm-row .n .tag { font-family: var(--font); height: 52px; font-size: 26px; }
.cm-row .a { font-size: 90px; color: #9AA6B6; }
.cm-row .c { display: flex; align-items: baseline; gap: 18px; }
.cm-row .c small { font-size: 40px; font-weight: 700; color: var(--ink-2); }
.cm-row .c b { font-size: 164px; color: var(--cobalt); }
.cm-row.is-reading { background: var(--red-50); }
.cm-row.is-reading .n { animation: pulse 1s ease-in-out 2; }

/* =========================================================
   THÔNG BÁO KHẨN TOÀN MÀN HÌNH
   ========================================================= */
.evac { position: absolute; inset: 0; z-index: 20; display: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 0 200px; background: var(--red); color: #fff; }
.evac.is-on { display: flex; }
.evac > .ic { font-size: 200px; animation: nudge 1.2s ease-in-out infinite; }
.evac h2 { margin-top: 30px; font-size: 120px; font-weight: 800; letter-spacing: .04em; }
.evac p { margin-top: 26px; font-size: 52px; font-weight: 600; line-height: 1.4; }
.evac small { margin-top: 30px; font-size: 34px; opacity: .85; }

/* =========================================================
   BẢNG MÔ PHỎNG
   ========================================================= */
.sim { position: relative; width: 300px; flex: none; max-height: calc(100vh - 32px); overflow-y: auto; padding: 20px; border-radius: 18px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .14); color: #DCE6F7; font-size: 14px; line-height: 1.45; }
.sim h4 { font-size: 17px; color: #fff; }
.sim .note { margin-top: 6px; color: #A9B7D0; font-size: 13px; }
.sim code { color: var(--gold); }
.grp { margin-top: 16px; display: flex; flex-direction: column; gap: 7px; }
.lbl { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--gold); }
.grp button { display: flex; justify-content: space-between; align-items: center; text-align: left; padding: 9px 12px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .12); background: rgba(255, 255, 255, .08); color: #fff; cursor: pointer; transition: background .2s; }
.grp button:hover { background: rgba(255, 255, 255, .16); }
.grp button.pri { background: var(--gold); color: var(--cobalt-900); font-weight: 700; border: 0; }
.grp .row { display: flex; gap: 8px; }
.grp select { flex: none; width: 96px; border-radius: 10px; padding: 0 8px; background: #fff; color: var(--cobalt-900); border: 0; }
.grp .row button { flex: 1; justify-content: center; }
.grp label { display: flex; align-items: center; gap: 9px; cursor: pointer; padding: 2px 0; }
.grp input { width: 17px; height: 17px; accent-color: var(--gold); flex: none; }
kbd { font-family: inherit; font-size: 11px; padding: 1px 6px; border-radius: 5px; background: rgba(255, 255, 255, .14); color: #DCE6F7; }
.qinfo { font-size: 13px; color: #A9B7D0; }
.qinfo b { color: var(--gold); }
.sim .toast { position: sticky; bottom: 0; margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--gold); color: var(--cobalt-900); font-weight: 600; opacity: 0; transition: opacity .3s; pointer-events: none; }
.sim .toast.is-on { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
