:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #3b82f6;
  --ok: #10b981;
  --warn: #f59e0b;
  --error: #ef4444;
  --border: #e5e7eb;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes ripple {
  0% {
    box-shadow: 0 0 0 0 currentColor;
  }

  100% {
    box-shadow: 0 0 0 12px transparent;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  background: linear-gradient(180deg, #f6f8fc 0%, #ffffff 60%, #f6f8fc 100%);
  color: var(--text);
  overflow-x: hidden;
}

.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #ffffff 0%, #fafbff 100%);
  color: var(--text);
  padding: 26px 22px;
  border-right: 1px solid var(--border);
  box-shadow: 2px 0 20px rgba(0, 0, 0, 0.05);
  position: relative;
  overflow-y: auto;
}

.sidebar::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 1px;
  height: 100%;
  background: linear-gradient(180deg,
      transparent,
      rgba(59, 130, 246, 0.1) 50%,
      transparent);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
  animation: slideIn 0.5s ease-out;
}

.brand i {
  font-size: 26px;
  color: var(--primary);
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 2px 4px rgba(59, 130, 246, 0.2));
}

.brand h1 {
  font-size: 18px;
  margin: 0;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-title {
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.6px;
}

.nav-item {
  padding: 10px 10px;
  border-radius: 10px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  background: #f3f4f6;
  border: 1px solid var(--border);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.nav-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 3px;
  background: var(--primary);
  transform: scaleY(0);
  transition: transform 0.3s ease;
}

.nav-item:hover {
  background: #eef2f7;
  transform: translateX(2px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.nav-item.active {
  background: linear-gradient(135deg, #ffffff 0%, #f0f7ff 100%);
  border: 1px solid var(--primary);
  color: var(--primary);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.nav-item.active::before {
  transform: scaleY(1);
}

.sensor-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.sensor {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 13px;
  transition: all 0.3s ease;
  cursor: pointer;
}

.sensor:hover {
  transform: translateX(3px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border-color: #cbd5e1;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2px;
  transition: all 0.2s ease;
}

.chip.ok {
  background: linear-gradient(135deg,
      rgba(16, 185, 129, 0.15),
      rgba(16, 185, 129, 0.08));
  color: var(--ok);
  border: 1px solid rgba(16, 185, 129, 0.35);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.15);
}

.chip.warn {
  background: linear-gradient(135deg,
      rgba(245, 158, 11, 0.15),
      rgba(245, 158, 11, 0.08));
  color: var(--warn);
  border: 1px solid rgba(245, 158, 11, 0.35);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.15);
}

.chip.error {
  background: linear-gradient(135deg,
      rgba(239, 68, 68, 0.15),
      rgba(239, 68, 68, 0.08));
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.35);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.15);
}

.main {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: saturate(180%) blur(12px);
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  animation: slideIn 0.4s ease-out;
}

.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 160px);
  gap: 14px;
}

.stat {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.stat::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #2563eb);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.stat:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  border-color: var(--primary);
}

.stat:hover::before {
  transform: scaleX(1);
}

.stat-value {
  font-size: 30px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
}

.actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
}

.btn {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.1);
  transform: translate(-50%, -50%);
  transition: width 0.4s ease, height 0.4s ease;
}

.btn:hover {
  border-color: #cbd5e1;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn:hover::before {
  width: 200px;
  height: 200px;
}

.btn.primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn.primary:hover {
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
  transform: translateY(-2px);
}

.grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  grid-auto-rows: minmax(140px, auto);
  gap: 18px;
}

.card {
  background: linear-gradient(135deg, #ffffff 0%, #fafbff 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  animation: slideIn 0.5s ease-out backwards;
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
}

.card:hover::before {
  opacity: 1;
}

.card:nth-child(1) {
  animation-delay: 0.05s;
}

.card:nth-child(2) {
  animation-delay: 0.1s;
}

.card:nth-child(3) {
  animation-delay: 0.15s;
}

.card:nth-child(4) {
  animation-delay: 0.2s;
}

.card:nth-child(5) {
  animation-delay: 0.25s;
}

.card:nth-child(6) {
  animation-delay: 0.3s;
}

.card:nth-child(7) {
  animation-delay: 0.35s;
}

.card:nth-child(8) {
  animation-delay: 0.4s;
}

.card.wide {
  grid-column: 1 / span 2;
}

#realtimeCard,
#trendCard {
  grid-column: 1 / span 2;
}

#alertsCard,
#radarCard {
  grid-column: 3;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.card-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.legend {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--muted);
}

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

.dot.ok {
  background: var(--ok);
}

.dot.warn {
  background: var(--warn);
}

.dot.error {
  background: var(--error);
}

.map {
  height: 390px;
  border-radius: 12px;
  background-image: url("../image/backImg.png");
  background-size: cover;
  background-position: center;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.03);
}

.map::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(0deg,
      transparent,
      transparent 19px,
      rgba(59, 130, 246, 0.03) 19px,
      rgba(59, 130, 246, 0.03) 20px),
    repeating-linear-gradient(90deg,
      transparent,
      transparent 19px,
      rgba(59, 130, 246, 0.03) 19px,
      rgba(59, 130, 246, 0.03) 20px);
  pointer-events: none;
}

.pin {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: ripple 2s infinite;
  cursor: pointer;
  transition: all 0.3s ease;
}

.pin::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: inherit;
  filter: blur(4px);
}

.pin:hover {
  transform: translate(-50%, -50%) scale(1.3);
  animation: none;
}

