:root {
  --bg-0: #04070f;
  --bg-1: #070d1a;
  --panel: rgba(9, 17, 31, 0.72);
  --panel-line: rgba(94, 234, 255, 0.18);
  --text: #dbe9ff;
  --muted: #7d90ad;
  --cyan: #4fe3ff;
  --cyan-dim: rgba(79, 227, 255, 0.35);
  --amber: #ffb648;
  --red: #ff4d4d;
  --green: #46e39b;
  --violet: #a78bfa;
  --font: "HarmonyOS Sans SC", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }

#app { position: fixed; inset: 0; }

#stage { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }

/* ---------- 氛围层 ---------- */
.vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background:
    radial-gradient(120% 90% at 50% 40%, transparent 40%, rgba(2, 5, 12, 0.72) 100%),
    radial-gradient(60% 40% at 50% 0%, rgba(79, 227, 255, 0.07), transparent 70%);
}
.scanlines {
  position: absolute; inset: 0; pointer-events: none; z-index: 2; opacity: .32;
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,.028) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: absolute; top: 0; left: 0; right: 0; height: 64px; z-index: 6;
  display: grid; grid-template-columns: minmax(300px, 340px) 1fr minmax(300px, 330px); align-items: center;
  padding: 0 18px; gap: 16px;
  background: linear-gradient(180deg, rgba(4,9,18,.94), rgba(4,9,18,.42) 70%, transparent);
  border-bottom: 1px solid rgba(79, 227, 255, 0.1);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { color: var(--cyan); filter: drop-shadow(0 0 10px rgba(79,227,255,.55)); }
