/* ===== 公共样式 - 电网调度台风格（青色信号 + 工程细线 + 角标面板） ===== */

:root {
  --bg-primary: #0A0E14;
  --bg-secondary: #111823;
  --bg-tertiary: #16202C;
  --bg-card: #16202C;
  --border-color: #1E2A38;
  --text-primary: #E2E8F0;
  --text-secondary: #8B9BB0;
  --text-muted: #55677D;
  --signal: #22D3EE;
  --signal-dim: rgba(34,211,238,0.12);
  --amber: #F59E0B;
  --danger: #F87171;
  --success: #34D399;
  --accent-red: #F87171;
  --accent-blue: #22D3EE;
  --accent-green: #34D399;
  --accent-cyan: #22D3EE;
  --accent-orange: #F59E0B;
  --accent-yellow: #F59E0B;
  --corner: #2A3A4D;
  --shadow-card: 0 4px 20px rgba(0,0,0,0.5);
  --radius-sm: 4px;
  --radius-md: 4px;
  --radius-lg: 4px;
  --font-family: 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  --font-display: 'Rajdhani', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', ui-monospace, monospace;
  --transition: all 0.2s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
}

/* 工程制图式网格点阵背景（1px 点，间距 24px） */
body {
  background-image: radial-gradient(rgba(34,211,238,0.03) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* 标题/关键数字/按钮专用字体 */
h1, h2, h3, .panel-title,
.detail-panel-title, .topbar-title, .stat-item .dot, .timeline-stat-value,
.button, .btn, .view-toggle-btn, .alert-tab, .data-table th {
  font-family: var(--font-display);
  letter-spacing: 0.04em;
}

/* ===== 签名元素：面板四角 L 形角标（取景框/工程蓝图感） ===== */
.frame-corner {
  position: relative;
}
.frame-corner::before,
.frame-corner::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  border: 1px solid var(--corner);
  pointer-events: none;
  transition: border-color 0.2s ease;
  z-index: 3;
}
.frame-corner::before {
  top: -1px;
  left: -1px;
  border-right: none;
  border-bottom: none;
}
.frame-corner::after {
  bottom: -1px;
  right: -1px;
  border-left: none;
  border-top: none;
}
.frame-corner:hover::before,
.frame-corner:hover::after,
.frame-corner.active::before,
.frame-corner.active::after {
  border-color: var(--signal);
}

/* 页面加载时角标一次性淡入 */
@keyframes cornerFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.app-container::before,
.app-container::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  border: 1px solid var(--signal);
  pointer-events: none;
  opacity: 0;
  animation: cornerFadeIn 0.8s ease forwards;
  z-index: 5;
}
.app-container::before {
  top: 0;
  left: 0;
  border-right: none;
  border-bottom: none;
}
.app-container::after {
  bottom: 0;
  right: 0;
  border-left: none;
  border-top: none;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #1E2A38;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #2A3A4D;
}

/* ===== 布局系统 ===== */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* ===== 侧边栏 ===== */
.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 10;
  transition: var(--transition);
}

/* 侧边栏取景框角标 */
.sidebar.frame-corner::before {
  top: 8px;
  left: 8px;
}
.sidebar.frame-corner::after {
  bottom: 8px;
  right: 8px;
}

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(180deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
}

.sidebar-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-left: 3px solid var(--signal);
  padding-left: 10px;
  line-height: 1.2;
}
.sidebar-header h1::after {
  content: '';
  display: block;
  width: 32px;
  height: 2px;
  margin-top: 6px;
  background: var(--signal);
  box-shadow: 0 0 8px rgba(34,211,238,0.5);
  margin-left: 0;
}

.sidebar-header p {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.sidebar-search {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-search .enterprise-select {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.sidebar-search .enterprise-select:focus {
  border-color: var(--signal);
  box-shadow: 0 0 10px rgba(34,211,238,0.25);
  background-color: var(--bg-tertiary);
}

.sidebar-search .enterprise-select option {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.sidebar-search input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition);
}

.sidebar-search input:focus {
  border-color: var(--signal);
  box-shadow: 0 0 10px rgba(34,211,238,0.25);
}

.sidebar-search input::placeholder {
  color: var(--text-muted);
}

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.enterprise-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 4px;
  border: 1px solid transparent;
}

.enterprise-item:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-color);
}

