/* Bố cục chung của các phân hệ (.tv-*): An ninh trật tự (order.js, order.css); lấy từ phần Giao thông của demo cũ. Màu / thẻ / nút dùng chung với phần Khuôn mặt (base.css). */

/* ---------- tab chính ---------- */
#mainTabs button { padding: 7px 16px; font-size: 13px; font-weight: 500; }
#trafficView { display: none; }
body.tab-traffic .camstrip, body.tab-traffic .wrap, body.tab-traffic #status { display: none !important; }
body.tab-traffic #trafficView { display: block; }
body.tab-analytics #trafficView { display: none; }
body.tab-traffic .toast { pointer-events: none; }

/* ---------- mục con (Giao thông, An ninh trật tự) ---------- */
.tv-sub { display: flex; gap: 2px; padding: 0 14px; border-bottom: 1px solid var(--line); background: #0c1117; overflow-x: auto; }
.stab { display: inline-flex; align-items: center; gap: 9px; min-height: 44px; padding: 0 16px; border: 0; border-bottom: 2px solid transparent;
        background: none; color: var(--muted); cursor: pointer; font-weight: 500; white-space: nowrap; }
.stab:hover:not(:disabled) { color: var(--text); }
.stab.on { color: var(--text); border-bottom-color: var(--accent); }
.stab:disabled { cursor: default; opacity: .6; }
.stab .n { font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--panel3); color: #c9d3df; font-variant-numeric: tabular-nums; }
.stab.on .n { background: rgba(61,139,253,.2); color: #cfe2ff; }
.stab .n.alert { background: rgba(239,68,68,.18); color: #fca5a5; }

/* ---------- bố cục: camera | tìm + danh sách | chi tiết ---------- */
.tv-body { display: grid; grid-template-columns: 320px minmax(0, 1fr) 460px; gap: 16px; padding: 16px; height: calc(100vh - 58px - 45px); }
.tv-side, .tv-main, .tv-detail { min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.tv-side > *, .tv-main > *, .tv-detail > * { flex-shrink: 0; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; background: var(--panel3); border: 1px solid var(--line2);
       font-size: 12px; color: #c9d3df; white-space: nowrap; }
.tag.warn { background: rgba(245,158,11,.14); border-color: rgba(245,158,11,.45); color: #fcd34d; }
.tag.bad { background: rgba(239,68,68,.14); border-color: rgba(239,68,68,.45); color: #fca5a5; }
.tag.ok { background: rgba(34,197,94,.13); border-color: rgba(34,197,94,.4); color: #86efac; }
.tag.info { background: var(--accent-soft); border-color: rgba(61,139,253,.45); color: #b9d4ff; }
.tag.demo { background: transparent; border-style: dashed; color: var(--muted); font-size: 10.5px; padding: 0 7px; text-transform: none; letter-spacing: 0; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); }

/* xem trực tiếp */
.tv-live { overflow: hidden; }
.tv-livebar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; min-width: 0; }
.tv-livebar b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-livebar .muted { font-size: 12px; white-space: nowrap; }
.tv-livebar .rec { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); flex: none; animation: blink 1.4s infinite; }
.tv-livebar .icon-btn { width: 30px; height: 30px; flex: none; }
.tv-vp { position: relative; aspect-ratio: 16 / 9; background: #05080b; }
.tv-vp iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.tv-vnote { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 12px; background: #05080b; color: var(--muted); font-size: 12.5px; }
.tv-vnote[hidden] { display: none; }

/* danh sách camera: tìm, lọc, nhóm theo khu vực, mỗi camera một dòng */
.tv-cams { padding: 12px 8px 8px; display: flex; flex-direction: column; gap: 10px; }
.tv-cams .sec-t { padding: 0 4px; } .tv-cams .cnt { text-transform: none; letter-spacing: 0; font-weight: 500; }
.tv-q { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line2); background: #0f151d; color: var(--muted); }
.tv-q.big { flex: 1 1 320px; height: 40px; border-radius: 10px; }
.tv-q input { flex: 1; min-width: 0; height: 34px; border: 0; background: none; outline: none; font-size: 13px; }
.tv-q:focus-within { border-color: var(--accent); }
.tv-camf, .tv-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.qchip b { font-weight: 600; }
.tv-camlist { max-height: 540px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -4px; padding: 0 4px; }
.cgh { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 36px; padding: 0 8px; border: 0; border-radius: 8px; background: var(--panel);
       cursor: pointer; font-size: 12.5px; text-align: left; margin-top: 4px; }
.cgh:hover { background: var(--panel3); }
.cgh svg { transition: transform .15s; flex: none; color: var(--muted); } .cgh.open svg { transform: rotate(90deg); }
.cgh b { font-weight: 600; } .cgh .tag { font-size: 11px; padding: 0 7px; }
.crow { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 34px; padding: 0 8px 0 26px; border: 1px solid transparent; border-radius: 7px;
        background: none; cursor: pointer; font-size: 13px; text-align: left; }
.crow:hover { background: var(--panel2); }
.crow.on { background: rgba(61,139,253,.12); border-color: rgba(61,139,253,.5); }
.crow.filt { background: rgba(61,139,253,.22); border-color: #3d8bfd; box-shadow: inset 3px 0 0 #3d8bfd; } .crow.filt .nm { font-weight: 600; }
.crow .d { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--ok); } .crow .d.down { background: #f87171; }
.crow .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crow .fs { display: flex; gap: 3px; }
.crow .n { width: 38px; text-align: right; font-size: 12px; color: #a3aebd; font-family: var(--mono); } .crow .n.pend { color: #fcd34d; }
.fb { display: inline-grid; place-items: center; width: 17px; height: 17px; border-radius: 4px; background: var(--panel3); color: #a3aebd; font-size: 10px; font-weight: 700; font-style: normal; }
.fb.on { background: rgba(61,139,253,.22); color: #cfe2ff; }
.tv-legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 11.5px; color: var(--muted); padding: 2px 4px 0; }
.tv-empty { padding: 18px 10px; text-align: center; color: var(--muted); font-size: 13px; border: 1px dashed var(--line2); border-radius: 10px; }

/* tìm kiếm */
.tv-search { padding: 14px; display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.fld { display: flex; flex-direction: column; gap: 5px; font-size: 11.5px; font-weight: 500; color: var(--muted); min-width: 0; flex: 1 1 140px; }
.fld.w2 { flex: 2 1 200px; }
.fld input, .fld select { height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line2); background: #0f151d; color: var(--text); font-size: 13px; min-width: 0; color-scheme: dark; }
.fld input:focus, .fld select:focus { outline: none; border-color: var(--accent); }
#tvPlate { text-transform: uppercase; }
.tv-attrs { flex: 1 1 100%; display: flex; flex-direction: column; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.tv-attrs[hidden], .tv-desc[hidden], #fStatusBox[hidden], #tvNew[hidden], #tvMore[hidden] { display: none; }
.tv-row { display: flex; flex-wrap: wrap; gap: 10px; }
#fStatusBox { display: contents; }
.tv-desc { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.tv-hint { font-size: 13px; color: var(--muted); } .tv-hint b { color: var(--text); font-weight: 500; } .tv-hint .warn { font-size: 12.5px; color: #fcd34d; }
#tvNew { height: 26px; color: #86efac; border-color: rgba(34,197,94,.45); background: var(--ok-soft); font-size: 12px; }

/* số liệu */
.tv-kpis { display: flex; flex-wrap: wrap; gap: 12px; }
.tv-kpi { flex: 1 1 150px; padding: 12px 14px; }
.tv-kpi .l { font-size: 12px; color: var(--muted); } .tv-kpi .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tv-kpi .s { font-size: 12px; color: var(--muted); }

/* danh sách sự kiện */
.tv-listbox { padding: 8px; }
.tv-lh { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 6px 8px 10px; }
.tv-lh h2 { margin: 0; font-size: 15px; font-weight: 600; } .tv-lh .muted { font-size: 12.5px; }
.tv-more { display: flex; justify-content: center; padding: 10px; }
.erow { display: grid; grid-template-columns: 92px 116px minmax(0, 1fr) auto; gap: 14px; align-items: center; width: 100%; text-align: left; padding: 8px 12px;
        border: 1px solid transparent; border-radius: 10px; background: none; cursor: pointer; }
.erow:hover { background: #121a23; }
.erow.on { background: rgba(61,139,253,.09); border-color: rgba(61,139,253,.5); }
.erow.fresh { animation: tfFresh 2.4s ease-out; }
@keyframes tfFresh { from { border-color: var(--ok); box-shadow: 0 0 0 2px var(--ok-soft); } }
.erow .th { width: 92px; height: 58px; border-radius: 6px; overflow: hidden; background: #0d1319; border: 1px solid var(--line); display: block; }
.erow .th img, .erow .th svg { width: 100%; height: 100%; object-fit: cover; display: block; }
.erow .mid { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.erow .t1 { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.erow .t2 { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--muted); }
.erow .t2 .tag { font-size: 11px; padding: 0 7px; }
.erow .rt { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.erow .rt .tag { font-size: 11px; padding: 0 8px; }

/* biển số vẽ bằng chữ (ảnh biển thật hiện ở chi tiết) */
.plate { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; background: #f4f6f8; color: #0b0f14; border: 2px solid #0b0f14;
         box-shadow: 0 0 0 1px #c9d3df; border-radius: 5px; font-family: var(--mono); font-weight: 700; line-height: 1.05; letter-spacing: .02em; white-space: nowrap; }
.plate.one { padding: 4px 8px; font-size: 13.5px; } .plate.two { padding: 3px 8px; font-size: 12px; }
.plate.big.one { padding: 8px 16px; font-size: 24px; border-width: 3px; } .plate.big.two { padding: 6px 16px; font-size: 20px; border-width: 3px; }
.plate.none { background: var(--panel3); color: var(--muted); border-color: var(--line2); box-shadow: none; font-family: inherit; font-weight: 500; font-size: 12px; }

/* lưới thẻ của tìm theo mô tả (như bên Khuôn mặt) */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; padding: 0 8px 10px; }
.pgrid .empty { grid-column: 1 / -1; }
.vcard { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer; display: flex; flex-direction: column;
         padding: 0; text-align: left; transition: transform .15s ease, border-color .15s ease; }
.vcard:hover { transform: translateY(-2px); border-color: var(--line2); }
.vcard.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.vcard .ph { display: block; aspect-ratio: 4 / 3; background: #05080b; position: relative; }
.vcard .ph img, .vcard .ph svg { width: 100%; height: 100%; object-fit: cover; display: block; }
.vcard .mp { position: absolute; right: 8px; top: 8px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent2); color: #fff; }
.vcard.maybe .mp { background: #f59e0b; color: #2b1a00; } .vcard.far .mp { background: var(--panel3); color: #a3aebd; }
.vcard .pl { position: absolute; left: 8px; bottom: 8px; }
.vcard .bd { padding: 9px 11px 11px; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.vcard .meta { display: flex; justify-content: space-between; gap: 6px; color: var(--muted); }
.vcard .meta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chk .chua { color: var(--muted); }

/* chi tiết */
.tv-detail .card { padding: 16px; }
.tv-detail .sec-t .tag { text-transform: none; letter-spacing: 0; }
.dhead { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.dhead .tt { flex: 1; min-width: 160px; } .dhead .tt b { display: block; font-size: 16px; font-weight: 600; }
.dhead .tt span { font-size: 12.5px; color: var(--muted); }
.dclose { display: none; }
.media { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.media figure { margin: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.media figure.scene { flex: 2 1 220px; } .media figure.pl { flex: 1 1 140px; }
.media img, .media svg.ph { width: 100%; border-radius: 8px; background: #05080b; border: 1px solid var(--line); display: block; }
.media figcaption { font-size: 12px; color: var(--muted); }
.media .platebox { aspect-ratio: 2 / 1; border-radius: 8px; background: #11171e; border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; }
.media .platebox img { border: 0; height: 100%; object-fit: contain; }
.vplayer { position: relative; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #05080b; margin-top: 14px; }
.vplayer img, .vplayer svg { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.vplayer .box { position: absolute; border: 2px solid #f59e0b; border-radius: 3px; transition: all .3s; }
.vplayer .cap { position: absolute; left: 8px; bottom: 8px; font-size: 12px; color: #fcd34d; background: rgba(5,8,11,.75); padding: 2px 8px; border-radius: 6px; }
.vplayer .clk { position: absolute; left: 8px; top: 8px; font-size: 11.5px; color: #c9d3df; background: rgba(5,8,11,.75); padding: 2px 8px; border-radius: 6px; font-family: var(--mono); }
.vplayer .tag { position: absolute; right: 8px; bottom: 8px; }
.scrub { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.scrub .bar { position: relative; flex: 1; height: 22px; cursor: pointer; }
.scrub .bar::before { content: ''; position: absolute; left: 0; right: 0; top: 9px; height: 4px; border-radius: 4px; background: var(--line); }
.scrub .fill { position: absolute; left: 0; top: 9px; height: 4px; border-radius: 4px; background: var(--accent); }
.scrub .mark { position: absolute; left: 50%; top: 2px; width: 2px; height: 18px; background: var(--bad); }
.scrub .knob { position: absolute; top: 4px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--text); }
.scrub-l { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.kfs { display: flex; gap: 8px; margin-top: 8px; }
.kf { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 6px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
      cursor: pointer; overflow: hidden; text-align: left; }
.kf.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.kf .im { position: relative; display: block; aspect-ratio: 16 / 9; background: #0b1016; overflow: hidden; }
.kf .im img { width: 100%; height: 100%; object-fit: cover; display: block; }
.kf .im i { position: absolute; border: 1.5px solid #f59e0b; }
.kf span.l { padding: 0 8px 7px; font-size: 12px; color: #c9d3df; }
.dacts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.kv2 { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px 14px; font-size: 13px; margin: 0; }
.kv2 dt { color: var(--muted); } .kv2 dd { margin: 0; overflow-wrap: anywhere; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 1px solid #46515f; vertical-align: -2px; margin-right: 8px; }
.placebox { margin-top: 12px; border-radius: 8px; border: 1px solid var(--line); background: #0f151d; padding: 10px; display: flex; gap: 10px; align-items: center; font-size: 12.5px; }
.person { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 12px; padding: 10px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); }
.person + .person { margin-top: 8px; }
.person .av { width: 52px; height: 68px; border-radius: 6px; background: #0d1319; border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; }
.person .av img { width: 100%; height: 100%; object-fit: cover; }
.person .nm { display: flex; gap: 8px; align-items: baseline; } .person .nm b { font-weight: 600; font-size: 13.5px; } .person .nm span { font-size: 12px; color: var(--muted); }
.person .tg { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.hist { display: grid; grid-template-columns: 70px 14px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 6px 0; font-size: 13px; }
.hist .o { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--accent); }
.hist .tag { font-size: 11px; padding: 0 8px; }
.review textarea, .review input { width: 100%; height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line2); background: #0f151d; color: var(--text); font-size: 13px; }
/* nút là thẻ <a> (tải ảnh, bản đồ): bỏ màu / gạch chân của link */
#trafficView a.btn, #trafficView a.btn:visited, #orderView a.btn, #orderView a.btn:visited { color: var(--text); text-decoration: none; }
#trafficView .btn:disabled, #orderView .btn:disabled { opacity: .45; cursor: default; }
#trafficView .btn:disabled:hover { background: var(--panel2); }
.dacts .btn svg, .mapbtn svg { flex: none; color: var(--muted); }
.dacts .btn:hover:not(:disabled) svg, .mapbtn:hover svg { color: var(--text); }
.placebox .mapbtn { flex: none; align-self: center; }
.dacts .grow { flex: 1; }
.btn.okb { background: rgba(34,197,94,.16); border-color: rgba(34,197,94,.45); color: #86efac; }
.tv-noev { padding: 50px 20px; text-align: center; color: var(--muted); }

/* màn hẹp: chi tiết thành ngăn trượt bên phải */
@media (max-width: 1380px) {
  .tv-body { grid-template-columns: 300px minmax(0, 1fr); }
  .tv-detail { position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); z-index: 40; background: var(--bg); border-left: 1px solid var(--line);
               padding: 14px; box-shadow: var(--shadow); transform: translateX(105%); transition: transform .2s ease; }
  .tv-detail.show { transform: none; }
  .dclose { display: inline-flex; }
}
@media (max-width: 900px) {
  .tv-body { grid-template-columns: 1fr; height: auto; }
  .tv-side, .tv-main { overflow: visible; }
  .erow { grid-template-columns: 116px minmax(0, 1fr); } .erow .th { display: none; } .erow .rt { grid-column: 1 / -1; align-items: flex-start; flex-direction: row; }
  .kv2 { grid-template-columns: 120px minmax(0, 1fr); }
}
@media (max-width: 640px) { #mainTabs button { padding: 6px 9px; font-size: 12px; } .brand b { display: none; } .brand .sep { display: none; } }

/* ---------- chấm "cập nhật trực tiếp" (Giao thông, An ninh trật tự) ---------- */
.tf-live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.tf-live i { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.tf-live.on i { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
