:root {
  --bg: #ffffff;
  --fg: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #0f766e;
  --danger: #dc2626;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  color: var(--fg);
  background: var(--bg);
}

#map {
  position: absolute;
  inset: 0;
}

/* ---------- 侧栏 ---------- */

#panel {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1000;
  width: 264px;
  max-height: calc(100% - 24px);
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .14);
  overflow: hidden;
  backdrop-filter: blur(6px);
}

#panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

#panel h1 {
  margin: 0;
  font-size: 17px;
  letter-spacing: .5px;
}

#panel button {
  font: inherit;
  font-size: 13px;
  color: var(--accent);
  background: #f0fdfa;
  border: 1px solid #ccfbf1;
  border-radius: 8px;
  padding: 5px 10px;
  cursor: pointer;
}

#panel button:active { transform: scale(.97); }

#list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  flex: 1;
}

#list .empty {
  padding: 14px 10px;
  color: var(--muted);
  font-size: 14px;
}

#list li.item {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
}

#list li.item:hover { background: #f8fafc; }
#list li.item.active { background: #ecfdf5; }

#list .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--c, var(--accent));
}

#list li.offline .dot { background: #9ca3af; }

#list .name {
  font-size: 15px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#list .sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

#list .right {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}

#list li.offline .name { color: var(--muted); }
#list li.stale .sub { color: var(--danger); }

#track-bar {
  border-top: 1px solid var(--line);
  padding: 10px 12px;
  font-size: 13px;
}

#track-label {
  display: block;
  color: var(--muted);
  margin-bottom: 6px;
}

.track-actions { display: flex; gap: 6px; }

#track-bar button.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

#panel footer {
  border-top: 1px solid var(--line);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- 地图标记 ---------- */

.pin { position: relative; }

.pin .dot {
  position: absolute;
  left: -8px;
  top: -8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--c, var(--accent));
  border: 3px solid #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .35);
}

.pin.offline .dot { background: #9ca3af; }

.pin .label {
  position: absolute;
  left: 0;
  top: 10px;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--line);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .12);
}

.pin.offline .label { color: var(--muted); }

/* ---------- 登录 ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(3px);
}

.overlay[hidden] { display: none; }

#login-form {
  width: min(320px, 86vw);
  padding: 24px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#login-form h2 {
  margin: 0 0 4px;
  font-size: 20px;
  text-align: center;
}

#login-form input {
  font: inherit;
  font-size: 16px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}

#login-form input:focus { border-color: var(--accent); }

#login-form button {
  font: inherit;
  font-size: 16px;
  padding: 11px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}

.error {
  margin: 0;
  min-height: 16px;
  font-size: 13px;
  color: var(--danger);
  text-align: center;
}

/* ---------- 手机 ---------- */

@media (max-width: 640px) {
  #panel {
    top: auto;
    bottom: 10px;
    left: 8px;
    right: 8px;
    width: auto;
    max-height: 46vh;
  }
  #panel header { padding: 10px 12px; }
  #list li.item { padding: 9px; }
}