.enterprise-item.active {
  background: var(--signal-dim);
  border-color: rgba(34,211,238,0.4);
  box-shadow: 0 0 12px rgba(34,211,238,0.12);
}

.enterprise-item .e-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--signal-dim);
  border: 1px solid rgba(34,211,238,0.35);
  color: var(--signal);
  box-shadow: 0 0 10px rgba(34,211,238,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.enterprise-item .e-info {
  flex: 1;
  min-width: 0;
}

.enterprise-item .e-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.enterprise-item .e-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.enterprise-item .e-count {
  font-size: 0.75rem;
  color: var(--signal);
  font-weight: 600;
  font-family: var(--font-display);
  background: rgba(34,211,238,0.1);
  padding: 2px 8px;
  border-radius: 999px;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 8px;
}

/* ===== 主内容区 ===== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* 主内容区取景框角标 */
.main-content.frame-corner::before {
  top: 8px;
  left: 8px;
}
.main-content.frame-corner::after {
  bottom: 8px;
  right: 8px;
}

/* ===== 顶部控制栏 ===== */
.topbar {
  height: 52px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 5;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-title .highlight {
  color: var(--signal);
  text-shadow: 0 0 10px rgba(34,211,238,0.5);
}

.topbar-stats {
  display: flex;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ===== 顶栏系统读数（大号数字 + 小号大写标签） ===== */
.topbar-readouts {
  display: flex;
  gap: 18px;
  margin-right: 8px;
  padding-right: 16px;
  border-right: 1px solid var(--border-color);
  align-items: stretch;
}
.readout {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  line-height: 1.1;
  padding: 2px 0;
}
.readout-num {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--signal);
  text-shadow: 0 0 10px rgba(34,211,238,0.35);
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: baseline;
}
.readout-label {
  font-family: var(--font-display);
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.stat-item .dot.red { background: var(--danger); box-shadow: 0 0 10px rgba(248,113,113,0.7), 0 0 20px rgba(248,113,113,0.35); }
.stat-item .dot.blue { background: var(--signal); box-shadow: 0 0 8px rgba(34,211,238,0.8), 0 0 16px rgba(34,211,238,0.4); }
.stat-item .dot.green { background: var(--success); box-shadow: 0 0 8px rgba(52,211,153,0.8), 0 0 16px rgba(52,211,153,0.4); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== 全局搜索框 ===== */
.topbar-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-search-input {
  width: 240px;
  padding: 6px 32px 6px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.topbar-search-input::placeholder {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.topbar-search-input:focus {
  border-color: var(--signal);
  box-shadow: 0 0 8px rgba(34,211,238,0.25);
  width: 300px;
}

.topbar-search-input.has-results {
  border-color: var(--signal);
}

.topbar-search-input.no-results {
  border-color: var(--accent-red);
}

.search-match-count {
  font-size: 0.7rem;
  color: var(--signal);
  font-family: var(--font-mono);
  white-space: nowrap;
  padding: 2px 8px;
  background: rgba(34,211,238,0.1);
  border-radius: 999px;
  animation: fadeIn 0.2s ease-out;
}

/* ================================================================
   移动端适配 (max-width: 768px)
   ================================================================ */

@media (max-width: 768px) {
  /* 全局 */
  html, body {
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: manipulation;
  }

  /* ===== 显示移动端元素，隐藏桌面端元素 ===== */
  .mobile-hamburger {
    display: flex;
  }

  .mobile-search-btn {
    display: inline-flex !important;
  }

  .mobile-fab-container {
    display: flex;
  }

  /* 隐藏桌面端搜索框和部分按钮 */
  .topbar-search {
    display: none !important;
  }

  #btn-rotate,
  #btn-reset,
  #btn-export {
    display: none;
  }

  /* ===== 布局 ===== */
  .app-container {
    position: relative;
  }

  /* ===== 侧边栏 - 全屏覆盖 ===== */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    max-width: 360px;
    height: 100%;
    height: 100dvh;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    box-shadow: 4px 0 30px rgba(0,0,0,0.5);
    min-width: auto;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-header {
    padding: 24px 16px 16px;
    position: relative;
  }

  .sidebar-header h1 {
    font-size: 1.2rem;
  }

  .sidebar-search {
    padding: 12px 16px;
  }

  .sidebar-search .enterprise-select {
    font-size: 16px;  /* 防止 iOS 自动缩放 */
    padding: 12px 36px 12px 14px;
  }

  .sidebar-list {
    padding: 8px 12px;
  }

  .enterprise-item {
    padding: 14px 12px;
    min-height: 52px;
    gap: 12px;
  }

  .enterprise-item .e-icon {
    width: 42px;
    height: 42px;
    font-size: 0.9rem;
  }

  .enterprise-item .e-name {
    font-size: 0.95rem;
  }

  .enterprise-item .e-meta {
    font-size: 0.78rem;
  }

  .enterprise-item .e-count {
    font-size: 0.78rem;
    padding: 3px 10px;
  }

  .sidebar-footer {
    padding: 14px 16px;
    flex-direction: column;
  }

  .sidebar-footer .btn {
    min-height: 44px;
    font-size: 0.9rem;
  }

  /* ===== 侧边栏遮罩 ===== */
  .sidebar-overlay {
    display: block;
  }

  .sidebar-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }

  /* ===== 汉堡菜单按钮 ===== */
  .mobile-hamburger {
    width: 40px;
    height: 40px;
    min-width: 40px;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.3rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-hamburger:active {
    background: rgba(255,255,255,0.08);
  }

  /* ===== 主内容区 ===== */
  .main-content {
    width: 100%;
  }

  /* ===== 顶部栏 ===== */
  .topbar {
    height: 48px;
    padding: 0 8px;
    gap: 6px;
  }

  .topbar-left {
    gap: 6px;
    overflow: hidden;
    flex: 1;
    min-width: 0;
  }

  .topbar-title {
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
  }

  .topbar-stats {
    display: none;
  }

  /* 移动端隐藏顶栏系统读数，节省空间 */
  .topbar-readouts {
    display: none;
  }

  .topbar-right {
    gap: 3px;
    flex-shrink: 0;
  }

  /* ===== 按钮触摸优化 ===== */
  .btn {
    min-height: 36px;
    padding: 6px 12px;
    font-size: 0.82rem;
  }

  .btn-sm {
    min-height: 36px;
    min-width: 36px;
    padding: 6px 10px;
    font-size: 0.78rem;
  }

  /* 触摸按下反馈 */
  .btn:active,
  .view-toggle-btn:active,
  .enterprise-item:active {
    transform: scale(0.96);
    transition: transform 0.1s;
  }

  /* ===== 视图切换 ===== */
  .view-toggle-btn {
    padding: 5px 10px;
    font-size: 0.75rem;
    min-height: 34px;
  }

  /* ===== 3D 图容器 ===== */
  .graph-container {
    position: absolute;
    inset: 0;
    top: 48px;
  }

  /* ===== 图例 ===== */
  .legend {
    bottom: 80px;
    left: 8px;
    padding: 8px 10px;
    font-size: 0.68rem;
    max-width: 150px;
    border-radius: var(--radius-sm);
  }

  .legend-item {
    margin-bottom: 3px;
    font-size: 0.68rem;
  }

  .legend-title {
    font-size: 0.72rem;
    margin-bottom: 6px;
  }

  /* ===== 节点详情面板 - 底部弹出 sheet ===== */
  .detail-panel {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 55vh;
    border-radius: 4px 4px 0 0;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 150;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .detail-panel.open {
    transform: translateY(0);
  }

  /* 拖拽指示条 */
  .detail-panel::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    margin: 8px auto 16px;
  }

  .detail-panel-header {
    margin-bottom: 12px;
    padding-bottom: 10px;
  }

  .detail-panel-title {
    font-size: 1.05rem;
  }

  .detail-row {
    padding: 10px 0;
    font-size: 0.88rem;
  }

  /* ===== 移动端悬浮操作按钮 (FAB) ===== */
  .mobile-fab-container {
    display: none;
    position: fixed;
    bottom: 16px;
    right: 12px;
    z-index: 80;
    flex-direction: column;
    gap: 8px;
  }

  .mobile-fab {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
    backdrop-filter: blur(6px);
  }

  .mobile-fab:active {
    transform: scale(0.88);
    background: var(--signal-dim);
    border-color: var(--signal);
  }

  .mobile-fab.active {
    background: var(--signal);
    color: #0A0E14;
    border-color: transparent;
    box-shadow: 0 4px 20px rgba(34,211,238,0.4);
  }

  .mobile-search-btn {
    display: none;
  }

  /* ===== 移动端搜索栏 ===== */
  .mobile-search-bar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 160;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 8px 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    animation: mobileSlideDown 0.22s ease-out;
    align-items: center;
    gap: 8px;
  }

  .mobile-search-bar.open {
    display: flex;
  }

  @keyframes mobileSlideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }

  .mobile-search-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    outline: none;
    -webkit-appearance: none;
  }

  .mobile-search-input:focus {
    border-color: var(--signal);
    box-shadow: 0 0 8px rgba(34,211,238,0.25);
  }

  .mobile-search-input::placeholder {
    color: var(--text-muted);
    font-size: 0.9rem;
  }

  .mobile-search-cancel {
    padding: 10px 14px;
    background: none;
    border: none;
    color: var(--signal);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    border-radius: var(--radius-sm);
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-search-cancel:active {
    background: var(--signal-dim);
  }

  /* ===== Tooltip 移动端适配 ===== */
  .tooltip {
    max-width: 260px;
    font-size: 0.8rem;
  }

  /* ===== 告警面板 ===== */
  .alert-panel {
    width: 100vw;
    max-width: 100vw;
  }

  .alert-panel-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 8px;
    gap: 2px;
  }

  .alert-tab {
    padding: 10px 10px;
    font-size: 0.78rem;
    white-space: nowrap;
  }

  /* ===== 时间轴适配 ===== */
  .timeline-stats {
    gap: 12px;
    padding: 12px 16px;
    flex-wrap: wrap;
  }

  .timeline-stat-value {
    font-size: 1rem;
  }

  .timeline-controls {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 16px;
  }

  .timeline-legend {
    flex-wrap: wrap;
    gap: 12px;
  }

  .timeline-chart-wrapper {
    padding: 8px 8px 12px 4px;
  }
}

/* ================================================================
   小手机适配 (max-width: 480px)
   ================================================================ */

@media (max-width: 480px) {
  .topbar {
    padding: 0 6px;
  }

  .topbar-title {
    font-size: 0.76rem;
    max-width: 90px;
  }

  .sidebar {
    max-width: 100%;
  }

  .legend {
    bottom: 75px;
    left: 4px;
    max-width: 135px;
    font-size: 0.62rem;
    padding: 6px 8px;
  }

  .mobile-fab {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    font-size: 1.1rem;
  }

  .mobile-fab-container {
    bottom: 12px;
    right: 8px;
    gap: 6px;
  }

  .detail-panel {
    max-height: 60vh;
  }
}

/* ================================================================
   横屏适配 (orientation: landscape)
   ================================================================ */

@media (max-width: 768px) and (orientation: landscape) {
  .topbar-title {
    max-width: 220px;
  }

  .detail-panel {
    max-height: 80vh;
  }

  .mobile-fab-container {
    bottom: 10px;
    right: 14px;
    gap: 5px;
    flex-direction: row;
  }

  .mobile-fab {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    font-size: 1rem;
  }

  .legend {
    bottom: 10px;
    left: 6px;
    max-width: 130px;
    padding: 6px 8px;
  }
}

.search-match-count.no-match {
  color: var(--danger);
  background: rgba(248,113,113,0.1);
}

.search-clear-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 50%;
  transition: var(--transition);
}

.search-clear-btn:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.08);
}

