/* 定位底座 · 设备管理页样式 */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0f1419;
  --panel: #1a2027;
  --panel-2: #232b33;
  --line: #2d3743;
  --text: #e6edf3;
  --muted: #8b98a5;
  --green: #3fb950;
  --red: #f85149;
  --blue: #58a6ff;
  --amber: #d29922;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

#app { display: flex; height: 100vh; }

/* ---------- 侧栏 ---------- */
#sidebar {
  width: 340px;
  min-width: 340px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

#sidebar header {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

#sidebar h1 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 8px;
}

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

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.on { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot.off { background: var(--red); }
.dot.wait { background: var(--amber); }

.kpi {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}

.kpi-item {
  background: var(--panel);
  padding: 12px 8px;
  text-align: center;
}

.kpi-v { display: block; font-size: 20px; font-weight: 700; color: var(--blue); }
.kpi-l { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }

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

.btn {
  flex: 1;
  min-width: 80px;
  padding: 7px 10px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: .15s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: var(--panel-2); color: var(--muted); }
.btn.danger { background: var(--red); }

/* ---------- 设备列表 ---------- */
.dev-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.dev-item {
  background: var(--panel-2);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: .15s;
}
.dev-item:hover { border-color: var(--line); background: #28323c; }
.dev-item.active { border-color: var(--blue); }
.dev-item.offline { opacity: .55; }

.dev-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.dev-sn { font-weight: 600; font-size: 13px; font-family: ui-monospace, monospace; }
.dev-badge { font-size: 10px; padding: 2px 7px; border-radius: 10px; }
.dev-badge.on { background: rgba(63,185,80,.18); color: var(--green); }
.dev-badge.off { background: rgba(248,81,73,.15); color: var(--red); }

.dev-meta { font-size: 11px; color: var(--muted); line-height: 1.7; }
.dev-meta .coord { font-family: ui-monospace, monospace; color: #a5b4fc; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 16px;
  font-size: 13px;
  line-height: 1.8;
}

/* ---------- 地图 ---------- */
#map-wrap { flex: 1; position: relative; }
#map { width: 100%; height: 100%; background: #0d1117; }

/* ---------- 详情面板 ---------- */
.detail {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 320px;
  max-height: calc(100% - 24px);
  overflow-y: auto;
  background: rgba(26,32,39,.97);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  z-index: 1000;
  box-shadow: 0 8px 32px rgba(0,0,0,.6);
}
.detail.hidden { display: none; }

.detail h2 {
  font-size: 15px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.detail .close { cursor: pointer; color: var(--muted); font-size: 18px; line-height: 1; }

.detail .row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 12px;
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.detail .row:last-child { border: none; }
.detail .k { color: var(--muted); }
.detail .v { font-family: ui-monospace, monospace; }

.detail .actions { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }

/* ---------- Leaflet 覆盖 ---------- */
.leaflet-container { background: #0d1117; }
.leaflet-popup-content-wrapper { background: var(--panel); color: var(--text); border-radius: 8px; }
.leaflet-popup-tip { background: var(--panel); }

/* ---------- 提示条 ---------- */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  transition: .3s;
  z-index: 2000;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 登录遮罩 ---------- */
.login-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(9, 12, 16, .92);
  display: flex; align-items: center; justify-content: center;
}
.login-overlay.hidden { display: none; }
.login-box {
  width: 360px; max-width: 90vw;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 28px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
.login-box h2 { font-size: 20px; margin-bottom: 6px; }
.login-sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.login-box input {
  width: 100%; padding: 10px 12px; margin-bottom: 12px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
  font-size: 13px; font-family: monospace;
}
.login-box input:focus { outline: none; border-color: var(--blue); }
.login-box .btn { width: 100%; }
.login-error { color: var(--red); font-size: 12px; margin: -4px 0 12px; }
.login-error.hidden { display: none; }
.login-hint { color: var(--muted); font-size: 11px; margin-top: 14px; text-align: center; }
