/* ============================================================
   iCleverVision — enterprise VMS UI (HikCentral / Genetec / Milestone style)
   ============================================================ */
:root {
  /* neutral dark surfaces */
  --bg: #0a0d12;
  --s1: #0d1118;          /* rails */
  --s2: #11161f;          /* headers / cards */
  --s3: #161c27;          /* hover */
  --line: #1b2230;
  --line2: #273141;
  /* text */
  --tx: #e6ebf2;
  --tx-dim: #93a1b3;
  --tx-mute: #5d6878;
  /* brand + status */
  --accent: #2f81f7;
  --accent-d: #1f5fc0;
  --ok: #1bb673;
  --p1: #f0483e;          /* critical */
  --p2: #f59e0b;          /* major */
  --p3: #3b9eff;          /* minor / info */
  --radius: 8px;
  --mono: "SF Mono", "JetBrains Mono", "Consolas", ui-monospace, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--tx);
  font-family: "Inter", "Segoe UI", Roboto, -apple-system, system-ui, Arial, sans-serif;
  font-size: 13px; line-height: 1.45; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
.app { display: flex; flex-direction: column; height: 100vh; }
.muted { color: var(--tx-mute); font-weight: 400; }
.ic { width: 16px; height: 16px; flex: 0 0 auto; }
.pill { background: var(--s3); color: var(--tx-dim); border: 1px solid var(--line2); border-radius: 20px; padding: 0 7px; font-size: 11px; font-weight: 600; }