/* 搜索脉冲动画 */
@keyframes searchPulse {
  0%, 100% {
    box-shadow: 0 0 4px rgba(34,211,238,0.4);
  }
  50% {
    box-shadow: 0 0 16px rgba(34,211,238,0.8);
  }
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-display);
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: transparent;
  color: var(--signal);
  border: 1px solid var(--signal);
}

.btn-primary:hover {
  background: var(--signal-dim);
  box-shadow: 0 0 12px rgba(34,211,238,0.25);
  color: var(--signal);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-ghost:hover {
  border-color: var(--signal);
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(248,113,113,0.4);
}

.btn-danger:hover {
  background: rgba(248,113,113,0.1);
  box-shadow: 0 0 12px rgba(248,113,113,0.25);
}

.btn-success {
  background: transparent;
  color: var(--success);
  border: 1px solid rgba(52,211,153,0.4);
}

.btn-success:hover {
  background: rgba(52,211,153,0.1);
  box-shadow: 0 0 12px rgba(52,211,153,0.25);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.75rem;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

/* ===== 移动端元素（桌面端隐藏） ===== */
.mobile-hamburger {
  display: none;
}

.mobile-search-btn {
  display: none !important;
}

.mobile-fab-container {
  display: none;
}

.mobile-search-bar {
  display: none;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  backdrop-filter: blur(2px);
}

/* ===== 3D 图容器 ===== */
.graph-container {
  flex: 1;
  position: relative;
  background: radial-gradient(ellipse at center, #0A0E14 0%, #080C11 70%);
}

.graph-container canvas {
  display: block;
}

/* ===== 面板垂直扫描线（极淡，8s 循环，不拦截交互） ===== */
.graph-container::after,
.timeline-container::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(34,211,238,0.06), transparent);
  pointer-events: none;
  z-index: 4;
  animation: scanLine 8s linear infinite;
}

@keyframes scanLine {
  0% { transform: translateY(0); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(100vh); opacity: 0; }
}

/* ===== 悬浮提示框 ===== */
.tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(17,24,39,0.96);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.85rem;
  color: var(--text-primary);
  box-shadow: 0 0 20px rgba(0,0,0,0.5);
  z-index: 100;
  max-width: 320px;
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.2s;
}

