:root {
  --bg: #0a1628;
  --bg-panel: #101f38;
  --bg-panel-2: #0d1a30;
  --border: #1e3355;
  --text: #dbe7f5;
  --text-dim: #7d93b2;
  --cyan: #22d3ee;
  --purple: #a78bfa;
  --orange: #fb923c;
  --blue: #60a5fa;
  --red: #f87171;
  --green: #34d399;
}

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

body {
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 60% 40% at 20% 0%, rgba(96,165,250,.08), transparent),
    radial-gradient(ellipse 50% 35% at 85% 10%, rgba(167,139,250,.07), transparent);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  min-height: 100vh;
  padding: 18px 22px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px;
  background: linear-gradient(90deg, var(--bg-panel), var(--bg-panel-2));
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 16px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 46px; height: 46px; border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #22d3ee);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 20px; color: #fff;
  box-shadow: 0 0 18px rgba(34,211,238,.35);
}
.brand-text h1 { font-size: 19px; font-weight: 700; letter-spacing: .5px; }
.subtitle { font-size: 11px; color: var(--text-dim); letter-spacing: 1px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.badge-demo {
  font-size: 12px; color: var(--orange);
  border: 1px solid rgba(251,146,60,.45);
  background: rgba(251,146,60,.1);
  padding: 4px 12px; border-radius: 999px;
}
.sim-toggle {
  font-size: 12px; color: var(--cyan); cursor: pointer; user-select: none;
  border: 1px solid rgba(34,211,238,.4);
  background: rgba(34,211,238,.08);
  padding: 4px 12px; border-radius: 999px;
  transition: background .2s;
}
.sim-toggle:hover { background: rgba(34,211,238,.18); }
.clock { font-size: 15px; font-variant-numeric: tabular-nums; color: var(--cyan); }

/* ---------- KPI ---------- */
.kpi-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
  margin-bottom: 16px;
}
.kpi-card {
  background: linear-gradient(160deg, var(--bg-panel), var(--bg-panel-2));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  position: relative; overflow: hidden;
}
.kpi-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
}
.c-cyan::before   { background: var(--cyan); }
.c-purple::before { background: var(--purple); }
.c-orange::before { background: var(--orange); }
.c-blue::before   { background: var(--blue); }
.kpi-label { font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }
.kpi-value { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi-unit { font-size: 14px; font-weight: 400; color: var(--text-dim); margin-left: 4px; }
.c-cyan .kpi-value   { color: var(--cyan); }
.c-purple .kpi-value { color: var(--purple); }
.c-orange .kpi-value { color: var(--orange); }
.c-blue .kpi-value   { color: var(--blue); }
.kpi-foot { font-size: 12px; color: var(--text-dim); margin-top: 6px; }

/* ---------- 主网格 ---------- */
.grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  grid-template-areas:
    "map side"
    "chart side";
  gap: 14px;
}
.panel-map   { grid-area: map; }
.panel-chart { grid-area: chart; }
.side-col { grid-area: side; display: flex; flex-direction: column; gap: 14px; }

