/* ===== Global Reset ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-dark: #060a14;
  --bg-panel: rgba(8, 16, 32, 0.82);
  --bg-panel-border: rgba(0, 217, 255, 0.25);
  --color-primary: #00d9ff;
  --color-supply: #ffdd44;
  --color-return: #00f0ff;
  --color-normal: #00e676;
  --color-warning: #ffab00;
  --color-error: #ff3d3d;
  --color-text: #e0e6ed;
  --color-text-dim: #6b7a8f;
  --color-text-label: #8fa3b8;
  --glow-primary: 0 0 12px rgba(0, 217, 255, 0.5);
  --glow-supply: 0 0 12px rgba(255, 107, 53, 0.5);
  --glow-error: 0 0 12px rgba(255, 61, 61, 0.6);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
  color: var(--color-text);
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  user-select: none;
}

/* ===== Canvas ===== */
#canvas-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

#label-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

/* ===== Top Bar ===== */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  background: linear-gradient(180deg, rgba(6, 10, 20, 0.95) 0%, rgba(6, 10, 20, 0.3) 100%);
  border-bottom: 1px solid var(--bg-panel-border);
  z-index: 10;
}

.top-bar__left, .top-bar__right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
}

.top-bar__right {
  justify-content: flex-end;
}

.top-bar__title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 4px;
  background: linear-gradient(90deg, #00d9ff, #4a9eff, #00d9ff);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 3s linear infinite;
}

@keyframes shimmer {
  to { background-position: 200% center; }
}

.top-bar__time {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-primary);
  font-family: "Consolas", monospace;
}

.top-bar__date {
  font-size: 13px;
  color: var(--color-text-dim);
}

.top-bar__label {
  font-size: 13px;
  color: var(--color-text-dim);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot--online {
  background: var(--color-normal);
  box-shadow: 0 0 8px var(--color-normal);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ===== Panels ===== */
.panel {
  position: fixed;
  background: var(--bg-panel);
  border: 1px solid var(--bg-panel-border);
  border-radius: 4px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

.panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--color-primary), transparent);
}

.panel--left-top {
  top: 76px;
  left: 20px;
  width: 280px;
}

.panel--right-top {
  top: 76px;
  right: 20px;
  width: 300px;
}

.panel--left-bottom {
  bottom: 50px;
  left: 20px;
  width: 380px;
  height: 200px;
}

.panel--right-bottom {
  bottom: 50px;
  right: 20px;
  width: 300px;
  height: 200px;
}

.panel__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(0, 217, 255, 0.1);
}

.panel__icon {
  width: 4px;
  height: 14px;
  background: var(--color-primary);
  border-radius: 2px;
  box-shadow: var(--glow-primary);
}

.panel__icon--alarm {
  background: var(--color-warning);
  box-shadow: 0 0 8px rgba(255, 171, 0, 0.5);
}

.panel__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: 1px;
}

.alarm-badge {
  margin-left: auto;
  background: var(--color-error);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

/* ===== Metrics Grid ===== */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: rgba(0, 217, 255, 0.08);
  padding: 1px;
}

.metric-card {
  background: rgba(6, 10, 20, 0.9);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background 0.3s;
}

.metric-card:hover {
  background: rgba(0, 217, 255, 0.08);
}

.metric-card__label {
  font-size: 11px;
  color: var(--color-text-label);
  letter-spacing: 0.5px;
}

.metric-card__value {
  font-size: 22px;
  font-weight: 700;
  font-family: "Consolas", monospace;
  color: var(--color-primary);
  text-shadow: 0 0 10px rgba(0, 217, 255, 0.4);
}

.metric-card__unit {
  font-size: 12px;
  color: var(--color-text-dim);
  font-weight: 400;
  margin-left: 3px;
}

.metric-card--warning .metric-card__value {
  color: var(--color-warning);
  text-shadow: 0 0 10px rgba(255, 171, 0, 0.4);
}

.metric-card--error .metric-card__value {
  color: var(--color-error);
  text-shadow: 0 0 10px rgba(255, 61, 61, 0.4);
}

/* ===== Alarm List ===== */
.alarm-list {
  max-height: 260px;
  overflow-y: auto;
  padding: 6px 0;
}

.alarm-list::-webkit-scrollbar {
  width: 4px;
}

.alarm-list::-webkit-scrollbar-thumb {
  background: rgba(0, 217, 255, 0.2);
  border-radius: 2px;
}

.alarm-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: background 0.2s;
}

.alarm-item:hover {
  background: rgba(0, 217, 255, 0.06);
}

.alarm-item__level {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}

.alarm-item__level--error {
  background: var(--color-error);
  box-shadow: 0 0 6px var(--color-error);
  animation: pulse-dot 1.5s ease-in-out infinite;
}

.alarm-item__level--warning {
  background: var(--color-warning);
  box-shadow: 0 0 6px var(--color-warning);
}

.alarm-item__level--info {
  background: var(--color-primary);
  box-shadow: 0 0 6px var(--color-primary);
}

.alarm-item__content {
  flex: 1;
  min-width: 0;
}

.alarm-item__desc {
  font-size: 12px;
  color: var(--color-text);
  line-height: 1.4;
}

