:root {
  --bg: #EEF0EC;
  --card: rgba(255, 255, 255, 0.92);
  --card-solid: #FFFFFF;
  --ink: #15191E;
  --ink-2: #4A535D;
  --muted: #8A929B;
  --line: #DDE1DC;
  --soft: rgba(20, 30, 40, 0.04);
  --accent: #E8612C;
  --accent-ink: #FFFFFF;
  --ok: #17A673;
  --warn: #E59A0B;
  --alarm: #E5383B;
  --off: #8A929B;
  --dead: #B9BFC5;
  --shadow: 0 6px 24px rgba(20, 28, 36, 0.08), 0 1px 3px rgba(20, 28, 36, 0.06);
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0E1318;
  --card: rgba(22, 29, 37, 0.9);
  --card-solid: #161D25;
  --ink: #EEF2F5;
  --ink-2: #A9B3BD;
  --muted: #6E7A86;
  --line: #2A3542;
  --soft: rgba(255, 255, 255, 0.04);
  --off: #6E7A86;
  --dead: #46515C;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; }
body { background: var(--bg); color: var(--ink); font: 13px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

#viewport { position: fixed; inset: 0; }
#viewport canvas { display: block; outline: none; touch-action: none; }
#labels { position: fixed; inset: 0; pointer-events: none; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.muted { color: var(--muted); }

/* ---------- 顶部 HUD ---------- */
.hud.top {
  position: fixed; top: 16px; left: 16px; right: 16px; z-index: 10;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  pointer-events: none;
}
.hud.top > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 12px; padding: 10px 16px 10px 12px; min-width: 0; }
.logo { width: 32px; height: 32px; flex: none; border-radius: 9px; background: var(--accent); display: grid; place-items: center; }
.logo svg { width: 18px; height: 18px; fill: #fff; stroke: none; }
.brand h1 { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.brand p { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

.kpis { display: flex; padding: 6px; gap: 4px; }
.kpi { display: flex; flex-direction: column; padding: 5px 12px; border-radius: 8px; min-width: 96px; }
.kpi span { font-size: 11px; color: var(--muted); white-space: nowrap; }
.kpi b { font: 700 16px/1.3 var(--mono); white-space: nowrap; font-variant-numeric: tabular-nums; }
.kpi b small { font-size: 10.5px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.kpi b.warn { color: var(--warn); }
.kpi b.alarm { color: var(--alarm); }

.actions { display: flex; gap: 8px; align-items: center; }
.btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.icon { width: 36px; padding: 0; justify-content: center; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn em.minor, .ptabs em.minor { background: var(--warn); }
.btn em { font-style: normal; background: var(--alarm); color: #fff; border-radius: 9px; min-width: 18px; height: 18px; padding: 0 5px; font-size: 11px; display: inline-grid; place-items: center; }
.select { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 6px 0 12px; border-radius: 10px; font-size: 12.5px; font-weight: 600; }
.select span { color: var(--muted); font-weight: 500; }
.select select { border: 0; background: transparent; font-weight: 600; padding: 4px; outline: none; max-width: 170px; }
.select select option { background: var(--card-solid); }

/* ---------- 断线横幅 ---------- */
.banner {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%); z-index: 30;
  background: var(--alarm); color: #fff; font-weight: 600; font-size: 12.5px;
  padding: 6px 16px; border-radius: 0 0 10px 10px; box-shadow: var(--shadow);
}

/* ---------- 事件 ---------- */
.side-panel { position: fixed; z-index: 11; top: 84px; left: 16px; width: 340px; max-height: calc(100vh - 170px); display: flex; flex-direction: column; }
.side-panel header { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px 8px; border-bottom: 1px solid var(--line); }
.side-panel h2 { font-size: 13.5px; }
.side-panel header span { font-size: 11px; color: var(--muted); }
#events ol { list-style: none; overflow-y: auto; padding: 6px 0; }
#events li { display: grid; grid-template-columns: 8px 1fr; gap: 4px 10px; padding: 7px 14px; }
#events li i { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; background: var(--off); }
#events li.WARN i { background: var(--warn); }
#events li.ALARM i { background: var(--alarm); }
#events li.INFO i { background: var(--ok); }
#events li p { font-size: 12.5px; }
#events li time { grid-column: 2; font: 11px var(--mono); color: var(--muted); }
.side-panel .empty { padding: 14px; color: var(--muted); }

#events li[data-device] { cursor: pointer; }
#events li[data-device]:hover { background: var(--soft); }

/* ---------- 设备列表 ---------- */
.device-list { overflow-y: auto; padding: 4px 0 8px; }
.device-list h3 { font-size: 11px; font-weight: 600; color: var(--muted); padding: 10px 14px 4px; letter-spacing: 0.04em; }
.dev-row { display: grid; grid-template-columns: 8px 40px 1fr auto; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; padding: 7px 14px; text-align: left; }
.dev-row:hover, .dev-row.selected { background: var(--soft); }
.dev-row.selected { box-shadow: inset 3px 0 0 var(--accent); }
.dev-row b { font: 700 12px var(--mono); }
.dev-row span { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dev-row small { font: 11.5px var(--mono); color: var(--ink-2); white-space: nowrap; }
.dev-row .dot.ok { background: var(--ok); }

/* ---------- 视角 / 图例 ---------- */
.views { position: fixed; z-index: 10; bottom: 16px; left: calc((100% - 356px) / 2); transform: translateX(-50%); display: flex; gap: 4px; padding: 5px; }
.views button { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; font-weight: 600; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.views button:hover { background: var(--soft); color: var(--ink); }
.views button.active { background: var(--ink); color: var(--bg); }

.legend { position: fixed; z-index: 10; left: 16px; bottom: 16px; display: flex; gap: 12px; padding: 9px 14px; font-size: 11.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.alarm { background: var(--alarm); }
.dot.off { background: var(--off); }
.dot.dead { background: transparent; border: 1.5px dashed var(--muted); }
.dot.andon-green { background: #22C55E; }
.dot.andon-yellow { background: #F5B400; }
.dot.andon-red, .dot.andon-red_flash { background: #EF2B2B; }
.dot.andon-red_flash { animation: blink 0.76s infinite; }
.dot.andon-off { background: transparent; border: 1.5px solid var(--muted); }
.legend .lg-title { font-weight: 600; color: var(--ink); }
.lamp { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.lamp.red { background: #E5383B; box-shadow: 0 0 5px #E5383B; }
.lamp.green { background: #17A673; box-shadow: 0 0 5px #17A673; }
.lamp-note { border-left: 1px solid var(--line); padding-left: 12px; }

.heat-legend { position: fixed; z-index: 10; left: 16px; bottom: 64px; padding: 10px 14px; width: 220px; font-size: 11px; color: var(--ink-2); }
.hl-title { font-weight: 600; color: var(--ink); }
.hl-bar { height: 8px; border-radius: 4px; margin: 6px 0 4px; background: linear-gradient(90deg, hsl(223 75% 50%), hsl(180 75% 50%), hsl(120 75% 45%), hsl(55 85% 50%), hsl(0 75% 50%)); }
.hl-scale { display: flex; justify-content: space-between; font-family: var(--mono); }

/* ---------- 3D 导航控件 ---------- */
.navpad { position: fixed; z-index: 12; right: 364px; bottom: 16px; display: flex; align-items: flex-end; gap: 8px; transition: right 0.35s cubic-bezier(0.16, 1, 0.3, 1); user-select: none; -webkit-user-select: none; }
.dpad { display: grid; grid-template-columns: repeat(3, 34px); grid-template-rows: repeat(3, 34px); gap: 2px; padding: 6px; border-radius: 50%; }
.dpad button, .tools button { border: 0; background: transparent; border-radius: 8px; display: grid; place-items: center; color: var(--ink-2); touch-action: none; }
.dpad button:hover, .tools button:hover { background: var(--soft); color: var(--ink); }
.dpad button:active, .tools button:active, .dpad button.held, .tools button.held { background: var(--accent); color: var(--accent-ink); }
.dpad .up { grid-area: 1 / 2; }
.dpad .left { grid-area: 2 / 1; }
.dpad .center { grid-area: 2 / 2; border-radius: 50%; background: var(--soft); }
.dpad .right { grid-area: 2 / 3; }
.dpad .down { grid-area: 3 / 2; }
.dpad svg { width: 18px; height: 18px; }
.tools { display: flex; flex-direction: column; padding: 5px; gap: 2px; }
.tools button { width: 34px; height: 32px; }
.tools button.on { color: var(--accent); background: rgba(232, 97, 44, 0.12); }
.tools .sep { height: 1px; margin: 3px 6px; background: var(--line); }

/* ---------- 悬停信息卡 ---------- */
.hover-card { position: fixed; z-index: 25; width: 272px; padding: 12px 14px; pointer-events: none; background: var(--card-solid); }
.hover-card h4 { font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.hover-card h4 .pill { font-size: 10.5px; padding: 1px 8px; }
.hover-card .hc-sub { font: 11px var(--mono); color: var(--muted); margin: 2px 0 8px; }
.hover-card dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 12px; }
.hover-card dt { color: var(--muted); }
.hover-card dd { font: 600 12px var(--mono); text-align: right; }
.hover-card dd.warn { color: var(--warn); }
.hover-card dd.alarm { color: var(--alarm); }
.hover-card .hc-foot { margin-top: 8px; padding-top: 7px; border-top: 1px dashed var(--line); font-size: 11.5px; color: var(--accent); }

/* ---------- 设备标签 (CSS2D) ---------- */
.tag { pointer-events: auto; cursor: pointer; transform: translateY(-4px); }
.tag .pill-3d {
  display: flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 7px;
  background: var(--card); border: 1px solid var(--line); box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
  font: 600 11px var(--mono); white-space: nowrap; color: var(--ink);
  transition: transform 0.15s, border-color 0.15s;
}
.tag:hover .pill-3d, .tag.selected .pill-3d { border-color: var(--accent); transform: scale(1.06); box-shadow: 0 0 0 3px rgba(232, 97, 44, 0.2), 0 4px 12px rgba(0, 0, 0, 0.15); }
.tag .pill-3d .val { color: var(--ink-2); font-weight: 500; }
.tag .pill-3d .dot { box-shadow: 0 0 6px currentColor; }
.tag.andon-green .dot { background: #22C55E; color: #22C55E; }
.tag.andon-yellow .dot { background: #F5B400; color: #F5B400; }
.tag.andon-red .dot { background: #EF2B2B; color: #EF2B2B; }
.tag.andon-red_flash .dot { background: #EF2B2B; color: #EF2B2B; animation: blink 0.76s infinite; }
.tag.andon-off .dot { background: transparent; border: 1.5px solid var(--muted); box-shadow: none; }
.tag.andon-off .pill-3d, .tag.stale .pill-3d { opacity: 0.65; }
@keyframes blink { 50% { opacity: 0.35; } }

/* ---------- 详情抽屉 ---------- */
.drawer {
  position: fixed; z-index: 20; top: 84px; right: 16px; bottom: 16px; width: 340px;
  display: flex; flex-direction: column;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.d-head-text { min-width: 0; }
.back { display: inline-flex; align-items: center; gap: 2px; height: 30px; padding: 0 10px 0 6px; border-radius: 8px; border: 1px solid var(--line); background: transparent; font-size: 12px; font-weight: 600; color: var(--ink-2); flex: none; white-space: nowrap; }
.back:hover { color: var(--ink); border-color: var(--muted); }
.collapse { display: none; width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: transparent; place-items: center; color: var(--ink-2); flex: none; }
.drawer:not(.collapsed) .collapse svg { transform: rotate(180deg); }
.trend-head h3 small { font-weight: 500; color: var(--muted); font-size: 11px; margin-left: 4px; }
#ov-mon, #dev-mon { display: flex; flex-direction: column; gap: 12px; }
.ov-block h3, .pane > h3 { margin-bottom: 4px; }
.device-list.in-panel { padding: 0; margin: 0 -6px; }
.device-list.in-panel h3 { padding: 8px 6px 2px; }
.device-list.in-panel .dev-row { padding: 6px; border-radius: 6px; grid-template-columns: 8px 34px 1fr auto; }
.plan-list { display: flex; flex-direction: column; margin: 0 -6px; }
.plan-row { display: grid; grid-template-columns: 30px 1fr auto 74px; gap: 8px; align-items: center; border: 0; background: transparent; padding: 6px; border-radius: 6px; text-align: left; font-size: 12px; }
.plan-row:hover { background: var(--soft); }
.plan-row b { font: 700 12px var(--mono); }
.plan-row span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plan-row small { font: 11px var(--mono); color: var(--muted); }
.plan-row em { font-style: normal; font: 600 11.5px var(--mono); text-align: right; color: var(--ink-2); white-space: nowrap; }
.plan-row.warn em { color: var(--warn); }
.plan-row.alarm em { color: var(--alarm); }
.timeline li[data-device] { cursor: pointer; }
.drawer > header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 16px 12px; border-bottom: 1px solid var(--line); }
.drawer h2 { font-size: 15px; }
.drawer header p { font: 11px var(--mono); color: var(--muted); margin-top: 2px; }
.close { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: transparent; display: grid; place-items: center; color: var(--ink-2); flex: none; }
.close:hover { color: var(--ink); border-color: var(--muted); }
.drawer-head { padding: 12px 16px 0; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--line); }
.ptabs { display: flex; gap: 18px; }
.ptabs button { border: 0; background: transparent; padding: 6px 0 9px; font-weight: 600; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; align-items: center; gap: 5px; }
.ptabs button.active { color: var(--ink); border-bottom-color: var(--accent); }
.ptabs em { font-style: normal; background: var(--alarm); color: #fff; border-radius: 9px; min-width: 16px; height: 16px; padding: 0 4px; font-size: 10.5px; display: inline-grid; place-items: center; }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px 16px 16px; }
.pane { display: flex; flex-direction: column; gap: 12px; }

/* 台账 */
.ledger { display: grid; grid-template-columns: 88px 1fr; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.ledger dt, .ledger dd { padding: 8px 11px; font-size: 12px; border-bottom: 1px solid var(--line); }
.ledger dt { color: var(--muted); background: var(--soft); }
.ledger dd { color: var(--ink); word-break: break-all; }
.ledger dd.mono { font-family: var(--mono); }
.ledger dt:nth-last-of-type(1), .ledger dd:nth-last-of-type(1) { border-bottom: 0; }
.pane-note { font-size: 11px; color: var(--muted); }

/* 运维 */
.ops-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.ops-card { border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; background: var(--soft); }
.ops-card span { display: block; font-size: 11px; color: var(--muted); }
.ops-card b { font: 700 16px/1.4 var(--mono); }
.ops-card b small { font-size: 10.5px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.ops-card p { font-size: 11px; color: var(--ink-2); margin-top: 2px; }
.ops-card.warn b { color: var(--warn); }
.ops-card.alarm b { color: var(--alarm); }
.ops-card .bar { height: 5px; background: var(--line); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.ops-card .bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.timeline { list-style: none; display: flex; flex-direction: column; }
.timeline li { position: relative; padding: 0 0 14px 18px; }
.timeline li::before { content: ''; position: absolute; left: 4px; top: 6px; bottom: -6px; width: 1px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ''; position: absolute; left: 0; top: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); }
.timeline li.pending::after { background: var(--alarm); }
.timeline li.fixed::after { background: var(--warn); }
.tl-head { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.tl-head time { font: 11.5px var(--mono); color: var(--muted); }
.tl-head .kind { font-weight: 600; }
.tl-head .res { margin-left: auto; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--soft); color: var(--ink-2); }
.timeline li.pending .res { background: rgba(229, 56, 59, 0.12); color: var(--alarm); }
.timeline li p { font-size: 12.5px; margin-top: 3px; }
.timeline li small { font-size: 11px; color: var(--muted); }
.drawer h3 { font-size: 12.5px; font-weight: 600; }

.status-row { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.pill { font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 20px; background: var(--soft); }
.pill.ok { background: rgba(23, 166, 115, 0.12); color: var(--ok); }
.pill.warn { background: rgba(229, 154, 11, 0.14); color: var(--warn); }
.pill.alarm { background: rgba(229, 56, 59, 0.13); color: var(--alarm); }
.pill.off, .pill.dead { color: var(--muted); }

.breaker { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); }
.breaker p { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.op { border: 0; border-radius: 8px; padding: 8px 14px; font-weight: 700; font-size: 12px; white-space: nowrap; }
.op.to-open { background: rgba(23, 166, 115, 0.14); color: var(--ok); }
.op.to-close { background: rgba(229, 56, 59, 0.12); color: var(--alarm); }
.op:hover { filter: brightness(0.95); }

.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.metric { border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; background: var(--soft); min-width: 0; }
.metric span { display: block; font-size: 11px; color: var(--muted); }
.metric b { font: 700 16px/1.35 var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.metric b small { font-size: 10.5px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.metric.warn b { color: var(--warn); }
.metric.alarm b { color: var(--alarm); }

.phases { display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; background: var(--soft); }
.phases:empty { display: none; }
.phase { display: grid; grid-template-columns: 18px 1fr 64px; align-items: center; gap: 8px; font: 11.5px var(--mono); }
.phase i { width: 18px; height: 18px; border-radius: 4px; display: grid; place-items: center; color: #fff; font: 700 10px var(--mono); font-style: normal; }
.phase .track { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.phase .fill { height: 100%; border-radius: 3px; transition: width 0.4s; }
.phase span { text-align: right; }

.extra { display: flex; flex-direction: column; gap: 6px; }
.extra:empty { display: none; }
.extra-row { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.extra-row b { font: 600 12px var(--mono); }
.steps { display: flex; gap: 4px; }
.steps i { width: 14px; height: 14px; border-radius: 3px; background: var(--line); }
.steps i.on { background: var(--accent); }

.trend { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--soft); }
.trend-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.tabs { display: flex; gap: 2px; background: var(--line); padding: 2px; border-radius: 7px; }
.tabs button { border: 0; background: transparent; border-radius: 5px; padding: 3px 9px; font-size: 11.5px; font-weight: 600; color: var(--ink-2); }
.tabs button.active { background: var(--card-solid); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); }
#d-chart { width: 100%; height: 130px; display: block; }
.chart-note { font: 11px var(--mono); color: var(--muted); margin-top: 4px; }

/* ---------- 对话框 / 提示 ---------- */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(10, 14, 18, 0.4); display: grid; place-items: center; padding: 16px; }
.dialog { width: 380px; max-width: 100%; padding: 20px; display: flex; flex-direction: column; gap: 12px; background: var(--card-solid); }
.dialog h2 { font-size: 16px; }
.dialog p { color: var(--ink-2); }
.dialog label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.dialog input { height: 38px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; background: var(--bg); outline: none; }
.dialog input:focus { border-color: var(--accent); }
.modal-error { color: var(--alarm) !important; font-size: 12px; min-height: 1em; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast { position: fixed; z-index: 45; bottom: 72px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 10px; font-weight: 600; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.toast.error { background: var(--alarm); color: #fff; }

.fatal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.fatal .card { max-width: 440px; padding: 24px; }
.fatal h2 { font-size: 17px; margin-bottom: 8px; }
.fatal p { color: var(--ink-2); }

/* ---------- 窄屏 ---------- */
@media (max-width: 1280px) {
  .kpi:nth-child(n+5) { display: none; }
}
@media (max-width: 1020px) {
  .kpis { display: none; }
  .legend { display: none; }
  .heat-legend { bottom: 16px; }
}
@media (max-width: 640px) {
  .hud.top { flex-wrap: wrap; }
  .brand { flex: 1 1 100%; }
  .actions { flex: 1 1 100%; }
  .select { flex: 1; }
  .select select { max-width: none; flex: 1; }
  .side-panel { top: 128px; left: 16px; right: 16px; width: auto; }
  .drawer { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 62vh; border-radius: 16px 16px 0 0; }
  .drawer.collapsed { transform: translateY(calc(100% - 64px)); }
  .drawer > header { cursor: pointer; }
  .collapse { display: grid; }
  .views { left: 16px; right: 16px; bottom: 76px; transform: none; overflow-x: auto; }
  .views button { padding: 7px 10px; }
  .tag .pill-3d { padding: 3px 6px; gap: 4px; font-size: 10px; }
  .tag .pill-3d .val { display: none; }
  .navpad { bottom: 132px; right: 16px; }
  .dpad { grid-template-columns: repeat(3, 30px); grid-template-rows: repeat(3, 30px); }
  .tools button { width: 30px; height: 28px; }
  .tools #nav-full, .tools #nav-auto { display: none; }
  body.panel-expanded .navpad, body.panel-expanded .views { display: none; }
  .hover-card { display: none; }
  .heat-legend { bottom: 132px; width: 180px; }
}

/* ---------- 告警页签 ---------- */
.ops-cards.four { grid-template-columns: repeat(4, 1fr); gap: 6px; }
.ops-cards.four .ops-card { padding: 8px 10px; text-align: center; }
.ops-card.ok b { color: #16A34A; }
.chip { font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 10px; white-space: nowrap; }
.chip.urgent { background: #EF2B2B; color: #fff; }
.chip.major { background: rgba(239, 43, 43, 0.13); color: #DC2626; }
.chip.minor { background: rgba(245, 180, 0, 0.18); color: #B7791F; }
:root[data-theme="dark"] .chip.minor { color: #F5B400; }
.al-list, .ev-list { list-style: none; display: flex; flex-direction: column; margin: 0 -6px; }
.al-item { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; padding: 8px 6px; border-radius: 8px; cursor: pointer; border-left: 3px solid transparent; }
.al-item:hover { background: var(--soft); }
.al-item.urgent { border-left-color: #EF2B2B; background: rgba(239, 43, 43, 0.06); }
.al-item.major { border-left-color: #F87171; }
.al-item.minor { border-left-color: #F5B400; }
.al-item .chip { align-self: start; margin-top: 1px; }
.al-item b { font-size: 12.5px; }
.al-item p { font-size: 12px; color: var(--ink-2); margin-top: 1px; }
.al-item time { grid-column: 2; font: 11px var(--mono); color: var(--muted); }
.ev { display: grid; grid-template-columns: 8px 1fr; gap: 2px 10px; padding: 6px; border-radius: 6px; }
.ev[data-device] { cursor: pointer; }
.ev[data-device]:hover { background: var(--soft); }
.ev i { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; background: var(--ok); }
.ev.urgent i, .ev.major i { background: #EF2B2B; }
.ev.minor i { background: #F5B400; }
.ev p { font-size: 12px; }
.ev time { grid-column: 2; font: 11px var(--mono); color: var(--muted); }
.andon-card { display: flex; gap: 14px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--soft); }
.andon-card span { font-size: 11px; color: var(--muted); }
.andon-card b { display: block; font-size: 14px; margin: 1px 0 3px; }
.andon-card p { font-size: 11px; color: var(--muted); }
.andon-mini { display: flex; flex-direction: column; gap: 4px; padding: 6px; border-radius: 10px; background: #1F252B; flex: none; }
.andon-mini i { width: 16px; height: 16px; border-radius: 50%; background: #3C4148; }
.andon-mini.red i.r, .andon-mini.red_flash i.r { background: #EF2B2B; box-shadow: 0 0 10px #EF2B2B; }
.andon-mini.red_flash i.r { animation: blink 0.76s infinite; }
.andon-mini.yellow i.y { background: #F5B400; box-shadow: 0 0 10px #F5B400; }
.andon-mini.green i.g { background: #22C55E; box-shadow: 0 0 10px #22C55E; }