.panel {
  background: linear-gradient(160deg, var(--bg-panel), var(--bg-panel-2));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.panel-head h2 { font-size: 15px; font-weight: 700; }
.line-tag {
  font-size: 11px; color: var(--blue);
  border: 1px solid rgba(96,165,250,.4);
  padding: 2px 8px; border-radius: 999px; margin-left: 6px;
  vertical-align: 2px;
}
.panel-hint { font-size: 12px; color: var(--text-dim); }

/* ---------- 线路图 ---------- */
.map-wrap { width: 100%; }
#lineMap { width: 100%; height: auto; display: block; }

.station-detail {
  margin-top: 10px;
  border-top: 1px dashed var(--border);
  padding-top: 12px;
  min-height: 86px;
}
.sd-title { font-size: 14px; font-weight: 700; margin-bottom: 10px; color: var(--cyan); }
.sd-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
.sd-item {
  background: rgba(96,165,250,.06);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
.sd-item .k { font-size: 11px; color: var(--text-dim); }
.sd-item .v { font-size: 15px; font-weight: 700; margin-top: 3px; }

/* ---------- 机器人面板 ---------- */
.btn-primary {
  background: linear-gradient(90deg, #2563eb, #22d3ee);
  color: #fff; border: none; border-radius: 8px;
  padding: 7px 16px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: filter .2s, transform .1s;
}
.btn-primary:hover { filter: brightness(1.12); }
.btn-primary:active { transform: scale(.97); }
.btn-primary:disabled { filter: grayscale(.6); opacity: .55; cursor: not-allowed; }

.robot-card {
  background: rgba(34,211,238,.05);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.robot-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.robot-name { font-weight: 700; font-size: 15px; }
.robot-status { font-size: 12px; padding: 3px 10px; border-radius: 999px; }
.st-idle    { color: var(--text-dim); background: rgba(125,147,178,.15); }
.st-moving  { color: var(--blue);   background: rgba(96,165,250,.15); }
.st-working { color: var(--cyan);   background: rgba(34,211,238,.15); }
.st-charging{ color: var(--orange); background: rgba(251,146,60,.15); }

.battery-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.battery {
  flex: 1; height: 8px; border-radius: 4px;
  background: rgba(125,147,178,.2); overflow: hidden;
}
.battery-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, #22d3ee, #34d399);
  transition: width .6s;
}
.task-line { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.progress-track {
  height: 6px; border-radius: 3px;
  background: rgba(125,147,178,.2); overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, #a78bfa, #22d3ee);
  transition: width .5s;
}

.robot-list { list-style: none; }
.robot-list li {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; padding: 7px 4px;
  border-bottom: 1px dashed rgba(30,51,85,.7);
  color: var(--text-dim);
}
.robot-list li:last-child { border-bottom: none; }
.robot-list .r-name { color: var(--text); font-weight: 600; }

/* ---------- 告警 ---------- */
.panel-alerts { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.alert-list {
  list-style: none; overflow-y: auto; max-height: 300px;
  display: flex; flex-direction: column; gap: 8px;
}
.alert-list::-webkit-scrollbar { width: 4px; }
.alert-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.alert-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 8px;
  padding: 9px 12px;
  animation: slideIn .3s ease;
  font-size: 13px;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; } }
.lv-high   { border-left-color: var(--red);    background: rgba(248,113,113,.07); }
.lv-mid    { border-left-color: var(--orange); background: rgba(251,146,60,.07); }
.lv-low    { border-left-color: var(--blue);   background: rgba(96,165,250,.06); }
.alert-lv  { font-size: 11px; font-weight: 700; flex-shrink: 0; }
.lv-high .alert-lv { color: var(--red); }
.lv-mid  .alert-lv { color: var(--orange); }
.lv-low  .alert-lv { color: var(--blue); }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-weight: 600; }
.alert-meta { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.alert-ack {
  flex-shrink: 0; font-size: 12px; cursor: pointer;
  color: var(--cyan); background: none;
  border: 1px solid rgba(34,211,238,.4);
  border-radius: 6px; padding: 3px 10px;
}
.alert-ack:hover { background: rgba(34,211,238,.12); }
.alert-item.acked { opacity: .4; }
.alert-item.acked .alert-ack { display: none; }
.alert-empty { font-size: 13px; color: var(--text-dim); text-align: center; padding: 20px 0; }

/* ---------- 图表 ---------- */
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-dim); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.d-orange { background: var(--orange); }
.d-cyan   { background: var(--cyan); }
#trendChart { width: 100%; }

/* ---------- 页脚 ---------- */
.footer {
  text-align: center; font-size: 12px; color: var(--text-dim);
  margin-top: 18px; padding: 10px 0 4px;
}

@media (max-width: 980px) {
  .grid { grid-template-columns: 1fr; grid-template-areas: "map" "side" "chart"; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
}