.tooltip.visible {
  opacity: 1;
}

.tooltip-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 3px;
  font-size: 0.8rem;
}

.tooltip-label {
  color: var(--text-muted);
}

.tooltip-value {
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.tooltip-value.highlight {
  color: var(--signal);
  font-weight: 600;
}

/* ===== 图例 ===== */
.legend {
  position: absolute;
  bottom: 20px;
  left: 20px;
  background: rgba(17,24,39,0.92);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-size: 0.8rem;
  backdrop-filter: blur(8px);
  z-index: 50;
}

.legend-title {
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text-primary);
  font-size: 0.85rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.legend-item:last-child {
  margin-bottom: 0;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  animation: legendPulse 2.5s ease-in-out infinite;
}

.legend-dot:nth-child(odd) { animation-delay: 0s; }

@keyframes legendPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

.legend-line {
  width: 20px;
  height: 3px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ===== 加载状态 ===== */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  transition: opacity 0.3s;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border-color);
  border-top-color: var(--signal);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  margin-top: 16px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ===== 加载仪式感：双行状态提示 ===== */
.loading-status {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.loading-status-en {
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--signal);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  text-shadow: 0 0 12px rgba(34,211,238,0.4);
}
.loading-status-cn {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.2em;
}

/* ===== 空状态 ===== */
.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  z-index: 20;
}