.pin.ok {
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
}

.pin.warn {
  background: var(--warn);
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
}

.pin.error {
  background: var(--error);
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  animation: ripple 1.5s infinite;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 8px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

#metricsTable th,
#metricsTable td {
  text-align: center;
}

.table th {
  color: var(--muted);
  font-weight: 600;
}

.table tbody tr {
  transition: all 0.2s ease;
}

.table tbody tr:nth-child(odd) {
  background: linear-gradient(90deg, #fbfdff, #ffffff);
}

.table tbody tr:hover {
  background: linear-gradient(90deg, #f0f7ff, #f8fafc);
  transform: scale(1.01);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.badge.ok {
  background: linear-gradient(135deg,
      rgba(16, 185, 129, 0.15),
      rgba(16, 185, 129, 0.08));
  color: var(--ok);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge.warn {
  background: linear-gradient(135deg,
      rgba(245, 158, 11, 0.15),
      rgba(245, 158, 11, 0.08));
  color: var(--warn);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge.error {
  background: linear-gradient(135deg,
      rgba(239, 68, 68, 0.15),
      rgba(239, 68, 68, 0.08));
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.2);
  animation: pulse 2s infinite;
}

.list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.list-item {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  transition: all 0.3s ease;
  cursor: pointer;
}

.list-item:hover {
  border-color: var(--primary);
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  background: linear-gradient(135deg, #f0f7ff 0%, #f8fafc 100%);
}

.list-item i {
  color: var(--primary);
  transition: transform 0.3s ease;
}

.list-item:hover i {
  transform: scale(1.2) rotate(5deg);
}

/* KPI mini cards */
.mini-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.toolbar .mini-grid {
  grid-template-columns: repeat(4, minmax(90px, 1fr));
}

.mini {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(180deg, #f9fbff, #f8fafc);
}

.mini-value {
  font-size: 18px;
  font-weight: 700;
}

.mini-label {
  color: var(--muted);
  font-size: 12px;
}

/* Smart diagnosis list */
.diag-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.diag-list li {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 8px;
  align-items: start;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.diag-list i {
  color: var(--primary);
}

/* Features grid */
.features {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
}

.feature-item i {
  color: var(--primary);
  font-size: 18px;
}

/* System checklist */
.checklist {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.check-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.check-status {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.check-status.ok {
  background: rgba(16, 185, 129, 0.12);
  color: var(--ok);
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.check-status.warn {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warn);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.check-status.error {
  background: rgba(239, 68, 68, 0.12);
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.35);
}

/* 自定义滚动条 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #cbd5e1, #94a3b8);
  border-radius: 10px;
  transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #94a3b8, #64748b);
}

/* 选中文本样式 */
::selection {
  background: rgba(59, 130, 246, 0.2);
  color: var(--text);
}

/* 平滑滚动 */
html {
  scroll-behavior: smooth;
}

/* 卡片标题增强 */
.card-header h3 {
  position: relative;
  display: inline-block;
}

.card-header h3::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), transparent);
  transition: width 0.3s ease;
}

.card:hover .card-header h3::after {
  width: 100%;
}

/* Mini卡片增强 */
.mini {
  transition: all 0.3s ease;
  cursor: pointer;
}

.mini:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-color: var(--primary);
}

/* 功能项增强 */
.feature-item {
  transition: all 0.3s ease;
  cursor: pointer;
}

.feature-item:hover {
  transform: translateX(4px);
  background: linear-gradient(135deg, #f0f7ff 0%, #f8fafc 100%);
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
}

.feature-item:hover i {
  transform: scale(1.1) rotate(5deg);
  transition: transform 0.3s ease;
}

/* 诊断列表增强 */
.diag-list li {
  transition: all 0.3s ease;
  cursor: pointer;
}

.diag-list li:hover {
  background: linear-gradient(135deg, #f0f7ff 0%, #ffffff 100%);
  border-color: var(--primary);
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* 检查项增强 */
.check-item {
  transition: all 0.3s ease;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
}

.check-item:hover {
  transform: translateX(3px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  border-color: #cbd5e1;
}

/* 图例点增强 */
.legend .dot {
  box-shadow: 0 0 0 3px transparent;
  transition: all 0.3s ease;
}

.legend:hover .dot {
  box-shadow: 0 0 0 3px currentColor;
  opacity: 0.2;
}

/* 图表容器固定高度 */
.chart-container {
  position: relative;
  height: 200px;
  width: 100%;
}

.chart-container canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
}

/* 历史记录滚动容器 */
#historyCard .table-scroll {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

#historyCard thead th {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 2;
}

#historyCard .table tbody tr:hover {
  background: linear-gradient(90deg, #f0f7ff, #f8fafc);
}

/* 侧边栏历史记录卡片样式 */
.sidebar #historyCard {
  margin-top: 10px;
  padding: 12px;
  border-radius: 14px;
  background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.sidebar #historyCard:hover {
  transform: none;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
  border-color: var(--border);
}

.sidebar #historyCard .card-header {
  margin-bottom: 6px;
}

.sidebar #historyCard .card-header h3 {
  font-size: 14px;
}

.sidebar #historyCard .table th,
.sidebar #historyCard .table td {
  padding: 6px 6px;
  font-size: 12px;
}

/* 加载动画 */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.layout {
  animation: fadeIn 0.5s ease-out;
}

@media (max-width: 1200px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
  }
}

@media (max-width: 900px) {
  .stat-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .card.wide {
    grid-column: auto;
  }
}