:root {
  --bg: #080d16;
  --bg-deep: #060a11;
  --surface: #0f1623;
  --surface-2: #131c2b;
  --surface-3: #182233;
  --line: #1e2a3d;
  --line-strong: #2a3850;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --text-mute: #64748b;
  --accent: #22d3ee;
  --accent-dim: rgba(34, 211, 238, 0.14);
  --ok: #34d399;
  --ok-dim: rgba(52, 211, 153, 0.14);
  --warn: #facc15;
  --warn-dim: rgba(250, 204, 21, 0.14);
  --alarm: #f87171;
  --alarm-dim: rgba(248, 113, 113, 0.15);
  --invalid: #7c8798;
  --invalid-dim: rgba(124, 135, 152, 0.14);
  --radius: 8px;
  --radius-lg: 12px;
}

* { box-sizing: border-box; }

html, body, #app {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg-deep);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #24324a; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #31425f; }

/* ---------- 通用容器 ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  flex: none;
}

.panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 7px;
  letter-spacing: 0.02em;
}

.panel-title::before {
  content: "";
  width: 3px;
  height: 13px;
  background: var(--accent);
  border-radius: 2px;
}

.panel-title.accent-ok::before { background: var(--ok); }
.panel-title.accent-warn::before { background: var(--warn); }
.panel-title.accent-alarm::before { background: var(--alarm); }

.panel-body {
  padding: 12px 14px;
  overflow: auto;
  flex: 1;
  min-height: 0;
}

.panel-body.tight { padding: 6px 8px; }

/* ---------- 文本 ---------- */
.dim { color: var(--text-dim); }
.mute { color: var(--text-mute); }
.mono { font-variant-numeric: tabular-nums; font-family: "Cascadia Mono", "Consolas", monospace; }
.nowrap { white-space: nowrap; }

/* ---------- 状态 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 18px;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.badge.normal { color: var(--ok); background: var(--ok-dim); }
.badge.warn { color: var(--warn); background: var(--warn-dim); }
.badge.alarm { color: var(--alarm); background: var(--alarm-dim); }
.badge.invalid { color: var(--invalid); background: var(--invalid-dim); }
.badge.accent { color: var(--accent); background: var(--accent-dim); }

/* ---------- 指标行 ---------- */
.metric-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(30, 42, 61, 0.7);
}

.metric-row:last-child { border-bottom: none; }

.metric-label { color: var(--text-dim); font-size: 12px; }

.metric-value {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.metric-unit { font-size: 11px; color: var(--text-mute); margin-left: 3px; font-weight: 400; }

/* ---------- 表格 ---------- */
table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

table.grid th {
  text-align: left;
  font-weight: 500;
  color: var(--text-mute);
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--surface);
  white-space: nowrap;
  z-index: 1;
}

table.grid td {
  padding: 7px 10px;
  border-bottom: 1px solid rgba(30, 42, 61, 0.6);
  color: var(--text-dim);
  vertical-align: middle;
}

table.grid tbody tr { cursor: pointer; }
table.grid tbody tr:hover td { background: rgba(34, 211, 238, 0.05); }
table.grid tbody tr.active td { background: rgba(34, 211, 238, 0.1); color: var(--text); }

/* ---------- 控件 ---------- */
button, .btn {
  font-family: inherit;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

button:hover, .btn:hover { color: var(--text); border-color: var(--line-strong); background: var(--surface-3); }

button.primary {
  color: #04262d;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

button.primary:hover { background: #4adee8; border-color: #4adee8; }

button.danger { color: var(--alarm); border-color: rgba(248, 113, 113, 0.35); }
button.danger:hover { background: var(--alarm-dim); }

button:disabled { opacity: 0.45; cursor: not-allowed; }

input, select, textarea {
  font-family: inherit;
  font-size: 12px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 9px;
  outline: none;
  width: 100%;
}

input:focus, select:focus, textarea:focus { border-color: var(--accent); }

input[type="checkbox"] { width: auto; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field > label { font-size: 11px; color: var(--text-mute); }

.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.toolbar .field { width: auto; min-width: 130px; }
.toolbar .grow { flex: 1; }

/* ---------- 空态 ---------- */
.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 120px;
  color: var(--text-mute);
  font-size: 12px;
  text-align: center;
}

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(3, 6, 12, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal {
  width: 560px;
  max-width: 92vw;
  max-height: 86vh;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body { padding: 16px; overflow: auto; flex: 1; }
.modal-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid .full { grid-column: 1 / -1; }

/* ---------- 布局辅助 ---------- */
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.spacer { flex: 1; }
.relative { position: relative; min-height: 0; }
.flex-1 { flex: 1; min-height: 0; }

/* ---------- 主展示区（深色监控舱） ---------- */
.dash {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 272px 1fr 300px;
  grid-template-rows: 1fr 178px;
  gap: 10px;
}

.dash .col.left { grid-column: 1; grid-row: 1; min-height: 0; }
.dash .panel.center { grid-column: 2; grid-row: 1; min-height: 0; overflow: hidden; position: relative; }
.dash .col.right { grid-column: 3; grid-row: 1; min-height: 0; }
.dash .bottom {
  grid-column: 1 / -1;
  grid-row: 2;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  min-height: 0;
}

/* 状态摘要裸指标 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 12px;
}

.stat { display: flex; flex-direction: column; gap: 1px; }
.stat-label { font-size: 11px; color: var(--text-mute); }
.stat-num { font-size: 20px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }

/* 告警列表 */
.alarm-item {
  padding: 7px 8px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
}
.alarm-item:hover { background: var(--surface-2); }
.alarm-item.active { background: var(--accent-dim); border-color: rgba(34, 211, 238, 0.3); }
.alarm-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.alarm-name { font-size: 12px; color: var(--text); margin-top: 3px; }
.alarm-meta { font-size: 11px; color: var(--text-mute); }

/* 对象检视 */
.insp-title { font-size: 14px; font-weight: 600; color: var(--text); }
.insp-sub { font-size: 11px; color: var(--text-mute); margin: 1px 0 8px; }

.meta-list { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 6px; }
.meta-list > div {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 4px 0; font-size: 12px;
}
.meta-list span { color: var(--text-mute); }
.meta-list b { font-weight: 500; color: var(--text-dim); }

/* 测点列表 */
.point-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; border-radius: 6px; cursor: pointer;
  border: 1px solid transparent;
}
.point-row:hover { background: var(--surface-2); }
.point-row.active { background: var(--accent-dim); border-color: rgba(34, 211, 238, 0.3); }
.point-code { font-size: 11px; color: var(--accent); flex: none; }
.point-name {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12px; color: var(--text-dim);
}
.point-val { flex: none; font-size: 12px; color: var(--text); }
.point-val i { font-style: normal; font-size: 10px; color: var(--text-mute); margin-left: 2px; }

button.sel {
  color: var(--accent);
  border-color: rgba(34, 211, 238, 0.35);
  background: var(--accent-dim);
}