.empty-state-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state-text {
  font-size: 1rem;
  color: var(--text-secondary);
}

.empty-state-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ===== 节点详情面板 ===== */
.detail-panel {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 300px;
  background: rgba(17,24,39,0.96);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 20px;
  z-index: 50;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-card);
  transform: translateX(340px);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.detail-panel.frame-corner::before {
  top: -1px;
  left: -1px;
  border-color: var(--signal);
}
.detail-panel.frame-corner::after {
  bottom: -1px;
  right: -1px;
  border-color: var(--signal);
}

.detail-panel.open {
  transform: translateX(0);
}

.detail-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  padding-left: 10px;
  border-bottom: 1px solid var(--border-color);
  border-left: 3px solid var(--signal);
}

.detail-panel-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.detail-panel-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.2s;
}

.detail-panel-close:hover {
  color: var(--text-primary);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(42,63,95,0.5);
  font-size: 0.85rem;
}

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

.detail-label {
  color: var(--text-muted);
}

.detail-value {
  color: var(--text-primary);
  font-weight: 600;
  font-family: var(--font-display);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 10px;
  letter-spacing: 0.3px;
}

.detail-row hr {
  border: none;
  border-top: 1px solid;
  margin: 12px 0;
}

.detail-link {
  color: var(--signal);
  text-decoration: none;
  font-size: 0.78rem;
  font-family: inherit;
  transition: color 0.2s;
}