.brand-text { min-width: 0; }
.brand-text h1 { margin: 0; font-size: 15.5px; letter-spacing: .03em; font-weight: 700; white-space: nowrap; }
.brand-text p {
  margin: 2px 0 0; font-size: 9.5px; color: var(--muted); letter-spacing: .08em;
  font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.topbar-mid { display: flex; justify-content: center; }
.phase-track { display: flex; align-items: center; gap: 0; }
.phase {
  display: flex; align-items: center; gap: 7px;
  font-size: 11.5px; color: var(--muted); white-space: nowrap;
}
.phase .pip {
  width: 9px; height: 9px; border-radius: 50%;
  background: rgba(125, 144, 173, .3);
  box-shadow: 0 0 0 3px rgba(125,144,173,.08);
  transition: .35s;
}
.phase.done .pip { background: var(--cyan-dim); }
.phase.on .pip { background: var(--cyan); box-shadow: 0 0 0 4px rgba(79,227,255,.18), 0 0 14px var(--cyan); }
.phase.on { color: var(--cyan); }
.phase-link { width: 26px; height: 1px; background: rgba(125,144,173,.25); margin: 0 8px; }
.phase-link.done { background: var(--cyan-dim); }

.topbar-right { display: flex; align-items: center; justify-content: flex-end; gap: 14px; }
.clock { text-align: right; line-height: 1.15; }
.clock span { font-family: var(--mono); font-size: 18px; color: #eaf6ff; letter-spacing: .06em; }
.clock em { display: block; font-style: normal; font-size: 10px; color: var(--muted); font-family: var(--mono); }
.sys-state { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.live { background: var(--green); box-shadow: 0 0 10px var(--green); animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .35; } }
.back {
  font-size: 11px; color: var(--muted); text-decoration: none;
  border: 1px solid rgba(125,144,173,.28); border-radius: 6px; padding: 5px 9px;
  transition: .2s;
}
.back:hover { color: var(--cyan); border-color: var(--cyan-dim); }

/* ---------- 面板通用 ---------- */
.panel {
  position: absolute; top: 76px; bottom: 108px; z-index: 5; width: 320px;
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 13px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 48px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.04);
}
.panel::before, .panel::after {
  content: ""; position: absolute; width: 14px; height: 14px; pointer-events: none;
  border-color: var(--cyan); opacity: .75;
}
.panel::before { top: -1px; left: -1px; border-top: 2px solid; border-left: 2px solid; border-top-left-radius: 12px; }
.panel::after { bottom: -1px; right: -1px; border-bottom: 2px solid; border-right: 2px solid; border-bottom-right-radius: 12px; }
.panel-left { left: 18px; }
.panel-right { right: 18px; }

.panel-head { display: flex; align-items: center; justify-content: space-between; }
.panel-head h2 { margin: 0; font-size: 13.5px; letter-spacing: .08em; font-weight: 700; }
.tag {
  font-size: 10px; font-family: var(--mono); letter-spacing: .1em;
  color: var(--cyan); border: 1px solid var(--cyan-dim); border-radius: 999px; padding: 2px 8px;
}
.tag.alarm { color: var(--amber); border-color: rgba(255,182,72,.35); }
.tag.alarm.hot { color: var(--red); border-color: rgba(255,77,77,.5); background: rgba(255,77,77,.1); }

/* ---------- 流程步骤 ---------- */
.steps {
  list-style: none; margin: 0; padding: 2px 2px 2px 0;
  display: flex; flex-direction: column; gap: 6px;
  overflow: auto; flex: 1; min-height: 0;
}
.steps::-webkit-scrollbar, .events::-webkit-scrollbar { width: 4px; }
.steps::-webkit-scrollbar-thumb, .events::-webkit-scrollbar-thumb { background: rgba(79,227,255,.25); border-radius: 4px; }

.step {
  position: relative; display: grid; grid-template-columns: 30px 1fr auto; align-items: center;
  gap: 9px; padding: 8px 10px; cursor: pointer;
  border: 1px solid rgba(125,144,173,.16); border-radius: 9px;
  background: rgba(255,255,255,.015);
  transition: .22s;
}
.step:hover { border-color: var(--cyan-dim); background: rgba(79,227,255,.05); }
.step .no {
  width: 26px; height: 26px; border-radius: 7px;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  color: var(--muted); background: rgba(125,144,173,.12);
  border: 1px solid rgba(125,144,173,.2);
}
.step .nm { font-size: 13px; font-weight: 600; }
.step .en { font-size: 9.5px; color: var(--muted); font-family: var(--mono); letter-spacing: .06em; margin-top: 1px; }
.step .st { font-size: 9.5px; color: var(--muted); font-family: var(--mono); }
.step.done .no { color: var(--cyan); background: rgba(79,227,255,.1); border-color: var(--cyan-dim); }
.step.on {
  border-color: var(--cyan); background: linear-gradient(90deg, rgba(79,227,255,.16), rgba(79,227,255,.03));
  box-shadow: 0 0 0 1px rgba(79,227,255,.18), 0 8px 22px rgba(0,0,0,.35);
}
.step.on .no { color: #04121a; background: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 14px var(--cyan); }
.step.on .st { color: var(--cyan); }
.step.way { opacity: .62; }
.step.way .nm { font-weight: 500; font-size: 12px; }

.panel-sub { border-top: 1px dashed rgba(125,144,173,.22); padding-top: 10px; }
.sub-title { font-size: 10px; letter-spacing: .16em; color: var(--muted); font-family: var(--mono); margin-bottom: 7px; }
.detail-name { font-size: 14px; font-weight: 700; color: var(--cyan); }
.detail-desc { margin-top: 5px; font-size: 11.5px; line-height: 1.65; color: #a9bcd6; }
.detail-meta { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 10px; font-family: var(--mono);
  padding: 3px 7px; border-radius: 5px;
  color: #9fd8ff; background: rgba(79,227,255,.08); border: 1px solid rgba(79,227,255,.18);
}

/* ---------- 事件中心 ---------- */
.event-filters { display: flex; gap: 5px; }
.event-filters button {
  flex: 1; padding: 5px 0; font-size: 10.5px; cursor: pointer;
  color: var(--muted); background: rgba(255,255,255,.02);
  border: 1px solid rgba(125,144,173,.2); border-radius: 6px; transition: .2s;
}
.event-filters button:hover { color: var(--text); }
.event-filters button.on { color: #04121a; background: var(--cyan); border-color: var(--cyan); font-weight: 700; }

.events { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 7px; padding-right: 2px; }

.ev {
  position: relative; padding: 9px 10px 9px 12px;
  border: 1px solid rgba(125,144,173,.18); border-radius: 9px;
  background: rgba(255,255,255,.018);
  cursor: pointer; transition: .2s;
  animation: evIn .38s cubic-bezier(.2,.9,.3,1);
}
@keyframes evIn { from { opacity: 0; transform: translateX(14px); } }
.ev:hover { border-color: var(--cyan-dim); background: rgba(79,227,255,.05); }
.ev::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 2.5px; border-radius: 2px; background: var(--muted); }
.ev.exception::before { background: var(--amber); }
.ev.intrusion::before { background: var(--red); }
.ev.face::before { background: var(--green); }
.ev.info::before { background: var(--cyan); }
.ev.intrusion { background: rgba(255,77,77,.07); border-color: rgba(255,77,77,.28); }
.ev-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ev-title { font-size: 12.5px; font-weight: 600; }
.ev.exception .ev-title { color: var(--amber); }
.ev.intrusion .ev-title { color: #ff8080; }
.ev.face .ev-title { color: var(--green); }
.ev-time { font-size: 9.5px; color: var(--muted); font-family: var(--mono); flex: 0 0 auto; }
.ev-body { margin-top: 4px; font-size: 11px; line-height: 1.6; color: #9db0cb; }
.ev-tags { margin-top: 6px; display: flex; gap: 5px; flex-wrap: wrap; }
.ev-tag { font-size: 9.5px; font-family: var(--mono); padding: 2px 6px; border-radius: 4px; background: rgba(125,144,173,.14); color: #b9c9e0; }
.ev-tag.hot { background: rgba(255,77,77,.18); color: #ffb3b3; }
.ev-tag.ok { background: rgba(70,227,155,.15); color: #9df0c8; }

/* ---------- KPI ---------- */
.kpibar {
  position: absolute; left: 18px; right: 18px; bottom: 56px; z-index: 5; height: 62px;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px;
}
.kpi {
  position: relative; padding: 8px 12px; border-radius: 10px;
  background: linear-gradient(180deg, rgba(9,17,31,.8), rgba(9,17,31,.55));
  border: 1px solid var(--panel-line);
  backdrop-filter: blur(12px);
  display: flex; flex-direction: column; justify-content: center;
  overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  opacity: .5;
}
.kpi.warn::after { background: linear-gradient(90deg, transparent, var(--amber), transparent); }
.kpi.danger::after { background: linear-gradient(90deg, transparent, var(--red), transparent); }
.kpi.ok::after { background: linear-gradient(90deg, transparent, var(--green), transparent); }
.kpi label { font-size: 10px; color: var(--muted); letter-spacing: .08em; }
.kpi b { font-family: var(--mono); font-size: 21px; font-weight: 700; line-height: 1.15; color: #f0f8ff; }
.kpi.warn b { color: var(--amber); }
.kpi.danger b { color: var(--red); }
.kpi.ok b { color: var(--green); }
.kpi em { font-style: normal; font-size: 9.5px; color: var(--muted); margin-left: 3px; }
.kpi b + em, .kpi em { display: inline; }

/* ---------- 控制条 ---------- */
.dock {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 12px; z-index: 6;
  display: flex; align-items: center; gap: 6px;
  padding: 7px 10px; border-radius: 999px;
  background: rgba(9,17,31,.82); border: 1px solid var(--panel-line);
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 34px rgba(0,0,0,.5);
}
.dock button {
  padding: 6px 13px; font-size: 11.5px; cursor: pointer; border-radius: 999px;
  color: var(--muted); background: transparent; border: 1px solid transparent; transition: .2s;
}
.dock button:hover { color: var(--text); background: rgba(255,255,255,.05); }
.dock button.on { color: var(--cyan); border-color: var(--cyan-dim); background: rgba(79,227,255,.1); }
.dock button.primary {
  color: #04121a; background: linear-gradient(135deg, var(--cyan), #6ee7ff); font-weight: 700;
  box-shadow: 0 0 18px rgba(79,227,255,.35);
}
.dock .sep { width: 1px; height: 18px; background: rgba(125,144,173,.25); margin: 0 3px; }
.dock .speed { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--muted); padding-left: 4px; }
.dock .speed b { font-family: var(--mono); color: var(--cyan); font-size: 11px; min-width: 30px; }
.dock input[type=range] { width: 78px; accent-color: var(--cyan); }

/* ---------- 3D 标注 ---------- */
#labels { position: absolute; inset: 0; z-index: 4; pointer-events: none; overflow: hidden; }
.lbl {
  position: absolute; transform: translate(-50%, -100%);
  white-space: nowrap; pointer-events: none;
  transition: opacity .25s;
}
.lbl .lbl-card {
  position: relative;
  padding: 5px 10px 6px;
  border-radius: 7px;
  background: linear-gradient(180deg, rgba(6,14,26,.92), rgba(6,14,26,.7));
  border: 1px solid var(--cyan-dim);
  box-shadow: 0 6px 20px rgba(0,0,0,.55), 0 0 22px rgba(79,227,255,.12);
}
.lbl .lbl-no {
  position: absolute; left: -9px; top: -9px;
  width: 19px; height: 19px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  color: #04121a; background: var(--cyan); box-shadow: 0 0 12px var(--cyan);
}
.lbl .lbl-nm { font-size: 12px; font-weight: 700; letter-spacing: .02em; }
.lbl .lbl-en { font-size: 9px; color: #7fb9d8; font-family: var(--mono); letter-spacing: .08em; }
.lbl .lbl-stem { width: 1px; height: 26px; margin: 0 auto; background: linear-gradient(180deg, var(--cyan), transparent); }
.lbl.active .lbl-card { border-color: var(--cyan); box-shadow: 0 0 0 1px rgba(79,227,255,.3), 0 0 30px rgba(79,227,255,.35); }
.lbl.way .lbl-card { padding: 3px 7px; opacity: .72; border-color: rgba(125,144,173,.3); }
.lbl.way .lbl-nm { font-size: 10px; font-weight: 500; color: #9db0cb; }
.lbl.zone .lbl-card {
  background: rgba(6,14,26,.55); border-color: rgba(125,144,173,.22); padding: 3px 8px;
  box-shadow: none;
}
.lbl.zone .lbl-nm { font-size: 10.5px; font-weight: 500; color: #90a8c6; }
.lbl.cam .lbl-card { padding: 3px 7px; border-color: rgba(167,139,250,.35); }
.lbl.cam .lbl-nm { font-size: 10px; color: #c9b8ff; font-family: var(--mono); }
.lbl.alarm .lbl-card {
  border-color: var(--red); background: rgba(38,6,10,.9);
  box-shadow: 0 0 26px rgba(255,77,77,.45);
  animation: alarmPulse 1s infinite;
}
.lbl.alarm .lbl-nm { color: #ff9b9b; }
.lbl.alarm .lbl-no { background: var(--red); box-shadow: 0 0 14px var(--red); }
@keyframes alarmPulse { 50% { box-shadow: 0 0 8px rgba(255,77,77,.25); } }

/* ---------- 弹窗 ---------- */
.modal-wrap {
  position: absolute; inset: 0; z-index: 20; display: none;
  align-items: center; justify-content: center;
  background: rgba(2,5,12,.55); backdrop-filter: blur(3px);
}
.modal-wrap.show { display: flex; }
.modal {
  width: 430px; max-width: calc(100vw - 40px);
  border-radius: 14px; overflow: hidden;
  background: linear-gradient(180deg, rgba(11,20,36,.98), rgba(7,13,26,.98));
  border: 1px solid var(--panel-line);
  box-shadow: 0 30px 80px rgba(0,0,0,.7);
  animation: modalIn .3s cubic-bezier(.2,.9,.3,1);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(18px) scale(.97); } }
.modal .m-head {
  padding: 13px 16px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(125,144,173,.16);
}
.modal .m-icon {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  font-size: 15px; font-weight: 700;
}
.modal.exception .m-icon { background: rgba(255,182,72,.16); color: var(--amber); }
.modal.intrusion .m-icon { background: rgba(255,77,77,.16); color: var(--red); }
.modal.face .m-icon { background: rgba(70,227,155,.14); color: var(--green); }
.modal .m-title { font-size: 14.5px; font-weight: 700; }
.modal .m-sub { font-size: 10px; color: var(--muted); font-family: var(--mono); letter-spacing: .08em; margin-top: 2px; }
.modal .m-close { margin-left: auto; cursor: pointer; color: var(--muted); background: none; border: 0; font-size: 18px; line-height: 1; }
.modal .m-close:hover { color: var(--text); }
.modal .m-body { padding: 14px 16px; }
.kv { display: grid; grid-template-columns: 84px 1fr; gap: 7px 10px; font-size: 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: #dceaff; font-family: var(--mono); font-size: 11.5px; }
.kv dd.hot { color: var(--amber); }
.kv dd.bad { color: var(--red); }
.kv dd.good { color: var(--green); }
.m-note {
  margin-top: 12px; padding: 9px 11px; border-radius: 8px; font-size: 11.5px; line-height: 1.65;
  background: rgba(79,227,255,.06); border: 1px solid rgba(79,227,255,.16); color: #a8c6e0;
}
.modal.intrusion .m-note { background: rgba(255,77,77,.08); border-color: rgba(255,77,77,.22); color: #ffbcbc; }
.m-actions { display: flex; gap: 8px; padding: 0 16px 15px; }
.m-actions button {
  flex: 1; padding: 9px 0; border-radius: 8px; cursor: pointer; font-size: 12px; font-weight: 600;
  color: var(--text); background: rgba(255,255,255,.05); border: 1px solid rgba(125,144,173,.22);
  transition: .2s;
}
.m-actions button:hover { background: rgba(255,255,255,.1); }
.m-actions button.go { color: #04121a; background: linear-gradient(135deg, var(--cyan), #6ee7ff); border-color: transparent; }
.m-actions button.stop { color: #2a0b0b; background: linear-gradient(135deg, #ff7a7a, var(--red)); border-color: transparent; }

/* 人脸卡片 */
.face-card { display: flex; gap: 13px; align-items: flex-start; }
.face-photo {
  width: 78px; height: 92px; border-radius: 9px; flex: 0 0 auto; position: relative; overflow: hidden;
  background: linear-gradient(180deg, #16263f, #0b1526);
  border: 1px solid rgba(125,144,173,.25);
}
.face-photo svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.face-photo .scan {
  position: absolute; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  box-shadow: 0 0 12px var(--cyan);
  animation: faceScan 1.8s linear infinite;
}
@keyframes faceScan { 0% { top: 4%; } 50% { top: 92%; } 100% { top: 4%; } }
.modal.intrusion .face-photo .scan { background: linear-gradient(90deg, transparent, var(--red), transparent); box-shadow: 0 0 12px var(--red); }
.face-meta { flex: 1; min-width: 0; }

/* ---------- 加载 ---------- */
.loading {
  position: absolute; inset: 0; z-index: 30; display: grid; place-items: center;
  background: radial-gradient(60% 50% at 50% 50%, #0a1424, #03060d);
  transition: opacity .6s;
}
.loading.hide { opacity: 0; pointer-events: none; }
.loading-inner { text-align: center; }
.ring {
  width: 62px; height: 62px; margin: 0 auto 18px; border-radius: 50%;
  border: 2px solid rgba(79,227,255,.15); border-top-color: var(--cyan);
  animation: spin 1s linear infinite;
  box-shadow: 0 0 30px rgba(79,227,255,.25);
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading p { font-size: 12px; color: var(--muted); letter-spacing: .16em; font-family: var(--mono); }

@media (max-width: 1500px) {
  .panel { width: 280px; }
  .kpibar { grid-template-columns: repeat(4, 1fr); height: auto; bottom: 58px; }
  .kpi b { font-size: 18px; }
}
