:root {
  --bg: #020a16;
  --panel: rgba(6, 26, 52, 0.62);
  --panel-line: rgba(56, 150, 230, 0.22);
  --accent: #3cd2ff;
  --accent-2: #2ee6d0;
  --text: #d8ecff;
  --dim: #7f9bbd;
  --faint: #4d6888;
  --on: #34f5c5;
  --pend: #ffb648;
  --off: #5d7590;
  --hot: #ff6a4a;
  --sans: "HarmonyOS Sans SC", "MiSans", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --num: "DIN Alternate", "Bahnschrift", "DIN", "Roboto Condensed", "Arial Narrow", var(--sans);
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, a { font: inherit; color: inherit; }

.scr {
  display: grid;
  grid-template-columns: 400px minmax(0, 1fr) 420px;
  grid-template-rows: 76px minmax(0, 1fr) 28px;
  grid-template-areas:
    "hd hd hd"
    "left stage right"
    "ft ft ft";
  height: 100vh;
  background:
    radial-gradient(ellipse 60% 70% at 50% 55%, rgba(18, 74, 130, 0.35), transparent 70%),
    linear-gradient(180deg, #03101f 0%, #020a16 100%);
}

/* ---------- 顶栏 ---------- */
.hd {
  grid-area: hd;
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 24px;
  background: linear-gradient(180deg, rgba(10, 40, 78, 0.85), rgba(4, 18, 36, 0.4));
  border-bottom: 1px solid rgba(60, 170, 255, 0.28);
}
.hd::before, .hd::after {
  content: "";
  position: absolute;
  bottom: -2px;
  width: 120px;
  height: 3px;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(60, 210, 255, 0.7);
}
.hd::before { left: 24px; }
.hd::after { right: 24px; }
.hd-l { display: flex; align-items: center; gap: 14px; }
.hd-title b { display: block; font-size: 24px; font-weight: 700; letter-spacing: 0.06em; color: #fff; line-height: 1.15; }
.hd-title span { display: block; font-size: 12px; letter-spacing: 0.32em; color: var(--dim); }

.hd-tabs { display: flex; gap: 8px; }
.hd-tabs button {
  position: relative;
  min-width: 150px;
  height: 40px;
  padding: 0 24px;
  border: 1px solid rgba(60, 170, 255, 0.25);
  background: linear-gradient(180deg, rgba(20, 70, 130, 0.25), rgba(20, 70, 130, 0.05));
  color: var(--dim);
  font-size: 16px;
  letter-spacing: 0.12em;
  cursor: pointer;
  clip-path: polygon(12px 0, 100% 0, calc(100% - 12px) 100%, 0 100%);
}
.hd-tabs button:hover { color: var(--text); }
.hd-tabs button.on {
  color: #fff;
  border-color: rgba(60, 210, 255, 0.6);
  background: linear-gradient(180deg, rgba(30, 120, 210, 0.55), rgba(30, 120, 210, 0.12));
  text-shadow: 0 0 10px rgba(60, 210, 255, 0.8);
}
.hd-tabs i { position: absolute; left: 12px; right: 12px; bottom: 0; height: 2px; background: rgba(60, 210, 255, 0.15); }
.hd-tabs i::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--p, 0%); background: var(--accent); }
.hd-tabs button:not(.on) i { visibility: hidden; }

.hd-r { display: flex; align-items: center; justify-content: flex-end; gap: 22px; }
.hd-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--dim); }
.hd-status .err { color: var(--hot); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--off); }
.dot.on { background: var(--on); box-shadow: 0 0 6px var(--on); }
.dot.bad { background: var(--hot); box-shadow: 0 0 6px var(--hot); }
.hd-time { text-align: right; line-height: 1.1; }
.hd-time b { display: block; font-family: var(--num); font-size: 30px; font-weight: 600; letter-spacing: 0.04em; color: #fff; font-variant-numeric: tabular-nums; }
.hd-time span { font-size: 12px; color: var(--dim); }
.hd-btns { display: flex; gap: 6px; }
.hd-btns button, .hd-btns a {
  padding: 3px 10px;
  border: 1px solid rgba(60, 170, 255, 0.3);
  background: rgba(20, 70, 130, 0.2);
  color: var(--dim);
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
}
.hd-btns button:hover, .hd-btns a:hover { color: #fff; border-color: var(--accent); }

/* ---------- 面板 ---------- */
.side { min-height: 0; display: flex; flex-direction: column; gap: 12px; padding: 14px; position: relative; z-index: 2; }
.side-l { grid-area: left; }
.side-r { grid-area: right; }

.panel {
  --c: rgba(60, 210, 255, 0.85);
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--panel-line);
  background:
    linear-gradient(var(--c), var(--c)) top left / 12px 2px no-repeat,
    linear-gradient(var(--c), var(--c)) top left / 2px 12px no-repeat,
    linear-gradient(var(--c), var(--c)) top right / 12px 2px no-repeat,
    linear-gradient(var(--c), var(--c)) top right / 2px 12px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / 12px 2px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / 2px 12px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / 12px 2px no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / 2px 12px no-repeat,
    var(--panel);
}
.ph {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  margin: 0;
  padding: 0 14px;
  flex: none;
  font-size: 15px;
  font-weight: 600;
  background: linear-gradient(90deg, rgba(40, 140, 240, 0.35), rgba(40, 140, 240, 0) 75%);
  border-bottom: 1px solid rgba(60, 170, 255, 0.25);
}
.ph::before {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--accent);
  transform: rotate(45deg);
  box-shadow: 0 0 6px var(--accent);
}
.ph b { font-weight: 600; letter-spacing: 0.08em; color: #fff; }
.ph small { margin-left: auto; font-size: 12px; font-weight: 400; color: var(--dim); }
.pb { padding: 12px 14px; min-height: 0; }

/* 设备概况 */
.kpi-top { display: flex; align-items: center; gap: 16px; }
.kpi-big { flex: 1; }
.kpi-big span, .kpi-grid span { display: block; font-size: 12px; color: var(--dim); }
.kpi-big b { font-family: var(--num); font-size: 52px; line-height: 1; font-weight: 600; color: var(--accent-2); text-shadow: 0 0 14px rgba(46, 230, 208, 0.45); }
.kpi-big i { font-style: normal; font-family: var(--num); font-size: 22px; color: var(--faint); margin-left: 6px; }
.donut { width: 84px; height: 84px; flex: none; }
.donut circle { fill: none; stroke-width: 7; }
.donut .bg { stroke: rgba(60, 170, 255, 0.15); }
.donut .fg { stroke: var(--accent-2); stroke-linecap: butt; }
.donut text { fill: #fff; font-family: var(--num); font-size: 18px; font-weight: 600; text-anchor: middle; dominant-baseline: central; }
.donut .u { font-size: 10px; fill: var(--dim); }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 12px; padding-top: 10px; border-top: 1px dashed rgba(60, 170, 255, 0.2); }
.kpi-grid b { display: block; font-family: var(--num); font-size: 24px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-grid b small { font-size: 11px; color: var(--faint); margin-left: 2px; font-weight: 400; }
.kpi-grid b.warn { color: var(--pend); }
.kpi-grid b.hot { color: var(--hot); }
.kpi-grid b.cy { color: var(--accent); }

/* 网络 */
.p-nets .pb { display: flex; flex-direction: column; gap: 12px; max-height: 230px; overflow: hidden; }
.net-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.net-h b { font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.net-h span { font-family: var(--num); font-size: 20px; color: var(--accent-2); flex: none; }
.net-h span small { color: var(--faint); font-size: 13px; }
.net-s { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.cells { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 6px; }
.cells i { width: 12px; height: 8px; background: rgba(93, 117, 144, 0.35); transform: skewX(-20deg); }
.cells i.on { background: var(--on); box-shadow: 0 0 4px rgba(52, 245, 197, 0.6); }
.cells i.hot { background: var(--hot); }
.cells i.pend { background: var(--pend); }

/* 地域分布 */
.reg { display: grid; grid-template-columns: 72px minmax(0, 1fr) 54px; align-items: center; gap: 10px; height: 26px; }
.reg span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.reg svg { width: 100%; height: 8px; display: block; }
.reg rect.t { fill: rgba(60, 170, 255, 0.35); }
.reg rect.o { fill: var(--accent-2); }
.reg b { font-family: var(--num); font-weight: 600; text-align: right; font-size: 15px; }
.reg b small { color: var(--faint); font-weight: 400; }
.reg-empty { color: var(--faint); font-size: 12px; padding: 6px 0; }

/* 实时事件 */
.p-log { flex: 1; }
.p-log ol { list-style: none; margin: 0; overflow: hidden; flex: 1; }
.p-log li { position: relative; padding: 0 0 10px 16px; animation: ev-in 0.4s ease-out; }
.p-log li::before { content: ""; position: absolute; left: 2px; top: 6px; width: 7px; height: 7px; border-radius: 50%; border: 1px solid var(--accent); }
.p-log li::after { content: ""; position: absolute; left: 5px; top: 16px; bottom: 0; width: 1px; background: rgba(60, 170, 255, 0.2); }
.p-log time { display: block; font-family: var(--mono); font-size: 11px; color: var(--faint); }
.p-log .t { display: inline-block; margin-right: 8px; padding: 0 6px; font-size: 12px; line-height: 18px; border: 1px solid currentColor; }
.p-log .t.on { color: var(--on); }
.p-log .t.off { color: var(--off); }
.p-log .t.pend { color: var(--pend); }
.p-log .t.hot { color: var(--hot); }
.p-log .t.sys { color: var(--accent); }
.p-log li em { display: block; font-style: normal; font-family: var(--mono); font-size: 11px; color: var(--faint); }

@keyframes ev-in {
  from { opacity: 0; transform: translateX(-6px); }
  to { opacity: 1; transform: none; }
}

/* 设备列表 */
.p-devs { flex: 1; }
.devs { flex: 1; overflow-y: auto; padding-top: 4px; scrollbar-width: thin; scrollbar-color: rgba(60, 170, 255, 0.3) transparent; }
.dev {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) 64px 58px;
  align-items: center;
  gap: 12px;
  padding: 9px 6px;
  border-bottom: 1px solid rgba(60, 170, 255, 0.1);
}
.dev:hover, .dev.hl { background: rgba(40, 140, 240, 0.14); }
.dev .g { width: 8px; height: 8px; border: 1px solid var(--off); }
.dev.s-online .g { background: var(--on); border-color: var(--on); box-shadow: 0 0 5px var(--on); }
.dev.s-hot .g { background: var(--hot); border-color: var(--hot); }
.dev.s-pending .g { background: var(--pend); border-color: var(--pend); transform: rotate(45deg) scale(0.9); }
.dev .dn { min-width: 0; }
.dev .dn b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev .dn span { display: block; font-family: var(--mono); font-size: 11px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev.s-offline .dn b { color: var(--dim); }
.dev .spark { width: 64px; height: 20px; overflow: visible; }
.dev .spark polyline { fill: none; stroke: var(--on); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.dev.s-hot .spark polyline { stroke: var(--hot); }
.dev .lat { text-align: right; font-family: var(--num); font-size: 18px; font-variant-numeric: tabular-nums; line-height: 1; }
.dev .lat small { font-size: 11px; color: var(--faint); margin-left: 2px; }
.dev .lat.txt { font-family: var(--sans); font-size: 12px; color: var(--faint); }
.dev.s-pending .lat.txt { color: var(--pend); }
.dev.s-hot .lat { color: var(--hot); }

/* ---------- 地图 ---------- */
.stage { grid-area: stage; position: relative; min-height: 0; overflow: hidden; }
#viz { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
#viz.dragging { cursor: grabbing; }
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.labels[hidden] { display: none; }
.fade { position: absolute; inset: 0; background: var(--bg); opacity: 0; pointer-events: none; transition: opacity 0.45s ease; }
.fade.on { opacity: 1; }

.stage-top { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; pointer-events: none; }
.chip {
  min-width: 128px;
  padding: 6px 16px 8px;
  text-align: center;
  border: 1px solid rgba(60, 170, 255, 0.25);
  background: linear-gradient(180deg, rgba(20, 80, 150, 0.35), rgba(20, 80, 150, 0.05));
}
.chip span { display: block; font-size: 12px; color: var(--dim); }
.chip b { font-family: var(--num); font-size: 24px; font-weight: 600; line-height: 1.15; color: #fff; }
.chip b small { font-size: 12px; color: var(--faint); margin-left: 3px; font-weight: 400; }
.chip b.txt { font-family: var(--sans); font-size: 18px; }

.stage-note {
  position: absolute;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  border: 1px solid rgba(255, 182, 72, 0.4);
  background: rgba(40, 26, 6, 0.6);
  color: var(--pend);
  font-size: 12px;
  pointer-events: none;
}

.legend { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; gap: 20px; margin: 0; padding: 6px 16px; list-style: none; color: var(--dim); font-size: 12px; pointer-events: none; background: rgba(4, 18, 36, 0.6); border: 1px solid rgba(60, 170, 255, 0.15); white-space: nowrap; }
.legend li { display: flex; align-items: center; gap: 7px; }
.legend i { width: 20px; height: 0; border-top: 2px solid var(--on); }
.legend .lg-srv { width: 10px; height: 10px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 0 6px var(--accent), 0 0 0 3px rgba(60, 210, 255, 0.35); }
.legend .lg-hot { border-top-color: var(--hot); }
.legend .lg-pend { border-top: 2px dashed var(--pend); }
.legend .lg-off { border-top: 2px dotted var(--off); }
.hint { position: absolute; right: 18px; bottom: 22px; color: var(--faint); font-size: 11px; pointer-events: none; }

.ft {
  grid-area: ft;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid rgba(60, 170, 255, 0.18);
  background: rgba(2, 10, 22, 0.85);
  color: var(--faint);
  font-size: 12px;
  letter-spacing: 0.18em;
  z-index: 3;
}
.ft span { color: var(--dim); }

/* 地图上的文字（由脚本按三维坐标定位） */
.lbl { position: absolute; left: 0; top: 0; white-space: nowrap; will-change: transform; }
.lbl[hidden] { display: none; }
.lbl > div { position: absolute; }
.lbl.city > div {
  transform: translate(10px, -50%);
  padding: 2px 8px;
  border-left: 2px solid var(--on);
  background: linear-gradient(90deg, rgba(6, 30, 60, 0.85), rgba(6, 30, 60, 0.25));
  font-size: 12px;
  line-height: 1.35;
}
.lbl.city b { display: block; font-weight: 600; color: #fff; }
.lbl.city span { display: block; font-family: var(--mono); font-size: 11px; color: var(--on); }
.lbl.city.s-hot > div { border-left-color: var(--hot); }
.lbl.city.s-hot span { color: var(--hot); }
.lbl.city.s-pending > div { border-left-color: var(--pend); }
.lbl.city.s-pending span { color: var(--pend); }
.lbl.city.s-offline > div { border-left-color: var(--off); background: rgba(6, 20, 40, 0.5); }
.lbl.city.s-offline b { color: var(--dim); font-weight: 400; }
.lbl.city.s-offline span { color: var(--faint); }
.lbl.city.hl > div { background: rgba(30, 110, 200, 0.75); }
.lbl.srv > div {
  transform: translate(-50%, calc(-100% - 14px));
  padding: 3px 10px;
  text-align: center;
  border: 1px solid rgba(60, 210, 255, 0.7);
  background: rgba(8, 50, 100, 0.85);
  box-shadow: 0 0 12px rgba(60, 210, 255, 0.35);
}
.lbl.srv b { display: block; font-size: 13px; color: #fff; letter-spacing: 0.06em; }
.lbl.srv span { display: block; font-size: 11px; color: var(--accent); }
.lbl.prov > div { transform: translate(-50%, -50%); font-size: 11px; color: rgba(140, 190, 240, 0.5); }
.lbl.prov.has > div { color: #cfe8ff; font-weight: 600; }

.tip {
  position: absolute;
  z-index: 3;
  min-width: 250px;
  max-width: 340px;
  padding: 10px 12px;
  background: rgba(4, 22, 46, 0.94);
  border: 1px solid rgba(60, 210, 255, 0.45);
  pointer-events: none;
  font-size: 12px;
}
.tip > b { display: block; font-size: 14px; color: #fff; }
.tip > small { display: block; color: var(--faint); margin-bottom: 6px; }
.tip ul { list-style: none; margin: 0; padding: 6px 0 0; border-top: 1px solid rgba(60, 170, 255, 0.2); }
.tip li { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; gap: 8px; align-items: center; line-height: 20px; }
.tip li i { width: 7px; height: 7px; background: var(--off); }
.tip li.s-online i { background: var(--on); }
.tip li.s-hot i { background: var(--hot); }
.tip li.s-pending i { background: var(--pend); }
.tip li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tip li em { font-style: normal; font-family: var(--mono); color: var(--dim); }

@media (max-width: 1600px) {
  .scr { grid-template-columns: 340px minmax(0, 1fr) 360px; }
  .hd-tabs button { min-width: 120px; }
  .kpi-big b { font-size: 44px; }
  .dev { grid-template-columns: 10px minmax(0, 1fr) 50px 54px; }
  .dev .spark { width: 50px; }
  .stage-top .chip { min-width: 100px; padding: 4px 10px 6px; }
  .legend { gap: 12px; }
  .hint { display: none; }
}