.detail-link:hover {
  color: var(--signal);
  text-decoration: underline;
}

/* ===== 视图切换按钮组 ===== */
.view-toggle-group {
  display: inline-flex;
  gap: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.view-toggle-btn {
  padding: 5px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font-display);
  cursor: pointer;
  border: none;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  transition: var(--transition);
  letter-spacing: 0.04em;
}

.view-toggle-btn:first-child {
  border-right: 1px solid var(--border-color);
}

.view-toggle-btn.active {
  background: var(--signal-dim);
  color: var(--signal);
  box-shadow: inset 0 0 0 1px var(--signal), 0 0 10px rgba(34,211,238,0.25);
}

.view-toggle-btn:hover:not(.active) {
  color: var(--text-primary);
  background: var(--bg-card);
}

/* ===== 时间轴容器 ===== */
.timeline-container {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  background: radial-gradient(ellipse at center, #0A0E14 0%, #080C11 70%);
  z-index: 201;
}

/* ===== 时间轴统计栏 ===== */
.timeline-stats {
  display: flex;
  gap: 20px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(17, 24, 39, 0.7);
  backdrop-filter: blur(6px);
}

.timeline-stat-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.timeline-stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.timeline-stat-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.timeline-stat-unit {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 2px;
}

/* ===== 时间轴控制栏 ===== */
.timeline-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  border-bottom: 1px solid rgba(42, 63, 95, 0.3);
}

.timeline-legend {
  display: flex;
  gap: 20px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.timeline-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.timeline-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}

.timeline-granularity {
  display: inline-flex;
  gap: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.timeline-gran-btn {
  padding: 4px 14px;
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  transition: var(--transition);
}

.timeline-gran-btn + .timeline-gran-btn {
  border-left: 1px solid var(--border-color);
}

.timeline-gran-btn.active {
  background: var(--signal-dim);
  color: var(--signal);
  font-weight: 600;
}

.timeline-gran-btn:hover:not(.active) {
  color: var(--text-primary);
  background: var(--bg-card);
}

/* ===== 时间轴图表容器 ===== */
.timeline-chart-wrapper {
  flex: 1;
  position: relative;
  padding: 16px 20px 20px 10px;
  min-height: 0;
}

.timeline-chart-wrapper canvas {
  display: block;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    position: absolute;
    left: -100%;
    z-index: 100;
  }

  .sidebar.open {
    left: 0;
  }

  .topbar {
    padding: 0 12px;
  }

  .topbar-stats {
    display: none;
  }

  .legend {
    bottom: 10px;
    left: 10px;
    padding: 10px 12px;
    font-size: 0.7rem;
  }

  .detail-panel {
    width: calc(100% - 40px);
    right: 20px;
    top: auto;
    bottom: 20px;
    transform: translateY(calc(100% + 40px));
  }

  .detail-panel.open {
    transform: translateY(0);
  }
}