/* ===================== APP BAR ===================== */
.appbar {
  flex: 0 0 54px; height: 54px; display: flex; align-items: center; gap: 22px;
  padding: 0 16px; background: linear-gradient(180deg, #0f1623, #0b0f17);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; padding-right: 18px; border-right: 1px solid var(--line); height: 100%; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; color: #fff; }
.brand-text strong { font-size: 16px; font-weight: 700; letter-spacing: -.2px; }
.brand-text strong span { color: var(--accent); }
.brand-text small { display: block; font-size: 9.5px; color: var(--tx-mute); text-transform: uppercase; letter-spacing: 1.4px; margin-top: -1px; }

.modtabs { display: flex; gap: 2px; height: 100%; align-items: center; }
.modtabs a {
  display: flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: 6px;
  color: var(--tx-dim); cursor: pointer; font-size: 13px; font-weight: 500; transition: .12s;
}
.modtabs a:hover { color: var(--tx); background: #ffffff08; }
.modtabs a.active { color: #fff; background: var(--accent); box-shadow: 0 2px 10px #2f81f755; }
.modtabs a.active .ic { color: #fff; }

.appbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.kpi {
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05;
  min-width: 62px; height: 38px; padding: 0 10px; background: #ffffff06; border: 1px solid var(--line);
  border-radius: 7px;
}
.kpi-v { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-v.p1 { color: var(--p1); }
.kpi-l { font-size: 9px; text-transform: uppercase; letter-spacing: .6px; color: var(--tx-mute); }
.appbar-clock { text-align: right; padding: 0 8px 0 6px; line-height: 1.15; border-left: 1px solid var(--line); margin-left: 4px; }
.appbar-clock b { font-size: 15px; font-variant-numeric: tabular-nums; letter-spacing: .5px; font-family: var(--mono); }
.appbar-clock span { display: block; font-size: 10px; color: var(--tx-mute); }
.appbar-user { display: flex; align-items: center; gap: 9px; padding-left: 10px; border-left: 1px solid var(--line); }
.avatar { width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), var(--accent-d)); display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; }
.user-text b { font-size: 12.5px; display: block; }
.user-text .ok-dot { font-size: 10.5px; color: var(--ok); display: flex; align-items: center; gap: 4px; }
.user-text .ok-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 6px var(--ok); }

/* ===================== WORKSPACE ===================== */
.workspace { flex: 1; display: flex; min-height: 0; }
.rail { display: flex; flex-direction: column; background: var(--s1); overflow: hidden; }
.rail-left { width: 256px; flex: 0 0 256px; border-right: 1px solid var(--line); }
.rail-right { width: 360px; flex: 0 0 360px; border-left: 1px solid var(--line); }
.stage { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #070a0f; position: relative; }

.rail-head {
  display: flex; align-items: center; gap: 8px; padding: 11px 14px 9px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .9px; color: var(--tx-dim);
  background: var(--s2); border-bottom: 1px solid var(--line);
}
.dot-live { width: 8px; height: 8px; border-radius: 50%; background: var(--p1); margin-left: auto; animation: blink 1.4s infinite; }

/* device search */
.rail-search { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.rail-search .ic { color: var(--tx-mute); }
.rail-search input { flex: 1; background: #0a0e15; border: 1px solid var(--line2); color: var(--tx); border-radius: 6px; padding: 7px 9px; font-size: 12.5px; outline: none; }
.rail-search input:focus { border-color: var(--accent); }

/* device tree */
.tree { flex: 1; overflow-y: auto; padding: 6px 0; }
.tree-group { display: flex; align-items: center; gap: 6px; padding: 9px 14px 5px; color: var(--tx-mute); font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; }
.tree-group .ic { width: 13px; height: 13px; }
/* nhóm bài toán (phân loại camera) */
.cat { display: flex; align-items: center; gap: 8px; padding: 8px 12px; margin: 3px 6px 1px; cursor: pointer;
  border-radius: 7px; font-size: 12px; font-weight: 600; color: var(--tx-dim); border: 1px solid transparent; }
.cat:hover { background: #ffffff07; color: var(--tx); }
.cat.active { background: #2f81f714; border-color: #2f81f733; color: var(--tx); }
.cat > .ic { width: 16px; height: 16px; color: var(--accent); }
.cat .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat .cnt { font-size: 10px; color: var(--tx-mute); background: #ffffff10; padding: 1px 7px; border-radius: 9px; }
.cat .chev { display: grid; place-items: center; width: 14px; }
.cat .chev .ic { width: 13px; height: 13px; transform: rotate(90deg); transition: transform .15s; color: var(--tx-mute); }
.cat.collapsed .chev .ic { transform: rotate(0deg); }
.cat.all .chev { display: none; }
.catbox { display: block; }
/* công tắc bật/tắt bài toán */
.ftoggles { padding: 4px 8px 8px; display: flex; flex-direction: column; gap: 1px; }
.ft { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; cursor: pointer; }
.ft:hover { background: #ffffff07; }
.ft > .ic { width: 15px; height: 15px; color: var(--accent); flex: 0 0 auto; }
.ft-nm { flex: 1; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ft-sw { position: absolute; opacity: 0; width: 0; height: 0; }
.ft-track { width: 30px; height: 17px; border-radius: 9px; background: #3a4250; position: relative; transition: background .15s; flex: 0 0 auto; }
.ft-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; transition: transform .15s; }
.ft-sw:checked ~ .ft-track { background: var(--ok); }
.ft-sw:checked ~ .ft-track::after { transform: translateX(13px); }
.ft.off > .ic, .ft.off .ft-nm { color: var(--tx-mute); opacity: .55; }
.dev { display: flex; align-items: center; gap: 9px; padding: 7px 14px 7px 26px; cursor: pointer; border-left: 2px solid transparent; transition: .1s; }
.dev:hover { background: #ffffff07; }
.dev.active { background: #2f81f714; border-left-color: var(--accent); }
.dev .ic { width: 15px; height: 15px; color: var(--tx-mute); }
.dev.active .ic { color: var(--accent); }
.dev .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.dev .st { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 5px var(--ok); }
/* báo động: THUẦN đổi màu (chữ + icon + chấm đỏ), KHÔNG đổi border/padding/nền
   -> hình học y hệt dòng thường, không lệch, không to ra. Chấm đỏ glow như chấm xanh. */
.dev.alarm .ic { color: var(--p1); }
.dev.alarm .nm { color: #ff7b72; font-weight: 700; }
.dev.alarm .st { background: var(--p1); box-shadow: 0 0 5px var(--p1); }
.dev .cnt { font-size: 10px; color: var(--tx-mute); }

/* health */
.health { padding: 10px 12px 14px; display: flex; flex-direction: column; gap: 10px; max-height: 230px; overflow-y: auto; }
.hl { display: flex; align-items: center; gap: 9px; font-size: 12px; }
.hl .ic { width: 15px; height: 15px; color: var(--tx-dim); }
.hl .hlname { color: var(--tx-dim); flex: 0 0 92px; }
.hl .bar { flex: 1; height: 5px; background: #0a0e15; border-radius: 3px; overflow: hidden; }
.hl .bar > i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--accent), #56a8ff); }
.hl .hv { font-variant-numeric: tabular-nums; color: var(--tx); font-size: 11.5px; flex: 0 0 auto; min-width: 38px; text-align: right; }
.eng-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.eng-row .st { width: 7px; height: 7px; border-radius: 50%; }
.eng-row.on .st { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.eng-row.ready .st { background: var(--p2); }
.eng-row.off .st { background: #3a4452; }
.eng-row .nm { flex: 1; color: var(--tx-dim); }
.eng-row.on .nm { color: var(--tx); }
.eng-row .tag { font-size: 9px; text-transform: uppercase; letter-spacing: .5px; color: var(--tx-mute); }

/* ===================== STAGE / VIDEO WALL ===================== */
.stage-bar { display: flex; align-items: center; gap: 12px; padding: 9px 14px; background: var(--s2); border-bottom: 1px solid var(--line); }
.stage-title { font-size: 13px; font-weight: 600; }
.stage-tools { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.tool-hint { font-size: 11px; color: var(--tx-mute); }
.seg { display: flex; gap: 2px; background: #0a0e15; border: 1px solid var(--line2); border-radius: 7px; padding: 2px; }
.seg button { background: transparent; border: none; color: var(--tx-dim); height: 26px; min-width: 30px; padding: 0 8px; border-radius: 5px; cursor: pointer; font-size: 12px; display: grid; place-items: center; }
.seg button:hover { color: var(--tx); }
.seg button.active { background: var(--accent); color: #fff; }
.seg button .ic { width: 15px; height: 15px; }

.wall { flex: 1; display: grid; gap: 6px; padding: 6px; overflow-y: auto; align-content: start; }
.wall.cols-1 { grid-template-columns: 1fr; }
.wall.cols-2 { grid-template-columns: repeat(2, 1fr); }
.wall.cols-3 { grid-template-columns: repeat(3, 1fr); }

.tile { position: relative; background: #000; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; aspect-ratio: 16/9; transition: border-color .15s, box-shadow .15s; }
.tile:hover { border-color: var(--line2); }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; background: #05070a; }
.tile .t-top, .tile .t-bot { position: absolute; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: 7px 9px; font-size: 11px; pointer-events: none; }
.tile .t-top { top: 0; background: linear-gradient(180deg, #000000c0, transparent); }
.tile .t-bot { bottom: 0; justify-content: space-between; background: linear-gradient(0deg, #000000c0, transparent); }
.tile .ch { font-weight: 700; color: var(--accent); background: #00000080; padding: 1px 6px; border-radius: 4px; }
.tile .nm { font-weight: 600; color: #eef3f9; text-shadow: 0 1px 2px #000; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .rec { margin-left: auto; display: flex; align-items: center; gap: 5px; color: #fff; font-family: var(--mono); font-size: 10px; letter-spacing: .3px; }
.tile .rec i { width: 7px; height: 7px; border-radius: 50%; background: var(--p1); animation: blink 1.3s infinite; }
.tile .res { font-family: var(--mono); font-size: 9.5px; color: #cdd8e4; border: 1px solid #ffffff2a; border-radius: 3px; padding: 0 4px; }
.tile .det { color: #aebccb; font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-shadow: 0 1px 2px #000; }
.tile .live { color: var(--ok); display: flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 600; }
.tile .live i { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
/* báo động: KHÔNG phát sáng trồi ra -> viền đỏ + nền đỏ thụt vào trong (overlay), nhấp nháy nhẹ */
.tile.alarm, .tile.alarm.warn { box-shadow: none; }
.tile.alarm { border-color: var(--p1); }
.tile.alarm.warn { border-color: var(--p2); }
.tile.alarm::after { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: var(--radius); z-index: 1;
  box-shadow: inset 0 0 0 2px var(--p1), inset 0 0 28px #f0483e66; animation: tilePulse 1.1s ease-in-out infinite; }
.tile.alarm.warn::after { box-shadow: inset 0 0 0 2px var(--p2), inset 0 0 28px #f59e0b66; }
@keyframes tilePulse { 0%,100% { opacity: .5; } 50% { opacity: 1; } }
.tile .corner { position: absolute; top: 0; right: 0; display: none; align-items: center; gap: 5px; background: var(--p1); color: #fff; font-size: 10px; font-weight: 700; padding: 3px 8px; border-bottom-left-radius: 7px; z-index: 2; }
.tile.alarm .corner { display: flex; animation: blink 1s infinite; }
.tile.alarm.warn .corner { background: var(--p2); color: #1a1200; }

/* ===================== ALARM CENTER ===================== */
.tabs { margin: 8px 10px; }
.tabs button { flex: 1; font-size: 11.5px; font-weight: 600; height: 28px; }
/* chip lọc cảnh báo theo loại bài toán */
.typefilter { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 10px 6px; }
.typefilter .tf { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px;
  background: #0a0e15; border: 1px solid var(--line2); border-radius: 14px; color: var(--tx-dim);
  font-size: 11px; font-weight: 600; cursor: pointer; }
.typefilter .tf:hover { color: var(--tx); border-color: var(--accent); }
.typefilter .tf.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.typefilter .tf .ic { width: 13px; height: 13px; }
.alarms { flex: 1; overflow-y: auto; padding: 6px 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.alarm { flex: 0 0 auto; display: flex; gap: 10px; padding: 9px 10px; background: var(--s2); border: 1px solid var(--line); border-radius: 8px; position: relative; overflow: hidden; animation: slidein .2s ease; }
.alarm::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; }
.alarm.critical::before { background: var(--p1); }
.alarm.warning::before { background: var(--p2); }
.alarm.info::before { background: var(--p3); }
.alarm .a-ic { width: 34px; height: 34px; flex: 0 0 auto; border-radius: 7px; display: grid; place-items: center; }
.alarm.critical .a-ic { background: #f0483e1a; color: var(--p1); }
.alarm.warning .a-ic { background: #f59e0b1a; color: var(--p2); }
.alarm.info .a-ic { background: #3b9eff1a; color: var(--p3); }
.alarm .a-ic .ic { width: 19px; height: 19px; }
.alarm .a-body { flex: 1; min-width: 0; }
.alarm .a-ttl { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; }
.alarm .a-ttl .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alarm .prio { font-size: 9.5px; font-weight: 800; padding: 1px 5px; border-radius: 3px; flex: 0 0 auto; letter-spacing: .3px; }
.alarm.critical .prio { background: var(--p1); color: #fff; }
.alarm.warning .prio { background: var(--p2); color: #1a1200; }
.alarm.info .prio { background: #3b9eff22; color: var(--p3); }
.alarm .a-sub { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 11px; color: var(--tx-mute); margin-top: 3px; }
.alarm .a-sub .who { color: var(--tx-dim); }
.alarm .a-sub time { font-family: var(--mono); }
.alarm .a-sub .src { padding: 0 5px; border: 1px solid var(--line2); border-radius: 3px; font-size: 10px; }
.alarm .a-sub .src.real { color: var(--ok); border-color: #1bb67355; }
.alarm .a-sub .src.mock { color: var(--p2); border-color: #f59e0b55; }
.alarm img.snap { width: 78px; height: 46px; object-fit: cover; border-radius: 5px; border: 1px solid var(--line2); flex: 0 0 auto; }

/* ===================== STATUS BAR ===================== */
.statusbar { flex: 0 0 28px; height: 28px; display: flex; align-items: center; gap: 16px; padding: 0 16px; background: var(--s2); border-top: 1px solid var(--line); font-size: 11px; color: var(--tx-mute); }
.statusbar .si { display: flex; align-items: center; gap: 6px; }
.statusbar .si .ic { width: 13px; height: 13px; }
.statusbar b { color: var(--tx-dim); font-variant-numeric: tabular-nums; }
.statusbar .si.ok b { color: var(--ok); }
.statusbar .grow { margin-left: auto; }

/* ===================== THANH KHẨN CẤP DƯỚI CÙNG + PREVIEW HOVER ===================== */
/* Liệt kê cảnh báo khẩn cấp đang chờ ở đáy màn; KHÔNG che trung tâm cảnh báo.
   Rê chuột vào 1 mục -> hiện camera đó (preview live) phía trên + nút xác nhận. */
.alertbar { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; max-height: 0; overflow: hidden;
  background: linear-gradient(180deg, #1a0f10, var(--s2)); transition: max-height .25s, padding .25s, border-color .25s; border-top: 1px solid transparent; }
.alertbar.show { max-height: 50px; padding: 7px 12px; border-top-color: #f0483e44; }
.ab-head { flex: 0 0 auto; display: flex; align-items: center; gap: 7px; font-size: 11.5px; font-weight: 700; color: var(--p1); white-space: nowrap; }
.ab-head .ic { width: 15px; height: 15px; }
.ab-head b { font-variant-numeric: tabular-nums; }
.ab-list { flex: 1; display: flex; gap: 7px; overflow-x: auto; padding-bottom: 2px; }
.abi { flex: 0 0 auto; display: flex; align-items: center; gap: 7px; height: 32px; padding: 0 10px; cursor: pointer;
  background: var(--s1); border: 1px solid var(--line2); border-radius: 8px; font-size: 12px; transition: transform .12s, box-shadow .12s; }
.abi:hover { transform: translateY(-1px); }
.abi.critical { border-color: #f0483e66; } .abi.critical:hover { box-shadow: 0 0 0 1px var(--p1); }
.abi.warning { border-color: #f59e0b55; } .abi.warning:hover { box-shadow: 0 0 0 1px var(--p2); }
.abi .abp { font-size: 9px; font-weight: 800; padding: 1px 5px; border-radius: 3px; color: #fff; }
.abi.critical .abp { background: var(--p1); } .abi.warning .abp { background: var(--p2); color: #1a1200; }
.abi .ic { width: 16px; height: 16px; }
.abi.critical .ic { color: var(--p1); } .abi.warning .ic { color: var(--p2); }
.abi .abn { font-weight: 600; white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.abi time { font-family: var(--mono); font-size: 10.5px; color: var(--tx-mute); }
.abi.flash { animation: abiFlash 1s ease infinite; }
@keyframes abiFlash { 0%,100% { background: var(--s1); } 50% { background: #f0483e22; } }

/* preview camera khi rê chuột vào 1 mục — gọn nhỏ */
.apv { position: fixed; z-index: 200; width: 290px; max-width: calc(100vw - 16px); background: var(--s1);
  border: 2px solid var(--accent); border-radius: 11px; overflow: hidden; box-shadow: 0 14px 40px #000d;
  opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .15s, transform .15s; }
.apv.show { opacity: 1; pointer-events: auto; transform: translateY(0); }
.apv.critical { border-color: var(--p1); } .apv.warning { border-color: var(--p2); }
.apv-media { position: relative; aspect-ratio: 16/9; background: #000; }
.apv-media img { width: 100%; height: 100%; object-fit: cover; }
.apv-ch { position: absolute; top: 7px; left: 9px; background: #000000a8; color: var(--accent); font-weight: 700; padding: 1px 7px; border-radius: 5px; font-size: 10px; }
.apv-live { position: absolute; top: 7px; right: 9px; display: flex; align-items: center; gap: 4px; background: #000000a8; color: var(--ok); font-size: 9.5px; font-weight: 600; padding: 1px 7px; border-radius: 5px; }
.apv-live i { width: 5px; height: 5px; border-radius: 50%; background: var(--ok); animation: blink 1.3s infinite; }
.apv-banner { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 8px; padding: 16px 10px 8px; background: linear-gradient(0deg, #000000e6, transparent); }
.apv-banner .b-ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: 0 0 auto; }
.apv.critical .b-ic { background: #f0483e22; color: var(--p1); } .apv.warning .b-ic { background: #f59e0b22; color: var(--p2); }
.apv-banner .b-ic .ic { width: 18px; height: 18px; }
.apv-banner .b-ttl { font-size: 13.5px; font-weight: 800; text-shadow: 0 2px 8px #000; }
.apv-banner .b-sub { font-size: 10.5px; color: #c4d2e0; }
.apv-meta { display: grid; grid-template-columns: repeat(2, 1fr); border-bottom: 1px solid var(--line); }
.apv-meta .m { padding: 6px 10px; border-right: 1px solid var(--line); }
.apv-meta .m:last-child { border-right: none; }
.apv-meta .mk { font-size: 9px; text-transform: uppercase; letter-spacing: .5px; color: var(--tx-mute); }
.apv-meta .mv { font-size: 11.5px; font-weight: 600; margin-top: 1px; }
.apv-meta .mv.mono { font-family: var(--mono); font-size: 10.5px; }
.apv-act { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--s2); }
.apv-act .grow { flex: 1; }
.apv-act .btn { padding: 7px 12px; font-size: 12px; }
.apv-act .btn-ghost { width: 34px; padding: 7px; }
.apv-media { cursor: zoom-in; }

/* ===================== PHÓNG TO CAMERA RA GIỮA MÀN ===================== */
.camzoom { position: absolute; inset: 0; z-index: 60; display: none; align-items: center; justify-content: center; }
.camzoom.show { display: flex; }
.cz-back { position: absolute; inset: 0; background: #04070bcc; backdrop-filter: blur(2px); }
.cz-card { position: relative; display: flex; flex-direction: column; width: 96%; max-width: 100%; height: 94%; max-height: 94%; overflow: hidden; background: var(--s1);
  border: 2px solid var(--accent); border-radius: 14px; box-shadow: 0 30px 80px #000e; animation: modalin .25s cubic-bezier(.2,.9,.3,1.25); }
.cz-head { flex: 0 0 auto; }
.cz-act { flex: 0 0 auto; }
.camzoom.critical .cz-card { border-color: var(--p1); }
.camzoom.warning .cz-card { border-color: var(--p2); }
.cz-head { display: flex; align-items: center; gap: 10px; padding: 11px 14px; background: var(--s2); border-bottom: 1px solid var(--line); }
.cz-head .prio { font-size: 12px; font-weight: 800; padding: 2px 9px; border-radius: 5px; letter-spacing: .5px; color: #fff; }
.camzoom.critical .prio { background: var(--p1); } .camzoom.warning .prio { background: var(--p2); color: #1a1200; }
.cz-ttl { font-size: 14px; font-weight: 700; }
.cz-x { margin-left: auto; width: 30px; height: 30px; border-radius: 7px; background: #ffffff0e; border: 1px solid var(--line2); color: var(--tx-dim); cursor: pointer; display: grid; place-items: center; }
.cz-x:hover { background: var(--p1); color: #fff; }
.cz-x .ic { width: 16px; height: 16px; }
.cz-media { position: relative; flex: 1 1 auto; min-height: 0; background: #000; }
.cz-media img { width: 100%; height: 100%; object-fit: contain; }
.cz-media .apv-banner { padding: 30px 18px 16px; gap: 14px; }
.cz-media .apv-banner .b-ic { width: 46px; height: 46px; border-radius: 11px; }
.cz-media .apv-banner .b-ic .ic { width: 27px; height: 27px; }
.cz-media .apv-banner .b-ttl { font-size: 22px; }
.cz-media .apv-banner .b-sub { font-size: 13px; }
.camzoom.critical .cz-media .b-ic { background: #f0483e22; color: var(--p1); }
.camzoom.warning .cz-media .b-ic { background: #f59e0b22; color: var(--p2); }
.cz-act { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--s2); }
.cz-meta { flex: 1; font-size: 11.5px; color: var(--tx-mute); font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn { border: none; cursor: pointer; padding: 9px 16px; border-radius: 7px; font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 7px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #4a90f9; }
.btn-ghost { background: #ffffff0e; color: var(--tx-dim); border: 1px solid var(--line2); width: 40px; justify-content: center; }
.btn-ghost:hover { color: var(--tx); }
.btn-ghost.muted-on { color: var(--p1); }

/* ===================== view switching + extra views ===================== */
.is-hidden { display: none !important; }
.t-max { position: absolute; top: 6px; right: 6px; z-index: 3; width: 28px; height: 28px; border-radius: 6px;
  background: #000000a0; border: 1px solid #ffffff22; color: #dfe8f2; cursor: pointer; display: grid; place-items: center;
  opacity: 0; transition: opacity .15s; }
.tile:hover .t-max { opacity: 1; }
.t-max:hover { background: var(--accent); color: #fff; }
.t-max .ic { width: 15px; height: 15px; }
.tile:fullscreen img { object-fit: contain; }

.stage-extra { flex: 1; overflow-y: auto; padding: 14px; }
.loading { color: var(--tx-mute); padding: 30px; text-align: center; }
.mono { font-family: var(--mono); } .dim { color: var(--tx-mute); }
.panel-card { background: var(--s1); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 14px; }
.pc-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--tx-dim); margin-bottom: 12px; }

/* tables */
.dtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.dtable th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--tx-mute); padding: 8px 10px; border-bottom: 1px solid var(--line2); }
.dtable td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.dtable td .ic { vertical-align: -3px; color: var(--tx-dim); }
.dtable tr:hover td { background: #ffffff05; }
.chiptag { display: inline-block; background: var(--s3); border: 1px solid var(--line2); color: var(--tx-dim); border-radius: 5px; padding: 1px 7px; font-size: 11px; margin: 1px 3px 1px 0; }
.badge-ok { color: var(--ok); font-size: 12px; }
.dtable .prio { font-size: 10px; font-weight: 800; padding: 1px 6px; border-radius: 4px; }
.dtable .prio.critical { background: var(--p1); color: #fff; } .dtable .prio.warning { background: var(--p2); color: #1a1200; } .dtable .prio.info { background: #3b9eff22; color: var(--p3); }
.dtable .src { padding: 1px 6px; border: 1px solid var(--line2); border-radius: 4px; font-size: 11px; }
.dtable .src.real { color: var(--ok); border-color: #1bb67355; } .dtable .src.mock { color: var(--p2); border-color: #f59e0b55; }
.alarmtbl td .ic { width: 15px; }

/* analytics */
.an-kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 14px; }
.ancard { background: var(--s1); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.annum { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.annum.p1c { color: var(--p1); } .annum.p2c { color: var(--p2); }
.ankpi { font-size: 11px; color: var(--tx-mute); text-transform: uppercase; letter-spacing: .5px; margin-top: 2px; }
.an-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pc-wide { grid-column: 1 / -1; }
.anbar { display: flex; align-items: center; gap: 10px; margin: 7px 0; font-size: 12.5px; }
.anbar .anlbl { flex: 0 0 180px; color: var(--tx-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.anbar .antrack { flex: 1; height: 9px; background: #0a0e15; border-radius: 5px; overflow: hidden; }
.anbar .antrack > i { display: block; height: 100%; border-radius: 5px; background: var(--accent); }
.anbar .antrack > i.teal { background: #16b8a6; } .anbar .antrack > i.blue { background: var(--accent); }
.anbar .anval { flex: 0 0 38px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.anhours { display: flex; align-items: flex-end; gap: 5px; height: 150px; padding-top: 10px; }
.anhcol { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 4px; }
.anhcol > i { width: 100%; min-height: 2px; background: linear-gradient(180deg, var(--accent), #1f5fc0); border-radius: 3px 3px 0 0; }
.anhcol > span { font-size: 8.5px; color: var(--tx-mute); }

/* evidence gallery (Phân tích) */
.ev-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.ev-card { display: block; background: #0a0e15; border: 1px solid var(--line2); border-radius: 8px; overflow: hidden; text-decoration: none; color: var(--tx); transition: border-color .12s, transform .12s; border-left-width: 3px; }
.ev-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.ev-card.critical { border-left-color: var(--p1); }
.ev-card.warning { border-left-color: var(--p2); }
.ev-card.info { border-left-color: var(--p3); }
.ev-card img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; background: #000; }
.ev-cap { display: flex; align-items: center; gap: 7px; padding: 8px 10px 2px; font-size: 13px; font-weight: 600; }
.ev-cap .prio { font-size: 9.5px; font-weight: 800; padding: 1px 5px; border-radius: 3px; }
.ev-cap .prio.critical { background: var(--p1); color: #fff; } .ev-cap .prio.warning { background: var(--p2); color: #1a1200; } .ev-cap .prio.info { background: #3b9eff22; color: var(--p3); }
.ev-sub { padding: 0 10px 9px; font-size: 11px; color: var(--tx-mute); font-family: var(--mono); }

/* playback */
.pb-wrap { display: grid; grid-template-columns: 1fr 220px; gap: 14px; height: 100%; }
.pb-screen { position: relative; background: #000; border: 1px solid var(--line2); border-radius: 10px; overflow: hidden; aspect-ratio: 16/9; }
.pb-screen img { width: 100%; height: 100%; object-fit: contain; }
.pb-ovl { position: absolute; top: 10px; left: 12px; background: #000000a8; color: var(--accent); padding: 3px 9px; border-radius: 5px; font-size: 12px; font-weight: 600; }
.pb-controls { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.pb-seek { flex: 1; accent-color: var(--accent); }
.pb-list { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.pb-cam { cursor: pointer; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--s1); }
.pb-cam:hover { border-color: var(--accent); }
.pb-cam img { width: 100%; height: 96px; object-fit: cover; display: block; }
.pb-cam span { display: block; padding: 6px 8px; font-size: 11px; color: var(--tx-dim); }

/* ===================== scrollbar + animations ===================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #232c3a; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #2e3a4c; }
::-webkit-scrollbar-track { background: transparent; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
@keyframes slidein { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }
@keyframes modalin { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: scale(1); } }
@keyframes countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes strobeRed { 0% { border-color: var(--p1); box-shadow: 0 24px 70px #000d, 0 0 56px #f0483edd; } 50% { border-color: #6e211d; box-shadow: 0 24px 70px #000d, 0 0 10px #f0483e33; } 100% { border-color: var(--p1); box-shadow: 0 24px 70px #000d, 0 0 56px #f0483edd; } }
@keyframes strobeAmber { 0% { border-color: var(--p2); box-shadow: 0 24px 70px #000d, 0 0 50px #f59e0bcc; } 50% { border-color: #6e4a08; box-shadow: 0 24px 70px #000d, 0 0 10px #f59e0b33; } 100% { border-color: var(--p2); box-shadow: 0 24px 70px #000d, 0 0 50px #f59e0bcc; } }