.alarm-item__meta {
  font-size: 11px;
  color: var(--color-text-dim);
  margin-top: 2px;
}

.alarm-item__node {
  color: var(--color-primary);
}

/* ===== Chart Container ===== */
.chart-container {
  width: 100%;
  height: calc(100% - 38px);
}

/* ===== Detail Popup ===== */
.detail-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: 360px;
  background: var(--bg-panel);
  border: 1px solid var(--bg-panel-border);
  border-radius: 4px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6), 0 0 30px rgba(0, 217, 255, 0.15);
}

.detail-popup--visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.detail-popup__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(0, 217, 255, 0.15);
}

.detail-popup__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-primary);
}

.detail-popup__close {
  background: none;
  border: none;
  color: var(--color-text-dim);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
}

.detail-popup__close:hover {
  color: var(--color-error);
}

.detail-popup__body {
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-item__label {
  font-size: 11px;
  color: var(--color-text-label);
}

.detail-item__value {
  font-size: 18px;
  font-weight: 700;
  font-family: "Consolas", monospace;
  color: var(--color-text);
}

.detail-item__value--highlight {
  color: var(--color-primary);
}

.detail-item__value--warning {
  color: var(--color-warning);
}

.detail-item__value--error {
  color: var(--color-error);
}

.detail-item__unit {
  font-size: 12px;
  color: var(--color-text-dim);
  font-weight: 400;
  margin-left: 3px;
}

/* ===== Legend Bar ===== */
.legend-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: linear-gradient(0deg, rgba(6, 10, 20, 0.95) 0%, rgba(6, 10, 20, 0.3) 100%);
  border-top: 1px solid var(--bg-panel-border);
  z-index: 10;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--color-text-dim);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-dot--supply {
  background: var(--color-supply);
  box-shadow: 0 0 6px var(--color-supply);
}

.legend-dot--return {
  background: var(--color-return);
  box-shadow: 0 0 6px var(--color-return);
}

.legend-dot--normal {
  background: var(--color-normal);
  box-shadow: 0 0 6px var(--color-normal);
}

.legend-dot--warning {
  background: var(--color-warning);
  box-shadow: 0 0 6px var(--color-warning);
}

.legend-dot--error {
  background: var(--color-error);
  box-shadow: 0 0 6px var(--color-error);
}

.legend-hint {
  font-size: 11px;
  color: var(--color-text-dim);
  margin-left: 20px;
  opacity: 0.6;
}

/* ===== 3D Node Labels ===== */
.node-label {
  font-size: 12px;
  color: var(--color-text);
  background: rgba(6, 10, 20, 0.7);
  border: 1px solid rgba(0, 217, 255, 0.2);
  padding: 2px 8px;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
}

.node-label--source {
  border-color: rgba(255, 107, 53, 0.4);
  color: #ffaa88;
}

.node-label--exchange {
  border-color: rgba(0, 217, 255, 0.4);
  color: var(--color-primary);
}

.node-label--user {
  border-color: rgba(100, 255, 150, 0.2);
  font-size: 11px;
}

.node-label--warning {
  border-color: rgba(255, 171, 0, 0.5) !important;
  color: var(--color-warning) !important;
}

.node-label--error {
  border-color: rgba(255, 61, 61, 0.5) !important;
  color: var(--color-error) !important;
}

/* ===== Corner Decorations ===== */
.panel--left-top::after,
.panel--right-top::after,
.panel--left-bottom::after,
.panel--right-bottom::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0, 217, 255, 0.3), transparent);
}

/* Corner accent lines */
.panel::before {
  background: linear-gradient(90deg, transparent, var(--color-primary), transparent);
}

/* ===== District Labels ===== */
.district-label {
  font-size: 11px;
  color: rgba(143, 163, 184, 0.7);
  pointer-events: none;
  white-space: nowrap;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
  letter-spacing: 1px;
}

/* ===== Compute Engine Label (高空实时计算引擎) ===== */
.engine-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #bff6ff;
  background: rgba(6, 10, 20, 0.7);
  border: 1px solid rgba(0, 217, 255, 0.4);
  padding: 3px 10px;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 0 8px rgba(0, 217, 255, 0.6);
  box-shadow: 0 0 12px rgba(0, 217, 255, 0.25);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* ===== HUD 边框 / 扫描线（背景增强 E） ===== */
/* z-index 卡在 canvas(0/1) 与 panel(10) 之间；四角已有 panel 占着，
   故用屏幕内描边细框（藏在 panel 缝隙里）+ 一道缓慢扫描亮线，不冲突。 */
#hud-overlay {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  overflow: hidden;
  box-shadow:
    inset 0 0 0 1px rgba(0, 217, 255, 0.08),
    inset 0 0 70px rgba(0, 217, 255, 0.03);
}
.hud-scan {
  position: absolute;
  left: 0;
  right: 0;
  height: 140px;
  background: linear-gradient(180deg, transparent, rgba(0, 217, 255, 0.04) 50%, transparent);
  animation: hudScan 14s linear infinite;
}
@keyframes hudScan {
  0% { transform: translateY(-140px); }
  100% { transform: translateY(100vh); }
}