/* ===== 动画 ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 5px currentColor; }
  50% { box-shadow: 0 0 20px currentColor; }
}

.animate-fade-in {
  animation: fadeIn 0.3s ease-out;
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

/* ===== 扫描线效果 ===== */
.scanline {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(34,211,238,0.4), transparent);
  animation: scanline 4s linear infinite;
  pointer-events: none;
  z-index: 9999;
}

@keyframes scanline {
  0% { top: -2px; }
  100% { top: 100vh; }
}

/* ===== 导出按钮 ===== */
.btn-export {
  background: transparent;
  color: var(--success);
  border: 1px solid rgba(52,211,153,0.4);
}

.btn-export:hover {
  background: rgba(52,211,153,0.1);
  border-color: var(--success);
  box-shadow: 0 0 12px rgba(52,211,153,0.25);
  color: var(--success);
}

/* ===== 告警按钮 ===== */
.btn-alert {
  position: relative;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-alert:hover {
  border-color: var(--amber);
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.alert-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
  font-family: var(--font-display);
  line-height: 18px;
  text-align: center;
  border-radius: 999px;
  box-shadow: 0 0 8px rgba(248,113,113,0.5);
  animation: badgePulse 2s ease-in-out infinite;
}

.alert-badge.hidden {
  display: none;
}

@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* ===== 告警面板 ===== */
.alert-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  height: 100vh;
  background: rgba(17, 24, 39, 0.98);
  border-left: 1px solid var(--border-color);
  box-shadow: -4px 0 40px rgba(0,0,0,0.6);
  z-index: 500;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(12px);
}

.alert-panel.open {
  transform: translateX(0);
}

.alert-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(180deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
}

.alert-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-display);
  letter-spacing: 0.04em;
}

.alert-panel-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.alert-panel-close:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.06);
}

.alert-panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  padding: 0 16px;
  gap: 4px;
}

.alert-tab {
  padding: 10px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font-display);
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
  letter-spacing: 0.04em;
}

.alert-tab:hover {
  color: var(--text-primary);
}

.alert-tab.active {
  color: var(--signal);
  border-bottom-color: var(--signal);
}

.alert-tab .tab-count {
  display: inline-block;
  background: rgba(34,211,238,0.12);
  color: var(--signal);
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.7rem;
  margin-left: 6px;
  font-family: var(--font-display);
}

.alert-panel-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
}

.alert-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  margin-bottom: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  animation: fadeIn 0.3s ease-out;
}

.alert-item:hover {
  border-color: rgba(34,211,238,0.35);
  box-shadow: 0 0 12px rgba(34,211,238,0.08);
}

.alert-item.unread {
  border-left: 3px solid var(--warning, var(--danger));
}

.alert-item.read {
  opacity: 0.6;
}

.alert-item-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.alert-item-icon.new_supplier {
  background: rgba(34,211,238,0.12);
  color: var(--signal);
  box-shadow: 0 0 8px rgba(34,211,238,0.2);
}

.alert-item-icon.large_transaction {
  background: rgba(248,113,113,0.12);
  color: var(--danger);
  box-shadow: 0 0 8px rgba(248,113,113,0.2);
}

.alert-item-icon.nmg_supplier_new {
  background: rgba(52,211,153,0.12);
  color: var(--success);
  box-shadow: 0 0 8px rgba(52,211,153,0.2);
}

.alert-item-body {
  flex: 1;
  min-width: 0;
}

.alert-item-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.alert-item-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.alert-item-meta .highlight {
  color: var(--signal);
  font-weight: 600;
  font-family: var(--font-mono);
}

.alert-item-date {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.alert-item-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.alert-item-actions .btn {
  padding: 3px 8px;
  font-size: 0.7rem;
}

.alert-panel-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
}

.alert-panel-empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.3;
}

.alert-panel-empty-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* ===== 告警遮罩 ===== */
.alert-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 499;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.alert-overlay.open {
  opacity: 1;
  pointer-events: auto;
}


